diff --git a/.clang-format b/.clang-format index 8824d6c7ae..0e01ab74f9 100644 --- a/.clang-format +++ b/.clang-format @@ -24,5 +24,7 @@ ObjCSpaceBeforeProtocolList: false PenaltyBreakBeforeFirstCallParameter: 1 PenaltyReturnTypeOnItsOwnLine: 300 PointerAlignment: Left +SpacesInContainerLiterals: false +SpacesInSquareBrackets: false TabWidth: 4 ... diff --git a/.jenkins/Dockerfile.deploy b/.jenkins/Dockerfile.deploy index a47074e55a..3d5038e510 100644 --- a/.jenkins/Dockerfile.deploy +++ b/.jenkins/Dockerfile.deploy @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. FROM ubuntu:18.04 @@ -20,7 +20,7 @@ RUN apt-get update && \ apt-key add microsoft.asc && \ apt-get update && \ apt-get -y install apt-transport-https azure-cli unzip && \ - curl https://oejenkins.blob.core.windows.net/oejenkins/oe-engine -o /usr/bin/oe-engine && \ + curl https://oejenkinsciartifacts.blob.core.windows.net/oe-engine/latest/bin/oe-engine -o /usr/bin/oe-engine && \ chmod +x /usr/bin/oe-engine && \ wget https://releases.hashicorp.com/packer/1.4.2/packer_1.4.2_linux_amd64.zip && \ unzip packer_1.4.2_linux_amd64.zip -d /usr/sbin && \ diff --git a/.jenkins/Dockerfile.full b/.jenkins/Dockerfile.full index 7f837a2f14..31d8e70366 100644 --- a/.jenkins/Dockerfile.full +++ b/.jenkins/Dockerfile.full @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # diff --git a/.jenkins/Dockerfile.minimal b/.jenkins/Dockerfile.minimal index ef12afefb0..1f23161f82 100644 --- a/.jenkins/Dockerfile.minimal +++ b/.jenkins/Dockerfile.minimal @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ARG ubuntu_version=18.04 diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile index b2d3c88658..4434d7c347 100644 --- a/.jenkins/Jenkinsfile +++ b/.jenkins/Jenkinsfile @@ -1,8 +1,12 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + @Library("OpenEnclaveCommon") _ oe = new jenkins.common.Openenclave() GLOBAL_TIMEOUT_MINUTES = 240 CTEST_TIMEOUT_SECONDS = 480 +GLOBAL_ERROR = null def ACCTest(String label, String compiler, String build_type) { stage("${label} ${compiler} SGX1FLC ${build_type}") { @@ -28,7 +32,7 @@ def ACCGNUTest() { cleanWs() checkout scm def task = """ - cmake ${WORKSPACE} -DUSE_LIBSGX=ON + cmake ${WORKSPACE} -DHAS_QUOTE_PROVIDER=ON make ctest --output-on-failure --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -39,9 +43,9 @@ def ACCGNUTest() { } def simulationTest(String version, String platform_mode, String build_type) { - def use_libsgx = "OFF" + def has_quote_provider = "OFF" if (platform_mode == "SGX1FLC") { - use_libsgx = "ON" + has_quote_provider = "ON" } stage("Sim clang-7 Ubuntu${version} ${platform_mode} ${build_type}") { node("nonSGX") { @@ -50,7 +54,7 @@ def simulationTest(String version, String platform_mode, String build_type) { checkout scm withEnv(["OE_SIMULATION=1"]) { def task = """ - cmake ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DUSE_LIBSGX=${use_libsgx} -Wdev + cmake ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DHAS_QUOTE_PROVIDER=${has_quote_provider} -Wdev ninja -v ctest --output-on-failure --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -73,7 +77,7 @@ def AArch64GNUTest(String version, String build_type) { -DCMAKE_BUILD_TYPE=${build_type} \ -DCMAKE_TOOLCHAIN_FILE=${WORKSPACE}/cmake/arm-cross.cmake \ -DOE_TA_DEV_KIT_DIR=/devkits/vexpress-qemu_armv8a/export-ta_arm64 \ - -DUSE_LIBSGX=OFF \ + -DHAS_QUOTE_PROVIDER=OFF \ -Wdev ninja -v """ @@ -139,10 +143,10 @@ def checkDevFlows(String version) { cleanWs() checkout scm def task = """ - cmake ${WORKSPACE} -G Ninja -DUSE_LIBSGX=OFF -Wdev --warn-uninitialized -Werror=dev + cmake ${WORKSPACE} -G Ninja -DHAS_QUOTE_PROVIDER=OFF -Wdev --warn-uninitialized -Werror=dev ninja -v """ - oe.ContainerRun("oetools-minimal-${version}", "clang-7", task, "--cap-add=SYS_PTRACE") + oe.ContainerRun("oetools-full-${version}", "clang-7", task, "--cap-add=SYS_PTRACE") } } } @@ -169,7 +173,7 @@ def win2016LinuxElfBuild(String version, String compiler, String build_type) { cleanWs() checkout scm def task = """ - cmake ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DUSE_LIBSGX=ON -Wdev + cmake ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DHAS_QUOTE_PROVIDER=ON -Wdev ninja -v """ oe.ContainerRun("oetools-full-${version}", compiler, task, "--cap-add=SYS_PTRACE") @@ -184,11 +188,10 @@ def win2016LinuxElfBuild(String version, String compiler, String build_type) { checkout scm unstash "linux-${compiler}-${build_type}-${version}-${BUILD_NUMBER}" bat 'move build linuxbin' - powershell 'Copy-Item -Recurse C:\\openenclave\\prereqs\\nuget ${env:WORKSPACE}\\prereqs' dir('build') { bat """ vcvars64.bat x64 && \ - cmake.exe ${WORKSPACE} -G Ninja -DADD_WINDOWS_ENCLAVE_TESTS=ON -DBUILD_ENCLAVES=OFF -DUSE_LIBSGX=ON -DCMAKE_BUILD_TYPE=${build_type} -DLINUX_BIN_DIR=${WORKSPACE}\\linuxbin\\tests -Wdev && \ + cmake.exe ${WORKSPACE} -G Ninja -DADD_WINDOWS_ENCLAVE_TESTS=ON -DBUILD_ENCLAVES=OFF -DHAS_QUOTE_PROVIDER=ON -DCMAKE_BUILD_TYPE=${build_type} -DLINUX_BIN_DIR=${WORKSPACE}\\linuxbin\\tests -DNUGET_PACKAGE_PATH=C:/oe_prereqs -Wdev && \ ninja -v && \ ctest.exe -V -C ${build_type} --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -198,12 +201,12 @@ def win2016LinuxElfBuild(String version, String compiler, String build_type) { } } -def win2016CrossCompile(String build_type, String use_libsgx = 'OFF') { +def win2016CrossCompile(String build_type, String has_quote_provider = 'OFF') { def node_label = 'SGXFLC-Windows' - if (use_libsgx == "ON") { + if (has_quote_provider == "ON") { node_label = 'SGXFLC-Windows-DCAP' } - stage("Windows ${build_type} with SGX ${use_libsgx}") { + stage("Windows ${build_type} with SGX ${has_quote_provider}") { node(node_label) { timeout(GLOBAL_TIMEOUT_MINUTES) { cleanWs() @@ -211,12 +214,11 @@ def win2016CrossCompile(String build_type, String use_libsgx = 'OFF') { dir("build/X64-${build_type}") { /* We need to copy nuget into the expected location - https://github.com/microsoft/openenclave/blob/a982b46cf440def8fb66e94f2622a4f81e2b350b/host/CMakeLists.txt#L188-L197 */ - powershell 'Copy-Item -Recurse C:\\openenclave\\prereqs\\nuget ${env:WORKSPACE}\\prereqs' + https://github.com/openenclave/openenclave/blob/a982b46cf440def8fb66e94f2622a4f81e2b350b/host/CMakeLists.txt#L188-L197 */ bat """ vcvars64.bat x64 && \ - cmake.exe ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_ENCLAVES=ON -DUSE_LIBSGX=${use_libsgx} -Wdev && \ + cmake.exe ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_ENCLAVES=ON -DHAS_QUOTE_PROVIDER=${has_quote_provider} -DNUGET_PACKAGE_PATH=C:/oe_prereqs -Wdev && \ ninja.exe && \ ctest.exe -V -C ${build_type} --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -239,7 +241,7 @@ def ACCHostVerificationTest(String version, String build_type) { println("Generating certificates and reports ...") def task = """ - cmake ${WORKSPACE} -G Ninja -DUSE_LIBSGX=ON -DCMAKE_BUILD_TYPE=${build_type} -Wdev + cmake ${WORKSPACE} -G Ninja -DHAS_QUOTE_PROVIDER=ON -DCMAKE_BUILD_TYPE=${build_type} -Wdev ninja -v pushd tests/host_verify/host openssl ecparam -name prime256v1 -genkey -noout -out keyec.pem @@ -251,7 +253,7 @@ def ACCHostVerificationTest(String version, String build_type) { ../../tools/oecert/host/oecert ../../tools/oecert/enc/oecert_enc --report --out sgx_report.bin popd """ - oe.Run("clang-7", task) + oe.ContainerRun("oetools-full-${version}", "clang-7", task, "--cap-add=SYS_PTRACE --device /dev/sgx:/dev/sgx") def ec_cert_created = fileExists 'build/tests/host_verify/host/sgx_cert_ec.der' def rsa_cert_created = fileExists 'build/tests/host_verify/host/sgx_cert_rsa.der' @@ -277,7 +279,7 @@ def ACCHostVerificationTest(String version, String build_type) { } } - /* Compile the tests with USE_LIBSGX=OFF and unstash the certs over for verification. */ + /* Compile the tests with HAS_QUOTE_PROVIDER=OFF and unstash the certs over for verification. */ stage("Linux nonSGX Verify Quote") { node("nonSGX") { timeout(GLOBAL_TIMEOUT_MINUTES) { @@ -285,7 +287,7 @@ def ACCHostVerificationTest(String version, String build_type) { checkout scm unstash "linux_host_verify-${build_type}-${BUILD_NUMBER}" def task = """ - cmake ${WORKSPACE} -G Ninja -DBUILD_ENCLAVES=OFF -DUSE_LIBSGX=OFF -DCMAKE_BUILD_TYPE=${build_type} -Wdev + cmake ${WORKSPACE} -G Ninja -DBUILD_ENCLAVES=OFF -DHAS_QUOTE_PROVIDER=OFF -DCMAKE_BUILD_TYPE=${build_type} -Wdev ninja -v ctest -R host_verify --output-on-failure --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -302,11 +304,10 @@ def ACCHostVerificationTest(String version, String build_type) { cleanWs() checkout scm unstash "linux_host_verify-${build_type}-${BUILD_NUMBER}" - powershell 'Copy-Item -Recurse C:\\openenclave\\prereqs\\nuget ${env:WORKSPACE}\\prereqs' dir('build') { bat """ vcvars64.bat x64 && \ - cmake.exe ${WORKSPACE} -G Ninja -DBUILD_ENCLAVES=OFF -DUSE_LIBSGX=OFF -DCMAKE_BUILD_TYPE=${build_type} -Wdev && \ + cmake.exe ${WORKSPACE} -G Ninja -DBUILD_ENCLAVES=OFF -DHAS_QUOTE_PROVIDER=OFF -DCMAKE_BUILD_TYPE=${build_type} -DNUGET_PACKAGE_PATH=C:/oe_prereqs -Wdev && \ ninja -v && \ ctest.exe -V -C ${build_type} -R host_verify --output-on-failure --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -322,38 +323,50 @@ properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '90', numToKeepStr: '180')), [$class: 'JobRestrictionProperty']]) -parallel "Check Developer Experience Ubuntu 16.04" : { checkDevFlows('16.04') }, - "Check Developer Experience Ubuntu 18.04" : { checkDevFlows('18.04') }, - "Check CI" : { checkCI() }, - "ACC1604 clang-7 Debug" : { ACCTest('ACC-1604', 'clang-7', 'Debug') }, - "ACC1604 clang-7 Release" : { ACCTest('ACC-1604', 'clang-7', 'Release') }, - "ACC1604 gcc Debug" : { ACCTest('ACC-1604', 'gcc', 'Debug') }, - "ACC1604 gcc Release" : { ACCTest('ACC-1604', 'gcc', 'Release') }, - "ACC1604 Container RelWithDebInfo" : { ACCContainerTest('ACC-1604', '16.04') }, - "ACC1604 Package RelWithDebInfo" : { ACCPackageTest('ACC-1604', '16.04') }, - "ACC1804 clang-7 Debug" : { ACCTest('ACC-1804', 'clang-7', 'Debug') }, - "ACC1804 clang-7 Release" : { ACCTest('ACC-1804', 'clang-7', 'Release') }, - "ACC1804 gcc Debug" : { ACCTest('ACC-1804', 'gcc', 'Debug') }, - "ACC1804 gcc Release" : { ACCTest('ACC-1804', 'gcc', 'Release') }, - "ACC1804 Container RelWithDebInfo" : { ACCContainerTest('ACC-1804', '18.04') }, - "ACC1804 Package RelWithDebInfo" : { ACCPackageTest('ACC-1804', '18.04') }, - "ACC1804 GNU gcc SGX1FLC" : { ACCGNUTest() }, - "AArch64 1604 GNU gcc Debug" : { AArch64GNUTest('16.04', 'Debug')}, - "AArch64 1604 GNU gcc Release" : { AArch64GNUTest('16.04', 'Release')}, - "AArch64 1804 GNU gcc Debug" : { AArch64GNUTest('18.04', 'Debug')}, - "AArch64 1804 GNU gcc Release" : { AArch64GNUTest('18.04', 'Release')}, - "Sim 1804 clang-7 SGX1 Debug" : { simulationTest('18.04', 'SGX1', 'Debug')}, - "Sim 1804 clang-7 SGX1 Release" : { simulationTest('18.04', 'SGX1', 'Release')}, - "Sim 1804 clang-7 SGX1-FLC Debug" : { simulationTest('18.04', 'SGX1FLC', 'Debug')}, - "Sim 1804 clang-7 SGX1-FLC Release" : { simulationTest('18.04', 'SGX1FLC', 'Release')}, - "Win2016 Ubuntu1604 clang-7 Debug Linux-Elf-build" : { win2016LinuxElfBuild('16.04', 'clang-7', 'Debug') }, - "Win2016 Ubuntu1604 clang-7 Release Linux-Elf-build" : { win2016LinuxElfBuild('16.04', 'clang-7', 'Release') }, - "Win2016 Ubuntu1804 clang-7 Debug Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'clang-7', 'Debug') }, - "Win2016 Ubuntu1804 clang-7 Release Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'clang-7', 'Release') }, - "Win2016 Ubuntu1804 gcc Debug Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'gcc', 'Debug') }, - "Win2016 Debug Cross Compile" : { win2016CrossCompile('Debug') }, - "Win2016 Release Cross Compile" : { win2016CrossCompile('Release') }, - "Win2016 Debug Cross Compile with DCAP libs" : { win2016CrossCompile('Debug', 'ON') }, - "Win2016 Release Cross Compile with DCAP libs" : { win2016CrossCompile('Release', 'ON') }, - "Host verification Debug" : { ACCHostVerificationTest('18.04', 'Debug') }, - "Host verification Release" : { ACCHostVerificationTest('18.04', 'Release') } +try{ + oe.emailJobStatus('STARTED') + parallel "Check Developer Experience Ubuntu 16.04" : { checkDevFlows('16.04') }, + "Check Developer Experience Ubuntu 18.04" : { checkDevFlows('18.04') }, + "Check CI" : { checkCI() }, + "ACC1604 clang-7 Debug" : { ACCTest('ACC-1604', 'clang-7', 'Debug') }, + "ACC1604 clang-7 Release" : { ACCTest('ACC-1604', 'clang-7', 'Release') }, + "ACC1604 gcc Debug" : { ACCTest('ACC-1604', 'gcc', 'Debug') }, + "ACC1604 gcc Release" : { ACCTest('ACC-1604', 'gcc', 'Release') }, + "ACC1604 Container RelWithDebInfo" : { ACCContainerTest('ACC-1604', '16.04') }, + "ACC1604 Package RelWithDebInfo" : { ACCPackageTest('ACC-1604', '16.04') }, + "ACC1804 clang-7 Debug" : { ACCTest('ACC-1804', 'clang-7', 'Debug') }, + "ACC1804 clang-7 Release" : { ACCTest('ACC-1804', 'clang-7', 'Release') }, + "ACC1804 gcc Debug" : { ACCTest('ACC-1804', 'gcc', 'Debug') }, + "ACC1804 gcc Release" : { ACCTest('ACC-1804', 'gcc', 'Release') }, + "ACC1804 Container RelWithDebInfo" : { ACCContainerTest('ACC-1804', '18.04') }, + "ACC1804 Package RelWithDebInfo" : { ACCPackageTest('ACC-1804', '18.04') }, + "ACC1804 GNU gcc SGX1FLC" : { ACCGNUTest() }, + "AArch64 1604 GNU gcc Debug" : { AArch64GNUTest('16.04', 'Debug')}, + "AArch64 1604 GNU gcc Release" : { AArch64GNUTest('16.04', 'Release')}, + "AArch64 1804 GNU gcc Debug" : { AArch64GNUTest('18.04', 'Debug')}, + "AArch64 1804 GNU gcc Release" : { AArch64GNUTest('18.04', 'Release')}, + "Sim 1804 clang-7 SGX1 Debug" : { simulationTest('18.04', 'SGX1', 'Debug')}, + "Sim 1804 clang-7 SGX1 Release" : { simulationTest('18.04', 'SGX1', 'Release')}, + "Sim 1804 clang-7 SGX1-FLC Debug" : { simulationTest('18.04', 'SGX1FLC', 'Debug')}, + "Sim 1804 clang-7 SGX1-FLC Release" : { simulationTest('18.04', 'SGX1FLC', 'Release')}, + "Win2016 Ubuntu1604 clang-7 Debug Linux-Elf-build" : { win2016LinuxElfBuild('16.04', 'clang-7', 'Debug') }, + "Win2016 Ubuntu1604 clang-7 Release Linux-Elf-build" : { win2016LinuxElfBuild('16.04', 'clang-7', 'Release') }, + "Win2016 Ubuntu1804 clang-7 Debug Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'clang-7', 'Debug') }, + "Win2016 Ubuntu1804 clang-7 Release Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'clang-7', 'Release') }, + "Win2016 Ubuntu1804 gcc Debug Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'gcc', 'Debug') }, + "Win2016 Debug Cross Compile" : { win2016CrossCompile('Debug') }, + "Win2016 Release Cross Compile" : { win2016CrossCompile('Release') }, + "Win2016 Debug Cross Compile with DCAP libs" : { win2016CrossCompile('Debug', 'ON') }, + "Win2016 Release Cross Compile with DCAP libs" : { win2016CrossCompile('Release', 'ON') }, + "Host verification 1604 Debug" : { ACCHostVerificationTest('16.04', 'Debug') }, + "Host verification 1604 Release" : { ACCHostVerificationTest('16.04', 'Release') }, + "Host verification 1804 Debug" : { ACCHostVerificationTest('18.04', 'Debug') }, + "Host verification 1804 Release" : { ACCHostVerificationTest('18.04', 'Release') } +} catch(Exception e) { + println "Caught global pipeline exception :" + e + GLOBAL_ERROR = e + throw e +} finally { + currentBuild.result = (GLOBAL_ERROR != null) ? 'FAILURE' : "SUCCESS" + oe.emailJobStatus(currentBuild.result) +} diff --git a/.jenkins/Packaging.Jenkinsfile b/.jenkins/Packaging.Jenkinsfile index 0ab68f8e77..6dd883f3d1 100644 --- a/.jenkins/Packaging.Jenkinsfile +++ b/.jenkins/Packaging.Jenkinsfile @@ -1,10 +1,14 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + @Library("OpenEnclaveCommon") _ oe = new jenkins.common.Openenclave() GLOBAL_TIMEOUT_MINUTES = 240 CTEST_TIMEOUT_SECONDS = 480 +GLOBAL_ERROR = null -def packageUpload(String version, String build_type) { +def LinuxPackaging(String version, String build_type) { stage("Ubuntu${version} SGX1FLC Package ${build_type}") { node("ACC-${version}") { timeout(GLOBAL_TIMEOUT_MINUTES) { @@ -14,7 +18,8 @@ def packageUpload(String version, String build_type) { cmake ${WORKSPACE} -DCMAKE_BUILD_TYPE=${build_type} -DCMAKE_INSTALL_PREFIX:PATH='/opt/openenclave' -DCPACK_GENERATOR=DEB make ctest --output-on-failure --timeout ${CTEST_TIMEOUT_SECONDS} - make package + cpack + cpack -D CPACK_DEB_COMPONENT_INSTALL=ON -DCPACK_COMPONENTS_ALL=OEHOSTVERIFY """ oe.Run("clang-7", task) azureUpload(storageCredentialId: 'oe_jenkins_storage_account', filesPath: 'build/*.deb', storageType: 'blobstorage', virtualPath: "master/${BUILD_NUMBER}/ubuntu/${version}/${build_type}/SGX1FLC/", containerName: 'oejenkins') @@ -24,28 +29,44 @@ def packageUpload(String version, String build_type) { } } -def WindowsUpload() { - stage('Windows Release') { - node('SGXFLC-Windows') { +def WindowsPackaging(String build_type) { + stage('Windows SGX1FLC ${build_type}') { + node('SGXFLC-Windows-DCAP') { timeout(GLOBAL_TIMEOUT_MINUTES) { cleanWs() checkout scm dir('build') { - bat """vcvars64.bat x64 && \ - cmake.exe ${WORKSPACE} -G \"Visual Studio 15 2017 Win64\" && \ - msbuild tools\\oeedger8r\\oeedger8r_target.vcxproj -p:Configuration=Release""" + bat """ + vcvars64.bat x64 && \ + cmake.exe ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_ENCLAVES=ON -DHAS_QUOTE_PROVIDER=ON -DNUGET_PACKAGE_PATH=C:/oe_prereqs -DCPACK_GENERATOR=NuGet -Wdev && \ + ninja.exe && \ + ctest.exe -V -C RELEASE --timeout ${CTEST_TIMEOUT_SECONDS} && \ + cpack && \ + cpack -D CPACK_NUGET_COMPONENT_INSTALL=ON -DCPACK_COMPONENTS_ALL=OEHOSTVERIFY + """ } - azureUpload(storageCredentialId: 'oe_jenkins_storage_account', filesPath: 'build/tools/oeedger8r/oeedger8r.exe', storageType: 'blobstorage', virtualPath: "master/${BUILD_NUMBER}/windows/", containerName: 'oejenkins') - azureUpload(storageCredentialId: 'oe_jenkins_storage_account', filesPath: 'build/tools/oeedger8r/oeedger8r.exe', storageType: 'blobstorage', virtualPath: "master/latest/windows/", containerName: 'oejenkins') + azureUpload(storageCredentialId: 'oe_jenkins_storage_account', filesPath: 'build/*.nupkg', storageType: 'blobstorage', virtualPath: "master/${BUILD_NUMBER}/windows/${build_type}/SGX1FLC/", containerName: 'oejenkins') + azureUpload(storageCredentialId: 'oe_jenkins_storage_account', filesPath: 'build/*.nupkg', storageType: 'blobstorage', virtualPath: "master/latest/windows/${build_type}/SGX1FLC/", containerName: 'oejenkins') } } } } -parallel "1604 SGX1FLC Package Debug" : { packageUpload('1604', 'Debug') }, - "1604 SGX1FLC Package Release" : { packageUpload('1604', 'Release') }, - "1604 SGX1FLC Package RelWithDebInfo" : { packageUpload('1604', 'RelWithDebInfo') }, - "1804 SGX1FLC Package Debug" : { packageUpload('1804', 'Debug') }, - "1804 SGX1FLC Package Release" : { packageUpload('1804', 'Release') }, - "1804 SGX1FLC Package RelWithDebInfo" : { packageUpload('1804', 'RelWithDebInfo') }, - "Windows Release" : { WindowsUpload() } +try{ + oe.emailJobStatus('STARTED') + parallel "1604 SGX1FLC Package Debug" : { LinuxPackaging('1604', 'Debug') }, + "1604 SGX1FLC Package Release" : { LinuxPackaging('1604', 'Release') }, + "1604 SGX1FLC Package RelWithDebInfo" : { LinuxPackaging('1604', 'RelWithDebInfo') }, + "1804 SGX1FLC Package Debug" : { LinuxPackaging('1804', 'Debug') }, + "1804 SGX1FLC Package Release" : { LinuxPackaging('1804', 'Release') }, + "1804 SGX1FLC Package RelWithDebInfo" : { LinuxPackaging('1804', 'RelWithDebInfo') }, + "Windows Debug" : { WindowsPackaging('DEBUG') }, + "Windows Release" : { WindowsPackaging('RELEASE') } +} catch(Exception e) { + println "Caught global pipeline exception :" + e + GLOBAL_ERROR = e + throw e +} finally { + currentBuild.result = (GLOBAL_ERROR != null) ? 'FAILURE' : "SUCCESS" + oe.emailJobStatus(currentBuild.result) +} diff --git a/.jenkins/build_vhd.Jenkinsfile b/.jenkins/build_vhd.Jenkinsfile index 05d4e44c42..9ff6938b7a 100644 --- a/.jenkins/build_vhd.Jenkinsfile +++ b/.jenkins/build_vhd.Jenkinsfile @@ -5,35 +5,37 @@ GLOBAL_TIMEOUT_MINUTES = 240 def buildVHD(String os_type, String version, String imageName) { node("nonSGX") { - timeout(GLOBAL_TIMEOUT_MINUTES) { - cleanWs() - checkout scm + stage("${os_type}-${version}") { + timeout(GLOBAL_TIMEOUT_MINUTES) { + cleanWs() + checkout scm - withCredentials([azureStorage(credentialsId: 'oe_jenkins_storage_account', - storageAccountKeyVariable: 'EASTUS_STORAGE_ACCOUNT_KEY', - storageAccountNameVariable: 'EASTUS_STORAGE_ACCOUNT_NAME'), - azureStorage(credentialsId: 'oe_jenkins_storage_account_westeurope', - storageAccountKeyVariable: 'WESTEUROPE_STORAGE_ACCOUNT_KEY', - storageAccountNameVariable: 'WESTEUROPE_STORAGE_ACCOUNT_NAME')]) { - withEnv(["REGION=eastus", "DEST_VHD_NAME=${VHD_NAME_PREFIX}-${os_type}-${version}.vhd", "CONTAINER_NAME=disks"]) { - dir("${WORKSPACE}/.jenkins/provision") { - oe.azureEnvironment(""" - packer build -var-file=templates/packer/${os_type}-${version}-variables.json templates/packer/packer-${os_type}.json 2>&1 | tee packer.log - export SOURCE_URI=\$(cat packer.log | grep OSDiskUri: | awk '{print \$2}') - az storage blob copy start --source-uri \$SOURCE_URI --destination-blob \$DEST_VHD_NAME --destination-container \$CONTAINER_NAME --account-key \$EASTUS_STORAGE_ACCOUNT_KEY --account-name \$EASTUS_STORAGE_ACCOUNT_NAME - az storage blob copy start --source-uri \$SOURCE_URI --destination-blob \$DEST_VHD_NAME --destination-container \$CONTAINER_NAME --account-key \$WESTEUROPE_STORAGE_ACCOUNT_KEY --account-name \$WESTEUROPE_STORAGE_ACCOUNT_NAME - blob_status=\$(az storage blob show --name \$DEST_VHD_NAME --container-name \$CONTAINER_NAME \ - --account-key \$WESTEUROPE_STORAGE_ACCOUNT_KEY --account-name \$WESTEUROPE_STORAGE_ACCOUNT_NAME \ - --output json | jq -r .properties.copy.status) - while [ "\${blob_status}" != "success" ] - do - echo Waiting for \$DEST_VHD_NAME to finish copying ... - sleep 10 - blob_status=\$(az storage blob show --name \$DEST_VHD_NAME --container-name \$CONTAINER_NAME \ - --account-key \$WESTEUROPE_STORAGE_ACCOUNT_KEY --account-name \$WESTEUROPE_STORAGE_ACCOUNT_NAME \ - --output json | jq -r .properties.copy.status) - done - """, imageName) + withCredentials([azureStorage(credentialsId: 'oe_jenkins_storage_account', + storageAccountKeyVariable: 'EASTUS_STORAGE_ACCOUNT_KEY', + storageAccountNameVariable: 'EASTUS_STORAGE_ACCOUNT_NAME'), + azureStorage(credentialsId: 'oe_jenkins_storage_account_westeurope', + storageAccountKeyVariable: 'WESTEUROPE_STORAGE_ACCOUNT_KEY', + storageAccountNameVariable: 'WESTEUROPE_STORAGE_ACCOUNT_NAME')]) { + withEnv(["REGION=eastus", "DEST_VHD_NAME=${VHD_NAME_PREFIX}-${os_type}-${version}.vhd", "CONTAINER_NAME=disks"]) { + dir("${WORKSPACE}/.jenkins/provision") { + oe.azureEnvironment(""" + packer build -var-file=templates/packer/${os_type}-${version}-variables.json templates/packer/packer-${os_type}.json 2>&1 | tee packer.log + export SOURCE_URI=\$(cat packer.log | grep OSDiskUri: | awk '{print \$2}') + az storage blob copy start --source-uri \$SOURCE_URI --destination-blob \$DEST_VHD_NAME --destination-container \$CONTAINER_NAME --account-key \$EASTUS_STORAGE_ACCOUNT_KEY --account-name \$EASTUS_STORAGE_ACCOUNT_NAME + az storage blob copy start --source-uri \$SOURCE_URI --destination-blob \$DEST_VHD_NAME --destination-container \$CONTAINER_NAME --account-key \$WESTEUROPE_STORAGE_ACCOUNT_KEY --account-name \$WESTEUROPE_STORAGE_ACCOUNT_NAME + blob_status=\$(az storage blob show --name \$DEST_VHD_NAME --container-name \$CONTAINER_NAME \ + --account-key \$WESTEUROPE_STORAGE_ACCOUNT_KEY --account-name \$WESTEUROPE_STORAGE_ACCOUNT_NAME \ + --output json | jq -r .properties.copy.status) + while [ "\${blob_status}" != "success" ] + do + echo Waiting for \$DEST_VHD_NAME to finish copying ... + sleep 10 + blob_status=\$(az storage blob show --name \$DEST_VHD_NAME --container-name \$CONTAINER_NAME \ + --account-key \$WESTEUROPE_STORAGE_ACCOUNT_KEY --account-name \$WESTEUROPE_STORAGE_ACCOUNT_NAME \ + --output json | jq -r .properties.copy.status) + done + """, imageName) + } } } } @@ -42,4 +44,6 @@ def buildVHD(String os_type, String version, String imageName) { } parallel "Build Ubuntu 16.04" : { buildVHD("ubuntu", "16.04", OE_DEPLOY_IMAGE) }, - "Build Ubuntu 18.04" : { buildVHD("ubuntu", "18.04", OE_DEPLOY_IMAGE) } + "Build Ubuntu 18.04" : { buildVHD("ubuntu", "18.04", OE_DEPLOY_IMAGE) }, + "Build Windows 2016" : { buildVHD("win", "2016", OE_DEPLOY_IMAGE) }, + "Build Windows 2016 DCAP" : { buildVHD("win", "dcap", OE_DEPLOY_IMAGE) } diff --git a/.jenkins/custom_label.Jenkinsfile b/.jenkins/custom_label.Jenkinsfile index 3bac3ca3f4..bcc2a283a7 100644 --- a/.jenkins/custom_label.Jenkinsfile +++ b/.jenkins/custom_label.Jenkinsfile @@ -32,27 +32,30 @@ def ACCContainerTest(String label, String version) { ninja -v ctest --output-on-failure --timeout ${CTEST_TIMEOUT_SECONDS} """ - oe.ContainerRun("oetools-full-${version}", "clang-7", task, "--cap-add=SYS_PTRACE --device /dev/sgx:/dev/sgx") + oe.ContainerRun("oetools-full-${version}:${DOCKER_TAG}", "clang-7", task, "--cap-add=SYS_PTRACE --device /dev/sgx:/dev/sgx") } } } } -def win2016CrossCompile(String build_type, String use_libsgx = 'OFF') { - stage("Windows ${build_type} with SGX ${use_libsgx}") { - node(WINDOWS_2016_CUSTOM_LABEL) { +def win2016CrossCompile(String build_type, String has_quote_provider = 'OFF') { + def node_label = WINDOWS_2016_CUSTOM_LABEL + if (has_quote_provider == "ON") { + node_label = WINDOWS_DCAP_CUSTOM_LABEL + } + stage("Windows ${build_type} with SGX ${has_quote_provider}") { + node(node_label) { timeout(GLOBAL_TIMEOUT_MINUTES) { cleanWs() checkout scm dir("build/X64-${build_type}") { /* We need to copy nuget into the expected location - https://github.com/microsoft/openenclave/blob/a982b46cf440def8fb66e94f2622a4f81e2b350b/host/CMakeLists.txt#L188-L197 */ - powershell 'Copy-Item -Recurse C:\\openenclave\\prereqs\\nuget ${env:WORKSPACE}\\prereqs' + https://github.com/openenclave/openenclave/blob/a982b46cf440def8fb66e94f2622a4f81e2b350b/host/CMakeLists.txt#L188-L197 */ bat """ vcvars64.bat x64 && \ - cmake.exe ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_ENCLAVES=ON -DUSE_LIBSGX=${use_libsgx} -Wdev && \ + cmake.exe ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_ENCLAVES=ON -DHAS_QUOTE_PROVIDER=${has_quote_provider} -DNUGET_PACKAGE_PATH=C:/oe_prereqs -Wdev && \ ninja.exe && \ ctest.exe -V -C ${build_type} --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -62,6 +65,44 @@ def win2016CrossCompile(String build_type, String use_libsgx = 'OFF') { } } +def win2016LinuxElfBuild(String version, String compiler, String build_type) { + def ubuntu_label = UBUNTU_1604_CUSTOM_LABEL + if ( version == "18.04" ) { + ubuntu_label = UBUNTU_1804_CUSTOM_LABEL + } + stage("Ubuntu ${version} SGX1 ${compiler} ${build_type}}") { + node(ubuntu_label) { + timeout(GLOBAL_TIMEOUT_MINUTES) { + cleanWs() + checkout scm + def task = """ + cmake ${WORKSPACE} -G Ninja -DCMAKE_BUILD_TYPE=${build_type} -DHAS_QUOTE_PROVIDER=ON -Wdev + ninja -v + """ + oe.ContainerRun("oetools-full-${version}:${DOCKER_TAG}", compiler, task, "--cap-add=SYS_PTRACE") + stash includes: 'build/tests/**', name: "linux-${compiler}-${build_type}-${version}-${BUILD_NUMBER}" + } + } + } + stage("Windows ${build_type}") { + node(WINDOWS_DCAP_CUSTOM_LABEL) { + timeout(GLOBAL_TIMEOUT_MINUTES) { + cleanWs() + checkout scm + unstash "linux-${compiler}-${build_type}-${version}-${BUILD_NUMBER}" + bat 'move build linuxbin' + dir('build') { + bat """ + vcvars64.bat x64 && \ + cmake.exe ${WORKSPACE} -G Ninja -DADD_WINDOWS_ENCLAVE_TESTS=ON -DBUILD_ENCLAVES=OFF -DHAS_QUOTE_PROVIDER=ON -DCMAKE_BUILD_TYPE=${build_type} -DLINUX_BIN_DIR=${WORKSPACE}\\linuxbin\\tests -DNUGET_PACKAGE_PATH=C:/oe_prereqs -Wdev && \ + ninja -v && \ + ctest.exe -V -C ${build_type} --timeout ${CTEST_TIMEOUT_SECONDS} + """ + } + } + } + } +} properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '90', artifactNumToKeepStr: '180', @@ -69,7 +110,12 @@ properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '90', numToKeepStr: '180')), [$class: 'JobRestrictionProperty']]) -parallel "ACC1604 clang-7 RelWithDebInfo" : { ACCTest(UBUNTU_1604_CUSTOM_LABEL, 'clang-7', 'RelWithDebInfo') }, +parallel "Win2016 Release Cross Compile with DCAP libs" : { win2016CrossCompile('Release', 'ON') }, + "Win2016 Debug Cross Compile" : { win2016CrossCompile('Debug') }, + "Win2016 Ubuntu1604 clang-7 Debug Linux-Elf-build" : { win2016LinuxElfBuild('16.04', 'clang-7', 'Debug') }, + "Win2016 Ubuntu1804 clang-7 Release Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'clang-7', 'Release') }, + "Win2016 Ubuntu1804 gcc Debug Linux-Elf-build" : { win2016LinuxElfBuild('18.04', 'gcc', 'Debug') }, + "ACC1604 clang-7 RelWithDebInfo" : { ACCTest(UBUNTU_1604_CUSTOM_LABEL, 'clang-7', 'RelWithDebInfo') }, "ACC1604 gcc RelWithDebInfo" : { ACCTest(UBUNTU_1604_CUSTOM_LABEL, 'gcc', 'RelWithDebInfo') }, "ACC1604 Container RelWithDebInfo" : { ACCContainerTest(UBUNTU_1604_CUSTOM_LABEL, '16.04') }, "ACC1804 clang-7 RelWithDebInfo" : { ACCTest(UBUNTU_1804_CUSTOM_LABEL, 'clang-7', 'RelWithDebInfo') }, diff --git a/.jenkins/deploy_agent.Jenkinsfile b/.jenkins/deploy_agent.Jenkinsfile index c9a9c8e91c..ecda5dc81f 100644 --- a/.jenkins/deploy_agent.Jenkinsfile +++ b/.jenkins/deploy_agent.Jenkinsfile @@ -55,6 +55,9 @@ def generateVariablesFile() { echo ansible_ssh_private_key_file: inventory/id-rsa-oe-test } > ${var_file} """ } + if (DCAP_TESTING_NODE == "true") { + sh "echo dcap_testing_node: true >> ${var_file}" + } } def registerJenkinsSlave() { diff --git a/.jenkins/libcxx_tests.Jenkinsfile b/.jenkins/libcxx_tests.Jenkinsfile index 75823cdef9..892968579a 100644 --- a/.jenkins/libcxx_tests.Jenkinsfile +++ b/.jenkins/libcxx_tests.Jenkinsfile @@ -1,3 +1,6 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + import hudson.slaves.* import hudson.model.* @@ -6,6 +9,7 @@ oe = new jenkins.common.Openenclave() GLOBAL_TIMEOUT_MINUTES = 240 CTEST_TIMEOUT_SECONDS = 480 +GLOBAL_ERROR = null XENIAL_LABEL = "LIBCXX-${BUILD_NUMBER}-1604" BIONIC_LABEL = "LIBCXX-${BUILD_NUMBER}-1804" @@ -87,7 +91,7 @@ def ACClibcxxTest(String label, String compiler, String build_type) { cleanWs() checkout scm def task = """ - cmake .. -DCMAKE_BUILD_TYPE=${build_type} -DUSE_LIBSGX=ON -DENABLE_FULL_LIBCXX_TESTS=ON + cmake .. -DCMAKE_BUILD_TYPE=${build_type} -DHAS_QUOTE_PROVIDER=ON -DENABLE_FULL_LIBCXX_TESTS=ON make ctest -VV -debug --timeout ${CTEST_TIMEOUT_SECONDS} """ @@ -108,6 +112,7 @@ def cleanup(){ } try { + oe.emailJobStatus('STARTED') for (int i = 1 ; i <= AGENT_NUM ; i++ ) { parallel "Deploy Ubuntu 16.04 #${i}" : { ACCDeployVM("${XENIAL_LABEL}-${i}".toLowerCase(), "xenial" , "eastus", XENIAL_RG, "${VHD_URL_XENIAL}") }, "Deploy Ubuntu 18.04 #${i}" : { ACCDeployVM("${BIONIC_LABEL}-${i}".toLowerCase(), "bionic", "westeurope", BIONIC_RG, "${VHD_URL_BIONIC}") } @@ -127,7 +132,13 @@ try { "libcxx ACC1804 gcc Debug" : { ACClibcxxTest(BIONIC_LABEL, 'gcc', 'Debug') }, "libcxx ACC1804 gcc Release" : { ACClibcxxTest(BIONIC_LABEL, 'gcc', 'Release') }, "libcxx ACC1804 gcc RelWithDebInfo" : { ACClibcxxTest(BIONIC_LABEL, 'gcc', 'RelWithDebinfo') } +} catch(Exception e) { + println "Caught global pipeline exception :" + e + GLOBAL_ERROR = e + throw e } finally { cleanup() unregisterJenkinsSlaves() + currentBuild.result = (GLOBAL_ERROR != null) ? 'FAILURE' : "SUCCESS" + oe.emailJobStatus(currentBuild.result) } diff --git a/.jenkins/master.Jenkinsfile b/.jenkins/master.Jenkinsfile new file mode 100644 index 0000000000..31f7785b3e --- /dev/null +++ b/.jenkins/master.Jenkinsfile @@ -0,0 +1,140 @@ +import hudson.slaves.* +import hudson.model.* + +// Get current node label index from CI +def getStartingIndex(String label, String prefix) { + def startNum = [] + nodesByLabel(label).each { + startNum.add(it.replace(prefix,"").toInteger()) + } + return startNum.max() + 1 +} + +// Generate a list of Agent Names for each Agent Label +def generateAgentNames(String label, String prefix, Integer count) { + def first = getStartingIndex(label, prefix) + def nodeNames = [] + for (int i=0; i + nodesByLabel(label).each { + agentList.add(it) + } + } + return agentList +} + +// Save a list of current Jenkins node names, to be turned offline +CURRENT_JENKINS_NODES = currentAgentList() + +def cleanup(List currentNodes) { + for (aSlave in hudson.model.Hudson.instance.slaves) { + if (currentNodes.contains(aSlave.name)) { + println("Set ${aSlave.name} temporarily offline!"); + aSlave.getComputer().setTemporarilyOffline(true,null); + } + } +} + +// Generate Agent properties map +def xenial = [ + "agentType": "xenial", + "agentName": generateAgentNames("ACC-1604", "ACC-1604-", 3), + "agentLabel": "ACC-1604", + "agentRegion": "eastus", + "agentVhdUrl": "https://oejenkins.blob.core.windows.net/disks/${env.VHD_NAME_PREFIX}-ubuntu-16.04.vhd" +] + +def bionic = [ + "agentType": "bionic", + "agentName": generateAgentNames("ACC-1804", "ACC-1804-", 3), + "agentLabel": "ACC-1804", + "agentRegion": "westeurope", + "agentVhdUrl": "https://oejenkinswesteurope.blob.core.windows.net/disks/${env.VHD_NAME_PREFIX}-ubuntu-18.04.vhd" +] + +def win2016 = [ + "agentType": "windows", + "agentName": generateAgentNames("SGXFLC-Windows", "ACC-Win-SGX-", 2), + "agentLabel": "SGXFLC-Windows", + "agentRegion": "westeurope", + "agentVhdUrl": "https://oejenkinswesteurope.blob.core.windows.net/disks/${env.VHD_NAME_PREFIX}-win-2016.vhd" +] + +def win2016dcap = [ + "agentType": "windows", + "agentName": generateAgentNames("SGXFLC-Windows-DCAP", "ACC-Win-", 2), + "agentLabel": "SGXFLC-Windows-DCAP", + "agentRegion": "westeurope", + "agentVhdUrl": "https://oejenkinswesteurope.blob.core.windows.net/disks/${env.VHD_NAME_PREFIX}-win-dcap.vhd" +] + +def agentsProperties = [ + "xenial": xenial, + "bionic": bionic, + "win2016": win2016, + "win2016dcap": win2016dcap +] + + + +if(BUILD_IMAGES == "true") { + // Build Docker images triggering 'OpenEnclave-Docker-Images' job with code from OpenEnclave master branch + stage("Build Docker Images") { + build job: 'OpenEnclave-Docker-Images' , + parameters: [string(name: 'REPOSITORY_NAME', value: "openenclave/openenclave"), + string(name: 'BRANCH_SPECIFIER', value: "master"), + string(name: 'DOCKER_TAG', value: env.DOCKER_TAG), + booleanParam(name: 'TAG_LATEST',value: true)] + } + + /* + Build VHD images triggering 'OpenEnclave-jenkins-agents-VHDs' job with code from OpenEnclave master branch + Here we will use the oe-deploy docker image with the tag we just built in previous job + */ + stage("Build Jenkins Agents VHDs") { + build job: 'OpenEnclave-jenkins-agents-VHDs' , + parameters: [string(name: 'OE_DEPLOY_IMAGE', value: "oetools-deploy:${env.DOCKER_TAG}"), + string(name: 'REPOSITORY_NAME', value: "openenclave/openenclave"), + string(name: 'BRANCH_SPECIFIER', value: "master"), + string(name: 'VHD_NAME_PREFIX', value: env.VHD_NAME_PREFIX)] + } +} + +/* +Deploy Jenkins agents with the latest VHD +Register the new Jenkins agents into our CI +*/ + +def stepsForParallel = [:] +agentsProperties.keySet().each { agent -> + agentsProperties[agent]['agentName'].each { agent_name -> + stepsForParallel[agent_name] = { + build job: 'OpenEnclave-deploy-jenkins-agent-test', + parameters: [string(name: 'OE_DEPLOY_IMAGE', value: "oetools-deploy:${env.DOCKER_TAG}"), + string(name: 'REPOSITORY_NAME', value: "openenclave/openenclave"), + string(name: 'BRANCH_SPECIFIER', value: "master"), + string(name: 'VHD_URL', value: agentsProperties[agent]['agentVhdUrl']), + string(name: 'REGION', value: agentsProperties[agent]['agentRegion']), + string(name: 'RESOURCE_GROUP', value: agent_name), + string(name: 'AGENT_NAME', value: agent_name.toLowerCase()), + string(name: 'AGENT_LABEL', value: agentsProperties[agent]['agentLabel']), + string(name: 'AGENT_TYPE', value: agentsProperties[agent]['agentType'])] + } + } +} + +// Deploy Jenkins Agents +parallel stepsForParallel + +// Mark old Jenkins agents offline +stage("Mark old Jenkins agents offline") { + cleanup(CURRENT_JENKINS_NODES) +} diff --git a/.jenkins/provision/cleanup.sh b/.jenkins/provision/cleanup.sh index f4a202efc4..c474da918e 100755 --- a/.jenkins/provision/cleanup.sh +++ b/.jenkins/provision/cleanup.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/.jenkins/provision/deploy-agent.sh b/.jenkins/provision/deploy-agent.sh index 0b65239c8a..9600716784 100755 --- a/.jenkins/provision/deploy-agent.sh +++ b/.jenkins/provision/deploy-agent.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/.jenkins/provision/register-agents.sh b/.jenkins/provision/register-agents.sh index 72fa260d4e..a0216da52a 100755 --- a/.jenkins/provision/register-agents.sh +++ b/.jenkins/provision/register-agents.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/.jenkins/provision/templates/oe-engine/win-2016.json b/.jenkins/provision/templates/oe-engine/win-2016.json new file mode 100644 index 0000000000..abfba0a4d4 --- /dev/null +++ b/.jenkins/provision/templates/oe-engine/win-2016.json @@ -0,0 +1,30 @@ +{ + "properties": { + "vmProfiles": [ + { + "name": "${AGENT_NAME}", + "osType": "Windows", + "vmSize": "Standard_DC2s", + "ports": [3389, 5986], + "isVanilla": true, + "enableWinRM": true, + "hasDNSName": true + } + ], + "vnetProfile": { + "vnetResourceGroup": "OE-Jenkins-CI-westeurope", + "vnetName": "OE-Jenkins-CI-VNET", + "subnetName": "default" + }, + "windowsProfile": { + "adminUsername": "azureuser", + "adminPassword": "${WINDOWS_ADMIN_PASSWORD}", + "osImage": { + "url": "${VHD_URL}" + } + }, + "diagnosticsProfile": { + "enabled": false + } + } +} diff --git a/.jenkins/provision/templates/packer/packer-win.json b/.jenkins/provision/templates/packer/packer-win.json new file mode 100644 index 0000000000..79ffeabf18 --- /dev/null +++ b/.jenkins/provision/templates/packer/packer-win.json @@ -0,0 +1,87 @@ +{ + "variables": { + "resource_group": "{{env `RESOURCE_GROUP`}}", + "subscription_id": "{{env `SUBSCRIPTION_ID`}}", + "client_id": "{{env `SERVICE_PRINCIPAL_ID`}}", + "client_secret": "{{env `SERVICE_PRINCIPAL_PASSWORD`}}", + "tenant_id": "{{env `TENANT_ID`}}", + "location": "{{env `REGION`}}", + "storage_account": "", + "capture_container_name": "", + "capture_name_prefix": "", + "os_type": "", + "image_publisher": "", + "image_offer": "", + "image_sku": "", + "vm_size": "" + }, + "builders": [{ + "name": "{{user `os_type`}}", + "type": "azure-arm", + + "client_id": "{{user `client_id`}}", + "client_secret": "{{user `client_secret`}}", + "tenant_id": "{{user `tennant_id`}}", + "resource_group_name": "{{user `resource_group`}}", + "storage_account": "{{user `storage_account`}}", + "subscription_id": "{{user `subscription_id`}}", + + "capture_container_name": "{{user `capture_container_name`}}", + "capture_name_prefix": "{{user `capture_name_prefix`}}", + + "os_type": "{{user `os_type`}}", + "image_publisher": "{{user `image_publisher`}}", + "image_offer": "{{user `image_offer`}}", + "image_sku": "{{user `image_sku`}}", + + "communicator": "{{ user `communicator` }}", + "winrm_use_ssl": true, + "winrm_insecure": true, + "winrm_timeout": "5m", + "winrm_username": "Administrator", + + "location": "{{user `location`}}", + "vm_size": "{{user `vm_size`}}" + }], + "provisioners": [ + { + "type": "powershell", + "inline": [ + "(Invoke-WebRequest -Headers @{\"Metadata\"=\"true\"} -UseBasicParsing \"http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text\").Content | Out-File -Append -Encoding utf8 C:/Windows/Temp/ip-address" + ] + }, + { + "type": "file", + "direction": "download", + "source": "C:/Windows/Temp/ip-address", + "destination": "/ansible/inventory/hosts" + }, + { + "type": "shell-local", + "inline": [ + "IP=`cut -b 4- /ansible/inventory/hosts`", + "echo \"[{{ user `ansible_group` }}]\\n${IP}\" > /ansible/inventory/hosts" + ] + }, + { + "type": "shell-local", + "environment_vars": [ + "ANSIBLE_ROLES_PATH=/ansible/roles", + "ANSIBLE_CONFIG=/ansible/ansible.cfg", + "ANSIBLE_INVENTORY=/ansible/inventory/hosts", + "ANSIBLE_REMOTE_PORT=5986" + ], + "command": "ansible-playbook -e \"dcap_testing_node={{ user `dcap_testing_node` }} ansible_user=packer ansible_password={{.WinRMPassword}} ansible_become_pass={{.WinRMPassword}} ansible_connection=winrm ansible_winrm_server_cert_validation=ignore ansible_winrm_transport=ntlm\" {{ user `playbook_file` }}" + }, + { + "type": "powershell", + "inline": [ + " while ((Get-Service RdAgent).Status -ne 'Running') { Start-Sleep -s 5 }", + " while ((Get-Service WindowsAzureTelemetryService).Status -ne 'Running') { Start-Sleep -s 5 }", + " while ((Get-Service WindowsAzureGuestAgent).Status -ne 'Running') { Start-Sleep -s 5 }", + "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit", + "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }" + ] + } + ] +} diff --git a/.jenkins/provision/templates/packer/win-2016-variables.json b/.jenkins/provision/templates/packer/win-2016-variables.json new file mode 100644 index 0000000000..4405bbe597 --- /dev/null +++ b/.jenkins/provision/templates/packer/win-2016-variables.json @@ -0,0 +1,14 @@ +{ + "storage_account": "oejenkins", + "capture_container_name": "disks", + "capture_name_prefix": "packer", + "os_type": "Windows", + "image_publisher": "MicrosoftWindowsServer", + "image_offer": "confidential-compute-preview", + "image_sku": "acc-windows-server-2016-datacenter", + "vm_size": "Standard_DC2s", + "communicator": "winrm", + "ansible_group": "windows-agents", + "playbook_file": "/ansible/oe-windows-acc-setup.yml", + "dcap_testing_node": "false" +} diff --git a/.jenkins/provision/templates/packer/win-dcap-variables.json b/.jenkins/provision/templates/packer/win-dcap-variables.json new file mode 100644 index 0000000000..71e9ca45ba --- /dev/null +++ b/.jenkins/provision/templates/packer/win-dcap-variables.json @@ -0,0 +1,14 @@ +{ + "storage_account": "oejenkins", + "capture_container_name": "disks", + "capture_name_prefix": "packer", + "os_type": "Windows", + "image_publisher": "MicrosoftWindowsServer", + "image_offer": "confidential-compute-preview", + "image_sku": "acc-windows-server-2016-datacenter", + "vm_size": "Standard_DC2s", + "communicator": "winrm", + "ansible_group": "windows-agents", + "playbook_file": "/ansible/oe-windows-acc-setup.yml", + "dcap_testing_node": "true" +} diff --git a/.jenkins/test.Jenkinsfile b/.jenkins/test.Jenkinsfile index f4bc5e13bb..baa92383c9 100644 --- a/.jenkins/test.Jenkinsfile +++ b/.jenkins/test.Jenkinsfile @@ -26,6 +26,30 @@ try { */ stage("Deploy and register Jenkins Agent") { parallel ( + "Windows" : { + build job: 'OpenEnclave-deploy-jenkins-agent-test', + parameters: [string(name: 'OE_DEPLOY_IMAGE', value: "oetools-deploy:${env.BUILD_TAG}"), + string(name: 'REPOSITORY_NAME', value: env.REPOSITORY), + string(name: 'BRANCH_SPECIFIER', value: env.BRANCH), + string(name: 'VHD_URL', value: "https://oejenkinswesteurope.blob.core.windows.net/disks/${env.BUILD_TAG}-win-2016.vhd"), + string(name: 'REGION', value: "westeurope"), + string(name: 'RESOURCE_GROUP', value: "windows-${env.BUILD_TAG}"), + string(name: 'AGENT_NAME', value: "win-2016-${env.BUILD_NUMBER}-1"), + string(name: 'AGENT_LABEL', value: "windows-${env.BUILD_TAG}"), + string(name: 'AGENT_TYPE', value: 'windows')] + }, + "Windows DCAP" : { + build job: 'OpenEnclave-deploy-jenkins-agent-test', + parameters: [string(name: 'OE_DEPLOY_IMAGE', value: "oetools-deploy:${env.BUILD_TAG}"), + string(name: 'REPOSITORY_NAME', value: env.REPOSITORY), + string(name: 'BRANCH_SPECIFIER', value: env.BRANCH), + string(name: 'VHD_URL', value: "https://oejenkinswesteurope.blob.core.windows.net/disks/${env.BUILD_TAG}-win-dcap.vhd"), + string(name: 'REGION', value: "westeurope"), + string(name: 'RESOURCE_GROUP', value: "windows-dcap-${env.BUILD_TAG}"), + string(name: 'AGENT_NAME', value: "win-dcap-${env.BUILD_NUMBER}-1"), + string(name: 'AGENT_LABEL', value: "windows-dcap-${env.BUILD_TAG}"), + string(name: 'AGENT_TYPE', value: 'windows')] + }, "Ubuntu 16.04" : { build job: 'OpenEnclave-deploy-jenkins-agent-test', parameters: [string(name: 'OE_DEPLOY_IMAGE', value: "oetools-deploy:${env.BUILD_TAG}"), @@ -56,8 +80,11 @@ try { build job: 'OpenEnclave-custom_label-test', parameters: [string(name: 'REPOSITORY_NAME', value: env.REPOSITORY), string(name: 'BRANCH_SPECIFIER', value: env.BRANCH), + string(name: 'DOCKER_TAG', value: env.BUILD_TAG), string(name: 'UBUNTU_1604_CUSTOM_LABEL', value: "xenial-${env.BUILD_TAG}"), - string(name: 'UBUNTU_1804_CUSTOM_LABEL', value: "bionic-${env.BUILD_TAG}")] + string(name: 'UBUNTU_1804_CUSTOM_LABEL', value: "bionic-${env.BUILD_TAG}"), + string(name: 'WINDOWS_2016_CUSTOM_LABEL', value: "windows-${env.BUILD_TAG}"), + string(name: 'WINDOWS_DCAP_CUSTOM_LABEL', value: "windows-dcap-${env.BUILD_TAG}")] } } finally { @@ -69,7 +96,7 @@ try { parameters: [string(name: 'OE_DEPLOY_IMAGE', value: "oetools-deploy:${env.BUILD_TAG}"), string(name: 'REPOSITORY_NAME', value: env.REPOSITORY), string(name: 'BRANCH_SPECIFIER', value: env.BRANCH), - string(name: "AGENT_LABELS", value: "xenial-${env.BUILD_TAG},bionic-${env.BUILD_TAG}"), - string(name: "RESOURCE_GROUPS", value: "xenial-${env.BUILD_TAG},bionic-${env.BUILD_TAG}")] + string(name: "AGENT_LABELS", value: "xenial-${env.BUILD_TAG},bionic-${env.BUILD_TAG},windows-${env.BUILD_TAG},windows-dcap-${env.BUILD_TAG}"), + string(name: "RESOURCE_GROUPS", value: "xenial-${env.BUILD_TAG},bionic-${env.BUILD_TAG},windows-${env.BUILD_TAG},windows-dcap-${env.BUILD_TAG}")] } } diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index cee4b76f40..a00c8729c0 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # NOTE: This is set here so that both `libcxx` and `musl` can use it @@ -79,6 +79,10 @@ if (OE_TRUSTZONE) BYPRODUCTS /libteec/libteec.a) + set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + ${CMAKE_CURRENT_BINARY_DIR}/optee_client + ${CMAKE_BINARY_DIR}/libteec/libteec.a + ) ExternalProject_Get_property(optee_client-wrap SOURCE_DIR) ExternalProject_Get_property(optee_client-wrap BINARY_DIR) diff --git a/3rdparty/dlmalloc/update.make b/3rdparty/dlmalloc/update.make index 899087ae45..f5401053ea 100755 --- a/3rdparty/dlmalloc/update.make +++ b/3rdparty/dlmalloc/update.make @@ -1,6 +1,6 @@ #!/usr/bin/make -f -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. all: update-dlmalloc diff --git a/3rdparty/libcxx/CMakeLists.txt b/3rdparty/libcxx/CMakeLists.txt index 710955e404..3c5088b473 100644 --- a/3rdparty/libcxx/CMakeLists.txt +++ b/3rdparty/libcxx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include (ExternalProject) @@ -11,6 +11,10 @@ ExternalProject_Add(libcxx_includes COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/__config ${LIBCXX_INCLUDES}/__config INSTALL_COMMAND "") +set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + ${LIBCXX_INCLUDES} +) + add_library(libcxx OBJECT __dso_handle.cpp libcxx/src/algorithm.cpp diff --git a/3rdparty/libcxx/__config b/3rdparty/libcxx/__config index 1925fbd326..cd2ef93588 100644 --- a/3rdparty/libcxx/__config +++ b/3rdparty/libcxx/__config @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef __OPEN_ENCLAVE_LIBCXX_CONFIG diff --git a/3rdparty/libcxx/__dso_handle.cpp b/3rdparty/libcxx/__dso_handle.cpp index 03728e77fb..cc2b031d85 100644 --- a/3rdparty/libcxx/__dso_handle.cpp +++ b/3rdparty/libcxx/__dso_handle.cpp @@ -1,8 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#include #include #include -#include -const void *__dso_handle = NULL; +const void* __dso_handle = NULL; diff --git a/3rdparty/libcxx/libcxx/benchmarks/CMakeLists.txt b/3rdparty/libcxx/libcxx/benchmarks/CMakeLists.txt index 3823b87b39..414bde48fd 100644 --- a/3rdparty/libcxx/libcxx/benchmarks/CMakeLists.txt +++ b/3rdparty/libcxx/libcxx/benchmarks/CMakeLists.txt @@ -38,6 +38,9 @@ ExternalProject_Add(google-benchmark-libcxx -DBENCHMARK_USE_LIBCXX:BOOL=ON -DBENCHMARK_ENABLE_TESTING:BOOL=OFF) +set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx +) #============================================================================== # Build Google Benchmark for the native stdlib #============================================================================== @@ -61,6 +64,9 @@ if (LIBCXX_BENCHMARK_NATIVE_STDLIB) -DCMAKE_BUILD_TYPE:STRING=RELEASE -DCMAKE_INSTALL_PREFIX:PATH= -DBENCHMARK_ENABLE_TESTING:BOOL=OFF) + set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native + ) endif() diff --git a/3rdparty/libcxx/libcxx/utils/google-benchmark/cmake/HandleGTest.cmake b/3rdparty/libcxx/libcxx/utils/google-benchmark/cmake/HandleGTest.cmake index b9c14436db..751ed6704f 100644 --- a/3rdparty/libcxx/libcxx/utils/google-benchmark/cmake/HandleGTest.cmake +++ b/3rdparty/libcxx/libcxx/utils/google-benchmark/cmake/HandleGTest.cmake @@ -50,7 +50,9 @@ macro(build_external_gtest) -DCMAKE_CXX_FLAGS:STRING=${GTEST_FLAGS} -Dgtest_force_shared_crt:BOOL=ON ) - + set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + ${CMAKE_BINARY_DIR}/googletest + ) ExternalProject_Get_Property(googletest install_dir) set(GTEST_INCLUDE_DIRS ${install_dir}/include) file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIRS}) diff --git a/3rdparty/libcxx/libcxx/utils/libcxx/test/config.py b/3rdparty/libcxx/libcxx/utils/libcxx/test/config.py index 1aa52ddbbd..228af73d49 100644 --- a/3rdparty/libcxx/libcxx/utils/libcxx/test/config.py +++ b/3rdparty/libcxx/libcxx/utils/libcxx/test/config.py @@ -420,7 +420,7 @@ def configure_features(self): # Insert the platform name into the available features as a lower case. self.config.available_features.add(target_platform) - # Simulator testing can take a really long time for some of these tests + # Simulation mode testing can take a really long time for some of these tests # so add a feature check so we can REQUIRES: long_tests in them self.long_tests = self.get_lit_bool('long_tests') if self.long_tests is None: diff --git a/3rdparty/libcxx/update.make b/3rdparty/libcxx/update.make index 2702b83725..9db7ab766f 100755 --- a/3rdparty/libcxx/update.make +++ b/3rdparty/libcxx/update.make @@ -1,6 +1,6 @@ #!/usr/bin/make -f -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # libcxx SVN revision diff --git a/3rdparty/libcxxrt/CMakeLists.txt b/3rdparty/libcxxrt/CMakeLists.txt index 0df0cfb162..d24cd4b0ff 100644 --- a/3rdparty/libcxxrt/CMakeLists.txt +++ b/3rdparty/libcxxrt/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Compile libcxx for Open Enclave. Some of these build rules emulate diff --git a/3rdparty/libcxxrt/update.make b/3rdparty/libcxxrt/update.make index 9518143acc..ae602acc97 100755 --- a/3rdparty/libcxxrt/update.make +++ b/3rdparty/libcxxrt/update.make @@ -1,6 +1,6 @@ #!/usr/bin/make -f -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. all: update-libcxxrt diff --git a/3rdparty/libunwind/CMakeLists.txt b/3rdparty/libunwind/CMakeLists.txt index 05968faaed..3e9f28f4ed 100644 --- a/3rdparty/libunwind/CMakeLists.txt +++ b/3rdparty/libunwind/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (OE_SGX) diff --git a/3rdparty/libunwind/Gstep.c b/3rdparty/libunwind/Gstep.c index d9192f6065..a687fcc2d5 100644 --- a/3rdparty/libunwind/Gstep.c +++ b/3rdparty/libunwind/Gstep.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(__clang__) @@ -10,16 +10,15 @@ #endif #include -#include "unwind_i.h" #include +#include "unwind_i.h" #undef unw_step #define unw_step _ULx86_64_step - extern int _ULx86_64_step(unw_cursor_t* cursor); -// Wrapper for calling unw_step() throughout libunwind source. This +// Wrapper for calling unw_step() throughout libunwind source. This // function checks whether the cursor is within the enclave image. int __libunwind_unw_step(unw_cursor_t* cursor) { diff --git a/3rdparty/libunwind/libunwind-common.h b/3rdparty/libunwind/libunwind-common.h index ab9737a744..47e6608df6 100644 --- a/3rdparty/libunwind/libunwind-common.h +++ b/3rdparty/libunwind/libunwind-common.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_LIBUNWIND_COMMON_H diff --git a/3rdparty/libunwind/stubs.h b/3rdparty/libunwind/stubs.h index 74a3f474c8..f075f818b1 100644 --- a/3rdparty/libunwind/stubs.h +++ b/3rdparty/libunwind/stubs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef __OE_LIBUNWIND_STUBS_H @@ -6,16 +6,16 @@ #if !defined(__ASSEMBLER__) -#include -#include -#include -#include #include -#include +#include #include -#include -#include +#include #include +#include +#include +#include +#include +#include // Disable use of adaptive mutexes, which are defined by GCC headers but not // supported by MUSL pthreads. Note that libunwind is compiled with GCC headers @@ -109,10 +109,9 @@ static __inline void* __libunwind_mmap( return result; } - static __inline int __libunwind_munmap(void* addr, size_t length) { - extern void dlfree(void *ptr); + extern void dlfree(void* ptr); if (!addr) return -1; @@ -129,8 +128,8 @@ static __inline int __libunwind_msync(void* addr, size_t length, int flags) } static __inline int __libunwind_mincore( - void* addr, - size_t length, + void* addr, + size_t length, unsigned char* vec) { if (!addr || !vec) diff --git a/3rdparty/libunwind/update.make b/3rdparty/libunwind/update.make index befb90c22c..b87eb333cc 100755 --- a/3rdparty/libunwind/update.make +++ b/3rdparty/libunwind/update.make @@ -1,6 +1,6 @@ #!/usr/bin/make -f -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. #libunwind Version diff --git a/3rdparty/mbedtls/0001-Patch-x509write_crt.c-for-attestedTLS.patch b/3rdparty/mbedtls/0001-Patch-x509write_crt.c-for-attestedTLS.patch new file mode 100644 index 0000000000..6bf2af9a97 --- /dev/null +++ b/3rdparty/mbedtls/0001-Patch-x509write_crt.c-for-attestedTLS.patch @@ -0,0 +1,264 @@ +From cede0947eb335c4f2d425fa113adbf093efe8f6b Mon Sep 17 00:00:00 2001 +From: Simon Leet +Date: Fri, 13 Sep 2019 01:20:45 +0000 +Subject: [PATCH] Patch x509write_crt.c for attestedTLS + +--- + .../mbedtls/mbedtls/library/x509write_crt.c | 143 +++++++++++------- + 1 file changed, 89 insertions(+), 54 deletions(-) + +diff --git a/3rdparty/mbedtls/mbedtls/library/x509write_crt.c b/3rdparty/mbedtls/mbedtls/library/x509write_crt.c +index 41dfe87b7..de7bf0c70 100644 +--- a/3rdparty/mbedtls/mbedtls/library/x509write_crt.c ++++ b/3rdparty/mbedtls/mbedtls/library/x509write_crt.c +@@ -298,9 +298,10 @@ static int x509_write_time( unsigned char **p, unsigned char *start, + return( (int) len ); + } + +-int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, size_t size, +- int (*f_rng)(void *, unsigned char *, size_t), +- void *p_rng ) ++int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, ++ unsigned char *buf, size_t size, ++ int (*f_rng)(void *, unsigned char *, size_t), ++ void *p_rng ) + { + int ret; + const char *sig_oid; +@@ -308,15 +309,14 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, + unsigned char *c, *c2; + unsigned char hash[64]; + unsigned char sig[MBEDTLS_MPI_MAX_SIZE]; +- unsigned char tmp_buf[2048]; + size_t sub_len = 0, pub_len = 0, sig_and_oid_len = 0, sig_len; + size_t len = 0; + mbedtls_pk_type_t pk_alg; + + /* +- * Prepare data to be signed in tmp_buf ++ * Prepare data to be signed at the end of the target buffer + */ +- c = tmp_buf + sizeof( tmp_buf ); ++ c = buf + size; + + /* Signature algorithm needed in TBS, and later for actual signature */ + +@@ -342,27 +342,36 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, + /* Only for v3 */ + if( ctx->version == MBEDTLS_X509_CRT_VERSION_3 ) + { +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_extensions( &c, tmp_buf, ctx->extensions ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | +- MBEDTLS_ASN1_SEQUENCE ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC | +- MBEDTLS_ASN1_CONSTRUCTED | 3 ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_x509_write_extensions( &c, ++ buf, ctx->extensions ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_tag( &c, buf, ++ MBEDTLS_ASN1_CONSTRUCTED | ++ MBEDTLS_ASN1_SEQUENCE ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_tag( &c, buf, ++ MBEDTLS_ASN1_CONTEXT_SPECIFIC | ++ MBEDTLS_ASN1_CONSTRUCTED | 3 ) ); + } + + /* + * SubjectPublicKeyInfo + */ +- MBEDTLS_ASN1_CHK_ADD( pub_len, mbedtls_pk_write_pubkey_der( ctx->subject_key, +- tmp_buf, c - tmp_buf ) ); ++ MBEDTLS_ASN1_CHK_ADD( pub_len, ++ mbedtls_pk_write_pubkey_der( ctx->subject_key, ++ buf, c - buf ) ); + c -= pub_len; + len += pub_len; + + /* + * Subject ::= Name + */ +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->subject ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_x509_write_names( &c, buf, ++ ctx->subject ) ); + + /* + * Validity ::= SEQUENCE { +@@ -371,32 +380,39 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, + */ + sub_len = 0; + +- MBEDTLS_ASN1_CHK_ADD( sub_len, x509_write_time( &c, tmp_buf, ctx->not_after, +- MBEDTLS_X509_RFC5280_UTC_TIME_LEN ) ); ++ MBEDTLS_ASN1_CHK_ADD( sub_len, ++ x509_write_time( &c, buf, ctx->not_after, ++ MBEDTLS_X509_RFC5280_UTC_TIME_LEN ) ); + +- MBEDTLS_ASN1_CHK_ADD( sub_len, x509_write_time( &c, tmp_buf, ctx->not_before, +- MBEDTLS_X509_RFC5280_UTC_TIME_LEN ) ); ++ MBEDTLS_ASN1_CHK_ADD( sub_len, ++ x509_write_time( &c, buf, ctx->not_before, ++ MBEDTLS_X509_RFC5280_UTC_TIME_LEN ) ); + + len += sub_len; +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, sub_len ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | +- MBEDTLS_ASN1_SEQUENCE ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, sub_len ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_tag( &c, buf, ++ MBEDTLS_ASN1_CONSTRUCTED | ++ MBEDTLS_ASN1_SEQUENCE ) ); + + /* + * Issuer ::= Name + */ +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, tmp_buf, ctx->issuer ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_x509_write_names( &c, buf, ++ ctx->issuer ) ); + + /* + * Signature ::= AlgorithmIdentifier + */ +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_algorithm_identifier( &c, tmp_buf, +- sig_oid, strlen( sig_oid ), 0 ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_algorithm_identifier( &c, buf, ++ sig_oid, strlen( sig_oid ), 0 ) ); + + /* + * Serial ::= INTEGER + */ +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, tmp_buf, &ctx->serial ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_mpi( &c, buf, ++ &ctx->serial ) ); + + /* + * Version ::= INTEGER { v1(0), v2(1), v3(2) } +@@ -406,48 +422,67 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, + if( ctx->version != MBEDTLS_X509_CRT_VERSION_1 ) + { + sub_len = 0; +- MBEDTLS_ASN1_CHK_ADD( sub_len, mbedtls_asn1_write_int( &c, tmp_buf, ctx->version ) ); ++ MBEDTLS_ASN1_CHK_ADD( sub_len, ++ mbedtls_asn1_write_int( &c, buf, ctx->version ) ); + len += sub_len; +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, sub_len ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONTEXT_SPECIFIC | +- MBEDTLS_ASN1_CONSTRUCTED | 0 ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_len( &c, buf, sub_len ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_tag( &c, buf, ++ MBEDTLS_ASN1_CONTEXT_SPECIFIC | ++ MBEDTLS_ASN1_CONSTRUCTED | 0 ) ); + } + +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, tmp_buf, len ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, tmp_buf, MBEDTLS_ASN1_CONSTRUCTED | +- MBEDTLS_ASN1_SEQUENCE ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, ++ mbedtls_asn1_write_tag( &c, buf, MBEDTLS_ASN1_CONSTRUCTED | ++ MBEDTLS_ASN1_SEQUENCE ) ); + + /* + * Make signature + */ ++ ++ /* Compute hash of CRT. */ + if( ( ret = mbedtls_md( mbedtls_md_info_from_type( ctx->md_alg ), c, + len, hash ) ) != 0 ) + { + return( ret ); + } + +- if( ( ret = mbedtls_pk_sign( ctx->issuer_key, ctx->md_alg, hash, 0, sig, &sig_len, +- f_rng, p_rng ) ) != 0 ) ++ if( ( ret = mbedtls_pk_sign( ctx->issuer_key, ctx->md_alg, ++ hash, 0, sig, &sig_len, ++ f_rng, p_rng ) ) != 0 ) + { + return( ret ); + } + +- /* +- * Write data to output buffer +- */ ++ /* Move CRT to the front of the buffer to have space ++ * for the signature. */ ++ memmove( buf, c, len ); ++ c = buf + len; ++ ++ /* Add signature at the end of the buffer, ++ * making sure that it doesn't underflow ++ * into the CRT buffer. */ + c2 = buf + size; +- MBEDTLS_ASN1_CHK_ADD( sig_and_oid_len, mbedtls_x509_write_sig( &c2, buf, ++ MBEDTLS_ASN1_CHK_ADD( sig_and_oid_len, mbedtls_x509_write_sig( &c2, c, + sig_oid, sig_oid_len, sig, sig_len ) ); + +- if( len > (size_t)( c2 - buf ) ) +- return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); ++ /* ++ * Memory layout after this step: ++ * ++ * buf c=buf+len c2 buf+size ++ * [CRT0,...,CRTn, UNUSED, ..., UNUSED, SIG0, ..., SIGm] ++ */ + +- c2 -= len; +- memcpy( c2, c, len ); ++ /* Move raw CRT to just before the signature. */ ++ c = c2 - len; ++ memmove( c, buf, len ); + + len += sig_and_oid_len; +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c2, buf, len ) ); +- MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c2, buf, MBEDTLS_ASN1_CONSTRUCTED | ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( &c, buf, len ) ); ++ MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( &c, buf, ++ MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); + + return( (int) len ); +@@ -457,23 +492,23 @@ int mbedtls_x509write_crt_der( mbedtls_x509write_cert *ctx, unsigned char *buf, + #define PEM_END_CRT "-----END CERTIFICATE-----\n" + + #if defined(MBEDTLS_PEM_WRITE_C) +-int mbedtls_x509write_crt_pem( mbedtls_x509write_cert *crt, unsigned char *buf, size_t size, +- int (*f_rng)(void *, unsigned char *, size_t), +- void *p_rng ) ++int mbedtls_x509write_crt_pem( mbedtls_x509write_cert *crt, ++ unsigned char *buf, size_t size, ++ int (*f_rng)(void *, unsigned char *, size_t), ++ void *p_rng ) + { + int ret; +- unsigned char output_buf[4096]; +- size_t olen = 0; ++ size_t olen; + +- if( ( ret = mbedtls_x509write_crt_der( crt, output_buf, sizeof(output_buf), ++ if( ( ret = mbedtls_x509write_crt_der( crt, buf, size, + f_rng, p_rng ) ) < 0 ) + { + return( ret ); + } + + if( ( ret = mbedtls_pem_write_buffer( PEM_BEGIN_CRT, PEM_END_CRT, +- output_buf + sizeof(output_buf) - ret, +- ret, buf, size, &olen ) ) != 0 ) ++ buf + size - ret, ret, ++ buf, size, &olen ) ) != 0 ) + { + return( ret ); + } +-- +2.17.1 diff --git a/3rdparty/mbedtls/CMakeLists.txt b/3rdparty/mbedtls/CMakeLists.txt index a9a991e301..e4f9319d3b 100644 --- a/3rdparty/mbedtls/CMakeLists.txt +++ b/3rdparty/mbedtls/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Load the compiler info if we're cross compiling on Windows. @@ -103,6 +103,7 @@ add_library(mbedcrypto_static STATIC mbedtls/library/pkparse.c mbedtls/library/pkwrite.c mbedtls/library/platform.c + mbedtls/library/platform_util.c mbedtls/library/ripemd160.c mbedtls/library/rsa.c mbedtls/library/rsa_internal.c diff --git a/3rdparty/mbedtls/README.md b/3rdparty/mbedtls/README.md new file mode 100644 index 0000000000..659a570819 --- /dev/null +++ b/3rdparty/mbedtls/README.md @@ -0,0 +1,21 @@ +mbedTLS: +======== + +This directory contains the **mbedTLS** crypto library for enclaves. +The `./mbedtls` subdirectory contains a clone of the sources downloaded +from https://tls.mbed.org/download-archive. + +The version of mbedTLS currently in use is reflected in `update.make`. + +The enclave version of mbedTLS builds the cloned sources with the following +changes: + +- It uses a custom, scoped-down `config.h` defined in this folder. + +- It compiles in `mbedtls_hardware_poll.c` extension to provide the custom + entropy implementation mbedTLS libraries to avoid a circular dependency + with the Open Enclave core runtime. + +- It patches `mbedtls/library/x509write_crt.c` with + `0001-Patch-x509write_crt.c-for-attestedTLS.patch` to add support for writing + certificates that support using TLS with enclave attestation for auth. diff --git a/3rdparty/mbedtls/config.h b/3rdparty/mbedtls/config.h index 9f3b1ef3d9..1b74f487f9 100644 --- a/3rdparty/mbedtls/config.h +++ b/3rdparty/mbedtls/config.h @@ -8,7 +8,7 @@ * memory footprint. */ /* - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -48,10 +48,14 @@ * Requires support for asm() in compiler. * * Used in: + * library/aria.c * library/timing.c - * library/padlock.c * include/mbedtls/bn_mul.h * + * Required by: + * MBEDTLS_AESNI_C + * MBEDTLS_PADLOCK_C + * * Comment to disable the use of assembly code. */ #define MBEDTLS_HAVE_ASM @@ -85,6 +89,28 @@ // Open Enclave: enabled #define MBEDTLS_NO_UDBL_DIVISION +/** + * \def MBEDTLS_NO_64BIT_MULTIPLICATION + * + * The platform lacks support for 32x32 -> 64-bit multiplication. + * + * Used in: + * library/poly1305.c + * + * Some parts of the library may use multiplication of two unsigned 32-bit + * operands with a 64-bit result in order to speed up computations. On some + * platforms, this is not available in hardware and has to be implemented in + * software, usually in a library provided by the toolchain. + * + * Sometimes it is not desirable to have to link to that library. This option + * removes the dependency of that library on platforms that lack a hardware + * 64-bit multiplier by embedding a software implementation in Mbed TLS. + * + * Note that depending on the compiler, this may decrease performance compared + * to using the library function provided by the toolchain. + */ +//#define MBEDTLS_NO_64BIT_MULTIPLICATION + /** * \def MBEDTLS_HAVE_SSE2 * @@ -114,12 +140,21 @@ /** * \def MBEDTLS_HAVE_TIME_DATE * - * System has time.h and time(), gmtime() and the clock is correct. + * System has time.h, time(), and an implementation for + * mbedtls_platform_gmtime_r() (see below). * The time needs to be correct (not necesarily very accurate, but at least * the date should be correct). This is used to verify the validity period of * X.509 certificates. * * Comment if your system does not have a correct clock. + * + * \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that + * behaves similarly to the gmtime_r() function from the C standard. Refer to + * the documentation for mbedtls_platform_gmtime_r() for more information. + * + * \note It is possible to configure an implementation for + * mbedtls_platform_gmtime_r() at compile-time by using the macro + * MBEDTLS_PLATFORM_GMTIME_R_ALT. */ // Open Enclave: Time methods are not secure against host, enabled only for x509 expiration checks #define MBEDTLS_HAVE_TIME_DATE @@ -229,6 +264,48 @@ // Open Enclave: Enable deprecation errors #define MBEDTLS_DEPRECATED_REMOVED +/** + * \def MBEDTLS_CHECK_PARAMS + * + * This configuration option controls whether the library validates more of + * the parameters passed to it. + * + * When this flag is not defined, the library only attempts to validate an + * input parameter if: (1) they may come from the outside world (such as the + * network, the filesystem, etc.) or (2) not validating them could result in + * internal memory errors such as overflowing a buffer controlled by the + * library. On the other hand, it doesn't attempt to validate parameters whose + * values are fully controlled by the application (such as pointers). + * + * When this flag is defined, the library additionally attempts to validate + * parameters that are fully controlled by the application, and should always + * be valid if the application code is fully correct and trusted. + * + * For example, when a function accepts as input a pointer to a buffer that may + * contain untrusted data, and its documentation mentions that this pointer + * must not be NULL: + * - the pointer is checked to be non-NULL only if this option is enabled + * - the content of the buffer is always validated + * + * When this flag is defined, if a library function receives a parameter that + * is invalid, it will: + * - invoke the macro MBEDTLS_PARAM_FAILED() which by default expands to a + * call to the function mbedtls_param_failed() + * - immediately return (with a specific error code unless the function + * returns void and can't communicate an error). + * + * When defining this flag, you also need to: + * - either provide a definition of the function mbedtls_param_failed() in + * your application (see platform_util.h for its prototype) as the library + * calls that function, but does not provide a default definition for it, + * - or provide a different definition of the macro MBEDTLS_PARAM_FAILED() + * below if the above mechanism is not flexible enough to suit your needs. + * See the documentation of this macro later in this file. + * + * Uncomment to enable validation of application-controlled parameters. + */ +//#define MBEDTLS_CHECK_PARAMS + /* \} name SECTION: System support */ /** @@ -279,23 +356,29 @@ */ //#define MBEDTLS_AES_ALT //#define MBEDTLS_ARC4_ALT +//#define MBEDTLS_ARIA_ALT //#define MBEDTLS_BLOWFISH_ALT //#define MBEDTLS_CAMELLIA_ALT //#define MBEDTLS_CCM_ALT +//#define MBEDTLS_CHACHA20_ALT +//#define MBEDTLS_CHACHAPOLY_ALT //#define MBEDTLS_CMAC_ALT //#define MBEDTLS_DES_ALT //#define MBEDTLS_DHM_ALT //#define MBEDTLS_ECJPAKE_ALT //#define MBEDTLS_GCM_ALT +//#define MBEDTLS_NIST_KW_ALT //#define MBEDTLS_MD2_ALT //#define MBEDTLS_MD4_ALT //#define MBEDTLS_MD5_ALT +//#define MBEDTLS_POLY1305_ALT //#define MBEDTLS_RIPEMD160_ALT //#define MBEDTLS_RSA_ALT //#define MBEDTLS_SHA1_ALT //#define MBEDTLS_SHA256_ALT //#define MBEDTLS_SHA512_ALT //#define MBEDTLS_XTEA_ALT + /* * When replacing the elliptic curve module, pleace consider, that it is * implemented with two .c files: @@ -381,11 +464,11 @@ * unsigned char mbedtls_internal_ecp_grp_capable( * const mbedtls_ecp_group *grp ) * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ) - * void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp ) + * void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ) * The mbedtls_internal_ecp_grp_capable function should return 1 if the * replacement functions implement arithmetic for the given group and 0 * otherwise. - * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are + * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_free are * called before and after each point operation and provide an opportunity to * implement optimized set up and tear down instructions. * @@ -449,12 +532,45 @@ /** * \def MBEDTLS_AES_ROM_TABLES * - * Store the AES tables in ROM. + * Use precomputed AES tables stored in ROM. + * + * Uncomment this macro to use precomputed AES tables stored in ROM. + * Comment this macro to generate AES tables in RAM at runtime. + * + * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb + * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the + * initialization time before the first AES operation can be performed. + * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c + * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded + * performance if ROM access is slower than RAM access. + * + * This option is independent of \c MBEDTLS_AES_FEWER_TABLES. * - * Uncomment this macro to store the AES tables in ROM. */ //#define MBEDTLS_AES_ROM_TABLES +/** + * \def MBEDTLS_AES_FEWER_TABLES + * + * Use less ROM/RAM for AES tables. + * + * Uncommenting this macro omits 75% of the AES tables from + * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES) + * by computing their values on the fly during operations + * (the tables are entry-wise rotations of one another). + * + * Tradeoff: Uncommenting this reduces the RAM / ROM footprint + * by ~6kb but at the cost of more arithmetic operations during + * runtime. Specifically, one has to compare 4 accesses within + * different tables to 4 accesses with additional arithmetic + * operations within the same table. The performance gain/loss + * depends on the system and memory details. + * + * This option is independent of \c MBEDTLS_AES_ROM_TABLES. + * + */ +//#define MBEDTLS_AES_FEWER_TABLES + /** * \def MBEDTLS_CAMELLIA_SMALL_MEMORY * @@ -486,6 +602,20 @@ */ #define MBEDTLS_CIPHER_MODE_CTR +/** + * \def MBEDTLS_CIPHER_MODE_OFB + * + * Enable Output Feedback mode (OFB) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_OFB + +/** + * \def MBEDTLS_CIPHER_MODE_XTS + * + * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. + */ +#define MBEDTLS_CIPHER_MODE_XTS + /** * \def MBEDTLS_CIPHER_NULL_CIPHER * @@ -566,6 +696,26 @@ */ #define MBEDTLS_REMOVE_ARC4_CIPHERSUITES +/** + * \def MBEDTLS_REMOVE_3DES_CIPHERSUITES + * + * Remove 3DES ciphersuites by default in SSL / TLS. + * This flag removes the ciphersuites based on 3DES from the default list as + * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible + * to enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including + * them explicitly. + * + * A man-in-the-browser attacker can recover authentication tokens sent through + * a TLS connection using a 3DES based cipher suite (see "On the Practical + * (In-)Security of 64-bit Block Ciphers" by Karthikeyan Bhargavan and Gaëtan + * Leurent, see https://sweet32.info/SWEET32_CCS16.pdf). If this attack falls + * in your threat model or you are unsure, then you should keep this option + * enabled to remove 3DES based cipher suites. + * + * Comment this macro to keep 3DES in the default ciphersuite list. + */ +#define MBEDTLS_REMOVE_3DES_CIPHERSUITES + /** * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED * @@ -589,6 +739,7 @@ //#define MBEDTLS_ECP_DP_BP384R1_ENABLED //#define MBEDTLS_ECP_DP_BP512R1_ENABLED #define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define MBEDTLS_ECP_DP_CURVE448_ENABLED /** * \def MBEDTLS_ECP_NIST_OPTIM @@ -601,6 +752,30 @@ */ #define MBEDTLS_ECP_NIST_OPTIM +/** + * \def MBEDTLS_ECP_RESTARTABLE + * + * Enable "non-blocking" ECC operations that can return early and be resumed. + * + * This allows various functions to pause by returning + * #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module, + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in + * order to further progress and eventually complete their operation. This is + * controlled through mbedtls_ecp_set_max_ops() which limits the maximum + * number of ECC operations a function may perform before pausing; see + * mbedtls_ecp_set_max_ops() for more information. + * + * This is useful in non-threaded environments if you want to avoid blocking + * for too long on ECC (and, hence, X.509 or SSL/TLS) operations. + * + * Uncomment this macro to enable restartable ECC computations. + * + * \note This option only works with the default software implementation of + * elliptic curve functionality. It is incompatible with + * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT and MBEDTLS_ECDSA_XXX_ALT. + */ +//#define MBEDTLS_ECP_RESTARTABLE + /** * \def MBEDTLS_ECDSA_DETERMINISTIC * @@ -746,9 +921,9 @@ * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 */ -// Open Enclave: Support for backward compatibility -// Consider ECDHE key exchange instead for forward secrecy -#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +// Open Enclave: Deprecated in v0.7, developers should consider +// ECDHE key exchange instead for forward secrecy. +//#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED /** * \def MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED @@ -1090,8 +1265,8 @@ * * Enable the checkup functions (*_self_test). */ -// Open Enclave: Enable these by default for compliance checks -#define MBEDTLS_SELF_TEST +// Open Enclave: Disable these by default for performance +//#define MBEDTLS_SELF_TEST /** * \def MBEDTLS_SHA256_SMALLER @@ -1123,6 +1298,17 @@ */ #define MBEDTLS_SSL_ALL_ALERT_MESSAGES +/** + * \def MBEDTLS_SSL_ASYNC_PRIVATE + * + * Enable asynchronous external private key operations in SSL. This allows + * you to configure an SSL connection to call an external cryptographic + * module to perform private key operations instead of performing the + * operation inside the library. + * + */ +//#define MBEDTLS_SSL_ASYNC_PRIVATE + /** * \def MBEDTLS_SSL_DEBUG_ALL * @@ -1578,6 +1764,9 @@ * * \note Currently compression can't be used with DTLS. * + * \deprecated This feature is deprecated and will be removed + * in the next major revision of the library. + * * Used in: library/ssl_tls.c * library/ssl_cli.c * library/ssl_srv.c @@ -1616,7 +1805,7 @@ * Enable the AES block cipher. * * Module: library/aes.c - * Caller: library/ssl_tls.c + * Caller: library/cipher.c * library/pem.c * library/ctr_drbg.c * @@ -1691,7 +1880,7 @@ * Enable the ARCFOUR stream cipher. * * Module: library/arc4.c - * Caller: library/ssl_tls.c + * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): @@ -1787,7 +1976,7 @@ * Enable the Camellia block cipher. * * Module: library/camellia.c - * Caller: library/ssl_tls.c + * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): @@ -1837,6 +2026,58 @@ // Open Enclave: Drop support for uncommon cipher //#define MBEDTLS_CAMELLIA_C +/** + * \def MBEDTLS_ARIA_C + * + * Enable the ARIA block cipher. + * + * Module: library/aria.c + * Caller: library/cipher.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * + * MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 + */ +//#define MBEDTLS_ARIA_C + /** * \def MBEDTLS_CCM_C * @@ -1864,6 +2105,28 @@ // Open Enclave: Enabled conditionally #cmakedefine MBEDTLS_CERTS_C +/** + * \def MBEDTLS_CHACHA20_C + * + * Enable the ChaCha20 stream cipher. + * + * Module: library/chacha20.c + */ +// Open Enclave: Disable less common cipher until there's a demand for it. +//#define MBEDTLS_CHACHA20_C + +/** + * \def MBEDTLS_CHACHAPOLY_C + * + * Enable the ChaCha20-Poly1305 AEAD algorithm. + * + * Module: library/chachapoly.c + * + * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C + */ +// Open Enclave: Disable less common cipher until there's a demand for it. +//#define MBEDTLS_CHACHAPOLY_C + /** * \def MBEDTLS_CIPHER_C * @@ -1893,14 +2156,16 @@ /** * \def MBEDTLS_CTR_DRBG_C * - * Enable the CTR_DRBG AES-256-based random generator. + * Enable the CTR_DRBG AES-based random generator. + * The CTR_DRBG generator uses AES-256 by default. + * To use AES-128 instead, enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY below. * * Module: library/ctr_drbg.c * Caller: * * Requires: MBEDTLS_AES_C * - * This module provides the CTR_DRBG AES-256 random number generator. + * This module provides the CTR_DRBG AES random number generator. */ #define MBEDTLS_CTR_DRBG_C @@ -1917,7 +2182,7 @@ * This module provides debugging functions. */ // Open Enclave: Enabled conditionally -#define MBEDTLS_DEBUG_C +#cmakedefine MBEDTLS_DEBUG_C /** * \def MBEDTLS_DES_C @@ -1926,7 +2191,7 @@ * * Module: library/des.c * Caller: library/pem.c - * library/ssl_tls.c + * library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): @@ -2099,6 +2364,21 @@ */ //#define MBEDTLS_HAVEGE_C +/** + * \def MBEDTLS_HKDF_C + * + * Enable the HKDF algorithm (RFC 5869). + * + * Module: library/hkdf.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the Hashed Message Authentication Code + * (HMAC)-based key derivation function (HKDF). + */ +#define MBEDTLS_HKDF_C + /** * \def MBEDTLS_HMAC_DRBG_C * @@ -2113,6 +2393,19 @@ */ #define MBEDTLS_HMAC_DRBG_C +/** + * \def MBEDTLS_NIST_KW_C + * + * Enable the Key Wrapping mode for 128-bit block ciphers, + * as defined in NIST SP 800-38F. Only KW and KWP modes + * are supported. At the moment, only AES is approved by NIST. + * + * Module: library/nist_kw.c + * + * Requires: MBEDTLS_AES_C and MBEDTLS_CIPHER_C + */ +//#define MBEDTLS_NIST_KW_C + /** * \def MBEDTLS_MD_C * @@ -2399,6 +2692,17 @@ */ #define MBEDTLS_PLATFORM_C +/** + * \def MBEDTLS_POLY1305_C + * + * Enable the Poly1305 MAC algorithm. + * + * Module: library/poly1305.c + * Caller: library/chachapoly.c + */ +// Open Enclave: Drop uncommon hash algorithm to minimize TCB. +//#define MBEDTLS_POLY1305_C + /** * \def MBEDTLS_RIPEMD160_C * @@ -2408,7 +2712,7 @@ * Caller: library/md.c * */ -// Open Enclave: Drop uncommon hash algorithm to minimize TCB +// Open Enclave: Drop uncommon hash algorithm to minimize TCB. //#define MBEDTLS_RIPEMD160_C /** @@ -2758,6 +3062,7 @@ //#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ //#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ //#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ +//#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY /**< Use 128-bit key for CTR_DRBG - may reduce security (see ctr_drbg.h) */ /* HMAC_DRBG options */ //#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ @@ -2780,16 +3085,8 @@ /* Platform options */ //#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ -/* Open Enclave: Redirect the mbedtls_calloc/free calls to the corelibc methods - * so that mbedtls does not need to depend on oelibc. Note that we do this - * instead of defining the MBEDTLS_PLATFORM_CALLOC/FREE_MACRO as the STD - * implementation defines them as function pointers instead of macros, which is - * resiliant to compiling without the oe_calloc/free definition as happens in - * tests/mbed where the return value is corrupted by being marshalled as an - * int by default instead of void*. - */ //#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ @@ -2810,19 +3107,140 @@ //#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ //#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */ -/* Open Enclave: Redirect printf to corelibc version for tests */ //#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ /* Note: your snprintf must correclty zero-terminate the buffer! */ //#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ //#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ +/** + * \brief This macro is invoked by the library when an invalid parameter + * is detected that is only checked with MBEDTLS_CHECK_PARAMS + * (see the documentation of that option for context). + * + * When you leave this undefined here, a default definition is + * provided that invokes the function mbedtls_param_failed(), + * which is declared in platform_util.h for the benefit of the + * library, but that you need to define in your application. + * + * When you define this here, this replaces the default + * definition in platform_util.h (which no longer declares the + * function mbedtls_param_failed()) and it is your responsibility + * to make sure this macro expands to something suitable (in + * particular, that all the necessary declarations are visible + * from within the library - you can ensure that by providing + * them in this file next to the macro definition). + * + * Note that you may define this macro to expand to nothing, in + * which case you don't have to worry about declarations or + * definitions. However, you will then be notified about invalid + * parameters only in non-void functions, and void function will + * just silently return early on invalid parameters, which + * partially negates the benefits of enabling + * #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged. + * + * \param cond The expression that should evaluate to true, but doesn't. + */ +//#define MBEDTLS_PARAM_FAILED( cond ) assert( cond ) + /* SSL Cache options */ //#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ //#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ /* SSL options */ -//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ + +/** \def MBEDTLS_SSL_MAX_CONTENT_LEN + * + * Maximum length (in bytes) of incoming and outgoing plaintext fragments. + * + * This determines the size of both the incoming and outgoing TLS I/O buffers + * in such a way that both are capable of holding the specified amount of + * plaintext data, regardless of the protection mechanism used. + * + * To configure incoming and outgoing I/O buffers separately, use + * #MBEDTLS_SSL_IN_CONTENT_LEN and #MBEDTLS_SSL_OUT_CONTENT_LEN, + * which overwrite the value set by this option. + * + * \note When using a value less than the default of 16KB on the client, it is + * recommended to use the Maximum Fragment Length (MFL) extension to + * inform the server about this limitation. On the server, there + * is no supported, standardized way of informing the client about + * restriction on the maximum size of incoming messages, and unless + * the limitation has been communicated by other means, it is recommended + * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN + * while keeping the default value of 16KB for the incoming buffer. + * + * Uncomment to set the maximum plaintext size of both + * incoming and outgoing I/O buffers. + */ +//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 + +/** \def MBEDTLS_SSL_IN_CONTENT_LEN + * + * Maximum length (in bytes) of incoming plaintext fragments. + * + * This determines the size of the incoming TLS I/O buffer in such a way + * that it is capable of holding the specified amount of plaintext data, + * regardless of the protection mechanism used. + * + * If this option is undefined, it inherits its value from + * #MBEDTLS_SSL_MAX_CONTENT_LEN. + * + * \note When using a value less than the default of 16KB on the client, it is + * recommended to use the Maximum Fragment Length (MFL) extension to + * inform the server about this limitation. On the server, there + * is no supported, standardized way of informing the client about + * restriction on the maximum size of incoming messages, and unless + * the limitation has been communicated by other means, it is recommended + * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN + * while keeping the default value of 16KB for the incoming buffer. + * + * Uncomment to set the maximum plaintext size of the incoming I/O buffer + * independently of the outgoing I/O buffer. + */ +//#define MBEDTLS_SSL_IN_CONTENT_LEN 16384 + +/** \def MBEDTLS_SSL_OUT_CONTENT_LEN + * + * Maximum length (in bytes) of outgoing plaintext fragments. + * + * This determines the size of the outgoing TLS I/O buffer in such a way + * that it is capable of holding the specified amount of plaintext data, + * regardless of the protection mechanism used. + * + * If this option undefined, it inherits its value from + * #MBEDTLS_SSL_MAX_CONTENT_LEN. + * + * It is possible to save RAM by setting a smaller outward buffer, while keeping + * the default inward 16384 byte buffer to conform to the TLS specification. + * + * The minimum required outward buffer size is determined by the handshake + * protocol's usage. Handshaking will fail if the outward buffer is too small. + * The specific size requirement depends on the configured ciphers and any + * certificate data which is sent during the handshake. + * + * Uncomment to set the maximum plaintext size of the outgoing I/O buffer + * independently of the incoming I/O buffer. + */ +//#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384 + +/** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING + * + * Maximum number of heap-allocated bytes for the purpose of + * DTLS handshake message reassembly and future message buffering. + * + * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN + * to account for a reassembled handshake message of maximum size, + * together with its reassembly bitmap. + * + * A value of 2 * MBEDTLS_SSL_IN_CONTENT_LEN (32768 by default) + * should be sufficient for all practical situations as it allows + * to reassembly a large handshake message (such as a certificate) + * while buffering multiple smaller handshake messages. + * + */ +//#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 + //#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ //#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ //#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ @@ -2874,32 +3292,60 @@ * on it, and considering stronger message digests instead. * */ -// Open Enclave: Support for backward compatibility. Still common, but -// developers should move to SHA256 -#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE +// Open Enclave: Deprecated in v0.7, developers should move to SHA256 +//#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE -/* \} name SECTION: Customisation configuration options */ +/** + * Uncomment the macro to let mbed TLS use your alternate implementation of + * mbedtls_platform_zeroize(). This replaces the default implementation in + * platform_util.c. + * + * mbedtls_platform_zeroize() is a widely used function across the library to + * zero a block of memory. The implementation is expected to be secure in the + * sense that it has been written to prevent the compiler from removing calls + * to mbedtls_platform_zeroize() as part of redundant code elimination + * optimizations. However, it is difficult to guarantee that calls to + * mbedtls_platform_zeroize() will not be optimized by the compiler as older + * versions of the C language standards do not provide a secure implementation + * of memset(). Therefore, MBEDTLS_PLATFORM_ZEROIZE_ALT enables users to + * configure their own implementation of mbedtls_platform_zeroize(), for + * example by using directives specific to their compiler, features from newer + * C standards (e.g using memset_s() in C11) or calling a secure memset() from + * their system (e.g explicit_bzero() in BSD). + */ +//#define MBEDTLS_PLATFORM_ZEROIZE_ALT -/* Target and application specific configurations */ -//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "target_config.h" +/** + * Uncomment the macro to let Mbed TLS use your alternate implementation of + * mbedtls_platform_gmtime_r(). This replaces the default implementation in + * platform_util.c. + * + * gmtime() is not a thread-safe function as defined in the C standard. The + * library will try to use safer implementations of this function, such as + * gmtime_r() when available. However, if Mbed TLS cannot identify the target + * system, the implementation of mbedtls_platform_gmtime_r() will default to + * using the standard gmtime(). In this case, calls from the library to + * gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex + * if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the + * library are also guarded with this mutex to avoid race conditions. However, + * if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will + * unconditionally use the implementation for mbedtls_platform_gmtime_r() + * supplied at compile time. + */ +//#define MBEDTLS_PLATFORM_GMTIME_R_ALT -#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE) -#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE -#endif +/* \} name SECTION: Customisation configuration options */ -/* +/* Target and application specific configurations + * * Allow user to override any previous default. * - * Use two macro names for that, as: - * - with yotta the prefix YOTTA_CFG_ is forced - * - without yotta is looks weird to have a YOTTA prefix. */ -#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) -#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE -#elif defined(MBEDTLS_USER_CONFIG_FILE) +#if defined(MBEDTLS_USER_CONFIG_FILE) #include MBEDTLS_USER_CONFIG_FILE #endif +// Open Enclave: Update path relative to source tree #include #endif /* MBEDTLS_CONFIG_H */ diff --git a/3rdparty/mbedtls/mbedtls/.globalrc b/3rdparty/mbedtls/mbedtls/.globalrc new file mode 100644 index 0000000000..01b2ea5a31 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/.globalrc @@ -0,0 +1,3 @@ +default:\ + :langmap=c\:.c.h.function:\ + diff --git a/3rdparty/mbedtls/mbedtls/.pylintrc b/3rdparty/mbedtls/mbedtls/.pylintrc new file mode 100644 index 0000000000..168e0b7590 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/.pylintrc @@ -0,0 +1,52 @@ +[BASIC] +# We're ok with short funtion argument names. +# [invalid-name] +argument-rgx=[a-z_][a-z0-9_]*$ + +# Allow filter and map. +# [bad-builtin] +bad-functions=input + +# We prefer docstrings, but we don't require them on all functions. +# Require them only on long functions (for some value of long). +# [missing-docstring] +docstring-min-length=10 + +# Allow longer methods than the default. +# [invalid-name] +method-rgx=[a-z_][a-z0-9_]{2,35}$ + +# Allow module names containing a dash (but no underscore or uppercase letter). +# They are whole programs, not meant to be included by another module. +# [invalid-name] +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|[a-z][-0-9a-z]+)$ + +# Some functions don't need docstrings. +# [missing-docstring] +no-docstring-rgx=(run_)main$ + +# We're ok with short local or global variable names. +# [invalid-name] +variable-rgx=[a-z_][a-z0-9_]*$ + +[DESIGN] +# Allow more than the default 7 attributes. +# [too-many-instance-attributes] +max-attributes=15 + +[FORMAT] +# Allow longer modules than the default recommended maximum. +# [too-many-lines] +max-module-lines=2000 + +[MESSAGES CONTROL] +disable= + +[REPORTS] +# Don't diplay statistics. Just the facts. +reports=no + +[VARIABLES] +# Allow unused variables if their name starts with an underscore. +# [unused-argument] +dummy-variables-rgx=_.* diff --git a/3rdparty/mbedtls/mbedtls/.travis.yml b/3rdparty/mbedtls/mbedtls/.travis.yml index 4d23652c67..c45d4081d0 100644 --- a/3rdparty/mbedtls/mbedtls/.travis.yml +++ b/3rdparty/mbedtls/mbedtls/.travis.yml @@ -4,6 +4,13 @@ compiler: - gcc sudo: false cache: ccache + +# blocklist +branches: + except: + - development-psa + - coverity_scan + script: - tests/scripts/recursion.pl library/*.c - tests/scripts/check-generated-files.sh @@ -24,7 +31,8 @@ after_failure: - tests/scripts/travis-log-failure.sh env: global: - secure: "barHldniAfXyoWOD/vcO+E6/Xm4fmcaUoC9BeKW+LwsHqlDMLvugaJnmLXkSpkbYhVL61Hzf3bo0KPJn88AFc5Rkf8oYHPjH4adMnVXkf3B9ghHCgznqHsAH3choo6tnPxaFgOwOYmLGb382nQxfE5lUdvnM/W/psQjWt66A1+k=" + - SEED=1 + - secure: "barHldniAfXyoWOD/vcO+E6/Xm4fmcaUoC9BeKW+LwsHqlDMLvugaJnmLXkSpkbYhVL61Hzf3bo0KPJn88AFc5Rkf8oYHPjH4adMnVXkf3B9ghHCgznqHsAH3choo6tnPxaFgOwOYmLGb382nQxfE5lUdvnM/W/psQjWt66A1+k=" addons: apt: @@ -34,7 +42,7 @@ addons: coverity_scan: project: name: "ARMmbed/mbedtls" - notification_email: p.j.bakker@polarssl.org + notification_email: simon.butcher@arm.com build_command_prepend: build_command: make branch_pattern: coverity_scan diff --git a/3rdparty/mbedtls/mbedtls/CMakeLists.txt b/3rdparty/mbedtls/mbedtls/CMakeLists.txt index 0ade1d4cb8..5f7d0d8862 100644 --- a/3rdparty/mbedtls/mbedtls/CMakeLists.txt +++ b/3rdparty/mbedtls/mbedtls/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 2.6) -project("mbed TLS" C) +if(TEST_CPP) + project("mbed TLS" C CXX) +else() + project("mbed TLS" C) +endif() option(USE_PKCS11_HELPER_LIBRARY "Build mbed TLS with the pkcs11-helper library." OFF) option(ENABLE_ZLIB_SUPPORT "Build mbed TLS with zlib library." OFF) @@ -32,9 +36,27 @@ set(NULL_ENTROPY_WARNING "${WARNING_BORDER}" "${NULL_ENTROPY_WARN_L3}" "${WARNING_BORDER}") +set(CTR_DRBG_128_BIT_KEY_WARN_L1 "**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined!\n") +set(CTR_DRBG_128_BIT_KEY_WARN_L2 "**** Using 128-bit keys for CTR_DRBG limits the security of generated\n") +set(CTR_DRBG_128_BIT_KEY_WARN_L3 "**** keys and operations that use random values generated to 128-bit security\n") + +set(CTR_DRBG_128_BIT_KEY_WARNING "${WARNING_BORDER}" + "${CTR_DRBG_128_BIT_KEY_WARN_L1}" + "${CTR_DRBG_128_BIT_KEY_WARN_L2}" + "${CTR_DRBG_128_BIT_KEY_WARN_L3}" + "${WARNING_BORDER}") + +find_package(PythonInterp) find_package(Perl) if(PERL_FOUND) + # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning + execute_process(COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/config.pl -f ${CMAKE_CURRENT_SOURCE_DIR}/include/mbedtls/config.h get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY + RESULT_VARIABLE result) + if(${result} EQUAL 0) + message(WARNING ${CTR_DRBG_128_BIT_KEY_WARNING}) + endif() + # If NULL Entropy is configured, display an appropriate warning execute_process(COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/config.pl -f ${CMAKE_CURRENT_SOURCE_DIR}/include/mbedtls/config.h get MBEDTLS_TEST_NULL_ENTROPY RESULT_VARIABLE result) @@ -65,8 +87,14 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} # to the corresponding path in the source directory. function(link_to_source base_name) # Get OS dependent path to use in `execute_process` - file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${base_name}" link) - file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}" target) + if (CMAKE_HOST_WIN32) + #mklink is an internal command of cmd.exe it can only work with \ + string(REPLACE "/" "\\" link "${CMAKE_CURRENT_BINARY_DIR}/${base_name}") + string(REPLACE "/" "\\" target "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}") + else() + set(link "${CMAKE_CURRENT_BINARY_DIR}/${base_name}") + set(target "${CMAKE_CURRENT_SOURCE_DIR}/${base_name}") + endif() if (NOT EXISTS ${link}) if (CMAKE_HOST_UNIX) @@ -200,13 +228,13 @@ if(ENABLE_TESTING) COMMAND mv DartConfiguration.tcl.bak DartConfiguration.tcl ) endif(UNIX) -endif() -# Make scripts needed for testing available in an out-of-source build. -if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) - link_to_source(scripts) - # Copy (don't link) DartConfiguration.tcl, needed for memcheck, to - # keep things simple with the sed commands in the memcheck target. - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DartConfiguration.tcl - ${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl COPYONLY) + # Make scripts needed for testing available in an out-of-source build. + if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) + link_to_source(scripts) + # Copy (don't link) DartConfiguration.tcl, needed for memcheck, to + # keep things simple with the sed commands in the memcheck target. + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DartConfiguration.tcl + ${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl COPYONLY) + endif() endif() diff --git a/3rdparty/mbedtls/mbedtls/CONTRIBUTING.md b/3rdparty/mbedtls/mbedtls/CONTRIBUTING.md new file mode 100644 index 0000000000..010dffc638 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/CONTRIBUTING.md @@ -0,0 +1,95 @@ +Contributing +============ +We gratefully accept bug reports and contributions from the community. There are some requirements we need to fulfill in order to be able to integrate contributions: + + - As with any open source project, contributions will be reviewed by the project team and community and may need some modifications to be accepted. + - The contribution should not break API or ABI, unless there is a real justification for that. If there is an API change, the contribution, if accepted, will be merged only when there will be a major release. + +Contributor License Agreement (CLA) +----------------------------------- +- All contributions, whether large or small, require a Contributor's License Agreement (CLA) to be accepted. This is because source code can possibly fall under copyright law and we need your consent to share in the ownership of the copyright. +- To accept the Contributor’s License Agreement (CLA), individual contributors can do this by creating an Mbed account and [accepting the online agreement here with a click through](https://developer.mbed.org/contributor_agreement/). Alternatively, for contributions from corporations, or those that do not wish to create an Mbed account, a slightly different agreement can be found [here](https://www.mbed.com/en/about-mbed/contributor-license-agreements/). This agreement should be signed and returned to Arm as described in the instructions given. + +Coding Standards +---------------- +- We would ask that contributions conform to [our coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards), and that contributions are fully tested before submission, as mentioned in the [Tests](#tests) and [Continuous Integration](#continuous-integration-tests) sections. +- The code should be written in a clean and readable style. +- The code should be written in a portable generic way, that will benefit the whole community, and not only your own needs. +- The code should be secure, and will be reviewed from a security point of view as well. + +Making a Contribution +--------------------- +1. [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug. +1. Fork the [Mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the ["development" branch](https://github.com/ARMmbed/mbedtls/tree/development) as a basis. +1. Write a test which shows that the bug was fixed or that the feature works as expected. +1. Send a pull request (PR) and work with us until it gets merged and published. Contributions may need some modifications, so a few rounds of review and fixing may be necessary. We will include your name in the ChangeLog :) +1. For quick merging, the contribution should be short, and concentrated on a single feature or topic. The larger the contribution is, the longer it would take to review it and merge it. +1. Mbed TLS is released under the Apache license, and as such, all the added files should include the Apache license header. + +API/ABI Compatibility +--------------------- +The project aims to minimise the impact on users upgrading to newer versions of the library and it should not be necessary for a user to make any changes to their own code to work with a newer version of the library. Unless the user has made an active decision to use newer features, a newer generation of the library or a change has been necessary due to a security issue or other significant software defect, no modifications to their own code should be necessary. To achieve this, API compatibility is maintained between different versions of Mbed TLS on the main development branch and in LTS (Long Term Support) branches. + +To minimise such disruption to users, where a change to the interface is required, all changes to the ABI or API, even on the main development branch where new features are added, need to be justifiable by either being a significant enhancement, new feature or bug fix which is best resolved by an interface change. + +Where changes to an existing interface are necessary, functions in the public interface which need to be changed, are marked as 'deprecated'. This is done with the preprocessor symbols `MBEDTLS_DEPRECATED_WARNING` and `MBEDTLS_DEPRECATED_REMOVED`. Then, a new function with a new name but similar if not identical behaviour to the original function containing the necessary changes should be created alongside the existing deprecated function. + +When a build is made with the deprecation preprocessor symbols defined, a compiler warning will be generated to warn a user that the function will be removed at some point in the future, notifying users that they should change from the older deprecated function to the newer function at their own convenience. + +Therefore, no changes are permitted to the definition of functions in the public interface which will change the API. Instead the interface can only be changed by its extension. As described above, if a function needs to be changed, a new function needs to be created alongside it, with a new name, and whatever change is necessary, such as a new parameter or the addition of a return value. + +Periodically, the library will remove deprecated functions from the library which will be a breaking change in the API, but such changes will be made only in a planned, structured way that gives sufficient notice to users of the library. + +Long Term Support Branches +-------------------------- +Mbed TLS maintains several LTS (Long Term Support) branches, which are maintained continuously for a given period. The LTS branches are provided to allow users of the library to have a maintained, stable version of the library which contains only security fixes and fixes for other defects, without encountering additional features or API extensions which may introduce issues or change the code size or RAM usage, which can be significant considerations on some platforms. To allow users to take advantage of the LTS branches, these branches maintain backwards compatibility for both the public API and ABI. + +When backporting to these branches please observe the following rules: + + 1. Any change to the library which changes the API or ABI cannot be backported. + + 2. All bug fixes that correct a defect that is also present in an LTS branch must be backported to that LTS branch. If a bug fix introduces a change to the API such as a new function, the fix should be reworked to avoid the API change. API changes without very strong justification are unlikely to be accepted. + + 3. If a contribution is a new feature or enhancement, no backporting is required. Exceptions to this may be addtional test cases or quality improvements such as changes to build or test scripts. + +It would be highly appreciated if contributions are backported to LTS branches in addition to the [development branch](https://github.com/ARMmbed/mbedtls/tree/development) by contributors. + +Currently maintained LTS branches are: + +1. [mbedtls-2.7](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.7) + +1. [mbedtls-2.16](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.16) + + +Tests +----- +As mentioned, tests that show the correctness of the feature or bug fix should be added to the pull request, if no such tests exist. + +Mbed TLS includes a comprehensive set of test suites in the `tests/` directory that are dynamically generated to produce the actual test source files (e.g. `test_suite_mpi.c`). These files are generated from a `function file` (e.g. `suites/test_suite_mpi.function`) and a `data file` (e.g. `suites/test_suite_mpi.data`). The function file contains the test functions. The data file contains the test cases, specified as parameters that will be passed to the test function. + +[A Knowledge Base article describing how to add additional tests is available on the Mbed TLS website](https://tls.mbed.org/kb/development/test_suites). + +A test script `tests/scripts/basic-build-test.sh` is available to show test coverage of the library. New code contributions should provide a similar level of code coverage to that which already exists for the library. + +Sample applications, if needed, should be modified as well. + +Continuous Integration Tests +---------------------------- +Once a PR has been made, the Continuous Integration (CI) tests are triggered and run. You should follow the result of the CI tests, and fix failures. + +It is advised to enable the [githooks scripts](https://github.com/ARMmbed/mbedtls/tree/development/tests/git-scripts) prior to pushing your changes, for catching some of the issues as early as possible. + +Documentation +------------- +Mbed TLS is well documented, but if you think documentation is needed, speak out! + +1. All interfaces should be documented through Doxygen. New APIs should introduce Doxygen documentation. + +2. Complex parts in the code should include comments. + +3. If needed, a Readme file is advised. + +4. If a [Knowledge Base (KB)](https://tls.mbed.org/kb) article should be added, write this as a comment in the PR description. + +5. A [ChangeLog](https://github.com/ARMmbed/mbedtls/blob/development/ChangeLog) entry should be added for this contribution. + diff --git a/3rdparty/mbedtls/mbedtls/ChangeLog b/3rdparty/mbedtls/mbedtls/ChangeLog index 661eb82510..8c1d03c0ba 100644 --- a/3rdparty/mbedtls/mbedtls/ChangeLog +++ b/3rdparty/mbedtls/mbedtls/ChangeLog @@ -1,6 +1,154 @@ mbed TLS ChangeLog (Sorted per branch, date) -= mbed TLS 2.7.9 branch released 2018-12-21 += mbed TLS 2.16.2 branch released 2019-06-11 + +Security + * Make mbedtls_ecdh_get_params return an error if the second key + belongs to a different group from the first. Before, if an application + passed keys that belonged to different group, the first key's data was + interpreted according to the second group, which could lead to either + an error or a meaningless output from mbedtls_ecdh_get_params. In the + latter case, this could expose at most 5 bits of the private key. + +Bugfix + * Server's RSA certificate in certs.c was SHA-1 signed. In the default + mbedTLS configuration only SHA-2 signed certificates are accepted. + This certificate is used in the demo server programs, which lead the + client programs to fail at the peer's certificate verification + due to an unacceptable hash signature. The certificate has been + updated to one that is SHA-256 signed. Fix contributed by + Illya Gerasymchuk. + * Fix private key DER output in the key_app_writer example. File contents + were shifted by one byte, creating an invalid ASN.1 tag. Fixed by + Christian Walther in #2239. + * Fix potential memory leak in X.509 self test. Found and fixed by + Junhwan Park, #2106. + * Reduce stack usage of hkdf tests. Fixes #2195. + * Fix 1-byte buffer overflow in mbedtls_mpi_write_string() when + used with negative inputs. Found by Guido Vranken in #2404. Credit to + OSS-Fuzz. + * Fix bugs in the AEAD test suite which would be exposed by ciphers which + either used both encrypt and decrypt key schedules, or which perform padding. + GCM and CCM were not affected. Fixed by Jack Lloyd. + * Fix incorrect default port number in ssl_mail_client example's usage. + Found and fixed by irwir. #2337 + * Add missing parentheses around parameters in the definition of the + public macro MBEDTLS_X509_ID_FLAG. This could lead to invalid evaluation + in case operators binding less strongly than subtraction were used + for the parameter. + * Add a check for MBEDTLS_X509_CRL_PARSE_C in ssl_server2, guarding the crl + sni entry parameter. Reported by inestlerode in #560. + * Add DER-encoded test CRTs to library/certs.c, allowing + the example programs ssl_server2 and ssl_client2 to be run + if MBEDTLS_FS_IO and MBEDTLS_PEM_PARSE_C are unset. Fixes #2254. + * Fix missing bounds checks in X.509 parsing functions that could + lead to successful parsing of ill-formed X.509 CRTs. Fixes #2437. + * Fix multiple X.509 functions previously returning ASN.1 low-level error + codes to always wrap these codes into X.509 high level error codes before + returning. Fixes #2431. + +Changes + * Return from various debugging routines immediately if the + provided SSL context is unset. + * Remove dead code from bignum.c in the default configuration. + Found by Coverity, reported and fixed by Peter Kolbus (Garmin). Fixes #2309. + * Add test for minimal value of MBEDTLS_MPI_WINDOW_SIZE to all.sh. + Contributed by Peter Kolbus (Garmin). + * Change wording in the `mbedtls_ssl_conf_max_frag_len()`'s documentation to + improve clarity. Fixes #2258. + * Replace multiple uses of MD2 by SHA-256 in X.509 test suite. Fixes #821. + += mbed TLS 2.16.1 branch released 2019-03-19 + +Features + * Add MBEDTLS_REMOVE_3DES_CIPHERSUITES to allow removing 3DES ciphersuites + from the default list (enabled by default). See + https://sweet32.info/SWEET32_CCS16.pdf. + +Bugfix + * Fix a compilation issue with mbedtls_ecp_restart_ctx not being defined + when MBEDTLS_ECP_ALT is defined. Reported by jwhui. Fixes #2242. + * Run the AD too long test only if MBEDTLS_CCM_ALT is not defined. + Raised as a comment in #1996. + * Reduce the stack consumption of mbedtls_mpi_fill_random() which could + previously lead to a stack overflow on constrained targets. + * Add `MBEDTLS_SELF_TEST` for the mbedtls_self_test functions + in the header files, which missed the precompilation check. #971 + * Fix clobber list in MIPS assembly for large integer multiplication. + Previously, this could lead to functionally incorrect assembly being + produced by some optimizing compilers, showing up as failures in + e.g. RSA or ECC signature operations. Reported in #1722, fix suggested + by Aurelien Jarno and submitted by Jeffrey Martin. + * Fix signed-to-unsigned integer conversion warning + in X.509 module. Fixes #2212. + * Reduce stack usage of `mpi_write_hlp()` by eliminating recursion. + Fixes #2190. + * Remove a duplicate #include in a sample program. Fixed by Masashi Honma #2326. + * Remove the mbedtls namespacing from the header file, to fix a "file not found" + build error. Fixed by Haijun Gu #2319. + * Fix returning the value 1 when mbedtls_ecdsa_genkey failed. + * Fix false failure in all.sh when backup files exist in include/mbedtls + (e.g. config.h.bak). Fixed by Peter Kolbus (Garmin) #2407. + * Ensure that unused bits are zero when writing ASN.1 bitstrings when using + mbedtls_asn1_write_bitstring(). + * Fix issue when writing the named bitstrings in KeyUsage and NsCertType + extensions in CSRs and CRTs that caused these bitstrings to not be encoded + correctly as trailing zeroes were not accounted for as unused bits in the + leading content octet. Fixes #1610. + +Changes + * Include configuration file in all header files that use configuration, + instead of relying on other header files that they include. + Inserted as an enhancement for #1371 + * Add support for alternative CSR headers, as used by Microsoft and defined + in RFC 7468. Found by Michael Ernst. Fixes #767. + * Fix configuration queries in ssl-opt.h. #2030 + * Ensure that ssl-opt.h can be run in OS X. #2029 + * Reduce the complexity of the timing tests. They were assuming more than the + underlying OS actually guarantees. + * Re-enable certain interoperability tests in ssl-opt.sh which had previously + been disabled for lack of a sufficiently recent version of GnuTLS on the CI. + * Ciphersuites based on 3DES now have the lowest priority by default when + they are enabled. + += mbed TLS 2.16.0 branch released 2018-12-21 + +Features + * Add a new config.h option of MBEDTLS_CHECK_PARAMS that enables validation + of parameters in the API. This allows detection of obvious misuses of the + API, such as passing NULL pointers. The API of existing functions hasn't + changed, but requirements on parameters have been made more explicit in + the documentation. See the corresponding API documentation for each + function to see for which parameter values it is defined. This feature is + disabled by default. See its API documentation in config.h for additional + steps you have to take when enabling it. + +API Changes + * The following functions in the random generator modules have been + deprecated and replaced as shown below. The new functions change + the return type from void to int to allow returning error codes when + using MBEDTLS__ALT for the underlying AES or message digest + primitive. Fixes #1798. + mbedtls_ctr_drbg_update() -> mbedtls_ctr_drbg_update_ret() + mbedtls_hmac_drbg_update() -> mbedtls_hmac_drbg_update_ret() + * Extend ECDH interface to enable alternative implementations. + * Deprecate error codes of the form MBEDTLS_ERR_xxx_INVALID_KEY_LENGTH for + ARIA, CAMELLIA and Blowfish. These error codes will be replaced by + the more generic per-module error codes MBEDTLS_ERR_xxx_BAD_INPUT_DATA. + * Additional parameter validation checks have been added for the following + modules - AES, ARIA, Blowfish, CAMELLIA, CCM, GCM, DHM, ECP, ECDSA, ECDH, + ECJPAKE, SHA, Chacha20 and Poly1305, cipher, pk, RSA, and MPI. + Where modules have had parameter validation added, existing parameter + checks may have changed. Some modules, such as Chacha20 had existing + parameter validation whereas other modules had little. This has now been + changed so that the same level of validation is present in all modules, and + that it is now optional with the MBEDTLS_CHECK_PARAMS flag which by default + is off. That means that checks which were previously present by default + will no longer be. + +New deprecations + * Deprecate mbedtls_ctr_drbg_update and mbedtls_hmac_drbg_update + in favor of functions that can return an error code. Bugfix * Fix for Clang, which was reporting a warning for the bignum.c inline @@ -15,10 +163,12 @@ Bugfix * Add explicit integer to enumeration type casts to example program programs/pkey/gen_key which previously led to compilation failure on some toolchains. Reported by phoenixmcallister. Fixes #2170. + * Fix double initialization of ECC hardware that made some accelerators + hang. * Clarify documentation of mbedtls_ssl_set_own_cert() regarding the absence of check for certificate/key matching. Reported by Attila Molnar, #507. -= mbed TLS 2.7.8 branch released 2018-11-30 += mbed TLS 2.14.1 branch released 2018-11-30 Security * Fix timing variations and memory access variations in RSA PKCS#1 v1.5 @@ -47,7 +197,7 @@ API Changes report errors whereas the old functions return void. We recommend that applications use the new functions. -= mbed TLS 2.7.7 branch released 2018-11-19 += mbed TLS 2.14.0 branch released 2018-11-19 Security * Fix overly strict DN comparison when looking for CRLs belonging to a @@ -60,7 +210,7 @@ Security incoming message buffer was placed within the first 64KiB of address space and a PSK-(EC)DHE ciphersuite was used, this allowed an attacker to trigger a memory access up to 64KiB beyond the incoming message buffer, - potentially leading to application crash or information disclosure. + potentially leading to an application crash or information disclosure. * Fix mbedtls_mpi_is_prime() to use more rounds of probabilistic testing. The previous settings for the number of rounds made it practical for an adversary to construct non-primes that would be erroneously accepted as @@ -73,31 +223,79 @@ Security See "Prime and Prejudice" by by Martin R. Albrecht and Jake Massimo and Kenneth G. Paterson and Juraj Somorovsky. +Features + * Add support for temporarily suspending expensive ECC computations after + some configurable amount of operations. This is intended to be used in + constrained, single-threaded systems where ECC is time consuming and can + block other operations until they complete. This is disabled by default, + but can be enabled by MBEDTLS_ECP_RESTARTABLE at compile time and + configured by mbedtls_ecp_set_max_ops() at runtime. It applies to the new + xxx_restartable functions in ECP, ECDSA, PK and X.509 (CRL not supported + yet), and to existing functions in ECDH and SSL (currently only + implemented client-side, for ECDHE-ECDSA ciphersuites in TLS 1.2, + including client authentication). + * Add support for Arm CPU DSP extensions to accelerate asymmetric key + operations. On CPUs where the extensions are available, they can accelerate + MPI multiplications used in ECC and RSA cryptography. Contributed by + Aurelien Jarno. + * Extend RSASSA-PSS signature to allow a smaller salt size. Previously, PSS + signature always used a salt with the same length as the hash, and returned + an error if this was not possible. Now the salt size may be up to two bytes + shorter. This allows the library to support all hash and signature sizes + that comply with FIPS 186-4, including SHA-512 with a 1024-bit key. + * Add support for 128-bit keys in CTR_DRBG. Note that using keys shorter + than 256 bits limits the security of generated material to 128 bits. + +API Changes + * Add a common error code of `MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED` for + a feature that is not supported by underlying alternative + implementations implementing cryptographic primitives. This is useful for + hardware accelerators that don't implement all options or features. + +New deprecations + * All module specific errors following the form + MBEDTLS_ERR_XXX_FEATURE_UNAVAILABLE that indicate a feature is not + supported are deprecated and are now replaced by the new equivalent + platform error. + * All module specific generic hardware acceleration errors following the + form MBEDTLS_ERR_XXX_HW_ACCEL_FAILED that are deprecated and are replaced + by the equivalent plaform error. + * Deprecate the function mbedtls_mpi_is_prime() in favor of + mbedtls_mpi_is_prime_ext() which allows specifying the number of + Miller-Rabin rounds. + Bugfix - * Fix failure in hmac_drbg in the benchmark sample application, when - MBEDTLS_THREADING_C is defined. Found by TrinityTonic, #1095 - * Fix a bug in the update function for SSL ticket keys which previously - invalidated keys of a lifetime of less than a 1s. Fixes #1968. - * Fix a bug in the record decryption routine ssl_decrypt_buf() - which led to accepting properly authenticated but improperly - padded records in case of CBC ciphersuites using Encrypt-then-MAC. * Fix wrong order of freeing in programs/ssl/ssl_server2 example application leading to a memory leak in case both MBEDTLS_MEMORY_BUFFER_ALLOC_C and MBEDTLS_MEMORY_BACKTRACE are set. Fixes #2069. + * Fix a bug in the update function for SSL ticket keys which previously + invalidated keys of a lifetime of less than a 1s. Fixes #1968. + * Fix failure in hmac_drbg in the benchmark sample application, when + MBEDTLS_THREADING_C is defined. Found by TrinityTonic, #1095 + * Fix a bug in the record decryption routine ssl_decrypt_buf() + which lead to accepting properly authenticated but improperly + padded records in case of CBC ciphersuites using Encrypt-then-MAC. * Fix memory leak and freeing without initialization in the example program programs/x509/cert_write. Fixes #1422. * Ignore IV in mbedtls_cipher_set_iv() when the cipher mode is - MBEDTLS_MODE_ECB. Found by ezdevelop. Fixes for #1091. - * Zeroize memory used for reassembling handshake messages after use. - * Use `mbedtls_zeroize()` instead of `memset()` for zeroization of - sensitive data in the example programs aescrypt2 and crypt_and_hash. + MBEDTLS_MODE_ECB. Found by ezdevelop. Fixes #1091. + * Zeroize memory used for buffering or reassembling handshake messages + after use. + * Use `mbedtls_platform_zeroize()` instead of `memset()` for zeroization + of sensitive data in the example programs aescrypt2 and crypt_and_hash. + * Change the default string format used for various X.509 DN attributes to + UTF8String. Previously, the use of the PrintableString format led to + wildcards and non-ASCII characters being unusable in some DN attributes. + Reported by raprepo in #1860 and by kevinpt in #468. Fix contributed by + Thomas-Dee. * Fix compilation failure for configurations which use compile time replacements of standard calloc/free functions through the macros MBEDTLS_PLATFORM_CALLOC_MACRO and MBEDTLS_PLATFORM_FREE_MACRO. Reported by ole-de and ddhome2006. Fixes #882, #1642 and #1706. Changes + * Removed support for Yotta as a build tool. * Add tests for session resumption in DTLS. * Close a test gap in (D)TLS between the client side and the server side: test the handling of large packets and small packets on the client side @@ -107,10 +305,35 @@ Changes * Change the use of Windows threading to use Microsoft Visual C++ runtime calls, rather than Win32 API calls directly. This is necessary to avoid conflict with C runtime usage. Found and fixed by irwir. + * Remember the string format of X.509 DN attributes when replicating + X.509 DNs. Previously, DN attributes were always written in their default + string format (mostly PrintableString), which could lead to CRTs being + created which used PrintableStrings in the issuer field even though the + signing CA used UTF8Strings in its subject field; while X.509 compliant, + such CRTs were rejected in some applications, e.g. some versions of + Firefox, curl and GnuTLS. Reported in #1033 by Moschn. Fix contributed by + Thomas-Dee. * Improve documentation of mbedtls_ssl_get_verify_result(). Fixes #517 reported by github-monoculture. + * Add MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR flag to mbedtls_mpi_gen_prime() and + use it to reduce error probability in RSA key generation to levels mandated + by FIPS-186-4. -= mbed TLS 2.7.6 branch released 2018-08-31 += mbed TLS 2.13.1 branch released 2018-09-06 + +API Changes + * Extend the platform module with an abstraction mbedtls_platform_gmtime_r() + whose implementation should behave as a thread-safe version of gmtime(). + This allows users to configure such an implementation at compile time when + the target system cannot be deduced automatically, by setting the option + MBEDTLS_PLATFORM_GMTIME_R_ALT. At this stage Mbed TLS is only able to + automatically select implementations for Windows and POSIX C libraries. + +Bugfix + * Fix build failures on platforms where only gmtime() is available but + neither gmtime_r() nor gmtime_s() are present. Fixes #1907. + += mbed TLS 2.13.0 branch released 2018-08-31 Security * Fix an issue in the X.509 module which could lead to a buffer overread @@ -118,35 +341,66 @@ Security input (extensions length field equal to 0), an illegal read of one byte beyond the input buffer is made. Found and analyzed by Nathan Crandall. +Features + * Add support for fragmentation of outgoing DTLS handshake messages. This + is controlled by the maximum fragment length as set locally or negotiated + with the peer, as well as by a new per-connection MTU option, set using + mbedtls_ssl_set_mtu(). + * Add support for auto-adjustment of MTU to a safe value during the + handshake when flights do not get through (RFC 6347, section 4.1.1.1, + last paragraph). + * Add support for packing multiple records within a single datagram, + enabled by default. + * Add support for buffering out-of-order handshake messages in DTLS. + The maximum amount of RAM used for this can be controlled by the + compile-time constant MBEDTLS_SSL_DTLS_MAX_BUFFERING defined + in mbedtls/config.h. + +API Changes + * Add function mbedtls_ssl_set_datagram_packing() to configure + the use of datagram packing (enabled by default). + Bugfix * Fix a potential memory leak in mbedtls_ssl_setup() function. An allocation failure in the function could lead to other buffers being leaked. - * Fixes a missing test dependency on MBEDTLS_ARC4_C. #1890 + * Fixes an issue with MBEDTLS_CHACHAPOLY_C which would not compile if + MBEDTLS_ARC4_C and MBEDTLS_CIPHER_NULL_CIPHER weren't also defined. #1890 * Fix a memory leak in ecp_mul_comb() if ecp_precompute_comb() fails. Fix contributed by Espressif Systems. * Add ecc extensions only if an ecc based ciphersuite is used. This improves compliance to RFC 4492, and as a result, solves interoperability issues with BouncyCastle. Raised by milenamil in #1157. + * Replace printf with mbedtls_printf in the ARIA module. Found by + TrinityTonic in #1908. * Fix potential use-after-free in mbedtls_ssl_get_max_frag_len() and mbedtls_ssl_get_record_expansion() after a session reset. Fixes #1941. - * Fix a miscalculation of the maximum record expansion in - mbedtls_ssl_get_record_expansion() in case of CBC ciphersuites - in (D)TLS versions 1.1 or higher. Fixes #1914. * Fix a bug that caused SSL/TLS clients to incorrectly abort the handshake with TLS versions 1.1 and earlier when the server requested authentication without providing a list of CAs. This was due to an overly strict bounds - check in parsing the CertificateRequest message, introduced in - Mbed TLS 2.12.0. Fixes #1954. + check in parsing the CertificateRequest message, + introduced in Mbed TLS 2.12.0. Fixes #1954. + * Fix a miscalculation of the maximum record expansion in + mbedtls_ssl_get_record_expansion() in case of ChachaPoly ciphersuites, + or CBC ciphersuites in (D)TLS versions 1.1 or higher. Fixes #1913, #1914. * Fix undefined shifts with negative values in certificates parsing (found by Catena cyber using oss-fuzz) * Fix memory leak and free without initialization in pk_encrypt and pk_decrypt example programs. Reported by Brace Stout. Fixes #1128. + * Remove redundant else statement. Raised by irwir. Fixes #1776. Changes + * Copy headers preserving timestamps when doing a "make install". + Contributed by xueruini. + * Allow the forward declaration of public structs. Contributed by Dawid + Drozd. Fixes #1215 raised by randombit. * Improve compatibility with some alternative CCM implementations by using CCM test vectors from RAM. + * Add support for buffering of out-of-order handshake messages. + * Add warnings to the documentation of the HKDF module to reduce the risk + of misusing the mbedtls_hkdf_extract() and mbedtls_hkdf_expand() + functions. Fixes #1775. Reported by Brian J. Murray. -= mbed TLS 2.7.5 branch released 2018-07-25 += mbed TLS 2.12.0 branch released 2018-07-25 Security * Fix a vulnerability in TLS ciphersuites based on CBC and using SHA-384, @@ -181,23 +435,40 @@ Security Encrypt-then-Mac (RFC 7366) were not affected. Found by Kenny Paterson, Eyal Ronen and Adi Shamir. +Features + * Add new crypto primitives from RFC 7539: stream cipher Chacha20, one-time + authenticator Poly1305 and AEAD construct Chacha20-Poly1305. Contributed + by Daniel King. + * Add support for CHACHA20-POLY1305 ciphersuites from RFC 7905. + * Add platform support for the Haiku OS. (https://www.haiku-os.org). + Contributed by Augustin Cavalier. + * Make the receive and transmit buffers independent sizes, for situations + where the outgoing buffer can be fixed at a smaller size than the incoming + buffer, which can save some RAM. If buffer lengths are kept equal, there + is no functional difference. Contributed by Angus Gratton, and also + independently contributed again by Paul Sokolovsky. + * Add support for key wrapping modes based on AES as defined by + NIST SP 800-38F algorithms KW and KWP and by RFC 3394 and RFC 5649. + Bugfix + * Fix the key_app_writer example which was writing a leading zero byte which + was creating an invalid ASN.1 tag. Found by Aryeh R. Fixes #1257. * Fix compilation error on C++, because of a variable named new. Found and fixed by Hirotaka Niisato in #1783. - * Fix the inline assembly for the MPI multiply helper function for i386 and - i386 with SSE2. Found by László Langó. Fixes #1550 - * Fix a memory leak in mbedtls_x509_csr_parse(), found by catenacyber, - Philippe Antoine. Fixes #1623. + * Fix "no symbols" warning issued by ranlib when building on Mac OS X. Fix + contributed by tabascoeye. * Clarify documentation for mbedtls_ssl_write() to include 0 as a valid return value. Found by @davidwu2000. #839 - * Fix the key_app_writer example which was writing a leading zero byte which - was creating an invalid ASN.1 tag. Found by Aryeh R. Fixes #1257. + * Fix a memory leak in mbedtls_x509_csr_parse(), found by catenacyber, + Philippe Antoine. Fixes #1623. * Remove unused headers included in x509.c. Found by Chris Hanson and fixed by Brendan Shanks. Part of a fix for #992. * Fix compilation error when MBEDTLS_ARC4_C is disabled and MBEDTLS_CIPHER_NULL_CIPHER is enabled. Found by TrinityTonic in #1719. * Added length checks to some TLS parsing functions. Found and fixed by Philippe Antoine from Catena cyber. #1663. + * Fix the inline assembly for the MPI multiply helper function for i386 and + i386 with SSE2. Found by László Langó. Fixes #1550 * Fix namespacing in header files. Remove the `mbedtls` namespacing in the `#include` in the header files. Resolves #857 * Fix compiler warning of 'use before initialisation' in @@ -214,34 +485,76 @@ Bugfix Fixes #1833. * Correct the documentation for `mbedtls_ssl_get_session()`. This API has deep copy of the session, and the peer certificate is not lost. Fixes #926. + * Fix build using -std=c99. Fixed by Nick Wilson. Changes * Fail when receiving a TLS alert message with an invalid length, or invalid zero-length messages when using TLS 1.2. Contributed by Espressif Systems. + * Change the default behaviour of mbedtls_hkdf_extract() to return an error + when calling with a NULL salt and non-zero salt_len. Contributed by + Brian J Murray * Change the shebang line in Perl scripts to look up perl in the PATH. - Contributed by fbrosson in #1533. + Contributed by fbrosson. + * Allow overriding the time on Windows via the platform-time abstraction. + Fixed by Nick Wilson. + * Use gmtime_r/gmtime_s for thread-safety. Fixed by Nick Wilson. -= mbed TLS 2.7.4 branch released 2018-06-18 += mbed TLS 2.11.0 branch released 2018-06-18 + +Features + * Add additional block mode, OFB (Output Feedback), to the AES module and + cipher abstraction module. + * Implement the HMAC-based extract-and-expand key derivation function + (HKDF) per RFC 5869. Contributed by Thomas Fossati. + * Add support for the CCM* block cipher mode as defined in IEEE Std. 802.15.4. + * Add support for the XTS block cipher mode with AES (AES-XTS). + Contributed by Aorimn in pull request #414. + * In TLS servers, support offloading private key operations to an external + cryptoprocessor. Private key operations can be asynchronous to allow + non-blocking operation of the TLS server stack. Bugfix - * Fix redundant declaration of mbedtls_ssl_list_ciphersuites. Raised by - TrinityTonic. #1359. + * Fix the cert_write example to handle certificates signed with elliptic + curves as well as RSA. Fixes #777 found by dbedev. * Fix for redefinition of _WIN32_WINNT to avoid overriding a definition used by user applications. Found and fixed by Fabio Alessandrelli. - * Fix braces in mbedtls_memory_buffer_alloc_status(). Found by sbranden, #552. - * Fix an issue with MicroBlaze support in bn_mul.h which was causing the - build to fail. Found by zv-io. Fixes #1651. * Fix compilation warnings with IAR toolchain, on 32 bit platform. Reported by rahmanih in #683 + * Fix braces in mbedtls_memory_buffer_alloc_status(). Found by sbranden, #552. Changes - * Support TLS testing in out-of-source builds using cmake. Fixes #1193. * Changed CMake defaults for IAR to treat all compiler warnings as errors. * Changed the Clang parameters used in the CMake build files to work for versions later than 3.6. Versions of Clang earlier than this may no longer work. Fixes #1072 -= mbed TLS 2.7.3 branch released 2018-04-30 += mbed TLS 2.10.0 branch released 2018-06-06 + +Features + * Add support for ARIA cipher (RFC 5794) and associated TLS ciphersuites + (RFC 6209). Disabled by default, see MBEDTLS_ARIA_C in config.h + +API Changes + * Extend the platform module with a util component that contains + functionality shared by multiple Mbed TLS modules. At this stage + platform_util.h (and its associated platform_util.c) only contain + mbedtls_platform_zeroize(), which is a critical function from a security + point of view. mbedtls_platform_zeroize() needs to be regularly tested + against compilers to ensure that calls to it are not removed from the + output binary as part of redundant code elimination optimizations. + Therefore, mbedtls_platform_zeroize() is moved to the platform module to + facilitate testing and maintenance. + +Bugfix + * Fix an issue with MicroBlaze support in bn_mul.h which was causing the + build to fail. Found by zv-io. Fixes #1651. + +Changes + * Support TLS testing in out-of-source builds using cmake. Fixes #1193. + * Fix redundant declaration of mbedtls_ssl_list_ciphersuites. Raised by + TrinityTonic. #1359. + += mbed TLS 2.9.0 branch released 2018-04-30 Security * Fix an issue in the X.509 module which could lead to a buffer overread @@ -263,6 +576,25 @@ Security chosen by the server. This could lead to corruption of internal data structures for some configurations. +Features + * Add an option, MBEDTLS_AES_FEWER_TABLES, to dynamically compute smaller AES + tables during runtime, thereby reducing the RAM/ROM footprint by ~6KiB. + Suggested and contributed by jkivilin in pull request #394. + * Add initial support for Curve448 (RFC 7748). Only mbedtls_ecp_mul() and + ECDH primitive functions (mbedtls_ecdh_gen_public(), + mbedtls_ecdh_compute_shared()) are supported for now. Contributed by + Nicholas Wilson in pull request #348. + +API Changes + * Extend the public API with the function of mbedtls_net_poll() to allow user + applications to wait for a network context to become ready before reading + or writing. + * Add function mbedtls_ssl_check_pending() to the public API to allow + a check for whether more more data is pending to be processed in the + internal message buffers. + This function is necessary to determine when it is safe to idle on the + underlying transport in case event-driven IO is used. + Bugfix * Fix a spurious uninitialized variable warning in cmac.c. Fix independently contributed by Brian J Murray and David Brown. @@ -284,13 +616,25 @@ Bugfix Andy Leiserson. * Fix overriding and ignoring return values when parsing and writing to a file in pk_sign program. Found by kevlut in #1142. + * Restrict usage of error code MBEDTLS_ERR_SSL_WANT_READ to situations + where data needs to be fetched from the underlying transport in order + to make progress. Previously, this error code was also occasionally + returned when unexpected messages were being discarded, ignoring that + further messages could potentially already be pending to be processed + in the internal buffers; these cases led to deadlocks when event-driven + I/O was used. Found and reported by Hubert Mis in #772. * Fix buffer length assertions in the ssl_parse_certificate_request() function which leads to a potential one byte overread of the message buffer. * Fix invalid buffer sizes passed to zlib during record compression and decompression. + * Fix the soversion of libmbedcrypto to match the soversion of the + maintained 2.7 branch. The soversion was increased in Mbed TLS + version 2.7.1 to reflect breaking changes in that release, but the + increment was missed in 2.8.0 and later releases outside of the 2.7 branch. Changes + * Remove some redundant code in bignum.c. Contributed by Alexey Skalozub. * Support cmake builds where Mbed TLS is a subproject. Fix contributed independently by Matthieu Volat and Arne Schwabe. * Improve testing in configurations that omit certain hashes or @@ -299,9 +643,16 @@ Changes * Do not define global mutexes around readdir() and gmtime() in configurations where the feature is disabled. Found and fixed by Gergely Budai. + * Harden the function mbedtls_ssl_config_free() against misuse, so that it + doesn't leak memory if the user doesn't use mbedtls_ssl_conf_psk() and + instead incorrectly manipulates the configuration structure directly. + Found and fix submitted by junyeonLEE in #1220. * Provide an empty implementation of mbedtls_pkcs5_pbes2() when MBEDTLS_ASN1_PARSE_C is not enabled. This allows the use of PBKDF2 without PBES2. Fixed by Marcos Del Sol Vives. + * Add the order of the base point as N in the mbedtls_ecp_group structure + for Curve25519 (other curves had it already). Contributed by Nicholas + Wilson #481 * Improve the documentation of mbedtls_net_accept(). Contributed by Ivan Krylov. * Improve the documentation of mbedtls_ssl_write(). Suggested by @@ -311,16 +662,40 @@ Changes Alex Hixon. * Allow configuring the shared library extension by setting the DLEXT environment variable when using the project makefiles. + * Optimize unnecessary zeroing in mbedtls_mpi_copy. Based on a contribution + by Alexey Skalozub in #405. * In the SSL module, when f_send, f_recv or f_recv_timeout report transmitting more than the required length, return an error. Raised by Sam O'Connor in #1245. * Improve robustness of mbedtls_ssl_derive_keys against the use of HMAC functions with non-HMAC ciphersuites. Independently contributed by Jiayuan Chen in #1377. Fixes #1437. + * Improve security of RSA key generation by including criteria from + FIPS 186-4. Contributed by Jethro Beekman. #1380 + * Declare functions in header files even when an alternative implementation + of the corresponding module is activated by defining the corresponding + MBEDTLS_XXX_ALT macro. This means that alternative implementations do + not need to copy the declarations, and ensures that they will have the + same API. + * Add platform setup and teardown calls in test suites. -= mbed TLS 2.7.2 branch released 2018-03-16 += mbed TLS 2.8.0 branch released 2018-03-16 + +Default behavior changes + * The truncated HMAC extension now conforms to RFC 6066. This means + that when both sides of a TLS connection negotiate the truncated + HMAC extension, Mbed TLS can now interoperate with other + compliant implementations, but this breaks interoperability with + prior versions of Mbed TLS. To restore the old behavior, enable + the (deprecated) option MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT in + config.h. Found by Andreas Walz (ivESK, Offenburg University of + Applied Sciences). Security + * Fix implementation of the truncated HMAC extension. The previous + implementation allowed an offline 2^80 brute force attack on the + HMAC key of a single, uninterrupted connection (with no + resumption of the session). * Verify results of RSA private key operations to defend against Bellcore glitch attack. * Fix a buffer overread in ssl_parse_server_key_exchange() that could cause @@ -336,8 +711,21 @@ Features This allows reading encrypted PEM files produced by software that uses PBKDF2-SHA2, such as OpenSSL 1.1. Submitted by Antonio Quartulli, OpenVPN Inc. Fixes #1339 + * Add support for public keys encoded in PKCS#1 format. #1122 + +New deprecations + * Deprecate support for record compression (configuration option + MBEDTLS_ZLIB_SUPPORT). Bugfix + * Fix the name of a DHE parameter that was accidentally changed in 2.7.0. + Fixes #1358. + * Fix test_suite_pk to work on 64-bit ILP32 systems. #849 + * Fix mbedtls_x509_crt_profile_suiteb, which used to reject all certificates + with flag MBEDTLS_X509_BADCERT_BAD_PK even when the key type was correct. + In the context of SSL, this resulted in handshake failure. Reported by + daniel in the Mbed TLS forum. #1351 + * Fix Windows x64 builds with the included mbedTLS.sln file. #1347 * Fix setting version TLSv1 as minimal version, even if TLS 1 is not enabled. Set MBEDTLS_SSL_MIN_MAJOR_VERSION and MBEDTLS_SSL_MIN_MINOR_VERSION instead of @@ -361,43 +749,16 @@ Bugfix * Fix a 1-byte heap buffer overflow (read-only) during private key parsing. Found through fuzz testing. -Changes - * Clarify the documentation of mbedtls_ssl_setup. - -= mbed TLS 2.7.1 branch released 2018-02-23 - -Default behavior changes - * The truncated HMAC extension now conforms to RFC 6066. This means - that when both sides of a TLS connection negotiate the truncated - HMAC extension, Mbed TLS can now interoperate with other - compliant implementations, but this breaks interoperability with - prior versions of Mbed TLS. To restore the old behavior, enable - the (deprecated) option MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT in - config.h. Found by Andreas Walz (ivESK, Offenburg University of - Applied Sciences). - -Security - * Fix implementation of the truncated HMAC extension. The previous - implementation allowed an offline 2^80 brute force attack on the - HMAC key of a single, uninterrupted connection (with no - resumption of the session). - -Bugfix - * Fix the name of a DHE parameter that was accidentally changed in 2.7.0. - Fixes #1358. - * Fix test_suite_pk to work on 64-bit ILP32 systems. #849 - * Fix mbedtls_x509_crt_profile_suiteb, which used to reject all certificates - with flag MBEDTLS_X509_BADCERT_BAD_PK even when the key type was correct. - In the context of SSL, this resulted in handshake failure. Reported by - daniel in the Mbed TLS forum. #1351 - * Fix Windows x64 builds with the included mbedTLS.sln file. #1347 - Changes * Fix tag lengths and value ranges in the documentation of CCM encryption. Contributed by Mathieu Briand. * Fix typo in a comment ctr_drbg.c. Contributed by Paul Sokolovsky. + * Remove support for the library reference configuration for picocoin. * MD functions deprecated in 2.7.0 are no longer inline, to provide a migration path for those depending on the library's ABI. + * Clarify the documentation of mbedtls_ssl_setup. + * Use (void) when defining functions with no parameters. Contributed by + Joris Aerts. #678 = mbed TLS 2.7.0 branch released 2018-02-03 @@ -514,7 +875,7 @@ Bugfix * Fix ssl_parse_record_header() to silently discard invalid DTLS records as recommended in RFC 6347 Section 4.1.2.7. * Fix memory leak in mbedtls_ssl_set_hostname() when called multiple times. - Found by projectgus and jethrogb, #836. + Found by projectgus and Jethro Beekman, #836. * Fix usage help in ssl_server2 example. Found and fixed by Bei Lin. * Parse signature algorithm extension when renegotiating. Previously, renegotiated handshakes would only accept signatures using SHA-1 @@ -708,8 +1069,7 @@ Bugfix Previous behaviour was to keep processing data even after the alert has been sent. * Accept empty trusted CA chain in authentication mode - MBEDTLS_SSL_VERIFY_OPTIONAL. - Found by jethrogb. #864 + MBEDTLS_SSL_VERIFY_OPTIONAL. Found by Jethro Beekman. #864 * Fix implementation of mbedtls_ssl_parse_certificate() to not annihilate fatal errors in authentication mode MBEDTLS_SSL_VERIFY_OPTIONAL and to reflect bad EC curves within verification result. diff --git a/3rdparty/mbedtls/mbedtls/Makefile b/3rdparty/mbedtls/mbedtls/Makefile index a0fcb2bc56..1ae6bd9917 100644 --- a/3rdparty/mbedtls/mbedtls/Makefile +++ b/3rdparty/mbedtls/mbedtls/Makefile @@ -23,7 +23,7 @@ tests: lib ifndef WINDOWS install: no_test mkdir -p $(DESTDIR)/include/mbedtls - cp -r include/mbedtls $(DESTDIR)/include + cp -rp include/mbedtls $(DESTDIR)/include mkdir -p $(DESTDIR)/lib cp -RP library/libmbedtls.* $(DESTDIR)/lib @@ -61,9 +61,21 @@ NULL_ENTROPY_WARN_L3=**** AND IS *NOT* SUITABLE FOR PRODUCTION USE ****\n NULL_ENTROPY_WARNING=\n$(WARNING_BORDER)$(NULL_ENTROPY_WARN_L1)$(NULL_ENTROPY_WARN_L2)$(NULL_ENTROPY_WARN_L3)$(WARNING_BORDER) +WARNING_BORDER_LONG =**********************************************************************************\n +CTR_DRBG_128_BIT_KEY_WARN_L1=**** WARNING! MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined! ****\n +CTR_DRBG_128_BIT_KEY_WARN_L2=**** Using 128-bit keys for CTR_DRBG limits the security of generated ****\n +CTR_DRBG_128_BIT_KEY_WARN_L3=**** keys and operations that use random values generated to 128-bit security ****\n + +CTR_DRBG_128_BIT_KEY_WARNING=\n$(WARNING_BORDER_LONG)$(CTR_DRBG_128_BIT_KEY_WARN_L1)$(CTR_DRBG_128_BIT_KEY_WARN_L2)$(CTR_DRBG_128_BIT_KEY_WARN_L3)$(WARNING_BORDER_LONG) + # Post build steps post_build: ifndef WINDOWS + + # If 128-bit keys are configured for CTR_DRBG, display an appropriate warning + -scripts/config.pl get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \ + echo '$(CTR_DRBG_128_BIT_KEY_WARNING)' + # If NULL Entropy is configured, display an appropriate warning -scripts/config.pl get MBEDTLS_TEST_NULL_ENTROPY && ([ $$? -eq 0 ]) && \ echo '$(NULL_ENTROPY_WARNING)' @@ -108,3 +120,12 @@ apidoc: apidoc_clean: rm -rf apidoc endif + +## Editor navigation files +C_SOURCE_FILES = $(wildcard include/*/*.h library/*.[hc] programs/*/*.[hc] tests/suites/*.function) +tags: $(C_SOURCE_FILES) + ctags -o $@ $(C_SOURCE_FILES) +TAGS: $(C_SOURCE_FILES) + etags -o $@ $(C_SOURCE_FILES) +GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES) + ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc diff --git a/3rdparty/mbedtls/mbedtls/README.md b/3rdparty/mbedtls/mbedtls/README.md index ced36e1921..94ea84b9d5 100644 --- a/3rdparty/mbedtls/mbedtls/README.md +++ b/3rdparty/mbedtls/mbedtls/README.md @@ -11,47 +11,16 @@ Compiler options can be set using conventional environment variables such as `CC Compiling --------- -There are currently four active build systems used within Mbed TLS releases: +There are currently three active build systems used within Mbed TLS releases: -- yotta - GNU Make - CMake - Microsoft Visual Studio (Microsoft Visual Studio 2010 or later) The main systems used for development are CMake and GNU Make. Those systems are always complete and up-to-date. The others should reflect all changes present in the CMake and Make build system, although features may not be ported there automatically. -Yotta, as a build system, is slightly different from the other build systems: - -- it provides a minimalistic configuration file by default -- depending on the yotta target, features of Mbed OS may be used in examples and tests - The Make and CMake build systems create three libraries: libmbedcrypto, libmbedx509, and libmbedtls. Note that libmbedtls depends on libmbedx509 and libmbedcrypto, and libmbedx509 depends on libmbedcrypto. As a result, some linkers will expect flags to be in a specific order, for example the GNU linker wants `-lmbedtls -lmbedx509 -lmbedcrypto`. Also, when loading shared libraries using dlopen(), you'll need to load libmbedcrypto first, then libmbedx509, before you can load libmbedtls. -### Yotta - -[yotta](http://yottabuild.org) is a package manager and build system developed by Mbed, and is the build system of Mbed OS 16.03. To install it on your platform, please follow the yotta [installation instructions](http://docs.yottabuild.org/#installing). - -Once yotta is installed, you can use it to download the latest version of Mbed TLS from the yotta registry with: - - yotta install mbedtls - -and build it with: - - yotta build - -If, on the other hand, you already have a copy of Mbed TLS from a source other than the yotta registry, for example from cloning our GitHub repository, or from downloading a tarball of the standalone edition, then you'll first need to generate the yotta module by running: - - yotta/create-module.sh - -This should be executed from the root Mbed TLS project directory. This will create the yotta module in the `yotta/module` directory within it. You can then change to that directory and build as usual: - - cd yotta/module - yotta build - -In any case, you'll probably want to set the yotta target before building unless it has already been set globally. For more information on using yotta, please consult the [yotta documentation](http://docs.yottabuild.org/). - -For more details on the yotta/Mbed OS edition of Mbed TLS, including example programs, please consult the [Readme at the root of the yotta module](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/README.md). - ### Make We require GNU Make. To build the library and the sample programs, GNU Make and a C compiler are sufficient. Some of the more advanced build targets require some Unix/Linux tools. @@ -66,7 +35,7 @@ In order to run the tests, enter: make check -The tests need Perl to be built and run. If you don't have Perl installed, you can skip building the tests with: +The tests need Python to be built and Perl to be run. If you don't have one of them installed, you can skip building the tests with: make no_test @@ -78,11 +47,11 @@ In order to build for a Windows platform, you should use `WINDOWS_BUILD=1` if th Setting the variable `SHARED` in your environment will build shared libraries in addition to the static libraries. Setting `DEBUG` gives you a debug build. You can override `CFLAGS` and `LDFLAGS` by setting them in your environment or on the make command line; compiler warning options may be overridden separately using `WARNING_CFLAGS`. Some directory-specific options (for example, `-I` directives) are still preserved. -Please note that setting `CFLAGS` overrides its default value of `-O2` and setting `WARNING_CFLAGS` overrides its default value (starting with `-Wall -W`), so it you just want to add some warning options to the default ones, you can do so by setting `CFLAGS=-O2 -Werror` for example. Setting `WARNING_CFLAGS` is useful when you want to get rid of its default content (for example because your compiler doesn't accept `-Wall` as an option). Directory-specific options cannot be overriden from the command line. +Please note that setting `CFLAGS` overrides its default value of `-O2` and setting `WARNING_CFLAGS` overrides its default value (starting with `-Wall -W`), so if you just want to add some warning options to the default ones, you can do so by setting `CFLAGS=-O2 -Werror` for example. Setting `WARNING_CFLAGS` is useful when you want to get rid of its default content (for example because your compiler doesn't accept `-Wall` as an option). Directory-specific options cannot be overriden from the command line. Depending on your platform, you might run into some issues. Please check the Makefiles in `library/`, `programs/` and `tests/` for options to manually add or remove for specific platforms. You can also check [the Mbed TLS Knowledge Base](https://tls.mbed.org/kb) for articles on your platform or issue. -In case you find that you need to do something else as well, please let us know what, so we can add it to the [Mbed TLS knowledge base](https://tls.mbed.org/kb). +In case you find that you need to do something else as well, please let us know what, so we can add it to the [Mbed TLS Knowledge Base](https://tls.mbed.org/kb). ### CMake @@ -96,7 +65,7 @@ In order to run the tests, enter: make test -The test suites need Perl to be built. If you don't have Perl installed, you'll want to disable the test suites with: +The test suites need Python to be built and Perl to be executed. If you don't have one of these installed, you'll want to disable the test suites with: cmake -DENABLE_TESTING=Off /path/to/mbedtls_source @@ -164,17 +133,17 @@ on the build mode as seen above), it's merely prepended to it. The build files for Microsoft Visual Studio are generated for Visual Studio 2010. -The solution file `mbedTLS.sln` contains all the basic projects needed to build the library and all the programs. The files in tests are not generated and compiled, as these need a perl environment as well. However, the selftest program in `programs/test/` is still available. +The solution file `mbedTLS.sln` contains all the basic projects needed to build the library and all the programs. The files in tests are not generated and compiled, as these need Python and perl environments as well. However, the selftest program in `programs/test/` is still available. Example programs ---------------- -We've included example programs for a lot of different features and uses in `programs/`. Most programs only focus on a single feature or usage scenario, so keep that in mind when copying parts of the code. +We've included example programs for a lot of different features and uses in [`programs/`](programs/README.md). Most programs only focus on a single feature or usage scenario, so keep that in mind when copying parts of the code. Tests ----- -Mbed TLS includes an elaborate test suite in `tests/` that initially requires Perl to generate the tests files (e.g. `test\_suite\_mpi.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_mpi.function`) and a `data file` (e.g. `suites/test\_suite\_mpi.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function. +Mbed TLS includes an elaborate test suite in `tests/` that initially requires Python to generate the tests files (e.g. `test\_suite\_mpi.c`). These files are generated from a `function file` (e.g. `suites/test\_suite\_mpi.function`) and a `data file` (e.g. `suites/test\_suite\_mpi.data`). The `function file` contains the test functions. The `data file` contains the test cases, specified as parameters that will be passed to the test function. For machines with a Unix shell and OpenSSL (and optionally GnuTLS) installed, additional test scripts are available: @@ -192,7 +161,7 @@ We provide some non-standard configurations focused on specific use cases in the Porting Mbed TLS ---------------- -Mbed TLS can be ported to many different architectures, OS's and platforms. Before starting a port, you may find the following knowledge base articles useful: +Mbed TLS can be ported to many different architectures, OS's and platforms. Before starting a port, you may find the following Knowledge Base articles useful: - [Porting Mbed TLS to a new environment or OS](https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS) - [What external dependencies does Mbed TLS rely on?](https://tls.mbed.org/kb/development/what-external-dependencies-does-mbedtls-rely-on) diff --git a/3rdparty/mbedtls/mbedtls/circle.yml b/3rdparty/mbedtls/mbedtls/circle.yml deleted file mode 100644 index eaed02a815..0000000000 --- a/3rdparty/mbedtls/mbedtls/circle.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Purpose: -# - To test and prove that a new commit in the mbed TLS repository builds -# and integrates with mbed-os properly. -# AND -# - To test and prove that the current development head of mbed TLS builds -# and integrates with the current mbed-os master branch. -# -# The script fetches all the prerequisites and builds the mbed TLS 'tls-client' -# example. This script is triggered by every commit and once each night and the -# exact behaviour depends on how it was triggered: -# - If it is a nightly build then it builds the mbed TLS development head with -# mbed-os master. -# - If it was triggered by the commit, then it builds the example with mbed TLS -# at that commit and mbed-os at the commit pointed by mbed-os.lib in the -# example repository. - -test: - override: - - cd ../mbed-os-example-tls/tls-client/ && mbed compile -m K64F -t GCC_ARM -c - -dependencies: - pre: - # Install gcc-arm - - cd .. && wget "https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2" - - cd .. && tar -xvjf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 - - ln -s ../gcc-arm-none-eabi-4_9-2015q3/bin/* ../bin/ - # Install mbed-cli - - cd ../ && git clone https://github.com/ARMmbed/mbed-cli.git - - cd ../mbed-cli && sudo -H pip install -e . - # Get the sample application - - cd ../ && git clone git@github.com:ARMmbed/mbed-os-example-tls.git - # Get mbed-os - - cd ../mbed-os-example-tls/tls-client && mbed deploy - # Update mbed-os to master only if it is a nightly build - - > - if [ -n "${RUN_NIGHTLY_BUILD}" ]; then - cd ../mbed-os-example-tls/tls-client/mbed-os/ && mbed update master; - fi - # Import mbedtls current revision - - ln -s ../../../../../../../mbedtls/ ../mbed-os-example-tls/tls-client/mbed-os/features/mbedtls/importer/TARGET_IGNORE/mbedtls - - cd ../mbed-os-example-tls/tls-client/mbed-os/features/mbedtls/importer/ && make - override: - # Install the missing python packages - - cd ../mbed-os-example-tls/tls-client/mbed-os/ && sudo -H pip install -r requirements.txt diff --git a/3rdparty/mbedtls/mbedtls/configs/config-ccm-psk-tls1_2.h b/3rdparty/mbedtls/mbedtls/configs/config-ccm-psk-tls1_2.h index a783e6b73b..c9b58dd538 100644 --- a/3rdparty/mbedtls/mbedtls/configs/config-ccm-psk-tls1_2.h +++ b/3rdparty/mbedtls/mbedtls/configs/config-ccm-psk-tls1_2.h @@ -81,7 +81,7 @@ * both ends of the connection! (See comments in "mbedtls/ssl.h".) * The optimal size here depends on the typical size of records. */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 512 +#define MBEDTLS_SSL_MAX_CONTENT_LEN 1024 #include "mbedtls/check_config.h" diff --git a/3rdparty/mbedtls/mbedtls/configs/config-no-entropy.h b/3rdparty/mbedtls/mbedtls/configs/config-no-entropy.h index b4a0930b9c..7d34ad52ec 100644 --- a/3rdparty/mbedtls/mbedtls/configs/config-no-entropy.h +++ b/3rdparty/mbedtls/mbedtls/configs/config-no-entropy.h @@ -82,6 +82,7 @@ #define MBEDTLS_X509_USE_C #define MBEDTLS_X509_CRT_PARSE_C #define MBEDTLS_X509_CRL_PARSE_C +//#define MBEDTLS_CMAC_C /* Miscellaneous options */ #define MBEDTLS_AES_ROM_TABLES diff --git a/3rdparty/mbedtls/mbedtls/configs/config-picocoin.h b/3rdparty/mbedtls/mbedtls/configs/config-picocoin.h deleted file mode 100644 index 5d41f282f1..0000000000 --- a/3rdparty/mbedtls/mbedtls/configs/config-picocoin.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * \file config-picocoin.h - * - * \brief Reduced configuration used by Picocoin. - */ -/* - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ -/* - * Reduced configuration used by Picocoin. - * - * See README.txt for usage instructions. - * - * Distinguishing features: - * - no SSL/TLS; - * - no X.509; - * - ECDSA/PK and some other chosen crypto bits. - */ - -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -/* System support */ -#define MBEDTLS_HAVE_ASM -#define MBEDTLS_HAVE_TIME - -/* mbed TLS feature support */ -#define MBEDTLS_CIPHER_MODE_CBC -#define MBEDTLS_CIPHER_PADDING_PKCS7 -#define MBEDTLS_ECP_DP_SECP256K1_ENABLED -#define MBEDTLS_ECDSA_DETERMINISTIC -#define MBEDTLS_PK_PARSE_EC_EXTENDED -#define MBEDTLS_ERROR_STRERROR_DUMMY -#define MBEDTLS_FS_IO - -/* mbed TLS modules */ -#define MBEDTLS_AESNI_C -#define MBEDTLS_AES_C -#define MBEDTLS_ASN1_PARSE_C -#define MBEDTLS_ASN1_WRITE_C -#define MBEDTLS_BASE64_C -#define MBEDTLS_BIGNUM_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_ECP_C -#define MBEDTLS_ENTROPY_C -#define MBEDTLS_HMAC_DRBG_C -#define MBEDTLS_MD_C -#define MBEDTLS_OID_C -#define MBEDTLS_PADLOCK_C -#define MBEDTLS_PK_C -#define MBEDTLS_PK_PARSE_C -#define MBEDTLS_PK_WRITE_C -#define MBEDTLS_RIPEMD160_C -#define MBEDTLS_SHA1_C -#define MBEDTLS_SHA256_C - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ diff --git a/3rdparty/mbedtls/mbedtls/doxygen/input/doc_mainpage.h b/3rdparty/mbedtls/mbedtls/doxygen/input/doc_mainpage.h index 0038615fef..3336f0fcaa 100644 --- a/3rdparty/mbedtls/mbedtls/doxygen/input/doc_mainpage.h +++ b/3rdparty/mbedtls/mbedtls/doxygen/input/doc_mainpage.h @@ -24,7 +24,7 @@ */ /** - * @mainpage mbed TLS v2.7.9 source code documentation + * @mainpage mbed TLS v2.16.2 source code documentation * * This documentation describes the internal structure of mbed TLS. It was * automatically generated from specially formatted comment blocks in diff --git a/3rdparty/mbedtls/mbedtls/doxygen/mbedtls.doxyfile b/3rdparty/mbedtls/mbedtls/doxygen/mbedtls.doxyfile index 54e446398c..40a1cabb33 100644 --- a/3rdparty/mbedtls/mbedtls/doxygen/mbedtls.doxyfile +++ b/3rdparty/mbedtls/mbedtls/doxygen/mbedtls.doxyfile @@ -28,7 +28,7 @@ DOXYFILE_ENCODING = UTF-8 # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. -PROJECT_NAME = "mbed TLS v2.7.9" +PROJECT_NAME = "mbed TLS v2.16.2" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or diff --git a/3rdparty/mbedtls/mbedtls/include/CMakeLists.txt b/3rdparty/mbedtls/mbedtls/include/CMakeLists.txt index 1b581a54dd..c2f2bd4e6f 100644 --- a/3rdparty/mbedtls/mbedtls/include/CMakeLists.txt +++ b/3rdparty/mbedtls/mbedtls/include/CMakeLists.txt @@ -11,6 +11,6 @@ if(INSTALL_MBEDTLS_HEADERS) endif(INSTALL_MBEDTLS_HEADERS) # Make config.h available in an out-of-source build. ssl-opt.sh requires it. -if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) +if (ENABLE_TESTING AND NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) link_to_source(mbedtls) endif() diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/aes.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/aes.h index 46016dcb7f..94e7282d36 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/aes.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/aes.h @@ -1,7 +1,9 @@ /** * \file aes.h * - * \brief The Advanced Encryption Standard (AES) specifies a FIPS-approved + * \brief This file contains AES definitions and functions. + * + * The Advanced Encryption Standard (AES) specifies a FIPS-approved * cryptographic algorithm that can be used to protect electronic * data. * @@ -11,7 +13,13 @@ * ISO/IEC 18033-2:2006: Information technology -- Security * techniques -- Encryption algorithms -- Part 2: Asymmetric * ciphers. + * + * The AES-XTS block mode is standardized by NIST SP 800-38E + * + * and described in detail by IEEE P1619 + * . */ + /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 * @@ -50,8 +58,13 @@ #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ -/* Error codes in range 0x0023-0x0025 */ +/* Error codes in range 0x0021-0x0025 */ +#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021 /**< Invalid input data. */ + +/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */ #define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023 /**< Feature not available. For example, an unsupported AES key size. */ + +/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025 /**< AES hardware accelerator failed. */ #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ @@ -59,18 +72,18 @@ #define inline __inline #endif -#if !defined(MBEDTLS_AES_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_AES_ALT) +// Regular implementation +// + /** * \brief The AES context-type definition. */ -typedef struct +typedef struct mbedtls_aes_context { int nr; /*!< The number of rounds. */ uint32_t *rk; /*!< AES round keys. */ @@ -85,13 +98,30 @@ typedef struct } mbedtls_aes_context; +#if defined(MBEDTLS_CIPHER_MODE_XTS) +/** + * \brief The AES XTS context-type definition. + */ +typedef struct mbedtls_aes_xts_context +{ + mbedtls_aes_context crypt; /*!< The AES context to use for AES block + encryption or decryption. */ + mbedtls_aes_context tweak; /*!< The AES context used for tweak + computation. */ +} mbedtls_aes_xts_context; +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + +#else /* MBEDTLS_AES_ALT */ +#include "aes_alt.h" +#endif /* MBEDTLS_AES_ALT */ + /** * \brief This function initializes the specified AES context. * * It must be the first API called before using * the context. * - * \param ctx The AES context to initialize. + * \param ctx The AES context to initialize. This must not be \c NULL. */ void mbedtls_aes_init( mbedtls_aes_context *ctx ); @@ -99,21 +129,46 @@ void mbedtls_aes_init( mbedtls_aes_context *ctx ); * \brief This function releases and clears the specified AES context. * * \param ctx The AES context to clear. + * If this is \c NULL, this function does nothing. + * Otherwise, the context must have been at least initialized. */ void mbedtls_aes_free( mbedtls_aes_context *ctx ); +#if defined(MBEDTLS_CIPHER_MODE_XTS) +/** + * \brief This function initializes the specified AES XTS context. + * + * It must be the first API called before using + * the context. + * + * \param ctx The AES XTS context to initialize. This must not be \c NULL. + */ +void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx ); + +/** + * \brief This function releases and clears the specified AES XTS context. + * + * \param ctx The AES XTS context to clear. + * If this is \c NULL, this function does nothing. + * Otherwise, the context must have been at least initialized. + */ +void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ); +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + /** * \brief This function sets the encryption key. * * \param ctx The AES context to which the key should be bound. + * It must be initialized. * \param key The encryption key. + * This must be a readable buffer of size \p keybits bits. * \param keybits The size of data passed in bits. Valid options are: *
  • 128 bits
  • *
  • 192 bits
  • *
  • 256 bits
* - * \return \c 0 on success or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH - * on failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); @@ -122,17 +177,62 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, * \brief This function sets the decryption key. * * \param ctx The AES context to which the key should be bound. + * It must be initialized. * \param key The decryption key. + * This must be a readable buffer of size \p keybits bits. * \param keybits The size of data passed. Valid options are: *
  • 128 bits
  • *
  • 192 bits
  • *
  • 256 bits
* - * \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. */ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits ); +#if defined(MBEDTLS_CIPHER_MODE_XTS) +/** + * \brief This function prepares an XTS context for encryption and + * sets the encryption key. + * + * \param ctx The AES XTS context to which the key should be bound. + * It must be initialized. + * \param key The encryption key. This is comprised of the XTS key1 + * concatenated with the XTS key2. + * This must be a readable buffer of size \p keybits bits. + * \param keybits The size of \p key passed in bits. Valid options are: + *
  • 256 bits (each of key1 and key2 is a 128-bit key)
  • + *
  • 512 bits (each of key1 and key2 is a 256-bit key)
+ * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. + */ +int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, + const unsigned char *key, + unsigned int keybits ); + +/** + * \brief This function prepares an XTS context for decryption and + * sets the decryption key. + * + * \param ctx The AES XTS context to which the key should be bound. + * It must be initialized. + * \param key The decryption key. This is comprised of the XTS key1 + * concatenated with the XTS key2. + * This must be a readable buffer of size \p keybits bits. + * \param keybits The size of \p key passed in bits. Valid options are: + *
  • 256 bits (each of key1 and key2 is a 128-bit key)
  • + *
  • 512 bits (each of key1 and key2 is a 256-bit key)
+ * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_AES_INVALID_KEY_LENGTH on failure. + */ +int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, + const unsigned char *key, + unsigned int keybits ); +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + /** * \brief This function performs an AES single-block encryption or * decryption operation. @@ -146,10 +246,13 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, * call to this API with the same context. * * \param ctx The AES context to use for encryption or decryption. + * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. - * \param input The 16-Byte buffer holding the input data. - * \param output The 16-Byte buffer holding the output data. + * \param input The buffer holding the input data. + * It must be readable and at least \c 16 Bytes long. + * \param output The buffer where the output data will be written. + * It must be writeable and at least \c 16 Bytes long. * \return \c 0 on success. */ @@ -172,8 +275,8 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, * mbedtls_aes_setkey_enc() or mbedtls_aes_setkey_dec() must be called * before the first call to this API with the same context. * - * \note This function operates on aligned blocks, that is, the input size - * must be a multiple of the AES block size of 16 Bytes. + * \note This function operates on full blocks, that is, the input size + * must be a multiple of the AES block size of \c 16 Bytes. * * \note Upon exit, the content of the IV is updated so that you can * call the same function again on the next @@ -184,15 +287,20 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, * * * \param ctx The AES context to use for encryption or decryption. + * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. * \param length The length of the input data in Bytes. This must be a - * multiple of the block size (16 Bytes). + * multiple of the block size (\c 16 Bytes). * \param iv Initialization vector (updated after use). + * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. + * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. + * It must be writeable and of size \p length Bytes. * - * \return \c 0 on success, or #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH + * \return \c 0 on success. + * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH * on failure. */ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, @@ -203,6 +311,50 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) +/** + * \brief This function performs an AES-XTS encryption or decryption + * operation for an entire XTS data unit. + * + * AES-XTS encrypts or decrypts blocks based on their location as + * defined by a data unit number. The data unit number must be + * provided by \p data_unit. + * + * NIST SP 800-38E limits the maximum size of a data unit to 2^20 + * AES blocks. If the data unit is larger than this, this function + * returns #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH. + * + * \param ctx The AES XTS context to use for AES XTS operations. + * It must be initialized and bound to a key. + * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or + * #MBEDTLS_AES_DECRYPT. + * \param length The length of a data unit in Bytes. This can be any + * length between 16 bytes and 2^24 bytes inclusive + * (between 1 and 2^20 block cipher blocks). + * \param data_unit The address of the data unit encoded as an array of 16 + * bytes in little-endian format. For disk encryption, this + * is typically the index of the block device sector that + * contains the data. + * \param input The buffer holding the input data (which is an entire + * data unit). This function reads \p length Bytes from \p + * input. + * \param output The buffer holding the output data (which is an entire + * data unit). This function writes \p length Bytes to \p + * output. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH if \p length is + * smaller than an AES block in size (16 Bytes) or if \p + * length is larger than 2^20 blocks (16 MiB). + */ +int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, + int mode, + size_t length, + const unsigned char data_unit[16], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + #if defined(MBEDTLS_CIPHER_MODE_CFB) /** * \brief This function performs an AES-CFB128 encryption or decryption @@ -228,13 +380,18 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, * * * \param ctx The AES context to use for encryption or decryption. + * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT. - * \param length The length of the input data. + * \param length The length of the input data in Bytes. * \param iv_off The offset in IV (updated after use). + * It must point to a valid \c size_t. * \param iv The initialization vector (updated after use). + * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. + * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. + * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. */ @@ -269,12 +426,16 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, * * * \param ctx The AES context to use for encryption or decryption. + * It must be initialized and bound to a key. * \param mode The AES operation: #MBEDTLS_AES_ENCRYPT or * #MBEDTLS_AES_DECRYPT * \param length The length of the input data. * \param iv The initialization vector (updated after use). + * It must be a readable and writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. + * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. + * It must be writeable and of size \p length Bytes. * * \return \c 0 on success. */ @@ -286,6 +447,61 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, unsigned char *output ); #endif /*MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) +/** + * \brief This function performs an AES-OFB (Output Feedback Mode) + * encryption or decryption operation. + * + * For OFB, you must set up the context with + * mbedtls_aes_setkey_enc(), regardless of whether you are + * performing an encryption or decryption operation. This is + * because OFB mode uses the same key schedule for encryption and + * decryption. + * + * The OFB operation is identical for encryption or decryption, + * therefore no operation mode needs to be specified. + * + * \note Upon exit, the content of iv, the Initialisation Vector, is + * updated so that you can call the same function again on the next + * block(s) of data and get the same result as if it was encrypted + * in one call. This allows a "streaming" usage, by initialising + * iv_off to 0 before the first call, and preserving its value + * between calls. + * + * For non-streaming use, the iv should be initialised on each call + * to a unique value, and iv_off set to 0 on each call. + * + * If you need to retain the contents of the initialisation vector, + * you must either save it manually or use the cipher module + * instead. + * + * \warning For the OFB mode, the initialisation vector must be unique + * every encryption operation. Reuse of an initialisation vector + * will compromise security. + * + * \param ctx The AES context to use for encryption or decryption. + * It must be initialized and bound to a key. + * \param length The length of the input data. + * \param iv_off The offset in IV (updated after use). + * It must point to a valid \c size_t. + * \param iv The initialization vector (updated after use). + * It must be a readable and writeable buffer of \c 16 Bytes. + * \param input The buffer holding the input data. + * It must be readable and of size \p length Bytes. + * \param output The buffer holding the output data. + * It must be writeable and of size \p length Bytes. + * + * \return \c 0 on success. + */ +int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); + +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + #if defined(MBEDTLS_CIPHER_MODE_CTR) /** * \brief This function performs an AES-CTR encryption or decryption @@ -300,20 +516,68 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, * must use the context initialized with mbedtls_aes_setkey_enc() * for both #MBEDTLS_AES_ENCRYPT and #MBEDTLS_AES_DECRYPT. * - * \warning You must keep the maximum use of your counter in mind. + * \warning You must never reuse a nonce value with the same key. Doing so + * would void the encryption for the two messages encrypted with + * the same nonce and key. + * + * There are two common strategies for managing nonces with CTR: + * + * 1. You can handle everything as a single message processed over + * successive calls to this function. In that case, you want to + * set \p nonce_counter and \p nc_off to 0 for the first call, and + * then preserve the values of \p nonce_counter, \p nc_off and \p + * stream_block across calls to this function as they will be + * updated by this function. + * + * With this strategy, you must not encrypt more than 2**128 + * blocks of data with the same key. + * + * 2. You can encrypt separate messages by dividing the \p + * nonce_counter buffer in two areas: the first one used for a + * per-message nonce, handled by yourself, and the second one + * updated by this function internally. + * + * For example, you might reserve the first 12 bytes for the + * per-message nonce, and the last 4 bytes for internal use. In that + * case, before calling this function on a new message you need to + * set the first 12 bytes of \p nonce_counter to your chosen nonce + * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p + * stream_block to be ignored). That way, you can encrypt at most + * 2**96 messages of up to 2**32 blocks each with the same key. + * + * The per-message nonce (or information sufficient to reconstruct + * it) needs to be communicated with the ciphertext and must be unique. + * The recommended way to ensure uniqueness is to use a message + * counter. An alternative is to generate random nonces, but this + * limits the number of messages that can be securely encrypted: + * for example, with 96-bit random nonces, you should not encrypt + * more than 2**32 messages with the same key. + * + * Note that for both stategies, sizes are measured in blocks and + * that an AES block is 16 bytes. + * + * \warning Upon return, \p stream_block contains sensitive data. Its + * content must not be written to insecure storage and should be + * securely discarded as soon as it's no longer needed. * * \param ctx The AES context to use for encryption or decryption. + * It must be initialized and bound to a key. * \param length The length of the input data. * \param nc_off The offset in the current \p stream_block, for * resuming within the current cipher stream. The * offset pointer should be 0 at the start of a stream. + * It must point to a valid \c size_t. * \param nonce_counter The 128-bit nonce and counter. + * It must be a readable-writeable buffer of \c 16 Bytes. * \param stream_block The saved stream block for resuming. This is * overwritten by the function. + * It must be a readable-writeable buffer of \c 16 Bytes. * \param input The buffer holding the input data. + * It must be readable and of size \p length Bytes. * \param output The buffer holding the output data. + * It must be writeable and of size \p length Bytes. * - * \return \c 0 on success. + * \return \c 0 on success. */ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, size_t length, @@ -364,7 +628,7 @@ int mbedtls_internal_aes_decrypt( mbedtls_aes_context *ctx, * \brief Deprecated internal AES block encryption function * without return value. * - * \deprecated Superseded by mbedtls_aes_encrypt_ext() in 2.5.0. + * \deprecated Superseded by mbedtls_internal_aes_encrypt() * * \param ctx The AES context to use for encryption. * \param input Plaintext block. @@ -378,7 +642,7 @@ MBEDTLS_DEPRECATED void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, * \brief Deprecated internal AES block decryption function * without return value. * - * \deprecated Superseded by mbedtls_aes_decrypt_ext() in 2.5.0. + * \deprecated Superseded by mbedtls_internal_aes_decrypt() * * \param ctx The AES context to use for decryption. * \param input Ciphertext block. @@ -391,25 +655,18 @@ MBEDTLS_DEPRECATED void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_AES_ALT */ -#include "aes_alt.h" -#endif /* MBEDTLS_AES_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_aes_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/aesni.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/aesni.h index 746baa0e17..a4ca012f8a 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/aesni.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/aesni.h @@ -2,6 +2,9 @@ * \file aesni.h * * \brief AES-NI for hardware AES acceleration on some Intel processors + * + * \warning These functions are only for internal use by other library + * functions; you must not call them directly. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved @@ -24,6 +27,12 @@ #ifndef MBEDTLS_AESNI_H #define MBEDTLS_AESNI_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "aes.h" #define MBEDTLS_AESNI_AES 0x02000000u @@ -42,7 +51,10 @@ extern "C" { #endif /** - * \brief AES-NI features detection routine + * \brief Internal function to detect the AES-NI feature in CPUs. + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param what The feature to detect * (MBEDTLS_AESNI_AES or MBEDTLS_AESNI_CLMUL) @@ -52,7 +64,10 @@ extern "C" { int mbedtls_aesni_has_support( unsigned int what ); /** - * \brief AES-NI AES-ECB block en(de)cryption + * \brief Internal AES-NI AES-ECB block encryption and decryption + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param ctx AES context * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT @@ -62,12 +77,15 @@ int mbedtls_aesni_has_support( unsigned int what ); * \return 0 on success (cannot fail) */ int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx, - int mode, - const unsigned char input[16], - unsigned char output[16] ); + int mode, + const unsigned char input[16], + unsigned char output[16] ); /** - * \brief GCM multiplication: c = a * b in GF(2^128) + * \brief Internal GCM multiplication: c = a * b in GF(2^128) + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param c Result * \param a First operand @@ -77,21 +95,29 @@ int mbedtls_aesni_crypt_ecb( mbedtls_aes_context *ctx, * elements of GF(2^128) as per the GCM spec. */ void mbedtls_aesni_gcm_mult( unsigned char c[16], - const unsigned char a[16], - const unsigned char b[16] ); + const unsigned char a[16], + const unsigned char b[16] ); /** - * \brief Compute decryption round keys from encryption round keys + * \brief Internal round key inversion. This function computes + * decryption round keys from the encryption round keys. + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param invkey Round keys for the equivalent inverse cipher * \param fwdkey Original round keys (for encryption) * \param nr Number of rounds (that is, number of round keys minus one) */ void mbedtls_aesni_inverse_key( unsigned char *invkey, - const unsigned char *fwdkey, int nr ); + const unsigned char *fwdkey, + int nr ); /** - * \brief Perform key expansion (for encryption) + * \brief Internal key expansion for encryption + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param rk Destination buffer where the round keys are written * \param key Encryption key @@ -100,8 +126,8 @@ void mbedtls_aesni_inverse_key( unsigned char *invkey, * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH */ int mbedtls_aesni_setkey_enc( unsigned char *rk, - const unsigned char *key, - size_t bits ); + const unsigned char *key, + size_t bits ); #ifdef __cplusplus } diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/arc4.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/arc4.h index f9d93f822f..fb044d5b7f 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/arc4.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/arc4.h @@ -36,16 +36,17 @@ #include +/* MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED -0x0019 /**< ARC4 hardware accelerator failed. */ -#if !defined(MBEDTLS_ARC4_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_ARC4_ALT) +// Regular implementation +// + /** * \brief ARC4 context structure * @@ -53,7 +54,7 @@ extern "C" { * security risk. We recommend considering stronger ciphers instead. * */ -typedef struct +typedef struct mbedtls_arc4_context { int x; /*!< permutation index */ int y; /*!< permutation index */ @@ -61,6 +62,10 @@ typedef struct } mbedtls_arc4_context; +#else /* MBEDTLS_ARC4_ALT */ +#include "arc4_alt.h" +#endif /* MBEDTLS_ARC4_ALT */ + /** * \brief Initialize ARC4 context * @@ -118,17 +123,7 @@ void mbedtls_arc4_setup( mbedtls_arc4_context *ctx, const unsigned char *key, int mbedtls_arc4_crypt( mbedtls_arc4_context *ctx, size_t length, const unsigned char *input, unsigned char *output ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_ARC4_ALT */ -#include "arc4_alt.h" -#endif /* MBEDTLS_ARC4_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine @@ -142,6 +137,8 @@ extern "C" { */ int mbedtls_arc4_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/aria.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/aria.h new file mode 100644 index 0000000000..1e8956ed13 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/aria.h @@ -0,0 +1,370 @@ +/** + * \file aria.h + * + * \brief ARIA block cipher + * + * The ARIA algorithm is a symmetric block cipher that can encrypt and + * decrypt information. It is defined by the Korean Agency for + * Technology and Standards (KATS) in KS X 1213:2004 (in + * Korean, but see http://210.104.33.10/ARIA/index-e.html in English) + * and also described by the IETF in RFC 5794. + */ +/* Copyright (C) 2006-2018, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_ARIA_H +#define MBEDTLS_ARIA_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#include "platform_util.h" + +#define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */ +#define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */ + +#define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */ +#define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maxiumum number of rounds in ARIA. */ +#define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */ + +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#define MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x005C ) +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#define MBEDTLS_ERR_ARIA_BAD_INPUT_DATA -0x005C /**< Bad input data. */ + +#define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */ + +/* MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE is deprecated and should not be used. + */ +#define MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE -0x005A /**< Feature not available. For example, an unsupported ARIA key size. */ + +/* MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED is deprecated and should not be used. */ +#define MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED -0x0058 /**< ARIA hardware accelerator failed. */ + +#if !defined(MBEDTLS_ARIA_ALT) +// Regular implementation +// + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The ARIA context-type definition. + */ +typedef struct mbedtls_aria_context +{ + unsigned char nr; /*!< The number of rounds (12, 14 or 16) */ + /*! The ARIA round keys. */ + uint32_t rk[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4]; +} +mbedtls_aria_context; + +#else /* MBEDTLS_ARIA_ALT */ +#include "aria_alt.h" +#endif /* MBEDTLS_ARIA_ALT */ + +/** + * \brief This function initializes the specified ARIA context. + * + * It must be the first API called before using + * the context. + * + * \param ctx The ARIA context to initialize. This must not be \c NULL. + */ +void mbedtls_aria_init( mbedtls_aria_context *ctx ); + +/** + * \brief This function releases and clears the specified ARIA context. + * + * \param ctx The ARIA context to clear. This may be \c NULL, in which + * case this function returns immediately. If it is not \c NULL, + * it must point to an initialized ARIA context. + */ +void mbedtls_aria_free( mbedtls_aria_context *ctx ); + +/** + * \brief This function sets the encryption key. + * + * \param ctx The ARIA context to which the key should be bound. + * This must be initialized. + * \param key The encryption key. This must be a readable buffer + * of size \p keybits Bits. + * \param keybits The size of \p key in Bits. Valid options are: + *
  • 128 bits
  • + *
  • 192 bits
  • + *
  • 256 bits
+ * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, + const unsigned char *key, + unsigned int keybits ); + +/** + * \brief This function sets the decryption key. + * + * \param ctx The ARIA context to which the key should be bound. + * This must be initialized. + * \param key The decryption key. This must be a readable buffer + * of size \p keybits Bits. + * \param keybits The size of data passed. Valid options are: + *
  • 128 bits
  • + *
  • 192 bits
  • + *
  • 256 bits
+ * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx, + const unsigned char *key, + unsigned int keybits ); + +/** + * \brief This function performs an ARIA single-block encryption or + * decryption operation. + * + * It performs encryption or decryption (depending on whether + * the key was set for encryption on decryption) on the input + * data buffer defined in the \p input parameter. + * + * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or + * mbedtls_aria_setkey_dec() must be called before the first + * call to this API with the same context. + * + * \param ctx The ARIA context to use for encryption or decryption. + * This must be initialized and bound to a key. + * \param input The 16-Byte buffer holding the input data. + * \param output The 16-Byte buffer holding the output data. + + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, + const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], + unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/** + * \brief This function performs an ARIA-CBC encryption or decryption operation + * on full blocks. + * + * It performs the operation defined in the \p mode + * parameter (encrypt/decrypt), on the input data buffer defined in + * the \p input parameter. + * + * It can be called as many times as needed, until all the input + * data is processed. mbedtls_aria_init(), and either + * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called + * before the first call to this API with the same context. + * + * \note This function operates on aligned blocks, that is, the input size + * must be a multiple of the ARIA block size of 16 Bytes. + * + * \note Upon exit, the content of the IV is updated so that you can + * call the same function again on the next + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If you need to retain the contents of the IV, you should + * either save it manually or use the cipher module instead. + * + * + * \param ctx The ARIA context to use for encryption or decryption. + * This must be initialized and bound to a key. + * \param mode The mode of operation. This must be either + * #MBEDTLS_ARIA_ENCRYPT for encryption, or + * #MBEDTLS_ARIA_DECRYPT for decryption. + * \param length The length of the input data in Bytes. This must be a + * multiple of the block size (16 Bytes). + * \param iv Initialization vector (updated after use). + * This must be a readable buffer of size 16 Bytes. + * \param input The buffer holding the input data. This must + * be a readable buffer of length \p length Bytes. + * \param output The buffer holding the output data. This must + * be a writable buffer of length \p length Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx, + int mode, + size_t length, + unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/** + * \brief This function performs an ARIA-CFB128 encryption or decryption + * operation. + * + * It performs the operation defined in the \p mode + * parameter (encrypt or decrypt), on the input data buffer + * defined in the \p input parameter. + * + * For CFB, you must set up the context with mbedtls_aria_setkey_enc(), + * regardless of whether you are performing an encryption or decryption + * operation, that is, regardless of the \p mode parameter. This is + * because CFB mode uses the same key schedule for encryption and + * decryption. + * + * \note Upon exit, the content of the IV is updated so that you can + * call the same function again on the next + * block(s) of data and get the same result as if it was + * encrypted in one call. This allows a "streaming" usage. + * If you need to retain the contents of the + * IV, you must either save it manually or use the cipher + * module instead. + * + * + * \param ctx The ARIA context to use for encryption or decryption. + * This must be initialized and bound to a key. + * \param mode The mode of operation. This must be either + * #MBEDTLS_ARIA_ENCRYPT for encryption, or + * #MBEDTLS_ARIA_DECRYPT for decryption. + * \param length The length of the input data \p input in Bytes. + * \param iv_off The offset in IV (updated after use). + * This must not be larger than 15. + * \param iv The initialization vector (updated after use). + * This must be a readable buffer of size 16 Bytes. + * \param input The buffer holding the input data. This must + * be a readable buffer of length \p length Bytes. + * \param output The buffer holding the output data. This must + * be a writable buffer of length \p length Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/** + * \brief This function performs an ARIA-CTR encryption or decryption + * operation. + * + * This function performs the operation defined in the \p mode + * parameter (encrypt/decrypt), on the input data buffer + * defined in the \p input parameter. + * + * Due to the nature of CTR, you must use the same key schedule + * for both encryption and decryption operations. Therefore, you + * must use the context initialized with mbedtls_aria_setkey_enc() + * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT. + * + * \warning You must never reuse a nonce value with the same key. Doing so + * would void the encryption for the two messages encrypted with + * the same nonce and key. + * + * There are two common strategies for managing nonces with CTR: + * + * 1. You can handle everything as a single message processed over + * successive calls to this function. In that case, you want to + * set \p nonce_counter and \p nc_off to 0 for the first call, and + * then preserve the values of \p nonce_counter, \p nc_off and \p + * stream_block across calls to this function as they will be + * updated by this function. + * + * With this strategy, you must not encrypt more than 2**128 + * blocks of data with the same key. + * + * 2. You can encrypt separate messages by dividing the \p + * nonce_counter buffer in two areas: the first one used for a + * per-message nonce, handled by yourself, and the second one + * updated by this function internally. + * + * For example, you might reserve the first 12 bytes for the + * per-message nonce, and the last 4 bytes for internal use. In that + * case, before calling this function on a new message you need to + * set the first 12 bytes of \p nonce_counter to your chosen nonce + * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p + * stream_block to be ignored). That way, you can encrypt at most + * 2**96 messages of up to 2**32 blocks each with the same key. + * + * The per-message nonce (or information sufficient to reconstruct + * it) needs to be communicated with the ciphertext and must be unique. + * The recommended way to ensure uniqueness is to use a message + * counter. An alternative is to generate random nonces, but this + * limits the number of messages that can be securely encrypted: + * for example, with 96-bit random nonces, you should not encrypt + * more than 2**32 messages with the same key. + * + * Note that for both stategies, sizes are measured in blocks and + * that an ARIA block is 16 bytes. + * + * \warning Upon return, \p stream_block contains sensitive data. Its + * content must not be written to insecure storage and should be + * securely discarded as soon as it's no longer needed. + * + * \param ctx The ARIA context to use for encryption or decryption. + * This must be initialized and bound to a key. + * \param length The length of the input data \p input in Bytes. + * \param nc_off The offset in Bytes in the current \p stream_block, + * for resuming within the current cipher stream. The + * offset pointer should be \c 0 at the start of a + * stream. This must not be larger than \c 15 Bytes. + * \param nonce_counter The 128-bit nonce and counter. This must point to + * a read/write buffer of length \c 16 bytes. + * \param stream_block The saved stream block for resuming. This must + * point to a read/write buffer of length \c 16 bytes. + * This is overwritten by the function. + * \param input The buffer holding the input data. This must + * be a readable buffer of length \p length Bytes. + * \param output The buffer holding the output data. This must + * be a writable buffer of length \p length Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE], + unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief Checkup routine. + * + * \return \c 0 on success, or \c 1 on failure. + */ +int mbedtls_aria_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + +#ifdef __cplusplus +} +#endif + +#endif /* aria.h */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/asn1write.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/asn1write.h index f76fc807d0..a194243696 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/asn1write.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/asn1write.h @@ -24,193 +24,281 @@ #ifndef MBEDTLS_ASN1_WRITE_H #define MBEDTLS_ASN1_WRITE_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "asn1.h" -#define MBEDTLS_ASN1_CHK_ADD(g, f) do { if( ( ret = f ) < 0 ) return( ret ); else \ - g += ret; } while( 0 ) +#define MBEDTLS_ASN1_CHK_ADD(g, f) \ + do \ + { \ + if( ( ret = (f) ) < 0 ) \ + return( ret ); \ + else \ + (g) += ret; \ + } while( 0 ) #ifdef __cplusplus extern "C" { #endif /** - * \brief Write a length field in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a length field in ASN.1 format. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param len the length to write + * \note This function works backwards in data buffer. * - * \return the length written or a negative error code + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param len The length value to write. + * + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ -int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len ); - +int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, + size_t len ); /** - * \brief Write a ASN.1 tag in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write an ASN.1 tag in ASN.1 format. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param tag the tag to write + * \note This function works backwards in data buffer. * - * \return the length written or a negative error code + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param tag The tag to write. + * + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, - unsigned char tag ); + unsigned char tag ); /** - * \brief Write raw buffer data - * Note: function works backwards in data buffer + * \brief Write raw buffer data. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param buf data buffer to write - * \param size length of the data buffer + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param buf The data buffer to write. + * \param size The length of the data buffer. * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_raw_buffer( unsigned char **p, unsigned char *start, - const unsigned char *buf, size_t size ); + const unsigned char *buf, size_t size ); #if defined(MBEDTLS_BIGNUM_C) /** - * \brief Write a big number (MBEDTLS_ASN1_INTEGER) in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a arbitrary-precision number (#MBEDTLS_ASN1_INTEGER) + * in ASN.1 format. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param X the MPI to write + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param X The MPI to write. * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ -int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, const mbedtls_mpi *X ); +int mbedtls_asn1_write_mpi( unsigned char **p, unsigned char *start, + const mbedtls_mpi *X ); #endif /* MBEDTLS_BIGNUM_C */ /** - * \brief Write a NULL tag (MBEDTLS_ASN1_NULL) with zero data in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a NULL tag (#MBEDTLS_ASN1_NULL) with zero data + * in ASN.1 format. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) + * \note This function works backwards in data buffer. * - * \return the length written or a negative error code + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_null( unsigned char **p, unsigned char *start ); /** - * \brief Write an OID tag (MBEDTLS_ASN1_OID) and data in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write an OID tag (#MBEDTLS_ASN1_OID) and data + * in ASN.1 format. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param oid the OID to write - * \param oid_len length of the OID + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param oid The OID to write. + * \param oid_len The length of the OID. * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_oid( unsigned char **p, unsigned char *start, - const char *oid, size_t oid_len ); + const char *oid, size_t oid_len ); /** - * \brief Write an AlgorithmIdentifier sequence in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write an AlgorithmIdentifier sequence in ASN.1 format. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param oid the OID of the algorithm - * \param oid_len length of the OID - * \param par_len length of parameters, which must be already written. + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param oid The OID of the algorithm to write. + * \param oid_len The length of the algorithm's OID. + * \param par_len The length of the parameters, which must be already written. * If 0, NULL parameters are added * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ -int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start, - const char *oid, size_t oid_len, - size_t par_len ); +int mbedtls_asn1_write_algorithm_identifier( unsigned char **p, + unsigned char *start, + const char *oid, size_t oid_len, + size_t par_len ); /** - * \brief Write a boolean tag (MBEDTLS_ASN1_BOOLEAN) and value in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a boolean tag (#MBEDTLS_ASN1_BOOLEAN) and value + * in ASN.1 format. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param boolean 0 or 1 + * \note This function works backwards in data buffer. * - * \return the length written or a negative error code + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param boolean The boolean value to write, either \c 0 or \c 1. + * + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ -int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, int boolean ); +int mbedtls_asn1_write_bool( unsigned char **p, unsigned char *start, + int boolean ); /** - * \brief Write an int tag (MBEDTLS_ASN1_INTEGER) and value in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write an int tag (#MBEDTLS_ASN1_INTEGER) and value + * in ASN.1 format. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param val the integer value + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param val The integer value to write. * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ); /** - * \brief Write a printable string tag (MBEDTLS_ASN1_PRINTABLE_STRING) and - * value in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a string in ASN.1 format using a specific + * string encoding tag. + + * \note This function works backwards in data buffer. + * + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param tag The string encoding tag to write, e.g. + * #MBEDTLS_ASN1_UTF8_STRING. + * \param text The string to write. + * \param text_len The length of \p text in bytes (which might + * be strictly larger than the number of characters). + * + * \return The number of bytes written to \p p on success. + * \return A negative error code on failure. + */ +int mbedtls_asn1_write_tagged_string( unsigned char **p, unsigned char *start, + int tag, const char *text, + size_t text_len ); + +/** + * \brief Write a string in ASN.1 format using the PrintableString + * string encoding tag (#MBEDTLS_ASN1_PRINTABLE_STRING). + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param text the text to write - * \param text_len length of the text + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param text The string to write. + * \param text_len The length of \p text in bytes (which might + * be strictly larger than the number of characters). * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative error code on failure. */ -int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, - const char *text, size_t text_len ); +int mbedtls_asn1_write_printable_string( unsigned char **p, + unsigned char *start, + const char *text, size_t text_len ); /** - * \brief Write an IA5 string tag (MBEDTLS_ASN1_IA5_STRING) and - * value in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a UTF8 string in ASN.1 format using the UTF8String + * string encoding tag (#MBEDTLS_ASN1_PRINTABLE_STRING). * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param text the text to write - * \param text_len length of the text + * \note This function works backwards in data buffer. * - * \return the length written or a negative error code + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param text The string to write. + * \param text_len The length of \p text in bytes (which might + * be strictly larger than the number of characters). + * + * \return The number of bytes written to \p p on success. + * \return A negative error code on failure. + */ +int mbedtls_asn1_write_utf8_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ); + +/** + * \brief Write a string in ASN.1 format using the IA5String + * string encoding tag (#MBEDTLS_ASN1_IA5_STRING). + * + * \note This function works backwards in data buffer. + * + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param text The string to write. + * \param text_len The length of \p text in bytes (which might + * be strictly larger than the number of characters). + * + * \return The number of bytes written to \p p on success. + * \return A negative error code on failure. */ int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, - const char *text, size_t text_len ); + const char *text, size_t text_len ); /** - * \brief Write a bitstring tag (MBEDTLS_ASN1_BIT_STRING) and - * value in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write a bitstring tag (#MBEDTLS_ASN1_BIT_STRING) and + * value in ASN.1 format. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param buf the bitstring - * \param bits the total number of bits in the bitstring + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param buf The bitstring to write. + * \param bits The total number of bits in the bitstring. * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative error code on failure. */ int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start, - const unsigned char *buf, size_t bits ); + const unsigned char *buf, size_t bits ); /** - * \brief Write an octet string tag (MBEDTLS_ASN1_OCTET_STRING) and - * value in ASN.1 format - * Note: function works backwards in data buffer + * \brief Write an octet string tag (#MBEDTLS_ASN1_OCTET_STRING) + * and value in ASN.1 format. + * + * \note This function works backwards in data buffer. * - * \param p reference to current position pointer - * \param start start of the buffer (for bounds-checking) - * \param buf data buffer to write - * \param size length of the data buffer + * \param p The reference to the current position pointer. + * \param start The start of the buffer, for bounds-checking. + * \param buf The buffer holding the data to write. + * \param size The length of the data buffer \p buf. * - * \return the length written or a negative error code + * \return The number of bytes written to \p p on success. + * \return A negative error code on failure. */ int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start, - const unsigned char *buf, size_t size ); + const unsigned char *buf, size_t size ); /** * \brief Create or find a specific named_data entry for writing in a @@ -218,15 +306,16 @@ int mbedtls_asn1_write_octet_string( unsigned char **p, unsigned char *start, * a new entry is added to the head of the list. * Warning: Destructive behaviour for the val data! * - * \param list Pointer to the location of the head of the list to seek - * through (will be updated in case of a new entry) - * \param oid The OID to look for - * \param oid_len Size of the OID - * \param val Data to store (can be NULL if you want to fill it by hand) - * \param val_len Minimum length of the data buffer needed + * \param list The pointer to the location of the head of the list to seek + * through (will be updated in case of a new entry). + * \param oid The OID to look for. + * \param oid_len The size of the OID. + * \param val The data to store (can be \c NULL if you want to fill + * it by hand). + * \param val_len The minimum length of the data buffer needed. * - * \return NULL if if there was a memory allocation error, or a pointer - * to the new / existing entry. + * \return A pointer to the new / existing entry on success. + * \return \c NULL if if there was a memory allocation error. */ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data **list, const char *oid, size_t oid_len, diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/base64.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/base64.h index 7a64f52163..0d024164c5 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/base64.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/base64.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_BASE64_H #define MBEDTLS_BASE64_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include #define MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL -0x002A /**< Output buffer too small. */ @@ -75,6 +81,7 @@ int mbedtls_base64_encode( unsigned char *dst, size_t dlen, size_t *olen, int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, const unsigned char *src, size_t slen ); +#if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine * @@ -82,6 +89,8 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen, */ int mbedtls_base64_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/bignum.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/bignum.h index 3bf02a7ee1..1c8607264f 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/bignum.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/bignum.h @@ -46,7 +46,12 @@ #define MBEDTLS_ERR_MPI_NOT_ACCEPTABLE -0x000E /**< The input arguments are not acceptable. */ #define MBEDTLS_ERR_MPI_ALLOC_FAILED -0x0010 /**< Memory allocation failed. */ -#define MBEDTLS_MPI_CHK(f) do { if( ( ret = f ) != 0 ) goto cleanup; } while( 0 ) +#define MBEDTLS_MPI_CHK(f) \ + do \ + { \ + if( ( ret = (f) ) != 0 ) \ + goto cleanup; \ + } while( 0 ) /* * Maximum size MPIs are allowed to grow to in number of limbs. @@ -177,7 +182,7 @@ extern "C" { /** * \brief MPI structure */ -typedef struct +typedef struct mbedtls_mpi { int s; /*!< integer sign */ size_t n; /*!< total # of limbs */ @@ -186,90 +191,115 @@ typedef struct mbedtls_mpi; /** - * \brief Initialize one MPI (make internal references valid) - * This just makes it ready to be set or freed, + * \brief Initialize an MPI context. + * + * This makes the MPI ready to be set or freed, * but does not define a value for the MPI. * - * \param X One MPI to initialize. + * \param X The MPI context to initialize. This must not be \c NULL. */ void mbedtls_mpi_init( mbedtls_mpi *X ); /** - * \brief Unallocate one MPI + * \brief This function frees the components of an MPI context. * - * \param X One MPI to unallocate. + * \param X The MPI context to be cleared. This may be \c NULL, + * in which case this function is a no-op. If it is + * not \c NULL, it must point to an initialized MPI. */ void mbedtls_mpi_free( mbedtls_mpi *X ); /** - * \brief Enlarge to the specified number of limbs + * \brief Enlarge an MPI to the specified number of limbs. + * + * \note This function does nothing if the MPI is + * already large enough. * - * \param X MPI to grow - * \param nblimbs The target number of limbs + * \param X The MPI to grow. It must be initialized. + * \param nblimbs The target number of limbs. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs ); /** - * \brief Resize down, keeping at least the specified number of limbs + * \brief This function resizes an MPI downwards, keeping at least the + * specified number of limbs. + * + * If \c X is smaller than \c nblimbs, it is resized up + * instead. * - * \param X MPI to shrink - * \param nblimbs The minimum number of limbs to keep + * \param X The MPI to shrink. This must point to an initialized MPI. + * \param nblimbs The minimum number of limbs to keep. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * (this can only happen when resizing up). + * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs ); /** - * \brief Copy the contents of Y into X + * \brief Make a copy of an MPI. * - * \param X Destination MPI - * \param Y Source MPI + * \param X The destination MPI. This must point to an initialized MPI. + * \param Y The source MPI. This must point to an initialized MPI. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \note The limb-buffer in the destination MPI is enlarged + * if necessary to hold the value in the source MPI. + * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ); /** - * \brief Swap the contents of X and Y + * \brief Swap the contents of two MPIs. * - * \param X First MPI value - * \param Y Second MPI value + * \param X The first MPI. It must be initialized. + * \param Y The second MPI. It must be initialized. */ void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ); /** - * \brief Safe conditional assignement X = Y if assign is 1 - * - * \param X MPI to conditionally assign to - * \param Y Value to be assigned - * \param assign 1: perform the assignment, 0: keep X's original value + * \brief Perform a safe conditional copy of MPI which doesn't + * reveal whether the condition was true or not. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * \param X The MPI to conditionally assign to. This must point + * to an initialized MPI. + * \param Y The MPI to be assigned from. This must point to an + * initialized MPI. + * \param assign The condition deciding whether to perform the + * assignment or not. Possible values: + * * \c 1: Perform the assignment `X = Y`. + * * \c 0: Keep the original value of \p X. * * \note This function is equivalent to - * if( assign ) mbedtls_mpi_copy( X, Y ); + * `if( assign ) mbedtls_mpi_copy( X, Y );` * except that it avoids leaking any information about whether * the assignment was done or not (the above code may leak * information through branch prediction and/or memory access * patterns analysis). + * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned char assign ); /** - * \brief Safe conditional swap X <-> Y if swap is 1 - * - * \param X First mbedtls_mpi value - * \param Y Second mbedtls_mpi value - * \param assign 1: perform the swap, 0: keep X and Y's original values + * \brief Perform a safe conditional swap which doesn't + * reveal whether the condition was true or not. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, + * \param X The first MPI. This must be initialized. + * \param Y The second MPI. This must be initialized. + * \param assign The condition deciding whether to perform + * the swap or not. Possible values: + * * \c 1: Swap the values of \p X and \p Y. + * * \c 0: Keep the original values of \p X and \p Y. * * \note This function is equivalent to * if( assign ) mbedtls_mpi_swap( X, Y ); @@ -277,415 +307,512 @@ int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned * the assignment was done or not (the above code may leak * information through branch prediction and/or memory access * patterns analysis). + * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on other kinds of failure. + * */ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char assign ); /** - * \brief Set value from integer + * \brief Store integer value in MPI. * - * \param X MPI to set - * \param z Value to use + * \param X The MPI to set. This must be initialized. + * \param z The value to use. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ); /** - * \brief Get a specific bit from X + * \brief Get a specific bit from an MPI. * - * \param X MPI to use - * \param pos Zero-based index of the bit in X + * \param X The MPI to query. This must be initialized. + * \param pos Zero-based index of the bit to query. * - * \return Either a 0 or a 1 + * \return \c 0 or \c 1 on success, depending on whether bit \c pos + * of \c X is unset or set. + * \return A negative error code on failure. */ int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos ); /** - * \brief Set a bit of X to a specific value of 0 or 1 + * \brief Modify a specific bit in an MPI. * - * \note Will grow X if necessary to set a bit to 1 in a not yet - * existing limb. Will not grow if bit should be set to 0 + * \note This function will grow the target MPI if necessary to set a + * bit to \c 1 in a not yet existing limb. It will not grow if + * the bit should be set to \c 0. * - * \param X MPI to use - * \param pos Zero-based index of the bit in X - * \param val The value to set the bit to (0 or 1) + * \param X The MPI to modify. This must be initialized. + * \param pos Zero-based index of the bit to modify. + * \param val The desired value of bit \c pos: \c 0 or \c 1. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if val is not 0 or 1 + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on other kinds of failure. */ int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val ); /** - * \brief Return the number of zero-bits before the least significant - * '1' bit + * \brief Return the number of bits of value \c 0 before the + * least significant bit of value \c 1. * - * Note: Thus also the zero-based index of the least significant '1' bit + * \note This is the same as the zero-based index of + * the least significant bit of value \c 1. * - * \param X MPI to use + * \param X The MPI to query. + * + * \return The number of bits of value \c 0 before the least significant + * bit of value \c 1 in \p X. */ size_t mbedtls_mpi_lsb( const mbedtls_mpi *X ); /** * \brief Return the number of bits up to and including the most - * significant '1' bit' + * significant bit of value \c 1. + * + * * \note This is same as the one-based index of the most + * significant bit of value \c 1. * - * Note: Thus also the one-based index of the most significant '1' bit + * \param X The MPI to query. This must point to an initialized MPI. * - * \param X MPI to use + * \return The number of bits up to and including the most + * significant bit of value \c 1. */ size_t mbedtls_mpi_bitlen( const mbedtls_mpi *X ); /** - * \brief Return the total size in bytes + * \brief Return the total size of an MPI value in bytes. + * + * \param X The MPI to use. This must point to an initialized MPI. + * + * \note The value returned by this function may be less than + * the number of bytes used to store \p X internally. + * This happens if and only if there are trailing bytes + * of value zero. * - * \param X MPI to use + * \return The least number of bytes capable of storing + * the absolute value of \p X. */ size_t mbedtls_mpi_size( const mbedtls_mpi *X ); /** - * \brief Import from an ASCII string + * \brief Import an MPI from an ASCII string. * - * \param X Destination MPI - * \param radix Input numeric base - * \param s Null-terminated string buffer + * \param X The destination MPI. This must point to an initialized MPI. + * \param radix The numeric base of the input string. + * \param s Null-terminated string buffer. * - * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ); /** - * \brief Export into an ASCII string + * \brief Export an MPI to an ASCII string. * - * \param X Source MPI - * \param radix Output numeric base - * \param buf Buffer to write the string to - * \param buflen Length of buf - * \param olen Length of the string written, including final NUL byte + * \param X The source MPI. This must point to an initialized MPI. + * \param radix The numeric base of the output string. + * \param buf The buffer to write the string to. This must be writable + * buffer of length \p buflen Bytes. + * \param buflen The available size in Bytes of \p buf. + * \param olen The address at which to store the length of the string + * written, including the final \c NULL byte. This must + * not be \c NULL. * - * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code. - * *olen is always updated to reflect the amount - * of data that has (or would have) been written. + * \note You can call this function with `buflen == 0` to obtain the + * minimum required buffer size in `*olen`. * - * \note Call this function with buflen = 0 to obtain the - * minimum required buffer size in *olen. + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if the target buffer \p buf + * is too small to hold the value of \p X in the desired base. + * In this case, `*olen` is nonetheless updated to contain the + * size of \p buf required for a successful call. + * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, char *buf, size_t buflen, size_t *olen ); #if defined(MBEDTLS_FS_IO) /** - * \brief Read MPI from a line in an opened file + * \brief Read an MPI from a line in an opened file. * - * \param X Destination MPI - * \param radix Input numeric base - * \param fin Input file handle - * - * \return 0 if successful, MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if - * the file read buffer is too small or a - * MBEDTLS_ERR_MPI_XXX error code + * \param X The destination MPI. This must point to an initialized MPI. + * \param radix The numeric base of the string representation used + * in the source line. + * \param fin The input file handle to use. This must not be \c NULL. * * \note On success, this function advances the file stream * to the end of the current line or to EOF. * - * The function returns 0 on an empty line. + * The function returns \c 0 on an empty line. * * Leading whitespaces are ignored, as is a - * '0x' prefix for radix 16. + * '0x' prefix for radix \c 16. * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if the file read buffer + * is too small. + * \return Another negative error code on failure. */ int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ); /** - * \brief Write X into an opened file, or stdout if fout is NULL - * - * \param p Prefix, can be NULL - * \param X Source MPI - * \param radix Output numeric base - * \param fout Output file handle (can be NULL) + * \brief Export an MPI into an opened file. * - * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code + * \param p A string prefix to emit prior to the MPI data. + * For example, this might be a label, or "0x" when + * printing in base \c 16. This may be \c NULL if no prefix + * is needed. + * \param X The source MPI. This must point to an initialized MPI. + * \param radix The numeric base to be used in the emitted string. + * \param fout The output file handle. This may be \c NULL, in which case + * the output is written to \c stdout. * - * \note Set fout == NULL to print X on the console. + * \return \c 0 if successful. + * \return A negative error code on failure. */ -int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout ); +int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, + int radix, FILE *fout ); #endif /* MBEDTLS_FS_IO */ /** - * \brief Import X from unsigned binary data, big endian + * \brief Import an MPI from unsigned big endian binary data. * - * \param X Destination MPI - * \param buf Input buffer - * \param buflen Input buffer size + * \param X The destination MPI. This must point to an initialized MPI. + * \param buf The input buffer. This must be a readable buffer of length + * \p buflen Bytes. + * \param buflen The length of the input buffer \p p in Bytes. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen ); +int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, + size_t buflen ); /** - * \brief Export X into unsigned binary data, big endian. - * Always fills the whole buffer, which will start with zeros - * if the number is smaller. + * \brief Export an MPI into unsigned big endian binary data + * of fixed size. * - * \param X Source MPI - * \param buf Output buffer - * \param buflen Output buffer size + * \param X The source MPI. This must point to an initialized MPI. + * \param buf The output buffer. This must be a writable buffer of length + * \p buflen Bytes. + * \param buflen The size of the output buffer \p buf in Bytes. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if buf isn't large enough + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL if \p buf isn't + * large enough to hold the value of \p X. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen ); +int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, + size_t buflen ); /** - * \brief Left-shift: X <<= count + * \brief Perform a left-shift on an MPI: X <<= count * - * \param X MPI to shift - * \param count Amount to shift + * \param X The MPI to shift. This must point to an initialized MPI. + * \param count The number of bits to shift by. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count ); /** - * \brief Right-shift: X >>= count + * \brief Perform a right-shift on an MPI: X >>= count * - * \param X MPI to shift - * \param count Amount to shift + * \param X The MPI to shift. This must point to an initialized MPI. + * \param count The number of bits to shift by. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count ); /** - * \brief Compare unsigned values + * \brief Compare the absolute values of two MPIs. * - * \param X Left-hand MPI - * \param Y Right-hand MPI + * \param X The left-hand MPI. This must point to an initialized MPI. + * \param Y The right-hand MPI. This must point to an initialized MPI. * - * \return 1 if |X| is greater than |Y|, - * -1 if |X| is lesser than |Y| or - * 0 if |X| is equal to |Y| + * \return \c 1 if `|X|` is greater than `|Y|`. + * \return \c -1 if `|X|` is lesser than `|Y|`. + * \return \c 0 if `|X|` is equal to `|Y|`. */ int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y ); /** - * \brief Compare signed values + * \brief Compare two MPIs. * - * \param X Left-hand MPI - * \param Y Right-hand MPI + * \param X The left-hand MPI. This must point to an initialized MPI. + * \param Y The right-hand MPI. This must point to an initialized MPI. * - * \return 1 if X is greater than Y, - * -1 if X is lesser than Y or - * 0 if X is equal to Y + * \return \c 1 if \p X is greater than \p Y. + * \return \c -1 if \p X is lesser than \p Y. + * \return \c 0 if \p X is equal to \p Y. */ int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y ); /** - * \brief Compare signed values + * \brief Compare an MPI with an integer. * - * \param X Left-hand MPI - * \param z The integer value to compare to + * \param X The left-hand MPI. This must point to an initialized MPI. + * \param z The integer value to compare \p X to. * - * \return 1 if X is greater than z, - * -1 if X is lesser than z or - * 0 if X is equal to z + * \return \c 1 if \p X is greater than \p z. + * \return \c -1 if \p X is lesser than \p z. + * \return \c 0 if \p X is equal to \p z. */ int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z ); /** - * \brief Unsigned addition: X = |A| + |B| + * \brief Perform an unsigned addition of MPIs: X = |A| + |B| * - * \param X Destination MPI - * \param A Left-hand MPI - * \param B Right-hand MPI + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The first summand. This must point to an initialized MPI. + * \param B The second summand. This must point to an initialized MPI. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Unsigned subtraction: X = |A| - |B| + * \brief Perform an unsigned subtraction of MPIs: X = |A| - |B| * - * \param X Destination MPI - * \param A Left-hand MPI - * \param B Right-hand MPI + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The minuend. This must point to an initialized MPI. + * \param B The subtrahend. This must point to an initialized MPI. + * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p B is greater than \p A. + * \return Another negative error code on different kinds of failure. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if B is greater than A */ -int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Signed addition: X = A + B + * \brief Perform a signed addition of MPIs: X = A + B * - * \param X Destination MPI - * \param A Left-hand MPI - * \param B Right-hand MPI + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The first summand. This must point to an initialized MPI. + * \param B The second summand. This must point to an initialized MPI. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Signed subtraction: X = A - B + * \brief Perform a signed subtraction of MPIs: X = A - B * - * \param X Destination MPI - * \param A Left-hand MPI - * \param B Right-hand MPI + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The minuend. This must point to an initialized MPI. + * \param B The subtrahend. This must point to an initialized MPI. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Signed addition: X = A + b + * \brief Perform a signed addition of an MPI and an integer: X = A + b * - * \param X Destination MPI - * \param A Left-hand MPI - * \param b The integer value to add + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The first summand. This must point to an initialized MPI. + * \param b The second summand. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ); +int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, + mbedtls_mpi_sint b ); /** - * \brief Signed subtraction: X = A - b + * \brief Perform a signed subtraction of an MPI and an integer: + * X = A - b * - * \param X Destination MPI - * \param A Left-hand MPI - * \param b The integer value to subtract + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The minuend. This must point to an initialized MPI. + * \param b The subtrahend. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ); +int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, + mbedtls_mpi_sint b ); /** - * \brief Baseline multiplication: X = A * B + * \brief Perform a multiplication of two MPIs: X = A * B + * + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The first factor. This must point to an initialized MPI. + * \param B The second factor. This must point to an initialized MPI. * - * \param X Destination MPI - * \param A Left-hand MPI - * \param B Right-hand MPI + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed */ -int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Baseline multiplication: X = A * b + * \brief Perform a multiplication of an MPI with an unsigned integer: + * X = A * b * - * \param X Destination MPI - * \param A Left-hand MPI - * \param b The unsigned integer value to multiply with + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The first factor. This must point to an initialized MPI. + * \param b The second factor. * - * \note b is unsigned + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed */ -int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b ); +int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, + mbedtls_mpi_uint b ); /** - * \brief Division by mbedtls_mpi: A = Q * B + R + * \brief Perform a division with remainder of two MPIs: + * A = Q * B + R * - * \param Q Destination MPI for the quotient - * \param R Destination MPI for the rest value - * \param A Left-hand MPI - * \param B Right-hand MPI + * \param Q The destination MPI for the quotient. + * This may be \c NULL if the value of the + * quotient is not needed. + * \param R The destination MPI for the remainder value. + * This may be \c NULL if the value of the + * remainder is not needed. + * \param A The dividend. This must point to an initialized MPi. + * \param B The divisor. This must point to an initialized MPI. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if B == 0 - * - * \note Either Q or R can be NULL. + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p B equals zero. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Division by int: A = Q * b + R - * - * \param Q Destination MPI for the quotient - * \param R Destination MPI for the rest value - * \param A Left-hand MPI - * \param b Integer to divide by + * \brief Perform a division with remainder of an MPI by an integer: + * A = Q * b + R * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if b == 0 + * \param Q The destination MPI for the quotient. + * This may be \c NULL if the value of the + * quotient is not needed. + * \param R The destination MPI for the remainder value. + * This may be \c NULL if the value of the + * remainder is not needed. + * \param A The dividend. This must point to an initialized MPi. + * \param b The divisor. * - * \note Either Q or R can be NULL. + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed. + * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p b equals zero. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b ); +int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, + mbedtls_mpi_sint b ); /** - * \brief Modulo: R = A mod B + * \brief Perform a modular reduction. R = A mod B * - * \param R Destination MPI for the rest value - * \param A Left-hand MPI - * \param B Right-hand MPI + * \param R The destination MPI for the residue value. + * This must point to an initialized MPI. + * \param A The MPI to compute the residue of. + * This must point to an initialized MPI. + * \param B The base of the modular reduction. + * This must point to an initialized MPI. + * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p B equals zero. + * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p B is negative. + * \return Another negative error code on different kinds of failure. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if B == 0, - * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if B < 0 */ -int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ); +int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Modulo: r = A mod b + * \brief Perform a modular reduction with respect to an integer. + * r = A mod b * - * \param r Destination mbedtls_mpi_uint - * \param A Left-hand MPI - * \param b Integer to divide by + * \param r The address at which to store the residue. + * This must not be \c NULL. + * \param A The MPI to compute the residue of. + * This must point to an initialized MPi. + * \param b The integer base of the modular reduction. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if b == 0, - * MBEDTLS_ERR_MPI_NEGATIVE_VALUE if b < 0 + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_DIVISION_BY_ZERO if \p b equals zero. + * \return #MBEDTLS_ERR_MPI_NEGATIVE_VALUE if \p b is negative. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b ); +int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, + mbedtls_mpi_sint b ); /** - * \brief Sliding-window exponentiation: X = A^E mod N - * - * \param X Destination MPI - * \param A Left-hand MPI - * \param E Exponent MPI - * \param N Modular MPI - * \param _RR Speed-up MPI used for recalculations + * \brief Perform a sliding-window exponentiation: X = A^E mod N * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is negative or even or - * if E is negative + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The base of the exponentiation. + * This must point to an initialized MPI. + * \param E The exponent MPI. This must point to an initialized MPI. + * \param N The base for the modular reduction. This must point to an + * initialized MPI. + * \param _RR A helper MPI depending solely on \p N which can be used to + * speed-up multiple modular exponentiations for the same value + * of \p N. This may be \c NULL. If it is not \c NULL, it must + * point to an initialized MPI. If it hasn't been used after + * the call to mbedtls_mpi_init(), this function will compute + * the helper value and store it in \p _RR for reuse on + * subsequent calls to this function. Otherwise, the function + * will assume that \p _RR holds the helper value set by a + * previous call to mbedtls_mpi_exp_mod(), and reuse it. + * + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \c N is negative or + * even, or if \c E is negative. + * \return Another negative error code on different kinds of failures. * - * \note _RR is used to avoid re-computing R*R mod N across - * multiple calls, which speeds up things a bit. It can - * be set to NULL if the extra performance is unneeded. */ -int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR ); +int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *E, const mbedtls_mpi *N, + mbedtls_mpi *_RR ); /** - * \brief Fill an MPI X with size bytes of random + * \brief Fill an MPI with a number of random bytes. * - * \param X Destination MPI - * \param size Size in bytes - * \param f_rng RNG function - * \param p_rng RNG parameter + * \param X The destination MPI. This must point to an initialized MPI. + * \param size The number of random bytes to generate. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. This may be + * \c NULL if \p f_rng doesn't need a context argument. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on failure. * - * \note The bytes obtained from the PRNG are interpreted + * \note The bytes obtained from the RNG are interpreted * as a big-endian representation of an MPI; this can * be relevant in applications like deterministic ECDSA. */ @@ -694,64 +821,135 @@ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, void *p_rng ); /** - * \brief Greatest common divisor: G = gcd(A, B) - * - * \param G Destination MPI - * \param A Left-hand MPI - * \param B Right-hand MPI - * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed - */ -int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B ); - -/** - * \brief Modular inverse: X = A^-1 mod N + * \brief Compute the greatest common divisor: G = gcd(A, B) * - * \param X Destination MPI - * \param A Left-hand MPI - * \param N Right-hand MPI + * \param G The destination MPI. This must point to an initialized MPI. + * \param A The first operand. This must point to an initialized MPI. + * \param B The second operand. This must point to an initialized MPI. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if N is <= 1, - MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if A has no inverse mod N. + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return Another negative error code on different kinds of failure. */ -int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ); +int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, + const mbedtls_mpi *B ); /** - * \brief Miller-Rabin primality test + * \brief Compute the modular inverse: X = A^-1 mod N * - * \param X MPI to check - * \param f_rng RNG function - * \param p_rng RNG parameter + * \param X The destination MPI. This must point to an initialized MPI. + * \param A The MPI to calculate the modular inverse of. This must point + * to an initialized MPI. + * \param N The base of the modular inversion. This must point to an + * initialized MPI. * - * \return 0 if successful (probably prime), - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if X is not prime + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if \p N is less than + * or equal to one. + * \return #MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if \p has no modular inverse + * with respect to \p N. */ -int mbedtls_mpi_is_prime( const mbedtls_mpi *X, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ); +int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *N ); +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif /** - * \brief Prime number generation - * - * \param X Destination MPI - * \param nbits Required size of X in bits - * ( 3 <= nbits <= MBEDTLS_MPI_MAX_BITS ) - * \param dh_flag If 1, then (X-1)/2 will be prime too - * \param f_rng RNG function - * \param p_rng RNG parameter - * - * \return 0 if successful (probably prime), - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_MPI_BAD_INPUT_DATA if nbits is < 3 - */ -int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag, + * \brief Perform a Miller-Rabin primality test with error + * probability of 2-80. + * + * \deprecated Superseded by mbedtls_mpi_is_prime_ext() which allows + * specifying the number of Miller-Rabin rounds. + * + * \param X The MPI to check for primality. + * This must point to an initialized MPI. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. + * This may be \c NULL if \p f_rng doesn't use a + * context parameter. + * + * \return \c 0 if successful, i.e. \p X is probably prime. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if \p X is not prime. + * \return Another negative error code on other kinds of failure. + */ +MBEDTLS_DEPRECATED int mbedtls_mpi_is_prime( const mbedtls_mpi *X, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); +#undef MBEDTLS_DEPRECATED +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ + +/** + * \brief Miller-Rabin primality test. + * + * \warning If \p X is potentially generated by an adversary, for example + * when validating cryptographic parameters that you didn't + * generate yourself and that are supposed to be prime, then + * \p rounds should be at least the half of the security + * strength of the cryptographic algorithm. On the other hand, + * if \p X is chosen uniformly or non-adversially (as is the + * case when mbedtls_mpi_gen_prime calls this function), then + * \p rounds can be much lower. + * + * \param X The MPI to check for primality. + * This must point to an initialized MPI. + * \param rounds The number of bases to perform the Miller-Rabin primality + * test for. The probability of returning 0 on a composite is + * at most 2-2*\p rounds. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. + * This may be \c NULL if \p f_rng doesn't use + * a context parameter. + * + * \return \c 0 if successful, i.e. \p X is probably prime. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_NOT_ACCEPTABLE if \p X is not prime. + * \return Another negative error code on other kinds of failure. + */ +int mbedtls_mpi_is_prime_ext( const mbedtls_mpi *X, int rounds, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); +/** + * \brief Flags for mbedtls_mpi_gen_prime() + * + * Each of these flags is a constraint on the result X returned by + * mbedtls_mpi_gen_prime(). + */ +typedef enum { + MBEDTLS_MPI_GEN_PRIME_FLAG_DH = 0x0001, /**< (X-1)/2 is prime too */ + MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR = 0x0002, /**< lower error rate from 2-80 to 2-128 */ +} mbedtls_mpi_gen_prime_flag_t; + +/** + * \brief Generate a prime number. + * + * \param X The destination MPI to store the generated prime in. + * This must point to an initialized MPi. + * \param nbits The required size of the destination MPI in bits. + * This must be between \c 3 and #MBEDTLS_MPI_MAX_BITS. + * \param flags A mask of flags of type #mbedtls_mpi_gen_prime_flag_t. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. + * This may be \c NULL if \p f_rng doesn't use + * a context parameter. + * + * \return \c 0 if successful, in which case \p X holds a + * probably prime number. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED if a memory allocation failed. + * \return #MBEDTLS_ERR_MPI_BAD_INPUT_DATA if `nbits` is not between + * \c 3 and #MBEDTLS_MPI_MAX_BITS. + */ +int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -759,6 +957,8 @@ int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag, */ int mbedtls_mpi_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/blowfish.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/blowfish.h index c0ef5a04cc..f01573dcaf 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/blowfish.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/blowfish.h @@ -33,6 +33,8 @@ #include #include +#include "platform_util.h" + #define MBEDTLS_BLOWFISH_ENCRYPT 1 #define MBEDTLS_BLOWFISH_DECRYPT 0 #define MBEDTLS_BLOWFISH_MAX_KEY_BITS 448 @@ -40,63 +42,87 @@ #define MBEDTLS_BLOWFISH_ROUNDS 16 /**< Rounds to use. When increasing this value, make sure to extend the initialisation vectors */ #define MBEDTLS_BLOWFISH_BLOCKSIZE 8 /* Blowfish uses 64 bit blocks */ -#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH -0x0016 /**< Invalid key length. */ -#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017 /**< Blowfish hardware accelerator failed. */ -#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#define MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0016 ) +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#define MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA -0x0016 /**< Bad input data. */ -#if !defined(MBEDTLS_BLOWFISH_ALT) -// Regular implementation -// +#define MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH -0x0018 /**< Invalid data input length. */ + +/* MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED is deprecated and should not be used. + */ +#define MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED -0x0017 /**< Blowfish hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_BLOWFISH_ALT) +// Regular implementation +// + /** * \brief Blowfish context structure */ -typedef struct +typedef struct mbedtls_blowfish_context { uint32_t P[MBEDTLS_BLOWFISH_ROUNDS + 2]; /*!< Blowfish round keys */ uint32_t S[4][256]; /*!< key dependent S-boxes */ } mbedtls_blowfish_context; +#else /* MBEDTLS_BLOWFISH_ALT */ +#include "blowfish_alt.h" +#endif /* MBEDTLS_BLOWFISH_ALT */ + /** - * \brief Initialize Blowfish context + * \brief Initialize a Blowfish context. * - * \param ctx Blowfish context to be initialized + * \param ctx The Blowfish context to be initialized. + * This must not be \c NULL. */ void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx ); /** - * \brief Clear Blowfish context + * \brief Clear a Blowfish context. * - * \param ctx Blowfish context to be cleared + * \param ctx The Blowfish context to be cleared. + * This may be \c NULL, in which case this function + * returns immediately. If it is not \c NULL, it must + * point to an initialized Blowfish context. */ void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx ); /** - * \brief Blowfish key schedule + * \brief Perform a Blowfish key schedule operation. * - * \param ctx Blowfish context to be initialized - * \param key encryption key - * \param keybits must be between 32 and 448 bits + * \param ctx The Blowfish context to perform the key schedule on. + * \param key The encryption key. This must be a readable buffer of + * length \p keybits Bits. + * \param keybits The length of \p key in Bits. This must be between + * \c 32 and \c 448 and a multiple of \c 8. * - * \return 0 if successful, or MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key, unsigned int keybits ); /** - * \brief Blowfish-ECB block encryption/decryption + * \brief Perform a Blowfish-ECB block encryption/decryption operation. * - * \param ctx Blowfish context - * \param mode MBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT - * \param input 8-byte input block - * \param output 8-byte output block + * \param ctx The Blowfish context to use. This must be initialized + * and bound to a key. + * \param mode The mode of operation. Possible values are + * #MBEDTLS_BLOWFISH_ENCRYPT for encryption, or + * #MBEDTLS_BLOWFISH_DECRYPT for decryption. + * \param input The input block. This must be a readable buffer + * of size \c 8 Bytes. + * \param output The output block. This must be a writable buffer + * of size \c 8 Bytes. * - * \return 0 if successful + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, int mode, @@ -105,9 +131,7 @@ int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_CBC) /** - * \brief Blowfish-CBC buffer encryption/decryption - * Length should be a multiple of the block - * size (8 bytes) + * \brief Perform a Blowfish-CBC buffer encryption/decryption operation. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following @@ -117,15 +141,22 @@ int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, * IV, you should either save it manually or use the cipher * module instead. * - * \param ctx Blowfish context - * \param mode MBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT - * \param length length of the input data - * \param iv initialization vector (updated after use) - * \param input buffer holding the input data - * \param output buffer holding the output data + * \param ctx The Blowfish context to use. This must be initialized + * and bound to a key. + * \param mode The mode of operation. Possible values are + * #MBEDTLS_BLOWFISH_ENCRYPT for encryption, or + * #MBEDTLS_BLOWFISH_DECRYPT for decryption. + * \param length The length of the input data in Bytes. This must be + * multiple of \c 8. + * \param iv The initialization vector. This must be a read/write buffer + * of length \c 8 Bytes. It is updated by this function. + * \param input The input data. This must be a readable buffer of length + * \p length Bytes. + * \param output The output data. This must be a writable buffer of length + * \p length Bytes. * - * \return 0 if successful, or - * MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, int mode, @@ -137,7 +168,7 @@ int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_CFB) /** - * \brief Blowfish CFB buffer encryption/decryption. + * \brief Perform a Blowfish CFB buffer encryption/decryption operation. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following @@ -147,15 +178,25 @@ int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, * IV, you should either save it manually or use the cipher * module instead. * - * \param ctx Blowfish context - * \param mode MBEDTLS_BLOWFISH_ENCRYPT or MBEDTLS_BLOWFISH_DECRYPT - * \param length length of the input data - * \param iv_off offset in IV (updated after use) - * \param iv initialization vector (updated after use) - * \param input buffer holding the input data - * \param output buffer holding the output data + * \param ctx The Blowfish context to use. This must be initialized + * and bound to a key. + * \param mode The mode of operation. Possible values are + * #MBEDTLS_BLOWFISH_ENCRYPT for encryption, or + * #MBEDTLS_BLOWFISH_DECRYPT for decryption. + * \param length The length of the input data in Bytes. + * \param iv_off The offset in the initialiation vector. + * The value pointed to must be smaller than \c 8 Bytes. + * It is updated by this function to support the aforementioned + * streaming usage. + * \param iv The initialization vector. This must be a read/write buffer + * of size \c 8 Bytes. It is updated after use. + * \param input The input data. This must be a readable buffer of length + * \p length Bytes. + * \param output The output data. This must be a writable buffer of length + * \p length Bytes. * - * \return 0 if successful + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx, int mode, @@ -168,22 +209,67 @@ int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_CTR) /** - * \brief Blowfish-CTR buffer encryption/decryption + * \brief Perform a Blowfish-CTR buffer encryption/decryption operation. + * + * \warning You must never reuse a nonce value with the same key. Doing so + * would void the encryption for the two messages encrypted with + * the same nonce and key. + * + * There are two common strategies for managing nonces with CTR: + * + * 1. You can handle everything as a single message processed over + * successive calls to this function. In that case, you want to + * set \p nonce_counter and \p nc_off to 0 for the first call, and + * then preserve the values of \p nonce_counter, \p nc_off and \p + * stream_block across calls to this function as they will be + * updated by this function. + * + * With this strategy, you must not encrypt more than 2**64 + * blocks of data with the same key. + * + * 2. You can encrypt separate messages by dividing the \p + * nonce_counter buffer in two areas: the first one used for a + * per-message nonce, handled by yourself, and the second one + * updated by this function internally. + * + * For example, you might reserve the first 4 bytes for the + * per-message nonce, and the last 4 bytes for internal use. In that + * case, before calling this function on a new message you need to + * set the first 4 bytes of \p nonce_counter to your chosen nonce + * value, the last 4 to 0, and \p nc_off to 0 (which will cause \p + * stream_block to be ignored). That way, you can encrypt at most + * 2**32 messages of up to 2**32 blocks each with the same key. * - * Warning: You have to keep the maximum use of your counter in mind! + * The per-message nonce (or information sufficient to reconstruct + * it) needs to be communicated with the ciphertext and must be unique. + * The recommended way to ensure uniqueness is to use a message + * counter. * - * \param ctx Blowfish context - * \param length The length of the data + * Note that for both stategies, sizes are measured in blocks and + * that a Blowfish block is 8 bytes. + * + * \warning Upon return, \p stream_block contains sensitive data. Its + * content must not be written to insecure storage and should be + * securely discarded as soon as it's no longer needed. + * + * \param ctx The Blowfish context to use. This must be initialized + * and bound to a key. + * \param length The length of the input data in Bytes. * \param nc_off The offset in the current stream_block (for resuming - * within current cipher stream). The offset pointer to - * should be 0 at the start of a stream. - * \param nonce_counter The 64-bit nonce and counter. - * \param stream_block The saved stream-block for resuming. Is overwritten - * by the function. - * \param input The input data stream - * \param output The output data stream - * - * \return 0 if successful + * within current cipher stream). The offset pointer + * should be \c 0 at the start of a stream and must be + * smaller than \c 8. It is updated by this function. + * \param nonce_counter The 64-bit nonce and counter. This must point to a + * read/write buffer of length \c 8 Bytes. + * \param stream_block The saved stream-block for resuming. This must point to + * a read/write buffer of length \c 8 Bytes. + * \param input The input data. This must be a readable buffer of + * length \p length Bytes. + * \param output The output data. This must be a writable buffer of + * length \p length Bytes. + * + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx, size_t length, @@ -198,8 +284,4 @@ int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx, } #endif -#else /* MBEDTLS_BLOWFISH_ALT */ -#include "blowfish_alt.h" -#endif /* MBEDTLS_BLOWFISH_ALT */ - #endif /* blowfish.h */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/bn_mul.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/bn_mul.h index 80e4b380d1..c33bd8d4ab 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/bn_mul.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/bn_mul.h @@ -38,6 +38,12 @@ #ifndef MBEDTLS_BN_MUL_H #define MBEDTLS_BN_MUL_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "bignum.h" #if defined(MBEDTLS_HAVE_ASM) @@ -565,9 +571,8 @@ #endif /* TriCore */ /* - * gcc -O0 by default uses r7 for the frame pointer, so it complains about our - * use of r7 below, unless -fomit-frame-pointer is passed. Unfortunately, - * passing that option is not easy when building with yotta. + * Note, gcc -O0 by default uses r7 for the frame pointer, so it complains about + * our use of r7 below, unless -fomit-frame-pointer is passed. * * On the other hand, -fomit-frame-pointer is implied by any -Ox options with * x !=0, which we can detect using __OPTIMIZE__ (which is also defined by @@ -637,6 +642,23 @@ "r6", "r7", "r8", "r9", "cc" \ ); +#elif defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1) + +#define MULADDC_INIT \ + asm( + +#define MULADDC_CORE \ + "ldr r0, [%0], #4 \n\t" \ + "ldr r1, [%1] \n\t" \ + "umaal r1, %2, %3, r0 \n\t" \ + "str r1, [%1], #4 \n\t" + +#define MULADDC_STOP \ + : "=r" (s), "=r" (d), "=r" (c) \ + : "r" (b), "0" (s), "1" (d), "2" (c) \ + : "r0", "r1", "memory" \ + ); + #else #define MULADDC_INIT \ @@ -734,7 +756,7 @@ "sw $10, %2 \n\t" \ : "=m" (c), "=m" (d), "=m" (s) \ : "m" (s), "m" (d), "m" (c), "m" (b) \ - : "$9", "$10", "$11", "$12", "$13", "$14", "$15" \ + : "$9", "$10", "$11", "$12", "$13", "$14", "$15", "lo", "hi" \ ); #endif /* MIPS */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/camellia.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/camellia.h index cf07629d9b..3eeb66366d 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/camellia.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/camellia.h @@ -33,78 +33,107 @@ #include #include +#include "platform_util.h" + #define MBEDTLS_CAMELLIA_ENCRYPT 1 #define MBEDTLS_CAMELLIA_DECRYPT 0 -#define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH -0x0024 /**< Invalid key length. */ -#define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */ -#define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027 /**< Camellia hardware accelerator failed. */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#define MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( -0x0024 ) +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#define MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA -0x0024 /**< Bad input data. */ -#if !defined(MBEDTLS_CAMELLIA_ALT) -// Regular implementation -// +#define MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH -0x0026 /**< Invalid data input length. */ + +/* MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED is deprecated and should not be used. + */ +#define MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED -0x0027 /**< Camellia hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_CAMELLIA_ALT) +// Regular implementation +// + /** * \brief CAMELLIA context structure */ -typedef struct +typedef struct mbedtls_camellia_context { int nr; /*!< number of rounds */ uint32_t rk[68]; /*!< CAMELLIA round keys */ } mbedtls_camellia_context; +#else /* MBEDTLS_CAMELLIA_ALT */ +#include "camellia_alt.h" +#endif /* MBEDTLS_CAMELLIA_ALT */ + /** - * \brief Initialize CAMELLIA context + * \brief Initialize a CAMELLIA context. * - * \param ctx CAMELLIA context to be initialized + * \param ctx The CAMELLIA context to be initialized. + * This must not be \c NULL. */ void mbedtls_camellia_init( mbedtls_camellia_context *ctx ); /** - * \brief Clear CAMELLIA context + * \brief Clear a CAMELLIA context. * - * \param ctx CAMELLIA context to be cleared + * \param ctx The CAMELLIA context to be cleared. This may be \c NULL, + * in which case this function returns immediately. If it is not + * \c NULL, it must be initialized. */ void mbedtls_camellia_free( mbedtls_camellia_context *ctx ); /** - * \brief CAMELLIA key schedule (encryption) + * \brief Perform a CAMELLIA key schedule operation for encryption. * - * \param ctx CAMELLIA context to be initialized - * \param key encryption key - * \param keybits must be 128, 192 or 256 + * \param ctx The CAMELLIA context to use. This must be initialized. + * \param key The encryption key to use. This must be a readable buffer + * of size \p keybits Bits. + * \param keybits The length of \p key in Bits. This must be either \c 128, + * \c 192 or \c 256. * - * \return 0 if successful, or MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH + * \return \c 0 if successful. + * \return A negative error code on failure. */ -int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key, - unsigned int keybits ); +int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, + const unsigned char *key, + unsigned int keybits ); /** - * \brief CAMELLIA key schedule (decryption) + * \brief Perform a CAMELLIA key schedule operation for decryption. * - * \param ctx CAMELLIA context to be initialized - * \param key decryption key - * \param keybits must be 128, 192 or 256 + * \param ctx The CAMELLIA context to use. This must be initialized. + * \param key The decryption key. This must be a readable buffer + * of size \p keybits Bits. + * \param keybits The length of \p key in Bits. This must be either \c 128, + * \c 192 or \c 256. * - * \return 0 if successful, or MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH + * \return \c 0 if successful. + * \return A negative error code on failure. */ -int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key, - unsigned int keybits ); +int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, + const unsigned char *key, + unsigned int keybits ); /** - * \brief CAMELLIA-ECB block encryption/decryption + * \brief Perform a CAMELLIA-ECB block encryption/decryption operation. * - * \param ctx CAMELLIA context - * \param mode MBEDTLS_CAMELLIA_ENCRYPT or MBEDTLS_CAMELLIA_DECRYPT - * \param input 16-byte input block - * \param output 16-byte output block + * \param ctx The CAMELLIA context to use. This must be initialized + * and bound to a key. + * \param mode The mode of operation. This must be either + * #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. + * \param input The input block. This must be a readable buffer + * of size \c 16 Bytes. + * \param output The output block. This must be a writable buffer + * of size \c 16 Bytes. * - * \return 0 if successful + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, int mode, @@ -113,9 +142,7 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_CBC) /** - * \brief CAMELLIA-CBC buffer encryption/decryption - * Length should be a multiple of the block - * size (16 bytes) + * \brief Perform a CAMELLIA-CBC buffer encryption/decryption operation. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following @@ -125,15 +152,22 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, * IV, you should either save it manually or use the cipher * module instead. * - * \param ctx CAMELLIA context - * \param mode MBEDTLS_CAMELLIA_ENCRYPT or MBEDTLS_CAMELLIA_DECRYPT - * \param length length of the input data - * \param iv initialization vector (updated after use) - * \param input buffer holding the input data - * \param output buffer holding the output data + * \param ctx The CAMELLIA context to use. This must be initialized + * and bound to a key. + * \param mode The mode of operation. This must be either + * #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. + * \param length The length in Bytes of the input data \p input. + * This must be a multiple of \c 16 Bytes. + * \param iv The initialization vector. This must be a read/write buffer + * of length \c 16 Bytes. It is updated to allow streaming + * use as explained above. + * \param input The buffer holding the input data. This must point to a + * readable buffer of length \p length Bytes. + * \param output The buffer holding the output data. This must point to a + * writable buffer of length \p length Bytes. * - * \return 0 if successful, or - * MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, int mode, @@ -145,11 +179,14 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_CFB) /** - * \brief CAMELLIA-CFB128 buffer encryption/decryption + * \brief Perform a CAMELLIA-CFB128 buffer encryption/decryption + * operation. * - * Note: Due to the nature of CFB you should use the same key schedule for - * both encryption and decryption. So a context initialized with - * mbedtls_camellia_setkey_enc() for both MBEDTLS_CAMELLIA_ENCRYPT and CAMELLIE_DECRYPT. + * \note Due to the nature of CFB mode, you should use the same + * key for both encryption and decryption. In particular, calls + * to this function should be preceded by a key-schedule via + * mbedtls_camellia_setkey_enc() regardless of whether \p mode + * is #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. * * \note Upon exit, the content of the IV is updated so that you can * call the function same function again on the following @@ -159,16 +196,24 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, * IV, you should either save it manually or use the cipher * module instead. * - * \param ctx CAMELLIA context - * \param mode MBEDTLS_CAMELLIA_ENCRYPT or MBEDTLS_CAMELLIA_DECRYPT - * \param length length of the input data - * \param iv_off offset in IV (updated after use) - * \param iv initialization vector (updated after use) - * \param input buffer holding the input data - * \param output buffer holding the output data + * \param ctx The CAMELLIA context to use. This must be initialized + * and bound to a key. + * \param mode The mode of operation. This must be either + * #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. + * \param length The length of the input data \p input. Any value is allowed. + * \param iv_off The current offset in the IV. This must be smaller + * than \c 16 Bytes. It is updated after this call to allow + * the aforementioned streaming usage. + * \param iv The initialization vector. This must be a read/write buffer + * of length \c 16 Bytes. It is updated after this call to + * allow the aforementioned streaming usage. + * \param input The buffer holding the input data. This must be a readable + * buffer of size \p length Bytes. + * \param output The buffer to hold the output data. This must be a writable + * buffer of length \p length Bytes. * - * \return 0 if successful, or - * MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx, int mode, @@ -181,26 +226,78 @@ int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx, #if defined(MBEDTLS_CIPHER_MODE_CTR) /** - * \brief CAMELLIA-CTR buffer encryption/decryption + * \brief Perform a CAMELLIA-CTR buffer encryption/decryption operation. + * + * *note Due to the nature of CTR mode, you should use the same + * key for both encryption and decryption. In particular, calls + * to this function should be preceded by a key-schedule via + * mbedtls_camellia_setkey_enc() regardless of whether \p mode + * is #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. + * + * \warning You must never reuse a nonce value with the same key. Doing so + * would void the encryption for the two messages encrypted with + * the same nonce and key. + * + * There are two common strategies for managing nonces with CTR: * - * Warning: You have to keep the maximum use of your counter in mind! + * 1. You can handle everything as a single message processed over + * successive calls to this function. In that case, you want to + * set \p nonce_counter and \p nc_off to 0 for the first call, and + * then preserve the values of \p nonce_counter, \p nc_off and \p + * stream_block across calls to this function as they will be + * updated by this function. * - * Note: Due to the nature of CTR you should use the same key schedule for - * both encryption and decryption. So a context initialized with - * mbedtls_camellia_setkey_enc() for both MBEDTLS_CAMELLIA_ENCRYPT and MBEDTLS_CAMELLIA_DECRYPT. + * With this strategy, you must not encrypt more than 2**128 + * blocks of data with the same key. * - * \param ctx CAMELLIA context - * \param length The length of the data - * \param nc_off The offset in the current stream_block (for resuming + * 2. You can encrypt separate messages by dividing the \p + * nonce_counter buffer in two areas: the first one used for a + * per-message nonce, handled by yourself, and the second one + * updated by this function internally. + * + * For example, you might reserve the first \c 12 Bytes for the + * per-message nonce, and the last \c 4 Bytes for internal use. + * In that case, before calling this function on a new message you + * need to set the first \c 12 Bytes of \p nonce_counter to your + * chosen nonce value, the last four to \c 0, and \p nc_off to \c 0 + * (which will cause \p stream_block to be ignored). That way, you + * can encrypt at most \c 2**96 messages of up to \c 2**32 blocks + * each with the same key. + * + * The per-message nonce (or information sufficient to reconstruct + * it) needs to be communicated with the ciphertext and must be + * unique. The recommended way to ensure uniqueness is to use a + * message counter. An alternative is to generate random nonces, + * but this limits the number of messages that can be securely + * encrypted: for example, with 96-bit random nonces, you should + * not encrypt more than 2**32 messages with the same key. + * + * Note that for both stategies, sizes are measured in blocks and + * that a CAMELLIA block is \c 16 Bytes. + * + * \warning Upon return, \p stream_block contains sensitive data. Its + * content must not be written to insecure storage and should be + * securely discarded as soon as it's no longer needed. + * + * \param ctx The CAMELLIA context to use. This must be initialized + * and bound to a key. + * \param length The length of the input data \p input in Bytes. + * Any value is allowed. + * \param nc_off The offset in the current \p stream_block (for resuming * within current cipher stream). The offset pointer to - * should be 0 at the start of a stream. - * \param nonce_counter The 128-bit nonce and counter. - * \param stream_block The saved stream-block for resuming. Is overwritten - * by the function. - * \param input The input data stream - * \param output The output data stream - * - * \return 0 if successful + * should be \c 0 at the start of a stream. It is updated + * at the end of this call. + * \param nonce_counter The 128-bit nonce and counter. This must be a read/write + * buffer of length \c 16 Bytes. + * \param stream_block The saved stream-block for resuming. This must be a + * read/write buffer of length \c 16 Bytes. + * \param input The input data stream. This must be a readable buffer of + * size \p length Bytes. + * \param output The output data stream. This must be a writable buffer + * of size \p length Bytes. + * + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx, size_t length, @@ -211,17 +308,7 @@ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx, unsigned char *output ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_CAMELLIA_ALT */ -#include "camellia_alt.h" -#endif /* MBEDTLS_CAMELLIA_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine @@ -230,6 +317,8 @@ extern "C" { */ int mbedtls_camellia_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ccm.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ccm.h index 630b7fdf6c..f03e3b580e 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ccm.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ccm.h @@ -1,8 +1,11 @@ /** * \file ccm.h * - * \brief CCM combines Counter mode encryption with CBC-MAC authentication - * for 128-bit block ciphers. + * \brief This file provides an API for the CCM authenticated encryption + * mode for block ciphers. + * + * CCM combines Counter mode encryption with CBC-MAC authentication + * for 128-bit block ciphers. * * Input to CCM includes the following elements: *
  • Payload - data that is both authenticated and encrypted.
  • @@ -11,6 +14,18 @@ *
  • Nonce - A unique value that is assigned to the payload and the * associated data.
* + * Definition of CCM: + * http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf + * RFC 3610 "Counter with CBC-MAC (CCM)" + * + * Related: + * RFC 5116 "An Interface and Algorithms for Authenticated Encryption" + * + * Definition of CCM*: + * IEEE 802.15.4 - IEEE Standard for Local and metropolitan area networks + * Integer representation is fixed most-significant-octet-first order and + * the representation of octets is most-significant-bit-first order. This is + * consistent with RFC 3610. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved @@ -34,35 +49,48 @@ #ifndef MBEDTLS_CCM_H #define MBEDTLS_CCM_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "cipher.h" #define MBEDTLS_ERR_CCM_BAD_INPUT -0x000D /**< Bad input parameters to the function. */ #define MBEDTLS_ERR_CCM_AUTH_FAILED -0x000F /**< Authenticated decryption failed. */ -#define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011 /**< CCM hardware accelerator failed. */ -#if !defined(MBEDTLS_CCM_ALT) -// Regular implementation -// +/* MBEDTLS_ERR_CCM_HW_ACCEL_FAILED is deprecated and should not be used. */ +#define MBEDTLS_ERR_CCM_HW_ACCEL_FAILED -0x0011 /**< CCM hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_CCM_ALT) +// Regular implementation +// + /** * \brief The CCM context-type definition. The CCM context is passed * to the APIs called. */ -typedef struct { +typedef struct mbedtls_ccm_context +{ mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */ } mbedtls_ccm_context; +#else /* MBEDTLS_CCM_ALT */ +#include "ccm_alt.h" +#endif /* MBEDTLS_CCM_ALT */ + /** * \brief This function initializes the specified CCM context, * to make references valid, and prepare the context * for mbedtls_ccm_setkey() or mbedtls_ccm_free(). * - * \param ctx The CCM context to initialize. + * \param ctx The CCM context to initialize. This must not be \c NULL. */ void mbedtls_ccm_init( mbedtls_ccm_context *ctx ); @@ -70,12 +98,14 @@ void mbedtls_ccm_init( mbedtls_ccm_context *ctx ); * \brief This function initializes the CCM context set in the * \p ctx parameter and sets the encryption key. * - * \param ctx The CCM context to initialize. + * \param ctx The CCM context to initialize. This must be an initialized + * context. * \param cipher The 128-bit block cipher to use. - * \param key The encryption key. + * \param key The encryption key. This must not be \c NULL. * \param keybits The key size in bits. This must be acceptable by the cipher. * - * \return \c 0 on success, or a cipher-specific error code. + * \return \c 0 on success. + * \return A CCM or cipher-specific error code on failure. */ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, mbedtls_cipher_id_t cipher, @@ -86,36 +116,96 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, * \brief This function releases and clears the specified CCM context * and underlying cipher sub-context. * - * \param ctx The CCM context to clear. + * \param ctx The CCM context to clear. If this is \c NULL, the function + * has no effect. Otherwise, this must be initialized. */ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ); /** * \brief This function encrypts a buffer using CCM. * - * \param ctx The CCM context to use for encryption. + * \note The tag is written to a separate buffer. To concatenate + * the \p tag with the \p output, as done in RFC-3610: + * Counter with CBC-MAC (CCM), use + * \p tag = \p output + \p length, and make sure that the + * output buffer is at least \p length + \p tag_len wide. + * + * \param ctx The CCM context to use for encryption. This must be + * initialized and bound to a key. * \param length The length of the input data in Bytes. - * \param iv Initialization vector (nonce). - * \param iv_len The length of the IV in Bytes: 7, 8, 9, 10, 11, 12, or 13. - * \param add The additional data field. + * \param iv The initialization vector (nonce). This must be a readable + * buffer of at least \p iv_len Bytes. + * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, + * or 13. The length L of the message length field is + * 15 - \p iv_len. + * \param add The additional data field. If \p add_len is greater than + * zero, \p add must be a readable buffer of at least that + * length. * \param add_len The length of additional data in Bytes. - * Must be less than 2^16 - 2^8. - * \param input The buffer holding the input data. - * \param output The buffer holding the output data. - * Must be at least \p length Bytes wide. - * \param tag The buffer holding the tag. - * \param tag_len The length of the tag to generate in Bytes: + * This must be less than `2^16 - 2^8`. + * \param input The buffer holding the input data. If \p length is greater + * than zero, \p input must be a readable buffer of at least + * that length. + * \param output The buffer holding the output data. If \p length is greater + * than zero, \p output must be a writable buffer of at least + * that length. + * \param tag The buffer holding the authentication field. This must be a + * readable buffer of at least \p tag_len Bytes. + * \param tag_len The length of the authentication field to generate in Bytes: * 4, 6, 8, 10, 12, 14 or 16. * + * \return \c 0 on success. + * \return A CCM or cipher-specific error code on failure. + */ +int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + unsigned char *tag, size_t tag_len ); + +/** + * \brief This function encrypts a buffer using CCM*. + * * \note The tag is written to a separate buffer. To concatenate * the \p tag with the \p output, as done in RFC-3610: * Counter with CBC-MAC (CCM), use * \p tag = \p output + \p length, and make sure that the * output buffer is at least \p length + \p tag_len wide. * + * \note When using this function in a variable tag length context, + * the tag length has to be encoded into the \p iv passed to + * this function. + * + * \param ctx The CCM context to use for encryption. This must be + * initialized and bound to a key. + * \param length The length of the input data in Bytes. + * \param iv The initialization vector (nonce). This must be a readable + * buffer of at least \p iv_len Bytes. + * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, + * or 13. The length L of the message length field is + * 15 - \p iv_len. + * \param add The additional data field. This must be a readable buffer of + * at least \p add_len Bytes. + * \param add_len The length of additional data in Bytes. + * This must be less than 2^16 - 2^8. + * \param input The buffer holding the input data. If \p length is greater + * than zero, \p input must be a readable buffer of at least + * that length. + * \param output The buffer holding the output data. If \p length is greater + * than zero, \p output must be a writable buffer of at least + * that length. + * \param tag The buffer holding the authentication field. This must be a + * readable buffer of at least \p tag_len Bytes. + * \param tag_len The length of the authentication field to generate in Bytes: + * 0, 4, 6, 8, 10, 12, 14 or 16. + * + * \warning Passing \c 0 as \p tag_len means that the message is no + * longer authenticated. + * * \return \c 0 on success. + * \return A CCM or cipher-specific error code on failure. */ -int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, +int mbedtls_ccm_star_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, @@ -125,22 +215,32 @@ int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, * \brief This function performs a CCM authenticated decryption of a * buffer. * - * \param ctx The CCM context to use for decryption. + * \param ctx The CCM context to use for decryption. This must be + * initialized and bound to a key. * \param length The length of the input data in Bytes. - * \param iv Initialization vector. - * \param iv_len The length of the IV in Bytes: 7, 8, 9, 10, 11, 12, or 13. - * \param add The additional data field. + * \param iv The initialization vector (nonce). This must be a readable + * buffer of at least \p iv_len Bytes. + * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, + * or 13. The length L of the message length field is + * 15 - \p iv_len. + * \param add The additional data field. This must be a readable buffer + * of at least that \p add_len Bytes.. * \param add_len The length of additional data in Bytes. - * Must be less than 2^16 - 2^8. - * \param input The buffer holding the input data. - * \param output The buffer holding the output data. - * Must be at least \p length Bytes wide. - * \param tag The buffer holding the tag. - * \param tag_len The length of the tag in Bytes. + * This must be less than 2^16 - 2^8. + * \param input The buffer holding the input data. If \p length is greater + * than zero, \p input must be a readable buffer of at least + * that length. + * \param output The buffer holding the output data. If \p length is greater + * than zero, \p output must be a writable buffer of at least + * that length. + * \param tag The buffer holding the authentication field. This must be a + * readable buffer of at least \p tag_len Bytes. + * \param tag_len The length of the authentication field to generate in Bytes: * 4, 6, 8, 10, 12, 14 or 16. * - * \return 0 if successful and authenticated, or - * #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match. + * \return \c 0 on success. This indicates that the message is authentic. + * \return #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match. + * \return A cipher-specific error code on calculation failure. */ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, @@ -148,23 +248,57 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *input, unsigned char *output, const unsigned char *tag, size_t tag_len ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_CCM_ALT */ -#include "ccm_alt.h" -#endif /* MBEDTLS_CCM_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +/** + * \brief This function performs a CCM* authenticated decryption of a + * buffer. + * + * \note When using this function in a variable tag length context, + * the tag length has to be decoded from \p iv and passed to + * this function as \p tag_len. (\p tag needs to be adjusted + * accordingly.) + * + * \param ctx The CCM context to use for decryption. This must be + * initialized and bound to a key. + * \param length The length of the input data in Bytes. + * \param iv The initialization vector (nonce). This must be a readable + * buffer of at least \p iv_len Bytes. + * \param iv_len The length of the nonce in Bytes: 7, 8, 9, 10, 11, 12, + * or 13. The length L of the message length field is + * 15 - \p iv_len. + * \param add The additional data field. This must be a readable buffer of + * at least that \p add_len Bytes. + * \param add_len The length of additional data in Bytes. + * This must be less than 2^16 - 2^8. + * \param input The buffer holding the input data. If \p length is greater + * than zero, \p input must be a readable buffer of at least + * that length. + * \param output The buffer holding the output data. If \p length is greater + * than zero, \p output must be a writable buffer of at least + * that length. + * \param tag The buffer holding the authentication field. This must be a + * readable buffer of at least \p tag_len Bytes. + * \param tag_len The length of the authentication field in Bytes. + * 0, 4, 6, 8, 10, 12, 14 or 16. + * + * \warning Passing \c 0 as \p tag_len means that the message is nos + * longer authenticated. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CCM_AUTH_FAILED if the tag does not match. + * \return A cipher-specific error code on calculation failure. + */ +int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + const unsigned char *tag, size_t tag_len ); #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) /** * \brief The CCM checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_ccm_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/certs.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/certs.h index 8dab7b5ce8..179ebbbad2 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/certs.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/certs.h @@ -24,74 +24,226 @@ #ifndef MBEDTLS_CERTS_H #define MBEDTLS_CERTS_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include #ifdef __cplusplus extern "C" { #endif +/* List of all PEM-encoded CA certificates, terminated by NULL; + * PEM encoded if MBEDTLS_PEM_PARSE_C is enabled, DER encoded + * otherwise. */ +extern const char * mbedtls_test_cas[]; +extern const size_t mbedtls_test_cas_len[]; + +/* List of all DER-encoded CA certificates, terminated by NULL */ +extern const unsigned char * mbedtls_test_cas_der[]; +extern const size_t mbedtls_test_cas_der_len[]; + #if defined(MBEDTLS_PEM_PARSE_C) /* Concatenation of all CA certificates in PEM format if available */ extern const char mbedtls_test_cas_pem[]; extern const size_t mbedtls_test_cas_pem_len; -#endif - -/* List of all CA certificates, terminated by NULL */ -extern const char * mbedtls_test_cas[]; -extern const size_t mbedtls_test_cas_len[]; +#endif /* MBEDTLS_PEM_PARSE_C */ /* - * Convenience for users who just want a certificate: - * RSA by default, or ECDSA if RSA is not available + * CA test certificates */ + +extern const char mbedtls_test_ca_crt_ec_pem[]; +extern const char mbedtls_test_ca_key_ec_pem[]; +extern const char mbedtls_test_ca_pwd_ec_pem[]; +extern const char mbedtls_test_ca_key_rsa_pem[]; +extern const char mbedtls_test_ca_pwd_rsa_pem[]; +extern const char mbedtls_test_ca_crt_rsa_sha1_pem[]; +extern const char mbedtls_test_ca_crt_rsa_sha256_pem[]; + +extern const unsigned char mbedtls_test_ca_crt_ec_der[]; +extern const unsigned char mbedtls_test_ca_key_ec_der[]; +extern const unsigned char mbedtls_test_ca_key_rsa_der[]; +extern const unsigned char mbedtls_test_ca_crt_rsa_sha1_der[]; +extern const unsigned char mbedtls_test_ca_crt_rsa_sha256_der[]; + +extern const size_t mbedtls_test_ca_crt_ec_pem_len; +extern const size_t mbedtls_test_ca_key_ec_pem_len; +extern const size_t mbedtls_test_ca_pwd_ec_pem_len; +extern const size_t mbedtls_test_ca_key_rsa_pem_len; +extern const size_t mbedtls_test_ca_pwd_rsa_pem_len; +extern const size_t mbedtls_test_ca_crt_rsa_sha1_pem_len; +extern const size_t mbedtls_test_ca_crt_rsa_sha256_pem_len; + +extern const size_t mbedtls_test_ca_crt_ec_der_len; +extern const size_t mbedtls_test_ca_key_ec_der_len; +extern const size_t mbedtls_test_ca_pwd_ec_der_len; +extern const size_t mbedtls_test_ca_key_rsa_der_len; +extern const size_t mbedtls_test_ca_pwd_rsa_der_len; +extern const size_t mbedtls_test_ca_crt_rsa_sha1_der_len; +extern const size_t mbedtls_test_ca_crt_rsa_sha256_der_len; + +/* Config-dependent dispatch between PEM and DER encoding + * (PEM if enabled, otherwise DER) */ + +extern const char mbedtls_test_ca_crt_ec[]; +extern const char mbedtls_test_ca_key_ec[]; +extern const char mbedtls_test_ca_pwd_ec[]; +extern const char mbedtls_test_ca_key_rsa[]; +extern const char mbedtls_test_ca_pwd_rsa[]; +extern const char mbedtls_test_ca_crt_rsa_sha1[]; +extern const char mbedtls_test_ca_crt_rsa_sha256[]; + +extern const size_t mbedtls_test_ca_crt_ec_len; +extern const size_t mbedtls_test_ca_key_ec_len; +extern const size_t mbedtls_test_ca_pwd_ec_len; +extern const size_t mbedtls_test_ca_key_rsa_len; +extern const size_t mbedtls_test_ca_pwd_rsa_len; +extern const size_t mbedtls_test_ca_crt_rsa_sha1_len; +extern const size_t mbedtls_test_ca_crt_rsa_sha256_len; + +/* Config-dependent dispatch between SHA-1 and SHA-256 + * (SHA-256 if enabled, otherwise SHA-1) */ + +extern const char mbedtls_test_ca_crt_rsa[]; +extern const size_t mbedtls_test_ca_crt_rsa_len; + +/* Config-dependent dispatch between EC and RSA + * (RSA if enabled, otherwise EC) */ + extern const char * mbedtls_test_ca_crt; -extern const size_t mbedtls_test_ca_crt_len; extern const char * mbedtls_test_ca_key; -extern const size_t mbedtls_test_ca_key_len; extern const char * mbedtls_test_ca_pwd; +extern const size_t mbedtls_test_ca_crt_len; +extern const size_t mbedtls_test_ca_key_len; extern const size_t mbedtls_test_ca_pwd_len; + +/* + * Server test certificates + */ + +extern const char mbedtls_test_srv_crt_ec_pem[]; +extern const char mbedtls_test_srv_key_ec_pem[]; +extern const char mbedtls_test_srv_pwd_ec_pem[]; +extern const char mbedtls_test_srv_key_rsa_pem[]; +extern const char mbedtls_test_srv_pwd_rsa_pem[]; +extern const char mbedtls_test_srv_crt_rsa_sha1_pem[]; +extern const char mbedtls_test_srv_crt_rsa_sha256_pem[]; + +extern const unsigned char mbedtls_test_srv_crt_ec_der[]; +extern const unsigned char mbedtls_test_srv_key_ec_der[]; +extern const unsigned char mbedtls_test_srv_key_rsa_der[]; +extern const unsigned char mbedtls_test_srv_crt_rsa_sha1_der[]; +extern const unsigned char mbedtls_test_srv_crt_rsa_sha256_der[]; + +extern const size_t mbedtls_test_srv_crt_ec_pem_len; +extern const size_t mbedtls_test_srv_key_ec_pem_len; +extern const size_t mbedtls_test_srv_pwd_ec_pem_len; +extern const size_t mbedtls_test_srv_key_rsa_pem_len; +extern const size_t mbedtls_test_srv_pwd_rsa_pem_len; +extern const size_t mbedtls_test_srv_crt_rsa_sha1_pem_len; +extern const size_t mbedtls_test_srv_crt_rsa_sha256_pem_len; + +extern const size_t mbedtls_test_srv_crt_ec_der_len; +extern const size_t mbedtls_test_srv_key_ec_der_len; +extern const size_t mbedtls_test_srv_pwd_ec_der_len; +extern const size_t mbedtls_test_srv_key_rsa_der_len; +extern const size_t mbedtls_test_srv_pwd_rsa_der_len; +extern const size_t mbedtls_test_srv_crt_rsa_sha1_der_len; +extern const size_t mbedtls_test_srv_crt_rsa_sha256_der_len; + +/* Config-dependent dispatch between PEM and DER encoding + * (PEM if enabled, otherwise DER) */ + +extern const char mbedtls_test_srv_crt_ec[]; +extern const char mbedtls_test_srv_key_ec[]; +extern const char mbedtls_test_srv_pwd_ec[]; +extern const char mbedtls_test_srv_key_rsa[]; +extern const char mbedtls_test_srv_pwd_rsa[]; +extern const char mbedtls_test_srv_crt_rsa_sha1[]; +extern const char mbedtls_test_srv_crt_rsa_sha256[]; + +extern const size_t mbedtls_test_srv_crt_ec_len; +extern const size_t mbedtls_test_srv_key_ec_len; +extern const size_t mbedtls_test_srv_pwd_ec_len; +extern const size_t mbedtls_test_srv_key_rsa_len; +extern const size_t mbedtls_test_srv_pwd_rsa_len; +extern const size_t mbedtls_test_srv_crt_rsa_sha1_len; +extern const size_t mbedtls_test_srv_crt_rsa_sha256_len; + +/* Config-dependent dispatch between SHA-1 and SHA-256 + * (SHA-256 if enabled, otherwise SHA-1) */ + +extern const char mbedtls_test_srv_crt_rsa[]; +extern const size_t mbedtls_test_srv_crt_rsa_len; + +/* Config-dependent dispatch between EC and RSA + * (RSA if enabled, otherwise EC) */ + extern const char * mbedtls_test_srv_crt; -extern const size_t mbedtls_test_srv_crt_len; extern const char * mbedtls_test_srv_key; +extern const char * mbedtls_test_srv_pwd; +extern const size_t mbedtls_test_srv_crt_len; extern const size_t mbedtls_test_srv_key_len; -extern const char * mbedtls_test_cli_crt; -extern const size_t mbedtls_test_cli_crt_len; -extern const char * mbedtls_test_cli_key; -extern const size_t mbedtls_test_cli_key_len; +extern const size_t mbedtls_test_srv_pwd_len; + +/* + * Client test certificates + */ + +extern const char mbedtls_test_cli_crt_ec_pem[]; +extern const char mbedtls_test_cli_key_ec_pem[]; +extern const char mbedtls_test_cli_pwd_ec_pem[]; +extern const char mbedtls_test_cli_key_rsa_pem[]; +extern const char mbedtls_test_cli_pwd_rsa_pem[]; +extern const char mbedtls_test_cli_crt_rsa_pem[]; + +extern const unsigned char mbedtls_test_cli_crt_ec_der[]; +extern const unsigned char mbedtls_test_cli_key_ec_der[]; +extern const unsigned char mbedtls_test_cli_key_rsa_der[]; +extern const unsigned char mbedtls_test_cli_crt_rsa_der[]; + +extern const size_t mbedtls_test_cli_crt_ec_pem_len; +extern const size_t mbedtls_test_cli_key_ec_pem_len; +extern const size_t mbedtls_test_cli_pwd_ec_pem_len; +extern const size_t mbedtls_test_cli_key_rsa_pem_len; +extern const size_t mbedtls_test_cli_pwd_rsa_pem_len; +extern const size_t mbedtls_test_cli_crt_rsa_pem_len; + +extern const size_t mbedtls_test_cli_crt_ec_der_len; +extern const size_t mbedtls_test_cli_key_ec_der_len; +extern const size_t mbedtls_test_cli_key_rsa_der_len; +extern const size_t mbedtls_test_cli_crt_rsa_der_len; + +/* Config-dependent dispatch between PEM and DER encoding + * (PEM if enabled, otherwise DER) */ + +extern const char mbedtls_test_cli_crt_ec[]; +extern const char mbedtls_test_cli_key_ec[]; +extern const char mbedtls_test_cli_pwd_ec[]; +extern const char mbedtls_test_cli_key_rsa[]; +extern const char mbedtls_test_cli_pwd_rsa[]; +extern const char mbedtls_test_cli_crt_rsa[]; -#if defined(MBEDTLS_ECDSA_C) -extern const char mbedtls_test_ca_crt_ec[]; -extern const size_t mbedtls_test_ca_crt_ec_len; -extern const char mbedtls_test_ca_key_ec[]; -extern const size_t mbedtls_test_ca_key_ec_len; -extern const char mbedtls_test_ca_pwd_ec[]; -extern const size_t mbedtls_test_ca_pwd_ec_len; -extern const char mbedtls_test_srv_crt_ec[]; -extern const size_t mbedtls_test_srv_crt_ec_len; -extern const char mbedtls_test_srv_key_ec[]; -extern const size_t mbedtls_test_srv_key_ec_len; -extern const char mbedtls_test_cli_crt_ec[]; extern const size_t mbedtls_test_cli_crt_ec_len; -extern const char mbedtls_test_cli_key_ec[]; extern const size_t mbedtls_test_cli_key_ec_len; -#endif - -#if defined(MBEDTLS_RSA_C) -extern const char mbedtls_test_ca_crt_rsa[]; -extern const size_t mbedtls_test_ca_crt_rsa_len; -extern const char mbedtls_test_ca_key_rsa[]; -extern const size_t mbedtls_test_ca_key_rsa_len; -extern const char mbedtls_test_ca_pwd_rsa[]; -extern const size_t mbedtls_test_ca_pwd_rsa_len; -extern const char mbedtls_test_srv_crt_rsa[]; -extern const size_t mbedtls_test_srv_crt_rsa_len; -extern const char mbedtls_test_srv_key_rsa[]; -extern const size_t mbedtls_test_srv_key_rsa_len; -extern const char mbedtls_test_cli_crt_rsa[]; -extern const size_t mbedtls_test_cli_crt_rsa_len; -extern const char mbedtls_test_cli_key_rsa[]; +extern const size_t mbedtls_test_cli_pwd_ec_len; extern const size_t mbedtls_test_cli_key_rsa_len; -#endif +extern const size_t mbedtls_test_cli_pwd_rsa_len; +extern const size_t mbedtls_test_cli_crt_rsa_len; + +/* Config-dependent dispatch between EC and RSA + * (RSA if enabled, otherwise EC) */ + +extern const char * mbedtls_test_cli_crt; +extern const char * mbedtls_test_cli_key; +extern const char * mbedtls_test_cli_pwd; +extern const size_t mbedtls_test_cli_crt_len; +extern const size_t mbedtls_test_cli_key_len; +extern const size_t mbedtls_test_cli_pwd_len; #ifdef __cplusplus } diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/chacha20.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/chacha20.h new file mode 100644 index 0000000000..2ae5e6e5f4 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/chacha20.h @@ -0,0 +1,226 @@ +/** + * \file chacha20.h + * + * \brief This file contains ChaCha20 definitions and functions. + * + * ChaCha20 is a stream cipher that can encrypt and decrypt + * information. ChaCha was created by Daniel Bernstein as a variant of + * its Salsa cipher https://cr.yp.to/chacha/chacha-20080128.pdf + * ChaCha20 is the variant with 20 rounds, that was also standardized + * in RFC 7539. + * + * \author Daniel King + */ + +/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_CHACHA20_H +#define MBEDTLS_CHACHA20_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#define MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA -0x0051 /**< Invalid input parameter(s). */ + +/* MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE is deprecated and should not be + * used. */ +#define MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE -0x0053 /**< Feature not available. For example, s part of the API is not implemented. */ + +/* MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED is deprecated and should not be used. + */ +#define MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED -0x0055 /**< Chacha20 hardware accelerator failed. */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(MBEDTLS_CHACHA20_ALT) + +typedef struct mbedtls_chacha20_context +{ + uint32_t state[16]; /*! The state (before round operations). */ + uint8_t keystream8[64]; /*! Leftover keystream bytes. */ + size_t keystream_bytes_used; /*! Number of keystream bytes already used. */ +} +mbedtls_chacha20_context; + +#else /* MBEDTLS_CHACHA20_ALT */ +#include "chacha20_alt.h" +#endif /* MBEDTLS_CHACHA20_ALT */ + +/** + * \brief This function initializes the specified ChaCha20 context. + * + * It must be the first API called before using + * the context. + * + * It is usually followed by calls to + * \c mbedtls_chacha20_setkey() and + * \c mbedtls_chacha20_starts(), then one or more calls to + * to \c mbedtls_chacha20_update(), and finally to + * \c mbedtls_chacha20_free(). + * + * \param ctx The ChaCha20 context to initialize. + * This must not be \c NULL. + */ +void mbedtls_chacha20_init( mbedtls_chacha20_context *ctx ); + +/** + * \brief This function releases and clears the specified + * ChaCha20 context. + * + * \param ctx The ChaCha20 context to clear. This may be \c NULL, + * in which case this function is a no-op. If it is not + * \c NULL, it must point to an initialized context. + * + */ +void mbedtls_chacha20_free( mbedtls_chacha20_context *ctx ); + +/** + * \brief This function sets the encryption/decryption key. + * + * \note After using this function, you must also call + * \c mbedtls_chacha20_starts() to set a nonce before you + * start encrypting/decrypting data with + * \c mbedtls_chacha_update(). + * + * \param ctx The ChaCha20 context to which the key should be bound. + * It must be initialized. + * \param key The encryption/decryption key. This must be \c 32 Bytes + * in length. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA if ctx or key is NULL. + */ +int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx, + const unsigned char key[32] ); + +/** + * \brief This function sets the nonce and initial counter value. + * + * \note A ChaCha20 context can be re-used with the same key by + * calling this function to change the nonce. + * + * \warning You must never use the same nonce twice with the same key. + * This would void any confidentiality guarantees for the + * messages encrypted with the same nonce and key. + * + * \param ctx The ChaCha20 context to which the nonce should be bound. + * It must be initialized and bound to a key. + * \param nonce The nonce. This must be \c 12 Bytes in size. + * \param counter The initial counter value. This is usually \c 0. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA if ctx or nonce is + * NULL. + */ +int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx, + const unsigned char nonce[12], + uint32_t counter ); + +/** + * \brief This function encrypts or decrypts data. + * + * Since ChaCha20 is a stream cipher, the same operation is + * used for encrypting and decrypting data. + * + * \note The \p input and \p output pointers must either be equal or + * point to non-overlapping buffers. + * + * \note \c mbedtls_chacha20_setkey() and + * \c mbedtls_chacha20_starts() must be called at least once + * to setup the context before this function can be called. + * + * \note This function can be called multiple times in a row in + * order to encrypt of decrypt data piecewise with the same + * key and nonce. + * + * \param ctx The ChaCha20 context to use for encryption or decryption. + * It must be initialized and bound to a key and nonce. + * \param size The length of the input data in Bytes. + * \param input The buffer holding the input data. + * This pointer can be \c NULL if `size == 0`. + * \param output The buffer holding the output data. + * This must be able to hold \p size Bytes. + * This pointer can be \c NULL if `size == 0`. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_chacha20_update( mbedtls_chacha20_context *ctx, + size_t size, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief This function encrypts or decrypts data with ChaCha20 and + * the given key and nonce. + * + * Since ChaCha20 is a stream cipher, the same operation is + * used for encrypting and decrypting data. + * + * \warning You must never use the same (key, nonce) pair more than + * once. This would void any confidentiality guarantees for + * the messages encrypted with the same nonce and key. + * + * \note The \p input and \p output pointers must either be equal or + * point to non-overlapping buffers. + * + * \param key The encryption/decryption key. + * This must be \c 32 Bytes in length. + * \param nonce The nonce. This must be \c 12 Bytes in size. + * \param counter The initial counter value. This is usually \c 0. + * \param size The length of the input data in Bytes. + * \param input The buffer holding the input data. + * This pointer can be \c NULL if `size == 0`. + * \param output The buffer holding the output data. + * This must be able to hold \p size Bytes. + * This pointer can be \c NULL if `size == 0`. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_chacha20_crypt( const unsigned char key[32], + const unsigned char nonce[12], + uint32_t counter, + size_t size, + const unsigned char* input, + unsigned char* output ); + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief The ChaCha20 checkup routine. + * + * \return \c 0 on success. + * \return \c 1 on failure. + */ +int mbedtls_chacha20_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CHACHA20_H */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/chachapoly.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/chachapoly.h new file mode 100644 index 0000000000..49e615d278 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/chachapoly.h @@ -0,0 +1,358 @@ +/** + * \file chachapoly.h + * + * \brief This file contains the AEAD-ChaCha20-Poly1305 definitions and + * functions. + * + * ChaCha20-Poly1305 is an algorithm for Authenticated Encryption + * with Associated Data (AEAD) that can be used to encrypt and + * authenticate data. It is based on ChaCha20 and Poly1305 by Daniel + * Bernstein and was standardized in RFC 7539. + * + * \author Daniel King + */ + +/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_CHACHAPOLY_H +#define MBEDTLS_CHACHAPOLY_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +/* for shared error codes */ +#include "poly1305.h" + +#define MBEDTLS_ERR_CHACHAPOLY_BAD_STATE -0x0054 /**< The requested operation is not permitted in the current state. */ +#define MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED -0x0056 /**< Authenticated decryption failed: data was not authentic. */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + MBEDTLS_CHACHAPOLY_ENCRYPT, /**< The mode value for performing encryption. */ + MBEDTLS_CHACHAPOLY_DECRYPT /**< The mode value for performing decryption. */ +} +mbedtls_chachapoly_mode_t; + +#if !defined(MBEDTLS_CHACHAPOLY_ALT) + +#include "chacha20.h" + +typedef struct mbedtls_chachapoly_context +{ + mbedtls_chacha20_context chacha20_ctx; /**< The ChaCha20 context. */ + mbedtls_poly1305_context poly1305_ctx; /**< The Poly1305 context. */ + uint64_t aad_len; /**< The length (bytes) of the Additional Authenticated Data. */ + uint64_t ciphertext_len; /**< The length (bytes) of the ciphertext. */ + int state; /**< The current state of the context. */ + mbedtls_chachapoly_mode_t mode; /**< Cipher mode (encrypt or decrypt). */ +} +mbedtls_chachapoly_context; + +#else /* !MBEDTLS_CHACHAPOLY_ALT */ +#include "chachapoly_alt.h" +#endif /* !MBEDTLS_CHACHAPOLY_ALT */ + +/** + * \brief This function initializes the specified ChaCha20-Poly1305 context. + * + * It must be the first API called before using + * the context. It must be followed by a call to + * \c mbedtls_chachapoly_setkey() before any operation can be + * done, and to \c mbedtls_chachapoly_free() once all + * operations with that context have been finished. + * + * In order to encrypt or decrypt full messages at once, for + * each message you should make a single call to + * \c mbedtls_chachapoly_crypt_and_tag() or + * \c mbedtls_chachapoly_auth_decrypt(). + * + * In order to encrypt messages piecewise, for each + * message you should make a call to + * \c mbedtls_chachapoly_starts(), then 0 or more calls to + * \c mbedtls_chachapoly_update_aad(), then 0 or more calls to + * \c mbedtls_chachapoly_update(), then one call to + * \c mbedtls_chachapoly_finish(). + * + * \warning Decryption with the piecewise API is discouraged! Always + * use \c mbedtls_chachapoly_auth_decrypt() when possible! + * + * If however this is not possible because the data is too + * large to fit in memory, you need to: + * + * - call \c mbedtls_chachapoly_starts() and (if needed) + * \c mbedtls_chachapoly_update_aad() as above, + * - call \c mbedtls_chachapoly_update() multiple times and + * ensure its output (the plaintext) is NOT used in any other + * way than placing it in temporary storage at this point, + * - call \c mbedtls_chachapoly_finish() to compute the + * authentication tag and compared it in constant time to the + * tag received with the ciphertext. + * + * If the tags are not equal, you must immediately discard + * all previous outputs of \c mbedtls_chachapoly_update(), + * otherwise you can now safely use the plaintext. + * + * \param ctx The ChachaPoly context to initialize. Must not be \c NULL. + */ +void mbedtls_chachapoly_init( mbedtls_chachapoly_context *ctx ); + +/** + * \brief This function releases and clears the specified + * ChaCha20-Poly1305 context. + * + * \param ctx The ChachaPoly context to clear. This may be \c NULL, in which + * case this function is a no-op. + */ +void mbedtls_chachapoly_free( mbedtls_chachapoly_context *ctx ); + +/** + * \brief This function sets the ChaCha20-Poly1305 + * symmetric encryption key. + * + * \param ctx The ChaCha20-Poly1305 context to which the key should be + * bound. This must be initialized. + * \param key The \c 256 Bit (\c 32 Bytes) key. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx, + const unsigned char key[32] ); + +/** + * \brief This function starts a ChaCha20-Poly1305 encryption or + * decryption operation. + * + * \warning You must never use the same nonce twice with the same key. + * This would void any confidentiality and authenticity + * guarantees for the messages encrypted with the same nonce + * and key. + * + * \note If the context is being used for AAD only (no data to + * encrypt or decrypt) then \p mode can be set to any value. + * + * \warning Decryption with the piecewise API is discouraged, see the + * warning on \c mbedtls_chachapoly_init(). + * + * \param ctx The ChaCha20-Poly1305 context. This must be initialized + * and bound to a key. + * \param nonce The nonce/IV to use for the message. + * This must be a redable buffer of length \c 12 Bytes. + * \param mode The operation to perform: #MBEDTLS_CHACHAPOLY_ENCRYPT or + * #MBEDTLS_CHACHAPOLY_DECRYPT (discouraged, see warning). + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx, + const unsigned char nonce[12], + mbedtls_chachapoly_mode_t mode ); + +/** + * \brief This function feeds additional data to be authenticated + * into an ongoing ChaCha20-Poly1305 operation. + * + * The Additional Authenticated Data (AAD), also called + * Associated Data (AD) is only authenticated but not + * encrypted nor included in the encrypted output. It is + * usually transmitted separately from the ciphertext or + * computed locally by each party. + * + * \note This function is called before data is encrypted/decrypted. + * I.e. call this function to process the AAD before calling + * \c mbedtls_chachapoly_update(). + * + * You may call this function multiple times to process + * an arbitrary amount of AAD. It is permitted to call + * this function 0 times, if no AAD is used. + * + * This function cannot be called any more if data has + * been processed by \c mbedtls_chachapoly_update(), + * or if the context has been finished. + * + * \warning Decryption with the piecewise API is discouraged, see the + * warning on \c mbedtls_chachapoly_init(). + * + * \param ctx The ChaCha20-Poly1305 context. This must be initialized + * and bound to a key. + * \param aad_len The length in Bytes of the AAD. The length has no + * restrictions. + * \param aad Buffer containing the AAD. + * This pointer can be \c NULL if `aad_len == 0`. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA + * if \p ctx or \p aad are NULL. + * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE + * if the operations has not been started or has been + * finished, or if the AAD has been finished. + */ +int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx, + const unsigned char *aad, + size_t aad_len ); + +/** + * \brief Thus function feeds data to be encrypted or decrypted + * into an on-going ChaCha20-Poly1305 + * operation. + * + * The direction (encryption or decryption) depends on the + * mode that was given when calling + * \c mbedtls_chachapoly_starts(). + * + * You may call this function multiple times to process + * an arbitrary amount of data. It is permitted to call + * this function 0 times, if no data is to be encrypted + * or decrypted. + * + * \warning Decryption with the piecewise API is discouraged, see the + * warning on \c mbedtls_chachapoly_init(). + * + * \param ctx The ChaCha20-Poly1305 context to use. This must be initialized. + * \param len The length (in bytes) of the data to encrypt or decrypt. + * \param input The buffer containing the data to encrypt or decrypt. + * This pointer can be \c NULL if `len == 0`. + * \param output The buffer to where the encrypted or decrypted data is + * written. This must be able to hold \p len bytes. + * This pointer can be \c NULL if `len == 0`. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE + * if the operation has not been started or has been + * finished. + * \return Another negative error code on other kinds of failure. + */ +int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx, + size_t len, + const unsigned char *input, + unsigned char *output ); + +/** + * \brief This function finished the ChaCha20-Poly1305 operation and + * generates the MAC (authentication tag). + * + * \param ctx The ChaCha20-Poly1305 context to use. This must be initialized. + * \param mac The buffer to where the 128-bit (16 bytes) MAC is written. + * + * \warning Decryption with the piecewise API is discouraged, see the + * warning on \c mbedtls_chachapoly_init(). + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE + * if the operation has not been started or has been + * finished. + * \return Another negative error code on other kinds of failure. + */ +int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx, + unsigned char mac[16] ); + +/** + * \brief This function performs a complete ChaCha20-Poly1305 + * authenticated encryption with the previously-set key. + * + * \note Before using this function, you must set the key with + * \c mbedtls_chachapoly_setkey(). + * + * \warning You must never use the same nonce twice with the same key. + * This would void any confidentiality and authenticity + * guarantees for the messages encrypted with the same nonce + * and key. + * + * \param ctx The ChaCha20-Poly1305 context to use (holds the key). + * This must be initialized. + * \param length The length (in bytes) of the data to encrypt or decrypt. + * \param nonce The 96-bit (12 bytes) nonce/IV to use. + * \param aad The buffer containing the additional authenticated + * data (AAD). This pointer can be \c NULL if `aad_len == 0`. + * \param aad_len The length (in bytes) of the AAD data to process. + * \param input The buffer containing the data to encrypt or decrypt. + * This pointer can be \c NULL if `ilen == 0`. + * \param output The buffer to where the encrypted or decrypted data + * is written. This pointer can be \c NULL if `ilen == 0`. + * \param tag The buffer to where the computed 128-bit (16 bytes) MAC + * is written. This must not be \c NULL. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_chachapoly_encrypt_and_tag( mbedtls_chachapoly_context *ctx, + size_t length, + const unsigned char nonce[12], + const unsigned char *aad, + size_t aad_len, + const unsigned char *input, + unsigned char *output, + unsigned char tag[16] ); + +/** + * \brief This function performs a complete ChaCha20-Poly1305 + * authenticated decryption with the previously-set key. + * + * \note Before using this function, you must set the key with + * \c mbedtls_chachapoly_setkey(). + * + * \param ctx The ChaCha20-Poly1305 context to use (holds the key). + * \param length The length (in Bytes) of the data to decrypt. + * \param nonce The \c 96 Bit (\c 12 bytes) nonce/IV to use. + * \param aad The buffer containing the additional authenticated data (AAD). + * This pointer can be \c NULL if `aad_len == 0`. + * \param aad_len The length (in bytes) of the AAD data to process. + * \param tag The buffer holding the authentication tag. + * This must be a readable buffer of length \c 16 Bytes. + * \param input The buffer containing the data to decrypt. + * This pointer can be \c NULL if `ilen == 0`. + * \param output The buffer to where the decrypted data is written. + * This pointer can be \c NULL if `ilen == 0`. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED + * if the data was not authentic. + * \return Another negative error code on other kinds of failure. + */ +int mbedtls_chachapoly_auth_decrypt( mbedtls_chachapoly_context *ctx, + size_t length, + const unsigned char nonce[12], + const unsigned char *aad, + size_t aad_len, + const unsigned char tag[16], + const unsigned char *input, + unsigned char *output ); + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief The ChaCha20-Poly1305 checkup routine. + * + * \return \c 0 on success. + * \return \c 1 on failure. + */ +int mbedtls_chachapoly_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_CHACHAPOLY_H */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/check_config.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/check_config.h index fa7110fe92..b86e5807e0 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/check_config.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/check_config.h @@ -4,7 +4,7 @@ * \brief Consistency checks for configuration options */ /* - * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -87,6 +87,11 @@ #error "MBEDTLS_CMAC_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_NIST_KW_C) && \ + ( !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_CIPHER_C) ) +#error "MBEDTLS_NIST_KW_C defined, but not all prerequisites" +#endif + #if defined(MBEDTLS_ECDH_C) && !defined(MBEDTLS_ECP_C) #error "MBEDTLS_ECDH_C defined, but not all prerequisites" #endif @@ -103,6 +108,17 @@ #error "MBEDTLS_ECJPAKE_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_ECP_RESTARTABLE) && \ + ( defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) || \ + defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) || \ + defined(MBEDTLS_ECDSA_SIGN_ALT) || \ + defined(MBEDTLS_ECDSA_VERIFY_ALT) || \ + defined(MBEDTLS_ECDSA_GENKEY_ALT) || \ + defined(MBEDTLS_ECP_INTERNAL_ALT) || \ + defined(MBEDTLS_ECP_ALT) ) +#error "MBEDTLS_ECP_RESTARTABLE defined, but it cannot coexist with an alternative ECP implementation" +#endif + #if defined(MBEDTLS_ECDSA_DETERMINISTIC) && !defined(MBEDTLS_HMAC_DRBG_C) #error "MBEDTLS_ECDSA_DETERMINISTIC defined, but not all prerequisites" #endif @@ -195,6 +211,10 @@ #error "MBEDTLS_HAVEGE_C defined, but not all prerequisites" #endif +#if defined(MBEDTLS_HKDF_C) && !defined(MBEDTLS_MD_C) +#error "MBEDTLS_HKDF_C defined, but not all prerequisites" +#endif + #if defined(MBEDTLS_HMAC_DRBG_C) && !defined(MBEDTLS_MD_C) #error "MBEDTLS_HMAC_DRBG_C defined, but not all prerequisites" #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher.h index 1c453a1d32..082a691741 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher.h @@ -1,7 +1,9 @@ /** * \file cipher.h * - * \brief The generic cipher wrapper. + * \brief This file contains an abstraction interface for use with the cipher + * primitives provided by the library. It provides a common interface to all of + * the available cipher operations. * * \author Adriaan de Jong */ @@ -34,8 +36,9 @@ #endif #include +#include "platform_util.h" -#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) || defined(MBEDTLS_CHACHAPOLY_C) #define MBEDTLS_CIPHER_MODE_AEAD #endif @@ -43,7 +46,8 @@ #define MBEDTLS_CIPHER_MODE_WITH_PADDING #endif -#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) +#if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \ + defined(MBEDTLS_CHACHA20_C) #define MBEDTLS_CIPHER_MODE_STREAM #endif @@ -59,6 +63,8 @@ #define MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */ #define MBEDTLS_ERR_CIPHER_AUTH_FAILED -0x6300 /**< Authentication failed (for AEAD modes). */ #define MBEDTLS_ERR_CIPHER_INVALID_CONTEXT -0x6380 /**< The context is invalid. For example, because it was freed. */ + +/* MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED -0x6400 /**< Cipher hardware accelerator failed. */ #define MBEDTLS_CIPHER_VARIABLE_IV_LEN 0x01 /**< Cipher accepts IVs of variable length. */ @@ -69,93 +75,122 @@ extern "C" { #endif /** - * \brief An enumeration of supported ciphers. + * \brief Supported cipher types. * - * \warning ARC4 and DES are considered weak ciphers and their use - * constitutes a security risk. We recommend considering stronger + * \warning RC4 and DES are considered weak ciphers and their use + * constitutes a security risk. Arm recommends considering stronger * ciphers instead. */ typedef enum { - MBEDTLS_CIPHER_ID_NONE = 0, - MBEDTLS_CIPHER_ID_NULL, - MBEDTLS_CIPHER_ID_AES, - MBEDTLS_CIPHER_ID_DES, - MBEDTLS_CIPHER_ID_3DES, - MBEDTLS_CIPHER_ID_CAMELLIA, - MBEDTLS_CIPHER_ID_BLOWFISH, - MBEDTLS_CIPHER_ID_ARC4, + MBEDTLS_CIPHER_ID_NONE = 0, /**< Placeholder to mark the end of cipher ID lists. */ + MBEDTLS_CIPHER_ID_NULL, /**< The identity cipher, treated as a stream cipher. */ + MBEDTLS_CIPHER_ID_AES, /**< The AES cipher. */ + MBEDTLS_CIPHER_ID_DES, /**< The DES cipher. */ + MBEDTLS_CIPHER_ID_3DES, /**< The Triple DES cipher. */ + MBEDTLS_CIPHER_ID_CAMELLIA, /**< The Camellia cipher. */ + MBEDTLS_CIPHER_ID_BLOWFISH, /**< The Blowfish cipher. */ + MBEDTLS_CIPHER_ID_ARC4, /**< The RC4 cipher. */ + MBEDTLS_CIPHER_ID_ARIA, /**< The Aria cipher. */ + MBEDTLS_CIPHER_ID_CHACHA20, /**< The ChaCha20 cipher. */ } mbedtls_cipher_id_t; /** - * \brief An enumeration of supported (cipher, mode) pairs. + * \brief Supported {cipher type, cipher mode} pairs. * - * \warning ARC4 and DES are considered weak ciphers and their use - * constitutes a security risk. We recommend considering stronger + * \warning RC4 and DES are considered weak ciphers and their use + * constitutes a security risk. Arm recommends considering stronger * ciphers instead. */ typedef enum { - MBEDTLS_CIPHER_NONE = 0, - MBEDTLS_CIPHER_NULL, - MBEDTLS_CIPHER_AES_128_ECB, - MBEDTLS_CIPHER_AES_192_ECB, - MBEDTLS_CIPHER_AES_256_ECB, - MBEDTLS_CIPHER_AES_128_CBC, - MBEDTLS_CIPHER_AES_192_CBC, - MBEDTLS_CIPHER_AES_256_CBC, - MBEDTLS_CIPHER_AES_128_CFB128, - MBEDTLS_CIPHER_AES_192_CFB128, - MBEDTLS_CIPHER_AES_256_CFB128, - MBEDTLS_CIPHER_AES_128_CTR, - MBEDTLS_CIPHER_AES_192_CTR, - MBEDTLS_CIPHER_AES_256_CTR, - MBEDTLS_CIPHER_AES_128_GCM, - MBEDTLS_CIPHER_AES_192_GCM, - MBEDTLS_CIPHER_AES_256_GCM, - MBEDTLS_CIPHER_CAMELLIA_128_ECB, - MBEDTLS_CIPHER_CAMELLIA_192_ECB, - MBEDTLS_CIPHER_CAMELLIA_256_ECB, - MBEDTLS_CIPHER_CAMELLIA_128_CBC, - MBEDTLS_CIPHER_CAMELLIA_192_CBC, - MBEDTLS_CIPHER_CAMELLIA_256_CBC, - MBEDTLS_CIPHER_CAMELLIA_128_CFB128, - MBEDTLS_CIPHER_CAMELLIA_192_CFB128, - MBEDTLS_CIPHER_CAMELLIA_256_CFB128, - MBEDTLS_CIPHER_CAMELLIA_128_CTR, - MBEDTLS_CIPHER_CAMELLIA_192_CTR, - MBEDTLS_CIPHER_CAMELLIA_256_CTR, - MBEDTLS_CIPHER_CAMELLIA_128_GCM, - MBEDTLS_CIPHER_CAMELLIA_192_GCM, - MBEDTLS_CIPHER_CAMELLIA_256_GCM, - MBEDTLS_CIPHER_DES_ECB, - MBEDTLS_CIPHER_DES_CBC, - MBEDTLS_CIPHER_DES_EDE_ECB, - MBEDTLS_CIPHER_DES_EDE_CBC, - MBEDTLS_CIPHER_DES_EDE3_ECB, - MBEDTLS_CIPHER_DES_EDE3_CBC, - MBEDTLS_CIPHER_BLOWFISH_ECB, - MBEDTLS_CIPHER_BLOWFISH_CBC, - MBEDTLS_CIPHER_BLOWFISH_CFB64, - MBEDTLS_CIPHER_BLOWFISH_CTR, - MBEDTLS_CIPHER_ARC4_128, - MBEDTLS_CIPHER_AES_128_CCM, - MBEDTLS_CIPHER_AES_192_CCM, - MBEDTLS_CIPHER_AES_256_CCM, - MBEDTLS_CIPHER_CAMELLIA_128_CCM, - MBEDTLS_CIPHER_CAMELLIA_192_CCM, - MBEDTLS_CIPHER_CAMELLIA_256_CCM, + MBEDTLS_CIPHER_NONE = 0, /**< Placeholder to mark the end of cipher-pair lists. */ + MBEDTLS_CIPHER_NULL, /**< The identity stream cipher. */ + MBEDTLS_CIPHER_AES_128_ECB, /**< AES cipher with 128-bit ECB mode. */ + MBEDTLS_CIPHER_AES_192_ECB, /**< AES cipher with 192-bit ECB mode. */ + MBEDTLS_CIPHER_AES_256_ECB, /**< AES cipher with 256-bit ECB mode. */ + MBEDTLS_CIPHER_AES_128_CBC, /**< AES cipher with 128-bit CBC mode. */ + MBEDTLS_CIPHER_AES_192_CBC, /**< AES cipher with 192-bit CBC mode. */ + MBEDTLS_CIPHER_AES_256_CBC, /**< AES cipher with 256-bit CBC mode. */ + MBEDTLS_CIPHER_AES_128_CFB128, /**< AES cipher with 128-bit CFB128 mode. */ + MBEDTLS_CIPHER_AES_192_CFB128, /**< AES cipher with 192-bit CFB128 mode. */ + MBEDTLS_CIPHER_AES_256_CFB128, /**< AES cipher with 256-bit CFB128 mode. */ + MBEDTLS_CIPHER_AES_128_CTR, /**< AES cipher with 128-bit CTR mode. */ + MBEDTLS_CIPHER_AES_192_CTR, /**< AES cipher with 192-bit CTR mode. */ + MBEDTLS_CIPHER_AES_256_CTR, /**< AES cipher with 256-bit CTR mode. */ + MBEDTLS_CIPHER_AES_128_GCM, /**< AES cipher with 128-bit GCM mode. */ + MBEDTLS_CIPHER_AES_192_GCM, /**< AES cipher with 192-bit GCM mode. */ + MBEDTLS_CIPHER_AES_256_GCM, /**< AES cipher with 256-bit GCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_ECB, /**< Camellia cipher with 128-bit ECB mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_ECB, /**< Camellia cipher with 192-bit ECB mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_ECB, /**< Camellia cipher with 256-bit ECB mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_CBC, /**< Camellia cipher with 128-bit CBC mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_CBC, /**< Camellia cipher with 192-bit CBC mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_CBC, /**< Camellia cipher with 256-bit CBC mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_CFB128, /**< Camellia cipher with 128-bit CFB128 mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_CFB128, /**< Camellia cipher with 192-bit CFB128 mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_CFB128, /**< Camellia cipher with 256-bit CFB128 mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_CTR, /**< Camellia cipher with 128-bit CTR mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_CTR, /**< Camellia cipher with 192-bit CTR mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_CTR, /**< Camellia cipher with 256-bit CTR mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_GCM, /**< Camellia cipher with 128-bit GCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_GCM, /**< Camellia cipher with 192-bit GCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_GCM, /**< Camellia cipher with 256-bit GCM mode. */ + MBEDTLS_CIPHER_DES_ECB, /**< DES cipher with ECB mode. */ + MBEDTLS_CIPHER_DES_CBC, /**< DES cipher with CBC mode. */ + MBEDTLS_CIPHER_DES_EDE_ECB, /**< DES cipher with EDE ECB mode. */ + MBEDTLS_CIPHER_DES_EDE_CBC, /**< DES cipher with EDE CBC mode. */ + MBEDTLS_CIPHER_DES_EDE3_ECB, /**< DES cipher with EDE3 ECB mode. */ + MBEDTLS_CIPHER_DES_EDE3_CBC, /**< DES cipher with EDE3 CBC mode. */ + MBEDTLS_CIPHER_BLOWFISH_ECB, /**< Blowfish cipher with ECB mode. */ + MBEDTLS_CIPHER_BLOWFISH_CBC, /**< Blowfish cipher with CBC mode. */ + MBEDTLS_CIPHER_BLOWFISH_CFB64, /**< Blowfish cipher with CFB64 mode. */ + MBEDTLS_CIPHER_BLOWFISH_CTR, /**< Blowfish cipher with CTR mode. */ + MBEDTLS_CIPHER_ARC4_128, /**< RC4 cipher with 128-bit mode. */ + MBEDTLS_CIPHER_AES_128_CCM, /**< AES cipher with 128-bit CCM mode. */ + MBEDTLS_CIPHER_AES_192_CCM, /**< AES cipher with 192-bit CCM mode. */ + MBEDTLS_CIPHER_AES_256_CCM, /**< AES cipher with 256-bit CCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_128_CCM, /**< Camellia cipher with 128-bit CCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_192_CCM, /**< Camellia cipher with 192-bit CCM mode. */ + MBEDTLS_CIPHER_CAMELLIA_256_CCM, /**< Camellia cipher with 256-bit CCM mode. */ + MBEDTLS_CIPHER_ARIA_128_ECB, /**< Aria cipher with 128-bit key and ECB mode. */ + MBEDTLS_CIPHER_ARIA_192_ECB, /**< Aria cipher with 192-bit key and ECB mode. */ + MBEDTLS_CIPHER_ARIA_256_ECB, /**< Aria cipher with 256-bit key and ECB mode. */ + MBEDTLS_CIPHER_ARIA_128_CBC, /**< Aria cipher with 128-bit key and CBC mode. */ + MBEDTLS_CIPHER_ARIA_192_CBC, /**< Aria cipher with 192-bit key and CBC mode. */ + MBEDTLS_CIPHER_ARIA_256_CBC, /**< Aria cipher with 256-bit key and CBC mode. */ + MBEDTLS_CIPHER_ARIA_128_CFB128, /**< Aria cipher with 128-bit key and CFB-128 mode. */ + MBEDTLS_CIPHER_ARIA_192_CFB128, /**< Aria cipher with 192-bit key and CFB-128 mode. */ + MBEDTLS_CIPHER_ARIA_256_CFB128, /**< Aria cipher with 256-bit key and CFB-128 mode. */ + MBEDTLS_CIPHER_ARIA_128_CTR, /**< Aria cipher with 128-bit key and CTR mode. */ + MBEDTLS_CIPHER_ARIA_192_CTR, /**< Aria cipher with 192-bit key and CTR mode. */ + MBEDTLS_CIPHER_ARIA_256_CTR, /**< Aria cipher with 256-bit key and CTR mode. */ + MBEDTLS_CIPHER_ARIA_128_GCM, /**< Aria cipher with 128-bit key and GCM mode. */ + MBEDTLS_CIPHER_ARIA_192_GCM, /**< Aria cipher with 192-bit key and GCM mode. */ + MBEDTLS_CIPHER_ARIA_256_GCM, /**< Aria cipher with 256-bit key and GCM mode. */ + MBEDTLS_CIPHER_ARIA_128_CCM, /**< Aria cipher with 128-bit key and CCM mode. */ + MBEDTLS_CIPHER_ARIA_192_CCM, /**< Aria cipher with 192-bit key and CCM mode. */ + MBEDTLS_CIPHER_ARIA_256_CCM, /**< Aria cipher with 256-bit key and CCM mode. */ + MBEDTLS_CIPHER_AES_128_OFB, /**< AES 128-bit cipher in OFB mode. */ + MBEDTLS_CIPHER_AES_192_OFB, /**< AES 192-bit cipher in OFB mode. */ + MBEDTLS_CIPHER_AES_256_OFB, /**< AES 256-bit cipher in OFB mode. */ + MBEDTLS_CIPHER_AES_128_XTS, /**< AES 128-bit cipher in XTS block mode. */ + MBEDTLS_CIPHER_AES_256_XTS, /**< AES 256-bit cipher in XTS block mode. */ + MBEDTLS_CIPHER_CHACHA20, /**< ChaCha20 stream cipher. */ + MBEDTLS_CIPHER_CHACHA20_POLY1305, /**< ChaCha20-Poly1305 AEAD cipher. */ } mbedtls_cipher_type_t; /** Supported cipher modes. */ typedef enum { - MBEDTLS_MODE_NONE = 0, - MBEDTLS_MODE_ECB, - MBEDTLS_MODE_CBC, - MBEDTLS_MODE_CFB, - MBEDTLS_MODE_OFB, /* Unused! */ - MBEDTLS_MODE_CTR, - MBEDTLS_MODE_GCM, - MBEDTLS_MODE_STREAM, - MBEDTLS_MODE_CCM, + MBEDTLS_MODE_NONE = 0, /**< None. */ + MBEDTLS_MODE_ECB, /**< The ECB cipher mode. */ + MBEDTLS_MODE_CBC, /**< The CBC cipher mode. */ + MBEDTLS_MODE_CFB, /**< The CFB cipher mode. */ + MBEDTLS_MODE_OFB, /**< The OFB cipher mode. */ + MBEDTLS_MODE_CTR, /**< The CTR cipher mode. */ + MBEDTLS_MODE_GCM, /**< The GCM cipher mode. */ + MBEDTLS_MODE_STREAM, /**< The stream cipher mode. */ + MBEDTLS_MODE_CCM, /**< The CCM cipher mode. */ + MBEDTLS_MODE_XTS, /**< The XTS cipher mode. */ + MBEDTLS_MODE_CHACHAPOLY, /**< The ChaCha-Poly cipher mode. */ } mbedtls_cipher_mode_t; /** Supported cipher padding types. */ @@ -163,8 +198,8 @@ typedef enum { MBEDTLS_PADDING_PKCS7 = 0, /**< PKCS7 padding (default). */ MBEDTLS_PADDING_ONE_AND_ZEROS, /**< ISO/IEC 7816-4 padding. */ MBEDTLS_PADDING_ZEROS_AND_LEN, /**< ANSI X.923 padding. */ - MBEDTLS_PADDING_ZEROS, /**< zero padding (not reversible). */ - MBEDTLS_PADDING_NONE, /**< never pad (full blocks only). */ + MBEDTLS_PADDING_ZEROS, /**< Zero padding (not reversible). */ + MBEDTLS_PADDING_NONE, /**< Never pad (full blocks only). */ } mbedtls_cipher_padding_t; /** Type of operation. */ @@ -204,7 +239,8 @@ typedef struct mbedtls_cmac_context_t mbedtls_cmac_context_t; * Cipher information. Allows calling cipher functions * in a generic way. */ -typedef struct { +typedef struct mbedtls_cipher_info_t +{ /** Full cipher identifier. For example, * MBEDTLS_CIPHER_AES_256_CBC. */ @@ -228,7 +264,10 @@ typedef struct { */ unsigned int iv_size; - /** Flags to set. For example, if the cipher supports variable IV sizes or variable key sizes. */ + /** Bitflag comprised of MBEDTLS_CIPHER_VARIABLE_IV_LEN and + * MBEDTLS_CIPHER_VARIABLE_KEY_LEN indicating whether the + * cipher supports variable IV or variable key sizes, respectively. + */ int flags; /** The block size, in Bytes. */ @@ -242,7 +281,8 @@ typedef struct { /** * Generic cipher context. */ -typedef struct { +typedef struct mbedtls_cipher_context_t +{ /** Information about the associated cipher. */ const mbedtls_cipher_info_t *cipher_info; @@ -268,7 +308,8 @@ typedef struct { /** Number of Bytes that have not been processed yet. */ size_t unprocessed_len; - /** Current IV or NONCE_COUNTER for CTR-mode. */ + /** Current IV or NONCE_COUNTER for CTR-mode, data unit (or sector) number + * for XTS-mode. */ unsigned char iv[MBEDTLS_MAX_IV_LENGTH]; /** IV size in Bytes, for ciphers with variable-length IVs. */ @@ -296,10 +337,12 @@ const int *mbedtls_cipher_list( void ); * \brief This function retrieves the cipher-information * structure associated with the given cipher name. * - * \param cipher_name Name of the cipher to search for. + * \param cipher_name Name of the cipher to search for. This must not be + * \c NULL. * * \return The cipher information structure associated with the - * given \p cipher_name, or NULL if not found. + * given \p cipher_name. + * \return \c NULL if the associated cipher information is not found. */ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher_name ); @@ -310,7 +353,8 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher * \param cipher_type Type of the cipher to search for. * * \return The cipher information structure associated with the - * given \p cipher_type, or NULL if not found. + * given \p cipher_type. + * \return \c NULL if the associated cipher information is not found. */ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher_type_t cipher_type ); @@ -325,7 +369,8 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_type( const mbedtls_cipher * \param mode The cipher mode. For example, #MBEDTLS_MODE_CBC. * * \return The cipher information structure associated with the - * given \p cipher_id, or NULL if not found. + * given \p cipher_id. + * \return \c NULL if the associated cipher information is not found. */ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_cipher_id_t cipher_id, int key_bitlen, @@ -333,6 +378,8 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_ciph /** * \brief This function initializes a \p cipher_context as NONE. + * + * \param ctx The context to be initialized. This must not be \c NULL. */ void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ); @@ -340,6 +387,10 @@ void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ); * \brief This function frees and clears the cipher-specific * context of \p ctx. Freeing \p ctx itself remains the * responsibility of the caller. + * + * \param ctx The context to be freed. If this is \c NULL, the + * function has no effect, otherwise this must point to an + * initialized context. */ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ); @@ -349,31 +400,35 @@ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ); * structure with the appropriate values. It also clears * the structure. * - * \param ctx The context to initialize. May not be NULL. + * \param ctx The context to initialize. This must be initialized. * \param cipher_info The cipher to use. * - * \return \c 0 on success, - * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter failure, - * #MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the - * cipher-specific context failed. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return #MBEDTLS_ERR_CIPHER_ALLOC_FAILED if allocation of the + * cipher-specific context fails. * * \internal Currently, the function also clears the structure. * In future versions, the caller will be required to call * mbedtls_cipher_init() on the structure first. */ -int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ); +int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, + const mbedtls_cipher_info_t *cipher_info ); /** * \brief This function returns the block size of the given cipher. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return The size of the blocks of the cipher, or zero if \p ctx - * has not been initialized. + * \return The block size of the underlying cipher. + * \return \c 0 if \p ctx has not been initialized. */ -static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_context_t *ctx ) +static inline unsigned int mbedtls_cipher_get_block_size( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, 0 ); + if( ctx->cipher_info == NULL ) return 0; return ctx->cipher_info->block_size; @@ -383,14 +438,16 @@ static inline unsigned int mbedtls_cipher_get_block_size( const mbedtls_cipher_c * \brief This function returns the mode of operation for * the cipher. For example, MBEDTLS_MODE_CBC. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return The mode of operation, or #MBEDTLS_MODE_NONE if - * \p ctx has not been initialized. + * \return The mode of operation. + * \return #MBEDTLS_MODE_NONE if \p ctx has not been initialized. */ -static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtls_cipher_context_t *ctx ) +static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, MBEDTLS_MODE_NONE ); + if( ctx->cipher_info == NULL ) return MBEDTLS_MODE_NONE; return ctx->cipher_info->mode; @@ -400,15 +457,17 @@ static inline mbedtls_cipher_mode_t mbedtls_cipher_get_cipher_mode( const mbedtl * \brief This function returns the size of the IV or nonce * of the cipher, in Bytes. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return
  • If no IV has been set: the recommended IV size. - * 0 for ciphers not using IV or nonce.
  • - *
  • If IV has already been set: the actual size.
+ * \return The recommended IV size if no IV has been set. + * \return \c 0 for ciphers not using an IV or a nonce. + * \return The actual size if an IV has been set. */ -static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ctx ) +static inline int mbedtls_cipher_get_iv_size( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, 0 ); + if( ctx->cipher_info == NULL ) return 0; if( ctx->iv_size != 0 ) @@ -420,14 +479,17 @@ static inline int mbedtls_cipher_get_iv_size( const mbedtls_cipher_context_t *ct /** * \brief This function returns the type of the given cipher. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return The type of the cipher, or #MBEDTLS_CIPHER_NONE if - * \p ctx has not been initialized. + * \return The type of the cipher. + * \return #MBEDTLS_CIPHER_NONE if \p ctx has not been initialized. */ -static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_cipher_context_t *ctx ) +static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( + ctx != NULL, MBEDTLS_CIPHER_NONE ); + if( ctx->cipher_info == NULL ) return MBEDTLS_CIPHER_NONE; return ctx->cipher_info->type; @@ -437,14 +499,16 @@ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_ciphe * \brief This function returns the name of the given cipher * as a string. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return The name of the cipher, or NULL if \p ctx has not - * been not initialized. + * \return The name of the cipher. + * \return NULL if \p ctx has not been not initialized. */ -static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx ) +static inline const char *mbedtls_cipher_get_name( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( ctx != NULL, 0 ); + if( ctx->cipher_info == NULL ) return 0; return ctx->cipher_info->name; @@ -453,15 +517,18 @@ static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_ /** * \brief This function returns the key length of the cipher. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return The key length of the cipher in bits, or - * #MBEDTLS_KEY_LENGTH_NONE if ctx \p has not been + * \return The key length of the cipher in bits. + * \return #MBEDTLS_KEY_LENGTH_NONE if ctx \p has not been * initialized. */ -static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t *ctx ) +static inline int mbedtls_cipher_get_key_bitlen( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( + ctx != NULL, MBEDTLS_KEY_LENGTH_NONE ); + if( ctx->cipher_info == NULL ) return MBEDTLS_KEY_LENGTH_NONE; return (int) ctx->cipher_info->key_bitlen; @@ -470,15 +537,17 @@ static inline int mbedtls_cipher_get_key_bitlen( const mbedtls_cipher_context_t /** * \brief This function returns the operation of the given cipher. * - * \param ctx The context of the cipher. Must be initialized. + * \param ctx The context of the cipher. This must be initialized. * - * \return The type of operation: #MBEDTLS_ENCRYPT or - * #MBEDTLS_DECRYPT, or #MBEDTLS_OPERATION_NONE if \p ctx - * has not been initialized. + * \return The type of operation: #MBEDTLS_ENCRYPT or #MBEDTLS_DECRYPT. + * \return #MBEDTLS_OPERATION_NONE if \p ctx has not been initialized. */ -static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_cipher_context_t *ctx ) +static inline mbedtls_operation_t mbedtls_cipher_get_operation( + const mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + MBEDTLS_INTERNAL_VALIDATE_RET( + ctx != NULL, MBEDTLS_OPERATION_NONE ); + if( ctx->cipher_info == NULL ) return MBEDTLS_OPERATION_NONE; return ctx->operation; @@ -487,20 +556,23 @@ static inline mbedtls_operation_t mbedtls_cipher_get_operation( const mbedtls_ci /** * \brief This function sets the key to use with the given context. * - * \param ctx The generic cipher context. May not be NULL. Must have - * been initialized using mbedtls_cipher_info_from_type() - * or mbedtls_cipher_info_from_string(). - * \param key The key to use. - * \param key_bitlen The key length to use, in bits. + * \param ctx The generic cipher context. This must be initialized and + * bound to a cipher information structure. + * \param key The key to use. This must be a readable buffer of at + * least \p key_bitlen Bits. + * \param key_bitlen The key length to use, in Bits. * \param operation The operation that the key will be used for: * #MBEDTLS_ENCRYPT or #MBEDTLS_DECRYPT. * - * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if - * parameter verification fails, or a cipher-specific - * error code. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return A cipher-specific error code on failure. */ -int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, - int key_bitlen, const mbedtls_operation_t operation ); +int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, + const unsigned char *key, + int key_bitlen, + const mbedtls_operation_t operation ); #if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) /** @@ -509,59 +581,71 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *k * * The default passing mode is PKCS7 padding. * - * \param ctx The generic cipher context. + * \param ctx The generic cipher context. This must be initialized and + * bound to a cipher information structure. * \param mode The padding mode. * - * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE - * if the selected padding mode is not supported, or - * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE + * if the selected padding mode is not supported. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode * does not support padding. */ -int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ); +int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, + mbedtls_cipher_padding_t mode ); #endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ /** * \brief This function sets the initialization vector (IV) * or nonce. * - * \param ctx The generic cipher context. - * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. + * \note Some ciphers do not use IVs nor nonce. For these + * ciphers, this function has no effect. + * + * \param ctx The generic cipher context. This must be initialized and + * bound to a cipher information structure. + * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. This + * must be a readable buffer of at least \p iv_len Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size IV. * - * \returns \c 0 on success, or #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA - * - * \note Some ciphers do not use IVs nor nonce. For these - * ciphers, this function has no effect. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. */ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, - const unsigned char *iv, size_t iv_len ); + const unsigned char *iv, + size_t iv_len ); /** * \brief This function resets the cipher state. * - * \param ctx The generic cipher context. + * \param ctx The generic cipher context. This must be initialized. * - * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA - * if parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. */ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ); -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) /** * \brief This function adds additional data for AEAD ciphers. - * Only supported with GCM. Must be called - * exactly once, after mbedtls_cipher_reset(). + * Currently supported with GCM and ChaCha20+Poly1305. + * This must be called exactly once, after + * mbedtls_cipher_reset(). * - * \param ctx The generic cipher context. - * \param ad The additional data to use. - * \param ad_len the Length of \p ad. + * \param ctx The generic cipher context. This must be initialized. + * \param ad The additional data to use. This must be a readable + * buffer of at least \p ad_len Bytes. + * \param ad_len the Length of \p ad Bytes. * - * \return \c 0 on success, or a specific error code on failure. + * \return \c 0 on success. + * \return A specific error code on failure. */ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, const unsigned char *ad, size_t ad_len ); -#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ /** * \brief The generic cipher update function. It encrypts or @@ -573,25 +657,29 @@ int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, * Exception: For MBEDTLS_MODE_ECB, expects a single block * in size. For example, 16 Bytes for AES. * - * \param ctx The generic cipher context. - * \param input The buffer holding the input data. + * \note If the underlying cipher is used in GCM mode, all calls + * to this function, except for the last one before + * mbedtls_cipher_finish(), must have \p ilen as a + * multiple of the block size of the cipher. + * + * \param ctx The generic cipher context. This must be initialized and + * bound to a key. + * \param input The buffer holding the input data. This must be a + * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data. - * \param output The buffer for the output data. Must be able to hold at - * least \p ilen + block_size. Must not be the same buffer - * as input. + * \param output The buffer for the output data. This must be able to + * hold at least `ilen + block_size`. This must not be the + * same buffer as \p input. * \param olen The length of the output data, to be updated with the - * actual number of Bytes written. + * actual number of Bytes written. This must not be + * \c NULL. * - * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if - * parameter verification fails, - * #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE on an - * unsupported mode for a cipher, or a cipher-specific - * error code. - * - * \note If the underlying cipher is GCM, all calls to this - * function, except the last one before - * mbedtls_cipher_finish(). Must have \p ilen as a - * multiple of the block_size. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return #MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE on an + * unsupported mode for a cipher. + * \return A cipher-specific error code on failure. */ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ); @@ -602,78 +690,94 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i * contained in it is padded to the size of * the last block, and written to the \p output buffer. * - * \param ctx The generic cipher context. - * \param output The buffer to write data to. Needs block_size available. + * \param ctx The generic cipher context. This must be initialized and + * bound to a key. + * \param output The buffer to write data to. This needs to be a writable + * buffer of at least \p block_size Bytes. * \param olen The length of the data written to the \p output buffer. + * This may not be \c NULL. * - * \returns \c 0 on success, #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA if - * parameter verification fails, - * #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption - * expected a full block but was not provided one, - * #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding - * while decrypting, or a cipher-specific error code - * on failure for any other reason. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED on decryption + * expecting a full block but not receiving one. + * \return #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding + * while decrypting. + * \return A cipher-specific error code on failure. */ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen ); -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) /** * \brief This function writes a tag for AEAD ciphers. - * Only supported with GCM. - * Must be called after mbedtls_cipher_finish(). - * - * \param ctx The generic cipher context. - * \param tag The buffer to write the tag to. + * Currently supported with GCM and ChaCha20+Poly1305. + * This must be called after mbedtls_cipher_finish(). + * + * \param ctx The generic cipher context. This must be initialized, + * bound to a key, and have just completed a cipher + * operation through mbedtls_cipher_finish() the tag for + * which should be written. + * \param tag The buffer to write the tag to. This must be a writable + * buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to write. * - * \return \c 0 on success, or a specific error code on failure. + * \return \c 0 on success. + * \return A specific error code on failure. */ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, unsigned char *tag, size_t tag_len ); /** * \brief This function checks the tag for AEAD ciphers. - * Only supported with GCM. - * Must be called after mbedtls_cipher_finish(). + * Currently supported with GCM and ChaCha20+Poly1305. + * This must be called after mbedtls_cipher_finish(). * - * \param ctx The generic cipher context. - * \param tag The buffer holding the tag. + * \param ctx The generic cipher context. This must be initialized. + * \param tag The buffer holding the tag. This must be a readable + * buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to check. * - * \return \c 0 on success, or a specific error code on failure. + * \return \c 0 on success. + * \return A specific error code on failure. */ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, const unsigned char *tag, size_t tag_len ); -#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ /** * \brief The generic all-in-one encryption/decryption function, * for all ciphers except AEAD constructs. * - * \param ctx The generic cipher context. + * \param ctx The generic cipher context. This must be initialized. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. + * This must be a readable buffer of at least \p iv_len + * Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size * IV. - * \param input The buffer holding the input data. - * \param ilen The length of the input data. - * \param output The buffer for the output data. Must be able to hold at - * least \p ilen + block_size. Must not be the same buffer - * as input. + * \param input The buffer holding the input data. This must be a + * readable buffer of at least \p ilen Bytes. + * \param ilen The length of the input data in Bytes. + * \param output The buffer for the output data. This must be able to + * hold at least `ilen + block_size`. This must not be the + * same buffer as \p input. * \param olen The length of the output data, to be updated with the - * actual number of Bytes written. + * actual number of Bytes written. This must not be + * \c NULL. * * \note Some ciphers do not use IVs nor nonce. For these * ciphers, use \p iv = NULL and \p iv_len = 0. * - * \returns \c 0 on success, or - * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or - * #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED if decryption - * expected a full block but was not provided one, or - * #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding - * while decrypting, or a cipher-specific error code on - * failure for any other reason. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED on decryption + * expecting a full block but not receiving one. + * \return #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding + * while decrypting. + * \return A cipher-specific error code on failure. */ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, @@ -684,24 +788,32 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, /** * \brief The generic autenticated encryption (AEAD) function. * - * \param ctx The generic cipher context. + * \param ctx The generic cipher context. This must be initialized and + * bound to a key. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. + * This must be a readable buffer of at least \p iv_len + * Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size IV. - * \param ad The additional data to authenticate. + * \param ad The additional data to authenticate. This must be a + * readable buffer of at least \p ad_len Bytes. * \param ad_len The length of \p ad. - * \param input The buffer holding the input data. + * \param input The buffer holding the input data. This must be a + * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data. - * \param output The buffer for the output data. - * Must be able to hold at least \p ilen. + * \param output The buffer for the output data. This must be able to + * hold at least \p ilen Bytes. * \param olen The length of the output data, to be updated with the - * actual number of Bytes written. - * \param tag The buffer for the authentication tag. + * actual number of Bytes written. This must not be + * \c NULL. + * \param tag The buffer for the authentication tag. This must be a + * writable buffer of at least \p tag_len Bytes. * \param tag_len The desired length of the authentication tag. * - * \returns \c 0 on success, or - * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or - * a cipher-specific error code. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return A cipher-specific error code on failure. */ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, @@ -713,29 +825,37 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, /** * \brief The generic autenticated decryption (AEAD) function. * - * \param ctx The generic cipher context. + * \note If the data is not authentic, then the output buffer + * is zeroed out to prevent the unauthentic plaintext being + * used, making this interface safer. + * + * \param ctx The generic cipher context. This must be initialized and + * and bound to a key. * \param iv The IV to use, or NONCE_COUNTER for CTR-mode ciphers. + * This must be a readable buffer of at least \p iv_len + * Bytes. * \param iv_len The IV length for ciphers with variable-size IV. * This parameter is discarded by ciphers with fixed-size IV. - * \param ad The additional data to be authenticated. + * \param ad The additional data to be authenticated. This must be a + * readable buffer of at least \p ad_len Bytes. * \param ad_len The length of \p ad. - * \param input The buffer holding the input data. + * \param input The buffer holding the input data. This must be a + * readable buffer of at least \p ilen Bytes. * \param ilen The length of the input data. * \param output The buffer for the output data. - * Must be able to hold at least \p ilen. + * This must be able to hold at least \p ilen Bytes. * \param olen The length of the output data, to be updated with the - * actual number of Bytes written. - * \param tag The buffer holding the authentication tag. + * actual number of Bytes written. This must not be + * \c NULL. + * \param tag The buffer holding the authentication tag. This must be + * a readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the authentication tag. * - * \returns \c 0 on success, or - * #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, or - * #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic, - * or a cipher-specific error code on failure for any other reason. - * - * \note If the data is not authentic, then the output buffer - * is zeroed out to prevent the unauthentic plaintext being - * used, making this interface safer. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on + * parameter-verification failure. + * \return #MBEDTLS_ERR_CIPHER_AUTH_FAILED if data is not authentic. + * \return A cipher-specific error code on failure. */ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, const unsigned char *iv, size_t iv_len, diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher_internal.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher_internal.h index 969ff9ccb8..c6def0bef7 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher_internal.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/cipher_internal.h @@ -64,6 +64,14 @@ struct mbedtls_cipher_base_t unsigned char *output ); #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + /** Encrypt using OFB (Full length) */ + int (*ofb_func)( void *ctx, size_t length, size_t *iv_off, + unsigned char *iv, + const unsigned char *input, + unsigned char *output ); +#endif + #if defined(MBEDTLS_CIPHER_MODE_CTR) /** Encrypt using CTR */ int (*ctr_func)( void *ctx, size_t length, size_t *nc_off, @@ -71,6 +79,13 @@ struct mbedtls_cipher_base_t const unsigned char *input, unsigned char *output ); #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + /** Encrypt or decrypt using XTS. */ + int (*xts_func)( void *ctx, mbedtls_operation_t mode, size_t length, + const unsigned char data_unit[16], + const unsigned char *input, unsigned char *output ); +#endif + #if defined(MBEDTLS_CIPHER_MODE_STREAM) /** Encrypt using STREAM */ int (*stream_func)( void *ctx, size_t length, diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/cmac.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/cmac.h index 24839a20eb..9d42b3f209 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/cmac.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/cmac.h @@ -1,8 +1,10 @@ /** * \file cmac.h * - * \brief The Cipher-based Message Authentication Code (CMAC) Mode for - * Authentication. + * \brief This file contains CMAC definitions and functions. + * + * The Cipher-based Message Authentication Code (CMAC) Mode for + * Authentication is defined in RFC-4493: The AES-CMAC Algorithm. */ /* * Copyright (C) 2015-2018, Arm Limited (or its affiliates), All Rights Reserved @@ -26,21 +28,28 @@ #ifndef MBEDTLS_CMAC_H #define MBEDTLS_CMAC_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "cipher.h" #ifdef __cplusplus extern "C" { #endif +/* MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED -0x007A /**< CMAC hardware accelerator failed. */ #define MBEDTLS_AES_BLOCK_SIZE 16 #define MBEDTLS_DES3_BLOCK_SIZE 8 #if defined(MBEDTLS_AES_C) -#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /* The longest block used by CMAC is that of AES. */ +#define MBEDTLS_CIPHER_BLKSIZE_MAX 16 /**< The longest block used by CMAC is that of AES. */ #else -#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /* The longest block used by CMAC is that of 3DES. */ +#define MBEDTLS_CIPHER_BLKSIZE_MAX 8 /**< The longest block used by CMAC is that of 3DES. */ #endif #if !defined(MBEDTLS_CMAC_ALT) @@ -61,22 +70,25 @@ struct mbedtls_cmac_context_t size_t unprocessed_len; }; +#else /* !MBEDTLS_CMAC_ALT */ +#include "cmac_alt.h" +#endif /* !MBEDTLS_CMAC_ALT */ + /** * \brief This function sets the CMAC key, and prepares to authenticate * the input data. * Must be called with an initialized cipher context. * * \param ctx The cipher context used for the CMAC operation, initialized - * as one of the following types:
    - *
  • MBEDTLS_CIPHER_AES_128_ECB
  • - *
  • MBEDTLS_CIPHER_AES_192_ECB
  • - *
  • MBEDTLS_CIPHER_AES_256_ECB
  • - *
  • MBEDTLS_CIPHER_DES_EDE3_ECB
+ * as one of the following types: MBEDTLS_CIPHER_AES_128_ECB, + * MBEDTLS_CIPHER_AES_192_ECB, MBEDTLS_CIPHER_AES_256_ECB, + * or MBEDTLS_CIPHER_DES_EDE3_ECB. * \param key The CMAC key. * \param keybits The length of the CMAC key in bits. * Must be supported by the cipher. * - * \return \c 0 on success, or a cipher-specific error code. + * \return \c 0 on success. + * \return A cipher-specific error code on failure. */ int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, const unsigned char *key, size_t keybits ); @@ -93,8 +105,9 @@ int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, * \param input The buffer holding the input data. * \param ilen The length of the input data. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA - * if parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA + * if parameter verification fails. */ int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen ); @@ -110,7 +123,8 @@ int mbedtls_cipher_cmac_update( mbedtls_cipher_context_t *ctx, * \param ctx The cipher context used for the CMAC operation. * \param output The output buffer for the CMAC checksum result. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, @@ -126,7 +140,8 @@ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, * * \param ctx The cipher context used for the CMAC operation. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ); @@ -149,7 +164,8 @@ int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ); * \param ilen The length of the input data. * \param output The buffer for the generic CMAC result. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA * if parameter verification fails. */ int mbedtls_cipher_cmac( const mbedtls_cipher_info_t *cipher_info, @@ -180,23 +196,12 @@ int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_len, unsigned char output[16] ); #endif /* MBEDTLS_AES_C */ -#ifdef __cplusplus -} -#endif - -#else /* !MBEDTLS_CMAC_ALT */ -#include "cmac_alt.h" -#endif /* !MBEDTLS_CMAC_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - #if defined(MBEDTLS_SELF_TEST) && ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_DES_C) ) /** * \brief The CMAC checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_cmac_self_test( int verbose ); #endif /* MBEDTLS_SELF_TEST && ( MBEDTLS_AES_C || MBEDTLS_DES_C ) */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/compat-1.3.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/compat-1.3.h index 600a0f154c..a58b47243d 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/compat-1.3.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/compat-1.3.h @@ -25,6 +25,12 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) @@ -1378,7 +1384,8 @@ #define SSL_ANTI_REPLAY_ENABLED MBEDTLS_SSL_ANTI_REPLAY_ENABLED #define SSL_ARC4_DISABLED MBEDTLS_SSL_ARC4_DISABLED #define SSL_ARC4_ENABLED MBEDTLS_SSL_ARC4_ENABLED -#define SSL_BUFFER_LEN MBEDTLS_SSL_BUFFER_LEN +#define SSL_BUFFER_LEN ( ( ( MBEDTLS_SSL_IN_BUFFER_LEN ) < ( MBEDTLS_SSL_OUT_BUFFER_LEN ) ) \ + ? ( MBEDTLS_SSL_IN_BUFFER_LEN ) : ( MBEDTLS_SSL_OUT_BUFFER_LEN ) ) #define SSL_CACHE_DEFAULT_MAX_ENTRIES MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES #define SSL_CACHE_DEFAULT_TIMEOUT MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT #define SSL_CBC_RECORD_SPLITTING_DISABLED MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/config.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/config.h index 50239e1ff5..654f9725e4 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/config.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/config.h @@ -8,7 +8,7 @@ * memory footprint. */ /* - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -48,10 +48,14 @@ * Requires support for asm() in compiler. * * Used in: + * library/aria.c * library/timing.c - * library/padlock.c * include/mbedtls/bn_mul.h * + * Required by: + * MBEDTLS_AESNI_C + * MBEDTLS_PADLOCK_C + * * Comment to disable the use of assembly code. */ #define MBEDTLS_HAVE_ASM @@ -84,6 +88,28 @@ */ //#define MBEDTLS_NO_UDBL_DIVISION +/** + * \def MBEDTLS_NO_64BIT_MULTIPLICATION + * + * The platform lacks support for 32x32 -> 64-bit multiplication. + * + * Used in: + * library/poly1305.c + * + * Some parts of the library may use multiplication of two unsigned 32-bit + * operands with a 64-bit result in order to speed up computations. On some + * platforms, this is not available in hardware and has to be implemented in + * software, usually in a library provided by the toolchain. + * + * Sometimes it is not desirable to have to link to that library. This option + * removes the dependency of that library on platforms that lack a hardware + * 64-bit multiplier by embedding a software implementation in Mbed TLS. + * + * Note that depending on the compiler, this may decrease performance compared + * to using the library function provided by the toolchain. + */ +//#define MBEDTLS_NO_64BIT_MULTIPLICATION + /** * \def MBEDTLS_HAVE_SSE2 * @@ -111,12 +137,21 @@ /** * \def MBEDTLS_HAVE_TIME_DATE * - * System has time.h and time(), gmtime() and the clock is correct. + * System has time.h, time(), and an implementation for + * mbedtls_platform_gmtime_r() (see below). * The time needs to be correct (not necesarily very accurate, but at least * the date should be correct). This is used to verify the validity period of * X.509 certificates. * * Comment if your system does not have a correct clock. + * + * \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that + * behaves similarly to the gmtime_r() function from the C standard. Refer to + * the documentation for mbedtls_platform_gmtime_r() for more information. + * + * \note It is possible to configure an implementation for + * mbedtls_platform_gmtime_r() at compile-time by using the macro + * MBEDTLS_PLATFORM_GMTIME_R_ALT. */ #define MBEDTLS_HAVE_TIME_DATE @@ -221,6 +256,48 @@ */ //#define MBEDTLS_DEPRECATED_REMOVED +/** + * \def MBEDTLS_CHECK_PARAMS + * + * This configuration option controls whether the library validates more of + * the parameters passed to it. + * + * When this flag is not defined, the library only attempts to validate an + * input parameter if: (1) they may come from the outside world (such as the + * network, the filesystem, etc.) or (2) not validating them could result in + * internal memory errors such as overflowing a buffer controlled by the + * library. On the other hand, it doesn't attempt to validate parameters whose + * values are fully controlled by the application (such as pointers). + * + * When this flag is defined, the library additionally attempts to validate + * parameters that are fully controlled by the application, and should always + * be valid if the application code is fully correct and trusted. + * + * For example, when a function accepts as input a pointer to a buffer that may + * contain untrusted data, and its documentation mentions that this pointer + * must not be NULL: + * - the pointer is checked to be non-NULL only if this option is enabled + * - the content of the buffer is always validated + * + * When this flag is defined, if a library function receives a parameter that + * is invalid, it will: + * - invoke the macro MBEDTLS_PARAM_FAILED() which by default expands to a + * call to the function mbedtls_param_failed() + * - immediately return (with a specific error code unless the function + * returns void and can't communicate an error). + * + * When defining this flag, you also need to: + * - either provide a definition of the function mbedtls_param_failed() in + * your application (see platform_util.h for its prototype) as the library + * calls that function, but does not provide a default definition for it, + * - or provide a different definition of the macro MBEDTLS_PARAM_FAILED() + * below if the above mechanism is not flexible enough to suit your needs. + * See the documentation of this macro later in this file. + * + * Uncomment to enable validation of application-controlled parameters. + */ +//#define MBEDTLS_CHECK_PARAMS + /* \} name SECTION: System support */ /** @@ -271,23 +348,29 @@ */ //#define MBEDTLS_AES_ALT //#define MBEDTLS_ARC4_ALT +//#define MBEDTLS_ARIA_ALT //#define MBEDTLS_BLOWFISH_ALT //#define MBEDTLS_CAMELLIA_ALT //#define MBEDTLS_CCM_ALT +//#define MBEDTLS_CHACHA20_ALT +//#define MBEDTLS_CHACHAPOLY_ALT //#define MBEDTLS_CMAC_ALT //#define MBEDTLS_DES_ALT //#define MBEDTLS_DHM_ALT //#define MBEDTLS_ECJPAKE_ALT //#define MBEDTLS_GCM_ALT +//#define MBEDTLS_NIST_KW_ALT //#define MBEDTLS_MD2_ALT //#define MBEDTLS_MD4_ALT //#define MBEDTLS_MD5_ALT +//#define MBEDTLS_POLY1305_ALT //#define MBEDTLS_RIPEMD160_ALT //#define MBEDTLS_RSA_ALT //#define MBEDTLS_SHA1_ALT //#define MBEDTLS_SHA256_ALT //#define MBEDTLS_SHA512_ALT //#define MBEDTLS_XTEA_ALT + /* * When replacing the elliptic curve module, pleace consider, that it is * implemented with two .c files: @@ -373,11 +456,11 @@ * unsigned char mbedtls_internal_ecp_grp_capable( * const mbedtls_ecp_group *grp ) * int mbedtls_internal_ecp_init( const mbedtls_ecp_group *grp ) - * void mbedtls_internal_ecp_deinit( const mbedtls_ecp_group *grp ) + * void mbedtls_internal_ecp_free( const mbedtls_ecp_group *grp ) * The mbedtls_internal_ecp_grp_capable function should return 1 if the * replacement functions implement arithmetic for the given group and 0 * otherwise. - * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_deinit are + * The functions mbedtls_internal_ecp_init and mbedtls_internal_ecp_free are * called before and after each point operation and provide an opportunity to * implement optimized set up and tear down instructions. * @@ -440,12 +523,45 @@ /** * \def MBEDTLS_AES_ROM_TABLES * - * Store the AES tables in ROM. + * Use precomputed AES tables stored in ROM. + * + * Uncomment this macro to use precomputed AES tables stored in ROM. + * Comment this macro to generate AES tables in RAM at runtime. + * + * Tradeoff: Using precomputed ROM tables reduces RAM usage by ~8kb + * (or ~2kb if \c MBEDTLS_AES_FEWER_TABLES is used) and reduces the + * initialization time before the first AES operation can be performed. + * It comes at the cost of additional ~8kb ROM use (resp. ~2kb if \c + * MBEDTLS_AES_FEWER_TABLES below is used), and potentially degraded + * performance if ROM access is slower than RAM access. + * + * This option is independent of \c MBEDTLS_AES_FEWER_TABLES. * - * Uncomment this macro to store the AES tables in ROM. */ //#define MBEDTLS_AES_ROM_TABLES +/** + * \def MBEDTLS_AES_FEWER_TABLES + * + * Use less ROM/RAM for AES tables. + * + * Uncommenting this macro omits 75% of the AES tables from + * ROM / RAM (depending on the value of \c MBEDTLS_AES_ROM_TABLES) + * by computing their values on the fly during operations + * (the tables are entry-wise rotations of one another). + * + * Tradeoff: Uncommenting this reduces the RAM / ROM footprint + * by ~6kb but at the cost of more arithmetic operations during + * runtime. Specifically, one has to compare 4 accesses within + * different tables to 4 accesses with additional arithmetic + * operations within the same table. The performance gain/loss + * depends on the system and memory details. + * + * This option is independent of \c MBEDTLS_AES_ROM_TABLES. + * + */ +//#define MBEDTLS_AES_FEWER_TABLES + /** * \def MBEDTLS_CAMELLIA_SMALL_MEMORY * @@ -476,6 +592,20 @@ */ #define MBEDTLS_CIPHER_MODE_CTR +/** + * \def MBEDTLS_CIPHER_MODE_OFB + * + * Enable Output Feedback mode (OFB) for symmetric ciphers. + */ +#define MBEDTLS_CIPHER_MODE_OFB + +/** + * \def MBEDTLS_CIPHER_MODE_XTS + * + * Enable Xor-encrypt-xor with ciphertext stealing mode (XTS) for AES. + */ +#define MBEDTLS_CIPHER_MODE_XTS + /** * \def MBEDTLS_CIPHER_NULL_CIPHER * @@ -556,6 +686,26 @@ */ #define MBEDTLS_REMOVE_ARC4_CIPHERSUITES +/** + * \def MBEDTLS_REMOVE_3DES_CIPHERSUITES + * + * Remove 3DES ciphersuites by default in SSL / TLS. + * This flag removes the ciphersuites based on 3DES from the default list as + * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible + * to enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including + * them explicitly. + * + * A man-in-the-browser attacker can recover authentication tokens sent through + * a TLS connection using a 3DES based cipher suite (see "On the Practical + * (In-)Security of 64-bit Block Ciphers" by Karthikeyan Bhargavan and Gaëtan + * Leurent, see https://sweet32.info/SWEET32_CCS16.pdf). If this attack falls + * in your threat model or you are unsure, then you should keep this option + * enabled to remove 3DES based cipher suites. + * + * Comment this macro to keep 3DES in the default ciphersuite list. + */ +#define MBEDTLS_REMOVE_3DES_CIPHERSUITES + /** * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED * @@ -576,6 +726,7 @@ #define MBEDTLS_ECP_DP_BP384R1_ENABLED #define MBEDTLS_ECP_DP_BP512R1_ENABLED #define MBEDTLS_ECP_DP_CURVE25519_ENABLED +#define MBEDTLS_ECP_DP_CURVE448_ENABLED /** * \def MBEDTLS_ECP_NIST_OPTIM @@ -588,6 +739,30 @@ */ #define MBEDTLS_ECP_NIST_OPTIM +/** + * \def MBEDTLS_ECP_RESTARTABLE + * + * Enable "non-blocking" ECC operations that can return early and be resumed. + * + * This allows various functions to pause by returning + * #MBEDTLS_ERR_ECP_IN_PROGRESS (or, for functions in the SSL module, + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) and then be called later again in + * order to further progress and eventually complete their operation. This is + * controlled through mbedtls_ecp_set_max_ops() which limits the maximum + * number of ECC operations a function may perform before pausing; see + * mbedtls_ecp_set_max_ops() for more information. + * + * This is useful in non-threaded environments if you want to avoid blocking + * for too long on ECC (and, hence, X.509 or SSL/TLS) operations. + * + * Uncomment this macro to enable restartable ECC computations. + * + * \note This option only works with the default software implementation of + * elliptic curve functionality. It is incompatible with + * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT and MBEDTLS_ECDSA_XXX_ALT. + */ +//#define MBEDTLS_ECP_RESTARTABLE + /** * \def MBEDTLS_ECDSA_DETERMINISTIC * @@ -1094,6 +1269,17 @@ */ #define MBEDTLS_SSL_ALL_ALERT_MESSAGES +/** + * \def MBEDTLS_SSL_ASYNC_PRIVATE + * + * Enable asynchronous external private key operations in SSL. This allows + * you to configure an SSL connection to call an external cryptographic + * module to perform private key operations instead of performing the + * operation inside the library. + * + */ +//#define MBEDTLS_SSL_ASYNC_PRIVATE + /** * \def MBEDTLS_SSL_DEBUG_ALL * @@ -1542,6 +1728,9 @@ * * \note Currently compression can't be used with DTLS. * + * \deprecated This feature is deprecated and will be removed + * in the next major revision of the library. + * * Used in: library/ssl_tls.c * library/ssl_cli.c * library/ssl_srv.c @@ -1580,7 +1769,7 @@ * Enable the AES block cipher. * * Module: library/aes.c - * Caller: library/ssl_tls.c + * Caller: library/cipher.c * library/pem.c * library/ctr_drbg.c * @@ -1655,7 +1844,7 @@ * Enable the ARCFOUR stream cipher. * * Module: library/arc4.c - * Caller: library/ssl_tls.c + * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): @@ -1749,7 +1938,7 @@ * Enable the Camellia block cipher. * * Module: library/camellia.c - * Caller: library/ssl_tls.c + * Caller: library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): @@ -1798,6 +1987,58 @@ */ #define MBEDTLS_CAMELLIA_C +/** + * \def MBEDTLS_ARIA_C + * + * Enable the ARIA block cipher. + * + * Module: library/aria.c + * Caller: library/cipher.c + * + * This module enables the following ciphersuites (if other requisites are + * enabled as well): + * + * MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 + * MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 + * MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 + * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 + * MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 + */ +//#define MBEDTLS_ARIA_C + /** * \def MBEDTLS_CCM_C * @@ -1824,6 +2065,26 @@ */ #define MBEDTLS_CERTS_C +/** + * \def MBEDTLS_CHACHA20_C + * + * Enable the ChaCha20 stream cipher. + * + * Module: library/chacha20.c + */ +#define MBEDTLS_CHACHA20_C + +/** + * \def MBEDTLS_CHACHAPOLY_C + * + * Enable the ChaCha20-Poly1305 AEAD algorithm. + * + * Module: library/chachapoly.c + * + * This module requires: MBEDTLS_CHACHA20_C, MBEDTLS_POLY1305_C + */ +#define MBEDTLS_CHACHAPOLY_C + /** * \def MBEDTLS_CIPHER_C * @@ -1852,14 +2113,16 @@ /** * \def MBEDTLS_CTR_DRBG_C * - * Enable the CTR_DRBG AES-256-based random generator. + * Enable the CTR_DRBG AES-based random generator. + * The CTR_DRBG generator uses AES-256 by default. + * To use AES-128 instead, enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY below. * * Module: library/ctr_drbg.c * Caller: * * Requires: MBEDTLS_AES_C * - * This module provides the CTR_DRBG AES-256 random number generator. + * This module provides the CTR_DRBG AES random number generator. */ #define MBEDTLS_CTR_DRBG_C @@ -1884,7 +2147,7 @@ * * Module: library/des.c * Caller: library/pem.c - * library/ssl_tls.c + * library/cipher.c * * This module enables the following ciphersuites (if other requisites are * enabled as well): @@ -2054,6 +2317,21 @@ */ //#define MBEDTLS_HAVEGE_C +/** + * \def MBEDTLS_HKDF_C + * + * Enable the HKDF algorithm (RFC 5869). + * + * Module: library/hkdf.c + * Caller: + * + * Requires: MBEDTLS_MD_C + * + * This module adds support for the Hashed Message Authentication Code + * (HMAC)-based key derivation function (HKDF). + */ +#define MBEDTLS_HKDF_C + /** * \def MBEDTLS_HMAC_DRBG_C * @@ -2068,6 +2346,19 @@ */ #define MBEDTLS_HMAC_DRBG_C +/** + * \def MBEDTLS_NIST_KW_C + * + * Enable the Key Wrapping mode for 128-bit block ciphers, + * as defined in NIST SP 800-38F. Only KW and KWP modes + * are supported. At the moment, only AES is approved by NIST. + * + * Module: library/nist_kw.c + * + * Requires: MBEDTLS_AES_C and MBEDTLS_CIPHER_C + */ +//#define MBEDTLS_NIST_KW_C + /** * \def MBEDTLS_MD_C * @@ -2351,6 +2642,16 @@ */ #define MBEDTLS_PLATFORM_C +/** + * \def MBEDTLS_POLY1305_C + * + * Enable the Poly1305 MAC algorithm. + * + * Module: library/poly1305.c + * Caller: library/chachapoly.c + */ +#define MBEDTLS_POLY1305_C + /** * \def MBEDTLS_RIPEMD160_C * @@ -2706,6 +3007,7 @@ //#define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ //#define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ //#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ +//#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY /**< Use 128-bit key for CTR_DRBG - may reduce security (see ctr_drbg.h) */ /* HMAC_DRBG options */ //#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ @@ -2756,12 +3058,134 @@ //#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */ //#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */ +/** + * \brief This macro is invoked by the library when an invalid parameter + * is detected that is only checked with MBEDTLS_CHECK_PARAMS + * (see the documentation of that option for context). + * + * When you leave this undefined here, a default definition is + * provided that invokes the function mbedtls_param_failed(), + * which is declared in platform_util.h for the benefit of the + * library, but that you need to define in your application. + * + * When you define this here, this replaces the default + * definition in platform_util.h (which no longer declares the + * function mbedtls_param_failed()) and it is your responsibility + * to make sure this macro expands to something suitable (in + * particular, that all the necessary declarations are visible + * from within the library - you can ensure that by providing + * them in this file next to the macro definition). + * + * Note that you may define this macro to expand to nothing, in + * which case you don't have to worry about declarations or + * definitions. However, you will then be notified about invalid + * parameters only in non-void functions, and void function will + * just silently return early on invalid parameters, which + * partially negates the benefits of enabling + * #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged. + * + * \param cond The expression that should evaluate to true, but doesn't. + */ +//#define MBEDTLS_PARAM_FAILED( cond ) assert( cond ) + /* SSL Cache options */ //#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */ //#define MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES 50 /**< Maximum entries in cache */ /* SSL options */ -//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /**< Maxium fragment length in bytes, determines the size of each of the two internal I/O buffers */ + +/** \def MBEDTLS_SSL_MAX_CONTENT_LEN + * + * Maximum length (in bytes) of incoming and outgoing plaintext fragments. + * + * This determines the size of both the incoming and outgoing TLS I/O buffers + * in such a way that both are capable of holding the specified amount of + * plaintext data, regardless of the protection mechanism used. + * + * To configure incoming and outgoing I/O buffers separately, use + * #MBEDTLS_SSL_IN_CONTENT_LEN and #MBEDTLS_SSL_OUT_CONTENT_LEN, + * which overwrite the value set by this option. + * + * \note When using a value less than the default of 16KB on the client, it is + * recommended to use the Maximum Fragment Length (MFL) extension to + * inform the server about this limitation. On the server, there + * is no supported, standardized way of informing the client about + * restriction on the maximum size of incoming messages, and unless + * the limitation has been communicated by other means, it is recommended + * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN + * while keeping the default value of 16KB for the incoming buffer. + * + * Uncomment to set the maximum plaintext size of both + * incoming and outgoing I/O buffers. + */ +//#define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 + +/** \def MBEDTLS_SSL_IN_CONTENT_LEN + * + * Maximum length (in bytes) of incoming plaintext fragments. + * + * This determines the size of the incoming TLS I/O buffer in such a way + * that it is capable of holding the specified amount of plaintext data, + * regardless of the protection mechanism used. + * + * If this option is undefined, it inherits its value from + * #MBEDTLS_SSL_MAX_CONTENT_LEN. + * + * \note When using a value less than the default of 16KB on the client, it is + * recommended to use the Maximum Fragment Length (MFL) extension to + * inform the server about this limitation. On the server, there + * is no supported, standardized way of informing the client about + * restriction on the maximum size of incoming messages, and unless + * the limitation has been communicated by other means, it is recommended + * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN + * while keeping the default value of 16KB for the incoming buffer. + * + * Uncomment to set the maximum plaintext size of the incoming I/O buffer + * independently of the outgoing I/O buffer. + */ +//#define MBEDTLS_SSL_IN_CONTENT_LEN 16384 + +/** \def MBEDTLS_SSL_OUT_CONTENT_LEN + * + * Maximum length (in bytes) of outgoing plaintext fragments. + * + * This determines the size of the outgoing TLS I/O buffer in such a way + * that it is capable of holding the specified amount of plaintext data, + * regardless of the protection mechanism used. + * + * If this option undefined, it inherits its value from + * #MBEDTLS_SSL_MAX_CONTENT_LEN. + * + * It is possible to save RAM by setting a smaller outward buffer, while keeping + * the default inward 16384 byte buffer to conform to the TLS specification. + * + * The minimum required outward buffer size is determined by the handshake + * protocol's usage. Handshaking will fail if the outward buffer is too small. + * The specific size requirement depends on the configured ciphers and any + * certificate data which is sent during the handshake. + * + * Uncomment to set the maximum plaintext size of the outgoing I/O buffer + * independently of the incoming I/O buffer. + */ +//#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384 + +/** \def MBEDTLS_SSL_DTLS_MAX_BUFFERING + * + * Maximum number of heap-allocated bytes for the purpose of + * DTLS handshake message reassembly and future message buffering. + * + * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN + * to account for a reassembled handshake message of maximum size, + * together with its reassembly bitmap. + * + * A value of 2 * MBEDTLS_SSL_IN_CONTENT_LEN (32768 by default) + * should be sufficient for all practical situations as it allows + * to reassembly a large handshake message (such as a certificate) + * while buffering multiple smaller handshake messages. + * + */ +//#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 + //#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ //#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ //#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number of cookies issued */ @@ -2815,25 +3239,53 @@ */ #define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE -/* \} name SECTION: Customisation configuration options */ - -/* Target and application specific configurations */ -//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "target_config.h" +/** + * Uncomment the macro to let mbed TLS use your alternate implementation of + * mbedtls_platform_zeroize(). This replaces the default implementation in + * platform_util.c. + * + * mbedtls_platform_zeroize() is a widely used function across the library to + * zero a block of memory. The implementation is expected to be secure in the + * sense that it has been written to prevent the compiler from removing calls + * to mbedtls_platform_zeroize() as part of redundant code elimination + * optimizations. However, it is difficult to guarantee that calls to + * mbedtls_platform_zeroize() will not be optimized by the compiler as older + * versions of the C language standards do not provide a secure implementation + * of memset(). Therefore, MBEDTLS_PLATFORM_ZEROIZE_ALT enables users to + * configure their own implementation of mbedtls_platform_zeroize(), for + * example by using directives specific to their compiler, features from newer + * C standards (e.g using memset_s() in C11) or calling a secure memset() from + * their system (e.g explicit_bzero() in BSD). + */ +//#define MBEDTLS_PLATFORM_ZEROIZE_ALT + +/** + * Uncomment the macro to let Mbed TLS use your alternate implementation of + * mbedtls_platform_gmtime_r(). This replaces the default implementation in + * platform_util.c. + * + * gmtime() is not a thread-safe function as defined in the C standard. The + * library will try to use safer implementations of this function, such as + * gmtime_r() when available. However, if Mbed TLS cannot identify the target + * system, the implementation of mbedtls_platform_gmtime_r() will default to + * using the standard gmtime(). In this case, calls from the library to + * gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex + * if MBEDTLS_THREADING_C is enabled. We recommend that calls from outside the + * library are also guarded with this mutex to avoid race conditions. However, + * if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will + * unconditionally use the implementation for mbedtls_platform_gmtime_r() + * supplied at compile time. + */ +//#define MBEDTLS_PLATFORM_GMTIME_R_ALT -#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE) -#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE -#endif +/* \} name SECTION: Customisation configuration options */ -/* +/* Target and application specific configurations + * * Allow user to override any previous default. * - * Use two macro names for that, as: - * - with yotta the prefix YOTTA_CFG_ is forced - * - without yotta is looks weird to have a YOTTA prefix. */ -#if defined(YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE) -#include YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE -#elif defined(MBEDTLS_USER_CONFIG_FILE) +#if defined(MBEDTLS_USER_CONFIG_FILE) #include MBEDTLS_USER_CONFIG_FILE #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ctr_drbg.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ctr_drbg.h index 2b4dc73d3f..cc3df7b113 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ctr_drbg.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ctr_drbg.h @@ -1,10 +1,18 @@ /** * \file ctr_drbg.h * - * \brief CTR_DRBG is based on AES-256, as defined in NIST SP 800-90A: - * Recommendation for Random Number Generation Using Deterministic - * Random Bit Generators. + * \brief This file contains CTR_DRBG definitions and functions. * + * CTR_DRBG is a standardized way of building a PRNG from a block-cipher + * in counter mode operation, as defined in NIST SP 800-90A: + * Recommendation for Random Number Generation Using Deterministic Random + * Bit Generators. + * + * The Mbed TLS implementation of CTR_DRBG uses AES-256 (default) or AES-128 + * as the underlying block cipher. + * + * \warning Using 128-bit keys for CTR_DRBG limits the security of generated + * keys and operations that use random values generated to 128-bit security. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved @@ -28,6 +36,12 @@ #ifndef MBEDTLS_CTR_DRBG_H #define MBEDTLS_CTR_DRBG_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "aes.h" #if defined(MBEDTLS_THREADING_C) @@ -40,7 +54,13 @@ #define MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR -0x003A /**< Read or write error in file. */ #define MBEDTLS_CTR_DRBG_BLOCKSIZE 16 /**< The block size used by the cipher. */ -#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< The key size used by the cipher. */ + +#if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY) +#define MBEDTLS_CTR_DRBG_KEYSIZE 16 /**< The key size used by the cipher (compile-time choice: 128 bits). */ +#else +#define MBEDTLS_CTR_DRBG_KEYSIZE 32 /**< The key size used by the cipher (compile-time choice: 256 bits). */ +#endif + #define MBEDTLS_CTR_DRBG_KEYBITS ( MBEDTLS_CTR_DRBG_KEYSIZE * 8 ) /**< The key size for the DRBG operation, in bits. */ #define MBEDTLS_CTR_DRBG_SEEDLEN ( MBEDTLS_CTR_DRBG_KEYSIZE + MBEDTLS_CTR_DRBG_BLOCKSIZE ) /**< The seed length, calculated as (counter + AES key). */ @@ -103,7 +123,7 @@ extern "C" { /** * \brief The CTR_DRBG context structure. */ -typedef struct +typedef struct mbedtls_ctr_drbg_context { unsigned char counter[16]; /*!< The counter (V). */ int reseed_counter; /*!< The reseed counter. */ @@ -156,8 +176,8 @@ void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx ); identifiers. Can be NULL. * \param len The length of the personalization data. * - * \return \c 0 on success, or - * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure. */ int mbedtls_ctr_drbg_seed( mbedtls_ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), @@ -216,49 +236,30 @@ void mbedtls_ctr_drbg_set_reseed_interval( mbedtls_ctr_drbg_context *ctx, * \param additional Additional data to add to the state. Can be NULL. * \param len The length of the additional data. * - * \return \c 0 on success, or - * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on failure. */ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t len ); /** - * \brief This function updates the state of the CTR_DRBG context. - * - * \param ctx The CTR_DRBG context. - * \param additional The data to update the state with. - * \param add_len Length of \p additional in bytes. This must be at - * most #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT. - * - * \return \c 0 on success. - * \return #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG if - * \p add_len is more than - * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT. - * \return An error from the underlying AES cipher on failure. + * \brief This function updates the state of the CTR_DRBG context. + * + * \param ctx The CTR_DRBG context. + * \param additional The data to update the state with. + * \param add_len Length of \p additional in bytes. This must be at + * most #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG if + * \p add_len is more than + * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT. + * \return An error from the underlying AES cipher on failure. */ int mbedtls_ctr_drbg_update_ret( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ); -/** - * \brief This function updates the state of the CTR_DRBG context. - * - * \warning This function cannot report errors. You should use - * mbedtls_ctr_drbg_update_ret() instead. - * - * \note If \p add_len is greater than - * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first - * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used. - * The remaining Bytes are silently discarded. - * - * \param ctx The CTR_DRBG context. - * \param additional The data to update the state with. - * \param add_len Length of \p additional data. - */ -void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, - const unsigned char *additional, - size_t add_len ); - /** * \brief This function updates a CTR_DRBG instance with additional * data and uses it to generate random data. @@ -272,8 +273,8 @@ void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, * \param additional Additional data to update. Can be NULL. * \param add_len The length of the additional data. * - * \return \c 0 on success, or - * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure. */ int mbedtls_ctr_drbg_random_with_add( void *p_rng, @@ -290,13 +291,42 @@ int mbedtls_ctr_drbg_random_with_add( void *p_rng, * \param output The buffer to fill. * \param output_len The length of the buffer. * - * \return \c 0 on success, or - * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * #MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG on failure. */ int mbedtls_ctr_drbg_random( void *p_rng, unsigned char *output, size_t output_len ); + +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif +/** + * \brief This function updates the state of the CTR_DRBG context. + * + * \deprecated Superseded by mbedtls_ctr_drbg_update_ret() + * in 2.16.0. + * + * \note If \p add_len is greater than + * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT, only the first + * #MBEDTLS_CTR_DRBG_MAX_SEED_INPUT Bytes are used. + * The remaining Bytes are silently discarded. + * + * \param ctx The CTR_DRBG context. + * \param additional The data to update the state with. + * \param add_len Length of \p additional data. + */ +MBEDTLS_DEPRECATED void mbedtls_ctr_drbg_update( + mbedtls_ctr_drbg_context *ctx, + const unsigned char *additional, + size_t add_len ); +#undef MBEDTLS_DEPRECATED +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ + #if defined(MBEDTLS_FS_IO) /** * \brief This function writes a seed file. @@ -304,9 +334,9 @@ int mbedtls_ctr_drbg_random( void *p_rng, * \param ctx The CTR_DRBG context. * \param path The name of the file. * - * \return \c 0 on success, - * #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, or - * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error. + * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED on * failure. */ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ); @@ -318,21 +348,26 @@ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char * \param ctx The CTR_DRBG context. * \param path The name of the file. * - * \return \c 0 on success, - * #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error, - * #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or + * \return \c 0 on success. + * \return #MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR on file error. + * \return #MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED or * #MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG on failure. */ int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ); #endif /* MBEDTLS_FS_IO */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief The CTR_DRBG checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_ctr_drbg_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + /* Internal functions (do not call directly) */ int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *, int (*)(void *, unsigned char *, size_t), void *, diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/debug.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/debug.h index ef8db67ff1..736444bb76 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/debug.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/debug.h @@ -65,6 +65,11 @@ mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ) #endif +#if defined(MBEDTLS_ECDH_C) +#define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) \ + mbedtls_debug_printf_ecdh( ssl, level, __FILE__, __LINE__, ecdh, attr ) +#endif + #else /* MBEDTLS_DEBUG_C */ #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 ) @@ -73,6 +78,7 @@ #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) +#define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) do { } while( 0 ) #endif /* MBEDTLS_DEBUG_C */ @@ -221,6 +227,36 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, const char *text, const mbedtls_x509_crt *crt ); #endif +#if defined(MBEDTLS_ECDH_C) +typedef enum +{ + MBEDTLS_DEBUG_ECDH_Q, + MBEDTLS_DEBUG_ECDH_QP, + MBEDTLS_DEBUG_ECDH_Z, +} mbedtls_debug_ecdh_attr; + +/** + * \brief Print a field of the ECDH structure in the SSL context to the debug + * output. This function is always used through the + * MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file + * and line number parameters. + * + * \param ssl SSL context + * \param level error level of the debug message + * \param file file the error has occurred in + * \param line line number the error has occurred in + * \param ecdh the ECDH context + * \param attr the identifier of the attribute being output + * + * \attention This function is intended for INTERNAL usage within the + * library only. + */ +void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const mbedtls_ecdh_context *ecdh, + mbedtls_debug_ecdh_attr attr ); +#endif + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/des.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/des.h index 5a1a636522..54e6b7894b 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/des.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/des.h @@ -42,18 +42,20 @@ #define MBEDTLS_DES_DECRYPT 0 #define MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH -0x0032 /**< The data input has an invalid length. */ + +/* MBEDTLS_ERR_DES_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_DES_HW_ACCEL_FAILED -0x0033 /**< DES hardware accelerator failed. */ #define MBEDTLS_DES_KEY_SIZE 8 -#if !defined(MBEDTLS_DES_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_DES_ALT) +// Regular implementation +// + /** * \brief DES context structure * @@ -61,7 +63,7 @@ extern "C" { * security risk. We recommend considering stronger ciphers * instead. */ -typedef struct +typedef struct mbedtls_des_context { uint32_t sk[32]; /*!< DES subkeys */ } @@ -70,12 +72,16 @@ mbedtls_des_context; /** * \brief Triple-DES context structure */ -typedef struct +typedef struct mbedtls_des3_context { uint32_t sk[96]; /*!< 3DES subkeys */ } mbedtls_des3_context; +#else /* MBEDTLS_DES_ALT */ +#include "des_alt.h" +#endif /* MBEDTLS_DES_ALT */ + /** * \brief Initialize DES context * @@ -331,17 +337,8 @@ int mbedtls_des3_crypt_cbc( mbedtls_des3_context *ctx, */ void mbedtls_des_setkey( uint32_t SK[32], const unsigned char key[MBEDTLS_DES_KEY_SIZE] ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_DES_ALT */ -#include "des_alt.h" -#endif /* MBEDTLS_DES_ALT */ -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine @@ -350,6 +347,8 @@ extern "C" { */ int mbedtls_des_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/dhm.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/dhm.h index 00fafd8d16..2909f5fbc8 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/dhm.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/dhm.h @@ -1,7 +1,13 @@ /** * \file dhm.h * - * \brief Diffie-Hellman-Merkle key exchange. + * \brief This file contains Diffie-Hellman-Merkle (DHM) key exchange + * definitions and functions. + * + * Diffie-Hellman-Merkle (DHM) key exchange is defined in + * RFC-2631: Diffie-Hellman Key Agreement Method and + * Public-Key Cryptography Standards (PKCS) #3: Diffie + * Hellman Key Agreement Standard. * * RFC-3526: More Modular Exponential (MODP) Diffie-Hellman groups for * Internet Key Exchange (IKE) defines a number of standardized @@ -65,7 +71,6 @@ #include MBEDTLS_CONFIG_FILE #endif #include "bignum.h" -#if !defined(MBEDTLS_DHM_ALT) /* * DHM Error codes @@ -79,17 +84,22 @@ #define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */ #define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */ #define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read or write of file failed. */ + +/* MBEDTLS_ERR_DHM_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_DHM_HW_ACCEL_FAILED -0x3500 /**< DHM hardware accelerator failed. */ + #define MBEDTLS_ERR_DHM_SET_GROUP_FAILED -0x3580 /**< Setting the modulus and generator failed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_DHM_ALT) + /** * \brief The DHM context structure. */ -typedef struct +typedef struct mbedtls_dhm_context { size_t len; /*!< The size of \p P in Bytes. */ mbedtls_mpi P; /*!< The prime modulus. */ @@ -105,6 +115,10 @@ typedef struct } mbedtls_dhm_context; +#else /* MBEDTLS_DHM_ALT */ +#include "dhm_alt.h" +#endif /* MBEDTLS_DHM_ALT */ + /** * \brief This function initializes the DHM context. * @@ -113,9 +127,15 @@ mbedtls_dhm_context; void mbedtls_dhm_init( mbedtls_dhm_context *ctx ); /** - * \brief This function parses the ServerKeyExchange parameters. + * \brief This function parses the DHM parameters in a + * TLS ServerKeyExchange handshake message + * (DHM modulus, generator, and public key). + * + * \note In a TLS handshake, this is the how the client + * sets up its DHM context from the server's public + * DHM key material. * - * \param ctx The DHM context. + * \param ctx The DHM context to use. This must be initialized. * \param p On input, *p must be the start of the input buffer. * On output, *p is updated to point to the end of the data * that has been read. On success, this is the first byte @@ -125,38 +145,44 @@ void mbedtls_dhm_init( mbedtls_dhm_context *ctx ); * failures. * \param end The end of the input buffer. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx, - unsigned char **p, - const unsigned char *end ); + unsigned char **p, + const unsigned char *end ); /** - * \brief This function sets up and writes the ServerKeyExchange - * parameters. - * - * \param ctx The DHM context. - * \param x_size The private value size in Bytes. - * \param olen The number of characters written. - * \param output The destination buffer. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * - * \note The destination buffer must be large enough to hold - * the reduced binary presentation of the modulus, the generator - * and the public key, each wrapped with a 2-byte length field. - * It is the responsibility of the caller to ensure that enough - * space is available. Refer to \c mbedtls_mpi_size to computing - * the byte-size of an MPI. + * \brief This function generates a DHM key pair and exports its + * public part together with the DHM parameters in the format + * used in a TLS ServerKeyExchange handshake message. * - * \note This function assumes that \c ctx->P and \c ctx->G - * have already been properly set. For that, use + * \note This function assumes that the DHM parameters \c ctx->P + * and \c ctx->G have already been properly set. For that, use * mbedtls_dhm_set_group() below in conjunction with * mbedtls_mpi_read_binary() and mbedtls_mpi_read_string(). * - * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code - * on failure. + * \note In a TLS handshake, this is the how the server generates + * and exports its DHM key material. + * + * \param ctx The DHM context to use. This must be initialized + * and have the DHM parameters set. It may or may not + * already have imported the peer's public key. + * \param x_size The private key size in Bytes. + * \param olen The address at which to store the number of Bytes + * written on success. This must not be \c NULL. + * \param output The destination buffer. This must be a writable buffer of + * sufficient size to hold the reduced binary presentation of + * the modulus, the generator and the public key, each wrapped + * with a 2-byte length field. It is the responsibility of the + * caller to ensure that enough space is available. Refer to + * mbedtls_mpi_size() to computing the byte-size of an MPI. + * \param f_rng The RNG function. Must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng doesn't need a context parameter. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t *olen, @@ -164,54 +190,66 @@ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, void *p_rng ); /** - * \brief Set prime modulus and generator + * \brief This function sets the prime modulus and generator. * - * \param ctx The DHM context. - * \param P The MPI holding DHM prime modulus. - * \param G The MPI holding DHM generator. + * \note This function can be used to set \c ctx->P, \c ctx->G + * in preparation for mbedtls_dhm_make_params(). * - * \note This function can be used to set P, G - * in preparation for \c mbedtls_dhm_make_params. + * \param ctx The DHM context to configure. This must be initialized. + * \param P The MPI holding the DHM prime modulus. This must be + * an initialized MPI. + * \param G The MPI holding the DHM generator. This must be an + * initialized MPI. * - * \return \c 0 if successful, or an \c MBEDTLS_ERR_DHM_XXX error code - * on failure. + * \return \c 0 if successful. + * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_set_group( mbedtls_dhm_context *ctx, const mbedtls_mpi *P, const mbedtls_mpi *G ); /** - * \brief This function imports the public value G^Y of the peer. + * \brief This function imports the raw public value of the peer. * - * \param ctx The DHM context. - * \param input The input buffer. - * \param ilen The size of the input buffer. + * \note In a TLS handshake, this is the how the server imports + * the Client's public DHM key. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code - * on failure. + * \param ctx The DHM context to use. This must be initialized and have + * its DHM parameters set, e.g. via mbedtls_dhm_set_group(). + * It may or may not already have generated its own private key. + * \param input The input buffer containing the \c G^Y value of the peer. + * This must be a readable buffer of size \p ilen Bytes. + * \param ilen The size of the input buffer \p input in Bytes. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx, const unsigned char *input, size_t ilen ); /** - * \brief This function creates its own private value \c X and - * exports \c G^X. + * \brief This function creates a DHM key pair and exports + * the raw public key in big-endian format. * - * \param ctx The DHM context. - * \param x_size The private value size in Bytes. - * \param output The destination buffer. - * \param olen The length of the destination buffer. Must be at least - equal to ctx->len (the size of \c P). - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. + * \note The destination buffer is always fully written + * so as to contain a big-endian representation of G^X mod P. + * If it is larger than \c ctx->len, it is padded accordingly + * with zero-bytes at the beginning. * - * \note The destination buffer will always be fully written - * so as to contain a big-endian presentation of G^X mod P. - * If it is larger than ctx->len, it will accordingly be - * padded with zero-bytes in the beginning. + * \param ctx The DHM context to use. This must be initialized and + * have the DHM parameters set. It may or may not already + * have imported the peer's public key. + * \param x_size The private key size in Bytes. + * \param output The destination buffer. This must be a writable buffer of + * size \p olen Bytes. + * \param olen The length of the destination buffer. This must be at least + * equal to `ctx->len` (the size of \c P). + * \param f_rng The RNG function. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL + * if \p f_rng doesn't need a context argument. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, unsigned char *output, size_t olen, @@ -219,25 +257,30 @@ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, void *p_rng ); /** - * \brief This function derives and exports the shared secret - * \c (G^Y)^X mod \c P. + * \brief This function derives and exports the shared secret + * \c (G^Y)^X mod \c P. * - * \param ctx The DHM context. - * \param output The destination buffer. - * \param output_size The size of the destination buffer. Must be at least - * the size of ctx->len. - * \param olen On exit, holds the actual number of Bytes written. - * \param f_rng The RNG function, for blinding purposes. - * \param p_rng The RNG parameter. + * \note If \p f_rng is not \c NULL, it is used to blind the input as + * a countermeasure against timing attacks. Blinding is used + * only if our private key \c X is re-used, and not used + * otherwise. We recommend always passing a non-NULL + * \p f_rng argument. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_DHM_XXX error code - * on failure. + * \param ctx The DHM context to use. This must be initialized + * and have its own private key generated and the peer's + * public key imported. + * \param output The buffer to write the generated shared key to. This + * must be a writable buffer of size \p output_size Bytes. + * \param output_size The size of the destination buffer. This must be at + * least the size of \c ctx->len (the size of \c P). + * \param olen On exit, holds the actual number of Bytes written. + * \param f_rng The RNG function, for blinding purposes. This may + * b \c NULL if blinding isn't needed. + * \param p_rng The RNG context. This may be \c NULL if \p f_rng + * doesn't need a context argument. * - * \note If non-NULL, \p f_rng is used to blind the input as - * a countermeasure against timing attacks. Blinding is used - * only if our secret value \p X is re-used and omitted - * otherwise. Therefore, we recommend always passing a - * non-NULL \p f_rng argument. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX error code on failure. */ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, unsigned char *output, size_t output_size, size_t *olen, @@ -245,9 +288,12 @@ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, void *p_rng ); /** - * \brief This function frees and clears the components of a DHM key. + * \brief This function frees and clears the components + * of a DHM context. * - * \param ctx The DHM context to free and clear. + * \param ctx The DHM context to free and clear. This may be \c NULL, + * in which case this function is a no-op. If it is not \c NULL, + * it must point to an initialized DHM context. */ void mbedtls_dhm_free( mbedtls_dhm_context *ctx ); @@ -256,16 +302,19 @@ void mbedtls_dhm_free( mbedtls_dhm_context *ctx ); /** * \brief This function parses DHM parameters in PEM or DER format. * - * \param dhm The DHM context to initialize. - * \param dhmin The input buffer. - * \param dhminlen The size of the buffer, including the terminating null - * Byte for PEM data. + * \param dhm The DHM context to import the DHM parameters into. + * This must be initialized. + * \param dhmin The input buffer. This must be a readable buffer of + * length \p dhminlen Bytes. + * \param dhminlen The size of the input buffer \p dhmin, including the + * terminating \c NULL Byte for PEM data. * - * \return \c 0 on success, or a specific DHM or PEM error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX or \c MBEDTLS_ERR_PEM_XXX error + * code on failure. */ int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin, - size_t dhminlen ); + size_t dhminlen ); #if defined(MBEDTLS_FS_IO) /** \ingroup x509_module */ @@ -273,34 +322,29 @@ int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin, * \brief This function loads and parses DHM parameters from a file. * * \param dhm The DHM context to load the parameters to. + * This must be initialized. * \param path The filename to read the DHM parameters from. + * This must not be \c NULL. * - * \return \c 0 on success, or a specific DHM or PEM error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_DHM_XXX or \c MBEDTLS_ERR_PEM_XXX + * error code on failure. */ int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ); #endif /* MBEDTLS_FS_IO */ #endif /* MBEDTLS_ASN1_PARSE_C */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_DHM_ALT */ -#include "dhm_alt.h" -#endif /* MBEDTLS_DHM_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief The DMH checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_dhm_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } #endif @@ -348,15 +392,6 @@ int mbedtls_dhm_self_test( int verbose ); #if !defined(MBEDTLS_DEPRECATED_REMOVED) -#if defined(MBEDTLS_DEPRECATED_WARNING) -#define MBEDTLS_DEPRECATED __attribute__((deprecated)) -MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_constant_t; -#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \ - ( (mbedtls_deprecated_constant_t) ( VAL ) ) -#else -#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL -#endif /* ! MBEDTLS_DEPRECATED_WARNING */ - /** * \warning The origin of the primes in RFC 5114 is not documented and * their use therefore constitutes a security risk! diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdh.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdh.h index 99cfde00d0..4479a1d46f 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdh.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdh.h @@ -1,10 +1,11 @@ /** * \file ecdh.h * - * \brief The Elliptic Curve Diffie-Hellman (ECDH) protocol APIs. + * \brief This file contains ECDH definitions and functions. * - * ECDH is an anonymous key agreement protocol allowing two parties to - * establish a shared secret over an insecure channel. Each party must have an + * The Elliptic Curve Diffie-Hellman (ECDH) protocol is an anonymous + * key agreement protocol allowing two parties to establish a shared + * secret over an insecure channel. Each party must have an * elliptic-curve public–private key pair. * * For more information, see NIST SP 800-56A Rev. 2: Recommendation for @@ -33,28 +34,82 @@ #ifndef MBEDTLS_ECDH_H #define MBEDTLS_ECDH_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "ecp.h" +/* + * Use a backward compatible ECDH context. + * + * This flag is always enabled for now and future versions might add a + * configuration option that conditionally undefines this flag. + * The configuration option in question may have a different name. + * + * Features undefining this flag, must have a warning in their description in + * config.h stating that the feature breaks backward compatibility. + */ +#define MBEDTLS_ECDH_LEGACY_CONTEXT + #ifdef __cplusplus extern "C" { #endif /** - * Defines the source of the imported EC key: - *
  • Our key.
  • - *
  • The key of the peer.
+ * Defines the source of the imported EC key. */ typedef enum { - MBEDTLS_ECDH_OURS, - MBEDTLS_ECDH_THEIRS, + MBEDTLS_ECDH_OURS, /**< Our key. */ + MBEDTLS_ECDH_THEIRS, /**< The key of the peer. */ } mbedtls_ecdh_side; +#if !defined(MBEDTLS_ECDH_LEGACY_CONTEXT) +/** + * Defines the ECDH implementation used. + * + * Later versions of the library may add new variants, therefore users should + * not make any assumptions about them. + */ +typedef enum +{ + MBEDTLS_ECDH_VARIANT_NONE = 0, /*!< Implementation not defined. */ + MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0,/*!< The default Mbed TLS implementation */ +} mbedtls_ecdh_variant; + /** + * The context used by the default ECDH implementation. + * + * Later versions might change the structure of this context, therefore users + * should not make any assumptions about the structure of + * mbedtls_ecdh_context_mbed. + */ +typedef struct mbedtls_ecdh_context_mbed +{ + mbedtls_ecp_group grp; /*!< The elliptic curve used. */ + mbedtls_mpi d; /*!< The private key. */ + mbedtls_ecp_point Q; /*!< The public key. */ + mbedtls_ecp_point Qp; /*!< The value of the public key of the peer. */ + mbedtls_mpi z; /*!< The shared secret. */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_ctx rs; /*!< The restart context for EC computations. */ +#endif +} mbedtls_ecdh_context_mbed; +#endif + +/** + * + * \warning Performing multiple operations concurrently on the same + * ECDSA context is not supported; objects of this type + * should not be shared between multiple threads. * \brief The ECDH context structure. */ -typedef struct +typedef struct mbedtls_ecdh_context { +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) mbedtls_ecp_group grp; /*!< The elliptic curve used. */ mbedtls_mpi d; /*!< The private key. */ mbedtls_ecp_point Q; /*!< The public key. */ @@ -64,6 +119,29 @@ typedef struct mbedtls_ecp_point Vi; /*!< The blinding value. */ mbedtls_ecp_point Vf; /*!< The unblinding value. */ mbedtls_mpi _d; /*!< The previous \p d. */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + int restart_enabled; /*!< The flag for restartable mode. */ + mbedtls_ecp_restart_ctx rs; /*!< The restart context for EC computations. */ +#endif /* MBEDTLS_ECP_RESTARTABLE */ +#else + uint8_t point_format; /*!< The format of point export in TLS messages + as defined in RFC 4492. */ + mbedtls_ecp_group_id grp_id;/*!< The elliptic curve used. */ + mbedtls_ecdh_variant var; /*!< The ECDH implementation/structure used. */ + union + { + mbedtls_ecdh_context_mbed mbed_ecdh; + } ctx; /*!< Implementation-specific context. The + context in use is specified by the \c var + field. */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + uint8_t restart_enabled; /*!< The flag for restartable mode. Functions of + an alternative implementation not supporting + restartable mode must return + MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED error + if this flag is set. */ +#endif /* MBEDTLS_ECP_RESTARTABLE */ +#endif /* MBEDTLS_ECDH_LEGACY_CONTEXT */ } mbedtls_ecdh_context; @@ -75,16 +153,22 @@ mbedtls_ecdh_context; * implemented during the ECDH key exchange. The second core * computation is performed by mbedtls_ecdh_compute_shared(). * - * \param grp The ECP group. + * \see ecp.h + * + * \param grp The ECP group to use. This must be initialized and have + * domain parameters loaded, for example through + * mbedtls_ecp_load() or mbedtls_ecp_tls_read_group(). * \param d The destination MPI (private key). + * This must be initialized. * \param Q The destination point (public key). - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. + * This must be initialized. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL in case \p f_rng doesn't need a context argument. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or + * \return \c 0 on success. + * \return Another \c MBEDTLS_ERR_ECP_XXX or * \c MBEDTLS_MPI_XXX error code on failure. - * - * \see ecp.h */ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), @@ -97,21 +181,32 @@ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp * implemented during the ECDH key exchange. The first core * computation is performed by mbedtls_ecdh_gen_public(). * - * \param grp The ECP group. + * \see ecp.h + * + * \note If \p f_rng is not NULL, it is used to implement + * countermeasures against side-channel attacks. + * For more information, see mbedtls_ecp_mul(). + * + * \param grp The ECP group to use. This must be initialized and have + * domain parameters loaded, for example through + * mbedtls_ecp_load() or mbedtls_ecp_tls_read_group(). * \param z The destination MPI (shared secret). + * This must be initialized. * \param Q The public key from another party. + * This must be initialized. * \param d Our secret exponent (private key). - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or + * This must be initialized. + * \param f_rng The RNG function. This may be \c NULL if randomization + * of intermediate results during the ECP computations is + * not needed (discouraged). See the documentation of + * mbedtls_ecp_mul() for more. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a + * context argument. + * + * \return \c 0 on success. + * \return Another \c MBEDTLS_ERR_ECP_XXX or * \c MBEDTLS_MPI_XXX error code on failure. - * - * \see ecp.h - * - * \note If \p f_rng is not NULL, it is used to implement - * countermeasures against potential elaborate timing - * attacks. For more information, see mbedtls_ecp_mul(). */ int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, const mbedtls_ecp_point *Q, const mbedtls_mpi *d, @@ -121,39 +216,62 @@ int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, /** * \brief This function initializes an ECDH context. * - * \param ctx The ECDH context to initialize. + * \param ctx The ECDH context to initialize. This must not be \c NULL. */ void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ); /** - * \brief This function frees a context. + * \brief This function sets up the ECDH context with the information + * given. * - * \param ctx The context to free. - */ -void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ); - -/** - * \brief This function generates a public key and a TLS - * ServerKeyExchange payload. + * This function should be called after mbedtls_ecdh_init() but + * before mbedtls_ecdh_make_params(). There is no need to call + * this function before mbedtls_ecdh_read_params(). * * This is the first function used by a TLS server for ECDHE * ciphersuites. * - * \param ctx The ECDH context. - * \param olen The number of characters written. - * \param buf The destination buffer. - * \param blen The length of the destination buffer. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. + * \param ctx The ECDH context to set up. This must be initialized. + * \param grp_id The group id of the group to set up the context for. * - * \note This function assumes that the ECP group (grp) of the - * \p ctx context has already been properly set, - * for example, using mbedtls_ecp_group_load(). + * \return \c 0 on success. + */ +int mbedtls_ecdh_setup( mbedtls_ecdh_context *ctx, + mbedtls_ecp_group_id grp_id ); + +/** + * \brief This function frees a context. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code - * on failure. + * \param ctx The context to free. This may be \c NULL, in which + * case this function does nothing. If it is not \c NULL, + * it must point to an initialized ECDH context. + */ +void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ); + +/** + * \brief This function generates an EC key pair and exports its + * in the format used in a TLS ServerKeyExchange handshake + * message. + * + * This is the second function used by a TLS server for ECDHE + * ciphersuites. (It is called after mbedtls_ecdh_setup().) * * \see ecp.h + * + * \param ctx The ECDH context to use. This must be initialized + * and bound to a group, for example via mbedtls_ecdh_setup(). + * \param olen The address at which to store the number of Bytes written. + * \param buf The destination buffer. This must be a writable buffer of + * length \p blen Bytes. + * \param blen The length of the destination buffer \p buf in Bytes. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL in case \p f_rng doesn't need a context argument. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, @@ -161,23 +279,32 @@ int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, void *p_rng ); /** - * \brief This function parses and processes a TLS ServerKeyExhange - * payload. + * \brief This function parses the ECDHE parameters in a + * TLS ServerKeyExchange handshake message. * - * This is the first function used by a TLS client for ECDHE - * ciphersuites. + * \note In a TLS handshake, this is the how the client + * sets up its ECDHE context from the server's public + * ECDHE key material. + * + * \see ecp.h * - * \param ctx The ECDH context. - * \param buf The pointer to the start of the input buffer. - * \param end The address for one Byte past the end of the buffer. + * \param ctx The ECDHE context to use. This must be initialized. + * \param buf On input, \c *buf must be the start of the input buffer. + * On output, \c *buf is updated to point to the end of the + * data that has been read. On success, this is the first byte + * past the end of the ServerKeyExchange parameters. + * On error, this is the point at which an error has been + * detected, which is usually not useful except to debug + * failures. + * \param end The end of the input buffer. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX error code on failure. * - * \see ecp.h */ int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, - const unsigned char **buf, const unsigned char *end ); + const unsigned char **buf, + const unsigned char *end ); /** * \brief This function sets up an ECDH context from an EC key. @@ -186,38 +313,47 @@ int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, * ServerKeyEchange for static ECDH, and imports ECDH * parameters from the EC key information of a certificate. * - * \param ctx The ECDH context to set up. - * \param key The EC key to use. - * \param side Defines the source of the key: - *
  • 1: Our key.
  • -
  • 0: The key of the peer.
+ * \see ecp.h * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code - * on failure. + * \param ctx The ECDH context to set up. This must be initialized. + * \param key The EC key to use. This must be initialized. + * \param side Defines the source of the key. Possible values are: + * - #MBEDTLS_ECDH_OURS: The key is ours. + * - #MBEDTLS_ECDH_THEIRS: The key is that of the peer. + * + * \return \c 0 on success. + * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. * - * \see ecp.h */ -int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, - mbedtls_ecdh_side side ); +int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, + const mbedtls_ecp_keypair *key, + mbedtls_ecdh_side side ); /** - * \brief This function generates a public key and a TLS - * ClientKeyExchange payload. + * \brief This function generates a public key and exports it + * as a TLS ClientKeyExchange payload. * * This is the second function used by a TLS client for ECDH(E) * ciphersuites. * - * \param ctx The ECDH context. - * \param olen The number of Bytes written. - * \param buf The destination buffer. - * \param blen The size of the destination buffer. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code - * on failure. - * * \see ecp.h + * + * \param ctx The ECDH context to use. This must be initialized + * and bound to a group, the latter usually by + * mbedtls_ecdh_read_params(). + * \param olen The address at which to store the number of Bytes written. + * This must not be \c NULL. + * \param buf The destination buffer. This must be a writable buffer + * of length \p blen Bytes. + * \param blen The size of the destination buffer \p buf in Bytes. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL in case \p f_rng doesn't need a context argument. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, @@ -225,23 +361,26 @@ int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, void *p_rng ); /** - * \brief This function parses and processes a TLS ClientKeyExchange - * payload. + * \brief This function parses and processes the ECDHE payload of a + * TLS ClientKeyExchange message. * - * This is the second function used by a TLS server for ECDH(E) - * ciphersuites. + * This is the third function used by a TLS server for ECDH(E) + * ciphersuites. (It is called after mbedtls_ecdh_setup() and + * mbedtls_ecdh_make_params().) * - * \param ctx The ECDH context. - * \param buf The start of the input buffer. - * \param blen The length of the input buffer. + * \see ecp.h * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code - * on failure. + * \param ctx The ECDH context to use. This must be initialized + * and bound to a group, for example via mbedtls_ecdh_setup(). + * \param buf The pointer to the ClientKeyExchange payload. This must + * be a readable buffer of length \p blen Bytes. + * \param blen The length of the input buffer \p buf in Bytes. * - * \see ecp.h + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, - const unsigned char *buf, size_t blen ); + const unsigned char *buf, size_t blen ); /** * \brief This function derives and exports the shared secret. @@ -249,27 +388,51 @@ int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, * This is the last function used by both TLS client * and servers. * - * \param ctx The ECDH context. - * \param olen The number of Bytes written. - * \param buf The destination buffer. - * \param blen The length of the destination buffer. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code - * on failure. + * \note If \p f_rng is not NULL, it is used to implement + * countermeasures against side-channel attacks. + * For more information, see mbedtls_ecp_mul(). * * \see ecp.h - * - * \note If \p f_rng is not NULL, it is used to implement - * countermeasures against potential elaborate timing - * attacks. For more information, see mbedtls_ecp_mul(). + + * \param ctx The ECDH context to use. This must be initialized + * and have its own private key generated and the peer's + * public key imported. + * \param olen The address at which to store the total number of + * Bytes written on success. This must not be \c NULL. + * \param buf The buffer to write the generated shared key to. This + * must be a writable buffer of size \p blen Bytes. + * \param blen The length of the destination buffer \p buf in Bytes. + * \param f_rng The RNG function, for blinding purposes. This may + * b \c NULL if blinding isn't needed. + * \param p_rng The RNG context. This may be \c NULL if \p f_rng + * doesn't need a context argument. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another \c MBEDTLS_ERR_ECP_XXX error code on failure. */ int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, unsigned char *buf, size_t blen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); +#if defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief This function enables restartable EC computations for this + * context. (Default: disabled.) + * + * \see \c mbedtls_ecp_set_max_ops() + * + * \note It is not possible to safely disable restartable + * computations once enabled, except by free-ing the context, + * which cancels possible in-progress operations. + * + * \param ctx The ECDH context to use. This must be initialized. + */ +void mbedtls_ecdh_enable_restart( mbedtls_ecdh_context *ctx ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdsa.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdsa.h index ff6efbc3ff..f8b28507c2 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdsa.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecdsa.h @@ -1,9 +1,10 @@ /** * \file ecdsa.h * - * \brief The Elliptic Curve Digital Signature Algorithm (ECDSA). + * \brief This file contains ECDSA definitions and functions. * - * ECDSA is defined in Standards for Efficient Cryptography Group (SECG): + * The Elliptic Curve Digital Signature Algorithm (ECDSA) is defined in + * Standards for Efficient Cryptography Group (SECG): * SEC1 Elliptic Curve Cryptography. * The use of ECDSA for TLS is defined in RFC-4492: Elliptic Curve * Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS). @@ -31,6 +32,12 @@ #ifndef MBEDTLS_ECDSA_H #define MBEDTLS_ECDSA_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "ecp.h" #include "md.h" @@ -54,29 +61,71 @@ /** The maximal size of an ECDSA signature in Bytes. */ #define MBEDTLS_ECDSA_MAX_LEN ( 3 + 2 * ( 3 + MBEDTLS_ECP_MAX_BYTES ) ) +#ifdef __cplusplus +extern "C" { +#endif + /** * \brief The ECDSA context structure. + * + * \warning Performing multiple operations concurrently on the same + * ECDSA context is not supported; objects of this type + * should not be shared between multiple threads. */ typedef mbedtls_ecp_keypair mbedtls_ecdsa_context; -#ifdef __cplusplus -extern "C" { +#if defined(MBEDTLS_ECP_RESTARTABLE) + +/** + * \brief Internal restart context for ecdsa_verify() + * + * \note Opaque struct, defined in ecdsa.c + */ +typedef struct mbedtls_ecdsa_restart_ver mbedtls_ecdsa_restart_ver_ctx; + +/** + * \brief Internal restart context for ecdsa_sign() + * + * \note Opaque struct, defined in ecdsa.c + */ +typedef struct mbedtls_ecdsa_restart_sig mbedtls_ecdsa_restart_sig_ctx; + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) +/** + * \brief Internal restart context for ecdsa_sign_det() + * + * \note Opaque struct, defined in ecdsa.c + */ +typedef struct mbedtls_ecdsa_restart_det mbedtls_ecdsa_restart_det_ctx; #endif +/** + * \brief General context for resuming ECDSA operations + */ +typedef struct +{ + mbedtls_ecp_restart_ctx ecp; /*!< base context for ECP restart and + shared administrative info */ + mbedtls_ecdsa_restart_ver_ctx *ver; /*!< ecdsa_verify() sub-context */ + mbedtls_ecdsa_restart_sig_ctx *sig; /*!< ecdsa_sign() sub-context */ +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + mbedtls_ecdsa_restart_det_ctx *det; /*!< ecdsa_sign_det() sub-context */ +#endif +} mbedtls_ecdsa_restart_ctx; + +#else /* MBEDTLS_ECP_RESTARTABLE */ + +/* Now we can declare functions that take a pointer to that */ +typedef void mbedtls_ecdsa_restart_ctx; + +#endif /* MBEDTLS_ECP_RESTARTABLE */ + /** * \brief This function computes the ECDSA signature of a * previously-hashed message. * - * \note The deterministic version is usually preferred. - * - * \param grp The ECP group. - * \param r The first output integer. - * \param s The second output integer. - * \param d The private signing key. - * \param buf The message hash. - * \param blen The length of \p buf. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. + * \note The deterministic version implemented in + * mbedtls_ecdsa_sign_det() is usually preferred. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated @@ -84,10 +133,28 @@ extern "C" { * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.3, step 5. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX - * or \c MBEDTLS_MPI_XXX error code on failure. - * * \see ecp.h + * + * \param grp The context for the elliptic curve to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param r The MPI context in which to store the first part + * the signature. This must be initialized. + * \param s The MPI context in which to store the second part + * the signature. This must be initialized. + * \param d The private signing key. This must be initialized. + * \param buf The content to be signed. This is usually the hash of + * the original data to be signed. This must be a readable + * buffer of length \p blen Bytes. It may be \c NULL if + * \p blen is zero. + * \param blen The length of \p buf in Bytes. + * \param f_rng The RNG function. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng doesn't need a context parameter. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX + * or \c MBEDTLS_MPI_XXX error code on failure. */ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, @@ -97,62 +164,80 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, /** * \brief This function computes the ECDSA signature of a * previously-hashed message, deterministic version. + * * For more information, see RFC-6979: Deterministic * Usage of the Digital Signature Algorithm (DSA) and Elliptic * Curve Digital Signature Algorithm (ECDSA). * - * \param grp The ECP group. - * \param r The first output integer. - * \param s The second output integer. - * \param d The private signing key. - * \param buf The message hash. - * \param blen The length of \p buf. - * \param md_alg The MD algorithm used to hash the message. - * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.3, step 5. * - * \return \c 0 on success, - * or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX - * error code on failure. - * * \see ecp.h + * + * \param grp The context for the elliptic curve to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param r The MPI context in which to store the first part + * the signature. This must be initialized. + * \param s The MPI context in which to store the second part + * the signature. This must be initialized. + * \param d The private signing key. This must be initialized + * and setup, for example through mbedtls_ecp_gen_privkey(). + * \param buf The hashed content to be signed. This must be a readable + * buffer of length \p blen Bytes. It may be \c NULL if + * \p blen is zero. + * \param blen The length of \p buf in Bytes. + * \param md_alg The hash algorithm used to hash the original data. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX + * error code on failure. */ -int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, - const mbedtls_mpi *d, const unsigned char *buf, size_t blen, - mbedtls_md_type_t md_alg ); +int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, + mbedtls_mpi *s, const mbedtls_mpi *d, + const unsigned char *buf, size_t blen, + mbedtls_md_type_t md_alg ); #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ /** * \brief This function verifies the ECDSA signature of a * previously-hashed message. * - * \param grp The ECP group. - * \param buf The message hash. - * \param blen The length of \p buf. - * \param Q The public key to use for verification. - * \param r The first integer of the signature. - * \param s The second integer of the signature. - * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.4, step 3. * - * \return \c 0 on success, - * #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid, - * or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX - * error code on failure for any other reason. - * * \see ecp.h + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param buf The hashed content that was signed. This must be a readable + * buffer of length \p blen Bytes. It may be \c NULL if + * \p blen is zero. + * \param blen The length of \p buf in Bytes. + * \param Q The public key to use for verification. This must be + * initialized and setup. + * \param r The first integer of the signature. + * This must be initialized. + * \param s The second integer of the signature. + * This must be initialized. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the signature + * is invalid. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX + * error code on failure for any other reason. */ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, - const unsigned char *buf, size_t blen, - const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s); + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, const mbedtls_mpi *r, + const mbedtls_mpi *s); /** * \brief This function computes the ECDSA signature and writes it @@ -169,38 +254,92 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, * of the Digital Signature Algorithm (DSA) and Elliptic * Curve Digital Signature Algorithm (ECDSA)
. * - * \param ctx The ECDSA context. - * \param md_alg The message digest that was used to hash the message. - * \param hash The message hash. - * \param hlen The length of the hash. - * \param sig The buffer that holds the signature. - * \param slen The length of the signature written. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * - * \note The \p sig buffer must be at least twice as large as the - * size of the curve used, plus 9. For example, 73 Bytes if - * a 256-bit curve is used. A buffer length of - * #MBEDTLS_ECDSA_MAX_LEN is always safe. - * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.3, step 5. * - * \return \c 0 on success, - * or an \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or - * \c MBEDTLS_ERR_ASN1_XXX error code on failure. - * * \see ecp.h + * + * \param ctx The ECDSA context to use. This must be initialized + * and have a group and private key bound to it, for example + * via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair(). + * \param md_alg The message digest that was used to hash the message. + * \param hash The message hash to be signed. This must be a readable + * buffer of length \p blen Bytes. + * \param hlen The length of the hash \p hash in Bytes. + * \param sig The buffer to which to write the signature. This must be a + * writable buffer of length at least twice as large as the + * size of the curve used, plus 9. For example, 73 Bytes if + * a 256-bit curve is used. A buffer length of + * #MBEDTLS_ECDSA_MAX_LEN is always safe. + * \param slen The address at which to store the actual length of + * the signature written. Must not be \c NULL. + * \param f_rng The RNG function. This must not be \c NULL if + * #MBEDTLS_ECDSA_DETERMINISTIC is unset. Otherwise, + * it is unused and may be set to \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't use a context. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or + * \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ -int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, +int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, + mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); +/** + * \brief This function computes the ECDSA signature and writes it + * to a buffer, in a restartable way. + * + * \see \c mbedtls_ecdsa_write_signature() + * + * \note This function is like \c mbedtls_ecdsa_write_signature() + * but it can return early and restart according to the limit + * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. + * + * \param ctx The ECDSA context to use. This must be initialized + * and have a group and private key bound to it, for example + * via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair(). + * \param md_alg The message digest that was used to hash the message. + * \param hash The message hash to be signed. This must be a readable + * buffer of length \p blen Bytes. + * \param hlen The length of the hash \p hash in Bytes. + * \param sig The buffer to which to write the signature. This must be a + * writable buffer of length at least twice as large as the + * size of the curve used, plus 9. For example, 73 Bytes if + * a 256-bit curve is used. A buffer length of + * #MBEDTLS_ECDSA_MAX_LEN is always safe. + * \param slen The address at which to store the actual length of + * the signature written. Must not be \c NULL. + * \param f_rng The RNG function. This must not be \c NULL if + * #MBEDTLS_ECDSA_DETERMINISTIC is unset. Otherwise, + * it is unused and may be set to \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't use a context. + * \param rs_ctx The restart context to use. This may be \c NULL to disable + * restarting. If it is not \c NULL, it must point to an + * initialized restart context. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or + * \c MBEDTLS_ERR_ASN1_XXX error code on failure. + */ +int mbedtls_ecdsa_write_signature_restartable( mbedtls_ecdsa_context *ctx, + mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hlen, + unsigned char *sig, size_t *slen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + mbedtls_ecdsa_restart_ctx *rs_ctx ); + #if defined(MBEDTLS_ECDSA_DETERMINISTIC) #if ! defined(MBEDTLS_DEPRECATED_REMOVED) #if defined(MBEDTLS_DEPRECATED_WARNING) @@ -209,31 +348,17 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t #define MBEDTLS_DEPRECATED #endif /** - * \brief This function computes an ECDSA signature and writes it to a buffer, - * serialized as defined in RFC-4492: Elliptic Curve Cryptography - * (ECC) Cipher Suites for Transport Layer Security (TLS). + * \brief This function computes an ECDSA signature and writes + * it to a buffer, serialized as defined in RFC-4492: + * Elliptic Curve Cryptography (ECC) Cipher Suites for + * Transport Layer Security (TLS). * - * The deterministic version is defined in RFC-6979: - * Deterministic Usage of the Digital Signature Algorithm (DSA) and - * Elliptic Curve Digital Signature Algorithm (ECDSA). + * The deterministic version is defined in RFC-6979: + * Deterministic Usage of the Digital Signature Algorithm (DSA) + * and Elliptic Curve Digital Signature Algorithm (ECDSA). * * \warning It is not thread-safe to use the same context in * multiple threads. - - * - * \deprecated Superseded by mbedtls_ecdsa_write_signature() in 2.0.0 - * - * \param ctx The ECDSA context. - * \param hash The Message hash. - * \param hlen The length of the hash. - * \param sig The buffer that holds the signature. - * \param slen The length of the signature written. - * \param md_alg The MD algorithm used to hash the message. - * - * \note The \p sig buffer must be at least twice as large as the - * size of the curve used, plus 9. For example, 73 Bytes if a - * 256-bit curve is used. A buffer length of - * #MBEDTLS_ECDSA_MAX_LEN is always safe. * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as @@ -241,11 +366,29 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.3, step 5. * - * \return \c 0 on success, - * or an \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or - * \c MBEDTLS_ERR_ASN1_XXX error code on failure. - * * \see ecp.h + * + * \deprecated Superseded by mbedtls_ecdsa_write_signature() in + * Mbed TLS version 2.0 and later. + * + * \param ctx The ECDSA context to use. This must be initialized + * and have a group and private key bound to it, for example + * via mbedtls_ecdsa_genkey() or mbedtls_ecdsa_from_keypair(). + * \param hash The message hash to be signed. This must be a readable + * buffer of length \p blen Bytes. + * \param hlen The length of the hash \p hash in Bytes. + * \param sig The buffer to which to write the signature. This must be a + * writable buffer of length at least twice as large as the + * size of the curve used, plus 9. For example, 73 Bytes if + * a 256-bit curve is used. A buffer length of + * #MBEDTLS_ECDSA_MAX_LEN is always safe. + * \param slen The address at which to store the actual length of + * the signature written. Must not be \c NULL. + * \param md_alg The message digest that was used to hash the message. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX, \c MBEDTLS_ERR_MPI_XXX or + * \c MBEDTLS_ERR_ASN1_XXX error code on failure. */ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, @@ -258,75 +401,143 @@ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, /** * \brief This function reads and verifies an ECDSA signature. * - * \param ctx The ECDSA context. - * \param hash The message hash. - * \param hlen The size of the hash. - * \param sig The signature to read and verify. - * \param slen The size of \p sig. - * * \note If the bitlength of the message hash is larger than the * bitlength of the group order, then the hash is truncated as * defined in Standards for Efficient Cryptography Group * (SECG): SEC1 Elliptic Curve Cryptography, section * 4.1.4, step 3. * - * \return \c 0 on success, - * #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid, - * #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if there is a valid - * signature in sig but its length is less than \p siglen, - * or an \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX - * error code on failure for any other reason. - * * \see ecp.h + * + * \param ctx The ECDSA context to use. This must be initialized + * and have a group and public key bound to it. + * \param hash The message hash that was signed. This must be a readable + * buffer of length \p size Bytes. + * \param hlen The size of the hash \p hash. + * \param sig The signature to read and verify. This must be a readable + * buffer of length \p slen Bytes. + * \param slen The size of \p sig in Bytes. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid. + * \return #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if there is a valid + * signature in \p sig, but its length is less than \p siglen. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX + * error code on failure for any other reason. */ int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen ); +/** + * \brief This function reads and verifies an ECDSA signature, + * in a restartable way. + * + * \see \c mbedtls_ecdsa_read_signature() + * + * \note This function is like \c mbedtls_ecdsa_read_signature() + * but it can return early and restart according to the limit + * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. + * + * \param ctx The ECDSA context to use. This must be initialized + * and have a group and public key bound to it. + * \param hash The message hash that was signed. This must be a readable + * buffer of length \p size Bytes. + * \param hlen The size of the hash \p hash. + * \param sig The signature to read and verify. This must be a readable + * buffer of length \p slen Bytes. + * \param slen The size of \p sig in Bytes. + * \param rs_ctx The restart context to use. This may be \c NULL to disable + * restarting. If it is not \c NULL, it must point to an + * initialized restart context. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if signature is invalid. + * \return #MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH if there is a valid + * signature in \p sig, but its length is less than \p siglen. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_ERR_MPI_XXX + * error code on failure for any other reason. + */ +int mbedtls_ecdsa_read_signature_restartable( mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen, + mbedtls_ecdsa_restart_ctx *rs_ctx ); + /** * \brief This function generates an ECDSA keypair on the given curve. * + * \see ecp.h + * * \param ctx The ECDSA context to store the keypair in. + * This must be initialized. * \param gid The elliptic curve to use. One of the various * \c MBEDTLS_ECP_DP_XXX macros depending on configuration. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX code on - * failure. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng doesn't need a context argument. * - * \see ecp.h + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX code on failure. */ int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** - * \brief This function sets an ECDSA context from an EC key pair. + * \brief This function sets up an ECDSA context from an EC key pair. * - * \param ctx The ECDSA context to set. - * \param key The EC key to use. + * \see ecp.h * - * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX code on - * failure. + * \param ctx The ECDSA context to setup. This must be initialized. + * \param key The EC key to use. This must be initialized and hold + * a private-public key pair or a public key. In the former + * case, the ECDSA context may be used for signature creation + * and verification after this call. In the latter case, it + * may be used for signature verification. * - * \see ecp.h + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX code on failure. */ -int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key ); +int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, + const mbedtls_ecp_keypair *key ); /** * \brief This function initializes an ECDSA context. * * \param ctx The ECDSA context to initialize. + * This must not be \c NULL. */ void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx ); /** * \brief This function frees an ECDSA context. * - * \param ctx The ECDSA context to free. + * \param ctx The ECDSA context to free. This may be \c NULL, + * in which case this function does nothing. If it + * is not \c NULL, it must be initialized. */ void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx ); +#if defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief Initialize a restart context. + * + * \param ctx The restart context to initialize. + * This must not be \c NULL. + */ +void mbedtls_ecdsa_restart_init( mbedtls_ecdsa_restart_ctx *ctx ); + +/** + * \brief Free the components of a restart context. + * + * \param ctx The restart context to free. This may be \c NULL, + * in which case this function does nothing. If it + * is not \c NULL, it must be initialized. + */ +void mbedtls_ecdsa_restart_free( mbedtls_ecdsa_restart_ctx *ctx ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecjpake.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecjpake.h index d86e8207f1..3d8d02ae64 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecjpake.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecjpake.h @@ -40,12 +40,15 @@ * The payloads are serialized in a way suitable for use in TLS, but could * also be use outside TLS. */ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif #include "ecp.h" #include "md.h" -#if !defined(MBEDTLS_ECJPAKE_ALT) - #ifdef __cplusplus extern "C" { #endif @@ -58,6 +61,7 @@ typedef enum { MBEDTLS_ECJPAKE_SERVER, /**< Server */ } mbedtls_ecjpake_role; +#if !defined(MBEDTLS_ECJPAKE_ALT) /** * EC J-PAKE context structure. * @@ -69,7 +73,7 @@ typedef enum { * convetion from the Thread v1.0 spec. Correspondance is indicated in the * description as a pair C: client name, S: server name */ -typedef struct +typedef struct mbedtls_ecjpake_context { const mbedtls_md_info_t *md_info; /**< Hash to use */ mbedtls_ecp_group grp; /**< Elliptic curve */ @@ -88,29 +92,38 @@ typedef struct mbedtls_mpi s; /**< Pre-shared secret (passphrase) */ } mbedtls_ecjpake_context; +#else /* MBEDTLS_ECJPAKE_ALT */ +#include "ecjpake_alt.h" +#endif /* MBEDTLS_ECJPAKE_ALT */ + /** - * \brief Initialize a context - * (just makes it ready for setup() or free()). + * \brief Initialize an ECJPAKE context. * - * \param ctx context to initialize + * \param ctx The ECJPAKE context to initialize. + * This must not be \c NULL. */ void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx ); /** - * \brief Set up a context for use + * \brief Set up an ECJPAKE context for use. * * \note Currently the only values for hash/curve allowed by the - * standard are MBEDTLS_MD_SHA256/MBEDTLS_ECP_DP_SECP256R1. + * standard are #MBEDTLS_MD_SHA256/#MBEDTLS_ECP_DP_SECP256R1. * - * \param ctx context to set up - * \param role Our role: client or server - * \param hash hash function to use (MBEDTLS_MD_XXX) - * \param curve elliptic curve identifier (MBEDTLS_ECP_DP_XXX) - * \param secret pre-shared secret (passphrase) - * \param len length of the shared secret + * \param ctx The ECJPAKE context to set up. This must be initialized. + * \param role The role of the caller. This must be either + * #MBEDTLS_ECJPAKE_CLIENT or #MBEDTLS_ECJPAKE_SERVER. + * \param hash The identifier of the hash function to use, + * for example #MBEDTLS_MD_SHA256. + * \param curve The identifier of the elliptic curve to use, + * for example #MBEDTLS_ECP_DP_SECP256R1. + * \param secret The pre-shared secret (passphrase). This must be + * a readable buffer of length \p len Bytes. It need + * only be valid for the duration of this call. + * \param len The length of the pre-shared secret \p secret. * - * \return 0 if successfull, - * a negative error code otherwise + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, mbedtls_ecjpake_role role, @@ -120,29 +133,34 @@ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, size_t len ); /** - * \brief Check if a context is ready for use + * \brief Check if an ECJPAKE context is ready for use. * - * \param ctx Context to check + * \param ctx The ECJPAKE context to check. This must be + * initialized. * - * \return 0 if the context is ready for use, - * MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise + * \return \c 0 if the context is ready for use. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise. */ int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx ); /** * \brief Generate and write the first round message * (TLS: contents of the Client/ServerHello extension, - * excluding extension type and length bytes) + * excluding extension type and length bytes). * - * \param ctx Context to use - * \param buf Buffer to write the contents to - * \param len Buffer size - * \param olen Will be updated with the number of bytes written - * \param f_rng RNG function - * \param p_rng RNG parameter + * \param ctx The ECJPAKE context to use. This must be + * initialized and set up. + * \param buf The buffer to write the contents to. This must be a + * writable buffer of length \p len Bytes. + * \param len The length of \p buf in Bytes. + * \param olen The address at which to store the total number + * of Bytes written to \p buf. This must not be \c NULL. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. This + * may be \c NULL if \p f_rng doesn't use a context. * - * \return 0 if successfull, - * a negative error code otherwise + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, @@ -152,14 +170,16 @@ int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx, /** * \brief Read and process the first round message * (TLS: contents of the Client/ServerHello extension, - * excluding extension type and length bytes) + * excluding extension type and length bytes). * - * \param ctx Context to use - * \param buf Pointer to extension contents - * \param len Extension length + * \param ctx The ECJPAKE context to use. This must be initialized + * and set up. + * \param buf The buffer holding the first round message. This must + * be a readable buffer of length \p len Bytes. + * \param len The length in Bytes of \p buf. * - * \return 0 if successfull, - * a negative error code otherwise + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx, const unsigned char *buf, @@ -167,17 +187,21 @@ int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx, /** * \brief Generate and write the second round message - * (TLS: contents of the Client/ServerKeyExchange) + * (TLS: contents of the Client/ServerKeyExchange). * - * \param ctx Context to use - * \param buf Buffer to write the contents to - * \param len Buffer size - * \param olen Will be updated with the number of bytes written - * \param f_rng RNG function - * \param p_rng RNG parameter + * \param ctx The ECJPAKE context to use. This must be initialized, + * set up, and already have performed round one. + * \param buf The buffer to write the round two contents to. + * This must be a writable buffer of length \p len Bytes. + * \param len The size of \p buf in Bytes. + * \param olen The address at which to store the total number of Bytes + * written to \p buf. This must not be \c NULL. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. This + * may be \c NULL if \p f_rng doesn't use a context. * - * \return 0 if successfull, - * a negative error code otherwise + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, @@ -186,14 +210,16 @@ int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx, /** * \brief Read and process the second round message - * (TLS: contents of the Client/ServerKeyExchange) + * (TLS: contents of the Client/ServerKeyExchange). * - * \param ctx Context to use - * \param buf Pointer to the message - * \param len Message length + * \param ctx The ECJPAKE context to use. This must be initialized + * and set up and already have performed round one. + * \param buf The buffer holding the second round message. This must + * be a readable buffer of length \p len Bytes. + * \param len The length in Bytes of \p buf. * - * \return 0 if successfull, - * a negative error code otherwise + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx, const unsigned char *buf, @@ -201,17 +227,21 @@ int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx, /** * \brief Derive the shared secret - * (TLS: Pre-Master Secret) + * (TLS: Pre-Master Secret). * - * \param ctx Context to use - * \param buf Buffer to write the contents to - * \param len Buffer size - * \param olen Will be updated with the number of bytes written - * \param f_rng RNG function - * \param p_rng RNG parameter + * \param ctx The ECJPAKE context to use. This must be initialized, + * set up and have performed both round one and two. + * \param buf The buffer to write the derived secret to. This must + * be a writable buffer of length \p len Bytes. + * \param len The length of \p buf in Bytes. + * \param olen The address at which to store the total number of Bytes + * written to \p buf. This must not be \c NULL. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. This + * may be \c NULL if \p f_rng doesn't use a context. * - * \return 0 if successfull, - * a negative error code otherwise + * \return \c 0 if successful. + * \return A negative error code on failure. */ int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx, unsigned char *buf, size_t len, size_t *olen, @@ -219,26 +249,17 @@ int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx, void *p_rng ); /** - * \brief Free a context's content + * \brief This clears an ECJPAKE context and frees any + * embedded data structure. * - * \param ctx context to free + * \param ctx The ECJPAKE context to free. This may be \c NULL, + * in which case this function does nothing. If it is not + * \c NULL, it must point to an initialized ECJPAKE context. */ void mbedtls_ecjpake_free( mbedtls_ecjpake_context *ctx ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_ECJPAKE_ALT */ -#include "ecjpake_alt.h" -#endif /* MBEDTLS_ECJPAKE_ALT */ - #if defined(MBEDTLS_SELF_TEST) -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief Checkup routine * @@ -246,10 +267,11 @@ extern "C" { */ int mbedtls_ecjpake_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif -#endif /* MBEDTLS_SELF_TEST */ #endif /* ecjpake.h */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp.h index 7b8ffff44e..065a4cc0b9 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp.h @@ -1,10 +1,21 @@ /** * \file ecp.h * - * \brief Elliptic curves over GF(p) + * \brief This file provides an API for Elliptic Curves over GF(P) (ECP). + * + * The use of ECP in cryptography and TLS is defined in + * Standards for Efficient Cryptography Group (SECG): SEC1 + * Elliptic Curve Cryptography and + * RFC-4492: Elliptic Curve Cryptography (ECC) Cipher Suites + * for Transport Layer Security (TLS). + * + * RFC-2409: The Internet Key Exchange (IKE) defines ECP + * group types. + * */ + /* - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -19,11 +30,18 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * This file is part of mbed TLS (https://tls.mbed.org) + * This file is part of Mbed TLS (https://tls.mbed.org) */ + #ifndef MBEDTLS_ECP_H #define MBEDTLS_ECP_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "bignum.h" /* @@ -31,160 +49,165 @@ */ #define MBEDTLS_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL -0x4F00 /**< The buffer is too small to write to. */ -#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80 /**< Requested curve not available. */ +#define MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE -0x4E80 /**< The requested feature is not available, for example, the requested curve is not supported. */ #define MBEDTLS_ERR_ECP_VERIFY_FAILED -0x4E00 /**< The signature is not valid. */ #define MBEDTLS_ERR_ECP_ALLOC_FAILED -0x4D80 /**< Memory allocation failed. */ -#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as (ephemeral) key, failed. */ +#define MBEDTLS_ERR_ECP_RANDOM_FAILED -0x4D00 /**< Generation of random value, such as ephemeral key, failed. */ #define MBEDTLS_ERR_ECP_INVALID_KEY -0x4C80 /**< Invalid private or public key. */ #define MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH -0x4C00 /**< The buffer contains a valid signature followed by more data. */ -#define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80 /**< ECP hardware accelerator failed. */ -#if !defined(MBEDTLS_ECP_ALT) -/* - * default mbed TLS elliptic curve arithmetic implementation - * - * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an - * alternative implementation for the whole module and it will replace this - * one.) - */ +/* MBEDTLS_ERR_ECP_HW_ACCEL_FAILED is deprecated and should not be used. */ +#define MBEDTLS_ERR_ECP_HW_ACCEL_FAILED -0x4B80 /**< The ECP hardware accelerator failed. */ + +#define MBEDTLS_ERR_ECP_IN_PROGRESS -0x4B00 /**< Operation in progress, call again with the same parameters to continue. */ #ifdef __cplusplus extern "C" { #endif /** - * Domain parameters (curve, subgroup and generator) identifiers. + * Domain-parameter identifiers: curve, subgroup, and generator. * - * Only curves over prime fields are supported. + * \note Only curves over prime fields are supported. * * \warning This library does not support validation of arbitrary domain - * parameters. Therefore, only well-known domain parameters from trusted + * parameters. Therefore, only standardized domain parameters from trusted * sources should be used. See mbedtls_ecp_group_load(). */ typedef enum { - MBEDTLS_ECP_DP_NONE = 0, - MBEDTLS_ECP_DP_SECP192R1, /*!< 192-bits NIST curve */ - MBEDTLS_ECP_DP_SECP224R1, /*!< 224-bits NIST curve */ - MBEDTLS_ECP_DP_SECP256R1, /*!< 256-bits NIST curve */ - MBEDTLS_ECP_DP_SECP384R1, /*!< 384-bits NIST curve */ - MBEDTLS_ECP_DP_SECP521R1, /*!< 521-bits NIST curve */ - MBEDTLS_ECP_DP_BP256R1, /*!< 256-bits Brainpool curve */ - MBEDTLS_ECP_DP_BP384R1, /*!< 384-bits Brainpool curve */ - MBEDTLS_ECP_DP_BP512R1, /*!< 512-bits Brainpool curve */ - MBEDTLS_ECP_DP_CURVE25519, /*!< Curve25519 */ - MBEDTLS_ECP_DP_SECP192K1, /*!< 192-bits "Koblitz" curve */ - MBEDTLS_ECP_DP_SECP224K1, /*!< 224-bits "Koblitz" curve */ - MBEDTLS_ECP_DP_SECP256K1, /*!< 256-bits "Koblitz" curve */ + MBEDTLS_ECP_DP_NONE = 0, /*!< Curve not defined. */ + MBEDTLS_ECP_DP_SECP192R1, /*!< Domain parameters for the 192-bit curve defined by FIPS 186-4 and SEC1. */ + MBEDTLS_ECP_DP_SECP224R1, /*!< Domain parameters for the 224-bit curve defined by FIPS 186-4 and SEC1. */ + MBEDTLS_ECP_DP_SECP256R1, /*!< Domain parameters for the 256-bit curve defined by FIPS 186-4 and SEC1. */ + MBEDTLS_ECP_DP_SECP384R1, /*!< Domain parameters for the 384-bit curve defined by FIPS 186-4 and SEC1. */ + MBEDTLS_ECP_DP_SECP521R1, /*!< Domain parameters for the 521-bit curve defined by FIPS 186-4 and SEC1. */ + MBEDTLS_ECP_DP_BP256R1, /*!< Domain parameters for 256-bit Brainpool curve. */ + MBEDTLS_ECP_DP_BP384R1, /*!< Domain parameters for 384-bit Brainpool curve. */ + MBEDTLS_ECP_DP_BP512R1, /*!< Domain parameters for 512-bit Brainpool curve. */ + MBEDTLS_ECP_DP_CURVE25519, /*!< Domain parameters for Curve25519. */ + MBEDTLS_ECP_DP_SECP192K1, /*!< Domain parameters for 192-bit "Koblitz" curve. */ + MBEDTLS_ECP_DP_SECP224K1, /*!< Domain parameters for 224-bit "Koblitz" curve. */ + MBEDTLS_ECP_DP_SECP256K1, /*!< Domain parameters for 256-bit "Koblitz" curve. */ + MBEDTLS_ECP_DP_CURVE448, /*!< Domain parameters for Curve448. */ } mbedtls_ecp_group_id; /** - * Number of supported curves (plus one for NONE). + * The number of supported curves, plus one for #MBEDTLS_ECP_DP_NONE. * - * (Montgomery curves excluded for now.) + * \note Montgomery curves are currently excluded. */ #define MBEDTLS_ECP_DP_MAX 12 /** - * Curve information for use by other modules + * Curve information, for use by other modules. */ -typedef struct +typedef struct mbedtls_ecp_curve_info { - mbedtls_ecp_group_id grp_id; /*!< Internal identifier */ - uint16_t tls_id; /*!< TLS NamedCurve identifier */ - uint16_t bit_size; /*!< Curve size in bits */ - const char *name; /*!< Human-friendly name */ + mbedtls_ecp_group_id grp_id; /*!< An internal identifier. */ + uint16_t tls_id; /*!< The TLS NamedCurve identifier. */ + uint16_t bit_size; /*!< The curve size in bits. */ + const char *name; /*!< A human-friendly name. */ } mbedtls_ecp_curve_info; /** - * \brief ECP point structure (jacobian coordinates) + * \brief The ECP point structure, in Jacobian coordinates. * * \note All functions expect and return points satisfying - * the following condition: Z == 0 or Z == 1. (Other - * values of Z are used by internal functions only.) - * The point is zero, or "at infinity", if Z == 0. - * Otherwise, X and Y are its standard (affine) coordinates. + * the following condition: Z == 0 or + * Z == 1. Other values of \p Z are + * used only by internal functions. + * The point is zero, or "at infinity", if Z == 0. + * Otherwise, \p X and \p Y are its standard (affine) + * coordinates. */ -typedef struct +typedef struct mbedtls_ecp_point { - mbedtls_mpi X; /*!< the point's X coordinate */ - mbedtls_mpi Y; /*!< the point's Y coordinate */ - mbedtls_mpi Z; /*!< the point's Z coordinate */ + mbedtls_mpi X; /*!< The X coordinate of the ECP point. */ + mbedtls_mpi Y; /*!< The Y coordinate of the ECP point. */ + mbedtls_mpi Z; /*!< The Z coordinate of the ECP point. */ } mbedtls_ecp_point; -/** - * \brief ECP group structure - * - * We consider two types of curves equations: - * 1. Short Weierstrass y^2 = x^3 + A x + B mod P (SEC1 + RFC 4492) - * 2. Montgomery, y^2 = x^3 + A x^2 + x mod P (Curve25519 + draft) - * In both cases, a generator G for a prime-order subgroup is fixed. In the - * short weierstrass, this subgroup is actually the whole curve, and its - * cardinal is denoted by N. - * - * In the case of Short Weierstrass curves, our code requires that N is an odd - * prime. (Use odd in mbedtls_ecp_mul() and prime in mbedtls_ecdsa_sign() for blinding.) - * - * In the case of Montgomery curves, we don't store A but (A + 2) / 4 which is - * the quantity actually used in the formulas. Also, nbits is not the size of N - * but the required size for private keys. +#if !defined(MBEDTLS_ECP_ALT) +/* + * default mbed TLS elliptic curve arithmetic implementation * - * If modp is NULL, reduction modulo P is done using a generic algorithm. - * Otherwise, it must point to a function that takes an mbedtls_mpi in the range - * 0..2^(2*pbits)-1 and transforms it in-place in an integer of little more - * than pbits, so that the integer may be efficiently brought in the 0..P-1 - * range by a few additions or substractions. It must return 0 on success and - * non-zero on failure. + * (in case MBEDTLS_ECP_ALT is defined then the developer has to provide an + * alternative implementation for the whole module and it will replace this + * one.) */ -typedef struct -{ - mbedtls_ecp_group_id id; /*!< internal group identifier */ - mbedtls_mpi P; /*!< prime modulus of the base field */ - mbedtls_mpi A; /*!< 1. A in the equation, or 2. (A + 2) / 4 */ - mbedtls_mpi B; /*!< 1. B in the equation, or 2. unused */ - mbedtls_ecp_point G; /*!< generator of the (sub)group used */ - mbedtls_mpi N; /*!< 1. the order of G, or 2. unused */ - size_t pbits; /*!< number of bits in P */ - size_t nbits; /*!< number of bits in 1. P, or 2. private keys */ - unsigned int h; /*!< internal: 1 if the constants are static */ - int (*modp)(mbedtls_mpi *); /*!< function for fast reduction mod P */ - int (*t_pre)(mbedtls_ecp_point *, void *); /*!< unused */ - int (*t_post)(mbedtls_ecp_point *, void *); /*!< unused */ - void *t_data; /*!< unused */ - mbedtls_ecp_point *T; /*!< pre-computed points for ecp_mul_comb() */ - size_t T_size; /*!< number for pre-computed points */ -} -mbedtls_ecp_group; /** - * \brief ECP key pair structure - * - * A generic key pair that could be used for ECDSA, fixed ECDH, etc. + * \brief The ECP group structure. + * + * We consider two types of curve equations: + *
  • Short Weierstrass: y^2 = x^3 + A x + B mod P + * (SEC1 + RFC-4492)
  • + *
  • Montgomery: y^2 = x^3 + A x^2 + x mod P (Curve25519, + * Curve448)
+ * In both cases, the generator (\p G) for a prime-order subgroup is fixed. + * + * For Short Weierstrass, this subgroup is the whole curve, and its + * cardinality is denoted by \p N. Our code requires that \p N is an + * odd prime as mbedtls_ecp_mul() requires an odd number, and + * mbedtls_ecdsa_sign() requires that it is prime for blinding purposes. + * + * For Montgomery curves, we do not store \p A, but (A + 2) / 4, + * which is the quantity used in the formulas. Additionally, \p nbits is + * not the size of \p N but the required size for private keys. + * + * If \p modp is NULL, reduction modulo \p P is done using a generic algorithm. + * Otherwise, \p modp must point to a function that takes an \p mbedtls_mpi in the + * range of 0..2^(2*pbits)-1, and transforms it in-place to an integer + * which is congruent mod \p P to the given MPI, and is close enough to \p pbits + * in size, so that it may be efficiently brought in the 0..P-1 range by a few + * additions or subtractions. Therefore, it is only an approximative modular + * reduction. It must return 0 on success and non-zero on failure. + * + * \note Alternative implementations must keep the group IDs distinct. If + * two group structures have the same ID, then they must be + * identical. * - * \note Members purposefully in the same order as struc mbedtls_ecdsa_context. */ -typedef struct +typedef struct mbedtls_ecp_group { - mbedtls_ecp_group grp; /*!< Elliptic curve and base point */ - mbedtls_mpi d; /*!< our secret value */ - mbedtls_ecp_point Q; /*!< our public value */ + mbedtls_ecp_group_id id; /*!< An internal group identifier. */ + mbedtls_mpi P; /*!< The prime modulus of the base field. */ + mbedtls_mpi A; /*!< For Short Weierstrass: \p A in the equation. For + Montgomery curves: (A + 2) / 4. */ + mbedtls_mpi B; /*!< For Short Weierstrass: \p B in the equation. + For Montgomery curves: unused. */ + mbedtls_ecp_point G; /*!< The generator of the subgroup used. */ + mbedtls_mpi N; /*!< The order of \p G. */ + size_t pbits; /*!< The number of bits in \p P.*/ + size_t nbits; /*!< For Short Weierstrass: The number of bits in \p P. + For Montgomery curves: the number of bits in the + private keys. */ + unsigned int h; /*!< \internal 1 if the constants are static. */ + int (*modp)(mbedtls_mpi *); /*!< The function for fast pseudo-reduction + mod \p P (see above).*/ + int (*t_pre)(mbedtls_ecp_point *, void *); /*!< Unused. */ + int (*t_post)(mbedtls_ecp_point *, void *); /*!< Unused. */ + void *t_data; /*!< Unused. */ + mbedtls_ecp_point *T; /*!< Pre-computed points for ecp_mul_comb(). */ + size_t T_size; /*!< The number of pre-computed points. */ } -mbedtls_ecp_keypair; +mbedtls_ecp_group; /** * \name SECTION: Module settings * * The configuration options you can set for this module are in this section. - * Either change them in config.h or define them on the compiler command line. + * Either change them in config.h, or define them using the compiler command line. * \{ */ #if !defined(MBEDTLS_ECP_MAX_BITS) /** - * Maximum size of the groups (that is, of N and P) + * The maximum size of the groups, that is, of \c N and \c P. */ -#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ +#define MBEDTLS_ECP_MAX_BITS 521 /**< The maximum size of groups, in bits. */ #endif #define MBEDTLS_ECP_MAX_BYTES ( ( MBEDTLS_ECP_MAX_BITS + 7 ) / 8 ) @@ -207,11 +230,10 @@ mbedtls_ecp_keypair; * 521 145 141 135 120 97 * 384 214 209 198 177 146 * 256 320 320 303 262 226 - * 224 475 475 453 398 342 * 192 640 640 633 587 476 */ -#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< The maximum window size used. */ #endif /* MBEDTLS_ECP_WINDOW_SIZE */ #if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM) @@ -226,33 +248,188 @@ mbedtls_ecp_keypair; * * Change this value to 0 to reduce peak memory usage. */ -#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ +#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up. */ #endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */ /* \} name SECTION: Module settings */ +#else /* MBEDTLS_ECP_ALT */ +#include "ecp_alt.h" +#endif /* MBEDTLS_ECP_ALT */ + +#if defined(MBEDTLS_ECP_RESTARTABLE) + +/** + * \brief Internal restart context for multiplication + * + * \note Opaque struct + */ +typedef struct mbedtls_ecp_restart_mul mbedtls_ecp_restart_mul_ctx; + +/** + * \brief Internal restart context for ecp_muladd() + * + * \note Opaque struct + */ +typedef struct mbedtls_ecp_restart_muladd mbedtls_ecp_restart_muladd_ctx; + +/** + * \brief General context for resuming ECC operations + */ +typedef struct +{ + unsigned ops_done; /*!< current ops count */ + unsigned depth; /*!< call depth (0 = top-level) */ + mbedtls_ecp_restart_mul_ctx *rsm; /*!< ecp_mul_comb() sub-context */ + mbedtls_ecp_restart_muladd_ctx *ma; /*!< ecp_muladd() sub-context */ +} mbedtls_ecp_restart_ctx; + +/* + * Operation counts for restartable functions + */ +#define MBEDTLS_ECP_OPS_CHK 3 /*!< basic ops count for ecp_check_pubkey() */ +#define MBEDTLS_ECP_OPS_DBL 8 /*!< basic ops count for ecp_double_jac() */ +#define MBEDTLS_ECP_OPS_ADD 11 /*!< basic ops count for see ecp_add_mixed() */ +#define MBEDTLS_ECP_OPS_INV 120 /*!< empirical equivalent for mpi_mod_inv() */ + +/** + * \brief Internal; for restartable functions in other modules. + * Check and update basic ops budget. + * + * \param grp Group structure + * \param rs_ctx Restart context + * \param ops Number of basic ops to do + * + * \return \c 0 if doing \p ops basic ops is still allowed, + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS otherwise. + */ +int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp, + mbedtls_ecp_restart_ctx *rs_ctx, + unsigned ops ); + +/* Utility macro for checking and updating ops budget */ +#define MBEDTLS_ECP_BUDGET( ops ) \ + MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, rs_ctx, \ + (unsigned) (ops) ) ); + +#else /* MBEDTLS_ECP_RESTARTABLE */ + +#define MBEDTLS_ECP_BUDGET( ops ) /* no-op; for compatibility */ + +/* We want to declare restartable versions of existing functions anyway */ +typedef void mbedtls_ecp_restart_ctx; + +#endif /* MBEDTLS_ECP_RESTARTABLE */ + +/** + * \brief The ECP key-pair structure. + * + * A generic key-pair that may be used for ECDSA and fixed ECDH, for example. + * + * \note Members are deliberately in the same order as in the + * ::mbedtls_ecdsa_context structure. + */ +typedef struct mbedtls_ecp_keypair +{ + mbedtls_ecp_group grp; /*!< Elliptic curve and base point */ + mbedtls_mpi d; /*!< our secret value */ + mbedtls_ecp_point Q; /*!< our public value */ +} +mbedtls_ecp_keypair; + /* * Point formats, from RFC 4492's enum ECPointFormat */ -#define MBEDTLS_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format */ -#define MBEDTLS_ECP_PF_COMPRESSED 1 /**< Compressed point format */ +#define MBEDTLS_ECP_PF_UNCOMPRESSED 0 /**< Uncompressed point format. */ +#define MBEDTLS_ECP_PF_COMPRESSED 1 /**< Compressed point format. */ /* * Some other constants from RFC 4492 */ -#define MBEDTLS_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */ +#define MBEDTLS_ECP_TLS_NAMED_CURVE 3 /**< The named_curve of ECCurveType. */ + +#if defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief Set the maximum number of basic operations done in a row. + * + * If more operations are needed to complete a computation, + * #MBEDTLS_ERR_ECP_IN_PROGRESS will be returned by the + * function performing the computation. It is then the + * caller's responsibility to either call again with the same + * parameters until it returns 0 or an error code; or to free + * the restart context if the operation is to be aborted. + * + * It is strictly required that all input parameters and the + * restart context be the same on successive calls for the + * same operation, but output parameters need not be the + * same; they must not be used until the function finally + * returns 0. + * + * This only applies to functions whose documentation + * mentions they may return #MBEDTLS_ERR_ECP_IN_PROGRESS (or + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS for functions in the + * SSL module). For functions that accept a "restart context" + * argument, passing NULL disables restart and makes the + * function equivalent to the function with the same name + * with \c _restartable removed. For functions in the ECDH + * module, restart is disabled unless the function accepts + * an "ECDH context" argument and + * mbedtls_ecdh_enable_restart() was previously called on + * that context. For function in the SSL module, restart is + * only enabled for specific sides and key exchanges + * (currently only for clients and ECDHE-ECDSA). + * + * \param max_ops Maximum number of basic operations done in a row. + * Default: 0 (unlimited). + * Lower (non-zero) values mean ECC functions will block for + * a lesser maximum amount of time. + * + * \note A "basic operation" is defined as a rough equivalent of a + * multiplication in GF(p) for the NIST P-256 curve. + * As an indication, with default settings, a scalar + * multiplication (full run of \c mbedtls_ecp_mul()) is: + * - about 3300 basic operations for P-256 + * - about 9400 basic operations for P-384 + * + * \note Very low values are not always respected: sometimes + * functions need to block for a minimum number of + * operations, and will do so even if max_ops is set to a + * lower value. That minimum depends on the curve size, and + * can be made lower by decreasing the value of + * \c MBEDTLS_ECP_WINDOW_SIZE. As an indication, here is the + * lowest effective value for various curves and values of + * that parameter (w for short): + * w=6 w=5 w=4 w=3 w=2 + * P-256 208 208 160 136 124 + * P-384 682 416 320 272 248 + * P-521 1364 832 640 544 496 + * + * \note This setting is currently ignored by Curve25519. + */ +void mbedtls_ecp_set_max_ops( unsigned max_ops ); + +/** + * \brief Check if restart is enabled (max_ops != 0) + * + * \return \c 0 if \c max_ops == 0 (restart disabled) + * \return \c 1 otherwise (restart enabled) + */ +int mbedtls_ecp_restart_is_enabled( void ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ /** - * \brief Get the list of supported curves in order of preferrence - * (full information) + * \brief This function retrieves the information defined in + * mbedtls_ecp_curve_info() for all supported curves in order + * of preference. * - * \return A statically allocated array, the last entry is 0. + * \return A statically allocated array. The last entry is 0. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ); /** - * \brief Get the list of supported curves in order of preferrence - * (grp_id only) + * \brief This function retrieves the list of internal group + * identifiers of all supported curves in the order of + * preference. * * \return A statically allocated array, * terminated with MBEDTLS_ECP_DP_NONE. @@ -260,416 +437,689 @@ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_list( void ); const mbedtls_ecp_group_id *mbedtls_ecp_grp_id_list( void ); /** - * \brief Get curve information from an internal group identifier + * \brief This function retrieves curve information from an internal + * group identifier. * - * \param grp_id A MBEDTLS_ECP_DP_XXX value + * \param grp_id An \c MBEDTLS_ECP_DP_XXX value. * - * \return The associated curve information or NULL + * \return The associated curve information on success. + * \return NULL on failure. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_grp_id( mbedtls_ecp_group_id grp_id ); /** - * \brief Get curve information from a TLS NamedCurve value + * \brief This function retrieves curve information from a TLS + * NamedCurve value. * - * \param tls_id A MBEDTLS_ECP_DP_XXX value + * \param tls_id An \c MBEDTLS_ECP_DP_XXX value. * - * \return The associated curve information or NULL + * \return The associated curve information on success. + * \return NULL on failure. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_tls_id( uint16_t tls_id ); /** - * \brief Get curve information from a human-readable name + * \brief This function retrieves curve information from a + * human-readable name. * - * \param name The name + * \param name The human-readable name. * - * \return The associated curve information or NULL + * \return The associated curve information on success. + * \return NULL on failure. */ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name ); /** - * \brief Initialize a point (as zero) + * \brief This function initializes a point as zero. + * + * \param pt The point to initialize. */ void mbedtls_ecp_point_init( mbedtls_ecp_point *pt ); /** - * \brief Initialize a group (to something meaningless) + * \brief This function initializes an ECP group context + * without loading any domain parameters. + * + * \note After this function is called, domain parameters + * for various ECP groups can be loaded through the + * mbedtls_ecp_group_load() or mbedtls_ecp_tls_read_group() + * functions. */ void mbedtls_ecp_group_init( mbedtls_ecp_group *grp ); /** - * \brief Initialize a key pair (as an invalid one) + * \brief This function initializes a key pair as an invalid one. + * + * \param key The key pair to initialize. */ void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key ); /** - * \brief Free the components of a point + * \brief This function frees the components of a point. + * + * \param pt The point to free. */ void mbedtls_ecp_point_free( mbedtls_ecp_point *pt ); /** - * \brief Free the components of an ECP group + * \brief This function frees the components of an ECP group. + * + * \param grp The group to free. This may be \c NULL, in which + * case this function returns immediately. If it is not + * \c NULL, it must point to an initialized ECP group. */ void mbedtls_ecp_group_free( mbedtls_ecp_group *grp ); /** - * \brief Free the components of a key pair + * \brief This function frees the components of a key pair. + * + * \param key The key pair to free. This may be \c NULL, in which + * case this function returns immediately. If it is not + * \c NULL, it must point to an initialized ECP key pair. */ void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key ); +#if defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief Initialize a restart context. + * + * \param ctx The restart context to initialize. This must + * not be \c NULL. + */ +void mbedtls_ecp_restart_init( mbedtls_ecp_restart_ctx *ctx ); + /** - * \brief Copy the contents of point Q into P + * \brief Free the components of a restart context. * - * \param P Destination point - * \param Q Source point + * \param ctx The restart context to free. This may be \c NULL, in which + * case this function returns immediately. If it is not + * \c NULL, it must point to an initialized restart context. + */ +void mbedtls_ecp_restart_free( mbedtls_ecp_restart_ctx *ctx ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + +/** + * \brief This function copies the contents of point \p Q into + * point \p P. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \param P The destination point. This must be initialized. + * \param Q The source point. This must be initialized. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return Another negative error code for other kinds of failure. */ int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ); /** - * \brief Copy the contents of a group object + * \brief This function copies the contents of group \p src into + * group \p dst. * - * \param dst Destination group - * \param src Source group + * \param dst The destination group. This must be initialized. + * \param src The source group. This must be initialized. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src ); +int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, + const mbedtls_ecp_group *src ); /** - * \brief Set a point to zero + * \brief This function sets a point to the point at infinity. * - * \param pt Destination point + * \param pt The point to set. This must be initialized. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt ); /** - * \brief Tell if a point is zero + * \brief This function checks if a point is the point at infinity. * - * \param pt Point to test + * \param pt The point to test. This must be initialized. * - * \return 1 if point is zero, 0 otherwise + * \return \c 1 if the point is zero. + * \return \c 0 if the point is non-zero. + * \return A negative error code on failure. */ int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt ); /** - * \brief Compare two points + * \brief This function compares two points. * - * \note This assumes the points are normalized. Otherwise, + * \note This assumes that the points are normalized. Otherwise, * they may compare as "not equal" even if they are. * - * \param P First point to compare - * \param Q Second point to compare + * \param P The first point to compare. This must be initialized. + * \param Q The second point to compare. This must be initialized. * - * \return 0 if the points are equal, - * MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise + * \return \c 0 if the points are equal. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the points are not equal. */ int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ); /** - * \brief Import a non-zero point from two ASCII strings + * \brief This function imports a non-zero point from two ASCII + * strings. * - * \param P Destination point - * \param radix Input numeric base - * \param x First affine coordinate as a null-terminated string - * \param y Second affine coordinate as a null-terminated string + * \param P The destination point. This must be initialized. + * \param radix The numeric base of the input. + * \param x The first affine coordinate, as a null-terminated string. + * \param y The second affine coordinate, as a null-terminated string. * - * \return 0 if successful, or a MBEDTLS_ERR_MPI_XXX error code + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_MPI_XXX error code on failure. */ int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix, const char *x, const char *y ); /** - * \brief Export a point into unsigned binary data - * - * \param grp Group to which the point should belong - * \param P Point to export - * \param format Point format, should be a MBEDTLS_ECP_PF_XXX macro - * \param olen Length of the actual output - * \param buf Output buffer - * \param buflen Length of the output buffer - * - * \return 0 if successful, - * or MBEDTLS_ERR_ECP_BAD_INPUT_DATA - * or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL + * \brief This function exports a point into unsigned binary data. + * + * \param grp The group to which the point should belong. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param P The point to export. This must be initialized. + * \param format The point format. This must be either + * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED. + * \param olen The address at which to store the length of + * the output in Bytes. This must not be \c NULL. + * \param buf The output buffer. This must be a writable buffer + * of length \p buflen Bytes. + * \param buflen The length of the output buffer \p buf in Bytes. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output buffer + * is too small to hold the point. + * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, int format, size_t *olen, unsigned char *buf, size_t buflen ); /** - * \brief Import a point from unsigned binary data - * - * \param grp Group to which the point should belong - * \param P Point to import - * \param buf Input buffer - * \param ilen Actual length of input - * - * \return 0 if successful, - * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed, - * MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format + * \brief This function imports a point from unsigned binary data. + * + * \note This function does not check that the point actually + * belongs to the given group, see mbedtls_ecp_check_pubkey() + * for that. + * + * \param grp The group to which the point should belong. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param P The destination context to import the point to. + * This must be initialized. + * \param buf The input buffer. This must be a readable buffer + * of length \p ilen Bytes. + * \param ilen The length of the input buffer \p buf in Bytes. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the point format * is not implemented. - * - * \note This function does NOT check that the point actually - * belongs to the given group, see mbedtls_ecp_check_pubkey() for - * that. */ -int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, - const unsigned char *buf, size_t ilen ); +int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *P, + const unsigned char *buf, size_t ilen ); /** - * \brief Import a point from a TLS ECPoint record - * - * \param grp ECP group used - * \param pt Destination point - * \param buf $(Start of input buffer) - * \param len Buffer length - * - * \note buf is updated to point right after the ECPoint on exit - * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_XXX if initialization failed - * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid + * \brief This function imports a point from a TLS ECPoint record. + * + * \note On function return, \p *buf is updated to point immediately + * after the ECPoint record. + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param pt The destination point. + * \param buf The address of the pointer to the start of the input buffer. + * \param len The length of the buffer. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_MPI_XXX error code on initialization + * failure. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid. */ -int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, - const unsigned char **buf, size_t len ); +int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt, + const unsigned char **buf, size_t len ); /** - * \brief Export a point as a TLS ECPoint record - * - * \param grp ECP group used - * \param pt Point to export - * \param format Export format - * \param olen length of data written - * \param buf Buffer to write to - * \param blen Buffer length - * - * \return 0 if successful, - * or MBEDTLS_ERR_ECP_BAD_INPUT_DATA - * or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL + * \brief This function exports a point as a TLS ECPoint record + * defined in RFC 4492, Section 5.4. + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param pt The point to be exported. This must be initialized. + * \param format The point format to use. This must be either + * #MBEDTLS_ECP_PF_COMPRESSED or #MBEDTLS_ECP_PF_UNCOMPRESSED. + * \param olen The address at which to store the length in Bytes + * of the data written. + * \param buf The target buffer. This must be a writable buffer of + * length \p blen Bytes. + * \param blen The length of the target buffer \p buf in Bytes. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the input is invalid. + * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the target buffer + * is too small to hold the exported point. + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt, - int format, size_t *olen, - unsigned char *buf, size_t blen ); +int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, + const mbedtls_ecp_point *pt, + int format, size_t *olen, + unsigned char *buf, size_t blen ); /** - * \brief Set a group using well-known domain parameters + * \brief This function sets up an ECP group context + * from a standardized set of domain parameters. * - * \param grp Destination group - * \param id Index in the list of well-known domain parameters + * \note The index should be a value of the NamedCurve enum, + * as defined in RFC-4492: Elliptic Curve Cryptography + * (ECC) Cipher Suites for Transport Layer Security (TLS), + * usually in the form of an \c MBEDTLS_ECP_DP_XXX macro. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_XXX if initialization failed - * MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE for unkownn groups + * \param grp The group context to setup. This must be initialized. + * \param id The identifier of the domain parameter set to load. * - * \note Index should be a value of RFC 4492's enum NamedCurve, - * usually in the form of a MBEDTLS_ECP_DP_XXX macro. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if \p id doesn't + * correspond to a known group. + * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ); /** - * \brief Set a group from a TLS ECParameters record + * \brief This function sets up an ECP group context from a TLS + * ECParameters record as defined in RFC 4492, Section 5.4. * - * \param grp Destination group - * \param buf &(Start of input buffer) - * \param len Buffer length + * \note The read pointer \p buf is updated to point right after + * the ECParameters record on exit. * - * \note buf is updated to point right after ECParameters on exit + * \param grp The group context to setup. This must be initialized. + * \param buf The address of the pointer to the start of the input buffer. + * \param len The length of the input buffer \c *buf in Bytes. * - * \return 0 if successful, - * MBEDTLS_ERR_MPI_XXX if initialization failed - * MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid. + * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the group is not + * recognized. + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len ); +int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, + const unsigned char **buf, size_t len ); /** - * \brief Write the TLS ECParameters record for a group - * - * \param grp ECP group used - * \param olen Number of bytes actually written - * \param buf Buffer to write to - * \param blen Buffer length - * - * \return 0 if successful, - * or MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL + * \brief This function extracts an elliptic curve group ID from a + * TLS ECParameters record as defined in RFC 4492, Section 5.4. + * + * \note The read pointer \p buf is updated to point right after + * the ECParameters record on exit. + * + * \param grp The address at which to store the group id. + * This must not be \c NULL. + * \param buf The address of the pointer to the start of the input buffer. + * \param len The length of the input buffer \c *buf in Bytes. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if input is invalid. + * \return #MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE if the group is not + * recognized. + * \return Another negative error code on other kinds of failure. + */ +int mbedtls_ecp_tls_read_group_id( mbedtls_ecp_group_id *grp, + const unsigned char **buf, + size_t len ); +/** + * \brief This function exports an elliptic curve as a TLS + * ECParameters record as defined in RFC 4492, Section 5.4. + * + * \param grp The ECP group to be exported. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param olen The address at which to store the number of Bytes written. + * This must not be \c NULL. + * \param buf The buffer to write to. This must be a writable buffer + * of length \p blen Bytes. + * \param blen The length of the output buffer \p buf in Bytes. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL if the output + * buffer is too small to hold the exported group. + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, - unsigned char *buf, size_t blen ); +int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, + size_t *olen, + unsigned char *buf, size_t blen ); /** - * \brief Multiplication by an integer: R = m * P - * (Not thread-safe to use same group in multiple threads) - * - * \note In order to prevent timing attacks, this function - * executes the exact same sequence of (base field) - * operations for any valid m. It avoids any if-branch or - * array index depending on the value of m. - * - * \note If f_rng is not NULL, it is used to randomize intermediate - * results in order to prevent potential timing attacks - * targeting these results. It is recommended to always - * provide a non-NULL f_rng (the overhead is negligible). - * - * \param grp ECP group - * \param R Destination point - * \param m Integer by which to multiply - * \param P Point to multiply - * \param f_rng RNG function (see notes) - * \param p_rng RNG parameter - * - * \return 0 if successful, - * MBEDTLS_ERR_ECP_INVALID_KEY if m is not a valid privkey - * or P is not a valid pubkey, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \brief This function performs a scalar multiplication of a point + * by an integer: \p R = \p m * \p P. + * + * It is not thread-safe to use same group in multiple threads. + * + * \note To prevent timing attacks, this function + * executes the exact same sequence of base-field + * operations for any valid \p m. It avoids any if-branch or + * array index depending on the value of \p m. + * + * \note If \p f_rng is not NULL, it is used to randomize + * intermediate results to prevent potential timing attacks + * targeting these results. We recommend always providing + * a non-NULL \p f_rng. The overhead is negligible. + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param R The point in which to store the result of the calculation. + * This must be initialized. + * \param m The integer by which to multiply. This must be initialized. + * \param P The point to multiply. This must be initialized. + * \param f_rng The RNG function. This may be \c NULL if randomization + * of intermediate results isn't desired (discouraged). + * \param p_rng The RNG context to be passed to \p p_rng. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private + * key, or \p P is not a valid public key. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** - * \brief Multiplication and addition of two points by integers: - * R = m * P + n * Q - * (Not thread-safe to use same group in multiple threads) - * - * \note In contrast to mbedtls_ecp_mul(), this function does not guarantee - * a constant execution flow and timing. - * - * \param grp ECP group - * \param R Destination point - * \param m Integer by which to multiply P - * \param P Point to multiply by m - * \param n Integer by which to multiply Q - * \param Q Point to be multiplied by n - * - * \return 0 if successful, - * MBEDTLS_ERR_ECP_INVALID_KEY if m or n is not a valid privkey - * or P or Q is not a valid pubkey, - * MBEDTLS_ERR_MPI_ALLOC_FAILED if memory allocation failed + * \brief This function performs multiplication of a point by + * an integer: \p R = \p m * \p P in a restartable way. + * + * \see mbedtls_ecp_mul() + * + * \note This function does the same as \c mbedtls_ecp_mul(), but + * it can return early and restart according to the limit set + * with \c mbedtls_ecp_set_max_ops() to reduce blocking. + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param R The point in which to store the result of the calculation. + * This must be initialized. + * \param m The integer by which to multiply. This must be initialized. + * \param P The point to multiply. This must be initialized. + * \param f_rng The RNG function. This may be \c NULL if randomization + * of intermediate results isn't desired (discouraged). + * \param p_rng The RNG context to be passed to \p p_rng. + * \param rs_ctx The restart context (NULL disables restart). + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private + * key, or \p P is not a valid public key. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another negative error code on other kinds of failure. + */ +int mbedtls_ecp_mul_restartable( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ); + +/** + * \brief This function performs multiplication and addition of two + * points by integers: \p R = \p m * \p P + \p n * \p Q + * + * It is not thread-safe to use same group in multiple threads. + * + * \note In contrast to mbedtls_ecp_mul(), this function does not + * guarantee a constant execution flow and timing. + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param R The point in which to store the result of the calculation. + * This must be initialized. + * \param m The integer by which to multiply \p P. + * This must be initialized. + * \param P The point to multiply by \p m. This must be initialized. + * \param n The integer by which to multiply \p Q. + * This must be initialized. + * \param Q The point to be multiplied by \p n. + * This must be initialized. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m or \p n are not + * valid private keys, or \p P or \p Q are not valid public + * keys. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return Another negative error code on other kinds of failure. */ int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, const mbedtls_mpi *n, const mbedtls_ecp_point *Q ); /** - * \brief Check that a point is a valid public key on this curve - * - * \param grp Curve/group the point should belong to - * \param pt Point to check - * - * \return 0 if point is a valid public key, - * MBEDTLS_ERR_ECP_INVALID_KEY otherwise. - * - * \note This function only checks the point is non-zero, has valid - * coordinates and lies on the curve, but not that it is - * indeed a multiple of G. This is additional check is more - * expensive, isn't required by standards, and shouldn't be - * necessary if the group used has a small cofactor. In - * particular, it is useless for the NIST groups which all - * have a cofactor of 1. - * - * \note Uses bare components rather than an mbedtls_ecp_keypair structure - * in order to ease use with other structures such as - * mbedtls_ecdh_context of mbedtls_ecdsa_context. + * \brief This function performs multiplication and addition of two + * points by integers: \p R = \p m * \p P + \p n * \p Q in a + * restartable way. + * + * \see \c mbedtls_ecp_muladd() + * + * \note This function works the same as \c mbedtls_ecp_muladd(), + * but it can return early and restart according to the limit + * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. + * + * \param grp The ECP group to use. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param R The point in which to store the result of the calculation. + * This must be initialized. + * \param m The integer by which to multiply \p P. + * This must be initialized. + * \param P The point to multiply by \p m. This must be initialized. + * \param n The integer by which to multiply \p Q. + * This must be initialized. + * \param Q The point to be multiplied by \p n. + * This must be initialized. + * \param rs_ctx The restart context (NULL disables restart). + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_ECP_INVALID_KEY if \p m or \p n are not + * valid private keys, or \p P or \p Q are not valid public + * keys. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ); +int mbedtls_ecp_muladd_restartable( + mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + const mbedtls_mpi *n, const mbedtls_ecp_point *Q, + mbedtls_ecp_restart_ctx *rs_ctx ); /** - * \brief Check that an mbedtls_mpi is a valid private key for this curve - * - * \param grp Group used - * \param d Integer to check - * - * \return 0 if point is a valid private key, - * MBEDTLS_ERR_ECP_INVALID_KEY otherwise. - * - * \note Uses bare components rather than an mbedtls_ecp_keypair structure - * in order to ease use with other structures such as - * mbedtls_ecdh_context of mbedtls_ecdsa_context. + * \brief This function checks that a point is a valid public key + * on this curve. + * + * It only checks that the point is non-zero, has + * valid coordinates and lies on the curve. It does not verify + * that it is indeed a multiple of \p G. This additional + * check is computationally more expensive, is not required + * by standards, and should not be necessary if the group + * used has a small cofactor. In particular, it is useless for + * the NIST groups which all have a cofactor of 1. + * + * \note This function uses bare components rather than an + * ::mbedtls_ecp_keypair structure, to ease use with other + * structures, such as ::mbedtls_ecdh_context or + * ::mbedtls_ecdsa_context. + * + * \param grp The ECP group the point should belong to. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param pt The point to check. This must be initialized. + * + * \return \c 0 if the point is a valid public key. + * \return #MBEDTLS_ERR_ECP_INVALID_KEY if the point is not + * a valid public key for the given curve. + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d ); +int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, + const mbedtls_ecp_point *pt ); /** - * \brief Generate a keypair with configurable base point - * - * \param grp ECP group - * \param G Chosen base point - * \param d Destination MPI (secret part) - * \param Q Destination point (public part) - * \param f_rng RNG function - * \param p_rng RNG parameter - * - * \return 0 if successful, - * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code - * - * \note Uses bare components rather than an mbedtls_ecp_keypair structure - * in order to ease use with other structures such as - * mbedtls_ecdh_context of mbedtls_ecdsa_context. + * \brief This function checks that an \p mbedtls_mpi is a + * valid private key for this curve. + * + * \note This function uses bare components rather than an + * ::mbedtls_ecp_keypair structure to ease use with other + * structures, such as ::mbedtls_ecdh_context or + * ::mbedtls_ecdsa_context. + * + * \param grp The ECP group the private key should belong to. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param d The integer to check. This must be initialized. + * + * \return \c 0 if the point is a valid private key. + * \return #MBEDTLS_ERR_ECP_INVALID_KEY if the point is not a valid + * private key for the given curve. + * \return Another negative error code on other kinds of failure. */ -int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, - const mbedtls_ecp_point *G, - mbedtls_mpi *d, mbedtls_ecp_point *Q, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ); +int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, + const mbedtls_mpi *d ); /** - * \brief Generate a keypair - * - * \param grp ECP group - * \param d Destination MPI (secret part) - * \param Q Destination point (public part) - * \param f_rng RNG function - * \param p_rng RNG parameter - * - * \return 0 if successful, - * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code - * - * \note Uses bare components rather than an mbedtls_ecp_keypair structure - * in order to ease use with other structures such as - * mbedtls_ecdh_context of mbedtls_ecdsa_context. + * \brief This function generates a private key. + * + * \param grp The ECP group to generate a private key for. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param d The destination MPI (secret part). This must be initialized. + * \param f_rng The RNG function. This must not be \c NULL. + * \param p_rng The RNG parameter to be passed to \p f_rng. This may be + * \c NULL if \p f_rng doesn't need a context argument. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code + * on failure. */ -int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, +int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp, + mbedtls_mpi *d, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); /** - * \brief Generate a keypair + * \brief This function generates a keypair with a configurable base + * point. + * + * \note This function uses bare components rather than an + * ::mbedtls_ecp_keypair structure to ease use with other + * structures, such as ::mbedtls_ecdh_context or + * ::mbedtls_ecdsa_context. + * + * \param grp The ECP group to generate a key pair for. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param G The base point to use. This must be initialized + * and belong to \p grp. It replaces the default base + * point \c grp->G used by mbedtls_ecp_gen_keypair(). + * \param d The destination MPI (secret part). + * This must be initialized. + * \param Q The destination point (public part). + * This must be initialized. + * \param f_rng The RNG function. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may + * be \c NULL if \p f_rng doesn't need a context argument. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code + * on failure. + */ +int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, + const mbedtls_ecp_point *G, + mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief This function generates an ECP keypair. + * + * \note This function uses bare components rather than an + * ::mbedtls_ecp_keypair structure to ease use with other + * structures, such as ::mbedtls_ecdh_context or + * ::mbedtls_ecdsa_context. + * + * \param grp The ECP group to generate a key pair for. + * This must be initialized and have group parameters + * set, for example through mbedtls_ecp_group_load(). + * \param d The destination MPI (secret part). + * This must be initialized. + * \param Q The destination point (public part). + * This must be initialized. + * \param f_rng The RNG function. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may + * be \c NULL if \p f_rng doesn't need a context argument. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code + * on failure. + */ +int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, mbedtls_mpi *d, + mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); + +/** + * \brief This function generates an ECP key. * - * \param grp_id ECP group identifier - * \param key Destination keypair - * \param f_rng RNG function - * \param p_rng RNG parameter + * \param grp_id The ECP group identifier. + * \param key The destination key. This must be initialized. + * \param f_rng The RNG function to use. This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may + * be \c NULL if \p f_rng doesn't need a context argument. * - * \return 0 if successful, - * or a MBEDTLS_ERR_ECP_XXX or MBEDTLS_MPI_XXX error code + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_ECP_XXX or \c MBEDTLS_MPI_XXX error code + * on failure. */ int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, - int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ); /** - * \brief Check a public-private key pair - * - * \param pub Keypair structure holding a public key - * \param prv Keypair structure holding a private (plus public) key - * - * \return 0 if successful (keys are valid and match), or - * MBEDTLS_ERR_ECP_BAD_INPUT_DATA, or - * a MBEDTLS_ERR_ECP_XXX or MBEDTLS_ERR_MPI_XXX code. + * \brief This function checks that the keypair objects + * \p pub and \p prv have the same group and the + * same public point, and that the private key in + * \p prv is consistent with the public key. + * + * \param pub The keypair structure holding the public key. This + * must be initialized. If it contains a private key, that + * part is ignored. + * \param prv The keypair structure holding the full keypair. + * This must be initialized. + * + * \return \c 0 on success, meaning that the keys are valid and match. + * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA if the keys are invalid or do not match. + * \return An \c MBEDTLS_ERR_ECP_XXX or an \c MBEDTLS_ERR_MPI_XXX + * error code on calculation failure. */ -int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ecp_keypair *prv ); +int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, + const mbedtls_ecp_keypair *prv ); #if defined(MBEDTLS_SELF_TEST) /** - * \brief Checkup routine + * \brief The ECP checkup routine. * - * \return 0 if successful, or 1 if a test failed + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_ecp_self_test( int verbose ); @@ -679,8 +1129,4 @@ int mbedtls_ecp_self_test( int verbose ); } #endif -#else /* MBEDTLS_ECP_ALT */ -#include "ecp_alt.h" -#endif /* MBEDTLS_ECP_ALT */ - #endif /* ecp.h */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp_internal.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp_internal.h index 18040697ad..7625ed48e1 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp_internal.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ecp_internal.h @@ -61,6 +61,12 @@ #ifndef MBEDTLS_ECP_INTERNAL_H #define MBEDTLS_ECP_INTERNAL_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #if defined(MBEDTLS_ECP_INTERNAL_ALT) /** diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/entropy.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/entropy.h index fcb4d02557..ca06dc3c58 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/entropy.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/entropy.h @@ -107,7 +107,7 @@ typedef int (*mbedtls_entropy_f_source_ptr)(void *data, unsigned char *output, s /** * \brief Entropy source state */ -typedef struct +typedef struct mbedtls_entropy_source_state { mbedtls_entropy_f_source_ptr f_source; /**< The entropy source callback */ void * p_source; /**< The callback data pointer */ @@ -120,7 +120,7 @@ mbedtls_entropy_source_state; /** * \brief Entropy context structure */ -typedef struct +typedef struct mbedtls_entropy_context { int accumulator_started; #if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR) @@ -166,7 +166,7 @@ void mbedtls_entropy_free( mbedtls_entropy_context *ctx ); * \param threshold Minimum required from source before entropy is released * ( with mbedtls_entropy_func() ) (in bytes) * \param strong MBEDTLS_ENTROPY_SOURCE_STRONG or - * MBEDTSL_ENTROPY_SOURCE_WEAK. + * MBEDTLS_ENTROPY_SOURCE_WEAK. * At least one strong source needs to be added. * Weaker sources (such as the cycle counter) can be used as * a complement. diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/error.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/error.h index 8b4d3a8755..bee0fe485a 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/error.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/error.h @@ -4,7 +4,7 @@ * \brief Error to string translation */ /* - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved + * Copyright (C) 2006-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -24,6 +24,12 @@ #ifndef MBEDTLS_ERROR_H #define MBEDTLS_ERROR_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include /** @@ -53,7 +59,7 @@ * GCM 3 0x0012-0x0014 0x0013-0x0013 * BLOWFISH 3 0x0016-0x0018 0x0017-0x0017 * THREADING 3 0x001A-0x001E - * AES 4 0x0020-0x0022 0x0023-0x0025 + * AES 5 0x0020-0x0022 0x0021-0x0025 * CAMELLIA 3 0x0024-0x0026 0x0027-0x0027 * XTEA 2 0x0028-0x0028 0x0029-0x0029 * BASE64 2 0x002A-0x002C @@ -62,7 +68,8 @@ * DES 2 0x0032-0x0032 0x0033-0x0033 * CTR_DBRG 4 0x0034-0x003A * ENTROPY 3 0x003C-0x0040 0x003D-0x003F - * NET 11 0x0042-0x0052 0x0043-0x0045 + * NET 13 0x0042-0x0052 0x0043-0x0049 + * ARIA 4 0x0058-0x005E * ASN1 7 0x0060-0x006C * CMAC 1 0x007A-0x007A * PBKDF2 1 0x007C-0x007C @@ -73,9 +80,13 @@ * MD4 1 0x002D-0x002D * MD5 1 0x002F-0x002F * RIPEMD160 1 0x0031-0x0031 - * SHA1 1 0x0035-0x0035 - * SHA256 1 0x0037-0x0037 - * SHA512 1 0x0039-0x0039 + * SHA1 1 0x0035-0x0035 0x0073-0x0073 + * SHA256 1 0x0037-0x0037 0x0074-0x0074 + * SHA512 1 0x0039-0x0039 0x0075-0x0075 + * CHACHA20 3 0x0051-0x0055 + * POLY1305 3 0x0057-0x005B + * CHACHAPOLY 2 0x0054-0x0056 + * PLATFORM 1 0x0070-0x0072 * * High-level module nr (3 bits - 0x0...-0x7...) * Name ID Nr of Errors @@ -86,11 +97,12 @@ * DHM 3 11 * PK 3 15 (Started from top) * RSA 4 11 - * ECP 4 9 (Started from top) + * ECP 4 10 (Started from top) * MD 5 5 + * HKDF 5 1 (Started from top) * CIPHER 6 8 - * SSL 6 17 (Started from top) - * SSL 7 31 + * SSL 6 23 (Started from top) + * SSL 7 32 * * Module dependent error code (5 bits 0x.00.-0x.F8.) */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/gcm.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/gcm.h index 00ed42190c..fd130abd7c 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/gcm.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/gcm.h @@ -1,9 +1,11 @@ /** * \file gcm.h * - * \brief Galois/Counter Mode (GCM) for 128-bit block ciphers, as defined - * in D. McGrew, J. Viega, The Galois/Counter Mode of Operation - * (GCM), Natl. Inst. Stand. Technol. + * \brief This file contains GCM definitions and functions. + * + * The Galois/Counter Mode (GCM) for 128-bit block ciphers is defined + * in D. McGrew, J. Viega, The Galois/Counter Mode of Operation + * (GCM), Natl. Inst. Stand. Technol. * * For more information on GCM, see NIST SP 800-38D: Recommendation for * Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC. @@ -31,6 +33,12 @@ #ifndef MBEDTLS_GCM_H #define MBEDTLS_GCM_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "cipher.h" #include @@ -39,19 +47,23 @@ #define MBEDTLS_GCM_DECRYPT 0 #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012 /**< Authenticated decryption failed. */ + +/* MBEDTLS_ERR_GCM_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED -0x0013 /**< GCM hardware accelerator failed. */ -#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */ -#if !defined(MBEDTLS_GCM_ALT) +#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_GCM_ALT) + /** * \brief The GCM context structure. */ -typedef struct { +typedef struct mbedtls_gcm_context +{ mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */ uint64_t HL[16]; /*!< Precalculated HTable low. */ uint64_t HH[16]; /*!< Precalculated HTable high. */ @@ -66,6 +78,10 @@ typedef struct { } mbedtls_gcm_context; +#else /* !MBEDTLS_GCM_ALT */ +#include "gcm_alt.h" +#endif /* !MBEDTLS_GCM_ALT */ + /** * \brief This function initializes the specified GCM context, * to make references valid, and prepares the context @@ -75,7 +91,7 @@ mbedtls_gcm_context; * cipher, nor set the key. For this purpose, use * mbedtls_gcm_setkey(). * - * \param ctx The GCM context to initialize. + * \param ctx The GCM context to initialize. This must not be \c NULL. */ void mbedtls_gcm_init( mbedtls_gcm_context *ctx ); @@ -83,15 +99,17 @@ void mbedtls_gcm_init( mbedtls_gcm_context *ctx ); * \brief This function associates a GCM context with a * cipher algorithm and a key. * - * \param ctx The GCM context to initialize. + * \param ctx The GCM context. This must be initialized. * \param cipher The 128-bit block cipher to use. - * \param key The encryption key. + * \param key The encryption key. This must be a readable buffer of at + * least \p keybits bits. * \param keybits The key size in bits. Valid options are: *
  • 128 bits
  • *
  • 192 bits
  • *
  • 256 bits
* - * \return \c 0 on success, or a cipher specific error code. + * \return \c 0 on success. + * \return A cipher-specific error code on failure. */ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, mbedtls_cipher_id_t cipher, @@ -101,17 +119,18 @@ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, /** * \brief This function performs GCM encryption or decryption of a buffer. * - * \note For encryption, the output buffer can be the same as the input buffer. - * For decryption, the output buffer cannot be the same as input buffer. - * If the buffers overlap, the output buffer must trail at least 8 Bytes - * behind the input buffer. + * \note For encryption, the output buffer can be the same as the + * input buffer. For decryption, the output buffer cannot be + * the same as input buffer. If the buffers overlap, the output + * buffer must trail at least 8 Bytes behind the input buffer. * * \warning When this function performs a decryption, it outputs the * authentication tag and does not verify that the data is * authentic. You should use this function to perform encryption * only. For decryption, use mbedtls_gcm_auth_decrypt() instead. * - * \param ctx The GCM context to use for encryption or decryption. + * \param ctx The GCM context to use for encryption or decryption. This + * must be initialized. * \param mode The operation to perform: * - #MBEDTLS_GCM_ENCRYPT to perform authenticated encryption. * The ciphertext is written to \p output and the @@ -125,22 +144,28 @@ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, * calling this function in decryption mode. * \param length The length of the input data, which is equal to the length * of the output data. - * \param iv The initialization vector. + * \param iv The initialization vector. This must be a readable buffer of + * at least \p iv_len Bytes. * \param iv_len The length of the IV. - * \param add The buffer holding the additional data. + * \param add The buffer holding the additional data. This must be of at + * least that size in Bytes. * \param add_len The length of the additional data. - * \param input The buffer holding the input data. Its size is \b length. - * \param output The buffer for holding the output data. It must have room - * for \b length bytes. + * \param input The buffer holding the input data. If \p length is greater + * than zero, this must be a readable buffer of at least that + * size in Bytes. + * \param output The buffer for holding the output data. If \p length is greater + * than zero, this must be a writable buffer of at least that + * size in Bytes. * \param tag_len The length of the tag to generate. - * \param tag The buffer for holding the tag. + * \param tag The buffer for holding the tag. This must be a readable + * buffer of at least \p tag_len Bytes. * * \return \c 0 if the encryption or decryption was performed * successfully. Note that in #MBEDTLS_GCM_DECRYPT mode, * this does not indicate that the data is authentic. - * \return #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths are not valid. - * \return #MBEDTLS_ERR_GCM_HW_ACCEL_FAILED or a cipher-specific - * error code if the encryption or decryption failed. + * \return #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are + * not valid or a cipher-specific error code if the encryption + * or decryption failed. */ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx, int mode, @@ -158,28 +183,34 @@ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx, * \brief This function performs a GCM authenticated decryption of a * buffer. * - * \note For decryption, the output buffer cannot be the same as input buffer. - * If the buffers overlap, the output buffer must trail at least 8 Bytes - * behind the input buffer. + * \note For decryption, the output buffer cannot be the same as + * input buffer. If the buffers overlap, the output buffer + * must trail at least 8 Bytes behind the input buffer. * - * \param ctx The GCM context. + * \param ctx The GCM context. This must be initialized. * \param length The length of the ciphertext to decrypt, which is also * the length of the decrypted plaintext. - * \param iv The initialization vector. + * \param iv The initialization vector. This must be a readable buffer + * of at least \p iv_len Bytes. * \param iv_len The length of the IV. - * \param add The buffer holding the additional data. + * \param add The buffer holding the additional data. This must be of at + * least that size in Bytes. * \param add_len The length of the additional data. - * \param tag The buffer holding the tag to verify. + * \param tag The buffer holding the tag to verify. This must be a + * readable buffer of at least \p tag_len Bytes. * \param tag_len The length of the tag to verify. - * \param input The buffer holding the ciphertext. Its size is \b length. - * \param output The buffer for holding the decrypted plaintext. It must - * have room for \b length bytes. + * \param input The buffer holding the ciphertext. If \p length is greater + * than zero, this must be a readable buffer of at least that + * size. + * \param output The buffer for holding the decrypted plaintext. If \p length + * is greater than zero, this must be a writable buffer of at + * least that size. * * \return \c 0 if successful and authenticated. * \return #MBEDTLS_ERR_GCM_AUTH_FAILED if the tag does not match. - * \return #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths are not valid. - * \return #MBEDTLS_ERR_GCM_HW_ACCEL_FAILED or a cipher-specific - * error code if the decryption failed. + * \return #MBEDTLS_ERR_GCM_BAD_INPUT if the lengths or pointers are + * not valid or a cipher-specific error code if the decryption + * failed. */ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, size_t length, @@ -196,15 +227,18 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, * \brief This function starts a GCM encryption or decryption * operation. * - * \param ctx The GCM context. + * \param ctx The GCM context. This must be initialized. * \param mode The operation to perform: #MBEDTLS_GCM_ENCRYPT or * #MBEDTLS_GCM_DECRYPT. - * \param iv The initialization vector. + * \param iv The initialization vector. This must be a readable buffer of + * at least \p iv_len Bytes. * \param iv_len The length of the IV. - * \param add The buffer holding the additional data, or NULL if \p add_len is 0. - * \param add_len The length of the additional data. If 0, \p add is NULL. + * \param add The buffer holding the additional data, or \c NULL + * if \p add_len is \c 0. + * \param add_len The length of the additional data. If \c 0, + * \p add may be \c NULL. * - * \return \c 0 on success. + * \return \c 0 on success. */ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, int mode, @@ -221,16 +255,22 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, * Bytes. Only the last call before calling * mbedtls_gcm_finish() can be less than 16 Bytes. * - * \note For decryption, the output buffer cannot be the same as input buffer. - * If the buffers overlap, the output buffer must trail at least 8 Bytes - * behind the input buffer. + * \note For decryption, the output buffer cannot be the same as + * input buffer. If the buffers overlap, the output buffer + * must trail at least 8 Bytes behind the input buffer. * - * \param ctx The GCM context. - * \param length The length of the input data. This must be a multiple of 16 except in the last call before mbedtls_gcm_finish(). - * \param input The buffer holding the input data. - * \param output The buffer for holding the output data. + * \param ctx The GCM context. This must be initialized. + * \param length The length of the input data. This must be a multiple of + * 16 except in the last call before mbedtls_gcm_finish(). + * \param input The buffer holding the input data. If \p length is greater + * than zero, this must be a readable buffer of at least that + * size in Bytes. + * \param output The buffer for holding the output data. If \p length is + * greater than zero, this must be a writable buffer of at + * least that size in Bytes. * - * \return \c 0 on success, or #MBEDTLS_ERR_GCM_BAD_INPUT on failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_GCM_BAD_INPUT on failure. */ int mbedtls_gcm_update( mbedtls_gcm_context *ctx, size_t length, @@ -244,11 +284,14 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx, * It wraps up the GCM stream, and generates the * tag. The tag can have a maximum length of 16 Bytes. * - * \param ctx The GCM context. - * \param tag The buffer for holding the tag. - * \param tag_len The length of the tag to generate. Must be at least four. + * \param ctx The GCM context. This must be initialized. + * \param tag The buffer for holding the tag. This must be a readable + * buffer of at least \p tag_len Bytes. + * \param tag_len The length of the tag to generate. This must be at least + * four. * - * \return \c 0 on success, or #MBEDTLS_ERR_GCM_BAD_INPUT on failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_GCM_BAD_INPUT on failure. */ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, unsigned char *tag, @@ -258,29 +301,23 @@ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, * \brief This function clears a GCM context and the underlying * cipher sub-context. * - * \param ctx The GCM context to clear. + * \param ctx The GCM context to clear. If this is \c NULL, the call has + * no effect. Otherwise, this must be initialized. */ void mbedtls_gcm_free( mbedtls_gcm_context *ctx ); -#ifdef __cplusplus -} -#endif - -#else /* !MBEDTLS_GCM_ALT */ -#include "gcm_alt.h" -#endif /* !MBEDTLS_GCM_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief The GCM checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_gcm_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/havege.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/havege.h index d4cb3ed38d..4c1c86087a 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/havege.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/havege.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_HAVEGE_H #define MBEDTLS_HAVEGE_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include #define MBEDTLS_HAVEGE_COLLECT_SIZE 1024 @@ -35,7 +41,7 @@ extern "C" { /** * \brief HAVEGE state structure */ -typedef struct +typedef struct mbedtls_havege_state { int PT1, PT2, offset[2]; int pool[MBEDTLS_HAVEGE_COLLECT_SIZE]; diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/hkdf.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/hkdf.h new file mode 100644 index 0000000000..40ee64eb03 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/hkdf.h @@ -0,0 +1,141 @@ +/** + * \file hkdf.h + * + * \brief This file contains the HKDF interface. + * + * The HMAC-based Extract-and-Expand Key Derivation Function (HKDF) is + * specified by RFC 5869. + */ +/* + * Copyright (C) 2016-2018, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_HKDF_H +#define MBEDTLS_HKDF_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "md.h" + +/** + * \name HKDF Error codes + * \{ + */ +#define MBEDTLS_ERR_HKDF_BAD_INPUT_DATA -0x5F80 /**< Bad input parameters to function. */ +/* \} name */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief This is the HMAC-based Extract-and-Expand Key Derivation Function + * (HKDF). + * + * \param md A hash function; md.size denotes the length of the hash + * function output in bytes. + * \param salt An optional salt value (a non-secret random value); + * if the salt is not provided, a string of all zeros of + * md.size length is used as the salt. + * \param salt_len The length in bytes of the optional \p salt. + * \param ikm The input keying material. + * \param ikm_len The length in bytes of \p ikm. + * \param info An optional context and application specific information + * string. This can be a zero-length string. + * \param info_len The length of \p info in bytes. + * \param okm The output keying material of \p okm_len bytes. + * \param okm_len The length of the output keying material in bytes. This + * must be less than or equal to 255 * md.size bytes. + * + * \return 0 on success. + * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid. + * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying + * MD layer. + */ +int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, + size_t salt_len, const unsigned char *ikm, size_t ikm_len, + const unsigned char *info, size_t info_len, + unsigned char *okm, size_t okm_len ); + +/** + * \brief Take the input keying material \p ikm and extract from it a + * fixed-length pseudorandom key \p prk. + * + * \warning This function should only be used if the security of it has been + * studied and established in that particular context (eg. TLS 1.3 + * key schedule). For standard HKDF security guarantees use + * \c mbedtls_hkdf instead. + * + * \param md A hash function; md.size denotes the length of the + * hash function output in bytes. + * \param salt An optional salt value (a non-secret random value); + * if the salt is not provided, a string of all zeros + * of md.size length is used as the salt. + * \param salt_len The length in bytes of the optional \p salt. + * \param ikm The input keying material. + * \param ikm_len The length in bytes of \p ikm. + * \param[out] prk A pseudorandom key of at least md.size bytes. + * + * \return 0 on success. + * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid. + * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying + * MD layer. + */ +int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, + const unsigned char *salt, size_t salt_len, + const unsigned char *ikm, size_t ikm_len, + unsigned char *prk ); + +/** + * \brief Expand the supplied \p prk into several additional pseudorandom + * keys, which is the output of the HKDF. + * + * \warning This function should only be used if the security of it has been + * studied and established in that particular context (eg. TLS 1.3 + * key schedule). For standard HKDF security guarantees use + * \c mbedtls_hkdf instead. + * + * \param md A hash function; md.size denotes the length of the hash + * function output in bytes. + * \param prk A pseudorandom key of at least md.size bytes. \p prk is + * usually the output from the HKDF extract step. + * \param prk_len The length in bytes of \p prk. + * \param info An optional context and application specific information + * string. This can be a zero-length string. + * \param info_len The length of \p info in bytes. + * \param okm The output keying material of \p okm_len bytes. + * \param okm_len The length of the output keying material in bytes. This + * must be less than or equal to 255 * md.size bytes. + * + * \return 0 on success. + * \return #MBEDTLS_ERR_HKDF_BAD_INPUT_DATA when the parameters are invalid. + * \return An MBEDTLS_ERR_MD_* error for errors returned from the underlying + * MD layer. + */ +int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, + size_t prk_len, const unsigned char *info, + size_t info_len, unsigned char *okm, size_t okm_len ); + +#ifdef __cplusplus +} +#endif + +#endif /* hkdf.h */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/hmac_drbg.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/hmac_drbg.h index dd31fc8fdd..7eae32bbd6 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/hmac_drbg.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/hmac_drbg.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_HMAC_DRBG_H #define MBEDTLS_HMAC_DRBG_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "md.h" #if defined(MBEDTLS_THREADING_C) @@ -74,7 +80,7 @@ extern "C" { /** * HMAC_DRBG context. */ -typedef struct +typedef struct mbedtls_hmac_drbg_context { /* Working state: the key K is not stored explicitely, * but is implied by the HMAC context */ @@ -204,23 +210,6 @@ void mbedtls_hmac_drbg_set_reseed_interval( mbedtls_hmac_drbg_context *ctx, int mbedtls_hmac_drbg_update_ret( mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t add_len ); -/** - * \brief HMAC_DRBG update state - * - * \warning This function cannot report errors. You should use - * mbedtls_hmac_drbg_update_ret() instead. - * - * \param ctx HMAC_DRBG context - * \param additional Additional data to update state with, or NULL - * \param add_len Length of additional data, or 0 - * - * \note Additional data is optional, pass NULL and 0 as second - * third argument if no additional data is being used. - */ -void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx, - const unsigned char *additional, - size_t add_len ); - /** * \brief HMAC_DRBG reseeding (extracts data from entropy source) * @@ -277,6 +266,31 @@ int mbedtls_hmac_drbg_random( void *p_rng, unsigned char *output, size_t out_len */ void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx ); +#if ! defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +#else +#define MBEDTLS_DEPRECATED +#endif +/** + * \brief HMAC_DRBG update state + * + * \deprecated Superseded by mbedtls_hmac_drbg_update_ret() + * in 2.16.0. + * + * \param ctx HMAC_DRBG context + * \param additional Additional data to update state with, or NULL + * \param add_len Length of additional data, or 0 + * + * \note Additional data is optional, pass NULL and 0 as second + * third argument if no additional data is being used. + */ +MBEDTLS_DEPRECATED void mbedtls_hmac_drbg_update( + mbedtls_hmac_drbg_context *ctx, + const unsigned char *additional, size_t add_len ); +#undef MBEDTLS_DEPRECATED +#endif /* !MBEDTLS_DEPRECATED_REMOVED */ + #if defined(MBEDTLS_FS_IO) /** * \brief Write a seed file diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/md.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/md.h index 06538c3827..8bcf766a6c 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/md.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/md.h @@ -1,7 +1,7 @@ /** * \file md.h * - * \brief The generic message-digest wrapper. + * \brief This file contains the generic message-digest wrapper. * * \author Adriaan de Jong */ @@ -39,6 +39,8 @@ #define MBEDTLS_ERR_MD_BAD_INPUT_DATA -0x5100 /**< Bad input parameters to function. */ #define MBEDTLS_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */ #define MBEDTLS_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */ + +/* MBEDTLS_ERR_MD_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD_HW_ACCEL_FAILED -0x5280 /**< MD hardware accelerator failed. */ #ifdef __cplusplus @@ -46,7 +48,7 @@ extern "C" { #endif /** - * \brief Enumeration of supported message digests + * \brief Supported message digests. * * \warning MD2, MD4, MD5 and SHA-1 are considered weak message digests and * their use constitutes a security risk. We recommend considering @@ -54,16 +56,16 @@ extern "C" { * */ typedef enum { - MBEDTLS_MD_NONE=0, - MBEDTLS_MD_MD2, - MBEDTLS_MD_MD4, - MBEDTLS_MD_MD5, - MBEDTLS_MD_SHA1, - MBEDTLS_MD_SHA224, - MBEDTLS_MD_SHA256, - MBEDTLS_MD_SHA384, - MBEDTLS_MD_SHA512, - MBEDTLS_MD_RIPEMD160, + MBEDTLS_MD_NONE=0, /**< None. */ + MBEDTLS_MD_MD2, /**< The MD2 message digest. */ + MBEDTLS_MD_MD4, /**< The MD4 message digest. */ + MBEDTLS_MD_MD5, /**< The MD5 message digest. */ + MBEDTLS_MD_SHA1, /**< The SHA-1 message digest. */ + MBEDTLS_MD_SHA224, /**< The SHA-224 message digest. */ + MBEDTLS_MD_SHA256, /**< The SHA-256 message digest. */ + MBEDTLS_MD_SHA384, /**< The SHA-384 message digest. */ + MBEDTLS_MD_SHA512, /**< The SHA-512 message digest. */ + MBEDTLS_MD_RIPEMD160, /**< The RIPEMD-160 message digest. */ } mbedtls_md_type_t; #if defined(MBEDTLS_SHA512_C) @@ -80,7 +82,8 @@ typedef struct mbedtls_md_info_t mbedtls_md_info_t; /** * The generic message-digest context. */ -typedef struct { +typedef struct mbedtls_md_context_t +{ /** Information about the associated message digest. */ const mbedtls_md_info_t *md_info; @@ -108,8 +111,8 @@ const int *mbedtls_md_list( void ); * * \param md_name The name of the digest to search for. * - * \return The message-digest information associated with \p md_name, - * or NULL if not found. + * \return The message-digest information associated with \p md_name. + * \return NULL if the associated message-digest information is not found. */ const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name ); @@ -119,8 +122,8 @@ const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name ); * * \param md_type The type of digest to search for. * - * \return The message-digest information associated with \p md_type, - * or NULL if not found. + * \return The message-digest information associated with \p md_type. + * \return NULL if the associated message-digest information is not found. */ const mbedtls_md_info_t *mbedtls_md_info_from_type( mbedtls_md_type_t md_type ); @@ -168,9 +171,10 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx ); * \param md_info The information structure of the message-digest algorithm * to use. * - * \returns \c 0 on success, - * #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, - * #MBEDTLS_ERR_MD_ALLOC_FAILED memory allocation failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. + * \return #MBEDTLS_ERR_MD_ALLOC_FAILED on memory-allocation failure. */ int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info ) MBEDTLS_DEPRECATED; #undef MBEDTLS_DEPRECATED @@ -187,12 +191,13 @@ int mbedtls_md_init_ctx( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_ * \param ctx The context to set up. * \param md_info The information structure of the message-digest algorithm * to use. - * \param hmac
  • 0: HMAC is not used. Saves some memory.
  • - *
  • non-zero: HMAC is used with this context.
+ * \param hmac Defines if HMAC is used. 0: HMAC is not used (saves some memory), + * or non-zero: HMAC is used with this context. * - * \returns \c 0 on success, - * #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure, or - * #MBEDTLS_ERR_MD_ALLOC_FAILED on memory allocation failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. + * \return #MBEDTLS_ERR_MD_ALLOC_FAILED on memory-allocation failure. */ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info, int hmac ); @@ -212,8 +217,8 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_inf * \param dst The destination context. * \param src The context to be cloned. * - * \return \c 0 on success, - * #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification failure. */ int mbedtls_md_clone( mbedtls_md_context_t *dst, const mbedtls_md_context_t *src ); @@ -260,8 +265,9 @@ const char *mbedtls_md_get_name( const mbedtls_md_info_t *md_info ); * * \param ctx The generic message-digest context. * - * \returns \c 0 on success, #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_starts( mbedtls_md_context_t *ctx ); @@ -277,8 +283,9 @@ int mbedtls_md_starts( mbedtls_md_context_t *ctx ); * \param input The buffer holding the input data. * \param ilen The length of the input data. * - * \returns \c 0 on success, #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ); @@ -296,8 +303,9 @@ int mbedtls_md_update( mbedtls_md_context_t *ctx, const unsigned char *input, si * \param ctx The generic message-digest context. * \param output The buffer for the generic message-digest checksum result. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ); @@ -315,8 +323,9 @@ int mbedtls_md_finish( mbedtls_md_context_t *ctx, unsigned char *output ); * \param ilen The length of the input data. * \param output The generic message-digest checksum result. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output ); @@ -334,9 +343,10 @@ int mbedtls_md( const mbedtls_md_info_t *md_info, const unsigned char *input, si * \param path The input file name. * \param output The generic message-digest checksum result. * - * \return \c 0 on success, - * #MBEDTLS_ERR_MD_FILE_IO_ERROR if file input failed, or - * #MBEDTLS_ERR_MD_BAD_INPUT_DATA if \p md_info was NULL. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_FILE_IO_ERROR on an I/O error accessing + * the file pointed by \p path. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA if \p md_info was NULL. */ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigned char *output ); @@ -356,8 +366,9 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, * \param key The HMAC secret key. * \param keylen The length of the HMAC key in Bytes. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, size_t keylen ); @@ -377,8 +388,9 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, * \param input The buffer holding the input data. * \param ilen The length of the input data. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *input, size_t ilen ); @@ -397,8 +409,9 @@ int mbedtls_md_hmac_update( mbedtls_md_context_t *ctx, const unsigned char *inpu * context. * \param output The generic HMAC checksum result. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output); @@ -413,8 +426,9 @@ int mbedtls_md_hmac_finish( mbedtls_md_context_t *ctx, unsigned char *output); * \param ctx The message digest context containing an embedded HMAC * context. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ); @@ -436,8 +450,9 @@ int mbedtls_md_hmac_reset( mbedtls_md_context_t *ctx ); * \param ilen The length of the input data. * \param output The generic HMAC result. * - * \returns \c 0 on success, or #MBEDTLS_ERR_MD_BAD_INPUT_DATA if - * parameter verification fails. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MD_BAD_INPUT_DATA on parameter-verification + * failure. */ int mbedtls_md_hmac( const mbedtls_md_info_t *md_info, const unsigned char *key, size_t keylen, const unsigned char *input, size_t ilen, diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/md2.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/md2.h index 0fd8b5afcc..fe97cf08d4 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/md2.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/md2.h @@ -37,16 +37,17 @@ #include +/* MBEDTLS_ERR_MD2_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD2_HW_ACCEL_FAILED -0x002B /**< MD2 hardware accelerator failed */ -#if !defined(MBEDTLS_MD2_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_MD2_ALT) +// Regular implementation +// + /** * \brief MD2 context structure * @@ -55,7 +56,7 @@ extern "C" { * stronger message digests instead. * */ -typedef struct +typedef struct mbedtls_md2_context { unsigned char cksum[16]; /*!< checksum of the data block */ unsigned char state[48]; /*!< intermediate digest state */ @@ -64,6 +65,10 @@ typedef struct } mbedtls_md2_context; +#else /* MBEDTLS_MD2_ALT */ +#include "md2_alt.h" +#endif /* MBEDTLS_MD2_ALT */ + /** * \brief Initialize MD2 context * @@ -235,18 +240,6 @@ MBEDTLS_DEPRECATED void mbedtls_md2_process( mbedtls_md2_context *ctx ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_MD2_ALT */ -#include "md2_alt.h" -#endif /* MBEDTLS_MD2_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief Output = MD2( input buffer ) * @@ -290,6 +283,8 @@ MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -302,6 +297,8 @@ MBEDTLS_DEPRECATED void mbedtls_md2( const unsigned char *input, */ int mbedtls_md2_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/md4.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/md4.h index 23fa95e46a..ce703c0ba4 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/md4.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/md4.h @@ -38,16 +38,17 @@ #include #include +/* MBEDTLS_ERR_MD4_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD4_HW_ACCEL_FAILED -0x002D /**< MD4 hardware accelerator failed */ -#if !defined(MBEDTLS_MD4_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_MD4_ALT) +// Regular implementation +// + /** * \brief MD4 context structure * @@ -56,7 +57,7 @@ extern "C" { * stronger message digests instead. * */ -typedef struct +typedef struct mbedtls_md4_context { uint32_t total[2]; /*!< number of bytes processed */ uint32_t state[4]; /*!< intermediate digest state */ @@ -64,6 +65,10 @@ typedef struct } mbedtls_md4_context; +#else /* MBEDTLS_MD4_ALT */ +#include "md4_alt.h" +#endif /* MBEDTLS_MD4_ALT */ + /** * \brief Initialize MD4 context * @@ -238,18 +243,6 @@ MBEDTLS_DEPRECATED void mbedtls_md4_process( mbedtls_md4_context *ctx, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_MD4_ALT */ -#include "md4_alt.h" -#endif /* MBEDTLS_MD4_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief Output = MD4( input buffer ) * @@ -295,6 +288,8 @@ MBEDTLS_DEPRECATED void mbedtls_md4( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -307,6 +302,8 @@ MBEDTLS_DEPRECATED void mbedtls_md4( const unsigned char *input, */ int mbedtls_md4_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/md5.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/md5.h index 06ea4c5d44..6eed6cc864 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/md5.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/md5.h @@ -37,16 +37,17 @@ #include #include +/* MBEDTLS_ERR_MD5_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_MD5_HW_ACCEL_FAILED -0x002F /**< MD5 hardware accelerator failed */ -#if !defined(MBEDTLS_MD5_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_MD5_ALT) +// Regular implementation +// + /** * \brief MD5 context structure * @@ -55,7 +56,7 @@ extern "C" { * stronger message digests instead. * */ -typedef struct +typedef struct mbedtls_md5_context { uint32_t total[2]; /*!< number of bytes processed */ uint32_t state[4]; /*!< intermediate digest state */ @@ -63,6 +64,10 @@ typedef struct } mbedtls_md5_context; +#else /* MBEDTLS_MD5_ALT */ +#include "md5_alt.h" +#endif /* MBEDTLS_MD5_ALT */ + /** * \brief Initialize MD5 context * @@ -238,18 +243,6 @@ MBEDTLS_DEPRECATED void mbedtls_md5_process( mbedtls_md5_context *ctx, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_MD5_ALT */ -#include "md5_alt.h" -#endif /* MBEDTLS_MD5_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief Output = MD5( input buffer ) * @@ -295,6 +288,8 @@ MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -307,6 +302,8 @@ MBEDTLS_DEPRECATED void mbedtls_md5( const unsigned char *input, */ int mbedtls_md5_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/net.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/net.h index 6c13b53fb9..8cead58e5d 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/net.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/net.h @@ -23,6 +23,11 @@ * * This file is part of mbed TLS (https://tls.mbed.org) */ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif #if !defined(MBEDTLS_DEPRECATED_REMOVED) #include "net_sockets.h" diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/net_sockets.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/net_sockets.h index 52bb8de7c7..4c7ef00fe6 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/net_sockets.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/net_sockets.h @@ -1,7 +1,23 @@ /** * \file net_sockets.h * - * \brief Network communication functions + * \brief Network sockets abstraction layer to integrate Mbed TLS into a + * BSD-style sockets API. + * + * The network sockets module provides an example integration of the + * Mbed TLS library into a BSD sockets implementation. The module is + * intended to be an example of how Mbed TLS can be integrated into a + * networking stack, as well as to be Mbed TLS's network integration + * for its supported platforms. + * + * The module is intended only to be used with the Mbed TLS library and + * is not intended to be used by third party application software + * directly. + * + * The supported platforms are as follows: + * * Microsoft Windows and Windows CE + * * POSIX/Unix platforms including Linux, OS X + * */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved @@ -46,12 +62,17 @@ #define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */ #define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */ #define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */ +#define MBEDTLS_ERR_NET_POLL_FAILED -0x0047 /**< Polling the net context failed. */ +#define MBEDTLS_ERR_NET_BAD_INPUT_DATA -0x0049 /**< Input invalid. */ #define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */ #define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */ #define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */ +#define MBEDTLS_NET_POLL_READ 1 /**< Used in \c mbedtls_net_poll to check for pending data */ +#define MBEDTLS_NET_POLL_WRITE 2 /**< Used in \c mbedtls_net_poll to check if write possible */ + #ifdef __cplusplus extern "C" { #endif @@ -63,7 +84,7 @@ extern "C" { * (eg two file descriptors for combined IPv4 + IPv6 support, or additional * structures for hand-made UDP demultiplexing). */ -typedef struct +typedef struct mbedtls_net_context { int fd; /**< The underlying file descriptor */ } @@ -133,6 +154,29 @@ int mbedtls_net_accept( mbedtls_net_context *bind_ctx, mbedtls_net_context *client_ctx, void *client_ip, size_t buf_size, size_t *ip_len ); +/** + * \brief Check and wait for the context to be ready for read/write + * + * \param ctx Socket to check + * \param rw Bitflag composed of MBEDTLS_NET_POLL_READ and + * MBEDTLS_NET_POLL_WRITE specifying the events + * to wait for: + * - If MBEDTLS_NET_POLL_READ is set, the function + * will return as soon as the net context is available + * for reading. + * - If MBEDTLS_NET_POLL_WRITE is set, the function + * will return as soon as the net context is available + * for writing. + * \param timeout Maximal amount of time to wait before returning, + * in milliseconds. If \c timeout is zero, the + * function returns immediately. If \c timeout is + * -1u, the function blocks potentially indefinitely. + * + * \return Bitmask composed of MBEDTLS_NET_POLL_READ/WRITE + * on success or timeout, or a negative return code otherwise. + */ +int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout ); + /** * \brief Set the socket blocking * diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/nist_kw.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/nist_kw.h new file mode 100644 index 0000000000..3b67b59cd2 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/nist_kw.h @@ -0,0 +1,184 @@ +/** + * \file nist_kw.h + * + * \brief This file provides an API for key wrapping (KW) and key wrapping with + * padding (KWP) as defined in NIST SP 800-38F. + * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf + * + * Key wrapping specifies a deterministic authenticated-encryption mode + * of operation, according to NIST SP 800-38F: Recommendation for + * Block Cipher Modes of Operation: Methods for Key Wrapping. Its + * purpose is to protect cryptographic keys. + * + * Its equivalent is RFC 3394 for KW, and RFC 5649 for KWP. + * https://tools.ietf.org/html/rfc3394 + * https://tools.ietf.org/html/rfc5649 + * + */ +/* + * Copyright (C) 2018, Arm Limited (or its affiliates), All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_NIST_KW_H +#define MBEDTLS_NIST_KW_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "cipher.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum +{ + MBEDTLS_KW_MODE_KW = 0, + MBEDTLS_KW_MODE_KWP = 1 +} mbedtls_nist_kw_mode_t; + +#if !defined(MBEDTLS_NIST_KW_ALT) +// Regular implementation +// + +/** + * \brief The key wrapping context-type definition. The key wrapping context is passed + * to the APIs called. + * + * \note The definition of this type may change in future library versions. + * Don't make any assumptions on this context! + */ +typedef struct { + mbedtls_cipher_context_t cipher_ctx; /*!< The cipher context used. */ +} mbedtls_nist_kw_context; + +#else /* MBEDTLS_NIST_key wrapping_ALT */ +#include "nist_kw_alt.h" +#endif /* MBEDTLS_NIST_KW_ALT */ + +/** + * \brief This function initializes the specified key wrapping context + * to make references valid and prepare the context + * for mbedtls_nist_kw_setkey() or mbedtls_nist_kw_free(). + * + * \param ctx The key wrapping context to initialize. + * + */ +void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx ); + +/** + * \brief This function initializes the key wrapping context set in the + * \p ctx parameter and sets the encryption key. + * + * \param ctx The key wrapping context. + * \param cipher The 128-bit block cipher to use. Only AES is supported. + * \param key The Key Encryption Key (KEK). + * \param keybits The KEK size in bits. This must be acceptable by the cipher. + * \param is_wrap Specify whether the operation within the context is wrapping or unwrapping + * + * \return \c 0 on success. + * \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for any invalid input. + * \return \c MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE for 128-bit block ciphers + * which are not supported. + * \return cipher-specific error code on failure of the underlying cipher. + */ +int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx, + mbedtls_cipher_id_t cipher, + const unsigned char *key, + unsigned int keybits, + const int is_wrap ); + +/** + * \brief This function releases and clears the specified key wrapping context + * and underlying cipher sub-context. + * + * \param ctx The key wrapping context to clear. + */ +void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx ); + +/** + * \brief This function encrypts a buffer using key wrapping. + * + * \param ctx The key wrapping context to use for encryption. + * \param mode The key wrapping mode to use (MBEDTLS_KW_MODE_KW or MBEDTLS_KW_MODE_KWP) + * \param input The buffer holding the input data. + * \param in_len The length of the input data in Bytes. + * The input uses units of 8 Bytes called semiblocks. + *
  • For KW mode: a multiple of 8 bytes between 16 and 2^57-8 inclusive.
  • + *
  • For KWP mode: any length between 1 and 2^32-1 inclusive.
+ * \param[out] output The buffer holding the output data. + *
  • For KW mode: Must be at least 8 bytes larger than \p in_len.
  • + *
  • For KWP mode: Must be at least 8 bytes larger rounded up to a multiple of + * 8 bytes for KWP (15 bytes at most).
+ * \param[out] out_len The number of bytes written to the output buffer. \c 0 on failure. + * \param[in] out_size The capacity of the output buffer. + * + * \return \c 0 on success. + * \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length. + * \return cipher-specific error code on failure of the underlying cipher. + */ +int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode, + const unsigned char *input, size_t in_len, + unsigned char *output, size_t* out_len, size_t out_size ); + +/** + * \brief This function decrypts a buffer using key wrapping. + * + * \param ctx The key wrapping context to use for decryption. + * \param mode The key wrapping mode to use (MBEDTLS_KW_MODE_KW or MBEDTLS_KW_MODE_KWP) + * \param input The buffer holding the input data. + * \param in_len The length of the input data in Bytes. + * The input uses units of 8 Bytes called semiblocks. + * The input must be a multiple of semiblocks. + *
  • For KW mode: a multiple of 8 bytes between 24 and 2^57 inclusive.
  • + *
  • For KWP mode: a multiple of 8 bytes between 16 and 2^32 inclusive.
+ * \param[out] output The buffer holding the output data. + * The output buffer's minimal length is 8 bytes shorter than \p in_len. + * \param[out] out_len The number of bytes written to the output buffer. \c 0 on failure. + * For KWP mode, the length could be up to 15 bytes shorter than \p in_len, + * depending on how much padding was added to the data. + * \param[in] out_size The capacity of the output buffer. + * + * \return \c 0 on success. + * \return \c MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA for invalid input length. + * \return \c MBEDTLS_ERR_CIPHER_AUTH_FAILED for verification failure of the ciphertext. + * \return cipher-specific error code on failure of the underlying cipher. + */ +int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, mbedtls_nist_kw_mode_t mode, + const unsigned char *input, size_t in_len, + unsigned char *output, size_t* out_len, size_t out_size); + + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +/** + * \brief The key wrapping checkup routine. + * + * \return \c 0 on success. + * \return \c 1 on failure. + */ +int mbedtls_nist_kw_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_NIST_KW_H */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/oid.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/oid.h index 408645ece7..6fbd018aaa 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/oid.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/oid.h @@ -97,6 +97,8 @@ /* ISO arc for standard certificate and CRL extensions */ #define MBEDTLS_OID_ID_CE MBEDTLS_OID_ISO_CCITT_DS "\x1D" /**< id-ce OBJECT IDENTIFIER ::= {joint-iso-ccitt(2) ds(5) 29} */ +#define MBEDTLS_OID_NIST_ALG MBEDTLS_OID_GOV "\x03\x04" /** { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) */ + /** * Private Internet Extensions * { iso(1) identified-organization(3) dod(6) internet(1) @@ -219,12 +221,12 @@ #define MBEDTLS_OID_DIGEST_ALG_MD4 MBEDTLS_OID_RSA_COMPANY "\x02\x04" /**< id-mbedtls_md4 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 4 } */ #define MBEDTLS_OID_DIGEST_ALG_MD5 MBEDTLS_OID_RSA_COMPANY "\x02\x05" /**< id-mbedtls_md5 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 5 } */ #define MBEDTLS_OID_DIGEST_ALG_SHA1 MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_OIW_SECSIG_SHA1 /**< id-mbedtls_sha1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 26 } */ -#define MBEDTLS_OID_DIGEST_ALG_SHA224 MBEDTLS_OID_GOV "\x03\x04\x02\x04" /**< id-sha224 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 4 } */ -#define MBEDTLS_OID_DIGEST_ALG_SHA256 MBEDTLS_OID_GOV "\x03\x04\x02\x01" /**< id-mbedtls_sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 1 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA224 MBEDTLS_OID_NIST_ALG "\x02\x04" /**< id-sha224 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 4 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA256 MBEDTLS_OID_NIST_ALG "\x02\x01" /**< id-mbedtls_sha256 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 1 } */ -#define MBEDTLS_OID_DIGEST_ALG_SHA384 MBEDTLS_OID_GOV "\x03\x04\x02\x02" /**< id-sha384 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 2 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA384 MBEDTLS_OID_NIST_ALG "\x02\x02" /**< id-sha384 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 2 } */ -#define MBEDTLS_OID_DIGEST_ALG_SHA512 MBEDTLS_OID_GOV "\x03\x04\x02\x03" /**< id-mbedtls_sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 3 } */ +#define MBEDTLS_OID_DIGEST_ALG_SHA512 MBEDTLS_OID_NIST_ALG "\x02\x03" /**< id-mbedtls_sha512 OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistalgorithm(4) hashalgs(2) 3 } */ #define MBEDTLS_OID_HMAC_SHA1 MBEDTLS_OID_RSA_COMPANY "\x02\x07" /**< id-hmacWithSHA1 OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) digestAlgorithm(2) 7 } */ @@ -241,7 +243,20 @@ */ #define MBEDTLS_OID_DES_CBC MBEDTLS_OID_ISO_IDENTIFIED_ORG MBEDTLS_OID_OIW_SECSIG_ALG "\x07" /**< desCBC OBJECT IDENTIFIER ::= { iso(1) identified-organization(3) oiw(14) secsig(3) algorithms(2) 7 } */ #define MBEDTLS_OID_DES_EDE3_CBC MBEDTLS_OID_RSA_COMPANY "\x03\x07" /**< des-ede3-cbc OBJECT IDENTIFIER ::= { iso(1) member-body(2) -- us(840) rsadsi(113549) encryptionAlgorithm(3) 7 } */ +#define MBEDTLS_OID_AES MBEDTLS_OID_NIST_ALG "\x01" /** aes OBJECT IDENTIFIER ::= { joint-iso-itu-t(2) country(16) us(840) organization(1) gov(101) csor(3) nistAlgorithm(4) 1 } */ +/* + * Key Wrapping algorithms + */ +/* + * RFC 5649 + */ +#define MBEDTLS_OID_AES128_KW MBEDTLS_OID_AES "\x05" /** id-aes128-wrap OBJECT IDENTIFIER ::= { aes 5 } */ +#define MBEDTLS_OID_AES128_KWP MBEDTLS_OID_AES "\x08" /** id-aes128-wrap-pad OBJECT IDENTIFIER ::= { aes 8 } */ +#define MBEDTLS_OID_AES192_KW MBEDTLS_OID_AES "\x19" /** id-aes192-wrap OBJECT IDENTIFIER ::= { aes 25 } */ +#define MBEDTLS_OID_AES192_KWP MBEDTLS_OID_AES "\x1c" /** id-aes192-wrap-pad OBJECT IDENTIFIER ::= { aes 28 } */ +#define MBEDTLS_OID_AES256_KW MBEDTLS_OID_AES "\x2d" /** id-aes256-wrap OBJECT IDENTIFIER ::= { aes 45 } */ +#define MBEDTLS_OID_AES256_KWP MBEDTLS_OID_AES "\x30" /** id-aes256-wrap-pad OBJECT IDENTIFIER ::= { aes 48 } */ /* * PKCS#5 OIDs */ @@ -388,7 +403,8 @@ extern "C" { /** * \brief Base OID descriptor structure */ -typedef struct { +typedef struct mbedtls_oid_descriptor_t +{ const char *asn1; /*!< OID ASN.1 representation */ size_t asn1_len; /*!< length of asn1 */ const char *name; /*!< official name (e.g. from RFC) */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/padlock.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/padlock.h index 677936ebf8..721a5d4930 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/padlock.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/padlock.h @@ -3,6 +3,9 @@ * * \brief VIA PadLock ACE for HW encryption/decryption supported by some * processors + * + * \warning These functions are only for internal use by other library + * functions; you must not call them directly. */ /* * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved @@ -25,6 +28,12 @@ #ifndef MBEDTLS_PADLOCK_H #define MBEDTLS_PADLOCK_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "aes.h" #define MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED -0x0030 /**< Input data should be aligned. */ @@ -50,14 +59,17 @@ #define MBEDTLS_PADLOCK_PHE 0x0C00 #define MBEDTLS_PADLOCK_PMM 0x3000 -#define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) x & ~15)) +#define MBEDTLS_PADLOCK_ALIGN16(x) (uint32_t *) (16 + ((int32_t) (x) & ~15)) #ifdef __cplusplus extern "C" { #endif /** - * \brief PadLock detection routine + * \brief Internal PadLock detection routine + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param feature The feature to detect * @@ -66,7 +78,10 @@ extern "C" { int mbedtls_padlock_has_support( int feature ); /** - * \brief PadLock AES-ECB block en(de)cryption + * \brief Internal PadLock AES-ECB block en(de)cryption + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param ctx AES context * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT @@ -76,12 +91,15 @@ int mbedtls_padlock_has_support( int feature ); * \return 0 if success, 1 if operation failed */ int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx, - int mode, - const unsigned char input[16], - unsigned char output[16] ); + int mode, + const unsigned char input[16], + unsigned char output[16] ); /** - * \brief PadLock AES-CBC buffer en(de)cryption + * \brief Internal PadLock AES-CBC buffer en(de)cryption + * + * \note This function is only for internal use by other library + * functions; you must not call it directly. * * \param ctx AES context * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT @@ -93,11 +111,11 @@ int mbedtls_padlock_xcryptecb( mbedtls_aes_context *ctx, * \return 0 if success, 1 if operation failed */ int mbedtls_padlock_xcryptcbc( mbedtls_aes_context *ctx, - int mode, - size_t length, - unsigned char iv[16], - const unsigned char *input, - unsigned char *output ); + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ); #ifdef __cplusplus } diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/pem.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/pem.h index 2cf4c0a709..a29e9ce300 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/pem.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/pem.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_PEM_H #define MBEDTLS_PEM_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include /** @@ -51,7 +57,7 @@ extern "C" { /** * \brief PEM context structure */ -typedef struct +typedef struct mbedtls_pem_context { unsigned char *buf; /*!< buffer for decoded data */ size_t buflen; /*!< length of the buffer */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/pk.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/pk.h index ee06b2fd20..91950f9407 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/pk.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/pk.h @@ -64,6 +64,8 @@ #define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 /**< Elliptic curve is unsupported (only NIST curves are supported). */ #define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 /**< Unavailable feature, e.g. RSA disabled for RSA key. */ #define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 /**< The buffer contains a valid signature followed by more data. */ + +/* MBEDTLS_ERR_PK_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880 /**< PK hardware accelerator failed. */ #ifdef __cplusplus @@ -87,7 +89,7 @@ typedef enum { * \brief Options for RSASSA-PSS signature verification. * See \c mbedtls_rsa_rsassa_pss_verify_ext() */ -typedef struct +typedef struct mbedtls_pk_rsassa_pss_options { mbedtls_md_type_t mgf1_hash_id; int expected_salt_len; @@ -107,7 +109,7 @@ typedef enum /** * \brief Item to send to the debug module */ -typedef struct +typedef struct mbedtls_pk_debug_item { mbedtls_pk_debug_type type; const char *name; @@ -125,12 +127,26 @@ typedef struct mbedtls_pk_info_t mbedtls_pk_info_t; /** * \brief Public key container */ -typedef struct +typedef struct mbedtls_pk_context { - const mbedtls_pk_info_t * pk_info; /**< Public key informations */ + const mbedtls_pk_info_t * pk_info; /**< Public key information */ void * pk_ctx; /**< Underlying public key context */ } mbedtls_pk_context; +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief Context for resuming operations + */ +typedef struct +{ + const mbedtls_pk_info_t * pk_info; /**< Public key information */ + void * rs_ctx; /**< Underlying restart context */ +} mbedtls_pk_restart_ctx; +#else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ +/* Now we can declare functions that take a pointer to that */ +typedef void mbedtls_pk_restart_ctx; +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + #if defined(MBEDTLS_RSA_C) /** * Quick access to an RSA context inside a PK context. @@ -181,20 +197,45 @@ typedef size_t (*mbedtls_pk_rsa_alt_key_len_func)( void *ctx ); const mbedtls_pk_info_t *mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type ); /** - * \brief Initialize a mbedtls_pk_context (as NONE) + * \brief Initialize a #mbedtls_pk_context (as NONE). + * + * \param ctx The context to initialize. + * This must not be \c NULL. */ void mbedtls_pk_init( mbedtls_pk_context *ctx ); /** - * \brief Free a mbedtls_pk_context + * \brief Free the components of a #mbedtls_pk_context. + * + * \param ctx The context to clear. It must have been initialized. + * If this is \c NULL, this function does nothing. */ void mbedtls_pk_free( mbedtls_pk_context *ctx ); +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief Initialize a restart context + * + * \param ctx The context to initialize. + * This must not be \c NULL. + */ +void mbedtls_pk_restart_init( mbedtls_pk_restart_ctx *ctx ); + +/** + * \brief Free the components of a restart context + * + * \param ctx The context to clear. It must have been initialized. + * If this is \c NULL, this function does nothing. + */ +void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx ); +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + /** * \brief Initialize a PK context with the information given * and allocates the type-specific PK subcontext. * - * \param ctx Context to initialize. Must be empty (type NONE). + * \param ctx Context to initialize. It must not have been set + * up yet (type #MBEDTLS_PK_NONE). * \param info Information to use * * \return 0 on success, @@ -210,7 +251,8 @@ int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ); /** * \brief Initialize an RSA-alt context * - * \param ctx Context to initialize. Must be empty (type NONE). + * \param ctx Context to initialize. It must not have been set + * up yet (type #MBEDTLS_PK_NONE). * \param key RSA key pointer * \param decrypt_func Decryption function * \param sign_func Signing function @@ -230,7 +272,7 @@ int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, /** * \brief Get the size in bits of the underlying key * - * \param ctx Context to use + * \param ctx The context to query. It must have been initialized. * * \return Key size in bits, or 0 on error */ @@ -238,7 +280,8 @@ size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ); /** * \brief Get the length in bytes of the underlying key - * \param ctx Context to use + * + * \param ctx The context to query. It must have been initialized. * * \return Key length in bytes, or 0 on error */ @@ -250,18 +293,21 @@ static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx ) /** * \brief Tell if a context can do the operation given by type * - * \param ctx Context to test - * \param type Target type + * \param ctx The context to query. It must have been initialized. + * \param type The desired type. * - * \return 0 if context can't do the operations, - * 1 otherwise. + * \return 1 if the context can do operations on the given type. + * \return 0 if the context cannot do the operations on the given + * type. This is always the case for a context that has + * been initialized but not set up, or that has been + * cleared with mbedtls_pk_free(). */ int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ); /** * \brief Verify signature (including padding if relevant). * - * \param ctx PK context to use + * \param ctx The PK context to use. It must have been set up. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) @@ -286,13 +332,39 @@ int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len ); +/** + * \brief Restartable version of \c mbedtls_pk_verify() + * + * \note Performs the same job as \c mbedtls_pk_verify(), but can + * return early and restart according to the limit set with + * \c mbedtls_ecp_set_max_ops() to reduce blocking for ECC + * operations. For RSA, same as \c mbedtls_pk_verify(). + * + * \param ctx The PK context to use. It must have been set up. + * \param md_alg Hash algorithm used (see notes) + * \param hash Hash of the message to sign + * \param hash_len Hash length or 0 (see notes) + * \param sig Signature to verify + * \param sig_len Signature length + * \param rs_ctx Restart context (NULL to disable restart) + * + * \return See \c mbedtls_pk_verify(), or + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + */ +int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx, + mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len, + mbedtls_pk_restart_ctx *rs_ctx ); + /** * \brief Verify signature, with options. * (Includes verification of the padding depending on type.) * * \param type Signature type (inc. possible padding type) to verify * \param options Pointer to type-specific options, or NULL - * \param ctx PK context to use + * \param ctx The PK context to use. It must have been set up. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) @@ -323,7 +395,8 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options, /** * \brief Make signature, including padding if relevant. * - * \param ctx PK context to use - must hold a private key + * \param ctx The PK context to use. It must have been set up + * with a private key. * \param md_alg Hash algorithm used (see notes) * \param hash Hash of the message to sign * \param hash_len Hash length or 0 (see notes) @@ -349,10 +422,41 @@ int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); +/** + * \brief Restartable version of \c mbedtls_pk_sign() + * + * \note Performs the same job as \c mbedtls_pk_sign(), but can + * return early and restart according to the limit set with + * \c mbedtls_ecp_set_max_ops() to reduce blocking for ECC + * operations. For RSA, same as \c mbedtls_pk_sign(). + * + * \param ctx The PK context to use. It must have been set up + * with a private key. + * \param md_alg Hash algorithm used (see notes) + * \param hash Hash of the message to sign + * \param hash_len Hash length or 0 (see notes) + * \param sig Place to write the signature + * \param sig_len Number of bytes written + * \param f_rng RNG function + * \param p_rng RNG parameter + * \param rs_ctx Restart context (NULL to disable restart) + * + * \return See \c mbedtls_pk_sign(), or + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + */ +int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx, + mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_pk_restart_ctx *rs_ctx ); + /** * \brief Decrypt message (including padding if relevant). * - * \param ctx PK context to use - must hold a private key + * \param ctx The PK context to use. It must have been set up + * with a private key. * \param input Input to decrypt * \param ilen Input size * \param output Decrypted output @@ -373,7 +477,7 @@ int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, /** * \brief Encrypt message (including padding if relevant). * - * \param ctx PK context to use + * \param ctx The PK context to use. It must have been set up. * \param input Message to encrypt * \param ilen Message size * \param output Encrypted output @@ -404,7 +508,7 @@ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_conte /** * \brief Export debug information * - * \param ctx Context to use + * \param ctx The PK context to use. It must have been initialized. * \param items Place to write debug items * * \return 0 on success or MBEDTLS_ERR_PK_BAD_INPUT_DATA @@ -414,7 +518,7 @@ int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *item /** * \brief Access the type name * - * \param ctx Context to use + * \param ctx The PK context to use. It must have been initialized. * * \return Type name on success, or "invalid PK" */ @@ -423,9 +527,10 @@ const char * mbedtls_pk_get_name( const mbedtls_pk_context *ctx ); /** * \brief Get the key type * - * \param ctx Context to use + * \param ctx The PK context to use. It must have been initialized. * - * \return Type on success, or MBEDTLS_PK_NONE + * \return Type on success. + * \return #MBEDTLS_PK_NONE for a context that has not been set up. */ mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ); @@ -434,12 +539,22 @@ mbedtls_pk_type_t mbedtls_pk_get_type( const mbedtls_pk_context *ctx ); /** * \brief Parse a private key in PEM or DER format * - * \param ctx key to be initialized - * \param key input buffer - * \param keylen size of the buffer - * (including the terminating null byte for PEM data) - * \param pwd password for decryption (optional) - * \param pwdlen size of the password + * \param ctx The PK context to fill. It must have been initialized + * but not set up. + * \param key Input buffer to parse. + * The buffer must contain the input exactly, with no + * extra trailing material. For PEM, the buffer must + * contain a null-terminated string. + * \param keylen Size of \b key in bytes. + * For PEM data, this includes the terminating null byte, + * so \p keylen must be equal to `strlen(key) + 1`. + * \param pwd Optional password for decryption. + * Pass \c NULL if expecting a non-encrypted key. + * Pass a string of \p pwdlen bytes if expecting an encrypted + * key; a non-encrypted key will also be accepted. + * The empty password is not supported. + * \param pwdlen Size of the password in bytes. + * Ignored if \p pwd is \c NULL. * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a @@ -457,10 +572,15 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *ctx, /** * \brief Parse a public key in PEM or DER format * - * \param ctx key to be initialized - * \param key input buffer - * \param keylen size of the buffer - * (including the terminating null byte for PEM data) + * \param ctx The PK context to fill. It must have been initialized + * but not set up. + * \param key Input buffer to parse. + * The buffer must contain the input exactly, with no + * extra trailing material. For PEM, the buffer must + * contain a null-terminated string. + * \param keylen Size of \b key in bytes. + * For PEM data, this includes the terminating null byte, + * so \p keylen must be equal to `strlen(key) + 1`. * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a @@ -478,9 +598,14 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx, /** * \brief Load and parse a private key * - * \param ctx key to be initialized + * \param ctx The PK context to fill. It must have been initialized + * but not set up. * \param path filename to read the private key from - * \param password password to decrypt the file (can be NULL) + * \param password Optional password to decrypt the file. + * Pass \c NULL if expecting a non-encrypted key. + * Pass a null-terminated string if expecting an encrypted + * key; a non-encrypted key will also be accepted. + * The empty password is not supported. * * \note On entry, ctx must be empty, either freshly initialised * with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a @@ -497,7 +622,8 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, /** * \brief Load and parse a public key * - * \param ctx key to be initialized + * \param ctx The PK context to fill. It must have been initialized + * but not set up. * \param path filename to read the public key from * * \note On entry, ctx must be empty, either freshly initialised @@ -520,7 +646,7 @@ int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ) * return value to determine where you should start * using the buffer * - * \param ctx private to write away + * \param ctx PK context which must contain a valid private key. * \param buf buffer to write to * \param size size of the buffer * @@ -535,7 +661,7 @@ int mbedtls_pk_write_key_der( mbedtls_pk_context *ctx, unsigned char *buf, size_ * return value to determine where you should start * using the buffer * - * \param ctx public key to write away + * \param ctx PK context which must contain a valid public or private key. * \param buf buffer to write to * \param size size of the buffer * @@ -548,9 +674,10 @@ int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *ctx, unsigned char *buf, si /** * \brief Write a public key to a PEM string * - * \param ctx public key to write away - * \param buf buffer to write to - * \param size size of the buffer + * \param ctx PK context which must contain a valid public or private key. + * \param buf Buffer to write to. The output includes a + * terminating null byte. + * \param size Size of the buffer in bytes. * * \return 0 if successful, or a specific error code */ @@ -559,9 +686,10 @@ int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *ctx, unsigned char *buf, si /** * \brief Write a private key to a PKCS#1 or SEC1 PEM string * - * \param ctx private to write away - * \param buf buffer to write to - * \param size size of the buffer + * \param ctx PK context which must contain a valid private key. + * \param buf Buffer to write to. The output includes a + * terminating null byte. + * \param size Size of the buffer in bytes. * * \return 0 if successful, or a specific error code */ @@ -580,7 +708,8 @@ int mbedtls_pk_write_key_pem( mbedtls_pk_context *ctx, unsigned char *buf, size_ * * \param p the position in the ASN.1 data * \param end end of the buffer - * \param pk the key to fill + * \param pk The PK context to fill. It must have been initialized + * but not set up. * * \return 0 if successful, or a specific PK error code */ @@ -595,7 +724,7 @@ int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end, * * \param p reference to current position pointer * \param start start of the buffer (for bounds-checking) - * \param key public key to write away + * \param key PK context which must contain a valid public or private key. * * \return the length written or a negative error code */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/pk_internal.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/pk_internal.h index 3dae0fc5b2..48b7a5f7bf 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/pk_internal.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/pk_internal.h @@ -59,6 +59,21 @@ struct mbedtls_pk_info_t int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ); +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /** Verify signature (restartable) */ + int (*verify_rs_func)( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len, + void *rs_ctx ); + + /** Make signature (restartable) */ + int (*sign_rs_func)( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, void *rs_ctx ); +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + /** Decrypt message */ int (*decrypt_func)( void *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, @@ -80,6 +95,14 @@ struct mbedtls_pk_info_t /** Free the given context */ void (*ctx_free_func)( void *ctx ); +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /** Allocate the restart context */ + void * (*rs_alloc_func)( void ); + + /** Free the restart context */ + void (*rs_free_func)( void *rs_ctx ); +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + /** Interface with the debug module */ void (*debug_func)( const void *ctx, mbedtls_pk_debug_item *items ); diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs11.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs11.h index bf65c55a79..02427ddc1e 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs11.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs11.h @@ -50,7 +50,8 @@ extern "C" { /** * Context for PKCS #11 private keys. */ -typedef struct { +typedef struct mbedtls_pkcs11_context +{ pkcs11h_certificate_t pkcs11h_cert; int len; } mbedtls_pkcs11_context; diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs12.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs12.h index 69f04177c8..d441357b7f 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs12.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs12.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_PKCS12_H #define MBEDTLS_PKCS12_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "md.h" #include "cipher.h" #include "asn1.h" diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs5.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs5.h index d4bb36dfae..c92185f7a6 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs5.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/pkcs5.h @@ -26,6 +26,12 @@ #ifndef MBEDTLS_PKCS5_H #define MBEDTLS_PKCS5_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "asn1.h" #include "md.h" @@ -85,6 +91,8 @@ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *p unsigned int iteration_count, uint32_t key_length, unsigned char *output ); +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -92,6 +100,8 @@ int mbedtls_pkcs5_pbkdf2_hmac( mbedtls_md_context_t *ctx, const unsigned char *p */ int mbedtls_pkcs5_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/platform.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/platform.h index 7c2835b305..89fe8a7b19 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/platform.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/platform.h @@ -1,7 +1,16 @@ /** * \file platform.h * - * \brief The Mbed TLS platform abstraction layer. + * \brief This file contains the definitions and functions of the + * Mbed TLS platform abstraction layer. + * + * The platform abstraction layer removes the need for the library + * to directly link to standard C library functions or operating + * system services, making the library easier to port and embed. + * Application developers and users of the library can provide their own + * implementations of these functions, or implementations specific to + * their platform, which can be statically linked to the library or + * dynamically configured at runtime. */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved @@ -34,6 +43,9 @@ #include "platform_time.h" #endif +#define MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED -0x0070 /**< Hardware accelerator failed */ +#define MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED -0x0072 /**< The requested feature is not supported by the platform */ + #ifdef __cplusplus extern "C" { #endif @@ -102,7 +114,7 @@ extern "C" { /* \} name SECTION: Module settings */ /* - * The function pointers for calloc and free + * The function pointers for calloc and free. */ #if defined(MBEDTLS_PLATFORM_MEMORY) #if defined(MBEDTLS_PLATFORM_FREE_MACRO) && \ @@ -112,11 +124,12 @@ extern "C" { #else /* For size_t */ #include -extern void * (*mbedtls_calloc)( size_t n, size_t size ); -extern void (*mbedtls_free)( void *ptr ); +extern void *mbedtls_calloc( size_t n, size_t size ); +extern void mbedtls_free( void *ptr ); /** - * \brief This function allows configuring custom memory-management functions. + * \brief This function dynamically sets the memory-management + * functions used by the library, during runtime. * * \param calloc_func The \c calloc function implementation. * \param free_func The \c free function implementation. @@ -140,7 +153,9 @@ int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ), extern int (*mbedtls_fprintf)( FILE *stream, const char *format, ... ); /** - * \brief This function allows configuring a custom \p fprintf function pointer. + * \brief This function dynamically configures the fprintf + * function that is called when the + * mbedtls_fprintf() function is invoked by the library. * * \param fprintf_func The \c fprintf function implementation. * @@ -163,8 +178,9 @@ int mbedtls_platform_set_fprintf( int (*fprintf_func)( FILE *stream, const char extern int (*mbedtls_printf)( const char *format, ... ); /** - * \brief This function allows configuring a custom \c printf function - * pointer. + * \brief This function dynamically configures the snprintf + * function that is called when the mbedtls_snprintf() + * function is invoked by the library. * * \param printf_func The \c printf function implementation. * @@ -197,12 +213,12 @@ int mbedtls_platform_win32_snprintf( char *s, size_t n, const char *fmt, ... ); extern int (*mbedtls_snprintf)( char * s, size_t n, const char * format, ... ); /** - * \brief This function allows configuring a custom \c snprintf function - * pointer. + * \brief This function allows configuring a custom + * \c snprintf function pointer. * * \param snprintf_func The \c snprintf function implementation. * - * \return \c 0 on success. + * \return \c 0 on success. */ int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n, const char * format, ... ) ); @@ -221,12 +237,13 @@ int mbedtls_platform_set_snprintf( int (*snprintf_func)( char * s, size_t n, extern void (*mbedtls_exit)( int status ); /** - * \brief This function allows configuring a custom \c exit function - * pointer. + * \brief This function dynamically configures the exit + * function that is called when the mbedtls_exit() + * function is invoked by the library. * * \param exit_func The \c exit function implementation. * - * \return \c 0 on success. + * \return \c 0 on success. */ int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); #else @@ -301,8 +318,9 @@ int mbedtls_platform_set_nv_seed( * \note This structure may be used to assist platform-specific * setup or teardown operations. */ -typedef struct { - char dummy; /**< Placeholder member, as empty structs are not portable. */ +typedef struct mbedtls_platform_context +{ + char dummy; /**< A placeholder member, as empty structs are not portable. */ } mbedtls_platform_context; @@ -311,33 +329,34 @@ mbedtls_platform_context; #endif /* !MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */ /** - * \brief This function performs any platform initialization operations. + * \brief This function performs any platform-specific initialization + * operations. * - * \param ctx The Mbed TLS context. + * \note This function should be called before any other library functions. * - * \return \c 0 on success. - * - * \note This function is intended to allow platform-specific initialization, - * and should be called before any other library functions. Its - * implementation is platform-specific, and unless + * Its implementation is platform-specific, and unless * platform-specific code is provided, it does nothing. * - * Its use and whether it is necessary to call it is dependent on the - * platform. + * \note The usage and necessity of this function is dependent on the platform. + * + * \param ctx The platform context. + * + * \return \c 0 on success. */ int mbedtls_platform_setup( mbedtls_platform_context *ctx ); /** * \brief This function performs any platform teardown operations. * - * \param ctx The Mbed TLS context. - * * \note This function should be called after every other Mbed TLS module * has been correctly freed using the appropriate free function. + * * Its implementation is platform-specific, and unless * platform-specific code is provided, it does nothing. * - * Its use and whether it is necessary to call it is dependent on the - * platform. + * \note The usage and necessity of this function is dependent on the platform. + * + * \param ctx The platform context. + * */ void mbedtls_platform_teardown( mbedtls_platform_context *ctx ); diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/platform_util.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/platform_util.h new file mode 100644 index 0000000000..dba6d45982 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/platform_util.h @@ -0,0 +1,185 @@ +/** + * \file platform_util.h + * + * \brief Common and shared functions used by multiple modules in the Mbed TLS + * library. + */ +/* + * Copyright (C) 2018, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ +#ifndef MBEDTLS_PLATFORM_UTIL_H +#define MBEDTLS_PLATFORM_UTIL_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#if defined(MBEDTLS_HAVE_TIME_DATE) +#include "platform_time.h" +#include +#endif /* MBEDTLS_HAVE_TIME_DATE */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(MBEDTLS_CHECK_PARAMS) + +#if defined(MBEDTLS_PARAM_FAILED) +/** An alternative definition of MBEDTLS_PARAM_FAILED has been set in config.h. + * + * This flag can be used to check whether it is safe to assume that + * MBEDTLS_PARAM_FAILED() will expand to a call to mbedtls_param_failed(). + */ +#define MBEDTLS_PARAM_FAILED_ALT +#else /* MBEDTLS_PARAM_FAILED */ +#define MBEDTLS_PARAM_FAILED( cond ) \ + mbedtls_param_failed( #cond, __FILE__, __LINE__ ) + +/** + * \brief User supplied callback function for parameter validation failure. + * See #MBEDTLS_CHECK_PARAMS for context. + * + * This function will be called unless an alternative treatement + * is defined through the #MBEDTLS_PARAM_FAILED macro. + * + * This function can return, and the operation will be aborted, or + * alternatively, through use of setjmp()/longjmp() can resume + * execution in the application code. + * + * \param failure_condition The assertion that didn't hold. + * \param file The file where the assertion failed. + * \param line The line in the file where the assertion failed. + */ +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ); +#endif /* MBEDTLS_PARAM_FAILED */ + +/* Internal macro meant to be called only from within the library. */ +#define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) \ + do { \ + if( !(cond) ) \ + { \ + MBEDTLS_PARAM_FAILED( cond ); \ + return( ret ); \ + } \ + } while( 0 ) + +/* Internal macro meant to be called only from within the library. */ +#define MBEDTLS_INTERNAL_VALIDATE( cond ) \ + do { \ + if( !(cond) ) \ + { \ + MBEDTLS_PARAM_FAILED( cond ); \ + return; \ + } \ + } while( 0 ) + +#else /* MBEDTLS_CHECK_PARAMS */ + +/* Internal macros meant to be called only from within the library. */ +#define MBEDTLS_INTERNAL_VALIDATE_RET( cond, ret ) do { } while( 0 ) +#define MBEDTLS_INTERNAL_VALIDATE( cond ) do { } while( 0 ) + +#endif /* MBEDTLS_CHECK_PARAMS */ + +/* Internal helper macros for deprecating API constants. */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) +#if defined(MBEDTLS_DEPRECATED_WARNING) +/* Deliberately don't (yet) export MBEDTLS_DEPRECATED here + * to avoid conflict with other headers which define and use + * it, too. We might want to move all these definitions here at + * some point for uniformity. */ +#define MBEDTLS_DEPRECATED __attribute__((deprecated)) +MBEDTLS_DEPRECATED typedef char const * mbedtls_deprecated_string_constant_t; +#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) \ + ( (mbedtls_deprecated_string_constant_t) ( VAL ) ) +MBEDTLS_DEPRECATED typedef int mbedtls_deprecated_numeric_constant_t; +#define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) \ + ( (mbedtls_deprecated_numeric_constant_t) ( VAL ) ) +#undef MBEDTLS_DEPRECATED +#else /* MBEDTLS_DEPRECATED_WARNING */ +#define MBEDTLS_DEPRECATED_STRING_CONSTANT( VAL ) VAL +#define MBEDTLS_DEPRECATED_NUMERIC_CONSTANT( VAL ) VAL +#endif /* MBEDTLS_DEPRECATED_WARNING */ +#endif /* MBEDTLS_DEPRECATED_REMOVED */ + +/** + * \brief Securely zeroize a buffer + * + * The function is meant to wipe the data contained in a buffer so + * that it can no longer be recovered even if the program memory + * is later compromised. Call this function on sensitive data + * stored on the stack before returning from a function, and on + * sensitive data stored on the heap before freeing the heap + * object. + * + * It is extremely difficult to guarantee that calls to + * mbedtls_platform_zeroize() are not removed by aggressive + * compiler optimizations in a portable way. For this reason, Mbed + * TLS provides the configuration option + * MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure + * mbedtls_platform_zeroize() to use a suitable implementation for + * their platform and needs + * + * \param buf Buffer to be zeroized + * \param len Length of the buffer in bytes + * + */ +void mbedtls_platform_zeroize( void *buf, size_t len ); + +#if defined(MBEDTLS_HAVE_TIME_DATE) +/** + * \brief Platform-specific implementation of gmtime_r() + * + * The function is a thread-safe abstraction that behaves + * similarly to the gmtime_r() function from Unix/POSIX. + * + * Mbed TLS will try to identify the underlying platform and + * make use of an appropriate underlying implementation (e.g. + * gmtime_r() for POSIX and gmtime_s() for Windows). If this is + * not possible, then gmtime() will be used. In this case, calls + * from the library to gmtime() will be guarded by the mutex + * mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is + * enabled. It is recommended that calls from outside the library + * are also guarded by this mutex. + * + * If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will + * unconditionally use the alternative implementation for + * mbedtls_platform_gmtime_r() supplied by the user at compile time. + * + * \param tt Pointer to an object containing time (in seconds) since the + * epoch to be converted + * \param tm_buf Pointer to an object where the results will be stored + * + * \return Pointer to an object of type struct tm on success, otherwise + * NULL + */ +struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt, + struct tm *tm_buf ); +#endif /* MBEDTLS_HAVE_TIME_DATE */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_PLATFORM_UTIL_H */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/poly1305.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/poly1305.h new file mode 100644 index 0000000000..f0ec44c968 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/poly1305.h @@ -0,0 +1,192 @@ +/** + * \file poly1305.h + * + * \brief This file contains Poly1305 definitions and functions. + * + * Poly1305 is a one-time message authenticator that can be used to + * authenticate messages. Poly1305-AES was created by Daniel + * Bernstein https://cr.yp.to/mac/poly1305-20050329.pdf The generic + * Poly1305 algorithm (not tied to AES) was also standardized in RFC + * 7539. + * + * \author Daniel King + */ + +/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#ifndef MBEDTLS_POLY1305_H +#define MBEDTLS_POLY1305_H + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include +#include + +#define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057 /**< Invalid input parameter(s). */ + +/* MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE is deprecated and should not be + * used. */ +#define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059 /**< Feature not available. For example, s part of the API is not implemented. */ + +/* MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED is deprecated and should not be used. + */ +#define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B /**< Poly1305 hardware accelerator failed. */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(MBEDTLS_POLY1305_ALT) + +typedef struct mbedtls_poly1305_context +{ + uint32_t r[4]; /** The value for 'r' (low 128 bits of the key). */ + uint32_t s[4]; /** The value for 's' (high 128 bits of the key). */ + uint32_t acc[5]; /** The accumulator number. */ + uint8_t queue[16]; /** The current partial block of data. */ + size_t queue_len; /** The number of bytes stored in 'queue'. */ +} +mbedtls_poly1305_context; + +#else /* MBEDTLS_POLY1305_ALT */ +#include "poly1305_alt.h" +#endif /* MBEDTLS_POLY1305_ALT */ + +/** + * \brief This function initializes the specified Poly1305 context. + * + * It must be the first API called before using + * the context. + * + * It is usually followed by a call to + * \c mbedtls_poly1305_starts(), then one or more calls to + * \c mbedtls_poly1305_update(), then one call to + * \c mbedtls_poly1305_finish(), then finally + * \c mbedtls_poly1305_free(). + * + * \param ctx The Poly1305 context to initialize. This must + * not be \c NULL. + */ +void mbedtls_poly1305_init( mbedtls_poly1305_context *ctx ); + +/** + * \brief This function releases and clears the specified + * Poly1305 context. + * + * \param ctx The Poly1305 context to clear. This may be \c NULL, in which + * case this function is a no-op. If it is not \c NULL, it must + * point to an initialized Poly1305 context. + */ +void mbedtls_poly1305_free( mbedtls_poly1305_context *ctx ); + +/** + * \brief This function sets the one-time authentication key. + * + * \warning The key must be unique and unpredictable for each + * invocation of Poly1305. + * + * \param ctx The Poly1305 context to which the key should be bound. + * This must be initialized. + * \param key The buffer containing the \c 32 Byte (\c 256 Bit) key. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx, + const unsigned char key[32] ); + +/** + * \brief This functions feeds an input buffer into an ongoing + * Poly1305 computation. + * + * It is called between \c mbedtls_cipher_poly1305_starts() and + * \c mbedtls_cipher_poly1305_finish(). + * It can be called repeatedly to process a stream of data. + * + * \param ctx The Poly1305 context to use for the Poly1305 operation. + * This must be initialized and bound to a key. + * \param ilen The length of the input data in Bytes. + * Any value is accepted. + * \param input The buffer holding the input data. + * This pointer can be \c NULL if `ilen == 0`. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx, + const unsigned char *input, + size_t ilen ); + +/** + * \brief This function generates the Poly1305 Message + * Authentication Code (MAC). + * + * \param ctx The Poly1305 context to use for the Poly1305 operation. + * This must be initialized and bound to a key. + * \param mac The buffer to where the MAC is written. This must + * be a writable buffer of length \c 16 Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_poly1305_finish( mbedtls_poly1305_context *ctx, + unsigned char mac[16] ); + +/** + * \brief This function calculates the Poly1305 MAC of the input + * buffer with the provided key. + * + * \warning The key must be unique and unpredictable for each + * invocation of Poly1305. + * + * \param key The buffer containing the \c 32 Byte (\c 256 Bit) key. + * \param ilen The length of the input data in Bytes. + * Any value is accepted. + * \param input The buffer holding the input data. + * This pointer can be \c NULL if `ilen == 0`. + * \param mac The buffer to where the MAC is written. This must be + * a writable buffer of length \c 16 Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + */ +int mbedtls_poly1305_mac( const unsigned char key[32], + const unsigned char *input, + size_t ilen, + unsigned char mac[16] ); + +#if defined(MBEDTLS_SELF_TEST) +/** + * \brief The Poly1305 checkup routine. + * + * \return \c 0 on success. + * \return \c 1 on failure. + */ +int mbedtls_poly1305_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + +#ifdef __cplusplus +} +#endif + +#endif /* MBEDTLS_POLY1305_H */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ripemd160.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ripemd160.h index 3a8b50a621..b42f6d2a95 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ripemd160.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ripemd160.h @@ -33,20 +33,22 @@ #include #include +/* MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED is deprecated and should not be used. + */ #define MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED -0x0031 /**< RIPEMD160 hardware accelerator failed */ -#if !defined(MBEDTLS_RIPEMD160_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_RIPEMD160_ALT) +// Regular implementation +// + /** * \brief RIPEMD-160 context structure */ -typedef struct +typedef struct mbedtls_ripemd160_context { uint32_t total[2]; /*!< number of bytes processed */ uint32_t state[5]; /*!< intermediate digest state */ @@ -54,6 +56,10 @@ typedef struct } mbedtls_ripemd160_context; +#else /* MBEDTLS_RIPEMD160_ALT */ +#include "ripemd160.h" +#endif /* MBEDTLS_RIPEMD160_ALT */ + /** * \brief Initialize RIPEMD-160 context * @@ -178,18 +184,6 @@ MBEDTLS_DEPRECATED void mbedtls_ripemd160_process( #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_RIPEMD160_ALT */ -#include "ripemd160_alt.h" -#endif /* MBEDTLS_RIPEMD160_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief Output = RIPEMD-160( input buffer ) * @@ -225,6 +219,8 @@ MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -232,6 +228,8 @@ MBEDTLS_DEPRECATED void mbedtls_ripemd160( const unsigned char *input, */ int mbedtls_ripemd160_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/rsa.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/rsa.h index 5548f3c127..906c427332 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/rsa.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/rsa.h @@ -1,11 +1,12 @@ /** * \file rsa.h * - * \brief The RSA public-key cryptosystem. + * \brief This file provides an API for the RSA public-key cryptosystem. * - * For more information, see Public-Key Cryptography Standards (PKCS) - * #1 v1.5: RSA Encryption and Public-Key Cryptography Standards - * (PKCS) #1 v2.1: RSA Cryptography Specifications. + * The RSA public-key cryptosystem is defined in Public-Key + * Cryptography Standards (PKCS) #1 v1.5: RSA Encryption + * and Public-Key Cryptography Standards (PKCS) #1 v2.1: + * RSA Cryptography Specifications. * */ /* @@ -54,7 +55,12 @@ #define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380 /**< The PKCS#1 verification failed. */ #define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400 /**< The output buffer for decryption is not large enough. */ #define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480 /**< The random generator failed to generate non-zeros. */ + +/* MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION is deprecated and should not be used. + */ #define MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION -0x4500 /**< The implementation does not offer the requested operation, for example, because of security violations or lack of functionality. */ + +/* MBEDTLS_ERR_RSA_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_RSA_HW_ACCEL_FAILED -0x4580 /**< RSA hardware accelerator failed. */ /* @@ -63,8 +69,8 @@ #define MBEDTLS_RSA_PUBLIC 0 /**< Request private key operation. */ #define MBEDTLS_RSA_PRIVATE 1 /**< Request public key operation. */ -#define MBEDTLS_RSA_PKCS_V15 0 /**< Use PKCS-1 v1.5 encoding. */ -#define MBEDTLS_RSA_PKCS_V21 1 /**< Use PKCS-1 v2.1 encoding. */ +#define MBEDTLS_RSA_PKCS_V15 0 /**< Use PKCS#1 v1.5 encoding. */ +#define MBEDTLS_RSA_PKCS_V21 1 /**< Use PKCS#1 v2.1 encoding. */ #define MBEDTLS_RSA_SIGN 1 /**< Identifier for RSA signature operations. */ #define MBEDTLS_RSA_CRYPT 2 /**< Identifier for RSA encryption and decryption operations. */ @@ -76,14 +82,14 @@ * eg for alternative (PKCS#11) RSA implemenations in the PK layers. */ -#if !defined(MBEDTLS_RSA_ALT) -// Regular implementation -// - #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_RSA_ALT) +// Regular implementation +// + /** * \brief The RSA context structure. * @@ -91,29 +97,29 @@ extern "C" { * is deprecated. All manipulation should instead be done through * the public interface functions. */ -typedef struct +typedef struct mbedtls_rsa_context { int ver; /*!< Always 0.*/ size_t len; /*!< The size of \p N in Bytes. */ - mbedtls_mpi N; /*!< The public modulus. */ - mbedtls_mpi E; /*!< The public exponent. */ + mbedtls_mpi N; /*!< The public modulus. */ + mbedtls_mpi E; /*!< The public exponent. */ - mbedtls_mpi D; /*!< The private exponent. */ - mbedtls_mpi P; /*!< The first prime factor. */ - mbedtls_mpi Q; /*!< The second prime factor. */ + mbedtls_mpi D; /*!< The private exponent. */ + mbedtls_mpi P; /*!< The first prime factor. */ + mbedtls_mpi Q; /*!< The second prime factor. */ - mbedtls_mpi DP; /*!< \p D % (P - 1) */ - mbedtls_mpi DQ; /*!< \p D % (Q - 1) */ - mbedtls_mpi QP; /*!< 1 / (Q % P) */ + mbedtls_mpi DP; /*!< D % (P - 1). */ + mbedtls_mpi DQ; /*!< D % (Q - 1). */ + mbedtls_mpi QP; /*!< 1 / (Q % P). */ - mbedtls_mpi RN; /*!< cached R^2 mod \p N */ + mbedtls_mpi RN; /*!< cached R^2 mod N. */ - mbedtls_mpi RP; /*!< cached R^2 mod \p P */ - mbedtls_mpi RQ; /*!< cached R^2 mod \p Q */ + mbedtls_mpi RP; /*!< cached R^2 mod P. */ + mbedtls_mpi RQ; /*!< cached R^2 mod Q. */ - mbedtls_mpi Vi; /*!< The cached blinding value. */ - mbedtls_mpi Vf; /*!< The cached un-blinding value. */ + mbedtls_mpi Vi; /*!< The cached blinding value. */ + mbedtls_mpi Vf; /*!< The cached un-blinding value. */ int padding; /*!< Selects padding mode: #MBEDTLS_RSA_PKCS_V15 for 1.5 padding and @@ -128,18 +134,16 @@ typedef struct } mbedtls_rsa_context; +#else /* MBEDTLS_RSA_ALT */ +#include "rsa_alt.h" +#endif /* MBEDTLS_RSA_ALT */ + /** * \brief This function initializes an RSA context. * * \note Set padding to #MBEDTLS_RSA_PKCS_V21 for the RSAES-OAEP * encryption scheme and the RSASSA-PSS signature scheme. * - * \param ctx The RSA context to initialize. - * \param padding Selects padding mode: #MBEDTLS_RSA_PKCS_V15 or - * #MBEDTLS_RSA_PKCS_V21. - * \param hash_id The hash identifier of #mbedtls_md_type_t type, if - * \p padding is #MBEDTLS_RSA_PKCS_V21. - * * \note The \p hash_id parameter is ignored when using * #MBEDTLS_RSA_PKCS_V15 padding. * @@ -153,22 +157,22 @@ mbedtls_rsa_context; * encryption. For PSS signatures, it is always used for * making signatures, but can be overriden for verifying them. * If set to #MBEDTLS_MD_NONE, it is always overriden. + * + * \param ctx The RSA context to initialize. This must not be \c NULL. + * \param padding The padding mode to use. This must be either + * #MBEDTLS_RSA_PKCS_V15 or #MBEDTLS_RSA_PKCS_V21. + * \param hash_id The hash identifier of ::mbedtls_md_type_t type, if + * \p padding is #MBEDTLS_RSA_PKCS_V21. It is unused + * otherwise. */ void mbedtls_rsa_init( mbedtls_rsa_context *ctx, int padding, - int hash_id); + int hash_id ); /** * \brief This function imports a set of core parameters into an * RSA context. * - * \param ctx The initialized RSA context to store the parameters in. - * \param N The RSA modulus, or NULL. - * \param P The first prime factor of \p N, or NULL. - * \param Q The second prime factor of \p N, or NULL. - * \param D The private exponent, or NULL. - * \param E The public exponent, or NULL. - * * \note This function can be called multiple times for successive * imports, if the parameters are not simultaneously present. * @@ -184,7 +188,15 @@ void mbedtls_rsa_init( mbedtls_rsa_context *ctx, * \note The imported parameters are copied and need not be preserved * for the lifetime of the RSA context being set up. * - * \return \c 0 on success, or a non-zero error code on failure. + * \param ctx The initialized RSA context to store the parameters in. + * \param N The RSA modulus. This may be \c NULL. + * \param P The first prime factor of \p N. This may be \c NULL. + * \param Q The second prime factor of \p N. This may be \c NULL. + * \param D The private exponent. This may be \c NULL. + * \param E The public exponent. This may be \c NULL. + * + * \return \c 0 on success. + * \return A non-zero error code on failure. */ int mbedtls_rsa_import( mbedtls_rsa_context *ctx, const mbedtls_mpi *N, @@ -195,18 +207,6 @@ int mbedtls_rsa_import( mbedtls_rsa_context *ctx, * \brief This function imports core RSA parameters, in raw big-endian * binary format, into an RSA context. * - * \param ctx The initialized RSA context to store the parameters in. - * \param N The RSA modulus, or NULL. - * \param N_len The Byte length of \p N, ignored if \p N == NULL. - * \param P The first prime factor of \p N, or NULL. - * \param P_len The Byte length of \p P, ignored if \p P == NULL. - * \param Q The second prime factor of \p N, or NULL. - * \param Q_len The Byte length of \p Q, ignored if \p Q == NULL. - * \param D The private exponent, or NULL. - * \param D_len The Byte length of \p D, ignored if \p D == NULL. - * \param E The public exponent, or NULL. - * \param E_len The Byte length of \p E, ignored if \p E == NULL. - * * \note This function can be called multiple times for successive * imports, if the parameters are not simultaneously present. * @@ -222,7 +222,20 @@ int mbedtls_rsa_import( mbedtls_rsa_context *ctx, * \note The imported parameters are copied and need not be preserved * for the lifetime of the RSA context being set up. * - * \return \c 0 on success, or a non-zero error code on failure. + * \param ctx The initialized RSA context to store the parameters in. + * \param N The RSA modulus. This may be \c NULL. + * \param N_len The Byte length of \p N; it is ignored if \p N == NULL. + * \param P The first prime factor of \p N. This may be \c NULL. + * \param P_len The Byte length of \p P; it ns ignored if \p P == NULL. + * \param Q The second prime factor of \p N. This may be \c NULL. + * \param Q_len The Byte length of \p Q; it is ignored if \p Q == NULL. + * \param D The private exponent. This may be \c NULL. + * \param D_len The Byte length of \p D; it is ignored if \p D == NULL. + * \param E The public exponent. This may be \c NULL. + * \param E_len The Byte length of \p E; it is ignored if \p E == NULL. + * + * \return \c 0 on success. + * \return A non-zero error code on failure. */ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx, unsigned char const *N, size_t N_len, @@ -250,17 +263,18 @@ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx, * the RSA context can be used for RSA operations without * the risk of failure or crash. * - * \param ctx The initialized RSA context holding imported parameters. - * - * \return \c 0 on success, or #MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the - * attempted derivations failed. - * * \warning This function need not perform consistency checks * for the imported parameters. In particular, parameters that * are not needed by the implementation might be silently * discarded and left unchecked. To check the consistency * of the key material, see mbedtls_rsa_check_privkey(). * + * \param ctx The initialized RSA context holding imported parameters. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_RSA_BAD_INPUT_DATA if the attempted derivations + * failed. + * */ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ); @@ -273,7 +287,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ); * zero Bytes. * * Possible reasons for returning - * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION:
    + * #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED:
      *
    • An alternative RSA implementation is in use, which * stores the key externally, and either cannot or should * not export it into RAM.
    • @@ -286,17 +300,22 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ); * the RSA context stays intact and remains usable. * * \param ctx The initialized RSA context. - * \param N The MPI to hold the RSA modulus, or NULL. - * \param P The MPI to hold the first prime factor of \p N, or NULL. - * \param Q The MPI to hold the second prime factor of \p N, or NULL. - * \param D The MPI to hold the private exponent, or NULL. - * \param E The MPI to hold the public exponent, or NULL. - * - * \return \c 0 on success, - * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION if exporting the + * \param N The MPI to hold the RSA modulus. + * This may be \c NULL if this field need not be exported. + * \param P The MPI to hold the first prime factor of \p N. + * This may be \c NULL if this field need not be exported. + * \param Q The MPI to hold the second prime factor of \p N. + * This may be \c NULL if this field need not be exported. + * \param D The MPI to hold the private exponent. + * This may be \c NULL if this field need not be exported. + * \param E The MPI to hold the public exponent. + * This may be \c NULL if this field need not be exported. + * + * \return \c 0 on success. + * \return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED if exporting the * requested parameters cannot be done due to missing - * functionality or because of security policies, - * or a non-zero return code on any other failure. + * functionality or because of security policies. + * \return A non-zero return code on any other failure. * */ int mbedtls_rsa_export( const mbedtls_rsa_context *ctx, @@ -313,7 +332,7 @@ int mbedtls_rsa_export( const mbedtls_rsa_context *ctx, * zero Bytes. * * Possible reasons for returning - * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION:
        + * #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED:
          *
        • An alternative RSA implementation is in use, which * stores the key externally, and either cannot or should * not export it into RAM.
        • @@ -324,28 +343,31 @@ int mbedtls_rsa_export( const mbedtls_rsa_context *ctx, * If the function fails due to an unsupported operation, * the RSA context stays intact and remains usable. * + * \note The length parameters are ignored if the corresponding + * buffer pointers are NULL. + * * \param ctx The initialized RSA context. - * \param N The Byte array to store the RSA modulus, or NULL. + * \param N The Byte array to store the RSA modulus, + * or \c NULL if this field need not be exported. * \param N_len The size of the buffer for the modulus. - * \param P The Byte array to hold the first prime factor of \p N, or - * NULL. + * \param P The Byte array to hold the first prime factor of \p N, + * or \c NULL if this field need not be exported. * \param P_len The size of the buffer for the first prime factor. - * \param Q The Byte array to hold the second prime factor of \p N, or - NULL. + * \param Q The Byte array to hold the second prime factor of \p N, + * or \c NULL if this field need not be exported. * \param Q_len The size of the buffer for the second prime factor. - * \param D The Byte array to hold the private exponent, or NULL. + * \param D The Byte array to hold the private exponent, + * or \c NULL if this field need not be exported. * \param D_len The size of the buffer for the private exponent. - * \param E The Byte array to hold the public exponent, or NULL. + * \param E The Byte array to hold the public exponent, + * or \c NULL if this field need not be exported. * \param E_len The size of the buffer for the public exponent. * - * \note The length fields are ignored if the corresponding - * buffer pointers are NULL. - * - * \return \c 0 on success, - * #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION if exporting the + * \return \c 0 on success. + * \return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED if exporting the * requested parameters cannot be done due to missing - * functionality or because of security policies, - * or a non-zero return code on any other failure. + * functionality or because of security policies. + * \return A non-zero return code on any other failure. */ int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx, unsigned char *N, size_t N_len, @@ -357,17 +379,21 @@ int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx, /** * \brief This function exports CRT parameters of a private RSA key. * - * \param ctx The initialized RSA context. - * \param DP The MPI to hold D modulo P-1, or NULL. - * \param DQ The MPI to hold D modulo Q-1, or NULL. - * \param QP The MPI to hold modular inverse of Q modulo P, or NULL. - * - * \return \c 0 on success, non-zero error code otherwise. - * * \note Alternative RSA implementations not using CRT-parameters * internally can implement this function based on * mbedtls_rsa_deduce_opt(). * + * \param ctx The initialized RSA context. + * \param DP The MPI to hold \c D modulo `P-1`, + * or \c NULL if it need not be exported. + * \param DQ The MPI to hold \c D modulo `Q-1`, + * or \c NULL if it need not be exported. + * \param QP The MPI to hold modular inverse of \c Q modulo \c P, + * or \c NULL if it need not be exported. + * + * \return \c 0 on success. + * \return A non-zero error code on failure. + * */ int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx, mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP ); @@ -376,13 +402,13 @@ int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx, * \brief This function sets padding for an already initialized RSA * context. See mbedtls_rsa_init() for details. * - * \param ctx The RSA context to be set. - * \param padding Selects padding mode: #MBEDTLS_RSA_PKCS_V15 or - * #MBEDTLS_RSA_PKCS_V21. + * \param ctx The initialized RSA context to be configured. + * \param padding The padding mode to use. This must be either + * #MBEDTLS_RSA_PKCS_V15 or #MBEDTLS_RSA_PKCS_V21. * \param hash_id The #MBEDTLS_RSA_PKCS_V21 hash identifier. */ void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, - int hash_id); + int hash_id ); /** * \brief This function retrieves the length of RSA modulus in Bytes. @@ -397,17 +423,20 @@ size_t mbedtls_rsa_get_len( const mbedtls_rsa_context *ctx ); /** * \brief This function generates an RSA keypair. * - * \param ctx The RSA context used to hold the key. - * \param f_rng The RNG function. - * \param p_rng The RNG parameter. - * \param nbits The size of the public key in bits. - * \param exponent The public exponent. For example, 65537. - * * \note mbedtls_rsa_init() must be called before this function, * to set up the RSA context. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - on failure. + * \param ctx The initialized RSA context used to hold the key. + * \param f_rng The RNG function to be used for key generation. + * This must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. + * This may be \c NULL if \p f_rng doesn't need a context. + * \param nbits The size of the public key in bits. + * \param exponent The public exponent to use. For example, \c 65537. + * This must be odd and greater than \c 1. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -422,10 +451,10 @@ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, * enough information is present to perform an RSA public key * operation using mbedtls_rsa_public(). * - * \param ctx The RSA context to check. + * \param ctx The initialized RSA context to check. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. * */ int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ); @@ -434,11 +463,6 @@ int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ); * \brief This function checks if a context contains an RSA private key * and perform basic consistency checks. * - * \param ctx The RSA context to check. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code on - * failure. - * * \note The consistency checks performed by this function not only * ensure that mbedtls_rsa_private() can be called successfully * on the given context, but that the various parameters are @@ -465,6 +489,11 @@ int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ); * user to ensure the trustworthiness of the source of his RSA * parameters, which goes beyond what is effectively checkable * by the library.
        + * + * \param ctx The initialized RSA context to check. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ); @@ -473,11 +502,11 @@ int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ); * * It checks each of the contexts, and makes sure they match. * - * \param pub The RSA context holding the public key. - * \param prv The RSA context holding the private key. + * \param pub The initialized RSA context holding the public key. + * \param prv The initialized RSA context holding the private key. * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv ); @@ -485,20 +514,21 @@ int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, /** * \brief This function performs an RSA public key operation. * - * \param ctx The RSA context. - * \param input The input buffer. - * \param output The output buffer. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. + * \param ctx The initialized RSA context to use. + * \param input The input buffer. This must be a readable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * \param output The output buffer. This must be a writable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. * * \note This function does not handle message padding. * * \note Make sure to set \p input[0] = 0 or ensure that * input is smaller than \p N. * - * \note The input and output buffers must be large - * enough. For example, 128 Bytes if RSA-1024 is used. + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_public( mbedtls_rsa_context *ctx, const unsigned char *input, @@ -507,18 +537,6 @@ int mbedtls_rsa_public( mbedtls_rsa_context *ctx, /** * \brief This function performs an RSA private key operation. * - * \param ctx The RSA context. - * \param f_rng The RNG function. Needed for blinding. - * \param p_rng The RNG parameter. - * \param input The input buffer. - * \param output The output buffer. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The input and output buffers must be large - * enough. For example, 128 Bytes if RSA-1024 is used. - * * \note Blinding is used if and only if a PRNG is provided. * * \note If blinding is used, both the base of exponentation @@ -530,6 +548,22 @@ int mbedtls_rsa_public( mbedtls_rsa_context *ctx, * Future versions of the library may enforce the presence * of a PRNG. * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function, used for blinding. It is discouraged + * and deprecated to pass \c NULL here, in which case + * blinding will be omitted. + * \param p_rng The RNG context to pass to \p f_rng. This may be \c NULL + * if \p f_rng is \c NULL or if \p f_rng doesn't need a context. + * \param input The input buffer. This must be a readable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * \param output The output buffer. This must be a writable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. + * */ int mbedtls_rsa_private( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -544,16 +578,6 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx, * It is the generic wrapper for performing a PKCS#1 encryption * operation using the \p mode from the context. * - * - * \param ctx The RSA context. - * \param f_rng The RNG function. Needed for padding, PKCS#1 v2.1 - * encoding, and #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param ilen The length of the plaintext. - * \param input The buffer holding the data to encrypt. - * \param output The buffer used to hold the ciphertext. - * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it @@ -561,13 +585,29 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The input and output buffers must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG to use. It is mandatory for PKCS#1 v2.1 padding + * encoding, and for PKCS#1 v1.5 padding encoding when used + * with \p mode set to #MBEDTLS_RSA_PUBLIC. For PKCS#1 v1.5 + * padding encoding and \p mode set to #MBEDTLS_RSA_PRIVATE, + * it is used for blinding and should be provided in this + * case; see mbedtls_rsa_private() for more. + * \param p_rng The RNG context to be passed to \p f_rng. May be + * \c NULL if \p f_rng is \c NULL or if \p f_rng doesn't + * need a context argument. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). + * \param ilen The length of the plaintext in Bytes. + * \param input The input data to encrypt. This must be a readable + * buffer of size \p ilen Bytes. This must not be \c NULL. + * \param output The output buffer. This must be a writable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -580,15 +620,6 @@ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, * \brief This function performs a PKCS#1 v1.5 encryption operation * (RSAES-PKCS1-v1_5-ENCRYPT). * - * \param ctx The RSA context. - * \param f_rng The RNG function. Needed for padding and - * #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param ilen The length of the plaintext. - * \param input The buffer holding the data to encrypt. - * \param output The buffer used to hold the ciphertext. - * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it @@ -596,13 +627,27 @@ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The output buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function to use. It is needed for padding generation + * if \p mode is #MBEDTLS_RSA_PUBLIC. If \p mode is + * #MBEDTLS_RSA_PRIVATE (discouraged), it is used for + * blinding and should be provided; see mbedtls_rsa_private(). + * \param p_rng The RNG context to be passed to \p f_rng. This may + * be \c NULL if \p f_rng is \c NULL or if \p f_rng + * doesn't need a context argument. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). + * \param ilen The length of the plaintext in Bytes. + * \param input The input data to encrypt. This must be a readable + * buffer of size \p ilen Bytes. This must not be \c NULL. + * \param output The output buffer. This must be a writable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -615,31 +660,38 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, * \brief This function performs a PKCS#1 v2.1 OAEP encryption * operation (RSAES-OAEP-ENCRYPT). * - * \param ctx The RSA context. - * \param f_rng The RNG function. Needed for padding and PKCS#1 v2.1 - * encoding and #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. + * \note The output buffer must be as large as the size + * of ctx->N. For example, 128 Bytes if RSA-1024 is used. + * + * \deprecated It is deprecated and discouraged to call this function + * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library + * are likely to remove the \p mode argument and have it + * implicitly set to #MBEDTLS_RSA_PUBLIC. + * + * \note Alternative implementations of RSA need not support + * mode being set to #MBEDTLS_RSA_PRIVATE and might instead + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initnialized RSA context to use. + * \param f_rng The RNG function to use. This is needed for padding + * generation and must be provided. + * \param p_rng The RNG context to be passed to \p f_rng. This may + * be \c NULL if \p f_rng doesn't need a context argument. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). * \param label The buffer holding the custom label to use. - * \param label_len The length of the label. - * \param ilen The length of the plaintext. - * \param input The buffer holding the data to encrypt. - * \param output The buffer used to hold the ciphertext. - * - * \deprecated It is deprecated and discouraged to call this function - * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library - * are likely to remove the \p mode argument and have it - * implicitly set to #MBEDTLS_RSA_PUBLIC. - * - * \note Alternative implementations of RSA need not support - * mode being set to #MBEDTLS_RSA_PRIVATE and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The output buffer must be as large as the size - * of ctx->N. For example, 128 Bytes if RSA-1024 is used. + * This must be a readable buffer of length \p label_len + * Bytes. It may be \c NULL if \p label_len is \c 0. + * \param label_len The length of the label in Bytes. + * \param ilen The length of the plaintext buffer \p input in Bytes. + * \param input The input data to encrypt. This must be a readable + * buffer of size \p ilen Bytes. This must not be \c NULL. + * \param output The output buffer. This must be a writable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -657,14 +709,12 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, * It is the generic wrapper for performing a PKCS#1 decryption * operation using the \p mode from the context. * - * \param ctx The RSA context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param olen The length of the plaintext. - * \param input The buffer holding the encrypted data. - * \param output The buffer used to hold the plaintext. - * \param output_max_len The maximum length of the output buffer. + * \note The output buffer length \c output_max_len should be + * as large as the size \p ctx->len of \p ctx->N (for example, + * 128 Bytes if RSA-1024 is used) to be able to hold an + * arbitrary decrypted message. If it is not large enough to + * hold the decryption of the particular ciphertext provided, + * the function returns \c MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library @@ -673,20 +723,28 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The output buffer length \c output_max_len should be - * as large as the size \p ctx->len of \p ctx->N (for example, - * 128 Bytes if RSA-1024 is used) to be able to hold an - * arbitrary decrypted message. If it is not large enough to - * hold the decryption of the particular ciphertext provided, - * the function returns \c MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. - * - * \note The input buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. If \p mode is + * #MBEDTLS_RSA_PUBLIC, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). + * \param olen The address at which to store the length of + * the plaintext. This must not be \c NULL. + * \param input The ciphertext buffer. This must be a readable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * \param output The buffer used to hold the plaintext. This must + * be a writable buffer of length \p output_max_len Bytes. + * \param output_max_len The length in Bytes of the output buffer \p output. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -700,14 +758,12 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, * \brief This function performs a PKCS#1 v1.5 decryption * operation (RSAES-PKCS1-v1_5-DECRYPT). * - * \param ctx The RSA context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param olen The length of the plaintext. - * \param input The buffer holding the encrypted data. - * \param output The buffer to hold the plaintext. - * \param output_max_len The maximum length of the output buffer. + * \note The output buffer length \c output_max_len should be + * as large as the size \p ctx->len of \p ctx->N, for example, + * 128 Bytes if RSA-1024 is used, to be able to hold an + * arbitrary decrypted message. If it is not large enough to + * hold the decryption of the particular ciphertext provided, + * the function returns #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library @@ -716,20 +772,29 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. If \p mode is + * #MBEDTLS_RSA_PUBLIC, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). + * \param olen The address at which to store the length of + * the plaintext. This must not be \c NULL. + * \param input The ciphertext buffer. This must be a readable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * \param output The buffer used to hold the plaintext. This must + * be a writable buffer of length \p output_max_len Bytes. + * \param output_max_len The length in Bytes of the output buffer \p output. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. * - * \note The output buffer length \c output_max_len should be - * as large as the size \p ctx->len of \p ctx->N, for example, - * 128 Bytes if RSA-1024 is used, to be able to hold an - * arbitrary decrypted message. If it is not large enough to - * hold the decryption of the particular ciphertext provided, - * the function returns #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. - * - * \note The input buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. */ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -740,42 +805,50 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, size_t output_max_len ); /** - * \brief This function performs a PKCS#1 v2.1 OAEP decryption - * operation (RSAES-OAEP-DECRYPT). - * - * \param ctx The RSA context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. + * \brief This function performs a PKCS#1 v2.1 OAEP decryption + * operation (RSAES-OAEP-DECRYPT). + * + * \note The output buffer length \c output_max_len should be + * as large as the size \p ctx->len of \p ctx->N, for + * example, 128 Bytes if RSA-1024 is used, to be able to + * hold an arbitrary decrypted message. If it is not + * large enough to hold the decryption of the particular + * ciphertext provided, the function returns + * #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. + * + * \deprecated It is deprecated and discouraged to call this function + * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library + * are likely to remove the \p mode argument and have it + * implicitly set to #MBEDTLS_RSA_PRIVATE. + * + * \note Alternative implementations of RSA need not support + * mode being set to #MBEDTLS_RSA_PUBLIC and might instead + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. If \p mode is + * #MBEDTLS_RSA_PUBLIC, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). * \param label The buffer holding the custom label to use. - * \param label_len The length of the label. - * \param olen The length of the plaintext. - * \param input The buffer holding the encrypted data. - * \param output The buffer to hold the plaintext. - * \param output_max_len The maximum length of the output buffer. - * - * \deprecated It is deprecated and discouraged to call this function - * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library - * are likely to remove the \p mode argument and have it - * implicitly set to #MBEDTLS_RSA_PRIVATE. - * - * \note Alternative implementations of RSA need not support - * mode being set to #MBEDTLS_RSA_PUBLIC and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 on success, or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The output buffer length \c output_max_len should be - * as large as the size \p ctx->len of \p ctx->N, for - * example, 128 Bytes if RSA-1024 is used, to be able to - * hold an arbitrary decrypted message. If it is not - * large enough to hold the decryption of the particular - * ciphertext provided, the function returns - * #MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. - * - * \note The input buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * This must be a readable buffer of length \p label_len + * Bytes. It may be \c NULL if \p label_len is \c 0. + * \param label_len The length of the label in Bytes. + * \param olen The address at which to store the length of + * the plaintext. This must not be \c NULL. + * \param input The ciphertext buffer. This must be a readable buffer + * of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * \param output The buffer used to hold the plaintext. This must + * be a writable buffer of length \p output_max_len Bytes. + * \param output_max_len The length in Bytes of the output buffer \p output. + * + * \return \c 0 on success. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -794,16 +867,12 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, * It is the generic wrapper for performing a PKCS#1 * signature using the \p mode from the context. * - * \param ctx The RSA context. - * \param f_rng The RNG function. Needed for PKCS#1 v2.1 encoding and for - * #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param sig The buffer to hold the ciphertext. + * \note The \p sig buffer must be as large as the size + * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * + * \note For PKCS#1 v2.1 encoding, see comments on + * mbedtls_rsa_rsassa_pss_sign() for details on + * \p md_alg and \p hash_id. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library @@ -812,17 +881,33 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 if the signing operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code on failure. - * - * \note The \p sig buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. - * - * \note For PKCS#1 v2.1 encoding, see comments on - * mbedtls_rsa_rsassa_pss_sign() for details on - * \p md_alg and \p hash_id. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function to use. If the padding mode is PKCS#1 v2.1, + * this must be provided. If the padding mode is PKCS#1 v1.5 and + * \p mode is #MBEDTLS_RSA_PRIVATE, it is used for blinding + * and should be provided; see mbedtls_rsa_private() for more + * more. It is ignored otherwise. + * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL + * if \p f_rng is \c NULL or doesn't need a context argument. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * Ths is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param sig The buffer to hold the signature. This must be a writable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the signing operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -837,16 +922,6 @@ int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, * \brief This function performs a PKCS#1 v1.5 signature * operation (RSASSA-PKCS1-v1_5-SIGN). * - * \param ctx The RSA context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param sig The buffer to hold the ciphertext. - * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library * are likely to remove the \p mode argument and have it @@ -854,14 +929,32 @@ int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 if the signing operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The \p sig buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. If \p mode is + * #MBEDTLS_RSA_PUBLIC, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL + * if \p f_rng is \c NULL or doesn't need a context argument. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * Ths is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param sig The buffer to hold the signature. This must be a writable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the signing operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -876,16 +969,22 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, * \brief This function performs a PKCS#1 v2.1 PSS signature * operation (RSASSA-PSS-SIGN). * - * \param ctx The RSA context. - * \param f_rng The RNG function. Needed for PKCS#1 v2.1 encoding and for - * #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param sig The buffer to hold the ciphertext. + * \note The \p hash_id in the RSA context is the one used for the + * encoding. \p md_alg in the function call is the type of hash + * that is encoded. According to RFC-3447: Public-Key + * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography + * Specifications it is advised to keep both hashes the + * same. + * + * \note This function always uses the maximum possible salt size, + * up to the length of the payload hash. This choice of salt + * size complies with FIPS 186-4 §5.5 (e) and RFC 8017 (PKCS#1 + * v2.2) §9.1.1 step 3. Furthermore this function enforces a + * minimum salt size which is the hash size minus 2 bytes. If + * this minimum size is too large given the key size (the salt + * size, plus the hash size, plus 2 bytes must be no more than + * the key size in bytes), this function returns + * #MBEDTLS_ERR_RSA_BAD_INPUT_DATA. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PUBLIC mode. Future versions of the library @@ -894,21 +993,29 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PUBLIC and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 if the signing operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The \p sig buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. - * - * \note The \p hash_id in the RSA context is the one used for the - * encoding. \p md_alg in the function call is the type of hash - * that is encoded. According to RFC-3447: Public-Key - * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography - * Specifications it is advised to keep both hashes the - * same. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA context to use. + * \param f_rng The RNG function. It must not be \c NULL. + * \param p_rng The RNG context to be passed to \p f_rng. This may be \c NULL + * if \p f_rng doesn't need a context argument. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PRIVATE or #MBEDTLS_RSA_PUBLIC (deprecated). + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * Ths is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param sig The buffer to hold the signature. This must be a writable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the signing operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -926,15 +1033,9 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, * This is the generic wrapper for performing a PKCS#1 * verification using the mode from the context. * - * \param ctx The RSA public key context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param sig The buffer holding the ciphertext. + * \note For PKCS#1 v2.1 encoding, see comments on + * mbedtls_rsa_rsassa_pss_verify() about \p md_alg and + * \p hash_id. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library @@ -943,18 +1044,31 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 if the verify operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The \p sig buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. - * - * \note For PKCS#1 v2.1 encoding, see comments on - * mbedtls_rsa_rsassa_pss_verify() about \p md_alg and - * \p hash_id. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA public key context to use. + * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. Otherwise, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * This is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param sig The buffer holding the signature. This must be a readable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the verify operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -969,16 +1083,6 @@ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, * \brief This function performs a PKCS#1 v1.5 verification * operation (RSASSA-PKCS1-v1_5-VERIFY). * - * \param ctx The RSA public key context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param sig The buffer holding the ciphertext. - * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library * are likely to remove the \p mode argument and have it @@ -986,14 +1090,31 @@ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 if the verify operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The \p sig buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA public key context to use. + * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. Otherwise, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * This is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param sig The buffer holding the signature. This must be a readable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the verify operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -1011,15 +1132,13 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, * The hash function for the MGF mask generating function * is that specified in the RSA context. * - * \param ctx The RSA public key context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param sig The buffer holding the ciphertext. + * \note The \p hash_id in the RSA context is the one used for the + * verification. \p md_alg in the function call is the type of + * hash that is verified. According to RFC-3447: Public-Key + * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography + * Specifications it is advised to keep both hashes the + * same. If \p hash_id in the RSA context is unset, + * the \p md_alg from the function call is used. * * \deprecated It is deprecated and discouraged to call this function * in #MBEDTLS_RSA_PRIVATE mode. Future versions of the library @@ -1028,22 +1147,31 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, * * \note Alternative implementations of RSA need not support * mode being set to #MBEDTLS_RSA_PRIVATE and might instead - * return #MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION. - * - * \return \c 0 if the verify operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * - * \note The \p sig buffer must be as large as the size - * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. - * - * \note The \p hash_id in the RSA context is the one used for the - * verification. \p md_alg in the function call is the type of - * hash that is verified. According to RFC-3447: Public-Key - * Cryptography Standards (PKCS) #1 v2.1: RSA Cryptography - * Specifications it is advised to keep both hashes the - * same. If \p hash_id in the RSA context is unset, - * the \p md_alg from the function call is used. + * return #MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED. + * + * \param ctx The initialized RSA public key context to use. + * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. Otherwise, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE (deprecated). + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * This is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param sig The buffer holding the signature. This must be a readable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the verify operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -1061,27 +1189,37 @@ int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx, * The hash function for the MGF mask generating function * is that specified in \p mgf1_hash_id. * - * \param ctx The RSA public key context. - * \param f_rng The RNG function. Only needed for #MBEDTLS_RSA_PRIVATE. - * \param p_rng The RNG parameter. - * \param mode #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. - * \param md_alg The message-digest algorithm used to hash the original data. - * Use #MBEDTLS_MD_NONE for signing raw data. - * \param hashlen The length of the message digest. Only used if \p md_alg is #MBEDTLS_MD_NONE. - * \param hash The buffer holding the message digest. - * \param mgf1_hash_id The message digest used for mask generation. - * \param expected_salt_len The length of the salt used in padding. Use - * #MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length. - * \param sig The buffer holding the ciphertext. - * - * \return \c 0 if the verify operation was successful, - * or an \c MBEDTLS_ERR_RSA_XXX error code - * on failure. - * * \note The \p sig buffer must be as large as the size * of \p ctx->N. For example, 128 Bytes if RSA-1024 is used. * * \note The \p hash_id in the RSA context is ignored. + * + * \param ctx The initialized RSA public key context to use. + * \param f_rng The RNG function to use. If \p mode is #MBEDTLS_RSA_PRIVATE, + * this is used for blinding and should be provided; see + * mbedtls_rsa_private() for more. Otherwise, it is ignored. + * \param p_rng The RNG context to be passed to \p f_rng. This may be + * \c NULL if \p f_rng is \c NULL or doesn't need a context. + * \param mode The mode of operation. This must be either + * #MBEDTLS_RSA_PUBLIC or #MBEDTLS_RSA_PRIVATE. + * \param md_alg The message-digest algorithm used to hash the original data. + * Use #MBEDTLS_MD_NONE for signing raw data. + * \param hashlen The length of the message digest. + * This is only used if \p md_alg is #MBEDTLS_MD_NONE. + * \param hash The buffer holding the message digest or raw data. + * If \p md_alg is #MBEDTLS_MD_NONE, this must be a readable + * buffer of length \p hashlen Bytes. If \p md_alg is not + * #MBEDTLS_MD_NONE, it must be a readable buffer of length + * the size of the hash corresponding to \p md_alg. + * \param mgf1_hash_id The message digest used for mask generation. + * \param expected_salt_len The length of the salt used in padding. Use + * #MBEDTLS_RSA_SALT_LEN_ANY to accept any salt length. + * \param sig The buffer holding the signature. This must be a readable + * buffer of length \c ctx->len Bytes. For example, \c 256 Bytes + * for an 2048-bit RSA modulus. + * + * \return \c 0 if the verify operation was successful. + * \return An \c MBEDTLS_ERR_RSA_XXX error code on failure. */ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -1097,40 +1235,35 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx, /** * \brief This function copies the components of an RSA context. * - * \param dst The destination context. - * \param src The source context. + * \param dst The destination context. This must be initialized. + * \param src The source context. This must be initialized. * - * \return \c 0 on success, - * #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure. + * \return \c 0 on success. + * \return #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory allocation failure. */ int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src ); /** * \brief This function frees the components of an RSA key. * - * \param ctx The RSA Context to free. + * \param ctx The RSA context to free. May be \c NULL, in which case + * this function is a no-op. If it is not \c NULL, it must + * point to an initialized RSA context. */ void mbedtls_rsa_free( mbedtls_rsa_context *ctx ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_RSA_ALT */ -#include "rsa_alt.h" -#endif /* MBEDTLS_RSA_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief The RSA checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_rsa_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/sha1.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/sha1.h index 05540cde12..bb6ecf05a4 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/sha1.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/sha1.h @@ -1,7 +1,10 @@ /** * \file sha1.h * - * \brief The SHA-1 cryptographic hash function. + * \brief This file contains SHA-1 definitions and functions. + * + * The Secure Hash Algorithm 1 (SHA-1) cryptographic hash function is defined in + * FIPS 180-4: Secure Hash Standard (SHS). * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. We recommend considering stronger message @@ -37,16 +40,18 @@ #include #include +/* MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED -0x0035 /**< SHA-1 hardware accelerator failed */ - -#if !defined(MBEDTLS_SHA1_ALT) -// Regular implementation -// +#define MBEDTLS_ERR_SHA1_BAD_INPUT_DATA -0x0073 /**< SHA-1 input data was malformed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_SHA1_ALT) +// Regular implementation +// + /** * \brief The SHA-1 context structure. * @@ -55,7 +60,7 @@ extern "C" { * stronger message digests instead. * */ -typedef struct +typedef struct mbedtls_sha1_context { uint32_t total[2]; /*!< The number of Bytes processed. */ uint32_t state[5]; /*!< The intermediate digest state. */ @@ -63,40 +68,48 @@ typedef struct } mbedtls_sha1_context; +#else /* MBEDTLS_SHA1_ALT */ +#include "sha1_alt.h" +#endif /* MBEDTLS_SHA1_ALT */ + /** * \brief This function initializes a SHA-1 context. * - * \param ctx The SHA-1 context to initialize. - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param ctx The SHA-1 context to initialize. + * This must not be \c NULL. + * */ void mbedtls_sha1_init( mbedtls_sha1_context *ctx ); /** * \brief This function clears a SHA-1 context. * - * \param ctx The SHA-1 context to clear. - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param ctx The SHA-1 context to clear. This may be \c NULL, + * in which case this function does nothing. If it is + * not \c NULL, it must point to an initialized + * SHA-1 context. + * */ void mbedtls_sha1_free( mbedtls_sha1_context *ctx ); /** * \brief This function clones the state of a SHA-1 context. * - * \param dst The destination context. - * \param src The context to clone. - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param dst The SHA-1 context to clone to. This must be initialized. + * \param src The SHA-1 context to clone from. This must be initialized. + * */ void mbedtls_sha1_clone( mbedtls_sha1_context *dst, const mbedtls_sha1_context *src ); @@ -104,14 +117,15 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst, /** * \brief This function starts a SHA-1 checksum calculation. * - * \param ctx The context to initialize. - * - * \return \c 0 if successful - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param ctx The SHA-1 context to initialize. This must be initialized. + * + * \return \c 0 on success. + * \return A negative error code on failure. + * */ int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ); @@ -119,16 +133,18 @@ int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ); * \brief This function feeds an input buffer into an ongoing SHA-1 * checksum calculation. * - * \param ctx The SHA-1 context. - * \param input The buffer holding the input data. - * \param ilen The length of the input data. - * - * \return \c 0 if successful - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param ctx The SHA-1 context. This must be initialized + * and have a hash operation started. + * \param input The buffer holding the input data. + * This must be a readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data \p input in Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, const unsigned char *input, @@ -138,31 +154,35 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, * \brief This function finishes the SHA-1 operation, and writes * the result to the output buffer. * - * \param ctx The SHA-1 context. - * \param output The SHA-1 checksum result. - * - * \return \c 0 if successful - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param ctx The SHA-1 context to use. This must be initialized and + * have a hash operation started. + * \param output The SHA-1 checksum result. This must be a writable + * buffer of length \c 20 Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, unsigned char output[20] ); /** - * \brief SHA-1 process data block (internal use only) - * - * \param ctx SHA-1 context - * \param data The data block being processed. - * - * \return \c 0 if successful + * \brief SHA-1 process data block (internal use only). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param ctx The SHA-1 context to use. This must be initialized. + * \param data The data block being processed. This must be a + * readable buffer of length \c 64 Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + * */ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] ); @@ -174,65 +194,71 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, #define MBEDTLS_DEPRECATED #endif /** - * \brief SHA-1 context setup - * - * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0 - * - * \param ctx The SHA-1 context to be initialized. + * \brief This function starts a SHA-1 checksum calculation. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \deprecated Superseded by mbedtls_sha1_starts_ret() in 2.7.0. + * + * \param ctx The SHA-1 context to initialize. This must be initialized. + * */ MBEDTLS_DEPRECATED void mbedtls_sha1_starts( mbedtls_sha1_context *ctx ); /** - * \brief SHA-1 process buffer - * - * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0 - * - * \param ctx The SHA-1 context. - * \param input The buffer holding the input data. - * \param ilen The length of the input data. + * \brief This function feeds an input buffer into an ongoing SHA-1 + * checksum calculation. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \deprecated Superseded by mbedtls_sha1_update_ret() in 2.7.0. + * + * \param ctx The SHA-1 context. This must be initialized and + * have a hash operation started. + * \param input The buffer holding the input data. + * This must be a readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data \p input in Bytes. + * */ MBEDTLS_DEPRECATED void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen ); /** - * \brief SHA-1 final digest - * - * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0 - * - * \param ctx The SHA-1 context. - * \param output The SHA-1 checksum result. + * \brief This function finishes the SHA-1 operation, and writes + * the result to the output buffer. * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \deprecated Superseded by mbedtls_sha1_finish_ret() in 2.7.0. + * + * \param ctx The SHA-1 context. This must be initialized and + * have a hash operation started. + * \param output The SHA-1 checksum result. + * This must be a writable buffer of length \c 20 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] ); /** - * \brief SHA-1 process data block (internal use only) - * - * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0 - * - * \param ctx The SHA-1 context. - * \param data The data block being processed. + * \brief SHA-1 process data block (internal use only). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \deprecated Superseded by mbedtls_internal_sha1_process() in 2.7.0. + * + * \param ctx The SHA-1 context. This must be initialized. + * \param data The data block being processed. + * This must be a readable buffer of length \c 64 bytes. + * */ MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[64] ); @@ -240,18 +266,6 @@ MBEDTLS_DEPRECATED void mbedtls_sha1_process( mbedtls_sha1_context *ctx, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_SHA1_ALT */ -#include "sha1_alt.h" -#endif /* MBEDTLS_SHA1_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief This function calculates the SHA-1 checksum of a buffer. * @@ -261,16 +275,19 @@ extern "C" { * The SHA-1 result is calculated as * output = SHA-1(input buffer). * - * \param input The buffer holding the input data. - * \param ilen The length of the input data. - * \param output The SHA-1 checksum result. - * - * \return \c 0 if successful - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \param input The buffer holding the input data. + * This must be a readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data \p input in Bytes. + * \param output The SHA-1 checksum result. + * This must be a writable buffer of length \c 20 Bytes. + * + * \return \c 0 on success. + * \return A negative error code on failure. + * */ int mbedtls_sha1_ret( const unsigned char *input, size_t ilen, @@ -283,18 +300,26 @@ int mbedtls_sha1_ret( const unsigned char *input, #define MBEDTLS_DEPRECATED #endif /** - * \brief Output = SHA-1( input buffer ) + * \brief This function calculates the SHA-1 checksum of a buffer. * - * \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0 + * The function allocates the context, performs the + * calculation, and frees the context. * - * \param input The buffer holding the input data. - * \param ilen The length of the input data. - * \param output The SHA-1 checksum result. + * The SHA-1 result is calculated as + * output = SHA-1(input buffer). * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \deprecated Superseded by mbedtls_sha1_ret() in 2.7.0 + * + * \param input The buffer holding the input data. + * This must be a readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data \p input in Bytes. + * \param output The SHA-1 checksum result. This must be a writable + * buffer of size \c 20 Bytes. + * */ MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input, size_t ilen, @@ -303,18 +328,23 @@ MBEDTLS_DEPRECATED void mbedtls_sha1( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief The SHA-1 checkup routine. * - * \return \c 0 on success, or \c 1 on failure. - * * \warning SHA-1 is considered a weak message digest and its use * constitutes a security risk. We recommend considering * stronger message digests instead. * + * \return \c 0 on success. + * \return \c 1 on failure. + * */ int mbedtls_sha1_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/sha256.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/sha256.h index ffb16c277a..d64739820c 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/sha256.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/sha256.h @@ -1,7 +1,10 @@ /** * \file sha256.h * - * \brief The SHA-224 and SHA-256 cryptographic hash function. + * \brief This file contains SHA-224 and SHA-256 definitions and functions. + * + * The Secure Hash Algorithms 224 and 256 (SHA-224 and SHA-256) cryptographic + * hash functions are defined in FIPS 180-4: Secure Hash Standard (SHS). */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved @@ -33,16 +36,18 @@ #include #include +/* MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED -0x0037 /**< SHA-256 hardware accelerator failed */ - -#if !defined(MBEDTLS_SHA256_ALT) -// Regular implementation -// +#define MBEDTLS_ERR_SHA256_BAD_INPUT_DATA -0x0074 /**< SHA-256 input data was malformed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_SHA256_ALT) +// Regular implementation +// + /** * \brief The SHA-256 context structure. * @@ -50,36 +55,41 @@ extern "C" { * checksum calculations. The choice between these two is * made in the call to mbedtls_sha256_starts_ret(). */ -typedef struct +typedef struct mbedtls_sha256_context { uint32_t total[2]; /*!< The number of Bytes processed. */ uint32_t state[8]; /*!< The intermediate digest state. */ unsigned char buffer[64]; /*!< The data block being processed. */ - int is224; /*!< Determines which function to use. -
        • 0: Use SHA-256.
        • -
        • 1: Use SHA-224.
        */ + int is224; /*!< Determines which function to use: + 0: Use SHA-256, or 1: Use SHA-224. */ } mbedtls_sha256_context; +#else /* MBEDTLS_SHA256_ALT */ +#include "sha256_alt.h" +#endif /* MBEDTLS_SHA256_ALT */ + /** * \brief This function initializes a SHA-256 context. * - * \param ctx The SHA-256 context to initialize. + * \param ctx The SHA-256 context to initialize. This must not be \c NULL. */ void mbedtls_sha256_init( mbedtls_sha256_context *ctx ); /** * \brief This function clears a SHA-256 context. * - * \param ctx The SHA-256 context to clear. + * \param ctx The SHA-256 context to clear. This may be \c NULL, in which + * case this function returns immediately. If it is not \c NULL, + * it must point to an initialized SHA-256 context. */ void mbedtls_sha256_free( mbedtls_sha256_context *ctx ); /** * \brief This function clones the state of a SHA-256 context. * - * \param dst The destination context. - * \param src The context to clone. + * \param dst The destination context. This must be initialized. + * \param src The context to clone. This must be initialized. */ void mbedtls_sha256_clone( mbedtls_sha256_context *dst, const mbedtls_sha256_context *src ); @@ -88,12 +98,12 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst, * \brief This function starts a SHA-224 or SHA-256 checksum * calculation. * - * \param ctx The context to initialize. - * \param is224 Determines which function to use. - *
        • 0: Use SHA-256.
        • - *
        • 1: Use SHA-224.
        + * \param ctx The context to use. This must be initialized. + * \param is224 This determines which function to use. This must be + * either \c 0 for SHA-256, or \c 1 for SHA-224. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 ); @@ -101,11 +111,14 @@ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 ); * \brief This function feeds an input buffer into an ongoing * SHA-256 checksum calculation. * - * \param ctx SHA-256 context - * \param input buffer holding the data - * \param ilen length of the input data + * \param ctx The SHA-256 context. This must be initialized + * and have a hash operation started. + * \param input The buffer holding the data. This must be a readable + * buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, const unsigned char *input, @@ -115,10 +128,13 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, * \brief This function finishes the SHA-256 operation, and writes * the result to the output buffer. * - * \param ctx The SHA-256 context. + * \param ctx The SHA-256 context. This must be initialized + * and have a hash operation started. * \param output The SHA-224 or SHA-256 checksum result. + * This must be a writable buffer of length \c 32 Bytes. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, unsigned char output[32] ); @@ -128,10 +144,12 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, * the ongoing SHA-256 computation. This function is for * internal use only. * - * \param ctx The SHA-256 context. - * \param data The buffer holding one block of data. + * \param ctx The SHA-256 context. This must be initialized. + * \param data The buffer holding one block of data. This must + * be a readable buffer of length \c 64 Bytes. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ); @@ -143,14 +161,14 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, #define MBEDTLS_DEPRECATED #endif /** - * \brief This function starts a SHA-256 checksum calculation. + * \brief This function starts a SHA-224 or SHA-256 checksum + * calculation. * * \deprecated Superseded by mbedtls_sha256_starts_ret() in 2.7.0. * - * \param ctx The SHA-256 context to initialize. - * \param is224 Determines which function to use. - *
        • 0: Use SHA-256.
        • - *
        • 1: Use SHA-224.
        + * \param ctx The context to use. This must be initialized. + * \param is224 Determines which function to use. This must be + * either \c 0 for SHA-256, or \c 1 for SHA-224. */ MBEDTLS_DEPRECATED void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ); @@ -161,9 +179,11 @@ MBEDTLS_DEPRECATED void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, * * \deprecated Superseded by mbedtls_sha256_update_ret() in 2.7.0. * - * \param ctx The SHA-256 context to initialize. - * \param input The buffer holding the data. - * \param ilen The length of the input data. + * \param ctx The SHA-256 context to use. This must be + * initialized and have a hash operation started. + * \param input The buffer holding the data. This must be a readable + * buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, @@ -175,8 +195,10 @@ MBEDTLS_DEPRECATED void mbedtls_sha256_update( mbedtls_sha256_context *ctx, * * \deprecated Superseded by mbedtls_sha256_finish_ret() in 2.7.0. * - * \param ctx The SHA-256 context. - * \param output The SHA-224or SHA-256 checksum result. + * \param ctx The SHA-256 context. This must be initialized and + * have a hash operation started. + * \param output The SHA-224 or SHA-256 checksum result. This must be + * a writable buffer of length \c 32 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] ); @@ -188,25 +210,15 @@ MBEDTLS_DEPRECATED void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, * * \deprecated Superseded by mbedtls_internal_sha256_process() in 2.7.0. * - * \param ctx The SHA-256 context. - * \param data The buffer holding one block of data. + * \param ctx The SHA-256 context. This must be initialized. + * \param data The buffer holding one block of data. This must be + * a readable buffer of size \c 64 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ); #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_SHA256_ALT */ -#include "sha256_alt.h" -#endif /* MBEDTLS_SHA256_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif /** * \brief This function calculates the SHA-224 or SHA-256 @@ -218,12 +230,13 @@ extern "C" { * The SHA-256 result is calculated as * output = SHA-256(input buffer). * - * \param input The buffer holding the input data. - * \param ilen The length of the input data. - * \param output The SHA-224 or SHA-256 checksum result. - * \param is224 Determines which function to use. - *
        • 0: Use SHA-256.
        • - *
        • 1: Use SHA-224.
        + * \param input The buffer holding the data. This must be a readable + * buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. + * \param output The SHA-224 or SHA-256 checksum result. This must + * be a writable buffer of length \c 32 Bytes. + * \param is224 Determines which function to use. This must be + * either \c 0 for SHA-256, or \c 1 for SHA-224. */ int mbedtls_sha256_ret( const unsigned char *input, size_t ilen, @@ -249,12 +262,13 @@ int mbedtls_sha256_ret( const unsigned char *input, * * \deprecated Superseded by mbedtls_sha256_ret() in 2.7.0. * - * \param input The buffer holding the data. - * \param ilen The length of the input data. - * \param output The SHA-224 or SHA-256 checksum result. - * \param is224 Determines which function to use. - *
        • 0: Use SHA-256.
        • - *
        • 1: Use SHA-224.
        + * \param input The buffer holding the data. This must be a readable + * buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. + * \param output The SHA-224 or SHA-256 checksum result. This must be + * a writable buffer of length \c 32 Bytes. + * \param is224 Determines which function to use. This must be either + * \c 0 for SHA-256, or \c 1 for SHA-224. */ MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input, size_t ilen, @@ -264,13 +278,18 @@ MBEDTLS_DEPRECATED void mbedtls_sha256( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_SELF_TEST) + /** * \brief The SHA-224 and SHA-256 checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_sha256_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/sha512.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/sha512.h index 8404a2d599..c06ceed1d1 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/sha512.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/sha512.h @@ -1,7 +1,9 @@ /** * \file sha512.h + * \brief This file contains SHA-384 and SHA-512 definitions and functions. * - * \brief The SHA-384 and SHA-512 cryptographic hash function. + * The Secure Hash Algorithms 384 and 512 (SHA-384 and SHA-512) cryptographic + * hash functions are defined in FIPS 180-4: Secure Hash Standard (SHS). */ /* * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved @@ -33,16 +35,18 @@ #include #include +/* MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED is deprecated and should not be used. */ #define MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED -0x0039 /**< SHA-512 hardware accelerator failed */ - -#if !defined(MBEDTLS_SHA512_ALT) -// Regular implementation -// +#define MBEDTLS_ERR_SHA512_BAD_INPUT_DATA -0x0075 /**< SHA-512 input data was malformed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_SHA512_ALT) +// Regular implementation +// + /** * \brief The SHA-512 context structure. * @@ -50,36 +54,43 @@ extern "C" { * checksum calculations. The choice between these two is * made in the call to mbedtls_sha512_starts_ret(). */ -typedef struct +typedef struct mbedtls_sha512_context { uint64_t total[2]; /*!< The number of Bytes processed. */ uint64_t state[8]; /*!< The intermediate digest state. */ unsigned char buffer[128]; /*!< The data block being processed. */ - int is384; /*!< Determines which function to use. - *
        • 0: Use SHA-512.
        • - *
        • 1: Use SHA-384.
        */ + int is384; /*!< Determines which function to use: + 0: Use SHA-512, or 1: Use SHA-384. */ } mbedtls_sha512_context; +#else /* MBEDTLS_SHA512_ALT */ +#include "sha512_alt.h" +#endif /* MBEDTLS_SHA512_ALT */ + /** * \brief This function initializes a SHA-512 context. * - * \param ctx The SHA-512 context to initialize. + * \param ctx The SHA-512 context to initialize. This must + * not be \c NULL. */ void mbedtls_sha512_init( mbedtls_sha512_context *ctx ); /** * \brief This function clears a SHA-512 context. * - * \param ctx The SHA-512 context to clear. + * \param ctx The SHA-512 context to clear. This may be \c NULL, + * in which case this function does nothing. If it + * is not \c NULL, it must point to an initialized + * SHA-512 context. */ void mbedtls_sha512_free( mbedtls_sha512_context *ctx ); /** * \brief This function clones the state of a SHA-512 context. * - * \param dst The destination context. - * \param src The context to clone. + * \param dst The destination context. This must be initialized. + * \param src The context to clone. This must be initialized. */ void mbedtls_sha512_clone( mbedtls_sha512_context *dst, const mbedtls_sha512_context *src ); @@ -88,12 +99,12 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst, * \brief This function starts a SHA-384 or SHA-512 checksum * calculation. * - * \param ctx The SHA-512 context to initialize. - * \param is384 Determines which function to use. - *
        • 0: Use SHA-512.
        • - *
        • 1: Use SHA-384.
        + * \param ctx The SHA-512 context to use. This must be initialized. + * \param is384 Determines which function to use. This must be + * either \c for SHA-512, or \c 1 for SHA-384. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 ); @@ -101,11 +112,14 @@ int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 ); * \brief This function feeds an input buffer into an ongoing * SHA-512 checksum calculation. * - * \param ctx The SHA-512 context. - * \param input The buffer holding the input data. - * \param ilen The length of the input data. + * \param ctx The SHA-512 context. This must be initialized + * and have a hash operation started. + * \param input The buffer holding the input data. This must + * be a readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, const unsigned char *input, @@ -116,10 +130,13 @@ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, * the result to the output buffer. This function is for * internal use only. * - * \param ctx The SHA-512 context. + * \param ctx The SHA-512 context. This must be initialized + * and have a hash operation started. * \param output The SHA-384 or SHA-512 checksum result. + * This must be a writable buffer of length \c 64 Bytes. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, unsigned char output[64] ); @@ -128,10 +145,12 @@ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, * \brief This function processes a single data block within * the ongoing SHA-512 computation. * - * \param ctx The SHA-512 context. - * \param data The buffer holding one block of data. + * \param ctx The SHA-512 context. This must be initialized. + * \param data The buffer holding one block of data. This + * must be a readable buffer of length \c 128 Bytes. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] ); @@ -147,10 +166,9 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, * * \deprecated Superseded by mbedtls_sha512_starts_ret() in 2.7.0 * - * \param ctx The SHA-512 context to initialize. - * \param is384 Determines which function to use. - *
        • 0: Use SHA-512.
        • - *
        • 1: Use SHA-384.
        + * \param ctx The SHA-512 context to use. This must be initialized. + * \param is384 Determines which function to use. This must be either + * \c 0 for SHA-512 or \c 1 for SHA-384. */ MBEDTLS_DEPRECATED void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 ); @@ -159,11 +177,13 @@ MBEDTLS_DEPRECATED void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, * \brief This function feeds an input buffer into an ongoing * SHA-512 checksum calculation. * - * \deprecated Superseded by mbedtls_sha512_update_ret() in 2.7.0 + * \deprecated Superseded by mbedtls_sha512_update_ret() in 2.7.0. * - * \param ctx The SHA-512 context. - * \param input The buffer holding the data. - * \param ilen The length of the input data. + * \param ctx The SHA-512 context. This must be initialized + * and have a hash operation started. + * \param input The buffer holding the data. This must be a readable + * buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input, @@ -173,10 +193,12 @@ MBEDTLS_DEPRECATED void mbedtls_sha512_update( mbedtls_sha512_context *ctx, * \brief This function finishes the SHA-512 operation, and writes * the result to the output buffer. * - * \deprecated Superseded by mbedtls_sha512_finish_ret() in 2.7.0 + * \deprecated Superseded by mbedtls_sha512_finish_ret() in 2.7.0. * - * \param ctx The SHA-512 context. - * \param output The SHA-384 or SHA-512 checksum result. + * \param ctx The SHA-512 context. This must be initialized + * and have a hash operation started. + * \param output The SHA-384 or SHA-512 checksum result. This must + * be a writable buffer of size \c 64 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] ); @@ -186,10 +208,11 @@ MBEDTLS_DEPRECATED void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, * the ongoing SHA-512 computation. This function is for * internal use only. * - * \deprecated Superseded by mbedtls_internal_sha512_process() in 2.7.0 + * \deprecated Superseded by mbedtls_internal_sha512_process() in 2.7.0. * - * \param ctx The SHA-512 context. - * \param data The buffer holding one block of data. + * \param ctx The SHA-512 context. This must be initialized. + * \param data The buffer holding one block of data. This must be + * a readable buffer of length \c 128 Bytes. */ MBEDTLS_DEPRECATED void mbedtls_sha512_process( mbedtls_sha512_context *ctx, @@ -198,18 +221,6 @@ MBEDTLS_DEPRECATED void mbedtls_sha512_process( #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_SHA512_ALT */ -#include "sha512_alt.h" -#endif /* MBEDTLS_SHA512_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - /** * \brief This function calculates the SHA-512 or SHA-384 * checksum of a buffer. @@ -220,14 +231,16 @@ extern "C" { * The SHA-512 result is calculated as * output = SHA-512(input buffer). * - * \param input The buffer holding the input data. - * \param ilen The length of the input data. + * \param input The buffer holding the input data. This must be + * a readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. * \param output The SHA-384 or SHA-512 checksum result. - * \param is384 Determines which function to use. - *
        • 0: Use SHA-512.
        • - *
        • 1: Use SHA-384.
        + * This must be a writable buffer of length \c 64 Bytes. + * \param is384 Determines which function to use. This must be either + * \c 0 for SHA-512, or \c 1 for SHA-384. * * \return \c 0 on success. + * \return A negative error code on failure. */ int mbedtls_sha512_ret( const unsigned char *input, size_t ilen, @@ -240,6 +253,7 @@ int mbedtls_sha512_ret( const unsigned char *input, #else #define MBEDTLS_DEPRECATED #endif + /** * \brief This function calculates the SHA-512 or SHA-384 * checksum of a buffer. @@ -252,12 +266,13 @@ int mbedtls_sha512_ret( const unsigned char *input, * * \deprecated Superseded by mbedtls_sha512_ret() in 2.7.0 * - * \param input The buffer holding the data. - * \param ilen The length of the input data. - * \param output The SHA-384 or SHA-512 checksum result. - * \param is384 Determines which function to use. - *
        • 0: Use SHA-512.
        • - *
        • 1: Use SHA-384.
        + * \param input The buffer holding the data. This must be a + * readable buffer of length \p ilen Bytes. + * \param ilen The length of the input data in Bytes. + * \param output The SHA-384 or SHA-512 checksum result. This must + * be a writable buffer of length \c 64 Bytes. + * \param is384 Determines which function to use. This must be either + * \c 0 for SHA-512, or \c 1 for SHA-384. */ MBEDTLS_DEPRECATED void mbedtls_sha512( const unsigned char *input, size_t ilen, @@ -266,12 +281,17 @@ MBEDTLS_DEPRECATED void mbedtls_sha512( const unsigned char *input, #undef MBEDTLS_DEPRECATED #endif /* !MBEDTLS_DEPRECATED_REMOVED */ + +#if defined(MBEDTLS_SELF_TEST) + /** * \brief The SHA-384 or SHA-512 checkup routine. * - * \return \c 0 on success, or \c 1 on failure. + * \return \c 0 on success. + * \return \c 1 on failure. */ int mbedtls_sha512_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ #ifdef __cplusplus } diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl.h index 5593a5282a..d31f6cdd56 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl.h @@ -49,6 +49,15 @@ #endif #if defined(MBEDTLS_ZLIB_SUPPORT) + +#if defined(MBEDTLS_DEPRECATED_WARNING) +#warning "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and will be removed in the next major revision of the library" +#endif + +#if defined(MBEDTLS_DEPRECATED_REMOVED) +#error "Record compression support via MBEDTLS_ZLIB_SUPPORT is deprecated and cannot be used if MBEDTLS_DEPRECATED_REMOVED is set" +#endif + #include "zlib.h" #endif @@ -103,13 +112,17 @@ #define MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED -0x6A80 /**< DTLS client must retry for hello verification */ #define MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL -0x6A00 /**< A buffer is too small to receive or write a message */ #define MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE -0x6980 /**< None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages). */ -#define MBEDTLS_ERR_SSL_WANT_READ -0x6900 /**< Connection requires a read call. */ +#define MBEDTLS_ERR_SSL_WANT_READ -0x6900 /**< No data of requested type currently available on underlying transport. */ #define MBEDTLS_ERR_SSL_WANT_WRITE -0x6880 /**< Connection requires a write call. */ #define MBEDTLS_ERR_SSL_TIMEOUT -0x6800 /**< The operation timed out. */ #define MBEDTLS_ERR_SSL_CLIENT_RECONNECT -0x6780 /**< The client initiated a reconnect from the same port. */ #define MBEDTLS_ERR_SSL_UNEXPECTED_RECORD -0x6700 /**< Record header looks valid but is not expected. */ #define MBEDTLS_ERR_SSL_NON_FATAL -0x6680 /**< The alert message received indicates a non-fatal error. */ #define MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH -0x6600 /**< Couldn't set the hash for verifying CertificateVerify */ +#define MBEDTLS_ERR_SSL_CONTINUE_PROCESSING -0x6580 /**< Internal-only message signaling that further message-processing should be done */ +#define MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS -0x6500 /**< The asynchronous operation is not completed yet. */ +#define MBEDTLS_ERR_SSL_EARLY_MESSAGE -0x6480 /**< Internal-only message signaling that a message arrived early. */ +#define MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS -0x7000 /**< A cryptographic operation is in progress. Try again later. */ /* * Various constants @@ -209,7 +222,7 @@ #endif /* - * Maxium fragment length in bytes, + * Maximum fragment length in bytes, * determines the size of each of the two internal I/O buffers. * * Note: the RFC defines the default size of SSL / TLS messages. If you @@ -223,6 +236,22 @@ #define MBEDTLS_SSL_MAX_CONTENT_LEN 16384 /**< Size of the input / output buffer */ #endif +#if !defined(MBEDTLS_SSL_IN_CONTENT_LEN) +#define MBEDTLS_SSL_IN_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN +#endif + +#if !defined(MBEDTLS_SSL_OUT_CONTENT_LEN) +#define MBEDTLS_SSL_OUT_CONTENT_LEN MBEDTLS_SSL_MAX_CONTENT_LEN +#endif + +/* + * Maximum number of heap-allocated bytes for the purpose of + * DTLS handshake message reassembly and future message buffering. + */ +#if !defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING) +#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 +#endif + /* \} name SECTION: Module settings */ /* @@ -526,7 +555,6 @@ typedef void mbedtls_ssl_set_timer_t( void * ctx, */ typedef int mbedtls_ssl_get_timer_t( void * ctx ); - /* Defined below */ typedef struct mbedtls_ssl_session mbedtls_ssl_session; typedef struct mbedtls_ssl_context mbedtls_ssl_context; @@ -543,6 +571,218 @@ typedef struct mbedtls_ssl_key_cert mbedtls_ssl_key_cert; typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item; #endif +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +#if defined(MBEDTLS_X509_CRT_PARSE_C) +/** + * \brief Callback type: start external signature operation. + * + * This callback is called during an SSL handshake to start + * a signature decryption operation using an + * external processor. The parameter \p cert contains + * the public key; it is up to the callback function to + * determine how to access the associated private key. + * + * This function typically sends or enqueues a request, and + * does not wait for the operation to complete. This allows + * the handshake step to be non-blocking. + * + * The parameters \p ssl and \p cert are guaranteed to remain + * valid throughout the handshake. On the other hand, this + * function must save the contents of \p hash if the value + * is needed for later processing, because the \p hash buffer + * is no longer valid after this function returns. + * + * This function may call mbedtls_ssl_set_async_operation_data() + * to store an operation context for later retrieval + * by the resume or cancel callback. + * + * \note For RSA signatures, this function must produce output + * that is consistent with PKCS#1 v1.5 in the same way as + * mbedtls_rsa_pkcs1_sign(). Before the private key operation, + * apply the padding steps described in RFC 8017, section 9.2 + * "EMSA-PKCS1-v1_5" as follows. + * - If \p md_alg is #MBEDTLS_MD_NONE, apply the PKCS#1 v1.5 + * encoding, treating \p hash as the DigestInfo to be + * padded. In other words, apply EMSA-PKCS1-v1_5 starting + * from step 3, with `T = hash` and `tLen = hash_len`. + * - If `md_alg != MBEDTLS_MD_NONE`, apply the PKCS#1 v1.5 + * encoding, treating \p hash as the hash to be encoded and + * padded. In other words, apply EMSA-PKCS1-v1_5 starting + * from step 2, with `digestAlgorithm` obtained by calling + * mbedtls_oid_get_oid_by_md() on \p md_alg. + * + * \note For ECDSA signatures, the output format is the DER encoding + * `Ecdsa-Sig-Value` defined in + * [RFC 4492 section 5.4](https://tools.ietf.org/html/rfc4492#section-5.4). + * + * \param ssl The SSL connection instance. It should not be + * modified other than via + * mbedtls_ssl_set_async_operation_data(). + * \param cert Certificate containing the public key. + * In simple cases, this is one of the pointers passed to + * mbedtls_ssl_conf_own_cert() when configuring the SSL + * connection. However, if other callbacks are used, this + * property may not hold. For example, if an SNI callback + * is registered with mbedtls_ssl_conf_sni(), then + * this callback determines what certificate is used. + * \param md_alg Hash algorithm. + * \param hash Buffer containing the hash. This buffer is + * no longer valid when the function returns. + * \param hash_len Size of the \c hash buffer in bytes. + * + * \return 0 if the operation was started successfully and the SSL + * stack should call the resume callback immediately. + * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if the operation + * was started successfully and the SSL stack should return + * immediately without calling the resume callback yet. + * \return #MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH if the external + * processor does not support this key. The SSL stack will + * use the private key object instead. + * \return Any other error indicates a fatal failure and is + * propagated up the call chain. The callback should + * use \c MBEDTLS_ERR_PK_xxx error codes, and must not + * use \c MBEDTLS_ERR_SSL_xxx error codes except as + * directed in the documentation of this callback. + */ +typedef int mbedtls_ssl_async_sign_t( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *cert, + mbedtls_md_type_t md_alg, + const unsigned char *hash, + size_t hash_len ); + +/** + * \brief Callback type: start external decryption operation. + * + * This callback is called during an SSL handshake to start + * an RSA decryption operation using an + * external processor. The parameter \p cert contains + * the public key; it is up to the callback function to + * determine how to access the associated private key. + * + * This function typically sends or enqueues a request, and + * does not wait for the operation to complete. This allows + * the handshake step to be non-blocking. + * + * The parameters \p ssl and \p cert are guaranteed to remain + * valid throughout the handshake. On the other hand, this + * function must save the contents of \p input if the value + * is needed for later processing, because the \p input buffer + * is no longer valid after this function returns. + * + * This function may call mbedtls_ssl_set_async_operation_data() + * to store an operation context for later retrieval + * by the resume or cancel callback. + * + * \warning RSA decryption as used in TLS is subject to a potential + * timing side channel attack first discovered by Bleichenbacher + * in 1998. This attack can be remotely exploitable + * in practice. To avoid this attack, you must ensure that + * if the callback performs an RSA decryption, the time it + * takes to execute and return the result does not depend + * on whether the RSA decryption succeeded or reported + * invalid padding. + * + * \param ssl The SSL connection instance. It should not be + * modified other than via + * mbedtls_ssl_set_async_operation_data(). + * \param cert Certificate containing the public key. + * In simple cases, this is one of the pointers passed to + * mbedtls_ssl_conf_own_cert() when configuring the SSL + * connection. However, if other callbacks are used, this + * property may not hold. For example, if an SNI callback + * is registered with mbedtls_ssl_conf_sni(), then + * this callback determines what certificate is used. + * \param input Buffer containing the input ciphertext. This buffer + * is no longer valid when the function returns. + * \param input_len Size of the \p input buffer in bytes. + * + * \return 0 if the operation was started successfully and the SSL + * stack should call the resume callback immediately. + * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if the operation + * was started successfully and the SSL stack should return + * immediately without calling the resume callback yet. + * \return #MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH if the external + * processor does not support this key. The SSL stack will + * use the private key object instead. + * \return Any other error indicates a fatal failure and is + * propagated up the call chain. The callback should + * use \c MBEDTLS_ERR_PK_xxx error codes, and must not + * use \c MBEDTLS_ERR_SSL_xxx error codes except as + * directed in the documentation of this callback. + */ +typedef int mbedtls_ssl_async_decrypt_t( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *cert, + const unsigned char *input, + size_t input_len ); +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +/** + * \brief Callback type: resume external operation. + * + * This callback is called during an SSL handshake to resume + * an external operation started by the + * ::mbedtls_ssl_async_sign_t or + * ::mbedtls_ssl_async_decrypt_t callback. + * + * This function typically checks the status of a pending + * request or causes the request queue to make progress, and + * does not wait for the operation to complete. This allows + * the handshake step to be non-blocking. + * + * This function may call mbedtls_ssl_get_async_operation_data() + * to retrieve an operation context set by the start callback. + * It may call mbedtls_ssl_set_async_operation_data() to modify + * this context. + * + * Note that when this function returns a status other than + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS, it must free any + * resources associated with the operation. + * + * \param ssl The SSL connection instance. It should not be + * modified other than via + * mbedtls_ssl_set_async_operation_data(). + * \param output Buffer containing the output (signature or decrypted + * data) on success. + * \param output_len On success, number of bytes written to \p output. + * \param output_size Size of the \p output buffer in bytes. + * + * \return 0 if output of the operation is available in the + * \p output buffer. + * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if the operation + * is still in progress. Subsequent requests for progress + * on the SSL connection will call the resume callback + * again. + * \return Any other error means that the operation is aborted. + * The SSL handshake is aborted. The callback should + * use \c MBEDTLS_ERR_PK_xxx error codes, and must not + * use \c MBEDTLS_ERR_SSL_xxx error codes except as + * directed in the documentation of this callback. + */ +typedef int mbedtls_ssl_async_resume_t( mbedtls_ssl_context *ssl, + unsigned char *output, + size_t *output_len, + size_t output_size ); + +/** + * \brief Callback type: cancel external operation. + * + * This callback is called if an SSL connection is closed + * while an asynchronous operation is in progress. Note that + * this callback is not called if the + * ::mbedtls_ssl_async_resume_t callback has run and has + * returned a value other than + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS, since in that case + * the asynchronous operation has already completed. + * + * This function may call mbedtls_ssl_get_async_operation_data() + * to retrieve an operation context set by the start callback. + * + * \param ssl The SSL connection instance. It should not be + * modified. + */ +typedef void mbedtls_ssl_async_cancel_t( mbedtls_ssl_context *ssl ); +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + /* * This structure is used for storing current session data. */ @@ -659,6 +899,16 @@ struct mbedtls_ssl_config mbedtls_x509_crl *ca_crl; /*!< trusted CAs CRLs */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +#if defined(MBEDTLS_X509_CRT_PARSE_C) + mbedtls_ssl_async_sign_t *f_async_sign_start; /*!< start asynchronous signature operation */ + mbedtls_ssl_async_decrypt_t *f_async_decrypt_start; /*!< start asynchronous decryption operation */ +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + mbedtls_ssl_async_resume_t *f_async_resume; /*!< resume asynchronous operation */ + mbedtls_ssl_async_cancel_t *f_async_cancel; /*!< cancel asynchronous operation */ + void *p_async_config_data; /*!< Configuration data set by mbedtls_ssl_conf_async_private_cb(). */ +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + #if defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) const int *sig_hashes; /*!< allowed signature hashes */ #endif @@ -673,10 +923,18 @@ struct mbedtls_ssl_config #endif #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) - unsigned char *psk; /*!< pre-shared key */ - size_t psk_len; /*!< length of the pre-shared key */ - unsigned char *psk_identity; /*!< identity for PSK negotiation */ - size_t psk_identity_len;/*!< length of identity */ + unsigned char *psk; /*!< pre-shared key. This field should + only be set via + mbedtls_ssl_conf_psk() */ + size_t psk_len; /*!< length of the pre-shared key. This + field should only be set via + mbedtls_ssl_conf_psk() */ + unsigned char *psk_identity; /*!< identity for PSK negotiation. This + field should only be set via + mbedtls_ssl_conf_psk() */ + size_t psk_identity_len;/*!< length of identity. This field should + only be set via + mbedtls_ssl_conf_psk() */ #endif #if defined(MBEDTLS_SSL_ALPN) @@ -774,14 +1032,14 @@ struct mbedtls_ssl_context int renego_records_seen; /*!< Records since renego request, or with DTLS, number of retransmissions of request if renego_max_records is < 0 */ -#endif +#endif /* MBEDTLS_SSL_RENEGOTIATION */ int major_ver; /*!< equal to MBEDTLS_SSL_MAJOR_VERSION_3 */ int minor_ver; /*!< either 0 (SSL3) or 1 (TLS1.0) */ #if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) unsigned badmac_seen; /*!< records with a bad MAC received */ -#endif +#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ mbedtls_ssl_send_t *f_send; /*!< Callback for network send */ mbedtls_ssl_recv_t *f_recv; /*!< Callback for network receive */ @@ -837,11 +1095,11 @@ struct mbedtls_ssl_context uint16_t in_epoch; /*!< DTLS epoch for incoming records */ size_t next_record_offset; /*!< offset of the next record in datagram (equal to in_left if none) */ -#endif +#endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) uint64_t in_window_top; /*!< last validated record seq_num */ uint64_t in_window; /*!< bitmask for replay detection */ -#endif +#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ size_t in_hslen; /*!< current handshake message length, including the handshake header */ @@ -850,6 +1108,11 @@ struct mbedtls_ssl_context int keep_current_message; /*!< drop or reuse current message on next call to record layer? */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + uint8_t disable_datagram_packing; /*!< Disable packing multiple records + * within a single datagram. */ +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + /* * Record layer (outgoing data) */ @@ -864,12 +1127,18 @@ struct mbedtls_ssl_context size_t out_msglen; /*!< record header: message length */ size_t out_left; /*!< amount of data not yet written */ + unsigned char cur_out_ctr[8]; /*!< Outgoing record sequence number. */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + uint16_t mtu; /*!< path mtu, used to fragment outgoing messages */ +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + #if defined(MBEDTLS_ZLIB_SUPPORT) unsigned char *compress_buf; /*!< zlib data buffer */ -#endif +#endif /* MBEDTLS_ZLIB_SUPPORT */ #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) signed char split_done; /*!< current record already splitted? */ -#endif +#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ /* * PKI layer @@ -882,11 +1151,11 @@ struct mbedtls_ssl_context #if defined(MBEDTLS_X509_CRT_PARSE_C) char *hostname; /*!< expected peer CN for verification (and SNI if available) */ -#endif +#endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_SSL_ALPN) const char *alpn_chosen; /*!< negotiated protocol */ -#endif +#endif /* MBEDTLS_SSL_ALPN */ /* * Information for DTLS hello verify @@ -894,7 +1163,7 @@ struct mbedtls_ssl_context #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) unsigned char *cli_id; /*!< transport-level ID of the client */ size_t cli_id_len; /*!< length of cli_id */ -#endif +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */ /* * Secure renegotiation @@ -906,7 +1175,7 @@ struct mbedtls_ssl_context size_t verify_data_len; /*!< length of verify data stored */ char own_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */ char peer_verify_data[MBEDTLS_SSL_VERIFY_DATA_MAX_LEN]; /*!< previous handshake verify data */ -#endif +#endif /* MBEDTLS_SSL_RENEGOTIATION */ }; #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) @@ -1126,6 +1395,52 @@ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl, mbedtls_ssl_recv_t *f_recv, mbedtls_ssl_recv_timeout_t *f_recv_timeout ); +#if defined(MBEDTLS_SSL_PROTO_DTLS) +/** + * \brief Set the Maximum Tranport Unit (MTU). + * Special value: 0 means unset (no limit). + * This represents the maximum size of a datagram payload + * handled by the transport layer (usually UDP) as determined + * by the network link and stack. In practice, this controls + * the maximum size datagram the DTLS layer will pass to the + * \c f_send() callback set using \c mbedtls_ssl_set_bio(). + * + * \note The limit on datagram size is converted to a limit on + * record payload by subtracting the current overhead of + * encapsulation and encryption/authentication if any. + * + * \note This can be called at any point during the connection, for + * example when a Path Maximum Transfer Unit (PMTU) + * estimate becomes available from other sources, + * such as lower (or higher) protocol layers. + * + * \note This setting only controls the size of the packets we send, + * and does not restrict the size of the datagrams we're + * willing to receive. Client-side, you can request the + * server to use smaller records with \c + * mbedtls_ssl_conf_max_frag_len(). + * + * \note If both a MTU and a maximum fragment length have been + * configured (or negotiated with the peer), the resulting + * lower limit on record payload (see first note) is used. + * + * \note This can only be used to decrease the maximum size + * of datagrams (hence records, see first note) sent. It + * cannot be used to increase the maximum size of records over + * the limit set by #MBEDTLS_SSL_OUT_CONTENT_LEN. + * + * \note Values lower than the current record layer expansion will + * result in an error when trying to send data. + * + * \note Using record compression together with a non-zero MTU value + * will result in an error when trying to send data. + * + * \param ssl SSL context + * \param mtu Value of the path MTU in bytes + */ +void mbedtls_ssl_set_mtu( mbedtls_ssl_context *ssl, uint16_t mtu ); +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + /** * \brief Set the timeout period for mbedtls_ssl_read() * (Default: no timeout.) @@ -1289,6 +1604,85 @@ void mbedtls_ssl_conf_export_keys_cb( mbedtls_ssl_config *conf, void *p_export_keys ); #endif /* MBEDTLS_SSL_EXPORT_KEYS */ +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +/** + * \brief Configure asynchronous private key operation callbacks. + * + * \param conf SSL configuration context + * \param f_async_sign Callback to start a signature operation. See + * the description of ::mbedtls_ssl_async_sign_t + * for more information. This may be \c NULL if the + * external processor does not support any signature + * operation; in this case the private key object + * associated with the certificate will be used. + * \param f_async_decrypt Callback to start a decryption operation. See + * the description of ::mbedtls_ssl_async_decrypt_t + * for more information. This may be \c NULL if the + * external processor does not support any decryption + * operation; in this case the private key object + * associated with the certificate will be used. + * \param f_async_resume Callback to resume an asynchronous operation. See + * the description of ::mbedtls_ssl_async_resume_t + * for more information. This may not be \c NULL unless + * \p f_async_sign and \p f_async_decrypt are both + * \c NULL. + * \param f_async_cancel Callback to cancel an asynchronous operation. See + * the description of ::mbedtls_ssl_async_cancel_t + * for more information. This may be \c NULL if + * no cleanup is needed. + * \param config_data A pointer to configuration data which can be + * retrieved with + * mbedtls_ssl_conf_get_async_config_data(). The + * library stores this value without dereferencing it. + */ +void mbedtls_ssl_conf_async_private_cb( mbedtls_ssl_config *conf, + mbedtls_ssl_async_sign_t *f_async_sign, + mbedtls_ssl_async_decrypt_t *f_async_decrypt, + mbedtls_ssl_async_resume_t *f_async_resume, + mbedtls_ssl_async_cancel_t *f_async_cancel, + void *config_data ); + +/** + * \brief Retrieve the configuration data set by + * mbedtls_ssl_conf_async_private_cb(). + * + * \param conf SSL configuration context + * \return The configuration data set by + * mbedtls_ssl_conf_async_private_cb(). + */ +void *mbedtls_ssl_conf_get_async_config_data( const mbedtls_ssl_config *conf ); + +/** + * \brief Retrieve the asynchronous operation user context. + * + * \note This function may only be called while a handshake + * is in progress. + * + * \param ssl The SSL context to access. + * + * \return The asynchronous operation user context that was last + * set during the current handshake. If + * mbedtls_ssl_set_async_operation_data() has not yet been + * called during the current handshake, this function returns + * \c NULL. + */ +void *mbedtls_ssl_get_async_operation_data( const mbedtls_ssl_context *ssl ); + +/** + * \brief Retrieve the asynchronous operation user context. + * + * \note This function may only be called while a handshake + * is in progress. + * + * \param ssl The SSL context to access. + * \param ctx The new value of the asynchronous operation user context. + * Call mbedtls_ssl_get_async_operation_data() later during the + * same handshake to retrieve this value. + */ +void mbedtls_ssl_set_async_operation_data( mbedtls_ssl_context *ssl, + void *ctx ); +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + /** * \brief Callback type: generate a cookie * @@ -1430,6 +1824,38 @@ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limi #endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ #if defined(MBEDTLS_SSL_PROTO_DTLS) + +/** + * \brief Allow or disallow packing of multiple handshake records + * within a single datagram. + * + * \param ssl The SSL context to configure. + * \param allow_packing This determines whether datagram packing may + * be used or not. A value of \c 0 means that every + * record will be sent in a separate datagram; a + * value of \c 1 means that, if space permits, + * multiple handshake messages (including CCS) belonging to + * a single flight may be packed within a single datagram. + * + * \note This is enabled by default and should only be disabled + * for test purposes, or if datagram packing causes + * interoperability issues with peers that don't support it. + * + * \note Allowing datagram packing reduces the network load since + * there's less overhead if multiple messages share the same + * datagram. Also, it increases the handshake efficiency + * since messages belonging to a single datagram will not + * be reordered in transit, and so future message buffering + * or flight retransmission (if no buffering is used) as + * means to deal with reordering are needed less frequently. + * + * \note Application records are not affected by this option and + * are currently always sent in separate datagrams. + * + */ +void mbedtls_ssl_set_datagram_packing( mbedtls_ssl_context *ssl, + unsigned allow_packing ); + /** * \brief Set retransmit timeout values for the DTLS handshake. * (DTLS only, no effect on TLS.) @@ -1842,7 +2268,7 @@ void mbedtls_ssl_conf_sig_hashes( mbedtls_ssl_config *conf, * * \param ssl SSL context * \param hostname the server hostname, may be NULL to clear hostname - * + * \note Maximum hostname length MBEDTLS_SSL_MAX_HOST_NAME_LEN. * * \return 0 if successful, MBEDTLS_ERR_SSL_ALLOC_FAILED on @@ -2106,12 +2532,31 @@ void mbedtls_ssl_conf_cert_req_ca_list( mbedtls_ssl_config *conf, #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) /** - * \brief Set the maximum fragment length to emit and/or negotiate - * (Default: MBEDTLS_SSL_MAX_CONTENT_LEN, usually 2^14 bytes) + * \brief Set the maximum fragment length to emit and/or negotiate. + * (Typical: the smaller of #MBEDTLS_SSL_IN_CONTENT_LEN and + * #MBEDTLS_SSL_OUT_CONTENT_LEN, usually `2^14` bytes) * (Server: set maximum fragment length to emit, - * usually negotiated by the client during handshake + * usually negotiated by the client during handshake) * (Client: set maximum fragment length to emit *and* * negotiate with the server during handshake) + * (Default: #MBEDTLS_SSL_MAX_FRAG_LEN_NONE) + * + * \note On the client side, the maximum fragment length extension + * *will not* be used, unless the maximum fragment length has + * been set via this function to a value different than + * #MBEDTLS_SSL_MAX_FRAG_LEN_NONE. + * + * \note This sets the maximum length for a record's payload, + * excluding record overhead that will be added to it, see + * \c mbedtls_ssl_get_record_expansion(). + * + * \note With TLS, this currently only affects ApplicationData (sent + * with \c mbedtls_ssl_read()), not handshake messages. + * With DTLS, this affects both ApplicationData and handshake. + * + * \note For DTLS, it is also possible to set a limit for the total + * size of daragrams passed to the transport layer, including + * record overhead, see \c mbedtls_ssl_set_mtu(). * * \param conf SSL configuration * \param mfl_code Code for maximum fragment length (allowed values: @@ -2284,11 +2729,59 @@ void mbedtls_ssl_conf_renegotiation_period( mbedtls_ssl_config *conf, #endif /* MBEDTLS_SSL_RENEGOTIATION */ /** - * \brief Return the number of data bytes available to read + * \brief Check if there is data already read from the + * underlying transport but not yet processed. + * + * \param ssl SSL context + * + * \return 0 if nothing's pending, 1 otherwise. + * + * \note This is different in purpose and behaviour from + * \c mbedtls_ssl_get_bytes_avail in that it considers + * any kind of unprocessed data, not only unread + * application data. If \c mbedtls_ssl_get_bytes + * returns a non-zero value, this function will + * also signal pending data, but the converse does + * not hold. For example, in DTLS there might be + * further records waiting to be processed from + * the current underlying transport's datagram. + * + * \note If this function returns 1 (data pending), this + * does not imply that a subsequent call to + * \c mbedtls_ssl_read will provide any data; + * e.g., the unprocessed data might turn out + * to be an alert or a handshake message. + * + * \note This function is useful in the following situation: + * If the SSL/TLS module successfully returns from an + * operation - e.g. a handshake or an application record + * read - and you're awaiting incoming data next, you + * must not immediately idle on the underlying transport + * to have data ready, but you need to check the value + * of this function first. The reason is that the desired + * data might already be read but not yet processed. + * If, in contrast, a previous call to the SSL/TLS module + * returned MBEDTLS_ERR_SSL_WANT_READ, it is not necessary + * to call this function, as the latter error code entails + * that all internal data has been processed. + * + */ +int mbedtls_ssl_check_pending( const mbedtls_ssl_context *ssl ); + +/** + * \brief Return the number of application data bytes + * remaining to be read from the current record. * * \param ssl SSL context * - * \return how many bytes are available in the read buffer + * \return How many bytes are available in the application + * data record read buffer. + * + * \note When working over a datagram transport, this is + * useful to detect the current datagram's boundary + * in case \c mbedtls_ssl_read has written the maximal + * amount of data fitting into the input buffer. + * */ size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl ); @@ -2328,6 +2821,9 @@ const char *mbedtls_ssl_get_version( const mbedtls_ssl_context *ssl ); * \brief Return the (maximum) number of bytes added by the record * layer: header + encryption/MAC overhead (inc. padding) * + * \note This function is not available (always returns an error) + * when record compression is enabled. + * * \param ssl SSL context * * \return Current maximum record expansion in bytes, or @@ -2342,6 +2838,23 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ); * This is the value negotiated with peer if any, * or the locally configured value. * + * \sa mbedtls_ssl_conf_max_frag_len() + * \sa mbedtls_ssl_get_max_record_payload() + * + * \param ssl SSL context + * + * \return Current maximum fragment length. + */ +size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl ); +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +/** + * \brief Return the current maximum outgoing record payload in bytes. + * This takes into account the config.h setting \c + * MBEDTLS_SSL_OUT_CONTENT_LEN, the configured and negotiated + * max fragment length extension if used, and for DTLS the + * path MTU as configured and current record expansion. + * * \note With DTLS, \c mbedtls_ssl_write() will return an error if * called with a larger length value. * With TLS, \c mbedtls_ssl_write() will fragment the input if @@ -2349,12 +2862,19 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ); * to the caller to call \c mbedtls_ssl_write() again in * order to send the remaining bytes if any. * + * \note This function is not available (always returns an error) + * when record compression is enabled. + * + * \sa mbedtls_ssl_set_mtu() + * \sa mbedtls_ssl_get_max_frag_len() + * \sa mbedtls_ssl_get_record_expansion() + * * \param ssl SSL context * - * \return Current maximum fragment length. + * \return Current maximum payload for an outgoing record, + * or a negative error code. */ -size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl ); -#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ +int mbedtls_ssl_get_max_out_record_payload( const mbedtls_ssl_context *ssl ); #if defined(MBEDTLS_X509_CRT_PARSE_C) /** @@ -2409,21 +2929,50 @@ int mbedtls_ssl_get_session( const mbedtls_ssl_context *ssl, mbedtls_ssl_session * * \param ssl SSL context * - * \return 0 if successful, or - * MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or - * MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED (see below), or - * a specific SSL error code. - * - * \note If this function returns something other than 0 or - * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context - * becomes unusable, and you should either free it or call - * \c mbedtls_ssl_session_reset() on it before re-using it for - * a new connection; the current connection must be closed. + * \return \c 0 if successful. + * \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE + * if the handshake is incomplete and waiting for data to + * be available for reading from or writing to the underlying + * transport - in this case you must call this function again + * when the underlying transport is ready for the operation. + * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous + * operation is in progress (see + * mbedtls_ssl_conf_async_private_cb()) - in this case you + * must call this function again when the operation is ready. + * \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic + * operation is in progress (see mbedtls_ecp_set_max_ops()) - + * in this case you must call this function again to complete + * the handshake when you're done attending other tasks. + * \return #MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED if DTLS is in use + * and the client did not demonstrate reachability yet - in + * this case you must stop using the context (see below). + * \return Another SSL error code - in this case you must stop using + * the context (see below). + * + * \warning If this function returns something other than + * \c 0, + * #MBEDTLS_ERR_SSL_WANT_READ, + * #MBEDTLS_ERR_SSL_WANT_WRITE, + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, + * you must stop using the SSL context for reading or writing, + * and either free it or call \c mbedtls_ssl_session_reset() + * on it before re-using it for a new connection; the current + * connection must be closed. * * \note If DTLS is in use, then you may choose to handle - * MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging + * #MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED specially for logging * purposes, as it is an expected return value rather than an * actual error, but you still need to reset/free the context. + * + * \note Remarks regarding event-driven DTLS: + * If the function returns #MBEDTLS_ERR_SSL_WANT_READ, no datagram + * from the underlying transport layer is currently being processed, + * and it is safe to idle until the timer or the underlying transport + * signal a new event. This is not true for a successful handshake, + * in which case the datagram of the underlying transport that is + * currently being processed might or might not contain further + * DTLS records. */ int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl ); @@ -2431,20 +2980,21 @@ int mbedtls_ssl_handshake( mbedtls_ssl_context *ssl ); * \brief Perform a single step of the SSL handshake * * \note The state of the context (ssl->state) will be at - * the next state after execution of this function. Do not + * the next state after this function returns \c 0. Do not * call this function if state is MBEDTLS_SSL_HANDSHAKE_OVER. * - * \note If this function returns something other than 0 or - * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context - * becomes unusable, and you should either free it or call - * \c mbedtls_ssl_session_reset() on it before re-using it for - * a new connection; the current connection must be closed. - * * \param ssl SSL context * - * \return 0 if successful, or - * MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or - * a specific SSL error code. + * \return See mbedtls_ssl_handshake(). + * + * \warning If this function returns something other than \c 0, + * #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE, + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using + * the SSL context for reading or writing, and either free it + * or call \c mbedtls_ssl_session_reset() on it before + * re-using it for a new connection; the current connection + * must be closed. */ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ); @@ -2459,13 +3009,18 @@ int mbedtls_ssl_handshake_step( mbedtls_ssl_context *ssl ); * \param ssl SSL context * * \return 0 if successful, or any mbedtls_ssl_handshake() return - * value. + * value except #MBEDTLS_ERR_SSL_CLIENT_RECONNECT that can't + * happen during a renegotiation. + * + * \warning If this function returns something other than \c 0, + * #MBEDTLS_ERR_SSL_WANT_READ, #MBEDTLS_ERR_SSL_WANT_WRITE, + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, you must stop using + * the SSL context for reading or writing, and either free it + * or call \c mbedtls_ssl_session_reset() on it before + * re-using it for a new connection; the current connection + * must be closed. * - * \note If this function returns something other than 0 or - * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context - * becomes unusable, and you should either free it or call - * \c mbedtls_ssl_session_reset() on it before re-using it for - * a new connection; the current connection must be closed. */ int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl ); #endif /* MBEDTLS_SSL_RENEGOTIATION */ @@ -2477,32 +3032,68 @@ int mbedtls_ssl_renegotiate( mbedtls_ssl_context *ssl ); * \param buf buffer that will hold the data * \param len maximum number of bytes to read * - * \return the number of bytes read, or - * 0 for EOF, or - * MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, or - * MBEDTLS_ERR_SSL_CLIENT_RECONNECT (see below), or - * another negative error code. - * - * \note If this function returns something other than a positive - * value or MBEDTLS_ERR_SSL_WANT_READ/WRITE or - * MBEDTLS_ERR_SSL_CLIENT_RECONNECT, then the ssl context - * becomes unusable, and you should either free it or call - * \c mbedtls_ssl_session_reset() on it before re-using it for - * a new connection; the current connection must be closed. - * - * \note When this function return MBEDTLS_ERR_SSL_CLIENT_RECONNECT + * \return The (positive) number of bytes read if successful. + * \return \c 0 if the read end of the underlying transport was closed + * - in this case you must stop using the context (see below). + * \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE + * if the handshake is incomplete and waiting for data to + * be available for reading from or writing to the underlying + * transport - in this case you must call this function again + * when the underlying transport is ready for the operation. + * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous + * operation is in progress (see + * mbedtls_ssl_conf_async_private_cb()) - in this case you + * must call this function again when the operation is ready. + * \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic + * operation is in progress (see mbedtls_ecp_set_max_ops()) - + * in this case you must call this function again to complete + * the handshake when you're done attending other tasks. + * \return #MBEDTLS_ERR_SSL_CLIENT_RECONNECT if we're at the server + * side of a DTLS connection and the client is initiating a + * new connection using the same source port. See below. + * \return Another SSL error code - in this case you must stop using + * the context (see below). + * + * \warning If this function returns something other than + * a positive value, + * #MBEDTLS_ERR_SSL_WANT_READ, + * #MBEDTLS_ERR_SSL_WANT_WRITE, + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS, + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS or + * #MBEDTLS_ERR_SSL_CLIENT_RECONNECT, + * you must stop using the SSL context for reading or writing, + * and either free it or call \c mbedtls_ssl_session_reset() + * on it before re-using it for a new connection; the current + * connection must be closed. + * + * \note When this function returns #MBEDTLS_ERR_SSL_CLIENT_RECONNECT * (which can only happen server-side), it means that a client * is initiating a new connection using the same source port. * You can either treat that as a connection close and wait * for the client to resend a ClientHello, or directly * continue with \c mbedtls_ssl_handshake() with the same - * context (as it has beeen reset internally). Either way, you - * should make sure this is seen by the application as a new + * context (as it has been reset internally). Either way, you + * must make sure this is seen by the application as a new * connection: application state, if any, should be reset, and * most importantly the identity of the client must be checked * again. WARNING: not validating the identity of the client * again, or not transmitting the new identity to the * application layer, would allow authentication bypass! + * + * \note Remarks regarding event-driven DTLS: + * - If the function returns #MBEDTLS_ERR_SSL_WANT_READ, no datagram + * from the underlying transport layer is currently being processed, + * and it is safe to idle until the timer or the underlying transport + * signal a new event. + * - This function may return MBEDTLS_ERR_SSL_WANT_READ even if data was + * initially available on the underlying transport, as this data may have + * been only e.g. duplicated messages or a renegotiation request. + * Therefore, you must be prepared to receive MBEDTLS_ERR_SSL_WANT_READ even + * when reacting to an incoming-data event from the underlying transport. + * - On success, the datagram of the underlying transport that is currently + * being processed may contain further DTLS records. You should call + * \c mbedtls_ssl_check_pending to check for remaining records. + * */ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ); @@ -2519,21 +3110,39 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) * \param buf buffer holding the data * \param len how many bytes must be written * - * \return the number of bytes actually written (may be less than len), - * or MBEDTLS_ERR_SSL_WANT_WRITE or MBEDTLS_ERR_SSL_WANT_READ, - * or another negative error code. - * - * \note If this function returns something other than 0, a positive - * value or MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop - * using the SSL context for reading or writing, and either - * free it or call \c mbedtls_ssl_session_reset() on it before - * re-using it for a new connection; the current connection - * must be closed. - * - * \note When this function returns MBEDTLS_ERR_SSL_WANT_WRITE/READ, + * \return The (non-negative) number of bytes actually written if + * successful (may be less than \p len). + * \return #MBEDTLS_ERR_SSL_WANT_READ or #MBEDTLS_ERR_SSL_WANT_WRITE + * if the handshake is incomplete and waiting for data to + * be available for reading from or writing to the underlying + * transport - in this case you must call this function again + * when the underlying transport is ready for the operation. + * \return #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS if an asynchronous + * operation is in progress (see + * mbedtls_ssl_conf_async_private_cb()) - in this case you + * must call this function again when the operation is ready. + * \return #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS if a cryptographic + * operation is in progress (see mbedtls_ecp_set_max_ops()) - + * in this case you must call this function again to complete + * the handshake when you're done attending other tasks. + * \return Another SSL error code - in this case you must stop using + * the context (see below). + * + * \warning If this function returns something other than + * a non-negative value, + * #MBEDTLS_ERR_SSL_WANT_READ, + * #MBEDTLS_ERR_SSL_WANT_WRITE, + * #MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS or + * #MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS, + * you must stop using the SSL context for reading or writing, + * and either free it or call \c mbedtls_ssl_session_reset() + * on it before re-using it for a new connection; the current + * connection must be closed. + * + * \note When this function returns #MBEDTLS_ERR_SSL_WANT_WRITE/READ, * it must be called later with the *same* arguments, * until it returns a value greater that or equal to 0. When - * the function returns MBEDTLS_ERR_SSL_WANT_WRITE there may be + * the function returns #MBEDTLS_ERR_SSL_WANT_WRITE there may be * some partial data in the output buffer, however this is not * yet sent. * @@ -2561,10 +3170,10 @@ int mbedtls_ssl_write( mbedtls_ssl_context *ssl, const unsigned char *buf, size_ * \return 0 if successful, or a specific SSL error code. * * \note If this function returns something other than 0 or - * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context - * becomes unusable, and you should either free it or call - * \c mbedtls_ssl_session_reset() on it before re-using it for - * a new connection; the current connection must be closed. + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using + * the SSL context for reading or writing, and either free it or + * call \c mbedtls_ssl_session_reset() on it before re-using it + * for a new connection; the current connection must be closed. */ int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl, unsigned char level, @@ -2577,10 +3186,10 @@ int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl, * \return 0 if successful, or a specific SSL error code. * * \note If this function returns something other than 0 or - * MBEDTLS_ERR_SSL_WANT_READ/WRITE, then the ssl context - * becomes unusable, and you should either free it or call - * \c mbedtls_ssl_session_reset() on it before re-using it for - * a new connection; the current connection must be closed. + * MBEDTLS_ERR_SSL_WANT_READ/WRITE, you must stop using + * the SSL context for reading or writing, and either free it or + * call \c mbedtls_ssl_session_reset() on it before re-using it + * for a new connection; the current connection must be closed. */ int mbedtls_ssl_close_notify( mbedtls_ssl_context *ssl ); diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cache.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cache.h index ec081e6d24..52ba0948c5 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cache.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cache.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_SSL_CACHE_H #define MBEDTLS_SSL_CACHE_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "ssl.h" #if defined(MBEDTLS_THREADING_C) diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ciphersuites.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ciphersuites.h index 1d2aabc372..71053e5ba7 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ciphersuites.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ciphersuites.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_SSL_CIPHERSUITES_H #define MBEDTLS_SSL_CIPHERSUITES_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "pk.h" #include "cipher.h" #include "md.h" @@ -169,6 +175,45 @@ extern "C" { #define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256 0xC03A /**< Weak! No SSL3! */ #define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384 0xC03B /**< Weak! No SSL3! */ +#define MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256 0xC03C /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384 0xC03D /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 0xC044 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 0xC045 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 0xC048 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 0xC049 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 0xC04A /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 0xC04B /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 0xC04C /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 0xC04D /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 0xC04E /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 0xC04F /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256 0xC050 /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384 0xC051 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 0xC052 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 0xC053 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 0xC05C /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 0xC05D /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 0xC05E /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 0xC05F /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 0xC060 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 0xC061 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 0xC062 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 0xC063 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256 0xC064 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384 0xC065 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 0xC066 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 0xC067 /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 0xC068 /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 0xC069 /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256 0xC06A /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384 0xC06B /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 0xC06C /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 0xC06D /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 0xC06E /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 0xC06F /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 0xC070 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 0xC071 /**< TLS 1.2 */ + #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC072 /**< Not in SSL3! */ #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC073 /**< Not in SSL3! */ #define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC074 /**< Not in SSL3! */ @@ -232,6 +277,15 @@ extern "C" { #define MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 0xC0FF /**< experimental */ +/* RFC 7905 */ +#define MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA8 /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA9 /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 0xCCAA /**< TLS 1.2 */ +#define MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAB /**< TLS 1.2 */ +#define MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAC /**< TLS 1.2 */ +#define MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAD /**< TLS 1.2 */ +#define MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 0xCCAE /**< TLS 1.2 */ + /* Reminder: update mbedtls_ssl_premaster_secret when adding a new key exchange. * Reminder: update MBEDTLS_KEY_EXCHANGE__xxx below */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cookie.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cookie.h index 80b65bbbb9..e34760ae85 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cookie.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_cookie.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_SSL_COOKIE_H #define MBEDTLS_SSL_COOKIE_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "ssl.h" #if defined(MBEDTLS_THREADING_C) @@ -50,7 +56,7 @@ extern "C" { /** * \brief Context for the default cookie functions. */ -typedef struct +typedef struct mbedtls_ssl_cookie_ctx { mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */ #if !defined(MBEDTLS_HAVE_TIME) diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_internal.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_internal.h index 2b5a61637b..bd5ad94dbf 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_internal.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_internal.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_SSL_INTERNAL_H #define MBEDTLS_SSL_INTERNAL_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + #include "ssl.h" #include "cipher.h" @@ -93,6 +99,14 @@ #endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ +/* Shorthand for restartable ECC */ +#if defined(MBEDTLS_ECP_RESTARTABLE) && \ + defined(MBEDTLS_SSL_CLI_C) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) +#define MBEDTLS_SSL__ECP_RESTARTABLE +#endif + #define MBEDTLS_SSL_INITIAL_HANDSHAKE 0 #define MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS 1 /* In progress */ #define MBEDTLS_SSL_RENEGOTIATION_DONE 2 /* Done or aborted */ @@ -143,32 +157,76 @@ #define MBEDTLS_SSL_PADDING_ADD 0 #endif -#define MBEDTLS_SSL_PAYLOAD_LEN ( MBEDTLS_SSL_MAX_CONTENT_LEN \ - + MBEDTLS_SSL_COMPRESSION_ADD \ - + MBEDTLS_MAX_IV_LENGTH \ - + MBEDTLS_SSL_MAC_ADD \ - + MBEDTLS_SSL_PADDING_ADD \ - ) +#define MBEDTLS_SSL_PAYLOAD_OVERHEAD ( MBEDTLS_SSL_COMPRESSION_ADD + \ + MBEDTLS_MAX_IV_LENGTH + \ + MBEDTLS_SSL_MAC_ADD + \ + MBEDTLS_SSL_PADDING_ADD \ + ) + +#define MBEDTLS_SSL_IN_PAYLOAD_LEN ( MBEDTLS_SSL_PAYLOAD_OVERHEAD + \ + ( MBEDTLS_SSL_IN_CONTENT_LEN ) ) + +#define MBEDTLS_SSL_OUT_PAYLOAD_LEN ( MBEDTLS_SSL_PAYLOAD_OVERHEAD + \ + ( MBEDTLS_SSL_OUT_CONTENT_LEN ) ) + +/* The maximum number of buffered handshake messages. */ +#define MBEDTLS_SSL_MAX_BUFFERED_HS 4 + +/* Maximum length we can advertise as our max content length for + RFC 6066 max_fragment_length extension negotiation purposes + (the lesser of both sizes, if they are unequal.) + */ +#define MBEDTLS_TLS_EXT_ADV_CONTENT_LEN ( \ + (MBEDTLS_SSL_IN_CONTENT_LEN > MBEDTLS_SSL_OUT_CONTENT_LEN) \ + ? ( MBEDTLS_SSL_OUT_CONTENT_LEN ) \ + : ( MBEDTLS_SSL_IN_CONTENT_LEN ) \ + ) /* * Check that we obey the standard's message size bounds */ #if MBEDTLS_SSL_MAX_CONTENT_LEN > 16384 -#error Bad configuration - record content too large. +#error "Bad configuration - record content too large." +#endif + +#if MBEDTLS_SSL_IN_CONTENT_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN +#error "Bad configuration - incoming record content should not be larger than MBEDTLS_SSL_MAX_CONTENT_LEN." +#endif + +#if MBEDTLS_SSL_OUT_CONTENT_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN +#error "Bad configuration - outgoing record content should not be larger than MBEDTLS_SSL_MAX_CONTENT_LEN." #endif -#if MBEDTLS_SSL_PAYLOAD_LEN > 16384 + 2048 -#error Bad configuration - protected record payload too large. +#if MBEDTLS_SSL_IN_PAYLOAD_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN + 2048 +#error "Bad configuration - incoming protected record payload too large." #endif +#if MBEDTLS_SSL_OUT_PAYLOAD_LEN > MBEDTLS_SSL_MAX_CONTENT_LEN + 2048 +#error "Bad configuration - outgoing protected record payload too large." +#endif + +/* Calculate buffer sizes */ + /* Note: Even though the TLS record header is only 5 bytes long, we're internally using 8 bytes to store the implicit sequence number. */ #define MBEDTLS_SSL_HEADER_LEN 13 -#define MBEDTLS_SSL_BUFFER_LEN \ - ( ( MBEDTLS_SSL_HEADER_LEN ) + ( MBEDTLS_SSL_PAYLOAD_LEN ) ) +#define MBEDTLS_SSL_IN_BUFFER_LEN \ + ( ( MBEDTLS_SSL_HEADER_LEN ) + ( MBEDTLS_SSL_IN_PAYLOAD_LEN ) ) + +#define MBEDTLS_SSL_OUT_BUFFER_LEN \ + ( ( MBEDTLS_SSL_HEADER_LEN ) + ( MBEDTLS_SSL_OUT_PAYLOAD_LEN ) ) + +#ifdef MBEDTLS_ZLIB_SUPPORT +/* Compression buffer holds both IN and OUT buffers, so should be size of the larger */ +#define MBEDTLS_SSL_COMPRESS_BUFFER_LEN ( \ + ( MBEDTLS_SSL_IN_BUFFER_LEN > MBEDTLS_SSL_OUT_BUFFER_LEN ) \ + ? MBEDTLS_SSL_IN_BUFFER_LEN \ + : MBEDTLS_SSL_OUT_BUFFER_LEN \ + ) +#endif /* * TLS extension flags (for extensions with outgoing ServerHello content @@ -243,6 +301,18 @@ struct mbedtls_ssl_handshake_params mbedtls_x509_crl *sni_ca_crl; /*!< trusted CAs CRLs from SNI */ #endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + int ecrs_enabled; /*!< Handshake supports EC restart? */ + mbedtls_x509_crt_restart_ctx ecrs_ctx; /*!< restart context */ + enum { /* this complements ssl->state with info on intra-state operations */ + ssl_ecrs_none = 0, /*!< nothing going on (yet) */ + ssl_ecrs_crt_verify, /*!< Certificate: crt_verify() */ + ssl_ecrs_ske_start_processing, /*!< ServerKeyExchange: pk_verify() */ + ssl_ecrs_cke_ecdh_calc_secret, /*!< ClientKeyExchange: ECDH step 2 */ + ssl_ecrs_crt_vrfy_sign, /*!< CertificateVerify: pk_sign() */ + } ecrs_state; /*!< current (or last) operation */ + size_t ecrs_n; /*!< place for saving a length */ +#endif #if defined(MBEDTLS_SSL_PROTO_DTLS) unsigned int out_msg_seq; /*!< Outgoing handshake sequence number */ unsigned int in_msg_seq; /*!< Incoming handshake sequence number */ @@ -252,18 +322,45 @@ struct mbedtls_ssl_handshake_params unsigned char verify_cookie_len; /*!< Cli: cookie length Srv: flag for sending a cookie */ - unsigned char *hs_msg; /*!< Reassembled handshake message */ - uint32_t retransmit_timeout; /*!< Current value of timeout */ unsigned char retransmit_state; /*!< Retransmission state */ - mbedtls_ssl_flight_item *flight; /*!< Current outgoing flight */ - mbedtls_ssl_flight_item *cur_msg; /*!< Current message in flight */ + mbedtls_ssl_flight_item *flight; /*!< Current outgoing flight */ + mbedtls_ssl_flight_item *cur_msg; /*!< Current message in flight */ + unsigned char *cur_msg_p; /*!< Position in current message */ unsigned int in_flight_start_seq; /*!< Minimum message sequence in the flight being received */ mbedtls_ssl_transform *alt_transform_out; /*!< Alternative transform for resending messages */ unsigned char alt_out_ctr[8]; /*!< Alternative record epoch/counter for resending messages */ + + struct + { + size_t total_bytes_buffered; /*!< Cumulative size of heap allocated + * buffers used for message buffering. */ + + uint8_t seen_ccs; /*!< Indicates if a CCS message has + * been seen in the current flight. */ + + struct mbedtls_ssl_hs_buffer + { + unsigned is_valid : 1; + unsigned is_fragmented : 1; + unsigned is_complete : 1; + unsigned char *data; + size_t data_len; + } hs[MBEDTLS_SSL_MAX_BUFFERED_HS]; + + struct + { + unsigned char *data; + size_t len; + unsigned epoch; + } future_record; + + } buffering; + + uint16_t mtu; /*!< Handshake mtu, used to fragment outgoing messages */ #endif /* MBEDTLS_SSL_PROTO_DTLS */ /* @@ -307,8 +404,23 @@ struct mbedtls_ssl_handshake_params #if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) int extended_ms; /*!< use Extended Master Secret? */ #endif + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + unsigned int async_in_progress : 1; /*!< an asynchronous operation is in progress */ +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + /** Asynchronous operation context. This field is meant for use by the + * asynchronous operation callbacks (mbedtls_ssl_config::f_async_sign_start, + * mbedtls_ssl_config::f_async_decrypt_start, + * mbedtls_ssl_config::f_async_resume, mbedtls_ssl_config::f_async_cancel). + * The library does not use it internally. */ + void *user_async_ctx; +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ }; +typedef struct mbedtls_ssl_hs_buffer mbedtls_ssl_hs_buffer; + /* * This structure contains a full set of runtime transform parameters * either in negotiation or active. @@ -410,9 +522,9 @@ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ); * \brief Free referenced items in an SSL handshake context and clear * memory * - * \param handshake SSL handshake context + * \param ssl SSL context */ -void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake ); +void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ); @@ -423,7 +535,6 @@ int mbedtls_ssl_send_fatal_handshake_failure( mbedtls_ssl_context *ssl ); void mbedtls_ssl_reset_checksum( mbedtls_ssl_context *ssl ); int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ); -int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ); int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ); int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ); void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ); @@ -435,7 +546,10 @@ void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ); * of the logic of (D)TLS from the implementation * of the secure transport. * - * \param ssl SSL context to use + * \param ssl The SSL context to use. + * \param update_hs_digest This indicates if the handshake digest + * should be automatically updated in case + * a handshake message is found. * * \return 0 or non-zero error code. * @@ -501,10 +615,12 @@ void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ); * following the above definition. * */ -int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl, + unsigned update_hs_digest ); int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ); -int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ); int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ); int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ); @@ -613,6 +729,7 @@ static inline size_t mbedtls_ssl_hs_hdr_len( const mbedtls_ssl_context *ssl ) void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl ); void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl ); int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ); +int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl ); #endif /* Visible for testing purposes only */ @@ -652,9 +769,9 @@ int mbedtls_ssl_get_key_exchange_md_ssl_tls( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_2) int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl, - unsigned char *output, - unsigned char *data, size_t data_len, - mbedtls_md_type_t md_alg ); + unsigned char *hash, size_t *hashlen, + unsigned char *data, size_t data_len, + mbedtls_md_type_t md_alg ); #endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ MBEDTLS_SSL_PROTO_TLS1_2 */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ticket.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ticket.h index 93ad46ac9c..a84e7816e4 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ticket.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/ssl_ticket.h @@ -24,6 +24,12 @@ #ifndef MBEDTLS_SSL_TICKET_H #define MBEDTLS_SSL_TICKET_H +#if !defined(MBEDTLS_CONFIG_FILE) +#include "config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + /* * This implementation of the session ticket callbacks includes key * management, rotating the keys periodically in order to preserve forward @@ -44,7 +50,7 @@ extern "C" { /** * \brief Information for session ticket protection */ -typedef struct +typedef struct mbedtls_ssl_ticket_key { unsigned char name[4]; /*!< random key identifier */ uint32_t generation_time; /*!< key generation timestamp (seconds) */ @@ -55,7 +61,7 @@ mbedtls_ssl_ticket_key; /** * \brief Context for session ticket handling functions */ -typedef struct +typedef struct mbedtls_ssl_ticket_context { mbedtls_ssl_ticket_key keys[2]; /*!< ticket protection keys */ unsigned char active; /*!< index of the currently active key */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/threading.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/threading.h index aeea5d0e1a..92e6e6b987 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/threading.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/threading.h @@ -36,13 +36,16 @@ extern "C" { #endif +/* MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE is deprecated and should not be + * used. */ #define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A /**< The selected feature is not available. */ + #define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA -0x001C /**< Bad input parameters to function. */ #define MBEDTLS_ERR_THREADING_MUTEX_ERROR -0x001E /**< Locking / unlocking / free failed with error code. */ #if defined(MBEDTLS_THREADING_PTHREAD) #include -typedef struct +typedef struct mbedtls_threading_mutex_t { pthread_mutex_t mutex; char is_valid; @@ -99,9 +102,17 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex ); #if defined(MBEDTLS_FS_IO) extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; #endif -#if defined(MBEDTLS_HAVE_TIME_DATE) + +#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) +/* This mutex may or may not be used in the default definition of + * mbedtls_platform_gmtime_r(), but in order to determine that, + * we need to check POSIX features, hence modify _POSIX_C_SOURCE. + * With the current approach, this declaration is orphaned, lacking + * an accompanying definition, in case mbedtls_platform_gmtime_r() + * doesn't need it, but that's not a problem. */ extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex; -#endif +#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */ + #endif /* MBEDTLS_THREADING_C */ #ifdef __cplusplus diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/timing.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/timing.h index 2c497bf4eb..a965fe0d35 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/timing.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/timing.h @@ -30,16 +30,16 @@ #include MBEDTLS_CONFIG_FILE #endif -#if !defined(MBEDTLS_TIMING_ALT) -// Regular implementation -// - #include #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_TIMING_ALT) +// Regular implementation +// + /** * \brief timer structure */ @@ -51,13 +51,17 @@ struct mbedtls_timing_hr_time /** * \brief Context for mbedtls_timing_set/get_delay() */ -typedef struct +typedef struct mbedtls_timing_delay_context { struct mbedtls_timing_hr_time timer; uint32_t int_ms; uint32_t fin_ms; } mbedtls_timing_delay_context; +#else /* MBEDTLS_TIMING_ALT */ +#include "timing_alt.h" +#endif /* MBEDTLS_TIMING_ALT */ + extern volatile int mbedtls_timing_alarmed; /** @@ -133,18 +137,6 @@ void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms ); */ int mbedtls_timing_get_delay( void *data ); -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_TIMING_ALT */ -#include "timing_alt.h" -#endif /* MBEDTLS_TIMING_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif - #if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/version.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/version.h index 36feff0d82..ef8e4c1f4f 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/version.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/version.h @@ -39,17 +39,17 @@ * Major, Minor, Patchlevel */ #define MBEDTLS_VERSION_MAJOR 2 -#define MBEDTLS_VERSION_MINOR 7 -#define MBEDTLS_VERSION_PATCH 9 +#define MBEDTLS_VERSION_MINOR 16 +#define MBEDTLS_VERSION_PATCH 2 /** * The single version number has the following structure: * MMNNPP00 * Major version | Minor version | Patch version */ -#define MBEDTLS_VERSION_NUMBER 0x02070900 -#define MBEDTLS_VERSION_STRING "2.7.9" -#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.7.9" +#define MBEDTLS_VERSION_NUMBER 0x02100200 +#define MBEDTLS_VERSION_STRING "2.16.2" +#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.16.2" #if defined(MBEDTLS_VERSION_C) diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/x509.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/x509.h index d6db9c6e37..9ae825c183 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/x509.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/x509.h @@ -269,6 +269,8 @@ int mbedtls_x509_time_is_past( const mbedtls_x509_time *to ); */ int mbedtls_x509_time_is_future( const mbedtls_x509_time *from ); +#if defined(MBEDTLS_SELF_TEST) + /** * \brief Checkup routine * @@ -276,6 +278,8 @@ int mbedtls_x509_time_is_future( const mbedtls_x509_time *from ); */ int mbedtls_x509_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + /* * Internal module functions. You probably do not want to use these unless you * know you do. diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_crt.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_crt.h index 2c3c758e9e..670bd10d89 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_crt.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_crt.h @@ -98,14 +98,14 @@ mbedtls_x509_crt; * Build flag from an algorithm/curve identifier (pk, md, ecp) * Since 0 is always XXX_NONE, ignore it. */ -#define MBEDTLS_X509_ID_FLAG( id ) ( 1 << ( id - 1 ) ) +#define MBEDTLS_X509_ID_FLAG( id ) ( 1 << ( (id) - 1 ) ) /** * Security profile for certificate verification. * * All lists are bitfields, built by ORing flags from MBEDTLS_X509_ID_FLAG(). */ -typedef struct +typedef struct mbedtls_x509_crt_profile { uint32_t allowed_mds; /**< MDs for signatures */ uint32_t allowed_pks; /**< PK algs for signatures */ @@ -143,6 +143,63 @@ typedef struct mbedtls_x509write_cert } mbedtls_x509write_cert; +/** + * Item in a verification chain: cert and flags for it + */ +typedef struct { + mbedtls_x509_crt *crt; + uint32_t flags; +} mbedtls_x509_crt_verify_chain_item; + +/** + * Max size of verification chain: end-entity + intermediates + trusted root + */ +#define MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE ( MBEDTLS_X509_MAX_INTERMEDIATE_CA + 2 ) + +/** + * Verification chain as built by \c mbedtls_crt_verify_chain() + */ +typedef struct +{ + mbedtls_x509_crt_verify_chain_item items[MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE]; + unsigned len; +} mbedtls_x509_crt_verify_chain; + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + +/** + * \brief Context for resuming X.509 verify operations + */ +typedef struct +{ + /* for check_signature() */ + mbedtls_pk_restart_ctx pk; + + /* for find_parent_in() */ + mbedtls_x509_crt *parent; /* non-null iff parent_in in progress */ + mbedtls_x509_crt *fallback_parent; + int fallback_signature_is_good; + + /* for find_parent() */ + int parent_is_trusted; /* -1 if find_parent is not in progress */ + + /* for verify_chain() */ + enum { + x509_crt_rs_none, + x509_crt_rs_find_parent, + } in_progress; /* none if no operation is in progress */ + int self_cnt; + mbedtls_x509_crt_verify_chain ver_chain; + +} mbedtls_x509_crt_restart_ctx; + +#else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + +/* Now we can declare functions that take a pointer to that */ +typedef void mbedtls_x509_crt_restart_ctx; + +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + #if defined(MBEDTLS_X509_CRT_PARSE_C) /** * Default security profile. Should provide a good balance between security @@ -368,6 +425,37 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy ); +/** + * \brief Restartable version of \c mbedtls_crt_verify_with_profile() + * + * \note Performs the same job as \c mbedtls_crt_verify_with_profile() + * but can return early and restart according to the limit + * set with \c mbedtls_ecp_set_max_ops() to reduce blocking. + * + * \param crt a certificate (chain) to be verified + * \param trust_ca the list of trusted CAs + * \param ca_crl the list of CRLs for trusted CAs + * \param profile security profile for verification + * \param cn expected Common Name (can be set to + * NULL if the CN must not be verified) + * \param flags result of the verification + * \param f_vrfy verification function + * \param p_vrfy verification parameter + * \param rs_ctx restart context (NULL to disable restart) + * + * \return See \c mbedtls_crt_verify_with_profile(), or + * \return #MBEDTLS_ERR_ECP_IN_PROGRESS if maximum number of + * operations was reached: see \c mbedtls_ecp_set_max_ops(). + */ +int mbedtls_x509_crt_verify_restartable( mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + const char *cn, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy, + mbedtls_x509_crt_restart_ctx *rs_ctx ); + #if defined(MBEDTLS_X509_CHECK_KEY_USAGE) /** * \brief Check usage of certificate against keyUsage extension. @@ -439,6 +527,18 @@ void mbedtls_x509_crt_init( mbedtls_x509_crt *crt ); * \param crt Certificate chain to free */ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ); + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +/** + * \brief Initialize a restart context + */ +void mbedtls_x509_crt_restart_init( mbedtls_x509_crt_restart_ctx *ctx ); + +/** + * \brief Free the components of a restart context + */ +void mbedtls_x509_crt_restart_free( mbedtls_x509_crt_restart_ctx *ctx ); +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ #endif /* MBEDTLS_X509_CRT_PARSE_C */ /* \} name */ diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_csr.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_csr.h index 0c6ccad78d..a3c28048e0 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_csr.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/x509_csr.h @@ -205,6 +205,14 @@ void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_ty * \param key_usage key usage flags to set * * \return 0 if successful, or MBEDTLS_ERR_X509_ALLOC_FAILED + * + * \note The decipherOnly flag from the Key Usage + * extension is represented by bit 8 (i.e. + * 0x8000), which cannot typically be represented + * in an unsigned char. Therefore, the flag + * decipherOnly (i.e. + * #MBEDTLS_X509_KU_DECIPHER_ONLY) cannot be set using this + * function. */ int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage ); diff --git a/3rdparty/mbedtls/mbedtls/include/mbedtls/xtea.h b/3rdparty/mbedtls/mbedtls/include/mbedtls/xtea.h index 34ccee3c22..b47f553508 100644 --- a/3rdparty/mbedtls/mbedtls/include/mbedtls/xtea.h +++ b/3rdparty/mbedtls/mbedtls/include/mbedtls/xtea.h @@ -37,25 +37,31 @@ #define MBEDTLS_XTEA_DECRYPT 0 #define MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH -0x0028 /**< The data input has an invalid length. */ -#define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029 /**< XTEA hardware accelerator failed. */ -#if !defined(MBEDTLS_XTEA_ALT) -// Regular implementation -// +/* MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED is deprecated and should not be used. */ +#define MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED -0x0029 /**< XTEA hardware accelerator failed. */ #ifdef __cplusplus extern "C" { #endif +#if !defined(MBEDTLS_XTEA_ALT) +// Regular implementation +// + /** * \brief XTEA context structure */ -typedef struct +typedef struct mbedtls_xtea_context { uint32_t k[4]; /*!< key */ } mbedtls_xtea_context; +#else /* MBEDTLS_XTEA_ALT */ +#include "xtea_alt.h" +#endif /* MBEDTLS_XTEA_ALT */ + /** * \brief Initialize XTEA context * @@ -115,17 +121,7 @@ int mbedtls_xtea_crypt_cbc( mbedtls_xtea_context *ctx, unsigned char *output); #endif /* MBEDTLS_CIPHER_MODE_CBC */ -#ifdef __cplusplus -} -#endif - -#else /* MBEDTLS_XTEA_ALT */ -#include "xtea_alt.h" -#endif /* MBEDTLS_XTEA_ALT */ - -#ifdef __cplusplus -extern "C" { -#endif +#if defined(MBEDTLS_SELF_TEST) /** * \brief Checkup routine @@ -134,6 +130,8 @@ extern "C" { */ int mbedtls_xtea_self_test( int verbose ); +#endif /* MBEDTLS_SELF_TEST */ + #ifdef __cplusplus } #endif diff --git a/3rdparty/mbedtls/mbedtls/library/CMakeLists.txt b/3rdparty/mbedtls/mbedtls/library/CMakeLists.txt index 59df9589a4..2a0d47d8be 100644 --- a/3rdparty/mbedtls/mbedtls/library/CMakeLists.txt +++ b/3rdparty/mbedtls/mbedtls/library/CMakeLists.txt @@ -6,6 +6,7 @@ set(src_crypto aes.c aesni.c arc4.c + aria.c asn1parse.c asn1write.c base64.c @@ -13,6 +14,8 @@ set(src_crypto blowfish.c camellia.c ccm.c + chacha20.c + chachapoly.c cipher.c cipher_wrap.c cmac.c @@ -29,6 +32,7 @@ set(src_crypto error.c gcm.c havege.c + hkdf.c hmac_drbg.c md.c md2.c @@ -36,6 +40,7 @@ set(src_crypto md5.c md_wrap.c memory_buffer_alloc.c + nist_kw.c oid.c padlock.c pem.c @@ -46,6 +51,8 @@ set(src_crypto pkparse.c pkwrite.c platform.c + platform_util.c + poly1305.c ripemd160.c rsa.c rsa_internal.c @@ -91,10 +98,27 @@ if(CMAKE_COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations -Wmissing-prototypes -Wdocumentation -Wno-documentation-deprecated-sync -Wunreachable-code") endif(CMAKE_COMPILER_IS_CLANG) +if(UNSAFE_BUILD) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error") + set(CMAKE_C_FLAGS_ASAN "${CMAKE_C_FLAGS_ASAN} -Wno-error") + set(CMAKE_C_FLAGS_ASANDBG "${CMAKE_C_FLAGS_ASANDBG} -Wno-error") +endif(UNSAFE_BUILD) + if(WIN32) set(libs ${libs} ws2_32) endif(WIN32) +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + SET(CMAKE_C_ARCHIVE_CREATE " Scr ") + SET(CMAKE_CXX_ARCHIVE_CREATE " Scr ") + SET(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") + SET(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") +endif() + +if(HAIKU) + set(libs ${libs} network) +endif(HAIKU) + if(USE_PKCS11_HELPER_LIBRARY) set(libs ${libs} pkcs11-helper) endif(USE_PKCS11_HELPER_LIBRARY) @@ -141,15 +165,15 @@ endif(USE_STATIC_MBEDTLS_LIBRARY) if(USE_SHARED_MBEDTLS_LIBRARY) add_library(mbedcrypto SHARED ${src_crypto}) - set_target_properties(mbedcrypto PROPERTIES VERSION 2.7.9 SOVERSION 2) + set_target_properties(mbedcrypto PROPERTIES VERSION 2.16.2 SOVERSION 3) target_link_libraries(mbedcrypto ${libs}) add_library(mbedx509 SHARED ${src_x509}) - set_target_properties(mbedx509 PROPERTIES VERSION 2.7.9 SOVERSION 0) + set_target_properties(mbedx509 PROPERTIES VERSION 2.16.2 SOVERSION 0) target_link_libraries(mbedx509 ${libs} mbedcrypto) add_library(mbedtls SHARED ${src_tls}) - set_target_properties(mbedtls PROPERTIES VERSION 2.7.9 SOVERSION 10) + set_target_properties(mbedtls PROPERTIES VERSION 2.16.2 SOVERSION 12) target_link_libraries(mbedtls ${libs} mbedx509) install(TARGETS mbedtls mbedx509 mbedcrypto diff --git a/3rdparty/mbedtls/mbedtls/library/Makefile b/3rdparty/mbedtls/mbedtls/library/Makefile index 97f796fcf8..430c598812 100644 --- a/3rdparty/mbedtls/mbedtls/library/Makefile +++ b/3rdparty/mbedtls/mbedtls/library/Makefile @@ -21,6 +21,10 @@ endif # if were running on Windows build for Windows ifdef WINDOWS WINDOWS_BUILD=1 +else ifeq ($(shell uname -s),Darwin) +ifeq ($(AR),ar) +APPLE_BUILD ?= 1 +endif endif # To compile as a shared library: @@ -31,37 +35,52 @@ LOCAL_CFLAGS += -fPIC -fpic endif endif -SOEXT_TLS=so.10 +SOEXT_TLS=so.12 SOEXT_X509=so.0 -SOEXT_CRYPTO=so.2 - -# Set DLEXT=dylib to compile as a shared library for Mac OS X -DLEXT ?= so +SOEXT_CRYPTO=so.3 # Set AR_DASH= (empty string) to use an ar implentation that does not accept # the - prefix for command line options (e.g. llvm-ar) AR_DASH ?= - -# Windows shared library extension: +ARFLAGS = $(AR_DASH)src +ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) +ARFLAGS = $(AR_DASH)Src +RLFLAGS = -no_warning_for_no_symbols -c +RL ?= ranlib +endif +endif + +DLEXT ?= so ifdef WINDOWS_BUILD -DLEXT=dll +# Windows shared library extension: +DLEXT = dll +else ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) +# Mac OS X shared library extension: +DLEXT = dylib +endif endif OBJS_CRYPTO= aes.o aesni.o arc4.o \ - asn1parse.o asn1write.o base64.o \ - bignum.o blowfish.o camellia.o \ - ccm.o cipher.o cipher_wrap.o \ + aria.o asn1parse.o asn1write.o \ + base64.o bignum.o blowfish.o \ + camellia.o ccm.o chacha20.o \ + chachapoly.o cipher.o cipher_wrap.o \ cmac.o ctr_drbg.o des.o \ dhm.o ecdh.o ecdsa.o \ ecjpake.o ecp.o \ ecp_curves.o entropy.o entropy_poll.o \ error.o gcm.o havege.o \ + hkdf.o \ hmac_drbg.o md.o md2.o \ md4.o md5.o md_wrap.o \ - memory_buffer_alloc.o oid.o \ - padlock.o pem.o pk.o \ - pk_wrap.o pkcs12.o pkcs5.o \ - pkparse.o pkwrite.o platform.o \ + memory_buffer_alloc.o nist_kw.o \ + oid.o padlock.o pem.o \ + pk.o pk_wrap.o pkcs12.o \ + pkcs5.o pkparse.o pkwrite.o \ + platform.o platform_util.o poly1305.o \ ripemd160.o rsa_internal.o rsa.o \ sha1.o sha256.o sha512.o \ threading.o timing.o version.o \ @@ -94,9 +113,13 @@ shared: libmbedcrypto.$(DLEXT) libmbedx509.$(DLEXT) libmbedtls.$(DLEXT) # tls libmbedtls.a: $(OBJS_TLS) echo " AR $@" - $(AR) $(AR_DASH)rc $@ $(OBJS_TLS) + $(AR) $(ARFLAGS) $@ $(OBJS_TLS) +ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) echo " RL $@" - $(AR) $(AR_DASH)s $@ + $(RL) $(RLFLAGS) $@ +endif +endif libmbedtls.$(SOEXT_TLS): $(OBJS_TLS) libmbedx509.so echo " LD $@" @@ -117,9 +140,13 @@ libmbedtls.dll: $(OBJS_TLS) libmbedx509.dll # x509 libmbedx509.a: $(OBJS_X509) echo " AR $@" - $(AR) $(AR_DASH)rc $@ $(OBJS_X509) + $(AR) $(ARFLAGS) $@ $(OBJS_X509) +ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) echo " RL $@" - $(AR) $(AR_DASH)s $@ + $(RL) $(RLFLAGS) $@ +endif +endif libmbedx509.$(SOEXT_X509): $(OBJS_X509) libmbedcrypto.so echo " LD $@" @@ -140,9 +167,13 @@ libmbedx509.dll: $(OBJS_X509) libmbedcrypto.dll # crypto libmbedcrypto.a: $(OBJS_CRYPTO) echo " AR $@" - $(AR) $(AR_DASH)rc $@ $(OBJS_CRYPTO) + $(AR) $(ARFLAGS) $@ $(OBJS_CRYPTO) +ifdef APPLE_BUILD +ifneq ($(APPLE_BUILD),0) echo " RL $@" - $(AR) $(AR_DASH)s $@ + $(RL) $(RLFLAGS) $@ +endif +endif libmbedcrypto.$(SOEXT_CRYPTO): $(OBJS_CRYPTO) echo " LD $@" diff --git a/3rdparty/mbedtls/mbedtls/library/aes.c b/3rdparty/mbedtls/mbedtls/library/aes.c index 3d2eac82dd..aff0a9939a 100644 --- a/3rdparty/mbedtls/mbedtls/library/aes.c +++ b/3rdparty/mbedtls/mbedtls/library/aes.c @@ -36,6 +36,8 @@ #include #include "mbedtls/aes.h" +#include "mbedtls/platform.h" +#include "mbedtls/platform_util.h" #if defined(MBEDTLS_PADLOCK_C) #include "mbedtls/padlock.h" #endif @@ -54,10 +56,11 @@ #if !defined(MBEDTLS_AES_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} +/* Parameter validation macros based on platform_util.h */ +#define AES_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_AES_BAD_INPUT_DATA ) +#define AES_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) /* * 32-bit integer manipulation macros (little endian) @@ -201,6 +204,8 @@ static const unsigned char FSb[256] = static const uint32_t FT0[256] = { FT }; #undef V +#if !defined(MBEDTLS_AES_FEWER_TABLES) + #define V(a,b,c,d) 0x##b##c##d##a static const uint32_t FT1[256] = { FT }; #undef V @@ -213,6 +218,8 @@ static const uint32_t FT2[256] = { FT }; static const uint32_t FT3[256] = { FT }; #undef V +#endif /* !MBEDTLS_AES_FEWER_TABLES */ + #undef FT /* @@ -328,6 +335,8 @@ static const unsigned char RSb[256] = static const uint32_t RT0[256] = { RT }; #undef V +#if !defined(MBEDTLS_AES_FEWER_TABLES) + #define V(a,b,c,d) 0x##b##c##d##a static const uint32_t RT1[256] = { RT }; #undef V @@ -340,6 +349,8 @@ static const uint32_t RT2[256] = { RT }; static const uint32_t RT3[256] = { RT }; #undef V +#endif /* !MBEDTLS_AES_FEWER_TABLES */ + #undef RT /* @@ -359,18 +370,22 @@ static const uint32_t RCON[10] = */ static unsigned char FSb[256]; static uint32_t FT0[256]; +#if !defined(MBEDTLS_AES_FEWER_TABLES) static uint32_t FT1[256]; static uint32_t FT2[256]; static uint32_t FT3[256]; +#endif /* !MBEDTLS_AES_FEWER_TABLES */ /* * Reverse S-box & tables */ static unsigned char RSb[256]; static uint32_t RT0[256]; +#if !defined(MBEDTLS_AES_FEWER_TABLES) static uint32_t RT1[256]; static uint32_t RT2[256]; static uint32_t RT3[256]; +#endif /* !MBEDTLS_AES_FEWER_TABLES */ /* * Round constants @@ -380,9 +395,9 @@ static uint32_t RCON[10]; /* * Tables generation code */ -#define ROTL8(x) ( ( x << 8 ) & 0xFFFFFFFF ) | ( x >> 24 ) -#define XTIME(x) ( ( x << 1 ) ^ ( ( x & 0x80 ) ? 0x1B : 0x00 ) ) -#define MUL(x,y) ( ( x && y ) ? pow[(log[x]+log[y]) % 255] : 0 ) +#define ROTL8(x) ( ( (x) << 8 ) & 0xFFFFFFFF ) | ( (x) >> 24 ) +#define XTIME(x) ( ( (x) << 1 ) ^ ( ( (x) & 0x80 ) ? 0x1B : 0x00 ) ) +#define MUL(x,y) ( ( (x) && (y) ) ? pow[(log[(x)]+log[(y)]) % 255] : 0 ) static int aes_init_done = 0; @@ -445,9 +460,11 @@ static void aes_gen_tables( void ) ( (uint32_t) x << 16 ) ^ ( (uint32_t) z << 24 ); +#if !defined(MBEDTLS_AES_FEWER_TABLES) FT1[i] = ROTL8( FT0[i] ); FT2[i] = ROTL8( FT1[i] ); FT3[i] = ROTL8( FT2[i] ); +#endif /* !MBEDTLS_AES_FEWER_TABLES */ x = RSb[i]; @@ -456,16 +473,52 @@ static void aes_gen_tables( void ) ( (uint32_t) MUL( 0x0D, x ) << 16 ) ^ ( (uint32_t) MUL( 0x0B, x ) << 24 ); +#if !defined(MBEDTLS_AES_FEWER_TABLES) RT1[i] = ROTL8( RT0[i] ); RT2[i] = ROTL8( RT1[i] ); RT3[i] = ROTL8( RT2[i] ); +#endif /* !MBEDTLS_AES_FEWER_TABLES */ } } +#undef ROTL8 + #endif /* MBEDTLS_AES_ROM_TABLES */ +#if defined(MBEDTLS_AES_FEWER_TABLES) + +#define ROTL8(x) ( (uint32_t)( ( x ) << 8 ) + (uint32_t)( ( x ) >> 24 ) ) +#define ROTL16(x) ( (uint32_t)( ( x ) << 16 ) + (uint32_t)( ( x ) >> 16 ) ) +#define ROTL24(x) ( (uint32_t)( ( x ) << 24 ) + (uint32_t)( ( x ) >> 8 ) ) + +#define AES_RT0(idx) RT0[idx] +#define AES_RT1(idx) ROTL8( RT0[idx] ) +#define AES_RT2(idx) ROTL16( RT0[idx] ) +#define AES_RT3(idx) ROTL24( RT0[idx] ) + +#define AES_FT0(idx) FT0[idx] +#define AES_FT1(idx) ROTL8( FT0[idx] ) +#define AES_FT2(idx) ROTL16( FT0[idx] ) +#define AES_FT3(idx) ROTL24( FT0[idx] ) + +#else /* MBEDTLS_AES_FEWER_TABLES */ + +#define AES_RT0(idx) RT0[idx] +#define AES_RT1(idx) RT1[idx] +#define AES_RT2(idx) RT2[idx] +#define AES_RT3(idx) RT3[idx] + +#define AES_FT0(idx) FT0[idx] +#define AES_FT1(idx) FT1[idx] +#define AES_FT2(idx) FT2[idx] +#define AES_FT3(idx) FT3[idx] + +#endif /* MBEDTLS_AES_FEWER_TABLES */ + void mbedtls_aes_init( mbedtls_aes_context *ctx ) { + AES_VALIDATE( ctx != NULL ); + memset( ctx, 0, sizeof( mbedtls_aes_context ) ); } @@ -474,8 +527,27 @@ void mbedtls_aes_free( mbedtls_aes_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_aes_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_aes_context ) ); +} + +#if defined(MBEDTLS_CIPHER_MODE_XTS) +void mbedtls_aes_xts_init( mbedtls_aes_xts_context *ctx ) +{ + AES_VALIDATE( ctx != NULL ); + + mbedtls_aes_init( &ctx->crypt ); + mbedtls_aes_init( &ctx->tweak ); +} + +void mbedtls_aes_xts_free( mbedtls_aes_xts_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_aes_free( &ctx->crypt ); + mbedtls_aes_free( &ctx->tweak ); } +#endif /* MBEDTLS_CIPHER_MODE_XTS */ /* * AES key schedule (encryption) @@ -487,14 +559,8 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, unsigned int i; uint32_t *RK; -#if !defined(MBEDTLS_AES_ROM_TABLES) - if( aes_init_done == 0 ) - { - aes_gen_tables(); - aes_init_done = 1; - - } -#endif + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( key != NULL ); switch( keybits ) { @@ -504,6 +570,14 @@ int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, default : return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH ); } +#if !defined(MBEDTLS_AES_ROM_TABLES) + if( aes_init_done == 0 ) + { + aes_gen_tables(); + aes_init_done = 1; + } +#endif + #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16) if( aes_padlock_ace == -1 ) aes_padlock_ace = mbedtls_padlock_has_support( MBEDTLS_PADLOCK_ACE ); @@ -603,6 +677,9 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, uint32_t *RK; uint32_t *SK; + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( key != NULL ); + mbedtls_aes_init( &cty ); #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_PADLOCK_ALIGN16) @@ -641,10 +718,10 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, { for( j = 0; j < 4; j++, SK++ ) { - *RK++ = RT0[ FSb[ ( *SK ) & 0xFF ] ] ^ - RT1[ FSb[ ( *SK >> 8 ) & 0xFF ] ] ^ - RT2[ FSb[ ( *SK >> 16 ) & 0xFF ] ] ^ - RT3[ FSb[ ( *SK >> 24 ) & 0xFF ] ]; + *RK++ = AES_RT0( FSb[ ( *SK ) & 0xFF ] ) ^ + AES_RT1( FSb[ ( *SK >> 8 ) & 0xFF ] ) ^ + AES_RT2( FSb[ ( *SK >> 16 ) & 0xFF ] ) ^ + AES_RT3( FSb[ ( *SK >> 24 ) & 0xFF ] ); } } @@ -658,53 +735,133 @@ int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, return( ret ); } -#endif /* !MBEDTLS_AES_SETKEY_DEC_ALT */ -#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ -{ \ - X0 = *RK++ ^ FT0[ ( Y0 ) & 0xFF ] ^ \ - FT1[ ( Y1 >> 8 ) & 0xFF ] ^ \ - FT2[ ( Y2 >> 16 ) & 0xFF ] ^ \ - FT3[ ( Y3 >> 24 ) & 0xFF ]; \ - \ - X1 = *RK++ ^ FT0[ ( Y1 ) & 0xFF ] ^ \ - FT1[ ( Y2 >> 8 ) & 0xFF ] ^ \ - FT2[ ( Y3 >> 16 ) & 0xFF ] ^ \ - FT3[ ( Y0 >> 24 ) & 0xFF ]; \ - \ - X2 = *RK++ ^ FT0[ ( Y2 ) & 0xFF ] ^ \ - FT1[ ( Y3 >> 8 ) & 0xFF ] ^ \ - FT2[ ( Y0 >> 16 ) & 0xFF ] ^ \ - FT3[ ( Y1 >> 24 ) & 0xFF ]; \ - \ - X3 = *RK++ ^ FT0[ ( Y3 ) & 0xFF ] ^ \ - FT1[ ( Y0 >> 8 ) & 0xFF ] ^ \ - FT2[ ( Y1 >> 16 ) & 0xFF ] ^ \ - FT3[ ( Y2 >> 24 ) & 0xFF ]; \ +#if defined(MBEDTLS_CIPHER_MODE_XTS) +static int mbedtls_aes_xts_decode_keys( const unsigned char *key, + unsigned int keybits, + const unsigned char **key1, + unsigned int *key1bits, + const unsigned char **key2, + unsigned int *key2bits ) +{ + const unsigned int half_keybits = keybits / 2; + const unsigned int half_keybytes = half_keybits / 8; + + switch( keybits ) + { + case 256: break; + case 512: break; + default : return( MBEDTLS_ERR_AES_INVALID_KEY_LENGTH ); + } + + *key1bits = half_keybits; + *key2bits = half_keybits; + *key1 = &key[0]; + *key2 = &key[half_keybytes]; + + return 0; +} + +int mbedtls_aes_xts_setkey_enc( mbedtls_aes_xts_context *ctx, + const unsigned char *key, + unsigned int keybits) +{ + int ret; + const unsigned char *key1, *key2; + unsigned int key1bits, key2bits; + + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( key != NULL ); + + ret = mbedtls_aes_xts_decode_keys( key, keybits, &key1, &key1bits, + &key2, &key2bits ); + if( ret != 0 ) + return( ret ); + + /* Set the tweak key. Always set tweak key for the encryption mode. */ + ret = mbedtls_aes_setkey_enc( &ctx->tweak, key2, key2bits ); + if( ret != 0 ) + return( ret ); + + /* Set crypt key for encryption. */ + return mbedtls_aes_setkey_enc( &ctx->crypt, key1, key1bits ); } -#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ -{ \ - X0 = *RK++ ^ RT0[ ( Y0 ) & 0xFF ] ^ \ - RT1[ ( Y3 >> 8 ) & 0xFF ] ^ \ - RT2[ ( Y2 >> 16 ) & 0xFF ] ^ \ - RT3[ ( Y1 >> 24 ) & 0xFF ]; \ - \ - X1 = *RK++ ^ RT0[ ( Y1 ) & 0xFF ] ^ \ - RT1[ ( Y0 >> 8 ) & 0xFF ] ^ \ - RT2[ ( Y3 >> 16 ) & 0xFF ] ^ \ - RT3[ ( Y2 >> 24 ) & 0xFF ]; \ - \ - X2 = *RK++ ^ RT0[ ( Y2 ) & 0xFF ] ^ \ - RT1[ ( Y1 >> 8 ) & 0xFF ] ^ \ - RT2[ ( Y0 >> 16 ) & 0xFF ] ^ \ - RT3[ ( Y3 >> 24 ) & 0xFF ]; \ - \ - X3 = *RK++ ^ RT0[ ( Y3 ) & 0xFF ] ^ \ - RT1[ ( Y2 >> 8 ) & 0xFF ] ^ \ - RT2[ ( Y1 >> 16 ) & 0xFF ] ^ \ - RT3[ ( Y0 >> 24 ) & 0xFF ]; \ +int mbedtls_aes_xts_setkey_dec( mbedtls_aes_xts_context *ctx, + const unsigned char *key, + unsigned int keybits) +{ + int ret; + const unsigned char *key1, *key2; + unsigned int key1bits, key2bits; + + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( key != NULL ); + + ret = mbedtls_aes_xts_decode_keys( key, keybits, &key1, &key1bits, + &key2, &key2bits ); + if( ret != 0 ) + return( ret ); + + /* Set the tweak key. Always set tweak key for encryption. */ + ret = mbedtls_aes_setkey_enc( &ctx->tweak, key2, key2bits ); + if( ret != 0 ) + return( ret ); + + /* Set crypt key for decryption. */ + return mbedtls_aes_setkey_dec( &ctx->crypt, key1, key1bits ); } +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + +#endif /* !MBEDTLS_AES_SETKEY_DEC_ALT */ + +#define AES_FROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ + do \ + { \ + (X0) = *RK++ ^ AES_FT0( ( (Y0) ) & 0xFF ) ^ \ + AES_FT1( ( (Y1) >> 8 ) & 0xFF ) ^ \ + AES_FT2( ( (Y2) >> 16 ) & 0xFF ) ^ \ + AES_FT3( ( (Y3) >> 24 ) & 0xFF ); \ + \ + (X1) = *RK++ ^ AES_FT0( ( (Y1) ) & 0xFF ) ^ \ + AES_FT1( ( (Y2) >> 8 ) & 0xFF ) ^ \ + AES_FT2( ( (Y3) >> 16 ) & 0xFF ) ^ \ + AES_FT3( ( (Y0) >> 24 ) & 0xFF ); \ + \ + (X2) = *RK++ ^ AES_FT0( ( (Y2) ) & 0xFF ) ^ \ + AES_FT1( ( (Y3) >> 8 ) & 0xFF ) ^ \ + AES_FT2( ( (Y0) >> 16 ) & 0xFF ) ^ \ + AES_FT3( ( (Y1) >> 24 ) & 0xFF ); \ + \ + (X3) = *RK++ ^ AES_FT0( ( (Y3) ) & 0xFF ) ^ \ + AES_FT1( ( (Y0) >> 8 ) & 0xFF ) ^ \ + AES_FT2( ( (Y1) >> 16 ) & 0xFF ) ^ \ + AES_FT3( ( (Y2) >> 24 ) & 0xFF ); \ + } while( 0 ) + +#define AES_RROUND(X0,X1,X2,X3,Y0,Y1,Y2,Y3) \ + do \ + { \ + (X0) = *RK++ ^ AES_RT0( ( (Y0) ) & 0xFF ) ^ \ + AES_RT1( ( (Y3) >> 8 ) & 0xFF ) ^ \ + AES_RT2( ( (Y2) >> 16 ) & 0xFF ) ^ \ + AES_RT3( ( (Y1) >> 24 ) & 0xFF ); \ + \ + (X1) = *RK++ ^ AES_RT0( ( (Y1) ) & 0xFF ) ^ \ + AES_RT1( ( (Y0) >> 8 ) & 0xFF ) ^ \ + AES_RT2( ( (Y3) >> 16 ) & 0xFF ) ^ \ + AES_RT3( ( (Y2) >> 24 ) & 0xFF ); \ + \ + (X2) = *RK++ ^ AES_RT0( ( (Y2) ) & 0xFF ) ^ \ + AES_RT1( ( (Y1) >> 8 ) & 0xFF ) ^ \ + AES_RT2( ( (Y0) >> 16 ) & 0xFF ) ^ \ + AES_RT3( ( (Y3) >> 24 ) & 0xFF ); \ + \ + (X3) = *RK++ ^ AES_RT0( ( (Y3) ) & 0xFF ) ^ \ + AES_RT1( ( (Y2) >> 8 ) & 0xFF ) ^ \ + AES_RT2( ( (Y1) >> 16 ) & 0xFF ) ^ \ + AES_RT3( ( (Y0) >> 24 ) & 0xFF ); \ + } while( 0 ) /* * AES-ECB block encryption @@ -846,10 +1003,16 @@ void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, * AES-ECB block encryption/decryption */ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, - int mode, - const unsigned char input[16], - unsigned char output[16] ) + int mode, + const unsigned char input[16], + unsigned char output[16] ) { + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); + AES_VALIDATE_RET( mode == MBEDTLS_AES_ENCRYPT || + mode == MBEDTLS_AES_DECRYPT ); + #if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64) if( mbedtls_aesni_has_support( MBEDTLS_AESNI_AES ) ) return( mbedtls_aesni_crypt_ecb( ctx, mode, input, output ) ); @@ -887,6 +1050,13 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, int i; unsigned char temp[16]; + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( mode == MBEDTLS_AES_ENCRYPT || + mode == MBEDTLS_AES_DECRYPT ); + AES_VALIDATE_RET( iv != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); + if( length % 16 ) return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); @@ -939,6 +1109,172 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, } #endif /* MBEDTLS_CIPHER_MODE_CBC */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) + +/* Endianess with 64 bits values */ +#ifndef GET_UINT64_LE +#define GET_UINT64_LE(n,b,i) \ +{ \ + (n) = ( (uint64_t) (b)[(i) + 7] << 56 ) \ + | ( (uint64_t) (b)[(i) + 6] << 48 ) \ + | ( (uint64_t) (b)[(i) + 5] << 40 ) \ + | ( (uint64_t) (b)[(i) + 4] << 32 ) \ + | ( (uint64_t) (b)[(i) + 3] << 24 ) \ + | ( (uint64_t) (b)[(i) + 2] << 16 ) \ + | ( (uint64_t) (b)[(i) + 1] << 8 ) \ + | ( (uint64_t) (b)[(i) ] ); \ +} +#endif + +#ifndef PUT_UINT64_LE +#define PUT_UINT64_LE(n,b,i) \ +{ \ + (b)[(i) + 7] = (unsigned char) ( (n) >> 56 ); \ + (b)[(i) + 6] = (unsigned char) ( (n) >> 48 ); \ + (b)[(i) + 5] = (unsigned char) ( (n) >> 40 ); \ + (b)[(i) + 4] = (unsigned char) ( (n) >> 32 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) ] = (unsigned char) ( (n) ); \ +} +#endif + +typedef unsigned char mbedtls_be128[16]; + +/* + * GF(2^128) multiplication function + * + * This function multiplies a field element by x in the polynomial field + * representation. It uses 64-bit word operations to gain speed but compensates + * for machine endianess and hence works correctly on both big and little + * endian machines. + */ +static void mbedtls_gf128mul_x_ble( unsigned char r[16], + const unsigned char x[16] ) +{ + uint64_t a, b, ra, rb; + + GET_UINT64_LE( a, x, 0 ); + GET_UINT64_LE( b, x, 8 ); + + ra = ( a << 1 ) ^ 0x0087 >> ( 8 - ( ( b >> 63 ) << 3 ) ); + rb = ( a >> 63 ) | ( b << 1 ); + + PUT_UINT64_LE( ra, r, 0 ); + PUT_UINT64_LE( rb, r, 8 ); +} + +/* + * AES-XTS buffer encryption/decryption + */ +int mbedtls_aes_crypt_xts( mbedtls_aes_xts_context *ctx, + int mode, + size_t length, + const unsigned char data_unit[16], + const unsigned char *input, + unsigned char *output ) +{ + int ret; + size_t blocks = length / 16; + size_t leftover = length % 16; + unsigned char tweak[16]; + unsigned char prev_tweak[16]; + unsigned char tmp[16]; + + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( mode == MBEDTLS_AES_ENCRYPT || + mode == MBEDTLS_AES_DECRYPT ); + AES_VALIDATE_RET( data_unit != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); + + /* Data units must be at least 16 bytes long. */ + if( length < 16 ) + return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH; + + /* NIST SP 800-38E disallows data units larger than 2**20 blocks. */ + if( length > ( 1 << 20 ) * 16 ) + return MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH; + + /* Compute the tweak. */ + ret = mbedtls_aes_crypt_ecb( &ctx->tweak, MBEDTLS_AES_ENCRYPT, + data_unit, tweak ); + if( ret != 0 ) + return( ret ); + + while( blocks-- ) + { + size_t i; + + if( leftover && ( mode == MBEDTLS_AES_DECRYPT ) && blocks == 0 ) + { + /* We are on the last block in a decrypt operation that has + * leftover bytes, so we need to use the next tweak for this block, + * and this tweak for the lefover bytes. Save the current tweak for + * the leftovers and then update the current tweak for use on this, + * the last full block. */ + memcpy( prev_tweak, tweak, sizeof( tweak ) ); + mbedtls_gf128mul_x_ble( tweak, tweak ); + } + + for( i = 0; i < 16; i++ ) + tmp[i] = input[i] ^ tweak[i]; + + ret = mbedtls_aes_crypt_ecb( &ctx->crypt, mode, tmp, tmp ); + if( ret != 0 ) + return( ret ); + + for( i = 0; i < 16; i++ ) + output[i] = tmp[i] ^ tweak[i]; + + /* Update the tweak for the next block. */ + mbedtls_gf128mul_x_ble( tweak, tweak ); + + output += 16; + input += 16; + } + + if( leftover ) + { + /* If we are on the leftover bytes in a decrypt operation, we need to + * use the previous tweak for these bytes (as saved in prev_tweak). */ + unsigned char *t = mode == MBEDTLS_AES_DECRYPT ? prev_tweak : tweak; + + /* We are now on the final part of the data unit, which doesn't divide + * evenly by 16. It's time for ciphertext stealing. */ + size_t i; + unsigned char *prev_output = output - 16; + + /* Copy ciphertext bytes from the previous block to our output for each + * byte of cyphertext we won't steal. At the same time, copy the + * remainder of the input for this final round (since the loop bounds + * are the same). */ + for( i = 0; i < leftover; i++ ) + { + output[i] = prev_output[i]; + tmp[i] = input[i] ^ t[i]; + } + + /* Copy ciphertext bytes from the previous block for input in this + * round. */ + for( ; i < 16; i++ ) + tmp[i] = prev_output[i] ^ t[i]; + + ret = mbedtls_aes_crypt_ecb( &ctx->crypt, mode, tmp, tmp ); + if( ret != 0 ) + return ret; + + /* Write the result back to the previous block, overriding the previous + * output we copied. */ + for( i = 0; i < 16; i++ ) + prev_output[i] = tmp[i] ^ t[i]; + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + #if defined(MBEDTLS_CIPHER_MODE_CFB) /* * AES-CFB128 buffer encryption/decryption @@ -952,7 +1288,20 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, unsigned char *output ) { int c; - size_t n = *iv_off; + size_t n; + + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( mode == MBEDTLS_AES_ENCRYPT || + mode == MBEDTLS_AES_DECRYPT ); + AES_VALIDATE_RET( iv_off != NULL ); + AES_VALIDATE_RET( iv != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); + + n = *iv_off; + + if( n > 15 ) + return( MBEDTLS_ERR_AES_BAD_INPUT_DATA ); if( mode == MBEDTLS_AES_DECRYPT ) { @@ -990,15 +1339,21 @@ int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, * AES-CFB8 buffer encryption/decryption */ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, - int mode, - size_t length, - unsigned char iv[16], - const unsigned char *input, - unsigned char *output ) + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) { unsigned char c; unsigned char ov[17]; + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( mode == MBEDTLS_AES_ENCRYPT || + mode == MBEDTLS_AES_DECRYPT ); + AES_VALIDATE_RET( iv != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); while( length-- ) { memcpy( ov, iv, 16 ); @@ -1017,7 +1372,52 @@ int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, return( 0 ); } -#endif /*MBEDTLS_CIPHER_MODE_CFB */ +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_OFB) +/* + * AES-OFB (Output Feedback Mode) buffer encryption/decryption + */ +int mbedtls_aes_crypt_ofb( mbedtls_aes_context *ctx, + size_t length, + size_t *iv_off, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) +{ + int ret = 0; + size_t n; + + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( iv_off != NULL ); + AES_VALIDATE_RET( iv != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); + + n = *iv_off; + + if( n > 15 ) + return( MBEDTLS_ERR_AES_BAD_INPUT_DATA ); + + while( length-- ) + { + if( n == 0 ) + { + ret = mbedtls_aes_crypt_ecb( ctx, MBEDTLS_AES_ENCRYPT, iv, iv ); + if( ret != 0 ) + goto exit; + } + *output++ = *input++ ^ iv[n]; + + n = ( n + 1 ) & 0x0F; + } + + *iv_off = n; + +exit: + return( ret ); +} +#endif /* MBEDTLS_CIPHER_MODE_OFB */ #if defined(MBEDTLS_CIPHER_MODE_CTR) /* @@ -1032,7 +1432,19 @@ int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, unsigned char *output ) { int c, i; - size_t n = *nc_off; + size_t n; + + AES_VALIDATE_RET( ctx != NULL ); + AES_VALIDATE_RET( nc_off != NULL ); + AES_VALIDATE_RET( nonce_counter != NULL ); + AES_VALIDATE_RET( stream_block != NULL ); + AES_VALIDATE_RET( input != NULL ); + AES_VALIDATE_RET( output != NULL ); + + n = *nc_off; + + if ( n > 0x0F ) + return( MBEDTLS_ERR_AES_BAD_INPUT_DATA ); while( length-- ) { @@ -1171,6 +1583,72 @@ static const unsigned char aes_test_cfb128_ct[3][64] = }; #endif /* MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) +/* + * AES-OFB test vectors from: + * + * https://csrc.nist.gov/publications/detail/sp/800-38a/final + */ +static const unsigned char aes_test_ofb_key[3][32] = +{ + { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, + 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }, + { 0x8E, 0x73, 0xB0, 0xF7, 0xDA, 0x0E, 0x64, 0x52, + 0xC8, 0x10, 0xF3, 0x2B, 0x80, 0x90, 0x79, 0xE5, + 0x62, 0xF8, 0xEA, 0xD2, 0x52, 0x2C, 0x6B, 0x7B }, + { 0x60, 0x3D, 0xEB, 0x10, 0x15, 0xCA, 0x71, 0xBE, + 0x2B, 0x73, 0xAE, 0xF0, 0x85, 0x7D, 0x77, 0x81, + 0x1F, 0x35, 0x2C, 0x07, 0x3B, 0x61, 0x08, 0xD7, + 0x2D, 0x98, 0x10, 0xA3, 0x09, 0x14, 0xDF, 0xF4 } +}; + +static const unsigned char aes_test_ofb_iv[16] = +{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F +}; + +static const unsigned char aes_test_ofb_pt[64] = +{ + 0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96, + 0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A, + 0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C, + 0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51, + 0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11, + 0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF, + 0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17, + 0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10 +}; + +static const unsigned char aes_test_ofb_ct[3][64] = +{ + { 0x3B, 0x3F, 0xD9, 0x2E, 0xB7, 0x2D, 0xAD, 0x20, + 0x33, 0x34, 0x49, 0xF8, 0xE8, 0x3C, 0xFB, 0x4A, + 0x77, 0x89, 0x50, 0x8d, 0x16, 0x91, 0x8f, 0x03, + 0xf5, 0x3c, 0x52, 0xda, 0xc5, 0x4e, 0xd8, 0x25, + 0x97, 0x40, 0x05, 0x1e, 0x9c, 0x5f, 0xec, 0xf6, + 0x43, 0x44, 0xf7, 0xa8, 0x22, 0x60, 0xed, 0xcc, + 0x30, 0x4c, 0x65, 0x28, 0xf6, 0x59, 0xc7, 0x78, + 0x66, 0xa5, 0x10, 0xd9, 0xc1, 0xd6, 0xae, 0x5e }, + { 0xCD, 0xC8, 0x0D, 0x6F, 0xDD, 0xF1, 0x8C, 0xAB, + 0x34, 0xC2, 0x59, 0x09, 0xC9, 0x9A, 0x41, 0x74, + 0xfc, 0xc2, 0x8b, 0x8d, 0x4c, 0x63, 0x83, 0x7c, + 0x09, 0xe8, 0x17, 0x00, 0xc1, 0x10, 0x04, 0x01, + 0x8d, 0x9a, 0x9a, 0xea, 0xc0, 0xf6, 0x59, 0x6f, + 0x55, 0x9c, 0x6d, 0x4d, 0xaf, 0x59, 0xa5, 0xf2, + 0x6d, 0x9f, 0x20, 0x08, 0x57, 0xca, 0x6c, 0x3e, + 0x9c, 0xac, 0x52, 0x4b, 0xd9, 0xac, 0xc9, 0x2a }, + { 0xDC, 0x7E, 0x84, 0xBF, 0xDA, 0x79, 0x16, 0x4B, + 0x7E, 0xCD, 0x84, 0x86, 0x98, 0x5D, 0x38, 0x60, + 0x4f, 0xeb, 0xdc, 0x67, 0x40, 0xd2, 0x0b, 0x3a, + 0xc8, 0x8f, 0x6a, 0xd8, 0x2a, 0x4f, 0xb0, 0x8d, + 0x71, 0xab, 0x47, 0xa0, 0x86, 0xe8, 0x6e, 0xed, + 0xf3, 0x9d, 0x1c, 0x5b, 0xba, 0x97, 0xc4, 0x08, + 0x01, 0x26, 0x14, 0x1d, 0x67, 0xf3, 0x7b, 0xe8, + 0x53, 0x8f, 0x5a, 0x8b, 0xe7, 0x40, 0xe4, 0x84 } +}; +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + #if defined(MBEDTLS_CIPHER_MODE_CTR) /* * AES-CTR test vectors from: @@ -1234,6 +1712,74 @@ static const int aes_test_ctr_len[3] = { 16, 32, 36 }; #endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) +/* + * AES-XTS test vectors from: + * + * IEEE P1619/D16 Annex B + * https://web.archive.org/web/20150629024421/http://grouper.ieee.org/groups/1619/email/pdf00086.pdf + * (Archived from original at http://grouper.ieee.org/groups/1619/email/pdf00086.pdf) + */ +static const unsigned char aes_test_xts_key[][32] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }, + { 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, + 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }, +}; + +static const unsigned char aes_test_xts_pt32[][32] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, + { 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, +}; + +static const unsigned char aes_test_xts_ct32[][32] = +{ + { 0x91, 0x7c, 0xf6, 0x9e, 0xbd, 0x68, 0xb2, 0xec, + 0x9b, 0x9f, 0xe9, 0xa3, 0xea, 0xdd, 0xa6, 0x92, + 0xcd, 0x43, 0xd2, 0xf5, 0x95, 0x98, 0xed, 0x85, + 0x8c, 0x02, 0xc2, 0x65, 0x2f, 0xbf, 0x92, 0x2e }, + { 0xc4, 0x54, 0x18, 0x5e, 0x6a, 0x16, 0x93, 0x6e, + 0x39, 0x33, 0x40, 0x38, 0xac, 0xef, 0x83, 0x8b, + 0xfb, 0x18, 0x6f, 0xff, 0x74, 0x80, 0xad, 0xc4, + 0x28, 0x93, 0x82, 0xec, 0xd6, 0xd3, 0x94, 0xf0 }, + { 0xaf, 0x85, 0x33, 0x6b, 0x59, 0x7a, 0xfc, 0x1a, + 0x90, 0x0b, 0x2e, 0xb2, 0x1e, 0xc9, 0x49, 0xd2, + 0x92, 0xdf, 0x4c, 0x04, 0x7e, 0x0b, 0x21, 0x53, + 0x21, 0x86, 0xa5, 0x97, 0x1a, 0x22, 0x7a, 0x89 }, +}; + +static const unsigned char aes_test_xts_data_unit[][16] = +{ + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, + { 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, +}; + +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + /* * Checkup routine */ @@ -1250,11 +1796,14 @@ int mbedtls_aes_self_test( int verbose ) #if defined(MBEDTLS_CIPHER_MODE_CBC) unsigned char prv[16]; #endif -#if defined(MBEDTLS_CIPHER_MODE_CTR) || defined(MBEDTLS_CIPHER_MODE_CFB) +#if defined(MBEDTLS_CIPHER_MODE_CTR) || defined(MBEDTLS_CIPHER_MODE_CFB) || \ + defined(MBEDTLS_CIPHER_MODE_OFB) size_t offset; #endif -#if defined(MBEDTLS_CIPHER_MODE_CTR) +#if defined(MBEDTLS_CIPHER_MODE_CTR) || defined(MBEDTLS_CIPHER_MODE_XTS) int len; +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) unsigned char nonce_counter[16]; unsigned char stream_block[16]; #endif @@ -1294,7 +1843,7 @@ int mbedtls_aes_self_test( int verbose ) * there is an alternative underlying implementation i.e. when * MBEDTLS_AES_ALT is defined. */ - if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && keybits == 192 ) + if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) { mbedtls_printf( "skipped\n" ); continue; @@ -1358,7 +1907,7 @@ int mbedtls_aes_self_test( int verbose ) * there is an alternative underlying implementation i.e. when * MBEDTLS_AES_ALT is defined. */ - if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && keybits == 192 ) + if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) { mbedtls_printf( "skipped\n" ); continue; @@ -1423,7 +1972,7 @@ int mbedtls_aes_self_test( int verbose ) * there is an alternative underlying implementation i.e. when * MBEDTLS_AES_ALT is defined. */ - if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && keybits == 192 ) + if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) { mbedtls_printf( "skipped\n" ); continue; @@ -1462,6 +2011,69 @@ int mbedtls_aes_self_test( int verbose ) mbedtls_printf( "\n" ); #endif /* MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) + /* + * OFB mode + */ + for( i = 0; i < 6; i++ ) + { + u = i >> 1; + keybits = 128 + u * 64; + mode = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " AES-OFB-%3d (%s): ", keybits, + ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); + + memcpy( iv, aes_test_ofb_iv, 16 ); + memcpy( key, aes_test_ofb_key[u], keybits / 8 ); + + offset = 0; + ret = mbedtls_aes_setkey_enc( &ctx, key, keybits ); + /* + * AES-192 is an optional feature that may be unavailable when + * there is an alternative underlying implementation i.e. when + * MBEDTLS_AES_ALT is defined. + */ + if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && keybits == 192 ) + { + mbedtls_printf( "skipped\n" ); + continue; + } + else if( ret != 0 ) + { + goto exit; + } + + if( mode == MBEDTLS_AES_DECRYPT ) + { + memcpy( buf, aes_test_ofb_ct[u], 64 ); + aes_tests = aes_test_ofb_pt; + } + else + { + memcpy( buf, aes_test_ofb_pt, 64 ); + aes_tests = aes_test_ofb_ct[u]; + } + + ret = mbedtls_aes_crypt_ofb( &ctx, 64, &offset, iv, buf, buf ); + if( ret != 0 ) + goto exit; + + if( memcmp( buf, aes_tests, 64 ) != 0 ) + { + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + #if defined(MBEDTLS_CIPHER_MODE_CTR) /* * CTR mode @@ -1514,6 +2126,73 @@ int mbedtls_aes_self_test( int verbose ) mbedtls_printf( "\n" ); #endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) + { + static const int num_tests = + sizeof(aes_test_xts_key) / sizeof(*aes_test_xts_key); + mbedtls_aes_xts_context ctx_xts; + + /* + * XTS mode + */ + mbedtls_aes_xts_init( &ctx_xts ); + + for( i = 0; i < num_tests << 1; i++ ) + { + const unsigned char *data_unit; + u = i >> 1; + mode = i & 1; + + if( verbose != 0 ) + mbedtls_printf( " AES-XTS-128 (%s): ", + ( mode == MBEDTLS_AES_DECRYPT ) ? "dec" : "enc" ); + + memset( key, 0, sizeof( key ) ); + memcpy( key, aes_test_xts_key[u], 32 ); + data_unit = aes_test_xts_data_unit[u]; + + len = sizeof( *aes_test_xts_ct32 ); + + if( mode == MBEDTLS_AES_DECRYPT ) + { + ret = mbedtls_aes_xts_setkey_dec( &ctx_xts, key, 256 ); + if( ret != 0) + goto exit; + memcpy( buf, aes_test_xts_ct32[u], len ); + aes_tests = aes_test_xts_pt32[u]; + } + else + { + ret = mbedtls_aes_xts_setkey_enc( &ctx_xts, key, 256 ); + if( ret != 0) + goto exit; + memcpy( buf, aes_test_xts_pt32[u], len ); + aes_tests = aes_test_xts_ct32[u]; + } + + + ret = mbedtls_aes_crypt_xts( &ctx_xts, mode, len, data_unit, + buf, buf ); + if( ret != 0 ) + goto exit; + + if( memcmp( buf, aes_tests, len ) != 0 ) + { + ret = 1; + goto exit; + } + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + mbedtls_aes_xts_free( &ctx_xts ); + } +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + ret = 0; exit: diff --git a/3rdparty/mbedtls/mbedtls/library/aesni.c b/3rdparty/mbedtls/mbedtls/library/aesni.c index 1ca3c3ef5b..062708b047 100644 --- a/3rdparty/mbedtls/mbedtls/library/aesni.c +++ b/3rdparty/mbedtls/mbedtls/library/aesni.c @@ -32,6 +32,12 @@ #if defined(MBEDTLS_AESNI_C) +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) +#warning "MBEDTLS_AESNI_C is known to cause spurious error reports with some memory sanitizers as they do not understand the assembly code." +#endif +#endif + #include "mbedtls/aesni.h" #include diff --git a/3rdparty/mbedtls/mbedtls/library/arc4.c b/3rdparty/mbedtls/mbedtls/library/arc4.c index 05b33d3fdb..b8998ac6cd 100644 --- a/3rdparty/mbedtls/mbedtls/library/arc4.c +++ b/3rdparty/mbedtls/mbedtls/library/arc4.c @@ -33,6 +33,7 @@ #if defined(MBEDTLS_ARC4_C) #include "mbedtls/arc4.h" +#include "mbedtls/platform_util.h" #include @@ -47,11 +48,6 @@ #if !defined(MBEDTLS_ARC4_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} - void mbedtls_arc4_init( mbedtls_arc4_context *ctx ) { memset( ctx, 0, sizeof( mbedtls_arc4_context ) ); @@ -62,7 +58,7 @@ void mbedtls_arc4_free( mbedtls_arc4_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_arc4_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_arc4_context ) ); } /* diff --git a/3rdparty/mbedtls/mbedtls/library/aria.c b/3rdparty/mbedtls/mbedtls/library/aria.c new file mode 100644 index 0000000000..aff66d667f --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/aria.c @@ -0,0 +1,1079 @@ +/* + * ARIA implementation + * + * Copyright (C) 2006-2017, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +/* + * This implementation is based on the following standards: + * [1] http://210.104.33.10/ARIA/doc/ARIA-specification-e.pdf + * [2] https://tools.ietf.org/html/rfc5794 + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_ARIA_C) + +#include "mbedtls/aria.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_ARIA_ALT) + +#include "mbedtls/platform_util.h" + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +/* Parameter validation macros */ +#define ARIA_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ARIA_BAD_INPUT_DATA ) +#define ARIA_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +/* + * 32-bit integer manipulation macros (little endian) + */ +#ifndef GET_UINT32_LE +#define GET_UINT32_LE( n, b, i ) \ +{ \ + (n) = ( (uint32_t) (b)[(i) ] ) \ + | ( (uint32_t) (b)[(i) + 1] << 8 ) \ + | ( (uint32_t) (b)[(i) + 2] << 16 ) \ + | ( (uint32_t) (b)[(i) + 3] << 24 ); \ +} +#endif + +#ifndef PUT_UINT32_LE +#define PUT_UINT32_LE( n, b, i ) \ +{ \ + (b)[(i) ] = (unsigned char) ( ( (n) ) & 0xFF ); \ + (b)[(i) + 1] = (unsigned char) ( ( (n) >> 8 ) & 0xFF ); \ + (b)[(i) + 2] = (unsigned char) ( ( (n) >> 16 ) & 0xFF ); \ + (b)[(i) + 3] = (unsigned char) ( ( (n) >> 24 ) & 0xFF ); \ +} +#endif + +/* + * modify byte order: ( A B C D ) -> ( B A D C ), i.e. swap pairs of bytes + * + * This is submatrix P1 in [1] Appendix B.1 + * + * Common compilers fail to translate this to minimal number of instructions, + * so let's provide asm versions for common platforms with C fallback. + */ +#if defined(MBEDTLS_HAVE_ASM) +#if defined(__arm__) /* rev16 available from v6 up */ +/* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ +#if defined(__GNUC__) && \ + ( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 ) && \ + __ARM_ARCH >= 6 +static inline uint32_t aria_p1( uint32_t x ) +{ + uint32_t r; + __asm( "rev16 %0, %1" : "=l" (r) : "l" (x) ); + return( r ); +} +#define ARIA_P1 aria_p1 +#elif defined(__ARMCC_VERSION) && __ARMCC_VERSION < 6000000 && \ + ( __TARGET_ARCH_ARM >= 6 || __TARGET_ARCH_THUMB >= 3 ) +static inline uint32_t aria_p1( uint32_t x ) +{ + uint32_t r; + __asm( "rev16 r, x" ); + return( r ); +} +#define ARIA_P1 aria_p1 +#endif +#endif /* arm */ +#if defined(__GNUC__) && \ + defined(__i386__) || defined(__amd64__) || defined( __x86_64__) +/* I couldn't find an Intel equivalent of rev16, so two instructions */ +#define ARIA_P1(x) ARIA_P2( ARIA_P3( x ) ) +#endif /* x86 gnuc */ +#endif /* MBEDTLS_HAVE_ASM && GNUC */ +#if !defined(ARIA_P1) +#define ARIA_P1(x) ((((x) >> 8) & 0x00FF00FF) ^ (((x) & 0x00FF00FF) << 8)) +#endif + +/* + * modify byte order: ( A B C D ) -> ( C D A B ), i.e. rotate by 16 bits + * + * This is submatrix P2 in [1] Appendix B.1 + * + * Common compilers will translate this to a single instruction. + */ +#define ARIA_P2(x) (((x) >> 16) ^ ((x) << 16)) + +/* + * modify byte order: ( A B C D ) -> ( D C B A ), i.e. change endianness + * + * This is submatrix P3 in [1] Appendix B.1 + * + * Some compilers fail to translate this to a single instruction, + * so let's provide asm versions for common platforms with C fallback. + */ +#if defined(MBEDTLS_HAVE_ASM) +#if defined(__arm__) /* rev available from v6 up */ +/* armcc5 --gnu defines __GNUC__ but doesn't support GNU's extended asm */ +#if defined(__GNUC__) && \ + ( !defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000 ) && \ + __ARM_ARCH >= 6 +static inline uint32_t aria_p3( uint32_t x ) +{ + uint32_t r; + __asm( "rev %0, %1" : "=l" (r) : "l" (x) ); + return( r ); +} +#define ARIA_P3 aria_p3 +#elif defined(__ARMCC_VERSION) && __ARMCC_VERSION < 6000000 && \ + ( __TARGET_ARCH_ARM >= 6 || __TARGET_ARCH_THUMB >= 3 ) +static inline uint32_t aria_p3( uint32_t x ) +{ + uint32_t r; + __asm( "rev r, x" ); + return( r ); +} +#define ARIA_P3 aria_p3 +#endif +#endif /* arm */ +#if defined(__GNUC__) && \ + defined(__i386__) || defined(__amd64__) || defined( __x86_64__) +static inline uint32_t aria_p3( uint32_t x ) +{ + __asm( "bswap %0" : "=r" (x) : "0" (x) ); + return( x ); +} +#define ARIA_P3 aria_p3 +#endif /* x86 gnuc */ +#endif /* MBEDTLS_HAVE_ASM && GNUC */ +#if !defined(ARIA_P3) +#define ARIA_P3(x) ARIA_P2( ARIA_P1 ( x ) ) +#endif + +/* + * ARIA Affine Transform + * (a, b, c, d) = state in/out + * + * If we denote the first byte of input by 0, ..., the last byte by f, + * then inputs are: a = 0123, b = 4567, c = 89ab, d = cdef. + * + * Reading [1] 2.4 or [2] 2.4.3 in columns and performing simple + * rearrangements on adjacent pairs, output is: + * + * a = 3210 + 4545 + 6767 + 88aa + 99bb + dccd + effe + * = 3210 + 4567 + 6745 + 89ab + 98ba + dcfe + efcd + * b = 0101 + 2323 + 5476 + 8998 + baab + eecc + ffdd + * = 0123 + 2301 + 5476 + 89ab + ba98 + efcd + fedc + * c = 0022 + 1133 + 4554 + 7667 + ab89 + dcdc + fefe + * = 0123 + 1032 + 4567 + 7654 + ab89 + dcfe + fedc + * d = 1001 + 2332 + 6644 + 7755 + 9898 + baba + cdef + * = 1032 + 2301 + 6745 + 7654 + 98ba + ba98 + cdef + * + * Note: another presentation of the A transform can be found as the first + * half of App. B.1 in [1] in terms of 4-byte operators P1, P2, P3 and P4. + * The implementation below uses only P1 and P2 as they are sufficient. + */ +static inline void aria_a( uint32_t *a, uint32_t *b, + uint32_t *c, uint32_t *d ) +{ + uint32_t ta, tb, tc; + ta = *b; // 4567 + *b = *a; // 0123 + *a = ARIA_P2( ta ); // 6745 + tb = ARIA_P2( *d ); // efcd + *d = ARIA_P1( *c ); // 98ba + *c = ARIA_P1( tb ); // fedc + ta ^= *d; // 4567+98ba + tc = ARIA_P2( *b ); // 2301 + ta = ARIA_P1( ta ) ^ tc ^ *c; // 2301+5476+89ab+fedc + tb ^= ARIA_P2( *d ); // ba98+efcd + tc ^= ARIA_P1( *a ); // 2301+7654 + *b ^= ta ^ tb; // 0123+2301+5476+89ab+ba98+efcd+fedc OUT + tb = ARIA_P2( tb ) ^ ta; // 2301+5476+89ab+98ba+cdef+fedc + *a ^= ARIA_P1( tb ); // 3210+4567+6745+89ab+98ba+dcfe+efcd OUT + ta = ARIA_P2( ta ); // 0123+7654+ab89+dcfe + *d ^= ARIA_P1( ta ) ^ tc; // 1032+2301+6745+7654+98ba+ba98+cdef OUT + tc = ARIA_P2( tc ); // 0123+5476 + *c ^= ARIA_P1( tc ) ^ ta; // 0123+1032+4567+7654+ab89+dcfe+fedc OUT +} + +/* + * ARIA Substitution Layer SL1 / SL2 + * (a, b, c, d) = state in/out + * (sa, sb, sc, sd) = 256 8-bit S-Boxes (see below) + * + * By passing sb1, sb2, is1, is2 as S-Boxes you get SL1 + * By passing is1, is2, sb1, sb2 as S-Boxes you get SL2 + */ +static inline void aria_sl( uint32_t *a, uint32_t *b, + uint32_t *c, uint32_t *d, + const uint8_t sa[256], const uint8_t sb[256], + const uint8_t sc[256], const uint8_t sd[256] ) +{ + *a = ( (uint32_t) sa[ *a & 0xFF] ) ^ + (((uint32_t) sb[(*a >> 8) & 0xFF]) << 8) ^ + (((uint32_t) sc[(*a >> 16) & 0xFF]) << 16) ^ + (((uint32_t) sd[ *a >> 24 ]) << 24); + *b = ( (uint32_t) sa[ *b & 0xFF] ) ^ + (((uint32_t) sb[(*b >> 8) & 0xFF]) << 8) ^ + (((uint32_t) sc[(*b >> 16) & 0xFF]) << 16) ^ + (((uint32_t) sd[ *b >> 24 ]) << 24); + *c = ( (uint32_t) sa[ *c & 0xFF] ) ^ + (((uint32_t) sb[(*c >> 8) & 0xFF]) << 8) ^ + (((uint32_t) sc[(*c >> 16) & 0xFF]) << 16) ^ + (((uint32_t) sd[ *c >> 24 ]) << 24); + *d = ( (uint32_t) sa[ *d & 0xFF] ) ^ + (((uint32_t) sb[(*d >> 8) & 0xFF]) << 8) ^ + (((uint32_t) sc[(*d >> 16) & 0xFF]) << 16) ^ + (((uint32_t) sd[ *d >> 24 ]) << 24); +} + +/* + * S-Boxes + */ +static const uint8_t aria_sb1[256] = +{ + 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, + 0xFE, 0xD7, 0xAB, 0x76, 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, + 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, 0xB7, 0xFD, 0x93, 0x26, + 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, + 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, + 0xEB, 0x27, 0xB2, 0x75, 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, + 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, 0x53, 0xD1, 0x00, 0xED, + 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, + 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, + 0x50, 0x3C, 0x9F, 0xA8, 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, + 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, 0xCD, 0x0C, 0x13, 0xEC, + 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, + 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, + 0xDE, 0x5E, 0x0B, 0xDB, 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, + 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, 0xE7, 0xC8, 0x37, 0x6D, + 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, + 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, + 0x4B, 0xBD, 0x8B, 0x8A, 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, + 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, 0xE1, 0xF8, 0x98, 0x11, + 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, + 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, + 0xB0, 0x54, 0xBB, 0x16 +}; + +static const uint8_t aria_sb2[256] = +{ + 0xE2, 0x4E, 0x54, 0xFC, 0x94, 0xC2, 0x4A, 0xCC, 0x62, 0x0D, 0x6A, 0x46, + 0x3C, 0x4D, 0x8B, 0xD1, 0x5E, 0xFA, 0x64, 0xCB, 0xB4, 0x97, 0xBE, 0x2B, + 0xBC, 0x77, 0x2E, 0x03, 0xD3, 0x19, 0x59, 0xC1, 0x1D, 0x06, 0x41, 0x6B, + 0x55, 0xF0, 0x99, 0x69, 0xEA, 0x9C, 0x18, 0xAE, 0x63, 0xDF, 0xE7, 0xBB, + 0x00, 0x73, 0x66, 0xFB, 0x96, 0x4C, 0x85, 0xE4, 0x3A, 0x09, 0x45, 0xAA, + 0x0F, 0xEE, 0x10, 0xEB, 0x2D, 0x7F, 0xF4, 0x29, 0xAC, 0xCF, 0xAD, 0x91, + 0x8D, 0x78, 0xC8, 0x95, 0xF9, 0x2F, 0xCE, 0xCD, 0x08, 0x7A, 0x88, 0x38, + 0x5C, 0x83, 0x2A, 0x28, 0x47, 0xDB, 0xB8, 0xC7, 0x93, 0xA4, 0x12, 0x53, + 0xFF, 0x87, 0x0E, 0x31, 0x36, 0x21, 0x58, 0x48, 0x01, 0x8E, 0x37, 0x74, + 0x32, 0xCA, 0xE9, 0xB1, 0xB7, 0xAB, 0x0C, 0xD7, 0xC4, 0x56, 0x42, 0x26, + 0x07, 0x98, 0x60, 0xD9, 0xB6, 0xB9, 0x11, 0x40, 0xEC, 0x20, 0x8C, 0xBD, + 0xA0, 0xC9, 0x84, 0x04, 0x49, 0x23, 0xF1, 0x4F, 0x50, 0x1F, 0x13, 0xDC, + 0xD8, 0xC0, 0x9E, 0x57, 0xE3, 0xC3, 0x7B, 0x65, 0x3B, 0x02, 0x8F, 0x3E, + 0xE8, 0x25, 0x92, 0xE5, 0x15, 0xDD, 0xFD, 0x17, 0xA9, 0xBF, 0xD4, 0x9A, + 0x7E, 0xC5, 0x39, 0x67, 0xFE, 0x76, 0x9D, 0x43, 0xA7, 0xE1, 0xD0, 0xF5, + 0x68, 0xF2, 0x1B, 0x34, 0x70, 0x05, 0xA3, 0x8A, 0xD5, 0x79, 0x86, 0xA8, + 0x30, 0xC6, 0x51, 0x4B, 0x1E, 0xA6, 0x27, 0xF6, 0x35, 0xD2, 0x6E, 0x24, + 0x16, 0x82, 0x5F, 0xDA, 0xE6, 0x75, 0xA2, 0xEF, 0x2C, 0xB2, 0x1C, 0x9F, + 0x5D, 0x6F, 0x80, 0x0A, 0x72, 0x44, 0x9B, 0x6C, 0x90, 0x0B, 0x5B, 0x33, + 0x7D, 0x5A, 0x52, 0xF3, 0x61, 0xA1, 0xF7, 0xB0, 0xD6, 0x3F, 0x7C, 0x6D, + 0xED, 0x14, 0xE0, 0xA5, 0x3D, 0x22, 0xB3, 0xF8, 0x89, 0xDE, 0x71, 0x1A, + 0xAF, 0xBA, 0xB5, 0x81 +}; + +static const uint8_t aria_is1[256] = +{ + 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, + 0x81, 0xF3, 0xD7, 0xFB, 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, + 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, 0x54, 0x7B, 0x94, 0x32, + 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, + 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, + 0x6D, 0x8B, 0xD1, 0x25, 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, + 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, 0x6C, 0x70, 0x48, 0x50, + 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, + 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, + 0xB8, 0xB3, 0x45, 0x06, 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, + 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, 0x3A, 0x91, 0x11, 0x41, + 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, + 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, + 0x1C, 0x75, 0xDF, 0x6E, 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, + 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, 0xFC, 0x56, 0x3E, 0x4B, + 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, + 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, + 0x27, 0x80, 0xEC, 0x5F, 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, + 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, 0xA0, 0xE0, 0x3B, 0x4D, + 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, + 0x55, 0x21, 0x0C, 0x7D +}; + +static const uint8_t aria_is2[256] = +{ + 0x30, 0x68, 0x99, 0x1B, 0x87, 0xB9, 0x21, 0x78, 0x50, 0x39, 0xDB, 0xE1, + 0x72, 0x09, 0x62, 0x3C, 0x3E, 0x7E, 0x5E, 0x8E, 0xF1, 0xA0, 0xCC, 0xA3, + 0x2A, 0x1D, 0xFB, 0xB6, 0xD6, 0x20, 0xC4, 0x8D, 0x81, 0x65, 0xF5, 0x89, + 0xCB, 0x9D, 0x77, 0xC6, 0x57, 0x43, 0x56, 0x17, 0xD4, 0x40, 0x1A, 0x4D, + 0xC0, 0x63, 0x6C, 0xE3, 0xB7, 0xC8, 0x64, 0x6A, 0x53, 0xAA, 0x38, 0x98, + 0x0C, 0xF4, 0x9B, 0xED, 0x7F, 0x22, 0x76, 0xAF, 0xDD, 0x3A, 0x0B, 0x58, + 0x67, 0x88, 0x06, 0xC3, 0x35, 0x0D, 0x01, 0x8B, 0x8C, 0xC2, 0xE6, 0x5F, + 0x02, 0x24, 0x75, 0x93, 0x66, 0x1E, 0xE5, 0xE2, 0x54, 0xD8, 0x10, 0xCE, + 0x7A, 0xE8, 0x08, 0x2C, 0x12, 0x97, 0x32, 0xAB, 0xB4, 0x27, 0x0A, 0x23, + 0xDF, 0xEF, 0xCA, 0xD9, 0xB8, 0xFA, 0xDC, 0x31, 0x6B, 0xD1, 0xAD, 0x19, + 0x49, 0xBD, 0x51, 0x96, 0xEE, 0xE4, 0xA8, 0x41, 0xDA, 0xFF, 0xCD, 0x55, + 0x86, 0x36, 0xBE, 0x61, 0x52, 0xF8, 0xBB, 0x0E, 0x82, 0x48, 0x69, 0x9A, + 0xE0, 0x47, 0x9E, 0x5C, 0x04, 0x4B, 0x34, 0x15, 0x79, 0x26, 0xA7, 0xDE, + 0x29, 0xAE, 0x92, 0xD7, 0x84, 0xE9, 0xD2, 0xBA, 0x5D, 0xF3, 0xC5, 0xB0, + 0xBF, 0xA4, 0x3B, 0x71, 0x44, 0x46, 0x2B, 0xFC, 0xEB, 0x6F, 0xD5, 0xF6, + 0x14, 0xFE, 0x7C, 0x70, 0x5A, 0x7D, 0xFD, 0x2F, 0x18, 0x83, 0x16, 0xA5, + 0x91, 0x1F, 0x05, 0x95, 0x74, 0xA9, 0xC1, 0x5B, 0x4A, 0x85, 0x6D, 0x13, + 0x07, 0x4F, 0x4E, 0x45, 0xB2, 0x0F, 0xC9, 0x1C, 0xA6, 0xBC, 0xEC, 0x73, + 0x90, 0x7B, 0xCF, 0x59, 0x8F, 0xA1, 0xF9, 0x2D, 0xF2, 0xB1, 0x00, 0x94, + 0x37, 0x9F, 0xD0, 0x2E, 0x9C, 0x6E, 0x28, 0x3F, 0x80, 0xF0, 0x3D, 0xD3, + 0x25, 0x8A, 0xB5, 0xE7, 0x42, 0xB3, 0xC7, 0xEA, 0xF7, 0x4C, 0x11, 0x33, + 0x03, 0xA2, 0xAC, 0x60 +}; + +/* + * Helper for key schedule: r = FO( p, k ) ^ x + */ +static void aria_fo_xor( uint32_t r[4], const uint32_t p[4], + const uint32_t k[4], const uint32_t x[4] ) +{ + uint32_t a, b, c, d; + + a = p[0] ^ k[0]; + b = p[1] ^ k[1]; + c = p[2] ^ k[2]; + d = p[3] ^ k[3]; + + aria_sl( &a, &b, &c, &d, aria_sb1, aria_sb2, aria_is1, aria_is2 ); + aria_a( &a, &b, &c, &d ); + + r[0] = a ^ x[0]; + r[1] = b ^ x[1]; + r[2] = c ^ x[2]; + r[3] = d ^ x[3]; +} + +/* + * Helper for key schedule: r = FE( p, k ) ^ x + */ +static void aria_fe_xor( uint32_t r[4], const uint32_t p[4], + const uint32_t k[4], const uint32_t x[4] ) +{ + uint32_t a, b, c, d; + + a = p[0] ^ k[0]; + b = p[1] ^ k[1]; + c = p[2] ^ k[2]; + d = p[3] ^ k[3]; + + aria_sl( &a, &b, &c, &d, aria_is1, aria_is2, aria_sb1, aria_sb2 ); + aria_a( &a, &b, &c, &d ); + + r[0] = a ^ x[0]; + r[1] = b ^ x[1]; + r[2] = c ^ x[2]; + r[3] = d ^ x[3]; +} + +/* + * Big endian 128-bit rotation: r = a ^ (b <<< n), used only in key setup. + * + * We chose to store bytes into 32-bit words in little-endian format (see + * GET/PUT_UINT32_LE) so we need to reverse bytes here. + */ +static void aria_rot128( uint32_t r[4], const uint32_t a[4], + const uint32_t b[4], uint8_t n ) +{ + uint8_t i, j; + uint32_t t, u; + + const uint8_t n1 = n % 32; // bit offset + const uint8_t n2 = n1 ? 32 - n1 : 0; // reverse bit offset + + j = ( n / 32 ) % 4; // initial word offset + t = ARIA_P3( b[j] ); // big endian + for( i = 0; i < 4; i++ ) + { + j = ( j + 1 ) % 4; // get next word, big endian + u = ARIA_P3( b[j] ); + t <<= n1; // rotate + t |= u >> n2; + t = ARIA_P3( t ); // back to little endian + r[i] = a[i] ^ t; // store + t = u; // move to next word + } +} + +/* + * Set encryption key + */ +int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, + const unsigned char *key, unsigned int keybits ) +{ + /* round constant masks */ + const uint32_t rc[3][4] = + { + { 0xB7C17C51, 0x940A2227, 0xE8AB13FE, 0xE06E9AFA }, + { 0xCC4AB16D, 0x20C8219E, 0xD5B128FF, 0xB0E25DEF }, + { 0x1D3792DB, 0x70E92621, 0x75972403, 0x0EC9E804 } + }; + + int i; + uint32_t w[4][4], *w2; + ARIA_VALIDATE_RET( ctx != NULL ); + ARIA_VALIDATE_RET( key != NULL ); + + if( keybits != 128 && keybits != 192 && keybits != 256 ) + return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA ); + + /* Copy key to W0 (and potential remainder to W1) */ + GET_UINT32_LE( w[0][0], key, 0 ); + GET_UINT32_LE( w[0][1], key, 4 ); + GET_UINT32_LE( w[0][2], key, 8 ); + GET_UINT32_LE( w[0][3], key, 12 ); + + memset( w[1], 0, 16 ); + if( keybits >= 192 ) + { + GET_UINT32_LE( w[1][0], key, 16 ); // 192 bit key + GET_UINT32_LE( w[1][1], key, 20 ); + } + if( keybits == 256 ) + { + GET_UINT32_LE( w[1][2], key, 24 ); // 256 bit key + GET_UINT32_LE( w[1][3], key, 28 ); + } + + i = ( keybits - 128 ) >> 6; // index: 0, 1, 2 + ctx->nr = 12 + 2 * i; // no. rounds: 12, 14, 16 + + aria_fo_xor( w[1], w[0], rc[i], w[1] ); // W1 = FO(W0, CK1) ^ KR + i = i < 2 ? i + 1 : 0; + aria_fe_xor( w[2], w[1], rc[i], w[0] ); // W2 = FE(W1, CK2) ^ W0 + i = i < 2 ? i + 1 : 0; + aria_fo_xor( w[3], w[2], rc[i], w[1] ); // W3 = FO(W2, CK3) ^ W1 + + for( i = 0; i < 4; i++ ) // create round keys + { + w2 = w[(i + 1) & 3]; + aria_rot128( ctx->rk[i ], w[i], w2, 128 - 19 ); + aria_rot128( ctx->rk[i + 4], w[i], w2, 128 - 31 ); + aria_rot128( ctx->rk[i + 8], w[i], w2, 61 ); + aria_rot128( ctx->rk[i + 12], w[i], w2, 31 ); + } + aria_rot128( ctx->rk[16], w[0], w[1], 19 ); + + /* w holds enough info to reconstruct the round keys */ + mbedtls_platform_zeroize( w, sizeof( w ) ); + + return( 0 ); +} + +/* + * Set decryption key + */ +int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx, + const unsigned char *key, unsigned int keybits ) +{ + int i, j, k, ret; + ARIA_VALIDATE_RET( ctx != NULL ); + ARIA_VALIDATE_RET( key != NULL ); + + ret = mbedtls_aria_setkey_enc( ctx, key, keybits ); + if( ret != 0 ) + return( ret ); + + /* flip the order of round keys */ + for( i = 0, j = ctx->nr; i < j; i++, j-- ) + { + for( k = 0; k < 4; k++ ) + { + uint32_t t = ctx->rk[i][k]; + ctx->rk[i][k] = ctx->rk[j][k]; + ctx->rk[j][k] = t; + } + } + + /* apply affine transform to middle keys */ + for( i = 1; i < ctx->nr; i++ ) + { + aria_a( &ctx->rk[i][0], &ctx->rk[i][1], + &ctx->rk[i][2], &ctx->rk[i][3] ); + } + + return( 0 ); +} + +/* + * Encrypt a block + */ +int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, + const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], + unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] ) +{ + int i; + + uint32_t a, b, c, d; + ARIA_VALIDATE_RET( ctx != NULL ); + ARIA_VALIDATE_RET( input != NULL ); + ARIA_VALIDATE_RET( output != NULL ); + + GET_UINT32_LE( a, input, 0 ); + GET_UINT32_LE( b, input, 4 ); + GET_UINT32_LE( c, input, 8 ); + GET_UINT32_LE( d, input, 12 ); + + i = 0; + while( 1 ) + { + a ^= ctx->rk[i][0]; + b ^= ctx->rk[i][1]; + c ^= ctx->rk[i][2]; + d ^= ctx->rk[i][3]; + i++; + + aria_sl( &a, &b, &c, &d, aria_sb1, aria_sb2, aria_is1, aria_is2 ); + aria_a( &a, &b, &c, &d ); + + a ^= ctx->rk[i][0]; + b ^= ctx->rk[i][1]; + c ^= ctx->rk[i][2]; + d ^= ctx->rk[i][3]; + i++; + + aria_sl( &a, &b, &c, &d, aria_is1, aria_is2, aria_sb1, aria_sb2 ); + if( i >= ctx->nr ) + break; + aria_a( &a, &b, &c, &d ); + } + + /* final key mixing */ + a ^= ctx->rk[i][0]; + b ^= ctx->rk[i][1]; + c ^= ctx->rk[i][2]; + d ^= ctx->rk[i][3]; + + PUT_UINT32_LE( a, output, 0 ); + PUT_UINT32_LE( b, output, 4 ); + PUT_UINT32_LE( c, output, 8 ); + PUT_UINT32_LE( d, output, 12 ); + + return( 0 ); +} + +/* Initialize context */ +void mbedtls_aria_init( mbedtls_aria_context *ctx ) +{ + ARIA_VALIDATE( ctx != NULL ); + memset( ctx, 0, sizeof( mbedtls_aria_context ) ); +} + +/* Clear context */ +void mbedtls_aria_free( mbedtls_aria_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_aria_context ) ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * ARIA-CBC buffer encryption/decryption + */ +int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx, + int mode, + size_t length, + unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ) +{ + int i; + unsigned char temp[MBEDTLS_ARIA_BLOCKSIZE]; + + ARIA_VALIDATE_RET( ctx != NULL ); + ARIA_VALIDATE_RET( mode == MBEDTLS_ARIA_ENCRYPT || + mode == MBEDTLS_ARIA_DECRYPT ); + ARIA_VALIDATE_RET( length == 0 || input != NULL ); + ARIA_VALIDATE_RET( length == 0 || output != NULL ); + ARIA_VALIDATE_RET( iv != NULL ); + + if( length % MBEDTLS_ARIA_BLOCKSIZE ) + return( MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH ); + + if( mode == MBEDTLS_ARIA_DECRYPT ) + { + while( length > 0 ) + { + memcpy( temp, input, MBEDTLS_ARIA_BLOCKSIZE ); + mbedtls_aria_crypt_ecb( ctx, input, output ); + + for( i = 0; i < MBEDTLS_ARIA_BLOCKSIZE; i++ ) + output[i] = (unsigned char)( output[i] ^ iv[i] ); + + memcpy( iv, temp, MBEDTLS_ARIA_BLOCKSIZE ); + + input += MBEDTLS_ARIA_BLOCKSIZE; + output += MBEDTLS_ARIA_BLOCKSIZE; + length -= MBEDTLS_ARIA_BLOCKSIZE; + } + } + else + { + while( length > 0 ) + { + for( i = 0; i < MBEDTLS_ARIA_BLOCKSIZE; i++ ) + output[i] = (unsigned char)( input[i] ^ iv[i] ); + + mbedtls_aria_crypt_ecb( ctx, output, output ); + memcpy( iv, output, MBEDTLS_ARIA_BLOCKSIZE ); + + input += MBEDTLS_ARIA_BLOCKSIZE; + output += MBEDTLS_ARIA_BLOCKSIZE; + length -= MBEDTLS_ARIA_BLOCKSIZE; + } + } + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +/* + * ARIA-CFB128 buffer encryption/decryption + */ +int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx, + int mode, + size_t length, + size_t *iv_off, + unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ) +{ + unsigned char c; + size_t n; + + ARIA_VALIDATE_RET( ctx != NULL ); + ARIA_VALIDATE_RET( mode == MBEDTLS_ARIA_ENCRYPT || + mode == MBEDTLS_ARIA_DECRYPT ); + ARIA_VALIDATE_RET( length == 0 || input != NULL ); + ARIA_VALIDATE_RET( length == 0 || output != NULL ); + ARIA_VALIDATE_RET( iv != NULL ); + ARIA_VALIDATE_RET( iv_off != NULL ); + + n = *iv_off; + + /* An overly large value of n can lead to an unlimited + * buffer overflow. Therefore, guard against this + * outside of parameter validation. */ + if( n >= MBEDTLS_ARIA_BLOCKSIZE ) + return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA ); + + if( mode == MBEDTLS_ARIA_DECRYPT ) + { + while( length-- ) + { + if( n == 0 ) + mbedtls_aria_crypt_ecb( ctx, iv, iv ); + + c = *input++; + *output++ = c ^ iv[n]; + iv[n] = c; + + n = ( n + 1 ) & 0x0F; + } + } + else + { + while( length-- ) + { + if( n == 0 ) + mbedtls_aria_crypt_ecb( ctx, iv, iv ); + + iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); + + n = ( n + 1 ) & 0x0F; + } + } + + *iv_off = n; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * ARIA-CTR buffer encryption/decryption + */ +int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx, + size_t length, + size_t *nc_off, + unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE], + unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE], + const unsigned char *input, + unsigned char *output ) +{ + int c, i; + size_t n; + + ARIA_VALIDATE_RET( ctx != NULL ); + ARIA_VALIDATE_RET( length == 0 || input != NULL ); + ARIA_VALIDATE_RET( length == 0 || output != NULL ); + ARIA_VALIDATE_RET( nonce_counter != NULL ); + ARIA_VALIDATE_RET( stream_block != NULL ); + ARIA_VALIDATE_RET( nc_off != NULL ); + + n = *nc_off; + /* An overly large value of n can lead to an unlimited + * buffer overflow. Therefore, guard against this + * outside of parameter validation. */ + if( n >= MBEDTLS_ARIA_BLOCKSIZE ) + return( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA ); + + while( length-- ) + { + if( n == 0 ) { + mbedtls_aria_crypt_ecb( ctx, nonce_counter, + stream_block ); + + for( i = MBEDTLS_ARIA_BLOCKSIZE; i > 0; i-- ) + if( ++nonce_counter[i - 1] != 0 ) + break; + } + c = *input++; + *output++ = (unsigned char)( c ^ stream_block[n] ); + + n = ( n + 1 ) & 0x0F; + } + + *nc_off = n; + + return( 0 ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ +#endif /* !MBEDTLS_ARIA_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +/* + * Basic ARIA ECB test vectors from RFC 5794 + */ +static const uint8_t aria_test1_ecb_key[32] = // test key +{ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // 128 bit + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, // 192 bit + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F // 256 bit +}; + +static const uint8_t aria_test1_ecb_pt[MBEDTLS_ARIA_BLOCKSIZE] = // plaintext +{ + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // same for all + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF // key sizes +}; + +static const uint8_t aria_test1_ecb_ct[3][MBEDTLS_ARIA_BLOCKSIZE] = // ciphertext +{ + { 0xD7, 0x18, 0xFB, 0xD6, 0xAB, 0x64, 0x4C, 0x73, // 128 bit + 0x9D, 0xA9, 0x5F, 0x3B, 0xE6, 0x45, 0x17, 0x78 }, + { 0x26, 0x44, 0x9C, 0x18, 0x05, 0xDB, 0xE7, 0xAA, // 192 bit + 0x25, 0xA4, 0x68, 0xCE, 0x26, 0x3A, 0x9E, 0x79 }, + { 0xF9, 0x2B, 0xD7, 0xC7, 0x9F, 0xB7, 0x2E, 0x2F, // 256 bit + 0x2B, 0x8F, 0x80, 0xC1, 0x97, 0x2D, 0x24, 0xFC } +}; + +/* + * Mode tests from "Test Vectors for ARIA" Version 1.0 + * http://210.104.33.10/ARIA/doc/ARIA-testvector-e.pdf + */ +#if (defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB) || \ + defined(MBEDTLS_CIPHER_MODE_CTR)) +static const uint8_t aria_test2_key[32] = +{ + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // 128 bit + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, + 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // 192 bit + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff // 256 bit +}; + +static const uint8_t aria_test2_pt[48] = +{ + 0x11, 0x11, 0x11, 0x11, 0xaa, 0xaa, 0xaa, 0xaa, // same for all + 0x11, 0x11, 0x11, 0x11, 0xbb, 0xbb, 0xbb, 0xbb, + 0x11, 0x11, 0x11, 0x11, 0xcc, 0xcc, 0xcc, 0xcc, + 0x11, 0x11, 0x11, 0x11, 0xdd, 0xdd, 0xdd, 0xdd, + 0x22, 0x22, 0x22, 0x22, 0xaa, 0xaa, 0xaa, 0xaa, + 0x22, 0x22, 0x22, 0x22, 0xbb, 0xbb, 0xbb, 0xbb, +}; +#endif + +#if (defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB)) +static const uint8_t aria_test2_iv[MBEDTLS_ARIA_BLOCKSIZE] = +{ + 0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78, // same for CBC, CFB + 0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0 // CTR has zero IV +}; +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const uint8_t aria_test2_cbc_ct[3][48] = // CBC ciphertext +{ + { 0x49, 0xd6, 0x18, 0x60, 0xb1, 0x49, 0x09, 0x10, // 128-bit key + 0x9c, 0xef, 0x0d, 0x22, 0xa9, 0x26, 0x81, 0x34, + 0xfa, 0xdf, 0x9f, 0xb2, 0x31, 0x51, 0xe9, 0x64, + 0x5f, 0xba, 0x75, 0x01, 0x8b, 0xdb, 0x15, 0x38, + 0xb5, 0x33, 0x34, 0x63, 0x4b, 0xbf, 0x7d, 0x4c, + 0xd4, 0xb5, 0x37, 0x70, 0x33, 0x06, 0x0c, 0x15 }, + { 0xaf, 0xe6, 0xcf, 0x23, 0x97, 0x4b, 0x53, 0x3c, // 192-bit key + 0x67, 0x2a, 0x82, 0x62, 0x64, 0xea, 0x78, 0x5f, + 0x4e, 0x4f, 0x7f, 0x78, 0x0d, 0xc7, 0xf3, 0xf1, + 0xe0, 0x96, 0x2b, 0x80, 0x90, 0x23, 0x86, 0xd5, + 0x14, 0xe9, 0xc3, 0xe7, 0x72, 0x59, 0xde, 0x92, + 0xdd, 0x11, 0x02, 0xff, 0xab, 0x08, 0x6c, 0x1e }, + { 0x52, 0x3a, 0x8a, 0x80, 0x6a, 0xe6, 0x21, 0xf1, // 256-bit key + 0x55, 0xfd, 0xd2, 0x8d, 0xbc, 0x34, 0xe1, 0xab, + 0x7b, 0x9b, 0x42, 0x43, 0x2a, 0xd8, 0xb2, 0xef, + 0xb9, 0x6e, 0x23, 0xb1, 0x3f, 0x0a, 0x6e, 0x52, + 0xf3, 0x61, 0x85, 0xd5, 0x0a, 0xd0, 0x02, 0xc5, + 0xf6, 0x01, 0xbe, 0xe5, 0x49, 0x3f, 0x11, 0x8b } +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static const uint8_t aria_test2_cfb_ct[3][48] = // CFB ciphertext +{ + { 0x37, 0x20, 0xe5, 0x3b, 0xa7, 0xd6, 0x15, 0x38, // 128-bit key + 0x34, 0x06, 0xb0, 0x9f, 0x0a, 0x05, 0xa2, 0x00, + 0xc0, 0x7c, 0x21, 0xe6, 0x37, 0x0f, 0x41, 0x3a, + 0x5d, 0x13, 0x25, 0x00, 0xa6, 0x82, 0x85, 0x01, + 0x7c, 0x61, 0xb4, 0x34, 0xc7, 0xb7, 0xca, 0x96, + 0x85, 0xa5, 0x10, 0x71, 0x86, 0x1e, 0x4d, 0x4b }, + { 0x41, 0x71, 0xf7, 0x19, 0x2b, 0xf4, 0x49, 0x54, // 192-bit key + 0x94, 0xd2, 0x73, 0x61, 0x29, 0x64, 0x0f, 0x5c, + 0x4d, 0x87, 0xa9, 0xa2, 0x13, 0x66, 0x4c, 0x94, + 0x48, 0x47, 0x7c, 0x6e, 0xcc, 0x20, 0x13, 0x59, + 0x8d, 0x97, 0x66, 0x95, 0x2d, 0xd8, 0xc3, 0x86, + 0x8f, 0x17, 0xe3, 0x6e, 0xf6, 0x6f, 0xd8, 0x4b }, + { 0x26, 0x83, 0x47, 0x05, 0xb0, 0xf2, 0xc0, 0xe2, // 256-bit key + 0x58, 0x8d, 0x4a, 0x7f, 0x09, 0x00, 0x96, 0x35, + 0xf2, 0x8b, 0xb9, 0x3d, 0x8c, 0x31, 0xf8, 0x70, + 0xec, 0x1e, 0x0b, 0xdb, 0x08, 0x2b, 0x66, 0xfa, + 0x40, 0x2d, 0xd9, 0xc2, 0x02, 0xbe, 0x30, 0x0c, + 0x45, 0x17, 0xd1, 0x96, 0xb1, 0x4d, 0x4c, 0xe1 } +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static const uint8_t aria_test2_ctr_ct[3][48] = // CTR ciphertext +{ + { 0xac, 0x5d, 0x7d, 0xe8, 0x05, 0xa0, 0xbf, 0x1c, // 128-bit key + 0x57, 0xc8, 0x54, 0x50, 0x1a, 0xf6, 0x0f, 0xa1, + 0x14, 0x97, 0xe2, 0xa3, 0x45, 0x19, 0xde, 0xa1, + 0x56, 0x9e, 0x91, 0xe5, 0xb5, 0xcc, 0xae, 0x2f, + 0xf3, 0xbf, 0xa1, 0xbf, 0x97, 0x5f, 0x45, 0x71, + 0xf4, 0x8b, 0xe1, 0x91, 0x61, 0x35, 0x46, 0xc3 }, + { 0x08, 0x62, 0x5c, 0xa8, 0xfe, 0x56, 0x9c, 0x19, // 192-bit key + 0xba, 0x7a, 0xf3, 0x76, 0x0a, 0x6e, 0xd1, 0xce, + 0xf4, 0xd1, 0x99, 0x26, 0x3e, 0x99, 0x9d, 0xde, + 0x14, 0x08, 0x2d, 0xbb, 0xa7, 0x56, 0x0b, 0x79, + 0xa4, 0xc6, 0xb4, 0x56, 0xb8, 0x70, 0x7d, 0xce, + 0x75, 0x1f, 0x98, 0x54, 0xf1, 0x88, 0x93, 0xdf }, + { 0x30, 0x02, 0x6c, 0x32, 0x96, 0x66, 0x14, 0x17, // 256-bit key + 0x21, 0x17, 0x8b, 0x99, 0xc0, 0xa1, 0xf1, 0xb2, + 0xf0, 0x69, 0x40, 0x25, 0x3f, 0x7b, 0x30, 0x89, + 0xe2, 0xa3, 0x0e, 0xa8, 0x6a, 0xa3, 0xc8, 0x8f, + 0x59, 0x40, 0xf0, 0x5a, 0xd7, 0xee, 0x41, 0xd7, + 0x13, 0x47, 0xbb, 0x72, 0x61, 0xe3, 0x48, 0xf1 } +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#define ARIA_SELF_TEST_IF_FAIL \ + { \ + if( verbose ) \ + mbedtls_printf( "failed\n" ); \ + return( 1 ); \ + } else { \ + if( verbose ) \ + mbedtls_printf( "passed\n" ); \ + } + +/* + * Checkup routine + */ +int mbedtls_aria_self_test( int verbose ) +{ + int i; + uint8_t blk[MBEDTLS_ARIA_BLOCKSIZE]; + mbedtls_aria_context ctx; + +#if (defined(MBEDTLS_CIPHER_MODE_CFB) || defined(MBEDTLS_CIPHER_MODE_CTR)) + size_t j; +#endif + +#if (defined(MBEDTLS_CIPHER_MODE_CBC) || \ + defined(MBEDTLS_CIPHER_MODE_CFB) || \ + defined(MBEDTLS_CIPHER_MODE_CTR)) + uint8_t buf[48], iv[MBEDTLS_ARIA_BLOCKSIZE]; +#endif + + /* + * Test set 1 + */ + for( i = 0; i < 3; i++ ) + { + /* test ECB encryption */ + if( verbose ) + mbedtls_printf( " ARIA-ECB-%d (enc): ", 128 + 64 * i ); + mbedtls_aria_setkey_enc( &ctx, aria_test1_ecb_key, 128 + 64 * i ); + mbedtls_aria_crypt_ecb( &ctx, aria_test1_ecb_pt, blk ); + if( memcmp( blk, aria_test1_ecb_ct[i], MBEDTLS_ARIA_BLOCKSIZE ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + + /* test ECB decryption */ + if( verbose ) + mbedtls_printf( " ARIA-ECB-%d (dec): ", 128 + 64 * i ); + mbedtls_aria_setkey_dec( &ctx, aria_test1_ecb_key, 128 + 64 * i ); + mbedtls_aria_crypt_ecb( &ctx, aria_test1_ecb_ct[i], blk ); + if( memcmp( blk, aria_test1_ecb_pt, MBEDTLS_ARIA_BLOCKSIZE ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + } + if( verbose ) + mbedtls_printf( "\n" ); + + /* + * Test set 2 + */ +#if defined(MBEDTLS_CIPHER_MODE_CBC) + for( i = 0; i < 3; i++ ) + { + /* Test CBC encryption */ + if( verbose ) + mbedtls_printf( " ARIA-CBC-%d (enc): ", 128 + 64 * i ); + mbedtls_aria_setkey_enc( &ctx, aria_test2_key, 128 + 64 * i ); + memcpy( iv, aria_test2_iv, MBEDTLS_ARIA_BLOCKSIZE ); + memset( buf, 0x55, sizeof( buf ) ); + mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT, 48, iv, + aria_test2_pt, buf ); + if( memcmp( buf, aria_test2_cbc_ct[i], 48 ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + + /* Test CBC decryption */ + if( verbose ) + mbedtls_printf( " ARIA-CBC-%d (dec): ", 128 + 64 * i ); + mbedtls_aria_setkey_dec( &ctx, aria_test2_key, 128 + 64 * i ); + memcpy( iv, aria_test2_iv, MBEDTLS_ARIA_BLOCKSIZE ); + memset( buf, 0xAA, sizeof( buf ) ); + mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT, 48, iv, + aria_test2_cbc_ct[i], buf ); + if( memcmp( buf, aria_test2_pt, 48 ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + } + if( verbose ) + mbedtls_printf( "\n" ); + +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + for( i = 0; i < 3; i++ ) + { + /* Test CFB encryption */ + if( verbose ) + mbedtls_printf( " ARIA-CFB-%d (enc): ", 128 + 64 * i ); + mbedtls_aria_setkey_enc( &ctx, aria_test2_key, 128 + 64 * i ); + memcpy( iv, aria_test2_iv, MBEDTLS_ARIA_BLOCKSIZE ); + memset( buf, 0x55, sizeof( buf ) ); + j = 0; + mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_ENCRYPT, 48, &j, iv, + aria_test2_pt, buf ); + if( memcmp( buf, aria_test2_cfb_ct[i], 48 ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + + /* Test CFB decryption */ + if( verbose ) + mbedtls_printf( " ARIA-CFB-%d (dec): ", 128 + 64 * i ); + mbedtls_aria_setkey_enc( &ctx, aria_test2_key, 128 + 64 * i ); + memcpy( iv, aria_test2_iv, MBEDTLS_ARIA_BLOCKSIZE ); + memset( buf, 0xAA, sizeof( buf ) ); + j = 0; + mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_DECRYPT, 48, &j, + iv, aria_test2_cfb_ct[i], buf ); + if( memcmp( buf, aria_test2_pt, 48 ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + } + if( verbose ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + for( i = 0; i < 3; i++ ) + { + /* Test CTR encryption */ + if( verbose ) + mbedtls_printf( " ARIA-CTR-%d (enc): ", 128 + 64 * i ); + mbedtls_aria_setkey_enc( &ctx, aria_test2_key, 128 + 64 * i ); + memset( iv, 0, MBEDTLS_ARIA_BLOCKSIZE ); // IV = 0 + memset( buf, 0x55, sizeof( buf ) ); + j = 0; + mbedtls_aria_crypt_ctr( &ctx, 48, &j, iv, blk, + aria_test2_pt, buf ); + if( memcmp( buf, aria_test2_ctr_ct[i], 48 ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + + /* Test CTR decryption */ + if( verbose ) + mbedtls_printf( " ARIA-CTR-%d (dec): ", 128 + 64 * i ); + mbedtls_aria_setkey_enc( &ctx, aria_test2_key, 128 + 64 * i ); + memset( iv, 0, MBEDTLS_ARIA_BLOCKSIZE ); // IV = 0 + memset( buf, 0xAA, sizeof( buf ) ); + j = 0; + mbedtls_aria_crypt_ctr( &ctx, 48, &j, iv, blk, + aria_test2_ctr_ct[i], buf ); + if( memcmp( buf, aria_test2_pt, 48 ) != 0 ) + ARIA_SELF_TEST_IF_FAIL; + } + if( verbose ) + mbedtls_printf( "\n" ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_ARIA_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/asn1parse.c b/3rdparty/mbedtls/mbedtls/library/asn1parse.c index 4dd65c03c0..171c340b8c 100644 --- a/3rdparty/mbedtls/mbedtls/library/asn1parse.c +++ b/3rdparty/mbedtls/mbedtls/library/asn1parse.c @@ -28,6 +28,7 @@ #if defined(MBEDTLS_ASN1_PARSE_C) #include "mbedtls/asn1.h" +#include "mbedtls/platform_util.h" #include @@ -43,11 +44,6 @@ #define mbedtls_free free #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} - /* * ASN.1 DER decoding routines */ @@ -313,7 +309,7 @@ int mbedtls_asn1_get_alg( unsigned char **p, if( *p == end ) { - mbedtls_zeroize( params, sizeof(mbedtls_asn1_buf) ); + mbedtls_platform_zeroize( params, sizeof(mbedtls_asn1_buf) ); return( 0 ); } @@ -358,7 +354,7 @@ void mbedtls_asn1_free_named_data( mbedtls_asn1_named_data *cur ) mbedtls_free( cur->oid.p ); mbedtls_free( cur->val.p ); - mbedtls_zeroize( cur, sizeof( mbedtls_asn1_named_data ) ); + mbedtls_platform_zeroize( cur, sizeof( mbedtls_asn1_named_data ) ); } void mbedtls_asn1_free_named_data_list( mbedtls_asn1_named_data **head ) diff --git a/3rdparty/mbedtls/mbedtls/library/asn1write.c b/3rdparty/mbedtls/mbedtls/library/asn1write.c index c13e85e56a..c0b4622d58 100644 --- a/3rdparty/mbedtls/mbedtls/library/asn1write.c +++ b/3rdparty/mbedtls/mbedtls/library/asn1write.c @@ -236,9 +236,6 @@ int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ) int ret; size_t len = 0; - // DER format assumes 2s complement for numbers, so the leftmost bit - // should be 0 for positive numbers and 1 for negative numbers. - // if( *p - start < 1 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); @@ -260,56 +257,65 @@ int mbedtls_asn1_write_int( unsigned char **p, unsigned char *start, int val ) return( (int) len ); } -int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, - const char *text, size_t text_len ) +int mbedtls_asn1_write_tagged_string( unsigned char **p, unsigned char *start, int tag, + const char *text, size_t text_len ) { int ret; size_t len = 0; MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, - (const unsigned char *) text, text_len ) ); + (const unsigned char *) text, text_len ) ); MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_PRINTABLE_STRING ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, tag ) ); return( (int) len ); } -int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, - const char *text, size_t text_len ) +int mbedtls_asn1_write_utf8_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) { - int ret; - size_t len = 0; - - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_raw_buffer( p, start, - (const unsigned char *) text, text_len ) ); + return( mbedtls_asn1_write_tagged_string(p, start, MBEDTLS_ASN1_UTF8_STRING, text, text_len) ); +} - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_IA5_STRING ) ); +int mbedtls_asn1_write_printable_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) +{ + return( mbedtls_asn1_write_tagged_string(p, start, MBEDTLS_ASN1_PRINTABLE_STRING, text, text_len) ); +} - return( (int) len ); +int mbedtls_asn1_write_ia5_string( unsigned char **p, unsigned char *start, + const char *text, size_t text_len ) +{ + return( mbedtls_asn1_write_tagged_string(p, start, MBEDTLS_ASN1_IA5_STRING, text, text_len) ); } int mbedtls_asn1_write_bitstring( unsigned char **p, unsigned char *start, const unsigned char *buf, size_t bits ) { int ret; - size_t len = 0, size; + size_t len = 0; + size_t unused_bits, byte_len; - size = ( bits / 8 ) + ( ( bits % 8 ) ? 1 : 0 ); + byte_len = ( bits + 7 ) / 8; + unused_bits = ( byte_len * 8 ) - bits; - // Calculate byte length - // - if( *p < start || (size_t)( *p - start ) < size + 1 ) + if( *p < start || (size_t)( *p - start ) < byte_len + 1 ) return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); - len = size + 1; - (*p) -= size; - memcpy( *p, buf, size ); + len = byte_len + 1; - // Write unused bits - // - *--(*p) = (unsigned char) (size * 8 - bits); + /* Write the bitstring. Ensure the unused bits are zeroed */ + if( byte_len > 0 ) + { + byte_len--; + *--( *p ) = buf[byte_len] & ~( ( 0x1 << unused_bits ) - 1 ); + ( *p ) -= byte_len; + memcpy( *p, buf, byte_len ); + } + + /* Write unused bits */ + *--( *p ) = (unsigned char)unused_bits; MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_BIT_STRING ) ); diff --git a/3rdparty/mbedtls/mbedtls/library/bignum.c b/3rdparty/mbedtls/mbedtls/library/bignum.c index 18daea2589..41946183c5 100644 --- a/3rdparty/mbedtls/mbedtls/library/bignum.c +++ b/3rdparty/mbedtls/mbedtls/library/bignum.c @@ -45,6 +45,7 @@ #include "mbedtls/bignum.h" #include "mbedtls/bn_mul.h" +#include "mbedtls/platform_util.h" #include @@ -58,15 +59,10 @@ #define mbedtls_free free #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n ) { - volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0; -} - -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +#define MPI_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_MPI_BAD_INPUT_DATA ) +#define MPI_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) #define ciL (sizeof(mbedtls_mpi_uint)) /* chars in limb */ #define biL (ciL << 3) /* bits in limb */ @@ -81,13 +77,18 @@ static void mbedtls_zeroize( void *v, size_t n ) { #define BITS_TO_LIMBS(i) ( (i) / biL + ( (i) % biL != 0 ) ) #define CHARS_TO_LIMBS(i) ( (i) / ciL + ( (i) % ciL != 0 ) ) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_mpi_zeroize( mbedtls_mpi_uint *v, size_t n ) +{ + mbedtls_platform_zeroize( v, ciL * n ); +} + /* * Initialize one MPI */ void mbedtls_mpi_init( mbedtls_mpi *X ) { - if( X == NULL ) - return; + MPI_VALIDATE( X != NULL ); X->s = 1; X->n = 0; @@ -119,6 +120,7 @@ void mbedtls_mpi_free( mbedtls_mpi *X ) int mbedtls_mpi_grow( mbedtls_mpi *X, size_t nblimbs ) { mbedtls_mpi_uint *p; + MPI_VALIDATE_RET( X != NULL ); if( nblimbs > MBEDTLS_MPI_MAX_LIMBS ) return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); @@ -150,6 +152,10 @@ int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs ) { mbedtls_mpi_uint *p; size_t i; + MPI_VALIDATE_RET( X != NULL ); + + if( nblimbs > MBEDTLS_MPI_MAX_LIMBS ) + return( MBEDTLS_ERR_MPI_ALLOC_FAILED ); /* Actually resize up in this case */ if( X->n <= nblimbs ) @@ -184,8 +190,10 @@ int mbedtls_mpi_shrink( mbedtls_mpi *X, size_t nblimbs ) */ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ) { - int ret; + int ret = 0; size_t i; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); if( X == Y ) return( 0 ); @@ -203,9 +211,15 @@ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ) X->s = Y->s; - MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) ); + if( X->n < i ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) ); + } + else + { + memset( X->p + i, 0, ( X->n - i ) * ciL ); + } - memset( X->p, 0, X->n * ciL ); memcpy( X->p, Y->p, i * ciL ); cleanup: @@ -219,6 +233,8 @@ int mbedtls_mpi_copy( mbedtls_mpi *X, const mbedtls_mpi *Y ) void mbedtls_mpi_swap( mbedtls_mpi *X, mbedtls_mpi *Y ) { mbedtls_mpi T; + MPI_VALIDATE( X != NULL ); + MPI_VALIDATE( Y != NULL ); memcpy( &T, X, sizeof( mbedtls_mpi ) ); memcpy( X, Y, sizeof( mbedtls_mpi ) ); @@ -234,6 +250,8 @@ int mbedtls_mpi_safe_cond_assign( mbedtls_mpi *X, const mbedtls_mpi *Y, unsigned { int ret = 0; size_t i; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); /* make sure assign is 0 or 1 in a time-constant manner */ assign = (assign | (unsigned char)-assign) >> 7; @@ -263,6 +281,8 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw int ret, s; size_t i; mbedtls_mpi_uint tmp; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); if( X == Y ) return( 0 ); @@ -295,6 +315,7 @@ int mbedtls_mpi_safe_cond_swap( mbedtls_mpi *X, mbedtls_mpi *Y, unsigned char sw int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ) { int ret; + MPI_VALIDATE_RET( X != NULL ); MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, 1 ) ); memset( X->p, 0, X->n * ciL ); @@ -312,6 +333,8 @@ int mbedtls_mpi_lset( mbedtls_mpi *X, mbedtls_mpi_sint z ) */ int mbedtls_mpi_get_bit( const mbedtls_mpi *X, size_t pos ) { + MPI_VALIDATE_RET( X != NULL ); + if( X->n * biL <= pos ) return( 0 ); @@ -330,6 +353,7 @@ int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val ) int ret = 0; size_t off = pos / biL; size_t idx = pos % biL; + MPI_VALIDATE_RET( X != NULL ); if( val != 0 && val != 1 ) return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); @@ -356,6 +380,7 @@ int mbedtls_mpi_set_bit( mbedtls_mpi *X, size_t pos, unsigned char val ) size_t mbedtls_mpi_lsb( const mbedtls_mpi *X ) { size_t i, j, count = 0; + MBEDTLS_INTERNAL_VALIDATE_RET( X != NULL, 0 ); for( i = 0; i < X->n; i++ ) for( j = 0; j < biL; j++, count++ ) @@ -436,6 +461,8 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) size_t i, j, slen, n; mbedtls_mpi_uint d; mbedtls_mpi T; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( s != NULL ); if( radix < 2 || radix > 16 ) return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); @@ -500,26 +527,38 @@ int mbedtls_mpi_read_string( mbedtls_mpi *X, int radix, const char *s ) } /* - * Helper to write the digits high-order first + * Helper to write the digits high-order first. */ -static int mpi_write_hlp( mbedtls_mpi *X, int radix, char **p ) +static int mpi_write_hlp( mbedtls_mpi *X, int radix, + char **p, const size_t buflen ) { int ret; mbedtls_mpi_uint r; + size_t length = 0; + char *p_end = *p + buflen; - if( radix < 2 || radix > 16 ) - return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + do + { + if( length >= buflen ) + { + return( MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL ); + } - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, radix ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_div_int( X, NULL, X, radix ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, radix ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_div_int( X, NULL, X, radix ) ); + /* + * Write the residue in the current position, as an ASCII character. + */ + if( r < 0xA ) + *(--p_end) = (char)( '0' + r ); + else + *(--p_end) = (char)( 'A' + ( r - 0xA ) ); - if( mbedtls_mpi_cmp_int( X, 0 ) != 0 ) - MBEDTLS_MPI_CHK( mpi_write_hlp( X, radix, p ) ); + length++; + } while( mbedtls_mpi_cmp_int( X, 0 ) != 0 ); - if( r < 10 ) - *(*p)++ = (char)( r + 0x30 ); - else - *(*p)++ = (char)( r + 0x37 ); + memmove( *p, p_end, length ); + *p += length; cleanup: @@ -536,19 +575,27 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, size_t n; char *p; mbedtls_mpi T; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( olen != NULL ); + MPI_VALIDATE_RET( buflen == 0 || buf != NULL ); if( radix < 2 || radix > 16 ) return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); - n = mbedtls_mpi_bitlen( X ); - if( radix >= 4 ) n >>= 1; - if( radix >= 16 ) n >>= 1; - /* - * Round up the buffer length to an even value to ensure that there is - * enough room for hexadecimal values that can be represented in an odd - * number of digits. - */ - n += 3 + ( ( n + 1 ) & 1 ); + n = mbedtls_mpi_bitlen( X ); /* Number of bits necessary to present `n`. */ + if( radix >= 4 ) n >>= 1; /* Number of 4-adic digits necessary to present + * `n`. If radix > 4, this might be a strict + * overapproximation of the number of + * radix-adic digits needed to present `n`. */ + if( radix >= 16 ) n >>= 1; /* Number of hexadecimal digits necessary to + * present `n`. */ + + n += 1; /* Terminating null byte */ + n += 1; /* Compensate for the divisions above, which round down `n` + * in case it's not even. */ + n += 1; /* Potential '-'-sign. */ + n += ( n & 1 ); /* Make n even to have enough space for hexadecimal writing, + * which always uses an even number of hex-digits. */ if( buflen < n ) { @@ -560,7 +607,10 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, mbedtls_mpi_init( &T ); if( X->s == -1 ) + { *p++ = '-'; + buflen--; + } if( radix == 16 ) { @@ -589,7 +639,7 @@ int mbedtls_mpi_write_string( const mbedtls_mpi *X, int radix, if( T.s == -1 ) T.s = 1; - MBEDTLS_MPI_CHK( mpi_write_hlp( &T, radix, &p ) ); + MBEDTLS_MPI_CHK( mpi_write_hlp( &T, radix, &p, buflen ) ); } *p++ = '\0'; @@ -617,6 +667,12 @@ int mbedtls_mpi_read_file( mbedtls_mpi *X, int radix, FILE *fin ) */ char s[ MBEDTLS_MPI_RW_BUFFER_SIZE ]; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( fin != NULL ); + + if( radix < 2 || radix > 16 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + memset( s, 0, sizeof( s ) ); if( fgets( s, sizeof( s ) - 1, fin ) == NULL ) return( MBEDTLS_ERR_MPI_FILE_IO_ERROR ); @@ -648,6 +704,10 @@ int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE * newline characters and '\0' */ char s[ MBEDTLS_MPI_RW_BUFFER_SIZE ]; + MPI_VALIDATE_RET( X != NULL ); + + if( radix < 2 || radix > 16 ) + return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); memset( s, 0, sizeof( s ) ); @@ -675,14 +735,104 @@ int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE } #endif /* MBEDTLS_FS_IO */ + +/* Convert a big-endian byte array aligned to the size of mbedtls_mpi_uint + * into the storage form used by mbedtls_mpi. */ + +static mbedtls_mpi_uint mpi_uint_bigendian_to_host_c( mbedtls_mpi_uint x ) +{ + uint8_t i; + mbedtls_mpi_uint tmp = 0; + /* This works regardless of the endianness. */ + for( i = 0; i < ciL; i++, x >>= 8 ) + tmp |= ( x & 0xFF ) << ( ( ciL - 1 - i ) << 3 ); + return( tmp ); +} + +static mbedtls_mpi_uint mpi_uint_bigendian_to_host( mbedtls_mpi_uint x ) +{ +#if defined(__BYTE_ORDER__) + +/* Nothing to do on bigendian systems. */ +#if ( __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ ) + return( x ); +#endif /* __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ */ + +#if ( __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ ) + +/* For GCC and Clang, have builtins for byte swapping. */ +#if defined(__GNUC__) && defined(__GNUC_PREREQ) +#if __GNUC_PREREQ(4,3) +#define have_bswap +#endif +#endif + +#if defined(__clang__) && defined(__has_builtin) +#if __has_builtin(__builtin_bswap32) && \ + __has_builtin(__builtin_bswap64) +#define have_bswap +#endif +#endif + +#if defined(have_bswap) + /* The compiler is hopefully able to statically evaluate this! */ + switch( sizeof(mbedtls_mpi_uint) ) + { + case 4: + return( __builtin_bswap32(x) ); + case 8: + return( __builtin_bswap64(x) ); + } +#endif +#endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ +#endif /* __BYTE_ORDER__ */ + + /* Fall back to C-based reordering if we don't know the byte order + * or we couldn't use a compiler-specific builtin. */ + return( mpi_uint_bigendian_to_host_c( x ) ); +} + +static void mpi_bigendian_to_host( mbedtls_mpi_uint * const p, size_t limbs ) +{ + mbedtls_mpi_uint *cur_limb_left; + mbedtls_mpi_uint *cur_limb_right; + if( limbs == 0 ) + return; + + /* + * Traverse limbs and + * - adapt byte-order in each limb + * - swap the limbs themselves. + * For that, simultaneously traverse the limbs from left to right + * and from right to left, as long as the left index is not bigger + * than the right index (it's not a problem if limbs is odd and the + * indices coincide in the last iteration). + */ + for( cur_limb_left = p, cur_limb_right = p + ( limbs - 1 ); + cur_limb_left <= cur_limb_right; + cur_limb_left++, cur_limb_right-- ) + { + mbedtls_mpi_uint tmp; + /* Note that if cur_limb_left == cur_limb_right, + * this code effectively swaps the bytes only once. */ + tmp = mpi_uint_bigendian_to_host( *cur_limb_left ); + *cur_limb_left = mpi_uint_bigendian_to_host( *cur_limb_right ); + *cur_limb_right = tmp; + } +} + /* * Import X from unsigned binary data, big endian */ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t buflen ) { int ret; - size_t i, j; - size_t const limbs = CHARS_TO_LIMBS( buflen ); + size_t const limbs = CHARS_TO_LIMBS( buflen ); + size_t const overhead = ( limbs * ciL ) - buflen; + unsigned char *Xp; + + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( buflen == 0 || buf != NULL ); /* Ensure that target MPI has exactly the necessary number of limbs */ if( X->n != limbs ) @@ -691,11 +841,17 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t bu mbedtls_mpi_init( X ); MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, limbs ) ); } - MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); - for( i = buflen, j = 0; i > 0; i--, j++ ) - X->p[j / ciL] |= ((mbedtls_mpi_uint) buf[i - 1]) << ((j % ciL) << 3); + /* Avoid calling `memcpy` with NULL source argument, + * even if buflen is 0. */ + if( buf != NULL ) + { + Xp = (unsigned char*) X->p; + memcpy( Xp + overhead, buf, buflen ); + + mpi_bigendian_to_host( X->p, limbs ); + } cleanup: @@ -708,11 +864,16 @@ int mbedtls_mpi_read_binary( mbedtls_mpi *X, const unsigned char *buf, size_t bu int mbedtls_mpi_write_binary( const mbedtls_mpi *X, unsigned char *buf, size_t buflen ) { - size_t stored_bytes = X->n * ciL; + size_t stored_bytes; size_t bytes_to_copy; unsigned char *p; size_t i; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( buflen == 0 || buf != NULL ); + + stored_bytes = X->n * ciL; + if( stored_bytes < buflen ) { /* There is enough space in the output buffer. Write initial @@ -751,6 +912,7 @@ int mbedtls_mpi_shift_l( mbedtls_mpi *X, size_t count ) int ret; size_t i, v0, t1; mbedtls_mpi_uint r0 = 0, r1; + MPI_VALIDATE_RET( X != NULL ); v0 = count / (biL ); t1 = count & (biL - 1); @@ -800,6 +962,7 @@ int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count ) { size_t i, v0, v1; mbedtls_mpi_uint r0 = 0, r1; + MPI_VALIDATE_RET( X != NULL ); v0 = count / biL; v1 = count & (biL - 1); @@ -842,6 +1005,8 @@ int mbedtls_mpi_shift_r( mbedtls_mpi *X, size_t count ) int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y ) { size_t i, j; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); for( i = X->n; i > 0; i-- ) if( X->p[i - 1] != 0 ) @@ -872,6 +1037,8 @@ int mbedtls_mpi_cmp_abs( const mbedtls_mpi *X, const mbedtls_mpi *Y ) int mbedtls_mpi_cmp_mpi( const mbedtls_mpi *X, const mbedtls_mpi *Y ) { size_t i, j; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( Y != NULL ); for( i = X->n; i > 0; i-- ) if( X->p[i - 1] != 0 ) @@ -906,6 +1073,7 @@ int mbedtls_mpi_cmp_int( const mbedtls_mpi *X, mbedtls_mpi_sint z ) { mbedtls_mpi Y; mbedtls_mpi_uint p[1]; + MPI_VALIDATE_RET( X != NULL ); *p = ( z < 0 ) ? -z : z; Y.s = ( z < 0 ) ? -1 : 1; @@ -923,6 +1091,9 @@ int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi int ret; size_t i, j; mbedtls_mpi_uint *o, *p, c, tmp; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); if( X == B ) { @@ -988,7 +1159,7 @@ static void mpi_sub_hlp( size_t n, mbedtls_mpi_uint *s, mbedtls_mpi_uint *d ) while( c != 0 ) { z = ( *d < c ); *d -= c; - c = z; i++; d++; + c = z; d++; } } @@ -1000,6 +1171,9 @@ int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi mbedtls_mpi TB; int ret; size_t n; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); if( mbedtls_mpi_cmp_abs( A, B ) < 0 ) return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE ); @@ -1040,8 +1214,12 @@ int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi */ int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) { - int ret, s = A->s; + int ret, s; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); + s = A->s; if( A->s * B->s < 0 ) { if( mbedtls_mpi_cmp_abs( A, B ) >= 0 ) @@ -1071,8 +1249,12 @@ int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi */ int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) { - int ret, s = A->s; + int ret, s; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); + s = A->s; if( A->s * B->s > 0 ) { if( mbedtls_mpi_cmp_abs( A, B ) >= 0 ) @@ -1104,6 +1286,8 @@ int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint { mbedtls_mpi _B; mbedtls_mpi_uint p[1]; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); p[0] = ( b < 0 ) ? -b : b; _B.s = ( b < 0 ) ? -1 : 1; @@ -1120,6 +1304,8 @@ int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint { mbedtls_mpi _B; mbedtls_mpi_uint p[1]; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); p[0] = ( b < 0 ) ? -b : b; _B.s = ( b < 0 ) ? -1 : 1; @@ -1209,6 +1395,9 @@ int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi int ret; size_t i, j; mbedtls_mpi TA, TB; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB ); @@ -1226,8 +1415,8 @@ int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + j ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); - for( i++; j > 0; j-- ) - mpi_mul_hlp( i - 1, A->p, X->p + j - 1, B->p[j - 1] ); + for( ; j > 0; j-- ) + mpi_mul_hlp( i, A->p, X->p + j - 1, B->p[j - 1] ); X->s = A->s * B->s; @@ -1245,6 +1434,8 @@ int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint { mbedtls_mpi _B; mbedtls_mpi_uint p[1]; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); _B.s = 1; _B.n = 1; @@ -1353,11 +1544,14 @@ static mbedtls_mpi_uint mbedtls_int_div_int( mbedtls_mpi_uint u1, /* * Division by mbedtls_mpi: A = Q * B + R (HAC 14.20) */ -int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ) +int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, + const mbedtls_mpi *B ) { int ret; size_t i, n, t, k; mbedtls_mpi X, Y, Z, T1, T2; + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); if( mbedtls_mpi_cmp_int( B, 0 ) == 0 ) return( MBEDTLS_ERR_MPI_DIVISION_BY_ZERO ); @@ -1468,10 +1662,13 @@ int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, c /* * Division by int: A = Q * b + R */ -int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, mbedtls_mpi_sint b ) +int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, + const mbedtls_mpi *A, + mbedtls_mpi_sint b ) { mbedtls_mpi _B; mbedtls_mpi_uint p[1]; + MPI_VALIDATE_RET( A != NULL ); p[0] = ( b < 0 ) ? -b : b; _B.s = ( b < 0 ) ? -1 : 1; @@ -1487,6 +1684,9 @@ int mbedtls_mpi_div_int( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, m int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ) { int ret; + MPI_VALIDATE_RET( R != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); if( mbedtls_mpi_cmp_int( B, 0 ) < 0 ) return( MBEDTLS_ERR_MPI_NEGATIVE_VALUE ); @@ -1511,6 +1711,8 @@ int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_ { size_t i; mbedtls_mpi_uint x, y, z; + MPI_VALIDATE_RET( r != NULL ); + MPI_VALIDATE_RET( A != NULL ); if( b == 0 ) return( MBEDTLS_ERR_MPI_DIVISION_BY_ZERO ); @@ -1624,7 +1826,8 @@ static int mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi /* * Montgomery reduction: A = A * R^-1 mod N */ -static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint mm, const mbedtls_mpi *T ) +static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, + mbedtls_mpi_uint mm, const mbedtls_mpi *T ) { mbedtls_mpi_uint z = 1; mbedtls_mpi U; @@ -1638,7 +1841,9 @@ static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint m /* * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) */ -int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR ) +int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, + const mbedtls_mpi *E, const mbedtls_mpi *N, + mbedtls_mpi *_RR ) { int ret; size_t wbits, wsize, one = 1; @@ -1648,6 +1853,11 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi mbedtls_mpi RR, T, W[ 2 << MBEDTLS_MPI_WINDOW_SIZE ], Apos; int neg; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( E != NULL ); + MPI_VALIDATE_RET( N != NULL ); + if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 || ( N->p[0] & 1 ) == 0 ) return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); @@ -1667,8 +1877,10 @@ int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi wsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 : ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1; +#if( MBEDTLS_MPI_WINDOW_SIZE < 6 ) if( wsize > MBEDTLS_MPI_WINDOW_SIZE ) wsize = MBEDTLS_MPI_WINDOW_SIZE; +#endif j = N->n + 1; MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, j ) ); @@ -1852,6 +2064,10 @@ int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B size_t lz, lzt; mbedtls_mpi TG, TA, TB; + MPI_VALIDATE_RET( G != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( B != NULL ); + mbedtls_mpi_init( &TG ); mbedtls_mpi_init( &TA ); mbedtls_mpi_init( &TB ); MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) ); @@ -1907,16 +2123,28 @@ int mbedtls_mpi_fill_random( mbedtls_mpi *X, size_t size, void *p_rng ) { int ret; - unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + size_t const limbs = CHARS_TO_LIMBS( size ); + size_t const overhead = ( limbs * ciL ) - size; + unsigned char *Xp; - if( size > MBEDTLS_MPI_MAX_SIZE ) - return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( f_rng != NULL ); + + /* Ensure that target MPI has exactly the necessary number of limbs */ + if( X->n != limbs ) + { + mbedtls_mpi_free( X ); + mbedtls_mpi_init( X ); + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, limbs ) ); + } + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( X, 0 ) ); - MBEDTLS_MPI_CHK( f_rng( p_rng, buf, size ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_read_binary( X, buf, size ) ); + Xp = (unsigned char*) X->p; + f_rng( p_rng, Xp + overhead, size ); + + mpi_bigendian_to_host( X->p, limbs ); cleanup: - mbedtls_zeroize( buf, sizeof( buf ) ); return( ret ); } @@ -1927,6 +2155,9 @@ int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi { int ret; mbedtls_mpi G, TA, TU, U1, U2, TB, TV, V1, V2; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( A != NULL ); + MPI_VALIDATE_RET( N != NULL ); if( mbedtls_mpi_cmp_int( N, 1 ) <= 0 ) return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); @@ -2086,7 +2317,11 @@ static int mpi_miller_rabin( const mbedtls_mpi *X, size_t rounds, size_t i, j, k, s; mbedtls_mpi W, R, T, A, RR; - mbedtls_mpi_init( &W ); mbedtls_mpi_init( &R ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &A ); + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( f_rng != NULL ); + + mbedtls_mpi_init( &W ); mbedtls_mpi_init( &R ); + mbedtls_mpi_init( &T ); mbedtls_mpi_init( &A ); mbedtls_mpi_init( &RR ); /* @@ -2158,7 +2393,8 @@ static int mpi_miller_rabin( const mbedtls_mpi *X, size_t rounds, } cleanup: - mbedtls_mpi_free( &W ); mbedtls_mpi_free( &R ); mbedtls_mpi_free( &T ); mbedtls_mpi_free( &A ); + mbedtls_mpi_free( &W ); mbedtls_mpi_free( &R ); + mbedtls_mpi_free( &T ); mbedtls_mpi_free( &A ); mbedtls_mpi_free( &RR ); return( ret ); @@ -2167,12 +2403,14 @@ static int mpi_miller_rabin( const mbedtls_mpi *X, size_t rounds, /* * Pseudo-primality test: small factors, then Miller-Rabin */ -static int mpi_is_prime_internal( const mbedtls_mpi *X, int rounds, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) +int mbedtls_mpi_is_prime_ext( const mbedtls_mpi *X, int rounds, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) { int ret; mbedtls_mpi XX; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( f_rng != NULL ); XX.s = 1; XX.n = X->n; @@ -2196,6 +2434,7 @@ static int mpi_is_prime_internal( const mbedtls_mpi *X, int rounds, return( mpi_miller_rabin( &XX, rounds, f_rng, p_rng ) ); } +#if !defined(MBEDTLS_DEPRECATED_REMOVED) /* * Pseudo-primality test, error probability 2^-80 */ @@ -2203,22 +2442,45 @@ int mbedtls_mpi_is_prime( const mbedtls_mpi *X, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - return mpi_is_prime_internal( X, 40, f_rng, p_rng ); + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( f_rng != NULL ); + + /* + * In the past our key generation aimed for an error rate of at most + * 2^-80. Since this function is deprecated, aim for the same certainty + * here as well. + */ + return( mbedtls_mpi_is_prime_ext( X, 40, f_rng, p_rng ) ); } +#endif /* * Prime number generation + * + * To generate an RSA key in a way recommended by FIPS 186-4, both primes must + * be either 1024 bits or 1536 bits long, and flags must contain + * MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR. */ -int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag, +int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int flags, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - int ret; +#ifdef MBEDTLS_HAVE_INT64 +// ceil(2^63.5) +#define CEIL_MAXUINT_DIV_SQRT2 0xb504f333f9de6485ULL +#else +// ceil(2^31.5) +#define CEIL_MAXUINT_DIV_SQRT2 0xb504f334U +#endif + int ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; size_t k, n; int rounds; mbedtls_mpi_uint r; mbedtls_mpi Y; + MPI_VALIDATE_RET( X != NULL ); + MPI_VALIDATE_RET( f_rng != NULL ); + if( nbits < 3 || nbits > MBEDTLS_MPI_MAX_BITS ) return( MBEDTLS_ERR_MPI_BAD_INPUT_DATA ); @@ -2226,78 +2488,89 @@ int mbedtls_mpi_gen_prime( mbedtls_mpi *X, size_t nbits, int dh_flag, n = BITS_TO_LIMBS( nbits ); - /* - * 2^-80 error probability, number of rounds chosen per HAC, table 4.4 - */ - rounds = ( ( nbits >= 1300 ) ? 2 : ( nbits >= 850 ) ? 3 : - ( nbits >= 650 ) ? 4 : ( nbits >= 350 ) ? 8 : - ( nbits >= 250 ) ? 12 : ( nbits >= 150 ) ? 18 : 27 ); - - MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( X, n * ciL, f_rng, p_rng ) ); - - k = mbedtls_mpi_bitlen( X ); - if( k > nbits ) MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( X, k - nbits + 1 ) ); - - mbedtls_mpi_set_bit( X, nbits-1, 1 ); - - X->p[0] |= 1; - - if( dh_flag == 0 ) + if( ( flags & MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR ) == 0 ) { - while( ( ret = mpi_is_prime_internal( X, rounds, f_rng, p_rng ) ) != 0 ) - { - if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ) - goto cleanup; - - MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 2 ) ); - } + /* + * 2^-80 error probability, number of rounds chosen per HAC, table 4.4 + */ + rounds = ( ( nbits >= 1300 ) ? 2 : ( nbits >= 850 ) ? 3 : + ( nbits >= 650 ) ? 4 : ( nbits >= 350 ) ? 8 : + ( nbits >= 250 ) ? 12 : ( nbits >= 150 ) ? 18 : 27 ); } else { /* - * An necessary condition for Y and X = 2Y + 1 to be prime - * is X = 2 mod 3 (which is equivalent to Y = 2 mod 3). - * Make sure it is satisfied, while keeping X = 3 mod 4 + * 2^-100 error probability, number of rounds computed based on HAC, + * fact 4.48 */ + rounds = ( ( nbits >= 1450 ) ? 4 : ( nbits >= 1150 ) ? 5 : + ( nbits >= 1000 ) ? 6 : ( nbits >= 850 ) ? 7 : + ( nbits >= 750 ) ? 8 : ( nbits >= 500 ) ? 13 : + ( nbits >= 250 ) ? 28 : ( nbits >= 150 ) ? 40 : 51 ); + } - X->p[0] |= 2; - - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, 3 ) ); - if( r == 0 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 8 ) ); - else if( r == 1 ) - MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 4 ) ); + while( 1 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( X, n * ciL, f_rng, p_rng ) ); + /* make sure generated number is at least (nbits-1)+0.5 bits (FIPS 186-4 §B.3.3 steps 4.4, 5.5) */ + if( X->p[n-1] < CEIL_MAXUINT_DIV_SQRT2 ) continue; - /* Set Y = (X-1) / 2, which is X / 2 because X is odd */ - MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Y, X ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Y, 1 ) ); + k = n * biL; + if( k > nbits ) MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( X, k - nbits ) ); + X->p[0] |= 1; - while( 1 ) + if( ( flags & MBEDTLS_MPI_GEN_PRIME_FLAG_DH ) == 0 ) { - /* - * First, check small factors for X and Y - * before doing Miller-Rabin on any of them - */ - if( ( ret = mpi_check_small_factors( X ) ) == 0 && - ( ret = mpi_check_small_factors( &Y ) ) == 0 && - ( ret = mpi_miller_rabin( X, rounds, f_rng, p_rng ) ) - == 0 && - ( ret = mpi_miller_rabin( &Y, rounds, f_rng, p_rng ) ) - == 0 ) - { - break; - } + ret = mbedtls_mpi_is_prime_ext( X, rounds, f_rng, p_rng ); if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ) goto cleanup; - + } + else + { /* - * Next candidates. We want to preserve Y = (X-1) / 2 and - * Y = 1 mod 2 and Y = 2 mod 3 (eq X = 3 mod 4 and X = 2 mod 3) - * so up Y by 6 and X by 12. + * An necessary condition for Y and X = 2Y + 1 to be prime + * is X = 2 mod 3 (which is equivalent to Y = 2 mod 3). + * Make sure it is satisfied, while keeping X = 3 mod 4 */ - MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 12 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &Y, &Y, 6 ) ); + + X->p[0] |= 2; + + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, 3 ) ); + if( r == 0 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 8 ) ); + else if( r == 1 ) + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 4 ) ); + + /* Set Y = (X-1) / 2, which is X / 2 because X is odd */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Y, X ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Y, 1 ) ); + + while( 1 ) + { + /* + * First, check small factors for X and Y + * before doing Miller-Rabin on any of them + */ + if( ( ret = mpi_check_small_factors( X ) ) == 0 && + ( ret = mpi_check_small_factors( &Y ) ) == 0 && + ( ret = mpi_miller_rabin( X, rounds, f_rng, p_rng ) ) + == 0 && + ( ret = mpi_miller_rabin( &Y, rounds, f_rng, p_rng ) ) + == 0 ) + goto cleanup; + + if( ret != MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ) + goto cleanup; + + /* + * Next candidates. We want to preserve Y = (X-1) / 2 and + * Y = 1 mod 2 and Y = 2 mod 3 (eq X = 3 mod 4 and X = 2 mod 3) + * so up Y by 6 and X by 12. + */ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( X, X, 12 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &Y, &Y, 6 ) ); + } } } diff --git a/3rdparty/mbedtls/mbedtls/library/blowfish.c b/3rdparty/mbedtls/mbedtls/library/blowfish.c index 9003f0dfeb..cbf9238246 100644 --- a/3rdparty/mbedtls/mbedtls/library/blowfish.c +++ b/3rdparty/mbedtls/mbedtls/library/blowfish.c @@ -34,15 +34,17 @@ #if defined(MBEDTLS_BLOWFISH_C) #include "mbedtls/blowfish.h" +#include "mbedtls/platform_util.h" #include #if !defined(MBEDTLS_BLOWFISH_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} +/* Parameter validation macros */ +#define BLOWFISH_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA ) +#define BLOWFISH_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) /* * 32-bit integer manipulation macros (big endian) @@ -157,6 +159,7 @@ static void blowfish_dec( mbedtls_blowfish_context *ctx, uint32_t *xl, uint32_t void mbedtls_blowfish_init( mbedtls_blowfish_context *ctx ) { + BLOWFISH_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_blowfish_context ) ); } @@ -165,22 +168,26 @@ void mbedtls_blowfish_free( mbedtls_blowfish_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_blowfish_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_blowfish_context ) ); } /* * Blowfish key schedule */ -int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, const unsigned char *key, - unsigned int keybits ) +int mbedtls_blowfish_setkey( mbedtls_blowfish_context *ctx, + const unsigned char *key, + unsigned int keybits ) { unsigned int i, j, k; uint32_t data, datal, datar; + BLOWFISH_VALIDATE_RET( ctx != NULL ); + BLOWFISH_VALIDATE_RET( key != NULL ); - if( keybits < MBEDTLS_BLOWFISH_MIN_KEY_BITS || keybits > MBEDTLS_BLOWFISH_MAX_KEY_BITS || - ( keybits % 8 ) ) + if( keybits < MBEDTLS_BLOWFISH_MIN_KEY_BITS || + keybits > MBEDTLS_BLOWFISH_MAX_KEY_BITS || + keybits % 8 != 0 ) { - return( MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH ); + return( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA ); } keybits >>= 3; @@ -235,6 +242,11 @@ int mbedtls_blowfish_crypt_ecb( mbedtls_blowfish_context *ctx, unsigned char output[MBEDTLS_BLOWFISH_BLOCKSIZE] ) { uint32_t X0, X1; + BLOWFISH_VALIDATE_RET( ctx != NULL ); + BLOWFISH_VALIDATE_RET( mode == MBEDTLS_BLOWFISH_ENCRYPT || + mode == MBEDTLS_BLOWFISH_DECRYPT ); + BLOWFISH_VALIDATE_RET( input != NULL ); + BLOWFISH_VALIDATE_RET( output != NULL ); GET_UINT32_BE( X0, input, 0 ); GET_UINT32_BE( X1, input, 4 ); @@ -267,6 +279,12 @@ int mbedtls_blowfish_crypt_cbc( mbedtls_blowfish_context *ctx, { int i; unsigned char temp[MBEDTLS_BLOWFISH_BLOCKSIZE]; + BLOWFISH_VALIDATE_RET( ctx != NULL ); + BLOWFISH_VALIDATE_RET( mode == MBEDTLS_BLOWFISH_ENCRYPT || + mode == MBEDTLS_BLOWFISH_DECRYPT ); + BLOWFISH_VALIDATE_RET( iv != NULL ); + BLOWFISH_VALIDATE_RET( length == 0 || input != NULL ); + BLOWFISH_VALIDATE_RET( length == 0 || output != NULL ); if( length % MBEDTLS_BLOWFISH_BLOCKSIZE ) return( MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH ); @@ -321,7 +339,19 @@ int mbedtls_blowfish_crypt_cfb64( mbedtls_blowfish_context *ctx, unsigned char *output ) { int c; - size_t n = *iv_off; + size_t n; + + BLOWFISH_VALIDATE_RET( ctx != NULL ); + BLOWFISH_VALIDATE_RET( mode == MBEDTLS_BLOWFISH_ENCRYPT || + mode == MBEDTLS_BLOWFISH_DECRYPT ); + BLOWFISH_VALIDATE_RET( iv != NULL ); + BLOWFISH_VALIDATE_RET( iv_off != NULL ); + BLOWFISH_VALIDATE_RET( length == 0 || input != NULL ); + BLOWFISH_VALIDATE_RET( length == 0 || output != NULL ); + + n = *iv_off; + if( n >= 8 ) + return( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA ); if( mode == MBEDTLS_BLOWFISH_DECRYPT ) { @@ -369,7 +399,17 @@ int mbedtls_blowfish_crypt_ctr( mbedtls_blowfish_context *ctx, unsigned char *output ) { int c, i; - size_t n = *nc_off; + size_t n; + BLOWFISH_VALIDATE_RET( ctx != NULL ); + BLOWFISH_VALIDATE_RET( nonce_counter != NULL ); + BLOWFISH_VALIDATE_RET( stream_block != NULL ); + BLOWFISH_VALIDATE_RET( nc_off != NULL ); + BLOWFISH_VALIDATE_RET( length == 0 || input != NULL ); + BLOWFISH_VALIDATE_RET( length == 0 || output != NULL ); + + n = *nc_off; + if( n >= 8 ) + return( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA ); while( length-- ) { diff --git a/3rdparty/mbedtls/mbedtls/library/camellia.c b/3rdparty/mbedtls/mbedtls/library/camellia.c index ac6f96a83a..22262b89a8 100644 --- a/3rdparty/mbedtls/mbedtls/library/camellia.c +++ b/3rdparty/mbedtls/mbedtls/library/camellia.c @@ -34,6 +34,7 @@ #if defined(MBEDTLS_CAMELLIA_C) #include "mbedtls/camellia.h" +#include "mbedtls/platform_util.h" #include @@ -48,10 +49,11 @@ #if !defined(MBEDTLS_CAMELLIA_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} +/* Parameter validation macros */ +#define CAMELLIA_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA ) +#define CAMELLIA_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) /* * 32-bit integer manipulation macros (big endian) @@ -325,6 +327,7 @@ static void camellia_feistel( const uint32_t x[2], const uint32_t k[2], void mbedtls_camellia_init( mbedtls_camellia_context *ctx ) { + CAMELLIA_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_camellia_context ) ); } @@ -333,14 +336,15 @@ void mbedtls_camellia_free( mbedtls_camellia_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_camellia_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_camellia_context ) ); } /* * Camellia key schedule (encryption) */ -int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned char *key, - unsigned int keybits ) +int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, + const unsigned char *key, + unsigned int keybits ) { int idx; size_t i; @@ -350,6 +354,9 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned c uint32_t KC[16]; uint32_t TK[20]; + CAMELLIA_VALIDATE_RET( ctx != NULL ); + CAMELLIA_VALIDATE_RET( key != NULL ); + RK = ctx->rk; memset( t, 0, 64 ); @@ -360,7 +367,7 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned c case 128: ctx->nr = 3; idx = 0; break; case 192: case 256: ctx->nr = 4; idx = 1; break; - default : return( MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH ); + default : return( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA ); } for( i = 0; i < keybits / 8; ++i ) @@ -444,14 +451,17 @@ int mbedtls_camellia_setkey_enc( mbedtls_camellia_context *ctx, const unsigned c /* * Camellia key schedule (decryption) */ -int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, const unsigned char *key, - unsigned int keybits ) +int mbedtls_camellia_setkey_dec( mbedtls_camellia_context *ctx, + const unsigned char *key, + unsigned int keybits ) { int idx, ret; size_t i; mbedtls_camellia_context cty; uint32_t *RK; uint32_t *SK; + CAMELLIA_VALIDATE_RET( ctx != NULL ); + CAMELLIA_VALIDATE_RET( key != NULL ); mbedtls_camellia_init( &cty ); @@ -499,6 +509,11 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, { int NR; uint32_t *RK, X[4]; + CAMELLIA_VALIDATE_RET( ctx != NULL ); + CAMELLIA_VALIDATE_RET( mode == MBEDTLS_CAMELLIA_ENCRYPT || + mode == MBEDTLS_CAMELLIA_DECRYPT ); + CAMELLIA_VALIDATE_RET( input != NULL ); + CAMELLIA_VALIDATE_RET( output != NULL ); ( (void) mode ); @@ -556,14 +571,20 @@ int mbedtls_camellia_crypt_ecb( mbedtls_camellia_context *ctx, * Camellia-CBC buffer encryption/decryption */ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, - int mode, - size_t length, - unsigned char iv[16], - const unsigned char *input, - unsigned char *output ) + int mode, + size_t length, + unsigned char iv[16], + const unsigned char *input, + unsigned char *output ) { int i; unsigned char temp[16]; + CAMELLIA_VALIDATE_RET( ctx != NULL ); + CAMELLIA_VALIDATE_RET( mode == MBEDTLS_CAMELLIA_ENCRYPT || + mode == MBEDTLS_CAMELLIA_DECRYPT ); + CAMELLIA_VALIDATE_RET( iv != NULL ); + CAMELLIA_VALIDATE_RET( length == 0 || input != NULL ); + CAMELLIA_VALIDATE_RET( length == 0 || output != NULL ); if( length % 16 ) return( MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH ); @@ -618,7 +639,18 @@ int mbedtls_camellia_crypt_cfb128( mbedtls_camellia_context *ctx, unsigned char *output ) { int c; - size_t n = *iv_off; + size_t n; + CAMELLIA_VALIDATE_RET( ctx != NULL ); + CAMELLIA_VALIDATE_RET( mode == MBEDTLS_CAMELLIA_ENCRYPT || + mode == MBEDTLS_CAMELLIA_DECRYPT ); + CAMELLIA_VALIDATE_RET( iv != NULL ); + CAMELLIA_VALIDATE_RET( iv_off != NULL ); + CAMELLIA_VALIDATE_RET( length == 0 || input != NULL ); + CAMELLIA_VALIDATE_RET( length == 0 || output != NULL ); + + n = *iv_off; + if( n >= 16 ) + return( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA ); if( mode == MBEDTLS_CAMELLIA_DECRYPT ) { @@ -666,7 +698,17 @@ int mbedtls_camellia_crypt_ctr( mbedtls_camellia_context *ctx, unsigned char *output ) { int c, i; - size_t n = *nc_off; + size_t n; + CAMELLIA_VALIDATE_RET( ctx != NULL ); + CAMELLIA_VALIDATE_RET( nonce_counter != NULL ); + CAMELLIA_VALIDATE_RET( stream_block != NULL ); + CAMELLIA_VALIDATE_RET( nc_off != NULL ); + CAMELLIA_VALIDATE_RET( length == 0 || input != NULL ); + CAMELLIA_VALIDATE_RET( length == 0 || output != NULL ); + + n = *nc_off; + if( n >= 16 ) + return( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA ); while( length-- ) { diff --git a/3rdparty/mbedtls/mbedtls/library/ccm.c b/3rdparty/mbedtls/mbedtls/library/ccm.c index 658f0d2ff3..c6211ee773 100644 --- a/3rdparty/mbedtls/mbedtls/library/ccm.c +++ b/3rdparty/mbedtls/mbedtls/library/ccm.c @@ -37,6 +37,7 @@ #if defined(MBEDTLS_CCM_C) #include "mbedtls/ccm.h" +#include "mbedtls/platform_util.h" #include @@ -51,10 +52,10 @@ #if !defined(MBEDTLS_CCM_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} +#define CCM_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CCM_BAD_INPUT ) +#define CCM_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) #define CCM_ENCRYPT 0 #define CCM_DECRYPT 1 @@ -64,6 +65,7 @@ static void mbedtls_zeroize( void *v, size_t n ) { */ void mbedtls_ccm_init( mbedtls_ccm_context *ctx ) { + CCM_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_ccm_context ) ); } @@ -75,6 +77,9 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, int ret; const mbedtls_cipher_info_t *cipher_info; + CCM_VALIDATE_RET( ctx != NULL ); + CCM_VALIDATE_RET( key != NULL ); + cipher_info = mbedtls_cipher_info_from_values( cipher, keybits, MBEDTLS_MODE_ECB ); if( cipher_info == NULL ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); @@ -101,8 +106,10 @@ int mbedtls_ccm_setkey( mbedtls_ccm_context *ctx, */ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) { + if( ctx == NULL ) + return; mbedtls_cipher_free( &ctx->cipher_ctx ); - mbedtls_zeroize( ctx, sizeof( mbedtls_ccm_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ccm_context ) ); } /* @@ -127,11 +134,17 @@ void mbedtls_ccm_free( mbedtls_ccm_context *ctx ) * This avoids allocating one more 16 bytes buffer while allowing src == dst. */ #define CTR_CRYPT( dst, src, len ) \ - if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctr, 16, b, &olen ) ) != 0 ) \ - return( ret ); \ - \ - for( i = 0; i < len; i++ ) \ - dst[i] = src[i] ^ b[i]; + do \ + { \ + if( ( ret = mbedtls_cipher_update( &ctx->cipher_ctx, ctr, \ + 16, b, &olen ) ) != 0 ) \ + { \ + return( ret ); \ + } \ + \ + for( i = 0; i < (len); i++ ) \ + (dst)[i] = (src)[i] ^ b[i]; \ + } while( 0 ) /* * Authenticated encryption or decryption @@ -156,8 +169,10 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, * Check length requirements: SP800-38C A.1 * Additional requirement: a < 2^16 - 2^8 to simplify the code. * 'length' checked later (when writing it to the first block) + * + * Also, loosen the requirements to enable support for CCM* (IEEE 802.15.4). */ - if( tag_len < 4 || tag_len > 16 || tag_len % 2 != 0 ) + if( tag_len == 2 || tag_len > 16 || tag_len % 2 != 0 ) return( MBEDTLS_ERR_CCM_BAD_INPUT ); /* Also implies q is within bounds */ @@ -306,20 +321,45 @@ static int ccm_auth_crypt( mbedtls_ccm_context *ctx, int mode, size_t length, /* * Authenticated encryption */ -int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, +int mbedtls_ccm_star_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, unsigned char *tag, size_t tag_len ) { + CCM_VALIDATE_RET( ctx != NULL ); + CCM_VALIDATE_RET( iv != NULL ); + CCM_VALIDATE_RET( add_len == 0 || add != NULL ); + CCM_VALIDATE_RET( length == 0 || input != NULL ); + CCM_VALIDATE_RET( length == 0 || output != NULL ); + CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); return( ccm_auth_crypt( ctx, CCM_ENCRYPT, length, iv, iv_len, add, add_len, input, output, tag, tag_len ) ); } +int mbedtls_ccm_encrypt_and_tag( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + unsigned char *tag, size_t tag_len ) +{ + CCM_VALIDATE_RET( ctx != NULL ); + CCM_VALIDATE_RET( iv != NULL ); + CCM_VALIDATE_RET( add_len == 0 || add != NULL ); + CCM_VALIDATE_RET( length == 0 || input != NULL ); + CCM_VALIDATE_RET( length == 0 || output != NULL ); + CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); + if( tag_len == 0 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + return( mbedtls_ccm_star_encrypt_and_tag( ctx, length, iv, iv_len, add, + add_len, input, output, tag, tag_len ) ); +} + /* * Authenticated decryption */ -int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, +int mbedtls_ccm_star_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, @@ -330,6 +370,13 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, unsigned char i; int diff; + CCM_VALIDATE_RET( ctx != NULL ); + CCM_VALIDATE_RET( iv != NULL ); + CCM_VALIDATE_RET( add_len == 0 || add != NULL ); + CCM_VALIDATE_RET( length == 0 || input != NULL ); + CCM_VALIDATE_RET( length == 0 || output != NULL ); + CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); + if( ( ret = ccm_auth_crypt( ctx, CCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, check_tag, tag_len ) ) != 0 ) @@ -343,13 +390,32 @@ int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, if( diff != 0 ) { - mbedtls_zeroize( output, length ); + mbedtls_platform_zeroize( output, length ); return( MBEDTLS_ERR_CCM_AUTH_FAILED ); } return( 0 ); } +int mbedtls_ccm_auth_decrypt( mbedtls_ccm_context *ctx, size_t length, + const unsigned char *iv, size_t iv_len, + const unsigned char *add, size_t add_len, + const unsigned char *input, unsigned char *output, + const unsigned char *tag, size_t tag_len ) +{ + CCM_VALIDATE_RET( ctx != NULL ); + CCM_VALIDATE_RET( iv != NULL ); + CCM_VALIDATE_RET( add_len == 0 || add != NULL ); + CCM_VALIDATE_RET( length == 0 || input != NULL ); + CCM_VALIDATE_RET( length == 0 || output != NULL ); + CCM_VALIDATE_RET( tag_len == 0 || tag != NULL ); + + if( tag_len == 0 ) + return( MBEDTLS_ERR_CCM_BAD_INPUT ); + + return( mbedtls_ccm_star_auth_decrypt( ctx, length, iv, iv_len, add, + add_len, input, output, tag, tag_len ) ); +} #endif /* !MBEDTLS_CCM_ALT */ #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) diff --git a/3rdparty/mbedtls/mbedtls/library/certs.c b/3rdparty/mbedtls/mbedtls/library/certs.c index f1379b8cb1..b07fd8a3a1 100644 --- a/3rdparty/mbedtls/mbedtls/library/certs.c +++ b/3rdparty/mbedtls/mbedtls/library/certs.c @@ -29,325 +29,1673 @@ #if defined(MBEDTLS_CERTS_C) -#if defined(MBEDTLS_ECDSA_C) -#define TEST_CA_CRT_EC \ -"-----BEGIN CERTIFICATE-----\r\n" \ -"MIICUjCCAdegAwIBAgIJAMFD4n5iQ8zoMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYT\r\n" \ -"Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \ -"QyBDQTAeFw0xMzA5MjQxNTQ5NDhaFw0yMzA5MjIxNTQ5NDhaMD4xCzAJBgNVBAYT\r\n" \ -"Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \ -"QyBDQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABMPaKzRBN1gvh1b+/Im6KUNLTuBu\r\n" \ -"ww5XUzM5WNRStJGVOQsj318XJGJI/BqVKc4sLYfCiFKAr9ZqqyHduNMcbli4yuiy\r\n" \ -"aY7zQa0pw7RfdadHb9UZKVVpmlM7ILRmFmAzHqOBoDCBnTAdBgNVHQ4EFgQUnW0g\r\n" \ -"JEkBPyvLeLUZvH4kydv7NnwwbgYDVR0jBGcwZYAUnW0gJEkBPyvLeLUZvH4kydv7\r\n" \ -"NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UE\r\n" \ -"AxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAwGA1UdEwQFMAMBAf8w\r\n" \ -"CgYIKoZIzj0EAwIDaQAwZgIxAMO0YnNWKJUAfXgSJtJxexn4ipg+kv4znuR50v56\r\n" \ -"t4d0PCu412mUC6Nnd7izvtE2MgIxAP1nnJQjZ8BWukszFQDG48wxCCyci9qpdSMv\r\n" \ -"uCjn8pwUOkABXK8Mss90fzCfCEOtIA==\r\n" \ -"-----END CERTIFICATE-----\r\n" -const char mbedtls_test_ca_crt_ec[] = TEST_CA_CRT_EC; -const size_t mbedtls_test_ca_crt_ec_len = sizeof( mbedtls_test_ca_crt_ec ); - -const char mbedtls_test_ca_key_ec[] = -"-----BEGIN EC PRIVATE KEY-----\r\n" -"Proc-Type: 4,ENCRYPTED\r\n" -"DEK-Info: DES-EDE3-CBC,307EAB469933D64E\r\n" -"\r\n" -"IxbrRmKcAzctJqPdTQLA4SWyBYYGYJVkYEna+F7Pa5t5Yg/gKADrFKcm6B72e7DG\r\n" -"ihExtZI648s0zdYw6qSJ74vrPSuWDe5qm93BqsfVH9svtCzWHW0pm1p0KTBCFfUq\r\n" -"UsuWTITwJImcnlAs1gaRZ3sAWm7cOUidL0fo2G0fYUFNcYoCSLffCFTEHBuPnagb\r\n" -"a77x/sY1Bvii8S9/XhDTb6pTMx06wzrm\r\n" -"-----END EC PRIVATE KEY-----\r\n"; -const size_t mbedtls_test_ca_key_ec_len = sizeof( mbedtls_test_ca_key_ec ); - -const char mbedtls_test_ca_pwd_ec[] = "PolarSSLTest"; -const size_t mbedtls_test_ca_pwd_ec_len = sizeof( mbedtls_test_ca_pwd_ec ) - 1; - -const char mbedtls_test_srv_crt_ec[] = -"-----BEGIN CERTIFICATE-----\r\n" -"MIICHzCCAaWgAwIBAgIBCTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G\r\n" -"A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN\r\n" -"MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" -"A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEG\r\n" -"CCqGSM49AwEHA0IABDfMVtl2CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA\r\n" -"2CMR/+ov0jRdXRa9iojCa3cNVc2KKg76Aci07f+jgZ0wgZowCQYDVR0TBAIwADAd\r\n" -"BgNVHQ4EFgQUUGGlj9QH2deCAQzlZX+MY0anE74wbgYDVR0jBGcwZYAUnW0gJEkB\r\n" -"PyvLeLUZvH4kydv7NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xh\r\n" -"clNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAoG\r\n" -"CCqGSM49BAMCA2gAMGUCMQCaLFzXptui5WQN8LlO3ddh1hMxx6tzgLvT03MTVK2S\r\n" -"C12r0Lz3ri/moSEpNZWqPjkCMCE2f53GXcYLqyfyJR078c/xNSUU5+Xxl7VZ414V\r\n" -"fGa5kHvHARBPc8YAIVIqDvHH1Q==\r\n" -"-----END CERTIFICATE-----\r\n"; -const size_t mbedtls_test_srv_crt_ec_len = sizeof( mbedtls_test_srv_crt_ec ); - -const char mbedtls_test_srv_key_ec[] = -"-----BEGIN EC PRIVATE KEY-----\r\n" -"MHcCAQEEIPEqEyB2AnCoPL/9U/YDHvdqXYbIogTywwyp6/UfDw6noAoGCCqGSM49\r\n" -"AwEHoUQDQgAEN8xW2XYJHlpyPsdZLf8gbu58+QaRdNCtFLX3aCJZYpJO5QDYIxH/\r\n" -"6i/SNF1dFr2KiMJrdw1VzYoqDvoByLTt/w==\r\n" -"-----END EC PRIVATE KEY-----\r\n"; -const size_t mbedtls_test_srv_key_ec_len = sizeof( mbedtls_test_srv_key_ec ); - -const char mbedtls_test_cli_crt_ec[] = -"-----BEGIN CERTIFICATE-----\r\n" -"MIICLDCCAbKgAwIBAgIBDTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G\r\n" -"A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN\r\n" -"MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjBBMQswCQYDVQQGEwJOTDERMA8G\r\n" -"A1UEChMIUG9sYXJTU0wxHzAdBgNVBAMTFlBvbGFyU1NMIFRlc3QgQ2xpZW50IDIw\r\n" -"WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARX5a6xc9/TrLuTuIH/Eq7u5lOszlVT\r\n" -"9jQOzC7jYyUL35ji81xgNpbA1RgUcOV/n9VLRRjlsGzVXPiWj4dwo+THo4GdMIGa\r\n" -"MAkGA1UdEwQCMAAwHQYDVR0OBBYEFHoAX4Zk/OBd5REQO7LmO8QmP8/iMG4GA1Ud\r\n" -"IwRnMGWAFJ1tICRJAT8ry3i1Gbx+JMnb+zZ8oUKkQDA+MQswCQYDVQQGEwJOTDER\r\n" -"MA8GA1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0GC\r\n" -"CQDBQ+J+YkPM6DAKBggqhkjOPQQDAgNoADBlAjBKZQ17IIOimbmoD/yN7o89u3BM\r\n" -"lgOsjnhw3fIOoLIWy2WOGsk/LGF++DzvrRzuNiACMQCd8iem1XS4JK7haj8xocpU\r\n" -"LwjQje5PDGHfd3h9tP38Qknu5bJqws0md2KOKHyeV0U=\r\n" -"-----END CERTIFICATE-----\r\n"; -const size_t mbedtls_test_cli_crt_ec_len = sizeof( mbedtls_test_cli_crt_ec ); - -const char mbedtls_test_cli_key_ec[] = -"-----BEGIN EC PRIVATE KEY-----\r\n" -"MHcCAQEEIPb3hmTxZ3/mZI3vyk7p3U3wBf+WIop6hDhkFzJhmLcqoAoGCCqGSM49\r\n" -"AwEHoUQDQgAEV+WusXPf06y7k7iB/xKu7uZTrM5VU/Y0Dswu42MlC9+Y4vNcYDaW\r\n" -"wNUYFHDlf5/VS0UY5bBs1Vz4lo+HcKPkxw==\r\n" -"-----END EC PRIVATE KEY-----\r\n"; -const size_t mbedtls_test_cli_key_ec_len = sizeof( mbedtls_test_cli_key_ec ); -#endif /* MBEDTLS_ECDSA_C */ +/* + * Test CA Certificates + * + * We define test CA certificates for each choice of the following parameters: + * - PEM or DER encoding + * - SHA-1 or SHA-256 hash + * - RSA or EC key + * + * Things to add: + * - multiple EC curve types + * + */ -#if defined(MBEDTLS_RSA_C) +/* This is taken from tests/data_files/test-ca2.crt */ +/* BEGIN FILE string macro TEST_CA_CRT_EC_PEM tests/data_files/test-ca2.crt */ +#define TEST_CA_CRT_EC_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIICUjCCAdegAwIBAgIJAMFD4n5iQ8zoMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYT\r\n" \ + "Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \ + "QyBDQTAeFw0xMzA5MjQxNTQ5NDhaFw0yMzA5MjIxNTQ5NDhaMD4xCzAJBgNVBAYT\r\n" \ + "Ak5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBF\r\n" \ + "QyBDQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABMPaKzRBN1gvh1b+/Im6KUNLTuBu\r\n" \ + "ww5XUzM5WNRStJGVOQsj318XJGJI/BqVKc4sLYfCiFKAr9ZqqyHduNMcbli4yuiy\r\n" \ + "aY7zQa0pw7RfdadHb9UZKVVpmlM7ILRmFmAzHqOBoDCBnTAdBgNVHQ4EFgQUnW0g\r\n" \ + "JEkBPyvLeLUZvH4kydv7NnwwbgYDVR0jBGcwZYAUnW0gJEkBPyvLeLUZvH4kydv7\r\n" \ + "NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEcMBoGA1UE\r\n" \ + "AxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAwGA1UdEwQFMAMBAf8w\r\n" \ + "CgYIKoZIzj0EAwIDaQAwZgIxAMO0YnNWKJUAfXgSJtJxexn4ipg+kv4znuR50v56\r\n" \ + "t4d0PCu412mUC6Nnd7izvtE2MgIxAP1nnJQjZ8BWukszFQDG48wxCCyci9qpdSMv\r\n" \ + "uCjn8pwUOkABXK8Mss90fzCfCEOtIA==\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is generated from tests/data_files/test-ca2.crt.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CA_CRT_EC_DER tests/data_files/test-ca2.crt.der */ +#define TEST_CA_CRT_EC_DER { \ + 0x30, 0x82, 0x02, 0x52, 0x30, 0x82, 0x01, 0xd7, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x09, 0x00, 0xc1, 0x43, 0xe2, 0x7e, 0x62, 0x43, 0xcc, 0xe8, \ + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, \ + 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, \ + 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, \ + 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, \ + 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, \ + 0x43, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x33, 0x30, 0x39, \ + 0x32, 0x34, 0x31, 0x35, 0x34, 0x39, 0x34, 0x38, 0x5a, 0x17, 0x0d, 0x32, \ + 0x33, 0x30, 0x39, 0x32, 0x32, 0x31, 0x35, 0x34, 0x39, 0x34, 0x38, 0x5a, \ + 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, \ + 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, \ + 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, \ + 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, \ + 0x43, 0x20, 0x43, 0x41, 0x30, 0x76, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, \ + 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, \ + 0x03, 0x62, 0x00, 0x04, 0xc3, 0xda, 0x2b, 0x34, 0x41, 0x37, 0x58, 0x2f, \ + 0x87, 0x56, 0xfe, 0xfc, 0x89, 0xba, 0x29, 0x43, 0x4b, 0x4e, 0xe0, 0x6e, \ + 0xc3, 0x0e, 0x57, 0x53, 0x33, 0x39, 0x58, 0xd4, 0x52, 0xb4, 0x91, 0x95, \ + 0x39, 0x0b, 0x23, 0xdf, 0x5f, 0x17, 0x24, 0x62, 0x48, 0xfc, 0x1a, 0x95, \ + 0x29, 0xce, 0x2c, 0x2d, 0x87, 0xc2, 0x88, 0x52, 0x80, 0xaf, 0xd6, 0x6a, \ + 0xab, 0x21, 0xdd, 0xb8, 0xd3, 0x1c, 0x6e, 0x58, 0xb8, 0xca, 0xe8, 0xb2, \ + 0x69, 0x8e, 0xf3, 0x41, 0xad, 0x29, 0xc3, 0xb4, 0x5f, 0x75, 0xa7, 0x47, \ + 0x6f, 0xd5, 0x19, 0x29, 0x55, 0x69, 0x9a, 0x53, 0x3b, 0x20, 0xb4, 0x66, \ + 0x16, 0x60, 0x33, 0x1e, 0xa3, 0x81, 0xa0, 0x30, 0x81, 0x9d, 0x30, 0x1d, \ + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x9d, 0x6d, 0x20, \ + 0x24, 0x49, 0x01, 0x3f, 0x2b, 0xcb, 0x78, 0xb5, 0x19, 0xbc, 0x7e, 0x24, \ + 0xc9, 0xdb, 0xfb, 0x36, 0x7c, 0x30, 0x6e, 0x06, 0x03, 0x55, 0x1d, 0x23, \ + 0x04, 0x67, 0x30, 0x65, 0x80, 0x14, 0x9d, 0x6d, 0x20, 0x24, 0x49, 0x01, \ + 0x3f, 0x2b, 0xcb, 0x78, 0xb5, 0x19, 0xbc, 0x7e, 0x24, 0xc9, 0xdb, 0xfb, \ + 0x36, 0x7c, 0xa1, 0x42, 0xa4, 0x40, 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, \ + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, \ + 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, \ + 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, \ + 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, \ + 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x43, 0x20, 0x43, 0x41, 0x82, 0x09, \ + 0x00, 0xc1, 0x43, 0xe2, 0x7e, 0x62, 0x43, 0xcc, 0xe8, 0x30, 0x0c, 0x06, \ + 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, \ + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, \ + 0x69, 0x00, 0x30, 0x66, 0x02, 0x31, 0x00, 0xc3, 0xb4, 0x62, 0x73, 0x56, \ + 0x28, 0x95, 0x00, 0x7d, 0x78, 0x12, 0x26, 0xd2, 0x71, 0x7b, 0x19, 0xf8, \ + 0x8a, 0x98, 0x3e, 0x92, 0xfe, 0x33, 0x9e, 0xe4, 0x79, 0xd2, 0xfe, 0x7a, \ + 0xb7, 0x87, 0x74, 0x3c, 0x2b, 0xb8, 0xd7, 0x69, 0x94, 0x0b, 0xa3, 0x67, \ + 0x77, 0xb8, 0xb3, 0xbe, 0xd1, 0x36, 0x32, 0x02, 0x31, 0x00, 0xfd, 0x67, \ + 0x9c, 0x94, 0x23, 0x67, 0xc0, 0x56, 0xba, 0x4b, 0x33, 0x15, 0x00, 0xc6, \ + 0xe3, 0xcc, 0x31, 0x08, 0x2c, 0x9c, 0x8b, 0xda, 0xa9, 0x75, 0x23, 0x2f, \ + 0xb8, 0x28, 0xe7, 0xf2, 0x9c, 0x14, 0x3a, 0x40, 0x01, 0x5c, 0xaf, 0x0c, \ + 0xb2, 0xcf, 0x74, 0x7f, 0x30, 0x9f, 0x08, 0x43, 0xad, 0x20 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/test-ca2.key.enc */ +/* BEGIN FILE string macro TEST_CA_KEY_EC_PEM tests/data_files/test-ca2.key.enc */ +#define TEST_CA_KEY_EC_PEM \ + "-----BEGIN EC PRIVATE KEY-----\r\n" \ + "Proc-Type: 4,ENCRYPTED\r\n" \ + "DEK-Info: DES-EDE3-CBC,307EAB469933D64E\r\n" \ + "\r\n" \ + "IxbrRmKcAzctJqPdTQLA4SWyBYYGYJVkYEna+F7Pa5t5Yg/gKADrFKcm6B72e7DG\r\n" \ + "ihExtZI648s0zdYw6qSJ74vrPSuWDe5qm93BqsfVH9svtCzWHW0pm1p0KTBCFfUq\r\n" \ + "UsuWTITwJImcnlAs1gaRZ3sAWm7cOUidL0fo2G0fYUFNcYoCSLffCFTEHBuPnagb\r\n" \ + "a77x/sY1Bvii8S9/XhDTb6pTMx06wzrm\r\n" \ + "-----END EC PRIVATE KEY-----\r\n" +/* END FILE */ + +#define TEST_CA_PWD_EC_PEM "PolarSSLTest" + +/* This is generated from tests/data_files/test-ca2.key.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CA_KEY_EC_DER tests/data_files/test-ca2.key.der */ +#define TEST_CA_KEY_EC_DER { \ + 0x30, 0x81, 0xa4, 0x02, 0x01, 0x01, 0x04, 0x30, 0x83, 0xd9, 0x15, 0x0e, \ + 0xa0, 0x71, 0xf0, 0x57, 0x10, 0x33, 0xa3, 0x38, 0xb8, 0x86, 0xc1, 0xa6, \ + 0x11, 0x5d, 0x6d, 0xb4, 0x03, 0xe1, 0x29, 0x76, 0x45, 0xd7, 0x87, 0x6f, \ + 0x23, 0xab, 0x44, 0x20, 0xea, 0x64, 0x7b, 0x85, 0xb1, 0x76, 0xe7, 0x85, \ + 0x95, 0xaa, 0x74, 0xd6, 0xd1, 0xa4, 0x5e, 0xea, 0xa0, 0x07, 0x06, 0x05, \ + 0x2b, 0x81, 0x04, 0x00, 0x22, 0xa1, 0x64, 0x03, 0x62, 0x00, 0x04, 0xc3, \ + 0xda, 0x2b, 0x34, 0x41, 0x37, 0x58, 0x2f, 0x87, 0x56, 0xfe, 0xfc, 0x89, \ + 0xba, 0x29, 0x43, 0x4b, 0x4e, 0xe0, 0x6e, 0xc3, 0x0e, 0x57, 0x53, 0x33, \ + 0x39, 0x58, 0xd4, 0x52, 0xb4, 0x91, 0x95, 0x39, 0x0b, 0x23, 0xdf, 0x5f, \ + 0x17, 0x24, 0x62, 0x48, 0xfc, 0x1a, 0x95, 0x29, 0xce, 0x2c, 0x2d, 0x87, \ + 0xc2, 0x88, 0x52, 0x80, 0xaf, 0xd6, 0x6a, 0xab, 0x21, 0xdd, 0xb8, 0xd3, \ + 0x1c, 0x6e, 0x58, 0xb8, 0xca, 0xe8, 0xb2, 0x69, 0x8e, 0xf3, 0x41, 0xad, \ + 0x29, 0xc3, 0xb4, 0x5f, 0x75, 0xa7, 0x47, 0x6f, 0xd5, 0x19, 0x29, 0x55, \ + 0x69, 0x9a, 0x53, 0x3b, 0x20, 0xb4, 0x66, 0x16, 0x60, 0x33, 0x1e \ +} +/* END FILE */ + +/* This is taken from tests/data_files/test-ca-sha256.crt. */ +/* BEGIN FILE string macro TEST_CA_CRT_RSA_SHA256_PEM tests/data_files/test-ca-sha256.crt */ +#define TEST_CA_CRT_RSA_SHA256_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n" \ + "MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ + "MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \ + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \ + "mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \ + "50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" \ + "YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" \ + "R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" \ + "KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" \ + "UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/\r\n" \ + "MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBCwUA\r\n" \ + "A4IBAQB2W2dIy4q4KysbrTL4HIaOqu62RceGuQ/KhyiI6O0ndCtQ/PgCBqHHTP8u\r\n" \ + "8F1X2ivb60ynHV6baMLPI4Kf1k4MONtLSf/++1qh0Gdycd3A8IDAfy0YnC1F3OPK\r\n" \ + "vWO/cZGitKoTbEpP4y4Rng3sFCDndRCWIRIDOEEW/H3lCcfL7sOQojdLl85ajFkh\r\n" \ + "YvcDqjmnTcspUnuq9Y00C7porXJthZwz1S18qVjcFNk0zEhVMUbupSrdXVmKtOJW\r\n" \ + "MWZjgcA+OXzcnb2hSKWbhjykH/u6/PqkuHPkD723rwXbmHdxRVS9CW57kDkn5ezJ\r\n" \ + "5pE6Sam4qFsCNFJNBV9FRf3ZBMFi\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is generated from tests/data_files/test-ca-sha256.crt.der + * using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CA_CRT_RSA_SHA256_DER tests/data_files/test-ca-sha256.crt.der */ +#define TEST_CA_CRT_RSA_SHA256_DER { \ + 0x30, 0x82, 0x03, 0x41, 0x30, 0x82, 0x02, 0x29, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x03, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, \ + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x3b, 0x31, 0x0b, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, \ + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, \ + 0x04, 0x03, 0x0c, 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, \ + 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, 0x34, 0x30, 0x30, \ + 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, \ + 0x34, 0x30, 0x30, 0x5a, 0x30, 0x3b, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, \ + 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x20, 0x54, 0x65, \ + 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, \ + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, \ + 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, \ + 0x01, 0x00, 0xc0, 0xdf, 0x37, 0xfc, 0x17, 0xbb, 0xe0, 0x96, 0x9d, 0x3f, \ + 0x86, 0xde, 0x96, 0x32, 0x7d, 0x44, 0xa5, 0x16, 0xa0, 0xcd, 0x21, 0xf1, \ + 0x99, 0xd4, 0xec, 0xea, 0xcb, 0x7c, 0x18, 0x58, 0x08, 0x94, 0xa5, 0xec, \ + 0x9b, 0xc5, 0x8b, 0xdf, 0x1a, 0x1e, 0x99, 0x38, 0x99, 0x87, 0x1e, 0x7b, \ + 0xc0, 0x8d, 0x39, 0xdf, 0x38, 0x5d, 0x70, 0x78, 0x07, 0xd3, 0x9e, 0xd9, \ + 0x93, 0xe8, 0xb9, 0x72, 0x51, 0xc5, 0xce, 0xa3, 0x30, 0x52, 0xa9, 0xf2, \ + 0xe7, 0x40, 0x70, 0x14, 0xcb, 0x44, 0xa2, 0x72, 0x0b, 0xc2, 0xe5, 0x40, \ + 0xf9, 0x3e, 0xe5, 0xa6, 0x0e, 0xb3, 0xf9, 0xec, 0x4a, 0x63, 0xc0, 0xb8, \ + 0x29, 0x00, 0x74, 0x9c, 0x57, 0x3b, 0xa8, 0xa5, 0x04, 0x90, 0x71, 0xf1, \ + 0xbd, 0x83, 0xd9, 0x3f, 0xd6, 0xa5, 0xe2, 0x3c, 0x2a, 0x8f, 0xef, 0x27, \ + 0x60, 0xc3, 0xc6, 0x9f, 0xcb, 0xba, 0xec, 0x60, 0x7d, 0xb7, 0xe6, 0x84, \ + 0x32, 0xbe, 0x4f, 0xfb, 0x58, 0x26, 0x22, 0x03, 0x5b, 0xd4, 0xb4, 0xd5, \ + 0xfb, 0xf5, 0xe3, 0x96, 0x2e, 0x70, 0xc0, 0xe4, 0x2e, 0xbd, 0xfc, 0x2e, \ + 0xee, 0xe2, 0x41, 0x55, 0xc0, 0x34, 0x2e, 0x7d, 0x24, 0x72, 0x69, 0xcb, \ + 0x47, 0xb1, 0x14, 0x40, 0x83, 0x7d, 0x67, 0xf4, 0x86, 0xf6, 0x31, 0xab, \ + 0xf1, 0x79, 0xa4, 0xb2, 0xb5, 0x2e, 0x12, 0xf9, 0x84, 0x17, 0xf0, 0x62, \ + 0x6f, 0x27, 0x3e, 0x13, 0x58, 0xb1, 0x54, 0x0d, 0x21, 0x9a, 0x73, 0x37, \ + 0xa1, 0x30, 0xcf, 0x6f, 0x92, 0xdc, 0xf6, 0xe9, 0xfc, 0xac, 0xdb, 0x2e, \ + 0x28, 0xd1, 0x7e, 0x02, 0x4b, 0x23, 0xa0, 0x15, 0xf2, 0x38, 0x65, 0x64, \ + 0x09, 0xea, 0x0c, 0x6e, 0x8e, 0x1b, 0x17, 0xa0, 0x71, 0xc8, 0xb3, 0x9b, \ + 0xc9, 0xab, 0xe9, 0xc3, 0xf2, 0xcf, 0x87, 0x96, 0x8f, 0x80, 0x02, 0x32, \ + 0x9e, 0x99, 0x58, 0x6f, 0xa2, 0xd5, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, \ + 0x50, 0x30, 0x4e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, \ + 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, \ + 0x04, 0x16, 0x04, 0x14, 0xb4, 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, \ + 0xf6, 0xb9, 0xd5, 0xa6, 0x95, 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, \ + 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, \ + 0x14, 0xb4, 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, 0xf6, 0xb9, 0xd5, \ + 0xa6, 0x95, 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, 0x30, 0x0d, 0x06, \ + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, \ + 0x03, 0x82, 0x01, 0x01, 0x00, 0x76, 0x5b, 0x67, 0x48, 0xcb, 0x8a, 0xb8, \ + 0x2b, 0x2b, 0x1b, 0xad, 0x32, 0xf8, 0x1c, 0x86, 0x8e, 0xaa, 0xee, 0xb6, \ + 0x45, 0xc7, 0x86, 0xb9, 0x0f, 0xca, 0x87, 0x28, 0x88, 0xe8, 0xed, 0x27, \ + 0x74, 0x2b, 0x50, 0xfc, 0xf8, 0x02, 0x06, 0xa1, 0xc7, 0x4c, 0xff, 0x2e, \ + 0xf0, 0x5d, 0x57, 0xda, 0x2b, 0xdb, 0xeb, 0x4c, 0xa7, 0x1d, 0x5e, 0x9b, \ + 0x68, 0xc2, 0xcf, 0x23, 0x82, 0x9f, 0xd6, 0x4e, 0x0c, 0x38, 0xdb, 0x4b, \ + 0x49, 0xff, 0xfe, 0xfb, 0x5a, 0xa1, 0xd0, 0x67, 0x72, 0x71, 0xdd, 0xc0, \ + 0xf0, 0x80, 0xc0, 0x7f, 0x2d, 0x18, 0x9c, 0x2d, 0x45, 0xdc, 0xe3, 0xca, \ + 0xbd, 0x63, 0xbf, 0x71, 0x91, 0xa2, 0xb4, 0xaa, 0x13, 0x6c, 0x4a, 0x4f, \ + 0xe3, 0x2e, 0x11, 0x9e, 0x0d, 0xec, 0x14, 0x20, 0xe7, 0x75, 0x10, 0x96, \ + 0x21, 0x12, 0x03, 0x38, 0x41, 0x16, 0xfc, 0x7d, 0xe5, 0x09, 0xc7, 0xcb, \ + 0xee, 0xc3, 0x90, 0xa2, 0x37, 0x4b, 0x97, 0xce, 0x5a, 0x8c, 0x59, 0x21, \ + 0x62, 0xf7, 0x03, 0xaa, 0x39, 0xa7, 0x4d, 0xcb, 0x29, 0x52, 0x7b, 0xaa, \ + 0xf5, 0x8d, 0x34, 0x0b, 0xba, 0x68, 0xad, 0x72, 0x6d, 0x85, 0x9c, 0x33, \ + 0xd5, 0x2d, 0x7c, 0xa9, 0x58, 0xdc, 0x14, 0xd9, 0x34, 0xcc, 0x48, 0x55, \ + 0x31, 0x46, 0xee, 0xa5, 0x2a, 0xdd, 0x5d, 0x59, 0x8a, 0xb4, 0xe2, 0x56, \ + 0x31, 0x66, 0x63, 0x81, 0xc0, 0x3e, 0x39, 0x7c, 0xdc, 0x9d, 0xbd, 0xa1, \ + 0x48, 0xa5, 0x9b, 0x86, 0x3c, 0xa4, 0x1f, 0xfb, 0xba, 0xfc, 0xfa, 0xa4, \ + 0xb8, 0x73, 0xe4, 0x0f, 0xbd, 0xb7, 0xaf, 0x05, 0xdb, 0x98, 0x77, 0x71, \ + 0x45, 0x54, 0xbd, 0x09, 0x6e, 0x7b, 0x90, 0x39, 0x27, 0xe5, 0xec, 0xc9, \ + 0xe6, 0x91, 0x3a, 0x49, 0xa9, 0xb8, 0xa8, 0x5b, 0x02, 0x34, 0x52, 0x4d, \ + 0x05, 0x5f, 0x45, 0x45, 0xfd, 0xd9, 0x04, 0xc1, 0x62 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/test-ca-sha1.crt. */ +/* BEGIN FILE string macro TEST_CA_CRT_RSA_SHA1_PEM tests/data_files/test-ca-sha1.crt */ +#define TEST_CA_CRT_RSA_SHA1_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" \ + "MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ + "MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \ + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \ + "mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \ + "50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" \ + "YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" \ + "R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" \ + "KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" \ + "UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/\r\n" \ + "MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBBQUA\r\n" \ + "A4IBAQABE3OEPfEd/bcJW5ZdU3/VgPNS4tMzh8gnJP/V2FcvFtGylMpQq6YnEBYI\r\n" \ + "yBHAL4DRvlMY5rnXGBp3ODR8MpqHC6AquRTCLzjS57iYff//4QFQqW9n92zctspv\r\n" \ + "czkaPKgjqo1No3Uq0Xaz10rcxyTUPrf5wNVRZ2V0KvllvAAVSzbI4mpdUXztjhST\r\n" \ + "S5A2BeWQAAOr0zq1F7TSRVJpJs7jmB2ai/igkh1IAjcuwV6VwlP+sbw0gjQ0NpGM\r\n" \ + "iHpnlzRAi/tIbtOvMIGOBU2TIfax/5jq1agUx5aPmT5TWAiJPOOP6l5xXnDwxeYS\r\n" \ + "NWqiX9GyusBZjezaCaHabjDLU0qQ\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is taken from tests/data_files/test-ca-sha1.crt.der. */ +/* BEGIN FILE binary macro TEST_CA_CRT_RSA_SHA1_DER tests/data_files/test-ca-sha1.crt.der */ +#define TEST_CA_CRT_RSA_SHA1_DER { \ + 0x30, 0x82, 0x03, 0x41, 0x30, 0x82, 0x02, 0x29, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x03, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, \ + 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x3b, 0x31, 0x0b, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, \ + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, \ + 0x04, 0x03, 0x0c, 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, \ + 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, 0x34, 0x30, 0x30, \ + 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, \ + 0x34, 0x30, 0x30, 0x5a, 0x30, 0x3b, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, \ + 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x20, 0x54, 0x65, \ + 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, \ + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, \ + 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, \ + 0x01, 0x00, 0xc0, 0xdf, 0x37, 0xfc, 0x17, 0xbb, 0xe0, 0x96, 0x9d, 0x3f, \ + 0x86, 0xde, 0x96, 0x32, 0x7d, 0x44, 0xa5, 0x16, 0xa0, 0xcd, 0x21, 0xf1, \ + 0x99, 0xd4, 0xec, 0xea, 0xcb, 0x7c, 0x18, 0x58, 0x08, 0x94, 0xa5, 0xec, \ + 0x9b, 0xc5, 0x8b, 0xdf, 0x1a, 0x1e, 0x99, 0x38, 0x99, 0x87, 0x1e, 0x7b, \ + 0xc0, 0x8d, 0x39, 0xdf, 0x38, 0x5d, 0x70, 0x78, 0x07, 0xd3, 0x9e, 0xd9, \ + 0x93, 0xe8, 0xb9, 0x72, 0x51, 0xc5, 0xce, 0xa3, 0x30, 0x52, 0xa9, 0xf2, \ + 0xe7, 0x40, 0x70, 0x14, 0xcb, 0x44, 0xa2, 0x72, 0x0b, 0xc2, 0xe5, 0x40, \ + 0xf9, 0x3e, 0xe5, 0xa6, 0x0e, 0xb3, 0xf9, 0xec, 0x4a, 0x63, 0xc0, 0xb8, \ + 0x29, 0x00, 0x74, 0x9c, 0x57, 0x3b, 0xa8, 0xa5, 0x04, 0x90, 0x71, 0xf1, \ + 0xbd, 0x83, 0xd9, 0x3f, 0xd6, 0xa5, 0xe2, 0x3c, 0x2a, 0x8f, 0xef, 0x27, \ + 0x60, 0xc3, 0xc6, 0x9f, 0xcb, 0xba, 0xec, 0x60, 0x7d, 0xb7, 0xe6, 0x84, \ + 0x32, 0xbe, 0x4f, 0xfb, 0x58, 0x26, 0x22, 0x03, 0x5b, 0xd4, 0xb4, 0xd5, \ + 0xfb, 0xf5, 0xe3, 0x96, 0x2e, 0x70, 0xc0, 0xe4, 0x2e, 0xbd, 0xfc, 0x2e, \ + 0xee, 0xe2, 0x41, 0x55, 0xc0, 0x34, 0x2e, 0x7d, 0x24, 0x72, 0x69, 0xcb, \ + 0x47, 0xb1, 0x14, 0x40, 0x83, 0x7d, 0x67, 0xf4, 0x86, 0xf6, 0x31, 0xab, \ + 0xf1, 0x79, 0xa4, 0xb2, 0xb5, 0x2e, 0x12, 0xf9, 0x84, 0x17, 0xf0, 0x62, \ + 0x6f, 0x27, 0x3e, 0x13, 0x58, 0xb1, 0x54, 0x0d, 0x21, 0x9a, 0x73, 0x37, \ + 0xa1, 0x30, 0xcf, 0x6f, 0x92, 0xdc, 0xf6, 0xe9, 0xfc, 0xac, 0xdb, 0x2e, \ + 0x28, 0xd1, 0x7e, 0x02, 0x4b, 0x23, 0xa0, 0x15, 0xf2, 0x38, 0x65, 0x64, \ + 0x09, 0xea, 0x0c, 0x6e, 0x8e, 0x1b, 0x17, 0xa0, 0x71, 0xc8, 0xb3, 0x9b, \ + 0xc9, 0xab, 0xe9, 0xc3, 0xf2, 0xcf, 0x87, 0x96, 0x8f, 0x80, 0x02, 0x32, \ + 0x9e, 0x99, 0x58, 0x6f, 0xa2, 0xd5, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, \ + 0x50, 0x30, 0x4e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x05, \ + 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, \ + 0x04, 0x16, 0x04, 0x14, 0xb4, 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, \ + 0xf6, 0xb9, 0xd5, 0xa6, 0x95, 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, \ + 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, \ + 0x14, 0xb4, 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, 0xf6, 0xb9, 0xd5, \ + 0xa6, 0x95, 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, 0x30, 0x0d, 0x06, \ + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, \ + 0x03, 0x82, 0x01, 0x01, 0x00, 0x01, 0x13, 0x73, 0x84, 0x3d, 0xf1, 0x1d, \ + 0xfd, 0xb7, 0x09, 0x5b, 0x96, 0x5d, 0x53, 0x7f, 0xd5, 0x80, 0xf3, 0x52, \ + 0xe2, 0xd3, 0x33, 0x87, 0xc8, 0x27, 0x24, 0xff, 0xd5, 0xd8, 0x57, 0x2f, \ + 0x16, 0xd1, 0xb2, 0x94, 0xca, 0x50, 0xab, 0xa6, 0x27, 0x10, 0x16, 0x08, \ + 0xc8, 0x11, 0xc0, 0x2f, 0x80, 0xd1, 0xbe, 0x53, 0x18, 0xe6, 0xb9, 0xd7, \ + 0x18, 0x1a, 0x77, 0x38, 0x34, 0x7c, 0x32, 0x9a, 0x87, 0x0b, 0xa0, 0x2a, \ + 0xb9, 0x14, 0xc2, 0x2f, 0x38, 0xd2, 0xe7, 0xb8, 0x98, 0x7d, 0xff, 0xff, \ + 0xe1, 0x01, 0x50, 0xa9, 0x6f, 0x67, 0xf7, 0x6c, 0xdc, 0xb6, 0xca, 0x6f, \ + 0x73, 0x39, 0x1a, 0x3c, 0xa8, 0x23, 0xaa, 0x8d, 0x4d, 0xa3, 0x75, 0x2a, \ + 0xd1, 0x76, 0xb3, 0xd7, 0x4a, 0xdc, 0xc7, 0x24, 0xd4, 0x3e, 0xb7, 0xf9, \ + 0xc0, 0xd5, 0x51, 0x67, 0x65, 0x74, 0x2a, 0xf9, 0x65, 0xbc, 0x00, 0x15, \ + 0x4b, 0x36, 0xc8, 0xe2, 0x6a, 0x5d, 0x51, 0x7c, 0xed, 0x8e, 0x14, 0x93, \ + 0x4b, 0x90, 0x36, 0x05, 0xe5, 0x90, 0x00, 0x03, 0xab, 0xd3, 0x3a, 0xb5, \ + 0x17, 0xb4, 0xd2, 0x45, 0x52, 0x69, 0x26, 0xce, 0xe3, 0x98, 0x1d, 0x9a, \ + 0x8b, 0xf8, 0xa0, 0x92, 0x1d, 0x48, 0x02, 0x37, 0x2e, 0xc1, 0x5e, 0x95, \ + 0xc2, 0x53, 0xfe, 0xb1, 0xbc, 0x34, 0x82, 0x34, 0x34, 0x36, 0x91, 0x8c, \ + 0x88, 0x7a, 0x67, 0x97, 0x34, 0x40, 0x8b, 0xfb, 0x48, 0x6e, 0xd3, 0xaf, \ + 0x30, 0x81, 0x8e, 0x05, 0x4d, 0x93, 0x21, 0xf6, 0xb1, 0xff, 0x98, 0xea, \ + 0xd5, 0xa8, 0x14, 0xc7, 0x96, 0x8f, 0x99, 0x3e, 0x53, 0x58, 0x08, 0x89, \ + 0x3c, 0xe3, 0x8f, 0xea, 0x5e, 0x71, 0x5e, 0x70, 0xf0, 0xc5, 0xe6, 0x12, \ + 0x35, 0x6a, 0xa2, 0x5f, 0xd1, 0xb2, 0xba, 0xc0, 0x59, 0x8d, 0xec, 0xda, \ + 0x09, 0xa1, 0xda, 0x6e, 0x30, 0xcb, 0x53, 0x4a, 0x90 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/test-ca.key */ +/* BEGIN FILE string macro TEST_CA_KEY_RSA_PEM tests/data_files/test-ca.key */ +#define TEST_CA_KEY_RSA_PEM \ + "-----BEGIN RSA PRIVATE KEY-----\r\n" \ + "Proc-Type: 4,ENCRYPTED\r\n" \ + "DEK-Info: DES-EDE3-CBC,A8A95B05D5B7206B\r\n" \ + "\r\n" \ + "9Qd9GeArejl1GDVh2lLV1bHt0cPtfbh5h/5zVpAVaFpqtSPMrElp50Rntn9et+JA\r\n" \ + "7VOyboR+Iy2t/HU4WvA687k3Bppe9GwKHjHhtl//8xFKwZr3Xb5yO5JUP8AUctQq\r\n" \ + "Nb8CLlZyuUC+52REAAthdWgsX+7dJO4yabzUcQ22Tp9JSD0hiL43BlkWYUNK3dAo\r\n" \ + "PZlmiptjnzVTjg1MxsBSydZinWOLBV8/JQgxSPo2yD4uEfig28qbvQ2wNIn0pnAb\r\n" \ + "GxnSAOazkongEGfvcjIIs+LZN9gXFhxcOh6kc4Q/c99B7QWETwLLkYgZ+z1a9VY9\r\n" \ + "gEU7CwCxYCD+h9hY6FPmsK0/lC4O7aeRKpYq00rPPxs6i7phiexg6ax6yTMmArQq\r\n" \ + "QmK3TAsJm8V/J5AWpLEV6jAFgRGymGGHnof0DXzVWZidrcZJWTNuGEX90nB3ee2w\r\n" \ + "PXJEFWKoD3K3aFcSLdHYr3mLGxP7H9ThQai9VsycxZKS5kwvBKQ//YMrmFfwPk8x\r\n" \ + "vTeY4KZMaUrveEel5tWZC94RSMKgxR6cyE1nBXyTQnDOGbfpNNgBKxyKbINWoOJU\r\n" \ + "WJZAwlsQn+QzCDwpri7+sV1mS3gBE6UY7aQmnmiiaC2V3Hbphxct/en5QsfDOt1X\r\n" \ + "JczSfpRWLlbPznZg8OQh/VgCMA58N5DjOzTIK7sJJ5r+94ZBTCpgAMbF588f0NTR\r\n" \ + "KCe4yrxGJR7X02M4nvD4IwOlpsQ8xQxZtOSgXv4LkxvdU9XJJKWZ/XNKJeWztxSe\r\n" \ + "Z1vdTc2YfsDBA2SEv33vxHx2g1vqtw8SjDRT2RaQSS0QuSaMJimdOX6mTOCBKk1J\r\n" \ + "9Q5mXTrER+/LnK0jEmXsBXWA5bqqVZIyahXSx4VYZ7l7w/PHiUDtDgyRhMMKi4n2\r\n" \ + "iQvQcWSQTjrpnlJbca1/DkpRt3YwrvJwdqb8asZU2VrNETh5x0QVefDRLFiVpif/\r\n" \ + "tUaeAe/P1F8OkS7OIZDs1SUbv/sD2vMbhNkUoCms3/PvNtdnvgL4F0zhaDpKCmlT\r\n" \ + "P8vx49E7v5CyRNmED9zZg4o3wmMqrQO93PtTug3Eu9oVx1zPQM1NVMyBa2+f29DL\r\n" \ + "1nuTCeXdo9+ni45xx+jAI4DCwrRdhJ9uzZyC6962H37H6D+5naNvClFR1s6li1Gb\r\n" \ + "nqPoiy/OBsEx9CaDGcqQBp5Wme/3XW+6z1ISOx+igwNTVCT14mHdBMbya0eIKft5\r\n" \ + "X+GnwtgEMyCYyyWuUct8g4RzErcY9+yW9Om5Hzpx4zOuW4NPZgPDTgK+t2RSL/Yq\r\n" \ + "rE1njrgeGYcVeG3f+OftH4s6fPbq7t1A5ZgUscbLMBqr9tK+OqygR4EgKBPsH6Cz\r\n" \ + "L6zlv/2RV0qAHvVuDJcIDIgwY5rJtINEm32rhOeFNJwZS5MNIC1czXZx5//ugX7l\r\n" \ + "I4sy5nbVhwSjtAk8Xg5dZbdTZ6mIrb7xqH+fdakZor1khG7bC2uIwibD3cSl2XkR\r\n" \ + "wN48lslbHnqqagr6Xm1nNOSVl8C/6kbJEsMpLhAezfRtGwvOucoaE+WbeUNolGde\r\n" \ + "P/eQiddSf0brnpiLJRh7qZrl9XuqYdpUqnoEdMAfotDOID8OtV7gt8a48ad8VPW2\r\n" \ + "-----END RSA PRIVATE KEY-----\r\n" +/* END FILE */ + +#define TEST_CA_PWD_RSA_PEM "PolarSSLTest" + +/* This was generated from test-ca.key.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CA_KEY_RSA_DER tests/data_files/test-ca.key.der */ +#define TEST_CA_KEY_RSA_DER { \ + 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, \ + 0xc0, 0xdf, 0x37, 0xfc, 0x17, 0xbb, 0xe0, 0x96, 0x9d, 0x3f, 0x86, 0xde, \ + 0x96, 0x32, 0x7d, 0x44, 0xa5, 0x16, 0xa0, 0xcd, 0x21, 0xf1, 0x99, 0xd4, \ + 0xec, 0xea, 0xcb, 0x7c, 0x18, 0x58, 0x08, 0x94, 0xa5, 0xec, 0x9b, 0xc5, \ + 0x8b, 0xdf, 0x1a, 0x1e, 0x99, 0x38, 0x99, 0x87, 0x1e, 0x7b, 0xc0, 0x8d, \ + 0x39, 0xdf, 0x38, 0x5d, 0x70, 0x78, 0x07, 0xd3, 0x9e, 0xd9, 0x93, 0xe8, \ + 0xb9, 0x72, 0x51, 0xc5, 0xce, 0xa3, 0x30, 0x52, 0xa9, 0xf2, 0xe7, 0x40, \ + 0x70, 0x14, 0xcb, 0x44, 0xa2, 0x72, 0x0b, 0xc2, 0xe5, 0x40, 0xf9, 0x3e, \ + 0xe5, 0xa6, 0x0e, 0xb3, 0xf9, 0xec, 0x4a, 0x63, 0xc0, 0xb8, 0x29, 0x00, \ + 0x74, 0x9c, 0x57, 0x3b, 0xa8, 0xa5, 0x04, 0x90, 0x71, 0xf1, 0xbd, 0x83, \ + 0xd9, 0x3f, 0xd6, 0xa5, 0xe2, 0x3c, 0x2a, 0x8f, 0xef, 0x27, 0x60, 0xc3, \ + 0xc6, 0x9f, 0xcb, 0xba, 0xec, 0x60, 0x7d, 0xb7, 0xe6, 0x84, 0x32, 0xbe, \ + 0x4f, 0xfb, 0x58, 0x26, 0x22, 0x03, 0x5b, 0xd4, 0xb4, 0xd5, 0xfb, 0xf5, \ + 0xe3, 0x96, 0x2e, 0x70, 0xc0, 0xe4, 0x2e, 0xbd, 0xfc, 0x2e, 0xee, 0xe2, \ + 0x41, 0x55, 0xc0, 0x34, 0x2e, 0x7d, 0x24, 0x72, 0x69, 0xcb, 0x47, 0xb1, \ + 0x14, 0x40, 0x83, 0x7d, 0x67, 0xf4, 0x86, 0xf6, 0x31, 0xab, 0xf1, 0x79, \ + 0xa4, 0xb2, 0xb5, 0x2e, 0x12, 0xf9, 0x84, 0x17, 0xf0, 0x62, 0x6f, 0x27, \ + 0x3e, 0x13, 0x58, 0xb1, 0x54, 0x0d, 0x21, 0x9a, 0x73, 0x37, 0xa1, 0x30, \ + 0xcf, 0x6f, 0x92, 0xdc, 0xf6, 0xe9, 0xfc, 0xac, 0xdb, 0x2e, 0x28, 0xd1, \ + 0x7e, 0x02, 0x4b, 0x23, 0xa0, 0x15, 0xf2, 0x38, 0x65, 0x64, 0x09, 0xea, \ + 0x0c, 0x6e, 0x8e, 0x1b, 0x17, 0xa0, 0x71, 0xc8, 0xb3, 0x9b, 0xc9, 0xab, \ + 0xe9, 0xc3, 0xf2, 0xcf, 0x87, 0x96, 0x8f, 0x80, 0x02, 0x32, 0x9e, 0x99, \ + 0x58, 0x6f, 0xa2, 0xd5, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01, \ + 0x00, 0x3f, 0xf7, 0x07, 0xd3, 0x34, 0x6f, 0xdb, 0xc9, 0x37, 0xb7, 0x84, \ + 0xdc, 0x37, 0x45, 0xe1, 0x63, 0xad, 0xb8, 0xb6, 0x75, 0xb1, 0xc7, 0x35, \ + 0xb4, 0x77, 0x2a, 0x5b, 0x77, 0xf9, 0x7e, 0xe0, 0xc1, 0xa3, 0xd1, 0xb7, \ + 0xcb, 0xa9, 0x5a, 0xc1, 0x87, 0xda, 0x5a, 0xfa, 0x17, 0xe4, 0xd5, 0x38, \ + 0x03, 0xde, 0x68, 0x98, 0x81, 0xec, 0xb5, 0xf2, 0x2a, 0x8d, 0xe9, 0x2c, \ + 0xf3, 0xa6, 0xe5, 0x32, 0x17, 0x7f, 0x33, 0x81, 0xe8, 0x38, 0x72, 0xd5, \ + 0x9c, 0xfa, 0x4e, 0xfb, 0x26, 0xf5, 0x15, 0x0b, 0xaf, 0x84, 0x66, 0xab, \ + 0x02, 0xe0, 0x18, 0xd5, 0x91, 0x7c, 0xd6, 0x8f, 0xc9, 0x4b, 0x76, 0x08, \ + 0x2b, 0x1d, 0x81, 0x68, 0x30, 0xe1, 0xfa, 0x70, 0x6c, 0x13, 0x4e, 0x10, \ + 0x03, 0x35, 0x3e, 0xc5, 0xca, 0x58, 0x20, 0x8a, 0x21, 0x18, 0x38, 0xa0, \ + 0x0f, 0xed, 0xc4, 0xbb, 0x45, 0x6f, 0xf5, 0x84, 0x5b, 0xb0, 0xcf, 0x4e, \ + 0x9d, 0x58, 0x13, 0x6b, 0x35, 0x35, 0x69, 0xa1, 0xd2, 0xc4, 0xf2, 0xc1, \ + 0x48, 0x04, 0x20, 0x51, 0xb9, 0x6b, 0xa4, 0x5d, 0xa5, 0x4b, 0x84, 0x88, \ + 0x43, 0x48, 0x99, 0x2c, 0xbb, 0xa4, 0x97, 0xd6, 0xd6, 0x18, 0xf6, 0xec, \ + 0x5c, 0xd1, 0x31, 0x49, 0xc9, 0xf2, 0x8f, 0x0b, 0x4d, 0xef, 0x09, 0x02, \ + 0xfe, 0x7d, 0xfd, 0xbb, 0xaf, 0x2b, 0x83, 0x94, 0x22, 0xc4, 0xa7, 0x3e, \ + 0x66, 0xf5, 0xe0, 0x57, 0xdc, 0xf2, 0xed, 0x2c, 0x3e, 0x81, 0x74, 0x76, \ + 0x1e, 0x96, 0x6f, 0x74, 0x1e, 0x32, 0x0e, 0x14, 0x31, 0xd0, 0x74, 0xf0, \ + 0xf4, 0x07, 0xbd, 0xc3, 0xd1, 0x22, 0xc2, 0xa8, 0x95, 0x92, 0x06, 0x7f, \ + 0x43, 0x02, 0x91, 0xbc, 0xdd, 0x23, 0x01, 0x89, 0x94, 0x20, 0x44, 0x64, \ + 0xf5, 0x1d, 0x67, 0xd2, 0x8f, 0xe8, 0x69, 0xa5, 0x29, 0x25, 0xe6, 0x50, \ + 0x9c, 0xe3, 0xe9, 0xcb, 0x75, 0x02, 0x81, 0x81, 0x00, 0xe2, 0x29, 0x3e, \ + 0xaa, 0x6b, 0xd5, 0x59, 0x1e, 0x9c, 0xe6, 0x47, 0xd5, 0xb6, 0xd7, 0xe3, \ + 0xf1, 0x8e, 0x9e, 0xe9, 0x83, 0x5f, 0x10, 0x9f, 0x63, 0xec, 0x04, 0x44, \ + 0xcc, 0x3f, 0xf8, 0xd9, 0x3a, 0x17, 0xe0, 0x4f, 0xfe, 0xd8, 0x4d, 0xcd, \ + 0x46, 0x54, 0x74, 0xbf, 0x0a, 0xc4, 0x67, 0x9c, 0xa7, 0xd8, 0x89, 0x65, \ + 0x4c, 0xfd, 0x58, 0x2a, 0x47, 0x0f, 0xf4, 0x37, 0xb6, 0x55, 0xb0, 0x1d, \ + 0xed, 0xa7, 0x39, 0xfc, 0x4f, 0xa3, 0xc4, 0x75, 0x3a, 0xa3, 0x98, 0xa7, \ + 0x45, 0xf5, 0x66, 0xcb, 0x7c, 0x65, 0xfb, 0x80, 0x23, 0xe6, 0xff, 0xfd, \ + 0x99, 0x1f, 0x8e, 0x6b, 0xff, 0x5e, 0x93, 0x66, 0xdf, 0x6c, 0x6f, 0xc3, \ + 0xf6, 0x38, 0x2e, 0xff, 0x69, 0xb5, 0xac, 0xae, 0xbb, 0xc6, 0x71, 0x16, \ + 0x6b, 0xd0, 0xf8, 0x22, 0xd9, 0xf8, 0xa2, 0x72, 0x20, 0xd2, 0xe2, 0x3a, \ + 0x70, 0x4b, 0xde, 0xab, 0x2f, 0x02, 0x81, 0x81, 0x00, 0xda, 0x51, 0x9b, \ + 0xb8, 0xb2, 0x2a, 0x14, 0x75, 0x58, 0x40, 0x8d, 0x27, 0x70, 0xfa, 0x31, \ + 0x48, 0xb0, 0x20, 0x21, 0x34, 0xfa, 0x4c, 0x57, 0xa8, 0x11, 0x88, 0xf3, \ + 0xa7, 0xae, 0x21, 0xe9, 0xb6, 0x2b, 0xd1, 0xcd, 0xa7, 0xf8, 0xd8, 0x0c, \ + 0x8a, 0x76, 0x22, 0x35, 0x44, 0xce, 0x3f, 0x25, 0x29, 0x83, 0x7d, 0x79, \ + 0xa7, 0x31, 0xd6, 0xec, 0xb2, 0xbf, 0xda, 0x34, 0xb6, 0xf6, 0xb2, 0x3b, \ + 0xf3, 0x78, 0x5a, 0x04, 0x83, 0x33, 0x3e, 0xa2, 0xe2, 0x81, 0x82, 0x13, \ + 0xd4, 0x35, 0x17, 0x63, 0x9b, 0x9e, 0xc4, 0x8d, 0x91, 0x4c, 0x03, 0x77, \ + 0xc7, 0x71, 0x5b, 0xee, 0x83, 0x6d, 0xd5, 0x78, 0x88, 0xf6, 0x2c, 0x79, \ + 0xc2, 0x4a, 0xb4, 0x79, 0x90, 0x70, 0xbf, 0xdf, 0x34, 0x56, 0x96, 0x71, \ + 0xe3, 0x0e, 0x68, 0x91, 0xbc, 0xea, 0xcb, 0x33, 0xc0, 0xbe, 0x45, 0xd7, \ + 0xfc, 0x30, 0xfd, 0x01, 0x3b, 0x02, 0x81, 0x81, 0x00, 0xd2, 0x9f, 0x2a, \ + 0xb7, 0x38, 0x19, 0xc7, 0x17, 0x95, 0x73, 0x78, 0xae, 0xf5, 0xcb, 0x75, \ + 0x83, 0x7f, 0x19, 0x4b, 0xcb, 0x86, 0xfb, 0x4a, 0x15, 0x9a, 0xb6, 0x17, \ + 0x04, 0x49, 0x07, 0x8d, 0xf6, 0x66, 0x4a, 0x06, 0xf6, 0x05, 0xa7, 0xdf, \ + 0x66, 0x82, 0x3c, 0xff, 0xb6, 0x1d, 0x57, 0x89, 0x33, 0x5f, 0x9c, 0x05, \ + 0x75, 0x7f, 0xf3, 0x5d, 0xdc, 0x34, 0x65, 0x72, 0x85, 0x22, 0xa4, 0x14, \ + 0x1b, 0x41, 0xc3, 0xe4, 0xd0, 0x9e, 0x69, 0xd5, 0xeb, 0x38, 0x74, 0x70, \ + 0x43, 0xdc, 0xd9, 0x50, 0xe4, 0x97, 0x6d, 0x73, 0xd6, 0xfb, 0xc8, 0xa7, \ + 0xfa, 0xb4, 0xc2, 0xc4, 0x9d, 0x5d, 0x0c, 0xd5, 0x9f, 0x79, 0xb3, 0x54, \ + 0xc2, 0xb7, 0x6c, 0x3d, 0x7d, 0xcb, 0x2d, 0xf8, 0xc4, 0xf3, 0x78, 0x5a, \ + 0x33, 0x2a, 0xb8, 0x0c, 0x6d, 0x06, 0xfa, 0xf2, 0x62, 0xd3, 0x42, 0xd0, \ + 0xbd, 0xc8, 0x4a, 0xa5, 0x0d, 0x02, 0x81, 0x81, 0x00, 0xd4, 0xa9, 0x90, \ + 0x15, 0xde, 0xbf, 0x2c, 0xc4, 0x8d, 0x9d, 0xfb, 0xa1, 0xc2, 0xe4, 0x83, \ + 0xe3, 0x79, 0x65, 0x22, 0xd3, 0xb7, 0x49, 0x6c, 0x4d, 0x94, 0x1f, 0x22, \ + 0xb1, 0x60, 0xe7, 0x3a, 0x00, 0xb1, 0x38, 0xa2, 0xab, 0x0f, 0xb4, 0x6c, \ + 0xaa, 0xe7, 0x9e, 0x34, 0xe3, 0x7c, 0x40, 0x78, 0x53, 0xb2, 0xf9, 0x23, \ + 0xea, 0xa0, 0x9a, 0xea, 0x60, 0xc8, 0x8f, 0xa6, 0xaf, 0xdf, 0x29, 0x09, \ + 0x4b, 0x06, 0x1e, 0x31, 0xad, 0x17, 0xda, 0xd8, 0xd1, 0xe9, 0x33, 0xab, \ + 0x5b, 0x18, 0x08, 0x5b, 0x87, 0xf8, 0xa5, 0x1f, 0xfd, 0xbb, 0xdc, 0xd8, \ + 0xed, 0x97, 0x57, 0xe4, 0xc3, 0x73, 0xd6, 0xf0, 0x9e, 0x01, 0xa6, 0x9b, \ + 0x48, 0x8e, 0x7a, 0xb4, 0xbb, 0xe5, 0x88, 0x91, 0xc5, 0x2a, 0xdf, 0x4b, \ + 0xba, 0xd0, 0x8b, 0x3e, 0x03, 0x97, 0x77, 0x2f, 0x47, 0x7e, 0x51, 0x0c, \ + 0xae, 0x65, 0x8d, 0xde, 0x87, 0x02, 0x81, 0x80, 0x20, 0x24, 0x0f, 0xd2, \ + 0xaf, 0xc2, 0x28, 0x3b, 0x97, 0x20, 0xb2, 0x92, 0x49, 0xeb, 0x09, 0x68, \ + 0x40, 0xb2, 0xbe, 0xd1, 0xc3, 0x83, 0x94, 0x34, 0x38, 0xd6, 0xc9, 0xec, \ + 0x34, 0x09, 0xf9, 0x41, 0x6d, 0x5c, 0x42, 0x94, 0xf7, 0x04, 0xfc, 0x32, \ + 0x39, 0x69, 0xbc, 0x1c, 0xfb, 0x3e, 0x61, 0x98, 0xc0, 0x80, 0xd8, 0x36, \ + 0x47, 0xc3, 0x6d, 0xc2, 0x2e, 0xe7, 0x81, 0x2a, 0x17, 0x34, 0x64, 0x30, \ + 0x4e, 0x96, 0xbb, 0x26, 0x16, 0xb9, 0x41, 0x36, 0xfe, 0x8a, 0xd6, 0x53, \ + 0x7c, 0xaa, 0xec, 0x39, 0x42, 0x50, 0xef, 0xe3, 0xb3, 0x01, 0x28, 0x32, \ + 0xca, 0x6d, 0xf5, 0x9a, 0x1e, 0x9f, 0x37, 0xbe, 0xfe, 0x38, 0x20, 0x22, \ + 0x91, 0x8c, 0xcd, 0x95, 0x02, 0xf2, 0x4d, 0x6f, 0x1a, 0xb4, 0x43, 0xf0, \ + 0x19, 0xdf, 0x65, 0xc0, 0x92, 0xe7, 0x9d, 0x2f, 0x09, 0xe7, 0xec, 0x69, \ + 0xa8, 0xc2, 0x8f, 0x0d \ +} +/* END FILE */ + +/* + * Test server Certificates + * + * Test server certificates are defined for each choice + * of the following parameters: + * - PEM or DER encoding + * - SHA-1 or SHA-256 hash + * - RSA or EC key + * + * Things to add: + * - multiple EC curve types + */ + +/* This is taken from tests/data_files/server5.crt. */ +/* BEGIN FILE string macro TEST_SRV_CRT_EC_PEM tests/data_files/server5.crt */ +#define TEST_SRV_CRT_EC_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIICHzCCAaWgAwIBAgIBCTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN\r\n" \ + "MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDBZMBMGByqGSM49AgEG\r\n" \ + "CCqGSM49AwEHA0IABDfMVtl2CR5acj7HWS3/IG7ufPkGkXTQrRS192giWWKSTuUA\r\n" \ + "2CMR/+ov0jRdXRa9iojCa3cNVc2KKg76Aci07f+jgZ0wgZowCQYDVR0TBAIwADAd\r\n" \ + "BgNVHQ4EFgQUUGGlj9QH2deCAQzlZX+MY0anE74wbgYDVR0jBGcwZYAUnW0gJEkB\r\n" \ + "PyvLeLUZvH4kydv7NnyhQqRAMD4xCzAJBgNVBAYTAk5MMREwDwYDVQQKEwhQb2xh\r\n" \ + "clNTTDEcMBoGA1UEAxMTUG9sYXJzc2wgVGVzdCBFQyBDQYIJAMFD4n5iQ8zoMAoG\r\n" \ + "CCqGSM49BAMCA2gAMGUCMQCaLFzXptui5WQN8LlO3ddh1hMxx6tzgLvT03MTVK2S\r\n" \ + "C12r0Lz3ri/moSEpNZWqPjkCMCE2f53GXcYLqyfyJR078c/xNSUU5+Xxl7VZ414V\r\n" \ + "fGa5kHvHARBPc8YAIVIqDvHH1Q==\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is generated from tests/data_files/server5.crt.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_SRV_CRT_EC_DER tests/data_files/server5.crt.der */ +#define TEST_SRV_CRT_EC_DER { \ + 0x30, 0x82, 0x02, 0x1f, 0x30, 0x82, 0x01, 0xa5, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x09, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, \ + 0x3d, 0x04, 0x03, 0x02, 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, \ + 0x13, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, 0x54, 0x65, \ + 0x73, 0x74, 0x20, 0x45, 0x43, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x33, 0x30, 0x39, 0x32, 0x34, 0x31, 0x35, 0x35, 0x32, 0x30, 0x34, \ + 0x5a, 0x17, 0x0d, 0x32, 0x33, 0x30, 0x39, 0x32, 0x32, 0x31, 0x35, 0x35, \ + 0x32, 0x30, 0x34, 0x5a, 0x30, 0x34, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, \ + 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x59, \ + 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, \ + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, \ + 0x04, 0x37, 0xcc, 0x56, 0xd9, 0x76, 0x09, 0x1e, 0x5a, 0x72, 0x3e, 0xc7, \ + 0x59, 0x2d, 0xff, 0x20, 0x6e, 0xee, 0x7c, 0xf9, 0x06, 0x91, 0x74, 0xd0, \ + 0xad, 0x14, 0xb5, 0xf7, 0x68, 0x22, 0x59, 0x62, 0x92, 0x4e, 0xe5, 0x00, \ + 0xd8, 0x23, 0x11, 0xff, 0xea, 0x2f, 0xd2, 0x34, 0x5d, 0x5d, 0x16, 0xbd, \ + 0x8a, 0x88, 0xc2, 0x6b, 0x77, 0x0d, 0x55, 0xcd, 0x8a, 0x2a, 0x0e, 0xfa, \ + 0x01, 0xc8, 0xb4, 0xed, 0xff, 0xa3, 0x81, 0x9d, 0x30, 0x81, 0x9a, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, \ + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x50, 0x61, 0xa5, \ + 0x8f, 0xd4, 0x07, 0xd9, 0xd7, 0x82, 0x01, 0x0c, 0xe5, 0x65, 0x7f, 0x8c, \ + 0x63, 0x46, 0xa7, 0x13, 0xbe, 0x30, 0x6e, 0x06, 0x03, 0x55, 0x1d, 0x23, \ + 0x04, 0x67, 0x30, 0x65, 0x80, 0x14, 0x9d, 0x6d, 0x20, 0x24, 0x49, 0x01, \ + 0x3f, 0x2b, 0xcb, 0x78, 0xb5, 0x19, 0xbc, 0x7e, 0x24, 0xc9, 0xdb, 0xfb, \ + 0x36, 0x7c, 0xa1, 0x42, 0xa4, 0x40, 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, \ + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, \ + 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, \ + 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, \ + 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, \ + 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x43, 0x20, 0x43, 0x41, 0x82, 0x09, \ + 0x00, 0xc1, 0x43, 0xe2, 0x7e, 0x62, 0x43, 0xcc, 0xe8, 0x30, 0x0a, 0x06, \ + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x68, 0x00, \ + 0x30, 0x65, 0x02, 0x31, 0x00, 0x9a, 0x2c, 0x5c, 0xd7, 0xa6, 0xdb, 0xa2, \ + 0xe5, 0x64, 0x0d, 0xf0, 0xb9, 0x4e, 0xdd, 0xd7, 0x61, 0xd6, 0x13, 0x31, \ + 0xc7, 0xab, 0x73, 0x80, 0xbb, 0xd3, 0xd3, 0x73, 0x13, 0x54, 0xad, 0x92, \ + 0x0b, 0x5d, 0xab, 0xd0, 0xbc, 0xf7, 0xae, 0x2f, 0xe6, 0xa1, 0x21, 0x29, \ + 0x35, 0x95, 0xaa, 0x3e, 0x39, 0x02, 0x30, 0x21, 0x36, 0x7f, 0x9d, 0xc6, \ + 0x5d, 0xc6, 0x0b, 0xab, 0x27, 0xf2, 0x25, 0x1d, 0x3b, 0xf1, 0xcf, 0xf1, \ + 0x35, 0x25, 0x14, 0xe7, 0xe5, 0xf1, 0x97, 0xb5, 0x59, 0xe3, 0x5e, 0x15, \ + 0x7c, 0x66, 0xb9, 0x90, 0x7b, 0xc7, 0x01, 0x10, 0x4f, 0x73, 0xc6, 0x00, \ + 0x21, 0x52, 0x2a, 0x0e, 0xf1, 0xc7, 0xd5 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/server5.key. */ +/* BEGIN FILE string macro TEST_SRV_KEY_EC_PEM tests/data_files/server5.key */ +#define TEST_SRV_KEY_EC_PEM \ + "-----BEGIN EC PRIVATE KEY-----\r\n" \ + "MHcCAQEEIPEqEyB2AnCoPL/9U/YDHvdqXYbIogTywwyp6/UfDw6noAoGCCqGSM49\r\n" \ + "AwEHoUQDQgAEN8xW2XYJHlpyPsdZLf8gbu58+QaRdNCtFLX3aCJZYpJO5QDYIxH/\r\n" \ + "6i/SNF1dFr2KiMJrdw1VzYoqDvoByLTt/w==\r\n" \ + "-----END EC PRIVATE KEY-----\r\n" +/* END FILE */ + +/* This is generated from tests/data_files/server5.key.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_SRV_KEY_EC_DER tests/data_files/server5.key.der */ +#define TEST_SRV_KEY_EC_DER { \ + 0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0xf1, 0x2a, 0x13, 0x20, 0x76, \ + 0x02, 0x70, 0xa8, 0x3c, 0xbf, 0xfd, 0x53, 0xf6, 0x03, 0x1e, 0xf7, 0x6a, \ + 0x5d, 0x86, 0xc8, 0xa2, 0x04, 0xf2, 0xc3, 0x0c, 0xa9, 0xeb, 0xf5, 0x1f, \ + 0x0f, 0x0e, 0xa7, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, \ + 0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x37, 0xcc, 0x56, \ + 0xd9, 0x76, 0x09, 0x1e, 0x5a, 0x72, 0x3e, 0xc7, 0x59, 0x2d, 0xff, 0x20, \ + 0x6e, 0xee, 0x7c, 0xf9, 0x06, 0x91, 0x74, 0xd0, 0xad, 0x14, 0xb5, 0xf7, \ + 0x68, 0x22, 0x59, 0x62, 0x92, 0x4e, 0xe5, 0x00, 0xd8, 0x23, 0x11, 0xff, \ + 0xea, 0x2f, 0xd2, 0x34, 0x5d, 0x5d, 0x16, 0xbd, 0x8a, 0x88, 0xc2, 0x6b, \ + 0x77, 0x0d, 0x55, 0xcd, 0x8a, 0x2a, 0x0e, 0xfa, 0x01, 0xc8, 0xb4, 0xed, \ + 0xff \ +} +/* END FILE */ + +/* This is taken from tests/data_files/server2-sha256.crt. */ +/* BEGIN FILE string macro TEST_SRV_CRT_RSA_SHA256_PEM tests/data_files/server2-sha256.crt */ +#define TEST_SRV_CRT_RSA_SHA256_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n" \ + "MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ + "MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UECgwIUG9sYXJTU0wxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN\r\n" \ + "AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN\r\n" \ + "owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz\r\n" \ + "NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM\r\n" \ + "tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P\r\n" \ + "hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya\r\n" \ + "HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD\r\n" \ + "VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw\r\n" \ + "FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQELBQADggEBAGGEshT5\r\n" \ + "kvnRmLVScVeUEdwIrvW7ezbGbUvJ8VxeJ79/HSjlLiGbMc4uUathwtzEdi9R/4C5\r\n" \ + "DXBNeEPTkbB+fhG1W06iHYj/Dp8+aaG7fuDxKVKHVZSqBnmQLn73ymyclZNHii5A\r\n" \ + "3nTS8WUaHAzxN/rajOtoM7aH1P9tULpHrl+7HOeLMpxUnwI12ZqZaLIzxbcdJVcr\r\n" \ + "ra2F00aXCGkYVLvyvbZIq7LC+yVysej5gCeQYD7VFOEks0jhFjrS06gP0/XnWv6v\r\n" \ + "eBoPez9d+CCjkrhseiWzXOiriIMICX48EloO/DrsMRAtvlwq7EDz4QhILz6ffndm\r\n" \ + "e4K1cVANRPN2o9Y=\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is taken from tests/data_files/server2-sha256.crt.der. */ +/* BEGIN FILE binary macro TEST_SRV_CRT_RSA_SHA256_DER tests/data_files/server2-sha256.crt.der */ +#define TEST_SRV_CRT_RSA_SHA256_DER { \ + 0x30, 0x82, 0x03, 0x37, 0x30, 0x82, 0x02, 0x1f, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, \ + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x3b, 0x31, 0x0b, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, \ + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, \ + 0x04, 0x03, 0x0c, 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, \ + 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, 0x34, 0x30, 0x36, \ + 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, \ + 0x34, 0x30, 0x36, 0x5a, 0x30, 0x34, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, \ + 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x82, \ + 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, \ + 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, \ + 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc1, 0x4d, 0xa3, 0xdd, 0xe7, \ + 0xcd, 0x1d, 0xd1, 0x04, 0xd7, 0x49, 0x72, 0xb8, 0x99, 0xac, 0x0e, 0x78, \ + 0xe4, 0x3a, 0x3c, 0x4a, 0xcf, 0x3a, 0x13, 0x16, 0xd0, 0x5a, 0xe4, 0xcd, \ + 0xa3, 0x00, 0x88, 0xa7, 0xee, 0x1e, 0x6b, 0x96, 0xa7, 0x52, 0xb4, 0x90, \ + 0xef, 0x2d, 0x72, 0x7a, 0x3e, 0x24, 0x9a, 0xfc, 0xb6, 0x34, 0xac, 0x24, \ + 0xf5, 0x77, 0xe0, 0x26, 0x64, 0x8c, 0x9c, 0xb0, 0x28, 0x7d, 0xa1, 0xda, \ + 0xea, 0x8c, 0xe6, 0xc9, 0x1c, 0x96, 0xbc, 0xfe, 0xc1, 0x04, 0x52, 0xb3, \ + 0x36, 0xd4, 0xa3, 0xfa, 0xe1, 0xb1, 0x76, 0xd8, 0x90, 0xc1, 0x61, 0xb4, \ + 0x66, 0x52, 0x36, 0xa2, 0x26, 0x53, 0xaa, 0xab, 0x74, 0x5e, 0x07, 0x7d, \ + 0x19, 0x82, 0xdb, 0x2a, 0xd8, 0x1f, 0xa0, 0xd9, 0x0d, 0x1c, 0x2d, 0x49, \ + 0x66, 0xf7, 0x5b, 0x25, 0x73, 0x46, 0xe8, 0x0b, 0x8a, 0x4f, 0x69, 0x0c, \ + 0xb5, 0x00, 0x90, 0xe1, 0xda, 0x82, 0x10, 0x66, 0x7d, 0xae, 0x54, 0x2b, \ + 0x8b, 0x65, 0x79, 0x91, 0xa1, 0xe2, 0x61, 0xc3, 0xcd, 0x40, 0x49, 0x08, \ + 0xee, 0x68, 0x0c, 0xf1, 0x8b, 0x86, 0xd2, 0x46, 0xbf, 0xd0, 0xb8, 0xaa, \ + 0x11, 0x03, 0x1e, 0x7f, 0x56, 0xa8, 0x1a, 0x1e, 0x44, 0x18, 0x0f, 0x0f, \ + 0x85, 0x8b, 0xda, 0x8b, 0x44, 0x5e, 0xe2, 0x18, 0xc6, 0x62, 0x2f, 0xc7, \ + 0x66, 0x8d, 0xfa, 0x5d, 0xd8, 0x7d, 0xf3, 0x27, 0x89, 0x29, 0x01, 0xc5, \ + 0x90, 0x0e, 0x3f, 0x27, 0xf1, 0x30, 0xc8, 0x4a, 0x0e, 0xef, 0xd6, 0xde, \ + 0xc7, 0xc7, 0x27, 0x6b, 0xc7, 0x05, 0x3d, 0x7a, 0xc4, 0x02, 0x3c, 0x9a, \ + 0x1d, 0x3e, 0x0f, 0xe8, 0x34, 0x98, 0x5b, 0xcb, 0x73, 0x4b, 0x52, 0x96, \ + 0xd8, 0x11, 0xa2, 0x2c, 0x80, 0x88, 0x69, 0x39, 0x5a, 0xd3, 0x0f, 0xb0, \ + 0xde, 0x59, 0x2f, 0x11, 0xc7, 0xf7, 0xea, 0x12, 0x01, 0x30, 0x97, 0x02, \ + 0x03, 0x01, 0x00, 0x01, 0xa3, 0x4d, 0x30, 0x4b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, \ + 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xa5, 0x05, 0xe8, 0x64, 0xb8, 0xdc, \ + 0xdf, 0x60, 0x0f, 0x50, 0x12, 0x4d, 0x60, 0xa8, 0x64, 0xaf, 0x4d, 0x8b, \ + 0x43, 0x93, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, \ + 0x16, 0x80, 0x14, 0xb4, 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, 0xf6, \ + 0xb9, 0xd5, 0xa6, 0x95, 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, 0x30, \ + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, \ + 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x61, 0x84, 0xb2, 0x14, 0xf9, \ + 0x92, 0xf9, 0xd1, 0x98, 0xb5, 0x52, 0x71, 0x57, 0x94, 0x11, 0xdc, 0x08, \ + 0xae, 0xf5, 0xbb, 0x7b, 0x36, 0xc6, 0x6d, 0x4b, 0xc9, 0xf1, 0x5c, 0x5e, \ + 0x27, 0xbf, 0x7f, 0x1d, 0x28, 0xe5, 0x2e, 0x21, 0x9b, 0x31, 0xce, 0x2e, \ + 0x51, 0xab, 0x61, 0xc2, 0xdc, 0xc4, 0x76, 0x2f, 0x51, 0xff, 0x80, 0xb9, \ + 0x0d, 0x70, 0x4d, 0x78, 0x43, 0xd3, 0x91, 0xb0, 0x7e, 0x7e, 0x11, 0xb5, \ + 0x5b, 0x4e, 0xa2, 0x1d, 0x88, 0xff, 0x0e, 0x9f, 0x3e, 0x69, 0xa1, 0xbb, \ + 0x7e, 0xe0, 0xf1, 0x29, 0x52, 0x87, 0x55, 0x94, 0xaa, 0x06, 0x79, 0x90, \ + 0x2e, 0x7e, 0xf7, 0xca, 0x6c, 0x9c, 0x95, 0x93, 0x47, 0x8a, 0x2e, 0x40, \ + 0xde, 0x74, 0xd2, 0xf1, 0x65, 0x1a, 0x1c, 0x0c, 0xf1, 0x37, 0xfa, 0xda, \ + 0x8c, 0xeb, 0x68, 0x33, 0xb6, 0x87, 0xd4, 0xff, 0x6d, 0x50, 0xba, 0x47, \ + 0xae, 0x5f, 0xbb, 0x1c, 0xe7, 0x8b, 0x32, 0x9c, 0x54, 0x9f, 0x02, 0x35, \ + 0xd9, 0x9a, 0x99, 0x68, 0xb2, 0x33, 0xc5, 0xb7, 0x1d, 0x25, 0x57, 0x2b, \ + 0xad, 0xad, 0x85, 0xd3, 0x46, 0x97, 0x08, 0x69, 0x18, 0x54, 0xbb, 0xf2, \ + 0xbd, 0xb6, 0x48, 0xab, 0xb2, 0xc2, 0xfb, 0x25, 0x72, 0xb1, 0xe8, 0xf9, \ + 0x80, 0x27, 0x90, 0x60, 0x3e, 0xd5, 0x14, 0xe1, 0x24, 0xb3, 0x48, 0xe1, \ + 0x16, 0x3a, 0xd2, 0xd3, 0xa8, 0x0f, 0xd3, 0xf5, 0xe7, 0x5a, 0xfe, 0xaf, \ + 0x78, 0x1a, 0x0f, 0x7b, 0x3f, 0x5d, 0xf8, 0x20, 0xa3, 0x92, 0xb8, 0x6c, \ + 0x7a, 0x25, 0xb3, 0x5c, 0xe8, 0xab, 0x88, 0x83, 0x08, 0x09, 0x7e, 0x3c, \ + 0x12, 0x5a, 0x0e, 0xfc, 0x3a, 0xec, 0x31, 0x10, 0x2d, 0xbe, 0x5c, 0x2a, \ + 0xec, 0x40, 0xf3, 0xe1, 0x08, 0x48, 0x2f, 0x3e, 0x9f, 0x7e, 0x77, 0x66, \ + 0x7b, 0x82, 0xb5, 0x71, 0x50, 0x0d, 0x44, 0xf3, 0x76, 0xa3, 0xd6 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/server2.crt. */ +/* BEGIN FILE string macro TEST_SRV_CRT_RSA_SHA1_PEM tests/data_files/server2.crt */ +#define TEST_SRV_CRT_RSA_SHA1_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" \ + "MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ + "MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UECgwIUG9sYXJTU0wxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN\r\n" \ + "AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN\r\n" \ + "owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz\r\n" \ + "NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM\r\n" \ + "tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P\r\n" \ + "hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya\r\n" \ + "HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD\r\n" \ + "VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw\r\n" \ + "FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQADggEBAAFzC0rF\r\n" \ + "y6De8WMcdgQrEw3AhBHFjzqnxZw1ene4IBSC7lTw8rBSy3jOWQdPUWn+0y/pCeeF\r\n" \ + "kti6sevFdl1hLemGtd4q+T9TKEKGg3ND4ARfB5AUZZ9uEHq8WBkiwus5clGS17Qd\r\n" \ + "dS/TOisB59tQruLx1E1bPLtBKyqk4koC5WAULJwfpswGSyWJTpYwIpxcWE3D2tBu\r\n" \ + "UB6MZfXZFzWmWEOyKbeoXjXe8GBCGgHLywvYDsGQ36HSGtEsAvR2QaTLSxWYcfk1\r\n" \ + "fbDn4jSWkb4yZy1r01UEigFQtONieGwRFaUqEcFJHJvEEGVgh9keaVlOj2vrwf5r\r\n" \ + "4mN4lW7gLdenN6g=\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is taken from tests/data_files/server2.crt.der. */ +/* BEGIN FILE binary macro TEST_SRV_CRT_RSA_SHA1_DER tests/data_files/server2.crt.der */ +#define TEST_SRV_CRT_RSA_SHA1_DER { \ + 0x30, 0x82, 0x03, 0x37, 0x30, 0x82, 0x02, 0x1f, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x02, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, \ + 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x3b, 0x31, 0x0b, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, \ + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, \ + 0x04, 0x03, 0x0c, 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, \ + 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, 0x34, 0x30, 0x36, \ + 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, \ + 0x34, 0x30, 0x36, 0x5a, 0x30, 0x34, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, \ + 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x30, 0x82, \ + 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, \ + 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, \ + 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xc1, 0x4d, 0xa3, 0xdd, 0xe7, \ + 0xcd, 0x1d, 0xd1, 0x04, 0xd7, 0x49, 0x72, 0xb8, 0x99, 0xac, 0x0e, 0x78, \ + 0xe4, 0x3a, 0x3c, 0x4a, 0xcf, 0x3a, 0x13, 0x16, 0xd0, 0x5a, 0xe4, 0xcd, \ + 0xa3, 0x00, 0x88, 0xa7, 0xee, 0x1e, 0x6b, 0x96, 0xa7, 0x52, 0xb4, 0x90, \ + 0xef, 0x2d, 0x72, 0x7a, 0x3e, 0x24, 0x9a, 0xfc, 0xb6, 0x34, 0xac, 0x24, \ + 0xf5, 0x77, 0xe0, 0x26, 0x64, 0x8c, 0x9c, 0xb0, 0x28, 0x7d, 0xa1, 0xda, \ + 0xea, 0x8c, 0xe6, 0xc9, 0x1c, 0x96, 0xbc, 0xfe, 0xc1, 0x04, 0x52, 0xb3, \ + 0x36, 0xd4, 0xa3, 0xfa, 0xe1, 0xb1, 0x76, 0xd8, 0x90, 0xc1, 0x61, 0xb4, \ + 0x66, 0x52, 0x36, 0xa2, 0x26, 0x53, 0xaa, 0xab, 0x74, 0x5e, 0x07, 0x7d, \ + 0x19, 0x82, 0xdb, 0x2a, 0xd8, 0x1f, 0xa0, 0xd9, 0x0d, 0x1c, 0x2d, 0x49, \ + 0x66, 0xf7, 0x5b, 0x25, 0x73, 0x46, 0xe8, 0x0b, 0x8a, 0x4f, 0x69, 0x0c, \ + 0xb5, 0x00, 0x90, 0xe1, 0xda, 0x82, 0x10, 0x66, 0x7d, 0xae, 0x54, 0x2b, \ + 0x8b, 0x65, 0x79, 0x91, 0xa1, 0xe2, 0x61, 0xc3, 0xcd, 0x40, 0x49, 0x08, \ + 0xee, 0x68, 0x0c, 0xf1, 0x8b, 0x86, 0xd2, 0x46, 0xbf, 0xd0, 0xb8, 0xaa, \ + 0x11, 0x03, 0x1e, 0x7f, 0x56, 0xa8, 0x1a, 0x1e, 0x44, 0x18, 0x0f, 0x0f, \ + 0x85, 0x8b, 0xda, 0x8b, 0x44, 0x5e, 0xe2, 0x18, 0xc6, 0x62, 0x2f, 0xc7, \ + 0x66, 0x8d, 0xfa, 0x5d, 0xd8, 0x7d, 0xf3, 0x27, 0x89, 0x29, 0x01, 0xc5, \ + 0x90, 0x0e, 0x3f, 0x27, 0xf1, 0x30, 0xc8, 0x4a, 0x0e, 0xef, 0xd6, 0xde, \ + 0xc7, 0xc7, 0x27, 0x6b, 0xc7, 0x05, 0x3d, 0x7a, 0xc4, 0x02, 0x3c, 0x9a, \ + 0x1d, 0x3e, 0x0f, 0xe8, 0x34, 0x98, 0x5b, 0xcb, 0x73, 0x4b, 0x52, 0x96, \ + 0xd8, 0x11, 0xa2, 0x2c, 0x80, 0x88, 0x69, 0x39, 0x5a, 0xd3, 0x0f, 0xb0, \ + 0xde, 0x59, 0x2f, 0x11, 0xc7, 0xf7, 0xea, 0x12, 0x01, 0x30, 0x97, 0x02, \ + 0x03, 0x01, 0x00, 0x01, 0xa3, 0x4d, 0x30, 0x4b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, \ + 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xa5, 0x05, 0xe8, 0x64, 0xb8, 0xdc, \ + 0xdf, 0x60, 0x0f, 0x50, 0x12, 0x4d, 0x60, 0xa8, 0x64, 0xaf, 0x4d, 0x8b, \ + 0x43, 0x93, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, \ + 0x16, 0x80, 0x14, 0xb4, 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, 0xf6, \ + 0xb9, 0xd5, 0xa6, 0x95, 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, 0x30, \ + 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, \ + 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x01, 0x73, 0x0b, 0x4a, 0xc5, \ + 0xcb, 0xa0, 0xde, 0xf1, 0x63, 0x1c, 0x76, 0x04, 0x2b, 0x13, 0x0d, 0xc0, \ + 0x84, 0x11, 0xc5, 0x8f, 0x3a, 0xa7, 0xc5, 0x9c, 0x35, 0x7a, 0x77, 0xb8, \ + 0x20, 0x14, 0x82, 0xee, 0x54, 0xf0, 0xf2, 0xb0, 0x52, 0xcb, 0x78, 0xce, \ + 0x59, 0x07, 0x4f, 0x51, 0x69, 0xfe, 0xd3, 0x2f, 0xe9, 0x09, 0xe7, 0x85, \ + 0x92, 0xd8, 0xba, 0xb1, 0xeb, 0xc5, 0x76, 0x5d, 0x61, 0x2d, 0xe9, 0x86, \ + 0xb5, 0xde, 0x2a, 0xf9, 0x3f, 0x53, 0x28, 0x42, 0x86, 0x83, 0x73, 0x43, \ + 0xe0, 0x04, 0x5f, 0x07, 0x90, 0x14, 0x65, 0x9f, 0x6e, 0x10, 0x7a, 0xbc, \ + 0x58, 0x19, 0x22, 0xc2, 0xeb, 0x39, 0x72, 0x51, 0x92, 0xd7, 0xb4, 0x1d, \ + 0x75, 0x2f, 0xd3, 0x3a, 0x2b, 0x01, 0xe7, 0xdb, 0x50, 0xae, 0xe2, 0xf1, \ + 0xd4, 0x4d, 0x5b, 0x3c, 0xbb, 0x41, 0x2b, 0x2a, 0xa4, 0xe2, 0x4a, 0x02, \ + 0xe5, 0x60, 0x14, 0x2c, 0x9c, 0x1f, 0xa6, 0xcc, 0x06, 0x4b, 0x25, 0x89, \ + 0x4e, 0x96, 0x30, 0x22, 0x9c, 0x5c, 0x58, 0x4d, 0xc3, 0xda, 0xd0, 0x6e, \ + 0x50, 0x1e, 0x8c, 0x65, 0xf5, 0xd9, 0x17, 0x35, 0xa6, 0x58, 0x43, 0xb2, \ + 0x29, 0xb7, 0xa8, 0x5e, 0x35, 0xde, 0xf0, 0x60, 0x42, 0x1a, 0x01, 0xcb, \ + 0xcb, 0x0b, 0xd8, 0x0e, 0xc1, 0x90, 0xdf, 0xa1, 0xd2, 0x1a, 0xd1, 0x2c, \ + 0x02, 0xf4, 0x76, 0x41, 0xa4, 0xcb, 0x4b, 0x15, 0x98, 0x71, 0xf9, 0x35, \ + 0x7d, 0xb0, 0xe7, 0xe2, 0x34, 0x96, 0x91, 0xbe, 0x32, 0x67, 0x2d, 0x6b, \ + 0xd3, 0x55, 0x04, 0x8a, 0x01, 0x50, 0xb4, 0xe3, 0x62, 0x78, 0x6c, 0x11, \ + 0x15, 0xa5, 0x2a, 0x11, 0xc1, 0x49, 0x1c, 0x9b, 0xc4, 0x10, 0x65, 0x60, \ + 0x87, 0xd9, 0x1e, 0x69, 0x59, 0x4e, 0x8f, 0x6b, 0xeb, 0xc1, 0xfe, 0x6b, \ + 0xe2, 0x63, 0x78, 0x95, 0x6e, 0xe0, 0x2d, 0xd7, 0xa7, 0x37, 0xa8 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/server2.key. */ +/* BEGIN FILE string macro TEST_SRV_KEY_RSA_PEM tests/data_files/server2.key */ +#define TEST_SRV_KEY_RSA_PEM \ + "-----BEGIN RSA PRIVATE KEY-----\r\n" \ + "MIIEpAIBAAKCAQEAwU2j3efNHdEE10lyuJmsDnjkOjxKzzoTFtBa5M2jAIin7h5r\r\n" \ + "lqdStJDvLXJ6PiSa/LY0rCT1d+AmZIycsCh9odrqjObJHJa8/sEEUrM21KP64bF2\r\n" \ + "2JDBYbRmUjaiJlOqq3ReB30Zgtsq2B+g2Q0cLUlm91slc0boC4pPaQy1AJDh2oIQ\r\n" \ + "Zn2uVCuLZXmRoeJhw81ASQjuaAzxi4bSRr/QuKoRAx5/VqgaHkQYDw+Fi9qLRF7i\r\n" \ + "GMZiL8dmjfpd2H3zJ4kpAcWQDj8n8TDISg7v1t7HxydrxwU9esQCPJodPg/oNJhb\r\n" \ + "y3NLUpbYEaIsgIhpOVrTD7DeWS8Rx/fqEgEwlwIDAQABAoIBAQCXR0S8EIHFGORZ\r\n" \ + "++AtOg6eENxD+xVs0f1IeGz57Tjo3QnXX7VBZNdj+p1ECvhCE/G7XnkgU5hLZX+G\r\n" \ + "Z0jkz/tqJOI0vRSdLBbipHnWouyBQ4e/A1yIJdlBtqXxJ1KE/ituHRbNc4j4kL8Z\r\n" \ + "/r6pvwnTI0PSx2Eqs048YdS92LT6qAv4flbNDxMn2uY7s4ycS4Q8w1JXnCeaAnYm\r\n" \ + "WYI5wxO+bvRELR2Mcz5DmVnL8jRyml6l6582bSv5oufReFIbyPZbQWlXgYnpu6He\r\n" \ + "GTc7E1zKYQGG/9+DQUl/1vQuCPqQwny0tQoX2w5tdYpdMdVm+zkLtbajzdTviJJa\r\n" \ + "TWzL6lt5AoGBAN86+SVeJDcmQJcv4Eq6UhtRr4QGMiQMz0Sod6ettYxYzMgxtw28\r\n" \ + "CIrgpozCc+UaZJLo7UxvC6an85r1b2nKPCLQFaggJ0H4Q0J/sZOhBIXaoBzWxveK\r\n" \ + "nupceKdVxGsFi8CDy86DBfiyFivfBj+47BbaQzPBj7C4rK7UlLjab2rDAoGBAN2u\r\n" \ + "AM2gchoFiu4v1HFL8D7lweEpi6ZnMJjnEu/dEgGQJFjwdpLnPbsj4c75odQ4Gz8g\r\n" \ + "sw9lao9VVzbusoRE/JGI4aTdO0pATXyG7eG1Qu+5Yc1YGXcCrliA2xM9xx+d7f+s\r\n" \ + "mPzN+WIEg5GJDYZDjAzHG5BNvi/FfM1C9dOtjv2dAoGAF0t5KmwbjWHBhcVqO4Ic\r\n" \ + "BVvN3BIlc1ue2YRXEDlxY5b0r8N4XceMgKmW18OHApZxfl8uPDauWZLXOgl4uepv\r\n" \ + "whZC3EuWrSyyICNhLY21Ah7hbIEBPF3L3ZsOwC+UErL+dXWLdB56Jgy3gZaBeW7b\r\n" \ + "vDrEnocJbqCm7IukhXHOBK8CgYEAwqdHB0hqyNSzIOGY7v9abzB6pUdA3BZiQvEs\r\n" \ + "3LjHVd4HPJ2x0N8CgrBIWOE0q8+0hSMmeE96WW/7jD3fPWwCR5zlXknxBQsfv0gP\r\n" \ + "3BC5PR0Qdypz+d+9zfMf625kyit4T/hzwhDveZUzHnk1Cf+IG7Q+TOEnLnWAWBED\r\n" \ + "ISOWmrUCgYAFEmRxgwAc/u+D6t0syCwAYh6POtscq9Y0i9GyWk89NzgC4NdwwbBH\r\n" \ + "4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n" \ + "TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n" \ + "-----END RSA PRIVATE KEY-----\r\n" +/* END FILE */ + +/* This was generated from tests/data_files/server2.key.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_SRV_KEY_RSA_DER tests/data_files/server2.key.der */ +#define TEST_SRV_KEY_RSA_DER { \ + 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, \ + 0xc1, 0x4d, 0xa3, 0xdd, 0xe7, 0xcd, 0x1d, 0xd1, 0x04, 0xd7, 0x49, 0x72, \ + 0xb8, 0x99, 0xac, 0x0e, 0x78, 0xe4, 0x3a, 0x3c, 0x4a, 0xcf, 0x3a, 0x13, \ + 0x16, 0xd0, 0x5a, 0xe4, 0xcd, 0xa3, 0x00, 0x88, 0xa7, 0xee, 0x1e, 0x6b, \ + 0x96, 0xa7, 0x52, 0xb4, 0x90, 0xef, 0x2d, 0x72, 0x7a, 0x3e, 0x24, 0x9a, \ + 0xfc, 0xb6, 0x34, 0xac, 0x24, 0xf5, 0x77, 0xe0, 0x26, 0x64, 0x8c, 0x9c, \ + 0xb0, 0x28, 0x7d, 0xa1, 0xda, 0xea, 0x8c, 0xe6, 0xc9, 0x1c, 0x96, 0xbc, \ + 0xfe, 0xc1, 0x04, 0x52, 0xb3, 0x36, 0xd4, 0xa3, 0xfa, 0xe1, 0xb1, 0x76, \ + 0xd8, 0x90, 0xc1, 0x61, 0xb4, 0x66, 0x52, 0x36, 0xa2, 0x26, 0x53, 0xaa, \ + 0xab, 0x74, 0x5e, 0x07, 0x7d, 0x19, 0x82, 0xdb, 0x2a, 0xd8, 0x1f, 0xa0, \ + 0xd9, 0x0d, 0x1c, 0x2d, 0x49, 0x66, 0xf7, 0x5b, 0x25, 0x73, 0x46, 0xe8, \ + 0x0b, 0x8a, 0x4f, 0x69, 0x0c, 0xb5, 0x00, 0x90, 0xe1, 0xda, 0x82, 0x10, \ + 0x66, 0x7d, 0xae, 0x54, 0x2b, 0x8b, 0x65, 0x79, 0x91, 0xa1, 0xe2, 0x61, \ + 0xc3, 0xcd, 0x40, 0x49, 0x08, 0xee, 0x68, 0x0c, 0xf1, 0x8b, 0x86, 0xd2, \ + 0x46, 0xbf, 0xd0, 0xb8, 0xaa, 0x11, 0x03, 0x1e, 0x7f, 0x56, 0xa8, 0x1a, \ + 0x1e, 0x44, 0x18, 0x0f, 0x0f, 0x85, 0x8b, 0xda, 0x8b, 0x44, 0x5e, 0xe2, \ + 0x18, 0xc6, 0x62, 0x2f, 0xc7, 0x66, 0x8d, 0xfa, 0x5d, 0xd8, 0x7d, 0xf3, \ + 0x27, 0x89, 0x29, 0x01, 0xc5, 0x90, 0x0e, 0x3f, 0x27, 0xf1, 0x30, 0xc8, \ + 0x4a, 0x0e, 0xef, 0xd6, 0xde, 0xc7, 0xc7, 0x27, 0x6b, 0xc7, 0x05, 0x3d, \ + 0x7a, 0xc4, 0x02, 0x3c, 0x9a, 0x1d, 0x3e, 0x0f, 0xe8, 0x34, 0x98, 0x5b, \ + 0xcb, 0x73, 0x4b, 0x52, 0x96, 0xd8, 0x11, 0xa2, 0x2c, 0x80, 0x88, 0x69, \ + 0x39, 0x5a, 0xd3, 0x0f, 0xb0, 0xde, 0x59, 0x2f, 0x11, 0xc7, 0xf7, 0xea, \ + 0x12, 0x01, 0x30, 0x97, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01, \ + 0x01, 0x00, 0x97, 0x47, 0x44, 0xbc, 0x10, 0x81, 0xc5, 0x18, 0xe4, 0x59, \ + 0xfb, 0xe0, 0x2d, 0x3a, 0x0e, 0x9e, 0x10, 0xdc, 0x43, 0xfb, 0x15, 0x6c, \ + 0xd1, 0xfd, 0x48, 0x78, 0x6c, 0xf9, 0xed, 0x38, 0xe8, 0xdd, 0x09, 0xd7, \ + 0x5f, 0xb5, 0x41, 0x64, 0xd7, 0x63, 0xfa, 0x9d, 0x44, 0x0a, 0xf8, 0x42, \ + 0x13, 0xf1, 0xbb, 0x5e, 0x79, 0x20, 0x53, 0x98, 0x4b, 0x65, 0x7f, 0x86, \ + 0x67, 0x48, 0xe4, 0xcf, 0xfb, 0x6a, 0x24, 0xe2, 0x34, 0xbd, 0x14, 0x9d, \ + 0x2c, 0x16, 0xe2, 0xa4, 0x79, 0xd6, 0xa2, 0xec, 0x81, 0x43, 0x87, 0xbf, \ + 0x03, 0x5c, 0x88, 0x25, 0xd9, 0x41, 0xb6, 0xa5, 0xf1, 0x27, 0x52, 0x84, \ + 0xfe, 0x2b, 0x6e, 0x1d, 0x16, 0xcd, 0x73, 0x88, 0xf8, 0x90, 0xbf, 0x19, \ + 0xfe, 0xbe, 0xa9, 0xbf, 0x09, 0xd3, 0x23, 0x43, 0xd2, 0xc7, 0x61, 0x2a, \ + 0xb3, 0x4e, 0x3c, 0x61, 0xd4, 0xbd, 0xd8, 0xb4, 0xfa, 0xa8, 0x0b, 0xf8, \ + 0x7e, 0x56, 0xcd, 0x0f, 0x13, 0x27, 0xda, 0xe6, 0x3b, 0xb3, 0x8c, 0x9c, \ + 0x4b, 0x84, 0x3c, 0xc3, 0x52, 0x57, 0x9c, 0x27, 0x9a, 0x02, 0x76, 0x26, \ + 0x59, 0x82, 0x39, 0xc3, 0x13, 0xbe, 0x6e, 0xf4, 0x44, 0x2d, 0x1d, 0x8c, \ + 0x73, 0x3e, 0x43, 0x99, 0x59, 0xcb, 0xf2, 0x34, 0x72, 0x9a, 0x5e, 0xa5, \ + 0xeb, 0x9f, 0x36, 0x6d, 0x2b, 0xf9, 0xa2, 0xe7, 0xd1, 0x78, 0x52, 0x1b, \ + 0xc8, 0xf6, 0x5b, 0x41, 0x69, 0x57, 0x81, 0x89, 0xe9, 0xbb, 0xa1, 0xde, \ + 0x19, 0x37, 0x3b, 0x13, 0x5c, 0xca, 0x61, 0x01, 0x86, 0xff, 0xdf, 0x83, \ + 0x41, 0x49, 0x7f, 0xd6, 0xf4, 0x2e, 0x08, 0xfa, 0x90, 0xc2, 0x7c, 0xb4, \ + 0xb5, 0x0a, 0x17, 0xdb, 0x0e, 0x6d, 0x75, 0x8a, 0x5d, 0x31, 0xd5, 0x66, \ + 0xfb, 0x39, 0x0b, 0xb5, 0xb6, 0xa3, 0xcd, 0xd4, 0xef, 0x88, 0x92, 0x5a, \ + 0x4d, 0x6c, 0xcb, 0xea, 0x5b, 0x79, 0x02, 0x81, 0x81, 0x00, 0xdf, 0x3a, \ + 0xf9, 0x25, 0x5e, 0x24, 0x37, 0x26, 0x40, 0x97, 0x2f, 0xe0, 0x4a, 0xba, \ + 0x52, 0x1b, 0x51, 0xaf, 0x84, 0x06, 0x32, 0x24, 0x0c, 0xcf, 0x44, 0xa8, \ + 0x77, 0xa7, 0xad, 0xb5, 0x8c, 0x58, 0xcc, 0xc8, 0x31, 0xb7, 0x0d, 0xbc, \ + 0x08, 0x8a, 0xe0, 0xa6, 0x8c, 0xc2, 0x73, 0xe5, 0x1a, 0x64, 0x92, 0xe8, \ + 0xed, 0x4c, 0x6f, 0x0b, 0xa6, 0xa7, 0xf3, 0x9a, 0xf5, 0x6f, 0x69, 0xca, \ + 0x3c, 0x22, 0xd0, 0x15, 0xa8, 0x20, 0x27, 0x41, 0xf8, 0x43, 0x42, 0x7f, \ + 0xb1, 0x93, 0xa1, 0x04, 0x85, 0xda, 0xa0, 0x1c, 0xd6, 0xc6, 0xf7, 0x8a, \ + 0x9e, 0xea, 0x5c, 0x78, 0xa7, 0x55, 0xc4, 0x6b, 0x05, 0x8b, 0xc0, 0x83, \ + 0xcb, 0xce, 0x83, 0x05, 0xf8, 0xb2, 0x16, 0x2b, 0xdf, 0x06, 0x3f, 0xb8, \ + 0xec, 0x16, 0xda, 0x43, 0x33, 0xc1, 0x8f, 0xb0, 0xb8, 0xac, 0xae, 0xd4, \ + 0x94, 0xb8, 0xda, 0x6f, 0x6a, 0xc3, 0x02, 0x81, 0x81, 0x00, 0xdd, 0xae, \ + 0x00, 0xcd, 0xa0, 0x72, 0x1a, 0x05, 0x8a, 0xee, 0x2f, 0xd4, 0x71, 0x4b, \ + 0xf0, 0x3e, 0xe5, 0xc1, 0xe1, 0x29, 0x8b, 0xa6, 0x67, 0x30, 0x98, 0xe7, \ + 0x12, 0xef, 0xdd, 0x12, 0x01, 0x90, 0x24, 0x58, 0xf0, 0x76, 0x92, 0xe7, \ + 0x3d, 0xbb, 0x23, 0xe1, 0xce, 0xf9, 0xa1, 0xd4, 0x38, 0x1b, 0x3f, 0x20, \ + 0xb3, 0x0f, 0x65, 0x6a, 0x8f, 0x55, 0x57, 0x36, 0xee, 0xb2, 0x84, 0x44, \ + 0xfc, 0x91, 0x88, 0xe1, 0xa4, 0xdd, 0x3b, 0x4a, 0x40, 0x4d, 0x7c, 0x86, \ + 0xed, 0xe1, 0xb5, 0x42, 0xef, 0xb9, 0x61, 0xcd, 0x58, 0x19, 0x77, 0x02, \ + 0xae, 0x58, 0x80, 0xdb, 0x13, 0x3d, 0xc7, 0x1f, 0x9d, 0xed, 0xff, 0xac, \ + 0x98, 0xfc, 0xcd, 0xf9, 0x62, 0x04, 0x83, 0x91, 0x89, 0x0d, 0x86, 0x43, \ + 0x8c, 0x0c, 0xc7, 0x1b, 0x90, 0x4d, 0xbe, 0x2f, 0xc5, 0x7c, 0xcd, 0x42, \ + 0xf5, 0xd3, 0xad, 0x8e, 0xfd, 0x9d, 0x02, 0x81, 0x80, 0x17, 0x4b, 0x79, \ + 0x2a, 0x6c, 0x1b, 0x8d, 0x61, 0xc1, 0x85, 0xc5, 0x6a, 0x3b, 0x82, 0x1c, \ + 0x05, 0x5b, 0xcd, 0xdc, 0x12, 0x25, 0x73, 0x5b, 0x9e, 0xd9, 0x84, 0x57, \ + 0x10, 0x39, 0x71, 0x63, 0x96, 0xf4, 0xaf, 0xc3, 0x78, 0x5d, 0xc7, 0x8c, \ + 0x80, 0xa9, 0x96, 0xd7, 0xc3, 0x87, 0x02, 0x96, 0x71, 0x7e, 0x5f, 0x2e, \ + 0x3c, 0x36, 0xae, 0x59, 0x92, 0xd7, 0x3a, 0x09, 0x78, 0xb9, 0xea, 0x6f, \ + 0xc2, 0x16, 0x42, 0xdc, 0x4b, 0x96, 0xad, 0x2c, 0xb2, 0x20, 0x23, 0x61, \ + 0x2d, 0x8d, 0xb5, 0x02, 0x1e, 0xe1, 0x6c, 0x81, 0x01, 0x3c, 0x5d, 0xcb, \ + 0xdd, 0x9b, 0x0e, 0xc0, 0x2f, 0x94, 0x12, 0xb2, 0xfe, 0x75, 0x75, 0x8b, \ + 0x74, 0x1e, 0x7a, 0x26, 0x0c, 0xb7, 0x81, 0x96, 0x81, 0x79, 0x6e, 0xdb, \ + 0xbc, 0x3a, 0xc4, 0x9e, 0x87, 0x09, 0x6e, 0xa0, 0xa6, 0xec, 0x8b, 0xa4, \ + 0x85, 0x71, 0xce, 0x04, 0xaf, 0x02, 0x81, 0x81, 0x00, 0xc2, 0xa7, 0x47, \ + 0x07, 0x48, 0x6a, 0xc8, 0xd4, 0xb3, 0x20, 0xe1, 0x98, 0xee, 0xff, 0x5a, \ + 0x6f, 0x30, 0x7a, 0xa5, 0x47, 0x40, 0xdc, 0x16, 0x62, 0x42, 0xf1, 0x2c, \ + 0xdc, 0xb8, 0xc7, 0x55, 0xde, 0x07, 0x3c, 0x9d, 0xb1, 0xd0, 0xdf, 0x02, \ + 0x82, 0xb0, 0x48, 0x58, 0xe1, 0x34, 0xab, 0xcf, 0xb4, 0x85, 0x23, 0x26, \ + 0x78, 0x4f, 0x7a, 0x59, 0x6f, 0xfb, 0x8c, 0x3d, 0xdf, 0x3d, 0x6c, 0x02, \ + 0x47, 0x9c, 0xe5, 0x5e, 0x49, 0xf1, 0x05, 0x0b, 0x1f, 0xbf, 0x48, 0x0f, \ + 0xdc, 0x10, 0xb9, 0x3d, 0x1d, 0x10, 0x77, 0x2a, 0x73, 0xf9, 0xdf, 0xbd, \ + 0xcd, 0xf3, 0x1f, 0xeb, 0x6e, 0x64, 0xca, 0x2b, 0x78, 0x4f, 0xf8, 0x73, \ + 0xc2, 0x10, 0xef, 0x79, 0x95, 0x33, 0x1e, 0x79, 0x35, 0x09, 0xff, 0x88, \ + 0x1b, 0xb4, 0x3e, 0x4c, 0xe1, 0x27, 0x2e, 0x75, 0x80, 0x58, 0x11, 0x03, \ + 0x21, 0x23, 0x96, 0x9a, 0xb5, 0x02, 0x81, 0x80, 0x05, 0x12, 0x64, 0x71, \ + 0x83, 0x00, 0x1c, 0xfe, 0xef, 0x83, 0xea, 0xdd, 0x2c, 0xc8, 0x2c, 0x00, \ + 0x62, 0x1e, 0x8f, 0x3a, 0xdb, 0x1c, 0xab, 0xd6, 0x34, 0x8b, 0xd1, 0xb2, \ + 0x5a, 0x4f, 0x3d, 0x37, 0x38, 0x02, 0xe0, 0xd7, 0x70, 0xc1, 0xb0, 0x47, \ + 0xe0, 0x08, 0x1a, 0x84, 0xec, 0x48, 0xc5, 0x7c, 0x76, 0x83, 0x12, 0x67, \ + 0xab, 0x7c, 0x9f, 0x90, 0x97, 0xc8, 0x8f, 0x07, 0xf4, 0xb3, 0x60, 0xf2, \ + 0x3f, 0x49, 0x18, 0xdb, 0x2e, 0x94, 0x6b, 0x53, 0x9e, 0xa2, 0x63, 0xde, \ + 0x63, 0xd9, 0xab, 0x21, 0x2e, 0x2d, 0x0a, 0xe0, 0xd0, 0xe8, 0xba, 0xc4, \ + 0x4c, 0x1e, 0xa5, 0xf5, 0x51, 0xa8, 0xc4, 0x92, 0xf8, 0x7f, 0x21, 0xe7, \ + 0x65, 0xbf, 0x0b, 0xe6, 0x01, 0xaf, 0x9c, 0x1d, 0x5b, 0x6c, 0x3f, 0x1c, \ + 0x2f, 0xa6, 0x0f, 0x68, 0x38, 0x8e, 0x85, 0xc4, 0x6c, 0x78, 0x2f, 0x6f, \ + 0x06, 0x21, 0x2e, 0x56 \ +} +/* END FILE */ + +/* + * Test client Certificates + * + * Test client certificates are defined for each choice + * of the following parameters: + * - PEM or DER encoding + * - RSA or EC key + * + * Things to add: + * - hash type + * - multiple EC curve types + */ + +/* This is taken from tests/data_files/cli2.crt. */ +/* BEGIN FILE string macro TEST_CLI_CRT_EC_PEM tests/data_files/cli2.crt */ +#define TEST_CLI_CRT_EC_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIICLDCCAbKgAwIBAgIBDTAKBggqhkjOPQQDAjA+MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0EwHhcN\r\n" \ + "MTMwOTI0MTU1MjA0WhcNMjMwOTIyMTU1MjA0WjBBMQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UEChMIUG9sYXJTU0wxHzAdBgNVBAMTFlBvbGFyU1NMIFRlc3QgQ2xpZW50IDIw\r\n" \ + "WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARX5a6xc9/TrLuTuIH/Eq7u5lOszlVT\r\n" \ + "9jQOzC7jYyUL35ji81xgNpbA1RgUcOV/n9VLRRjlsGzVXPiWj4dwo+THo4GdMIGa\r\n" \ + "MAkGA1UdEwQCMAAwHQYDVR0OBBYEFHoAX4Zk/OBd5REQO7LmO8QmP8/iMG4GA1Ud\r\n" \ + "IwRnMGWAFJ1tICRJAT8ry3i1Gbx+JMnb+zZ8oUKkQDA+MQswCQYDVQQGEwJOTDER\r\n" \ + "MA8GA1UEChMIUG9sYXJTU0wxHDAaBgNVBAMTE1BvbGFyc3NsIFRlc3QgRUMgQ0GC\r\n" \ + "CQDBQ+J+YkPM6DAKBggqhkjOPQQDAgNoADBlAjBKZQ17IIOimbmoD/yN7o89u3BM\r\n" \ + "lgOsjnhw3fIOoLIWy2WOGsk/LGF++DzvrRzuNiACMQCd8iem1XS4JK7haj8xocpU\r\n" \ + "LwjQje5PDGHfd3h9tP38Qknu5bJqws0md2KOKHyeV0U=\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This is generated from tests/data_files/cli2.crt.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CLI_CRT_EC_DER tests/data_files/cli2.crt.der */ +#define TEST_CLI_CRT_EC_DER { \ + 0x30, 0x82, 0x02, 0x2c, 0x30, 0x82, 0x01, 0xb2, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x0d, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, \ + 0x3d, 0x04, 0x03, 0x02, 0x30, 0x3e, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, \ + 0x13, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x73, 0x73, 0x6c, 0x20, 0x54, 0x65, \ + 0x73, 0x74, 0x20, 0x45, 0x43, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x33, 0x30, 0x39, 0x32, 0x34, 0x31, 0x35, 0x35, 0x32, 0x30, 0x34, \ + 0x5a, 0x17, 0x0d, 0x32, 0x33, 0x30, 0x39, 0x32, 0x32, 0x31, 0x35, 0x35, \ + 0x32, 0x30, 0x34, 0x5a, 0x30, 0x41, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x1f, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, \ + 0x16, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x20, 0x54, 0x65, \ + 0x73, 0x74, 0x20, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x20, 0x32, 0x30, \ + 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, \ + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, \ + 0x00, 0x04, 0x57, 0xe5, 0xae, 0xb1, 0x73, 0xdf, 0xd3, 0xac, 0xbb, 0x93, \ + 0xb8, 0x81, 0xff, 0x12, 0xae, 0xee, 0xe6, 0x53, 0xac, 0xce, 0x55, 0x53, \ + 0xf6, 0x34, 0x0e, 0xcc, 0x2e, 0xe3, 0x63, 0x25, 0x0b, 0xdf, 0x98, 0xe2, \ + 0xf3, 0x5c, 0x60, 0x36, 0x96, 0xc0, 0xd5, 0x18, 0x14, 0x70, 0xe5, 0x7f, \ + 0x9f, 0xd5, 0x4b, 0x45, 0x18, 0xe5, 0xb0, 0x6c, 0xd5, 0x5c, 0xf8, 0x96, \ + 0x8f, 0x87, 0x70, 0xa3, 0xe4, 0xc7, 0xa3, 0x81, 0x9d, 0x30, 0x81, 0x9a, \ + 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00, 0x30, \ + 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x7a, 0x00, \ + 0x5f, 0x86, 0x64, 0xfc, 0xe0, 0x5d, 0xe5, 0x11, 0x10, 0x3b, 0xb2, 0xe6, \ + 0x3b, 0xc4, 0x26, 0x3f, 0xcf, 0xe2, 0x30, 0x6e, 0x06, 0x03, 0x55, 0x1d, \ + 0x23, 0x04, 0x67, 0x30, 0x65, 0x80, 0x14, 0x9d, 0x6d, 0x20, 0x24, 0x49, \ + 0x01, 0x3f, 0x2b, 0xcb, 0x78, 0xb5, 0x19, 0xbc, 0x7e, 0x24, 0xc9, 0xdb, \ + 0xfb, 0x36, 0x7c, 0xa1, 0x42, 0xa4, 0x40, 0x30, 0x3e, 0x31, 0x0b, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, \ + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x08, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, \ + 0x04, 0x03, 0x13, 0x13, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x73, 0x73, 0x6c, \ + 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x43, 0x20, 0x43, 0x41, 0x82, \ + 0x09, 0x00, 0xc1, 0x43, 0xe2, 0x7e, 0x62, 0x43, 0xcc, 0xe8, 0x30, 0x0a, \ + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x68, \ + 0x00, 0x30, 0x65, 0x02, 0x30, 0x4a, 0x65, 0x0d, 0x7b, 0x20, 0x83, 0xa2, \ + 0x99, 0xb9, 0xa8, 0x0f, 0xfc, 0x8d, 0xee, 0x8f, 0x3d, 0xbb, 0x70, 0x4c, \ + 0x96, 0x03, 0xac, 0x8e, 0x78, 0x70, 0xdd, 0xf2, 0x0e, 0xa0, 0xb2, 0x16, \ + 0xcb, 0x65, 0x8e, 0x1a, 0xc9, 0x3f, 0x2c, 0x61, 0x7e, 0xf8, 0x3c, 0xef, \ + 0xad, 0x1c, 0xee, 0x36, 0x20, 0x02, 0x31, 0x00, 0x9d, 0xf2, 0x27, 0xa6, \ + 0xd5, 0x74, 0xb8, 0x24, 0xae, 0xe1, 0x6a, 0x3f, 0x31, 0xa1, 0xca, 0x54, \ + 0x2f, 0x08, 0xd0, 0x8d, 0xee, 0x4f, 0x0c, 0x61, 0xdf, 0x77, 0x78, 0x7d, \ + 0xb4, 0xfd, 0xfc, 0x42, 0x49, 0xee, 0xe5, 0xb2, 0x6a, 0xc2, 0xcd, 0x26, \ + 0x77, 0x62, 0x8e, 0x28, 0x7c, 0x9e, 0x57, 0x45 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/cli2.key. */ +/* BEGIN FILE string macro TEST_CLI_KEY_EC_PEM tests/data_files/cli2.key */ +#define TEST_CLI_KEY_EC_PEM \ + "-----BEGIN EC PRIVATE KEY-----\r\n" \ + "MHcCAQEEIPb3hmTxZ3/mZI3vyk7p3U3wBf+WIop6hDhkFzJhmLcqoAoGCCqGSM49\r\n" \ + "AwEHoUQDQgAEV+WusXPf06y7k7iB/xKu7uZTrM5VU/Y0Dswu42MlC9+Y4vNcYDaW\r\n" \ + "wNUYFHDlf5/VS0UY5bBs1Vz4lo+HcKPkxw==\r\n" \ + "-----END EC PRIVATE KEY-----\r\n" +/* END FILE */ + +/* This is generated from tests/data_files/cli2.key.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CLI_KEY_EC_DER tests/data_files/cli2.key.der */ +#define TEST_CLI_KEY_EC_DER { \ + 0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0xf6, 0xf7, 0x86, 0x64, 0xf1, \ + 0x67, 0x7f, 0xe6, 0x64, 0x8d, 0xef, 0xca, 0x4e, 0xe9, 0xdd, 0x4d, 0xf0, \ + 0x05, 0xff, 0x96, 0x22, 0x8a, 0x7a, 0x84, 0x38, 0x64, 0x17, 0x32, 0x61, \ + 0x98, 0xb7, 0x2a, 0xa0, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, \ + 0x03, 0x01, 0x07, 0xa1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x57, 0xe5, 0xae, \ + 0xb1, 0x73, 0xdf, 0xd3, 0xac, 0xbb, 0x93, 0xb8, 0x81, 0xff, 0x12, 0xae, \ + 0xee, 0xe6, 0x53, 0xac, 0xce, 0x55, 0x53, 0xf6, 0x34, 0x0e, 0xcc, 0x2e, \ + 0xe3, 0x63, 0x25, 0x0b, 0xdf, 0x98, 0xe2, 0xf3, 0x5c, 0x60, 0x36, 0x96, \ + 0xc0, 0xd5, 0x18, 0x14, 0x70, 0xe5, 0x7f, 0x9f, 0xd5, 0x4b, 0x45, 0x18, \ + 0xe5, 0xb0, 0x6c, 0xd5, 0x5c, 0xf8, 0x96, 0x8f, 0x87, 0x70, 0xa3, 0xe4, \ + 0xc7 \ +} +/* END FILE */ + +/* This is taken from tests/data_files/cli-rsa-sha256.crt. */ +/* BEGIN FILE string macro TEST_CLI_CRT_RSA_PEM tests/data_files/cli-rsa-sha256.crt */ +#define TEST_CLI_CRT_RSA_PEM \ + "-----BEGIN CERTIFICATE-----\r\n" \ + "MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n" \ + "MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ + "MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n" \ + "A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN\r\n" \ + "BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f\r\n" \ + "M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu\r\n" \ + "1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw\r\n" \ + "MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v\r\n" \ + "4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/\r\n" \ + "/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB\r\n" \ + "o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf\r\n" \ + "BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQsFAAOC\r\n" \ + "AQEAlHabem2Tu69VUN7EipwnQn1dIHdgvT5i+iQHpSxY1crPnBbAeSdAXwsVEqLQ\r\n" \ + "gOOIAQD5VIITNuoGgo4i+4OpNh9u7ZkpRHla+/swsfrFWRRbBNP5Bcu74AGLstwU\r\n" \ + "zM8gIkBiyfM1Q1qDQISV9trlCG6O8vh8dp/rbI3rfzo99BOHXgFCrzXjCuW4vDsF\r\n" \ + "r+Dao26bX3sJ6UnEWg1H3o2x6PpUcvQ36h71/bz4TEbbUUEpe02V4QWuL+wrhHJL\r\n" \ + "U7o3SVE3Og7jPF8sat0a50YUWhwEFI256m02KAXLg89ueUyYKEr6rNwhcvXJpvU9\r\n" \ + "giIVvd0Sbjjnn7NC4VDbcXV8vw==\r\n" \ + "-----END CERTIFICATE-----\r\n" +/* END FILE */ + +/* This was generated from tests/data_files/cli-rsa-sha256.crt.der + using `xxd -i.` */ +/* BEGIN FILE binary macro TEST_CLI_CRT_RSA_DER tests/data_files/cli-rsa-sha256.crt.der */ +#define TEST_CLI_CRT_RSA_DER { \ + 0x30, 0x82, 0x03, 0x3f, 0x30, 0x82, 0x02, 0x27, 0xa0, 0x03, 0x02, 0x01, \ + 0x02, 0x02, 0x01, 0x04, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, \ + 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x3b, 0x31, 0x0b, 0x30, \ + 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, \ + 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, \ + 0x61, 0x72, 0x53, 0x53, 0x4c, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55, \ + 0x04, 0x03, 0x0c, 0x10, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, \ + 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1e, 0x17, 0x0d, \ + 0x31, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, 0x34, 0x30, 0x36, \ + 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x32, 0x31, 0x32, 0x31, 0x34, 0x34, \ + 0x34, 0x30, 0x36, 0x5a, 0x30, 0x3c, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, \ + 0x55, 0x04, 0x06, 0x13, 0x02, 0x4e, 0x4c, 0x31, 0x11, 0x30, 0x0f, 0x06, \ + 0x03, 0x55, 0x04, 0x0a, 0x0c, 0x08, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, \ + 0x53, 0x4c, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, \ + 0x11, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x53, 0x53, 0x4c, 0x20, 0x43, 0x6c, \ + 0x69, 0x65, 0x6e, 0x74, 0x20, 0x32, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, \ + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, \ + 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, \ + 0x01, 0x01, 0x00, 0xc8, 0x74, 0xc4, 0xcc, 0xb9, 0xf9, 0xb5, 0x79, 0xe9, \ + 0x45, 0xd9, 0x14, 0x60, 0xb0, 0x7d, 0xbb, 0x93, 0xf2, 0x6b, 0x1e, 0x9f, \ + 0x33, 0xad, 0x0d, 0x8f, 0x8a, 0x3c, 0x56, 0x65, 0xe5, 0xdc, 0x44, 0xd9, \ + 0xcc, 0x66, 0x85, 0x07, 0xd5, 0xf8, 0x27, 0xb0, 0x4a, 0x35, 0xd0, 0x63, \ + 0x9e, 0x0a, 0x6e, 0x1b, 0xb7, 0xda, 0xf0, 0x7e, 0xab, 0xee, 0x0c, 0x10, \ + 0x93, 0x86, 0x49, 0x18, 0x34, 0xf3, 0xa8, 0x2a, 0xd2, 0x57, 0xf5, 0x2e, \ + 0xd4, 0x2f, 0x77, 0x29, 0x84, 0x61, 0x4d, 0x82, 0x50, 0x8f, 0xa7, 0x95, \ + 0x48, 0x70, 0xf5, 0x6e, 0x4d, 0xb2, 0xd5, 0x13, 0xc3, 0xd2, 0x1a, 0xed, \ + 0xe6, 0x43, 0xea, 0x42, 0x14, 0xeb, 0x74, 0xea, 0xc0, 0xed, 0x1f, 0xd4, \ + 0x57, 0x4e, 0xa9, 0xf3, 0xa8, 0xed, 0xd2, 0xe0, 0xc1, 0x30, 0x71, 0x30, \ + 0x32, 0x30, 0xd5, 0xd3, 0xf6, 0x08, 0xd0, 0x56, 0x4f, 0x46, 0x8e, 0xf2, \ + 0x5f, 0xf9, 0x3d, 0x67, 0x91, 0x88, 0x30, 0x2e, 0x42, 0xb2, 0xdf, 0x7d, \ + 0xfb, 0xe5, 0x0c, 0x77, 0xff, 0xec, 0x31, 0xc0, 0x78, 0x8f, 0xbf, 0xc2, \ + 0x7f, 0xca, 0xad, 0x6c, 0x21, 0xd6, 0x8d, 0xd9, 0x8b, 0x6a, 0x8e, 0x6f, \ + 0xe0, 0x9b, 0xf8, 0x10, 0x56, 0xcc, 0xb3, 0x8e, 0x13, 0x15, 0xe6, 0x34, \ + 0x04, 0x66, 0xc7, 0xee, 0xf9, 0x36, 0x0e, 0x6a, 0x95, 0xf6, 0x09, 0x9a, \ + 0x06, 0x67, 0xf4, 0x65, 0x71, 0xf8, 0xca, 0xa4, 0xb1, 0x25, 0xe0, 0xfe, \ + 0x3c, 0x8b, 0x35, 0x04, 0x67, 0xba, 0xe0, 0x4f, 0x76, 0x85, 0xfc, 0x7f, \ + 0xfc, 0x36, 0x6b, 0xb5, 0xe9, 0xcd, 0x2d, 0x03, 0x62, 0x4e, 0xb3, 0x3d, \ + 0x00, 0xcf, 0xaf, 0x76, 0xa0, 0x69, 0x56, 0x83, 0x6a, 0xd2, 0xa8, 0xd4, \ + 0xe7, 0x50, 0x71, 0xe6, 0xb5, 0x36, 0x05, 0x77, 0x05, 0x6d, 0x7b, 0xc8, \ + 0xe4, 0xc4, 0xfd, 0x4c, 0xd5, 0x21, 0x5f, 0x02, 0x03, 0x01, 0x00, 0x01, \ + 0xa3, 0x4d, 0x30, 0x4b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x04, \ + 0x02, 0x30, 0x00, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, \ + 0x04, 0x14, 0x71, 0xa1, 0x00, 0x73, 0x72, 0x40, 0x2f, 0x54, 0x76, 0x5e, \ + 0x33, 0xfc, 0x52, 0x8f, 0xbc, 0xf1, 0xdd, 0x6b, 0x46, 0x21, 0x30, 0x1f, \ + 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0xb4, \ + 0x5a, 0xe4, 0xa5, 0xb3, 0xde, 0xd2, 0x52, 0xf6, 0xb9, 0xd5, 0xa6, 0x95, \ + 0x0f, 0xeb, 0x3e, 0xbc, 0xc7, 0xfd, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, \ + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, \ + 0x01, 0x01, 0x00, 0x94, 0x76, 0x9b, 0x7a, 0x6d, 0x93, 0xbb, 0xaf, 0x55, \ + 0x50, 0xde, 0xc4, 0x8a, 0x9c, 0x27, 0x42, 0x7d, 0x5d, 0x20, 0x77, 0x60, \ + 0xbd, 0x3e, 0x62, 0xfa, 0x24, 0x07, 0xa5, 0x2c, 0x58, 0xd5, 0xca, 0xcf, \ + 0x9c, 0x16, 0xc0, 0x79, 0x27, 0x40, 0x5f, 0x0b, 0x15, 0x12, 0xa2, 0xd0, \ + 0x80, 0xe3, 0x88, 0x01, 0x00, 0xf9, 0x54, 0x82, 0x13, 0x36, 0xea, 0x06, \ + 0x82, 0x8e, 0x22, 0xfb, 0x83, 0xa9, 0x36, 0x1f, 0x6e, 0xed, 0x99, 0x29, \ + 0x44, 0x79, 0x5a, 0xfb, 0xfb, 0x30, 0xb1, 0xfa, 0xc5, 0x59, 0x14, 0x5b, \ + 0x04, 0xd3, 0xf9, 0x05, 0xcb, 0xbb, 0xe0, 0x01, 0x8b, 0xb2, 0xdc, 0x14, \ + 0xcc, 0xcf, 0x20, 0x22, 0x40, 0x62, 0xc9, 0xf3, 0x35, 0x43, 0x5a, 0x83, \ + 0x40, 0x84, 0x95, 0xf6, 0xda, 0xe5, 0x08, 0x6e, 0x8e, 0xf2, 0xf8, 0x7c, \ + 0x76, 0x9f, 0xeb, 0x6c, 0x8d, 0xeb, 0x7f, 0x3a, 0x3d, 0xf4, 0x13, 0x87, \ + 0x5e, 0x01, 0x42, 0xaf, 0x35, 0xe3, 0x0a, 0xe5, 0xb8, 0xbc, 0x3b, 0x05, \ + 0xaf, 0xe0, 0xda, 0xa3, 0x6e, 0x9b, 0x5f, 0x7b, 0x09, 0xe9, 0x49, 0xc4, \ + 0x5a, 0x0d, 0x47, 0xde, 0x8d, 0xb1, 0xe8, 0xfa, 0x54, 0x72, 0xf4, 0x37, \ + 0xea, 0x1e, 0xf5, 0xfd, 0xbc, 0xf8, 0x4c, 0x46, 0xdb, 0x51, 0x41, 0x29, \ + 0x7b, 0x4d, 0x95, 0xe1, 0x05, 0xae, 0x2f, 0xec, 0x2b, 0x84, 0x72, 0x4b, \ + 0x53, 0xba, 0x37, 0x49, 0x51, 0x37, 0x3a, 0x0e, 0xe3, 0x3c, 0x5f, 0x2c, \ + 0x6a, 0xdd, 0x1a, 0xe7, 0x46, 0x14, 0x5a, 0x1c, 0x04, 0x14, 0x8d, 0xb9, \ + 0xea, 0x6d, 0x36, 0x28, 0x05, 0xcb, 0x83, 0xcf, 0x6e, 0x79, 0x4c, 0x98, \ + 0x28, 0x4a, 0xfa, 0xac, 0xdc, 0x21, 0x72, 0xf5, 0xc9, 0xa6, 0xf5, 0x3d, \ + 0x82, 0x22, 0x15, 0xbd, 0xdd, 0x12, 0x6e, 0x38, 0xe7, 0x9f, 0xb3, 0x42, \ + 0xe1, 0x50, 0xdb, 0x71, 0x75, 0x7c, 0xbf \ +} +/* END FILE */ + +/* This is taken from tests/data_files/cli-rsa.key. */ +/* BEGIN FILE string macro TEST_CLI_KEY_RSA_PEM tests/data_files/cli-rsa.key */ +#define TEST_CLI_KEY_RSA_PEM \ + "-----BEGIN RSA PRIVATE KEY-----\r\n" \ + "MIIEpAIBAAKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6fM60Nj4o8VmXl3ETZzGaF\r\n" \ + "B9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu1C93KYRhTYJQj6eVSHD1\r\n" \ + "bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEwMjDV0/YI0FZPRo7yX/k9\r\n" \ + "Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v4Jv4EFbMs44TFeY0BGbH\r\n" \ + "7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx//DZrtenNLQNiTrM9AM+v\r\n" \ + "dqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQABAoIBAGdNtfYDiap6bzst\r\n" \ + "yhCiI8m9TtrhZw4MisaEaN/ll3XSjaOG2dvV6xMZCMV+5TeXDHOAZnY18Yi18vzz\r\n" \ + "4Ut2TnNFzizCECYNaA2fST3WgInnxUkV3YXAyP6CNxJaCmv2aA0yFr2kFVSeaKGt\r\n" \ + "ymvljNp2NVkvm7Th8fBQBO7I7AXhz43k0mR7XmPgewe8ApZOG3hstkOaMvbWAvWA\r\n" \ + "zCZupdDjZYjOJqlA4eEA4H8/w7F83r5CugeBE8LgEREjLPiyejrU5H1fubEY+h0d\r\n" \ + "l5HZBJ68ybTXfQ5U9o/QKA3dd0toBEhhdRUDGzWtjvwkEQfqF1reGWj/tod/gCpf\r\n" \ + "DFi6X0ECgYEA4wOv/pjSC3ty6TuOvKX2rOUiBrLXXv2JSxZnMoMiWI5ipLQt+RYT\r\n" \ + "VPafL/m7Dn6MbwjayOkcZhBwk5CNz5A6Q4lJ64Mq/lqHznRCQQ2Mc1G8eyDF/fYL\r\n" \ + "Ze2pLvwP9VD5jTc2miDfw+MnvJhywRRLcemDFP8k4hQVtm8PMp3ZmNECgYEA4gz7\r\n" \ + "wzObR4gn8ibe617uQPZjWzUj9dUHYd+in1gwBCIrtNnaRn9I9U/Q6tegRYpii4ys\r\n" \ + "c176NmU+umy6XmuSKV5qD9bSpZWG2nLFnslrN15Lm3fhZxoeMNhBaEDTnLT26yoi\r\n" \ + "33gp0mSSWy94ZEqipms+ULF6sY1ZtFW6tpGFoy8CgYAQHhnnvJflIs2ky4q10B60\r\n" \ + "ZcxFp3rtDpkp0JxhFLhiizFrujMtZSjYNm5U7KkgPVHhLELEUvCmOnKTt4ap/vZ0\r\n" \ + "BxJNe1GZH3pW6SAvGDQpl9sG7uu/vTFP+lCxukmzxB0DrrDcvorEkKMom7ZCCRvW\r\n" \ + "KZsZ6YeH2Z81BauRj218kQKBgQCUV/DgKP2985xDTT79N08jUo3hTP5MVYCCuj/+\r\n" \ + "UeEw1TvZcx3LJby7P6Xad6a1/BqveaGyFKIfEFIaBUBItk801sDDpDaYc4gL00Xc\r\n" \ + "7lFuBHOZkxJYlss5QrGpuOEl9ZwUt5IrFLBdYaKqNHzNVC1pCPfb/JyH6Dr2HUxq\r\n" \ + "gxUwAQKBgQCcU6G2L8AG9d9c0UpOyL1tMvFe5Ttw0KjlQVdsh1MP6yigYo9DYuwu\r\n" \ + "bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n" \ + "8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n" \ + "-----END RSA PRIVATE KEY-----\r\n"/* END FILE */ + +/* This was generated from tests/data_files/cli-rsa.key.der using `xxd -i`. */ +/* BEGIN FILE binary macro TEST_CLI_KEY_RSA_DER tests/data_files/cli-rsa.key.der */ +#define TEST_CLI_KEY_RSA_DER { \ + 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, \ + 0xc8, 0x74, 0xc4, 0xcc, 0xb9, 0xf9, 0xb5, 0x79, 0xe9, 0x45, 0xd9, 0x14, \ + 0x60, 0xb0, 0x7d, 0xbb, 0x93, 0xf2, 0x6b, 0x1e, 0x9f, 0x33, 0xad, 0x0d, \ + 0x8f, 0x8a, 0x3c, 0x56, 0x65, 0xe5, 0xdc, 0x44, 0xd9, 0xcc, 0x66, 0x85, \ + 0x07, 0xd5, 0xf8, 0x27, 0xb0, 0x4a, 0x35, 0xd0, 0x63, 0x9e, 0x0a, 0x6e, \ + 0x1b, 0xb7, 0xda, 0xf0, 0x7e, 0xab, 0xee, 0x0c, 0x10, 0x93, 0x86, 0x49, \ + 0x18, 0x34, 0xf3, 0xa8, 0x2a, 0xd2, 0x57, 0xf5, 0x2e, 0xd4, 0x2f, 0x77, \ + 0x29, 0x84, 0x61, 0x4d, 0x82, 0x50, 0x8f, 0xa7, 0x95, 0x48, 0x70, 0xf5, \ + 0x6e, 0x4d, 0xb2, 0xd5, 0x13, 0xc3, 0xd2, 0x1a, 0xed, 0xe6, 0x43, 0xea, \ + 0x42, 0x14, 0xeb, 0x74, 0xea, 0xc0, 0xed, 0x1f, 0xd4, 0x57, 0x4e, 0xa9, \ + 0xf3, 0xa8, 0xed, 0xd2, 0xe0, 0xc1, 0x30, 0x71, 0x30, 0x32, 0x30, 0xd5, \ + 0xd3, 0xf6, 0x08, 0xd0, 0x56, 0x4f, 0x46, 0x8e, 0xf2, 0x5f, 0xf9, 0x3d, \ + 0x67, 0x91, 0x88, 0x30, 0x2e, 0x42, 0xb2, 0xdf, 0x7d, 0xfb, 0xe5, 0x0c, \ + 0x77, 0xff, 0xec, 0x31, 0xc0, 0x78, 0x8f, 0xbf, 0xc2, 0x7f, 0xca, 0xad, \ + 0x6c, 0x21, 0xd6, 0x8d, 0xd9, 0x8b, 0x6a, 0x8e, 0x6f, 0xe0, 0x9b, 0xf8, \ + 0x10, 0x56, 0xcc, 0xb3, 0x8e, 0x13, 0x15, 0xe6, 0x34, 0x04, 0x66, 0xc7, \ + 0xee, 0xf9, 0x36, 0x0e, 0x6a, 0x95, 0xf6, 0x09, 0x9a, 0x06, 0x67, 0xf4, \ + 0x65, 0x71, 0xf8, 0xca, 0xa4, 0xb1, 0x25, 0xe0, 0xfe, 0x3c, 0x8b, 0x35, \ + 0x04, 0x67, 0xba, 0xe0, 0x4f, 0x76, 0x85, 0xfc, 0x7f, 0xfc, 0x36, 0x6b, \ + 0xb5, 0xe9, 0xcd, 0x2d, 0x03, 0x62, 0x4e, 0xb3, 0x3d, 0x00, 0xcf, 0xaf, \ + 0x76, 0xa0, 0x69, 0x56, 0x83, 0x6a, 0xd2, 0xa8, 0xd4, 0xe7, 0x50, 0x71, \ + 0xe6, 0xb5, 0x36, 0x05, 0x77, 0x05, 0x6d, 0x7b, 0xc8, 0xe4, 0xc4, 0xfd, \ + 0x4c, 0xd5, 0x21, 0x5f, 0x02, 0x03, 0x01, 0x00, 0x01, 0x02, 0x82, 0x01, \ + 0x00, 0x67, 0x4d, 0xb5, 0xf6, 0x03, 0x89, 0xaa, 0x7a, 0x6f, 0x3b, 0x2d, \ + 0xca, 0x10, 0xa2, 0x23, 0xc9, 0xbd, 0x4e, 0xda, 0xe1, 0x67, 0x0e, 0x0c, \ + 0x8a, 0xc6, 0x84, 0x68, 0xdf, 0xe5, 0x97, 0x75, 0xd2, 0x8d, 0xa3, 0x86, \ + 0xd9, 0xdb, 0xd5, 0xeb, 0x13, 0x19, 0x08, 0xc5, 0x7e, 0xe5, 0x37, 0x97, \ + 0x0c, 0x73, 0x80, 0x66, 0x76, 0x35, 0xf1, 0x88, 0xb5, 0xf2, 0xfc, 0xf3, \ + 0xe1, 0x4b, 0x76, 0x4e, 0x73, 0x45, 0xce, 0x2c, 0xc2, 0x10, 0x26, 0x0d, \ + 0x68, 0x0d, 0x9f, 0x49, 0x3d, 0xd6, 0x80, 0x89, 0xe7, 0xc5, 0x49, 0x15, \ + 0xdd, 0x85, 0xc0, 0xc8, 0xfe, 0x82, 0x37, 0x12, 0x5a, 0x0a, 0x6b, 0xf6, \ + 0x68, 0x0d, 0x32, 0x16, 0xbd, 0xa4, 0x15, 0x54, 0x9e, 0x68, 0xa1, 0xad, \ + 0xca, 0x6b, 0xe5, 0x8c, 0xda, 0x76, 0x35, 0x59, 0x2f, 0x9b, 0xb4, 0xe1, \ + 0xf1, 0xf0, 0x50, 0x04, 0xee, 0xc8, 0xec, 0x05, 0xe1, 0xcf, 0x8d, 0xe4, \ + 0xd2, 0x64, 0x7b, 0x5e, 0x63, 0xe0, 0x7b, 0x07, 0xbc, 0x02, 0x96, 0x4e, \ + 0x1b, 0x78, 0x6c, 0xb6, 0x43, 0x9a, 0x32, 0xf6, 0xd6, 0x02, 0xf5, 0x80, \ + 0xcc, 0x26, 0x6e, 0xa5, 0xd0, 0xe3, 0x65, 0x88, 0xce, 0x26, 0xa9, 0x40, \ + 0xe1, 0xe1, 0x00, 0xe0, 0x7f, 0x3f, 0xc3, 0xb1, 0x7c, 0xde, 0xbe, 0x42, \ + 0xba, 0x07, 0x81, 0x13, 0xc2, 0xe0, 0x11, 0x11, 0x23, 0x2c, 0xf8, 0xb2, \ + 0x7a, 0x3a, 0xd4, 0xe4, 0x7d, 0x5f, 0xb9, 0xb1, 0x18, 0xfa, 0x1d, 0x1d, \ + 0x97, 0x91, 0xd9, 0x04, 0x9e, 0xbc, 0xc9, 0xb4, 0xd7, 0x7d, 0x0e, 0x54, \ + 0xf6, 0x8f, 0xd0, 0x28, 0x0d, 0xdd, 0x77, 0x4b, 0x68, 0x04, 0x48, 0x61, \ + 0x75, 0x15, 0x03, 0x1b, 0x35, 0xad, 0x8e, 0xfc, 0x24, 0x11, 0x07, 0xea, \ + 0x17, 0x5a, 0xde, 0x19, 0x68, 0xff, 0xb6, 0x87, 0x7f, 0x80, 0x2a, 0x5f, \ + 0x0c, 0x58, 0xba, 0x5f, 0x41, 0x02, 0x81, 0x81, 0x00, 0xe3, 0x03, 0xaf, \ + 0xfe, 0x98, 0xd2, 0x0b, 0x7b, 0x72, 0xe9, 0x3b, 0x8e, 0xbc, 0xa5, 0xf6, \ + 0xac, 0xe5, 0x22, 0x06, 0xb2, 0xd7, 0x5e, 0xfd, 0x89, 0x4b, 0x16, 0x67, \ + 0x32, 0x83, 0x22, 0x58, 0x8e, 0x62, 0xa4, 0xb4, 0x2d, 0xf9, 0x16, 0x13, \ + 0x54, 0xf6, 0x9f, 0x2f, 0xf9, 0xbb, 0x0e, 0x7e, 0x8c, 0x6f, 0x08, 0xda, \ + 0xc8, 0xe9, 0x1c, 0x66, 0x10, 0x70, 0x93, 0x90, 0x8d, 0xcf, 0x90, 0x3a, \ + 0x43, 0x89, 0x49, 0xeb, 0x83, 0x2a, 0xfe, 0x5a, 0x87, 0xce, 0x74, 0x42, \ + 0x41, 0x0d, 0x8c, 0x73, 0x51, 0xbc, 0x7b, 0x20, 0xc5, 0xfd, 0xf6, 0x0b, \ + 0x65, 0xed, 0xa9, 0x2e, 0xfc, 0x0f, 0xf5, 0x50, 0xf9, 0x8d, 0x37, 0x36, \ + 0x9a, 0x20, 0xdf, 0xc3, 0xe3, 0x27, 0xbc, 0x98, 0x72, 0xc1, 0x14, 0x4b, \ + 0x71, 0xe9, 0x83, 0x14, 0xff, 0x24, 0xe2, 0x14, 0x15, 0xb6, 0x6f, 0x0f, \ + 0x32, 0x9d, 0xd9, 0x98, 0xd1, 0x02, 0x81, 0x81, 0x00, 0xe2, 0x0c, 0xfb, \ + 0xc3, 0x33, 0x9b, 0x47, 0x88, 0x27, 0xf2, 0x26, 0xde, 0xeb, 0x5e, 0xee, \ + 0x40, 0xf6, 0x63, 0x5b, 0x35, 0x23, 0xf5, 0xd5, 0x07, 0x61, 0xdf, 0xa2, \ + 0x9f, 0x58, 0x30, 0x04, 0x22, 0x2b, 0xb4, 0xd9, 0xda, 0x46, 0x7f, 0x48, \ + 0xf5, 0x4f, 0xd0, 0xea, 0xd7, 0xa0, 0x45, 0x8a, 0x62, 0x8b, 0x8c, 0xac, \ + 0x73, 0x5e, 0xfa, 0x36, 0x65, 0x3e, 0xba, 0x6c, 0xba, 0x5e, 0x6b, 0x92, \ + 0x29, 0x5e, 0x6a, 0x0f, 0xd6, 0xd2, 0xa5, 0x95, 0x86, 0xda, 0x72, 0xc5, \ + 0x9e, 0xc9, 0x6b, 0x37, 0x5e, 0x4b, 0x9b, 0x77, 0xe1, 0x67, 0x1a, 0x1e, \ + 0x30, 0xd8, 0x41, 0x68, 0x40, 0xd3, 0x9c, 0xb4, 0xf6, 0xeb, 0x2a, 0x22, \ + 0xdf, 0x78, 0x29, 0xd2, 0x64, 0x92, 0x5b, 0x2f, 0x78, 0x64, 0x4a, 0xa2, \ + 0xa6, 0x6b, 0x3e, 0x50, 0xb1, 0x7a, 0xb1, 0x8d, 0x59, 0xb4, 0x55, 0xba, \ + 0xb6, 0x91, 0x85, 0xa3, 0x2f, 0x02, 0x81, 0x80, 0x10, 0x1e, 0x19, 0xe7, \ + 0xbc, 0x97, 0xe5, 0x22, 0xcd, 0xa4, 0xcb, 0x8a, 0xb5, 0xd0, 0x1e, 0xb4, \ + 0x65, 0xcc, 0x45, 0xa7, 0x7a, 0xed, 0x0e, 0x99, 0x29, 0xd0, 0x9c, 0x61, \ + 0x14, 0xb8, 0x62, 0x8b, 0x31, 0x6b, 0xba, 0x33, 0x2d, 0x65, 0x28, 0xd8, \ + 0x36, 0x6e, 0x54, 0xec, 0xa9, 0x20, 0x3d, 0x51, 0xe1, 0x2c, 0x42, 0xc4, \ + 0x52, 0xf0, 0xa6, 0x3a, 0x72, 0x93, 0xb7, 0x86, 0xa9, 0xfe, 0xf6, 0x74, \ + 0x07, 0x12, 0x4d, 0x7b, 0x51, 0x99, 0x1f, 0x7a, 0x56, 0xe9, 0x20, 0x2f, \ + 0x18, 0x34, 0x29, 0x97, 0xdb, 0x06, 0xee, 0xeb, 0xbf, 0xbd, 0x31, 0x4f, \ + 0xfa, 0x50, 0xb1, 0xba, 0x49, 0xb3, 0xc4, 0x1d, 0x03, 0xae, 0xb0, 0xdc, \ + 0xbe, 0x8a, 0xc4, 0x90, 0xa3, 0x28, 0x9b, 0xb6, 0x42, 0x09, 0x1b, 0xd6, \ + 0x29, 0x9b, 0x19, 0xe9, 0x87, 0x87, 0xd9, 0x9f, 0x35, 0x05, 0xab, 0x91, \ + 0x8f, 0x6d, 0x7c, 0x91, 0x02, 0x81, 0x81, 0x00, 0x94, 0x57, 0xf0, 0xe0, \ + 0x28, 0xfd, 0xbd, 0xf3, 0x9c, 0x43, 0x4d, 0x3e, 0xfd, 0x37, 0x4f, 0x23, \ + 0x52, 0x8d, 0xe1, 0x4c, 0xfe, 0x4c, 0x55, 0x80, 0x82, 0xba, 0x3f, 0xfe, \ + 0x51, 0xe1, 0x30, 0xd5, 0x3b, 0xd9, 0x73, 0x1d, 0xcb, 0x25, 0xbc, 0xbb, \ + 0x3f, 0xa5, 0xda, 0x77, 0xa6, 0xb5, 0xfc, 0x1a, 0xaf, 0x79, 0xa1, 0xb2, \ + 0x14, 0xa2, 0x1f, 0x10, 0x52, 0x1a, 0x05, 0x40, 0x48, 0xb6, 0x4f, 0x34, \ + 0xd6, 0xc0, 0xc3, 0xa4, 0x36, 0x98, 0x73, 0x88, 0x0b, 0xd3, 0x45, 0xdc, \ + 0xee, 0x51, 0x6e, 0x04, 0x73, 0x99, 0x93, 0x12, 0x58, 0x96, 0xcb, 0x39, \ + 0x42, 0xb1, 0xa9, 0xb8, 0xe1, 0x25, 0xf5, 0x9c, 0x14, 0xb7, 0x92, 0x2b, \ + 0x14, 0xb0, 0x5d, 0x61, 0xa2, 0xaa, 0x34, 0x7c, 0xcd, 0x54, 0x2d, 0x69, \ + 0x08, 0xf7, 0xdb, 0xfc, 0x9c, 0x87, 0xe8, 0x3a, 0xf6, 0x1d, 0x4c, 0x6a, \ + 0x83, 0x15, 0x30, 0x01, 0x02, 0x81, 0x81, 0x00, 0x9c, 0x53, 0xa1, 0xb6, \ + 0x2f, 0xc0, 0x06, 0xf5, 0xdf, 0x5c, 0xd1, 0x4a, 0x4e, 0xc8, 0xbd, 0x6d, \ + 0x32, 0xf1, 0x5e, 0xe5, 0x3b, 0x70, 0xd0, 0xa8, 0xe5, 0x41, 0x57, 0x6c, \ + 0x87, 0x53, 0x0f, 0xeb, 0x28, 0xa0, 0x62, 0x8f, 0x43, 0x62, 0xec, 0x2e, \ + 0x6c, 0x71, 0x55, 0x5b, 0x6a, 0xf4, 0x74, 0x14, 0xea, 0x7a, 0x03, 0xf6, \ + 0xfc, 0xa4, 0xce, 0xc4, 0xac, 0xda, 0x1d, 0xf0, 0xb5, 0xa9, 0xfd, 0x11, \ + 0x18, 0x3b, 0x14, 0xa0, 0x90, 0x8d, 0x26, 0xb7, 0x75, 0x73, 0x0a, 0x02, \ + 0x2c, 0x6f, 0x0f, 0xd8, 0x41, 0x78, 0xc3, 0x73, 0x81, 0xac, 0xaa, 0xaf, \ + 0xf2, 0xee, 0x32, 0xb5, 0x8d, 0x05, 0xf9, 0x59, 0x5a, 0x9e, 0x3e, 0x65, \ + 0x9b, 0x74, 0xda, 0xa0, 0x74, 0x95, 0x17, 0x5f, 0x8d, 0x58, 0xfc, 0x8e, \ + 0x4e, 0x2c, 0x1e, 0xbc, 0x81, 0x02, 0x18, 0xac, 0x12, 0xc6, 0xf9, 0x64, \ + 0x8b, 0x87, 0xc3, 0x00 \ +} +/* END FILE */ + +/* + * + * Test certificates and keys as C variables + * + */ + +/* + * CA + */ + +const char mbedtls_test_ca_crt_ec_pem[] = TEST_CA_CRT_EC_PEM; +const char mbedtls_test_ca_key_ec_pem[] = TEST_CA_KEY_EC_PEM; +const char mbedtls_test_ca_pwd_ec_pem[] = TEST_CA_PWD_EC_PEM; +const char mbedtls_test_ca_key_rsa_pem[] = TEST_CA_KEY_RSA_PEM; +const char mbedtls_test_ca_pwd_rsa_pem[] = TEST_CA_PWD_RSA_PEM; +const char mbedtls_test_ca_crt_rsa_sha1_pem[] = TEST_CA_CRT_RSA_SHA1_PEM; +const char mbedtls_test_ca_crt_rsa_sha256_pem[] = TEST_CA_CRT_RSA_SHA256_PEM; + +const unsigned char mbedtls_test_ca_crt_ec_der[] = TEST_CA_CRT_EC_DER; +const unsigned char mbedtls_test_ca_key_ec_der[] = TEST_CA_KEY_EC_DER; +const unsigned char mbedtls_test_ca_key_rsa_der[] = TEST_CA_KEY_RSA_DER; +const unsigned char mbedtls_test_ca_crt_rsa_sha1_der[] = + TEST_CA_CRT_RSA_SHA1_DER; +const unsigned char mbedtls_test_ca_crt_rsa_sha256_der[] = + TEST_CA_CRT_RSA_SHA256_DER; + +const size_t mbedtls_test_ca_crt_ec_pem_len = + sizeof( mbedtls_test_ca_crt_ec_pem ); +const size_t mbedtls_test_ca_key_ec_pem_len = + sizeof( mbedtls_test_ca_key_ec_pem ); +const size_t mbedtls_test_ca_pwd_ec_pem_len = + sizeof( mbedtls_test_ca_pwd_ec_pem ) - 1; +const size_t mbedtls_test_ca_key_rsa_pem_len = + sizeof( mbedtls_test_ca_key_rsa_pem ); +const size_t mbedtls_test_ca_pwd_rsa_pem_len = + sizeof( mbedtls_test_ca_pwd_rsa_pem ) - 1; +const size_t mbedtls_test_ca_crt_rsa_sha1_pem_len = + sizeof( mbedtls_test_ca_crt_rsa_sha1_pem ); +const size_t mbedtls_test_ca_crt_rsa_sha256_pem_len = + sizeof( mbedtls_test_ca_crt_rsa_sha256_pem ); + +const size_t mbedtls_test_ca_crt_ec_der_len = + sizeof( mbedtls_test_ca_crt_ec_der ); +const size_t mbedtls_test_ca_key_ec_der_len = + sizeof( mbedtls_test_ca_key_ec_der ); +const size_t mbedtls_test_ca_pwd_ec_der_len = 0; +const size_t mbedtls_test_ca_key_rsa_der_len = + sizeof( mbedtls_test_ca_key_rsa_der ); +const size_t mbedtls_test_ca_pwd_rsa_der_len = 0; +const size_t mbedtls_test_ca_crt_rsa_sha1_der_len = + sizeof( mbedtls_test_ca_crt_rsa_sha1_der ); +const size_t mbedtls_test_ca_crt_rsa_sha256_der_len = + sizeof( mbedtls_test_ca_crt_rsa_sha256_der ); + +/* + * Server + */ + +const char mbedtls_test_srv_crt_ec_pem[] = TEST_SRV_CRT_EC_PEM; +const char mbedtls_test_srv_key_ec_pem[] = TEST_SRV_KEY_EC_PEM; +const char mbedtls_test_srv_pwd_ec_pem[] = ""; +const char mbedtls_test_srv_key_rsa_pem[] = TEST_SRV_KEY_RSA_PEM; +const char mbedtls_test_srv_pwd_rsa_pem[] = ""; +const char mbedtls_test_srv_crt_rsa_sha1_pem[] = TEST_SRV_CRT_RSA_SHA1_PEM; +const char mbedtls_test_srv_crt_rsa_sha256_pem[] = TEST_SRV_CRT_RSA_SHA256_PEM; + +const unsigned char mbedtls_test_srv_crt_ec_der[] = TEST_SRV_CRT_EC_DER; +const unsigned char mbedtls_test_srv_key_ec_der[] = TEST_SRV_KEY_EC_DER; +const unsigned char mbedtls_test_srv_key_rsa_der[] = TEST_SRV_KEY_RSA_DER; +const unsigned char mbedtls_test_srv_crt_rsa_sha1_der[] = + TEST_SRV_CRT_RSA_SHA1_DER; +const unsigned char mbedtls_test_srv_crt_rsa_sha256_der[] = + TEST_SRV_CRT_RSA_SHA256_DER; + +const size_t mbedtls_test_srv_crt_ec_pem_len = + sizeof( mbedtls_test_srv_crt_ec_pem ); +const size_t mbedtls_test_srv_key_ec_pem_len = + sizeof( mbedtls_test_srv_key_ec_pem ); +const size_t mbedtls_test_srv_pwd_ec_pem_len = + sizeof( mbedtls_test_srv_pwd_ec_pem ) - 1; +const size_t mbedtls_test_srv_key_rsa_pem_len = + sizeof( mbedtls_test_srv_key_rsa_pem ); +const size_t mbedtls_test_srv_pwd_rsa_pem_len = + sizeof( mbedtls_test_srv_pwd_rsa_pem ) - 1; +const size_t mbedtls_test_srv_crt_rsa_sha1_pem_len = + sizeof( mbedtls_test_srv_crt_rsa_sha1_pem ); +const size_t mbedtls_test_srv_crt_rsa_sha256_pem_len = + sizeof( mbedtls_test_srv_crt_rsa_sha256_pem ); + +const size_t mbedtls_test_srv_crt_ec_der_len = + sizeof( mbedtls_test_srv_crt_ec_der ); +const size_t mbedtls_test_srv_key_ec_der_len = + sizeof( mbedtls_test_srv_key_ec_der ); +const size_t mbedtls_test_srv_pwd_ec_der_len = 0; +const size_t mbedtls_test_srv_key_rsa_der_len = + sizeof( mbedtls_test_srv_key_rsa_der ); +const size_t mbedtls_test_srv_pwd_rsa_der_len = 0; +const size_t mbedtls_test_srv_crt_rsa_sha1_der_len = + sizeof( mbedtls_test_srv_crt_rsa_sha1_der ); +const size_t mbedtls_test_srv_crt_rsa_sha256_der_len = + sizeof( mbedtls_test_srv_crt_rsa_sha256_der ); + +/* + * Client + */ + +const char mbedtls_test_cli_crt_ec_pem[] = TEST_CLI_CRT_EC_PEM; +const char mbedtls_test_cli_key_ec_pem[] = TEST_CLI_KEY_EC_PEM; +const char mbedtls_test_cli_pwd_ec_pem[] = ""; +const char mbedtls_test_cli_key_rsa_pem[] = TEST_CLI_KEY_RSA_PEM; +const char mbedtls_test_cli_pwd_rsa_pem[] = ""; +const char mbedtls_test_cli_crt_rsa_pem[] = TEST_CLI_CRT_RSA_PEM; + +const unsigned char mbedtls_test_cli_crt_ec_der[] = TEST_CLI_CRT_EC_DER; +const unsigned char mbedtls_test_cli_key_ec_der[] = TEST_CLI_KEY_EC_DER; +const unsigned char mbedtls_test_cli_key_rsa_der[] = TEST_CLI_KEY_RSA_DER; +const unsigned char mbedtls_test_cli_crt_rsa_der[] = TEST_CLI_CRT_RSA_DER; + +const size_t mbedtls_test_cli_crt_ec_pem_len = + sizeof( mbedtls_test_cli_crt_ec_pem ); +const size_t mbedtls_test_cli_key_ec_pem_len = + sizeof( mbedtls_test_cli_key_ec_pem ); +const size_t mbedtls_test_cli_pwd_ec_pem_len = + sizeof( mbedtls_test_cli_pwd_ec_pem ) - 1; +const size_t mbedtls_test_cli_key_rsa_pem_len = + sizeof( mbedtls_test_cli_key_rsa_pem ); +const size_t mbedtls_test_cli_pwd_rsa_pem_len = + sizeof( mbedtls_test_cli_pwd_rsa_pem ) - 1; +const size_t mbedtls_test_cli_crt_rsa_pem_len = + sizeof( mbedtls_test_cli_crt_rsa_pem ); + +const size_t mbedtls_test_cli_crt_ec_der_len = + sizeof( mbedtls_test_cli_crt_ec_der ); +const size_t mbedtls_test_cli_key_ec_der_len = + sizeof( mbedtls_test_cli_key_ec_der ); +const size_t mbedtls_test_cli_key_rsa_der_len = + sizeof( mbedtls_test_cli_key_rsa_der ); +const size_t mbedtls_test_cli_crt_rsa_der_len = + sizeof( mbedtls_test_cli_crt_rsa_der ); + +/* + * + * Definitions of test CRTs without specification of all parameters, choosing + * them automatically according to the config. For example, mbedtls_test_ca_crt + * is one of mbedtls_test_ca_crt_{rsa|ec}_{sha1|sha256}_{pem|der}. + * + */ + +/* + * Dispatch between PEM and DER according to config + */ + +#if defined(MBEDTLS_PEM_PARSE_C) + +/* PEM encoded test CA certificates and keys */ + +#define TEST_CA_KEY_RSA TEST_CA_KEY_RSA_PEM +#define TEST_CA_PWD_RSA TEST_CA_PWD_RSA_PEM +#define TEST_CA_CRT_RSA_SHA256 TEST_CA_CRT_RSA_SHA256_PEM +#define TEST_CA_CRT_RSA_SHA1 TEST_CA_CRT_RSA_SHA1_PEM +#define TEST_CA_KEY_EC TEST_CA_KEY_EC_PEM +#define TEST_CA_PWD_EC TEST_CA_PWD_EC_PEM +#define TEST_CA_CRT_EC TEST_CA_CRT_EC_PEM + +/* PEM encoded test server certificates and keys */ + +#define TEST_SRV_KEY_RSA TEST_SRV_KEY_RSA_PEM +#define TEST_SRV_PWD_RSA "" +#define TEST_SRV_CRT_RSA_SHA256 TEST_SRV_CRT_RSA_SHA256_PEM +#define TEST_SRV_CRT_RSA_SHA1 TEST_SRV_CRT_RSA_SHA1_PEM +#define TEST_SRV_KEY_EC TEST_SRV_KEY_EC_PEM +#define TEST_SRV_PWD_EC "" +#define TEST_SRV_CRT_EC TEST_SRV_CRT_EC_PEM + +/* PEM encoded test client certificates and keys */ + +#define TEST_CLI_KEY_RSA TEST_CLI_KEY_RSA_PEM +#define TEST_CLI_PWD_RSA "" +#define TEST_CLI_CRT_RSA TEST_CLI_CRT_RSA_PEM +#define TEST_CLI_KEY_EC TEST_CLI_KEY_EC_PEM +#define TEST_CLI_PWD_EC "" +#define TEST_CLI_CRT_EC TEST_CLI_CRT_EC_PEM + +#else /* MBEDTLS_PEM_PARSE_C */ + +/* DER encoded test CA certificates and keys */ + +#define TEST_CA_KEY_RSA TEST_CA_KEY_RSA_DER +#define TEST_CA_PWD_RSA "" +#define TEST_CA_CRT_RSA_SHA256 TEST_CA_CRT_RSA_SHA256_DER +#define TEST_CA_CRT_RSA_SHA1 TEST_CA_CRT_RSA_SHA1_DER +#define TEST_CA_KEY_EC TEST_CA_KEY_EC_DER +#define TEST_CA_PWD_EC "" +#define TEST_CA_CRT_EC TEST_CA_CRT_EC_DER + +/* DER encoded test server certificates and keys */ + +#define TEST_SRV_KEY_RSA TEST_SRV_KEY_RSA_DER +#define TEST_SRV_PWD_RSA "" +#define TEST_SRV_CRT_RSA_SHA256 TEST_SRV_CRT_RSA_SHA256_DER +#define TEST_SRV_CRT_RSA_SHA1 TEST_SRV_CRT_RSA_SHA1_DER +#define TEST_SRV_KEY_EC TEST_SRV_KEY_EC_DER +#define TEST_SRV_PWD_EC "" +#define TEST_SRV_CRT_EC TEST_SRV_CRT_EC_DER + +/* DER encoded test client certificates and keys */ + +#define TEST_CLI_KEY_RSA TEST_CLI_KEY_RSA_DER +#define TEST_CLI_PWD_RSA "" +#define TEST_CLI_CRT_RSA TEST_CLI_CRT_RSA_DER +#define TEST_CLI_KEY_EC TEST_CLI_KEY_EC_DER +#define TEST_CLI_PWD_EC "" +#define TEST_CLI_CRT_EC TEST_CLI_CRT_EC_DER + +#endif /* MBEDTLS_PEM_PARSE_C */ + +const char mbedtls_test_ca_key_rsa[] = TEST_CA_KEY_RSA; +const char mbedtls_test_ca_pwd_rsa[] = TEST_CA_PWD_RSA; +const char mbedtls_test_ca_crt_rsa_sha256[] = TEST_CA_CRT_RSA_SHA256; +const char mbedtls_test_ca_crt_rsa_sha1[] = TEST_CA_CRT_RSA_SHA1; +const char mbedtls_test_ca_key_ec[] = TEST_CA_KEY_EC; +const char mbedtls_test_ca_pwd_ec[] = TEST_CA_PWD_EC; +const char mbedtls_test_ca_crt_ec[] = TEST_CA_CRT_EC; + +const char mbedtls_test_srv_key_rsa[] = TEST_SRV_KEY_RSA; +const char mbedtls_test_srv_pwd_rsa[] = TEST_SRV_PWD_RSA; +const char mbedtls_test_srv_crt_rsa_sha256[] = TEST_SRV_CRT_RSA_SHA256; +const char mbedtls_test_srv_crt_rsa_sha1[] = TEST_SRV_CRT_RSA_SHA1; +const char mbedtls_test_srv_key_ec[] = TEST_SRV_KEY_EC; +const char mbedtls_test_srv_pwd_ec[] = TEST_SRV_PWD_EC; +const char mbedtls_test_srv_crt_ec[] = TEST_SRV_CRT_EC; + +const char mbedtls_test_cli_key_rsa[] = TEST_CLI_KEY_RSA; +const char mbedtls_test_cli_pwd_rsa[] = TEST_CLI_PWD_RSA; +const char mbedtls_test_cli_crt_rsa[] = TEST_CLI_CRT_RSA; +const char mbedtls_test_cli_key_ec[] = TEST_CLI_KEY_EC; +const char mbedtls_test_cli_pwd_ec[] = TEST_CLI_PWD_EC; +const char mbedtls_test_cli_crt_ec[] = TEST_CLI_CRT_EC; + +const size_t mbedtls_test_ca_key_rsa_len = + sizeof( mbedtls_test_ca_key_rsa ); +const size_t mbedtls_test_ca_pwd_rsa_len = + sizeof( mbedtls_test_ca_pwd_rsa ) - 1; +const size_t mbedtls_test_ca_crt_rsa_sha256_len = + sizeof( mbedtls_test_ca_crt_rsa_sha256 ); +const size_t mbedtls_test_ca_crt_rsa_sha1_len = + sizeof( mbedtls_test_ca_crt_rsa_sha1 ); +const size_t mbedtls_test_ca_key_ec_len = + sizeof( mbedtls_test_ca_key_ec ); +const size_t mbedtls_test_ca_pwd_ec_len = + sizeof( mbedtls_test_ca_pwd_ec ) - 1; +const size_t mbedtls_test_ca_crt_ec_len = + sizeof( mbedtls_test_ca_crt_ec ); + +const size_t mbedtls_test_srv_key_rsa_len = + sizeof( mbedtls_test_srv_key_rsa ); +const size_t mbedtls_test_srv_pwd_rsa_len = + sizeof( mbedtls_test_srv_pwd_rsa ) -1; +const size_t mbedtls_test_srv_crt_rsa_sha256_len = + sizeof( mbedtls_test_srv_crt_rsa_sha256 ); +const size_t mbedtls_test_srv_crt_rsa_sha1_len = + sizeof( mbedtls_test_srv_crt_rsa_sha1 ); +const size_t mbedtls_test_srv_key_ec_len = + sizeof( mbedtls_test_srv_key_ec ); +const size_t mbedtls_test_srv_pwd_ec_len = + sizeof( mbedtls_test_srv_pwd_ec ) - 1; +const size_t mbedtls_test_srv_crt_ec_len = + sizeof( mbedtls_test_srv_crt_ec ); + +const size_t mbedtls_test_cli_key_rsa_len = + sizeof( mbedtls_test_cli_key_rsa ); +const size_t mbedtls_test_cli_pwd_rsa_len = + sizeof( mbedtls_test_cli_pwd_rsa ) - 1; +const size_t mbedtls_test_cli_crt_rsa_len = + sizeof( mbedtls_test_cli_crt_rsa ); +const size_t mbedtls_test_cli_key_ec_len = + sizeof( mbedtls_test_cli_key_ec ); +const size_t mbedtls_test_cli_pwd_ec_len = + sizeof( mbedtls_test_cli_pwd_ec ) - 1; +const size_t mbedtls_test_cli_crt_ec_len = + sizeof( mbedtls_test_cli_crt_ec ); + +/* + * Dispatch between SHA-1 and SHA-256 + */ #if defined(MBEDTLS_SHA256_C) -#define TEST_CA_CRT_RSA_SHA256 \ -"-----BEGIN CERTIFICATE-----\r\n" \ -"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n" \ -"MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ -"MTcwNTA0MTY1NzAxWhcNMjcwNTA1MTY1NzAxWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \ -"A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \ -"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \ -"mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \ -"50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" \ -"YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" \ -"R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" \ -"KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" \ -"gZUwgZIwHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/MGMGA1UdIwRcMFqA\r\n" \ -"FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE\r\n" \ -"CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T\r\n" \ -"BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAHK/HHrTZMnnVMpde1io+voAtql7j\r\n" \ -"4sRhLrjD7o3THtwRbDa2diCvpq0Sq23Ng2LMYoXsOxoL/RQK3iN7UKxV3MKPEr0w\r\n" \ -"XQS+kKQqiT2bsfrjnWMVHZtUOMpm6FNqcdGm/Rss3vKda2lcKl8kUnq/ylc1+QbB\r\n" \ -"G6A6tUvQcr2ZyWfVg+mM5XkhTrOOXus2OLikb4WwEtJTJRNE0f+yPODSUz0/vT57\r\n" \ -"ApH0CnB80bYJshYHPHHymOtleAB8KSYtqm75g/YNobjnjB6cm4HkW3OZRVIl6fYY\r\n" \ -"n20NRVA1Vjs6GAROr4NqW4k/+LofY9y0LLDE+p0oIEKXIsIvhPr39swxSA==\r\n" \ -"-----END CERTIFICATE-----\r\n" - -const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA_SHA256; -const size_t mbedtls_test_ca_crt_rsa_len = sizeof( mbedtls_test_ca_crt_rsa ); -#define TEST_CA_CRT_RSA_SOME - -static const char mbedtls_test_ca_crt_rsa_sha256[] = TEST_CA_CRT_RSA_SHA256; +#define TEST_CA_CRT_RSA TEST_CA_CRT_RSA_SHA256 +#define TEST_SRV_CRT_RSA TEST_SRV_CRT_RSA_SHA256 +#else +#define TEST_CA_CRT_RSA TEST_CA_CRT_RSA_SHA1 +#define TEST_SRV_CRT_RSA TEST_SRV_CRT_RSA_SHA1 +#endif /* MBEDTLS_SHA256_C */ -#endif +const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA; +const char mbedtls_test_srv_crt_rsa[] = TEST_SRV_CRT_RSA; -#if !defined(TEST_CA_CRT_RSA_SOME) || defined(MBEDTLS_SHA1_C) -#define TEST_CA_CRT_RSA_SHA1 \ -"-----BEGIN CERTIFICATE-----\r\n" \ -"MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" \ -"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" \ -"MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G\r\n" \ -"A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G\r\n" \ -"CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx\r\n" \ -"mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny\r\n" \ -"50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n\r\n" \ -"YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL\r\n" \ -"R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu\r\n" \ -"KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj\r\n" \ -"gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH\r\n" \ -"/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV\r\n" \ -"BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz\r\n" \ -"dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ\r\n" \ -"SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H\r\n" \ -"DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF\r\n" \ -"pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf\r\n" \ -"m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ\r\n" \ -"7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA==\r\n" \ -"-----END CERTIFICATE-----\r\n" - -#if !defined (TEST_CA_CRT_RSA_SOME) -const char mbedtls_test_ca_crt_rsa[] = TEST_CA_CRT_RSA_SHA1; -const size_t mbedtls_test_ca_crt_rsa_len = sizeof( mbedtls_test_ca_crt_rsa ); -#endif +const size_t mbedtls_test_ca_crt_rsa_len = + sizeof( mbedtls_test_ca_crt_rsa ); +const size_t mbedtls_test_srv_crt_rsa_len = + sizeof( mbedtls_test_srv_crt_rsa ); -static const char mbedtls_test_ca_crt_rsa_sha1[] = TEST_CA_CRT_RSA_SHA1; +/* + * Dispatch between RSA and EC + */ -#endif +#if defined(MBEDTLS_RSA_C) + +#define TEST_CA_KEY TEST_CA_KEY_RSA +#define TEST_CA_PWD TEST_CA_PWD_RSA +#define TEST_CA_CRT TEST_CA_CRT_RSA + +#define TEST_SRV_KEY TEST_SRV_KEY_RSA +#define TEST_SRV_PWD TEST_SRV_PWD_RSA +#define TEST_SRV_CRT TEST_SRV_CRT_RSA + +#define TEST_CLI_KEY TEST_CLI_KEY_RSA +#define TEST_CLI_PWD TEST_CLI_PWD_RSA +#define TEST_CLI_CRT TEST_CLI_CRT_RSA + +#else /* no RSA, so assume ECDSA */ + +#define TEST_CA_KEY TEST_CA_KEY_EC +#define TEST_CA_PWD TEST_CA_PWD_EC +#define TEST_CA_CRT TEST_CA_CRT_EC + +#define TEST_SRV_KEY TEST_SRV_KEY_EC +#define TEST_SRV_PWD TEST_SRV_PWD_EC +#define TEST_SRV_CRT TEST_SRV_CRT_EC + +#define TEST_CLI_KEY TEST_CLI_KEY_EC +#define TEST_CLI_PWD TEST_CLI_PWD_EC +#define TEST_CLI_CRT TEST_CLI_CRT_EC -const char mbedtls_test_ca_key_rsa[] = -"-----BEGIN RSA PRIVATE KEY-----\r\n" -"Proc-Type: 4,ENCRYPTED\r\n" -"DEK-Info: DES-EDE3-CBC,A8A95B05D5B7206B\r\n" -"\r\n" -"9Qd9GeArejl1GDVh2lLV1bHt0cPtfbh5h/5zVpAVaFpqtSPMrElp50Rntn9et+JA\r\n" -"7VOyboR+Iy2t/HU4WvA687k3Bppe9GwKHjHhtl//8xFKwZr3Xb5yO5JUP8AUctQq\r\n" -"Nb8CLlZyuUC+52REAAthdWgsX+7dJO4yabzUcQ22Tp9JSD0hiL43BlkWYUNK3dAo\r\n" -"PZlmiptjnzVTjg1MxsBSydZinWOLBV8/JQgxSPo2yD4uEfig28qbvQ2wNIn0pnAb\r\n" -"GxnSAOazkongEGfvcjIIs+LZN9gXFhxcOh6kc4Q/c99B7QWETwLLkYgZ+z1a9VY9\r\n" -"gEU7CwCxYCD+h9hY6FPmsK0/lC4O7aeRKpYq00rPPxs6i7phiexg6ax6yTMmArQq\r\n" -"QmK3TAsJm8V/J5AWpLEV6jAFgRGymGGHnof0DXzVWZidrcZJWTNuGEX90nB3ee2w\r\n" -"PXJEFWKoD3K3aFcSLdHYr3mLGxP7H9ThQai9VsycxZKS5kwvBKQ//YMrmFfwPk8x\r\n" -"vTeY4KZMaUrveEel5tWZC94RSMKgxR6cyE1nBXyTQnDOGbfpNNgBKxyKbINWoOJU\r\n" -"WJZAwlsQn+QzCDwpri7+sV1mS3gBE6UY7aQmnmiiaC2V3Hbphxct/en5QsfDOt1X\r\n" -"JczSfpRWLlbPznZg8OQh/VgCMA58N5DjOzTIK7sJJ5r+94ZBTCpgAMbF588f0NTR\r\n" -"KCe4yrxGJR7X02M4nvD4IwOlpsQ8xQxZtOSgXv4LkxvdU9XJJKWZ/XNKJeWztxSe\r\n" -"Z1vdTc2YfsDBA2SEv33vxHx2g1vqtw8SjDRT2RaQSS0QuSaMJimdOX6mTOCBKk1J\r\n" -"9Q5mXTrER+/LnK0jEmXsBXWA5bqqVZIyahXSx4VYZ7l7w/PHiUDtDgyRhMMKi4n2\r\n" -"iQvQcWSQTjrpnlJbca1/DkpRt3YwrvJwdqb8asZU2VrNETh5x0QVefDRLFiVpif/\r\n" -"tUaeAe/P1F8OkS7OIZDs1SUbv/sD2vMbhNkUoCms3/PvNtdnvgL4F0zhaDpKCmlT\r\n" -"P8vx49E7v5CyRNmED9zZg4o3wmMqrQO93PtTug3Eu9oVx1zPQM1NVMyBa2+f29DL\r\n" -"1nuTCeXdo9+ni45xx+jAI4DCwrRdhJ9uzZyC6962H37H6D+5naNvClFR1s6li1Gb\r\n" -"nqPoiy/OBsEx9CaDGcqQBp5Wme/3XW+6z1ISOx+igwNTVCT14mHdBMbya0eIKft5\r\n" -"X+GnwtgEMyCYyyWuUct8g4RzErcY9+yW9Om5Hzpx4zOuW4NPZgPDTgK+t2RSL/Yq\r\n" -"rE1njrgeGYcVeG3f+OftH4s6fPbq7t1A5ZgUscbLMBqr9tK+OqygR4EgKBPsH6Cz\r\n" -"L6zlv/2RV0qAHvVuDJcIDIgwY5rJtINEm32rhOeFNJwZS5MNIC1czXZx5//ugX7l\r\n" -"I4sy5nbVhwSjtAk8Xg5dZbdTZ6mIrb7xqH+fdakZor1khG7bC2uIwibD3cSl2XkR\r\n" -"wN48lslbHnqqagr6Xm1nNOSVl8C/6kbJEsMpLhAezfRtGwvOucoaE+WbeUNolGde\r\n" -"P/eQiddSf0brnpiLJRh7qZrl9XuqYdpUqnoEdMAfotDOID8OtV7gt8a48ad8VPW2\r\n" -"-----END RSA PRIVATE KEY-----\r\n"; -const size_t mbedtls_test_ca_key_rsa_len = sizeof( mbedtls_test_ca_key_rsa ); - -const char mbedtls_test_ca_pwd_rsa[] = "PolarSSLTest"; -const size_t mbedtls_test_ca_pwd_rsa_len = sizeof( mbedtls_test_ca_pwd_rsa ) - 1; - -const char mbedtls_test_srv_crt_rsa[] = -"-----BEGIN CERTIFICATE-----\r\n" -"MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER\r\n" -"MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" -"MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G\r\n" -"A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN\r\n" -"AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN\r\n" -"owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz\r\n" -"NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM\r\n" -"tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P\r\n" -"hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya\r\n" -"HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD\r\n" -"VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw\r\n" -"FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQADggEBAJxnXClY\r\n" -"oHkbp70cqBrsGXLybA74czbO5RdLEgFs7rHVS9r+c293luS/KdliLScZqAzYVylw\r\n" -"UfRWvKMoWhHYKp3dEIS4xTXk6/5zXxhv9Rw8SGc8qn6vITHk1S1mPevtekgasY5Y\r\n" -"iWQuM3h4YVlRH3HHEMAD1TnAexfXHHDFQGe+Bd1iAbz1/sH9H8l4StwX6egvTK3M\r\n" -"wXRwkKkvjKaEDA9ATbZx0mI8LGsxSuCqe9r9dyjmttd47J1p1Rulz3CLzaRcVIuS\r\n" -"RRQfaD8neM9c1S/iJ/amTVqJxA1KOdOS5780WhPfSArA+g4qAmSjelc3p4wWpha8\r\n" -"zhuYwjVuX6JHG0c=\r\n" -"-----END CERTIFICATE-----\r\n"; -const size_t mbedtls_test_srv_crt_rsa_len = sizeof( mbedtls_test_srv_crt_rsa ); - -const char mbedtls_test_srv_key_rsa[] = -"-----BEGIN RSA PRIVATE KEY-----\r\n" -"MIIEpAIBAAKCAQEAwU2j3efNHdEE10lyuJmsDnjkOjxKzzoTFtBa5M2jAIin7h5r\r\n" -"lqdStJDvLXJ6PiSa/LY0rCT1d+AmZIycsCh9odrqjObJHJa8/sEEUrM21KP64bF2\r\n" -"2JDBYbRmUjaiJlOqq3ReB30Zgtsq2B+g2Q0cLUlm91slc0boC4pPaQy1AJDh2oIQ\r\n" -"Zn2uVCuLZXmRoeJhw81ASQjuaAzxi4bSRr/QuKoRAx5/VqgaHkQYDw+Fi9qLRF7i\r\n" -"GMZiL8dmjfpd2H3zJ4kpAcWQDj8n8TDISg7v1t7HxydrxwU9esQCPJodPg/oNJhb\r\n" -"y3NLUpbYEaIsgIhpOVrTD7DeWS8Rx/fqEgEwlwIDAQABAoIBAQCXR0S8EIHFGORZ\r\n" -"++AtOg6eENxD+xVs0f1IeGz57Tjo3QnXX7VBZNdj+p1ECvhCE/G7XnkgU5hLZX+G\r\n" -"Z0jkz/tqJOI0vRSdLBbipHnWouyBQ4e/A1yIJdlBtqXxJ1KE/ituHRbNc4j4kL8Z\r\n" -"/r6pvwnTI0PSx2Eqs048YdS92LT6qAv4flbNDxMn2uY7s4ycS4Q8w1JXnCeaAnYm\r\n" -"WYI5wxO+bvRELR2Mcz5DmVnL8jRyml6l6582bSv5oufReFIbyPZbQWlXgYnpu6He\r\n" -"GTc7E1zKYQGG/9+DQUl/1vQuCPqQwny0tQoX2w5tdYpdMdVm+zkLtbajzdTviJJa\r\n" -"TWzL6lt5AoGBAN86+SVeJDcmQJcv4Eq6UhtRr4QGMiQMz0Sod6ettYxYzMgxtw28\r\n" -"CIrgpozCc+UaZJLo7UxvC6an85r1b2nKPCLQFaggJ0H4Q0J/sZOhBIXaoBzWxveK\r\n" -"nupceKdVxGsFi8CDy86DBfiyFivfBj+47BbaQzPBj7C4rK7UlLjab2rDAoGBAN2u\r\n" -"AM2gchoFiu4v1HFL8D7lweEpi6ZnMJjnEu/dEgGQJFjwdpLnPbsj4c75odQ4Gz8g\r\n" -"sw9lao9VVzbusoRE/JGI4aTdO0pATXyG7eG1Qu+5Yc1YGXcCrliA2xM9xx+d7f+s\r\n" -"mPzN+WIEg5GJDYZDjAzHG5BNvi/FfM1C9dOtjv2dAoGAF0t5KmwbjWHBhcVqO4Ic\r\n" -"BVvN3BIlc1ue2YRXEDlxY5b0r8N4XceMgKmW18OHApZxfl8uPDauWZLXOgl4uepv\r\n" -"whZC3EuWrSyyICNhLY21Ah7hbIEBPF3L3ZsOwC+UErL+dXWLdB56Jgy3gZaBeW7b\r\n" -"vDrEnocJbqCm7IukhXHOBK8CgYEAwqdHB0hqyNSzIOGY7v9abzB6pUdA3BZiQvEs\r\n" -"3LjHVd4HPJ2x0N8CgrBIWOE0q8+0hSMmeE96WW/7jD3fPWwCR5zlXknxBQsfv0gP\r\n" -"3BC5PR0Qdypz+d+9zfMf625kyit4T/hzwhDveZUzHnk1Cf+IG7Q+TOEnLnWAWBED\r\n" -"ISOWmrUCgYAFEmRxgwAc/u+D6t0syCwAYh6POtscq9Y0i9GyWk89NzgC4NdwwbBH\r\n" -"4AgahOxIxXx2gxJnq3yfkJfIjwf0s2DyP0kY2y6Ua1OeomPeY9mrIS4tCuDQ6LrE\r\n" -"TB6l9VGoxJL4fyHnZb8L5gGvnB1bbD8cL6YPaDiOhcRseC9vBiEuVg==\r\n" -"-----END RSA PRIVATE KEY-----\r\n"; -const size_t mbedtls_test_srv_key_rsa_len = sizeof( mbedtls_test_srv_key_rsa ); - -const char mbedtls_test_cli_crt_rsa[] = -"-----BEGIN CERTIFICATE-----\r\n" -"MIIDhTCCAm2gAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER\r\n" -"MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN\r\n" -"MTcwNTA1MTMwNzU5WhcNMjcwNTA2MTMwNzU5WjA8MQswCQYDVQQGEwJOTDERMA8G\r\n" -"A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN\r\n" -"BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f\r\n" -"M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu\r\n" -"1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw\r\n" -"MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v\r\n" -"4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/\r\n" -"/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB\r\n" -"o4GSMIGPMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITBjBgNVHSMEXDBa\r\n" -"gBS0WuSls97SUva51aaVD+s+vMf9/6E/pD0wOzELMAkGA1UEBhMCTkwxETAPBgNV\r\n" -"BAoMCFBvbGFyU1NMMRkwFwYDVQQDDBBQb2xhclNTTCBUZXN0IENBggEAMAkGA1Ud\r\n" -"EwQCMAAwDQYJKoZIhvcNAQELBQADggEBAC7yO786NvcHpK8UovKIG9cB32oSQQom\r\n" -"LoR0eHDRzdqEkoq7yGZufHFiRAAzbMqJfogRtxlrWAeB4y/jGaMBV25IbFOIcH2W\r\n" -"iCEaMMbG+VQLKNvuC63kmw/Zewc9ThM6Pa1Hcy0axT0faf1B/U01j0FIcw/6mTfK\r\n" -"D8w48OIwc1yr0JtutCVjig5DC0yznGMt32RyseOLcUe+lfq005v2PAiCozr5X8rE\r\n" -"ofGZpiM2NqRPePgYy+Vc75Zk28xkRQq1ncprgQb3S4vTsZdScpM9hLf+eMlrgqlj\r\n" -"c5PLSkXBeLE5+fedkyfTaLxxQlgCpuoOhKBm04/R1pWNzUHyqagjO9Q=\r\n" -"-----END CERTIFICATE-----\r\n"; -const size_t mbedtls_test_cli_crt_rsa_len = sizeof( mbedtls_test_cli_crt_rsa ); - -const char mbedtls_test_cli_key_rsa[] = -"-----BEGIN RSA PRIVATE KEY-----\r\n" -"MIIEpAIBAAKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6fM60Nj4o8VmXl3ETZzGaF\r\n" -"B9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu1C93KYRhTYJQj6eVSHD1\r\n" -"bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEwMjDV0/YI0FZPRo7yX/k9\r\n" -"Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v4Jv4EFbMs44TFeY0BGbH\r\n" -"7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx//DZrtenNLQNiTrM9AM+v\r\n" -"dqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQABAoIBAGdNtfYDiap6bzst\r\n" -"yhCiI8m9TtrhZw4MisaEaN/ll3XSjaOG2dvV6xMZCMV+5TeXDHOAZnY18Yi18vzz\r\n" -"4Ut2TnNFzizCECYNaA2fST3WgInnxUkV3YXAyP6CNxJaCmv2aA0yFr2kFVSeaKGt\r\n" -"ymvljNp2NVkvm7Th8fBQBO7I7AXhz43k0mR7XmPgewe8ApZOG3hstkOaMvbWAvWA\r\n" -"zCZupdDjZYjOJqlA4eEA4H8/w7F83r5CugeBE8LgEREjLPiyejrU5H1fubEY+h0d\r\n" -"l5HZBJ68ybTXfQ5U9o/QKA3dd0toBEhhdRUDGzWtjvwkEQfqF1reGWj/tod/gCpf\r\n" -"DFi6X0ECgYEA4wOv/pjSC3ty6TuOvKX2rOUiBrLXXv2JSxZnMoMiWI5ipLQt+RYT\r\n" -"VPafL/m7Dn6MbwjayOkcZhBwk5CNz5A6Q4lJ64Mq/lqHznRCQQ2Mc1G8eyDF/fYL\r\n" -"Ze2pLvwP9VD5jTc2miDfw+MnvJhywRRLcemDFP8k4hQVtm8PMp3ZmNECgYEA4gz7\r\n" -"wzObR4gn8ibe617uQPZjWzUj9dUHYd+in1gwBCIrtNnaRn9I9U/Q6tegRYpii4ys\r\n" -"c176NmU+umy6XmuSKV5qD9bSpZWG2nLFnslrN15Lm3fhZxoeMNhBaEDTnLT26yoi\r\n" -"33gp0mSSWy94ZEqipms+ULF6sY1ZtFW6tpGFoy8CgYAQHhnnvJflIs2ky4q10B60\r\n" -"ZcxFp3rtDpkp0JxhFLhiizFrujMtZSjYNm5U7KkgPVHhLELEUvCmOnKTt4ap/vZ0\r\n" -"BxJNe1GZH3pW6SAvGDQpl9sG7uu/vTFP+lCxukmzxB0DrrDcvorEkKMom7ZCCRvW\r\n" -"KZsZ6YeH2Z81BauRj218kQKBgQCUV/DgKP2985xDTT79N08jUo3hTP5MVYCCuj/+\r\n" -"UeEw1TvZcx3LJby7P6Xad6a1/BqveaGyFKIfEFIaBUBItk801sDDpDaYc4gL00Xc\r\n" -"7lFuBHOZkxJYlss5QrGpuOEl9ZwUt5IrFLBdYaKqNHzNVC1pCPfb/JyH6Dr2HUxq\r\n" -"gxUwAQKBgQCcU6G2L8AG9d9c0UpOyL1tMvFe5Ttw0KjlQVdsh1MP6yigYo9DYuwu\r\n" -"bHFVW2r0dBTqegP2/KTOxKzaHfC1qf0RGDsUoJCNJrd1cwoCLG8P2EF4w3OBrKqv\r\n" -"8u4ytY0F+Vlanj5lm3TaoHSVF1+NWPyOTiwevIECGKwSxvlki4fDAA==\r\n" -"-----END RSA PRIVATE KEY-----\r\n"; -const size_t mbedtls_test_cli_key_rsa_len = sizeof( mbedtls_test_cli_key_rsa ); #endif /* MBEDTLS_RSA_C */ -#if defined(MBEDTLS_PEM_PARSE_C) -/* Concatenation of all available CA certificates */ -const char mbedtls_test_cas_pem[] = -#ifdef TEST_CA_CRT_RSA_SHA1 - TEST_CA_CRT_RSA_SHA1 -#endif -#ifdef TEST_CA_CRT_RSA_SHA256 - TEST_CA_CRT_RSA_SHA256 -#endif -#ifdef TEST_CA_CRT_EC - TEST_CA_CRT_EC -#endif - ""; -const size_t mbedtls_test_cas_pem_len = sizeof( mbedtls_test_cas_pem ); -#endif +/* API stability forces us to declare + * mbedtls_test_{ca|srv|cli}_{key|pwd|crt} + * as pointers. */ +static const char test_ca_key[] = TEST_CA_KEY; +static const char test_ca_pwd[] = TEST_CA_PWD; +static const char test_ca_crt[] = TEST_CA_CRT; + +static const char test_srv_key[] = TEST_SRV_KEY; +static const char test_srv_pwd[] = TEST_SRV_PWD; +static const char test_srv_crt[] = TEST_SRV_CRT; + +static const char test_cli_key[] = TEST_CLI_KEY; +static const char test_cli_pwd[] = TEST_CLI_PWD; +static const char test_cli_crt[] = TEST_CLI_CRT; + +const char *mbedtls_test_ca_key = test_ca_key; +const char *mbedtls_test_ca_pwd = test_ca_pwd; +const char *mbedtls_test_ca_crt = test_ca_crt; + +const char *mbedtls_test_srv_key = test_srv_key; +const char *mbedtls_test_srv_pwd = test_srv_pwd; +const char *mbedtls_test_srv_crt = test_srv_crt; + +const char *mbedtls_test_cli_key = test_cli_key; +const char *mbedtls_test_cli_pwd = test_cli_pwd; +const char *mbedtls_test_cli_crt = test_cli_crt; + +const size_t mbedtls_test_ca_key_len = + sizeof( test_ca_key ); +const size_t mbedtls_test_ca_pwd_len = + sizeof( test_ca_pwd ) - 1; +const size_t mbedtls_test_ca_crt_len = + sizeof( test_ca_crt ); -/* List of all available CA certificates */ +const size_t mbedtls_test_srv_key_len = + sizeof( test_srv_key ); +const size_t mbedtls_test_srv_pwd_len = + sizeof( test_srv_pwd ) - 1; +const size_t mbedtls_test_srv_crt_len = + sizeof( test_srv_crt ); + +const size_t mbedtls_test_cli_key_len = + sizeof( test_cli_key ); +const size_t mbedtls_test_cli_pwd_len = + sizeof( test_cli_pwd ) - 1; +const size_t mbedtls_test_cli_crt_len = + sizeof( test_cli_crt ); + +/* + * + * Lists of certificates + * + */ + +/* List of CAs in PEM or DER, depending on config */ const char * mbedtls_test_cas[] = { -#if defined(TEST_CA_CRT_RSA_SHA1) +#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA1_C) mbedtls_test_ca_crt_rsa_sha1, #endif -#if defined(TEST_CA_CRT_RSA_SHA256) +#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) mbedtls_test_ca_crt_rsa_sha256, #endif #if defined(MBEDTLS_ECDSA_C) @@ -356,10 +1704,10 @@ const char * mbedtls_test_cas[] = { NULL }; const size_t mbedtls_test_cas_len[] = { -#if defined(TEST_CA_CRT_RSA_SHA1) +#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA1_C) sizeof( mbedtls_test_ca_crt_rsa_sha1 ), #endif -#if defined(TEST_CA_CRT_RSA_SHA256) +#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) sizeof( mbedtls_test_ca_crt_rsa_sha256 ), #endif #if defined(MBEDTLS_ECDSA_C) @@ -368,36 +1716,53 @@ const size_t mbedtls_test_cas_len[] = { 0 }; +/* List of all available CA certificates in DER format */ +const unsigned char * mbedtls_test_cas_der[] = { #if defined(MBEDTLS_RSA_C) -const char *mbedtls_test_ca_crt = mbedtls_test_ca_crt_rsa; /* SHA1 or SHA256 */ -const char *mbedtls_test_ca_key = mbedtls_test_ca_key_rsa; -const char *mbedtls_test_ca_pwd = mbedtls_test_ca_pwd_rsa; -const char *mbedtls_test_srv_crt = mbedtls_test_srv_crt_rsa; -const char *mbedtls_test_srv_key = mbedtls_test_srv_key_rsa; -const char *mbedtls_test_cli_crt = mbedtls_test_cli_crt_rsa; -const char *mbedtls_test_cli_key = mbedtls_test_cli_key_rsa; -const size_t mbedtls_test_ca_crt_len = sizeof( mbedtls_test_ca_crt_rsa ); -const size_t mbedtls_test_ca_key_len = sizeof( mbedtls_test_ca_key_rsa ); -const size_t mbedtls_test_ca_pwd_len = sizeof( mbedtls_test_ca_pwd_rsa ) - 1; -const size_t mbedtls_test_srv_crt_len = sizeof( mbedtls_test_srv_crt_rsa ); -const size_t mbedtls_test_srv_key_len = sizeof( mbedtls_test_srv_key_rsa ); -const size_t mbedtls_test_cli_crt_len = sizeof( mbedtls_test_cli_crt_rsa ); -const size_t mbedtls_test_cli_key_len = sizeof( mbedtls_test_cli_key_rsa ); -#else /* ! MBEDTLS_RSA_C, so MBEDTLS_ECDSA_C */ -const char *mbedtls_test_ca_crt = mbedtls_test_ca_crt_ec; -const char *mbedtls_test_ca_key = mbedtls_test_ca_key_ec; -const char *mbedtls_test_ca_pwd = mbedtls_test_ca_pwd_ec; -const char *mbedtls_test_srv_crt = mbedtls_test_srv_crt_ec; -const char *mbedtls_test_srv_key = mbedtls_test_srv_key_ec; -const char *mbedtls_test_cli_crt = mbedtls_test_cli_crt_ec; -const char *mbedtls_test_cli_key = mbedtls_test_cli_key_ec; -const size_t mbedtls_test_ca_crt_len = sizeof( mbedtls_test_ca_crt_ec ); -const size_t mbedtls_test_ca_key_len = sizeof( mbedtls_test_ca_key_ec ); -const size_t mbedtls_test_ca_pwd_len = sizeof( mbedtls_test_ca_pwd_ec ) - 1; -const size_t mbedtls_test_srv_crt_len = sizeof( mbedtls_test_srv_crt_ec ); -const size_t mbedtls_test_srv_key_len = sizeof( mbedtls_test_srv_key_ec ); -const size_t mbedtls_test_cli_crt_len = sizeof( mbedtls_test_cli_crt_ec ); -const size_t mbedtls_test_cli_key_len = sizeof( mbedtls_test_cli_key_ec ); +#if defined(MBEDTLS_SHA256_C) + mbedtls_test_ca_crt_rsa_sha256_der, +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA1_C) + mbedtls_test_ca_crt_rsa_sha1_der, +#endif /* MBEDTLS_SHA1_C */ #endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECDSA_C) + mbedtls_test_ca_crt_ec_der, +#endif /* MBEDTLS_ECDSA_C */ + NULL +}; + +const size_t mbedtls_test_cas_der_len[] = { +#if defined(MBEDTLS_RSA_C) +#if defined(MBEDTLS_SHA256_C) + sizeof( mbedtls_test_ca_crt_rsa_sha256_der ), +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA1_C) + sizeof( mbedtls_test_ca_crt_rsa_sha1_der ), +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECDSA_C) + sizeof( mbedtls_test_ca_crt_ec_der ), +#endif /* MBEDTLS_ECDSA_C */ + 0 +}; + +/* Concatenation of all available CA certificates in PEM format */ +#if defined(MBEDTLS_PEM_PARSE_C) +const char mbedtls_test_cas_pem[] = +#if defined(MBEDTLS_RSA_C) +#if defined(MBEDTLS_SHA256_C) + TEST_CA_CRT_RSA_SHA256_PEM +#endif /* MBEDTLS_SHA256_C */ +#if defined(MBEDTLS_SHA1_C) + TEST_CA_CRT_RSA_SHA1_PEM +#endif /* MBEDTLS_SHA1_C */ +#endif /* MBEDTLS_RSA_C */ +#if defined(MBEDTLS_ECDSA_C) + TEST_CA_CRT_EC_PEM +#endif /* MBEDTLS_ECDSA_C */ + ""; +const size_t mbedtls_test_cas_pem_len = sizeof( mbedtls_test_cas_pem ); +#endif /* MBEDTLS_PEM_PARSE_C */ #endif /* MBEDTLS_CERTS_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/chacha20.c b/3rdparty/mbedtls/mbedtls/library/chacha20.c new file mode 100644 index 0000000000..8a3610f0e0 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/chacha20.c @@ -0,0 +1,570 @@ +/** + * \file chacha20.c + * + * \brief ChaCha20 cipher. + * + * \author Daniel King + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CHACHA20_C) + +#include "mbedtls/chacha20.h" +#include "mbedtls/platform_util.h" + +#include +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_CHACHA20_ALT) + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +/* Parameter validation macros */ +#define CHACHA20_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA ) +#define CHACHA20_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +#define BYTES_TO_U32_LE( data, offset ) \ + ( (uint32_t) (data)[offset] \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ + ) + +#define ROTL32( value, amount ) \ + ( (uint32_t) ( (value) << (amount) ) | ( (value) >> ( 32 - (amount) ) ) ) + +#define CHACHA20_CTR_INDEX ( 12U ) + +#define CHACHA20_BLOCK_SIZE_BYTES ( 4U * 16U ) + +/** + * \brief ChaCha20 quarter round operation. + * + * The quarter round is defined as follows (from RFC 7539): + * 1. a += b; d ^= a; d <<<= 16; + * 2. c += d; b ^= c; b <<<= 12; + * 3. a += b; d ^= a; d <<<= 8; + * 4. c += d; b ^= c; b <<<= 7; + * + * \param state ChaCha20 state to modify. + * \param a The index of 'a' in the state. + * \param b The index of 'b' in the state. + * \param c The index of 'c' in the state. + * \param d The index of 'd' in the state. + */ +static inline void chacha20_quarter_round( uint32_t state[16], + size_t a, + size_t b, + size_t c, + size_t d ) +{ + /* a += b; d ^= a; d <<<= 16; */ + state[a] += state[b]; + state[d] ^= state[a]; + state[d] = ROTL32( state[d], 16 ); + + /* c += d; b ^= c; b <<<= 12 */ + state[c] += state[d]; + state[b] ^= state[c]; + state[b] = ROTL32( state[b], 12 ); + + /* a += b; d ^= a; d <<<= 8; */ + state[a] += state[b]; + state[d] ^= state[a]; + state[d] = ROTL32( state[d], 8 ); + + /* c += d; b ^= c; b <<<= 7; */ + state[c] += state[d]; + state[b] ^= state[c]; + state[b] = ROTL32( state[b], 7 ); +} + +/** + * \brief Perform the ChaCha20 inner block operation. + * + * This function performs two rounds: the column round and the + * diagonal round. + * + * \param state The ChaCha20 state to update. + */ +static void chacha20_inner_block( uint32_t state[16] ) +{ + chacha20_quarter_round( state, 0, 4, 8, 12 ); + chacha20_quarter_round( state, 1, 5, 9, 13 ); + chacha20_quarter_round( state, 2, 6, 10, 14 ); + chacha20_quarter_round( state, 3, 7, 11, 15 ); + + chacha20_quarter_round( state, 0, 5, 10, 15 ); + chacha20_quarter_round( state, 1, 6, 11, 12 ); + chacha20_quarter_round( state, 2, 7, 8, 13 ); + chacha20_quarter_round( state, 3, 4, 9, 14 ); +} + +/** + * \brief Generates a keystream block. + * + * \param initial_state The initial ChaCha20 state (key, nonce, counter). + * \param keystream Generated keystream bytes are written to this buffer. + */ +static void chacha20_block( const uint32_t initial_state[16], + unsigned char keystream[64] ) +{ + uint32_t working_state[16]; + size_t i; + + memcpy( working_state, + initial_state, + CHACHA20_BLOCK_SIZE_BYTES ); + + for( i = 0U; i < 10U; i++ ) + chacha20_inner_block( working_state ); + + working_state[ 0] += initial_state[ 0]; + working_state[ 1] += initial_state[ 1]; + working_state[ 2] += initial_state[ 2]; + working_state[ 3] += initial_state[ 3]; + working_state[ 4] += initial_state[ 4]; + working_state[ 5] += initial_state[ 5]; + working_state[ 6] += initial_state[ 6]; + working_state[ 7] += initial_state[ 7]; + working_state[ 8] += initial_state[ 8]; + working_state[ 9] += initial_state[ 9]; + working_state[10] += initial_state[10]; + working_state[11] += initial_state[11]; + working_state[12] += initial_state[12]; + working_state[13] += initial_state[13]; + working_state[14] += initial_state[14]; + working_state[15] += initial_state[15]; + + for( i = 0U; i < 16; i++ ) + { + size_t offset = i * 4U; + + keystream[offset ] = (unsigned char)( working_state[i] ); + keystream[offset + 1U] = (unsigned char)( working_state[i] >> 8 ); + keystream[offset + 2U] = (unsigned char)( working_state[i] >> 16 ); + keystream[offset + 3U] = (unsigned char)( working_state[i] >> 24 ); + } + + mbedtls_platform_zeroize( working_state, sizeof( working_state ) ); +} + +void mbedtls_chacha20_init( mbedtls_chacha20_context *ctx ) +{ + CHACHA20_VALIDATE( ctx != NULL ); + + mbedtls_platform_zeroize( ctx->state, sizeof( ctx->state ) ); + mbedtls_platform_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) ); + + /* Initially, there's no keystream bytes available */ + ctx->keystream_bytes_used = CHACHA20_BLOCK_SIZE_BYTES; +} + +void mbedtls_chacha20_free( mbedtls_chacha20_context *ctx ) +{ + if( ctx != NULL ) + { + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_chacha20_context ) ); + } +} + +int mbedtls_chacha20_setkey( mbedtls_chacha20_context *ctx, + const unsigned char key[32] ) +{ + CHACHA20_VALIDATE_RET( ctx != NULL ); + CHACHA20_VALIDATE_RET( key != NULL ); + + /* ChaCha20 constants - the string "expand 32-byte k" */ + ctx->state[0] = 0x61707865; + ctx->state[1] = 0x3320646e; + ctx->state[2] = 0x79622d32; + ctx->state[3] = 0x6b206574; + + /* Set key */ + ctx->state[4] = BYTES_TO_U32_LE( key, 0 ); + ctx->state[5] = BYTES_TO_U32_LE( key, 4 ); + ctx->state[6] = BYTES_TO_U32_LE( key, 8 ); + ctx->state[7] = BYTES_TO_U32_LE( key, 12 ); + ctx->state[8] = BYTES_TO_U32_LE( key, 16 ); + ctx->state[9] = BYTES_TO_U32_LE( key, 20 ); + ctx->state[10] = BYTES_TO_U32_LE( key, 24 ); + ctx->state[11] = BYTES_TO_U32_LE( key, 28 ); + + return( 0 ); +} + +int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx, + const unsigned char nonce[12], + uint32_t counter ) +{ + CHACHA20_VALIDATE_RET( ctx != NULL ); + CHACHA20_VALIDATE_RET( nonce != NULL ); + + /* Counter */ + ctx->state[12] = counter; + + /* Nonce */ + ctx->state[13] = BYTES_TO_U32_LE( nonce, 0 ); + ctx->state[14] = BYTES_TO_U32_LE( nonce, 4 ); + ctx->state[15] = BYTES_TO_U32_LE( nonce, 8 ); + + mbedtls_platform_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) ); + + /* Initially, there's no keystream bytes available */ + ctx->keystream_bytes_used = CHACHA20_BLOCK_SIZE_BYTES; + + return( 0 ); +} + +int mbedtls_chacha20_update( mbedtls_chacha20_context *ctx, + size_t size, + const unsigned char *input, + unsigned char *output ) +{ + size_t offset = 0U; + size_t i; + + CHACHA20_VALIDATE_RET( ctx != NULL ); + CHACHA20_VALIDATE_RET( size == 0 || input != NULL ); + CHACHA20_VALIDATE_RET( size == 0 || output != NULL ); + + /* Use leftover keystream bytes, if available */ + while( size > 0U && ctx->keystream_bytes_used < CHACHA20_BLOCK_SIZE_BYTES ) + { + output[offset] = input[offset] + ^ ctx->keystream8[ctx->keystream_bytes_used]; + + ctx->keystream_bytes_used++; + offset++; + size--; + } + + /* Process full blocks */ + while( size >= CHACHA20_BLOCK_SIZE_BYTES ) + { + /* Generate new keystream block and increment counter */ + chacha20_block( ctx->state, ctx->keystream8 ); + ctx->state[CHACHA20_CTR_INDEX]++; + + for( i = 0U; i < 64U; i += 8U ) + { + output[offset + i ] = input[offset + i ] ^ ctx->keystream8[i ]; + output[offset + i+1] = input[offset + i+1] ^ ctx->keystream8[i+1]; + output[offset + i+2] = input[offset + i+2] ^ ctx->keystream8[i+2]; + output[offset + i+3] = input[offset + i+3] ^ ctx->keystream8[i+3]; + output[offset + i+4] = input[offset + i+4] ^ ctx->keystream8[i+4]; + output[offset + i+5] = input[offset + i+5] ^ ctx->keystream8[i+5]; + output[offset + i+6] = input[offset + i+6] ^ ctx->keystream8[i+6]; + output[offset + i+7] = input[offset + i+7] ^ ctx->keystream8[i+7]; + } + + offset += CHACHA20_BLOCK_SIZE_BYTES; + size -= CHACHA20_BLOCK_SIZE_BYTES; + } + + /* Last (partial) block */ + if( size > 0U ) + { + /* Generate new keystream block and increment counter */ + chacha20_block( ctx->state, ctx->keystream8 ); + ctx->state[CHACHA20_CTR_INDEX]++; + + for( i = 0U; i < size; i++) + { + output[offset + i] = input[offset + i] ^ ctx->keystream8[i]; + } + + ctx->keystream_bytes_used = size; + + } + + return( 0 ); +} + +int mbedtls_chacha20_crypt( const unsigned char key[32], + const unsigned char nonce[12], + uint32_t counter, + size_t data_len, + const unsigned char* input, + unsigned char* output ) +{ + mbedtls_chacha20_context ctx; + int ret; + + CHACHA20_VALIDATE_RET( key != NULL ); + CHACHA20_VALIDATE_RET( nonce != NULL ); + CHACHA20_VALIDATE_RET( data_len == 0 || input != NULL ); + CHACHA20_VALIDATE_RET( data_len == 0 || output != NULL ); + + mbedtls_chacha20_init( &ctx ); + + ret = mbedtls_chacha20_setkey( &ctx, key ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_chacha20_starts( &ctx, nonce, counter ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_chacha20_update( &ctx, data_len, input, output ); + +cleanup: + mbedtls_chacha20_free( &ctx ); + return( ret ); +} + +#endif /* !MBEDTLS_CHACHA20_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +static const unsigned char test_keys[2][32] = +{ + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 + } +}; + +static const unsigned char test_nonces[2][12] = +{ + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }, + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02 + } +}; + +static const uint32_t test_counters[2] = +{ + 0U, + 1U +}; + +static const unsigned char test_input[2][375] = +{ + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + }, + { + 0x41, 0x6e, 0x79, 0x20, 0x73, 0x75, 0x62, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74, + 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x49, 0x45, + 0x54, 0x46, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x6e, + 0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x20, 0x66, + 0x6f, 0x72, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, + 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x72, + 0x20, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6f, 0x66, + 0x20, 0x61, 0x6e, 0x20, 0x49, 0x45, 0x54, 0x46, + 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x20, + 0x6f, 0x72, 0x20, 0x52, 0x46, 0x43, 0x20, 0x61, + 0x6e, 0x64, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x77, 0x69, + 0x74, 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, + 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, + 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x49, + 0x45, 0x54, 0x46, 0x20, 0x61, 0x63, 0x74, 0x69, + 0x76, 0x69, 0x74, 0x79, 0x20, 0x69, 0x73, 0x20, + 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72, + 0x65, 0x64, 0x20, 0x61, 0x6e, 0x20, 0x22, 0x49, + 0x45, 0x54, 0x46, 0x20, 0x43, 0x6f, 0x6e, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x22, 0x2e, 0x20, 0x53, 0x75, 0x63, 0x68, 0x20, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, + 0x64, 0x65, 0x20, 0x6f, 0x72, 0x61, 0x6c, 0x20, + 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45, + 0x54, 0x46, 0x20, 0x73, 0x65, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x61, 0x73, 0x20, + 0x77, 0x65, 0x6c, 0x6c, 0x20, 0x61, 0x73, 0x20, + 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, + 0x61, 0x6e, 0x64, 0x20, 0x65, 0x6c, 0x65, 0x63, + 0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63, 0x20, 0x63, + 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61, + 0x64, 0x65, 0x20, 0x61, 0x74, 0x20, 0x61, 0x6e, + 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x6f, + 0x72, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2c, + 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61, + 0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f + } +}; + +static const unsigned char test_output[2][375] = +{ + { + 0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, + 0x40, 0x5d, 0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, + 0xbd, 0xd2, 0x19, 0xb8, 0xa0, 0x8d, 0xed, 0x1a, + 0xa8, 0x36, 0xef, 0xcc, 0x8b, 0x77, 0x0d, 0xc7, + 0xda, 0x41, 0x59, 0x7c, 0x51, 0x57, 0x48, 0x8d, + 0x77, 0x24, 0xe0, 0x3f, 0xb8, 0xd8, 0x4a, 0x37, + 0x6a, 0x43, 0xb8, 0xf4, 0x15, 0x18, 0xa1, 0x1c, + 0xc3, 0x87, 0xb6, 0x69, 0xb2, 0xee, 0x65, 0x86 + }, + { + 0xa3, 0xfb, 0xf0, 0x7d, 0xf3, 0xfa, 0x2f, 0xde, + 0x4f, 0x37, 0x6c, 0xa2, 0x3e, 0x82, 0x73, 0x70, + 0x41, 0x60, 0x5d, 0x9f, 0x4f, 0x4f, 0x57, 0xbd, + 0x8c, 0xff, 0x2c, 0x1d, 0x4b, 0x79, 0x55, 0xec, + 0x2a, 0x97, 0x94, 0x8b, 0xd3, 0x72, 0x29, 0x15, + 0xc8, 0xf3, 0xd3, 0x37, 0xf7, 0xd3, 0x70, 0x05, + 0x0e, 0x9e, 0x96, 0xd6, 0x47, 0xb7, 0xc3, 0x9f, + 0x56, 0xe0, 0x31, 0xca, 0x5e, 0xb6, 0x25, 0x0d, + 0x40, 0x42, 0xe0, 0x27, 0x85, 0xec, 0xec, 0xfa, + 0x4b, 0x4b, 0xb5, 0xe8, 0xea, 0xd0, 0x44, 0x0e, + 0x20, 0xb6, 0xe8, 0xdb, 0x09, 0xd8, 0x81, 0xa7, + 0xc6, 0x13, 0x2f, 0x42, 0x0e, 0x52, 0x79, 0x50, + 0x42, 0xbd, 0xfa, 0x77, 0x73, 0xd8, 0xa9, 0x05, + 0x14, 0x47, 0xb3, 0x29, 0x1c, 0xe1, 0x41, 0x1c, + 0x68, 0x04, 0x65, 0x55, 0x2a, 0xa6, 0xc4, 0x05, + 0xb7, 0x76, 0x4d, 0x5e, 0x87, 0xbe, 0xa8, 0x5a, + 0xd0, 0x0f, 0x84, 0x49, 0xed, 0x8f, 0x72, 0xd0, + 0xd6, 0x62, 0xab, 0x05, 0x26, 0x91, 0xca, 0x66, + 0x42, 0x4b, 0xc8, 0x6d, 0x2d, 0xf8, 0x0e, 0xa4, + 0x1f, 0x43, 0xab, 0xf9, 0x37, 0xd3, 0x25, 0x9d, + 0xc4, 0xb2, 0xd0, 0xdf, 0xb4, 0x8a, 0x6c, 0x91, + 0x39, 0xdd, 0xd7, 0xf7, 0x69, 0x66, 0xe9, 0x28, + 0xe6, 0x35, 0x55, 0x3b, 0xa7, 0x6c, 0x5c, 0x87, + 0x9d, 0x7b, 0x35, 0xd4, 0x9e, 0xb2, 0xe6, 0x2b, + 0x08, 0x71, 0xcd, 0xac, 0x63, 0x89, 0x39, 0xe2, + 0x5e, 0x8a, 0x1e, 0x0e, 0xf9, 0xd5, 0x28, 0x0f, + 0xa8, 0xca, 0x32, 0x8b, 0x35, 0x1c, 0x3c, 0x76, + 0x59, 0x89, 0xcb, 0xcf, 0x3d, 0xaa, 0x8b, 0x6c, + 0xcc, 0x3a, 0xaf, 0x9f, 0x39, 0x79, 0xc9, 0x2b, + 0x37, 0x20, 0xfc, 0x88, 0xdc, 0x95, 0xed, 0x84, + 0xa1, 0xbe, 0x05, 0x9c, 0x64, 0x99, 0xb9, 0xfd, + 0xa2, 0x36, 0xe7, 0xe8, 0x18, 0xb0, 0x4b, 0x0b, + 0xc3, 0x9c, 0x1e, 0x87, 0x6b, 0x19, 0x3b, 0xfe, + 0x55, 0x69, 0x75, 0x3f, 0x88, 0x12, 0x8c, 0xc0, + 0x8a, 0xaa, 0x9b, 0x63, 0xd1, 0xa1, 0x6f, 0x80, + 0xef, 0x25, 0x54, 0xd7, 0x18, 0x9c, 0x41, 0x1f, + 0x58, 0x69, 0xca, 0x52, 0xc5, 0xb8, 0x3f, 0xa3, + 0x6f, 0xf2, 0x16, 0xb9, 0xc1, 0xd3, 0x00, 0x62, + 0xbe, 0xbc, 0xfd, 0x2d, 0xc5, 0xbc, 0xe0, 0x91, + 0x19, 0x34, 0xfd, 0xa7, 0x9a, 0x86, 0xf6, 0xe6, + 0x98, 0xce, 0xd7, 0x59, 0xc3, 0xff, 0x9b, 0x64, + 0x77, 0x33, 0x8f, 0x3d, 0xa4, 0xf9, 0xcd, 0x85, + 0x14, 0xea, 0x99, 0x82, 0xcc, 0xaf, 0xb3, 0x41, + 0xb2, 0x38, 0x4d, 0xd9, 0x02, 0xf3, 0xd1, 0xab, + 0x7a, 0xc6, 0x1d, 0xd2, 0x9c, 0x6f, 0x21, 0xba, + 0x5b, 0x86, 0x2f, 0x37, 0x30, 0xe3, 0x7c, 0xfd, + 0xc4, 0xfd, 0x80, 0x6c, 0x22, 0xf2, 0x21 + } +}; + +static const size_t test_lengths[2] = +{ + 64U, + 375U +}; + +#define ASSERT( cond, args ) \ + do \ + { \ + if( ! ( cond ) ) \ + { \ + if( verbose != 0 ) \ + mbedtls_printf args; \ + \ + return( -1 ); \ + } \ + } \ + while( 0 ) + +int mbedtls_chacha20_self_test( int verbose ) +{ + unsigned char output[381]; + unsigned i; + int ret; + + for( i = 0U; i < 2U; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " ChaCha20 test %u ", i ); + + ret = mbedtls_chacha20_crypt( test_keys[i], + test_nonces[i], + test_counters[i], + test_lengths[i], + test_input[i], + output ); + + ASSERT( 0 == ret, ( "error code: %i\n", ret ) ); + + ASSERT( 0 == memcmp( output, test_output[i], test_lengths[i] ), + ( "failed (output)\n" ) ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* !MBEDTLS_CHACHA20_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/chachapoly.c b/3rdparty/mbedtls/mbedtls/library/chachapoly.c new file mode 100644 index 0000000000..dc643dd618 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/chachapoly.c @@ -0,0 +1,540 @@ +/** + * \file chachapoly.c + * + * \brief ChaCha20-Poly1305 AEAD construction based on RFC 7539. + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_CHACHAPOLY_C) + +#include "mbedtls/chachapoly.h" +#include "mbedtls/platform_util.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_CHACHAPOLY_ALT) + +/* Parameter validation macros */ +#define CHACHAPOLY_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA ) +#define CHACHAPOLY_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +#define CHACHAPOLY_STATE_INIT ( 0 ) +#define CHACHAPOLY_STATE_AAD ( 1 ) +#define CHACHAPOLY_STATE_CIPHERTEXT ( 2 ) /* Encrypting or decrypting */ +#define CHACHAPOLY_STATE_FINISHED ( 3 ) + +/** + * \brief Adds nul bytes to pad the AAD for Poly1305. + * + * \param ctx The ChaCha20-Poly1305 context. + */ +static int chachapoly_pad_aad( mbedtls_chachapoly_context *ctx ) +{ + uint32_t partial_block_len = (uint32_t) ( ctx->aad_len % 16U ); + unsigned char zeroes[15]; + + if( partial_block_len == 0U ) + return( 0 ); + + memset( zeroes, 0, sizeof( zeroes ) ); + + return( mbedtls_poly1305_update( &ctx->poly1305_ctx, + zeroes, + 16U - partial_block_len ) ); +} + +/** + * \brief Adds nul bytes to pad the ciphertext for Poly1305. + * + * \param ctx The ChaCha20-Poly1305 context. + */ +static int chachapoly_pad_ciphertext( mbedtls_chachapoly_context *ctx ) +{ + uint32_t partial_block_len = (uint32_t) ( ctx->ciphertext_len % 16U ); + unsigned char zeroes[15]; + + if( partial_block_len == 0U ) + return( 0 ); + + memset( zeroes, 0, sizeof( zeroes ) ); + return( mbedtls_poly1305_update( &ctx->poly1305_ctx, + zeroes, + 16U - partial_block_len ) ); +} + +void mbedtls_chachapoly_init( mbedtls_chachapoly_context *ctx ) +{ + CHACHAPOLY_VALIDATE( ctx != NULL ); + + mbedtls_chacha20_init( &ctx->chacha20_ctx ); + mbedtls_poly1305_init( &ctx->poly1305_ctx ); + ctx->aad_len = 0U; + ctx->ciphertext_len = 0U; + ctx->state = CHACHAPOLY_STATE_INIT; + ctx->mode = MBEDTLS_CHACHAPOLY_ENCRYPT; +} + +void mbedtls_chachapoly_free( mbedtls_chachapoly_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_chacha20_free( &ctx->chacha20_ctx ); + mbedtls_poly1305_free( &ctx->poly1305_ctx ); + ctx->aad_len = 0U; + ctx->ciphertext_len = 0U; + ctx->state = CHACHAPOLY_STATE_INIT; + ctx->mode = MBEDTLS_CHACHAPOLY_ENCRYPT; +} + +int mbedtls_chachapoly_setkey( mbedtls_chachapoly_context *ctx, + const unsigned char key[32] ) +{ + int ret; + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( key != NULL ); + + ret = mbedtls_chacha20_setkey( &ctx->chacha20_ctx, key ); + + return( ret ); +} + +int mbedtls_chachapoly_starts( mbedtls_chachapoly_context *ctx, + const unsigned char nonce[12], + mbedtls_chachapoly_mode_t mode ) +{ + int ret; + unsigned char poly1305_key[64]; + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( nonce != NULL ); + + /* Set counter = 0, will be update to 1 when generating Poly1305 key */ + ret = mbedtls_chacha20_starts( &ctx->chacha20_ctx, nonce, 0U ); + if( ret != 0 ) + goto cleanup; + + /* Generate the Poly1305 key by getting the ChaCha20 keystream output with + * counter = 0. This is the same as encrypting a buffer of zeroes. + * Only the first 256-bits (32 bytes) of the key is used for Poly1305. + * The other 256 bits are discarded. + */ + memset( poly1305_key, 0, sizeof( poly1305_key ) ); + ret = mbedtls_chacha20_update( &ctx->chacha20_ctx, sizeof( poly1305_key ), + poly1305_key, poly1305_key ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_poly1305_starts( &ctx->poly1305_ctx, poly1305_key ); + + if( ret == 0 ) + { + ctx->aad_len = 0U; + ctx->ciphertext_len = 0U; + ctx->state = CHACHAPOLY_STATE_AAD; + ctx->mode = mode; + } + +cleanup: + mbedtls_platform_zeroize( poly1305_key, 64U ); + return( ret ); +} + +int mbedtls_chachapoly_update_aad( mbedtls_chachapoly_context *ctx, + const unsigned char *aad, + size_t aad_len ) +{ + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( aad_len == 0 || aad != NULL ); + + if( ctx->state != CHACHAPOLY_STATE_AAD ) + return( MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + + ctx->aad_len += aad_len; + + return( mbedtls_poly1305_update( &ctx->poly1305_ctx, aad, aad_len ) ); +} + +int mbedtls_chachapoly_update( mbedtls_chachapoly_context *ctx, + size_t len, + const unsigned char *input, + unsigned char *output ) +{ + int ret; + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( len == 0 || input != NULL ); + CHACHAPOLY_VALIDATE_RET( len == 0 || output != NULL ); + + if( ( ctx->state != CHACHAPOLY_STATE_AAD ) && + ( ctx->state != CHACHAPOLY_STATE_CIPHERTEXT ) ) + { + return( MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + } + + if( ctx->state == CHACHAPOLY_STATE_AAD ) + { + ctx->state = CHACHAPOLY_STATE_CIPHERTEXT; + + ret = chachapoly_pad_aad( ctx ); + if( ret != 0 ) + return( ret ); + } + + ctx->ciphertext_len += len; + + if( ctx->mode == MBEDTLS_CHACHAPOLY_ENCRYPT ) + { + ret = mbedtls_chacha20_update( &ctx->chacha20_ctx, len, input, output ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_poly1305_update( &ctx->poly1305_ctx, output, len ); + if( ret != 0 ) + return( ret ); + } + else /* DECRYPT */ + { + ret = mbedtls_poly1305_update( &ctx->poly1305_ctx, input, len ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_chacha20_update( &ctx->chacha20_ctx, len, input, output ); + if( ret != 0 ) + return( ret ); + } + + return( 0 ); +} + +int mbedtls_chachapoly_finish( mbedtls_chachapoly_context *ctx, + unsigned char mac[16] ) +{ + int ret; + unsigned char len_block[16]; + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( mac != NULL ); + + if( ctx->state == CHACHAPOLY_STATE_INIT ) + { + return( MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + } + + if( ctx->state == CHACHAPOLY_STATE_AAD ) + { + ret = chachapoly_pad_aad( ctx ); + if( ret != 0 ) + return( ret ); + } + else if( ctx->state == CHACHAPOLY_STATE_CIPHERTEXT ) + { + ret = chachapoly_pad_ciphertext( ctx ); + if( ret != 0 ) + return( ret ); + } + + ctx->state = CHACHAPOLY_STATE_FINISHED; + + /* The lengths of the AAD and ciphertext are processed by + * Poly1305 as the final 128-bit block, encoded as little-endian integers. + */ + len_block[ 0] = (unsigned char)( ctx->aad_len ); + len_block[ 1] = (unsigned char)( ctx->aad_len >> 8 ); + len_block[ 2] = (unsigned char)( ctx->aad_len >> 16 ); + len_block[ 3] = (unsigned char)( ctx->aad_len >> 24 ); + len_block[ 4] = (unsigned char)( ctx->aad_len >> 32 ); + len_block[ 5] = (unsigned char)( ctx->aad_len >> 40 ); + len_block[ 6] = (unsigned char)( ctx->aad_len >> 48 ); + len_block[ 7] = (unsigned char)( ctx->aad_len >> 56 ); + len_block[ 8] = (unsigned char)( ctx->ciphertext_len ); + len_block[ 9] = (unsigned char)( ctx->ciphertext_len >> 8 ); + len_block[10] = (unsigned char)( ctx->ciphertext_len >> 16 ); + len_block[11] = (unsigned char)( ctx->ciphertext_len >> 24 ); + len_block[12] = (unsigned char)( ctx->ciphertext_len >> 32 ); + len_block[13] = (unsigned char)( ctx->ciphertext_len >> 40 ); + len_block[14] = (unsigned char)( ctx->ciphertext_len >> 48 ); + len_block[15] = (unsigned char)( ctx->ciphertext_len >> 56 ); + + ret = mbedtls_poly1305_update( &ctx->poly1305_ctx, len_block, 16U ); + if( ret != 0 ) + return( ret ); + + ret = mbedtls_poly1305_finish( &ctx->poly1305_ctx, mac ); + + return( ret ); +} + +static int chachapoly_crypt_and_tag( mbedtls_chachapoly_context *ctx, + mbedtls_chachapoly_mode_t mode, + size_t length, + const unsigned char nonce[12], + const unsigned char *aad, + size_t aad_len, + const unsigned char *input, + unsigned char *output, + unsigned char tag[16] ) +{ + int ret; + + ret = mbedtls_chachapoly_starts( ctx, nonce, mode ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_chachapoly_update_aad( ctx, aad, aad_len ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_chachapoly_update( ctx, length, input, output ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_chachapoly_finish( ctx, tag ); + +cleanup: + return( ret ); +} + +int mbedtls_chachapoly_encrypt_and_tag( mbedtls_chachapoly_context *ctx, + size_t length, + const unsigned char nonce[12], + const unsigned char *aad, + size_t aad_len, + const unsigned char *input, + unsigned char *output, + unsigned char tag[16] ) +{ + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( nonce != NULL ); + CHACHAPOLY_VALIDATE_RET( tag != NULL ); + CHACHAPOLY_VALIDATE_RET( aad_len == 0 || aad != NULL ); + CHACHAPOLY_VALIDATE_RET( length == 0 || input != NULL ); + CHACHAPOLY_VALIDATE_RET( length == 0 || output != NULL ); + + return( chachapoly_crypt_and_tag( ctx, MBEDTLS_CHACHAPOLY_ENCRYPT, + length, nonce, aad, aad_len, + input, output, tag ) ); +} + +int mbedtls_chachapoly_auth_decrypt( mbedtls_chachapoly_context *ctx, + size_t length, + const unsigned char nonce[12], + const unsigned char *aad, + size_t aad_len, + const unsigned char tag[16], + const unsigned char *input, + unsigned char *output ) +{ + int ret; + unsigned char check_tag[16]; + size_t i; + int diff; + CHACHAPOLY_VALIDATE_RET( ctx != NULL ); + CHACHAPOLY_VALIDATE_RET( nonce != NULL ); + CHACHAPOLY_VALIDATE_RET( tag != NULL ); + CHACHAPOLY_VALIDATE_RET( aad_len == 0 || aad != NULL ); + CHACHAPOLY_VALIDATE_RET( length == 0 || input != NULL ); + CHACHAPOLY_VALIDATE_RET( length == 0 || output != NULL ); + + if( ( ret = chachapoly_crypt_and_tag( ctx, + MBEDTLS_CHACHAPOLY_DECRYPT, length, nonce, + aad, aad_len, input, output, check_tag ) ) != 0 ) + { + return( ret ); + } + + /* Check tag in "constant-time" */ + for( diff = 0, i = 0; i < sizeof( check_tag ); i++ ) + diff |= tag[i] ^ check_tag[i]; + + if( diff != 0 ) + { + mbedtls_platform_zeroize( output, length ); + return( MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED ); + } + + return( 0 ); +} + +#endif /* MBEDTLS_CHACHAPOLY_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +static const unsigned char test_key[1][32] = +{ + { + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f + } +}; + +static const unsigned char test_nonce[1][12] = +{ + { + 0x07, 0x00, 0x00, 0x00, /* 32-bit common part */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 /* 64-bit IV */ + } +}; + +static const unsigned char test_aad[1][12] = +{ + { + 0x50, 0x51, 0x52, 0x53, 0xc0, 0xc1, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7 + } +}; + +static const size_t test_aad_len[1] = +{ + 12U +}; + +static const unsigned char test_input[1][114] = +{ + { + 0x4c, 0x61, 0x64, 0x69, 0x65, 0x73, 0x20, 0x61, + 0x6e, 0x64, 0x20, 0x47, 0x65, 0x6e, 0x74, 0x6c, + 0x65, 0x6d, 0x65, 0x6e, 0x20, 0x6f, 0x66, 0x20, + 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x61, 0x73, + 0x73, 0x20, 0x6f, 0x66, 0x20, 0x27, 0x39, 0x39, + 0x3a, 0x20, 0x49, 0x66, 0x20, 0x49, 0x20, 0x63, + 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6f, 0x66, 0x66, + 0x65, 0x72, 0x20, 0x79, 0x6f, 0x75, 0x20, 0x6f, + 0x6e, 0x6c, 0x79, 0x20, 0x6f, 0x6e, 0x65, 0x20, + 0x74, 0x69, 0x70, 0x20, 0x66, 0x6f, 0x72, 0x20, + 0x74, 0x68, 0x65, 0x20, 0x66, 0x75, 0x74, 0x75, + 0x72, 0x65, 0x2c, 0x20, 0x73, 0x75, 0x6e, 0x73, + 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x77, 0x6f, + 0x75, 0x6c, 0x64, 0x20, 0x62, 0x65, 0x20, 0x69, + 0x74, 0x2e + } +}; + +static const unsigned char test_output[1][114] = +{ + { + 0xd3, 0x1a, 0x8d, 0x34, 0x64, 0x8e, 0x60, 0xdb, + 0x7b, 0x86, 0xaf, 0xbc, 0x53, 0xef, 0x7e, 0xc2, + 0xa4, 0xad, 0xed, 0x51, 0x29, 0x6e, 0x08, 0xfe, + 0xa9, 0xe2, 0xb5, 0xa7, 0x36, 0xee, 0x62, 0xd6, + 0x3d, 0xbe, 0xa4, 0x5e, 0x8c, 0xa9, 0x67, 0x12, + 0x82, 0xfa, 0xfb, 0x69, 0xda, 0x92, 0x72, 0x8b, + 0x1a, 0x71, 0xde, 0x0a, 0x9e, 0x06, 0x0b, 0x29, + 0x05, 0xd6, 0xa5, 0xb6, 0x7e, 0xcd, 0x3b, 0x36, + 0x92, 0xdd, 0xbd, 0x7f, 0x2d, 0x77, 0x8b, 0x8c, + 0x98, 0x03, 0xae, 0xe3, 0x28, 0x09, 0x1b, 0x58, + 0xfa, 0xb3, 0x24, 0xe4, 0xfa, 0xd6, 0x75, 0x94, + 0x55, 0x85, 0x80, 0x8b, 0x48, 0x31, 0xd7, 0xbc, + 0x3f, 0xf4, 0xde, 0xf0, 0x8e, 0x4b, 0x7a, 0x9d, + 0xe5, 0x76, 0xd2, 0x65, 0x86, 0xce, 0xc6, 0x4b, + 0x61, 0x16 + } +}; + +static const size_t test_input_len[1] = +{ + 114U +}; + +static const unsigned char test_mac[1][16] = +{ + { + 0x1a, 0xe1, 0x0b, 0x59, 0x4f, 0x09, 0xe2, 0x6a, + 0x7e, 0x90, 0x2e, 0xcb, 0xd0, 0x60, 0x06, 0x91 + } +}; + +#define ASSERT( cond, args ) \ + do \ + { \ + if( ! ( cond ) ) \ + { \ + if( verbose != 0 ) \ + mbedtls_printf args; \ + \ + return( -1 ); \ + } \ + } \ + while( 0 ) + +int mbedtls_chachapoly_self_test( int verbose ) +{ + mbedtls_chachapoly_context ctx; + unsigned i; + int ret; + unsigned char output[200]; + unsigned char mac[16]; + + for( i = 0U; i < 1U; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " ChaCha20-Poly1305 test %u ", i ); + + mbedtls_chachapoly_init( &ctx ); + + ret = mbedtls_chachapoly_setkey( &ctx, test_key[i] ); + ASSERT( 0 == ret, ( "setkey() error code: %i\n", ret ) ); + + ret = mbedtls_chachapoly_encrypt_and_tag( &ctx, + test_input_len[i], + test_nonce[i], + test_aad[i], + test_aad_len[i], + test_input[i], + output, + mac ); + + ASSERT( 0 == ret, ( "crypt_and_tag() error code: %i\n", ret ) ); + + ASSERT( 0 == memcmp( output, test_output[i], test_input_len[i] ), + ( "failure (wrong output)\n" ) ); + + ASSERT( 0 == memcmp( mac, test_mac[i], 16U ), + ( "failure (wrong MAC)\n" ) ); + + mbedtls_chachapoly_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_CHACHAPOLY_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/cipher.c b/3rdparty/mbedtls/mbedtls/library/cipher.c index bd39e4f097..273997577b 100644 --- a/3rdparty/mbedtls/mbedtls/library/cipher.c +++ b/3rdparty/mbedtls/mbedtls/library/cipher.c @@ -33,10 +33,15 @@ #include "mbedtls/cipher.h" #include "mbedtls/cipher_internal.h" +#include "mbedtls/platform_util.h" #include #include +#if defined(MBEDTLS_CHACHAPOLY_C) +#include "mbedtls/chachapoly.h" +#endif + #if defined(MBEDTLS_GCM_C) #include "mbedtls/gcm.h" #endif @@ -45,6 +50,10 @@ #include "mbedtls/ccm.h" #endif +#if defined(MBEDTLS_CHACHA20_C) +#include "mbedtls/chacha20.h" +#endif + #if defined(MBEDTLS_CMAC_C) #include "mbedtls/cmac.h" #endif @@ -56,10 +65,30 @@ #define mbedtls_free free #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; +#define CIPHER_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ) +#define CIPHER_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) +/* Compare the contents of two buffers in constant time. + * Returns 0 if the contents are bitwise identical, otherwise returns + * a non-zero value. + * This is currently only used by GCM and ChaCha20+Poly1305. + */ +static int mbedtls_constant_time_memcmp( const void *v1, const void *v2, size_t len ) +{ + const unsigned char *p1 = (const unsigned char*) v1; + const unsigned char *p2 = (const unsigned char*) v2; + size_t i; + unsigned char diff; + + for( diff = 0, i = 0; i < len; i++ ) + diff |= p1[i] ^ p2[i]; + + return( (int)diff ); } +#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ static int supported_init = 0; @@ -126,6 +155,7 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_values( const mbedtls_ciph void mbedtls_cipher_init( mbedtls_cipher_context_t *ctx ) { + CIPHER_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_cipher_context_t ) ); } @@ -137,7 +167,8 @@ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ) #if defined(MBEDTLS_CMAC_C) if( ctx->cmac_ctx ) { - mbedtls_zeroize( ctx->cmac_ctx, sizeof( mbedtls_cmac_context_t ) ); + mbedtls_platform_zeroize( ctx->cmac_ctx, + sizeof( mbedtls_cmac_context_t ) ); mbedtls_free( ctx->cmac_ctx ); } #endif @@ -145,12 +176,13 @@ void mbedtls_cipher_free( mbedtls_cipher_context_t *ctx ) if( ctx->cipher_ctx ) ctx->cipher_info->base->ctx_free_func( ctx->cipher_ctx ); - mbedtls_zeroize( ctx, sizeof(mbedtls_cipher_context_t) ); + mbedtls_platform_zeroize( ctx, sizeof(mbedtls_cipher_context_t) ); } int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_info_t *cipher_info ) { - if( NULL == cipher_info || NULL == ctx ) + CIPHER_VALIDATE_RET( ctx != NULL ); + if( cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); memset( ctx, 0, sizeof( mbedtls_cipher_context_t ) ); @@ -174,10 +206,16 @@ int mbedtls_cipher_setup( mbedtls_cipher_context_t *ctx, const mbedtls_cipher_in return( 0 ); } -int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *key, - int key_bitlen, const mbedtls_operation_t operation ) +int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, + const unsigned char *key, + int key_bitlen, + const mbedtls_operation_t operation ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( key != NULL ); + CIPHER_VALIDATE_RET( operation == MBEDTLS_ENCRYPT || + operation == MBEDTLS_DECRYPT ); + if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); if( ( ctx->cipher_info->flags & MBEDTLS_CIPHER_VARIABLE_KEY_LEN ) == 0 && @@ -190,34 +228,34 @@ int mbedtls_cipher_setkey( mbedtls_cipher_context_t *ctx, const unsigned char *k ctx->operation = operation; /* - * For CFB and CTR mode always use the encryption key schedule + * For OFB, CFB and CTR mode always use the encryption key schedule */ if( MBEDTLS_ENCRYPT == operation || MBEDTLS_MODE_CFB == ctx->cipher_info->mode || + MBEDTLS_MODE_OFB == ctx->cipher_info->mode || MBEDTLS_MODE_CTR == ctx->cipher_info->mode ) { - return ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key, - ctx->key_bitlen ); + return( ctx->cipher_info->base->setkey_enc_func( ctx->cipher_ctx, key, + ctx->key_bitlen ) ); } if( MBEDTLS_DECRYPT == operation ) - return ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key, - ctx->key_bitlen ); + return( ctx->cipher_info->base->setkey_dec_func( ctx->cipher_ctx, key, + ctx->key_bitlen ) ); return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); } int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, - const unsigned char *iv, size_t iv_len ) + const unsigned char *iv, + size_t iv_len ) { size_t actual_iv_size; - if( NULL == ctx || NULL == ctx->cipher_info ) - return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - else if( NULL == iv && iv_len != 0 ) - return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - if( NULL == iv && iv_len == 0 ) - ctx->iv_size = 0; + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( iv_len == 0 || iv != NULL ); + if( ctx->cipher_info == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); /* avoid buffer overflow in ctx->iv */ if( iv_len > MBEDTLS_MAX_IV_LENGTH ) @@ -233,6 +271,19 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, if( actual_iv_size > iv_len ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); } + +#if defined(MBEDTLS_CHACHA20_C) + if ( ctx->cipher_info->type == MBEDTLS_CIPHER_CHACHA20 ) + { + if ( 0 != mbedtls_chacha20_starts( (mbedtls_chacha20_context*)ctx->cipher_ctx, + iv, + 0U ) ) /* Initial counter value */ + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + } +#endif + if ( actual_iv_size != 0 ) { memcpy( ctx->iv, iv, actual_iv_size ); @@ -244,7 +295,8 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx, int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + CIPHER_VALIDATE_RET( ctx != NULL ); + if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); ctx->unprocessed_len = 0; @@ -252,33 +304,60 @@ int mbedtls_cipher_reset( mbedtls_cipher_context_t *ctx ) return( 0 ); } -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) int mbedtls_cipher_update_ad( mbedtls_cipher_context_t *ctx, const unsigned char *ad, size_t ad_len ) { - if( NULL == ctx || NULL == ctx->cipher_info ) + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( ad_len == 0 || ad != NULL ); + if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +#if defined(MBEDTLS_GCM_C) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) { - return mbedtls_gcm_starts( (mbedtls_gcm_context *) ctx->cipher_ctx, ctx->operation, - ctx->iv, ctx->iv_size, ad, ad_len ); + return( mbedtls_gcm_starts( (mbedtls_gcm_context *) ctx->cipher_ctx, ctx->operation, + ctx->iv, ctx->iv_size, ad, ad_len ) ); + } +#endif + +#if defined(MBEDTLS_CHACHAPOLY_C) + if (MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type ) + { + int result; + mbedtls_chachapoly_mode_t mode; + + mode = ( ctx->operation == MBEDTLS_ENCRYPT ) + ? MBEDTLS_CHACHAPOLY_ENCRYPT + : MBEDTLS_CHACHAPOLY_DECRYPT; + + result = mbedtls_chachapoly_starts( (mbedtls_chachapoly_context*) ctx->cipher_ctx, + ctx->iv, + mode ); + if ( result != 0 ) + return( result ); + + return( mbedtls_chachapoly_update_aad( (mbedtls_chachapoly_context*) ctx->cipher_ctx, + ad, ad_len ) ); } +#endif return( 0 ); } -#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen ) { int ret; - size_t block_size = 0; + size_t block_size; - if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen ) - { + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( ilen == 0 || input != NULL ); + CIPHER_VALIDATE_RET( output != NULL ); + CIPHER_VALIDATE_RET( olen != NULL ); + if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - } *olen = 0; block_size = mbedtls_cipher_get_block_size( ctx ); @@ -303,14 +382,23 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i if( ctx->cipher_info->mode == MBEDTLS_MODE_GCM ) { *olen = ilen; - return mbedtls_gcm_update( (mbedtls_gcm_context *) ctx->cipher_ctx, ilen, input, - output ); + return( mbedtls_gcm_update( (mbedtls_gcm_context *) ctx->cipher_ctx, ilen, input, + output ) ); + } +#endif + +#if defined(MBEDTLS_CHACHAPOLY_C) + if ( ctx->cipher_info->type == MBEDTLS_CIPHER_CHACHA20_POLY1305 ) + { + *olen = ilen; + return( mbedtls_chachapoly_update( (mbedtls_chachapoly_context*) ctx->cipher_ctx, + ilen, input, output ) ); } #endif if ( 0 == block_size ) { - return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT; + return( MBEDTLS_ERR_CIPHER_INVALID_CONTEXT ); } if( input == output && @@ -373,7 +461,7 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i { if( 0 == block_size ) { - return MBEDTLS_ERR_CIPHER_INVALID_CONTEXT; + return( MBEDTLS_ERR_CIPHER_INVALID_CONTEXT ); } /* Encryption: only cache partial blocks @@ -429,6 +517,21 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i } #endif /* MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) + if( ctx->cipher_info->mode == MBEDTLS_MODE_OFB ) + { + if( 0 != ( ret = ctx->cipher_info->base->ofb_func( ctx->cipher_ctx, + ilen, &ctx->unprocessed_len, ctx->iv, input, output ) ) ) + { + return( ret ); + } + + *olen = ilen; + + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + #if defined(MBEDTLS_CIPHER_MODE_CTR) if( ctx->cipher_info->mode == MBEDTLS_MODE_CTR ) { @@ -445,6 +548,27 @@ int mbedtls_cipher_update( mbedtls_cipher_context_t *ctx, const unsigned char *i } #endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) + if( ctx->cipher_info->mode == MBEDTLS_MODE_XTS ) + { + if( ctx->unprocessed_len > 0 ) { + /* We can only process an entire data unit at a time. */ + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); + } + + ret = ctx->cipher_info->base->xts_func( ctx->cipher_ctx, + ctx->operation, ilen, ctx->iv, input, output ); + if( ret != 0 ) + { + return( ret ); + } + + *olen = ilen; + + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + #if defined(MBEDTLS_CIPHER_MODE_STREAM) if( ctx->cipher_info->mode == MBEDTLS_MODE_STREAM ) { @@ -638,19 +762,30 @@ static int get_no_padding( unsigned char *input, size_t input_len, int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen ) { - if( NULL == ctx || NULL == ctx->cipher_info || NULL == olen ) + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( output != NULL ); + CIPHER_VALIDATE_RET( olen != NULL ); + if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); *olen = 0; if( MBEDTLS_MODE_CFB == ctx->cipher_info->mode || + MBEDTLS_MODE_OFB == ctx->cipher_info->mode || MBEDTLS_MODE_CTR == ctx->cipher_info->mode || MBEDTLS_MODE_GCM == ctx->cipher_info->mode || + MBEDTLS_MODE_XTS == ctx->cipher_info->mode || MBEDTLS_MODE_STREAM == ctx->cipher_info->mode ) { return( 0 ); } + if ( ( MBEDTLS_CIPHER_CHACHA20 == ctx->cipher_info->type ) || + ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type ) ) + { + return( 0 ); + } + if( MBEDTLS_MODE_ECB == ctx->cipher_info->mode ) { if( ctx->unprocessed_len != 0 ) @@ -700,8 +835,8 @@ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, /* Set output size for decryption */ if( MBEDTLS_DECRYPT == ctx->operation ) - return ctx->get_padding( output, mbedtls_cipher_get_block_size( ctx ), - olen ); + return( ctx->get_padding( output, mbedtls_cipher_get_block_size( ctx ), + olen ) ); /* Set output size for encryption */ *olen = mbedtls_cipher_get_block_size( ctx ); @@ -715,10 +850,12 @@ int mbedtls_cipher_finish( mbedtls_cipher_context_t *ctx, } #if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) -int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_cipher_padding_t mode ) +int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, + mbedtls_cipher_padding_t mode ) { - if( NULL == ctx || - MBEDTLS_MODE_CBC != ctx->cipher_info->mode ) + CIPHER_VALIDATE_RET( ctx != NULL ); + + if( NULL == ctx->cipher_info || MBEDTLS_MODE_CBC != ctx->cipher_info->mode ) { return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); } @@ -762,18 +899,35 @@ int mbedtls_cipher_set_padding_mode( mbedtls_cipher_context_t *ctx, mbedtls_ciph } #endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, unsigned char *tag, size_t tag_len ) { - if( NULL == ctx || NULL == ctx->cipher_info || NULL == tag ) + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL ); + if( ctx->cipher_info == NULL ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); if( MBEDTLS_ENCRYPT != ctx->operation ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +#if defined(MBEDTLS_GCM_C) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) - return mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, tag, tag_len ); + return( mbedtls_gcm_finish( (mbedtls_gcm_context *) ctx->cipher_ctx, + tag, tag_len ) ); +#endif + +#if defined(MBEDTLS_CHACHAPOLY_C) + if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type ) + { + /* Don't allow truncated MAC for Poly1305 */ + if ( tag_len != 16U ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + return( mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx, + tag ) ); + } +#endif return( 0 ); } @@ -781,20 +935,22 @@ int mbedtls_cipher_write_tag( mbedtls_cipher_context_t *ctx, int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, const unsigned char *tag, size_t tag_len ) { + unsigned char check_tag[16]; int ret; - if( NULL == ctx || NULL == ctx->cipher_info || - MBEDTLS_DECRYPT != ctx->operation ) + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL ); + if( ctx->cipher_info == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( MBEDTLS_DECRYPT != ctx->operation ) { return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); } +#if defined(MBEDTLS_GCM_C) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) { - unsigned char check_tag[16]; - size_t i; - int diff; - if( tag_len > sizeof( check_tag ) ) return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); @@ -805,18 +961,38 @@ int mbedtls_cipher_check_tag( mbedtls_cipher_context_t *ctx, } /* Check the tag in "constant-time" */ - for( diff = 0, i = 0; i < tag_len; i++ ) - diff |= tag[i] ^ check_tag[i]; + if( mbedtls_constant_time_memcmp( tag, check_tag, tag_len ) != 0 ) + return( MBEDTLS_ERR_CIPHER_AUTH_FAILED ); + + return( 0 ); + } +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CHACHAPOLY_C) + if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type ) + { + /* Don't allow truncated MAC for Poly1305 */ + if ( tag_len != sizeof( check_tag ) ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - if( diff != 0 ) + ret = mbedtls_chachapoly_finish( (mbedtls_chachapoly_context*) ctx->cipher_ctx, + check_tag ); + if ( ret != 0 ) + { + return( ret ); + } + + /* Check the tag in "constant-time" */ + if( mbedtls_constant_time_memcmp( tag, check_tag, tag_len ) != 0 ) return( MBEDTLS_ERR_CIPHER_AUTH_FAILED ); return( 0 ); } +#endif /* MBEDTLS_CHACHAPOLY_C */ return( 0 ); } -#endif /* MBEDTLS_GCM_C */ +#endif /* MBEDTLS_GCM_C || MBEDTLS_CHACHAPOLY_C */ /* * Packet-oriented wrapper for non-AEAD modes @@ -829,6 +1005,12 @@ int mbedtls_cipher_crypt( mbedtls_cipher_context_t *ctx, int ret; size_t finish_olen; + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( iv_len == 0 || iv != NULL ); + CIPHER_VALIDATE_RET( ilen == 0 || input != NULL ); + CIPHER_VALIDATE_RET( output != NULL ); + CIPHER_VALIDATE_RET( olen != NULL ); + if( ( ret = mbedtls_cipher_set_iv( ctx, iv, iv_len ) ) != 0 ) return( ret ); @@ -857,6 +1039,14 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen, unsigned char *tag, size_t tag_len ) { + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( iv != NULL ); + CIPHER_VALIDATE_RET( ad_len == 0 || ad != NULL ); + CIPHER_VALIDATE_RET( ilen == 0 || input != NULL ); + CIPHER_VALIDATE_RET( output != NULL ); + CIPHER_VALIDATE_RET( olen != NULL ); + CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL ); + #if defined(MBEDTLS_GCM_C) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) { @@ -875,6 +1065,21 @@ int mbedtls_cipher_auth_encrypt( mbedtls_cipher_context_t *ctx, tag, tag_len ) ); } #endif /* MBEDTLS_CCM_C */ +#if defined(MBEDTLS_CHACHAPOLY_C) + if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type ) + { + /* ChachaPoly has fixed length nonce and MAC (tag) */ + if ( ( iv_len != ctx->cipher_info->iv_size ) || + ( tag_len != 16U ) ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + *olen = ilen; + return( mbedtls_chachapoly_encrypt_and_tag( ctx->cipher_ctx, + ilen, iv, ad, ad_len, input, output, tag ) ); + } +#endif /* MBEDTLS_CHACHAPOLY_C */ return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); } @@ -889,6 +1094,14 @@ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, unsigned char *output, size_t *olen, const unsigned char *tag, size_t tag_len ) { + CIPHER_VALIDATE_RET( ctx != NULL ); + CIPHER_VALIDATE_RET( iv != NULL ); + CIPHER_VALIDATE_RET( ad_len == 0 || ad != NULL ); + CIPHER_VALIDATE_RET( ilen == 0 || input != NULL ); + CIPHER_VALIDATE_RET( output != NULL ); + CIPHER_VALIDATE_RET( olen != NULL ); + CIPHER_VALIDATE_RET( tag_len == 0 || tag != NULL ); + #if defined(MBEDTLS_GCM_C) if( MBEDTLS_MODE_GCM == ctx->cipher_info->mode ) { @@ -921,6 +1134,28 @@ int mbedtls_cipher_auth_decrypt( mbedtls_cipher_context_t *ctx, return( ret ); } #endif /* MBEDTLS_CCM_C */ +#if defined(MBEDTLS_CHACHAPOLY_C) + if ( MBEDTLS_CIPHER_CHACHA20_POLY1305 == ctx->cipher_info->type ) + { + int ret; + + /* ChachaPoly has fixed length nonce and MAC (tag) */ + if ( ( iv_len != ctx->cipher_info->iv_size ) || + ( tag_len != 16U ) ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + *olen = ilen; + ret = mbedtls_chachapoly_auth_decrypt( ctx->cipher_ctx, ilen, + iv, ad, ad_len, tag, input, output ); + + if( ret == MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED ) + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + + return( ret ); + } +#endif /* MBEDTLS_CHACHAPOLY_C */ return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); } diff --git a/3rdparty/mbedtls/mbedtls/library/cipher_wrap.c b/3rdparty/mbedtls/mbedtls/library/cipher_wrap.c index dbc5d3fe48..6dd8c5d3a9 100644 --- a/3rdparty/mbedtls/mbedtls/library/cipher_wrap.c +++ b/3rdparty/mbedtls/mbedtls/library/cipher_wrap.c @@ -33,6 +33,10 @@ #include "mbedtls/cipher_internal.h" +#if defined(MBEDTLS_CHACHAPOLY_C) +#include "mbedtls/chachapoly.h" +#endif + #if defined(MBEDTLS_AES_C) #include "mbedtls/aes.h" #endif @@ -45,6 +49,10 @@ #include "mbedtls/camellia.h" #endif +#if defined(MBEDTLS_ARIA_C) +#include "mbedtls/aria.h" +#endif + #if defined(MBEDTLS_DES_C) #include "mbedtls/des.h" #endif @@ -53,6 +61,10 @@ #include "mbedtls/blowfish.h" #endif +#if defined(MBEDTLS_CHACHA20_C) +#include "mbedtls/chacha20.h" +#endif + #if defined(MBEDTLS_GCM_C) #include "mbedtls/gcm.h" #endif @@ -138,6 +150,15 @@ static int aes_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, } #endif /* MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) +static int aes_crypt_ofb_wrap( void *ctx, size_t length, size_t *iv_off, + unsigned char *iv, const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aes_crypt_ofb( (mbedtls_aes_context *) ctx, length, iv_off, + iv, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + #if defined(MBEDTLS_CIPHER_MODE_CTR) static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, unsigned char *nonce_counter, unsigned char *stream_block, @@ -148,6 +169,33 @@ static int aes_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, } #endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) +static int aes_crypt_xts_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, + const unsigned char data_unit[16], + const unsigned char *input, + unsigned char *output ) +{ + mbedtls_aes_xts_context *xts_ctx = ctx; + int mode; + + switch( operation ) + { + case MBEDTLS_ENCRYPT: + mode = MBEDTLS_AES_ENCRYPT; + break; + case MBEDTLS_DECRYPT: + mode = MBEDTLS_AES_DECRYPT; + break; + default: + return MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + } + + return mbedtls_aes_crypt_xts( xts_ctx, mode, length, + data_unit, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + static int aes_setkey_dec_wrap( void *ctx, const unsigned char *key, unsigned int key_bitlen ) { @@ -187,9 +235,15 @@ static const mbedtls_cipher_base_t aes_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) aes_crypt_cfb128_wrap, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + aes_crypt_ofb_wrap, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) aes_crypt_ctr_wrap, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -302,6 +356,41 @@ static const mbedtls_cipher_info_t aes_256_cfb128_info = { }; #endif /* MBEDTLS_CIPHER_MODE_CFB */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) +static const mbedtls_cipher_info_t aes_128_ofb_info = { + MBEDTLS_CIPHER_AES_128_OFB, + MBEDTLS_MODE_OFB, + 128, + "AES-128-OFB", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_192_ofb_info = { + MBEDTLS_CIPHER_AES_192_OFB, + MBEDTLS_MODE_OFB, + 192, + "AES-192-OFB", + 16, + 0, + 16, + &aes_info +}; + +static const mbedtls_cipher_info_t aes_256_ofb_info = { + MBEDTLS_CIPHER_AES_256_OFB, + MBEDTLS_MODE_OFB, + 256, + "AES-256-OFB", + 16, + 0, + 16, + &aes_info +}; +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + #if defined(MBEDTLS_CIPHER_MODE_CTR) static const mbedtls_cipher_info_t aes_128_ctr_info = { MBEDTLS_CIPHER_AES_128_CTR, @@ -337,6 +426,92 @@ static const mbedtls_cipher_info_t aes_256_ctr_info = { }; #endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) +static int xts_aes_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + mbedtls_aes_xts_context *xts_ctx = ctx; + return( mbedtls_aes_xts_setkey_enc( xts_ctx, key, key_bitlen ) ); +} + +static int xts_aes_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + mbedtls_aes_xts_context *xts_ctx = ctx; + return( mbedtls_aes_xts_setkey_dec( xts_ctx, key, key_bitlen ) ); +} + +static void *xts_aes_ctx_alloc( void ) +{ + mbedtls_aes_xts_context *xts_ctx = mbedtls_calloc( 1, sizeof( *xts_ctx ) ); + + if( xts_ctx != NULL ) + mbedtls_aes_xts_init( xts_ctx ); + + return( xts_ctx ); +} + +static void xts_aes_ctx_free( void *ctx ) +{ + mbedtls_aes_xts_context *xts_ctx = ctx; + + if( xts_ctx == NULL ) + return; + + mbedtls_aes_xts_free( xts_ctx ); + mbedtls_free( xts_ctx ); +} + +static const mbedtls_cipher_base_t xts_aes_info = { + MBEDTLS_CIPHER_ID_AES, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + aes_crypt_xts_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + xts_aes_setkey_enc_wrap, + xts_aes_setkey_dec_wrap, + xts_aes_ctx_alloc, + xts_aes_ctx_free +}; + +static const mbedtls_cipher_info_t aes_128_xts_info = { + MBEDTLS_CIPHER_AES_128_XTS, + MBEDTLS_MODE_XTS, + 256, + "AES-128-XTS", + 16, + 0, + 16, + &xts_aes_info +}; + +static const mbedtls_cipher_info_t aes_256_xts_info = { + MBEDTLS_CIPHER_AES_256_XTS, + MBEDTLS_MODE_XTS, + 512, + "AES-256-XTS", + 16, + 0, + 16, + &xts_aes_info +}; +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + #if defined(MBEDTLS_GCM_C) static int gcm_aes_setkey_wrap( void *ctx, const unsigned char *key, unsigned int key_bitlen ) @@ -354,9 +529,15 @@ static const mbedtls_cipher_base_t gcm_aes_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -417,9 +598,15 @@ static const mbedtls_cipher_base_t ccm_aes_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -544,9 +731,15 @@ static const mbedtls_cipher_base_t camellia_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) camellia_crypt_cfb128_wrap, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) camellia_crypt_ctr_wrap, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -711,9 +904,15 @@ static const mbedtls_cipher_base_t gcm_camellia_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -774,9 +973,15 @@ static const mbedtls_cipher_base_t ccm_camellia_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -822,6 +1027,382 @@ static const mbedtls_cipher_info_t camellia_256_ccm_info = { #endif /* MBEDTLS_CAMELLIA_C */ +#if defined(MBEDTLS_ARIA_C) + +static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, + const unsigned char *input, unsigned char *output ) +{ + (void) operation; + return mbedtls_aria_crypt_ecb( (mbedtls_aria_context *) ctx, input, + output ); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static int aria_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, unsigned char *iv, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aria_crypt_cbc( (mbedtls_aria_context *) ctx, operation, length, iv, + input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static int aria_crypt_cfb128_wrap( void *ctx, mbedtls_operation_t operation, + size_t length, size_t *iv_off, unsigned char *iv, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aria_crypt_cfb128( (mbedtls_aria_context *) ctx, operation, length, + iv_off, iv, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static int aria_crypt_ctr_wrap( void *ctx, size_t length, size_t *nc_off, + unsigned char *nonce_counter, unsigned char *stream_block, + const unsigned char *input, unsigned char *output ) +{ + return mbedtls_aria_crypt_ctr( (mbedtls_aria_context *) ctx, length, nc_off, + nonce_counter, stream_block, input, output ); +} +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +static int aria_setkey_dec_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_aria_setkey_dec( (mbedtls_aria_context *) ctx, key, key_bitlen ); +} + +static int aria_setkey_enc_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_aria_setkey_enc( (mbedtls_aria_context *) ctx, key, key_bitlen ); +} + +static void * aria_ctx_alloc( void ) +{ + mbedtls_aria_context *ctx; + ctx = mbedtls_calloc( 1, sizeof( mbedtls_aria_context ) ); + + if( ctx == NULL ) + return( NULL ); + + mbedtls_aria_init( ctx ); + + return( ctx ); +} + +static void aria_ctx_free( void *ctx ) +{ + mbedtls_aria_free( (mbedtls_aria_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t aria_info = { + MBEDTLS_CIPHER_ID_ARIA, + aria_crypt_ecb_wrap, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + aria_crypt_cbc_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + aria_crypt_cfb128_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + aria_crypt_ctr_wrap, +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + aria_setkey_enc_wrap, + aria_setkey_dec_wrap, + aria_ctx_alloc, + aria_ctx_free +}; + +static const mbedtls_cipher_info_t aria_128_ecb_info = { + MBEDTLS_CIPHER_ARIA_128_ECB, + MBEDTLS_MODE_ECB, + 128, + "ARIA-128-ECB", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_192_ecb_info = { + MBEDTLS_CIPHER_ARIA_192_ECB, + MBEDTLS_MODE_ECB, + 192, + "ARIA-192-ECB", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_256_ecb_info = { + MBEDTLS_CIPHER_ARIA_256_ECB, + MBEDTLS_MODE_ECB, + 256, + "ARIA-256-ECB", + 16, + 0, + 16, + &aria_info +}; + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +static const mbedtls_cipher_info_t aria_128_cbc_info = { + MBEDTLS_CIPHER_ARIA_128_CBC, + MBEDTLS_MODE_CBC, + 128, + "ARIA-128-CBC", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_192_cbc_info = { + MBEDTLS_CIPHER_ARIA_192_CBC, + MBEDTLS_MODE_CBC, + 192, + "ARIA-192-CBC", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_256_cbc_info = { + MBEDTLS_CIPHER_ARIA_256_CBC, + MBEDTLS_MODE_CBC, + 256, + "ARIA-256-CBC", + 16, + 0, + 16, + &aria_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +static const mbedtls_cipher_info_t aria_128_cfb128_info = { + MBEDTLS_CIPHER_ARIA_128_CFB128, + MBEDTLS_MODE_CFB, + 128, + "ARIA-128-CFB128", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_192_cfb128_info = { + MBEDTLS_CIPHER_ARIA_192_CFB128, + MBEDTLS_MODE_CFB, + 192, + "ARIA-192-CFB128", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_256_cfb128_info = { + MBEDTLS_CIPHER_ARIA_256_CFB128, + MBEDTLS_MODE_CFB, + 256, + "ARIA-256-CFB128", + 16, + 0, + 16, + &aria_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +static const mbedtls_cipher_info_t aria_128_ctr_info = { + MBEDTLS_CIPHER_ARIA_128_CTR, + MBEDTLS_MODE_CTR, + 128, + "ARIA-128-CTR", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_192_ctr_info = { + MBEDTLS_CIPHER_ARIA_192_CTR, + MBEDTLS_MODE_CTR, + 192, + "ARIA-192-CTR", + 16, + 0, + 16, + &aria_info +}; + +static const mbedtls_cipher_info_t aria_256_ctr_info = { + MBEDTLS_CIPHER_ARIA_256_CTR, + MBEDTLS_MODE_CTR, + 256, + "ARIA-256-CTR", + 16, + 0, + 16, + &aria_info +}; +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_GCM_C) +static int gcm_aria_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_gcm_setkey( (mbedtls_gcm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA, + key, key_bitlen ); +} + +static const mbedtls_cipher_base_t gcm_aria_info = { + MBEDTLS_CIPHER_ID_ARIA, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + gcm_aria_setkey_wrap, + gcm_aria_setkey_wrap, + gcm_ctx_alloc, + gcm_ctx_free, +}; + +static const mbedtls_cipher_info_t aria_128_gcm_info = { + MBEDTLS_CIPHER_ARIA_128_GCM, + MBEDTLS_MODE_GCM, + 128, + "ARIA-128-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_aria_info +}; + +static const mbedtls_cipher_info_t aria_192_gcm_info = { + MBEDTLS_CIPHER_ARIA_192_GCM, + MBEDTLS_MODE_GCM, + 192, + "ARIA-192-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_aria_info +}; + +static const mbedtls_cipher_info_t aria_256_gcm_info = { + MBEDTLS_CIPHER_ARIA_256_GCM, + MBEDTLS_MODE_GCM, + 256, + "ARIA-256-GCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &gcm_aria_info +}; +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_CCM_C) +static int ccm_aria_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + return mbedtls_ccm_setkey( (mbedtls_ccm_context *) ctx, MBEDTLS_CIPHER_ID_ARIA, + key, key_bitlen ); +} + +static const mbedtls_cipher_base_t ccm_aria_info = { + MBEDTLS_CIPHER_ID_ARIA, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + ccm_aria_setkey_wrap, + ccm_aria_setkey_wrap, + ccm_ctx_alloc, + ccm_ctx_free, +}; + +static const mbedtls_cipher_info_t aria_128_ccm_info = { + MBEDTLS_CIPHER_ARIA_128_CCM, + MBEDTLS_MODE_CCM, + 128, + "ARIA-128-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aria_info +}; + +static const mbedtls_cipher_info_t aria_192_ccm_info = { + MBEDTLS_CIPHER_ARIA_192_CCM, + MBEDTLS_MODE_CCM, + 192, + "ARIA-192-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aria_info +}; + +static const mbedtls_cipher_info_t aria_256_ccm_info = { + MBEDTLS_CIPHER_ARIA_256_CCM, + MBEDTLS_MODE_CCM, + 256, + "ARIA-256-CCM", + 12, + MBEDTLS_CIPHER_VARIABLE_IV_LEN, + 16, + &ccm_aria_info +}; +#endif /* MBEDTLS_CCM_C */ + +#endif /* MBEDTLS_ARIA_C */ + #if defined(MBEDTLS_DES_C) static int des_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, @@ -950,9 +1531,15 @@ static const mbedtls_cipher_base_t des_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -995,9 +1582,15 @@ static const mbedtls_cipher_base_t des_ede_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -1040,9 +1633,15 @@ static const mbedtls_cipher_base_t des_ede3_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -1149,9 +1748,15 @@ static const mbedtls_cipher_base_t blowfish_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) blowfish_crypt_cfb64_wrap, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) blowfish_crypt_ctr_wrap, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) NULL, #endif @@ -1259,9 +1864,15 @@ static const mbedtls_cipher_base_t arc4_base_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) arc4_crypt_stream_wrap, #endif @@ -1283,6 +1894,162 @@ static const mbedtls_cipher_info_t arc4_128_info = { }; #endif /* MBEDTLS_ARC4_C */ +#if defined(MBEDTLS_CHACHA20_C) + +static int chacha20_setkey_wrap( void *ctx, const unsigned char *key, + unsigned int key_bitlen ) +{ + if( key_bitlen != 256U ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if ( 0 != mbedtls_chacha20_setkey( (mbedtls_chacha20_context*)ctx, key ) ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + return( 0 ); +} + +static int chacha20_stream_wrap( void *ctx, size_t length, + const unsigned char *input, + unsigned char *output ) +{ + int ret; + + ret = mbedtls_chacha20_update( ctx, length, input, output ); + if( ret == MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + return( ret ); +} + +static void * chacha20_ctx_alloc( void ) +{ + mbedtls_chacha20_context *ctx; + ctx = mbedtls_calloc( 1, sizeof( mbedtls_chacha20_context ) ); + + if( ctx == NULL ) + return( NULL ); + + mbedtls_chacha20_init( ctx ); + + return( ctx ); +} + +static void chacha20_ctx_free( void *ctx ) +{ + mbedtls_chacha20_free( (mbedtls_chacha20_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t chacha20_base_info = { + MBEDTLS_CIPHER_ID_CHACHA20, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + chacha20_stream_wrap, +#endif + chacha20_setkey_wrap, + chacha20_setkey_wrap, + chacha20_ctx_alloc, + chacha20_ctx_free +}; +static const mbedtls_cipher_info_t chacha20_info = { + MBEDTLS_CIPHER_CHACHA20, + MBEDTLS_MODE_STREAM, + 256, + "CHACHA20", + 12, + 0, + 1, + &chacha20_base_info +}; +#endif /* MBEDTLS_CHACHA20_C */ + +#if defined(MBEDTLS_CHACHAPOLY_C) + +static int chachapoly_setkey_wrap( void *ctx, + const unsigned char *key, + unsigned int key_bitlen ) +{ + if( key_bitlen != 256U ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if ( 0 != mbedtls_chachapoly_setkey( (mbedtls_chachapoly_context*)ctx, key ) ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + return( 0 ); +} + +static void * chachapoly_ctx_alloc( void ) +{ + mbedtls_chachapoly_context *ctx; + ctx = mbedtls_calloc( 1, sizeof( mbedtls_chachapoly_context ) ); + + if( ctx == NULL ) + return( NULL ); + + mbedtls_chachapoly_init( ctx ); + + return( ctx ); +} + +static void chachapoly_ctx_free( void *ctx ) +{ + mbedtls_chachapoly_free( (mbedtls_chachapoly_context *) ctx ); + mbedtls_free( ctx ); +} + +static const mbedtls_cipher_base_t chachapoly_base_info = { + MBEDTLS_CIPHER_ID_CHACHA20, + NULL, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif +#if defined(MBEDTLS_CIPHER_MODE_STREAM) + NULL, +#endif + chachapoly_setkey_wrap, + chachapoly_setkey_wrap, + chachapoly_ctx_alloc, + chachapoly_ctx_free +}; +static const mbedtls_cipher_info_t chachapoly_info = { + MBEDTLS_CIPHER_CHACHA20_POLY1305, + MBEDTLS_MODE_CHACHAPOLY, + 256, + "CHACHA20-POLY1305", + 12, + 0, + 1, + &chachapoly_base_info +}; +#endif /* MBEDTLS_CHACHAPOLY_C */ + #if defined(MBEDTLS_CIPHER_NULL_CIPHER) static int null_crypt_stream( void *ctx, size_t length, const unsigned char *input, @@ -1322,9 +2089,15 @@ static const mbedtls_cipher_base_t null_base_info = { #if defined(MBEDTLS_CIPHER_MODE_CFB) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) NULL, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + NULL, +#endif #if defined(MBEDTLS_CIPHER_MODE_STREAM) null_crypt_stream, #endif @@ -1362,11 +2135,20 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = { MBEDTLS_CIPHER_AES_192_CFB128, &aes_192_cfb128_info }, { MBEDTLS_CIPHER_AES_256_CFB128, &aes_256_cfb128_info }, #endif +#if defined(MBEDTLS_CIPHER_MODE_OFB) + { MBEDTLS_CIPHER_AES_128_OFB, &aes_128_ofb_info }, + { MBEDTLS_CIPHER_AES_192_OFB, &aes_192_ofb_info }, + { MBEDTLS_CIPHER_AES_256_OFB, &aes_256_ofb_info }, +#endif #if defined(MBEDTLS_CIPHER_MODE_CTR) { MBEDTLS_CIPHER_AES_128_CTR, &aes_128_ctr_info }, { MBEDTLS_CIPHER_AES_192_CTR, &aes_192_ctr_info }, { MBEDTLS_CIPHER_AES_256_CTR, &aes_256_ctr_info }, #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + { MBEDTLS_CIPHER_AES_128_XTS, &aes_128_xts_info }, + { MBEDTLS_CIPHER_AES_256_XTS, &aes_256_xts_info }, +#endif #if defined(MBEDTLS_GCM_C) { MBEDTLS_CIPHER_AES_128_GCM, &aes_128_gcm_info }, { MBEDTLS_CIPHER_AES_192_GCM, &aes_192_gcm_info }, @@ -1427,6 +2209,37 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = #endif #endif /* MBEDTLS_CAMELLIA_C */ +#if defined(MBEDTLS_ARIA_C) + { MBEDTLS_CIPHER_ARIA_128_ECB, &aria_128_ecb_info }, + { MBEDTLS_CIPHER_ARIA_192_ECB, &aria_192_ecb_info }, + { MBEDTLS_CIPHER_ARIA_256_ECB, &aria_256_ecb_info }, +#if defined(MBEDTLS_CIPHER_MODE_CBC) + { MBEDTLS_CIPHER_ARIA_128_CBC, &aria_128_cbc_info }, + { MBEDTLS_CIPHER_ARIA_192_CBC, &aria_192_cbc_info }, + { MBEDTLS_CIPHER_ARIA_256_CBC, &aria_256_cbc_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) + { MBEDTLS_CIPHER_ARIA_128_CFB128, &aria_128_cfb128_info }, + { MBEDTLS_CIPHER_ARIA_192_CFB128, &aria_192_cfb128_info }, + { MBEDTLS_CIPHER_ARIA_256_CFB128, &aria_256_cfb128_info }, +#endif +#if defined(MBEDTLS_CIPHER_MODE_CTR) + { MBEDTLS_CIPHER_ARIA_128_CTR, &aria_128_ctr_info }, + { MBEDTLS_CIPHER_ARIA_192_CTR, &aria_192_ctr_info }, + { MBEDTLS_CIPHER_ARIA_256_CTR, &aria_256_ctr_info }, +#endif +#if defined(MBEDTLS_GCM_C) + { MBEDTLS_CIPHER_ARIA_128_GCM, &aria_128_gcm_info }, + { MBEDTLS_CIPHER_ARIA_192_GCM, &aria_192_gcm_info }, + { MBEDTLS_CIPHER_ARIA_256_GCM, &aria_256_gcm_info }, +#endif +#if defined(MBEDTLS_CCM_C) + { MBEDTLS_CIPHER_ARIA_128_CCM, &aria_128_ccm_info }, + { MBEDTLS_CIPHER_ARIA_192_CCM, &aria_192_ccm_info }, + { MBEDTLS_CIPHER_ARIA_256_CCM, &aria_256_ccm_info }, +#endif +#endif /* MBEDTLS_ARIA_C */ + #if defined(MBEDTLS_DES_C) { MBEDTLS_CIPHER_DES_ECB, &des_ecb_info }, { MBEDTLS_CIPHER_DES_EDE_ECB, &des_ede_ecb_info }, @@ -1438,6 +2251,14 @@ const mbedtls_cipher_definition_t mbedtls_cipher_definitions[] = #endif #endif /* MBEDTLS_DES_C */ +#if defined(MBEDTLS_CHACHA20_C) + { MBEDTLS_CIPHER_CHACHA20, &chacha20_info }, +#endif + +#if defined(MBEDTLS_CHACHAPOLY_C) + { MBEDTLS_CIPHER_CHACHA20_POLY1305, &chachapoly_info }, +#endif + #if defined(MBEDTLS_CIPHER_NULL_CIPHER) { MBEDTLS_CIPHER_NULL, &null_cipher_info }, #endif /* MBEDTLS_CIPHER_NULL_CIPHER */ diff --git a/3rdparty/mbedtls/mbedtls/library/cmac.c b/3rdparty/mbedtls/mbedtls/library/cmac.c index 9a73faa6d5..5d101e1c7d 100644 --- a/3rdparty/mbedtls/mbedtls/library/cmac.c +++ b/3rdparty/mbedtls/mbedtls/library/cmac.c @@ -49,6 +49,7 @@ #if defined(MBEDTLS_CMAC_C) #include "mbedtls/cmac.h" +#include "mbedtls/platform_util.h" #include @@ -67,11 +68,6 @@ #if !defined(MBEDTLS_CMAC_ALT) || defined(MBEDTLS_SELF_TEST) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} - /* * Multiplication by u in the Galois field of GF(2^n) * @@ -144,7 +140,7 @@ static int cmac_generate_subkeys( mbedtls_cipher_context_t *ctx, unsigned char L[MBEDTLS_CIPHER_BLKSIZE_MAX]; size_t olen, block_size; - mbedtls_zeroize( L, sizeof( L ) ); + mbedtls_platform_zeroize( L, sizeof( L ) ); block_size = ctx->cipher_info->block_size; @@ -162,7 +158,7 @@ static int cmac_generate_subkeys( mbedtls_cipher_context_t *ctx, goto exit; exit: - mbedtls_zeroize( L, sizeof( L ) ); + mbedtls_platform_zeroize( L, sizeof( L ) ); return( ret ); } @@ -238,7 +234,7 @@ int mbedtls_cipher_cmac_starts( mbedtls_cipher_context_t *ctx, ctx->cmac_ctx = cmac_ctx; - mbedtls_zeroize( cmac_ctx->state, sizeof( cmac_ctx->state ) ); + mbedtls_platform_zeroize( cmac_ctx->state, sizeof( cmac_ctx->state ) ); return 0; } @@ -330,8 +326,8 @@ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, block_size = ctx->cipher_info->block_size; state = cmac_ctx->state; - mbedtls_zeroize( K1, sizeof( K1 ) ); - mbedtls_zeroize( K2, sizeof( K2 ) ); + mbedtls_platform_zeroize( K1, sizeof( K1 ) ); + mbedtls_platform_zeroize( K2, sizeof( K2 ) ); cmac_generate_subkeys( ctx, K1, K2 ); last_block = cmac_ctx->unprocessed_block; @@ -361,14 +357,14 @@ int mbedtls_cipher_cmac_finish( mbedtls_cipher_context_t *ctx, exit: /* Wipe the generated keys on the stack, and any other transients to avoid * side channel leakage */ - mbedtls_zeroize( K1, sizeof( K1 ) ); - mbedtls_zeroize( K2, sizeof( K2 ) ); + mbedtls_platform_zeroize( K1, sizeof( K1 ) ); + mbedtls_platform_zeroize( K2, sizeof( K2 ) ); cmac_ctx->unprocessed_len = 0; - mbedtls_zeroize( cmac_ctx->unprocessed_block, - sizeof( cmac_ctx->unprocessed_block ) ); + mbedtls_platform_zeroize( cmac_ctx->unprocessed_block, + sizeof( cmac_ctx->unprocessed_block ) ); - mbedtls_zeroize( state, MBEDTLS_CIPHER_BLKSIZE_MAX ); + mbedtls_platform_zeroize( state, MBEDTLS_CIPHER_BLKSIZE_MAX ); return( ret ); } @@ -383,10 +379,10 @@ int mbedtls_cipher_cmac_reset( mbedtls_cipher_context_t *ctx ) /* Reset the internal state */ cmac_ctx->unprocessed_len = 0; - mbedtls_zeroize( cmac_ctx->unprocessed_block, - sizeof( cmac_ctx->unprocessed_block ) ); - mbedtls_zeroize( cmac_ctx->state, - sizeof( cmac_ctx->state ) ); + mbedtls_platform_zeroize( cmac_ctx->unprocessed_block, + sizeof( cmac_ctx->unprocessed_block ) ); + mbedtls_platform_zeroize( cmac_ctx->state, + sizeof( cmac_ctx->state ) ); return( 0 ); } @@ -466,7 +462,7 @@ int mbedtls_aes_cmac_prf_128( const unsigned char *key, size_t key_length, output ); exit: - mbedtls_zeroize( int_key, sizeof( int_key ) ); + mbedtls_platform_zeroize( int_key, sizeof( int_key ) ); return( ret ); } diff --git a/3rdparty/mbedtls/mbedtls/library/ctr_drbg.c b/3rdparty/mbedtls/mbedtls/library/ctr_drbg.c index d7a94840cc..fb121575bb 100644 --- a/3rdparty/mbedtls/mbedtls/library/ctr_drbg.c +++ b/3rdparty/mbedtls/mbedtls/library/ctr_drbg.c @@ -33,6 +33,7 @@ #if defined(MBEDTLS_CTR_DRBG_C) #include "mbedtls/ctr_drbg.h" +#include "mbedtls/platform_util.h" #include @@ -49,11 +50,6 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * CTR_DRBG context initialization */ @@ -70,6 +66,18 @@ void mbedtls_ctr_drbg_init( mbedtls_ctr_drbg_context *ctx ) * Non-public function wrapped by mbedtls_ctr_drbg_seed(). Necessary to allow * NIST tests to succeed (which require known length fixed entropy) */ +/* CTR_DRBG_Instantiate with derivation function (SP 800-90A §10.2.1.3.2) + * mbedtls_ctr_drbg_seed_entropy_len(ctx, f_entropy, p_entropy, + * custom, len, entropy_len) + * implements + * CTR_DRBG_Instantiate(entropy_input, nonce, personalization_string, + * security_strength) -> initial_working_state + * with inputs + * custom[:len] = nonce || personalization_string + * where entropy_input comes from f_entropy for entropy_len bytes + * and with outputs + * ctx = initial_working_state + */ int mbedtls_ctr_drbg_seed_entropy_len( mbedtls_ctr_drbg_context *ctx, int (*f_entropy)(void *, unsigned char *, size_t), @@ -125,7 +133,7 @@ void mbedtls_ctr_drbg_free( mbedtls_ctr_drbg_context *ctx ) mbedtls_mutex_free( &ctx->mutex ); #endif mbedtls_aes_free( &ctx->aes_ctx ); - mbedtls_zeroize( ctx, sizeof( mbedtls_ctr_drbg_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ctr_drbg_context ) ); } void mbedtls_ctr_drbg_set_prediction_resistance( mbedtls_ctr_drbg_context *ctx, int resistance ) @@ -245,21 +253,29 @@ static int block_cipher_df( unsigned char *output, /* * tidy up the stack */ - mbedtls_zeroize( buf, sizeof( buf ) ); - mbedtls_zeroize( tmp, sizeof( tmp ) ); - mbedtls_zeroize( key, sizeof( key ) ); - mbedtls_zeroize( chain, sizeof( chain ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( key, sizeof( key ) ); + mbedtls_platform_zeroize( chain, sizeof( chain ) ); if( 0 != ret ) { /* * wipe partial seed from memory */ - mbedtls_zeroize( output, MBEDTLS_CTR_DRBG_SEEDLEN ); + mbedtls_platform_zeroize( output, MBEDTLS_CTR_DRBG_SEEDLEN ); } return( ret ); } +/* CTR_DRBG_Update (SP 800-90A §10.2.1.2) + * ctr_drbg_update_internal(ctx, provided_data) + * implements + * CTR_DRBG_Update(provided_data, Key, V) + * with inputs and outputs + * ctx->aes_ctx = Key + * ctx->counter = V + */ static int ctr_drbg_update_internal( mbedtls_ctr_drbg_context *ctx, const unsigned char data[MBEDTLS_CTR_DRBG_SEEDLEN] ) { @@ -299,10 +315,22 @@ static int ctr_drbg_update_internal( mbedtls_ctr_drbg_context *ctx, memcpy( ctx->counter, tmp + MBEDTLS_CTR_DRBG_KEYSIZE, MBEDTLS_CTR_DRBG_BLOCKSIZE ); exit: - mbedtls_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); return( ret ); } +/* CTR_DRBG_Instantiate with derivation function (SP 800-90A §10.2.1.3.2) + * mbedtls_ctr_drbg_update(ctx, additional, add_len) + * implements + * CTR_DRBG_Instantiate(entropy_input, nonce, personalization_string, + * security_strength) -> initial_working_state + * with inputs + * ctx->counter = all-bits-0 + * ctx->aes_ctx = context from all-bits-0 key + * additional[:add_len] = entropy_input || nonce || personalization_string + * and with outputs + * ctx = initial_working_state + */ int mbedtls_ctr_drbg_update_ret( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ) @@ -319,11 +347,11 @@ int mbedtls_ctr_drbg_update_ret( mbedtls_ctr_drbg_context *ctx, goto exit; exit: - mbedtls_zeroize( add_input, sizeof( add_input ) ); + mbedtls_platform_zeroize( add_input, sizeof( add_input ) ); return( ret ); } -/* Deprecated function, kept for backward compatibility. */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t add_len ) @@ -334,7 +362,20 @@ void mbedtls_ctr_drbg_update( mbedtls_ctr_drbg_context *ctx, add_len = MBEDTLS_CTR_DRBG_MAX_SEED_INPUT; (void) mbedtls_ctr_drbg_update_ret( ctx, additional, add_len ); } - +#endif /* MBEDTLS_DEPRECATED_REMOVED */ + +/* CTR_DRBG_Reseed with derivation function (SP 800-90A §10.2.1.4.2) + * mbedtls_ctr_drbg_reseed(ctx, additional, len) + * implements + * CTR_DRBG_Reseed(working_state, entropy_input, additional_input) + * -> new_working_state + * with inputs + * ctx contains working_state + * additional[:len] = additional_input + * and entropy_input comes from calling ctx->f_entropy + * and with output + * ctx contains new_working_state + */ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx, const unsigned char *additional, size_t len ) { @@ -382,10 +423,29 @@ int mbedtls_ctr_drbg_reseed( mbedtls_ctr_drbg_context *ctx, ctx->reseed_counter = 1; exit: - mbedtls_zeroize( seed, sizeof( seed ) ); + mbedtls_platform_zeroize( seed, sizeof( seed ) ); return( ret ); } +/* CTR_DRBG_Generate with derivation function (SP 800-90A §10.2.1.5.2) + * mbedtls_ctr_drbg_random_with_add(ctx, output, output_len, additional, add_len) + * implements + * CTR_DRBG_Reseed(working_state, entropy_input, additional[:add_len]) + * -> working_state_after_reseed + * if required, then + * CTR_DRBG_Generate(working_state_after_reseed, + * requested_number_of_bits, additional_input) + * -> status, returned_bits, new_working_state + * with inputs + * ctx contains working_state + * requested_number_of_bits = 8 * output_len + * additional[:add_len] = additional_input + * and entropy_input comes from calling ctx->f_entropy + * and with outputs + * status = SUCCESS (this function does the reseed internally) + * returned_bits = output[:output_len] + * ctx contains new_working_state + */ int mbedtls_ctr_drbg_random_with_add( void *p_rng, unsigned char *output, size_t output_len, const unsigned char *additional, size_t add_len ) @@ -455,8 +515,8 @@ int mbedtls_ctr_drbg_random_with_add( void *p_rng, ctx->reseed_counter++; exit: - mbedtls_zeroize( add_input, sizeof( add_input ) ); - mbedtls_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( add_input, sizeof( add_input ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); return( 0 ); } @@ -499,7 +559,7 @@ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char ret = 0; exit: - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); fclose( f ); return( ret ); @@ -508,35 +568,36 @@ int mbedtls_ctr_drbg_write_seed_file( mbedtls_ctr_drbg_context *ctx, const char int mbedtls_ctr_drbg_update_seed_file( mbedtls_ctr_drbg_context *ctx, const char *path ) { int ret = 0; - FILE *f; + FILE *f = NULL; size_t n; unsigned char buf[ MBEDTLS_CTR_DRBG_MAX_INPUT ]; + unsigned char c; if( ( f = fopen( path, "rb" ) ) == NULL ) return( MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR ); - fseek( f, 0, SEEK_END ); - n = (size_t) ftell( f ); - fseek( f, 0, SEEK_SET ); - - if( n > MBEDTLS_CTR_DRBG_MAX_INPUT ) + n = fread( buf, 1, sizeof( buf ), f ); + if( fread( &c, 1, 1, f ) != 0 ) { - fclose( f ); - return( MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG ); + ret = MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG; + goto exit; } - - if( fread( buf, 1, n, f ) != n ) + if( n == 0 || ferror( f ) ) + { ret = MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR; - else - ret = mbedtls_ctr_drbg_update_ret( ctx, buf, n ); - + goto exit; + } fclose( f ); + f = NULL; - mbedtls_zeroize( buf, sizeof( buf ) ); + ret = mbedtls_ctr_drbg_update_ret( ctx, buf, n ); +exit: + mbedtls_platform_zeroize( buf, sizeof( buf ) ); + if( f != NULL ) + fclose( f ); if( ret != 0 ) return( ret ); - return( mbedtls_ctr_drbg_write_seed_file( ctx, path ) ); } #endif /* MBEDTLS_FS_IO */ diff --git a/3rdparty/mbedtls/mbedtls/library/debug.c b/3rdparty/mbedtls/mbedtls/library/debug.c index db3924ac54..36510cdd56 100644 --- a/3rdparty/mbedtls/mbedtls/library/debug.c +++ b/3rdparty/mbedtls/mbedtls/library/debug.c @@ -86,8 +86,13 @@ void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level, char str[DEBUG_BUF_SIZE]; int ret; - if( NULL == ssl || NULL == ssl->conf || NULL == ssl->conf->f_dbg || level > debug_threshold ) + if( NULL == ssl || + NULL == ssl->conf || + NULL == ssl->conf->f_dbg || + level > debug_threshold ) + { return; + } va_start( argp, format ); #if defined(_WIN32) @@ -121,8 +126,13 @@ void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level, { char str[DEBUG_BUF_SIZE]; - if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + if( NULL == ssl || + NULL == ssl->conf || + NULL == ssl->conf->f_dbg || + level > debug_threshold ) + { return; + } /* * With non-blocking I/O and examples that just retry immediately, @@ -146,8 +156,13 @@ void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level, char txt[17]; size_t i, idx = 0; - if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + if( NULL == ssl || + NULL == ssl->conf || + NULL == ssl->conf->f_dbg || + level > debug_threshold ) + { return; + } mbedtls_snprintf( str + idx, sizeof( str ) - idx, "dumping '%s' (%u bytes)\n", text, (unsigned int) len ); @@ -199,8 +214,13 @@ void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level, { char str[DEBUG_BUF_SIZE]; - if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold ) + if( NULL == ssl || + NULL == ssl->conf || + NULL == ssl->conf->f_dbg || + level > debug_threshold ) + { return; + } mbedtls_snprintf( str, sizeof( str ), "%s(X)", text ); mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->X ); @@ -219,8 +239,14 @@ void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level, int j, k, zeros = 1; size_t i, n, idx = 0; - if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || X == NULL || level > debug_threshold ) + if( NULL == ssl || + NULL == ssl->conf || + NULL == ssl->conf->f_dbg || + NULL == X || + level > debug_threshold ) + { return; + } for( n = X->n - 1; n > 0; n-- ) if( X->p[n] != 0 ) @@ -345,8 +371,14 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, char str[DEBUG_BUF_SIZE]; int i = 0; - if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || crt == NULL || level > debug_threshold ) + if( NULL == ssl || + NULL == ssl->conf || + NULL == ssl->conf->f_dbg || + NULL == crt || + level > debug_threshold ) + { return; + } while( crt != NULL ) { @@ -365,4 +397,54 @@ void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level, } #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_ECDH_C) +static void mbedtls_debug_printf_ecdh_internal( const mbedtls_ssl_context *ssl, + int level, const char *file, + int line, + const mbedtls_ecdh_context *ecdh, + mbedtls_debug_ecdh_attr attr ) +{ +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + const mbedtls_ecdh_context* ctx = ecdh; +#else + const mbedtls_ecdh_context_mbed* ctx = &ecdh->ctx.mbed_ecdh; +#endif + + switch( attr ) + { + case MBEDTLS_DEBUG_ECDH_Q: + mbedtls_debug_print_ecp( ssl, level, file, line, "ECDH: Q", + &ctx->Q ); + break; + case MBEDTLS_DEBUG_ECDH_QP: + mbedtls_debug_print_ecp( ssl, level, file, line, "ECDH: Qp", + &ctx->Qp ); + break; + case MBEDTLS_DEBUG_ECDH_Z: + mbedtls_debug_print_mpi( ssl, level, file, line, "ECDH: z", + &ctx->z ); + break; + default: + break; + } +} + +void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level, + const char *file, int line, + const mbedtls_ecdh_context *ecdh, + mbedtls_debug_ecdh_attr attr ) +{ +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + mbedtls_debug_printf_ecdh_internal( ssl, level, file, line, ecdh, attr ); +#else + switch( ecdh->var ) + { + default: + mbedtls_debug_printf_ecdh_internal( ssl, level, file, line, ecdh, + attr ); + } +#endif +} +#endif /* MBEDTLS_ECDH_C */ + #endif /* MBEDTLS_DEBUG_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/des.c b/3rdparty/mbedtls/mbedtls/library/des.c index 09f95cfc3b..8a33d82e50 100644 --- a/3rdparty/mbedtls/mbedtls/library/des.c +++ b/3rdparty/mbedtls/mbedtls/library/des.c @@ -34,6 +34,7 @@ #if defined(MBEDTLS_DES_C) #include "mbedtls/des.h" +#include "mbedtls/platform_util.h" #include @@ -48,11 +49,6 @@ #if !defined(MBEDTLS_DES_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} - /* * 32-bit integer manipulation macros (big endian) */ @@ -261,50 +257,57 @@ static const uint32_t RHs[16] = /* * Initial Permutation macro */ -#define DES_IP(X,Y) \ -{ \ - T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \ - T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \ - T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \ - T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \ - Y = ((Y << 1) | (Y >> 31)) & 0xFFFFFFFF; \ - T = (X ^ Y) & 0xAAAAAAAA; Y ^= T; X ^= T; \ - X = ((X << 1) | (X >> 31)) & 0xFFFFFFFF; \ -} +#define DES_IP(X,Y) \ + do \ + { \ + T = (((X) >> 4) ^ (Y)) & 0x0F0F0F0F; (Y) ^= T; (X) ^= (T << 4); \ + T = (((X) >> 16) ^ (Y)) & 0x0000FFFF; (Y) ^= T; (X) ^= (T << 16); \ + T = (((Y) >> 2) ^ (X)) & 0x33333333; (X) ^= T; (Y) ^= (T << 2); \ + T = (((Y) >> 8) ^ (X)) & 0x00FF00FF; (X) ^= T; (Y) ^= (T << 8); \ + (Y) = (((Y) << 1) | ((Y) >> 31)) & 0xFFFFFFFF; \ + T = ((X) ^ (Y)) & 0xAAAAAAAA; (Y) ^= T; (X) ^= T; \ + (X) = (((X) << 1) | ((X) >> 31)) & 0xFFFFFFFF; \ + } while( 0 ) /* * Final Permutation macro */ -#define DES_FP(X,Y) \ -{ \ - X = ((X << 31) | (X >> 1)) & 0xFFFFFFFF; \ - T = (X ^ Y) & 0xAAAAAAAA; X ^= T; Y ^= T; \ - Y = ((Y << 31) | (Y >> 1)) & 0xFFFFFFFF; \ - T = ((Y >> 8) ^ X) & 0x00FF00FF; X ^= T; Y ^= (T << 8); \ - T = ((Y >> 2) ^ X) & 0x33333333; X ^= T; Y ^= (T << 2); \ - T = ((X >> 16) ^ Y) & 0x0000FFFF; Y ^= T; X ^= (T << 16); \ - T = ((X >> 4) ^ Y) & 0x0F0F0F0F; Y ^= T; X ^= (T << 4); \ -} +#define DES_FP(X,Y) \ + do \ + { \ + (X) = (((X) << 31) | ((X) >> 1)) & 0xFFFFFFFF; \ + T = ((X) ^ (Y)) & 0xAAAAAAAA; (X) ^= T; (Y) ^= T; \ + (Y) = (((Y) << 31) | ((Y) >> 1)) & 0xFFFFFFFF; \ + T = (((Y) >> 8) ^ (X)) & 0x00FF00FF; (X) ^= T; (Y) ^= (T << 8); \ + T = (((Y) >> 2) ^ (X)) & 0x33333333; (X) ^= T; (Y) ^= (T << 2); \ + T = (((X) >> 16) ^ (Y)) & 0x0000FFFF; (Y) ^= T; (X) ^= (T << 16); \ + T = (((X) >> 4) ^ (Y)) & 0x0F0F0F0F; (Y) ^= T; (X) ^= (T << 4); \ + } while( 0 ) /* * DES round macro */ -#define DES_ROUND(X,Y) \ -{ \ - T = *SK++ ^ X; \ - Y ^= SB8[ (T ) & 0x3F ] ^ \ - SB6[ (T >> 8) & 0x3F ] ^ \ - SB4[ (T >> 16) & 0x3F ] ^ \ - SB2[ (T >> 24) & 0x3F ]; \ - \ - T = *SK++ ^ ((X << 28) | (X >> 4)); \ - Y ^= SB7[ (T ) & 0x3F ] ^ \ - SB5[ (T >> 8) & 0x3F ] ^ \ - SB3[ (T >> 16) & 0x3F ] ^ \ - SB1[ (T >> 24) & 0x3F ]; \ -} - -#define SWAP(a,b) { uint32_t t = a; a = b; b = t; t = 0; } +#define DES_ROUND(X,Y) \ + do \ + { \ + T = *SK++ ^ (X); \ + (Y) ^= SB8[ (T ) & 0x3F ] ^ \ + SB6[ (T >> 8) & 0x3F ] ^ \ + SB4[ (T >> 16) & 0x3F ] ^ \ + SB2[ (T >> 24) & 0x3F ]; \ + \ + T = *SK++ ^ (((X) << 28) | ((X) >> 4)); \ + (Y) ^= SB7[ (T ) & 0x3F ] ^ \ + SB5[ (T >> 8) & 0x3F ] ^ \ + SB3[ (T >> 16) & 0x3F ] ^ \ + SB1[ (T >> 24) & 0x3F ]; \ + } while( 0 ) + +#define SWAP(a,b) \ + do \ + { \ + uint32_t t = (a); (a) = (b); (b) = t; t = 0; \ + } while( 0 ) void mbedtls_des_init( mbedtls_des_context *ctx ) { @@ -316,7 +319,7 @@ void mbedtls_des_free( mbedtls_des_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_des_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_des_context ) ); } void mbedtls_des3_init( mbedtls_des3_context *ctx ) @@ -329,7 +332,7 @@ void mbedtls_des3_free( mbedtls_des3_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_des3_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_des3_context ) ); } static const unsigned char odd_parity_table[128] = { 1, 2, 4, 7, 8, @@ -553,7 +556,7 @@ int mbedtls_des3_set2key_enc( mbedtls_des3_context *ctx, uint32_t sk[96]; des3_set2key( ctx->sk, sk, key ); - mbedtls_zeroize( sk, sizeof( sk ) ); + mbedtls_platform_zeroize( sk, sizeof( sk ) ); return( 0 ); } @@ -567,7 +570,7 @@ int mbedtls_des3_set2key_dec( mbedtls_des3_context *ctx, uint32_t sk[96]; des3_set2key( sk, ctx->sk, key ); - mbedtls_zeroize( sk, sizeof( sk ) ); + mbedtls_platform_zeroize( sk, sizeof( sk ) ); return( 0 ); } @@ -604,7 +607,7 @@ int mbedtls_des3_set3key_enc( mbedtls_des3_context *ctx, uint32_t sk[96]; des3_set3key( ctx->sk, sk, key ); - mbedtls_zeroize( sk, sizeof( sk ) ); + mbedtls_platform_zeroize( sk, sizeof( sk ) ); return( 0 ); } @@ -618,7 +621,7 @@ int mbedtls_des3_set3key_dec( mbedtls_des3_context *ctx, uint32_t sk[96]; des3_set3key( sk, ctx->sk, key ); - mbedtls_zeroize( sk, sizeof( sk ) ); + mbedtls_platform_zeroize( sk, sizeof( sk ) ); return( 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/library/dhm.c b/3rdparty/mbedtls/mbedtls/library/dhm.c index 28ac31003c..8255632a99 100644 --- a/3rdparty/mbedtls/mbedtls/library/dhm.c +++ b/3rdparty/mbedtls/mbedtls/library/dhm.c @@ -36,6 +36,7 @@ #if defined(MBEDTLS_DHM_C) #include "mbedtls/dhm.h" +#include "mbedtls/platform_util.h" #include @@ -58,10 +59,11 @@ #endif #if !defined(MBEDTLS_DHM_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} + +#define DHM_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_DHM_BAD_INPUT_DATA ) +#define DHM_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) /* * helper to validate the mbedtls_mpi size and import it @@ -124,6 +126,7 @@ static int dhm_check_range( const mbedtls_mpi *param, const mbedtls_mpi *P ) void mbedtls_dhm_init( mbedtls_dhm_context *ctx ) { + DHM_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_dhm_context ) ); } @@ -135,6 +138,9 @@ int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx, const unsigned char *end ) { int ret; + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( p != NULL && *p != NULL ); + DHM_VALIDATE_RET( end != NULL ); if( ( ret = dhm_read_bignum( &ctx->P, p, end ) ) != 0 || ( ret = dhm_read_bignum( &ctx->G, p, end ) ) != 0 || @@ -160,6 +166,10 @@ int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size, int ret, count = 0; size_t n1, n2, n3; unsigned char *p; + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( output != NULL ); + DHM_VALIDATE_RET( olen != NULL ); + DHM_VALIDATE_RET( f_rng != NULL ); if( mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ) return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); @@ -230,9 +240,9 @@ int mbedtls_dhm_set_group( mbedtls_dhm_context *ctx, const mbedtls_mpi *G ) { int ret; - - if( ctx == NULL || P == NULL || G == NULL ) - return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( P != NULL ); + DHM_VALIDATE_RET( G != NULL ); if( ( ret = mbedtls_mpi_copy( &ctx->P, P ) ) != 0 || ( ret = mbedtls_mpi_copy( &ctx->G, G ) ) != 0 ) @@ -251,8 +261,10 @@ int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx, const unsigned char *input, size_t ilen ) { int ret; + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( input != NULL ); - if( ctx == NULL || ilen < 1 || ilen > ctx->len ) + if( ilen < 1 || ilen > ctx->len ) return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); if( ( ret = mbedtls_mpi_read_binary( &ctx->GY, input, ilen ) ) != 0 ) @@ -270,8 +282,11 @@ int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size, void *p_rng ) { int ret, count = 0; + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( output != NULL ); + DHM_VALIDATE_RET( f_rng != NULL ); - if( ctx == NULL || olen < 1 || olen > ctx->len ) + if( olen < 1 || olen > ctx->len ) return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); if( mbedtls_mpi_cmp_int( &ctx->P, 0 ) == 0 ) @@ -383,8 +398,11 @@ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, { int ret; mbedtls_mpi GYb; + DHM_VALIDATE_RET( ctx != NULL ); + DHM_VALIDATE_RET( output != NULL ); + DHM_VALIDATE_RET( olen != NULL ); - if( ctx == NULL || output_size < ctx->len ) + if( output_size < ctx->len ) return( MBEDTLS_ERR_DHM_BAD_INPUT_DATA ); if( ( ret = dhm_check_range( &ctx->GY, &ctx->P ) ) != 0 ) @@ -431,13 +449,21 @@ int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx, */ void mbedtls_dhm_free( mbedtls_dhm_context *ctx ) { - mbedtls_mpi_free( &ctx->pX ); mbedtls_mpi_free( &ctx->Vf ); - mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->RP ); - mbedtls_mpi_free( &ctx->K ); mbedtls_mpi_free( &ctx->GY ); - mbedtls_mpi_free( &ctx->GX ); mbedtls_mpi_free( &ctx->X ); - mbedtls_mpi_free( &ctx->G ); mbedtls_mpi_free( &ctx->P ); - - mbedtls_zeroize( ctx, sizeof( mbedtls_dhm_context ) ); + if( ctx == NULL ) + return; + + mbedtls_mpi_free( &ctx->pX ); + mbedtls_mpi_free( &ctx->Vf ); + mbedtls_mpi_free( &ctx->Vi ); + mbedtls_mpi_free( &ctx->RP ); + mbedtls_mpi_free( &ctx->K ); + mbedtls_mpi_free( &ctx->GY ); + mbedtls_mpi_free( &ctx->GX ); + mbedtls_mpi_free( &ctx->X ); + mbedtls_mpi_free( &ctx->G ); + mbedtls_mpi_free( &ctx->P ); + + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_dhm_context ) ); } #if defined(MBEDTLS_ASN1_PARSE_C) @@ -452,7 +478,12 @@ int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin, unsigned char *p, *end; #if defined(MBEDTLS_PEM_PARSE_C) mbedtls_pem_context pem; +#endif /* MBEDTLS_PEM_PARSE_C */ + + DHM_VALIDATE_RET( dhm != NULL ); + DHM_VALIDATE_RET( dhmin != NULL ); +#if defined(MBEDTLS_PEM_PARSE_C) mbedtls_pem_init( &pem ); /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ @@ -575,7 +606,7 @@ static int load_file( const char *path, unsigned char **buf, size_t *n ) { fclose( f ); - mbedtls_zeroize( *buf, *n + 1 ); + mbedtls_platform_zeroize( *buf, *n + 1 ); mbedtls_free( *buf ); return( MBEDTLS_ERR_DHM_FILE_IO_ERROR ); @@ -599,13 +630,15 @@ int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ) int ret; size_t n; unsigned char *buf; + DHM_VALIDATE_RET( dhm != NULL ); + DHM_VALIDATE_RET( path != NULL ); if( ( ret = load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = mbedtls_dhm_parse_dhm( dhm, buf, n ); - mbedtls_zeroize( buf, n ); + mbedtls_platform_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); @@ -616,12 +649,28 @@ int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path ) #if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PEM_PARSE_C) static const char mbedtls_test_dhm_params[] = "-----BEGIN DH PARAMETERS-----\r\n" "MIGHAoGBAJ419DBEOgmQTzo5qXl5fQcN9TN455wkOL7052HzxxRVMyhYmwQcgJvh\r\n" "1sa18fyfR9OiVEMYglOpkqVoGLN7qd5aQNNi5W7/C+VBdHTBJcGZJyyP5B3qcz32\r\n" "9mLJKudlVudV0Qxk5qUJaPZ/xupz0NyoVpviuiBOI1gNi8ovSXWzAgEC\r\n" "-----END DH PARAMETERS-----\r\n"; +#else /* MBEDTLS_PEM_PARSE_C */ +static const char mbedtls_test_dhm_params[] = { + 0x30, 0x81, 0x87, 0x02, 0x81, 0x81, 0x00, 0x9e, 0x35, 0xf4, 0x30, 0x44, + 0x3a, 0x09, 0x90, 0x4f, 0x3a, 0x39, 0xa9, 0x79, 0x79, 0x7d, 0x07, 0x0d, + 0xf5, 0x33, 0x78, 0xe7, 0x9c, 0x24, 0x38, 0xbe, 0xf4, 0xe7, 0x61, 0xf3, + 0xc7, 0x14, 0x55, 0x33, 0x28, 0x58, 0x9b, 0x04, 0x1c, 0x80, 0x9b, 0xe1, + 0xd6, 0xc6, 0xb5, 0xf1, 0xfc, 0x9f, 0x47, 0xd3, 0xa2, 0x54, 0x43, 0x18, + 0x82, 0x53, 0xa9, 0x92, 0xa5, 0x68, 0x18, 0xb3, 0x7b, 0xa9, 0xde, 0x5a, + 0x40, 0xd3, 0x62, 0xe5, 0x6e, 0xff, 0x0b, 0xe5, 0x41, 0x74, 0x74, 0xc1, + 0x25, 0xc1, 0x99, 0x27, 0x2c, 0x8f, 0xe4, 0x1d, 0xea, 0x73, 0x3d, 0xf6, + 0xf6, 0x62, 0xc9, 0x2a, 0xe7, 0x65, 0x56, 0xe7, 0x55, 0xd1, 0x0c, 0x64, + 0xe6, 0xa5, 0x09, 0x68, 0xf6, 0x7f, 0xc6, 0xea, 0x73, 0xd0, 0xdc, 0xa8, + 0x56, 0x9b, 0xe2, 0xba, 0x20, 0x4e, 0x23, 0x58, 0x0d, 0x8b, 0xca, 0x2f, + 0x49, 0x75, 0xb3, 0x02, 0x01, 0x02 }; +#endif /* MBEDTLS_PEM_PARSE_C */ static const size_t mbedtls_test_dhm_params_len = sizeof( mbedtls_test_dhm_params ); diff --git a/3rdparty/mbedtls/mbedtls/library/ecdh.c b/3rdparty/mbedtls/mbedtls/library/ecdh.c index 61380b6936..c5726877d5 100644 --- a/3rdparty/mbedtls/mbedtls/library/ecdh.c +++ b/3rdparty/mbedtls/mbedtls/library/ecdh.c @@ -35,41 +35,92 @@ #if defined(MBEDTLS_ECDH_C) #include "mbedtls/ecdh.h" +#include "mbedtls/platform_util.h" #include +/* Parameter validation macros based on platform_util.h */ +#define ECDH_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA ) +#define ECDH_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) +typedef mbedtls_ecdh_context mbedtls_ecdh_context_mbed; +#endif + +static mbedtls_ecp_group_id mbedtls_ecdh_grp_id( + const mbedtls_ecdh_context *ctx ) +{ +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ctx->grp.id ); +#else + return( ctx->grp_id ); +#endif +} + #if !defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) /* - * Generate public key: simple wrapper around mbedtls_ecp_gen_keypair + * Generate public key (restartable version) + * + * Note: this internal function relies on its caller preserving the value of + * the output parameter 'd' across continuation calls. This would not be + * acceptable for a public function but is OK here as we control call sites. + */ +static int ecdh_gen_public_restartable( mbedtls_ecp_group *grp, + mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ) +{ + int ret; + + /* If multiplication is in progress, we already generated a privkey */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx == NULL || rs_ctx->rsm == NULL ) +#endif + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_privkey( grp, d, f_rng, p_rng ) ); + + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_restartable( grp, Q, d, &grp->G, + f_rng, p_rng, rs_ctx ) ); + +cleanup: + return( ret ); +} + +/* + * Generate public key */ int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - return mbedtls_ecp_gen_keypair( grp, d, Q, f_rng, p_rng ); + ECDH_VALIDATE_RET( grp != NULL ); + ECDH_VALIDATE_RET( d != NULL ); + ECDH_VALIDATE_RET( Q != NULL ); + ECDH_VALIDATE_RET( f_rng != NULL ); + return( ecdh_gen_public_restartable( grp, d, Q, f_rng, p_rng, NULL ) ); } -#endif /* MBEDTLS_ECDH_GEN_PUBLIC_ALT */ +#endif /* !MBEDTLS_ECDH_GEN_PUBLIC_ALT */ #if !defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) /* * Compute shared secret (SEC1 3.3.1) */ -int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, +static int ecdh_compute_shared_restartable( mbedtls_ecp_group *grp, + mbedtls_mpi *z, const mbedtls_ecp_point *Q, const mbedtls_mpi *d, int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) + void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ) { int ret; mbedtls_ecp_point P; mbedtls_ecp_point_init( &P ); - /* - * Make sure Q is a valid pubkey before using it - */ - MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, Q ) ); - - MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &P, d, Q, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_restartable( grp, &P, d, Q, + f_rng, p_rng, rs_ctx ) ); if( mbedtls_ecp_is_zero( &P ) ) { @@ -84,71 +135,250 @@ int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, return( ret ); } -#endif /* MBEDTLS_ECDH_COMPUTE_SHARED_ALT */ + +/* + * Compute shared secret (SEC1 3.3.1) + */ +int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, + const mbedtls_ecp_point *Q, const mbedtls_mpi *d, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + ECDH_VALIDATE_RET( grp != NULL ); + ECDH_VALIDATE_RET( Q != NULL ); + ECDH_VALIDATE_RET( d != NULL ); + ECDH_VALIDATE_RET( z != NULL ); + return( ecdh_compute_shared_restartable( grp, z, Q, d, + f_rng, p_rng, NULL ) ); +} +#endif /* !MBEDTLS_ECDH_COMPUTE_SHARED_ALT */ + +static void ecdh_init_internal( mbedtls_ecdh_context_mbed *ctx ) +{ + mbedtls_ecp_group_init( &ctx->grp ); + mbedtls_mpi_init( &ctx->d ); + mbedtls_ecp_point_init( &ctx->Q ); + mbedtls_ecp_point_init( &ctx->Qp ); + mbedtls_mpi_init( &ctx->z ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_init( &ctx->rs ); +#endif +} /* * Initialize context */ void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ) { + ECDH_VALIDATE( ctx != NULL ); + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + ecdh_init_internal( ctx ); + mbedtls_ecp_point_init( &ctx->Vi ); + mbedtls_ecp_point_init( &ctx->Vf ); + mbedtls_mpi_init( &ctx->_d ); +#else memset( ctx, 0, sizeof( mbedtls_ecdh_context ) ); + + ctx->var = MBEDTLS_ECDH_VARIANT_NONE; +#endif + ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED; +#if defined(MBEDTLS_ECP_RESTARTABLE) + ctx->restart_enabled = 0; +#endif +} + +static int ecdh_setup_internal( mbedtls_ecdh_context_mbed *ctx, + mbedtls_ecp_group_id grp_id ) +{ + int ret; + + ret = mbedtls_ecp_group_load( &ctx->grp, grp_id ); + if( ret != 0 ) + { + return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); + } + + return( 0 ); } /* - * Free context + * Setup context */ -void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ) +int mbedtls_ecdh_setup( mbedtls_ecdh_context *ctx, mbedtls_ecp_group_id grp_id ) { - if( ctx == NULL ) - return; + ECDH_VALIDATE_RET( ctx != NULL ); + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_setup_internal( ctx, grp_id ) ); +#else + switch( grp_id ) + { + default: + ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED; + ctx->var = MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0; + ctx->grp_id = grp_id; + ecdh_init_internal( &ctx->ctx.mbed_ecdh ); + return( ecdh_setup_internal( &ctx->ctx.mbed_ecdh, grp_id ) ); + } +#endif +} +static void ecdh_free_internal( mbedtls_ecdh_context_mbed *ctx ) +{ mbedtls_ecp_group_free( &ctx->grp ); + mbedtls_mpi_free( &ctx->d ); mbedtls_ecp_point_free( &ctx->Q ); mbedtls_ecp_point_free( &ctx->Qp ); - mbedtls_ecp_point_free( &ctx->Vi ); - mbedtls_ecp_point_free( &ctx->Vf ); - mbedtls_mpi_free( &ctx->d ); mbedtls_mpi_free( &ctx->z ); - mbedtls_mpi_free( &ctx->_d ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_free( &ctx->rs ); +#endif } +#if defined(MBEDTLS_ECP_RESTARTABLE) /* - * Setup and write the ServerKeyExhange parameters (RFC 4492) - * struct { - * ECParameters curve_params; - * ECPoint public; - * } ServerECDHParams; + * Enable restartable operations for context */ -int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, - unsigned char *buf, size_t blen, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) +void mbedtls_ecdh_enable_restart( mbedtls_ecdh_context *ctx ) +{ + ECDH_VALIDATE( ctx != NULL ); + + ctx->restart_enabled = 1; +} +#endif + +/* + * Free context + */ +void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ) +{ + if( ctx == NULL ) + return; + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + mbedtls_ecp_point_free( &ctx->Vi ); + mbedtls_ecp_point_free( &ctx->Vf ); + mbedtls_mpi_free( &ctx->_d ); + ecdh_free_internal( ctx ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + ecdh_free_internal( &ctx->ctx.mbed_ecdh ); + break; + default: + break; + } + + ctx->point_format = MBEDTLS_ECP_PF_UNCOMPRESSED; + ctx->var = MBEDTLS_ECDH_VARIANT_NONE; + ctx->grp_id = MBEDTLS_ECP_DP_NONE; +#endif +} + +static int ecdh_make_params_internal( mbedtls_ecdh_context_mbed *ctx, + size_t *olen, int point_format, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, + unsigned char *, + size_t), + void *p_rng, + int restart_enabled ) { int ret; size_t grp_len, pt_len; +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_ctx *rs_ctx = NULL; +#endif - if( ctx == NULL || ctx->grp.pbits == 0 ) + if( ctx->grp.pbits == 0 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) - != 0 ) +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( restart_enabled ) + rs_ctx = &ctx->rs; +#else + (void) restart_enabled; +#endif + + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ( ret = ecdh_gen_public_restartable( &ctx->grp, &ctx->d, &ctx->Q, + f_rng, p_rng, rs_ctx ) ) != 0 ) + return( ret ); +#else + if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, + f_rng, p_rng ) ) != 0 ) return( ret ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ - if( ( ret = mbedtls_ecp_tls_write_group( &ctx->grp, &grp_len, buf, blen ) ) - != 0 ) + if( ( ret = mbedtls_ecp_tls_write_group( &ctx->grp, &grp_len, buf, + blen ) ) != 0 ) return( ret ); buf += grp_len; blen -= grp_len; - if( ( ret = mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, ctx->point_format, - &pt_len, buf, blen ) ) != 0 ) + if( ( ret = mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, point_format, + &pt_len, buf, blen ) ) != 0 ) return( ret ); *olen = grp_len + pt_len; return( 0 ); } +/* + * Setup and write the ServerKeyExhange parameters (RFC 4492) + * struct { + * ECParameters curve_params; + * ECPoint public; + * } ServerECDHParams; + */ +int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int restart_enabled = 0; + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( olen != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + ECDH_VALIDATE_RET( f_rng != NULL ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + restart_enabled = ctx->restart_enabled; +#else + (void) restart_enabled; +#endif + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_make_params_internal( ctx, olen, ctx->point_format, buf, blen, + f_rng, p_rng, restart_enabled ) ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_make_params_internal( &ctx->ctx.mbed_ecdh, olen, + ctx->point_format, buf, blen, + f_rng, p_rng, + restart_enabled ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + +static int ecdh_read_params_internal( mbedtls_ecdh_context_mbed *ctx, + const unsigned char **buf, + const unsigned char *end ) +{ + return( mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, buf, + end - *buf ) ); +} + /* * Read the ServerKeyExhange parameters (RFC 4492) * struct { @@ -157,31 +387,43 @@ int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, * } ServerECDHParams; */ int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, - const unsigned char **buf, const unsigned char *end ) + const unsigned char **buf, + const unsigned char *end ) { int ret; - - if( ( ret = mbedtls_ecp_tls_read_group( &ctx->grp, buf, end - *buf ) ) != 0 ) + mbedtls_ecp_group_id grp_id; + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + ECDH_VALIDATE_RET( *buf != NULL ); + ECDH_VALIDATE_RET( end != NULL ); + + if( ( ret = mbedtls_ecp_tls_read_group_id( &grp_id, buf, end - *buf ) ) + != 0 ) return( ret ); - if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, buf, end - *buf ) ) - != 0 ) + if( ( ret = mbedtls_ecdh_setup( ctx, grp_id ) ) != 0 ) return( ret ); - return( 0 ); +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_read_params_internal( ctx, buf, end ) ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_read_params_internal( &ctx->ctx.mbed_ecdh, + buf, end ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif } -/* - * Get parameters from a keypair - */ -int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, - mbedtls_ecdh_side side ) +static int ecdh_get_params_internal( mbedtls_ecdh_context_mbed *ctx, + const mbedtls_ecp_keypair *key, + mbedtls_ecdh_side side ) { int ret; - if( ( ret = mbedtls_ecp_group_copy( &ctx->grp, &key->grp ) ) != 0 ) - return( ret ); - /* If it's not our key, just import the public part as Qp */ if( side == MBEDTLS_ECDH_THEIRS ) return( mbedtls_ecp_copy( &ctx->Qp, &key->Q ) ); @@ -198,39 +440,129 @@ int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypai } /* - * Setup and export the client public value + * Get parameters from a keypair */ -int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, - unsigned char *buf, size_t blen, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) +int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, + const mbedtls_ecp_keypair *key, + mbedtls_ecdh_side side ) { int ret; + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( key != NULL ); + ECDH_VALIDATE_RET( side == MBEDTLS_ECDH_OURS || + side == MBEDTLS_ECDH_THEIRS ); - if( ctx == NULL || ctx->grp.pbits == 0 ) + if( mbedtls_ecdh_grp_id( ctx ) == MBEDTLS_ECP_DP_NONE ) + { + /* This is the first call to get_params(). Set up the context + * for use with the group. */ + if( ( ret = mbedtls_ecdh_setup( ctx, key->grp.id ) ) != 0 ) + return( ret ); + } + else + { + /* This is not the first call to get_params(). Check that the + * current key's group is the same as the context's, which was set + * from the first key's group. */ + if( mbedtls_ecdh_grp_id( ctx ) != key->grp.id ) + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + } + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_get_params_internal( ctx, key, side ) ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_get_params_internal( &ctx->ctx.mbed_ecdh, + key, side ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + +static int ecdh_make_public_internal( mbedtls_ecdh_context_mbed *ctx, + size_t *olen, int point_format, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, + unsigned char *, + size_t), + void *p_rng, + int restart_enabled ) +{ + int ret; +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_ctx *rs_ctx = NULL; +#endif + + if( ctx->grp.pbits == 0 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ) - != 0 ) +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( restart_enabled ) + rs_ctx = &ctx->rs; +#else + (void) restart_enabled; +#endif + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ( ret = ecdh_gen_public_restartable( &ctx->grp, &ctx->d, &ctx->Q, + f_rng, p_rng, rs_ctx ) ) != 0 ) + return( ret ); +#else + if( ( ret = mbedtls_ecdh_gen_public( &ctx->grp, &ctx->d, &ctx->Q, + f_rng, p_rng ) ) != 0 ) return( ret ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ - return mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, ctx->point_format, - olen, buf, blen ); + return mbedtls_ecp_tls_write_point( &ctx->grp, &ctx->Q, point_format, olen, + buf, blen ); } /* - * Parse and import the client's public value + * Setup and export the client public value */ -int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, - const unsigned char *buf, size_t blen ) +int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int restart_enabled = 0; + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( olen != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + ECDH_VALIDATE_RET( f_rng != NULL ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + restart_enabled = ctx->restart_enabled; +#endif + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_make_public_internal( ctx, olen, ctx->point_format, buf, blen, + f_rng, p_rng, restart_enabled ) ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_make_public_internal( &ctx->ctx.mbed_ecdh, olen, + ctx->point_format, buf, blen, + f_rng, p_rng, + restart_enabled ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + +static int ecdh_read_public_internal( mbedtls_ecdh_context_mbed *ctx, + const unsigned char *buf, size_t blen ) { int ret; const unsigned char *p = buf; - if( ctx == NULL ) - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - - if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, &p, blen ) ) != 0 ) + if( ( ret = mbedtls_ecp_tls_read_point( &ctx->grp, &ctx->Qp, &p, + blen ) ) != 0 ) return( ret ); if( (size_t)( p - buf ) != blen ) @@ -240,23 +572,66 @@ int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, } /* - * Derive and export the shared secret + * Parse and import the client's public value */ -int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, - unsigned char *buf, size_t blen, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) +int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, + const unsigned char *buf, size_t blen ) +{ + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_read_public_internal( ctx, buf, blen ) ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_read_public_internal( &ctx->ctx.mbed_ecdh, + buf, blen ) ); + default: + return MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + } +#endif +} + +static int ecdh_calc_secret_internal( mbedtls_ecdh_context_mbed *ctx, + size_t *olen, unsigned char *buf, + size_t blen, + int (*f_rng)(void *, + unsigned char *, + size_t), + void *p_rng, + int restart_enabled ) { int ret; +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_ctx *rs_ctx = NULL; +#endif - if( ctx == NULL ) + if( ctx == NULL || ctx->grp.pbits == 0 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - if( ( ret = mbedtls_ecdh_compute_shared( &ctx->grp, &ctx->z, &ctx->Qp, &ctx->d, - f_rng, p_rng ) ) != 0 ) +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( restart_enabled ) + rs_ctx = &ctx->rs; +#else + (void) restart_enabled; +#endif + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ( ret = ecdh_compute_shared_restartable( &ctx->grp, &ctx->z, &ctx->Qp, + &ctx->d, f_rng, p_rng, + rs_ctx ) ) != 0 ) + { + return( ret ); + } +#else + if( ( ret = mbedtls_ecdh_compute_shared( &ctx->grp, &ctx->z, &ctx->Qp, + &ctx->d, f_rng, p_rng ) ) != 0 ) { return( ret ); } +#endif /* MBEDTLS_ECP_RESTARTABLE */ if( mbedtls_mpi_size( &ctx->z ) > blen ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); @@ -265,4 +640,37 @@ int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, return mbedtls_mpi_write_binary( &ctx->z, buf, *olen ); } +/* + * Derive and export the shared secret + */ +int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, + unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int restart_enabled = 0; + ECDH_VALIDATE_RET( ctx != NULL ); + ECDH_VALIDATE_RET( olen != NULL ); + ECDH_VALIDATE_RET( buf != NULL ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + restart_enabled = ctx->restart_enabled; +#endif + +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + return( ecdh_calc_secret_internal( ctx, olen, buf, blen, f_rng, p_rng, + restart_enabled ) ); +#else + switch( ctx->var ) + { + case MBEDTLS_ECDH_VARIANT_MBEDTLS_2_0: + return( ecdh_calc_secret_internal( &ctx->ctx.mbed_ecdh, olen, buf, + blen, f_rng, p_rng, + restart_enabled ) ); + default: + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + } +#endif +} + #endif /* MBEDTLS_ECDH_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/ecdsa.c b/3rdparty/mbedtls/mbedtls/library/ecdsa.c index 17a88bdd29..dc19384d61 100644 --- a/3rdparty/mbedtls/mbedtls/library/ecdsa.c +++ b/3rdparty/mbedtls/mbedtls/library/ecdsa.c @@ -42,6 +42,186 @@ #include "mbedtls/hmac_drbg.h" #endif +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/platform_util.h" + +/* Parameter validation macros based on platform_util.h */ +#define ECDSA_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA ) +#define ECDSA_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +#if defined(MBEDTLS_ECP_RESTARTABLE) + +/* + * Sub-context for ecdsa_verify() + */ +struct mbedtls_ecdsa_restart_ver +{ + mbedtls_mpi u1, u2; /* intermediate values */ + enum { /* what to do next? */ + ecdsa_ver_init = 0, /* getting started */ + ecdsa_ver_muladd, /* muladd step */ + } state; +}; + +/* + * Init verify restart sub-context + */ +static void ecdsa_restart_ver_init( mbedtls_ecdsa_restart_ver_ctx *ctx ) +{ + mbedtls_mpi_init( &ctx->u1 ); + mbedtls_mpi_init( &ctx->u2 ); + ctx->state = ecdsa_ver_init; +} + +/* + * Free the components of a verify restart sub-context + */ +static void ecdsa_restart_ver_free( mbedtls_ecdsa_restart_ver_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_mpi_free( &ctx->u1 ); + mbedtls_mpi_free( &ctx->u2 ); + + ecdsa_restart_ver_init( ctx ); +} + +/* + * Sub-context for ecdsa_sign() + */ +struct mbedtls_ecdsa_restart_sig +{ + int sign_tries; + int key_tries; + mbedtls_mpi k; /* per-signature random */ + mbedtls_mpi r; /* r value */ + enum { /* what to do next? */ + ecdsa_sig_init = 0, /* getting started */ + ecdsa_sig_mul, /* doing ecp_mul() */ + ecdsa_sig_modn, /* mod N computations */ + } state; +}; + +/* + * Init verify sign sub-context + */ +static void ecdsa_restart_sig_init( mbedtls_ecdsa_restart_sig_ctx *ctx ) +{ + ctx->sign_tries = 0; + ctx->key_tries = 0; + mbedtls_mpi_init( &ctx->k ); + mbedtls_mpi_init( &ctx->r ); + ctx->state = ecdsa_sig_init; +} + +/* + * Free the components of a sign restart sub-context + */ +static void ecdsa_restart_sig_free( mbedtls_ecdsa_restart_sig_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_mpi_free( &ctx->k ); + mbedtls_mpi_free( &ctx->r ); +} + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) +/* + * Sub-context for ecdsa_sign_det() + */ +struct mbedtls_ecdsa_restart_det +{ + mbedtls_hmac_drbg_context rng_ctx; /* DRBG state */ + enum { /* what to do next? */ + ecdsa_det_init = 0, /* getting started */ + ecdsa_det_sign, /* make signature */ + } state; +}; + +/* + * Init verify sign_det sub-context + */ +static void ecdsa_restart_det_init( mbedtls_ecdsa_restart_det_ctx *ctx ) +{ + mbedtls_hmac_drbg_init( &ctx->rng_ctx ); + ctx->state = ecdsa_det_init; +} + +/* + * Free the components of a sign_det restart sub-context + */ +static void ecdsa_restart_det_free( mbedtls_ecdsa_restart_det_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_hmac_drbg_free( &ctx->rng_ctx ); + + ecdsa_restart_det_init( ctx ); +} +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ + +#define ECDSA_RS_ECP &rs_ctx->ecp + +/* Utility macro for checking and updating ops budget */ +#define ECDSA_BUDGET( ops ) \ + MBEDTLS_MPI_CHK( mbedtls_ecp_check_budget( grp, &rs_ctx->ecp, ops ) ); + +/* Call this when entering a function that needs its own sub-context */ +#define ECDSA_RS_ENTER( SUB ) do { \ + /* reset ops count for this call if top-level */ \ + if( rs_ctx != NULL && rs_ctx->ecp.depth++ == 0 ) \ + rs_ctx->ecp.ops_done = 0; \ + \ + /* set up our own sub-context if needed */ \ + if( mbedtls_ecp_restart_is_enabled() && \ + rs_ctx != NULL && rs_ctx->SUB == NULL ) \ + { \ + rs_ctx->SUB = mbedtls_calloc( 1, sizeof( *rs_ctx->SUB ) ); \ + if( rs_ctx->SUB == NULL ) \ + return( MBEDTLS_ERR_ECP_ALLOC_FAILED ); \ + \ + ecdsa_restart_## SUB ##_init( rs_ctx->SUB ); \ + } \ +} while( 0 ) + +/* Call this when leaving a function that needs its own sub-context */ +#define ECDSA_RS_LEAVE( SUB ) do { \ + /* clear our sub-context when not in progress (done or error) */ \ + if( rs_ctx != NULL && rs_ctx->SUB != NULL && \ + ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) \ + { \ + ecdsa_restart_## SUB ##_free( rs_ctx->SUB ); \ + mbedtls_free( rs_ctx->SUB ); \ + rs_ctx->SUB = NULL; \ + } \ + \ + if( rs_ctx != NULL ) \ + rs_ctx->ecp.depth--; \ +} while( 0 ) + +#else /* MBEDTLS_ECP_RESTARTABLE */ + +#define ECDSA_RS_ECP NULL + +#define ECDSA_BUDGET( ops ) /* no-op; for compatibility */ + +#define ECDSA_RS_ENTER( SUB ) (void) rs_ctx +#define ECDSA_RS_LEAVE( SUB ) (void) rs_ctx + +#endif /* MBEDTLS_ECP_RESTARTABLE */ + /* * Derive a suitable integer for group grp from a buffer of length len * SEC1 4.1.3 step 5 aka SEC1 4.1.4 step 3 @@ -70,13 +250,17 @@ static int derive_mpi( const mbedtls_ecp_group *grp, mbedtls_mpi *x, * Compute ECDSA signature of a hashed message (SEC1 4.1.3) * Obviously, compared to SEC1 4.1.3, we skip step 4 (hash message) */ -int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, +static int ecdsa_sign_restartable( mbedtls_ecp_group *grp, + mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, - int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_ecdsa_restart_ctx *rs_ctx ) { - int ret, key_tries, sign_tries, blind_tries; + int ret, key_tries, sign_tries; + int *p_sign_tries = &sign_tries, *p_key_tries = &key_tries; mbedtls_ecp_point R; mbedtls_mpi k, e, t; + mbedtls_mpi *pk = &k, *pr = r; /* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */ if( grp->N.p == NULL ) @@ -89,26 +273,72 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, mbedtls_ecp_point_init( &R ); mbedtls_mpi_init( &k ); mbedtls_mpi_init( &e ); mbedtls_mpi_init( &t ); - sign_tries = 0; + ECDSA_RS_ENTER( sig ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->sig != NULL ) + { + /* redirect to our context */ + p_sign_tries = &rs_ctx->sig->sign_tries; + p_key_tries = &rs_ctx->sig->key_tries; + pk = &rs_ctx->sig->k; + pr = &rs_ctx->sig->r; + + /* jump to current step */ + if( rs_ctx->sig->state == ecdsa_sig_mul ) + goto mul; + if( rs_ctx->sig->state == ecdsa_sig_modn ) + goto modn; + } +#endif /* MBEDTLS_ECP_RESTARTABLE */ + + *p_sign_tries = 0; do { + if( *p_sign_tries++ > 10 ) + { + ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; + goto cleanup; + } + /* * Steps 1-3: generate a suitable ephemeral keypair * and set r = xR mod n */ - key_tries = 0; + *p_key_tries = 0; do { - MBEDTLS_MPI_CHK( mbedtls_ecp_gen_keypair( grp, &k, &R, f_rng, p_rng ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( r, &R.X, &grp->N ) ); - - if( key_tries++ > 10 ) + if( *p_key_tries++ > 10 ) { ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; goto cleanup; } + + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_privkey( grp, pk, f_rng, p_rng ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->sig != NULL ) + rs_ctx->sig->state = ecdsa_sig_mul; + +mul: +#endif + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_restartable( grp, &R, pk, &grp->G, + f_rng, p_rng, ECDSA_RS_ECP ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( pr, &R.X, &grp->N ) ); } - while( mbedtls_mpi_cmp_int( r, 0 ) == 0 ); + while( mbedtls_mpi_cmp_int( pr, 0 ) == 0 ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->sig != NULL ) + rs_ctx->sig->state = ecdsa_sig_modn; + +modn: +#endif + /* + * Accounting for everything up to the end of the loop + * (step 6, but checking now avoids saving e and t) + */ + ECDSA_BUDGET( MBEDTLS_ECP_OPS_INV + 4 ); /* * Step 5: derive MPI from hashed message @@ -119,57 +349,67 @@ int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, * Generate a random value to blind inv_mod in next step, * avoiding a potential timing leak. */ - blind_tries = 0; - do - { - size_t n_size = ( grp->nbits + 7 ) / 8; - MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &t, n_size, f_rng, p_rng ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &t, 8 * n_size - grp->nbits ) ); - - /* See mbedtls_ecp_gen_keypair() */ - if( ++blind_tries > 30 ) - return( MBEDTLS_ERR_ECP_RANDOM_FAILED ); - } - while( mbedtls_mpi_cmp_int( &t, 1 ) < 0 || - mbedtls_mpi_cmp_mpi( &t, &grp->N ) >= 0 ); + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_privkey( grp, &t, f_rng, p_rng ) ); /* * Step 6: compute s = (e + r * d) / k = t (e + rd) / (kt) mod n */ - MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( s, r, d ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( s, pr, d ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &e, &e, s ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &e, &e, &t ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &k, &k, &t ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( s, &k, &grp->N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( pk, pk, &t ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( s, pk, &grp->N ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( s, s, &e ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( s, s, &grp->N ) ); - - if( sign_tries++ > 10 ) - { - ret = MBEDTLS_ERR_ECP_RANDOM_FAILED; - goto cleanup; - } } while( mbedtls_mpi_cmp_int( s, 0 ) == 0 ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->sig != NULL ) + mbedtls_mpi_copy( r, pr ); +#endif + cleanup: mbedtls_ecp_point_free( &R ); mbedtls_mpi_free( &k ); mbedtls_mpi_free( &e ); mbedtls_mpi_free( &t ); + ECDSA_RS_LEAVE( sig ); + return( ret ); } -#endif /* MBEDTLS_ECDSA_SIGN_ALT */ + +/* + * Compute ECDSA signature of a hashed message + */ +int mbedtls_ecdsa_sign( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, + const mbedtls_mpi *d, const unsigned char *buf, size_t blen, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + ECDSA_VALIDATE_RET( grp != NULL ); + ECDSA_VALIDATE_RET( r != NULL ); + ECDSA_VALIDATE_RET( s != NULL ); + ECDSA_VALIDATE_RET( d != NULL ); + ECDSA_VALIDATE_RET( f_rng != NULL ); + ECDSA_VALIDATE_RET( buf != NULL || blen == 0 ); + + return( ecdsa_sign_restartable( grp, r, s, d, buf, blen, + f_rng, p_rng, NULL ) ); +} +#endif /* !MBEDTLS_ECDSA_SIGN_ALT */ #if defined(MBEDTLS_ECDSA_DETERMINISTIC) /* * Deterministic signature wrapper */ -int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, +static int ecdsa_sign_det_restartable( mbedtls_ecp_group *grp, + mbedtls_mpi *r, mbedtls_mpi *s, const mbedtls_mpi *d, const unsigned char *buf, size_t blen, - mbedtls_md_type_t md_alg ) + mbedtls_md_type_t md_alg, + mbedtls_ecdsa_restart_ctx *rs_ctx ) { int ret; mbedtls_hmac_drbg_context rng_ctx; + mbedtls_hmac_drbg_context *p_rng = &rng_ctx; unsigned char data[2 * MBEDTLS_ECP_MAX_BYTES]; size_t grp_len = ( grp->nbits + 7 ) / 8; const mbedtls_md_info_t *md_info; @@ -181,21 +421,64 @@ int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi mbedtls_mpi_init( &h ); mbedtls_hmac_drbg_init( &rng_ctx ); + ECDSA_RS_ENTER( det ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->det != NULL ) + { + /* redirect to our context */ + p_rng = &rs_ctx->det->rng_ctx; + + /* jump to current step */ + if( rs_ctx->det->state == ecdsa_det_sign ) + goto sign; + } +#endif /* MBEDTLS_ECP_RESTARTABLE */ + /* Use private key and message hash (reduced) to initialize HMAC_DRBG */ MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( d, data, grp_len ) ); MBEDTLS_MPI_CHK( derive_mpi( grp, &h, buf, blen ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_write_binary( &h, data + grp_len, grp_len ) ); - mbedtls_hmac_drbg_seed_buf( &rng_ctx, md_info, data, 2 * grp_len ); + mbedtls_hmac_drbg_seed_buf( p_rng, md_info, data, 2 * grp_len ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->det != NULL ) + rs_ctx->det->state = ecdsa_det_sign; + +sign: +#endif +#if defined(MBEDTLS_ECDSA_SIGN_ALT) ret = mbedtls_ecdsa_sign( grp, r, s, d, buf, blen, - mbedtls_hmac_drbg_random, &rng_ctx ); + mbedtls_hmac_drbg_random, p_rng ); +#else + ret = ecdsa_sign_restartable( grp, r, s, d, buf, blen, + mbedtls_hmac_drbg_random, p_rng, rs_ctx ); +#endif /* MBEDTLS_ECDSA_SIGN_ALT */ cleanup: mbedtls_hmac_drbg_free( &rng_ctx ); mbedtls_mpi_free( &h ); + ECDSA_RS_LEAVE( det ); + return( ret ); } + +/* + * Deterministic signature wrapper + */ +int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi *s, + const mbedtls_mpi *d, const unsigned char *buf, size_t blen, + mbedtls_md_type_t md_alg ) +{ + ECDSA_VALIDATE_RET( grp != NULL ); + ECDSA_VALIDATE_RET( r != NULL ); + ECDSA_VALIDATE_RET( s != NULL ); + ECDSA_VALIDATE_RET( d != NULL ); + ECDSA_VALIDATE_RET( buf != NULL || blen == 0 ); + + return( ecdsa_sign_det_restartable( grp, r, s, d, buf, blen, md_alg, NULL ) ); +} #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ #if !defined(MBEDTLS_ECDSA_VERIFY_ALT) @@ -203,21 +486,40 @@ int mbedtls_ecdsa_sign_det( mbedtls_ecp_group *grp, mbedtls_mpi *r, mbedtls_mpi * Verify ECDSA signature of hashed message (SEC1 4.1.4) * Obviously, compared to SEC1 4.1.3, we skip step 2 (hash message) */ -int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, - const unsigned char *buf, size_t blen, - const mbedtls_ecp_point *Q, const mbedtls_mpi *r, const mbedtls_mpi *s) +static int ecdsa_verify_restartable( mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, + const mbedtls_mpi *r, const mbedtls_mpi *s, + mbedtls_ecdsa_restart_ctx *rs_ctx ) { int ret; mbedtls_mpi e, s_inv, u1, u2; mbedtls_ecp_point R; + mbedtls_mpi *pu1 = &u1, *pu2 = &u2; mbedtls_ecp_point_init( &R ); - mbedtls_mpi_init( &e ); mbedtls_mpi_init( &s_inv ); mbedtls_mpi_init( &u1 ); mbedtls_mpi_init( &u2 ); + mbedtls_mpi_init( &e ); mbedtls_mpi_init( &s_inv ); + mbedtls_mpi_init( &u1 ); mbedtls_mpi_init( &u2 ); /* Fail cleanly on curves such as Curve25519 that can't be used for ECDSA */ if( grp->N.p == NULL ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + ECDSA_RS_ENTER( ver ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ver != NULL ) + { + /* redirect to our context */ + pu1 = &rs_ctx->ver->u1; + pu2 = &rs_ctx->ver->u2; + + /* jump to current step */ + if( rs_ctx->ver->state == ecdsa_ver_muladd ) + goto muladd; + } +#endif /* MBEDTLS_ECP_RESTARTABLE */ + /* * Step 1: make sure r and s are in range 1..n-1 */ @@ -228,11 +530,6 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, goto cleanup; } - /* - * Additional precaution: make sure Q is valid - */ - MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, Q ) ); - /* * Step 3: derive MPI from hashed message */ @@ -241,21 +538,27 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, /* * Step 4: u1 = e / s mod n, u2 = r / s mod n */ + ECDSA_BUDGET( MBEDTLS_ECP_OPS_CHK + MBEDTLS_ECP_OPS_INV + 2 ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &s_inv, s, &grp->N ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &u1, &e, &s_inv ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &u1, &u1, &grp->N ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( pu1, &e, &s_inv ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( pu1, pu1, &grp->N ) ); + + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( pu2, r, &s_inv ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( pu2, pu2, &grp->N ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &u2, r, &s_inv ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &u2, &u2, &grp->N ) ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ver != NULL ) + rs_ctx->ver->state = ecdsa_ver_muladd; +muladd: +#endif /* * Step 5: R = u1 G + u2 Q - * - * Since we're not using any secret data, no need to pass a RNG to - * mbedtls_ecp_mul() for countermesures. */ - MBEDTLS_MPI_CHK( mbedtls_ecp_muladd( grp, &R, &u1, &grp->G, &u2, Q ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_muladd_restartable( grp, + &R, pu1, &grp->G, pu2, Q, ECDSA_RS_ECP ) ); if( mbedtls_ecp_is_zero( &R ) ) { @@ -280,11 +583,32 @@ int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, cleanup: mbedtls_ecp_point_free( &R ); - mbedtls_mpi_free( &e ); mbedtls_mpi_free( &s_inv ); mbedtls_mpi_free( &u1 ); mbedtls_mpi_free( &u2 ); + mbedtls_mpi_free( &e ); mbedtls_mpi_free( &s_inv ); + mbedtls_mpi_free( &u1 ); mbedtls_mpi_free( &u2 ); + + ECDSA_RS_LEAVE( ver ); return( ret ); } -#endif /* MBEDTLS_ECDSA_VERIFY_ALT */ + +/* + * Verify ECDSA signature of hashed message + */ +int mbedtls_ecdsa_verify( mbedtls_ecp_group *grp, + const unsigned char *buf, size_t blen, + const mbedtls_ecp_point *Q, + const mbedtls_mpi *r, + const mbedtls_mpi *s) +{ + ECDSA_VALIDATE_RET( grp != NULL ); + ECDSA_VALIDATE_RET( Q != NULL ); + ECDSA_VALIDATE_RET( r != NULL ); + ECDSA_VALIDATE_RET( s != NULL ); + ECDSA_VALIDATE_RET( buf != NULL || blen == 0 ); + + return( ecdsa_verify_restartable( grp, buf, blen, Q, r, s, NULL ) ); +} +#endif /* !MBEDTLS_ECDSA_VERIFY_ALT */ /* * Convert a signature (given by context) to ASN.1 @@ -313,14 +637,20 @@ static int ecdsa_signature_to_asn1( const mbedtls_mpi *r, const mbedtls_mpi *s, /* * Compute and write signature */ -int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t md_alg, +int mbedtls_ecdsa_write_signature_restartable( mbedtls_ecdsa_context *ctx, + mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) + void *p_rng, + mbedtls_ecdsa_restart_ctx *rs_ctx ) { int ret; mbedtls_mpi r, s; + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( hash != NULL ); + ECDSA_VALIDATE_RET( sig != NULL ); + ECDSA_VALIDATE_RET( slen != NULL ); mbedtls_mpi_init( &r ); mbedtls_mpi_init( &s ); @@ -329,14 +659,19 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t (void) f_rng; (void) p_rng; - MBEDTLS_MPI_CHK( mbedtls_ecdsa_sign_det( &ctx->grp, &r, &s, &ctx->d, - hash, hlen, md_alg ) ); + MBEDTLS_MPI_CHK( ecdsa_sign_det_restartable( &ctx->grp, &r, &s, &ctx->d, + hash, hlen, md_alg, rs_ctx ) ); #else (void) md_alg; +#if defined(MBEDTLS_ECDSA_SIGN_ALT) MBEDTLS_MPI_CHK( mbedtls_ecdsa_sign( &ctx->grp, &r, &s, &ctx->d, hash, hlen, f_rng, p_rng ) ); -#endif +#else + MBEDTLS_MPI_CHK( ecdsa_sign_restartable( &ctx->grp, &r, &s, &ctx->d, + hash, hlen, f_rng, p_rng, rs_ctx ) ); +#endif /* MBEDTLS_ECDSA_SIGN_ALT */ +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ MBEDTLS_MPI_CHK( ecdsa_signature_to_asn1( &r, &s, sig, slen ) ); @@ -347,13 +682,35 @@ int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, mbedtls_md_type_t return( ret ); } -#if ! defined(MBEDTLS_DEPRECATED_REMOVED) && \ +/* + * Compute and write signature + */ +int mbedtls_ecdsa_write_signature( mbedtls_ecdsa_context *ctx, + mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hlen, + unsigned char *sig, size_t *slen, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( hash != NULL ); + ECDSA_VALIDATE_RET( sig != NULL ); + ECDSA_VALIDATE_RET( slen != NULL ); + return( mbedtls_ecdsa_write_signature_restartable( + ctx, md_alg, hash, hlen, sig, slen, f_rng, p_rng, NULL ) ); +} + +#if !defined(MBEDTLS_DEPRECATED_REMOVED) && \ defined(MBEDTLS_ECDSA_DETERMINISTIC) int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, unsigned char *sig, size_t *slen, mbedtls_md_type_t md_alg ) { + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( hash != NULL ); + ECDSA_VALIDATE_RET( sig != NULL ); + ECDSA_VALIDATE_RET( slen != NULL ); return( mbedtls_ecdsa_write_signature( ctx, md_alg, hash, hlen, sig, slen, NULL, NULL ) ); } @@ -365,12 +722,30 @@ int mbedtls_ecdsa_write_signature_det( mbedtls_ecdsa_context *ctx, int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, const unsigned char *hash, size_t hlen, const unsigned char *sig, size_t slen ) +{ + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( hash != NULL ); + ECDSA_VALIDATE_RET( sig != NULL ); + return( mbedtls_ecdsa_read_signature_restartable( + ctx, hash, hlen, sig, slen, NULL ) ); +} + +/* + * Restartable read and check signature + */ +int mbedtls_ecdsa_read_signature_restartable( mbedtls_ecdsa_context *ctx, + const unsigned char *hash, size_t hlen, + const unsigned char *sig, size_t slen, + mbedtls_ecdsa_restart_ctx *rs_ctx ) { int ret; unsigned char *p = (unsigned char *) sig; const unsigned char *end = sig + slen; size_t len; mbedtls_mpi r, s; + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( hash != NULL ); + ECDSA_VALIDATE_RET( sig != NULL ); mbedtls_mpi_init( &r ); mbedtls_mpi_init( &s ); @@ -395,10 +770,15 @@ int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, ret += MBEDTLS_ERR_ECP_BAD_INPUT_DATA; goto cleanup; } - +#if defined(MBEDTLS_ECDSA_VERIFY_ALT) if( ( ret = mbedtls_ecdsa_verify( &ctx->grp, hash, hlen, - &ctx->Q, &r, &s ) ) != 0 ) + &ctx->Q, &r, &s ) ) != 0 ) + goto cleanup; +#else + if( ( ret = ecdsa_verify_restartable( &ctx->grp, hash, hlen, + &ctx->Q, &r, &s, rs_ctx ) ) != 0 ) goto cleanup; +#endif /* MBEDTLS_ECDSA_VERIFY_ALT */ /* At this point we know that the buffer starts with a valid signature. * Return 0 if the buffer just contains the signature, and a specific @@ -420,10 +800,18 @@ int mbedtls_ecdsa_read_signature( mbedtls_ecdsa_context *ctx, int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - return( mbedtls_ecp_group_load( &ctx->grp, gid ) || - mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) ); + int ret = 0; + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( f_rng != NULL ); + + ret = mbedtls_ecp_group_load( &ctx->grp, gid ); + if( ret != 0 ) + return( ret ); + + return( mbedtls_ecp_gen_keypair( &ctx->grp, &ctx->d, + &ctx->Q, f_rng, p_rng ) ); } -#endif /* MBEDTLS_ECDSA_GENKEY_ALT */ +#endif /* !MBEDTLS_ECDSA_GENKEY_ALT */ /* * Set context from an mbedtls_ecp_keypair @@ -431,6 +819,8 @@ int mbedtls_ecdsa_genkey( mbedtls_ecdsa_context *ctx, mbedtls_ecp_group_id gid, int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_keypair *key ) { int ret; + ECDSA_VALIDATE_RET( ctx != NULL ); + ECDSA_VALIDATE_RET( key != NULL ); if( ( ret = mbedtls_ecp_group_copy( &ctx->grp, &key->grp ) ) != 0 || ( ret = mbedtls_mpi_copy( &ctx->d, &key->d ) ) != 0 || @@ -447,6 +837,8 @@ int mbedtls_ecdsa_from_keypair( mbedtls_ecdsa_context *ctx, const mbedtls_ecp_ke */ void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx ) { + ECDSA_VALIDATE( ctx != NULL ); + mbedtls_ecp_keypair_init( ctx ); } @@ -455,7 +847,53 @@ void mbedtls_ecdsa_init( mbedtls_ecdsa_context *ctx ) */ void mbedtls_ecdsa_free( mbedtls_ecdsa_context *ctx ) { + if( ctx == NULL ) + return; + mbedtls_ecp_keypair_free( ctx ); } +#if defined(MBEDTLS_ECP_RESTARTABLE) +/* + * Initialize a restart context + */ +void mbedtls_ecdsa_restart_init( mbedtls_ecdsa_restart_ctx *ctx ) +{ + ECDSA_VALIDATE( ctx != NULL ); + + mbedtls_ecp_restart_init( &ctx->ecp ); + + ctx->ver = NULL; + ctx->sig = NULL; +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + ctx->det = NULL; +#endif +} + +/* + * Free the components of a restart context + */ +void mbedtls_ecdsa_restart_free( mbedtls_ecdsa_restart_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_ecp_restart_free( &ctx->ecp ); + + ecdsa_restart_ver_free( ctx->ver ); + mbedtls_free( ctx->ver ); + ctx->ver = NULL; + + ecdsa_restart_sig_free( ctx->sig ); + mbedtls_free( ctx->sig ); + ctx->sig = NULL; + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + ecdsa_restart_det_free( ctx->det ); + mbedtls_free( ctx->det ); + ctx->det = NULL; +#endif +} +#endif /* MBEDTLS_ECP_RESTARTABLE */ + #endif /* MBEDTLS_ECDSA_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/ecjpake.c b/3rdparty/mbedtls/mbedtls/library/ecjpake.c index ec5a4007db..be941b14b1 100644 --- a/3rdparty/mbedtls/mbedtls/library/ecjpake.c +++ b/3rdparty/mbedtls/mbedtls/library/ecjpake.c @@ -33,11 +33,18 @@ #if defined(MBEDTLS_ECJPAKE_C) #include "mbedtls/ecjpake.h" +#include "mbedtls/platform_util.h" #include #if !defined(MBEDTLS_ECJPAKE_ALT) +/* Parameter validation macros based on platform_util.h */ +#define ECJPAKE_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA ) +#define ECJPAKE_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + /* * Convert a mbedtls_ecjpake_role to identifier string */ @@ -54,8 +61,7 @@ static const char * const ecjpake_id[] = { */ void mbedtls_ecjpake_init( mbedtls_ecjpake_context *ctx ) { - if( ctx == NULL ) - return; + ECJPAKE_VALIDATE( ctx != NULL ); ctx->md_info = NULL; mbedtls_ecp_group_init( &ctx->grp ); @@ -106,6 +112,11 @@ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, { int ret; + ECJPAKE_VALIDATE_RET( ctx != NULL ); + ECJPAKE_VALIDATE_RET( role == MBEDTLS_ECJPAKE_CLIENT || + role == MBEDTLS_ECJPAKE_SERVER ); + ECJPAKE_VALIDATE_RET( secret != NULL || len == 0 ); + ctx->role = role; if( ( ctx->md_info = mbedtls_md_info_from_type( hash ) ) == NULL ) @@ -127,6 +138,8 @@ int mbedtls_ecjpake_setup( mbedtls_ecjpake_context *ctx, */ int mbedtls_ecjpake_check( const mbedtls_ecjpake_context *ctx ) { + ECJPAKE_VALIDATE_RET( ctx != NULL ); + if( ctx->md_info == NULL || ctx->grp.id == MBEDTLS_ECP_DP_NONE || ctx->s.p == NULL ) @@ -504,6 +517,9 @@ int mbedtls_ecjpake_read_round_one( mbedtls_ecjpake_context *ctx, const unsigned char *buf, size_t len ) { + ECJPAKE_VALIDATE_RET( ctx != NULL ); + ECJPAKE_VALIDATE_RET( buf != NULL ); + return( ecjpake_kkpp_read( ctx->md_info, &ctx->grp, ctx->point_format, &ctx->grp.G, &ctx->Xp1, &ctx->Xp2, ID_PEER, @@ -518,6 +534,11 @@ int mbedtls_ecjpake_write_round_one( mbedtls_ecjpake_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { + ECJPAKE_VALIDATE_RET( ctx != NULL ); + ECJPAKE_VALIDATE_RET( buf != NULL ); + ECJPAKE_VALIDATE_RET( olen != NULL ); + ECJPAKE_VALIDATE_RET( f_rng != NULL ); + return( ecjpake_kkpp_write( ctx->md_info, &ctx->grp, ctx->point_format, &ctx->grp.G, &ctx->xm1, &ctx->Xm1, &ctx->xm2, &ctx->Xm2, @@ -560,6 +581,9 @@ int mbedtls_ecjpake_read_round_two( mbedtls_ecjpake_context *ctx, mbedtls_ecp_group grp; mbedtls_ecp_point G; /* C: GB, S: GA */ + ECJPAKE_VALIDATE_RET( ctx != NULL ); + ECJPAKE_VALIDATE_RET( buf != NULL ); + mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &G ); @@ -652,6 +676,11 @@ int mbedtls_ecjpake_write_round_two( mbedtls_ecjpake_context *ctx, const unsigned char *end = buf + len; size_t ec_len; + ECJPAKE_VALIDATE_RET( ctx != NULL ); + ECJPAKE_VALIDATE_RET( buf != NULL ); + ECJPAKE_VALIDATE_RET( olen != NULL ); + ECJPAKE_VALIDATE_RET( f_rng != NULL ); + mbedtls_ecp_point_init( &G ); mbedtls_ecp_point_init( &Xm ); mbedtls_mpi_init( &xm ); @@ -727,6 +756,11 @@ int mbedtls_ecjpake_derive_secret( mbedtls_ecjpake_context *ctx, unsigned char kx[MBEDTLS_ECP_MAX_BYTES]; size_t x_bytes; + ECJPAKE_VALIDATE_RET( ctx != NULL ); + ECJPAKE_VALIDATE_RET( buf != NULL ); + ECJPAKE_VALIDATE_RET( olen != NULL ); + ECJPAKE_VALIDATE_RET( f_rng != NULL ); + *olen = mbedtls_md_get_size( ctx->md_info ); if( len < *olen ) return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL ); diff --git a/3rdparty/mbedtls/mbedtls/library/ecp.c b/3rdparty/mbedtls/mbedtls/library/ecp.c index 75233f8cef..db36191b9b 100644 --- a/3rdparty/mbedtls/mbedtls/library/ecp.c +++ b/3rdparty/mbedtls/mbedtls/library/ecp.c @@ -26,6 +26,7 @@ * GECC = Guide to Elliptic Curve Cryptography - Hankerson, Menezes, Vanstone * FIPS 186-3 http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf * RFC 4492 for the related TLS structures and constants + * RFC 7748 for the Curve448 and Curve25519 curve definitions * * [Curve25519] http://cr.yp.to/ecdh/curve25519-20060209.pdf * @@ -46,15 +47,51 @@ #include MBEDTLS_CONFIG_FILE #endif +/** + * \brief Function level alternative implementation. + * + * The MBEDTLS_ECP_INTERNAL_ALT macro enables alternative implementations to + * replace certain functions in this module. The alternative implementations are + * typically hardware accelerators and need to activate the hardware before the + * computation starts and deactivate it after it finishes. The + * mbedtls_internal_ecp_init() and mbedtls_internal_ecp_free() functions serve + * this purpose. + * + * To preserve the correct functionality the following conditions must hold: + * + * - The alternative implementation must be activated by + * mbedtls_internal_ecp_init() before any of the replaceable functions is + * called. + * - mbedtls_internal_ecp_free() must \b only be called when the alternative + * implementation is activated. + * - mbedtls_internal_ecp_init() must \b not be called when the alternative + * implementation is activated. + * - Public functions must not return while the alternative implementation is + * activated. + * - Replaceable functions are guarded by \c MBEDTLS_ECP_XXX_ALT macros and + * before calling them an \code if( mbedtls_internal_ecp_grp_capable( grp ) ) + * \endcode ensures that the alternative implementation supports the current + * group. + */ +#if defined(MBEDTLS_ECP_INTERNAL_ALT) +#endif + #if defined(MBEDTLS_ECP_C) #include "mbedtls/ecp.h" #include "mbedtls/threading.h" +#include "mbedtls/platform_util.h" #include #if !defined(MBEDTLS_ECP_ALT) +/* Parameter validation macros based on platform_util.h */ +#define ECP_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA ) +#define ECP_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" #else @@ -72,11 +109,6 @@ #define inline __inline #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - #if defined(MBEDTLS_SELF_TEST) /* * Counts of point addition and doubling, and field multiplications. @@ -85,6 +117,233 @@ static void mbedtls_zeroize( void *v, size_t n ) { static unsigned long add_count, dbl_count, mul_count; #endif +#if defined(MBEDTLS_ECP_RESTARTABLE) +/* + * Maximum number of "basic operations" to be done in a row. + * + * Default value 0 means that ECC operations will not yield. + * Note that regardless of the value of ecp_max_ops, always at + * least one step is performed before yielding. + * + * Setting ecp_max_ops=1 can be suitable for testing purposes + * as it will interrupt computation at all possible points. + */ +static unsigned ecp_max_ops = 0; + +/* + * Set ecp_max_ops + */ +void mbedtls_ecp_set_max_ops( unsigned max_ops ) +{ + ecp_max_ops = max_ops; +} + +/* + * Check if restart is enabled + */ +int mbedtls_ecp_restart_is_enabled( void ) +{ + return( ecp_max_ops != 0 ); +} + +/* + * Restart sub-context for ecp_mul_comb() + */ +struct mbedtls_ecp_restart_mul +{ + mbedtls_ecp_point R; /* current intermediate result */ + size_t i; /* current index in various loops, 0 outside */ + mbedtls_ecp_point *T; /* table for precomputed points */ + unsigned char T_size; /* number of points in table T */ + enum { /* what were we doing last time we returned? */ + ecp_rsm_init = 0, /* nothing so far, dummy initial state */ + ecp_rsm_pre_dbl, /* precompute 2^n multiples */ + ecp_rsm_pre_norm_dbl, /* normalize precomputed 2^n multiples */ + ecp_rsm_pre_add, /* precompute remaining points by adding */ + ecp_rsm_pre_norm_add, /* normalize all precomputed points */ + ecp_rsm_comb_core, /* ecp_mul_comb_core() */ + ecp_rsm_final_norm, /* do the final normalization */ + } state; +}; + +/* + * Init restart_mul sub-context + */ +static void ecp_restart_rsm_init( mbedtls_ecp_restart_mul_ctx *ctx ) +{ + mbedtls_ecp_point_init( &ctx->R ); + ctx->i = 0; + ctx->T = NULL; + ctx->T_size = 0; + ctx->state = ecp_rsm_init; +} + +/* + * Free the components of a restart_mul sub-context + */ +static void ecp_restart_rsm_free( mbedtls_ecp_restart_mul_ctx *ctx ) +{ + unsigned char i; + + if( ctx == NULL ) + return; + + mbedtls_ecp_point_free( &ctx->R ); + + if( ctx->T != NULL ) + { + for( i = 0; i < ctx->T_size; i++ ) + mbedtls_ecp_point_free( ctx->T + i ); + mbedtls_free( ctx->T ); + } + + ecp_restart_rsm_init( ctx ); +} + +/* + * Restart context for ecp_muladd() + */ +struct mbedtls_ecp_restart_muladd +{ + mbedtls_ecp_point mP; /* mP value */ + mbedtls_ecp_point R; /* R intermediate result */ + enum { /* what should we do next? */ + ecp_rsma_mul1 = 0, /* first multiplication */ + ecp_rsma_mul2, /* second multiplication */ + ecp_rsma_add, /* addition */ + ecp_rsma_norm, /* normalization */ + } state; +}; + +/* + * Init restart_muladd sub-context + */ +static void ecp_restart_ma_init( mbedtls_ecp_restart_muladd_ctx *ctx ) +{ + mbedtls_ecp_point_init( &ctx->mP ); + mbedtls_ecp_point_init( &ctx->R ); + ctx->state = ecp_rsma_mul1; +} + +/* + * Free the components of a restart_muladd sub-context + */ +static void ecp_restart_ma_free( mbedtls_ecp_restart_muladd_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_ecp_point_free( &ctx->mP ); + mbedtls_ecp_point_free( &ctx->R ); + + ecp_restart_ma_init( ctx ); +} + +/* + * Initialize a restart context + */ +void mbedtls_ecp_restart_init( mbedtls_ecp_restart_ctx *ctx ) +{ + ECP_VALIDATE( ctx != NULL ); + ctx->ops_done = 0; + ctx->depth = 0; + ctx->rsm = NULL; + ctx->ma = NULL; +} + +/* + * Free the components of a restart context + */ +void mbedtls_ecp_restart_free( mbedtls_ecp_restart_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + ecp_restart_rsm_free( ctx->rsm ); + mbedtls_free( ctx->rsm ); + + ecp_restart_ma_free( ctx->ma ); + mbedtls_free( ctx->ma ); + + mbedtls_ecp_restart_init( ctx ); +} + +/* + * Check if we can do the next step + */ +int mbedtls_ecp_check_budget( const mbedtls_ecp_group *grp, + mbedtls_ecp_restart_ctx *rs_ctx, + unsigned ops ) +{ + ECP_VALIDATE_RET( grp != NULL ); + + if( rs_ctx != NULL && ecp_max_ops != 0 ) + { + /* scale depending on curve size: the chosen reference is 256-bit, + * and multiplication is quadratic. Round to the closest integer. */ + if( grp->pbits >= 512 ) + ops *= 4; + else if( grp->pbits >= 384 ) + ops *= 2; + + /* Avoid infinite loops: always allow first step. + * Because of that, however, it's not generally true + * that ops_done <= ecp_max_ops, so the check + * ops_done > ecp_max_ops below is mandatory. */ + if( ( rs_ctx->ops_done != 0 ) && + ( rs_ctx->ops_done > ecp_max_ops || + ops > ecp_max_ops - rs_ctx->ops_done ) ) + { + return( MBEDTLS_ERR_ECP_IN_PROGRESS ); + } + + /* update running count */ + rs_ctx->ops_done += ops; + } + + return( 0 ); +} + +/* Call this when entering a function that needs its own sub-context */ +#define ECP_RS_ENTER( SUB ) do { \ + /* reset ops count for this call if top-level */ \ + if( rs_ctx != NULL && rs_ctx->depth++ == 0 ) \ + rs_ctx->ops_done = 0; \ + \ + /* set up our own sub-context if needed */ \ + if( mbedtls_ecp_restart_is_enabled() && \ + rs_ctx != NULL && rs_ctx->SUB == NULL ) \ + { \ + rs_ctx->SUB = mbedtls_calloc( 1, sizeof( *rs_ctx->SUB ) ); \ + if( rs_ctx->SUB == NULL ) \ + return( MBEDTLS_ERR_ECP_ALLOC_FAILED ); \ + \ + ecp_restart_## SUB ##_init( rs_ctx->SUB ); \ + } \ +} while( 0 ) + +/* Call this when leaving a function that needs its own sub-context */ +#define ECP_RS_LEAVE( SUB ) do { \ + /* clear our sub-context when not in progress (done or error) */ \ + if( rs_ctx != NULL && rs_ctx->SUB != NULL && \ + ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) \ + { \ + ecp_restart_## SUB ##_free( rs_ctx->SUB ); \ + mbedtls_free( rs_ctx->SUB ); \ + rs_ctx->SUB = NULL; \ + } \ + \ + if( rs_ctx != NULL ) \ + rs_ctx->depth--; \ +} while( 0 ) + +#else /* MBEDTLS_ECP_RESTARTABLE */ + +#define ECP_RS_ENTER( sub ) (void) rs_ctx; +#define ECP_RS_LEAVE( sub ) (void) rs_ctx; + +#endif /* MBEDTLS_ECP_RESTARTABLE */ + #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) || \ defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) || \ defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) || \ @@ -99,7 +358,8 @@ static unsigned long add_count, dbl_count, mul_count; #define ECP_SHORTWEIERSTRASS #endif -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \ + defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) #define ECP_MONTGOMERY #endif @@ -245,6 +505,9 @@ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name { const mbedtls_ecp_curve_info *curve_info; + if( name == NULL ) + return( NULL ); + for( curve_info = mbedtls_ecp_curve_list(); curve_info->grp_id != MBEDTLS_ECP_DP_NONE; curve_info++ ) @@ -275,8 +538,7 @@ static inline ecp_curve_type ecp_get_type( const mbedtls_ecp_group *grp ) */ void mbedtls_ecp_point_init( mbedtls_ecp_point *pt ) { - if( pt == NULL ) - return; + ECP_VALIDATE( pt != NULL ); mbedtls_mpi_init( &pt->X ); mbedtls_mpi_init( &pt->Y ); @@ -288,10 +550,23 @@ void mbedtls_ecp_point_init( mbedtls_ecp_point *pt ) */ void mbedtls_ecp_group_init( mbedtls_ecp_group *grp ) { - if( grp == NULL ) - return; - - memset( grp, 0, sizeof( mbedtls_ecp_group ) ); + ECP_VALIDATE( grp != NULL ); + + grp->id = MBEDTLS_ECP_DP_NONE; + mbedtls_mpi_init( &grp->P ); + mbedtls_mpi_init( &grp->A ); + mbedtls_mpi_init( &grp->B ); + mbedtls_ecp_point_init( &grp->G ); + mbedtls_mpi_init( &grp->N ); + grp->pbits = 0; + grp->nbits = 0; + grp->h = 0; + grp->modp = NULL; + grp->t_pre = NULL; + grp->t_post = NULL; + grp->t_data = NULL; + grp->T = NULL; + grp->T_size = 0; } /* @@ -299,8 +574,7 @@ void mbedtls_ecp_group_init( mbedtls_ecp_group *grp ) */ void mbedtls_ecp_keypair_init( mbedtls_ecp_keypair *key ) { - if( key == NULL ) - return; + ECP_VALIDATE( key != NULL ); mbedtls_ecp_group_init( &key->grp ); mbedtls_mpi_init( &key->d ); @@ -346,7 +620,7 @@ void mbedtls_ecp_group_free( mbedtls_ecp_group *grp ) mbedtls_free( grp->T ); } - mbedtls_zeroize( grp, sizeof( mbedtls_ecp_group ) ); + mbedtls_platform_zeroize( grp, sizeof( mbedtls_ecp_group ) ); } /* @@ -368,6 +642,8 @@ void mbedtls_ecp_keypair_free( mbedtls_ecp_keypair *key ) int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ) { int ret; + ECP_VALIDATE_RET( P != NULL ); + ECP_VALIDATE_RET( Q != NULL ); MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &P->X, &Q->X ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &P->Y, &Q->Y ) ); @@ -382,7 +658,10 @@ int mbedtls_ecp_copy( mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ) */ int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src ) { - return mbedtls_ecp_group_load( dst, src->id ); + ECP_VALIDATE_RET( dst != NULL ); + ECP_VALIDATE_RET( src != NULL ); + + return( mbedtls_ecp_group_load( dst, src->id ) ); } /* @@ -391,6 +670,7 @@ int mbedtls_ecp_group_copy( mbedtls_ecp_group *dst, const mbedtls_ecp_group *src int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt ) { int ret; + ECP_VALIDATE_RET( pt != NULL ); MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->X , 1 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &pt->Y , 1 ) ); @@ -405,6 +685,8 @@ int mbedtls_ecp_set_zero( mbedtls_ecp_point *pt ) */ int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt ) { + ECP_VALIDATE_RET( pt != NULL ); + return( mbedtls_mpi_cmp_int( &pt->Z, 0 ) == 0 ); } @@ -414,6 +696,9 @@ int mbedtls_ecp_is_zero( mbedtls_ecp_point *pt ) int mbedtls_ecp_point_cmp( const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q ) { + ECP_VALIDATE_RET( P != NULL ); + ECP_VALIDATE_RET( Q != NULL ); + if( mbedtls_mpi_cmp_mpi( &P->X, &Q->X ) == 0 && mbedtls_mpi_cmp_mpi( &P->Y, &Q->Y ) == 0 && mbedtls_mpi_cmp_mpi( &P->Z, &Q->Z ) == 0 ) @@ -431,6 +716,9 @@ int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix, const char *x, const char *y ) { int ret; + ECP_VALIDATE_RET( P != NULL ); + ECP_VALIDATE_RET( x != NULL ); + ECP_VALIDATE_RET( y != NULL ); MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &P->X, radix, x ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &P->Y, radix, y ) ); @@ -443,16 +731,19 @@ int mbedtls_ecp_point_read_string( mbedtls_ecp_point *P, int radix, /* * Export a point into unsigned binary data (SEC1 2.3.3) */ -int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *P, - int format, size_t *olen, - unsigned char *buf, size_t buflen ) +int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, + const mbedtls_ecp_point *P, + int format, size_t *olen, + unsigned char *buf, size_t buflen ) { int ret = 0; size_t plen; - - if( format != MBEDTLS_ECP_PF_UNCOMPRESSED && - format != MBEDTLS_ECP_PF_COMPRESSED ) - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( P != NULL ); + ECP_VALIDATE_RET( olen != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( format == MBEDTLS_ECP_PF_UNCOMPRESSED || + format == MBEDTLS_ECP_PF_COMPRESSED ); /* * Common case: P == 0 @@ -499,11 +790,15 @@ int mbedtls_ecp_point_write_binary( const mbedtls_ecp_group *grp, const mbedtls_ /* * Import a point from unsigned binary data (SEC1 2.3.4) */ -int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, - const unsigned char *buf, size_t ilen ) +int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt, + const unsigned char *buf, size_t ilen ) { int ret; size_t plen; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( pt != NULL ); + ECP_VALIDATE_RET( buf != NULL ); if( ilen < 1 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); @@ -538,11 +833,16 @@ int mbedtls_ecp_point_read_binary( const mbedtls_ecp_group *grp, mbedtls_ecp_poi * opaque point <1..2^8-1>; * } ECPoint; */ -int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point *pt, - const unsigned char **buf, size_t buf_len ) +int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *pt, + const unsigned char **buf, size_t buf_len ) { unsigned char data_len; const unsigned char *buf_start; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( pt != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( *buf != NULL ); /* * We must have at least two bytes (1 for length, at least one for data) @@ -560,7 +860,7 @@ int mbedtls_ecp_tls_read_point( const mbedtls_ecp_group *grp, mbedtls_ecp_point buf_start = *buf; *buf += data_len; - return mbedtls_ecp_point_read_binary( grp, pt, buf_start, data_len ); + return( mbedtls_ecp_point_read_binary( grp, pt, buf_start, data_len ) ); } /* @@ -574,6 +874,12 @@ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp unsigned char *buf, size_t blen ) { int ret; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( pt != NULL ); + ECP_VALIDATE_RET( olen != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( format == MBEDTLS_ECP_PF_UNCOMPRESSED || + format == MBEDTLS_ECP_PF_COMPRESSED ); /* * buffer length must be at least one, for our length byte @@ -597,10 +903,33 @@ int mbedtls_ecp_tls_write_point( const mbedtls_ecp_group *grp, const mbedtls_ecp /* * Set a group from an ECParameters record (RFC 4492) */ -int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **buf, size_t len ) +int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, + const unsigned char **buf, size_t len ) +{ + int ret; + mbedtls_ecp_group_id grp_id; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( *buf != NULL ); + + if( ( ret = mbedtls_ecp_tls_read_group_id( &grp_id, buf, len ) ) != 0 ) + return( ret ); + + return( mbedtls_ecp_group_load( grp, grp_id ) ); +} + +/* + * Read a group id from an ECParameters record (RFC 4492) and convert it to + * mbedtls_ecp_group_id. + */ +int mbedtls_ecp_tls_read_group_id( mbedtls_ecp_group_id *grp, + const unsigned char **buf, size_t len ) { uint16_t tls_id; const mbedtls_ecp_curve_info *curve_info; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( *buf != NULL ); /* * We expect at least three bytes (see below) @@ -624,7 +953,9 @@ int mbedtls_ecp_tls_read_group( mbedtls_ecp_group *grp, const unsigned char **bu if( ( curve_info = mbedtls_ecp_curve_info_from_tls_id( tls_id ) ) == NULL ) return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); - return mbedtls_ecp_group_load( grp, curve_info->grp_id ); + *grp = curve_info->grp_id; + + return( 0 ); } /* @@ -634,6 +965,9 @@ int mbedtls_ecp_tls_write_group( const mbedtls_ecp_group *grp, size_t *olen, unsigned char *buf, size_t blen ) { const mbedtls_ecp_curve_info *curve_info; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( buf != NULL ); + ECP_VALIDATE_RET( olen != NULL ); if( ( curve_info = mbedtls_ecp_curve_info_from_grp_id( grp->id ) ) == NULL ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); @@ -712,25 +1046,29 @@ static int ecp_modp( mbedtls_mpi *N, const mbedtls_ecp_group *grp ) #define INC_MUL_COUNT #endif -#define MOD_MUL( N ) do { MBEDTLS_MPI_CHK( ecp_modp( &N, grp ) ); INC_MUL_COUNT } \ - while( 0 ) +#define MOD_MUL( N ) \ + do \ + { \ + MBEDTLS_MPI_CHK( ecp_modp( &(N), grp ) ); \ + INC_MUL_COUNT \ + } while( 0 ) /* * Reduce a mbedtls_mpi mod p in-place, to use after mbedtls_mpi_sub_mpi * N->s < 0 is a very fast test, which fails only if N is 0 */ -#define MOD_SUB( N ) \ - while( N.s < 0 && mbedtls_mpi_cmp_int( &N, 0 ) != 0 ) \ - MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &N, &N, &grp->P ) ) +#define MOD_SUB( N ) \ + while( (N).s < 0 && mbedtls_mpi_cmp_int( &(N), 0 ) != 0 ) \ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &(N), &(N), &grp->P ) ) /* * Reduce a mbedtls_mpi mod p in-place, to use after mbedtls_mpi_add_mpi and mbedtls_mpi_mul_int. * We known P, N and the result are positive, so sub_abs is correct, and * a bit faster. */ -#define MOD_ADD( N ) \ - while( mbedtls_mpi_cmp_mpi( &N, &grp->P ) >= 0 ) \ - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &N, &N, &grp->P ) ) +#define MOD_ADD( N ) \ + while( mbedtls_mpi_cmp_mpi( &(N), &grp->P ) >= 0 ) \ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( &(N), &(N), &grp->P ) ) #if defined(ECP_SHORTWEIERSTRASS) /* @@ -754,11 +1092,10 @@ static int ecp_normalize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *p return( 0 ); #if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_normalize_jac( grp, pt ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_normalize_jac( grp, pt ) ); #endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */ + mbedtls_mpi_init( &Zi ); mbedtls_mpi_init( &ZZi ); /* @@ -798,32 +1135,33 @@ static int ecp_normalize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *p * Cost: 1N(t) := 1I + (6t - 3)M + 1S */ static int ecp_normalize_jac_many( const mbedtls_ecp_group *grp, - mbedtls_ecp_point *T[], size_t t_len ) + mbedtls_ecp_point *T[], size_t T_size ) { int ret; size_t i; mbedtls_mpi *c, u, Zi, ZZi; - if( t_len < 2 ) + if( T_size < 2 ) return( ecp_normalize_jac( grp, *T ) ); #if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_normalize_jac_many(grp, T, t_len); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_normalize_jac_many( grp, T, T_size ) ); #endif - if( ( c = mbedtls_calloc( t_len, sizeof( mbedtls_mpi ) ) ) == NULL ) + if( ( c = mbedtls_calloc( T_size, sizeof( mbedtls_mpi ) ) ) == NULL ) return( MBEDTLS_ERR_ECP_ALLOC_FAILED ); + for( i = 0; i < T_size; i++ ) + mbedtls_mpi_init( &c[i] ); + mbedtls_mpi_init( &u ); mbedtls_mpi_init( &Zi ); mbedtls_mpi_init( &ZZi ); /* * c[i] = Z_0 * ... * Z_i */ MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &c[0], &T[0]->Z ) ); - for( i = 1; i < t_len; i++ ) + for( i = 1; i < T_size; i++ ) { MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &c[i], &c[i-1], &T[i]->Z ) ); MOD_MUL( c[i] ); @@ -832,9 +1170,9 @@ static int ecp_normalize_jac_many( const mbedtls_ecp_group *grp, /* * u = 1 / (Z_0 * ... * Z_n) mod P */ - MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &u, &c[t_len-1], &grp->P ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &u, &c[T_size-1], &grp->P ) ); - for( i = t_len - 1; ; i-- ) + for( i = T_size - 1; ; i-- ) { /* * Zi = 1 / Z_i mod p @@ -874,7 +1212,7 @@ static int ecp_normalize_jac_many( const mbedtls_ecp_group *grp, cleanup: mbedtls_mpi_free( &u ); mbedtls_mpi_free( &Zi ); mbedtls_mpi_free( &ZZi ); - for( i = 0; i < t_len; i++ ) + for( i = 0; i < T_size; i++ ) mbedtls_mpi_free( &c[i] ); mbedtls_free( c ); @@ -931,10 +1269,8 @@ static int ecp_double_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, #endif #if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_double_jac( grp, R, P ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_double_jac( grp, R, P ) ); #endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */ mbedtls_mpi_init( &M ); mbedtls_mpi_init( &S ); mbedtls_mpi_init( &T ); mbedtls_mpi_init( &U ); @@ -1029,10 +1365,8 @@ static int ecp_add_mixed( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, #endif #if defined(MBEDTLS_ECP_ADD_MIXED_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_add_mixed( grp, R, P, Q ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_add_mixed( grp, R, P, Q ) ); #endif /* MBEDTLS_ECP_ADD_MIXED_ALT */ /* @@ -1116,10 +1450,8 @@ static int ecp_randomize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *p int count = 0; #if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_randomize_jac( grp, pt, f_rng, p_rng ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_randomize_jac( grp, pt, f_rng, p_rng ) ); #endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */ p_size = ( grp->pbits + 7 ) / 8; @@ -1175,11 +1507,38 @@ static int ecp_randomize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *p * modified version that provides resistance to SPA by avoiding zero * digits in the representation as in [3]. We modify the method further by * requiring that all K_i be odd, which has the small cost that our - * representation uses one more K_i, due to carries. + * representation uses one more K_i, due to carries, but saves on the size of + * the precomputed table. + * + * Summary of the comb method and its modifications: * - * Also, for the sake of compactness, only the seven low-order bits of x[i] - * are used to represent K_i, and the msb of x[i] encodes the the sign (s_i in - * the paper): it is set if and only if if s_i == -1; + * - The goal is to compute m*P for some w*d-bit integer m. + * + * - The basic comb method splits m into the w-bit integers + * x[0] .. x[d-1] where x[i] consists of the bits in m whose + * index has residue i modulo d, and computes m * P as + * S[x[0]] + 2 * S[x[1]] + .. + 2^(d-1) S[x[d-1]], where + * S[i_{w-1} .. i_0] := i_{w-1} 2^{(w-1)d} P + ... + i_1 2^d P + i_0 P. + * + * - If it happens that, say, x[i+1]=0 (=> S[x[i+1]]=0), one can replace the sum by + * .. + 2^{i-1} S[x[i-1]] - 2^i S[x[i]] + 2^{i+1} S[x[i]] + 2^{i+2} S[x[i+2]] .., + * thereby successively converting it into a form where all summands + * are nonzero, at the cost of negative summands. This is the basic idea of [3]. + * + * - More generally, even if x[i+1] != 0, we can first transform the sum as + * .. - 2^i S[x[i]] + 2^{i+1} ( S[x[i]] + S[x[i+1]] ) + 2^{i+2} S[x[i+2]] .., + * and then replace S[x[i]] + S[x[i+1]] = S[x[i] ^ x[i+1]] + 2 S[x[i] & x[i+1]]. + * Performing and iterating this procedure for those x[i] that are even + * (keeping track of carry), we can transform the original sum into one of the form + * S[x'[0]] +- 2 S[x'[1]] +- .. +- 2^{d-1} S[x'[d-1]] + 2^d S[x'[d]] + * with all x'[i] odd. It is therefore only necessary to know S at odd indices, + * which is why we are only computing half of it in the first place in + * ecp_precompute_comb and accessing it with index abs(i) / 2 in ecp_select_comb. + * + * - For the sake of compactness, only the seven low-order bits of x[i] + * are used to represent its absolute value (K_i in the paper), and the msb + * of x[i] encodes the sign (s_i in the paper): it is set if and only if + * if s_i == -1; * * Calling conventions: * - x is an array of size d + 1 @@ -1188,8 +1547,8 @@ static int ecp_randomize_jac( const mbedtls_ecp_group *grp, mbedtls_ecp_point *p * - m is the MPI, expected to be odd and such that bitlength(m) <= w * d * (the result will be incorrect if these assumptions are not satisfied) */ -static void ecp_comb_fixed( unsigned char x[], size_t d, - unsigned char w, const mbedtls_mpi *m ) +static void ecp_comb_recode_core( unsigned char x[], size_t d, + unsigned char w, const mbedtls_mpi *m ) { size_t i, j; unsigned char c, cc, adjust; @@ -1219,70 +1578,178 @@ static void ecp_comb_fixed( unsigned char x[], size_t d, } /* - * Precompute points for the comb method + * Precompute points for the adapted comb method * - * If i = i_{w-1} ... i_1 is the binary representation of i, then - * T[i] = i_{w-1} 2^{(w-1)d} P + ... + i_1 2^d P + P + * Assumption: T must be able to hold 2^{w - 1} elements. * - * T must be able to hold 2^{w - 1} elements + * Operation: If i = i_{w-1} ... i_1 is the binary representation of i, + * sets T[i] = i_{w-1} 2^{(w-1)d} P + ... + i_1 2^d P + P. * * Cost: d(w-1) D + (2^{w-1} - 1) A + 1 N(w-1) + 1 N(2^{w-1} - 1) + * + * Note: Even comb values (those where P would be omitted from the + * sum defining T[i] above) are not needed in our adaption + * the comb method. See ecp_comb_recode_core(). + * + * This function currently works in four steps: + * (1) [dbl] Computation of intermediate T[i] for 2-power values of i + * (2) [norm_dbl] Normalization of coordinates of these T[i] + * (3) [add] Computation of all T[i] + * (4) [norm_add] Normalization of all T[i] + * + * Step 1 can be interrupted but not the others; together with the final + * coordinate normalization they are the largest steps done at once, depending + * on the window size. Here are operation counts for P-256: + * + * step (2) (3) (4) + * w = 5 142 165 208 + * w = 4 136 77 160 + * w = 3 130 33 136 + * w = 2 124 11 124 + * + * So if ECC operations are blocking for too long even with a low max_ops + * value, it's useful to set MBEDTLS_ECP_WINDOW_SIZE to a lower value in order + * to minimize maximum blocking time. */ static int ecp_precompute_comb( const mbedtls_ecp_group *grp, mbedtls_ecp_point T[], const mbedtls_ecp_point *P, - unsigned char w, size_t d ) + unsigned char w, size_t d, + mbedtls_ecp_restart_ctx *rs_ctx ) { int ret; - unsigned char i, k; - size_t j; + unsigned char i; + size_t j = 0; + const unsigned char T_size = 1U << ( w - 1 ); mbedtls_ecp_point *cur, *TT[COMB_MAX_PRE - 1]; +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + { + if( rs_ctx->rsm->state == ecp_rsm_pre_dbl ) + goto dbl; + if( rs_ctx->rsm->state == ecp_rsm_pre_norm_dbl ) + goto norm_dbl; + if( rs_ctx->rsm->state == ecp_rsm_pre_add ) + goto add; + if( rs_ctx->rsm->state == ecp_rsm_pre_norm_add ) + goto norm_add; + } +#else + (void) rs_ctx; +#endif + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + { + rs_ctx->rsm->state = ecp_rsm_pre_dbl; + + /* initial state for the loop */ + rs_ctx->rsm->i = 0; + } + +dbl: +#endif /* * Set T[0] = P and * T[2^{l-1}] = 2^{dl} P for l = 1 .. w-1 (this is not the final value) */ MBEDTLS_MPI_CHK( mbedtls_ecp_copy( &T[0], P ) ); - k = 0; - for( i = 1; i < ( 1U << ( w - 1 ) ); i <<= 1 ) +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->i != 0 ) + j = rs_ctx->rsm->i; + else +#endif + j = 0; + + for( ; j < d * ( w - 1 ); j++ ) { + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_DBL ); + + i = 1U << ( j / d ); cur = T + i; - MBEDTLS_MPI_CHK( mbedtls_ecp_copy( cur, T + ( i >> 1 ) ) ); - for( j = 0; j < d; j++ ) - MBEDTLS_MPI_CHK( ecp_double_jac( grp, cur, cur ) ); - TT[k++] = cur; + if( j % d == 0 ) + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( cur, T + ( i >> 1 ) ) ); + + MBEDTLS_MPI_CHK( ecp_double_jac( grp, cur, cur ) ); } - MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, k ) ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + rs_ctx->rsm->state = ecp_rsm_pre_norm_dbl; + +norm_dbl: +#endif + /* + * Normalize current elements in T. As T has holes, + * use an auxiliary array of pointers to elements in T. + */ + j = 0; + for( i = 1; i < T_size; i <<= 1 ) + TT[j++] = T + i; + + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_INV + 6 * j - 2 ); + + MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, j ) ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + rs_ctx->rsm->state = ecp_rsm_pre_add; + +add: +#endif /* * Compute the remaining ones using the minimal number of additions * Be careful to update T[2^l] only after using it! */ - k = 0; - for( i = 1; i < ( 1U << ( w - 1 ) ); i <<= 1 ) + MBEDTLS_ECP_BUDGET( ( T_size - 1 ) * MBEDTLS_ECP_OPS_ADD ); + + for( i = 1; i < T_size; i <<= 1 ) { j = i; while( j-- ) - { MBEDTLS_MPI_CHK( ecp_add_mixed( grp, &T[i + j], &T[j], &T[i] ) ); - TT[k++] = &T[i + j]; - } } - MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, k ) ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + rs_ctx->rsm->state = ecp_rsm_pre_norm_add; + +norm_add: +#endif + /* + * Normalize final elements in T. Even though there are no holes now, we + * still need the auxiliary array for homogeneity with the previous + * call. Also, skip T[0] which is already normalised, being a copy of P. + */ + for( j = 0; j + 1 < T_size; j++ ) + TT[j] = T + j + 1; + + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_INV + 6 * j - 2 ); + + MBEDTLS_MPI_CHK( ecp_normalize_jac_many( grp, TT, j ) ); cleanup: +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL && + ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + { + if( rs_ctx->rsm->state == ecp_rsm_pre_dbl ) + rs_ctx->rsm->i = j; + } +#endif return( ret ); } /* * Select precomputed point: R = sign(i) * T[ abs(i) / 2 ] + * + * See ecp_comb_recode_core() for background */ static int ecp_select_comb( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, - const mbedtls_ecp_point T[], unsigned char t_len, + const mbedtls_ecp_point T[], unsigned char T_size, unsigned char i ) { int ret; @@ -1292,7 +1759,7 @@ static int ecp_select_comb( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, ii = ( i & 0x7Fu ) >> 1; /* Read the whole table to thwart cache-based timing attacks */ - for( j = 0; j < t_len; j++ ) + for( j = 0; j < T_size; j++ ) { MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &R->X, &T[j].X, j == ii ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &R->Y, &T[j].Y, j == ii ) ); @@ -1312,10 +1779,11 @@ static int ecp_select_comb( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, * Cost: d A + d D + 1 R */ static int ecp_mul_comb_core( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R, - const mbedtls_ecp_point T[], unsigned char t_len, + const mbedtls_ecp_point T[], unsigned char T_size, const unsigned char x[], size_t d, int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) + void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ) { int ret; mbedtls_ecp_point Txi; @@ -1323,17 +1791,42 @@ static int ecp_mul_comb_core( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R mbedtls_ecp_point_init( &Txi ); - /* Start with a non-zero point and randomize its coordinates */ - i = d; - MBEDTLS_MPI_CHK( ecp_select_comb( grp, R, T, t_len, x[i] ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->Z, 1 ) ); - if( f_rng != 0 ) - MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, R, f_rng, p_rng ) ); +#if !defined(MBEDTLS_ECP_RESTARTABLE) + (void) rs_ctx; +#endif + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL && + rs_ctx->rsm->state != ecp_rsm_comb_core ) + { + rs_ctx->rsm->i = 0; + rs_ctx->rsm->state = ecp_rsm_comb_core; + } + + /* new 'if' instead of nested for the sake of the 'else' branch */ + if( rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->i != 0 ) + { + /* restore current index (R already pointing to rs_ctx->rsm->R) */ + i = rs_ctx->rsm->i; + } + else +#endif + { + /* Start with a non-zero point and randomize its coordinates */ + i = d; + MBEDTLS_MPI_CHK( ecp_select_comb( grp, R, T, T_size, x[i] ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &R->Z, 1 ) ); + if( f_rng != 0 ) + MBEDTLS_MPI_CHK( ecp_randomize_jac( grp, R, f_rng, p_rng ) ); + } - while( i-- != 0 ) + while( i != 0 ) { + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_DBL + MBEDTLS_ECP_OPS_ADD ); + --i; + MBEDTLS_MPI_CHK( ecp_double_jac( grp, R, R ) ); - MBEDTLS_MPI_CHK( ecp_select_comb( grp, &Txi, T, t_len, x[i] ) ); + MBEDTLS_MPI_CHK( ecp_select_comb( grp, &Txi, T, T_size, x[i] ) ); MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, R, &Txi ) ); } @@ -1341,32 +1834,130 @@ static int ecp_mul_comb_core( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R mbedtls_ecp_point_free( &Txi ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL && + ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + { + rs_ctx->rsm->i = i; + /* no need to save R, already pointing to rs_ctx->rsm->R */ + } +#endif + return( ret ); } /* - * Multiplication using the comb method, - * for curves in short Weierstrass form - */ -static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, - const mbedtls_mpi *m, const mbedtls_ecp_point *P, - int (*f_rng)(void *, unsigned char *, size_t), - void *p_rng ) + * Recode the scalar to get constant-time comb multiplication + * + * As the actual scalar recoding needs an odd scalar as a starting point, + * this wrapper ensures that by replacing m by N - m if necessary, and + * informs the caller that the result of multiplication will be negated. + * + * This works because we only support large prime order for Short Weierstrass + * curves, so N is always odd hence either m or N - m is. + * + * See ecp_comb_recode_core() for background. + */ +static int ecp_comb_recode_scalar( const mbedtls_ecp_group *grp, + const mbedtls_mpi *m, + unsigned char k[COMB_MAX_D + 1], + size_t d, + unsigned char w, + unsigned char *parity_trick ) { int ret; - unsigned char w, m_is_odd, p_eq_g, pre_len, i; - size_t d; - unsigned char k[COMB_MAX_D + 1]; - mbedtls_ecp_point *T; mbedtls_mpi M, mm; mbedtls_mpi_init( &M ); mbedtls_mpi_init( &mm ); - /* we need N to be odd to trnaform m in an odd number, check now */ + /* N is always odd (see above), just make extra sure */ if( mbedtls_mpi_get_bit( &grp->N, 0 ) != 1 ) return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + /* do we need the parity trick? */ + *parity_trick = ( mbedtls_mpi_get_bit( m, 0 ) == 0 ); + + /* execute parity fix in constant time */ + MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &M, m ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &mm, &grp->N, m ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &M, &mm, *parity_trick ) ); + + /* actual scalar recoding */ + ecp_comb_recode_core( k, d, w, &M ); + +cleanup: + mbedtls_mpi_free( &mm ); + mbedtls_mpi_free( &M ); + + return( ret ); +} + +/* + * Perform comb multiplication (for short Weierstrass curves) + * once the auxiliary table has been pre-computed. + * + * Scalar recoding may use a parity trick that makes us compute -m * P, + * if that is the case we'll need to recover m * P at the end. + */ +static int ecp_mul_comb_after_precomp( const mbedtls_ecp_group *grp, + mbedtls_ecp_point *R, + const mbedtls_mpi *m, + const mbedtls_ecp_point *T, + unsigned char T_size, + unsigned char w, + size_t d, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ) +{ + int ret; + unsigned char parity_trick; + unsigned char k[COMB_MAX_D + 1]; + mbedtls_ecp_point *RR = R; + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + { + RR = &rs_ctx->rsm->R; + + if( rs_ctx->rsm->state == ecp_rsm_final_norm ) + goto final_norm; + } +#endif + + MBEDTLS_MPI_CHK( ecp_comb_recode_scalar( grp, m, k, d, w, + &parity_trick ) ); + MBEDTLS_MPI_CHK( ecp_mul_comb_core( grp, RR, T, T_size, k, d, + f_rng, p_rng, rs_ctx ) ); + MBEDTLS_MPI_CHK( ecp_safe_invert_jac( grp, RR, parity_trick ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + rs_ctx->rsm->state = ecp_rsm_final_norm; + +final_norm: +#endif + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_INV ); + MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, RR ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL ) + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, RR ) ); +#endif + +cleanup: + return( ret ); +} + +/* + * Pick window size based on curve size and whether we optimize for base point + */ +static unsigned char ecp_pick_window_size( const mbedtls_ecp_group *grp, + unsigned char p_eq_g ) +{ + unsigned char w; + /* * Minimize the number of multiplications, that is minimize * 10 * d * w + 18 * 2^(w-1) + 11 * d + 7 * w, with d = ceil( nbits / w ) @@ -1379,14 +1970,8 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, * Just adding one avoids upping the cost of the first mul too much, * and the memory cost too. */ -#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 - p_eq_g = ( mbedtls_mpi_cmp_mpi( &P->Y, &grp->G.Y ) == 0 && - mbedtls_mpi_cmp_mpi( &P->X, &grp->G.X ) == 0 ); if( p_eq_g ) w++; -#else - p_eq_g = 0; -#endif /* * Make sure w is within bounds. @@ -1397,75 +1982,140 @@ static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, if( w >= grp->nbits ) w = 2; - /* Other sizes that depend on w */ - pre_len = 1U << ( w - 1 ); + return( w ); +} + +/* + * Multiplication using the comb method - for curves in short Weierstrass form + * + * This function is mainly responsible for administrative work: + * - managing the restart context if enabled + * - managing the table of precomputed points (passed between the below two + * functions): allocation, computation, ownership tranfer, freeing. + * + * It delegates the actual arithmetic work to: + * ecp_precompute_comb() and ecp_mul_comb_with_precomp() + * + * See comments on ecp_comb_recode_core() regarding the computation strategy. + */ +static int ecp_mul_comb( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ) +{ + int ret; + unsigned char w, p_eq_g, i; + size_t d; + unsigned char T_size, T_ok; + mbedtls_ecp_point *T; + + ECP_RS_ENTER( rsm ); + + /* Is P the base point ? */ +#if MBEDTLS_ECP_FIXED_POINT_OPTIM == 1 + p_eq_g = ( mbedtls_mpi_cmp_mpi( &P->Y, &grp->G.Y ) == 0 && + mbedtls_mpi_cmp_mpi( &P->X, &grp->G.X ) == 0 ); +#else + p_eq_g = 0; +#endif + + /* Pick window size and deduce related sizes */ + w = ecp_pick_window_size( grp, p_eq_g ); + T_size = 1U << ( w - 1 ); d = ( grp->nbits + w - 1 ) / w; - /* - * Prepare precomputed points: if P == G we want to - * use grp->T if already initialized, or initialize it. - */ - T = p_eq_g ? grp->T : NULL; + /* Pre-computed table: do we have it already for the base point? */ + if( p_eq_g && grp->T != NULL ) + { + /* second pointer to the same table, will be deleted on exit */ + T = grp->T; + T_ok = 1; + } + else +#if defined(MBEDTLS_ECP_RESTARTABLE) + /* Pre-computed table: do we have one in progress? complete? */ + if( rs_ctx != NULL && rs_ctx->rsm != NULL && rs_ctx->rsm->T != NULL ) + { + /* transfer ownership of T from rsm to local function */ + T = rs_ctx->rsm->T; + rs_ctx->rsm->T = NULL; + rs_ctx->rsm->T_size = 0; - if( T == NULL ) + /* This effectively jumps to the call to mul_comb_after_precomp() */ + T_ok = rs_ctx->rsm->state >= ecp_rsm_comb_core; + } + else +#endif + /* Allocate table if we didn't have any */ { - T = mbedtls_calloc( pre_len, sizeof( mbedtls_ecp_point ) ); + T = mbedtls_calloc( T_size, sizeof( mbedtls_ecp_point ) ); if( T == NULL ) { ret = MBEDTLS_ERR_ECP_ALLOC_FAILED; goto cleanup; } - MBEDTLS_MPI_CHK( ecp_precompute_comb( grp, T, P, w, d ) ); + for( i = 0; i < T_size; i++ ) + mbedtls_ecp_point_init( &T[i] ); + + T_ok = 0; + } + + /* Compute table (or finish computing it) if not done already */ + if( !T_ok ) + { + MBEDTLS_MPI_CHK( ecp_precompute_comb( grp, T, P, w, d, rs_ctx ) ); if( p_eq_g ) { + /* almost transfer ownership of T to the group, but keep a copy of + * the pointer to use for calling the next function more easily */ grp->T = T; - grp->T_size = pre_len; + grp->T_size = T_size; } } - /* - * Make sure M is odd (M = m or M = N - m, since N is odd) - * using the fact that m * P = - (N - m) * P - */ - m_is_odd = ( mbedtls_mpi_get_bit( m, 0 ) == 1 ); - MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &M, m ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &mm, &grp->N, m ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( &M, &mm, ! m_is_odd ) ); + /* Actual comb multiplication using precomputed points */ + MBEDTLS_MPI_CHK( ecp_mul_comb_after_precomp( grp, R, m, + T, T_size, w, d, + f_rng, p_rng, rs_ctx ) ); - /* - * Go for comb multiplication, R = M * P - */ - ecp_comb_fixed( k, d, w, &M ); - MBEDTLS_MPI_CHK( ecp_mul_comb_core( grp, R, T, pre_len, k, d, f_rng, p_rng ) ); +cleanup: - /* - * Now get m * P from M * P and normalize it - */ - MBEDTLS_MPI_CHK( ecp_safe_invert_jac( grp, R, ! m_is_odd ) ); - MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) ); + /* does T belong to the group? */ + if( T == grp->T ) + T = NULL; -cleanup: + /* does T belong to the restart context? */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->rsm != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS && T != NULL ) + { + /* transfer ownership of T from local function to rsm */ + rs_ctx->rsm->T_size = T_size; + rs_ctx->rsm->T = T; + T = NULL; + } +#endif - /* There are two cases where T is not stored in grp: - * - P != G - * - An intermediate operation failed before setting grp->T - * In either case, T must be freed. - */ - if( T != NULL && T != grp->T ) + /* did T belong to us? then let's destroy it! */ + if( T != NULL ) { - for( i = 0; i < pre_len; i++ ) + for( i = 0; i < T_size; i++ ) mbedtls_ecp_point_free( &T[i] ); mbedtls_free( T ); } - mbedtls_mpi_free( &M ); - mbedtls_mpi_free( &mm ); - + /* don't free R while in progress in case R == P */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) +#endif + /* prevent caller from using invalid value */ if( ret != 0 ) mbedtls_ecp_point_free( R ); + ECP_RS_LEAVE( rsm ); + return( ret ); } @@ -1489,10 +2139,8 @@ static int ecp_normalize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P int ret; #if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_normalize_mxz( grp, P ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_normalize_mxz( grp, P ) ); #endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */ MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &P->Z, &P->Z, &grp->P ) ); @@ -1520,10 +2168,8 @@ static int ecp_randomize_mxz( const mbedtls_ecp_group *grp, mbedtls_ecp_point *P int count = 0; #if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_randomize_mxz( grp, P, f_rng, p_rng ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_randomize_mxz( grp, P, f_rng, p_rng ); #endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */ p_size = ( grp->pbits + 7 ) / 8; @@ -1575,10 +2221,8 @@ static int ecp_double_add_mxz( const mbedtls_ecp_group *grp, mbedtls_mpi A, AA, B, BB, E, C, D, DA, CB; #if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) - if ( mbedtls_internal_ecp_grp_capable( grp ) ) - { - return mbedtls_internal_ecp_double_add_mxz( grp, R, S, P, Q, d ); - } + if( mbedtls_internal_ecp_grp_capable( grp ) ) + return( mbedtls_internal_ecp_double_add_mxz( grp, R, S, P, Q, d ) ); #endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */ mbedtls_mpi_init( &A ); mbedtls_mpi_init( &AA ); mbedtls_mpi_init( &B ); @@ -1675,54 +2319,85 @@ static int ecp_mul_mxz( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, #endif /* ECP_MONTGOMERY */ /* - * Multiplication R = m * P + * Restartable multiplication R = m * P */ -int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, +int mbedtls_ecp_mul_restartable( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, - int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_ecp_restart_ctx *rs_ctx ) { int ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; #if defined(MBEDTLS_ECP_INTERNAL_ALT) char is_grp_capable = 0; #endif - - /* Common sanity checks */ - if( mbedtls_mpi_cmp_int( &P->Z, 1 ) != 0 ) - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); - - if( ( ret = mbedtls_ecp_check_privkey( grp, m ) ) != 0 || - ( ret = mbedtls_ecp_check_pubkey( grp, P ) ) != 0 ) - return( ret ); + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( R != NULL ); + ECP_VALIDATE_RET( m != NULL ); + ECP_VALIDATE_RET( P != NULL ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + /* reset ops count for this call if top-level */ + if( rs_ctx != NULL && rs_ctx->depth++ == 0 ) + rs_ctx->ops_done = 0; +#endif #if defined(MBEDTLS_ECP_INTERNAL_ALT) - if ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) ) - { + if( ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) ) ) MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) ); +#endif /* MBEDTLS_ECP_INTERNAL_ALT */ + +#if defined(MBEDTLS_ECP_RESTARTABLE) + /* skip argument check when restarting */ + if( rs_ctx == NULL || rs_ctx->rsm == NULL ) +#endif + { + /* check_privkey is free */ + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_CHK ); + + /* Common sanity checks */ + MBEDTLS_MPI_CHK( mbedtls_ecp_check_privkey( grp, m ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_check_pubkey( grp, P ) ); } -#endif /* MBEDTLS_ECP_INTERNAL_ALT */ + ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; #if defined(ECP_MONTGOMERY) if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) - ret = ecp_mul_mxz( grp, R, m, P, f_rng, p_rng ); - + MBEDTLS_MPI_CHK( ecp_mul_mxz( grp, R, m, P, f_rng, p_rng ) ); #endif #if defined(ECP_SHORTWEIERSTRASS) if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS ) - ret = ecp_mul_comb( grp, R, m, P, f_rng, p_rng ); - + MBEDTLS_MPI_CHK( ecp_mul_comb( grp, R, m, P, f_rng, p_rng, rs_ctx ) ); #endif -#if defined(MBEDTLS_ECP_INTERNAL_ALT) + cleanup: - if ( is_grp_capable ) - { +#if defined(MBEDTLS_ECP_INTERNAL_ALT) + if( is_grp_capable ) mbedtls_internal_ecp_free( grp ); - } - #endif /* MBEDTLS_ECP_INTERNAL_ALT */ + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL ) + rs_ctx->depth--; +#endif + return( ret ); } +/* + * Multiplication R = m * P + */ +int mbedtls_ecp_mul( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( R != NULL ); + ECP_VALIDATE_RET( m != NULL ); + ECP_VALIDATE_RET( P != NULL ); + return( mbedtls_ecp_mul_restartable( grp, R, m, P, f_rng, p_rng, NULL ) ); +} + #if defined(ECP_SHORTWEIERSTRASS) /* * Check that an affine point is valid as a public key, @@ -1780,7 +2455,8 @@ static int ecp_check_pubkey_sw( const mbedtls_ecp_group *grp, const mbedtls_ecp_ static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, - const mbedtls_ecp_point *P ) + const mbedtls_ecp_point *P, + mbedtls_ecp_restart_ctx *rs_ctx ) { int ret; @@ -1796,7 +2472,8 @@ static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp, } else { - MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, R, m, P, NULL, NULL ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_restartable( grp, R, m, P, + NULL, NULL, rs_ctx ) ); } cleanup: @@ -1804,51 +2481,118 @@ static int mbedtls_ecp_mul_shortcuts( mbedtls_ecp_group *grp, } /* - * Linear combination + * Restartable linear combination * NOT constant-time */ -int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, +int mbedtls_ecp_muladd_restartable( + mbedtls_ecp_group *grp, mbedtls_ecp_point *R, const mbedtls_mpi *m, const mbedtls_ecp_point *P, - const mbedtls_mpi *n, const mbedtls_ecp_point *Q ) + const mbedtls_mpi *n, const mbedtls_ecp_point *Q, + mbedtls_ecp_restart_ctx *rs_ctx ) { int ret; mbedtls_ecp_point mP; + mbedtls_ecp_point *pmP = &mP; + mbedtls_ecp_point *pR = R; #if defined(MBEDTLS_ECP_INTERNAL_ALT) char is_grp_capable = 0; #endif + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( R != NULL ); + ECP_VALIDATE_RET( m != NULL ); + ECP_VALIDATE_RET( P != NULL ); + ECP_VALIDATE_RET( n != NULL ); + ECP_VALIDATE_RET( Q != NULL ); if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS ) return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); mbedtls_ecp_point_init( &mP ); - MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, &mP, m, P ) ); - MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, R, n, Q ) ); + ECP_RS_ENTER( ma ); -#if defined(MBEDTLS_ECP_INTERNAL_ALT) - if ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) ) +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ma != NULL ) { - MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) ); + /* redirect intermediate results to restart context */ + pmP = &rs_ctx->ma->mP; + pR = &rs_ctx->ma->R; + + /* jump to next operation */ + if( rs_ctx->ma->state == ecp_rsma_mul2 ) + goto mul2; + if( rs_ctx->ma->state == ecp_rsma_add ) + goto add; + if( rs_ctx->ma->state == ecp_rsma_norm ) + goto norm; } +#endif /* MBEDTLS_ECP_RESTARTABLE */ + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, pmP, m, P, rs_ctx ) ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ma != NULL ) + rs_ctx->ma->state = ecp_rsma_mul2; + +mul2: +#endif + MBEDTLS_MPI_CHK( mbedtls_ecp_mul_shortcuts( grp, pR, n, Q, rs_ctx ) ); + +#if defined(MBEDTLS_ECP_INTERNAL_ALT) + if( ( is_grp_capable = mbedtls_internal_ecp_grp_capable( grp ) ) ) + MBEDTLS_MPI_CHK( mbedtls_internal_ecp_init( grp ) ); #endif /* MBEDTLS_ECP_INTERNAL_ALT */ - MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, &mP, R ) ); - MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) ); -cleanup: +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ma != NULL ) + rs_ctx->ma->state = ecp_rsma_add; +add: +#endif + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_ADD ); + MBEDTLS_MPI_CHK( ecp_add_mixed( grp, pR, pmP, pR ) ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ma != NULL ) + rs_ctx->ma->state = ecp_rsma_norm; + +norm: +#endif + MBEDTLS_ECP_BUDGET( MBEDTLS_ECP_OPS_INV ); + MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, pR ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && rs_ctx->ma != NULL ) + MBEDTLS_MPI_CHK( mbedtls_ecp_copy( R, pR ) ); +#endif + +cleanup: #if defined(MBEDTLS_ECP_INTERNAL_ALT) - if ( is_grp_capable ) - { + if( is_grp_capable ) mbedtls_internal_ecp_free( grp ); - } - #endif /* MBEDTLS_ECP_INTERNAL_ALT */ + mbedtls_ecp_point_free( &mP ); + ECP_RS_LEAVE( ma ); + return( ret ); } +/* + * Linear combination + * NOT constant-time + */ +int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, + const mbedtls_mpi *m, const mbedtls_ecp_point *P, + const mbedtls_mpi *n, const mbedtls_ecp_point *Q ) +{ + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( R != NULL ); + ECP_VALIDATE_RET( m != NULL ); + ECP_VALIDATE_RET( P != NULL ); + ECP_VALIDATE_RET( n != NULL ); + ECP_VALIDATE_RET( Q != NULL ); + return( mbedtls_ecp_muladd_restartable( grp, R, m, P, n, Q, NULL ) ); +} #if defined(ECP_MONTGOMERY) /* @@ -1857,6 +2601,8 @@ int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R, static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ) { /* [Curve25519 p. 5] Just check X is the correct number of bytes */ + /* Allow any public value, if it's too big then we'll just reduce it mod p + * (RFC 7748 sec. 5 para. 3). */ if( mbedtls_mpi_size( &pt->X ) > ( grp->nbits + 7 ) / 8 ) return( MBEDTLS_ERR_ECP_INVALID_KEY ); @@ -1867,8 +2613,12 @@ static int ecp_check_pubkey_mx( const mbedtls_ecp_group *grp, const mbedtls_ecp_ /* * Check that a point is valid as a public key */ -int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_point *pt ) +int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, + const mbedtls_ecp_point *pt ) { + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( pt != NULL ); + /* Must use affine coordinates */ if( mbedtls_mpi_cmp_int( &pt->Z, 1 ) != 0 ) return( MBEDTLS_ERR_ECP_INVALID_KEY ); @@ -1887,19 +2637,26 @@ int mbedtls_ecp_check_pubkey( const mbedtls_ecp_group *grp, const mbedtls_ecp_po /* * Check that an mbedtls_mpi is valid as a private key */ -int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi *d ) +int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, + const mbedtls_mpi *d ) { + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( d != NULL ); + #if defined(ECP_MONTGOMERY) if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) { - /* see [Curve25519] page 5 */ + /* see RFC 7748 sec. 5 para. 5 */ if( mbedtls_mpi_get_bit( d, 0 ) != 0 || mbedtls_mpi_get_bit( d, 1 ) != 0 || - mbedtls_mpi_get_bit( d, 2 ) != 0 || mbedtls_mpi_bitlen( d ) - 1 != grp->nbits ) /* mbedtls_mpi_bitlen is one-based! */ return( MBEDTLS_ERR_ECP_INVALID_KEY ); - else - return( 0 ); + + /* see [Curve25519] page 5 */ + if( grp->nbits == 254 && mbedtls_mpi_get_bit( d, 2 ) != 0 ) + return( MBEDTLS_ERR_ECP_INVALID_KEY ); + + return( 0 ); } #endif /* ECP_MONTGOMERY */ #if defined(ECP_SHORTWEIERSTRASS) @@ -1918,16 +2675,21 @@ int mbedtls_ecp_check_privkey( const mbedtls_ecp_group *grp, const mbedtls_mpi * } /* - * Generate a keypair with configurable base point + * Generate a private key */ -int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, - const mbedtls_ecp_point *G, - mbedtls_mpi *d, mbedtls_ecp_point *Q, +int mbedtls_ecp_gen_privkey( const mbedtls_ecp_group *grp, + mbedtls_mpi *d, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - int ret; - size_t n_size = ( grp->nbits + 7 ) / 8; + int ret = MBEDTLS_ERR_ECP_BAD_INPUT_DATA; + size_t n_size; + + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( d != NULL ); + ECP_VALIDATE_RET( f_rng != NULL ); + + n_size = ( grp->nbits + 7 ) / 8; #if defined(ECP_MONTGOMERY) if( ecp_get_type( grp ) == ECP_TYPE_MONTGOMERY ) @@ -1946,13 +2708,17 @@ int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, else MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, grp->nbits, 1 ) ); - /* Make sure the last three bits are unset */ + /* Make sure the last two bits are unset for Curve448, three bits for + Curve25519 */ MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 0, 0 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 1, 0 ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 2, 0 ) ); + if( grp->nbits == 254 ) + { + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( d, 2, 0 ) ); + } } - else #endif /* ECP_MONTGOMERY */ + #if defined(ECP_SHORTWEIERSTRASS) if( ecp_get_type( grp ) == ECP_TYPE_SHORT_WEIERSTRASS ) { @@ -1986,15 +2752,33 @@ int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, while( mbedtls_mpi_cmp_int( d, 1 ) < 0 || mbedtls_mpi_cmp_mpi( d, &grp->N ) >= 0 ); } - else #endif /* ECP_SHORTWEIERSTRASS */ - return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); cleanup: - if( ret != 0 ) - return( ret ); + return( ret ); +} + +/* + * Generate a keypair with configurable base point + */ +int mbedtls_ecp_gen_keypair_base( mbedtls_ecp_group *grp, + const mbedtls_ecp_point *G, + mbedtls_mpi *d, mbedtls_ecp_point *Q, + int (*f_rng)(void *, unsigned char *, size_t), + void *p_rng ) +{ + int ret; + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( d != NULL ); + ECP_VALIDATE_RET( G != NULL ); + ECP_VALIDATE_RET( Q != NULL ); + ECP_VALIDATE_RET( f_rng != NULL ); + + MBEDTLS_MPI_CHK( mbedtls_ecp_gen_privkey( grp, d, f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, Q, d, G, f_rng, p_rng ) ); - return( mbedtls_ecp_mul( grp, Q, d, G, f_rng, p_rng ) ); +cleanup: + return( ret ); } /* @@ -2005,6 +2789,11 @@ int mbedtls_ecp_gen_keypair( mbedtls_ecp_group *grp, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { + ECP_VALIDATE_RET( grp != NULL ); + ECP_VALIDATE_RET( d != NULL ); + ECP_VALIDATE_RET( Q != NULL ); + ECP_VALIDATE_RET( f_rng != NULL ); + return( mbedtls_ecp_gen_keypair_base( grp, &grp->G, d, Q, f_rng, p_rng ) ); } @@ -2015,6 +2804,8 @@ int mbedtls_ecp_gen_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { int ret; + ECP_VALIDATE_RET( key != NULL ); + ECP_VALIDATE_RET( f_rng != NULL ); if( ( ret = mbedtls_ecp_group_load( &key->grp, grp_id ) ) != 0 ) return( ret ); @@ -2030,6 +2821,8 @@ int mbedtls_ecp_check_pub_priv( const mbedtls_ecp_keypair *pub, const mbedtls_ec int ret; mbedtls_ecp_point Q; mbedtls_ecp_group grp; + ECP_VALIDATE_RET( pub != NULL ); + ECP_VALIDATE_RET( prv != NULL ); if( pub->grp.id == MBEDTLS_ECP_DP_NONE || pub->grp.id != prv->grp.id || diff --git a/3rdparty/mbedtls/mbedtls/library/ecp_curves.c b/3rdparty/mbedtls/mbedtls/library/ecp_curves.c index df5ac3eea5..282481d053 100644 --- a/3rdparty/mbedtls/mbedtls/library/ecp_curves.c +++ b/3rdparty/mbedtls/mbedtls/library/ecp_curves.c @@ -28,11 +28,18 @@ #if defined(MBEDTLS_ECP_C) #include "mbedtls/ecp.h" +#include "mbedtls/platform_util.h" #include #if !defined(MBEDTLS_ECP_ALT) +/* Parameter validation macros based on platform_util.h */ +#define ECP_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_ECP_BAD_INPUT_DATA ) +#define ECP_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ !defined(inline) && !defined(__cplusplus) #define inline __inline @@ -44,11 +51,11 @@ */ #if defined(MBEDTLS_HAVE_INT32) -#define BYTES_TO_T_UINT_4( a, b, c, d ) \ - ( (mbedtls_mpi_uint) a << 0 ) | \ - ( (mbedtls_mpi_uint) b << 8 ) | \ - ( (mbedtls_mpi_uint) c << 16 ) | \ - ( (mbedtls_mpi_uint) d << 24 ) +#define BYTES_TO_T_UINT_4( a, b, c, d ) \ + ( (mbedtls_mpi_uint) (a) << 0 ) | \ + ( (mbedtls_mpi_uint) (b) << 8 ) | \ + ( (mbedtls_mpi_uint) (c) << 16 ) | \ + ( (mbedtls_mpi_uint) (d) << 24 ) #define BYTES_TO_T_UINT_2( a, b ) \ BYTES_TO_T_UINT_4( a, b, 0, 0 ) @@ -60,14 +67,14 @@ #else /* 64-bits */ #define BYTES_TO_T_UINT_8( a, b, c, d, e, f, g, h ) \ - ( (mbedtls_mpi_uint) a << 0 ) | \ - ( (mbedtls_mpi_uint) b << 8 ) | \ - ( (mbedtls_mpi_uint) c << 16 ) | \ - ( (mbedtls_mpi_uint) d << 24 ) | \ - ( (mbedtls_mpi_uint) e << 32 ) | \ - ( (mbedtls_mpi_uint) f << 40 ) | \ - ( (mbedtls_mpi_uint) g << 48 ) | \ - ( (mbedtls_mpi_uint) h << 56 ) + ( (mbedtls_mpi_uint) (a) << 0 ) | \ + ( (mbedtls_mpi_uint) (b) << 8 ) | \ + ( (mbedtls_mpi_uint) (c) << 16 ) | \ + ( (mbedtls_mpi_uint) (d) << 24 ) | \ + ( (mbedtls_mpi_uint) (e) << 32 ) | \ + ( (mbedtls_mpi_uint) (f) << 40 ) | \ + ( (mbedtls_mpi_uint) (g) << 48 ) | \ + ( (mbedtls_mpi_uint) (h) << 56 ) #define BYTES_TO_T_UINT_4( a, b, c, d ) \ BYTES_TO_T_UINT_8( a, b, c, d, 0, 0, 0, 0 ) @@ -627,6 +634,9 @@ static int ecp_mod_p521( mbedtls_mpi * ); #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) static int ecp_mod_p255( mbedtls_mpi * ); #endif +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) +static int ecp_mod_p448( mbedtls_mpi * ); +#endif #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) static int ecp_mod_p192k1( mbedtls_mpi * ); #endif @@ -670,7 +680,12 @@ static int ecp_use_curve25519( mbedtls_ecp_group *grp ) MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &grp->P, &grp->P, 19 ) ); grp->pbits = mbedtls_mpi_bitlen( &grp->P ); - /* Y intentionaly not set, since we use x/z coordinates. + /* N = 2^252 + 27742317777372353535851937790883648493 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->N, 16, + "14DEF9DEA2F79CD65812631A5CF5D3ED" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( &grp->N, 252, 1 ) ); + + /* Y intentionally not set, since we use x/z coordinates. * This is used as a marker to identify Montgomery curves! */ MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->G.X, 9 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->G.Z, 1 ) ); @@ -687,11 +702,58 @@ static int ecp_use_curve25519( mbedtls_ecp_group *grp ) } #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) +/* + * Specialized function for creating the Curve448 group + */ +static int ecp_use_curve448( mbedtls_ecp_group *grp ) +{ + mbedtls_mpi Ns; + int ret; + + mbedtls_mpi_init( &Ns ); + + /* Actually ( A + 2 ) / 4 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &grp->A, 16, "98AA" ) ); + + /* P = 2^448 - 2^224 - 1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &grp->P, 224 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &grp->P, &grp->P, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &grp->P, 224 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &grp->P, &grp->P, 1 ) ); + grp->pbits = mbedtls_mpi_bitlen( &grp->P ); + + /* Y intentionally not set, since we use x/z coordinates. + * This is used as a marker to identify Montgomery curves! */ + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->G.X, 5 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &grp->G.Z, 1 ) ); + mbedtls_mpi_free( &grp->G.Y ); + + /* N = 2^446 - 13818066809895115352007386748515426880336692474882178609894547503885 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_set_bit( &grp->N, 446, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &Ns, 16, + "8335DC163BB124B65129C96FDE933D8D723A70AADC873D6D54A7BB0D" ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &grp->N, &grp->N, &Ns ) ); + + /* Actually, the required msb for private keys */ + grp->nbits = 447; + +cleanup: + mbedtls_mpi_free( &Ns ); + if( ret != 0 ) + mbedtls_ecp_group_free( grp ); + + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ + /* * Set a group using well-known domain parameters */ int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ) { + ECP_VALIDATE_RET( grp != NULL ); mbedtls_ecp_group_free( grp ); grp->id = id; @@ -767,6 +829,12 @@ int mbedtls_ecp_group_load( mbedtls_ecp_group *grp, mbedtls_ecp_group_id id ) return( ecp_use_curve25519( grp ) ); #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) + case MBEDTLS_ECP_DP_CURVE448: + grp->modp = ecp_mod_p448; + return( ecp_use_curve448( grp ) ); +#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ + default: mbedtls_ecp_group_free( grp ); return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE ); @@ -822,7 +890,7 @@ static inline void carry64( mbedtls_mpi_uint *dst, mbedtls_mpi_uint *carry ) } #define WIDTH 8 / sizeof( mbedtls_mpi_uint ) -#define A( i ) N->p + i * WIDTH +#define A( i ) N->p + (i) * WIDTH #define ADD( i ) add64( p, A( i ), &c ) #define NEXT p += WIDTH; carry64( p, &c ) #define LAST p += WIDTH; *p = c; while( ++p < end ) *p = 0 @@ -887,7 +955,8 @@ static int ecp_mod_p192( mbedtls_mpi *N ) #else /* 64-bit */ #define MAX32 N->n * 2 -#define A( j ) j % 2 ? (uint32_t)( N->p[j/2] >> 32 ) : (uint32_t)( N->p[j/2] ) +#define A( j ) (j) % 2 ? (uint32_t)( N->p[(j)/2] >> 32 ) : \ + (uint32_t)( N->p[(j)/2] ) #define STORE32 \ if( i % 2 ) { \ N->p[i/2] &= 0x00000000FFFFFFFF; \ @@ -921,20 +990,21 @@ static inline void sub32( uint32_t *dst, uint32_t src, signed char *carry ) * Helpers for the main 'loop' * (see fix_negative for the motivation of C) */ -#define INIT( b ) \ - int ret; \ - signed char c = 0, cc; \ - uint32_t cur; \ - size_t i = 0, bits = b; \ - mbedtls_mpi C; \ - mbedtls_mpi_uint Cp[ b / 8 / sizeof( mbedtls_mpi_uint) + 1 ]; \ - \ - C.s = 1; \ - C.n = b / 8 / sizeof( mbedtls_mpi_uint) + 1; \ - C.p = Cp; \ - memset( Cp, 0, C.n * sizeof( mbedtls_mpi_uint ) ); \ - \ - MBEDTLS_MPI_CHK( mbedtls_mpi_grow( N, b * 2 / 8 / sizeof( mbedtls_mpi_uint ) ) ); \ +#define INIT( b ) \ + int ret; \ + signed char c = 0, cc; \ + uint32_t cur; \ + size_t i = 0, bits = (b); \ + mbedtls_mpi C; \ + mbedtls_mpi_uint Cp[ (b) / 8 / sizeof( mbedtls_mpi_uint) + 1 ]; \ + \ + C.s = 1; \ + C.n = (b) / 8 / sizeof( mbedtls_mpi_uint) + 1; \ + C.p = Cp; \ + memset( Cp, 0, C.n * sizeof( mbedtls_mpi_uint ) ); \ + \ + MBEDTLS_MPI_CHK( mbedtls_mpi_grow( N, (b) * 2 / 8 / \ + sizeof( mbedtls_mpi_uint ) ) ); \ LOAD32; #define NEXT \ @@ -1176,7 +1246,7 @@ static int ecp_mod_p255( mbedtls_mpi *N ) M.s = 1; M.n = N->n - ( P255_WIDTH - 1 ); if( M.n > P255_WIDTH + 1 ) - M.n = P255_WIDTH + 1; + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); M.p = Mp; memset( Mp, 0, sizeof Mp ); memcpy( Mp, N->p + P255_WIDTH - 1, M.n * sizeof( mbedtls_mpi_uint ) ); @@ -1197,6 +1267,77 @@ static int ecp_mod_p255( mbedtls_mpi *N ) } #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) + +/* Size of p448 in terms of mbedtls_mpi_uint */ +#define P448_WIDTH ( 448 / 8 / sizeof( mbedtls_mpi_uint ) ) + +/* Number of limbs fully occupied by 2^224 (max), and limbs used by it (min) */ +#define DIV_ROUND_UP( X, Y ) ( ( ( X ) + ( Y ) - 1 ) / ( Y ) ) +#define P224_WIDTH_MIN ( 28 / sizeof( mbedtls_mpi_uint ) ) +#define P224_WIDTH_MAX DIV_ROUND_UP( 28, sizeof( mbedtls_mpi_uint ) ) +#define P224_UNUSED_BITS ( ( P224_WIDTH_MAX * sizeof( mbedtls_mpi_uint ) * 8 ) - 224 ) + +/* + * Fast quasi-reduction modulo p448 = 2^448 - 2^224 - 1 + * Write N as A0 + 2^448 A1 and A1 as B0 + 2^224 B1, and return + * A0 + A1 + B1 + (B0 + B1) * 2^224. This is different to the reference + * implementation of Curve448, which uses its own special 56-bit limbs rather + * than a generic bignum library. We could squeeze some extra speed out on + * 32-bit machines by splitting N up into 32-bit limbs and doing the + * arithmetic using the limbs directly as we do for the NIST primes above, + * but for 64-bit targets it should use half the number of operations if we do + * the reduction with 224-bit limbs, since mpi_add_mpi will then use 64-bit adds. + */ +static int ecp_mod_p448( mbedtls_mpi *N ) +{ + int ret; + size_t i; + mbedtls_mpi M, Q; + mbedtls_mpi_uint Mp[P448_WIDTH + 1], Qp[P448_WIDTH]; + + if( N->n <= P448_WIDTH ) + return( 0 ); + + /* M = A1 */ + M.s = 1; + M.n = N->n - ( P448_WIDTH ); + if( M.n > P448_WIDTH ) + /* Shouldn't be called with N larger than 2^896! */ + return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA ); + M.p = Mp; + memset( Mp, 0, sizeof( Mp ) ); + memcpy( Mp, N->p + P448_WIDTH, M.n * sizeof( mbedtls_mpi_uint ) ); + + /* N = A0 */ + for( i = P448_WIDTH; i < N->n; i++ ) + N->p[i] = 0; + + /* N += A1 */ + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( N, N, &M ) ); + + /* Q = B1, N += B1 */ + Q = M; + Q.p = Qp; + memcpy( Qp, Mp, sizeof( Qp ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_r( &Q, 224 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( N, N, &Q ) ); + + /* M = (B0 + B1) * 2^224, N += M */ + if( sizeof( mbedtls_mpi_uint ) > 4 ) + Mp[P224_WIDTH_MIN] &= ( (mbedtls_mpi_uint)-1 ) >> ( P224_UNUSED_BITS ); + for( i = P224_WIDTH_MAX; i < M.n; ++i ) + Mp[i] = 0; + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &M, &M, &Q ) ); + M.n = P448_WIDTH + 1; /* Make room for shifted carry bit from the addition */ + MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &M, 224 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( N, N, &M ) ); + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ + #if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) || \ defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) || \ defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) diff --git a/3rdparty/mbedtls/mbedtls/library/entropy.c b/3rdparty/mbedtls/mbedtls/library/entropy.c index e17512e779..f8db1a5503 100644 --- a/3rdparty/mbedtls/mbedtls/library/entropy.c +++ b/3rdparty/mbedtls/mbedtls/library/entropy.c @@ -35,6 +35,7 @@ #include "mbedtls/entropy.h" #include "mbedtls/entropy_poll.h" +#include "mbedtls/platform_util.h" #include @@ -59,11 +60,6 @@ #include "mbedtls/havege.h" #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - #define ENTROPY_MAX_LOOP 256 /**< Maximum amount to loop before error */ void mbedtls_entropy_init( mbedtls_entropy_context *ctx ) @@ -140,7 +136,7 @@ void mbedtls_entropy_free( mbedtls_entropy_context *ctx ) ctx->initial_entropy_run = 0; #endif ctx->source_count = 0; - mbedtls_zeroize( ctx->source, sizeof( ctx->source ) ); + mbedtls_platform_zeroize( ctx->source, sizeof( ctx->source ) ); ctx->accumulator_started = 0; } @@ -232,7 +228,7 @@ static int entropy_update( mbedtls_entropy_context *ctx, unsigned char source_id #endif cleanup: - mbedtls_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); return( ret ); } @@ -300,7 +296,7 @@ static int entropy_gather_internal( mbedtls_entropy_context *ctx ) ret = MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE; cleanup: - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); return( ret ); } @@ -433,7 +429,7 @@ int mbedtls_entropy_func( void *data, unsigned char *output, size_t len ) ret = 0; exit: - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); #if defined(MBEDTLS_THREADING_C) if( mbedtls_mutex_unlock( &ctx->mutex ) != 0 ) @@ -486,7 +482,7 @@ int mbedtls_entropy_write_seed_file( mbedtls_entropy_context *ctx, const char *p ret = 0; exit: - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); fclose( f ); return( ret ); @@ -516,7 +512,7 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char * fclose( f ); - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); if( ret != 0 ) return( ret ); diff --git a/3rdparty/mbedtls/mbedtls/library/entropy_poll.c b/3rdparty/mbedtls/mbedtls/library/entropy_poll.c index 02b25a2721..4556f88a55 100644 --- a/3rdparty/mbedtls/mbedtls/library/entropy_poll.c +++ b/3rdparty/mbedtls/mbedtls/library/entropy_poll.c @@ -19,19 +19,25 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +#if defined(__linux__) +/* Ensure that syscall() is available even when compiling with -std=c99 */ +#define _GNU_SOURCE +#endif + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE #endif +#include + #if defined(MBEDTLS_ENTROPY_C) #include "mbedtls/entropy.h" #include "mbedtls/entropy_poll.h" #if defined(MBEDTLS_TIMING_C) -#include #include "mbedtls/timing.h" #endif #if defined(MBEDTLS_HAVEGE_C) @@ -44,7 +50,8 @@ #if !defined(MBEDTLS_NO_PLATFORM_ENTROPY) #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ - !defined(__APPLE__) && !defined(_WIN32) + !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ + !defined(__HAIKU__) #error "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h" #endif diff --git a/3rdparty/mbedtls/mbedtls/library/error.c b/3rdparty/mbedtls/mbedtls/library/error.c index b173c7e8ef..12312a0562 100644 --- a/3rdparty/mbedtls/mbedtls/library/error.c +++ b/3rdparty/mbedtls/mbedtls/library/error.c @@ -49,6 +49,10 @@ #include "mbedtls/arc4.h" #endif +#if defined(MBEDTLS_ARIA_C) +#include "mbedtls/aria.h" +#endif + #if defined(MBEDTLS_BASE64_C) #include "mbedtls/base64.h" #endif @@ -69,6 +73,14 @@ #include "mbedtls/ccm.h" #endif +#if defined(MBEDTLS_CHACHA20_C) +#include "mbedtls/chacha20.h" +#endif + +#if defined(MBEDTLS_CHACHAPOLY_C) +#include "mbedtls/chachapoly.h" +#endif + #if defined(MBEDTLS_CIPHER_C) #include "mbedtls/cipher.h" #endif @@ -101,6 +113,10 @@ #include "mbedtls/gcm.h" #endif +#if defined(MBEDTLS_HKDF_C) +#include "mbedtls/hkdf.h" +#endif + #if defined(MBEDTLS_HMAC_DRBG_C) #include "mbedtls/hmac_drbg.h" #endif @@ -149,6 +165,14 @@ #include "mbedtls/pkcs5.h" #endif +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#endif + +#if defined(MBEDTLS_POLY1305_C) +#include "mbedtls/poly1305.h" +#endif + #if defined(MBEDTLS_RIPEMD160_C) #include "mbedtls/ripemd160.h" #endif @@ -256,19 +280,21 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) if( use_ret == -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) ) mbedtls_snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); if( use_ret == -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) ) - mbedtls_snprintf( buf, buflen, "ECP - Requested curve not available" ); + mbedtls_snprintf( buf, buflen, "ECP - The requested feature is not available, for example, the requested curve is not supported" ); if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) ) mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" ); if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) ) mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" ); if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) ) - mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" ); + mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as ephemeral key, failed" ); if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) ) mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" ); if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) ) mbedtls_snprintf( buf, buflen, "ECP - The buffer contains a valid signature followed by more data" ); if( use_ret == -(MBEDTLS_ERR_ECP_HW_ACCEL_FAILED) ) - mbedtls_snprintf( buf, buflen, "ECP - ECP hardware accelerator failed" ); + mbedtls_snprintf( buf, buflen, "ECP - The ECP hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_ECP_IN_PROGRESS) ) + mbedtls_snprintf( buf, buflen, "ECP - Operation in progress, call again with the same parameters to continue" ); #endif /* MBEDTLS_ECP_C */ #if defined(MBEDTLS_MD_C) @@ -478,7 +504,7 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) if( use_ret == -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) ) mbedtls_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" ); if( use_ret == -(MBEDTLS_ERR_SSL_WANT_READ) ) - mbedtls_snprintf( buf, buflen, "SSL - Connection requires a read call" ); + mbedtls_snprintf( buf, buflen, "SSL - No data of requested type currently available on underlying transport" ); if( use_ret == -(MBEDTLS_ERR_SSL_WANT_WRITE) ) mbedtls_snprintf( buf, buflen, "SSL - Connection requires a write call" ); if( use_ret == -(MBEDTLS_ERR_SSL_TIMEOUT) ) @@ -491,6 +517,14 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "SSL - The alert message received indicates a non-fatal error" ); if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH) ) mbedtls_snprintf( buf, buflen, "SSL - Couldn't set the hash for verifying CertificateVerify" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CONTINUE_PROCESSING) ) + mbedtls_snprintf( buf, buflen, "SSL - Internal-only message signaling that further message-processing should be done" ); + if( use_ret == -(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS) ) + mbedtls_snprintf( buf, buflen, "SSL - The asynchronous operation is not completed yet" ); + if( use_ret == -(MBEDTLS_ERR_SSL_EARLY_MESSAGE) ) + mbedtls_snprintf( buf, buflen, "SSL - Internal-only message signaling that a message arrived early" ); + if( use_ret == -(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS) ) + mbedtls_snprintf( buf, buflen, "SSL - A cryptographic operation is in progress. Try again later" ); #endif /* MBEDTLS_SSL_TLS_C */ #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) @@ -570,6 +604,8 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "AES - Invalid key length" ); if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) ) mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" ); + if( use_ret == -(MBEDTLS_ERR_AES_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "AES - Invalid input data" ); if( use_ret == -(MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE) ) mbedtls_snprintf( buf, buflen, "AES - Feature not available. For example, an unsupported AES key size" ); if( use_ret == -(MBEDTLS_ERR_AES_HW_ACCEL_FAILED) ) @@ -581,6 +617,17 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "ARC4 - ARC4 hardware accelerator failed" ); #endif /* MBEDTLS_ARC4_C */ +#if defined(MBEDTLS_ARIA_C) + if( use_ret == -(MBEDTLS_ERR_ARIA_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "ARIA - Bad input data" ); + if( use_ret == -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH) ) + mbedtls_snprintf( buf, buflen, "ARIA - Invalid data input length" ); + if( use_ret == -(MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "ARIA - Feature not available. For example, an unsupported ARIA key size" ); + if( use_ret == -(MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED) ) + mbedtls_snprintf( buf, buflen, "ARIA - ARIA hardware accelerator failed" ); +#endif /* MBEDTLS_ARIA_C */ + #if defined(MBEDTLS_ASN1_PARSE_C) if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) ) mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); @@ -625,17 +672,17 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) #endif /* MBEDTLS_BIGNUM_C */ #if defined(MBEDTLS_BLOWFISH_C) - if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) - mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); - if( use_ret == -(MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED) ) - mbedtls_snprintf( buf, buflen, "BLOWFISH - Blowfish hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "BLOWFISH - Bad input data" ); if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); + if( use_ret == -(MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED) ) + mbedtls_snprintf( buf, buflen, "BLOWFISH - Blowfish hardware accelerator failed" ); #endif /* MBEDTLS_BLOWFISH_C */ #if defined(MBEDTLS_CAMELLIA_C) - if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) - mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); + if( use_ret == -(MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "CAMELLIA - Bad input data" ); if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); if( use_ret == -(MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED) ) @@ -651,6 +698,22 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "CCM - CCM hardware accelerator failed" ); #endif /* MBEDTLS_CCM_C */ +#if defined(MBEDTLS_CHACHA20_C) + if( use_ret == -(MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "CHACHA20 - Invalid input parameter(s)" ); + if( use_ret == -(MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "CHACHA20 - Feature not available. For example, s part of the API is not implemented" ); + if( use_ret == -(MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED) ) + mbedtls_snprintf( buf, buflen, "CHACHA20 - Chacha20 hardware accelerator failed" ); +#endif /* MBEDTLS_CHACHA20_C */ + +#if defined(MBEDTLS_CHACHAPOLY_C) + if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE) ) + mbedtls_snprintf( buf, buflen, "CHACHAPOLY - The requested operation is not permitted in the current state" ); + if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED) ) + mbedtls_snprintf( buf, buflen, "CHACHAPOLY - Authenticated decryption failed: data was not authentic" ); +#endif /* MBEDTLS_CHACHAPOLY_C */ + #if defined(MBEDTLS_CMAC_C) if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) ) mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" ); @@ -696,6 +759,11 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" ); #endif /* MBEDTLS_GCM_C */ +#if defined(MBEDTLS_HKDF_C) + if( use_ret == -(MBEDTLS_ERR_HKDF_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "HKDF - Bad input parameters to function" ); +#endif /* MBEDTLS_HKDF_C */ + #if defined(MBEDTLS_HMAC_DRBG_C) if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); @@ -745,6 +813,10 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" ); if( use_ret == -(MBEDTLS_ERR_NET_INVALID_CONTEXT) ) mbedtls_snprintf( buf, buflen, "NET - The context is invalid, eg because it was free()ed" ); + if( use_ret == -(MBEDTLS_ERR_NET_POLL_FAILED) ) + mbedtls_snprintf( buf, buflen, "NET - Polling the net context failed" ); + if( use_ret == -(MBEDTLS_ERR_NET_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "NET - Input invalid" ); #endif /* MBEDTLS_NET_C */ #if defined(MBEDTLS_OID_C) @@ -759,6 +831,22 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); #endif /* MBEDTLS_PADLOCK_C */ +#if defined(MBEDTLS_PLATFORM_C) + if( use_ret == -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED) ) + mbedtls_snprintf( buf, buflen, "PLATFORM - Hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED) ) + mbedtls_snprintf( buf, buflen, "PLATFORM - The requested feature is not supported by the platform" ); +#endif /* MBEDTLS_PLATFORM_C */ + +#if defined(MBEDTLS_POLY1305_C) + if( use_ret == -(MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "POLY1305 - Invalid input parameter(s)" ); + if( use_ret == -(MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE) ) + mbedtls_snprintf( buf, buflen, "POLY1305 - Feature not available. For example, s part of the API is not implemented" ); + if( use_ret == -(MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED) ) + mbedtls_snprintf( buf, buflen, "POLY1305 - Poly1305 hardware accelerator failed" ); +#endif /* MBEDTLS_POLY1305_C */ + #if defined(MBEDTLS_RIPEMD160_C) if( use_ret == -(MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED) ) mbedtls_snprintf( buf, buflen, "RIPEMD160 - RIPEMD160 hardware accelerator failed" ); @@ -767,16 +855,22 @@ void mbedtls_strerror( int ret, char *buf, size_t buflen ) #if defined(MBEDTLS_SHA1_C) if( use_ret == -(MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED) ) mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_SHA1_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 input data was malformed" ); #endif /* MBEDTLS_SHA1_C */ #if defined(MBEDTLS_SHA256_C) if( use_ret == -(MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED) ) mbedtls_snprintf( buf, buflen, "SHA256 - SHA-256 hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_SHA256_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "SHA256 - SHA-256 input data was malformed" ); #endif /* MBEDTLS_SHA256_C */ #if defined(MBEDTLS_SHA512_C) if( use_ret == -(MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED) ) mbedtls_snprintf( buf, buflen, "SHA512 - SHA-512 hardware accelerator failed" ); + if( use_ret == -(MBEDTLS_ERR_SHA512_BAD_INPUT_DATA) ) + mbedtls_snprintf( buf, buflen, "SHA512 - SHA-512 input data was malformed" ); #endif /* MBEDTLS_SHA512_C */ #if defined(MBEDTLS_THREADING_C) diff --git a/3rdparty/mbedtls/mbedtls/library/gcm.c b/3rdparty/mbedtls/mbedtls/library/gcm.c index 294a86d3d4..675926a518 100644 --- a/3rdparty/mbedtls/mbedtls/library/gcm.c +++ b/3rdparty/mbedtls/mbedtls/library/gcm.c @@ -38,6 +38,7 @@ #if defined(MBEDTLS_GCM_C) #include "mbedtls/gcm.h" +#include "mbedtls/platform_util.h" #include @@ -47,9 +48,8 @@ #if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) #include "mbedtls/aes.h" -#if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" -#else +#if !defined(MBEDTLS_PLATFORM_C) #include #define mbedtls_printf printf #endif /* MBEDTLS_PLATFORM_C */ @@ -57,6 +57,12 @@ #if !defined(MBEDTLS_GCM_ALT) +/* Parameter validation macros */ +#define GCM_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_GCM_BAD_INPUT ) +#define GCM_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + /* * 32-bit integer manipulation macros (big endian) */ @@ -80,16 +86,12 @@ } #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * Initialize a context */ void mbedtls_gcm_init( mbedtls_gcm_context *ctx ) { + GCM_VALIDATE( ctx != NULL ); memset( ctx, 0, sizeof( mbedtls_gcm_context ) ); } @@ -169,6 +171,10 @@ int mbedtls_gcm_setkey( mbedtls_gcm_context *ctx, int ret; const mbedtls_cipher_info_t *cipher_info; + GCM_VALIDATE_RET( ctx != NULL ); + GCM_VALIDATE_RET( key != NULL ); + GCM_VALIDATE_RET( keybits == 128 || keybits == 192 || keybits == 256 ); + cipher_info = mbedtls_cipher_info_from_values( cipher, keybits, MBEDTLS_MODE_ECB ); if( cipher_info == NULL ) return( MBEDTLS_ERR_GCM_BAD_INPUT ); @@ -279,6 +285,10 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx, const unsigned char *p; size_t use_len, olen = 0; + GCM_VALIDATE_RET( ctx != NULL ); + GCM_VALIDATE_RET( iv != NULL ); + GCM_VALIDATE_RET( add_len == 0 || add != NULL ); + /* IV and AD are limited to 2^64 bits, so 2^61 bytes */ /* IV is not allowed to be zero length */ if( iv_len == 0 || @@ -361,6 +371,10 @@ int mbedtls_gcm_update( mbedtls_gcm_context *ctx, unsigned char *out_p = output; size_t use_len, olen = 0; + GCM_VALIDATE_RET( ctx != NULL ); + GCM_VALIDATE_RET( length == 0 || input != NULL ); + GCM_VALIDATE_RET( length == 0 || output != NULL ); + if( output > input && (size_t) ( output - input ) < length ) return( MBEDTLS_ERR_GCM_BAD_INPUT ); @@ -414,8 +428,14 @@ int mbedtls_gcm_finish( mbedtls_gcm_context *ctx, { unsigned char work_buf[16]; size_t i; - uint64_t orig_len = ctx->len * 8; - uint64_t orig_add_len = ctx->add_len * 8; + uint64_t orig_len; + uint64_t orig_add_len; + + GCM_VALIDATE_RET( ctx != NULL ); + GCM_VALIDATE_RET( tag != NULL ); + + orig_len = ctx->len * 8; + orig_add_len = ctx->add_len * 8; if( tag_len > 16 || tag_len < 4 ) return( MBEDTLS_ERR_GCM_BAD_INPUT ); @@ -457,6 +477,13 @@ int mbedtls_gcm_crypt_and_tag( mbedtls_gcm_context *ctx, { int ret; + GCM_VALIDATE_RET( ctx != NULL ); + GCM_VALIDATE_RET( iv != NULL ); + GCM_VALIDATE_RET( add_len == 0 || add != NULL ); + GCM_VALIDATE_RET( length == 0 || input != NULL ); + GCM_VALIDATE_RET( length == 0 || output != NULL ); + GCM_VALIDATE_RET( tag != NULL ); + if( ( ret = mbedtls_gcm_starts( ctx, mode, iv, iv_len, add, add_len ) ) != 0 ) return( ret ); @@ -485,6 +512,13 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, size_t i; int diff; + GCM_VALIDATE_RET( ctx != NULL ); + GCM_VALIDATE_RET( iv != NULL ); + GCM_VALIDATE_RET( add_len == 0 || add != NULL ); + GCM_VALIDATE_RET( tag != NULL ); + GCM_VALIDATE_RET( length == 0 || input != NULL ); + GCM_VALIDATE_RET( length == 0 || output != NULL ); + if( ( ret = mbedtls_gcm_crypt_and_tag( ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, check_tag ) ) != 0 ) @@ -498,7 +532,7 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, if( diff != 0 ) { - mbedtls_zeroize( output, length ); + mbedtls_platform_zeroize( output, length ); return( MBEDTLS_ERR_GCM_AUTH_FAILED ); } @@ -507,8 +541,10 @@ int mbedtls_gcm_auth_decrypt( mbedtls_gcm_context *ctx, void mbedtls_gcm_free( mbedtls_gcm_context *ctx ) { + if( ctx == NULL ) + return; mbedtls_cipher_free( &ctx->cipher_ctx ); - mbedtls_zeroize( ctx, sizeof( mbedtls_gcm_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_gcm_context ) ); } #endif /* !MBEDTLS_GCM_ALT */ @@ -768,7 +804,7 @@ int mbedtls_gcm_self_test( int verbose ) * there is an alternative underlying implementation i.e. when * MBEDTLS_AES_ALT is defined. */ - if( ret == MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE && key_len == 192 ) + if( ret == MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED && key_len == 192 ) { mbedtls_printf( "skipped\n" ); break; diff --git a/3rdparty/mbedtls/mbedtls/library/havege.c b/3rdparty/mbedtls/mbedtls/library/havege.c index 2b75ef7bd8..54f897c6e7 100644 --- a/3rdparty/mbedtls/mbedtls/library/havege.c +++ b/3rdparty/mbedtls/mbedtls/library/havege.c @@ -36,14 +36,10 @@ #include "mbedtls/havege.h" #include "mbedtls/timing.h" +#include "mbedtls/platform_util.h" #include -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* ------------------------------------------------------------------------ * On average, one iteration accesses two 8-word blocks in the havege WALK * table, and generates 16 words in the RES array. @@ -58,7 +54,7 @@ static void mbedtls_zeroize( void *v, size_t n ) { * ------------------------------------------------------------------------ */ -#define SWAP(X,Y) { int *T = X; X = Y; Y = T; } +#define SWAP(X,Y) { int *T = (X); (X) = (Y); (Y) = T; } #define TST1_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1; #define TST2_ENTER if( PTEST & 1 ) { PTEST ^= 3; PTEST >>= 1; @@ -208,7 +204,7 @@ void mbedtls_havege_free( mbedtls_havege_state *hs ) if( hs == NULL ) return; - mbedtls_zeroize( hs, sizeof( mbedtls_havege_state ) ); + mbedtls_platform_zeroize( hs, sizeof( mbedtls_havege_state ) ); } /* diff --git a/3rdparty/mbedtls/mbedtls/library/hkdf.c b/3rdparty/mbedtls/mbedtls/library/hkdf.c new file mode 100644 index 0000000000..82d8a429f4 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/hkdf.c @@ -0,0 +1,192 @@ +/* + * HKDF implementation -- RFC 5869 + * + * Copyright (C) 2016-2018, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_HKDF_C) + +#include +#include "mbedtls/hkdf.h" +#include "mbedtls/platform_util.h" + +int mbedtls_hkdf( const mbedtls_md_info_t *md, const unsigned char *salt, + size_t salt_len, const unsigned char *ikm, size_t ikm_len, + const unsigned char *info, size_t info_len, + unsigned char *okm, size_t okm_len ) +{ + int ret; + unsigned char prk[MBEDTLS_MD_MAX_SIZE]; + + ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, prk ); + + if( ret == 0 ) + { + ret = mbedtls_hkdf_expand( md, prk, mbedtls_md_get_size( md ), + info, info_len, okm, okm_len ); + } + + mbedtls_platform_zeroize( prk, sizeof( prk ) ); + + return( ret ); +} + +int mbedtls_hkdf_extract( const mbedtls_md_info_t *md, + const unsigned char *salt, size_t salt_len, + const unsigned char *ikm, size_t ikm_len, + unsigned char *prk ) +{ + unsigned char null_salt[MBEDTLS_MD_MAX_SIZE] = { '\0' }; + + if( salt == NULL ) + { + size_t hash_len; + + if( salt_len != 0 ) + { + return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; + } + + hash_len = mbedtls_md_get_size( md ); + + if( hash_len == 0 ) + { + return MBEDTLS_ERR_HKDF_BAD_INPUT_DATA; + } + + salt = null_salt; + salt_len = hash_len; + } + + return( mbedtls_md_hmac( md, salt, salt_len, ikm, ikm_len, prk ) ); +} + +int mbedtls_hkdf_expand( const mbedtls_md_info_t *md, const unsigned char *prk, + size_t prk_len, const unsigned char *info, + size_t info_len, unsigned char *okm, size_t okm_len ) +{ + size_t hash_len; + size_t where = 0; + size_t n; + size_t t_len = 0; + size_t i; + int ret = 0; + mbedtls_md_context_t ctx; + unsigned char t[MBEDTLS_MD_MAX_SIZE]; + + if( okm == NULL ) + { + return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); + } + + hash_len = mbedtls_md_get_size( md ); + + if( prk_len < hash_len || hash_len == 0 ) + { + return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); + } + + if( info == NULL ) + { + info = (const unsigned char *) ""; + info_len = 0; + } + + n = okm_len / hash_len; + + if( (okm_len % hash_len) != 0 ) + { + n++; + } + + /* + * Per RFC 5869 Section 2.3, okm_len must not exceed + * 255 times the hash length + */ + if( n > 255 ) + { + return( MBEDTLS_ERR_HKDF_BAD_INPUT_DATA ); + } + + mbedtls_md_init( &ctx ); + + if( (ret = mbedtls_md_setup( &ctx, md, 1) ) != 0 ) + { + goto exit; + } + + /* + * Compute T = T(1) | T(2) | T(3) | ... | T(N) + * Where T(N) is defined in RFC 5869 Section 2.3 + */ + for( i = 1; i <= n; i++ ) + { + size_t num_to_copy; + unsigned char c = i & 0xff; + + ret = mbedtls_md_hmac_starts( &ctx, prk, prk_len ); + if( ret != 0 ) + { + goto exit; + } + + ret = mbedtls_md_hmac_update( &ctx, t, t_len ); + if( ret != 0 ) + { + goto exit; + } + + ret = mbedtls_md_hmac_update( &ctx, info, info_len ); + if( ret != 0 ) + { + goto exit; + } + + /* The constant concatenated to the end of each T(n) is a single octet. + * */ + ret = mbedtls_md_hmac_update( &ctx, &c, 1 ); + if( ret != 0 ) + { + goto exit; + } + + ret = mbedtls_md_hmac_finish( &ctx, t ); + if( ret != 0 ) + { + goto exit; + } + + num_to_copy = i != n ? hash_len : okm_len - where; + memcpy( okm + where, t, num_to_copy ); + where += hash_len; + t_len = hash_len; + } + +exit: + mbedtls_md_free( &ctx ); + mbedtls_platform_zeroize( t, sizeof( t ) ); + + return( ret ); +} + +#endif /* MBEDTLS_HKDF_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/hmac_drbg.c b/3rdparty/mbedtls/mbedtls/library/hmac_drbg.c index 9801bc50d8..c50330e7d8 100644 --- a/3rdparty/mbedtls/mbedtls/library/hmac_drbg.c +++ b/3rdparty/mbedtls/mbedtls/library/hmac_drbg.c @@ -34,6 +34,7 @@ #if defined(MBEDTLS_HMAC_DRBG_C) #include "mbedtls/hmac_drbg.h" +#include "mbedtls/platform_util.h" #include @@ -50,11 +51,6 @@ #endif /* MBEDTLS_SELF_TEST */ #endif /* MBEDTLS_PLATFORM_C */ -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * HMAC_DRBG context initialization */ @@ -111,16 +107,18 @@ int mbedtls_hmac_drbg_update_ret( mbedtls_hmac_drbg_context *ctx, } exit: - mbedtls_zeroize( K, sizeof( K ) ); + mbedtls_platform_zeroize( K, sizeof( K ) ); return( ret ); } +#if !defined(MBEDTLS_DEPRECATED_REMOVED) void mbedtls_hmac_drbg_update( mbedtls_hmac_drbg_context *ctx, const unsigned char *additional, size_t add_len ) { (void) mbedtls_hmac_drbg_update_ret( ctx, additional, add_len ); } +#endif /* MBEDTLS_DEPRECATED_REMOVED */ /* * Simplified HMAC_DRBG initialisation (for use with deterministic ECDSA) @@ -192,7 +190,7 @@ int mbedtls_hmac_drbg_reseed( mbedtls_hmac_drbg_context *ctx, exit: /* 4. Done */ - mbedtls_zeroize( seed, seedlen ); + mbedtls_platform_zeroize( seed, seedlen ); return( ret ); } @@ -385,7 +383,7 @@ void mbedtls_hmac_drbg_free( mbedtls_hmac_drbg_context *ctx ) mbedtls_mutex_free( &ctx->mutex ); #endif mbedtls_md_free( &ctx->md_ctx ); - mbedtls_zeroize( ctx, sizeof( mbedtls_hmac_drbg_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_hmac_drbg_context ) ); } #if defined(MBEDTLS_FS_IO) @@ -411,7 +409,7 @@ int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const cha exit: fclose( f ); - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); return( ret ); } @@ -419,35 +417,36 @@ int mbedtls_hmac_drbg_write_seed_file( mbedtls_hmac_drbg_context *ctx, const cha int mbedtls_hmac_drbg_update_seed_file( mbedtls_hmac_drbg_context *ctx, const char *path ) { int ret = 0; - FILE *f; + FILE *f = NULL; size_t n; unsigned char buf[ MBEDTLS_HMAC_DRBG_MAX_INPUT ]; + unsigned char c; if( ( f = fopen( path, "rb" ) ) == NULL ) return( MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR ); - fseek( f, 0, SEEK_END ); - n = (size_t) ftell( f ); - fseek( f, 0, SEEK_SET ); - - if( n > MBEDTLS_HMAC_DRBG_MAX_INPUT ) + n = fread( buf, 1, sizeof( buf ), f ); + if( fread( &c, 1, 1, f ) != 0 ) { - fclose( f ); - return( MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG ); + ret = MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG; + goto exit; } - - if( fread( buf, 1, n, f ) != n ) + if( n == 0 || ferror( f ) ) + { ret = MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR; - else - ret = mbedtls_hmac_drbg_update_ret( ctx, buf, n ); - + goto exit; + } fclose( f ); + f = NULL; - mbedtls_zeroize( buf, sizeof( buf ) ); + ret = mbedtls_hmac_drbg_update_ret( ctx, buf, n ); +exit: + mbedtls_platform_zeroize( buf, sizeof( buf ) ); + if( f != NULL ) + fclose( f ); if( ret != 0 ) return( ret ); - return( mbedtls_hmac_drbg_write_seed_file( ctx, path ) ); } #endif /* MBEDTLS_FS_IO */ diff --git a/3rdparty/mbedtls/mbedtls/library/md.c b/3rdparty/mbedtls/mbedtls/library/md.c index 00249af78b..303cdcbeeb 100644 --- a/3rdparty/mbedtls/mbedtls/library/md.c +++ b/3rdparty/mbedtls/mbedtls/library/md.c @@ -33,6 +33,7 @@ #include "mbedtls/md.h" #include "mbedtls/md_internal.h" +#include "mbedtls/platform_util.h" #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" @@ -48,11 +49,6 @@ #include #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * Reminder: update profiles in x509_crt.c when adding a new hash! */ @@ -193,11 +189,12 @@ void mbedtls_md_free( mbedtls_md_context_t *ctx ) if( ctx->hmac_ctx != NULL ) { - mbedtls_zeroize( ctx->hmac_ctx, 2 * ctx->md_info->block_size ); + mbedtls_platform_zeroize( ctx->hmac_ctx, + 2 * ctx->md_info->block_size ); mbedtls_free( ctx->hmac_ctx ); } - mbedtls_zeroize( ctx, sizeof( mbedtls_md_context_t ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_md_context_t ) ); } int mbedtls_md_clone( mbedtls_md_context_t *dst, @@ -311,7 +308,7 @@ int mbedtls_md_file( const mbedtls_md_info_t *md_info, const char *path, unsigne ret = md_info->finish_func( ctx.md_ctx, output ); cleanup: - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); fclose( f ); mbedtls_md_free( &ctx ); @@ -361,7 +358,7 @@ int mbedtls_md_hmac_starts( mbedtls_md_context_t *ctx, const unsigned char *key, goto cleanup; cleanup: - mbedtls_zeroize( sum, sizeof( sum ) ); + mbedtls_platform_zeroize( sum, sizeof( sum ) ); return( ret ); } diff --git a/3rdparty/mbedtls/mbedtls/library/md2.c b/3rdparty/mbedtls/mbedtls/library/md2.c index b88aa406af..1c0b3df52d 100644 --- a/3rdparty/mbedtls/mbedtls/library/md2.c +++ b/3rdparty/mbedtls/mbedtls/library/md2.c @@ -34,6 +34,7 @@ #if defined(MBEDTLS_MD2_C) #include "mbedtls/md2.h" +#include "mbedtls/platform_util.h" #include @@ -48,11 +49,6 @@ #if !defined(MBEDTLS_MD2_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - static const unsigned char PI_SUBST[256] = { 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, @@ -93,7 +89,7 @@ void mbedtls_md2_free( mbedtls_md2_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_md2_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_md2_context ) ); } void mbedtls_md2_clone( mbedtls_md2_context *dst, diff --git a/3rdparty/mbedtls/mbedtls/library/md4.c b/3rdparty/mbedtls/mbedtls/library/md4.c index ba704f58e8..828fd42999 100644 --- a/3rdparty/mbedtls/mbedtls/library/md4.c +++ b/3rdparty/mbedtls/mbedtls/library/md4.c @@ -34,6 +34,7 @@ #if defined(MBEDTLS_MD4_C) #include "mbedtls/md4.h" +#include "mbedtls/platform_util.h" #include @@ -48,11 +49,6 @@ #if !defined(MBEDTLS_MD4_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * 32-bit integer manipulation macros (little endian) */ @@ -86,7 +82,7 @@ void mbedtls_md4_free( mbedtls_md4_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_md4_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_md4_context ) ); } void mbedtls_md4_clone( mbedtls_md4_context *dst, @@ -141,15 +137,21 @@ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, GET_UINT32_LE( X[14], data, 56 ); GET_UINT32_LE( X[15], data, 60 ); -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) +#define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n)))) A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; -#define F(x, y, z) ((x & y) | ((~x) & z)) -#define P(a,b,c,d,x,s) { a += F(b,c,d) + x; a = S(a,s); } +#define F(x, y, z) (((x) & (y)) | ((~(x)) & (z))) +#define P(a,b,c,d,x,s) \ + do \ + { \ + (a) += F((b),(c),(d)) + (x); \ + (a) = S((a),(s)); \ + } while( 0 ) + P( A, B, C, D, X[ 0], 3 ); P( D, A, B, C, X[ 1], 7 ); @@ -171,8 +173,13 @@ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, #undef P #undef F -#define F(x,y,z) ((x & y) | (x & z) | (y & z)) -#define P(a,b,c,d,x,s) { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); } +#define F(x,y,z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) +#define P(a,b,c,d,x,s) \ + do \ + { \ + (a) += F((b),(c),(d)) + (x) + 0x5A827999; \ + (a) = S((a),(s)); \ + } while( 0 ) P( A, B, C, D, X[ 0], 3 ); P( D, A, B, C, X[ 4], 5 ); @@ -194,8 +201,13 @@ int mbedtls_internal_md4_process( mbedtls_md4_context *ctx, #undef P #undef F -#define F(x,y,z) (x ^ y ^ z) -#define P(a,b,c,d,x,s) { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); } +#define F(x,y,z) ((x) ^ (y) ^ (z)) +#define P(a,b,c,d,x,s) \ + do \ + { \ + (a) += F((b),(c),(d)) + (x) + 0x6ED9EBA1; \ + (a) = S((a),(s)); \ + } while( 0 ) P( A, B, C, D, X[ 0], 3 ); P( D, A, B, C, X[ 8], 9 ); diff --git a/3rdparty/mbedtls/mbedtls/library/md5.c b/3rdparty/mbedtls/mbedtls/library/md5.c index 3ba88cfc5d..a93da8a061 100644 --- a/3rdparty/mbedtls/mbedtls/library/md5.c +++ b/3rdparty/mbedtls/mbedtls/library/md5.c @@ -33,6 +33,7 @@ #if defined(MBEDTLS_MD5_C) #include "mbedtls/md5.h" +#include "mbedtls/platform_util.h" #include @@ -47,11 +48,6 @@ #if !defined(MBEDTLS_MD5_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * 32-bit integer manipulation macros (little endian) */ @@ -85,7 +81,7 @@ void mbedtls_md5_free( mbedtls_md5_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_md5_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_md5_context ) ); } void mbedtls_md5_clone( mbedtls_md5_context *dst, @@ -140,19 +136,22 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, GET_UINT32_LE( X[14], data, 56 ); GET_UINT32_LE( X[15], data, 60 ); -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) +#define S(x,n) \ + ( ( (x) << (n) ) | ( ( (x) & 0xFFFFFFFF) >> ( 32 - (n) ) ) ) -#define P(a,b,c,d,k,s,t) \ -{ \ - a += F(b,c,d) + X[k] + t; a = S(a,s) + b; \ -} +#define P(a,b,c,d,k,s,t) \ + do \ + { \ + (a) += F((b),(c),(d)) + X[(k)] + (t); \ + (a) = S((a),(s)) + (b); \ + } while( 0 ) A = ctx->state[0]; B = ctx->state[1]; C = ctx->state[2]; D = ctx->state[3]; -#define F(x,y,z) (z ^ (x & (y ^ z))) +#define F(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) P( A, B, C, D, 0, 7, 0xD76AA478 ); P( D, A, B, C, 1, 12, 0xE8C7B756 ); @@ -173,7 +172,7 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, #undef F -#define F(x,y,z) (y ^ (z & (x ^ y))) +#define F(x,y,z) ((y) ^ ((z) & ((x) ^ (y)))) P( A, B, C, D, 1, 5, 0xF61E2562 ); P( D, A, B, C, 6, 9, 0xC040B340 ); @@ -194,7 +193,7 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, #undef F -#define F(x,y,z) (x ^ y ^ z) +#define F(x,y,z) ((x) ^ (y) ^ (z)) P( A, B, C, D, 5, 4, 0xFFFA3942 ); P( D, A, B, C, 8, 11, 0x8771F681 ); @@ -215,7 +214,7 @@ int mbedtls_internal_md5_process( mbedtls_md5_context *ctx, #undef F -#define F(x,y,z) (y ^ (x | ~z)) +#define F(x,y,z) ((y) ^ ((x) | ~(z))) P( A, B, C, D, 0, 6, 0xF4292244 ); P( D, A, B, C, 7, 10, 0x432AFF97 ); diff --git a/3rdparty/mbedtls/mbedtls/library/memory_buffer_alloc.c b/3rdparty/mbedtls/mbedtls/library/memory_buffer_alloc.c index eb555f3326..51ea7c41d7 100644 --- a/3rdparty/mbedtls/mbedtls/library/memory_buffer_alloc.c +++ b/3rdparty/mbedtls/mbedtls/library/memory_buffer_alloc.c @@ -31,6 +31,7 @@ /* No need for the header guard as MBEDTLS_MEMORY_BUFFER_ALLOC_C is dependent upon MBEDTLS_PLATFORM_C */ #include "mbedtls/platform.h" +#include "mbedtls/platform_util.h" #include @@ -42,11 +43,6 @@ #include "mbedtls/threading.h" #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - #define MAGIC1 0xFF00AA55 #define MAGIC2 0xEE119966 #define MAX_BT 20 @@ -113,7 +109,7 @@ static void debug_header( memory_header *hdr ) #endif } -static void debug_chain() +static void debug_chain( void ) { memory_header *cur = heap.first; @@ -180,7 +176,7 @@ static int verify_header( memory_header *hdr ) return( 0 ); } -static int verify_chain() +static int verify_chain( void ) { memory_header *prv = heap.first, *cur; @@ -504,13 +500,13 @@ void mbedtls_memory_buffer_set_verify( int verify ) heap.verify = verify; } -int mbedtls_memory_buffer_alloc_verify() +int mbedtls_memory_buffer_alloc_verify( void ) { return verify_chain(); } #if defined(MBEDTLS_MEMORY_DEBUG) -void mbedtls_memory_buffer_alloc_status() +void mbedtls_memory_buffer_alloc_status( void ) { mbedtls_fprintf( stderr, "Current use: %zu blocks / %zu bytes, max: %zu blocks / " @@ -609,12 +605,12 @@ void mbedtls_memory_buffer_alloc_init( unsigned char *buf, size_t len ) heap.first_free = heap.first; } -void mbedtls_memory_buffer_alloc_free() +void mbedtls_memory_buffer_alloc_free( void ) { #if defined(MBEDTLS_THREADING_C) mbedtls_mutex_free( &heap.mutex ); #endif - mbedtls_zeroize( &heap, sizeof(buffer_alloc_ctx) ); + mbedtls_platform_zeroize( &heap, sizeof(buffer_alloc_ctx) ); } #if defined(MBEDTLS_SELF_TEST) @@ -629,7 +625,7 @@ static int check_pointer( void *p ) return( 0 ); } -static int check_all_free( ) +static int check_all_free( void ) { if( #if defined(MBEDTLS_MEMORY_DEBUG) diff --git a/3rdparty/mbedtls/mbedtls/library/net_sockets.c b/3rdparty/mbedtls/mbedtls/library/net_sockets.c index 1e737c8bb7..816b1303df 100644 --- a/3rdparty/mbedtls/mbedtls/library/net_sockets.c +++ b/3rdparty/mbedtls/mbedtls/library/net_sockets.c @@ -19,6 +19,11 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +/* Enable definition of getaddrinfo() even when compiling with -std=c99. Must + * be set before config.h, which pulls in glibc's features.h indirectly. + * Harmless on other platforms. */ +#define _POSIX_C_SOURCE 200112L + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -28,7 +33,8 @@ #if defined(MBEDTLS_NET_C) #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ - !defined(__APPLE__) && !defined(_WIN32) + !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ + !defined(__HAIKU__) #error "This module only works on Unix and Windows, see MBEDTLS_NET_C in config.h" #endif @@ -45,6 +51,8 @@ #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ !defined(EFI32) +#define IS_EINTR( ret ) ( ( ret ) == WSAEINTR ) + #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0501) #undef _WIN32_WINNT /* Enables getaddrinfo() & Co */ @@ -83,6 +91,8 @@ static int wsa_init_done = 0; #include #include +#define IS_EINTR( ret ) ( ( ret ) == EINTR ) + #endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ /* Some MS functions want int and MSVC warns if we pass size_t, @@ -439,6 +449,72 @@ int mbedtls_net_set_nonblock( mbedtls_net_context *ctx ) #endif } +/* + * Check if data is available on the socket + */ + +int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout ) +{ + int ret; + struct timeval tv; + + fd_set read_fds; + fd_set write_fds; + + int fd = ctx->fd; + + if( fd < 0 ) + return( MBEDTLS_ERR_NET_INVALID_CONTEXT ); + +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + /* Ensure that memory sanitizers consider read_fds and write_fds as + * initialized even on platforms such as Glibc/x86_64 where FD_ZERO + * is implemented in assembly. */ + memset( &read_fds, 0, sizeof( read_fds ) ); + memset( &write_fds, 0, sizeof( write_fds ) ); +#endif +#endif + + FD_ZERO( &read_fds ); + if( rw & MBEDTLS_NET_POLL_READ ) + { + rw &= ~MBEDTLS_NET_POLL_READ; + FD_SET( fd, &read_fds ); + } + + FD_ZERO( &write_fds ); + if( rw & MBEDTLS_NET_POLL_WRITE ) + { + rw &= ~MBEDTLS_NET_POLL_WRITE; + FD_SET( fd, &write_fds ); + } + + if( rw != 0 ) + return( MBEDTLS_ERR_NET_BAD_INPUT_DATA ); + + tv.tv_sec = timeout / 1000; + tv.tv_usec = ( timeout % 1000 ) * 1000; + + do + { + ret = select( fd + 1, &read_fds, &write_fds, NULL, + timeout == (uint32_t) -1 ? NULL : &tv ); + } + while( IS_EINTR( ret ) ); + + if( ret < 0 ) + return( MBEDTLS_ERR_NET_POLL_FAILED ); + + ret = 0; + if( FD_ISSET( fd, &read_fds ) ) + ret |= MBEDTLS_NET_POLL_READ; + if( FD_ISSET( fd, &write_fds ) ) + ret |= MBEDTLS_NET_POLL_WRITE; + + return( ret ); +} + /* * Portable usleep helper */ @@ -498,8 +574,8 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ) /* * Read at most 'len' characters, blocking for at most 'timeout' ms */ -int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, - uint32_t timeout ) +int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, + size_t len, uint32_t timeout ) { int ret; struct timeval tv; diff --git a/3rdparty/mbedtls/mbedtls/library/nist_kw.c b/3rdparty/mbedtls/mbedtls/library/nist_kw.c new file mode 100644 index 0000000000..317a2426ae --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/nist_kw.c @@ -0,0 +1,755 @@ +/* + * Implementation of NIST SP 800-38F key wrapping, supporting KW and KWP modes + * only + * + * Copyright (C) 2018, Arm Limited (or its affiliates), All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ +/* + * Definition of Key Wrapping: + * https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf + * RFC 3394 "Advanced Encryption Standard (AES) Key Wrap Algorithm" + * RFC 5649 "Advanced Encryption Standard (AES) Key Wrap with Padding Algorithm" + * + * Note: RFC 3394 defines different methodology for intermediate operations for + * the wrapping and unwrapping operation than the definition in NIST SP 800-38F. + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_NIST_KW_C) + +#include "mbedtls/nist_kw.h" +#include "mbedtls/platform_util.h" + +#include +#include + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +#if !defined(MBEDTLS_NIST_KW_ALT) + +#define KW_SEMIBLOCK_LENGTH 8 +#define MIN_SEMIBLOCKS_COUNT 3 + +/* constant-time buffer comparison */ +static inline unsigned char mbedtls_nist_kw_safer_memcmp( const void *a, const void *b, size_t n ) +{ + size_t i; + volatile const unsigned char *A = (volatile const unsigned char *) a; + volatile const unsigned char *B = (volatile const unsigned char *) b; + volatile unsigned char diff = 0; + + for( i = 0; i < n; i++ ) + { + /* Read volatile data in order before computing diff. + * This avoids IAR compiler warning: + * 'the order of volatile accesses is undefined ..' */ + unsigned char x = A[i], y = B[i]; + diff |= x ^ y; + } + + return( diff ); +} + +/*! The 64-bit default integrity check value (ICV) for KW mode. */ +static const unsigned char NIST_KW_ICV1[] = {0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6}; +/*! The 32-bit default integrity check value (ICV) for KWP mode. */ +static const unsigned char NIST_KW_ICV2[] = {0xA6, 0x59, 0x59, 0xA6}; + +#ifndef GET_UINT32_BE +#define GET_UINT32_BE(n,b,i) \ +do { \ + (n) = ( (uint32_t) (b)[(i) ] << 24 ) \ + | ( (uint32_t) (b)[(i) + 1] << 16 ) \ + | ( (uint32_t) (b)[(i) + 2] << 8 ) \ + | ( (uint32_t) (b)[(i) + 3] ); \ +} while( 0 ) +#endif + +#ifndef PUT_UINT32_BE +#define PUT_UINT32_BE(n,b,i) \ +do { \ + (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \ + (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \ + (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \ + (b)[(i) + 3] = (unsigned char) ( (n) ); \ +} while( 0 ) +#endif + +/* + * Initialize context + */ +void mbedtls_nist_kw_init( mbedtls_nist_kw_context *ctx ) +{ + memset( ctx, 0, sizeof( mbedtls_nist_kw_context ) ); +} + +int mbedtls_nist_kw_setkey( mbedtls_nist_kw_context *ctx, + mbedtls_cipher_id_t cipher, + const unsigned char *key, + unsigned int keybits, + const int is_wrap ) +{ + int ret; + const mbedtls_cipher_info_t *cipher_info; + + cipher_info = mbedtls_cipher_info_from_values( cipher, + keybits, + MBEDTLS_MODE_ECB ); + if( cipher_info == NULL ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + if( cipher_info->block_size != 16 ) + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* + * SP 800-38F currently defines AES cipher as the only block cipher allowed: + * "For KW and KWP, the underlying block cipher shall be approved, and the + * block size shall be 128 bits. Currently, the AES block cipher, with key + * lengths of 128, 192, or 256 bits, is the only block cipher that fits + * this profile." + * Currently we don't support other 128 bit block ciphers for key wrapping, + * such as Camellia and Aria. + */ + if( cipher != MBEDTLS_CIPHER_ID_AES ) + return( MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE ); + + mbedtls_cipher_free( &ctx->cipher_ctx ); + + if( ( ret = mbedtls_cipher_setup( &ctx->cipher_ctx, cipher_info ) ) != 0 ) + return( ret ); + + if( ( ret = mbedtls_cipher_setkey( &ctx->cipher_ctx, key, keybits, + is_wrap ? MBEDTLS_ENCRYPT : + MBEDTLS_DECRYPT ) + ) != 0 ) + { + return( ret ); + } + + return( 0 ); +} + +/* + * Free context + */ +void mbedtls_nist_kw_free( mbedtls_nist_kw_context *ctx ) +{ + mbedtls_cipher_free( &ctx->cipher_ctx ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_nist_kw_context ) ); +} + +/* + * Helper function for Xoring the uint64_t "t" with the encrypted A. + * Defined in NIST SP 800-38F section 6.1 + */ +static void calc_a_xor_t( unsigned char A[KW_SEMIBLOCK_LENGTH], uint64_t t ) +{ + size_t i = 0; + for( i = 0; i < sizeof( t ); i++ ) + { + A[i] ^= ( t >> ( ( sizeof( t ) - 1 - i ) * 8 ) ) & 0xff; + } +} + +/* + * KW-AE as defined in SP 800-38F section 6.2 + * KWP-AE as defined in SP 800-38F section 6.3 + */ +int mbedtls_nist_kw_wrap( mbedtls_nist_kw_context *ctx, + mbedtls_nist_kw_mode_t mode, + const unsigned char *input, size_t in_len, + unsigned char *output, size_t *out_len, size_t out_size ) +{ + int ret = 0; + size_t semiblocks = 0; + size_t s; + size_t olen, padlen = 0; + uint64_t t = 0; + unsigned char outbuff[KW_SEMIBLOCK_LENGTH * 2]; + unsigned char inbuff[KW_SEMIBLOCK_LENGTH * 2]; + unsigned char *R2 = output + KW_SEMIBLOCK_LENGTH; + unsigned char *A = output; + + *out_len = 0; + /* + * Generate the String to work on + */ + if( mode == MBEDTLS_KW_MODE_KW ) + { + if( out_size < in_len + KW_SEMIBLOCK_LENGTH ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + /* + * According to SP 800-38F Table 1, the plaintext length for KW + * must be between 2 to 2^54-1 semiblocks inclusive. + */ + if( in_len < 16 || +#if SIZE_MAX > 0x1FFFFFFFFFFFFF8 + in_len > 0x1FFFFFFFFFFFFF8 || +#endif + in_len % KW_SEMIBLOCK_LENGTH != 0 ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + memcpy( output, NIST_KW_ICV1, KW_SEMIBLOCK_LENGTH ); + memmove( output + KW_SEMIBLOCK_LENGTH, input, in_len ); + } + else + { + if( in_len % 8 != 0 ) + { + padlen = ( 8 - ( in_len % 8 ) ); + } + + if( out_size < in_len + KW_SEMIBLOCK_LENGTH + padlen ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + /* + * According to SP 800-38F Table 1, the plaintext length for KWP + * must be between 1 and 2^32-1 octets inclusive. + */ + if( in_len < 1 +#if SIZE_MAX > 0xFFFFFFFF + || in_len > 0xFFFFFFFF +#endif + ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + memcpy( output, NIST_KW_ICV2, KW_SEMIBLOCK_LENGTH / 2 ); + PUT_UINT32_BE( ( in_len & 0xffffffff ), output, + KW_SEMIBLOCK_LENGTH / 2 ); + + memcpy( output + KW_SEMIBLOCK_LENGTH, input, in_len ); + memset( output + KW_SEMIBLOCK_LENGTH + in_len, 0, padlen ); + } + semiblocks = ( ( in_len + padlen ) / KW_SEMIBLOCK_LENGTH ) + 1; + + s = 6 * ( semiblocks - 1 ); + + if( mode == MBEDTLS_KW_MODE_KWP + && in_len <= KW_SEMIBLOCK_LENGTH ) + { + memcpy( inbuff, output, 16 ); + ret = mbedtls_cipher_update( &ctx->cipher_ctx, + inbuff, 16, output, &olen ); + if( ret != 0 ) + goto cleanup; + } + else + { + /* + * Do the wrapping function W, as defined in RFC 3394 section 2.2.1 + */ + if( semiblocks < MIN_SEMIBLOCKS_COUNT ) + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto cleanup; + } + + /* Calculate intermediate values */ + for( t = 1; t <= s; t++ ) + { + memcpy( inbuff, A, KW_SEMIBLOCK_LENGTH ); + memcpy( inbuff + KW_SEMIBLOCK_LENGTH, R2, KW_SEMIBLOCK_LENGTH ); + + ret = mbedtls_cipher_update( &ctx->cipher_ctx, + inbuff, 16, outbuff, &olen ); + if( ret != 0 ) + goto cleanup; + + memcpy( A, outbuff, KW_SEMIBLOCK_LENGTH ); + calc_a_xor_t( A, t ); + + memcpy( R2, outbuff + KW_SEMIBLOCK_LENGTH, KW_SEMIBLOCK_LENGTH ); + R2 += KW_SEMIBLOCK_LENGTH; + if( R2 >= output + ( semiblocks * KW_SEMIBLOCK_LENGTH ) ) + R2 = output + KW_SEMIBLOCK_LENGTH; + } + } + + *out_len = semiblocks * KW_SEMIBLOCK_LENGTH; + +cleanup: + + if( ret != 0) + { + memset( output, 0, semiblocks * KW_SEMIBLOCK_LENGTH ); + } + mbedtls_platform_zeroize( inbuff, KW_SEMIBLOCK_LENGTH * 2 ); + mbedtls_platform_zeroize( outbuff, KW_SEMIBLOCK_LENGTH * 2 ); + + return( ret ); +} + +/* + * W-1 function as defined in RFC 3394 section 2.2.2 + * This function assumes the following: + * 1. Output buffer is at least of size ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH. + * 2. The input buffer is of size semiblocks * KW_SEMIBLOCK_LENGTH. + * 3. Minimal number of semiblocks is 3. + * 4. A is a buffer to hold the first semiblock of the input buffer. + */ +static int unwrap( mbedtls_nist_kw_context *ctx, + const unsigned char *input, size_t semiblocks, + unsigned char A[KW_SEMIBLOCK_LENGTH], + unsigned char *output, size_t* out_len ) +{ + int ret = 0; + const size_t s = 6 * ( semiblocks - 1 ); + size_t olen; + uint64_t t = 0; + unsigned char outbuff[KW_SEMIBLOCK_LENGTH * 2]; + unsigned char inbuff[KW_SEMIBLOCK_LENGTH * 2]; + unsigned char *R = output + ( semiblocks - 2 ) * KW_SEMIBLOCK_LENGTH; + *out_len = 0; + + if( semiblocks < MIN_SEMIBLOCKS_COUNT ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + memcpy( A, input, KW_SEMIBLOCK_LENGTH ); + memmove( output, input + KW_SEMIBLOCK_LENGTH, ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH ); + + /* Calculate intermediate values */ + for( t = s; t >= 1; t-- ) + { + calc_a_xor_t( A, t ); + + memcpy( inbuff, A, KW_SEMIBLOCK_LENGTH ); + memcpy( inbuff + KW_SEMIBLOCK_LENGTH, R, KW_SEMIBLOCK_LENGTH ); + + ret = mbedtls_cipher_update( &ctx->cipher_ctx, + inbuff, 16, outbuff, &olen ); + if( ret != 0 ) + goto cleanup; + + memcpy( A, outbuff, KW_SEMIBLOCK_LENGTH ); + + /* Set R as LSB64 of outbuff */ + memcpy( R, outbuff + KW_SEMIBLOCK_LENGTH, KW_SEMIBLOCK_LENGTH ); + + if( R == output ) + R = output + ( semiblocks - 2 ) * KW_SEMIBLOCK_LENGTH; + else + R -= KW_SEMIBLOCK_LENGTH; + } + + *out_len = ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH; + +cleanup: + if( ret != 0) + memset( output, 0, ( semiblocks - 1 ) * KW_SEMIBLOCK_LENGTH ); + mbedtls_platform_zeroize( inbuff, sizeof( inbuff ) ); + mbedtls_platform_zeroize( outbuff, sizeof( outbuff ) ); + + return( ret ); +} + +/* + * KW-AD as defined in SP 800-38F section 6.2 + * KWP-AD as defined in SP 800-38F section 6.3 + */ +int mbedtls_nist_kw_unwrap( mbedtls_nist_kw_context *ctx, + mbedtls_nist_kw_mode_t mode, + const unsigned char *input, size_t in_len, + unsigned char *output, size_t *out_len, size_t out_size ) +{ + int ret = 0; + size_t i, olen; + unsigned char A[KW_SEMIBLOCK_LENGTH]; + unsigned char diff, bad_padding = 0; + + *out_len = 0; + if( out_size < in_len - KW_SEMIBLOCK_LENGTH ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + if( mode == MBEDTLS_KW_MODE_KW ) + { + /* + * According to SP 800-38F Table 1, the ciphertext length for KW + * must be between 3 to 2^54 semiblocks inclusive. + */ + if( in_len < 24 || +#if SIZE_MAX > 0x200000000000000 + in_len > 0x200000000000000 || +#endif + in_len % KW_SEMIBLOCK_LENGTH != 0 ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + ret = unwrap( ctx, input, in_len / KW_SEMIBLOCK_LENGTH, + A, output, out_len ); + if( ret != 0 ) + goto cleanup; + + /* Check ICV in "constant-time" */ + diff = mbedtls_nist_kw_safer_memcmp( NIST_KW_ICV1, A, KW_SEMIBLOCK_LENGTH ); + + if( diff != 0 ) + { + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + goto cleanup; + } + + } + else if( mode == MBEDTLS_KW_MODE_KWP ) + { + size_t padlen = 0; + uint32_t Plen; + /* + * According to SP 800-38F Table 1, the ciphertext length for KWP + * must be between 2 to 2^29 semiblocks inclusive. + */ + if( in_len < KW_SEMIBLOCK_LENGTH * 2 || +#if SIZE_MAX > 0x100000000 + in_len > 0x100000000 || +#endif + in_len % KW_SEMIBLOCK_LENGTH != 0 ) + { + return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + } + + if( in_len == KW_SEMIBLOCK_LENGTH * 2 ) + { + unsigned char outbuff[KW_SEMIBLOCK_LENGTH * 2]; + ret = mbedtls_cipher_update( &ctx->cipher_ctx, + input, 16, outbuff, &olen ); + if( ret != 0 ) + goto cleanup; + + memcpy( A, outbuff, KW_SEMIBLOCK_LENGTH ); + memcpy( output, outbuff + KW_SEMIBLOCK_LENGTH, KW_SEMIBLOCK_LENGTH ); + mbedtls_platform_zeroize( outbuff, sizeof( outbuff ) ); + *out_len = KW_SEMIBLOCK_LENGTH; + } + else + { + /* in_len >= KW_SEMIBLOCK_LENGTH * 3 */ + ret = unwrap( ctx, input, in_len / KW_SEMIBLOCK_LENGTH, + A, output, out_len ); + if( ret != 0 ) + goto cleanup; + } + + /* Check ICV in "constant-time" */ + diff = mbedtls_nist_kw_safer_memcmp( NIST_KW_ICV2, A, KW_SEMIBLOCK_LENGTH / 2 ); + + if( diff != 0 ) + { + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + } + + GET_UINT32_BE( Plen, A, KW_SEMIBLOCK_LENGTH / 2 ); + + /* + * Plen is the length of the plaintext, when the input is valid. + * If Plen is larger than the plaintext and padding, padlen will be + * larger than 8, because of the type wrap around. + */ + padlen = in_len - KW_SEMIBLOCK_LENGTH - Plen; + if ( padlen > 7 ) + { + padlen &= 7; + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + } + + /* Check padding in "constant-time" */ + for( diff = 0, i = 0; i < KW_SEMIBLOCK_LENGTH; i++ ) + { + if( i >= KW_SEMIBLOCK_LENGTH - padlen ) + diff |= output[*out_len - KW_SEMIBLOCK_LENGTH + i]; + else + bad_padding |= output[*out_len - KW_SEMIBLOCK_LENGTH + i]; + } + + if( diff != 0 ) + { + ret = MBEDTLS_ERR_CIPHER_AUTH_FAILED; + } + + if( ret != 0 ) + { + goto cleanup; + } + memset( output + Plen, 0, padlen ); + *out_len = Plen; + } + else + { + ret = MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE; + goto cleanup; + } + +cleanup: + if( ret != 0 ) + { + memset( output, 0, *out_len ); + *out_len = 0; + } + + mbedtls_platform_zeroize( &bad_padding, sizeof( bad_padding) ); + mbedtls_platform_zeroize( &diff, sizeof( diff ) ); + mbedtls_platform_zeroize( A, sizeof( A ) ); + + return( ret ); +} + +#endif /* !MBEDTLS_NIST_KW_ALT */ + +#if defined(MBEDTLS_SELF_TEST) && defined(MBEDTLS_AES_C) + +#define KW_TESTS 3 + +/* + * Test vectors taken from NIST + * https://csrc.nist.gov/Projects/Cryptographic-Algorithm-Validation-Program/CAVP-TESTING-BLOCK-CIPHER-MODES#KW + */ +static const unsigned int key_len[KW_TESTS] = { 16, 24, 32 }; + +static const unsigned char kw_key[KW_TESTS][32] = { + { 0x75, 0x75, 0xda, 0x3a, 0x93, 0x60, 0x7c, 0xc2, + 0xbf, 0xd8, 0xce, 0xc7, 0xaa, 0xdf, 0xd9, 0xa6 }, + { 0x2d, 0x85, 0x26, 0x08, 0x1d, 0x02, 0xfb, 0x5b, + 0x85, 0xf6, 0x9a, 0xc2, 0x86, 0xec, 0xd5, 0x7d, + 0x40, 0xdf, 0x5d, 0xf3, 0x49, 0x47, 0x44, 0xd3 }, + { 0x11, 0x2a, 0xd4, 0x1b, 0x48, 0x56, 0xc7, 0x25, + 0x4a, 0x98, 0x48, 0xd3, 0x0f, 0xdd, 0x78, 0x33, + 0x5b, 0x03, 0x9a, 0x48, 0xa8, 0x96, 0x2c, 0x4d, + 0x1c, 0xb7, 0x8e, 0xab, 0xd5, 0xda, 0xd7, 0x88 } +}; + +static const unsigned char kw_msg[KW_TESTS][40] = { + { 0x42, 0x13, 0x6d, 0x3c, 0x38, 0x4a, 0x3e, 0xea, + 0xc9, 0x5a, 0x06, 0x6f, 0xd2, 0x8f, 0xed, 0x3f }, + { 0x95, 0xc1, 0x1b, 0xf5, 0x35, 0x3a, 0xfe, 0xdb, + 0x98, 0xfd, 0xd6, 0xc8, 0xca, 0x6f, 0xdb, 0x6d, + 0xa5, 0x4b, 0x74, 0xb4, 0x99, 0x0f, 0xdc, 0x45, + 0xc0, 0x9d, 0x15, 0x8f, 0x51, 0xce, 0x62, 0x9d, + 0xe2, 0xaf, 0x26, 0xe3, 0x25, 0x0e, 0x6b, 0x4c }, + { 0x1b, 0x20, 0xbf, 0x19, 0x90, 0xb0, 0x65, 0xd7, + 0x98, 0xe1, 0xb3, 0x22, 0x64, 0xad, 0x50, 0xa8, + 0x74, 0x74, 0x92, 0xba, 0x09, 0xa0, 0x4d, 0xd1 } +}; + +static const size_t kw_msg_len[KW_TESTS] = { 16, 40, 24 }; +static const size_t kw_out_len[KW_TESTS] = { 24, 48, 32 }; +static const unsigned char kw_res[KW_TESTS][48] = { + { 0x03, 0x1f, 0x6b, 0xd7, 0xe6, 0x1e, 0x64, 0x3d, + 0xf6, 0x85, 0x94, 0x81, 0x6f, 0x64, 0xca, 0xa3, + 0xf5, 0x6f, 0xab, 0xea, 0x25, 0x48, 0xf5, 0xfb }, + { 0x44, 0x3c, 0x6f, 0x15, 0x09, 0x83, 0x71, 0x91, + 0x3e, 0x5c, 0x81, 0x4c, 0xa1, 0xa0, 0x42, 0xec, + 0x68, 0x2f, 0x7b, 0x13, 0x6d, 0x24, 0x3a, 0x4d, + 0x6c, 0x42, 0x6f, 0xc6, 0x97, 0x15, 0x63, 0xe8, + 0xa1, 0x4a, 0x55, 0x8e, 0x09, 0x64, 0x16, 0x19, + 0xbf, 0x03, 0xfc, 0xaf, 0x90, 0xb1, 0xfc, 0x2d }, + { 0xba, 0x8a, 0x25, 0x9a, 0x47, 0x1b, 0x78, 0x7d, + 0xd5, 0xd5, 0x40, 0xec, 0x25, 0xd4, 0x3d, 0x87, + 0x20, 0x0f, 0xda, 0xdc, 0x6d, 0x1f, 0x05, 0xd9, + 0x16, 0x58, 0x4f, 0xa9, 0xf6, 0xcb, 0xf5, 0x12 } +}; + +static const unsigned char kwp_key[KW_TESTS][32] = { + { 0x78, 0x65, 0xe2, 0x0f, 0x3c, 0x21, 0x65, 0x9a, + 0xb4, 0x69, 0x0b, 0x62, 0x9c, 0xdf, 0x3c, 0xc4 }, + { 0xf5, 0xf8, 0x96, 0xa3, 0xbd, 0x2f, 0x4a, 0x98, + 0x23, 0xef, 0x16, 0x2b, 0x00, 0xb8, 0x05, 0xd7, + 0xde, 0x1e, 0xa4, 0x66, 0x26, 0x96, 0xa2, 0x58 }, + { 0x95, 0xda, 0x27, 0x00, 0xca, 0x6f, 0xd9, 0xa5, + 0x25, 0x54, 0xee, 0x2a, 0x8d, 0xf1, 0x38, 0x6f, + 0x5b, 0x94, 0xa1, 0xa6, 0x0e, 0xd8, 0xa4, 0xae, + 0xf6, 0x0a, 0x8d, 0x61, 0xab, 0x5f, 0x22, 0x5a } +}; + +static const unsigned char kwp_msg[KW_TESTS][31] = { + { 0xbd, 0x68, 0x43, 0xd4, 0x20, 0x37, 0x8d, 0xc8, + 0x96 }, + { 0x6c, 0xcd, 0xd5, 0x85, 0x18, 0x40, 0x97, 0xeb, + 0xd5, 0xc3, 0xaf, 0x3e, 0x47, 0xd0, 0x2c, 0x19, + 0x14, 0x7b, 0x4d, 0x99, 0x5f, 0x96, 0x43, 0x66, + 0x91, 0x56, 0x75, 0x8c, 0x13, 0x16, 0x8f }, + { 0xd1 } +}; +static const size_t kwp_msg_len[KW_TESTS] = { 9, 31, 1 }; + +static const unsigned char kwp_res[KW_TESTS][48] = { + { 0x41, 0xec, 0xa9, 0x56, 0xd4, 0xaa, 0x04, 0x7e, + 0xb5, 0xcf, 0x4e, 0xfe, 0x65, 0x96, 0x61, 0xe7, + 0x4d, 0xb6, 0xf8, 0xc5, 0x64, 0xe2, 0x35, 0x00 }, + { 0x4e, 0x9b, 0xc2, 0xbc, 0xbc, 0x6c, 0x1e, 0x13, + 0xd3, 0x35, 0xbc, 0xc0, 0xf7, 0x73, 0x6a, 0x88, + 0xfa, 0x87, 0x53, 0x66, 0x15, 0xbb, 0x8e, 0x63, + 0x8b, 0xcc, 0x81, 0x66, 0x84, 0x68, 0x17, 0x90, + 0x67, 0xcf, 0xa9, 0x8a, 0x9d, 0x0e, 0x33, 0x26 }, + { 0x06, 0xba, 0x7a, 0xe6, 0xf3, 0x24, 0x8c, 0xfd, + 0xcf, 0x26, 0x75, 0x07, 0xfa, 0x00, 0x1b, 0xc4 } +}; +static const size_t kwp_out_len[KW_TESTS] = { 24, 40, 16 }; + +int mbedtls_nist_kw_self_test( int verbose ) +{ + mbedtls_nist_kw_context ctx; + unsigned char out[48]; + size_t olen; + int i; + int ret = 0; + mbedtls_nist_kw_init( &ctx ); + + for( i = 0; i < KW_TESTS; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " KW-AES-%u ", (unsigned int) key_len[i] * 8 ); + + ret = mbedtls_nist_kw_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, + kw_key[i], key_len[i] * 8, 1 ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( " KW: setup failed " ); + + goto end; + } + + ret = mbedtls_nist_kw_wrap( &ctx, MBEDTLS_KW_MODE_KW, kw_msg[i], + kw_msg_len[i], out, &olen, sizeof( out ) ); + if( ret != 0 || kw_out_len[i] != olen || + memcmp( out, kw_res[i], kw_out_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed. "); + + ret = 1; + goto end; + } + + if( ( ret = mbedtls_nist_kw_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, + kw_key[i], key_len[i] * 8, 0 ) ) + != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( " KW: setup failed "); + + goto end; + } + + ret = mbedtls_nist_kw_unwrap( &ctx, MBEDTLS_KW_MODE_KW, + out, olen, out, &olen, sizeof( out ) ); + + if( ret != 0 || olen != kw_msg_len[i] || + memcmp( out, kw_msg[i], kw_msg_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed\n" ); + + ret = 1; + goto end; + } + + if( verbose != 0 ) + mbedtls_printf( " passed\n" ); + } + + for( i = 0; i < KW_TESTS; i++ ) + { + olen = sizeof( out ); + if( verbose != 0 ) + mbedtls_printf( " KWP-AES-%u ", (unsigned int) key_len[i] * 8 ); + + ret = mbedtls_nist_kw_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, kwp_key[i], + key_len[i] * 8, 1 ); + if( ret != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( " KWP: setup failed " ); + + goto end; + } + ret = mbedtls_nist_kw_wrap( &ctx, MBEDTLS_KW_MODE_KWP, kwp_msg[i], + kwp_msg_len[i], out, &olen, sizeof( out ) ); + + if( ret != 0 || kwp_out_len[i] != olen || + memcmp( out, kwp_res[i], kwp_out_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed. "); + + ret = 1; + goto end; + } + + if( ( ret = mbedtls_nist_kw_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, + kwp_key[i], key_len[i] * 8, 0 ) ) + != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( " KWP: setup failed "); + + goto end; + } + + ret = mbedtls_nist_kw_unwrap( &ctx, MBEDTLS_KW_MODE_KWP, out, + olen, out, &olen, sizeof( out ) ); + + if( ret != 0 || olen != kwp_msg_len[i] || + memcmp( out, kwp_msg[i], kwp_msg_len[i] ) != 0 ) + { + if( verbose != 0 ) + mbedtls_printf( "failed. "); + + ret = 1; + goto end; + } + + if( verbose != 0 ) + mbedtls_printf( " passed\n" ); + } +end: + mbedtls_nist_kw_free( &ctx ); + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( ret ); +} + +#endif /* MBEDTLS_SELF_TEST && MBEDTLS_AES_C */ + +#endif /* MBEDTLS_NIST_KW_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/oid.c b/3rdparty/mbedtls/mbedtls/library/oid.c index edea950f8f..33f437cbe6 100644 --- a/3rdparty/mbedtls/mbedtls/library/oid.c +++ b/3rdparty/mbedtls/mbedtls/library/oid.c @@ -54,22 +54,24 @@ * Macro to generate an internal function for oid_XXX_from_asn1() (used by * the other functions) */ -#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \ -static const TYPE_T * oid_ ## NAME ## _from_asn1( const mbedtls_asn1_buf *oid ) \ -{ \ - const TYPE_T *p = LIST; \ - const mbedtls_oid_descriptor_t *cur = (const mbedtls_oid_descriptor_t *) p; \ - if( p == NULL || oid == NULL ) return( NULL ); \ - while( cur->asn1 != NULL ) { \ - if( cur->asn1_len == oid->len && \ - memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \ - return( p ); \ - } \ - p++; \ - cur = (const mbedtls_oid_descriptor_t *) p; \ - } \ - return( NULL ); \ -} +#define FN_OID_TYPED_FROM_ASN1( TYPE_T, NAME, LIST ) \ + static const TYPE_T * oid_ ## NAME ## _from_asn1( \ + const mbedtls_asn1_buf *oid ) \ + { \ + const TYPE_T *p = (LIST); \ + const mbedtls_oid_descriptor_t *cur = \ + (const mbedtls_oid_descriptor_t *) p; \ + if( p == NULL || oid == NULL ) return( NULL ); \ + while( cur->asn1 != NULL ) { \ + if( cur->asn1_len == oid->len && \ + memcmp( cur->asn1, oid->p, oid->len ) == 0 ) { \ + return( p ); \ + } \ + p++; \ + cur = (const mbedtls_oid_descriptor_t *) p; \ + } \ + return( NULL ); \ + } /* * Macro to generate a function for retrieving a single attribute from the @@ -103,12 +105,13 @@ int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1 ) */ #define FN_OID_GET_ATTR2(FN_NAME, TYPE_T, TYPE_NAME, ATTR1_TYPE, ATTR1, \ ATTR2_TYPE, ATTR2) \ -int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 ) \ +int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, \ + ATTR2_TYPE * ATTR2 ) \ { \ const TYPE_T *data = oid_ ## TYPE_NAME ## _from_asn1( oid ); \ - if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \ - *ATTR1 = data->ATTR1; \ - *ATTR2 = data->ATTR2; \ + if( data == NULL ) return( MBEDTLS_ERR_OID_NOT_FOUND ); \ + *(ATTR1) = data->ATTR1; \ + *(ATTR2) = data->ATTR2; \ return( 0 ); \ } @@ -119,16 +122,16 @@ int FN_NAME( const mbedtls_asn1_buf *oid, ATTR1_TYPE * ATTR1, ATTR2_TYPE * ATTR2 #define FN_OID_GET_OID_BY_ATTR1(FN_NAME, TYPE_T, LIST, ATTR1_TYPE, ATTR1) \ int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \ { \ - const TYPE_T *cur = LIST; \ + const TYPE_T *cur = (LIST); \ while( cur->descriptor.asn1 != NULL ) { \ - if( cur->ATTR1 == ATTR1 ) { \ + if( cur->ATTR1 == (ATTR1) ) { \ *oid = cur->descriptor.asn1; \ *olen = cur->descriptor.asn1_len; \ return( 0 ); \ } \ cur++; \ } \ - return( MBEDTLS_ERR_OID_NOT_FOUND ); \ + return( MBEDTLS_ERR_OID_NOT_FOUND ); \ } /* @@ -140,9 +143,9 @@ int FN_NAME( ATTR1_TYPE ATTR1, const char **oid, size_t *olen ) \ int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \ size_t *olen ) \ { \ - const TYPE_T *cur = LIST; \ + const TYPE_T *cur = (LIST); \ while( cur->descriptor.asn1 != NULL ) { \ - if( cur->ATTR1 == ATTR1 && cur->ATTR2 == ATTR2 ) { \ + if( cur->ATTR1 == (ATTR1) && cur->ATTR2 == (ATTR2) ) { \ *oid = cur->descriptor.asn1; \ *olen = cur->descriptor.asn1_len; \ return( 0 ); \ diff --git a/3rdparty/mbedtls/mbedtls/library/pem.c b/3rdparty/mbedtls/mbedtls/library/pem.c index ac86d7e479..897c8a0d6f 100644 --- a/3rdparty/mbedtls/mbedtls/library/pem.c +++ b/3rdparty/mbedtls/mbedtls/library/pem.c @@ -33,6 +33,7 @@ #include "mbedtls/aes.h" #include "mbedtls/md5.h" #include "mbedtls/cipher.h" +#include "mbedtls/platform_util.h" #include @@ -45,11 +46,6 @@ #endif #if defined(MBEDTLS_PEM_PARSE_C) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - void mbedtls_pem_init( mbedtls_pem_context *ctx ) { memset( ctx, 0, sizeof( mbedtls_pem_context ) ); @@ -135,7 +131,7 @@ static int pem_pbkdf1( unsigned char *key, size_t keylen, exit: mbedtls_md5_free( &md5_ctx ); - mbedtls_zeroize( md5sum, 16 ); + mbedtls_platform_zeroize( md5sum, 16 ); return( ret ); } @@ -164,7 +160,7 @@ static int pem_des_decrypt( unsigned char des_iv[8], exit: mbedtls_des_free( &des_ctx ); - mbedtls_zeroize( des_key, 8 ); + mbedtls_platform_zeroize( des_key, 8 ); return( ret ); } @@ -192,7 +188,7 @@ static int pem_des3_decrypt( unsigned char des3_iv[8], exit: mbedtls_des3_free( &des3_ctx ); - mbedtls_zeroize( des3_key, 24 ); + mbedtls_platform_zeroize( des3_key, 24 ); return( ret ); } @@ -222,7 +218,7 @@ static int pem_aes_decrypt( unsigned char aes_iv[16], unsigned int keylen, exit: mbedtls_aes_free( &aes_ctx ); - mbedtls_zeroize( aes_key, keylen ); + mbedtls_platform_zeroize( aes_key, keylen ); return( ret ); } @@ -359,7 +355,7 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const if( ( ret = mbedtls_base64_decode( buf, len, &len, s1, s2 - s1 ) ) != 0 ) { - mbedtls_zeroize( buf, len ); + mbedtls_platform_zeroize( buf, len ); mbedtls_free( buf ); return( MBEDTLS_ERR_PEM_INVALID_DATA + ret ); } @@ -370,7 +366,7 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const ( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) ) if( pwd == NULL ) { - mbedtls_zeroize( buf, len ); + mbedtls_platform_zeroize( buf, len ); mbedtls_free( buf ); return( MBEDTLS_ERR_PEM_PASSWORD_REQUIRED ); } @@ -403,16 +399,16 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const * The result will be ASN.1 starting with a SEQUENCE tag, with 1 to 3 * length bytes (allow 4 to be sure) in all known use cases. * - * Use that as heurisitic to try detecting password mismatchs. + * Use that as a heuristic to try to detect password mismatches. */ if( len <= 2 || buf[0] != 0x30 || buf[1] > 0x83 ) { - mbedtls_zeroize( buf, len ); + mbedtls_platform_zeroize( buf, len ); mbedtls_free( buf ); return( MBEDTLS_ERR_PEM_PASSWORD_MISMATCH ); } #else - mbedtls_zeroize( buf, len ); + mbedtls_platform_zeroize( buf, len ); mbedtls_free( buf ); return( MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE ); #endif /* MBEDTLS_MD5_C && MBEDTLS_CIPHER_MODE_CBC && @@ -427,12 +423,14 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const void mbedtls_pem_free( mbedtls_pem_context *ctx ) { - if( ctx->buf != NULL ) - mbedtls_zeroize( ctx->buf, ctx->buflen ); - mbedtls_free( ctx->buf ); + if ( ctx->buf != NULL ) + { + mbedtls_platform_zeroize( ctx->buf, ctx->buflen ); + mbedtls_free( ctx->buf ); + } mbedtls_free( ctx->info ); - mbedtls_zeroize( ctx, sizeof( mbedtls_pem_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pem_context ) ); } #endif /* MBEDTLS_PEM_PARSE_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/pk.c b/3rdparty/mbedtls/mbedtls/library/pk.c index b52c73fbc6..bac685dc19 100644 --- a/3rdparty/mbedtls/mbedtls/library/pk.c +++ b/3rdparty/mbedtls/mbedtls/library/pk.c @@ -29,6 +29,8 @@ #include "mbedtls/pk.h" #include "mbedtls/pk_internal.h" +#include "mbedtls/platform_util.h" + #if defined(MBEDTLS_RSA_C) #include "mbedtls/rsa.h" #endif @@ -42,18 +44,18 @@ #include #include -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +/* Parameter validation macros based on platform_util.h */ +#define PK_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_PK_BAD_INPUT_DATA ) +#define PK_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) /* * Initialise a mbedtls_pk_context */ void mbedtls_pk_init( mbedtls_pk_context *ctx ) { - if( ctx == NULL ) - return; + PK_VALIDATE( ctx != NULL ); ctx->pk_info = NULL; ctx->pk_ctx = NULL; @@ -64,13 +66,43 @@ void mbedtls_pk_init( mbedtls_pk_context *ctx ) */ void mbedtls_pk_free( mbedtls_pk_context *ctx ) { - if( ctx == NULL || ctx->pk_info == NULL ) + if( ctx == NULL ) + return; + + if ( ctx->pk_info != NULL ) + ctx->pk_info->ctx_free_func( ctx->pk_ctx ); + + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_pk_context ) ); +} + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +/* + * Initialize a restart context + */ +void mbedtls_pk_restart_init( mbedtls_pk_restart_ctx *ctx ) +{ + PK_VALIDATE( ctx != NULL ); + ctx->pk_info = NULL; + ctx->rs_ctx = NULL; +} + +/* + * Free the components of a restart context + */ +void mbedtls_pk_restart_free( mbedtls_pk_restart_ctx *ctx ) +{ + if( ctx == NULL || ctx->pk_info == NULL || + ctx->pk_info->rs_free_func == NULL ) + { return; + } - ctx->pk_info->ctx_free_func( ctx->pk_ctx ); + ctx->pk_info->rs_free_func( ctx->rs_ctx ); - mbedtls_zeroize( ctx, sizeof( mbedtls_pk_context ) ); + ctx->pk_info = NULL; + ctx->rs_ctx = NULL; } +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ /* * Get pk_info structure from type @@ -103,7 +135,8 @@ const mbedtls_pk_info_t * mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type ) */ int mbedtls_pk_setup( mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info ) { - if( ctx == NULL || info == NULL || ctx->pk_info != NULL ) + PK_VALIDATE_RET( ctx != NULL ); + if( info == NULL || ctx->pk_info != NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) @@ -126,7 +159,8 @@ int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, mbedtls_rsa_alt_context *rsa_alt; const mbedtls_pk_info_t *info = &mbedtls_rsa_alt_info; - if( ctx == NULL || ctx->pk_info != NULL ) + PK_VALIDATE_RET( ctx != NULL ); + if( ctx->pk_info != NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL ) @@ -150,7 +184,9 @@ int mbedtls_pk_setup_rsa_alt( mbedtls_pk_context *ctx, void * key, */ int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ) { - /* null or NONE context can't do anything */ + /* A context with null pk_info is not set up yet and can't do anything. + * For backward compatibility, also accept NULL instead of a context + * pointer. */ if( ctx == NULL || ctx->pk_info == NULL ) return( 0 ); @@ -174,17 +210,71 @@ static inline int pk_hashlen_helper( mbedtls_md_type_t md_alg, size_t *hash_len return( 0 ); } +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) /* - * Verify a signature + * Helper to set up a restart context if needed */ -int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, +static int pk_restart_setup( mbedtls_pk_restart_ctx *ctx, + const mbedtls_pk_info_t *info ) +{ + /* Don't do anything if already set up or invalid */ + if( ctx == NULL || ctx->pk_info != NULL ) + return( 0 ); + + /* Should never happen when we're called */ + if( info->rs_alloc_func == NULL || info->rs_free_func == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + if( ( ctx->rs_ctx = info->rs_alloc_func() ) == NULL ) + return( MBEDTLS_ERR_PK_ALLOC_FAILED ); + + ctx->pk_info = info; + + return( 0 ); +} +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + +/* + * Verify a signature (restartable) + */ +int mbedtls_pk_verify_restartable( mbedtls_pk_context *ctx, + mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, - const unsigned char *sig, size_t sig_len ) + const unsigned char *sig, size_t sig_len, + mbedtls_pk_restart_ctx *rs_ctx ) { - if( ctx == NULL || ctx->pk_info == NULL || + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) || + hash != NULL ); + PK_VALIDATE_RET( sig != NULL ); + + if( ctx->pk_info == NULL || pk_hashlen_helper( md_alg, &hash_len ) != 0 ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /* optimization: use non-restartable version if restart disabled */ + if( rs_ctx != NULL && + mbedtls_ecp_restart_is_enabled() && + ctx->pk_info->verify_rs_func != NULL ) + { + int ret; + + if( ( ret = pk_restart_setup( rs_ctx, ctx->pk_info ) ) != 0 ) + return( ret ); + + ret = ctx->pk_info->verify_rs_func( ctx->pk_ctx, + md_alg, hash, hash_len, sig, sig_len, rs_ctx->rs_ctx ); + + if( ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) + mbedtls_pk_restart_free( rs_ctx ); + + return( ret ); + } +#else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + (void) rs_ctx; +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + if( ctx->pk_info->verify_func == NULL ) return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); @@ -192,6 +282,17 @@ int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, sig, sig_len ) ); } +/* + * Verify a signature + */ +int mbedtls_pk_verify( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len ) +{ + return( mbedtls_pk_verify_restartable( ctx, md_alg, hash, hash_len, + sig, sig_len, NULL ) ); +} + /* * Verify a signature with options */ @@ -200,7 +301,12 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len ) { - if( ctx == NULL || ctx->pk_info == NULL ) + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) || + hash != NULL ); + PK_VALIDATE_RET( sig != NULL ); + + if( ctx->pk_info == NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); if( ! mbedtls_pk_can_do( ctx, type ) ) @@ -251,17 +357,47 @@ int mbedtls_pk_verify_ext( mbedtls_pk_type_t type, const void *options, } /* - * Make a signature + * Make a signature (restartable) */ -int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, +int mbedtls_pk_sign_restartable( mbedtls_pk_context *ctx, + mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, - int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + mbedtls_pk_restart_ctx *rs_ctx ) { - if( ctx == NULL || ctx->pk_info == NULL || + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && hash_len == 0 ) || + hash != NULL ); + PK_VALIDATE_RET( sig != NULL ); + + if( ctx->pk_info == NULL || pk_hashlen_helper( md_alg, &hash_len ) != 0 ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /* optimization: use non-restartable version if restart disabled */ + if( rs_ctx != NULL && + mbedtls_ecp_restart_is_enabled() && + ctx->pk_info->sign_rs_func != NULL ) + { + int ret; + + if( ( ret = pk_restart_setup( rs_ctx, ctx->pk_info ) ) != 0 ) + return( ret ); + + ret = ctx->pk_info->sign_rs_func( ctx->pk_ctx, md_alg, + hash, hash_len, sig, sig_len, f_rng, p_rng, rs_ctx->rs_ctx ); + + if( ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) + mbedtls_pk_restart_free( rs_ctx ); + + return( ret ); + } +#else /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + (void) rs_ctx; +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + if( ctx->pk_info->sign_func == NULL ) return( MBEDTLS_ERR_PK_TYPE_MISMATCH ); @@ -269,6 +405,18 @@ int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, sig, sig_len, f_rng, p_rng ) ); } +/* + * Make a signature + */ +int mbedtls_pk_sign( mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) +{ + return( mbedtls_pk_sign_restartable( ctx, md_alg, hash, hash_len, + sig, sig_len, f_rng, p_rng, NULL ) ); +} + /* * Decrypt message */ @@ -277,7 +425,12 @@ int mbedtls_pk_decrypt( mbedtls_pk_context *ctx, unsigned char *output, size_t *olen, size_t osize, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - if( ctx == NULL || ctx->pk_info == NULL ) + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( input != NULL || ilen == 0 ); + PK_VALIDATE_RET( output != NULL || osize == 0 ); + PK_VALIDATE_RET( olen != NULL ); + + if( ctx->pk_info == NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); if( ctx->pk_info->decrypt_func == NULL ) @@ -295,7 +448,12 @@ int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, unsigned char *output, size_t *olen, size_t osize, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) { - if( ctx == NULL || ctx->pk_info == NULL ) + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( input != NULL || ilen == 0 ); + PK_VALIDATE_RET( output != NULL || osize == 0 ); + PK_VALIDATE_RET( olen != NULL ); + + if( ctx->pk_info == NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); if( ctx->pk_info->encrypt_func == NULL ) @@ -310,8 +468,11 @@ int mbedtls_pk_encrypt( mbedtls_pk_context *ctx, */ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_context *prv ) { - if( pub == NULL || pub->pk_info == NULL || - prv == NULL || prv->pk_info == NULL || + PK_VALIDATE_RET( pub != NULL ); + PK_VALIDATE_RET( prv != NULL ); + + if( pub->pk_info == NULL || + prv->pk_info == NULL || prv->pk_info->check_pair_func == NULL ) { return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); @@ -336,6 +497,8 @@ int mbedtls_pk_check_pair( const mbedtls_pk_context *pub, const mbedtls_pk_conte */ size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ) { + /* For backward compatibility, accept NULL or a context that + * isn't set up yet, and return a fake value that should be safe. */ if( ctx == NULL || ctx->pk_info == NULL ) return( 0 ); @@ -347,7 +510,8 @@ size_t mbedtls_pk_get_bitlen( const mbedtls_pk_context *ctx ) */ int mbedtls_pk_debug( const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items ) { - if( ctx == NULL || ctx->pk_info == NULL ) + PK_VALIDATE_RET( ctx != NULL ); + if( ctx->pk_info == NULL ) return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); if( ctx->pk_info->debug_func == NULL ) diff --git a/3rdparty/mbedtls/mbedtls/library/pk_wrap.c b/3rdparty/mbedtls/mbedtls/library/pk_wrap.c index 5446e23507..87806be337 100644 --- a/3rdparty/mbedtls/mbedtls/library/pk_wrap.c +++ b/3rdparty/mbedtls/mbedtls/library/pk_wrap.c @@ -41,6 +41,10 @@ #include "mbedtls/ecdsa.h" #endif +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +#include "mbedtls/platform_util.h" +#endif + #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" #else @@ -52,13 +56,6 @@ #include #include -#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} -#endif - #if defined(MBEDTLS_RSA_C) static int rsa_can_do( mbedtls_pk_type_t type ) { @@ -193,11 +190,19 @@ const mbedtls_pk_info_t mbedtls_rsa_info = { rsa_can_do, rsa_verify_wrap, rsa_sign_wrap, +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + NULL, + NULL, +#endif rsa_decrypt_wrap, rsa_encrypt_wrap, rsa_check_pair_wrap, rsa_alloc_wrap, rsa_free_wrap, +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + NULL, + NULL, +#endif rsa_debug, }; #endif /* MBEDTLS_RSA_C */ @@ -265,6 +270,110 @@ static int eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, return( ret ); } +#if defined(MBEDTLS_ECP_RESTARTABLE) +/* Forward declarations */ +static int ecdsa_verify_rs_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len, + void *rs_ctx ); + +static int ecdsa_sign_rs_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + void *rs_ctx ); + +/* + * Restart context for ECDSA operations with ECKEY context + * + * We need to store an actual ECDSA context, as we need to pass the same to + * the underlying ecdsa function, so we can't create it on the fly every time. + */ +typedef struct +{ + mbedtls_ecdsa_restart_ctx ecdsa_rs; + mbedtls_ecdsa_context ecdsa_ctx; +} eckey_restart_ctx; + +static void *eckey_rs_alloc( void ) +{ + eckey_restart_ctx *rs_ctx; + + void *ctx = mbedtls_calloc( 1, sizeof( eckey_restart_ctx ) ); + + if( ctx != NULL ) + { + rs_ctx = ctx; + mbedtls_ecdsa_restart_init( &rs_ctx->ecdsa_rs ); + mbedtls_ecdsa_init( &rs_ctx->ecdsa_ctx ); + } + + return( ctx ); +} + +static void eckey_rs_free( void *ctx ) +{ + eckey_restart_ctx *rs_ctx; + + if( ctx == NULL) + return; + + rs_ctx = ctx; + mbedtls_ecdsa_restart_free( &rs_ctx->ecdsa_rs ); + mbedtls_ecdsa_free( &rs_ctx->ecdsa_ctx ); + + mbedtls_free( ctx ); +} + +static int eckey_verify_rs_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len, + void *rs_ctx ) +{ + int ret; + eckey_restart_ctx *rs = rs_ctx; + + /* Should never happen */ + if( rs == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + /* set up our own sub-context if needed (that is, on first run) */ + if( rs->ecdsa_ctx.grp.pbits == 0 ) + MBEDTLS_MPI_CHK( mbedtls_ecdsa_from_keypair( &rs->ecdsa_ctx, ctx ) ); + + MBEDTLS_MPI_CHK( ecdsa_verify_rs_wrap( &rs->ecdsa_ctx, + md_alg, hash, hash_len, + sig, sig_len, &rs->ecdsa_rs ) ); + +cleanup: + return( ret ); +} + +static int eckey_sign_rs_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + void *rs_ctx ) +{ + int ret; + eckey_restart_ctx *rs = rs_ctx; + + /* Should never happen */ + if( rs == NULL ) + return( MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + /* set up our own sub-context if needed (that is, on first run) */ + if( rs->ecdsa_ctx.grp.pbits == 0 ) + MBEDTLS_MPI_CHK( mbedtls_ecdsa_from_keypair( &rs->ecdsa_ctx, ctx ) ); + + MBEDTLS_MPI_CHK( ecdsa_sign_rs_wrap( &rs->ecdsa_ctx, md_alg, + hash, hash_len, sig, sig_len, + f_rng, p_rng, &rs->ecdsa_rs ) ); + +cleanup: + return( ret ); +} +#endif /* MBEDTLS_ECP_RESTARTABLE */ #endif /* MBEDTLS_ECDSA_C */ static int eckey_check_pair( const void *pub, const void *prv ) @@ -304,15 +413,23 @@ const mbedtls_pk_info_t mbedtls_eckey_info = { #if defined(MBEDTLS_ECDSA_C) eckey_verify_wrap, eckey_sign_wrap, -#else +#if defined(MBEDTLS_ECP_RESTARTABLE) + eckey_verify_rs_wrap, + eckey_sign_rs_wrap, +#endif +#else /* MBEDTLS_ECDSA_C */ NULL, NULL, -#endif +#endif /* MBEDTLS_ECDSA_C */ NULL, NULL, eckey_check_pair, eckey_alloc_wrap, eckey_free_wrap, +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + eckey_rs_alloc, + eckey_rs_free, +#endif eckey_debug, }; @@ -332,11 +449,19 @@ const mbedtls_pk_info_t mbedtls_eckeydh_info = { eckeydh_can_do, NULL, NULL, +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + NULL, + NULL, +#endif NULL, NULL, eckey_check_pair, eckey_alloc_wrap, /* Same underlying key structure */ eckey_free_wrap, /* Same underlying key structure */ +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + NULL, + NULL, +#endif eckey_debug, /* Same underlying key structure */ }; #endif /* MBEDTLS_ECP_C */ @@ -372,6 +497,40 @@ static int ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng ) ); } +#if defined(MBEDTLS_ECP_RESTARTABLE) +static int ecdsa_verify_rs_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + const unsigned char *sig, size_t sig_len, + void *rs_ctx ) +{ + int ret; + ((void) md_alg); + + ret = mbedtls_ecdsa_read_signature_restartable( + (mbedtls_ecdsa_context *) ctx, + hash, hash_len, sig, sig_len, + (mbedtls_ecdsa_restart_ctx *) rs_ctx ); + + if( ret == MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH ) + return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH ); + + return( ret ); +} + +static int ecdsa_sign_rs_wrap( void *ctx, mbedtls_md_type_t md_alg, + const unsigned char *hash, size_t hash_len, + unsigned char *sig, size_t *sig_len, + int (*f_rng)(void *, unsigned char *, size_t), void *p_rng, + void *rs_ctx ) +{ + return( mbedtls_ecdsa_write_signature_restartable( + (mbedtls_ecdsa_context *) ctx, + md_alg, hash, hash_len, sig, sig_len, f_rng, p_rng, + (mbedtls_ecdsa_restart_ctx *) rs_ctx ) ); + +} +#endif /* MBEDTLS_ECP_RESTARTABLE */ + static void *ecdsa_alloc_wrap( void ) { void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) ); @@ -388,6 +547,24 @@ static void ecdsa_free_wrap( void *ctx ) mbedtls_free( ctx ); } +#if defined(MBEDTLS_ECP_RESTARTABLE) +static void *ecdsa_rs_alloc( void ) +{ + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_restart_ctx ) ); + + if( ctx != NULL ) + mbedtls_ecdsa_restart_init( ctx ); + + return( ctx ); +} + +static void ecdsa_rs_free( void *ctx ) +{ + mbedtls_ecdsa_restart_free( ctx ); + mbedtls_free( ctx ); +} +#endif /* MBEDTLS_ECP_RESTARTABLE */ + const mbedtls_pk_info_t mbedtls_ecdsa_info = { MBEDTLS_PK_ECDSA, "ECDSA", @@ -395,11 +572,19 @@ const mbedtls_pk_info_t mbedtls_ecdsa_info = { ecdsa_can_do, ecdsa_verify_wrap, ecdsa_sign_wrap, +#if defined(MBEDTLS_ECP_RESTARTABLE) + ecdsa_verify_rs_wrap, + ecdsa_sign_rs_wrap, +#endif NULL, NULL, eckey_check_pair, /* Compatible key structures */ ecdsa_alloc_wrap, ecdsa_free_wrap, +#if defined(MBEDTLS_ECP_RESTARTABLE) + ecdsa_rs_alloc, + ecdsa_rs_free, +#endif eckey_debug, /* Compatible key structures */ }; #endif /* MBEDTLS_ECDSA_C */ @@ -498,7 +683,7 @@ static void *rsa_alt_alloc_wrap( void ) static void rsa_alt_free_wrap( void *ctx ) { - mbedtls_zeroize( ctx, sizeof( mbedtls_rsa_alt_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_rsa_alt_context ) ); mbedtls_free( ctx ); } @@ -509,6 +694,10 @@ const mbedtls_pk_info_t mbedtls_rsa_alt_info = { rsa_alt_can_do, NULL, rsa_alt_sign_wrap, +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + NULL, + NULL, +#endif rsa_alt_decrypt_wrap, NULL, #if defined(MBEDTLS_RSA_C) @@ -518,6 +707,10 @@ const mbedtls_pk_info_t mbedtls_rsa_alt_info = { #endif rsa_alt_alloc_wrap, rsa_alt_free_wrap, +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + NULL, + NULL, +#endif NULL, }; diff --git a/3rdparty/mbedtls/mbedtls/library/pkcs12.c b/3rdparty/mbedtls/mbedtls/library/pkcs12.c index 5e8b2879a0..7edf064c13 100644 --- a/3rdparty/mbedtls/mbedtls/library/pkcs12.c +++ b/3rdparty/mbedtls/mbedtls/library/pkcs12.c @@ -36,6 +36,7 @@ #include "mbedtls/pkcs12.h" #include "mbedtls/asn1.h" #include "mbedtls/cipher.h" +#include "mbedtls/platform_util.h" #include @@ -47,11 +48,6 @@ #include "mbedtls/des.h" #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - #if defined(MBEDTLS_ASN1_PARSE_C) static int pkcs12_parse_pbe_params( mbedtls_asn1_buf *params, @@ -168,7 +164,7 @@ int mbedtls_pkcs12_pbe_sha1_rc4_128( mbedtls_asn1_buf *pbe_params, int mode, goto exit; exit: - mbedtls_zeroize( key, sizeof( key ) ); + mbedtls_platform_zeroize( key, sizeof( key ) ); mbedtls_arc4_free( &ctx ); return( ret ); @@ -225,8 +221,8 @@ int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode, ret = MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH; exit: - mbedtls_zeroize( key, sizeof( key ) ); - mbedtls_zeroize( iv, sizeof( iv ) ); + mbedtls_platform_zeroize( key, sizeof( key ) ); + mbedtls_platform_zeroize( iv, sizeof( iv ) ); mbedtls_cipher_free( &cipher_ctx ); return( ret ); @@ -356,10 +352,10 @@ int mbedtls_pkcs12_derivation( unsigned char *data, size_t datalen, ret = 0; exit: - mbedtls_zeroize( salt_block, sizeof( salt_block ) ); - mbedtls_zeroize( pwd_block, sizeof( pwd_block ) ); - mbedtls_zeroize( hash_block, sizeof( hash_block ) ); - mbedtls_zeroize( hash_output, sizeof( hash_output ) ); + mbedtls_platform_zeroize( salt_block, sizeof( salt_block ) ); + mbedtls_platform_zeroize( pwd_block, sizeof( pwd_block ) ); + mbedtls_platform_zeroize( hash_block, sizeof( hash_block ) ); + mbedtls_platform_zeroize( hash_output, sizeof( hash_output ) ); mbedtls_md_free( &md_ctx ); diff --git a/3rdparty/mbedtls/mbedtls/library/pkparse.c b/3rdparty/mbedtls/mbedtls/library/pkparse.c index ec9b55f8c5..ae210bca6a 100644 --- a/3rdparty/mbedtls/mbedtls/library/pkparse.c +++ b/3rdparty/mbedtls/mbedtls/library/pkparse.c @@ -30,6 +30,7 @@ #include "mbedtls/pk.h" #include "mbedtls/asn1.h" #include "mbedtls/oid.h" +#include "mbedtls/platform_util.h" #include @@ -60,13 +61,11 @@ #define mbedtls_free free #endif -#if defined(MBEDTLS_FS_IO) || \ - defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} -#endif +/* Parameter validation macros based on platform_util.h */ +#define PK_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_PK_BAD_INPUT_DATA ) +#define PK_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) #if defined(MBEDTLS_FS_IO) /* @@ -81,6 +80,10 @@ int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n ) FILE *f; long size; + PK_VALIDATE_RET( path != NULL ); + PK_VALIDATE_RET( buf != NULL ); + PK_VALIDATE_RET( n != NULL ); + if( ( f = fopen( path, "rb" ) ) == NULL ) return( MBEDTLS_ERR_PK_FILE_IO_ERROR ); @@ -105,7 +108,7 @@ int mbedtls_pk_load_file( const char *path, unsigned char **buf, size_t *n ) { fclose( f ); - mbedtls_zeroize( *buf, *n ); + mbedtls_platform_zeroize( *buf, *n ); mbedtls_free( *buf ); return( MBEDTLS_ERR_PK_FILE_IO_ERROR ); @@ -131,6 +134,9 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, size_t n; unsigned char *buf; + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( path != NULL ); + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) return( ret ); @@ -140,7 +146,7 @@ int mbedtls_pk_parse_keyfile( mbedtls_pk_context *ctx, ret = mbedtls_pk_parse_key( ctx, buf, n, (const unsigned char *) pwd, strlen( pwd ) ); - mbedtls_zeroize( buf, n ); + mbedtls_platform_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); @@ -155,12 +161,15 @@ int mbedtls_pk_parse_public_keyfile( mbedtls_pk_context *ctx, const char *path ) size_t n; unsigned char *buf; + PK_VALIDATE_RET( ctx != NULL ); + PK_VALIDATE_RET( path != NULL ); + if( ( ret = mbedtls_pk_load_file( path, &buf, &n ) ) != 0 ) return( ret ); ret = mbedtls_pk_parse_public_key( ctx, buf, n ); - mbedtls_zeroize( buf, n ); + mbedtls_platform_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); @@ -612,6 +621,11 @@ int mbedtls_pk_parse_subpubkey( unsigned char **p, const unsigned char *end, mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE; const mbedtls_pk_info_t *pk_info; + PK_VALIDATE_RET( p != NULL ); + PK_VALIDATE_RET( *p != NULL ); + PK_VALIDATE_RET( end != NULL ); + PK_VALIDATE_RET( pk != NULL ); + if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) { @@ -1152,16 +1166,22 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, { int ret; const mbedtls_pk_info_t *pk_info; - #if defined(MBEDTLS_PEM_PARSE_C) size_t len; mbedtls_pem_context pem; +#endif - mbedtls_pem_init( &pem ); + PK_VALIDATE_RET( pk != NULL ); + if( keylen == 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + PK_VALIDATE_RET( key != NULL ); + +#if defined(MBEDTLS_PEM_PARSE_C) + mbedtls_pem_init( &pem ); #if defined(MBEDTLS_RSA_C) /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ - if( keylen == 0 || key[keylen - 1] != '\0' ) + if( key[keylen - 1] != '\0' ) ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; else ret = mbedtls_pem_read_buffer( &pem, @@ -1192,7 +1212,7 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, #if defined(MBEDTLS_ECP_C) /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ - if( keylen == 0 || key[keylen - 1] != '\0' ) + if( key[keylen - 1] != '\0' ) ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; else ret = mbedtls_pem_read_buffer( &pem, @@ -1222,7 +1242,7 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, #endif /* MBEDTLS_ECP_C */ /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ - if( keylen == 0 || key[keylen - 1] != '\0' ) + if( key[keylen - 1] != '\0' ) ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; else ret = mbedtls_pem_read_buffer( &pem, @@ -1245,7 +1265,7 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, #if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ - if( keylen == 0 || key[keylen - 1] != '\0' ) + if( key[keylen - 1] != '\0' ) ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; else ret = mbedtls_pem_read_buffer( &pem, @@ -1283,9 +1303,6 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, { unsigned char *key_copy; - if( keylen == 0 ) - return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); - if( ( key_copy = mbedtls_calloc( 1, keylen ) ) == NULL ) return( MBEDTLS_ERR_PK_ALLOC_FAILED ); @@ -1294,7 +1311,7 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, ret = pk_parse_key_pkcs8_encrypted_der( pk, key_copy, keylen, pwd, pwdlen ); - mbedtls_zeroize( key_copy, keylen ); + mbedtls_platform_zeroize( key_copy, keylen ); mbedtls_free( key_copy ); } @@ -1361,14 +1378,55 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx, { int ret; unsigned char *p; +#if defined(MBEDTLS_RSA_C) + const mbedtls_pk_info_t *pk_info; +#endif #if defined(MBEDTLS_PEM_PARSE_C) size_t len; mbedtls_pem_context pem; +#endif + + PK_VALIDATE_RET( ctx != NULL ); + if( keylen == 0 ) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + PK_VALIDATE_RET( key != NULL || keylen == 0 ); +#if defined(MBEDTLS_PEM_PARSE_C) mbedtls_pem_init( &pem ); +#if defined(MBEDTLS_RSA_C) + /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ + if( key[keylen - 1] != '\0' ) + ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; + else + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN RSA PUBLIC KEY-----", + "-----END RSA PUBLIC KEY-----", + key, NULL, 0, &len ); + + if( ret == 0 ) + { + p = pem.buf; + if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 ) + return( ret ); + + if ( ( ret = pk_get_rsapubkey( &p, p + pem.buflen, mbedtls_pk_rsa( *ctx ) ) ) != 0 ) + mbedtls_pk_free( ctx ); + + mbedtls_pem_free( &pem ); + return( ret ); + } + else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + { + mbedtls_pem_free( &pem ); + return( ret ); + } +#endif /* MBEDTLS_RSA_C */ /* Avoid calling mbedtls_pem_read_buffer() on non-null-terminated string */ - if( keylen == 0 || key[keylen - 1] != '\0' ) + if( key[keylen - 1] != '\0' ) ret = MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT; else ret = mbedtls_pem_read_buffer( &pem, @@ -1381,23 +1439,43 @@ int mbedtls_pk_parse_public_key( mbedtls_pk_context *ctx, /* * Was PEM encoded */ - key = pem.buf; - keylen = pem.buflen; + p = pem.buf; + + ret = mbedtls_pk_parse_subpubkey( &p, p + pem.buflen, ctx ); + mbedtls_pem_free( &pem ); + return( ret ); } else if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) { mbedtls_pem_free( &pem ); return( ret ); } + mbedtls_pem_free( &pem ); #endif /* MBEDTLS_PEM_PARSE_C */ + +#if defined(MBEDTLS_RSA_C) + if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL ) + return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); + + if( ( ret = mbedtls_pk_setup( ctx, pk_info ) ) != 0 ) + return( ret ); + + p = (unsigned char *)key; + ret = pk_get_rsapubkey( &p, p + keylen, mbedtls_pk_rsa( *ctx ) ); + if( ret == 0 ) + { + return( ret ); + } + mbedtls_pk_free( ctx ); + if( ret != ( MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) ) + { + return( ret ); + } +#endif /* MBEDTLS_RSA_C */ p = (unsigned char *) key; ret = mbedtls_pk_parse_subpubkey( &p, p + keylen, ctx ); -#if defined(MBEDTLS_PEM_PARSE_C) - mbedtls_pem_free( &pem ); -#endif - return( ret ); } diff --git a/3rdparty/mbedtls/mbedtls/library/pkwrite.c b/3rdparty/mbedtls/mbedtls/library/pkwrite.c index 8eabd889b5..8d1da2f757 100644 --- a/3rdparty/mbedtls/mbedtls/library/pkwrite.c +++ b/3rdparty/mbedtls/mbedtls/library/pkwrite.c @@ -30,6 +30,7 @@ #include "mbedtls/pk.h" #include "mbedtls/asn1write.h" #include "mbedtls/oid.h" +#include "mbedtls/platform_util.h" #include @@ -54,6 +55,12 @@ #define mbedtls_free free #endif +/* Parameter validation macros based on platform_util.h */ +#define PK_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_PK_BAD_INPUT_DATA ) +#define PK_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + #if defined(MBEDTLS_RSA_C) /* * RSAPublicKey ::= SEQUENCE { @@ -151,6 +158,11 @@ int mbedtls_pk_write_pubkey( unsigned char **p, unsigned char *start, int ret; size_t len = 0; + PK_VALIDATE_RET( p != NULL ); + PK_VALIDATE_RET( *p != NULL ); + PK_VALIDATE_RET( start != NULL ); + PK_VALIDATE_RET( key != NULL ); + #if defined(MBEDTLS_RSA_C) if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA ) MBEDTLS_ASN1_CHK_ADD( len, pk_write_rsa_pubkey( p, start, mbedtls_pk_rsa( *key ) ) ); @@ -173,6 +185,11 @@ int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *key, unsigned char *buf, si size_t len = 0, par_len = 0, oid_len; const char *oid; + PK_VALIDATE_RET( key != NULL ); + if( size == 0 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + PK_VALIDATE_RET( buf != NULL ); + c = buf + size; MBEDTLS_ASN1_CHK_ADD( len, mbedtls_pk_write_pubkey( &c, buf, key ) ); @@ -217,9 +234,16 @@ int mbedtls_pk_write_pubkey_der( mbedtls_pk_context *key, unsigned char *buf, si int mbedtls_pk_write_key_der( mbedtls_pk_context *key, unsigned char *buf, size_t size ) { int ret; - unsigned char *c = buf + size; + unsigned char *c; size_t len = 0; + PK_VALIDATE_RET( key != NULL ); + if( size == 0 ) + return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + PK_VALIDATE_RET( buf != NULL ); + + c = buf + size; + #if defined(MBEDTLS_RSA_C) if( mbedtls_pk_get_type( key ) == MBEDTLS_PK_RSA ) { @@ -457,6 +481,9 @@ int mbedtls_pk_write_pubkey_pem( mbedtls_pk_context *key, unsigned char *buf, si unsigned char output_buf[PUB_DER_MAX_BYTES]; size_t olen = 0; + PK_VALIDATE_RET( key != NULL ); + PK_VALIDATE_RET( buf != NULL || size == 0 ); + if( ( ret = mbedtls_pk_write_pubkey_der( key, output_buf, sizeof(output_buf) ) ) < 0 ) { @@ -480,6 +507,9 @@ int mbedtls_pk_write_key_pem( mbedtls_pk_context *key, unsigned char *buf, size_ const char *begin, *end; size_t olen = 0; + PK_VALIDATE_RET( key != NULL ); + PK_VALIDATE_RET( buf != NULL || size == 0 ); + if( ( ret = mbedtls_pk_write_key_der( key, output_buf, sizeof(output_buf) ) ) < 0 ) return( ret ); diff --git a/3rdparty/mbedtls/mbedtls/library/platform.c b/3rdparty/mbedtls/mbedtls/library/platform.c index aa88fc1a66..73a6db9ebe 100644 --- a/3rdparty/mbedtls/mbedtls/library/platform.c +++ b/3rdparty/mbedtls/mbedtls/library/platform.c @@ -28,14 +28,7 @@ #if defined(MBEDTLS_PLATFORM_C) #include "mbedtls/platform.h" - -#if defined(MBEDTLS_ENTROPY_NV_SEED) && \ - !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} -#endif +#include "mbedtls/platform_util.h" /* The compile time configuration of memory allocation via the macros * MBEDTLS_PLATFORM_{FREE/CALLOC}_MACRO takes precedence over the runtime @@ -65,14 +58,24 @@ static void platform_free_uninit( void *ptr ) #define MBEDTLS_PLATFORM_STD_FREE platform_free_uninit #endif /* !MBEDTLS_PLATFORM_STD_FREE */ -void * (*mbedtls_calloc)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC; -void (*mbedtls_free)( void * ) = MBEDTLS_PLATFORM_STD_FREE; +static void * (*mbedtls_calloc_func)( size_t, size_t ) = MBEDTLS_PLATFORM_STD_CALLOC; +static void (*mbedtls_free_func)( void * ) = MBEDTLS_PLATFORM_STD_FREE; + +void * mbedtls_calloc( size_t nmemb, size_t size ) +{ + return (*mbedtls_calloc_func)( nmemb, size ); +} + +void mbedtls_free( void * ptr ) +{ + (*mbedtls_free_func)( ptr ); +} int mbedtls_platform_set_calloc_free( void * (*calloc_func)( size_t, size_t ), void (*free_func)( void * ) ) { - mbedtls_calloc = calloc_func; - mbedtls_free = free_func; + mbedtls_calloc_func = calloc_func; + mbedtls_free_func = free_func; return( 0 ); } #endif /* MBEDTLS_PLATFORM_MEMORY && @@ -250,7 +253,7 @@ int mbedtls_platform_std_nv_seed_read( unsigned char *buf, size_t buf_len ) if( ( n = fread( buf, 1, buf_len, file ) ) != buf_len ) { fclose( file ); - mbedtls_zeroize( buf, buf_len ); + mbedtls_platform_zeroize( buf, buf_len ); return( -1 ); } diff --git a/3rdparty/mbedtls/mbedtls/library/platform_util.c b/3rdparty/mbedtls/mbedtls/library/platform_util.c new file mode 100644 index 0000000000..756e22679a --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/platform_util.c @@ -0,0 +1,136 @@ +/* + * Common and shared functions used by multiple modules in the Mbed TLS + * library. + * + * Copyright (C) 2018, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +/* + * Ensure gmtime_r is available even with -std=c99; must be defined before + * config.h, which pulls in glibc's features.h. Harmless on other platforms. + */ +#if !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 200112L +#endif + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "mbedtls/platform_util.h" +#include "mbedtls/platform.h" +#include "mbedtls/threading.h" + +#include +#include + +#if !defined(MBEDTLS_PLATFORM_ZEROIZE_ALT) +/* + * This implementation should never be optimized out by the compiler + * + * This implementation for mbedtls_platform_zeroize() was inspired from Colin + * Percival's blog article at: + * + * http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html + * + * It uses a volatile function pointer to the standard memset(). Because the + * pointer is volatile the compiler expects it to change at + * any time and will not optimize out the call that could potentially perform + * other operations on the input buffer instead of just setting it to 0. + * Nevertheless, as pointed out by davidtgoldblatt on Hacker News + * (refer to http://www.daemonology.net/blog/2014-09-05-erratum.html for + * details), optimizations of the following form are still possible: + * + * if( memset_func != memset ) + * memset_func( buf, 0, len ); + * + * Note that it is extremely difficult to guarantee that + * mbedtls_platform_zeroize() will not be optimized out by aggressive compilers + * in a portable way. For this reason, Mbed TLS also provides the configuration + * option MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure + * mbedtls_platform_zeroize() to use a suitable implementation for their + * platform and needs. + */ +static void * (* const volatile memset_func)( void *, int, size_t ) = memset; + +void mbedtls_platform_zeroize( void *buf, size_t len ) +{ + memset_func( buf, 0, len ); +} +#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */ + +#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) +#include +#if !defined(_WIN32) && (defined(unix) || \ + defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ + defined(__MACH__))) +#include +#endif /* !_WIN32 && (unix || __unix || __unix__ || + * (__APPLE__ && __MACH__)) */ + +#if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ + ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ + _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) +/* + * This is a convenience shorthand macro to avoid checking the long + * preprocessor conditions above. Ideally, we could expose this macro in + * platform_util.h and simply use it in platform_util.c, threading.c and + * threading.h. However, this macro is not part of the Mbed TLS public API, so + * we keep it private by only defining it in this file + */ +#if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) +#define PLATFORM_UTIL_USE_GMTIME +#endif /* ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) */ + +#endif /* !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ + ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ + _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) */ + +struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt, + struct tm *tm_buf ) +{ +#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) + return( ( gmtime_s( tm_buf, tt ) == 0 ) ? tm_buf : NULL ); +#elif !defined(PLATFORM_UTIL_USE_GMTIME) + return( gmtime_r( tt, tm_buf ) ); +#else + struct tm *lt; + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_lock( &mbedtls_threading_gmtime_mutex ) != 0 ) + return( NULL ); +#endif /* MBEDTLS_THREADING_C */ + + lt = gmtime( tt ); + + if( lt != NULL ) + { + memcpy( tm_buf, lt, sizeof( struct tm ) ); + } + +#if defined(MBEDTLS_THREADING_C) + if( mbedtls_mutex_unlock( &mbedtls_threading_gmtime_mutex ) != 0 ) + return( NULL ); +#endif /* MBEDTLS_THREADING_C */ + + return( ( lt == NULL ) ? NULL : tm_buf ); +#endif /* _WIN32 && !EFIX64 && !EFI32 */ +} +#endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */ diff --git a/3rdparty/mbedtls/mbedtls/library/poly1305.c b/3rdparty/mbedtls/mbedtls/library/poly1305.c new file mode 100644 index 0000000000..2b56c5f7ef --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/library/poly1305.c @@ -0,0 +1,559 @@ +/** + * \file poly1305.c + * + * \brief Poly1305 authentication algorithm. + * + * Copyright (C) 2006-2016, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_POLY1305_C) + +#include "mbedtls/poly1305.h" +#include "mbedtls/platform_util.h" + +#include + +#if defined(MBEDTLS_SELF_TEST) +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ +#endif /* MBEDTLS_SELF_TEST */ + +#if !defined(MBEDTLS_POLY1305_ALT) + +#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ + !defined(inline) && !defined(__cplusplus) +#define inline __inline +#endif + +/* Parameter validation macros */ +#define POLY1305_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA ) +#define POLY1305_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) + +#define POLY1305_BLOCK_SIZE_BYTES ( 16U ) + +#define BYTES_TO_U32_LE( data, offset ) \ + ( (uint32_t) (data)[offset] \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 ) \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 ) \ + | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 ) \ + ) + +/* + * Our implementation is tuned for 32-bit platforms with a 64-bit multiplier. + * However we provided an alternative for platforms without such a multiplier. + */ +#if defined(MBEDTLS_NO_64BIT_MULTIPLICATION) +static uint64_t mul64( uint32_t a, uint32_t b ) +{ + /* a = al + 2**16 ah, b = bl + 2**16 bh */ + const uint16_t al = (uint16_t) a; + const uint16_t bl = (uint16_t) b; + const uint16_t ah = a >> 16; + const uint16_t bh = b >> 16; + + /* ab = al*bl + 2**16 (ah*bl + bl*bh) + 2**32 ah*bh */ + const uint32_t lo = (uint32_t) al * bl; + const uint64_t me = (uint64_t)( (uint32_t) ah * bl ) + (uint32_t) al * bh; + const uint32_t hi = (uint32_t) ah * bh; + + return( lo + ( me << 16 ) + ( (uint64_t) hi << 32 ) ); +} +#else +static inline uint64_t mul64( uint32_t a, uint32_t b ) +{ + return( (uint64_t) a * b ); +} +#endif + + +/** + * \brief Process blocks with Poly1305. + * + * \param ctx The Poly1305 context. + * \param nblocks Number of blocks to process. Note that this + * function only processes full blocks. + * \param input Buffer containing the input block(s). + * \param needs_padding Set to 0 if the padding bit has already been + * applied to the input data before calling this + * function. Otherwise, set this parameter to 1. + */ +static void poly1305_process( mbedtls_poly1305_context *ctx, + size_t nblocks, + const unsigned char *input, + uint32_t needs_padding ) +{ + uint64_t d0, d1, d2, d3; + uint32_t acc0, acc1, acc2, acc3, acc4; + uint32_t r0, r1, r2, r3; + uint32_t rs1, rs2, rs3; + size_t offset = 0U; + size_t i; + + r0 = ctx->r[0]; + r1 = ctx->r[1]; + r2 = ctx->r[2]; + r3 = ctx->r[3]; + + rs1 = r1 + ( r1 >> 2U ); + rs2 = r2 + ( r2 >> 2U ); + rs3 = r3 + ( r3 >> 2U ); + + acc0 = ctx->acc[0]; + acc1 = ctx->acc[1]; + acc2 = ctx->acc[2]; + acc3 = ctx->acc[3]; + acc4 = ctx->acc[4]; + + /* Process full blocks */ + for( i = 0U; i < nblocks; i++ ) + { + /* The input block is treated as a 128-bit little-endian integer */ + d0 = BYTES_TO_U32_LE( input, offset + 0 ); + d1 = BYTES_TO_U32_LE( input, offset + 4 ); + d2 = BYTES_TO_U32_LE( input, offset + 8 ); + d3 = BYTES_TO_U32_LE( input, offset + 12 ); + + /* Compute: acc += (padded) block as a 130-bit integer */ + d0 += (uint64_t) acc0; + d1 += (uint64_t) acc1 + ( d0 >> 32U ); + d2 += (uint64_t) acc2 + ( d1 >> 32U ); + d3 += (uint64_t) acc3 + ( d2 >> 32U ); + acc0 = (uint32_t) d0; + acc1 = (uint32_t) d1; + acc2 = (uint32_t) d2; + acc3 = (uint32_t) d3; + acc4 += (uint32_t) ( d3 >> 32U ) + needs_padding; + + /* Compute: acc *= r */ + d0 = mul64( acc0, r0 ) + + mul64( acc1, rs3 ) + + mul64( acc2, rs2 ) + + mul64( acc3, rs1 ); + d1 = mul64( acc0, r1 ) + + mul64( acc1, r0 ) + + mul64( acc2, rs3 ) + + mul64( acc3, rs2 ) + + mul64( acc4, rs1 ); + d2 = mul64( acc0, r2 ) + + mul64( acc1, r1 ) + + mul64( acc2, r0 ) + + mul64( acc3, rs3 ) + + mul64( acc4, rs2 ); + d3 = mul64( acc0, r3 ) + + mul64( acc1, r2 ) + + mul64( acc2, r1 ) + + mul64( acc3, r0 ) + + mul64( acc4, rs3 ); + acc4 *= r0; + + /* Compute: acc %= (2^130 - 5) (partial remainder) */ + d1 += ( d0 >> 32 ); + d2 += ( d1 >> 32 ); + d3 += ( d2 >> 32 ); + acc0 = (uint32_t) d0; + acc1 = (uint32_t) d1; + acc2 = (uint32_t) d2; + acc3 = (uint32_t) d3; + acc4 = (uint32_t) ( d3 >> 32 ) + acc4; + + d0 = (uint64_t) acc0 + ( acc4 >> 2 ) + ( acc4 & 0xFFFFFFFCU ); + acc4 &= 3U; + acc0 = (uint32_t) d0; + d0 = (uint64_t) acc1 + ( d0 >> 32U ); + acc1 = (uint32_t) d0; + d0 = (uint64_t) acc2 + ( d0 >> 32U ); + acc2 = (uint32_t) d0; + d0 = (uint64_t) acc3 + ( d0 >> 32U ); + acc3 = (uint32_t) d0; + d0 = (uint64_t) acc4 + ( d0 >> 32U ); + acc4 = (uint32_t) d0; + + offset += POLY1305_BLOCK_SIZE_BYTES; + } + + ctx->acc[0] = acc0; + ctx->acc[1] = acc1; + ctx->acc[2] = acc2; + ctx->acc[3] = acc3; + ctx->acc[4] = acc4; +} + +/** + * \brief Compute the Poly1305 MAC + * + * \param ctx The Poly1305 context. + * \param mac The buffer to where the MAC is written. Must be + * big enough to contain the 16-byte MAC. + */ +static void poly1305_compute_mac( const mbedtls_poly1305_context *ctx, + unsigned char mac[16] ) +{ + uint64_t d; + uint32_t g0, g1, g2, g3, g4; + uint32_t acc0, acc1, acc2, acc3, acc4; + uint32_t mask; + uint32_t mask_inv; + + acc0 = ctx->acc[0]; + acc1 = ctx->acc[1]; + acc2 = ctx->acc[2]; + acc3 = ctx->acc[3]; + acc4 = ctx->acc[4]; + + /* Before adding 's' we ensure that the accumulator is mod 2^130 - 5. + * We do this by calculating acc - (2^130 - 5), then checking if + * the 131st bit is set. If it is, then reduce: acc -= (2^130 - 5) + */ + + /* Calculate acc + -(2^130 - 5) */ + d = ( (uint64_t) acc0 + 5U ); + g0 = (uint32_t) d; + d = ( (uint64_t) acc1 + ( d >> 32 ) ); + g1 = (uint32_t) d; + d = ( (uint64_t) acc2 + ( d >> 32 ) ); + g2 = (uint32_t) d; + d = ( (uint64_t) acc3 + ( d >> 32 ) ); + g3 = (uint32_t) d; + g4 = acc4 + (uint32_t) ( d >> 32U ); + + /* mask == 0xFFFFFFFF if 131st bit is set, otherwise mask == 0 */ + mask = (uint32_t) 0U - ( g4 >> 2U ); + mask_inv = ~mask; + + /* If 131st bit is set then acc=g, otherwise, acc is unmodified */ + acc0 = ( acc0 & mask_inv ) | ( g0 & mask ); + acc1 = ( acc1 & mask_inv ) | ( g1 & mask ); + acc2 = ( acc2 & mask_inv ) | ( g2 & mask ); + acc3 = ( acc3 & mask_inv ) | ( g3 & mask ); + + /* Add 's' */ + d = (uint64_t) acc0 + ctx->s[0]; + acc0 = (uint32_t) d; + d = (uint64_t) acc1 + ctx->s[1] + ( d >> 32U ); + acc1 = (uint32_t) d; + d = (uint64_t) acc2 + ctx->s[2] + ( d >> 32U ); + acc2 = (uint32_t) d; + acc3 += ctx->s[3] + (uint32_t) ( d >> 32U ); + + /* Compute MAC (128 least significant bits of the accumulator) */ + mac[ 0] = (unsigned char)( acc0 ); + mac[ 1] = (unsigned char)( acc0 >> 8 ); + mac[ 2] = (unsigned char)( acc0 >> 16 ); + mac[ 3] = (unsigned char)( acc0 >> 24 ); + mac[ 4] = (unsigned char)( acc1 ); + mac[ 5] = (unsigned char)( acc1 >> 8 ); + mac[ 6] = (unsigned char)( acc1 >> 16 ); + mac[ 7] = (unsigned char)( acc1 >> 24 ); + mac[ 8] = (unsigned char)( acc2 ); + mac[ 9] = (unsigned char)( acc2 >> 8 ); + mac[10] = (unsigned char)( acc2 >> 16 ); + mac[11] = (unsigned char)( acc2 >> 24 ); + mac[12] = (unsigned char)( acc3 ); + mac[13] = (unsigned char)( acc3 >> 8 ); + mac[14] = (unsigned char)( acc3 >> 16 ); + mac[15] = (unsigned char)( acc3 >> 24 ); +} + +void mbedtls_poly1305_init( mbedtls_poly1305_context *ctx ) +{ + POLY1305_VALIDATE( ctx != NULL ); + + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_poly1305_context ) ); +} + +void mbedtls_poly1305_free( mbedtls_poly1305_context *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_poly1305_context ) ); +} + +int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx, + const unsigned char key[32] ) +{ + POLY1305_VALIDATE_RET( ctx != NULL ); + POLY1305_VALIDATE_RET( key != NULL ); + + /* r &= 0x0ffffffc0ffffffc0ffffffc0fffffff */ + ctx->r[0] = BYTES_TO_U32_LE( key, 0 ) & 0x0FFFFFFFU; + ctx->r[1] = BYTES_TO_U32_LE( key, 4 ) & 0x0FFFFFFCU; + ctx->r[2] = BYTES_TO_U32_LE( key, 8 ) & 0x0FFFFFFCU; + ctx->r[3] = BYTES_TO_U32_LE( key, 12 ) & 0x0FFFFFFCU; + + ctx->s[0] = BYTES_TO_U32_LE( key, 16 ); + ctx->s[1] = BYTES_TO_U32_LE( key, 20 ); + ctx->s[2] = BYTES_TO_U32_LE( key, 24 ); + ctx->s[3] = BYTES_TO_U32_LE( key, 28 ); + + /* Initial accumulator state */ + ctx->acc[0] = 0U; + ctx->acc[1] = 0U; + ctx->acc[2] = 0U; + ctx->acc[3] = 0U; + ctx->acc[4] = 0U; + + /* Queue initially empty */ + mbedtls_platform_zeroize( ctx->queue, sizeof( ctx->queue ) ); + ctx->queue_len = 0U; + + return( 0 ); +} + +int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx, + const unsigned char *input, + size_t ilen ) +{ + size_t offset = 0U; + size_t remaining = ilen; + size_t queue_free_len; + size_t nblocks; + POLY1305_VALIDATE_RET( ctx != NULL ); + POLY1305_VALIDATE_RET( ilen == 0 || input != NULL ); + + if( ( remaining > 0U ) && ( ctx->queue_len > 0U ) ) + { + queue_free_len = ( POLY1305_BLOCK_SIZE_BYTES - ctx->queue_len ); + + if( ilen < queue_free_len ) + { + /* Not enough data to complete the block. + * Store this data with the other leftovers. + */ + memcpy( &ctx->queue[ctx->queue_len], + input, + ilen ); + + ctx->queue_len += ilen; + + remaining = 0U; + } + else + { + /* Enough data to produce a complete block */ + memcpy( &ctx->queue[ctx->queue_len], + input, + queue_free_len ); + + ctx->queue_len = 0U; + + poly1305_process( ctx, 1U, ctx->queue, 1U ); /* add padding bit */ + + offset += queue_free_len; + remaining -= queue_free_len; + } + } + + if( remaining >= POLY1305_BLOCK_SIZE_BYTES ) + { + nblocks = remaining / POLY1305_BLOCK_SIZE_BYTES; + + poly1305_process( ctx, nblocks, &input[offset], 1U ); + + offset += nblocks * POLY1305_BLOCK_SIZE_BYTES; + remaining %= POLY1305_BLOCK_SIZE_BYTES; + } + + if( remaining > 0U ) + { + /* Store partial block */ + ctx->queue_len = remaining; + memcpy( ctx->queue, &input[offset], remaining ); + } + + return( 0 ); +} + +int mbedtls_poly1305_finish( mbedtls_poly1305_context *ctx, + unsigned char mac[16] ) +{ + POLY1305_VALIDATE_RET( ctx != NULL ); + POLY1305_VALIDATE_RET( mac != NULL ); + + /* Process any leftover data */ + if( ctx->queue_len > 0U ) + { + /* Add padding bit */ + ctx->queue[ctx->queue_len] = 1U; + ctx->queue_len++; + + /* Pad with zeroes */ + memset( &ctx->queue[ctx->queue_len], + 0, + POLY1305_BLOCK_SIZE_BYTES - ctx->queue_len ); + + poly1305_process( ctx, 1U, /* Process 1 block */ + ctx->queue, 0U ); /* Already padded above */ + } + + poly1305_compute_mac( ctx, mac ); + + return( 0 ); +} + +int mbedtls_poly1305_mac( const unsigned char key[32], + const unsigned char *input, + size_t ilen, + unsigned char mac[16] ) +{ + mbedtls_poly1305_context ctx; + int ret; + POLY1305_VALIDATE_RET( key != NULL ); + POLY1305_VALIDATE_RET( mac != NULL ); + POLY1305_VALIDATE_RET( ilen == 0 || input != NULL ); + + mbedtls_poly1305_init( &ctx ); + + ret = mbedtls_poly1305_starts( &ctx, key ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_poly1305_update( &ctx, input, ilen ); + if( ret != 0 ) + goto cleanup; + + ret = mbedtls_poly1305_finish( &ctx, mac ); + +cleanup: + mbedtls_poly1305_free( &ctx ); + return( ret ); +} + +#endif /* MBEDTLS_POLY1305_ALT */ + +#if defined(MBEDTLS_SELF_TEST) + +static const unsigned char test_keys[2][32] = +{ + { + 0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33, + 0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8, + 0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd, + 0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b + }, + { + 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, + 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, + 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, + 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0 + } +}; + +static const unsigned char test_data[2][127] = +{ + { + 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72, + 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f, + 0x72, 0x75, 0x6d, 0x20, 0x52, 0x65, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x20, 0x47, 0x72, 0x6f, + 0x75, 0x70 + }, + { + 0x27, 0x54, 0x77, 0x61, 0x73, 0x20, 0x62, 0x72, + 0x69, 0x6c, 0x6c, 0x69, 0x67, 0x2c, 0x20, 0x61, + 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, + 0x6c, 0x69, 0x74, 0x68, 0x79, 0x20, 0x74, 0x6f, + 0x76, 0x65, 0x73, 0x0a, 0x44, 0x69, 0x64, 0x20, + 0x67, 0x79, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, + 0x20, 0x67, 0x69, 0x6d, 0x62, 0x6c, 0x65, 0x20, + 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, + 0x61, 0x62, 0x65, 0x3a, 0x0a, 0x41, 0x6c, 0x6c, + 0x20, 0x6d, 0x69, 0x6d, 0x73, 0x79, 0x20, 0x77, + 0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, + 0x62, 0x6f, 0x72, 0x6f, 0x67, 0x6f, 0x76, 0x65, + 0x73, 0x2c, 0x0a, 0x41, 0x6e, 0x64, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x6d, 0x6f, 0x6d, 0x65, 0x20, + 0x72, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x75, + 0x74, 0x67, 0x72, 0x61, 0x62, 0x65, 0x2e + } +}; + +static const size_t test_data_len[2] = +{ + 34U, + 127U +}; + +static const unsigned char test_mac[2][16] = +{ + { + 0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6, + 0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9 + }, + { + 0x45, 0x41, 0x66, 0x9a, 0x7e, 0xaa, 0xee, 0x61, + 0xe7, 0x08, 0xdc, 0x7c, 0xbc, 0xc5, 0xeb, 0x62 + } +}; + +#define ASSERT( cond, args ) \ + do \ + { \ + if( ! ( cond ) ) \ + { \ + if( verbose != 0 ) \ + mbedtls_printf args; \ + \ + return( -1 ); \ + } \ + } \ + while( 0 ) + +int mbedtls_poly1305_self_test( int verbose ) +{ + unsigned char mac[16]; + unsigned i; + int ret; + + for( i = 0U; i < 2U; i++ ) + { + if( verbose != 0 ) + mbedtls_printf( " Poly1305 test %u ", i ); + + ret = mbedtls_poly1305_mac( test_keys[i], + test_data[i], + test_data_len[i], + mac ); + ASSERT( 0 == ret, ( "error code: %i\n", ret ) ); + + ASSERT( 0 == memcmp( mac, test_mac[i], 16U ), ( "failed (mac)\n" ) ); + + if( verbose != 0 ) + mbedtls_printf( "passed\n" ); + } + + if( verbose != 0 ) + mbedtls_printf( "\n" ); + + return( 0 ); +} + +#endif /* MBEDTLS_SELF_TEST */ + +#endif /* MBEDTLS_POLY1305_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/ripemd160.c b/3rdparty/mbedtls/mbedtls/library/ripemd160.c index 2ba48b7fdb..0791ae4cc9 100644 --- a/3rdparty/mbedtls/mbedtls/library/ripemd160.c +++ b/3rdparty/mbedtls/mbedtls/library/ripemd160.c @@ -34,6 +34,7 @@ #if defined(MBEDTLS_RIPEMD160_C) #include "mbedtls/ripemd160.h" +#include "mbedtls/platform_util.h" #include @@ -71,11 +72,6 @@ } #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - void mbedtls_ripemd160_init( mbedtls_ripemd160_context *ctx ) { memset( ctx, 0, sizeof( mbedtls_ripemd160_context ) ); @@ -86,7 +82,7 @@ void mbedtls_ripemd160_free( mbedtls_ripemd160_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_ripemd160_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ripemd160_context ) ); } void mbedtls_ripemd160_clone( mbedtls_ripemd160_context *dst, @@ -151,22 +147,29 @@ int mbedtls_internal_ripemd160_process( mbedtls_ripemd160_context *ctx, D = Dp = ctx->state[3]; E = Ep = ctx->state[4]; -#define F1( x, y, z ) ( x ^ y ^ z ) -#define F2( x, y, z ) ( ( x & y ) | ( ~x & z ) ) -#define F3( x, y, z ) ( ( x | ~y ) ^ z ) -#define F4( x, y, z ) ( ( x & z ) | ( y & ~z ) ) -#define F5( x, y, z ) ( x ^ ( y | ~z ) ) - -#define S( x, n ) ( ( x << n ) | ( x >> (32 - n) ) ) - -#define P( a, b, c, d, e, r, s, f, k ) \ - a += f( b, c, d ) + X[r] + k; \ - a = S( a, s ) + e; \ - c = S( c, 10 ); - -#define P2( a, b, c, d, e, r, s, rp, sp ) \ - P( a, b, c, d, e, r, s, F, K ); \ - P( a ## p, b ## p, c ## p, d ## p, e ## p, rp, sp, Fp, Kp ); +#define F1( x, y, z ) ( (x) ^ (y) ^ (z) ) +#define F2( x, y, z ) ( ( (x) & (y) ) | ( ~(x) & (z) ) ) +#define F3( x, y, z ) ( ( (x) | ~(y) ) ^ (z) ) +#define F4( x, y, z ) ( ( (x) & (z) ) | ( (y) & ~(z) ) ) +#define F5( x, y, z ) ( (x) ^ ( (y) | ~(z) ) ) + +#define S( x, n ) ( ( (x) << (n) ) | ( (x) >> (32 - (n)) ) ) + +#define P( a, b, c, d, e, r, s, f, k ) \ + do \ + { \ + (a) += f( (b), (c), (d) ) + X[r] + (k); \ + (a) = S( (a), (s) ) + (e); \ + (c) = S( (c), 10 ); \ + } while( 0 ) + +#define P2( a, b, c, d, e, r, s, rp, sp ) \ + do \ + { \ + P( (a), (b), (c), (d), (e), (r), (s), F, K ); \ + P( a ## p, b ## p, c ## p, d ## p, e ## p, \ + (rp), (sp), Fp, Kp ); \ + } while( 0 ) #define F F1 #define K 0x00000000 diff --git a/3rdparty/mbedtls/mbedtls/library/rsa.c b/3rdparty/mbedtls/mbedtls/library/rsa.c index 4b3cc0213d..af1a878599 100644 --- a/3rdparty/mbedtls/mbedtls/library/rsa.c +++ b/3rdparty/mbedtls/mbedtls/library/rsa.c @@ -48,6 +48,7 @@ #include "mbedtls/rsa.h" #include "mbedtls/rsa_internal.h" #include "mbedtls/oid.h" +#include "mbedtls/platform_util.h" #include @@ -70,10 +71,11 @@ #if !defined(MBEDTLS_RSA_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} +/* Parameter validation macros */ +#define RSA_VALIDATE_RET( cond ) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_RSA_BAD_INPUT_DATA ) +#define RSA_VALIDATE( cond ) \ + MBEDTLS_INTERNAL_VALIDATE( cond ) #if defined(MBEDTLS_PKCS1_V15) /* constant-time buffer comparison */ @@ -97,6 +99,7 @@ int mbedtls_rsa_import( mbedtls_rsa_context *ctx, const mbedtls_mpi *D, const mbedtls_mpi *E ) { int ret; + RSA_VALIDATE_RET( ctx != NULL ); if( ( N != NULL && ( ret = mbedtls_mpi_copy( &ctx->N, N ) ) != 0 ) || ( P != NULL && ( ret = mbedtls_mpi_copy( &ctx->P, P ) ) != 0 ) || @@ -121,6 +124,7 @@ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx, unsigned char const *E, size_t E_len ) { int ret = 0; + RSA_VALIDATE_RET( ctx != NULL ); if( N != NULL ) { @@ -244,12 +248,16 @@ static int rsa_check_context( mbedtls_rsa_context const *ctx, int is_priv, int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ) { int ret = 0; + int have_N, have_P, have_Q, have_D, have_E; + int n_missing, pq_missing, d_missing, is_pub, is_priv; + + RSA_VALIDATE_RET( ctx != NULL ); - const int have_N = ( mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 ); - const int have_P = ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 ); - const int have_Q = ( mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 ); - const int have_D = ( mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 ); - const int have_E = ( mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0 ); + have_N = ( mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 ); + have_P = ( mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 ); + have_Q = ( mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 ); + have_D = ( mbedtls_mpi_cmp_int( &ctx->D, 0 ) != 0 ); + have_E = ( mbedtls_mpi_cmp_int( &ctx->E, 0 ) != 0 ); /* * Check whether provided parameters are enough @@ -261,13 +269,13 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx ) * */ - const int n_missing = have_P && have_Q && have_D && have_E; - const int pq_missing = have_N && !have_P && !have_Q && have_D && have_E; - const int d_missing = have_P && have_Q && !have_D && have_E; - const int is_pub = have_N && !have_P && !have_Q && !have_D && have_E; + n_missing = have_P && have_Q && have_D && have_E; + pq_missing = have_N && !have_P && !have_Q && have_D && have_E; + d_missing = have_P && have_Q && !have_D && have_E; + is_pub = have_N && !have_P && !have_Q && !have_D && have_E; /* These three alternatives are mutually exclusive */ - const int is_priv = n_missing || pq_missing || d_missing; + is_priv = n_missing || pq_missing || d_missing; if( !is_priv && !is_pub ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -340,9 +348,11 @@ int mbedtls_rsa_export_raw( const mbedtls_rsa_context *ctx, unsigned char *E, size_t E_len ) { int ret = 0; + int is_priv; + RSA_VALIDATE_RET( ctx != NULL ); /* Check if key is private or public */ - const int is_priv = + is_priv = mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 && mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 && mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 && @@ -383,9 +393,11 @@ int mbedtls_rsa_export( const mbedtls_rsa_context *ctx, mbedtls_mpi *D, mbedtls_mpi *E ) { int ret; + int is_priv; + RSA_VALIDATE_RET( ctx != NULL ); /* Check if key is private or public */ - int is_priv = + is_priv = mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 && mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 && mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 && @@ -425,9 +437,11 @@ int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx, mbedtls_mpi *DP, mbedtls_mpi *DQ, mbedtls_mpi *QP ) { int ret; + int is_priv; + RSA_VALIDATE_RET( ctx != NULL ); /* Check if key is private or public */ - int is_priv = + is_priv = mbedtls_mpi_cmp_int( &ctx->N, 0 ) != 0 && mbedtls_mpi_cmp_int( &ctx->P, 0 ) != 0 && mbedtls_mpi_cmp_int( &ctx->Q, 0 ) != 0 && @@ -463,6 +477,10 @@ void mbedtls_rsa_init( mbedtls_rsa_context *ctx, int padding, int hash_id ) { + RSA_VALIDATE( ctx != NULL ); + RSA_VALIDATE( padding == MBEDTLS_RSA_PKCS_V15 || + padding == MBEDTLS_RSA_PKCS_V21 ); + memset( ctx, 0, sizeof( mbedtls_rsa_context ) ); mbedtls_rsa_set_padding( ctx, padding, hash_id ); @@ -475,8 +493,13 @@ void mbedtls_rsa_init( mbedtls_rsa_context *ctx, /* * Set padding for an existing RSA context */ -void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, int hash_id ) +void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, + int hash_id ) { + RSA_VALIDATE( ctx != NULL ); + RSA_VALIDATE( padding == MBEDTLS_RSA_PKCS_V15 || + padding == MBEDTLS_RSA_PKCS_V21 ); + ctx->padding = padding; ctx->hash_id = hash_id; } @@ -495,6 +518,9 @@ size_t mbedtls_rsa_get_len( const mbedtls_rsa_context *ctx ) /* * Generate an RSA keypair + * + * This generation method follows the RSA key pair generation procedure of + * FIPS 186-4 if 2^16 < exponent < 2^256 and nbits = 2048 or nbits = 3072. */ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, int (*f_rng)(void *, unsigned char *, size_t), @@ -502,65 +528,87 @@ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, unsigned int nbits, int exponent ) { int ret; - mbedtls_mpi H, G; + mbedtls_mpi H, G, L; + int prime_quality = 0; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( f_rng != NULL ); - if( f_rng == NULL || nbits < 128 || exponent < 3 ) + if( nbits < 128 || exponent < 3 || nbits % 2 != 0 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); - if( nbits % 2 ) - return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + /* + * If the modulus is 1024 bit long or shorter, then the security strength of + * the RSA algorithm is less than or equal to 80 bits and therefore an error + * rate of 2^-80 is sufficient. + */ + if( nbits > 1024 ) + prime_quality = MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR; mbedtls_mpi_init( &H ); mbedtls_mpi_init( &G ); + mbedtls_mpi_init( &L ); /* * find primes P and Q with Q < P so that: - * GCD( E, (P-1)*(Q-1) ) == 1 + * 1. |P-Q| > 2^( nbits / 2 - 100 ) + * 2. GCD( E, (P-1)*(Q-1) ) == 1 + * 3. E^-1 mod LCM(P-1, Q-1) > 2^( nbits / 2 ) */ MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &ctx->E, exponent ) ); do { - MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, nbits >> 1, 0, - f_rng, p_rng ) ); - - MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, nbits >> 1, 0, - f_rng, p_rng ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->P, nbits >> 1, + prime_quality, f_rng, p_rng ) ); - if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) == 0 ) - continue; + MBEDTLS_MPI_CHK( mbedtls_mpi_gen_prime( &ctx->Q, nbits >> 1, + prime_quality, f_rng, p_rng ) ); - MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) ); - if( mbedtls_mpi_bitlen( &ctx->N ) != nbits ) + /* make sure the difference between p and q is not too small (FIPS 186-4 §B.3.3 step 5.4) */ + MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &H, &ctx->P, &ctx->Q ) ); + if( mbedtls_mpi_bitlen( &H ) <= ( ( nbits >= 200 ) ? ( ( nbits >> 1 ) - 99 ) : 0 ) ) continue; - if( mbedtls_mpi_cmp_mpi( &ctx->P, &ctx->Q ) < 0 ) + /* not required by any standards, but some users rely on the fact that P > Q */ + if( H.s < 0 ) mbedtls_mpi_swap( &ctx->P, &ctx->Q ); /* Temporarily replace P,Q by P-1, Q-1 */ MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &ctx->P, &ctx->P, 1 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_sub_int( &ctx->Q, &ctx->Q, 1 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &H, &ctx->P, &ctx->Q ) ); + + /* check GCD( E, (P-1)*(Q-1) ) == 1 (FIPS 186-4 §B.3.1 criterion 2(a)) */ MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->E, &H ) ); + if( mbedtls_mpi_cmp_int( &G, 1 ) != 0 ) + continue; + + /* compute smallest possible D = E^-1 mod LCM(P-1, Q-1) (FIPS 186-4 §B.3.1 criterion 3(b)) */ + MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, &ctx->P, &ctx->Q ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &L, NULL, &H, &G ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->D, &ctx->E, &L ) ); + + if( mbedtls_mpi_bitlen( &ctx->D ) <= ( ( nbits + 1 ) / 2 ) ) // (FIPS 186-4 §B.3.1 criterion 3(a)) + continue; + + break; } - while( mbedtls_mpi_cmp_int( &G, 1 ) != 0 ); + while( 1 ); /* Restore P,Q */ MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &ctx->P, &ctx->P, 1 ) ); MBEDTLS_MPI_CHK( mbedtls_mpi_add_int( &ctx->Q, &ctx->Q, 1 ) ); + MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P, &ctx->Q ) ); + ctx->len = mbedtls_mpi_size( &ctx->N ); +#if !defined(MBEDTLS_RSA_NO_CRT) /* - * D = E^-1 mod ((P-1)*(Q-1)) * DP = D mod (P - 1) * DQ = D mod (Q - 1) * QP = Q^-1 mod P */ - - MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &ctx->D, &ctx->E, &H ) ); - -#if !defined(MBEDTLS_RSA_NO_CRT) MBEDTLS_MPI_CHK( mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D, &ctx->DP, &ctx->DQ, &ctx->QP ) ); #endif /* MBEDTLS_RSA_NO_CRT */ @@ -572,6 +620,7 @@ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, mbedtls_mpi_free( &H ); mbedtls_mpi_free( &G ); + mbedtls_mpi_free( &L ); if( ret != 0 ) { @@ -589,6 +638,8 @@ int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx, */ int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ) { + RSA_VALIDATE_RET( ctx != NULL ); + if( rsa_check_context( ctx, 0 /* public */, 0 /* no blinding */ ) != 0 ) return( MBEDTLS_ERR_RSA_KEY_CHECK_FAILED ); @@ -612,6 +663,8 @@ int mbedtls_rsa_check_pubkey( const mbedtls_rsa_context *ctx ) */ int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ) { + RSA_VALIDATE_RET( ctx != NULL ); + if( mbedtls_rsa_check_pubkey( ctx ) != 0 || rsa_check_context( ctx, 1 /* private */, 1 /* blinding */ ) != 0 ) { @@ -641,6 +694,9 @@ int mbedtls_rsa_check_privkey( const mbedtls_rsa_context *ctx ) int mbedtls_rsa_check_pub_priv( const mbedtls_rsa_context *pub, const mbedtls_rsa_context *prv ) { + RSA_VALIDATE_RET( pub != NULL ); + RSA_VALIDATE_RET( prv != NULL ); + if( mbedtls_rsa_check_pubkey( pub ) != 0 || mbedtls_rsa_check_privkey( prv ) != 0 ) { @@ -666,6 +722,9 @@ int mbedtls_rsa_public( mbedtls_rsa_context *ctx, int ret; size_t olen; mbedtls_mpi T; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( input != NULL ); + RSA_VALIDATE_RET( output != NULL ); if( rsa_check_context( ctx, 0 /* public */, 0 /* no blinding */ ) ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -808,6 +867,10 @@ int mbedtls_rsa_private( mbedtls_rsa_context *ctx, * checked result; should be the same in the end. */ mbedtls_mpi I, C; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( input != NULL ); + RSA_VALIDATE_RET( output != NULL ); + if( rsa_check_context( ctx, 1 /* private key checks */, f_rng != NULL /* blinding y/n */ ) != 0 ) { @@ -1042,7 +1105,7 @@ static int mgf_mask( unsigned char *dst, size_t dlen, unsigned char *src, } exit: - mbedtls_zeroize( mask, sizeof( mask ) ); + mbedtls_platform_zeroize( mask, sizeof( mask ) ); return( ret ); } @@ -1068,6 +1131,13 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, const mbedtls_md_info_t *md_info; mbedtls_md_context_t md_ctx; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( output != NULL ); + RSA_VALIDATE_RET( input != NULL ); + RSA_VALIDATE_RET( label_len == 0 || label != NULL ); + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -1144,11 +1214,13 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, int ret; unsigned char *p = output; - if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) - return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( output != NULL ); + RSA_VALIDATE_RET( input != NULL ); - // We don't check p_rng because it won't be dereferenced here - if( f_rng == NULL || input == NULL || output == NULL ) + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); olen = ctx->len; @@ -1162,6 +1234,9 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx, *p++ = 0; if( mode == MBEDTLS_RSA_PUBLIC ) { + if( f_rng == NULL ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + *p++ = MBEDTLS_RSA_CRYPT; while( nb_pad-- > 0 ) @@ -1206,6 +1281,12 @@ int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx, const unsigned char *input, unsigned char *output ) { + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( output != NULL ); + RSA_VALIDATE_RET( input != NULL ); + switch( ctx->padding ) { #if defined(MBEDTLS_PKCS1_V15) @@ -1248,6 +1329,14 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, const mbedtls_md_info_t *md_info; mbedtls_md_context_t md_ctx; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( output_max_len == 0 || output != NULL ); + RSA_VALIDATE_RET( label_len == 0 || label != NULL ); + RSA_VALIDATE_RET( input != NULL ); + RSA_VALIDATE_RET( olen != NULL ); + /* * Parameters sanity checks */ @@ -1356,8 +1445,8 @@ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, ret = 0; cleanup: - mbedtls_zeroize( buf, sizeof( buf ) ); - mbedtls_zeroize( lhash, sizeof( lhash ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( lhash, sizeof( lhash ) ); return( ret ); } @@ -1467,11 +1556,7 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, size_t output_max_len ) { int ret; - size_t ilen = ctx->len; - size_t i; - size_t plaintext_max_size = ( output_max_len > ilen - 11 ? - ilen - 11 : - output_max_len ); + size_t ilen, i, plaintext_max_size; unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; /* The following variables take sensitive values: their value must * not leak into the observable behavior of the function other than @@ -1489,6 +1574,18 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, size_t plaintext_size = 0; unsigned output_too_large; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( output_max_len == 0 || output != NULL ); + RSA_VALIDATE_RET( input != NULL ); + RSA_VALIDATE_RET( olen != NULL ); + + ilen = ctx->len; + plaintext_max_size = ( output_max_len > ilen - 11 ? + ilen - 11 : + output_max_len ); + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -1607,7 +1704,7 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, *olen = plaintext_size; cleanup: - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); return( ret ); } @@ -1624,6 +1721,13 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, unsigned char *output, size_t output_max_len) { + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( output_max_len == 0 || output != NULL ); + RSA_VALIDATE_RET( input != NULL ); + RSA_VALIDATE_RET( olen != NULL ); + switch( ctx->padding ) { #if defined(MBEDTLS_PKCS1_V15) @@ -1660,11 +1764,18 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, size_t olen; unsigned char *p = sig; unsigned char salt[MBEDTLS_MD_MAX_SIZE]; - unsigned int slen, hlen, offset = 0; + size_t slen, min_slen, hlen, offset = 0; int ret; size_t msb; const mbedtls_md_info_t *md_info; mbedtls_md_context_t md_ctx; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + RSA_VALIDATE_RET( sig != NULL ); if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -1689,10 +1800,20 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); hlen = mbedtls_md_get_size( md_info ); - slen = hlen; - if( olen < hlen + slen + 2 ) + /* Calculate the largest possible salt length. Normally this is the hash + * length, which is the maximum length the salt can have. If there is not + * enough room, use the maximum salt length that fits. The constraint is + * that the hash length plus the salt length plus 2 bytes must be at most + * the key length. This complies with FIPS 186-4 §5.5 (e) and RFC 8017 + * (PKCS#1 v2.2) §9.1.1 step 3. */ + min_slen = hlen - 2; + if( olen < hlen + min_slen + 2 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + else if( olen >= hlen + hlen + 2 ) + slen = hlen; + else + slen = olen - hlen - 2; memset( sig, 0, olen ); @@ -1702,7 +1823,7 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, /* Note: EMSA-PSS encoding is over the length of N - 1 bits */ msb = mbedtls_mpi_bitlen( &ctx->N ) - 1; - p += olen - hlen * 2 - 2; + p += olen - hlen - slen - 2; *p++ = 0x01; memcpy( p, salt, slen ); p += slen; @@ -1738,7 +1859,7 @@ int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, p += hlen; *p++ = 0xBC; - mbedtls_zeroize( salt, sizeof( salt ) ); + mbedtls_platform_zeroize( salt, sizeof( salt ) ); exit: mbedtls_md_free( &md_ctx ); @@ -1880,7 +2001,7 @@ static int rsa_rsassa_pkcs1_v15_encode( mbedtls_md_type_t md_alg, * after the initial bounds check. */ if( p != dst + dst_len ) { - mbedtls_zeroize( dst, dst_len ); + mbedtls_platform_zeroize( dst, dst_len ); return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); } @@ -1902,6 +2023,14 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, int ret; unsigned char *sig_try = NULL, *verif = NULL; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + RSA_VALIDATE_RET( sig != NULL ); + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -1971,6 +2100,14 @@ int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx, const unsigned char *hash, unsigned char *sig ) { + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + RSA_VALIDATE_RET( sig != NULL ); + switch( ctx->padding ) { #if defined(MBEDTLS_PKCS1_V15) @@ -2017,6 +2154,14 @@ int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx, mbedtls_md_context_t md_ctx; unsigned char buf[MBEDTLS_MPI_MAX_SIZE]; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( sig != NULL ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V21 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -2145,7 +2290,16 @@ int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx, const unsigned char *hash, const unsigned char *sig ) { - mbedtls_md_type_t mgf1_hash_id = ( ctx->hash_id != MBEDTLS_MD_NONE ) + mbedtls_md_type_t mgf1_hash_id; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( sig != NULL ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + + mgf1_hash_id = ( ctx->hash_id != MBEDTLS_MD_NONE ) ? (mbedtls_md_type_t) ctx->hash_id : md_alg; @@ -2171,9 +2325,19 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, const unsigned char *sig ) { int ret = 0; - const size_t sig_len = ctx->len; + size_t sig_len; unsigned char *encoded = NULL, *encoded_expected = NULL; + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( sig != NULL ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + + sig_len = ctx->len; + if( mode == MBEDTLS_RSA_PRIVATE && ctx->padding != MBEDTLS_RSA_PKCS_V15 ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -2217,13 +2381,13 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, if( encoded != NULL ) { - mbedtls_zeroize( encoded, sig_len ); + mbedtls_platform_zeroize( encoded, sig_len ); mbedtls_free( encoded ); } if( encoded_expected != NULL ) { - mbedtls_zeroize( encoded_expected, sig_len ); + mbedtls_platform_zeroize( encoded_expected, sig_len ); mbedtls_free( encoded_expected ); } @@ -2243,6 +2407,14 @@ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, const unsigned char *hash, const unsigned char *sig ) { + RSA_VALIDATE_RET( ctx != NULL ); + RSA_VALIDATE_RET( mode == MBEDTLS_RSA_PRIVATE || + mode == MBEDTLS_RSA_PUBLIC ); + RSA_VALIDATE_RET( sig != NULL ); + RSA_VALIDATE_RET( ( md_alg == MBEDTLS_MD_NONE && + hashlen == 0 ) || + hash != NULL ); + switch( ctx->padding ) { #if defined(MBEDTLS_PKCS1_V15) @@ -2268,6 +2440,8 @@ int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx, int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src ) { int ret; + RSA_VALIDATE_RET( dst != NULL ); + RSA_VALIDATE_RET( src != NULL ); dst->ver = src->ver; dst->len = src->len; @@ -2307,14 +2481,23 @@ int mbedtls_rsa_copy( mbedtls_rsa_context *dst, const mbedtls_rsa_context *src ) */ void mbedtls_rsa_free( mbedtls_rsa_context *ctx ) { - mbedtls_mpi_free( &ctx->Vi ); mbedtls_mpi_free( &ctx->Vf ); - mbedtls_mpi_free( &ctx->RN ); mbedtls_mpi_free( &ctx->D ); - mbedtls_mpi_free( &ctx->Q ); mbedtls_mpi_free( &ctx->P ); - mbedtls_mpi_free( &ctx->E ); mbedtls_mpi_free( &ctx->N ); + if( ctx == NULL ) + return; + + mbedtls_mpi_free( &ctx->Vi ); + mbedtls_mpi_free( &ctx->Vf ); + mbedtls_mpi_free( &ctx->RN ); + mbedtls_mpi_free( &ctx->D ); + mbedtls_mpi_free( &ctx->Q ); + mbedtls_mpi_free( &ctx->P ); + mbedtls_mpi_free( &ctx->E ); + mbedtls_mpi_free( &ctx->N ); #if !defined(MBEDTLS_RSA_NO_CRT) - mbedtls_mpi_free( &ctx->RQ ); mbedtls_mpi_free( &ctx->RP ); - mbedtls_mpi_free( &ctx->QP ); mbedtls_mpi_free( &ctx->DQ ); + mbedtls_mpi_free( &ctx->RQ ); + mbedtls_mpi_free( &ctx->RP ); + mbedtls_mpi_free( &ctx->QP ); + mbedtls_mpi_free( &ctx->DQ ); mbedtls_mpi_free( &ctx->DP ); #endif /* MBEDTLS_RSA_NO_CRT */ diff --git a/3rdparty/mbedtls/mbedtls/library/rsa_internal.c b/3rdparty/mbedtls/mbedtls/library/rsa_internal.c index 507009f131..9a42d47ceb 100644 --- a/3rdparty/mbedtls/mbedtls/library/rsa_internal.c +++ b/3rdparty/mbedtls/mbedtls/library/rsa_internal.c @@ -351,15 +351,20 @@ int mbedtls_rsa_validate_params( const mbedtls_mpi *N, const mbedtls_mpi *P, */ #if defined(MBEDTLS_GENPRIME) + /* + * When generating keys, the strongest security we support aims for an error + * rate of at most 2^-100 and we are aiming for the same certainty here as + * well. + */ if( f_rng != NULL && P != NULL && - ( ret = mbedtls_mpi_is_prime( P, f_rng, p_rng ) ) != 0 ) + ( ret = mbedtls_mpi_is_prime_ext( P, 50, f_rng, p_rng ) ) != 0 ) { ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; goto cleanup; } if( f_rng != NULL && Q != NULL && - ( ret = mbedtls_mpi_is_prime( Q, f_rng, p_rng ) ) != 0 ) + ( ret = mbedtls_mpi_is_prime_ext( Q, 50, f_rng, p_rng ) ) != 0 ) { ret = MBEDTLS_ERR_RSA_KEY_CHECK_FAILED; goto cleanup; diff --git a/3rdparty/mbedtls/mbedtls/library/sha1.c b/3rdparty/mbedtls/mbedtls/library/sha1.c index 5d0335d5ae..355c83d2f7 100644 --- a/3rdparty/mbedtls/mbedtls/library/sha1.c +++ b/3rdparty/mbedtls/mbedtls/library/sha1.c @@ -33,6 +33,7 @@ #if defined(MBEDTLS_SHA1_C) #include "mbedtls/sha1.h" +#include "mbedtls/platform_util.h" #include @@ -45,12 +46,12 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ -#if !defined(MBEDTLS_SHA1_ALT) +#define SHA1_VALIDATE_RET(cond) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA1_BAD_INPUT_DATA ) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0; -} +#define SHA1_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) + +#if !defined(MBEDTLS_SHA1_ALT) /* * 32-bit integer manipulation macros (big endian) @@ -77,6 +78,8 @@ static void mbedtls_zeroize( void *v, size_t n ) { void mbedtls_sha1_init( mbedtls_sha1_context *ctx ) { + SHA1_VALIDATE( ctx != NULL ); + memset( ctx, 0, sizeof( mbedtls_sha1_context ) ); } @@ -85,12 +88,15 @@ void mbedtls_sha1_free( mbedtls_sha1_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_sha1_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_sha1_context ) ); } void mbedtls_sha1_clone( mbedtls_sha1_context *dst, const mbedtls_sha1_context *src ) { + SHA1_VALIDATE( dst != NULL ); + SHA1_VALIDATE( src != NULL ); + *dst = *src; } @@ -99,6 +105,8 @@ void mbedtls_sha1_clone( mbedtls_sha1_context *dst, */ int mbedtls_sha1_starts_ret( mbedtls_sha1_context *ctx ) { + SHA1_VALIDATE_RET( ctx != NULL ); + ctx->total[0] = 0; ctx->total[1] = 0; @@ -124,6 +132,9 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, { uint32_t temp, W[16], A, B, C, D, E; + SHA1_VALIDATE_RET( ctx != NULL ); + SHA1_VALIDATE_RET( (const unsigned char *)data != NULL ); + GET_UINT32_BE( W[ 0], data, 0 ); GET_UINT32_BE( W[ 1], data, 4 ); GET_UINT32_BE( W[ 2], data, 8 ); @@ -141,19 +152,21 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, GET_UINT32_BE( W[14], data, 56 ); GET_UINT32_BE( W[15], data, 60 ); -#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n))) +#define S(x,n) (((x) << (n)) | (((x) & 0xFFFFFFFF) >> (32 - (n)))) -#define R(t) \ -( \ - temp = W[( t - 3 ) & 0x0F] ^ W[( t - 8 ) & 0x0F] ^ \ - W[( t - 14 ) & 0x0F] ^ W[ t & 0x0F], \ - ( W[t & 0x0F] = S(temp,1) ) \ -) +#define R(t) \ + ( \ + temp = W[( (t) - 3 ) & 0x0F] ^ W[( (t) - 8 ) & 0x0F] ^ \ + W[( (t) - 14 ) & 0x0F] ^ W[ (t) & 0x0F], \ + ( W[(t) & 0x0F] = S(temp,1) ) \ + ) -#define P(a,b,c,d,e,x) \ -{ \ - e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \ -} +#define P(a,b,c,d,e,x) \ + do \ + { \ + (e) += S((a),5) + F((b),(c),(d)) + K + (x); \ + (b) = S((b),30); \ + } while( 0 ) A = ctx->state[0]; B = ctx->state[1]; @@ -161,7 +174,7 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, D = ctx->state[3]; E = ctx->state[4]; -#define F(x,y,z) (z ^ (x & (y ^ z))) +#define F(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) #define K 0x5A827999 P( A, B, C, D, E, W[0] ); @@ -188,7 +201,7 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, #undef K #undef F -#define F(x,y,z) (x ^ y ^ z) +#define F(x,y,z) ((x) ^ (y) ^ (z)) #define K 0x6ED9EBA1 P( A, B, C, D, E, R(20) ); @@ -215,7 +228,7 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, #undef K #undef F -#define F(x,y,z) ((x & y) | (z & (x | y))) +#define F(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) #define K 0x8F1BBCDC P( A, B, C, D, E, R(40) ); @@ -242,7 +255,7 @@ int mbedtls_internal_sha1_process( mbedtls_sha1_context *ctx, #undef K #undef F -#define F(x,y,z) (x ^ y ^ z) +#define F(x,y,z) ((x) ^ (y) ^ (z)) #define K 0xCA62C1D6 P( A, B, C, D, E, R(60) ); @@ -298,6 +311,9 @@ int mbedtls_sha1_update_ret( mbedtls_sha1_context *ctx, size_t fill; uint32_t left; + SHA1_VALIDATE_RET( ctx != NULL ); + SHA1_VALIDATE_RET( ilen == 0 || input != NULL ); + if( ilen == 0 ) return( 0 ); @@ -356,6 +372,9 @@ int mbedtls_sha1_finish_ret( mbedtls_sha1_context *ctx, uint32_t used; uint32_t high, low; + SHA1_VALIDATE_RET( ctx != NULL ); + SHA1_VALIDATE_RET( (unsigned char *)output != NULL ); + /* * Add padding: 0x80 then 0x00 until 8 bytes remain for the length */ @@ -424,6 +443,9 @@ int mbedtls_sha1_ret( const unsigned char *input, int ret; mbedtls_sha1_context ctx; + SHA1_VALIDATE_RET( ilen == 0 || input != NULL ); + SHA1_VALIDATE_RET( (unsigned char *)output != NULL ); + mbedtls_sha1_init( &ctx ); if( ( ret = mbedtls_sha1_starts_ret( &ctx ) ) != 0 ) diff --git a/3rdparty/mbedtls/mbedtls/library/sha256.c b/3rdparty/mbedtls/mbedtls/library/sha256.c index 4ec9164a8d..2dc0e1a2c9 100644 --- a/3rdparty/mbedtls/mbedtls/library/sha256.c +++ b/3rdparty/mbedtls/mbedtls/library/sha256.c @@ -33,6 +33,7 @@ #if defined(MBEDTLS_SHA256_C) #include "mbedtls/sha256.h" +#include "mbedtls/platform_util.h" #include @@ -48,12 +49,11 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ -#if !defined(MBEDTLS_SHA256_ALT) +#define SHA256_VALIDATE_RET(cond) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA256_BAD_INPUT_DATA ) +#define SHA256_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +#if !defined(MBEDTLS_SHA256_ALT) /* * 32-bit integer manipulation macros (big endian) @@ -80,6 +80,8 @@ do { \ void mbedtls_sha256_init( mbedtls_sha256_context *ctx ) { + SHA256_VALIDATE( ctx != NULL ); + memset( ctx, 0, sizeof( mbedtls_sha256_context ) ); } @@ -88,12 +90,15 @@ void mbedtls_sha256_free( mbedtls_sha256_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_sha256_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_sha256_context ) ); } void mbedtls_sha256_clone( mbedtls_sha256_context *dst, const mbedtls_sha256_context *src ) { + SHA256_VALIDATE( dst != NULL ); + SHA256_VALIDATE( src != NULL ); + *dst = *src; } @@ -102,6 +107,9 @@ void mbedtls_sha256_clone( mbedtls_sha256_context *dst, */ int mbedtls_sha256_starts_ret( mbedtls_sha256_context *ctx, int is224 ) { + SHA256_VALIDATE_RET( ctx != NULL ); + SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 ); + ctx->total[0] = 0; ctx->total[1] = 0; @@ -164,8 +172,8 @@ static const uint32_t K[] = 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2, }; -#define SHR(x,n) ((x & 0xFFFFFFFF) >> n) -#define ROTR(x,n) (SHR(x,n) | (x << (32 - n))) +#define SHR(x,n) (((x) & 0xFFFFFFFF) >> (n)) +#define ROTR(x,n) (SHR(x,n) | ((x) << (32 - (n)))) #define S0(x) (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3)) #define S1(x) (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10)) @@ -173,21 +181,22 @@ static const uint32_t K[] = #define S2(x) (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22)) #define S3(x) (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25)) -#define F0(x,y,z) ((x & y) | (z & (x | y))) -#define F1(x,y,z) (z ^ (x & (y ^ z))) +#define F0(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) +#define F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) #define R(t) \ -( \ - W[t] = S1(W[t - 2]) + W[t - 7] + \ - S0(W[t - 15]) + W[t - 16] \ -) - -#define P(a,b,c,d,e,f,g,h,x,K) \ -{ \ - temp1 = h + S3(e) + F1(e,f,g) + K + x; \ - temp2 = S2(a) + F0(a,b,c); \ - d += temp1; h = temp1 + temp2; \ -} + ( \ + W[t] = S1(W[(t) - 2]) + W[(t) - 7] + \ + S0(W[(t) - 15]) + W[(t) - 16] \ + ) + +#define P(a,b,c,d,e,f,g,h,x,K) \ + do \ + { \ + temp1 = (h) + S3(e) + F1((e),(f),(g)) + (K) + (x); \ + temp2 = S2(a) + F0((a),(b),(c)); \ + (d) += temp1; (h) = temp1 + temp2; \ + } while( 0 ) int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ) @@ -196,6 +205,9 @@ int mbedtls_internal_sha256_process( mbedtls_sha256_context *ctx, uint32_t A[8]; unsigned int i; + SHA256_VALIDATE_RET( ctx != NULL ); + SHA256_VALIDATE_RET( (const unsigned char *)data != NULL ); + for( i = 0; i < 8; i++ ) A[i] = ctx->state[i]; @@ -267,6 +279,9 @@ int mbedtls_sha256_update_ret( mbedtls_sha256_context *ctx, size_t fill; uint32_t left; + SHA256_VALIDATE_RET( ctx != NULL ); + SHA256_VALIDATE_RET( ilen == 0 || input != NULL ); + if( ilen == 0 ) return( 0 ); @@ -325,6 +340,9 @@ int mbedtls_sha256_finish_ret( mbedtls_sha256_context *ctx, uint32_t used; uint32_t high, low; + SHA256_VALIDATE_RET( ctx != NULL ); + SHA256_VALIDATE_RET( (unsigned char *)output != NULL ); + /* * Add padding: 0x80 then 0x00 until 8 bytes remain for the length */ @@ -399,6 +417,10 @@ int mbedtls_sha256_ret( const unsigned char *input, int ret; mbedtls_sha256_context ctx; + SHA256_VALIDATE_RET( is224 == 0 || is224 == 1 ); + SHA256_VALIDATE_RET( ilen == 0 || input != NULL ); + SHA256_VALIDATE_RET( (unsigned char *)output != NULL ); + mbedtls_sha256_init( &ctx ); if( ( ret = mbedtls_sha256_starts_ret( &ctx, is224 ) ) != 0 ) diff --git a/3rdparty/mbedtls/mbedtls/library/sha512.c b/3rdparty/mbedtls/mbedtls/library/sha512.c index db2617ebdf..bdd20b284a 100644 --- a/3rdparty/mbedtls/mbedtls/library/sha512.c +++ b/3rdparty/mbedtls/mbedtls/library/sha512.c @@ -33,6 +33,7 @@ #if defined(MBEDTLS_SHA512_C) #include "mbedtls/sha512.h" +#include "mbedtls/platform_util.h" #if defined(_MSC_VER) || defined(__WATCOMC__) #define UL64(x) x##ui64 @@ -54,12 +55,11 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ -#if !defined(MBEDTLS_SHA512_ALT) +#define SHA512_VALIDATE_RET(cond) \ + MBEDTLS_INTERNAL_VALIDATE_RET( cond, MBEDTLS_ERR_SHA512_BAD_INPUT_DATA ) +#define SHA512_VALIDATE(cond) MBEDTLS_INTERNAL_VALIDATE( cond ) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +#if !defined(MBEDTLS_SHA512_ALT) /* * 64-bit integer manipulation macros (big endian) @@ -94,6 +94,8 @@ static void mbedtls_zeroize( void *v, size_t n ) { void mbedtls_sha512_init( mbedtls_sha512_context *ctx ) { + SHA512_VALIDATE( ctx != NULL ); + memset( ctx, 0, sizeof( mbedtls_sha512_context ) ); } @@ -102,12 +104,15 @@ void mbedtls_sha512_free( mbedtls_sha512_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_sha512_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_sha512_context ) ); } void mbedtls_sha512_clone( mbedtls_sha512_context *dst, const mbedtls_sha512_context *src ) { + SHA512_VALIDATE( dst != NULL ); + SHA512_VALIDATE( src != NULL ); + *dst = *src; } @@ -116,6 +121,9 @@ void mbedtls_sha512_clone( mbedtls_sha512_context *dst, */ int mbedtls_sha512_starts_ret( mbedtls_sha512_context *ctx, int is384 ) { + SHA512_VALIDATE_RET( ctx != NULL ); + SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 ); + ctx->total[0] = 0; ctx->total[1] = 0; @@ -213,8 +221,11 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, uint64_t temp1, temp2, W[80]; uint64_t A, B, C, D, E, F, G, H; -#define SHR(x,n) (x >> n) -#define ROTR(x,n) (SHR(x,n) | (x << (64 - n))) + SHA512_VALIDATE_RET( ctx != NULL ); + SHA512_VALIDATE_RET( (const unsigned char *)data != NULL ); + +#define SHR(x,n) ((x) >> (n)) +#define ROTR(x,n) (SHR((x),(n)) | ((x) << (64 - (n)))) #define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7)) #define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6)) @@ -222,15 +233,16 @@ int mbedtls_internal_sha512_process( mbedtls_sha512_context *ctx, #define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39)) #define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41)) -#define F0(x,y,z) ((x & y) | (z & (x | y))) -#define F1(x,y,z) (z ^ (x & (y ^ z))) +#define F0(x,y,z) (((x) & (y)) | ((z) & ((x) | (y)))) +#define F1(x,y,z) ((z) ^ ((x) & ((y) ^ (z)))) -#define P(a,b,c,d,e,f,g,h,x,K) \ -{ \ - temp1 = h + S3(e) + F1(e,f,g) + K + x; \ - temp2 = S2(a) + F0(a,b,c); \ - d += temp1; h = temp1 + temp2; \ -} +#define P(a,b,c,d,e,f,g,h,x,K) \ + do \ + { \ + temp1 = (h) + S3(e) + F1((e),(f),(g)) + (K) + (x); \ + temp2 = S2(a) + F0((a),(b),(c)); \ + (d) += temp1; (h) = temp1 + temp2; \ + } while( 0 ) for( i = 0; i < 16; i++ ) { @@ -298,6 +310,9 @@ int mbedtls_sha512_update_ret( mbedtls_sha512_context *ctx, size_t fill; unsigned int left; + SHA512_VALIDATE_RET( ctx != NULL ); + SHA512_VALIDATE_RET( ilen == 0 || input != NULL ); + if( ilen == 0 ) return( 0 ); @@ -355,6 +370,9 @@ int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx, unsigned used; uint64_t high, low; + SHA512_VALIDATE_RET( ctx != NULL ); + SHA512_VALIDATE_RET( (unsigned char *)output != NULL ); + /* * Add padding: 0x80 then 0x00 until 16 bytes remain for the length */ @@ -431,6 +449,10 @@ int mbedtls_sha512_ret( const unsigned char *input, int ret; mbedtls_sha512_context ctx; + SHA512_VALIDATE_RET( is384 == 0 || is384 == 1 ); + SHA512_VALIDATE_RET( ilen == 0 || input != NULL ); + SHA512_VALIDATE_RET( (unsigned char *)output != NULL ); + mbedtls_sha512_init( &ctx ); if( ( ret = mbedtls_sha512_starts_ret( &ctx, is384 ) ) != 0 ) diff --git a/3rdparty/mbedtls/mbedtls/library/ssl_ciphersuites.c b/3rdparty/mbedtls/mbedtls/library/ssl_ciphersuites.c index 800b5f84d8..518f7dde00 100644 --- a/3rdparty/mbedtls/mbedtls/library/ssl_ciphersuites.c +++ b/3rdparty/mbedtls/mbedtls/library/ssl_ciphersuites.c @@ -43,11 +43,11 @@ /* * Ordered from most preferred to least preferred in terms of security. * - * Current rule (except rc4, weak and null which come last): + * Current rule (except RC4 and 3DES, weak and null which come last): * 1. By key exchange: * Forward-secure non-PSK > forward-secure PSK > ECJPAKE > other non-PSK > other PSK * 2. By key length and cipher: - * AES-256 > Camellia-256 > AES-128 > Camellia-128 > 3DES + * ChaCha > AES-256 > Camellia-256 > ARIA-256 > AES-128 > Camellia-128 > ARIA-128 * 3. By cipher mode when relevant GCM > CCM > CBC > CCM_8 * 4. By hash function used when relevant * 5. By key exchange/auth again: EC > non-EC @@ -57,6 +57,11 @@ static const int ciphersuite_preference[] = #if defined(MBEDTLS_SSL_CIPHERSUITES) MBEDTLS_SSL_CIPHERSUITES, #else + /* Chacha-Poly ephemeral suites */ + MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + /* All AES-256 ephemeral suites */ MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, @@ -81,6 +86,14 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256, MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, + /* All ARIA-256 ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384, + MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384, + MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384, + /* All AES-128 ephemeral suites */ MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, @@ -105,12 +118,17 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256, MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, - /* All remaining >= 128-bit ephemeral suites */ - MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, - MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, + /* All ARIA-128 ephemeral suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256, + MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256, + MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256, /* The PSK ephemeral suites */ + MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256, MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM, MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384, @@ -121,6 +139,9 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384, MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8, + MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384, + MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384, MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM, @@ -132,9 +153,9 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256, MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8, - - MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, - MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256, + MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256, /* The ECJPAKE suite */ MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8, @@ -161,6 +182,14 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384, MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384, + /* All ARIA-256 suites */ + MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384, + MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384, + MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384, + /* All AES-128 suites */ MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256, MBEDTLS_TLS_RSA_WITH_AES_128_CCM, @@ -183,27 +212,34 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256, MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256, - /* All remaining >= 128-bit suites */ - MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, - MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, - MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, + /* All ARIA-128 suites */ + MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256, + MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256, + MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256, /* The RSA PSK suites */ + MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256, MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384, MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384, MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA, MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384, MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384, + MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384, MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256, MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256, MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA, MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256, MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256, - - MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256, /* The PSK suites */ + MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256, MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384, MBEDTLS_TLS_PSK_WITH_AES_256_CCM, MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384, @@ -211,6 +247,8 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384, MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384, MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8, + MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384, + MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384, MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256, MBEDTLS_TLS_PSK_WITH_AES_128_CCM, @@ -219,7 +257,19 @@ static const int ciphersuite_preference[] = MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256, MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256, MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8, + MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256, + MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256, + /* 3DES suites */ + MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, + MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA, MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA, /* RC4 suites */ @@ -266,6 +316,75 @@ static const int ciphersuite_preference[] = static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = { +#if defined(MBEDTLS_CHACHAPOLY_C) && \ + defined(MBEDTLS_SHA256_C) && \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) + { MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + "TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + "TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + { MBEDTLS_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + "TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + { MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256, + "TLS-PSK-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + { MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256, + "TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + { MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256, + "TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + { MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256, + "TLS-RSA-PSK-WITH-CHACHA20-POLY1305-SHA256", + MBEDTLS_CIPHER_CHACHA20_POLY1305, MBEDTLS_MD_SHA256, + MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#endif /* MBEDTLS_CHACHAPOLY_C && + MBEDTLS_SHA256_C && + MBEDTLS_SSL_PROTO_TLS1_2 */ #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #if defined(MBEDTLS_AES_C) #if defined(MBEDTLS_SHA1_C) @@ -1688,6 +1807,365 @@ static const mbedtls_ssl_ciphersuite_t ciphersuite_definitions[] = #endif /* MBEDTLS_DES_C */ #endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */ +#if defined(MBEDTLS_ARIA_C) + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384, + "TLS-RSA-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384, + "TLS-RSA-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256, + "TLS-RSA-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256, + "TLS-RSA-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384, + "TLS-RSA-PSK-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384, + "TLS-RSA-PSK-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256, + "TLS-RSA-PSK-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256, + "TLS-RSA-PSK-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_RSA_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384, + "TLS-PSK-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384,MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384, + "TLS-PSK-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256, + "TLS-PSK-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256, + "TLS-PSK-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384, + "TLS-ECDH-RSA-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384, + "TLS-ECDH-RSA-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256, + "TLS-ECDH-RSA-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256, + "TLS-ECDH-RSA-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384, + "TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384, + "TLS-ECDHE-RSA-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256, + "TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256, + "TLS-ECDHE-RSA-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384, + "TLS-ECDHE-PSK-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256, + "TLS-ECDHE-PSK-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384, + "TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384, + "TLS-ECDHE-ECDSA-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256, + "TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256, + "TLS-ECDHE-ECDSA-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384, + "TLS-ECDH-ECDSA-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384, + "TLS-ECDH-ECDSA-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256, + "TLS-ECDH-ECDSA-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256, + "TLS-ECDH-ECDSA-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384, + "TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384, + "TLS-DHE-RSA-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256, + "TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256, + "TLS-DHE-RSA-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_RSA, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384, + "TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384", + MBEDTLS_CIPHER_ARIA_256_GCM, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA512_C)) + { MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384, + "TLS-DHE-PSK-WITH-ARIA-256-CBC-SHA384", + MBEDTLS_CIPHER_ARIA_256_CBC, MBEDTLS_MD_SHA384, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_GCM_C) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256, + "TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256", + MBEDTLS_CIPHER_ARIA_128_GCM, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif +#if (defined(MBEDTLS_CIPHER_MODE_CBC) && defined(MBEDTLS_SHA256_C)) + { MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256, + "TLS-DHE-PSK-WITH-ARIA-128-CBC-SHA256", + MBEDTLS_CIPHER_ARIA_128_CBC, MBEDTLS_MD_SHA256, MBEDTLS_KEY_EXCHANGE_DHE_PSK, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + MBEDTLS_SSL_MAJOR_VERSION_3, MBEDTLS_SSL_MINOR_VERSION_3, + 0 }, +#endif + +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#endif /* MBEDTLS_ARIA_C */ + + { 0, "", MBEDTLS_CIPHER_NONE, MBEDTLS_MD_NONE, MBEDTLS_KEY_EXCHANGE_NONE, 0, 0, 0, 0, 0 } @@ -1704,6 +2182,26 @@ const int *mbedtls_ssl_list_ciphersuites( void ) static int supported_ciphersuites[MAX_CIPHERSUITES]; static int supported_init = 0; +static int ciphersuite_is_removed( const mbedtls_ssl_ciphersuite_t *cs_info ) +{ + (void)cs_info; + +#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES) + if( cs_info->cipher == MBEDTLS_CIPHER_ARC4_128 ) + return( 1 ); +#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */ + +#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES) + if( cs_info->cipher == MBEDTLS_CIPHER_DES_EDE3_ECB || + cs_info->cipher == MBEDTLS_CIPHER_DES_EDE3_CBC ) + { + return( 1 ); + } +#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */ + + return( 0 ); +} + const int *mbedtls_ssl_list_ciphersuites( void ) { /* @@ -1719,14 +2217,12 @@ const int *mbedtls_ssl_list_ciphersuites( void ) *p != 0 && q < supported_ciphersuites + MAX_CIPHERSUITES - 1; p++ ) { -#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES) const mbedtls_ssl_ciphersuite_t *cs_info; if( ( cs_info = mbedtls_ssl_ciphersuite_from_id( *p ) ) != NULL && - cs_info->cipher != MBEDTLS_CIPHER_ARC4_128 ) -#else - if( mbedtls_ssl_ciphersuite_from_id( *p ) != NULL ) -#endif + !ciphersuite_is_removed( cs_info ) ) + { *(q++) = *p; + } } *q = 0; diff --git a/3rdparty/mbedtls/mbedtls/library/ssl_cli.c b/3rdparty/mbedtls/mbedtls/library/ssl_cli.c index 0d3623e613..afced7a99c 100644 --- a/3rdparty/mbedtls/mbedtls/library/ssl_cli.c +++ b/3rdparty/mbedtls/mbedtls/library/ssl_cli.c @@ -48,10 +48,7 @@ #endif #if defined(MBEDTLS_SSL_SESSION_TICKETS) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +#include "mbedtls/platform_util.h" #endif #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) @@ -60,7 +57,7 @@ static void ssl_write_hostname_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; size_t hostname_len; *olen = 0; @@ -130,7 +127,7 @@ static void ssl_write_renegotiation_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; *olen = 0; @@ -174,7 +171,7 @@ static void ssl_write_signature_algorithms_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; size_t sig_alg_len = 0; const int *md; #if defined(MBEDTLS_RSA_C) || defined(MBEDTLS_ECDSA_C) @@ -259,7 +256,7 @@ static void ssl_write_supported_elliptic_curves_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; unsigned char *elliptic_curve_list = p + 6; size_t elliptic_curve_len = 0; const mbedtls_ecp_curve_info *info; @@ -332,7 +329,7 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; *olen = 0; @@ -365,7 +362,7 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, { int ret; unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; size_t kkpp_len; *olen = 0; @@ -442,7 +439,7 @@ static void ssl_write_max_fragment_length_ext( mbedtls_ssl_context *ssl, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; *olen = 0; @@ -475,7 +472,7 @@ static void ssl_write_truncated_hmac_ext( mbedtls_ssl_context *ssl, unsigned char *buf, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; *olen = 0; @@ -507,7 +504,7 @@ static void ssl_write_encrypt_then_mac_ext( mbedtls_ssl_context *ssl, unsigned char *buf, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; *olen = 0; @@ -541,7 +538,7 @@ static void ssl_write_extended_ms_ext( mbedtls_ssl_context *ssl, unsigned char *buf, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; *olen = 0; @@ -575,7 +572,7 @@ static void ssl_write_session_ticket_ext( mbedtls_ssl_context *ssl, unsigned char *buf, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; size_t tlen = ssl->session_negotiate->ticket_len; *olen = 0; @@ -619,7 +616,7 @@ static void ssl_write_alpn_ext( mbedtls_ssl_context *ssl, unsigned char *buf, size_t *olen ) { unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; size_t alpnlen = 0; const char **cur; @@ -1091,12 +1088,21 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl ) mbedtls_ssl_send_flight_completed( ssl ); #endif - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flight_transmit", ret ); + return( ret ); + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write client hello" ) ); return( 0 ); @@ -1494,7 +1500,7 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) buf = ssl->in_msg; - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { /* No alert on a read error. */ MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); @@ -1757,6 +1763,14 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen ciphersuite: %s", suite_info->name ) ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( suite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA && + ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) + { + ssl->handshake->ecrs_enabled = 1; + } +#endif + if( comp != MBEDTLS_SSL_COMPRESS_NULL #if defined(MBEDTLS_ZLIB_SUPPORT) && comp != MBEDTLS_SSL_COMPRESS_DEFLATE @@ -2013,8 +2027,14 @@ static int ssl_parse_server_dh_params( mbedtls_ssl_context *ssl, unsigned char * static int ssl_check_server_ecdh_params( const mbedtls_ssl_context *ssl ) { const mbedtls_ecp_curve_info *curve_info; + mbedtls_ecp_group_id grp_id; +#if defined(MBEDTLS_ECDH_LEGACY_CONTEXT) + grp_id = ssl->handshake->ecdh_ctx.grp.id; +#else + grp_id = ssl->handshake->ecdh_ctx.grp_id; +#endif - curve_info = mbedtls_ecp_curve_info_from_grp_id( ssl->handshake->ecdh_ctx.grp.id ); + curve_info = mbedtls_ecp_curve_info_from_grp_id( grp_id ); if( curve_info == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); @@ -2024,14 +2044,15 @@ static int ssl_check_server_ecdh_params( const mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDH curve: %s", curve_info->name ) ); #if defined(MBEDTLS_ECP_C) - if( mbedtls_ssl_check_curve( ssl, ssl->handshake->ecdh_ctx.grp.id ) != 0 ) + if( mbedtls_ssl_check_curve( ssl, grp_id ) != 0 ) #else if( ssl->handshake->ecdh_ctx.grp.nbits < 163 || ssl->handshake->ecdh_ctx.grp.nbits > 521 ) #endif return( -1 ); - MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp", &ssl->handshake->ecdh_ctx.Qp ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_QP ); return( 0 ); } @@ -2062,6 +2083,10 @@ static int ssl_parse_server_ecdh_params( mbedtls_ssl_context *ssl, (const unsigned char **) p, end ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ecdh_read_params" ), ret ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS; +#endif return( ret ); } @@ -2132,7 +2157,7 @@ static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl, size_t len_bytes = ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 ? 0 : 2; unsigned char *p = ssl->handshake->premaster + pms_offset; - if( offset + len_bytes > MBEDTLS_SSL_MAX_CONTENT_LEN ) + if( offset + len_bytes > MBEDTLS_SSL_OUT_CONTENT_LEN ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "buffer too small for encrypted pms" ) ); return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); @@ -2175,7 +2200,7 @@ static int ssl_write_encrypted_pms( mbedtls_ssl_context *ssl, if( ( ret = mbedtls_pk_encrypt( &ssl->session_negotiate->peer_cert->pk, p, ssl->handshake->pmslen, ssl->out_msg + offset + len_bytes, olen, - MBEDTLS_SSL_MAX_CONTENT_LEN - offset - len_bytes, + MBEDTLS_SSL_OUT_CONTENT_LEN - offset - len_bytes, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_rsa_pkcs1_encrypt", ret ); @@ -2343,7 +2368,15 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED || MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled && + ssl->handshake->ecrs_state == ssl_ecrs_ske_start_processing ) + { + goto start_processing; + } +#endif + + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -2380,6 +2413,12 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); } +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled ) + ssl->handshake->ecrs_state = ssl_ecrs_ske_start_processing; + +start_processing: +#endif p = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); end = ssl->in_msg + ssl->in_hslen; MBEDTLS_SSL_DEBUG_BUF( 3, "server key exchange", p, end - p ); @@ -2472,6 +2511,7 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) mbedtls_pk_type_t pk_alg = MBEDTLS_PK_NONE; unsigned char *params = ssl->in_msg + mbedtls_ssl_hs_hdr_len( ssl ); size_t params_len = p - params; + void *rs_ctx = NULL; /* * Handle the digitally-signed structure @@ -2518,6 +2558,7 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) /* * Read signature */ + if( p > end - 2 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad server key exchange message" ) ); @@ -2558,10 +2599,9 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) defined(MBEDTLS_SSL_PROTO_TLS1_2) if( md_alg != MBEDTLS_MD_NONE ) { - /* Info from md_alg will be used instead */ - hashlen = 0; - ret = mbedtls_ssl_get_key_exchange_md_tls1_2( ssl, hash, params, - params_len, md_alg ); + ret = mbedtls_ssl_get_key_exchange_md_tls1_2( ssl, hash, &hashlen, + params, params_len, + md_alg ); if( ret != 0 ) return( ret ); } @@ -2573,8 +2613,7 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen : - (unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen ); if( ssl->session_negotiate->peer_cert == NULL ) { @@ -2595,12 +2634,25 @@ static int ssl_parse_server_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH ); } - if( ( ret = mbedtls_pk_verify( &ssl->session_negotiate->peer_cert->pk, - md_alg, hash, hashlen, p, sig_len ) ) != 0 ) +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled ) + rs_ctx = &ssl->handshake->ecrs_ctx.pk; +#endif + + if( ( ret = mbedtls_pk_verify_restartable( + &ssl->session_negotiate->peer_cert->pk, + md_alg, hash, hashlen, p, sig_len, rs_ctx ) ) != 0 ) { - mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) +#endif + mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, + MBEDTLS_SSL_ALERT_MSG_DECRYPT_ERROR ); MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_verify", ret ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS; +#endif return( ret ); } } @@ -2651,7 +2703,7 @@ static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl ) return( 0 ); } - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -2803,7 +2855,7 @@ static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse server hello done" ) ); - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -2898,6 +2950,16 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) */ i = 4; +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled ) + { + if( ssl->handshake->ecrs_state == ssl_ecrs_cke_ecdh_calc_secret ) + goto ecdh_calc_secret; + + mbedtls_ecdh_enable_restart( &ssl->handshake->ecdh_ctx ); + } +#endif + ret = mbedtls_ecdh_make_public( &ssl->handshake->ecdh_ctx, &n, &ssl->out_msg[i], 1000, @@ -2905,11 +2967,27 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_make_public", ret ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS; +#endif return( ret ); } - MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q", &ssl->handshake->ecdh_ctx.Q ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Q ); + +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled ) + { + ssl->handshake->ecrs_n = n; + ssl->handshake->ecrs_state = ssl_ecrs_cke_ecdh_calc_secret; + } +ecdh_calc_secret: + if( ssl->handshake->ecrs_enabled ) + n = ssl->handshake->ecrs_n; +#endif if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, &ssl->handshake->pmslen, ssl->handshake->premaster, @@ -2917,10 +2995,15 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_calc_secret", ret ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS; +#endif return( ret ); } - MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z", &ssl->handshake->ecdh_ctx.z ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Z ); } else #endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || @@ -2942,7 +3025,7 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) i = 4; n = ssl->conf->psk_identity_len; - if( i + 2 + n > MBEDTLS_SSL_MAX_CONTENT_LEN ) + if( i + 2 + n > MBEDTLS_SSL_OUT_CONTENT_LEN ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "psk identity too long or " "SSL buffer too short" ) ); @@ -2978,7 +3061,7 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) */ n = ssl->handshake->dhm_ctx.len; - if( i + 2 + n > MBEDTLS_SSL_MAX_CONTENT_LEN ) + if( i + 2 + n > MBEDTLS_SSL_OUT_CONTENT_LEN ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "psk identity or DHM size too long" " or SSL buffer too short" ) ); @@ -3007,7 +3090,7 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) * ClientECDiffieHellmanPublic public; */ ret = mbedtls_ecdh_make_public( &ssl->handshake->ecdh_ctx, &n, - &ssl->out_msg[i], MBEDTLS_SSL_MAX_CONTENT_LEN - i, + &ssl->out_msg[i], MBEDTLS_SSL_OUT_CONTENT_LEN - i, ssl->conf->f_rng, ssl->conf->p_rng ); if( ret != 0 ) { @@ -3015,7 +3098,8 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) return( ret ); } - MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q", &ssl->handshake->ecdh_ctx.Q ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Q ); } else #endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ @@ -3048,7 +3132,7 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) i = 4; ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx, - ssl->out_msg + i, MBEDTLS_SSL_MAX_CONTENT_LEN - i, &n, + ssl->out_msg + i, MBEDTLS_SSL_OUT_CONTENT_LEN - i, &n, ssl->conf->f_rng, ssl->conf->p_rng ); if( ret != 0 ) { @@ -3079,9 +3163,9 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl ) ssl->state++; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } @@ -3135,9 +3219,18 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl ) unsigned char *hash_start = hash; mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE; unsigned int hashlen; + void *rs_ctx = NULL; MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write certificate verify" ) ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled && + ssl->handshake->ecrs_state == ssl_ecrs_crt_vrfy_sign ) + { + goto sign; + } +#endif + if( ( ret = mbedtls_ssl_derive_keys( ssl ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_derive_keys", ret ); @@ -3169,8 +3262,15 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl ) } /* - * Make an RSA signature of the handshake digests + * Make a signature of the handshake digests */ +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled ) + ssl->handshake->ecrs_state = ssl_ecrs_crt_vrfy_sign; + +sign: +#endif + ssl->handshake->calc_verify( ssl, hash ); #if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ @@ -3247,11 +3347,21 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash_start, hashlen, +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled ) + rs_ctx = &ssl->handshake->ecrs_ctx.pk; +#endif + + if( ( ret = mbedtls_pk_sign_restartable( mbedtls_ssl_own_key( ssl ), + md_alg, hash_start, hashlen, ssl->out_msg + 6 + offset, &n, - ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + ssl->conf->f_rng, ssl->conf->p_rng, rs_ctx ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_sign", ret ); +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + ret = MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS; +#endif return( ret ); } @@ -3264,9 +3374,9 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl ) ssl->state++; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } @@ -3292,7 +3402,7 @@ static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse new session ticket" ) ); - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -3353,8 +3463,8 @@ static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl ) if( ticket_len == 0 ) return( 0 ); - mbedtls_zeroize( ssl->session_negotiate->ticket, - ssl->session_negotiate->ticket_len ); + mbedtls_platform_zeroize( ssl->session_negotiate->ticket, + ssl->session_negotiate->ticket_len ); mbedtls_free( ssl->session_negotiate->ticket ); ssl->session_negotiate->ticket = NULL; ssl->session_negotiate->ticket_len = 0; @@ -3406,10 +3516,10 @@ int mbedtls_ssl_handshake_client_step( mbedtls_ssl_context *ssl ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) { - if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) return( ret ); } -#endif +#endif /* MBEDTLS_SSL_PROTO_DTLS */ /* Change state now, so that it is right in mbedtls_ssl_read_record(), used * by DTLS for dropping out-of-sequence ChangeCipherSpec records */ diff --git a/3rdparty/mbedtls/mbedtls/library/ssl_cookie.c b/3rdparty/mbedtls/mbedtls/library/ssl_cookie.c index caf119990d..56e9bdd2bf 100644 --- a/3rdparty/mbedtls/mbedtls/library/ssl_cookie.c +++ b/3rdparty/mbedtls/mbedtls/library/ssl_cookie.c @@ -40,14 +40,10 @@ #include "mbedtls/ssl_cookie.h" #include "mbedtls/ssl_internal.h" +#include "mbedtls/platform_util.h" #include -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * If DTLS is in use, then at least one of SHA-1, SHA-256, SHA-512 is * available. Try SHA-256 first, 512 wastes resources since we need to stay @@ -101,7 +97,7 @@ void mbedtls_ssl_cookie_free( mbedtls_ssl_cookie_ctx *ctx ) mbedtls_mutex_free( &ctx->mutex ); #endif - mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_cookie_ctx ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ssl_cookie_ctx ) ); } int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, @@ -122,7 +118,7 @@ int mbedtls_ssl_cookie_setup( mbedtls_ssl_cookie_ctx *ctx, if( ret != 0 ) return( ret ); - mbedtls_zeroize( key, sizeof( key ) ); + mbedtls_platform_zeroize( key, sizeof( key ) ); return( 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/library/ssl_srv.c b/3rdparty/mbedtls/mbedtls/library/ssl_srv.c index c8da871cd7..bc77f80203 100644 --- a/3rdparty/mbedtls/mbedtls/library/ssl_srv.c +++ b/3rdparty/mbedtls/mbedtls/library/ssl_srv.c @@ -38,6 +38,7 @@ #include "mbedtls/debug.h" #include "mbedtls/ssl.h" #include "mbedtls/ssl_internal.h" +#include "mbedtls/platform_util.h" #include @@ -49,13 +50,6 @@ #include "mbedtls/platform_time.h" #endif -#if defined(MBEDTLS_SSL_SESSION_TICKETS) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} -#endif - #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) int mbedtls_ssl_set_client_transport_id( mbedtls_ssl_context *ssl, const unsigned char *info, @@ -572,7 +566,7 @@ static int ssl_parse_session_ticket_ext( mbedtls_ssl_context *ssl, memcpy( ssl->session_negotiate, &session, sizeof( mbedtls_ssl_session ) ); /* Zeroize instead of free as we copied the content */ - mbedtls_zeroize( &session, sizeof( mbedtls_ssl_session ) ); + mbedtls_platform_zeroize( &session, sizeof( mbedtls_ssl_session ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "session successfully restored from ticket" ) ); @@ -734,7 +728,7 @@ static int ssl_pick_cert( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_CRT( 3, "candidate certificate chain, certificate", cur->cert ); - if( ! mbedtls_pk_can_do( cur->key, pk_alg ) ) + if( ! mbedtls_pk_can_do( &cur->cert->pk, pk_alg ) ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: key type" ) ); continue; @@ -758,7 +752,7 @@ static int ssl_pick_cert( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_ECDSA_C) if( pk_alg == MBEDTLS_PK_ECDSA && - ssl_check_key_curve( cur->key, ssl->handshake->curves ) != 0 ) + ssl_check_key_curve( &cur->cert->pk, ssl->handshake->curves ) != 0 ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "certificate mismatch: elliptic curve" ) ); continue; @@ -1300,7 +1294,7 @@ static int ssl_parse_client_hello( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); } - memcpy( ssl->out_ctr + 2, ssl->in_ctr + 2, 6 ); + memcpy( ssl->cur_out_ctr + 2, ssl->in_ctr + 2, 6 ); #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) if( mbedtls_ssl_dtls_replay_check( ssl ) != 0 ) @@ -1328,7 +1322,7 @@ static int ssl_parse_client_hello( mbedtls_ssl_context *ssl ) else #endif { - if( msg_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + if( msg_len > MBEDTLS_SSL_IN_CONTENT_LEN ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad client hello message" ) ); return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO ); @@ -2266,7 +2260,7 @@ static void ssl_write_ecjpake_kkpp_ext( mbedtls_ssl_context *ssl, { int ret; unsigned char *p = buf; - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; size_t kkpp_len; *olen = 0; @@ -2373,7 +2367,7 @@ static int ssl_write_hello_verify_request( mbedtls_ssl_context *ssl ) cookie_len_byte = p++; if( ( ret = ssl->conf->f_cookie_write( ssl->conf->p_cookie, - &p, ssl->out_buf + MBEDTLS_SSL_BUFFER_LEN, + &p, ssl->out_buf + MBEDTLS_SSL_OUT_BUFFER_LEN, ssl->cli_id, ssl->cli_id_len ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "f_cookie_write", ret ); @@ -2390,11 +2384,20 @@ static int ssl_write_hello_verify_request( mbedtls_ssl_context *ssl ) ssl->state = MBEDTLS_SSL_SERVER_HELLO_VERIFY_REQUEST_SENT; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); + return( ret ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flight_transmit", ret ); return( ret ); } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write hello verify request" ) ); @@ -2630,7 +2633,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl ) ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_HELLO; - ret = mbedtls_ssl_write_record( ssl ); + ret = mbedtls_ssl_write_handshake_msg( ssl ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello" ) ); @@ -2673,7 +2676,7 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) size_t dn_size, total_dn_size; /* excluding length bytes */ size_t ct_len, sa_len; /* including length bytes */ unsigned char *buf, *p; - const unsigned char * const end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + const unsigned char * const end = ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN; const mbedtls_x509_crt *crt; int authmode; @@ -2825,7 +2828,7 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl ) ssl->out_msg[4 + ct_len + sa_len] = (unsigned char)( total_dn_size >> 8 ); ssl->out_msg[5 + ct_len + sa_len] = (unsigned char)( total_dn_size ); - ret = mbedtls_ssl_write_record( ssl ); + ret = mbedtls_ssl_write_handshake_msg( ssl ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write certificate request" ) ); @@ -2863,54 +2866,56 @@ static int ssl_get_ecdh_params_from_cert( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ -static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) && \ + defined(MBEDTLS_SSL_ASYNC_PRIVATE) +static int ssl_resume_server_key_exchange( mbedtls_ssl_context *ssl, + size_t *signature_len ) +{ + /* Append the signature to ssl->out_msg, leaving 2 bytes for the + * signature length which will be added in ssl_write_server_key_exchange + * after the call to ssl_prepare_server_key_exchange. + * ssl_write_server_key_exchange also takes care of incrementing + * ssl->out_msglen. */ + unsigned char *sig_start = ssl->out_msg + ssl->out_msglen + 2; + size_t sig_max_len = ( ssl->out_buf + MBEDTLS_SSL_OUT_CONTENT_LEN + - sig_start ); + int ret = ssl->conf->f_async_resume( ssl, + sig_start, signature_len, sig_max_len ); + if( ret != MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ) + { + ssl->handshake->async_in_progress = 0; + mbedtls_ssl_set_async_operation_data( ssl, NULL ); + } + MBEDTLS_SSL_DEBUG_RET( 2, "ssl_resume_server_key_exchange", ret ); + return( ret ); +} +#endif /* defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) && + defined(MBEDTLS_SSL_ASYNC_PRIVATE) */ + +/* Prepare the ServerKeyExchange message, up to and including + * calculating the signature if any, but excluding formatting the + * signature and sending the message. */ +static int ssl_prepare_server_key_exchange( mbedtls_ssl_context *ssl, + size_t *signature_len ) { - int ret; - size_t n = 0; const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; - #if defined(MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED) - unsigned char *p = ssl->out_msg + 4; - size_t len = 0; #if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) - unsigned char *dig_signed = p; - size_t dig_signed_len = 0; + unsigned char *dig_signed = NULL; #endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */ #endif /* MBEDTLS_KEY_EXCHANGE__SOME_PFS__ENABLED */ - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) ); - - /* - * - * Part 1: Extract static ECDH parameters and abort - * if ServerKeyExchange not needed. - * - */ - - /* For suites involving ECDH, extract DH parameters - * from certificate at this point. */ -#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED) - if( mbedtls_ssl_ciphersuite_uses_ecdh( ciphersuite_info ) ) - { - ssl_get_ecdh_params_from_cert( ssl ); - } -#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED */ + (void) ciphersuite_info; /* unused in some configurations */ +#if !defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) + (void) signature_len; +#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */ - /* Key exchanges not involving ephemeral keys don't use - * ServerKeyExchange, so end here. */ -#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED) - if( mbedtls_ssl_ciphersuite_no_pfs( ciphersuite_info ) ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); - ssl->state++; - return( 0 ); - } -#endif /* MBEDTLS_KEY_EXCHANGE__NON_PFS__ENABLED */ + ssl->out_msglen = 4; /* header (type:1, length:3) to be written later */ /* * - * Part 2: Provide key exchange parameters for chosen ciphersuite. + * Part 1: Provide key exchange parameters for chosen ciphersuite. * */ @@ -2920,18 +2925,21 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) { - const unsigned char *end = ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN; + int ret; + size_t len = 0; - ret = mbedtls_ecjpake_write_round_two( &ssl->handshake->ecjpake_ctx, - p, end - p, &len, ssl->conf->f_rng, ssl->conf->p_rng ); + ret = mbedtls_ecjpake_write_round_two( + &ssl->handshake->ecjpake_ctx, + ssl->out_msg + ssl->out_msglen, + MBEDTLS_SSL_OUT_CONTENT_LEN - ssl->out_msglen, &len, + ssl->conf->f_rng, ssl->conf->p_rng ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecjpake_write_round_two", ret ); return( ret ); } - p += len; - n += len; + ssl->out_msglen += len; } #endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ @@ -2945,10 +2953,8 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK ) { - *(p++) = 0x00; - *(p++) = 0x00; - - n += 2; + ssl->out_msg[ssl->out_msglen++] = 0x00; + ssl->out_msg[ssl->out_msglen++] = 0x00; } #endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED || MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ @@ -2959,6 +2965,9 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_KEY_EXCHANGE__SOME__DHE_ENABLED) if( mbedtls_ssl_ciphersuite_uses_dhe( ciphersuite_info ) ) { + int ret; + size_t len = 0; + if( ssl->conf->dhm_P.p == NULL || ssl->conf->dhm_G.p == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "no DH parameters set" ) ); @@ -2982,21 +2991,21 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) return( ret ); } - if( ( ret = mbedtls_dhm_make_params( &ssl->handshake->dhm_ctx, - (int) mbedtls_mpi_size( &ssl->handshake->dhm_ctx.P ), - p, &len, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + if( ( ret = mbedtls_dhm_make_params( + &ssl->handshake->dhm_ctx, + (int) mbedtls_mpi_size( &ssl->handshake->dhm_ctx.P ), + ssl->out_msg + ssl->out_msglen, &len, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_dhm_make_params", ret ); return( ret ); } #if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) - dig_signed = p; - dig_signed_len = len; + dig_signed = ssl->out_msg + ssl->out_msglen; #endif - p += len; - n += len; + ssl->out_msglen += len; MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: X ", &ssl->handshake->dhm_ctx.X ); MBEDTLS_SSL_DEBUG_MPI( 3, "DHM: P ", &ssl->handshake->dhm_ctx.P ); @@ -3021,6 +3030,8 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) */ const mbedtls_ecp_curve_info **curve = NULL; const mbedtls_ecp_group_id *gid; + int ret; + size_t len = 0; /* Match our preference list against the offered curves */ for( gid = ssl->conf->curve_list; *gid != MBEDTLS_ECP_DP_NONE; gid++ ) @@ -3037,48 +3048,50 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "ECDHE curve: %s", (*curve)->name ) ); - if( ( ret = mbedtls_ecp_group_load( &ssl->handshake->ecdh_ctx.grp, - (*curve)->grp_id ) ) != 0 ) + if( ( ret = mbedtls_ecdh_setup( &ssl->handshake->ecdh_ctx, + (*curve)->grp_id ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecp_group_load", ret ); return( ret ); } - if( ( ret = mbedtls_ecdh_make_params( &ssl->handshake->ecdh_ctx, &len, - p, MBEDTLS_SSL_MAX_CONTENT_LEN - n, - ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) + if( ( ret = mbedtls_ecdh_make_params( + &ssl->handshake->ecdh_ctx, &len, + ssl->out_msg + ssl->out_msglen, + MBEDTLS_SSL_OUT_CONTENT_LEN - ssl->out_msglen, + ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ecdh_make_params", ret ); return( ret ); } #if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) - dig_signed = p; - dig_signed_len = len; + dig_signed = ssl->out_msg + ssl->out_msglen; #endif - p += len; - n += len; + ssl->out_msglen += len; - MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Q ", &ssl->handshake->ecdh_ctx.Q ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Q ); } #endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDHE_ENABLED */ /* * - * Part 3: For key exchanges involving the server signing the + * Part 2: For key exchanges involving the server signing the * exchange parameters, compute and add the signature here. * */ #if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) if( mbedtls_ssl_ciphersuite_uses_server_signature( ciphersuite_info ) ) { - size_t signature_len = 0; - unsigned int hashlen = 0; - unsigned char hash[64]; + size_t dig_signed_len = ssl->out_msg + ssl->out_msglen - dig_signed; + size_t hashlen = 0; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + int ret; /* - * 3.1: Choose hash algorithm: + * 2.1: Choose hash algorithm: * A: For TLS 1.2, obey signature-hash-algorithm extension * to choose appropriate hash. * B: For SSL3, TLS1.0, TLS1.1 and ECDHE_ECDSA, use SHA1 @@ -3125,7 +3138,7 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 3, ( "pick hash algorithm %d for signing", md_alg ) ); /* - * 3.2: Compute the hash to be signed + * 2.2: Compute the hash to be signed */ #if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_1) @@ -3145,9 +3158,7 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) defined(MBEDTLS_SSL_PROTO_TLS1_2) if( md_alg != MBEDTLS_MD_NONE ) { - /* Info from md_alg will be used instead */ - hashlen = 0; - ret = mbedtls_ssl_get_key_exchange_md_tls1_2( ssl, hash, + ret = mbedtls_ssl_get_key_exchange_md_tls1_2( ssl, hash, &hashlen, dig_signed, dig_signed_len, md_alg ); @@ -3162,18 +3173,11 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen != 0 ? hashlen : - (unsigned int) ( mbedtls_md_get_size( mbedtls_md_info_from_type( md_alg ) ) ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "parameters hash", hash, hashlen ); /* - * 3.3: Compute and add the signature + * 2.3: Compute and add the signature */ - if( mbedtls_ssl_own_key( ssl ) == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no private key" ) ); - return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); - } - #if defined(MBEDTLS_SSL_PROTO_TLS1_2) if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_3 ) { @@ -3193,46 +3197,162 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) * */ - *(p++) = mbedtls_ssl_hash_from_md_alg( md_alg ); - *(p++) = mbedtls_ssl_sig_from_pk_alg( sig_alg ); - - n += 2; + ssl->out_msg[ssl->out_msglen++] = + mbedtls_ssl_hash_from_md_alg( md_alg ); + ssl->out_msg[ssl->out_msglen++] = + mbedtls_ssl_sig_from_pk_alg( sig_alg ); } #endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ - if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), md_alg, hash, hashlen, - p + 2 , &signature_len, ssl->conf->f_rng, ssl->conf->p_rng ) ) != 0 ) +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( ssl->conf->f_async_sign_start != NULL ) + { + ret = ssl->conf->f_async_sign_start( ssl, + mbedtls_ssl_own_cert( ssl ), + md_alg, hash, hashlen ); + switch( ret ) + { + case MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH: + /* act as if f_async_sign was null */ + break; + case 0: + ssl->handshake->async_in_progress = 1; + return( ssl_resume_server_key_exchange( ssl, signature_len ) ); + case MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS: + ssl->handshake->async_in_progress = 1; + return( MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ); + default: + MBEDTLS_SSL_DEBUG_RET( 1, "f_async_sign_start", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + + if( mbedtls_ssl_own_key( ssl ) == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no private key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + /* Append the signature to ssl->out_msg, leaving 2 bytes for the + * signature length which will be added in ssl_write_server_key_exchange + * after the call to ssl_prepare_server_key_exchange. + * ssl_write_server_key_exchange also takes care of incrementing + * ssl->out_msglen. */ + if( ( ret = mbedtls_pk_sign( mbedtls_ssl_own_key( ssl ), + md_alg, hash, hashlen, + ssl->out_msg + ssl->out_msglen + 2, + signature_len, + ssl->conf->f_rng, + ssl->conf->p_rng ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_pk_sign", ret ); return( ret ); } + } +#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */ + + return( 0 ); +} + +/* Prepare the ServerKeyExchange message and send it. For ciphersuites + * that do not include a ServerKeyExchange message, do nothing. Either + * way, if successful, move on to the next step in the SSL state + * machine. */ +static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) +{ + int ret; + size_t signature_len = 0; +#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED) + const mbedtls_ssl_ciphersuite_t *ciphersuite_info = + ssl->transform_negotiate->ciphersuite_info; +#endif /* MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED */ + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) ); + +#if defined(MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED) + /* Extract static ECDH parameters and abort if ServerKeyExchange + * is not needed. */ + if( mbedtls_ssl_ciphersuite_no_pfs( ciphersuite_info ) ) + { + /* For suites involving ECDH, extract DH parameters + * from certificate at this point. */ +#if defined(MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED) + if( mbedtls_ssl_ciphersuite_uses_ecdh( ciphersuite_info ) ) + { + ssl_get_ecdh_params_from_cert( ssl ); + } +#endif /* MBEDTLS_KEY_EXCHANGE__SOME__ECDH_ENABLED */ - *(p++) = (unsigned char)( signature_len >> 8 ); - *(p++) = (unsigned char)( signature_len ); - n += 2; + /* Key exchanges not involving ephemeral keys don't use + * ServerKeyExchange, so end here. */ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip write server key exchange" ) ); + ssl->state++; + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE__SOME_NON_PFS__ENABLED */ - MBEDTLS_SSL_DEBUG_BUF( 3, "my signature", p, signature_len ); +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) && \ + defined(MBEDTLS_SSL_ASYNC_PRIVATE) + /* If we have already prepared the message and there is an ongoing + * signature operation, resume signing. */ + if( ssl->handshake->async_in_progress != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "resuming signature operation" ) ); + ret = ssl_resume_server_key_exchange( ssl, &signature_len ); + } + else +#endif /* defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) && + defined(MBEDTLS_SSL_ASYNC_PRIVATE) */ + { + /* ServerKeyExchange is needed. Prepare the message. */ + ret = ssl_prepare_server_key_exchange( ssl, &signature_len ); + } - n += signature_len; + if( ret != 0 ) + { + /* If we're starting to write a new message, set ssl->out_msglen + * to 0. But if we're resuming after an asynchronous message, + * out_msglen is the amount of data written so far and mst be + * preserved. */ + if( ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ) + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server key exchange (pending)" ) ); + else + ssl->out_msglen = 0; + return( ret ); } -#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */ - /* Done with actual work; add header and send. */ + /* If there is a signature, write its length. + * ssl_prepare_server_key_exchange already wrote the signature + * itself at its proper place in the output buffer. */ +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) + if( signature_len != 0 ) + { + ssl->out_msg[ssl->out_msglen++] = (unsigned char)( signature_len >> 8 ); + ssl->out_msg[ssl->out_msglen++] = (unsigned char)( signature_len ); - ssl->out_msglen = 4 + n; + MBEDTLS_SSL_DEBUG_BUF( 3, "my signature", + ssl->out_msg + ssl->out_msglen, + signature_len ); + + /* Skip over the already-written signature */ + ssl->out_msglen += signature_len; + } +#endif /* MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED */ + + /* Add header and send. */ ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_SERVER_KEY_EXCHANGE; ssl->state++; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server key exchange" ) ); - return( 0 ); } @@ -3253,12 +3373,21 @@ static int ssl_write_server_hello_done( mbedtls_ssl_context *ssl ) mbedtls_ssl_send_flight_completed( ssl ); #endif - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flight_transmit", ret ); + return( ret ); + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write server hello done" ) ); return( 0 ); @@ -3307,28 +3436,50 @@ static int ssl_parse_client_dh_public( mbedtls_ssl_context *ssl, unsigned char * #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) -static int ssl_parse_encrypted_pms( mbedtls_ssl_context *ssl, - const unsigned char *p, - const unsigned char *end, - size_t pms_offset ) + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +static int ssl_resume_decrypt_pms( mbedtls_ssl_context *ssl, + unsigned char *peer_pms, + size_t *peer_pmslen, + size_t peer_pmssize ) +{ + int ret = ssl->conf->f_async_resume( ssl, + peer_pms, peer_pmslen, peer_pmssize ); + if( ret != MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ) + { + ssl->handshake->async_in_progress = 0; + mbedtls_ssl_set_async_operation_data( ssl, NULL ); + } + MBEDTLS_SSL_DEBUG_RET( 2, "ssl_decrypt_encrypted_pms", ret ); + return( ret ); +} +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + +static int ssl_decrypt_encrypted_pms( mbedtls_ssl_context *ssl, + const unsigned char *p, + const unsigned char *end, + unsigned char *peer_pms, + size_t *peer_pmslen, + size_t peer_pmssize ) { int ret; - size_t len = mbedtls_pk_get_len( mbedtls_ssl_own_key( ssl ) ); - unsigned char *pms = ssl->handshake->premaster + pms_offset; - unsigned char ver[2]; - unsigned char fake_pms[48], peer_pms[48]; - unsigned char mask; - size_t i, peer_pmslen; - unsigned int diff; + mbedtls_pk_context *private_key = mbedtls_ssl_own_key( ssl ); + mbedtls_pk_context *public_key = &mbedtls_ssl_own_cert( ssl )->pk; + size_t len = mbedtls_pk_get_len( public_key ); - if( ! mbedtls_pk_can_do( mbedtls_ssl_own_key( ssl ), MBEDTLS_PK_RSA ) ) +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + /* If we have already started decoding the message and there is an ongoing + * decryption operation, resume signing. */ + if( ssl->handshake->async_in_progress != 0 ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no RSA private key" ) ); - return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "resuming decryption operation" ) ); + return( ssl_resume_decrypt_pms( ssl, + peer_pms, peer_pmslen, peer_pmssize ) ); } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ /* - * Decrypt the premaster using own private RSA key + * Prepare to decrypt the premaster using own private RSA key */ #if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_2) @@ -3353,30 +3504,120 @@ static int ssl_parse_encrypted_pms( mbedtls_ssl_context *ssl, return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE ); } + /* + * Decrypt the premaster secret + */ +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( ssl->conf->f_async_decrypt_start != NULL ) + { + ret = ssl->conf->f_async_decrypt_start( ssl, + mbedtls_ssl_own_cert( ssl ), + p, len ); + switch( ret ) + { + case MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH: + /* act as if f_async_decrypt_start was null */ + break; + case 0: + ssl->handshake->async_in_progress = 1; + return( ssl_resume_decrypt_pms( ssl, + peer_pms, + peer_pmslen, + peer_pmssize ) ); + case MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS: + ssl->handshake->async_in_progress = 1; + return( MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ); + default: + MBEDTLS_SSL_DEBUG_RET( 1, "f_async_decrypt_start", ret ); + return( ret ); + } + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + + if( ! mbedtls_pk_can_do( private_key, MBEDTLS_PK_RSA ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "got no RSA private key" ) ); + return( MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED ); + } + + ret = mbedtls_pk_decrypt( private_key, p, len, + peer_pms, peer_pmslen, peer_pmssize, + ssl->conf->f_rng, ssl->conf->p_rng ); + return( ret ); +} + +static int ssl_parse_encrypted_pms( mbedtls_ssl_context *ssl, + const unsigned char *p, + const unsigned char *end, + size_t pms_offset ) +{ + int ret; + unsigned char *pms = ssl->handshake->premaster + pms_offset; + unsigned char ver[2]; + unsigned char fake_pms[48], peer_pms[48]; + unsigned char mask; + size_t i, peer_pmslen; + unsigned int diff; + + /* In case of a failure in decryption, the decryption may write less than + * 2 bytes of output, but we always read the first two bytes. It doesn't + * matter in the end because diff will be nonzero in that case due to + * peer_pmslen being less than 48, and we only care whether diff is 0. + * But do initialize peer_pms for robustness anyway. This also makes + * memory analyzers happy (don't access uninitialized memory, even + * if it's an unsigned char). */ + peer_pms[0] = peer_pms[1] = ~0; + + ret = ssl_decrypt_encrypted_pms( ssl, p, end, + peer_pms, + &peer_pmslen, + sizeof( peer_pms ) ); + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if ( ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ) + return( ret ); +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + mbedtls_ssl_write_version( ssl->handshake->max_major_ver, - ssl->handshake->max_minor_ver, - ssl->conf->transport, ver ); + ssl->handshake->max_minor_ver, + ssl->conf->transport, ver ); + + /* Avoid data-dependent branches while checking for invalid + * padding, to protect against timing-based Bleichenbacher-type + * attacks. */ + diff = (unsigned int) ret; + diff |= peer_pmslen ^ 48; + diff |= peer_pms[0] ^ ver[0]; + diff |= peer_pms[1] ^ ver[1]; + + /* mask = diff ? 0xff : 0x00 using bit operations to avoid branches */ + /* MSVC has a warning about unary minus on unsigned, but this is + * well-defined and precisely what we want to do here */ +#if defined(_MSC_VER) +#pragma warning( push ) +#pragma warning( disable : 4146 ) +#endif + mask = - ( ( diff | - diff ) >> ( sizeof( unsigned int ) * 8 - 1 ) ); +#if defined(_MSC_VER) +#pragma warning( pop ) +#endif /* * Protection against Bleichenbacher's attack: invalid PKCS#1 v1.5 padding * must not cause the connection to end immediately; instead, send a * bad_record_mac later in the handshake. - * Also, avoid data-dependant branches here to protect against - * timing-based variants. + * To protect against timing-based variants of the attack, we must + * not have any branch that depends on whether the decryption was + * successful. In particular, always generate the fake premaster secret, + * regardless of whether it will ultimately influence the output or not. */ ret = ssl->conf->f_rng( ssl->conf->p_rng, fake_pms, sizeof( fake_pms ) ); if( ret != 0 ) + { + /* It's ok to abort on an RNG failure, since this does not reveal + * anything about the RSA decryption. */ return( ret ); - - ret = mbedtls_pk_decrypt( mbedtls_ssl_own_key( ssl ), p, len, - peer_pms, &peer_pmslen, - sizeof( peer_pms ), - ssl->conf->f_rng, ssl->conf->p_rng ); - - diff = (unsigned int) ret; - diff |= peer_pmslen ^ 48; - diff |= peer_pms[0] ^ ver[0]; - diff |= peer_pms[1] ^ ver[1]; + } #if defined(MBEDTLS_SSL_DEBUG_ALL) if( diff != 0 ) @@ -3391,18 +3632,8 @@ static int ssl_parse_encrypted_pms( mbedtls_ssl_context *ssl, } ssl->handshake->pmslen = 48; - /* mask = diff ? 0xff : 0x00 using bit operations to avoid branches */ - /* MSVC has a warning about unary minus on unsigned, but this is - * well-defined and precisely what we want to do here */ -#if defined(_MSC_VER) -#pragma warning( push ) -#pragma warning( disable : 4146 ) -#endif - mask = - ( ( diff | - diff ) >> ( sizeof( unsigned int ) * 8 - 1 ) ); -#if defined(_MSC_VER) -#pragma warning( pop ) -#endif - + /* Set pms to either the true or the fake PMS, without + * data-dependent branches. */ for( i = 0; i < ssl->handshake->pmslen; i++ ) pms[i] = ( mask & fake_pms[i] ) | ( (~mask) & peer_pms[i] ); @@ -3484,7 +3715,21 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse client key exchange" ) ); - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) && \ + ( defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) || \ + defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) ) + if( ( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA ) && + ( ssl->handshake->async_in_progress != 0 ) ) + { + /* We've already read a record and there is an asynchronous + * operation in progress to decrypt it. So skip reading the + * record. */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "will resume decryption of previously-read record" ) ); + } + else +#endif + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -3550,7 +3795,8 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); } - MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp ", &ssl->handshake->ecdh_ctx.Qp ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_QP ); if( ( ret = mbedtls_ecdh_calc_secret( &ssl->handshake->ecdh_ctx, &ssl->handshake->pmslen, @@ -3562,7 +3808,8 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS ); } - MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z ", &ssl->handshake->ecdh_ctx.z ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Z ); } else #endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED || @@ -3596,6 +3843,19 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) { +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if ( ssl->handshake->async_in_progress != 0 ) + { + /* There is an asynchronous operation in progress to + * decrypt the encrypted premaster secret, so skip + * directly to resuming this operation. */ + MBEDTLS_SSL_DEBUG_MSG( 3, ( "PSK identity already parsed" ) ); + /* Update p to skip the PSK identity. ssl_parse_encrypted_pms + * won't actually use it, but maintain p anyway for robustness. */ + p += ssl->conf->psk_identity_len + 2; + } + else +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ if( ( ret = ssl_parse_client_psk_identity( ssl, &p, end ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_parse_client_psk_identity" ), ret ); @@ -3662,7 +3922,8 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP ); } - MBEDTLS_SSL_DEBUG_ECP( 3, "ECDH: Qp ", &ssl->handshake->ecdh_ctx.Qp ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_QP ); if( ( ret = mbedtls_ssl_psk_derive_premaster( ssl, ciphersuite_info->key_exchange ) ) != 0 ) @@ -3781,21 +4042,10 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl ) } /* Read the message without adding it to the checksum */ - do { - - if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret ); - return( ret ); - } - - ret = mbedtls_ssl_handle_message_type( ssl ); - - } while( MBEDTLS_ERR_SSL_NON_FATAL == ret ); - + ret = mbedtls_ssl_read_record( ssl, 0 /* no checksum update */ ); if( 0 != ret ) { - MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_handle_message_type" ), ret ); + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record" ), ret ); return( ret ); } @@ -3961,7 +4211,7 @@ static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) if( ( ret = ssl->conf->f_ticket_write( ssl->conf->p_ticket, ssl->session_negotiate, ssl->out_msg + 10, - ssl->out_msg + MBEDTLS_SSL_MAX_CONTENT_LEN, + ssl->out_msg + MBEDTLS_SSL_OUT_CONTENT_LEN, &tlen, &lifetime ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_ticket_write", ret ); @@ -3984,9 +4234,9 @@ static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl ) */ ssl->handshake->new_session_ticket = 0; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } @@ -4015,10 +4265,10 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) { - if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) return( ret ); } -#endif +#endif /* MBEDTLS_SSL_PROTO_DTLS */ switch( ssl->state ) { diff --git a/3rdparty/mbedtls/mbedtls/library/ssl_ticket.c b/3rdparty/mbedtls/mbedtls/library/ssl_ticket.c index 555c7b63bf..8492c19a8c 100644 --- a/3rdparty/mbedtls/mbedtls/library/ssl_ticket.c +++ b/3rdparty/mbedtls/mbedtls/library/ssl_ticket.c @@ -36,14 +36,10 @@ #endif #include "mbedtls/ssl_ticket.h" +#include "mbedtls/platform_util.h" #include -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * Initialze context */ @@ -83,7 +79,7 @@ static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx, mbedtls_cipher_get_key_bitlen( &key->ctx ), MBEDTLS_ENCRYPT ); - mbedtls_zeroize( buf, sizeof( buf ) ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); return( ret ); } @@ -483,7 +479,7 @@ void mbedtls_ssl_ticket_free( mbedtls_ssl_ticket_context *ctx ) mbedtls_mutex_free( &ctx->mutex ); #endif - mbedtls_zeroize( ctx, sizeof( mbedtls_ssl_ticket_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_ssl_ticket_context ) ); } #endif /* MBEDTLS_SSL_TICKET_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/ssl_tls.c b/3rdparty/mbedtls/mbedtls/library/ssl_tls.c index 6956b5f31b..38690fa664 100644 --- a/3rdparty/mbedtls/mbedtls/library/ssl_tls.c +++ b/3rdparty/mbedtls/mbedtls/library/ssl_tls.c @@ -46,6 +46,7 @@ #include "mbedtls/debug.h" #include "mbedtls/ssl.h" #include "mbedtls/ssl_internal.h" +#include "mbedtls/platform_util.h" #include @@ -53,10 +54,8 @@ #include "mbedtls/oid.h" #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +static void ssl_reset_in_out_pointers( mbedtls_ssl_context *ssl ); +static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl ); /* Length of the "epoch" field in the record header */ static inline size_t ssl_ep_len( const mbedtls_ssl_context *ssl ) @@ -100,7 +99,101 @@ static int ssl_check_timer( mbedtls_ssl_context *ssl ) return( 0 ); } +static void ssl_update_out_pointers( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ); +static void ssl_update_in_pointers( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ); + +#define SSL_DONT_FORCE_FLUSH 0 +#define SSL_FORCE_FLUSH 1 + #if defined(MBEDTLS_SSL_PROTO_DTLS) + +/* Forward declarations for functions related to message buffering. */ +static void ssl_buffering_free( mbedtls_ssl_context *ssl ); +static void ssl_buffering_free_slot( mbedtls_ssl_context *ssl, + uint8_t slot ); +static void ssl_free_buffered_record( mbedtls_ssl_context *ssl ); +static int ssl_load_buffered_message( mbedtls_ssl_context *ssl ); +static int ssl_load_buffered_record( mbedtls_ssl_context *ssl ); +static int ssl_buffer_message( mbedtls_ssl_context *ssl ); +static int ssl_buffer_future_record( mbedtls_ssl_context *ssl ); +static int ssl_next_record_is_in_datagram( mbedtls_ssl_context *ssl ); + +static size_t ssl_get_current_mtu( const mbedtls_ssl_context *ssl ); +static size_t ssl_get_maximum_datagram_size( mbedtls_ssl_context const *ssl ) +{ + size_t mtu = ssl_get_current_mtu( ssl ); + + if( mtu != 0 && mtu < MBEDTLS_SSL_OUT_BUFFER_LEN ) + return( mtu ); + + return( MBEDTLS_SSL_OUT_BUFFER_LEN ); +} + +static int ssl_get_remaining_space_in_datagram( mbedtls_ssl_context const *ssl ) +{ + size_t const bytes_written = ssl->out_left; + size_t const mtu = ssl_get_maximum_datagram_size( ssl ); + + /* Double-check that the write-index hasn't gone + * past what we can transmit in a single datagram. */ + if( bytes_written > mtu ) + { + /* Should never happen... */ + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + return( (int) ( mtu - bytes_written ) ); +} + +static int ssl_get_remaining_payload_in_datagram( mbedtls_ssl_context const *ssl ) +{ + int ret; + size_t remaining, expansion; + size_t max_len = MBEDTLS_SSL_OUT_CONTENT_LEN; + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + const size_t mfl = mbedtls_ssl_get_max_frag_len( ssl ); + + if( max_len > mfl ) + max_len = mfl; + + /* By the standard (RFC 6066 Sect. 4), the MFL extension + * only limits the maximum record payload size, so in theory + * we would be allowed to pack multiple records of payload size + * MFL into a single datagram. However, this would mean that there's + * no way to explicitly communicate MTU restrictions to the peer. + * + * The following reduction of max_len makes sure that we never + * write datagrams larger than MFL + Record Expansion Overhead. + */ + if( max_len <= ssl->out_left ) + return( 0 ); + + max_len -= ssl->out_left; +#endif + + ret = ssl_get_remaining_space_in_datagram( ssl ); + if( ret < 0 ) + return( ret ); + remaining = (size_t) ret; + + ret = mbedtls_ssl_get_record_expansion( ssl ); + if( ret < 0 ) + return( ret ); + expansion = (size_t) ret; + + if( remaining <= expansion ) + return( 0 ); + + remaining -= expansion; + if( remaining >= max_len ) + remaining = max_len; + + return( (int) remaining ); +} + /* * Double the retransmit timeout value, within the allowed range, * returning -1 if the maximum value has already been reached. @@ -112,6 +205,18 @@ static int ssl_double_retransmit_timeout( mbedtls_ssl_context *ssl ) if( ssl->handshake->retransmit_timeout >= ssl->conf->hs_timeout_max ) return( -1 ); + /* Implement the final paragraph of RFC 6347 section 4.1.1.1 + * in the following way: after the initial transmission and a first + * retransmission, back off to a temporary estimated MTU of 508 bytes. + * This value is guaranteed to be deliverable (if not guaranteed to be + * delivered) of any compliant IPv4 (and IPv6) network, and should work + * on most non-IP stacks too. */ + if( ssl->handshake->retransmit_timeout != ssl->conf->hs_timeout_min ) + { + ssl->handshake->mtu = 508; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "mtu autoreduction to %d bytes", ssl->handshake->mtu ) ); + } + new_timeout = 2 * ssl->handshake->retransmit_timeout; /* Avoid arithmetic overflow and range overflow */ @@ -145,14 +250,24 @@ static void ssl_reset_retransmit_timeout( mbedtls_ssl_context *ssl ) * } MaxFragmentLength; * and we add 0 -> extension unused */ -static unsigned int mfl_code_to_length[MBEDTLS_SSL_MAX_FRAG_LEN_INVALID] = +static unsigned int ssl_mfl_code_to_length( int mfl ) { - MBEDTLS_SSL_MAX_CONTENT_LEN, /* MBEDTLS_SSL_MAX_FRAG_LEN_NONE */ - 512, /* MBEDTLS_SSL_MAX_FRAG_LEN_512 */ - 1024, /* MBEDTLS_SSL_MAX_FRAG_LEN_1024 */ - 2048, /* MBEDTLS_SSL_MAX_FRAG_LEN_2048 */ - 4096, /* MBEDTLS_SSL_MAX_FRAG_LEN_4096 */ -}; + switch( mfl ) + { + case MBEDTLS_SSL_MAX_FRAG_LEN_NONE: + return ( MBEDTLS_TLS_EXT_ADV_CONTENT_LEN ); + case MBEDTLS_SSL_MAX_FRAG_LEN_512: + return 512; + case MBEDTLS_SSL_MAX_FRAG_LEN_1024: + return 1024; + case MBEDTLS_SSL_MAX_FRAG_LEN_2048: + return 2048; + case MBEDTLS_SSL_MAX_FRAG_LEN_4096: + return 4096; + default: + return ( MBEDTLS_TLS_EXT_ADV_CONTENT_LEN ); + } +} #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ #if defined(MBEDTLS_SSL_CLI_C) @@ -269,8 +384,8 @@ static int ssl3_prf( const unsigned char *secret, size_t slen, mbedtls_md5_free( &md5 ); mbedtls_sha1_free( &sha1 ); - mbedtls_zeroize( padding, sizeof( padding ) ); - mbedtls_zeroize( sha1sum, sizeof( sha1sum ) ); + mbedtls_platform_zeroize( padding, sizeof( padding ) ); + mbedtls_platform_zeroize( sha1sum, sizeof( sha1sum ) ); return( ret ); } @@ -367,8 +482,8 @@ static int tls1_prf( const unsigned char *secret, size_t slen, mbedtls_md_free( &md_ctx ); - mbedtls_zeroize( tmp, sizeof( tmp ) ); - mbedtls_zeroize( h_i, sizeof( h_i ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( h_i, sizeof( h_i ) ); return( 0 ); } @@ -432,8 +547,8 @@ static int tls_prf_generic( mbedtls_md_type_t md_type, mbedtls_md_free( &md_ctx ); - mbedtls_zeroize( tmp, sizeof( tmp ) ); - mbedtls_zeroize( h_i, sizeof( h_i ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( h_i, sizeof( h_i ) ); return( 0 ); } @@ -642,7 +757,8 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) return( ret ); } - mbedtls_zeroize( handshake->premaster, sizeof(handshake->premaster) ); + mbedtls_platform_zeroize( handshake->premaster, + sizeof(handshake->premaster) ); } else MBEDTLS_SSL_DEBUG_MSG( 3, ( "no premaster (session resumed)" ) ); @@ -653,7 +769,7 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) memcpy( tmp, handshake->randbytes, 64 ); memcpy( handshake->randbytes, tmp + 32, 32 ); memcpy( handshake->randbytes + 32, tmp, 32 ); - mbedtls_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); /* * SSLv3: @@ -681,7 +797,8 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_BUF( 4, "random bytes", handshake->randbytes, 64 ); MBEDTLS_SSL_DEBUG_BUF( 4, "key block", keyblk, 256 ); - mbedtls_zeroize( handshake->randbytes, sizeof( handshake->randbytes ) ); + mbedtls_platform_zeroize( handshake->randbytes, + sizeof( handshake->randbytes ) ); /* * Determine the appropriate key, IV and MAC length. @@ -690,18 +807,32 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) transform->keylen = cipher_info->key_bitlen / 8; if( cipher_info->mode == MBEDTLS_MODE_GCM || - cipher_info->mode == MBEDTLS_MODE_CCM ) + cipher_info->mode == MBEDTLS_MODE_CCM || + cipher_info->mode == MBEDTLS_MODE_CHACHAPOLY ) { + size_t taglen, explicit_ivlen; + transform->maclen = 0; mac_key_len = 0; + /* All modes haves 96-bit IVs; + * GCM and CCM has 4 implicit and 8 explicit bytes + * ChachaPoly has all 12 bytes implicit + */ transform->ivlen = 12; - transform->fixed_ivlen = 4; + if( cipher_info->mode == MBEDTLS_MODE_CHACHAPOLY ) + transform->fixed_ivlen = 12; + else + transform->fixed_ivlen = 4; + + /* All modes have 128-bit tags, except CCM_8 (ciphersuite flag) */ + taglen = transform->ciphersuite_info->flags & + MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16; - /* Minimum length is expicit IV + tag */ - transform->minlen = transform->ivlen - transform->fixed_ivlen - + ( transform->ciphersuite_info->flags & - MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16 ); + + /* Minimum length of encrypted record */ + explicit_ivlen = transform->ivlen - transform->fixed_ivlen; + transform->minlen = explicit_ivlen + taglen; } else { @@ -948,7 +1079,7 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) } #endif /* MBEDTLS_CIPHER_MODE_CBC */ - mbedtls_zeroize( keyblk, sizeof( keyblk ) ); + mbedtls_platform_zeroize( keyblk, sizeof( keyblk ) ); #if defined(MBEDTLS_ZLIB_SUPPORT) // Initialize compression @@ -958,11 +1089,11 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl ) if( ssl->compress_buf == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 3, ( "Allocating compression buffer" ) ); - ssl->compress_buf = mbedtls_calloc( 1, MBEDTLS_SSL_BUFFER_LEN ); + ssl->compress_buf = mbedtls_calloc( 1, MBEDTLS_SSL_COMPRESS_BUFFER_LEN ); if( ssl->compress_buf == NULL ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", - MBEDTLS_SSL_BUFFER_LEN ) ); + MBEDTLS_SSL_COMPRESS_BUFFER_LEN ) ); return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); } } @@ -1202,7 +1333,8 @@ int mbedtls_ssl_psk_derive_premaster( mbedtls_ssl_context *ssl, mbedtls_key_exch *(p++) = (unsigned char)( zlen ); p += zlen; - MBEDTLS_SSL_DEBUG_MPI( 3, "ECDH: z", &ssl->handshake->ecdh_ctx.z ); + MBEDTLS_SSL_DEBUG_ECDH( 3, &ssl->handshake->ecdh_ctx, + MBEDTLS_DEBUG_ECDH_Z ); } else #endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ @@ -1277,7 +1409,7 @@ static void ssl_mac( mbedtls_md_context_t *md_ctx, #if defined(MBEDTLS_ARC4_C) || defined(MBEDTLS_CIPHER_NULL_CIPHER) || \ ( defined(MBEDTLS_CIPHER_MODE_CBC) && \ - ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) ) + ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) || defined(MBEDTLS_ARIA_C)) ) #define SSL_SOME_MODES_USE_MAC #endif @@ -1323,14 +1455,6 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_BUF( 4, "before encrypt: output payload", ssl->out_msg, ssl->out_msglen ); - if( ssl->out_msglen > MBEDTLS_SSL_MAX_CONTENT_LEN ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "Record content %u too large, maximum %d", - (unsigned) ssl->out_msglen, - MBEDTLS_SSL_MAX_CONTENT_LEN ) ); - return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); - } - /* * Add MAC before if needed */ @@ -1420,17 +1544,26 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_ARC4_C || MBEDTLS_CIPHER_NULL_CIPHER */ -#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) +#if defined(MBEDTLS_GCM_C) || \ + defined(MBEDTLS_CCM_C) || \ + defined(MBEDTLS_CHACHAPOLY_C) if( mode == MBEDTLS_MODE_GCM || - mode == MBEDTLS_MODE_CCM ) + mode == MBEDTLS_MODE_CCM || + mode == MBEDTLS_MODE_CHACHAPOLY ) { int ret; size_t enc_msglen, olen; unsigned char *enc_msg; unsigned char add_data[13]; - unsigned char taglen = ssl->transform_out->ciphersuite_info->flags & + unsigned char iv[12]; + mbedtls_ssl_transform *transform = ssl->transform_out; + unsigned char taglen = transform->ciphersuite_info->flags & MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16; + size_t explicit_ivlen = transform->ivlen - transform->fixed_ivlen; + /* + * Prepare additional authenticated data + */ memcpy( add_data, ssl->out_ctr, 8 ); add_data[8] = ssl->out_msgtype; mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, @@ -1438,44 +1571,57 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) add_data[11] = ( ssl->out_msglen >> 8 ) & 0xFF; add_data[12] = ssl->out_msglen & 0xFF; - MBEDTLS_SSL_DEBUG_BUF( 4, "additional data used for AEAD", - add_data, 13 ); + MBEDTLS_SSL_DEBUG_BUF( 4, "additional data for AEAD", add_data, 13 ); /* * Generate IV */ - if( ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen != 8 ) + if( transform->ivlen == 12 && transform->fixed_ivlen == 4 ) + { + /* GCM and CCM: fixed || explicit (=seqnum) */ + memcpy( iv, transform->iv_enc, transform->fixed_ivlen ); + memcpy( iv + transform->fixed_ivlen, ssl->out_ctr, 8 ); + memcpy( ssl->out_iv, ssl->out_ctr, 8 ); + + } + else if( transform->ivlen == 12 && transform->fixed_ivlen == 12 ) + { + /* ChachaPoly: fixed XOR sequence number */ + unsigned char i; + + memcpy( iv, transform->iv_enc, transform->fixed_ivlen ); + + for( i = 0; i < 8; i++ ) + iv[i+4] ^= ssl->out_ctr[i]; + } + else { /* Reminder if we ever add an AEAD mode with a different size */ MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - memcpy( ssl->transform_out->iv_enc + ssl->transform_out->fixed_ivlen, - ssl->out_ctr, 8 ); - memcpy( ssl->out_iv, ssl->out_ctr, 8 ); - - MBEDTLS_SSL_DEBUG_BUF( 4, "IV used", ssl->out_iv, - ssl->transform_out->ivlen - ssl->transform_out->fixed_ivlen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "IV used (internal)", + iv, transform->ivlen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "IV used (transmitted)", + ssl->out_iv, explicit_ivlen ); /* - * Fix pointer positions and message length with added IV + * Fix message length with added IV */ enc_msg = ssl->out_msg; enc_msglen = ssl->out_msglen; - ssl->out_msglen += ssl->transform_out->ivlen - - ssl->transform_out->fixed_ivlen; + ssl->out_msglen += explicit_ivlen; MBEDTLS_SSL_DEBUG_MSG( 3, ( "before encrypt: msglen = %d, " - "including %d bytes of padding", - ssl->out_msglen, 0 ) ); + "including 0 bytes of padding", + ssl->out_msglen ) ); /* * Encrypt and authenticate */ - if( ( ret = mbedtls_cipher_auth_encrypt( &ssl->transform_out->cipher_ctx_enc, - ssl->transform_out->iv_enc, - ssl->transform_out->ivlen, + if( ( ret = mbedtls_cipher_auth_encrypt( &transform->cipher_ctx_enc, + iv, transform->ivlen, add_data, 13, enc_msg, enc_msglen, enc_msg, &olen, @@ -1499,7 +1645,7 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) else #endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) && \ - ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) + ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) || defined(MBEDTLS_ARIA_C) ) if( mode == MBEDTLS_MODE_CBC ) { int ret; @@ -1619,7 +1765,7 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_CIPHER_MODE_CBC && - ( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C ) */ + ( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C || MBEDTLS_ARIA_C ) */ { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); @@ -1639,7 +1785,6 @@ static int ssl_encrypt_buf( mbedtls_ssl_context *ssl ) static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) { - size_t i; mbedtls_cipher_mode_t mode; int auth_done = 0; #if defined(SSL_SOME_MODES_USE_MAC) @@ -1689,20 +1834,27 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_ARC4_C || MBEDTLS_CIPHER_NULL_CIPHER */ -#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CCM_C) +#if defined(MBEDTLS_GCM_C) || \ + defined(MBEDTLS_CCM_C) || \ + defined(MBEDTLS_CHACHAPOLY_C) if( mode == MBEDTLS_MODE_GCM || - mode == MBEDTLS_MODE_CCM ) + mode == MBEDTLS_MODE_CCM || + mode == MBEDTLS_MODE_CHACHAPOLY ) { int ret; size_t dec_msglen, olen; unsigned char *dec_msg; unsigned char *dec_msg_result; unsigned char add_data[13]; - unsigned char taglen = ssl->transform_in->ciphersuite_info->flags & + unsigned char iv[12]; + mbedtls_ssl_transform *transform = ssl->transform_in; + unsigned char taglen = transform->ciphersuite_info->flags & MBEDTLS_CIPHERSUITE_SHORT_TAG ? 8 : 16; - size_t explicit_iv_len = ssl->transform_in->ivlen - - ssl->transform_in->fixed_ivlen; + size_t explicit_iv_len = transform->ivlen - transform->fixed_ivlen; + /* + * Compute and update sizes + */ if( ssl->in_msglen < explicit_iv_len + taglen ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "msglen (%d) < explicit_iv_len (%d) " @@ -1716,6 +1868,9 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) dec_msg_result = ssl->in_msg; ssl->in_msglen = dec_msglen; + /* + * Prepare additional authenticated data + */ memcpy( add_data, ssl->in_ctr, 8 ); add_data[8] = ssl->in_msgtype; mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, @@ -1723,23 +1878,43 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) add_data[11] = ( ssl->in_msglen >> 8 ) & 0xFF; add_data[12] = ssl->in_msglen & 0xFF; - MBEDTLS_SSL_DEBUG_BUF( 4, "additional data used for AEAD", - add_data, 13 ); + MBEDTLS_SSL_DEBUG_BUF( 4, "additional data for AEAD", add_data, 13 ); + + /* + * Prepare IV + */ + if( transform->ivlen == 12 && transform->fixed_ivlen == 4 ) + { + /* GCM and CCM: fixed || explicit (transmitted) */ + memcpy( iv, transform->iv_dec, transform->fixed_ivlen ); + memcpy( iv + transform->fixed_ivlen, ssl->in_iv, 8 ); + + } + else if( transform->ivlen == 12 && transform->fixed_ivlen == 12 ) + { + /* ChachaPoly: fixed XOR sequence number */ + unsigned char i; + + memcpy( iv, transform->iv_dec, transform->fixed_ivlen ); - memcpy( ssl->transform_in->iv_dec + ssl->transform_in->fixed_ivlen, - ssl->in_iv, - ssl->transform_in->ivlen - ssl->transform_in->fixed_ivlen ); + for( i = 0; i < 8; i++ ) + iv[i+4] ^= ssl->in_ctr[i]; + } + else + { + /* Reminder if we ever add an AEAD mode with a different size */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } - MBEDTLS_SSL_DEBUG_BUF( 4, "IV used", ssl->transform_in->iv_dec, - ssl->transform_in->ivlen ); + MBEDTLS_SSL_DEBUG_BUF( 4, "IV used", iv, transform->ivlen ); MBEDTLS_SSL_DEBUG_BUF( 4, "TAG used", dec_msg + dec_msglen, taglen ); /* * Decrypt and authenticate */ if( ( ret = mbedtls_cipher_auth_decrypt( &ssl->transform_in->cipher_ctx_dec, - ssl->transform_in->iv_dec, - ssl->transform_in->ivlen, + iv, transform->ivlen, add_data, 13, dec_msg, dec_msglen, dec_msg_result, &olen, @@ -1763,7 +1938,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) else #endif /* MBEDTLS_GCM_C || MBEDTLS_CCM_C */ #if defined(MBEDTLS_CIPHER_MODE_CBC) && \ - ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) ) + ( defined(MBEDTLS_AES_C) || defined(MBEDTLS_CAMELLIA_C) || defined(MBEDTLS_ARIA_C) ) if( mode == MBEDTLS_MODE_CBC ) { /* @@ -1857,6 +2032,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) */ if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) { + unsigned char i; dec_msglen -= ssl->transform_in->ivlen; ssl->in_msglen -= ssl->transform_in->ivlen; @@ -1931,19 +2107,20 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) */ size_t pad_count = 0, real_count = 1; size_t padding_idx = ssl->in_msglen - padlen; + size_t i; /* * Padding is guaranteed to be incorrect if: * 1. padlen > ssl->in_msglen * - * 2. padding_idx > MBEDTLS_SSL_MAX_CONTENT_LEN + + * 2. padding_idx > MBEDTLS_SSL_IN_CONTENT_LEN + * ssl->transform_in->maclen * * In both cases we reset padding_idx to a safe value (0) to * prevent out-of-buffer reads. */ correct &= ( padlen <= ssl->in_msglen ); - correct &= ( padding_idx <= MBEDTLS_SSL_MAX_CONTENT_LEN + + correct &= ( padding_idx <= MBEDTLS_SSL_IN_CONTENT_LEN + ssl->transform_in->maclen ); padding_idx *= correct; @@ -1975,7 +2152,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_CIPHER_MODE_CBC && - ( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C ) */ + ( MBEDTLS_AES_C || MBEDTLS_CAMELLIA_C || MBEDTLS_ARIA_C ) */ { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); @@ -2183,6 +2360,7 @@ static int ssl_decrypt_buf( mbedtls_ssl_context *ssl ) else #endif { + unsigned char i; for( i = 8; i > ssl_ep_len( ssl ); i-- ) if( ++ssl->in_ctr[i - 1] != 0 ) break; @@ -2232,7 +2410,7 @@ static int ssl_compress_buf( mbedtls_ssl_context *ssl ) ssl->transform_out->ctx_deflate.next_in = msg_pre; ssl->transform_out->ctx_deflate.avail_in = len_pre; ssl->transform_out->ctx_deflate.next_out = msg_post; - ssl->transform_out->ctx_deflate.avail_out = MBEDTLS_SSL_BUFFER_LEN - bytes_written; + ssl->transform_out->ctx_deflate.avail_out = MBEDTLS_SSL_OUT_BUFFER_LEN - bytes_written; ret = deflate( &ssl->transform_out->ctx_deflate, Z_SYNC_FLUSH ); if( ret != Z_OK ) @@ -2241,7 +2419,7 @@ static int ssl_compress_buf( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED ); } - ssl->out_msglen = MBEDTLS_SSL_BUFFER_LEN - + ssl->out_msglen = MBEDTLS_SSL_OUT_BUFFER_LEN - ssl->transform_out->ctx_deflate.avail_out - bytes_written; MBEDTLS_SSL_DEBUG_MSG( 3, ( "after compression: msglen = %d, ", @@ -2279,7 +2457,7 @@ static int ssl_decompress_buf( mbedtls_ssl_context *ssl ) ssl->transform_in->ctx_inflate.next_in = msg_pre; ssl->transform_in->ctx_inflate.avail_in = len_pre; ssl->transform_in->ctx_inflate.next_out = msg_post; - ssl->transform_in->ctx_inflate.avail_out = MBEDTLS_SSL_BUFFER_LEN - + ssl->transform_in->ctx_inflate.avail_out = MBEDTLS_SSL_IN_BUFFER_LEN - header_bytes; ret = inflate( &ssl->transform_in->ctx_inflate, Z_SYNC_FLUSH ); @@ -2289,7 +2467,7 @@ static int ssl_decompress_buf( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_COMPRESSION_FAILED ); } - ssl->in_msglen = MBEDTLS_SSL_BUFFER_LEN - + ssl->in_msglen = MBEDTLS_SSL_IN_BUFFER_LEN - ssl->transform_in->ctx_inflate.avail_out - header_bytes; MBEDTLS_SSL_DEBUG_MSG( 3, ( "after decompression: msglen = %d, ", @@ -2364,7 +2542,7 @@ int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ) return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); } - if( nb_want > MBEDTLS_SSL_BUFFER_LEN - (size_t)( ssl->in_hdr - ssl->in_buf ) ) + if( nb_want > MBEDTLS_SSL_IN_BUFFER_LEN - (size_t)( ssl->in_hdr - ssl->in_buf ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "requesting more data than fits" ) ); return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); @@ -2444,10 +2622,13 @@ int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ) * that will end up being dropped. */ if( ssl_check_timer( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "timer has expired" ) ); ret = MBEDTLS_ERR_SSL_TIMEOUT; + } else { - len = MBEDTLS_SSL_BUFFER_LEN - ( ssl->in_hdr - ssl->in_buf ); + len = MBEDTLS_SSL_IN_BUFFER_LEN - ( ssl->in_hdr - ssl->in_buf ); if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER ) timeout = ssl->handshake->retransmit_timeout; @@ -2569,7 +2750,7 @@ int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want ) int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ) { int ret; - unsigned char *buf, i; + unsigned char *buf; MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> flush output" ) ); @@ -2592,8 +2773,7 @@ int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "message length: %d, out_left: %d", mbedtls_ssl_hdr_len( ssl ) + ssl->out_msglen, ssl->out_left ) ); - buf = ssl->out_hdr + mbedtls_ssl_hdr_len( ssl ) + - ssl->out_msglen - ssl->out_left; + buf = ssl->out_hdr - ssl->out_left; ret = ssl->f_send( ssl->p_bio, buf, ssl->out_left ); MBEDTLS_SSL_DEBUG_RET( 2, "ssl->f_send", ret ); @@ -2612,16 +2792,17 @@ int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ) ssl->out_left -= ret; } - for( i = 8; i > ssl_ep_len( ssl ); i-- ) - if( ++ssl->out_ctr[i - 1] != 0 ) - break; - - /* The loop goes to its end iff the counter is wrapping */ - if( i == ssl_ep_len( ssl ) ) +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "outgoing message counter would wrap" ) ); - return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); + ssl->out_hdr = ssl->out_buf; + } + else +#endif + { + ssl->out_hdr = ssl->out_buf + 8; } + ssl_update_out_pointers( ssl, ssl->transform_out ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= flush output" ) ); @@ -2638,6 +2819,9 @@ int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl ) static int ssl_flight_append( mbedtls_ssl_context *ssl ) { mbedtls_ssl_flight_item *msg; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> ssl_flight_append" ) ); + MBEDTLS_SSL_DEBUG_BUF( 4, "message appended to flight", + ssl->out_msg, ssl->out_msglen ); /* Allocate space for current message */ if( ( msg = mbedtls_calloc( 1, sizeof( mbedtls_ssl_flight_item ) ) ) == NULL ) @@ -2671,6 +2855,7 @@ static int ssl_flight_append( mbedtls_ssl_context *ssl ) cur->next = msg; } + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= ssl_flight_append" ) ); return( 0 ); } @@ -2719,19 +2904,12 @@ static void ssl_swap_epochs( mbedtls_ssl_context *ssl ) ssl->handshake->alt_transform_out = tmp_transform; /* Swap epoch + sequence_number */ - memcpy( tmp_out_ctr, ssl->out_ctr, 8 ); - memcpy( ssl->out_ctr, ssl->handshake->alt_out_ctr, 8 ); + memcpy( tmp_out_ctr, ssl->cur_out_ctr, 8 ); + memcpy( ssl->cur_out_ctr, ssl->handshake->alt_out_ctr, 8 ); memcpy( ssl->handshake->alt_out_ctr, tmp_out_ctr, 8 ); /* Adjust to the newly activated transform */ - if( ssl->transform_out != NULL && - ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) - { - ssl->out_msg = ssl->out_iv + ssl->transform_out->ivlen - - ssl->transform_out->fixed_ivlen; - } - else - ssl->out_msg = ssl->out_iv; + ssl_update_out_pointers( ssl, ssl->transform_out ); #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) if( mbedtls_ssl_hw_record_activate != NULL ) @@ -2747,20 +2925,38 @@ static void ssl_swap_epochs( mbedtls_ssl_context *ssl ) /* * Retransmit the current flight of messages. + */ +int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_resend" ) ); + + ret = mbedtls_ssl_flight_transmit( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_resend" ) ); + + return( ret ); +} + +/* + * Transmit or retransmit the current flight of messages. * * Need to remember the current message in case flush_output returns * WANT_WRITE, causing us to exit this function and come back later. * This function must be called until state is no longer SENDING. */ -int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl ) { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_resend" ) ); + int ret; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> mbedtls_ssl_flight_transmit" ) ); if( ssl->handshake->retransmit_state != MBEDTLS_SSL_RETRANS_SENDING ) { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialise resending" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialise flight transmission" ) ); ssl->handshake->cur_msg = ssl->handshake->flight; + ssl->handshake->cur_msg_p = ssl->handshake->flight->p + 12; ssl_swap_epochs( ssl ); ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_SENDING; @@ -2768,33 +2964,129 @@ int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ) while( ssl->handshake->cur_msg != NULL ) { - int ret; - mbedtls_ssl_flight_item *cur = ssl->handshake->cur_msg; + size_t max_frag_len; + const mbedtls_ssl_flight_item * const cur = ssl->handshake->cur_msg; + + int const is_finished = + ( cur->type == MBEDTLS_SSL_MSG_HANDSHAKE && + cur->p[0] == MBEDTLS_SSL_HS_FINISHED ); + + uint8_t const force_flush = ssl->disable_datagram_packing == 1 ? + SSL_FORCE_FLUSH : SSL_DONT_FORCE_FLUSH; /* Swap epochs before sending Finished: we can't do it after * sending ChangeCipherSpec, in case write returns WANT_READ. * Must be done before copying, may change out_msg pointer */ - if( cur->type == MBEDTLS_SSL_MSG_HANDSHAKE && - cur->p[0] == MBEDTLS_SSL_HS_FINISHED ) + if( is_finished && ssl->handshake->cur_msg_p == ( cur->p + 12 ) ) { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "swap epochs to send finished message" ) ); ssl_swap_epochs( ssl ); } - memcpy( ssl->out_msg, cur->p, cur->len ); - ssl->out_msglen = cur->len; - ssl->out_msgtype = cur->type; + ret = ssl_get_remaining_payload_in_datagram( ssl ); + if( ret < 0 ) + return( ret ); + max_frag_len = (size_t) ret; + + /* CCS is copied as is, while HS messages may need fragmentation */ + if( cur->type == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC ) + { + if( max_frag_len == 0 ) + { + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + + continue; + } + + memcpy( ssl->out_msg, cur->p, cur->len ); + ssl->out_msglen = cur->len; + ssl->out_msgtype = cur->type; + + /* Update position inside current message */ + ssl->handshake->cur_msg_p += cur->len; + } + else + { + const unsigned char * const p = ssl->handshake->cur_msg_p; + const size_t hs_len = cur->len - 12; + const size_t frag_off = p - ( cur->p + 12 ); + const size_t rem_len = hs_len - frag_off; + size_t cur_hs_frag_len, max_hs_frag_len; + + if( ( max_frag_len < 12 ) || ( max_frag_len == 12 && hs_len != 0 ) ) + { + if( is_finished ) + ssl_swap_epochs( ssl ); + + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + + continue; + } + max_hs_frag_len = max_frag_len - 12; + + cur_hs_frag_len = rem_len > max_hs_frag_len ? + max_hs_frag_len : rem_len; + + if( frag_off == 0 && cur_hs_frag_len != hs_len ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "fragmenting handshake message (%u > %u)", + (unsigned) cur_hs_frag_len, + (unsigned) max_hs_frag_len ) ); + } + + /* Messages are stored with handshake headers as if not fragmented, + * copy beginning of headers then fill fragmentation fields. + * Handshake headers: type(1) len(3) seq(2) f_off(3) f_len(3) */ + memcpy( ssl->out_msg, cur->p, 6 ); + + ssl->out_msg[6] = ( ( frag_off >> 16 ) & 0xff ); + ssl->out_msg[7] = ( ( frag_off >> 8 ) & 0xff ); + ssl->out_msg[8] = ( ( frag_off ) & 0xff ); - ssl->handshake->cur_msg = cur->next; + ssl->out_msg[ 9] = ( ( cur_hs_frag_len >> 16 ) & 0xff ); + ssl->out_msg[10] = ( ( cur_hs_frag_len >> 8 ) & 0xff ); + ssl->out_msg[11] = ( ( cur_hs_frag_len ) & 0xff ); - MBEDTLS_SSL_DEBUG_BUF( 3, "resent handshake message header", ssl->out_msg, 12 ); + MBEDTLS_SSL_DEBUG_BUF( 3, "handshake header", ssl->out_msg, 12 ); + + /* Copy the handshake message content and set records fields */ + memcpy( ssl->out_msg + 12, p, cur_hs_frag_len ); + ssl->out_msglen = cur_hs_frag_len + 12; + ssl->out_msgtype = cur->type; + + /* Update position inside current message */ + ssl->handshake->cur_msg_p += cur_hs_frag_len; + } + + /* If done with the current message move to the next one if any */ + if( ssl->handshake->cur_msg_p >= cur->p + cur->len ) + { + if( cur->next != NULL ) + { + ssl->handshake->cur_msg = cur->next; + ssl->handshake->cur_msg_p = cur->next->p + 12; + } + else + { + ssl->handshake->cur_msg = NULL; + ssl->handshake->cur_msg_p = NULL; + } + } - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + /* Actually send the message out */ + if( ( ret = mbedtls_ssl_write_record( ssl, force_flush ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); return( ret ); } } + if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + return( ret ); + + /* Update state and set timer */ if( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_FINISHED; else @@ -2803,7 +3095,7 @@ int mbedtls_ssl_resend( mbedtls_ssl_context *ssl ) ssl_set_timer( ssl, ssl->handshake->retransmit_timeout ); } - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_resend" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= mbedtls_ssl_flight_transmit" ) ); return( 0 ); } @@ -2821,6 +3113,12 @@ void mbedtls_ssl_recv_flight_completed( mbedtls_ssl_context *ssl ) /* The next incoming flight will start with this msg_seq */ ssl->handshake->in_flight_start_seq = ssl->handshake->in_msg_seq; + /* We don't want to remember CCS's across flight boundaries. */ + ssl->handshake->buffering.seen_ccs = 0; + + /* Clear future message buffering structure. */ + ssl_buffering_free( ssl ); + /* Cancel timer */ ssl_set_timer( ssl, 0 ); @@ -2852,43 +3150,102 @@ void mbedtls_ssl_send_flight_completed( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_SSL_PROTO_DTLS */ /* - * Record layer functions + * Handshake layer functions */ /* - * Write current record. - * Uses ssl->out_msgtype, ssl->out_msglen and bytes at ssl->out_msg. + * Write (DTLS: or queue) current handshake (including CCS) message. + * + * - fill in handshake headers + * - update handshake checksum + * - DTLS: save message for resending + * - then pass to the record layer + * + * DTLS: except for HelloRequest, messages are only queued, and will only be + * actually sent when calling flight_transmit() or resend(). + * + * Inputs: + * - ssl->out_msglen: 4 + actual handshake message len + * (4 is the size of handshake headers for TLS) + * - ssl->out_msg[0]: the handshake type (ClientHello, ServerHello, etc) + * - ssl->out_msg + 4: the handshake message body + * + * Outputs, ie state before passing to flight_append() or write_record(): + * - ssl->out_msglen: the length of the record contents + * (including handshake headers but excluding record headers) + * - ssl->out_msg: the record contents (handshake headers + content) */ -int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) +int mbedtls_ssl_write_handshake_msg( mbedtls_ssl_context *ssl ) { - int ret, done = 0, out_msg_type; - size_t len = ssl->out_msglen; + int ret; + const size_t hs_len = ssl->out_msglen - 4; + const unsigned char hs_type = ssl->out_msg[0]; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write record" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write handshake message" ) ); + + /* + * Sanity checks + */ + if( ssl->out_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE && + ssl->out_msgtype != MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC ) + { + /* In SSLv3, the client might send a NoCertificate alert. */ +#if defined(MBEDTLS_SSL_PROTO_SSL3) && defined(MBEDTLS_SSL_CLI_C) + if( ! ( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 && + ssl->out_msgtype == MBEDTLS_SSL_MSG_ALERT && + ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT ) ) +#endif /* MBEDTLS_SSL_PROTO_SSL3 && MBEDTLS_SSL_SRV_C */ + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } + + /* Whenever we send anything different from a + * HelloRequest we should be in a handshake - double check. */ + if( ! ( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + hs_type == MBEDTLS_SSL_HS_HELLO_REQUEST ) && + ssl->handshake == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && ssl->handshake != NULL && ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) { - ; /* Skip special handshake treatment when resending */ + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - else #endif - if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) - { - out_msg_type = ssl->out_msg[0]; - if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST && - ssl->handshake == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); - } + /* Double-check that we did not exceed the bounds + * of the outgoing record buffer. + * This should never fail as the various message + * writing functions must obey the bounds of the + * outgoing record buffer, but better be safe. + * + * Note: We deliberately do not check for the MTU or MFL here. + */ + if( ssl->out_msglen > MBEDTLS_SSL_OUT_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Record too large: " + "size %u, maximum %u", + (unsigned) ssl->out_msglen, + (unsigned) MBEDTLS_SSL_OUT_CONTENT_LEN ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } - ssl->out_msg[1] = (unsigned char)( ( len - 4 ) >> 16 ); - ssl->out_msg[2] = (unsigned char)( ( len - 4 ) >> 8 ); - ssl->out_msg[3] = (unsigned char)( ( len - 4 ) ); + /* + * Fill handshake headers + */ + if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) + { + ssl->out_msg[1] = (unsigned char)( hs_len >> 16 ); + ssl->out_msg[2] = (unsigned char)( hs_len >> 8 ); + ssl->out_msg[3] = (unsigned char)( hs_len ); /* * DTLS has additional fields in the Handshake layer, @@ -2901,21 +3258,20 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { /* Make room for the additional DTLS fields */ - if( MBEDTLS_SSL_MAX_CONTENT_LEN - ssl->out_msglen < 8 ) + if( MBEDTLS_SSL_OUT_CONTENT_LEN - ssl->out_msglen < 8 ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "DTLS handshake message too large: " "size %u, maximum %u", - (unsigned) ( ssl->in_hslen - 4 ), - (unsigned) ( MBEDTLS_SSL_MAX_CONTENT_LEN - 12 ) ) ); + (unsigned) ( hs_len ), + (unsigned) ( MBEDTLS_SSL_OUT_CONTENT_LEN - 12 ) ) ); return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); } - memmove( ssl->out_msg + 12, ssl->out_msg + 4, len - 4 ); + memmove( ssl->out_msg + 12, ssl->out_msg + 4, hs_len ); ssl->out_msglen += 8; - len += 8; /* Write message_seq and update it, except for HelloRequest */ - if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) + if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) { ssl->out_msg[4] = ( ssl->handshake->out_msg_seq >> 8 ) & 0xFF; ssl->out_msg[5] = ( ssl->handshake->out_msg_seq ) & 0xFF; @@ -2927,23 +3283,23 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) ssl->out_msg[5] = 0; } - /* We don't fragment, so frag_offset = 0 and frag_len = len */ + /* Handshake hashes are computed without fragmentation, + * so set frag_offset = 0 and frag_len = hs_len for now */ memset( ssl->out_msg + 6, 0x00, 3 ); memcpy( ssl->out_msg + 9, ssl->out_msg + 1, 3 ); } #endif /* MBEDTLS_SSL_PROTO_DTLS */ - if( out_msg_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) - ssl->handshake->update_checksum( ssl, ssl->out_msg, len ); + /* Update running hashes of handshake messages seen */ + if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST ) + ssl->handshake->update_checksum( ssl, ssl->out_msg, ssl->out_msglen ); } - /* Save handshake and CCS messages for resending */ + /* Either send now, or just save to be sent (and resent) later */ #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && - ssl->handshake != NULL && - ssl->handshake->retransmit_state != MBEDTLS_SSL_RETRANS_SENDING && - ( ssl->out_msgtype == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC || - ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) ) + ! ( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + hs_type == MBEDTLS_SSL_HS_HELLO_REQUEST ) ) { if( ( ret = ssl_flight_append( ssl ) ) != 0 ) { @@ -2951,7 +3307,40 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) return( ret ); } } + else #endif + { + if( ( ret = mbedtls_ssl_write_record( ssl, SSL_FORCE_FLUSH ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_write_record", ret ); + return( ret ); + } + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write handshake message" ) ); + + return( 0 ); +} + +/* + * Record layer functions + */ + +/* + * Write current record. + * + * Uses: + * - ssl->out_msgtype: type of the message (AppData, Handshake, Alert, CCS) + * - ssl->out_msglen: length of the record content (excl headers) + * - ssl->out_msg: record content + */ +int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl, uint8_t force_flush ) +{ + int ret, done = 0; + size_t len = ssl->out_msglen; + uint8_t flush = force_flush; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write record" ) ); #if defined(MBEDTLS_ZLIB_SUPPORT) if( ssl->transform_out != NULL && @@ -2985,10 +3374,14 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ if( !done ) { + unsigned i; + size_t protected_record_size; + ssl->out_hdr[0] = (unsigned char) ssl->out_msgtype; mbedtls_ssl_write_version( ssl->major_ver, ssl->minor_ver, ssl->conf->transport, ssl->out_hdr + 1 ); + memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 ); ssl->out_len[0] = (unsigned char)( len >> 8 ); ssl->out_len[1] = (unsigned char)( len ); @@ -3005,21 +3398,79 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) ssl->out_len[1] = (unsigned char)( len ); } - ssl->out_left = mbedtls_ssl_hdr_len( ssl ) + ssl->out_msglen; + protected_record_size = len + mbedtls_ssl_hdr_len( ssl ); + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + /* In case of DTLS, double-check that we don't exceed + * the remaining space in the datagram. */ + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ret = ssl_get_remaining_space_in_datagram( ssl ); + if( ret < 0 ) + return( ret ); + + if( protected_record_size > (size_t) ret ) + { + /* Should never happen */ + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ MBEDTLS_SSL_DEBUG_MSG( 3, ( "output record: msgtype = %d, " - "version = [%d:%d], msglen = %d", - ssl->out_hdr[0], ssl->out_hdr[1], ssl->out_hdr[2], - ( ssl->out_len[0] << 8 ) | ssl->out_len[1] ) ); + "version = [%d:%d], msglen = %d", + ssl->out_hdr[0], ssl->out_hdr[1], + ssl->out_hdr[2], len ) ); MBEDTLS_SSL_DEBUG_BUF( 4, "output record sent to network", - ssl->out_hdr, mbedtls_ssl_hdr_len( ssl ) + ssl->out_msglen ); - } + ssl->out_hdr, protected_record_size ); - if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flush_output", ret ); - return( ret ); + ssl->out_left += protected_record_size; + ssl->out_hdr += protected_record_size; + ssl_update_out_pointers( ssl, ssl->transform_out ); + + for( i = 8; i > ssl_ep_len( ssl ); i-- ) + if( ++ssl->cur_out_ctr[i - 1] != 0 ) + break; + + /* The loop goes to its end iff the counter is wrapping */ + if( i == ssl_ep_len( ssl ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "outgoing message counter would wrap" ) ); + return( MBEDTLS_ERR_SSL_COUNTER_WRAPPING ); + } + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + flush == SSL_DONT_FORCE_FLUSH ) + { + size_t remaining; + ret = ssl_get_remaining_payload_in_datagram( ssl ); + if( ret < 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "ssl_get_remaining_payload_in_datagram", + ret ); + return( ret ); + } + + remaining = (size_t) ret; + if( remaining == 0 ) + { + flush = SSL_FORCE_FLUSH; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Still %u bytes available in current datagram", (unsigned) remaining ) ); + } + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + if( ( flush == SSL_FORCE_FLUSH ) && + ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flush_output", ret ); + return( ret ); } MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write record" ) ); @@ -3028,6 +3479,52 @@ int mbedtls_ssl_write_record( mbedtls_ssl_context *ssl ) } #if defined(MBEDTLS_SSL_PROTO_DTLS) + +static int ssl_hs_is_proper_fragment( mbedtls_ssl_context *ssl ) +{ + if( ssl->in_msglen < ssl->in_hslen || + memcmp( ssl->in_msg + 6, "\0\0\0", 3 ) != 0 || + memcmp( ssl->in_msg + 9, ssl->in_msg + 1, 3 ) != 0 ) + { + return( 1 ); + } + return( 0 ); +} + +static uint32_t ssl_get_hs_frag_len( mbedtls_ssl_context const *ssl ) +{ + return( ( ssl->in_msg[9] << 16 ) | + ( ssl->in_msg[10] << 8 ) | + ssl->in_msg[11] ); +} + +static uint32_t ssl_get_hs_frag_off( mbedtls_ssl_context const *ssl ) +{ + return( ( ssl->in_msg[6] << 16 ) | + ( ssl->in_msg[7] << 8 ) | + ssl->in_msg[8] ); +} + +static int ssl_check_hs_header( mbedtls_ssl_context const *ssl ) +{ + uint32_t msg_len, frag_off, frag_len; + + msg_len = ssl_get_hs_total_len( ssl ); + frag_off = ssl_get_hs_frag_off( ssl ); + frag_len = ssl_get_hs_frag_len( ssl ); + + if( frag_off > msg_len ) + return( -1 ); + + if( frag_len > msg_len - frag_off ) + return( -1 ); + + if( frag_len + 12 > ssl->in_msglen ) + return( -1 ); + + return( 0 ); +} + /* * Mark bits in bitmask (used for DTLS HS reassembly) */ @@ -3089,162 +3586,29 @@ static int ssl_bitmask_check( unsigned char *mask, size_t len ) return( 0 ); } -/* - * Reassemble fragmented DTLS handshake messages. - * - * Use a temporary buffer for reassembly, divided in two parts: - * - the first holds the reassembled message (including handshake header), - * - the second holds a bitmask indicating which parts of the message - * (excluding headers) have been received so far. - */ -static int ssl_reassemble_dtls_handshake( mbedtls_ssl_context *ssl ) +/* msg_len does not include the handshake header */ +static size_t ssl_get_reassembly_buffer_size( size_t msg_len, + unsigned add_bitmap ) { - unsigned char *msg, *bitmask; - size_t frag_len, frag_off; - size_t msg_len = ssl->in_hslen - 12; /* Without headers */ - - if( ssl->handshake == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "not supported outside handshake (for now)" ) ); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); - } - - /* - * For first fragment, check size and allocate buffer - */ - if( ssl->handshake->hs_msg == NULL ) - { - size_t alloc_len; - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialize reassembly, total length = %d", - msg_len ) ); - - if( ssl->in_hslen > MBEDTLS_SSL_MAX_CONTENT_LEN ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "handshake message too large" ) ); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); - } - - /* The bitmask needs one bit per byte of message excluding header */ - alloc_len = 12 + msg_len + msg_len / 8 + ( msg_len % 8 != 0 ); - - ssl->handshake->hs_msg = mbedtls_calloc( 1, alloc_len ); - if( ssl->handshake->hs_msg == NULL ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc failed (%d bytes)", alloc_len ) ); - return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); - } - - /* Prepare final header: copy msg_type, length and message_seq, - * then add standardised fragment_offset and fragment_length */ - memcpy( ssl->handshake->hs_msg, ssl->in_msg, 6 ); - memset( ssl->handshake->hs_msg + 6, 0, 3 ); - memcpy( ssl->handshake->hs_msg + 9, - ssl->handshake->hs_msg + 1, 3 ); - } - else - { - /* Make sure msg_type and length are consistent */ - if( memcmp( ssl->handshake->hs_msg, ssl->in_msg, 4 ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "fragment header mismatch" ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } - } - - msg = ssl->handshake->hs_msg + 12; - bitmask = msg + msg_len; - - /* - * Check and copy current fragment - */ - frag_off = ( ssl->in_msg[6] << 16 ) | - ( ssl->in_msg[7] << 8 ) | - ssl->in_msg[8]; - frag_len = ( ssl->in_msg[9] << 16 ) | - ( ssl->in_msg[10] << 8 ) | - ssl->in_msg[11]; - - if( frag_off + frag_len > msg_len ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid fragment offset/len: %d + %d > %d", - frag_off, frag_len, msg_len ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } - - if( frag_len + 12 > ssl->in_msglen ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid fragment length: %d + 12 > %d", - frag_len, ssl->in_msglen ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "adding fragment, offset = %d, length = %d", - frag_off, frag_len ) ); - - memcpy( msg + frag_off, ssl->in_msg + 12, frag_len ); - ssl_bitmask_set( bitmask, frag_off, frag_len ); - - /* - * Do we have the complete message by now? - * If yes, finalize it, else ask to read the next record. - */ - if( ssl_bitmask_check( bitmask, msg_len ) != 0 ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "message is not complete yet" ) ); - return( MBEDTLS_ERR_SSL_WANT_READ ); - } - - MBEDTLS_SSL_DEBUG_MSG( 2, ( "handshake message completed" ) ); - - if( frag_len + 12 < ssl->in_msglen ) - { - /* - * We'got more handshake messages in the same record. - * This case is not handled now because no know implementation does - * that and it's hard to test, so we prefer to fail cleanly for now. - */ - MBEDTLS_SSL_DEBUG_MSG( 1, ( "last fragment not alone in its record" ) ); - return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); - } - - if( ssl->in_left > ssl->next_record_offset ) - { - /* - * We've got more data in the buffer after the current record, - * that we don't want to overwrite. Move it before writing the - * reassembled message, and adjust in_left and next_record_offset. - */ - unsigned char *cur_remain = ssl->in_hdr + ssl->next_record_offset; - unsigned char *new_remain = ssl->in_msg + ssl->in_hslen; - size_t remain_len = ssl->in_left - ssl->next_record_offset; - - /* First compute and check new lengths */ - ssl->next_record_offset = new_remain - ssl->in_hdr; - ssl->in_left = ssl->next_record_offset + remain_len; - - if( ssl->in_left > MBEDTLS_SSL_BUFFER_LEN - - (size_t)( ssl->in_hdr - ssl->in_buf ) ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "reassembled message too large for buffer" ) ); - return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL ); - } + size_t alloc_len; - memmove( new_remain, cur_remain, remain_len ); - } + alloc_len = 12; /* Handshake header */ + alloc_len += msg_len; /* Content buffer */ - memcpy( ssl->in_msg, ssl->handshake->hs_msg, ssl->in_hslen ); + if( add_bitmap ) + alloc_len += msg_len / 8 + ( msg_len % 8 != 0 ); /* Bitmap */ - mbedtls_zeroize( ssl->handshake->hs_msg, ssl->in_hslen ); - mbedtls_free( ssl->handshake->hs_msg ); - ssl->handshake->hs_msg = NULL; + return( alloc_len ); +} - MBEDTLS_SSL_DEBUG_BUF( 3, "reassembled handshake message", - ssl->in_msg, ssl->in_hslen ); +#endif /* MBEDTLS_SSL_PROTO_DTLS */ - return( 0 ); +static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl ) +{ + return( ( ssl->in_msg[1] << 16 ) | + ( ssl->in_msg[2] << 8 ) | + ssl->in_msg[3] ); } -#endif /* MBEDTLS_SSL_PROTO_DTLS */ int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ) { @@ -3255,10 +3619,7 @@ int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_INVALID_RECORD ); } - ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + ( - ( ssl->in_msg[1] << 16 ) | - ( ssl->in_msg[2] << 8 ) | - ssl->in_msg[3] ); + ssl->in_hslen = mbedtls_ssl_hs_hdr_len( ssl ) + ssl_get_hs_total_len( ssl ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "handshake message: msglen =" " %d, type = %d, hslen = %d", @@ -3270,10 +3631,26 @@ int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ) int ret; unsigned int recv_msg_seq = ( ssl->in_msg[4] << 8 ) | ssl->in_msg[5]; - /* ssl->handshake is NULL when receiving ClientHello for renego */ + if( ssl_check_hs_header( ssl ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid handshake header" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + if( ssl->handshake != NULL && - recv_msg_seq != ssl->handshake->in_msg_seq ) + ( ( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER && + recv_msg_seq != ssl->handshake->in_msg_seq ) || + ( ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER && + ssl->in_msg[0] != MBEDTLS_SSL_HS_CLIENT_HELLO ) ) ) { + if( recv_msg_seq > ssl->handshake->in_msg_seq ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "received future handshake message of sequence number %u (next %u)", + recv_msg_seq, + ssl->handshake->in_msg_seq ) ); + return( MBEDTLS_ERR_SSL_EARLY_MESSAGE ); + } + /* Retransmit only on last message from previous flight, to avoid * too many retransmissions. * Besides, No sane server ever retransmits HelloVerifyRequest */ @@ -3299,24 +3676,18 @@ int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ) ssl->handshake->in_msg_seq ) ); } - return( MBEDTLS_ERR_SSL_WANT_READ ); + return( MBEDTLS_ERR_SSL_CONTINUE_PROCESSING ); } /* Wait until message completion to increment in_msg_seq */ - /* Reassemble if current message is fragmented or reassembly is - * already in progress */ - if( ssl->in_msglen < ssl->in_hslen || - memcmp( ssl->in_msg + 6, "\0\0\0", 3 ) != 0 || - memcmp( ssl->in_msg + 9, ssl->in_msg + 1, 3 ) != 0 || - ( ssl->handshake != NULL && ssl->handshake->hs_msg != NULL ) ) + /* Message reassembly is handled alongside buffering of future + * messages; the commonality is that both handshake fragments and + * future messages cannot be forwarded immediately to the + * handshake logic layer. */ + if( ssl_hs_is_proper_fragment( ssl ) == 1 ) { MBEDTLS_SSL_DEBUG_MSG( 2, ( "found fragmented DTLS handshake message" ) ); - - if( ( ret = ssl_reassemble_dtls_handshake( ssl ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "ssl_reassemble_dtls_handshake", ret ); - return( ret ); - } + return( MBEDTLS_ERR_SSL_EARLY_MESSAGE ); } } else @@ -3333,9 +3704,9 @@ int mbedtls_ssl_prepare_handshake_record( mbedtls_ssl_context *ssl ) void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ) { + mbedtls_ssl_handshake_params * const hs = ssl->handshake; - if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER && - ssl->handshake != NULL ) + if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER && hs != NULL ) { ssl->handshake->update_checksum( ssl, ssl->in_msg, ssl->in_hslen ); } @@ -3345,7 +3716,29 @@ void mbedtls_ssl_update_handshake_status( mbedtls_ssl_context *ssl ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && ssl->handshake != NULL ) { - ssl->handshake->in_msg_seq++; + unsigned offset; + mbedtls_ssl_hs_buffer *hs_buf; + + /* Increment handshake sequence number */ + hs->in_msg_seq++; + + /* + * Clear up handshake buffering and reassembly structure. + */ + + /* Free first entry */ + ssl_buffering_free_slot( ssl, 0 ); + + /* Shift all other entries */ + for( offset = 0, hs_buf = &hs->buffering.hs[0]; + offset + 1 < MBEDTLS_SSL_MAX_BUFFERED_HS; + offset++, hs_buf++ ) + { + *hs_buf = *(hs_buf + 1); + } + + /* Create a fresh last entry */ + memset( hs_buf, 0, sizeof( mbedtls_ssl_hs_buffer ) ); } #endif } @@ -3598,7 +3991,7 @@ static int ssl_handle_possible_reconnect( mbedtls_ssl_context *ssl ) ssl->conf->p_cookie, ssl->cli_id, ssl->cli_id_len, ssl->in_buf, ssl->in_left, - ssl->out_buf, MBEDTLS_SSL_MAX_CONTENT_LEN, &len ); + ssl->out_buf, MBEDTLS_SSL_OUT_CONTENT_LEN, &len ); MBEDTLS_SSL_DEBUG_RET( 2, "ssl_check_dtls_clihlo_cookie", ret ); @@ -3695,88 +4088,30 @@ static int ssl_parse_record_header( mbedtls_ssl_context *ssl ) } /* Check length against the size of our buffer */ - if( ssl->in_msglen > MBEDTLS_SSL_BUFFER_LEN + if( ssl->in_msglen > MBEDTLS_SSL_IN_BUFFER_LEN - (size_t)( ssl->in_msg - ssl->in_buf ) ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( MBEDTLS_ERR_SSL_INVALID_RECORD ); } - /* Check length against bounds of the current transform and version */ - if( ssl->transform_in == NULL ) - { - if( ssl->in_msglen < 1 || - ssl->in_msglen > MBEDTLS_SSL_MAX_CONTENT_LEN ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } - } - else - { - if( ssl->in_msglen < ssl->transform_in->minlen ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } - -#if defined(MBEDTLS_SSL_PROTO_SSL3) - if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 && - ssl->in_msglen > ssl->transform_in->minlen + MBEDTLS_SSL_MAX_CONTENT_LEN ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } -#endif -#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ - defined(MBEDTLS_SSL_PROTO_TLS1_2) - /* - * TLS encrypted messages can have up to 256 bytes of padding - */ - if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 && - ssl->in_msglen > ssl->transform_in->minlen + - MBEDTLS_SSL_MAX_CONTENT_LEN + 256 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); - return( MBEDTLS_ERR_SSL_INVALID_RECORD ); - } -#endif - } - /* - * DTLS-related tests done last, because most of them may result in - * silently dropping the record (but not the whole datagram), and we only - * want to consider that after ensuring that the "basic" fields (type, - * version, length) are sane. + * DTLS-related tests. + * Check epoch before checking length constraint because + * the latter varies with the epoch. E.g., if a ChangeCipherSpec + * message gets duplicated before the corresponding Finished message, + * the second ChangeCipherSpec should be discarded because it belongs + * to an old epoch, but not because its length is shorter than + * the minimum record length for packets using the new record transform. + * Note that these two kinds of failures are handled differently, + * as an unexpected record is silently skipped but an invalid + * record leads to the entire datagram being dropped. */ #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) { unsigned int rec_epoch = ( ssl->in_ctr[0] << 8 ) | ssl->in_ctr[1]; - /* Drop unexpected ChangeCipherSpec messages */ - if( ssl->in_msgtype == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC && - ssl->state != MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC && - ssl->state != MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "dropping unexpected ChangeCipherSpec" ) ); - return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); - } - - /* Drop unexpected ApplicationData records, - * except at the beginning of renegotiations */ - if( ssl->in_msgtype == MBEDTLS_SSL_MSG_APPLICATION_DATA && - ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER -#if defined(MBEDTLS_SSL_RENEGOTIATION) - && ! ( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && - ssl->state == MBEDTLS_SSL_SERVER_HELLO ) -#endif - ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "dropping unexpected ApplicationData" ) ); - return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); - } - /* Check epoch (and sequence number) with DTLS */ if( rec_epoch != ssl->in_epoch ) { @@ -3804,7 +4139,16 @@ static int ssl_parse_record_header( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE && MBEDTLS_SSL_SRV_C */ + { + /* Consider buffering the record. */ + if( rec_epoch == (unsigned int) ssl->in_epoch + 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Consider record for buffering" ) ); + return( MBEDTLS_ERR_SSL_EARLY_MESSAGE ); + } + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } } #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) @@ -3816,9 +4160,65 @@ static int ssl_parse_record_header( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); } #endif + + /* Drop unexpected ApplicationData records, + * except at the beginning of renegotiations */ + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_APPLICATION_DATA && + ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER +#if defined(MBEDTLS_SSL_RENEGOTIATION) + && ! ( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_IN_PROGRESS && + ssl->state == MBEDTLS_SSL_SERVER_HELLO ) +#endif + ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "dropping unexpected ApplicationData" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } } #endif /* MBEDTLS_SSL_PROTO_DTLS */ + + /* Check length against bounds of the current transform and version */ + if( ssl->transform_in == NULL ) + { + if( ssl->in_msglen < 1 || + ssl->in_msglen > MBEDTLS_SSL_IN_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + } + else + { + if( ssl->in_msglen < ssl->transform_in->minlen ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( ssl->minor_ver == MBEDTLS_SSL_MINOR_VERSION_0 && + ssl->in_msglen > ssl->transform_in->minlen + MBEDTLS_SSL_IN_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } +#endif +#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ + defined(MBEDTLS_SSL_PROTO_TLS1_2) + /* + * TLS encrypted messages can have up to 256 bytes of padding + */ + if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_1 && + ssl->in_msglen > ssl->transform_in->minlen + + MBEDTLS_SSL_IN_CONTENT_LEN + 256 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } +#endif + } + return( 0 ); } @@ -3859,7 +4259,7 @@ static int ssl_prepare_record_content( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_BUF( 4, "input payload after decrypt", ssl->in_msg, ssl->in_msglen ); - if( ssl->in_msglen > MBEDTLS_SSL_MAX_CONTENT_LEN ) + if( ssl->in_msglen > MBEDTLS_SSL_IN_CONTENT_LEN ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad message length" ) ); return( MBEDTLS_ERR_SSL_INVALID_RECORD ); @@ -3897,7 +4297,14 @@ static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl ); * RFC 6347 4.1.2.7) and continue reading until a valid record is found. * */ -int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ) + +/* Helper functions for mbedtls_ssl_read_record(). */ +static int ssl_consume_current_message( mbedtls_ssl_context *ssl ); +static int ssl_get_next_record( mbedtls_ssl_context *ssl ); +static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl ); + +int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl, + unsigned update_hs_digest ) { int ret; @@ -3907,30 +4314,71 @@ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ) { do { - if( ( ret = mbedtls_ssl_read_record_layer( ssl ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret ); + ret = ssl_consume_current_message( ssl ); + if( ret != 0 ) return( ret ); + + if( ssl_record_is_in_progress( ssl ) == 0 ) + { +#if defined(MBEDTLS_SSL_PROTO_DTLS) + int have_buffered = 0; + + /* We only check for buffered messages if the + * current datagram is fully consumed. */ + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl_next_record_is_in_datagram( ssl ) == 0 ) + { + if( ssl_load_buffered_message( ssl ) == 0 ) + have_buffered = 1; + } + + if( have_buffered == 0 ) +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + { + ret = ssl_get_next_record( ssl ); + if( ret == MBEDTLS_ERR_SSL_CONTINUE_PROCESSING ) + continue; + + if( ret != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, ( "ssl_get_next_record" ), ret ); + return( ret ); + } + } } ret = mbedtls_ssl_handle_message_type( ssl ); - } while( MBEDTLS_ERR_SSL_NON_FATAL == ret ); +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ret == MBEDTLS_ERR_SSL_EARLY_MESSAGE ) + { + /* Buffer future message */ + ret = ssl_buffer_message( ssl ); + if( ret != 0 ) + return( ret ); + + ret = MBEDTLS_ERR_SSL_CONTINUE_PROCESSING; + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + } while( MBEDTLS_ERR_SSL_NON_FATAL == ret || + MBEDTLS_ERR_SSL_CONTINUE_PROCESSING == ret ); if( 0 != ret ) { - MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret ); + MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_handle_message_type" ), ret ); return( ret ); } - if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE ) + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && + update_hs_digest == 1 ) { mbedtls_ssl_update_handshake_status( ssl ); } } else { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= reuse previously read message" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "reuse previously read message" ) ); ssl->keep_current_message = 0; } @@ -3939,13 +4387,350 @@ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl ) return( 0 ); } -int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) +#if defined(MBEDTLS_SSL_PROTO_DTLS) +static int ssl_next_record_is_in_datagram( mbedtls_ssl_context *ssl ) { - int ret; + if( ssl->in_left > ssl->next_record_offset ) + return( 1 ); + + return( 0 ); +} + +static int ssl_load_buffered_message( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + mbedtls_ssl_hs_buffer * hs_buf; + int ret = 0; + + if( hs == NULL ) + return( -1 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> ssl_load_buffered_messsage" ) ); + + if( ssl->state == MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC || + ssl->state == MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC ) + { + /* Check if we have seen a ChangeCipherSpec before. + * If yes, synthesize a CCS record. */ + if( !hs->buffering.seen_ccs ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "CCS not seen in the current flight" ) ); + ret = -1; + goto exit; + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Injecting buffered CCS message" ) ); + ssl->in_msgtype = MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC; + ssl->in_msglen = 1; + ssl->in_msg[0] = 1; + + /* As long as they are equal, the exact value doesn't matter. */ + ssl->in_left = 0; + ssl->next_record_offset = 0; + + hs->buffering.seen_ccs = 0; + goto exit; + } + +#if defined(MBEDTLS_DEBUG_C) + /* Debug only */ + { + unsigned offset; + for( offset = 1; offset < MBEDTLS_SSL_MAX_BUFFERED_HS; offset++ ) + { + hs_buf = &hs->buffering.hs[offset]; + if( hs_buf->is_valid == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Future message with sequence number %u %s buffered.", + hs->in_msg_seq + offset, + hs_buf->is_complete ? "fully" : "partially" ) ); + } + } + } +#endif /* MBEDTLS_DEBUG_C */ + + /* Check if we have buffered and/or fully reassembled the + * next handshake message. */ + hs_buf = &hs->buffering.hs[0]; + if( ( hs_buf->is_valid == 1 ) && ( hs_buf->is_complete == 1 ) ) + { + /* Synthesize a record containing the buffered HS message. */ + size_t msg_len = ( hs_buf->data[1] << 16 ) | + ( hs_buf->data[2] << 8 ) | + hs_buf->data[3]; + + /* Double-check that we haven't accidentally buffered + * a message that doesn't fit into the input buffer. */ + if( msg_len + 12 > MBEDTLS_SSL_IN_CONTENT_LEN ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Next handshake message has been buffered - load" ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "Buffered handshake message (incl. header)", + hs_buf->data, msg_len + 12 ); + + ssl->in_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; + ssl->in_hslen = msg_len + 12; + ssl->in_msglen = msg_len + 12; + memcpy( ssl->in_msg, hs_buf->data, ssl->in_hslen ); + + ret = 0; + goto exit; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Next handshake message %u not or only partially bufffered", + hs->in_msg_seq ) ); + } + + ret = -1; + +exit: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= ssl_load_buffered_message" ) ); + return( ret ); +} + +static int ssl_buffer_make_space( mbedtls_ssl_context *ssl, + size_t desired ) +{ + int offset; + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Attempt to free buffered messages to have %u bytes available", + (unsigned) desired ) ); + + /* Get rid of future records epoch first, if such exist. */ + ssl_free_buffered_record( ssl ); + + /* Check if we have enough space available now. */ + if( desired <= ( MBEDTLS_SSL_DTLS_MAX_BUFFERING - + hs->buffering.total_bytes_buffered ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Enough space available after freeing future epoch record" ) ); + return( 0 ); + } + + /* We don't have enough space to buffer the next expected handshake + * message. Remove buffers used for future messages to gain space, + * starting with the most distant one. */ + for( offset = MBEDTLS_SSL_MAX_BUFFERED_HS - 1; + offset >= 0; offset-- ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Free buffering slot %d to make space for reassembly of next handshake message", + offset ) ); + + ssl_buffering_free_slot( ssl, (uint8_t) offset ); + + /* Check if we have enough space available now. */ + if( desired <= ( MBEDTLS_SSL_DTLS_MAX_BUFFERING - + hs->buffering.total_bytes_buffered ) ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Enough space available after freeing buffered HS messages" ) ); + return( 0 ); + } + } + + return( -1 ); +} + +static int ssl_buffer_message( mbedtls_ssl_context *ssl ) +{ + int ret = 0; + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + if( hs == NULL ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> ssl_buffer_message" ) ); + + switch( ssl->in_msgtype ) + { + case MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Remember CCS message" ) ); + + hs->buffering.seen_ccs = 1; + break; + + case MBEDTLS_SSL_MSG_HANDSHAKE: + { + unsigned recv_msg_seq_offset; + unsigned recv_msg_seq = ( ssl->in_msg[4] << 8 ) | ssl->in_msg[5]; + mbedtls_ssl_hs_buffer *hs_buf; + size_t msg_len = ssl->in_hslen - 12; + + /* We should never receive an old handshake + * message - double-check nonetheless. */ + if( recv_msg_seq < ssl->handshake->in_msg_seq ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + recv_msg_seq_offset = recv_msg_seq - ssl->handshake->in_msg_seq; + if( recv_msg_seq_offset >= MBEDTLS_SSL_MAX_BUFFERED_HS ) + { + /* Silently ignore -- message too far in the future */ + MBEDTLS_SSL_DEBUG_MSG( 2, + ( "Ignore future HS message with sequence number %u, " + "buffering window %u - %u", + recv_msg_seq, ssl->handshake->in_msg_seq, + ssl->handshake->in_msg_seq + MBEDTLS_SSL_MAX_BUFFERED_HS - 1 ) ); + + goto exit; + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering HS message with sequence number %u, offset %u ", + recv_msg_seq, recv_msg_seq_offset ) ); + + hs_buf = &hs->buffering.hs[ recv_msg_seq_offset ]; + + /* Check if the buffering for this seq nr has already commenced. */ + if( !hs_buf->is_valid ) + { + size_t reassembly_buf_sz; + + hs_buf->is_fragmented = + ( ssl_hs_is_proper_fragment( ssl ) == 1 ); + + /* We copy the message back into the input buffer + * after reassembly, so check that it's not too large. + * This is an implementation-specific limitation + * and not one from the standard, hence it is not + * checked in ssl_check_hs_header(). */ + if( msg_len + 12 > MBEDTLS_SSL_IN_CONTENT_LEN ) + { + /* Ignore message */ + goto exit; + } + + /* Check if we have enough space to buffer the message. */ + if( hs->buffering.total_bytes_buffered > + MBEDTLS_SSL_DTLS_MAX_BUFFERING ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); + } + + reassembly_buf_sz = ssl_get_reassembly_buffer_size( msg_len, + hs_buf->is_fragmented ); + + if( reassembly_buf_sz > ( MBEDTLS_SSL_DTLS_MAX_BUFFERING - + hs->buffering.total_bytes_buffered ) ) + { + if( recv_msg_seq_offset > 0 ) + { + /* If we can't buffer a future message because + * of space limitations -- ignore. */ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future message of size %u would exceed the compile-time limit %u (already %u bytes buffered) -- ignore\n", + (unsigned) msg_len, MBEDTLS_SSL_DTLS_MAX_BUFFERING, + (unsigned) hs->buffering.total_bytes_buffered ) ); + goto exit; + } + else + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future message of size %u would exceed the compile-time limit %u (already %u bytes buffered) -- attempt to make space by freeing buffered future messages\n", + (unsigned) msg_len, MBEDTLS_SSL_DTLS_MAX_BUFFERING, + (unsigned) hs->buffering.total_bytes_buffered ) ); + } + + if( ssl_buffer_make_space( ssl, reassembly_buf_sz ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Reassembly of next message of size %u (%u with bitmap) would exceed the compile-time limit %u (already %u bytes buffered) -- fail\n", + (unsigned) msg_len, + (unsigned) reassembly_buf_sz, + MBEDTLS_SSL_DTLS_MAX_BUFFERING, + (unsigned) hs->buffering.total_bytes_buffered ) ); + ret = MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL; + goto exit; + } + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "initialize reassembly, total length = %d", + msg_len ) ); + + hs_buf->data = mbedtls_calloc( 1, reassembly_buf_sz ); + if( hs_buf->data == NULL ) + { + ret = MBEDTLS_ERR_SSL_ALLOC_FAILED; + goto exit; + } + hs_buf->data_len = reassembly_buf_sz; + + /* Prepare final header: copy msg_type, length and message_seq, + * then add standardised fragment_offset and fragment_length */ + memcpy( hs_buf->data, ssl->in_msg, 6 ); + memset( hs_buf->data + 6, 0, 3 ); + memcpy( hs_buf->data + 9, hs_buf->data + 1, 3 ); + + hs_buf->is_valid = 1; + + hs->buffering.total_bytes_buffered += reassembly_buf_sz; + } + else + { + /* Make sure msg_type and length are consistent */ + if( memcmp( hs_buf->data, ssl->in_msg, 4 ) != 0 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "Fragment header mismatch - ignore" ) ); + /* Ignore */ + goto exit; + } + } + + if( !hs_buf->is_complete ) + { + size_t frag_len, frag_off; + unsigned char * const msg = hs_buf->data + 12; + + /* + * Check and copy current fragment + */ + + /* Validation of header fields already done in + * mbedtls_ssl_prepare_handshake_record(). */ + frag_off = ssl_get_hs_frag_off( ssl ); + frag_len = ssl_get_hs_frag_len( ssl ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "adding fragment, offset = %d, length = %d", + frag_off, frag_len ) ); + memcpy( msg + frag_off, ssl->in_msg + 12, frag_len ); + + if( hs_buf->is_fragmented ) + { + unsigned char * const bitmask = msg + msg_len; + ssl_bitmask_set( bitmask, frag_off, frag_len ); + hs_buf->is_complete = ( ssl_bitmask_check( bitmask, + msg_len ) == 0 ); + } + else + { + hs_buf->is_complete = 1; + } + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "message %scomplete", + hs_buf->is_complete ? "" : "not yet " ) ); + } + + break; + } + + default: + /* We don't buffer other types of messages. */ + break; + } + +exit: + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= ssl_buffer_message" ) ); + return( ret ); +} +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +static int ssl_consume_current_message( mbedtls_ssl_context *ssl ) +{ /* - * Step A - * * Consume last content-layer message and potentially * update in_msglen which keeps track of the contents' * consumption state. @@ -3957,11 +4742,6 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) * (2) Alert messages: * Consume whole record content, in_msglen = 0. * - * NOTE: This needs to be fixed, since like for - * handshake messages it is allowed to have - * multiple alerts witin a single record. - * Internal reference IOTSSL-1321. - * * (3) Change cipher spec: * Consume whole record content, in_msglen = 0. * @@ -3989,12 +4769,12 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) */ /* Notes: - * (1) in_hslen is *NOT* necessarily the size of the + * (1) in_hslen is not necessarily the size of the * current handshake content: If DTLS handshake * fragmentation is used, that's the fragment * size instead. Using the total handshake message - * size here is FAULTY and should be changed at - * some point. Internal reference IOTSSL-1414. + * size here is faulty and should be changed at + * some point. * (2) While it doesn't seem to cause problems, one * has to be very careful not to assume that in_hslen * is always <= in_msglen in a sensible communication. @@ -4011,47 +4791,182 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) memmove( ssl->in_msg, ssl->in_msg + ssl->in_hslen, ssl->in_msglen ); - MBEDTLS_SSL_DEBUG_BUF( 4, "remaining content in record", - ssl->in_msg, ssl->in_msglen ); - } - else - { - ssl->in_msglen = 0; - } + MBEDTLS_SSL_DEBUG_BUF( 4, "remaining content in record", + ssl->in_msg, ssl->in_msglen ); + } + else + { + ssl->in_msglen = 0; + } + + ssl->in_hslen = 0; + } + /* Case (4): Application data */ + else if( ssl->in_offt != NULL ) + { + return( 0 ); + } + /* Everything else (CCS & Alerts) */ + else + { + ssl->in_msglen = 0; + } + + return( 0 ); +} + +static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl ) +{ + if( ssl->in_msglen > 0 ) + return( 1 ); + + return( 0 ); +} + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + +static void ssl_free_buffered_record( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + if( hs == NULL ) + return; + + if( hs->buffering.future_record.data != NULL ) + { + hs->buffering.total_bytes_buffered -= + hs->buffering.future_record.len; + + mbedtls_free( hs->buffering.future_record.data ); + hs->buffering.future_record.data = NULL; + } +} - ssl->in_hslen = 0; +static int ssl_load_buffered_record( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + unsigned char * rec; + size_t rec_len; + unsigned rec_epoch; + + if( ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + return( 0 ); + + if( hs == NULL ) + return( 0 ); + + rec = hs->buffering.future_record.data; + rec_len = hs->buffering.future_record.len; + rec_epoch = hs->buffering.future_record.epoch; + + if( rec == NULL ) + return( 0 ); + + /* Only consider loading future records if the + * input buffer is empty. */ + if( ssl_next_record_is_in_datagram( ssl ) == 1 ) + return( 0 ); + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> ssl_load_buffered_record" ) ); + + if( rec_epoch != ssl->in_epoch ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffered record not from current epoch." ) ); + goto exit; } - /* Case (4): Application data */ - else if( ssl->in_offt != NULL ) + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Found buffered record from current epoch - load" ) ); + + /* Double-check that the record is not too large */ + if( rec_len > MBEDTLS_SSL_IN_BUFFER_LEN - + (size_t)( ssl->in_hdr - ssl->in_buf ) ) { - return( 0 ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); + return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } - /* Everything else (CCS & Alerts) */ - else + + memcpy( ssl->in_hdr, rec, rec_len ); + ssl->in_left = rec_len; + ssl->next_record_offset = 0; + + ssl_free_buffered_record( ssl ); + +exit: + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= ssl_load_buffered_record" ) ); + return( 0 ); +} + +static int ssl_buffer_future_record( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + size_t const rec_hdr_len = 13; + size_t const total_buf_sz = rec_hdr_len + ssl->in_msglen; + + /* Don't buffer future records outside handshakes. */ + if( hs == NULL ) + return( 0 ); + + /* Only buffer handshake records (we are only interested + * in Finished messages). */ + if( ssl->in_msgtype != MBEDTLS_SSL_MSG_HANDSHAKE ) + return( 0 ); + + /* Don't buffer more than one future epoch record. */ + if( hs->buffering.future_record.data != NULL ) + return( 0 ); + + /* Don't buffer record if there's not enough buffering space remaining. */ + if( total_buf_sz > ( MBEDTLS_SSL_DTLS_MAX_BUFFERING - + hs->buffering.total_bytes_buffered ) ) { - ssl->in_msglen = 0; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffering of future epoch record of size %u would exceed the compile-time limit %u (already %u bytes buffered) -- ignore\n", + (unsigned) total_buf_sz, MBEDTLS_SSL_DTLS_MAX_BUFFERING, + (unsigned) hs->buffering.total_bytes_buffered ) ); + return( 0 ); } - /* - * Step B - * - * Fetch and decode new record if current one is fully consumed. - * - */ + /* Buffer record */ + MBEDTLS_SSL_DEBUG_MSG( 2, ( "Buffer record from epoch %u", + ssl->in_epoch + 1 ) ); + MBEDTLS_SSL_DEBUG_BUF( 3, "Buffered record", ssl->in_hdr, + rec_hdr_len + ssl->in_msglen ); - if( ssl->in_msglen > 0 ) + /* ssl_parse_record_header() only considers records + * of the next epoch as candidates for buffering. */ + hs->buffering.future_record.epoch = ssl->in_epoch + 1; + hs->buffering.future_record.len = total_buf_sz; + + hs->buffering.future_record.data = + mbedtls_calloc( 1, hs->buffering.future_record.len ); + if( hs->buffering.future_record.data == NULL ) { - /* There's something left to be processed in the current record. */ + /* If we run out of RAM trying to buffer a + * record from the next epoch, just ignore. */ return( 0 ); } - /* Need to fetch a new record */ + memcpy( hs->buffering.future_record.data, ssl->in_hdr, total_buf_sz ); -#if defined(MBEDTLS_SSL_PROTO_DTLS) -read_record_header: -#endif + hs->buffering.total_bytes_buffered += total_buf_sz; + return( 0 ); +} + +#endif /* MBEDTLS_SSL_PROTO_DTLS */ - /* Current record either fully processed or to be discarded. */ +static int ssl_get_next_record( mbedtls_ssl_context *ssl ) +{ + int ret; + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + /* We might have buffered a future record; if so, + * and if the epoch matches now, load it. + * On success, this call will set ssl->in_left to + * the length of the buffered record, so that + * the calls to ssl_fetch_input() below will + * essentially be no-ops. */ + ret = ssl_load_buffered_record( ssl ); + if( ret != 0 ) + return( ret ); +#endif /* MBEDTLS_SSL_PROTO_DTLS */ if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) ) ) != 0 ) { @@ -4065,6 +4980,16 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && ret != MBEDTLS_ERR_SSL_CLIENT_RECONNECT ) { + if( ret == MBEDTLS_ERR_SSL_EARLY_MESSAGE ) + { + ret = ssl_buffer_future_record( ssl ); + if( ret != 0 ) + return( ret ); + + /* Fall through to handling of unexpected records */ + ret = MBEDTLS_ERR_SSL_UNEXPECTED_RECORD; + } + if( ret == MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ) { /* Skip unexpected record (but not whole datagram) */ @@ -4085,7 +5010,7 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) } /* Get next record */ - goto read_record_header; + return( MBEDTLS_ERR_SSL_CONTINUE_PROCESSING ); } #endif return( ret ); @@ -4104,7 +5029,13 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) /* Done reading this record, get ready for the next one */ #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { ssl->next_record_offset = ssl->in_msglen + mbedtls_ssl_hdr_len( ssl ); + if( ssl->next_record_offset < ssl->in_left ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "more than one record within datagram" ) ); + } + } else #endif ssl->in_left = 0; @@ -4151,7 +5082,7 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) ssl->in_left = 0; MBEDTLS_SSL_DEBUG_MSG( 1, ( "discarding invalid record (mac)" ) ); - goto read_record_header; + return( MBEDTLS_ERR_SSL_CONTINUE_PROCESSING ); } return( ret ); @@ -4172,46 +5103,6 @@ int mbedtls_ssl_read_record_layer( mbedtls_ssl_context *ssl ) } } - /* - * When we sent the last flight of the handshake, we MUST respond to a - * retransmit of the peer's previous flight with a retransmit. (In - * practice, only the Finished message will make it, other messages - * including CCS use the old transform so they're dropped as invalid.) - * - * If the record we received is not a handshake message, however, it - * means the peer received our last flight so we can clean up - * handshake info. - * - * This check needs to be done before prepare_handshake() due to an edge - * case: if the client immediately requests renegotiation, this - * finishes the current handshake first, avoiding the new ClientHello - * being mistaken for an ancient message in the current handshake. - */ -#if defined(MBEDTLS_SSL_PROTO_DTLS) - if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && - ssl->handshake != NULL && - ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) - { - if( ssl->in_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE && - ssl->in_msg[0] == MBEDTLS_SSL_HS_FINISHED ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "received retransmit of last flight" ) ); - - if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) - { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_resend", ret ); - return( ret ); - } - - return( MBEDTLS_ERR_SSL_WANT_READ ); - } - else - { - ssl_handshake_wrapup_free_hs_transform( ssl ); - } - } -#endif - return( 0 ); } @@ -4230,6 +5121,39 @@ int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ) } } + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_CHANGE_CIPHER_SPEC ) + { + if( ssl->in_msglen != 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid CCS message, len: %d", + ssl->in_msglen ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + + if( ssl->in_msg[0] != 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "invalid CCS message, content: %02x", + ssl->in_msg[0] ) ); + return( MBEDTLS_ERR_SSL_INVALID_RECORD ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->state != MBEDTLS_SSL_CLIENT_CHANGE_CIPHER_SPEC && + ssl->state != MBEDTLS_SSL_SERVER_CHANGE_CIPHER_SPEC ) + { + if( ssl->handshake == NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "dropping ChangeCipherSpec outside handshake" ) ); + return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); + } + + MBEDTLS_SSL_DEBUG_MSG( 1, ( "received out-of-order ChangeCipherSpec - remember" ) ); + return( MBEDTLS_ERR_SSL_EARLY_MESSAGE ); + } +#endif + } + if( ssl->in_msgtype == MBEDTLS_SSL_MSG_ALERT ) { if( ssl->in_msglen != 2 ) @@ -4266,7 +5190,7 @@ int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ) if( ssl->in_msg[0] == MBEDTLS_SSL_ALERT_LEVEL_WARNING && ssl->in_msg[1] == MBEDTLS_SSL_ALERT_MSG_NO_RENEGOTIATION ) { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "is a SSLv3 no_cert" ) ); + MBEDTLS_SSL_DEBUG_MSG( 2, ( "is a SSLv3 no renegotiation alert" ) ); /* Will be handled when trying to parse ServerHello */ return( 0 ); } @@ -4288,6 +5212,15 @@ int mbedtls_ssl_handle_message_type( mbedtls_ssl_context *ssl ) return MBEDTLS_ERR_SSL_NON_FATAL; } +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->handshake != NULL && + ssl->state == MBEDTLS_SSL_HANDSHAKE_OVER ) + { + ssl_handshake_wrapup_free_hs_transform( ssl ); + } +#endif + return( 0 ); } @@ -4322,7 +5255,7 @@ int mbedtls_ssl_send_alert_message( mbedtls_ssl_context *ssl, ssl->out_msg[0] = level; ssl->out_msg[1] = message; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_record( ssl, SSL_FORCE_FLUSH ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); return( ret ); @@ -4462,10 +5395,10 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) while( crt != NULL ) { n = crt->raw.len; - if( n > MBEDTLS_SSL_MAX_CONTENT_LEN - 3 - i ) + if( n > MBEDTLS_SSL_OUT_CONTENT_LEN - 3 - i ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "certificate too large, %d > %d", - i + 3 + n, MBEDTLS_SSL_MAX_CONTENT_LEN ) ); + i + 3 + n, MBEDTLS_SSL_OUT_CONTENT_LEN ) ); return( MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE ); } @@ -4491,9 +5424,9 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) ssl->state++; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } @@ -4502,60 +5435,16 @@ int mbedtls_ssl_write_certificate( mbedtls_ssl_context *ssl ) return( ret ); } -int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) +/* + * Once the certificate message is read, parse it into a cert chain and + * perform basic checks, but leave actual verification to the caller + */ +static int ssl_parse_certificate_chain( mbedtls_ssl_context *ssl ) { - int ret = MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE; + int ret; size_t i, n; - const mbedtls_ssl_ciphersuite_t *ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; - int authmode = ssl->conf->authmode; uint8_t alert; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); - - if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || - ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || - ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || - ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); - ssl->state++; - return( 0 ); - } - -#if defined(MBEDTLS_SSL_SRV_C) - if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && - ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) - { - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); - ssl->state++; - return( 0 ); - } - -#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) - if( ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET ) - authmode = ssl->handshake->sni_authmode; -#endif - - if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && - authmode == MBEDTLS_SSL_VERIFY_NONE ) - { - ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_SKIP_VERIFY; - MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); - ssl->state++; - return( 0 ); - } -#endif - - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) - { - /* mbedtls_ssl_read_record may have sent an alert already. We - let it decide whether to alert. */ - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); - return( ret ); - } - - ssl->state++; - #if defined(MBEDTLS_SSL_SRV_C) #if defined(MBEDTLS_SSL_PROTO_SSL3) /* @@ -4575,10 +5464,7 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) one. The client should know what's going on, so we don't send an alert. */ ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_MISSING; - if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL ) - return( 0 ); - else - return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE ); + return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE ); } } #endif /* MBEDTLS_SSL_PROTO_SSL3 */ @@ -4599,10 +5485,7 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) one. The client should know what's going on, so we don't send an alert. */ ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_MISSING; - if( authmode == MBEDTLS_SSL_VERIFY_OPTIONAL ) - return( 0 ); - else - return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE ); + return( MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE ); } } #endif /* MBEDTLS_SSL_PROTO_TLS1 || MBEDTLS_SSL_PROTO_TLS1_1 || \ @@ -4752,6 +5635,94 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) } #endif /* MBEDTLS_SSL_RENEGOTIATION && MBEDTLS_SSL_CLI_C */ + return( 0 ); +} + +int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) +{ + int ret; + const mbedtls_ssl_ciphersuite_t * const ciphersuite_info = + ssl->transform_negotiate->ciphersuite_info; +#if defined(MBEDTLS_SSL_SRV_C) && defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + const int authmode = ssl->handshake->sni_authmode != MBEDTLS_SSL_VERIFY_UNSET + ? ssl->handshake->sni_authmode + : ssl->conf->authmode; +#else + const int authmode = ssl->conf->authmode; +#endif + void *rs_ctx = NULL; + + MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse certificate" ) ); + + if( ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_DHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECDHE_PSK || + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_ECJPAKE ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + ssl->state++; + return( 0 ); + } + +#if defined(MBEDTLS_SSL_SRV_C) + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + ciphersuite_info->key_exchange == MBEDTLS_KEY_EXCHANGE_RSA_PSK ) + { + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + ssl->state++; + return( 0 ); + } + + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_SERVER && + authmode == MBEDTLS_SSL_VERIFY_NONE ) + { + ssl->session_negotiate->verify_result = MBEDTLS_X509_BADCERT_SKIP_VERIFY; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= skip parse certificate" ) ); + + ssl->state++; + return( 0 ); + } +#endif + +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled && + ssl->handshake->ecrs_state == ssl_ecrs_crt_verify ) + { + goto crt_verify; + } +#endif + + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) + { + /* mbedtls_ssl_read_record may have sent an alert already. We + let it decide whether to alert. */ + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); + return( ret ); + } + + if( ( ret = ssl_parse_certificate_chain( ssl ) ) != 0 ) + { +#if defined(MBEDTLS_SSL_SRV_C) + if( ret == MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE && + authmode == MBEDTLS_SSL_VERIFY_OPTIONAL ) + { + ret = 0; + } +#endif + + ssl->state++; + return( ret ); + } + +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ssl->handshake->ecrs_enabled) + ssl->handshake->ecrs_state = ssl_ecrs_crt_verify; + +crt_verify: + if( ssl->handshake->ecrs_enabled) + rs_ctx = &ssl->handshake->ecrs_ctx; +#endif + if( authmode != MBEDTLS_SSL_VERIFY_NONE ) { mbedtls_x509_crt *ca_chain; @@ -4773,19 +5744,24 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) /* * Main check: verify certificate */ - ret = mbedtls_x509_crt_verify_with_profile( + ret = mbedtls_x509_crt_verify_restartable( ssl->session_negotiate->peer_cert, ca_chain, ca_crl, ssl->conf->cert_profile, ssl->hostname, &ssl->session_negotiate->verify_result, - ssl->conf->f_vrfy, ssl->conf->p_vrfy ); + ssl->conf->f_vrfy, ssl->conf->p_vrfy, rs_ctx ); if( ret != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "x509_verify_cert", ret ); } +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + return( MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ); +#endif + /* * Secondary checks: always done, but change 'ret' only if it was 0 */ @@ -4838,6 +5814,8 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) if( ret != 0 ) { + uint8_t alert; + /* The certificate may have been rejected for several reasons. Pick one and send the corresponding alert. Which alert to send may be a subject of debate in some cases. */ @@ -4880,6 +5858,8 @@ int mbedtls_ssl_parse_certificate( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_DEBUG_C */ } + ssl->state++; + MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= parse certificate" ) ); return( ret ); @@ -4904,9 +5884,9 @@ int mbedtls_ssl_write_change_cipher_spec( mbedtls_ssl_context *ssl ) ssl->state++; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } @@ -4921,7 +5901,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> parse change cipher spec" ) ); - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -4935,13 +5915,8 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); } - if( ssl->in_msglen != 1 || ssl->in_msg[0] != 1 ) - { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "bad change cipher spec message" ) ); - mbedtls_ssl_send_alert_message( ssl, MBEDTLS_SSL_ALERT_LEVEL_FATAL, - MBEDTLS_SSL_ALERT_MSG_DECODE_ERROR ); - return( MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC ); - } + /* CCS records are only accepted if they have length 1 and content '1', + * so we don't need to check this here. */ /* * Switch to our negotiated transform and session parameters for inbound @@ -4971,16 +5946,7 @@ int mbedtls_ssl_parse_change_cipher_spec( mbedtls_ssl_context *ssl ) #endif /* MBEDTLS_SSL_PROTO_DTLS */ memset( ssl->in_ctr, 0, 8 ); - /* - * Set the in_msg pointer to the correct location based on IV length - */ - if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) - { - ssl->in_msg = ssl->in_iv + ssl->transform_negotiate->ivlen - - ssl->transform_negotiate->fixed_ivlen; - } - else - ssl->in_msg = ssl->in_iv; + ssl_update_in_pointers( ssl, ssl->transform_negotiate ); #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) if( mbedtls_ssl_hw_record_activate != NULL ) @@ -5171,9 +6137,9 @@ static void ssl_calc_finished_ssl( mbedtls_md5_free( &md5 ); mbedtls_sha1_free( &sha1 ); - mbedtls_zeroize( padbuf, sizeof( padbuf ) ); - mbedtls_zeroize( md5sum, sizeof( md5sum ) ); - mbedtls_zeroize( sha1sum, sizeof( sha1sum ) ); + mbedtls_platform_zeroize( padbuf, sizeof( padbuf ) ); + mbedtls_platform_zeroize( md5sum, sizeof( md5sum ) ); + mbedtls_platform_zeroize( sha1sum, sizeof( sha1sum ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); } @@ -5232,7 +6198,7 @@ static void ssl_calc_finished_tls( mbedtls_md5_free( &md5 ); mbedtls_sha1_free( &sha1 ); - mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + mbedtls_platform_zeroize( padbuf, sizeof( padbuf ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); } @@ -5282,7 +6248,7 @@ static void ssl_calc_finished_tls_sha256( mbedtls_sha256_free( &sha256 ); - mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + mbedtls_platform_zeroize( padbuf, sizeof( padbuf ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); } @@ -5331,7 +6297,7 @@ static void ssl_calc_finished_tls_sha384( mbedtls_sha512_free( &sha512 ); - mbedtls_zeroize( padbuf, sizeof( padbuf ) ); + mbedtls_platform_zeroize( padbuf, sizeof( padbuf ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= calc finished" ) ); } @@ -5345,7 +6311,7 @@ static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl ) /* * Free our handshake params */ - mbedtls_ssl_handshake_free( ssl->handshake ); + mbedtls_ssl_handshake_free( ssl ); mbedtls_free( ssl->handshake ); ssl->handshake = NULL; @@ -5431,16 +6397,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> write finished" ) ); - /* - * Set the out_msg pointer to the correct location based on IV length - */ - if( ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) - { - ssl->out_msg = ssl->out_iv + ssl->transform_negotiate->ivlen - - ssl->transform_negotiate->fixed_ivlen; - } - else - ssl->out_msg = ssl->out_iv; + ssl_update_out_pointers( ssl, ssl->transform_negotiate ); ssl->handshake->calc_finished( ssl, ssl->out_msg + 4, ssl->conf->endpoint ); @@ -5492,14 +6449,14 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) /* Remember current epoch settings for resending */ ssl->handshake->alt_transform_out = ssl->transform_out; - memcpy( ssl->handshake->alt_out_ctr, ssl->out_ctr, 8 ); + memcpy( ssl->handshake->alt_out_ctr, ssl->cur_out_ctr, 8 ); /* Set sequence_number to zero */ - memset( ssl->out_ctr + 2, 0, 6 ); + memset( ssl->cur_out_ctr + 2, 0, 6 ); /* Increment epoch */ for( i = 2; i > 0; i-- ) - if( ++ssl->out_ctr[i - 1] != 0 ) + if( ++ssl->cur_out_ctr[i - 1] != 0 ) break; /* The loop goes to its end iff the counter is wrapping */ @@ -5511,7 +6468,7 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) } else #endif /* MBEDTLS_SSL_PROTO_DTLS */ - memset( ssl->out_ctr, 0, 8 ); + memset( ssl->cur_out_ctr, 0, 8 ); ssl->transform_out = ssl->transform_negotiate; ssl->session_out = ssl->session_negotiate; @@ -5532,11 +6489,20 @@ int mbedtls_ssl_write_finished( mbedtls_ssl_context *ssl ) mbedtls_ssl_send_flight_completed( ssl ); #endif - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); + return( ret ); + } + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_flight_transmit", ret ); return( ret ); } +#endif MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write finished" ) ); @@ -5559,7 +6525,7 @@ int mbedtls_ssl_parse_finished( mbedtls_ssl_context *ssl ) ssl->handshake->calc_finished( ssl, buf, ssl->conf->endpoint ^ 1 ); - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_read_record", ret ); return( ret ); @@ -5671,6 +6637,10 @@ static void ssl_handshake_params_init( mbedtls_ssl_handshake_params *handshake ) #endif #endif +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + mbedtls_x509_crt_restart_init( &handshake->ecrs_ctx ); +#endif + #if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) handshake->sni_authmode = MBEDTLS_SSL_VERIFY_UNSET; #endif @@ -5700,7 +6670,7 @@ static int ssl_handshake_init( mbedtls_ssl_context *ssl ) if( ssl->session_negotiate ) mbedtls_ssl_session_free( ssl->session_negotiate ); if( ssl->handshake ) - mbedtls_ssl_handshake_free( ssl->handshake ); + mbedtls_ssl_handshake_free( ssl ); /* * Either the pointers are now NULL or cleared properly and can be freed. @@ -5790,6 +6760,78 @@ static int ssl_cookie_check_dummy( void *ctx, } #endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY && MBEDTLS_SSL_SRV_C */ +/* Once ssl->out_hdr as the address of the beginning of the + * next outgoing record is set, deduce the other pointers. + * + * Note: For TLS, we save the implicit record sequence number + * (entering MAC computation) in the 8 bytes before ssl->out_hdr, + * and the caller has to make sure there's space for this. + */ + +static void ssl_update_out_pointers( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ssl->out_ctr = ssl->out_hdr + 3; + ssl->out_len = ssl->out_hdr + 11; + ssl->out_iv = ssl->out_hdr + 13; + } + else +#endif + { + ssl->out_ctr = ssl->out_hdr - 8; + ssl->out_len = ssl->out_hdr + 3; + ssl->out_iv = ssl->out_hdr + 5; + } + + /* Adjust out_msg to make space for explicit IV, if used. */ + if( transform != NULL && + ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + ssl->out_msg = ssl->out_iv + transform->ivlen - transform->fixed_ivlen; + } + else + ssl->out_msg = ssl->out_iv; +} + +/* Once ssl->in_hdr as the address of the beginning of the + * next incoming record is set, deduce the other pointers. + * + * Note: For TLS, we save the implicit record sequence number + * (entering MAC computation) in the 8 bytes before ssl->in_hdr, + * and the caller has to make sure there's space for this. + */ + +static void ssl_update_in_pointers( mbedtls_ssl_context *ssl, + mbedtls_ssl_transform *transform ) +{ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ssl->in_ctr = ssl->in_hdr + 3; + ssl->in_len = ssl->in_hdr + 11; + ssl->in_iv = ssl->in_hdr + 13; + } + else +#endif + { + ssl->in_ctr = ssl->in_hdr - 8; + ssl->in_len = ssl->in_hdr + 3; + ssl->in_iv = ssl->in_hdr + 5; + } + + /* Offset in_msg from in_iv to allow space for explicit IV, if used. */ + if( transform != NULL && + ssl->minor_ver >= MBEDTLS_SSL_MINOR_VERSION_2 ) + { + ssl->in_msg = ssl->in_iv + transform->ivlen - transform->fixed_ivlen; + } + else + ssl->in_msg = ssl->in_iv; +} + /* * Initialize an SSL context */ @@ -5801,57 +6843,59 @@ void mbedtls_ssl_init( mbedtls_ssl_context *ssl ) /* * Setup an SSL context */ + +static void ssl_reset_in_out_pointers( mbedtls_ssl_context *ssl ) +{ + /* Set the incoming and outgoing record pointers. */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + { + ssl->out_hdr = ssl->out_buf; + ssl->in_hdr = ssl->in_buf; + } + else +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + { + ssl->out_hdr = ssl->out_buf + 8; + ssl->in_hdr = ssl->in_buf + 8; + } + + /* Derive other internal pointers. */ + ssl_update_out_pointers( ssl, NULL /* no transform enabled */ ); + ssl_update_in_pointers ( ssl, NULL /* no transform enabled */ ); +} + int mbedtls_ssl_setup( mbedtls_ssl_context *ssl, const mbedtls_ssl_config *conf ) { int ret; - const size_t len = MBEDTLS_SSL_BUFFER_LEN; ssl->conf = conf; /* * Prepare base structures */ - ssl->in_buf = NULL; + + /* Set to NULL in case of an error condition */ ssl->out_buf = NULL; - if( ( ssl-> in_buf = mbedtls_calloc( 1, len ) ) == NULL || - ( ssl->out_buf = mbedtls_calloc( 1, len ) ) == NULL ) + + ssl->in_buf = mbedtls_calloc( 1, MBEDTLS_SSL_IN_BUFFER_LEN ); + if( ssl->in_buf == NULL ) { - MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", len ) ); + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", MBEDTLS_SSL_IN_BUFFER_LEN) ); ret = MBEDTLS_ERR_SSL_ALLOC_FAILED; goto error; } -#if defined(MBEDTLS_SSL_PROTO_DTLS) - if( conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) + ssl->out_buf = mbedtls_calloc( 1, MBEDTLS_SSL_OUT_BUFFER_LEN ); + if( ssl->out_buf == NULL ) { - ssl->out_hdr = ssl->out_buf; - ssl->out_ctr = ssl->out_buf + 3; - ssl->out_len = ssl->out_buf + 11; - ssl->out_iv = ssl->out_buf + 13; - ssl->out_msg = ssl->out_buf + 13; - - ssl->in_hdr = ssl->in_buf; - ssl->in_ctr = ssl->in_buf + 3; - ssl->in_len = ssl->in_buf + 11; - ssl->in_iv = ssl->in_buf + 13; - ssl->in_msg = ssl->in_buf + 13; + MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc(%d bytes) failed", MBEDTLS_SSL_OUT_BUFFER_LEN) ); + ret = MBEDTLS_ERR_SSL_ALLOC_FAILED; + goto error; } - else -#endif - { - ssl->out_ctr = ssl->out_buf; - ssl->out_hdr = ssl->out_buf + 8; - ssl->out_len = ssl->out_buf + 11; - ssl->out_iv = ssl->out_buf + 13; - ssl->out_msg = ssl->out_buf + 13; - ssl->in_ctr = ssl->in_buf; - ssl->in_hdr = ssl->in_buf + 8; - ssl->in_len = ssl->in_buf + 11; - ssl->in_iv = ssl->in_buf + 13; - ssl->in_msg = ssl->in_buf + 13; - } + ssl_reset_in_out_pointers( ssl ); if( ( ret = ssl_handshake_init( ssl ) ) != 0 ) goto error; @@ -5893,6 +6937,11 @@ static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) { int ret; +#if !defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) || \ + !defined(MBEDTLS_SSL_SRV_C) + ((void) partial); +#endif + ssl->state = MBEDTLS_SSL_HELLO_REQUEST; /* Cancel any possibly running timer */ @@ -5909,12 +6958,10 @@ static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) ssl->secure_renegotiation = MBEDTLS_SSL_LEGACY_RENEGOTIATION; ssl->in_offt = NULL; + ssl_reset_in_out_pointers( ssl ); - ssl->in_msg = ssl->in_buf + 13; ssl->in_msgtype = 0; ssl->in_msglen = 0; - if( partial == 0 ) - ssl->in_left = 0; #if defined(MBEDTLS_SSL_PROTO_DTLS) ssl->next_record_offset = 0; ssl->in_epoch = 0; @@ -5928,7 +6975,6 @@ static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) ssl->keep_current_message = 0; - ssl->out_msg = ssl->out_buf + 13; ssl->out_msgtype = 0; ssl->out_msglen = 0; ssl->out_left = 0; @@ -5937,16 +6983,23 @@ static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) ssl->split_done = 0; #endif + memset( ssl->cur_out_ctr, 0, sizeof( ssl->cur_out_ctr ) ); + ssl->transform_in = NULL; ssl->transform_out = NULL; ssl->session_in = NULL; ssl->session_out = NULL; - memset( ssl->out_buf, 0, MBEDTLS_SSL_BUFFER_LEN ); + memset( ssl->out_buf, 0, MBEDTLS_SSL_OUT_BUFFER_LEN ); +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) && defined(MBEDTLS_SSL_SRV_C) if( partial == 0 ) - memset( ssl->in_buf, 0, MBEDTLS_SSL_BUFFER_LEN ); +#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE && MBEDTLS_SSL_SRV_C */ + { + ssl->in_left = 0; + memset( ssl->in_buf, 0, MBEDTLS_SSL_IN_BUFFER_LEN ); + } #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) if( mbedtls_ssl_hw_record_reset != NULL ) @@ -5979,7 +7032,9 @@ static int ssl_session_reset_int( mbedtls_ssl_context *ssl, int partial ) #endif #if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) && defined(MBEDTLS_SSL_SRV_C) +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) if( partial == 0 ) +#endif { mbedtls_free( ssl->cli_id ); ssl->cli_id = NULL; @@ -6030,7 +7085,15 @@ void mbedtls_ssl_conf_dtls_badmac_limit( mbedtls_ssl_config *conf, unsigned limi #endif #if defined(MBEDTLS_SSL_PROTO_DTLS) -void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, uint32_t min, uint32_t max ) + +void mbedtls_ssl_set_datagram_packing( mbedtls_ssl_context *ssl, + unsigned allow_packing ) +{ + ssl->disable_datagram_packing = !allow_packing; +} + +void mbedtls_ssl_conf_handshake_timeout( mbedtls_ssl_config *conf, + uint32_t min, uint32_t max ) { conf->hs_timeout_min = min; conf->hs_timeout_max = max; @@ -6080,6 +7143,13 @@ void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl, ssl->f_recv_timeout = f_recv_timeout; } +#if defined(MBEDTLS_SSL_PROTO_DTLS) +void mbedtls_ssl_set_mtu( mbedtls_ssl_context *ssl, uint16_t mtu ) +{ + ssl->mtu = mtu; +} +#endif + void mbedtls_ssl_conf_read_timeout( mbedtls_ssl_config *conf, uint32_t timeout ) { conf->read_timeout = timeout; @@ -6271,14 +7341,14 @@ int mbedtls_ssl_conf_psk( mbedtls_ssl_config *conf, /* Identity len will be encoded on two bytes */ if( ( psk_identity_len >> 16 ) != 0 || - psk_identity_len > MBEDTLS_SSL_MAX_CONTENT_LEN ) + psk_identity_len > MBEDTLS_SSL_OUT_CONTENT_LEN ) { return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); } if( conf->psk != NULL ) { - mbedtls_zeroize( conf->psk, conf->psk_len ); + mbedtls_platform_zeroize( conf->psk, conf->psk_len ); mbedtls_free( conf->psk ); conf->psk = NULL; @@ -6321,7 +7391,8 @@ int mbedtls_ssl_set_hs_psk( mbedtls_ssl_context *ssl, if( ssl->handshake->psk != NULL ) { - mbedtls_zeroize( ssl->handshake->psk, ssl->handshake->psk_len ); + mbedtls_platform_zeroize( ssl->handshake->psk, + ssl->handshake->psk_len ); mbedtls_free( ssl->handshake->psk ); ssl->handshake->psk_len = 0; } @@ -6451,7 +7522,7 @@ int mbedtls_ssl_set_hostname( mbedtls_ssl_context *ssl, const char *hostname ) if( ssl->hostname != NULL ) { - mbedtls_zeroize( ssl->hostname, strlen( ssl->hostname ) ); + mbedtls_platform_zeroize( ssl->hostname, strlen( ssl->hostname ) ); mbedtls_free( ssl->hostname ); } @@ -6571,7 +7642,7 @@ void mbedtls_ssl_conf_arc4_support( mbedtls_ssl_config *conf, char arc4 ) int mbedtls_ssl_conf_max_frag_len( mbedtls_ssl_config *conf, unsigned char mfl_code ) { if( mfl_code >= MBEDTLS_SSL_MAX_FRAG_LEN_INVALID || - mfl_code_to_length[mfl_code] > MBEDTLS_SSL_MAX_CONTENT_LEN ) + ssl_mfl_code_to_length( mfl_code ) > MBEDTLS_TLS_EXT_ADV_CONTENT_LEN ) { return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); } @@ -6650,6 +7721,43 @@ void mbedtls_ssl_conf_export_keys_cb( mbedtls_ssl_config *conf, } #endif +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +void mbedtls_ssl_conf_async_private_cb( + mbedtls_ssl_config *conf, + mbedtls_ssl_async_sign_t *f_async_sign, + mbedtls_ssl_async_decrypt_t *f_async_decrypt, + mbedtls_ssl_async_resume_t *f_async_resume, + mbedtls_ssl_async_cancel_t *f_async_cancel, + void *async_config_data ) +{ + conf->f_async_sign_start = f_async_sign; + conf->f_async_decrypt_start = f_async_decrypt; + conf->f_async_resume = f_async_resume; + conf->f_async_cancel = f_async_cancel; + conf->p_async_config_data = async_config_data; +} + +void *mbedtls_ssl_conf_get_async_config_data( const mbedtls_ssl_config *conf ) +{ + return( conf->p_async_config_data ); +} + +void *mbedtls_ssl_get_async_operation_data( const mbedtls_ssl_context *ssl ) +{ + if( ssl->handshake == NULL ) + return( NULL ); + else + return( ssl->handshake->user_async_ctx ); +} + +void mbedtls_ssl_set_async_operation_data( mbedtls_ssl_context *ssl, + void *ctx ) +{ + if( ssl->handshake != NULL ) + ssl->handshake->user_async_ctx = ctx; +} +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + /* * SSL get accessors */ @@ -6658,6 +7766,61 @@ size_t mbedtls_ssl_get_bytes_avail( const mbedtls_ssl_context *ssl ) return( ssl->in_offt == NULL ? 0 : ssl->in_msglen ); } +int mbedtls_ssl_check_pending( const mbedtls_ssl_context *ssl ) +{ + /* + * Case A: We're currently holding back + * a message for further processing. + */ + + if( ssl->keep_current_message == 1 ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_check_pending: record held back for processing" ) ); + return( 1 ); + } + + /* + * Case B: Further records are pending in the current datagram. + */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM && + ssl->in_left > ssl->next_record_offset ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_check_pending: more records within current datagram" ) ); + return( 1 ); + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + + /* + * Case C: A handshake message is being processed. + */ + + if( ssl->in_hslen > 0 && ssl->in_hslen < ssl->in_msglen ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_check_pending: more handshake messages within current record" ) ); + return( 1 ); + } + + /* + * Case D: An application data message is being processed + */ + if( ssl->in_offt != NULL ) + { + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_check_pending: application data record is being processed" ) ); + return( 1 ); + } + + /* + * In all other cases, the rest of the message can be dropped. + * As in ssl_get_next_record, this needs to be adapted if + * we implement support for multiple alerts in single records. + */ + + MBEDTLS_SSL_DEBUG_MSG( 3, ( "ssl_check_pending: nothing pending" ) ); + return( 0 ); +} + uint32_t mbedtls_ssl_get_verify_result( const mbedtls_ssl_context *ssl ) { if( ssl->session != NULL ) @@ -6733,6 +7896,7 @@ int mbedtls_ssl_get_record_expansion( const mbedtls_ssl_context *ssl ) { case MBEDTLS_MODE_GCM: case MBEDTLS_MODE_CCM: + case MBEDTLS_MODE_CHACHAPOLY: case MBEDTLS_MODE_STREAM: transform_expansion = transform->minlen; break; @@ -6775,21 +7939,91 @@ size_t mbedtls_ssl_get_max_frag_len( const mbedtls_ssl_context *ssl ) /* * Assume mfl_code is correct since it was checked when set */ - max_len = mfl_code_to_length[ssl->conf->mfl_code]; + max_len = ssl_mfl_code_to_length( ssl->conf->mfl_code ); - /* - * Check if a smaller max length was negotiated - */ + /* Check if a smaller max length was negotiated */ if( ssl->session_out != NULL && - mfl_code_to_length[ssl->session_out->mfl_code] < max_len ) + ssl_mfl_code_to_length( ssl->session_out->mfl_code ) < max_len ) + { + max_len = ssl_mfl_code_to_length( ssl->session_out->mfl_code ); + } + + /* During a handshake, use the value being negotiated */ + if( ssl->session_negotiate != NULL && + ssl_mfl_code_to_length( ssl->session_negotiate->mfl_code ) < max_len ) { - max_len = mfl_code_to_length[ssl->session_out->mfl_code]; + max_len = ssl_mfl_code_to_length( ssl->session_negotiate->mfl_code ); } - return max_len; + return( max_len ); } #endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ +#if defined(MBEDTLS_SSL_PROTO_DTLS) +static size_t ssl_get_current_mtu( const mbedtls_ssl_context *ssl ) +{ + /* Return unlimited mtu for client hello messages to avoid fragmentation. */ + if( ssl->conf->endpoint == MBEDTLS_SSL_IS_CLIENT && + ( ssl->state == MBEDTLS_SSL_CLIENT_HELLO || + ssl->state == MBEDTLS_SSL_SERVER_HELLO ) ) + return ( 0 ); + + if( ssl->handshake == NULL || ssl->handshake->mtu == 0 ) + return( ssl->mtu ); + + if( ssl->mtu == 0 ) + return( ssl->handshake->mtu ); + + return( ssl->mtu < ssl->handshake->mtu ? + ssl->mtu : ssl->handshake->mtu ); +} +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +int mbedtls_ssl_get_max_out_record_payload( const mbedtls_ssl_context *ssl ) +{ + size_t max_len = MBEDTLS_SSL_OUT_CONTENT_LEN; + +#if !defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) && \ + !defined(MBEDTLS_SSL_PROTO_DTLS) + (void) ssl; +#endif + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + const size_t mfl = mbedtls_ssl_get_max_frag_len( ssl ); + + if( max_len > mfl ) + max_len = mfl; +#endif + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( ssl_get_current_mtu( ssl ) != 0 ) + { + const size_t mtu = ssl_get_current_mtu( ssl ); + const int ret = mbedtls_ssl_get_record_expansion( ssl ); + const size_t overhead = (size_t) ret; + + if( ret < 0 ) + return( ret ); + + if( mtu <= overhead ) + { + MBEDTLS_SSL_DEBUG_MSG( 1, ( "MTU too low for record expansion" ) ); + return( MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE ); + } + + if( max_len > mtu - overhead ) + max_len = mtu - overhead; + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +#if !defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) && \ + !defined(MBEDTLS_SSL_PROTO_DTLS) + ((void) ssl); +#endif + + return( (int) max_len ); +} + #if defined(MBEDTLS_X509_CRT_PARSE_C) const mbedtls_x509_crt *mbedtls_ssl_get_peer_cert( const mbedtls_ssl_context *ssl ) { @@ -6877,9 +8111,9 @@ static int ssl_write_hello_request( mbedtls_ssl_context *ssl ) ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE; ssl->out_msg[0] = MBEDTLS_SSL_HS_HELLO_REQUEST; - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_handshake_msg( ssl ) ) != 0 ) { - MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_handshake_msg", ret ); return( ret ); } @@ -7009,7 +8243,7 @@ static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl ) in_ctr_cmp = memcmp( ssl->in_ctr + ep_len, ssl->conf->renego_period + ep_len, 8 - ep_len ); - out_ctr_cmp = memcmp( ssl->out_ctr + ep_len, + out_ctr_cmp = memcmp( ssl->cur_out_ctr + ep_len, ssl->conf->renego_period + ep_len, 8 - ep_len ); if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 ) @@ -7044,7 +8278,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) if( ssl->handshake != NULL && ssl->handshake->retransmit_state == MBEDTLS_SSL_RETRANS_SENDING ) { - if( ( ret = mbedtls_ssl_resend( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_flight_transmit( ssl ) ) != 0 ) return( ret ); } } @@ -7083,7 +8317,8 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) } } - if( ssl->in_offt == NULL ) + /* Loop as long as no application data record is available */ + while( ssl->in_offt == NULL ) { /* Start timer if not already running */ if( ssl->f_get_timer != NULL && @@ -7092,7 +8327,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) ssl_set_timer( ssl, ssl->conf->read_timeout ); } - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { if( ret == MBEDTLS_ERR_SSL_CONN_EOF ) return( 0 ); @@ -7107,7 +8342,7 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) /* * OpenSSL sends empty messages to randomize the IV */ - if( ( ret = mbedtls_ssl_read_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_read_record( ssl, 1 ) ) != 0 ) { if( ret == MBEDTLS_ERR_SSL_CONN_EOF ) return( 0 ); @@ -7137,7 +8372,9 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) /* With DTLS, drop the packet (probably from last handshake) */ #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) - return( MBEDTLS_ERR_SSL_WANT_READ ); + { + continue; + } #endif return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); } @@ -7152,7 +8389,9 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) /* With DTLS, drop the packet (probably from last handshake) */ #if defined(MBEDTLS_SSL_PROTO_DTLS) if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) - return( MBEDTLS_ERR_SSL_WANT_READ ); + { + continue; + } #endif return( MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE ); } @@ -7225,7 +8464,25 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) } } - return( MBEDTLS_ERR_SSL_WANT_READ ); + /* At this point, we don't know whether the renegotiation has been + * completed or not. The cases to consider are the following: + * 1) The renegotiation is complete. In this case, no new record + * has been read yet. + * 2) The renegotiation is incomplete because the client received + * an application data record while awaiting the ServerHello. + * 3) The renegotiation is incomplete because the client received + * a non-handshake, non-application data message while awaiting + * the ServerHello. + * In each of these case, looping will be the proper action: + * - For 1), the next iteration will read a new record and check + * if it's application data. + * - For 2), the loop condition isn't satisfied as application data + * is present, hence continue is the same as break + * - For 3), the loop condition is satisfied and read_record + * will re-deliver the message that was held back by the client + * when expecting the ServerHello. + */ + continue; } #if defined(MBEDTLS_SSL_RENEGOTIATION) else if( ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING ) @@ -7318,12 +8575,15 @@ int mbedtls_ssl_read( mbedtls_ssl_context *ssl, unsigned char *buf, size_t len ) static int ssl_write_real( mbedtls_ssl_context *ssl, const unsigned char *buf, size_t len ) { - int ret; -#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) - size_t max_len = mbedtls_ssl_get_max_frag_len( ssl ); -#else - size_t max_len = MBEDTLS_SSL_MAX_CONTENT_LEN; -#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + int ret = mbedtls_ssl_get_max_out_record_payload( ssl ); + const size_t max_len = (size_t) ret; + + if( ret < 0 ) + { + MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_get_max_out_record_payload", ret ); + return( ret ); + } + if( len > max_len ) { #if defined(MBEDTLS_SSL_PROTO_DTLS) @@ -7364,7 +8624,7 @@ static int ssl_write_real( mbedtls_ssl_context *ssl, ssl->out_msgtype = MBEDTLS_SSL_MSG_APPLICATION_DATA; memcpy( ssl->out_msg, buf, len ); - if( ( ret = mbedtls_ssl_write_record( ssl ) ) != 0 ) + if( ( ret = mbedtls_ssl_write_record( ssl, SSL_FORCE_FLUSH ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_write_record", ret ); return( ret ); @@ -7499,7 +8759,7 @@ void mbedtls_ssl_transform_free( mbedtls_ssl_transform *transform ) mbedtls_md_free( &transform->md_ctx_enc ); mbedtls_md_free( &transform->md_ctx_dec ); - mbedtls_zeroize( transform, sizeof( mbedtls_ssl_transform ) ); + mbedtls_platform_zeroize( transform, sizeof( mbedtls_ssl_transform ) ); } #if defined(MBEDTLS_X509_CRT_PARSE_C) @@ -7516,11 +8776,57 @@ static void ssl_key_cert_free( mbedtls_ssl_key_cert *key_cert ) } #endif /* MBEDTLS_X509_CRT_PARSE_C */ -void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake ) +#if defined(MBEDTLS_SSL_PROTO_DTLS) + +static void ssl_buffering_free( mbedtls_ssl_context *ssl ) { + unsigned offset; + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + + if( hs == NULL ) + return; + + ssl_free_buffered_record( ssl ); + + for( offset = 0; offset < MBEDTLS_SSL_MAX_BUFFERED_HS; offset++ ) + ssl_buffering_free_slot( ssl, offset ); +} + +static void ssl_buffering_free_slot( mbedtls_ssl_context *ssl, + uint8_t slot ) +{ + mbedtls_ssl_handshake_params * const hs = ssl->handshake; + mbedtls_ssl_hs_buffer * const hs_buf = &hs->buffering.hs[slot]; + + if( slot >= MBEDTLS_SSL_MAX_BUFFERED_HS ) + return; + + if( hs_buf->is_valid == 1 ) + { + hs->buffering.total_bytes_buffered -= hs_buf->data_len; + mbedtls_platform_zeroize( hs_buf->data, hs_buf->data_len ); + mbedtls_free( hs_buf->data ); + memset( hs_buf, 0, sizeof( mbedtls_ssl_hs_buffer ) ); + } +} + +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +void mbedtls_ssl_handshake_free( mbedtls_ssl_context *ssl ) +{ + mbedtls_ssl_handshake_params *handshake = ssl->handshake; + if( handshake == NULL ) return; +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( ssl->conf->f_async_cancel != NULL && handshake->async_in_progress != 0 ) + { + ssl->conf->f_async_cancel( ssl ); + handshake->async_in_progress = 0; + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + #if defined(MBEDTLS_SSL_PROTO_SSL3) || defined(MBEDTLS_SSL_PROTO_TLS1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_1) mbedtls_md5_free( &handshake->fin_md5 ); @@ -7559,7 +8865,7 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake ) #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) if( handshake->psk != NULL ) { - mbedtls_zeroize( handshake->psk, handshake->psk_len ); + mbedtls_platform_zeroize( handshake->psk, handshake->psk_len ); mbedtls_free( handshake->psk ); } #endif @@ -7583,13 +8889,18 @@ void mbedtls_ssl_handshake_free( mbedtls_ssl_handshake_params *handshake ) } #endif /* MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_SSL_SERVER_NAME_INDICATION */ +#if defined(MBEDTLS_SSL__ECP_RESTARTABLE) + mbedtls_x509_crt_restart_free( &handshake->ecrs_ctx ); +#endif + #if defined(MBEDTLS_SSL_PROTO_DTLS) mbedtls_free( handshake->verify_cookie ); - mbedtls_free( handshake->hs_msg ); ssl_flight_free( handshake->flight ); + ssl_buffering_free( ssl ); #endif - mbedtls_zeroize( handshake, sizeof( mbedtls_ssl_handshake_params ) ); + mbedtls_platform_zeroize( handshake, + sizeof( mbedtls_ssl_handshake_params ) ); } void mbedtls_ssl_session_free( mbedtls_ssl_session *session ) @@ -7609,7 +8920,7 @@ void mbedtls_ssl_session_free( mbedtls_ssl_session *session ) mbedtls_free( session->ticket ); #endif - mbedtls_zeroize( session, sizeof( mbedtls_ssl_session ) ); + mbedtls_platform_zeroize( session, sizeof( mbedtls_ssl_session ) ); } /* @@ -7624,20 +8935,20 @@ void mbedtls_ssl_free( mbedtls_ssl_context *ssl ) if( ssl->out_buf != NULL ) { - mbedtls_zeroize( ssl->out_buf, MBEDTLS_SSL_BUFFER_LEN ); + mbedtls_platform_zeroize( ssl->out_buf, MBEDTLS_SSL_OUT_BUFFER_LEN ); mbedtls_free( ssl->out_buf ); } if( ssl->in_buf != NULL ) { - mbedtls_zeroize( ssl->in_buf, MBEDTLS_SSL_BUFFER_LEN ); + mbedtls_platform_zeroize( ssl->in_buf, MBEDTLS_SSL_IN_BUFFER_LEN ); mbedtls_free( ssl->in_buf ); } #if defined(MBEDTLS_ZLIB_SUPPORT) if( ssl->compress_buf != NULL ) { - mbedtls_zeroize( ssl->compress_buf, MBEDTLS_SSL_BUFFER_LEN ); + mbedtls_platform_zeroize( ssl->compress_buf, MBEDTLS_SSL_COMPRESS_BUFFER_LEN ); mbedtls_free( ssl->compress_buf ); } #endif @@ -7650,7 +8961,7 @@ void mbedtls_ssl_free( mbedtls_ssl_context *ssl ) if( ssl->handshake ) { - mbedtls_ssl_handshake_free( ssl->handshake ); + mbedtls_ssl_handshake_free( ssl ); mbedtls_ssl_transform_free( ssl->transform_negotiate ); mbedtls_ssl_session_free( ssl->session_negotiate ); @@ -7668,7 +8979,7 @@ void mbedtls_ssl_free( mbedtls_ssl_context *ssl ) #if defined(MBEDTLS_X509_CRT_PARSE_C) if( ssl->hostname != NULL ) { - mbedtls_zeroize( ssl->hostname, strlen( ssl->hostname ) ); + mbedtls_platform_zeroize( ssl->hostname, strlen( ssl->hostname ) ); mbedtls_free( ssl->hostname ); } #endif @@ -7688,7 +8999,7 @@ void mbedtls_ssl_free( mbedtls_ssl_context *ssl ) MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= free" ) ); /* Actually clear after last debug message */ - mbedtls_zeroize( ssl, sizeof( mbedtls_ssl_context ) ); + mbedtls_platform_zeroize( ssl, sizeof( mbedtls_ssl_context ) ); } /* @@ -7915,11 +9226,17 @@ void mbedtls_ssl_config_free( mbedtls_ssl_config *conf ) #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) if( conf->psk != NULL ) { - mbedtls_zeroize( conf->psk, conf->psk_len ); - mbedtls_zeroize( conf->psk_identity, conf->psk_identity_len ); + mbedtls_platform_zeroize( conf->psk, conf->psk_len ); mbedtls_free( conf->psk ); - mbedtls_free( conf->psk_identity ); + conf->psk = NULL; conf->psk_len = 0; + } + + if( conf->psk_identity != NULL ) + { + mbedtls_platform_zeroize( conf->psk_identity, conf->psk_identity_len ); + mbedtls_free( conf->psk_identity ); + conf->psk_identity = NULL; conf->psk_identity_len = 0; } #endif @@ -7928,7 +9245,7 @@ void mbedtls_ssl_config_free( mbedtls_ssl_config *conf ) ssl_key_cert_free( conf->key_cert ); #endif - mbedtls_zeroize( conf, sizeof( mbedtls_ssl_config ) ); + mbedtls_platform_zeroize( conf, sizeof( mbedtls_ssl_config ) ); } #if defined(MBEDTLS_PK_C) && \ @@ -8411,13 +9728,14 @@ int mbedtls_ssl_get_key_exchange_md_ssl_tls( mbedtls_ssl_context *ssl, #if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1) || \ defined(MBEDTLS_SSL_PROTO_TLS1_2) int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl, - unsigned char *output, - unsigned char *data, size_t data_len, - mbedtls_md_type_t md_alg ) + unsigned char *hash, size_t *hashlen, + unsigned char *data, size_t data_len, + mbedtls_md_type_t md_alg ) { int ret = 0; mbedtls_md_context_t ctx; const mbedtls_md_info_t *md_info = mbedtls_md_info_from_type( md_alg ); + *hashlen = mbedtls_md_get_size( md_info ); mbedtls_md_init( &ctx ); @@ -8448,7 +9766,7 @@ int mbedtls_ssl_get_key_exchange_md_tls1_2( mbedtls_ssl_context *ssl, MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_update", ret ); goto exit; } - if( ( ret = mbedtls_md_finish( &ctx, output ) ) != 0 ) + if( ( ret = mbedtls_md_finish( &ctx, hash ) ) != 0 ) { MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_md_finish", ret ); goto exit; diff --git a/3rdparty/mbedtls/mbedtls/library/threading.c b/3rdparty/mbedtls/mbedtls/library/threading.c index f1c37245c7..7c90c7c595 100644 --- a/3rdparty/mbedtls/mbedtls/library/threading.c +++ b/3rdparty/mbedtls/mbedtls/library/threading.c @@ -19,6 +19,14 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +/* + * Ensure gmtime_r is available even with -std=c99; must be defined before + * config.h, which pulls in glibc's features.h. Harmless on other platforms. + */ +#if !defined(_POSIX_C_SOURCE) +#define _POSIX_C_SOURCE 200112L +#endif + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -29,6 +37,36 @@ #include "mbedtls/threading.h" +#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) + +#if !defined(_WIN32) && (defined(unix) || \ + defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ + defined(__MACH__))) +#include +#endif /* !_WIN32 && (unix || __unix || __unix__ || + * (__APPLE__ && __MACH__)) */ + +#if !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ + ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ + _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) +/* + * This is a convenience shorthand macro to avoid checking the long + * preprocessor conditions above. Ideally, we could expose this macro in + * platform_util.h and simply use it in platform_util.c, threading.c and + * threading.h. However, this macro is not part of the Mbed TLS public API, so + * we keep it private by only defining it in this file + */ + +#if ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) +#define THREADING_USE_GMTIME +#endif /* ! ( defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) ) */ + +#endif /* !( ( defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L ) || \ + ( defined(_POSIX_THREAD_SAFE_FUNCTIONS ) && \ + _POSIX_THREAD_SAFE_FUNCTIONS >= 20112L ) ) */ + +#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */ + #if defined(MBEDTLS_THREADING_PTHREAD) static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *mutex ) { @@ -114,7 +152,7 @@ void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * #if defined(MBEDTLS_FS_IO) mbedtls_mutex_init( &mbedtls_threading_readdir_mutex ); #endif -#if defined(MBEDTLS_HAVE_TIME_DATE) +#if defined(THREADING_USE_GMTIME) mbedtls_mutex_init( &mbedtls_threading_gmtime_mutex ); #endif } @@ -127,7 +165,7 @@ void mbedtls_threading_free_alt( void ) #if defined(MBEDTLS_FS_IO) mbedtls_mutex_free( &mbedtls_threading_readdir_mutex ); #endif -#if defined(MBEDTLS_HAVE_TIME_DATE) +#if defined(THREADING_USE_GMTIME) mbedtls_mutex_free( &mbedtls_threading_gmtime_mutex ); #endif } @@ -142,7 +180,7 @@ void mbedtls_threading_free_alt( void ) #if defined(MBEDTLS_FS_IO) mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex MUTEX_INIT; #endif -#if defined(MBEDTLS_HAVE_TIME_DATE) +#if defined(THREADING_USE_GMTIME) mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex MUTEX_INIT; #endif diff --git a/3rdparty/mbedtls/mbedtls/library/timing.c b/3rdparty/mbedtls/mbedtls/library/timing.c index 8b9038326e..413d133fb6 100644 --- a/3rdparty/mbedtls/mbedtls/library/timing.c +++ b/3rdparty/mbedtls/mbedtls/library/timing.c @@ -39,7 +39,8 @@ #if !defined(MBEDTLS_TIMING_ALT) #if !defined(unix) && !defined(__unix__) && !defined(__unix) && \ - !defined(__APPLE__) && !defined(_WIN32) + !defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \ + !defined(__HAIKU__) #error "This module only works on Unix and Windows, see MBEDTLS_TIMING_C in config.h" #endif diff --git a/3rdparty/mbedtls/mbedtls/library/version.c b/3rdparty/mbedtls/mbedtls/library/version.c index 6ca80d4695..fd96750885 100644 --- a/3rdparty/mbedtls/mbedtls/library/version.c +++ b/3rdparty/mbedtls/mbedtls/library/version.c @@ -30,7 +30,7 @@ #include "mbedtls/version.h" #include -unsigned int mbedtls_version_get_number() +unsigned int mbedtls_version_get_number( void ) { return( MBEDTLS_VERSION_NUMBER ); } diff --git a/3rdparty/mbedtls/mbedtls/library/version_features.c b/3rdparty/mbedtls/mbedtls/library/version_features.c index da47e3d753..24143d052c 100644 --- a/3rdparty/mbedtls/mbedtls/library/version_features.c +++ b/3rdparty/mbedtls/mbedtls/library/version_features.c @@ -39,6 +39,9 @@ static const char *features[] = { #if defined(MBEDTLS_NO_UDBL_DIVISION) "MBEDTLS_NO_UDBL_DIVISION", #endif /* MBEDTLS_NO_UDBL_DIVISION */ +#if defined(MBEDTLS_NO_64BIT_MULTIPLICATION) + "MBEDTLS_NO_64BIT_MULTIPLICATION", +#endif /* MBEDTLS_NO_64BIT_MULTIPLICATION */ #if defined(MBEDTLS_HAVE_SSE2) "MBEDTLS_HAVE_SSE2", #endif /* MBEDTLS_HAVE_SSE2 */ @@ -81,6 +84,9 @@ static const char *features[] = { #if defined(MBEDTLS_DEPRECATED_REMOVED) "MBEDTLS_DEPRECATED_REMOVED", #endif /* MBEDTLS_DEPRECATED_REMOVED */ +#if defined(MBEDTLS_CHECK_PARAMS) + "MBEDTLS_CHECK_PARAMS", +#endif /* MBEDTLS_CHECK_PARAMS */ #if defined(MBEDTLS_TIMING_ALT) "MBEDTLS_TIMING_ALT", #endif /* MBEDTLS_TIMING_ALT */ @@ -90,6 +96,9 @@ static const char *features[] = { #if defined(MBEDTLS_ARC4_ALT) "MBEDTLS_ARC4_ALT", #endif /* MBEDTLS_ARC4_ALT */ +#if defined(MBEDTLS_ARIA_ALT) + "MBEDTLS_ARIA_ALT", +#endif /* MBEDTLS_ARIA_ALT */ #if defined(MBEDTLS_BLOWFISH_ALT) "MBEDTLS_BLOWFISH_ALT", #endif /* MBEDTLS_BLOWFISH_ALT */ @@ -99,6 +108,12 @@ static const char *features[] = { #if defined(MBEDTLS_CCM_ALT) "MBEDTLS_CCM_ALT", #endif /* MBEDTLS_CCM_ALT */ +#if defined(MBEDTLS_CHACHA20_ALT) + "MBEDTLS_CHACHA20_ALT", +#endif /* MBEDTLS_CHACHA20_ALT */ +#if defined(MBEDTLS_CHACHAPOLY_ALT) + "MBEDTLS_CHACHAPOLY_ALT", +#endif /* MBEDTLS_CHACHAPOLY_ALT */ #if defined(MBEDTLS_CMAC_ALT) "MBEDTLS_CMAC_ALT", #endif /* MBEDTLS_CMAC_ALT */ @@ -114,6 +129,9 @@ static const char *features[] = { #if defined(MBEDTLS_GCM_ALT) "MBEDTLS_GCM_ALT", #endif /* MBEDTLS_GCM_ALT */ +#if defined(MBEDTLS_NIST_KW_ALT) + "MBEDTLS_NIST_KW_ALT", +#endif /* MBEDTLS_NIST_KW_ALT */ #if defined(MBEDTLS_MD2_ALT) "MBEDTLS_MD2_ALT", #endif /* MBEDTLS_MD2_ALT */ @@ -123,6 +141,9 @@ static const char *features[] = { #if defined(MBEDTLS_MD5_ALT) "MBEDTLS_MD5_ALT", #endif /* MBEDTLS_MD5_ALT */ +#if defined(MBEDTLS_POLY1305_ALT) + "MBEDTLS_POLY1305_ALT", +#endif /* MBEDTLS_POLY1305_ALT */ #if defined(MBEDTLS_RIPEMD160_ALT) "MBEDTLS_RIPEMD160_ALT", #endif /* MBEDTLS_RIPEMD160_ALT */ @@ -237,6 +258,9 @@ static const char *features[] = { #if defined(MBEDTLS_AES_ROM_TABLES) "MBEDTLS_AES_ROM_TABLES", #endif /* MBEDTLS_AES_ROM_TABLES */ +#if defined(MBEDTLS_AES_FEWER_TABLES) + "MBEDTLS_AES_FEWER_TABLES", +#endif /* MBEDTLS_AES_FEWER_TABLES */ #if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY) "MBEDTLS_CAMELLIA_SMALL_MEMORY", #endif /* MBEDTLS_CAMELLIA_SMALL_MEMORY */ @@ -249,6 +273,12 @@ static const char *features[] = { #if defined(MBEDTLS_CIPHER_MODE_CTR) "MBEDTLS_CIPHER_MODE_CTR", #endif /* MBEDTLS_CIPHER_MODE_CTR */ +#if defined(MBEDTLS_CIPHER_MODE_OFB) + "MBEDTLS_CIPHER_MODE_OFB", +#endif /* MBEDTLS_CIPHER_MODE_OFB */ +#if defined(MBEDTLS_CIPHER_MODE_XTS) + "MBEDTLS_CIPHER_MODE_XTS", +#endif /* MBEDTLS_CIPHER_MODE_XTS */ #if defined(MBEDTLS_CIPHER_NULL_CIPHER) "MBEDTLS_CIPHER_NULL_CIPHER", #endif /* MBEDTLS_CIPHER_NULL_CIPHER */ @@ -270,6 +300,9 @@ static const char *features[] = { #if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES) "MBEDTLS_REMOVE_ARC4_CIPHERSUITES", #endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */ +#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES) + "MBEDTLS_REMOVE_3DES_CIPHERSUITES", +#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */ #if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) "MBEDTLS_ECP_DP_SECP192R1_ENABLED", #endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ @@ -306,9 +339,15 @@ static const char *features[] = { #if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) "MBEDTLS_ECP_DP_CURVE25519_ENABLED", #endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) + "MBEDTLS_ECP_DP_CURVE448_ENABLED", +#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ #if defined(MBEDTLS_ECP_NIST_OPTIM) "MBEDTLS_ECP_NIST_OPTIM", #endif /* MBEDTLS_ECP_NIST_OPTIM */ +#if defined(MBEDTLS_ECP_RESTARTABLE) + "MBEDTLS_ECP_RESTARTABLE", +#endif /* MBEDTLS_ECP_RESTARTABLE */ #if defined(MBEDTLS_ECDSA_DETERMINISTIC) "MBEDTLS_ECDSA_DETERMINISTIC", #endif /* MBEDTLS_ECDSA_DETERMINISTIC */ @@ -396,6 +435,9 @@ static const char *features[] = { #if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES) "MBEDTLS_SSL_ALL_ALERT_MESSAGES", #endif /* MBEDTLS_SSL_ALL_ALERT_MESSAGES */ +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + "MBEDTLS_SSL_ASYNC_PRIVATE", +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ #if defined(MBEDTLS_SSL_DEBUG_ALL) "MBEDTLS_SSL_DEBUG_ALL", #endif /* MBEDTLS_SSL_DEBUG_ALL */ @@ -525,12 +567,21 @@ static const char *features[] = { #if defined(MBEDTLS_CAMELLIA_C) "MBEDTLS_CAMELLIA_C", #endif /* MBEDTLS_CAMELLIA_C */ +#if defined(MBEDTLS_ARIA_C) + "MBEDTLS_ARIA_C", +#endif /* MBEDTLS_ARIA_C */ #if defined(MBEDTLS_CCM_C) "MBEDTLS_CCM_C", #endif /* MBEDTLS_CCM_C */ #if defined(MBEDTLS_CERTS_C) "MBEDTLS_CERTS_C", #endif /* MBEDTLS_CERTS_C */ +#if defined(MBEDTLS_CHACHA20_C) + "MBEDTLS_CHACHA20_C", +#endif /* MBEDTLS_CHACHA20_C */ +#if defined(MBEDTLS_CHACHAPOLY_C) + "MBEDTLS_CHACHAPOLY_C", +#endif /* MBEDTLS_CHACHAPOLY_C */ #if defined(MBEDTLS_CIPHER_C) "MBEDTLS_CIPHER_C", #endif /* MBEDTLS_CIPHER_C */ @@ -573,9 +624,15 @@ static const char *features[] = { #if defined(MBEDTLS_HAVEGE_C) "MBEDTLS_HAVEGE_C", #endif /* MBEDTLS_HAVEGE_C */ +#if defined(MBEDTLS_HKDF_C) + "MBEDTLS_HKDF_C", +#endif /* MBEDTLS_HKDF_C */ #if defined(MBEDTLS_HMAC_DRBG_C) "MBEDTLS_HMAC_DRBG_C", #endif /* MBEDTLS_HMAC_DRBG_C */ +#if defined(MBEDTLS_NIST_KW_C) + "MBEDTLS_NIST_KW_C", +#endif /* MBEDTLS_NIST_KW_C */ #if defined(MBEDTLS_MD_C) "MBEDTLS_MD_C", #endif /* MBEDTLS_MD_C */ @@ -627,6 +684,9 @@ static const char *features[] = { #if defined(MBEDTLS_PLATFORM_C) "MBEDTLS_PLATFORM_C", #endif /* MBEDTLS_PLATFORM_C */ +#if defined(MBEDTLS_POLY1305_C) + "MBEDTLS_POLY1305_C", +#endif /* MBEDTLS_POLY1305_C */ #if defined(MBEDTLS_RIPEMD160_C) "MBEDTLS_RIPEMD160_C", #endif /* MBEDTLS_RIPEMD160_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/x509.c b/3rdparty/mbedtls/mbedtls/library/x509.c index 264c7fb0c6..a562df7ca3 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509.c +++ b/3rdparty/mbedtls/mbedtls/library/x509.c @@ -59,19 +59,23 @@ #define mbedtls_snprintf snprintf #endif - #if defined(MBEDTLS_HAVE_TIME) #include "mbedtls/platform_time.h" #endif - -#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) -#include -#else +#if defined(MBEDTLS_HAVE_TIME_DATE) +#include "mbedtls/platform_util.h" #include #endif -#define CHECK(code) if( ( ret = code ) != 0 ){ return( ret ); } -#define CHECK_RANGE(min, max, val) if( val < min || val > max ){ return( ret ); } +#define CHECK(code) if( ( ret = ( code ) ) != 0 ){ return( ret ); } +#define CHECK_RANGE(min, max, val) \ + do \ + { \ + if( ( val ) < ( min ) || ( val ) > ( max ) ) \ + { \ + return( ret ); \ + } \ + } while( 0 ) /* * CertificateSerialNumber ::= INTEGER @@ -357,6 +361,8 @@ static int x509_get_attr_type_value( unsigned char **p, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) return( MBEDTLS_ERR_X509_INVALID_NAME + ret ); + end = *p + len; + if( ( end - *p ) < 1 ) return( MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA ); @@ -390,6 +396,12 @@ static int x509_get_attr_type_value( unsigned char **p, val->p = *p; *p += val->len; + if( *p != end ) + { + return( MBEDTLS_ERR_X509_INVALID_NAME + + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); + } + cur->next = NULL; return( 0 ); @@ -696,30 +708,25 @@ int mbedtls_x509_get_sig_alg( const mbedtls_x509_buf *sig_oid, const mbedtls_x50 * be either manually updated or extensions should be parsed!) */ int mbedtls_x509_get_ext( unsigned char **p, const unsigned char *end, - mbedtls_x509_buf *ext, int tag ) + mbedtls_x509_buf *ext, int tag ) { int ret; size_t len; - if( *p == end ) - return( 0 ); - - ext->tag = **p; - - if( ( ret = mbedtls_asn1_get_tag( p, end, &ext->len, - MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | tag ) ) != 0 ) - return( ret ); + /* Extension structure use EXPLICIT tagging. That is, the actual + * `Extensions` structure is wrapped by a tag-length pair using + * the respective context-specific tag. */ + ret = mbedtls_asn1_get_tag( p, end, &ext->len, + MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | tag ); + if( ret != 0 ) + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + ret ); - ext->p = *p; - end = *p + ext->len; + ext->tag = MBEDTLS_ASN1_CONTEXT_SPECIFIC | MBEDTLS_ASN1_CONSTRUCTED | tag; + ext->p = *p; + end = *p + ext->len; /* * Extensions ::= SEQUENCE SIZE (1..MAX) OF Extension - * - * Extension ::= SEQUENCE { - * extnID OBJECT IDENTIFIER, - * critical BOOLEAN DEFAULT FALSE, - * extnValue OCTET STRING } */ if( ( ret = mbedtls_asn1_get_tag( p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) @@ -894,36 +901,14 @@ int mbedtls_x509_key_size_helper( char *buf, size_t buf_size, const char *name ) * Set the time structure to the current time. * Return 0 on success, non-zero on failure. */ -#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) -static int x509_get_current_time( mbedtls_x509_time *now ) -{ - SYSTEMTIME st; - - GetSystemTime( &st ); - - now->year = st.wYear; - now->mon = st.wMonth; - now->day = st.wDay; - now->hour = st.wHour; - now->min = st.wMinute; - now->sec = st.wSecond; - - return( 0 ); -} -#else static int x509_get_current_time( mbedtls_x509_time *now ) { - struct tm *lt; + struct tm *lt, tm_buf; mbedtls_time_t tt; int ret = 0; -#if defined(MBEDTLS_THREADING_C) - if( mbedtls_mutex_lock( &mbedtls_threading_gmtime_mutex ) != 0 ) - return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); -#endif - tt = mbedtls_time( NULL ); - lt = gmtime( &tt ); + lt = mbedtls_platform_gmtime_r( &tt, &tm_buf ); if( lt == NULL ) ret = -1; @@ -937,14 +922,8 @@ static int x509_get_current_time( mbedtls_x509_time *now ) now->sec = lt->tm_sec; } -#if defined(MBEDTLS_THREADING_C) - if( mbedtls_mutex_unlock( &mbedtls_threading_gmtime_mutex ) != 0 ) - return( MBEDTLS_ERR_THREADING_MUTEX_ERROR ); -#endif - return( ret ); } -#endif /* _WIN32 && !EFIX64 && !EFI32 */ /* * Return 0 if before <= after, 1 otherwise @@ -1032,8 +1011,8 @@ int mbedtls_x509_time_is_future( const mbedtls_x509_time *from ) */ int mbedtls_x509_self_test( int verbose ) { + int ret = 0; #if defined(MBEDTLS_CERTS_C) && defined(MBEDTLS_SHA256_C) - int ret; uint32_t flags; mbedtls_x509_crt cacert; mbedtls_x509_crt clicert; @@ -1041,6 +1020,7 @@ int mbedtls_x509_self_test( int verbose ) if( verbose != 0 ) mbedtls_printf( " X.509 certificate load: " ); + mbedtls_x509_crt_init( &cacert ); mbedtls_x509_crt_init( &clicert ); ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt, @@ -1050,11 +1030,9 @@ int mbedtls_x509_self_test( int verbose ) if( verbose != 0 ) mbedtls_printf( "failed\n" ); - return( ret ); + goto cleanup; } - mbedtls_x509_crt_init( &cacert ); - ret = mbedtls_x509_crt_parse( &cacert, (const unsigned char *) mbedtls_test_ca_crt, mbedtls_test_ca_crt_len ); if( ret != 0 ) @@ -1062,7 +1040,7 @@ int mbedtls_x509_self_test( int verbose ) if( verbose != 0 ) mbedtls_printf( "failed\n" ); - return( ret ); + goto cleanup; } if( verbose != 0 ) @@ -1074,20 +1052,19 @@ int mbedtls_x509_self_test( int verbose ) if( verbose != 0 ) mbedtls_printf( "failed\n" ); - return( ret ); + goto cleanup; } if( verbose != 0 ) mbedtls_printf( "passed\n\n"); +cleanup: mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &clicert ); - - return( 0 ); #else ((void) verbose); - return( 0 ); #endif /* MBEDTLS_CERTS_C && MBEDTLS_SHA1_C */ + return( ret ); } #endif /* MBEDTLS_SELF_TEST */ diff --git a/3rdparty/mbedtls/mbedtls/library/x509_create.c b/3rdparty/mbedtls/mbedtls/library/x509_create.c index df20ec8ebd..546e8fa1a9 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509_create.c +++ b/3rdparty/mbedtls/mbedtls/library/x509_create.c @@ -33,48 +33,84 @@ #include +/* Structure linking OIDs for X.509 DN AttributeTypes to their + * string representations and default string encodings used by Mbed TLS. */ typedef struct { - const char *name; - size_t name_len; - const char*oid; + const char *name; /* String representation of AttributeType, e.g. + * "CN" or "emailAddress". */ + size_t name_len; /* Length of 'name', without trailing 0 byte. */ + const char *oid; /* String representation of OID of AttributeType, + * as per RFC 5280, Appendix A.1. */ + int default_tag; /* The default character encoding used for the + * given attribute type, e.g. + * MBEDTLS_ASN1_UTF8_STRING for UTF-8. */ } x509_attr_descriptor_t; #define ADD_STRLEN( s ) s, sizeof( s ) - 1 +/* X.509 DN attributes from RFC 5280, Appendix A.1. */ static const x509_attr_descriptor_t x509_attrs[] = { - { ADD_STRLEN( "CN" ), MBEDTLS_OID_AT_CN }, - { ADD_STRLEN( "commonName" ), MBEDTLS_OID_AT_CN }, - { ADD_STRLEN( "C" ), MBEDTLS_OID_AT_COUNTRY }, - { ADD_STRLEN( "countryName" ), MBEDTLS_OID_AT_COUNTRY }, - { ADD_STRLEN( "O" ), MBEDTLS_OID_AT_ORGANIZATION }, - { ADD_STRLEN( "organizationName" ), MBEDTLS_OID_AT_ORGANIZATION }, - { ADD_STRLEN( "L" ), MBEDTLS_OID_AT_LOCALITY }, - { ADD_STRLEN( "locality" ), MBEDTLS_OID_AT_LOCALITY }, - { ADD_STRLEN( "R" ), MBEDTLS_OID_PKCS9_EMAIL }, - { ADD_STRLEN( "OU" ), MBEDTLS_OID_AT_ORG_UNIT }, - { ADD_STRLEN( "organizationalUnitName" ), MBEDTLS_OID_AT_ORG_UNIT }, - { ADD_STRLEN( "ST" ), MBEDTLS_OID_AT_STATE }, - { ADD_STRLEN( "stateOrProvinceName" ), MBEDTLS_OID_AT_STATE }, - { ADD_STRLEN( "emailAddress" ), MBEDTLS_OID_PKCS9_EMAIL }, - { ADD_STRLEN( "serialNumber" ), MBEDTLS_OID_AT_SERIAL_NUMBER }, - { ADD_STRLEN( "postalAddress" ), MBEDTLS_OID_AT_POSTAL_ADDRESS }, - { ADD_STRLEN( "postalCode" ), MBEDTLS_OID_AT_POSTAL_CODE }, - { ADD_STRLEN( "dnQualifier" ), MBEDTLS_OID_AT_DN_QUALIFIER }, - { ADD_STRLEN( "title" ), MBEDTLS_OID_AT_TITLE }, - { ADD_STRLEN( "surName" ), MBEDTLS_OID_AT_SUR_NAME }, - { ADD_STRLEN( "SN" ), MBEDTLS_OID_AT_SUR_NAME }, - { ADD_STRLEN( "givenName" ), MBEDTLS_OID_AT_GIVEN_NAME }, - { ADD_STRLEN( "GN" ), MBEDTLS_OID_AT_GIVEN_NAME }, - { ADD_STRLEN( "initials" ), MBEDTLS_OID_AT_INITIALS }, - { ADD_STRLEN( "pseudonym" ), MBEDTLS_OID_AT_PSEUDONYM }, - { ADD_STRLEN( "generationQualifier" ), MBEDTLS_OID_AT_GENERATION_QUALIFIER }, - { ADD_STRLEN( "domainComponent" ), MBEDTLS_OID_DOMAIN_COMPONENT }, - { ADD_STRLEN( "DC" ), MBEDTLS_OID_DOMAIN_COMPONENT }, - { NULL, 0, NULL } + { ADD_STRLEN( "CN" ), + MBEDTLS_OID_AT_CN, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "commonName" ), + MBEDTLS_OID_AT_CN, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "C" ), + MBEDTLS_OID_AT_COUNTRY, MBEDTLS_ASN1_PRINTABLE_STRING }, + { ADD_STRLEN( "countryName" ), + MBEDTLS_OID_AT_COUNTRY, MBEDTLS_ASN1_PRINTABLE_STRING }, + { ADD_STRLEN( "O" ), + MBEDTLS_OID_AT_ORGANIZATION, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "organizationName" ), + MBEDTLS_OID_AT_ORGANIZATION, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "L" ), + MBEDTLS_OID_AT_LOCALITY, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "locality" ), + MBEDTLS_OID_AT_LOCALITY, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "R" ), + MBEDTLS_OID_PKCS9_EMAIL, MBEDTLS_ASN1_IA5_STRING }, + { ADD_STRLEN( "OU" ), + MBEDTLS_OID_AT_ORG_UNIT, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "organizationalUnitName" ), + MBEDTLS_OID_AT_ORG_UNIT, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "ST" ), + MBEDTLS_OID_AT_STATE, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "stateOrProvinceName" ), + MBEDTLS_OID_AT_STATE, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "emailAddress" ), + MBEDTLS_OID_PKCS9_EMAIL, MBEDTLS_ASN1_IA5_STRING }, + { ADD_STRLEN( "serialNumber" ), + MBEDTLS_OID_AT_SERIAL_NUMBER, MBEDTLS_ASN1_PRINTABLE_STRING }, + { ADD_STRLEN( "postalAddress" ), + MBEDTLS_OID_AT_POSTAL_ADDRESS, MBEDTLS_ASN1_PRINTABLE_STRING }, + { ADD_STRLEN( "postalCode" ), + MBEDTLS_OID_AT_POSTAL_CODE, MBEDTLS_ASN1_PRINTABLE_STRING }, + { ADD_STRLEN( "dnQualifier" ), + MBEDTLS_OID_AT_DN_QUALIFIER, MBEDTLS_ASN1_PRINTABLE_STRING }, + { ADD_STRLEN( "title" ), + MBEDTLS_OID_AT_TITLE, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "surName" ), + MBEDTLS_OID_AT_SUR_NAME, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "SN" ), + MBEDTLS_OID_AT_SUR_NAME, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "givenName" ), + MBEDTLS_OID_AT_GIVEN_NAME, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "GN" ), + MBEDTLS_OID_AT_GIVEN_NAME, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "initials" ), + MBEDTLS_OID_AT_INITIALS, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "pseudonym" ), + MBEDTLS_OID_AT_PSEUDONYM, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "generationQualifier" ), + MBEDTLS_OID_AT_GENERATION_QUALIFIER, MBEDTLS_ASN1_UTF8_STRING }, + { ADD_STRLEN( "domainComponent" ), + MBEDTLS_OID_DOMAIN_COMPONENT, MBEDTLS_ASN1_IA5_STRING }, + { ADD_STRLEN( "DC" ), + MBEDTLS_OID_DOMAIN_COMPONENT, MBEDTLS_ASN1_IA5_STRING }, + { NULL, 0, NULL, MBEDTLS_ASN1_NULL } }; -static const char *x509_at_oid_from_name( const char *name, size_t name_len ) +static const x509_attr_descriptor_t *x509_attr_descr_from_name( const char *name, size_t name_len ) { const x509_attr_descriptor_t *cur; @@ -83,7 +119,10 @@ static const char *x509_at_oid_from_name( const char *name, size_t name_len ) strncmp( cur->name, name, name_len ) == 0 ) break; - return( cur->oid ); + if ( cur->name == NULL ) + return( NULL ); + + return( cur ); } int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *name ) @@ -92,6 +131,7 @@ int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *na const char *s = name, *c = s; const char *end = s + strlen( s ); const char *oid = NULL; + const x509_attr_descriptor_t* attr_descr = NULL; int in_tag = 1; char data[MBEDTLS_X509_MAX_DN_NAME_SIZE]; char *d = data; @@ -103,12 +143,13 @@ int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *na { if( in_tag && *c == '=' ) { - if( ( oid = x509_at_oid_from_name( s, c - s ) ) == NULL ) + if( ( attr_descr = x509_attr_descr_from_name( s, c - s ) ) == NULL ) { ret = MBEDTLS_ERR_X509_UNKNOWN_OID; goto exit; } + oid = attr_descr->oid; s = c + 1; in_tag = 0; d = data; @@ -127,13 +168,19 @@ int mbedtls_x509_string_to_names( mbedtls_asn1_named_data **head, const char *na } else if( !in_tag && ( *c == ',' || c == end ) ) { - if( mbedtls_asn1_store_named_data( head, oid, strlen( oid ), - (unsigned char *) data, - d - data ) == NULL ) + mbedtls_asn1_named_data* cur = + mbedtls_asn1_store_named_data( head, oid, strlen( oid ), + (unsigned char *) data, + d - data ); + + if(cur == NULL ) { return( MBEDTLS_ERR_X509_ALLOC_FAILED ); } + // set tagType + cur->val.tag = attr_descr->default_tag; + while( c < end && *(c + 1) == ' ' ) c++; @@ -192,46 +239,40 @@ int mbedtls_x509_set_extension( mbedtls_asn1_named_data **head, const char *oid, * * AttributeValue ::= ANY DEFINED BY AttributeType */ -static int x509_write_name( unsigned char **p, unsigned char *start, - const char *oid, size_t oid_len, - const unsigned char *name, size_t name_len ) +static int x509_write_name( unsigned char **p, unsigned char *start, mbedtls_asn1_named_data* cur_name) { int ret; size_t len = 0; - - // Write PrintableString for all except MBEDTLS_OID_PKCS9_EMAIL - // - if( MBEDTLS_OID_SIZE( MBEDTLS_OID_PKCS9_EMAIL ) == oid_len && - memcmp( oid, MBEDTLS_OID_PKCS9_EMAIL, oid_len ) == 0 ) - { - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_ia5_string( p, start, - (const char *) name, - name_len ) ); - } - else - { - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_printable_string( p, start, - (const char *) name, - name_len ) ); - } - + const char *oid = (const char*)cur_name->oid.p; + size_t oid_len = cur_name->oid.len; + const unsigned char *name = cur_name->val.p; + size_t name_len = cur_name->val.len; + + // Write correct string tag and value + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tagged_string( p, start, + cur_name->val.tag, + (const char *) name, + name_len ) ); // Write OID // - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( p, start, oid, oid_len ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_oid( p, start, oid, + oid_len ) ); MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | - MBEDTLS_ASN1_SEQUENCE ) ); + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, + MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_SEQUENCE ) ); MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_len( p, start, len ) ); - MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, MBEDTLS_ASN1_CONSTRUCTED | + MBEDTLS_ASN1_CHK_ADD( len, mbedtls_asn1_write_tag( p, start, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SET ) ); return( (int) len ); } int mbedtls_x509_write_names( unsigned char **p, unsigned char *start, - mbedtls_asn1_named_data *first ) + mbedtls_asn1_named_data *first ) { int ret; size_t len = 0; @@ -239,9 +280,7 @@ int mbedtls_x509_write_names( unsigned char **p, unsigned char *start, while( cur != NULL ) { - MBEDTLS_ASN1_CHK_ADD( len, x509_write_name( p, start, (char *) cur->oid.p, - cur->oid.len, - cur->val.p, cur->val.len ) ); + MBEDTLS_ASN1_CHK_ADD( len, x509_write_name( p, start, cur ) ); cur = cur->next; } diff --git a/3rdparty/mbedtls/mbedtls/library/x509_crl.c b/3rdparty/mbedtls/mbedtls/library/x509_crl.c index b0f39d428b..00f8545d7c 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509_crl.c +++ b/3rdparty/mbedtls/mbedtls/library/x509_crl.c @@ -39,6 +39,7 @@ #include "mbedtls/x509_crl.h" #include "mbedtls/oid.h" +#include "mbedtls/platform_util.h" #include @@ -66,11 +67,6 @@ #include #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * Version ::= INTEGER { v1(0), v2(1) } */ @@ -107,17 +103,17 @@ static int x509_get_crl_ext( unsigned char **p, { int ret; + if( *p == end ) + return( 0 ); + /* * crlExtensions [0] EXPLICIT Extensions OPTIONAL * -- if present, version MUST be v2 */ if( ( ret = mbedtls_x509_get_ext( p, end, ext, 0 ) ) != 0 ) - { - if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) - return( 0 ); - return( ret ); - } + + end = ext->p + ext->len; while( *p < end ) { @@ -616,7 +612,7 @@ int mbedtls_x509_crl_parse_file( mbedtls_x509_crl *chain, const char *path ) ret = mbedtls_x509_crl_parse( chain, buf, n ); - mbedtls_zeroize( buf, n ); + mbedtls_platform_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); @@ -737,7 +733,7 @@ void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ) { name_prv = name_cur; name_cur = name_cur->next; - mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_platform_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); mbedtls_free( name_prv ); } @@ -746,13 +742,14 @@ void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ) { entry_prv = entry_cur; entry_cur = entry_cur->next; - mbedtls_zeroize( entry_prv, sizeof( mbedtls_x509_crl_entry ) ); + mbedtls_platform_zeroize( entry_prv, + sizeof( mbedtls_x509_crl_entry ) ); mbedtls_free( entry_prv ); } if( crl_cur->raw.p != NULL ) { - mbedtls_zeroize( crl_cur->raw.p, crl_cur->raw.len ); + mbedtls_platform_zeroize( crl_cur->raw.p, crl_cur->raw.len ); mbedtls_free( crl_cur->raw.p ); } @@ -766,7 +763,7 @@ void mbedtls_x509_crl_free( mbedtls_x509_crl *crl ) crl_prv = crl_cur; crl_cur = crl_cur->next; - mbedtls_zeroize( crl_prv, sizeof( mbedtls_x509_crl ) ); + mbedtls_platform_zeroize( crl_prv, sizeof( mbedtls_x509_crl ) ); if( crl_prv != crl ) mbedtls_free( crl_prv ); } diff --git a/3rdparty/mbedtls/mbedtls/library/x509_crt.c b/3rdparty/mbedtls/mbedtls/library/x509_crt.c index d64d7279a5..97e1d72e3c 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509_crt.c +++ b/3rdparty/mbedtls/mbedtls/library/x509_crt.c @@ -27,6 +27,8 @@ * * http://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf * http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf + * + * [SIRO] https://cabforum.org/wp-content/uploads/Chunghwatelecom201503cabforumV4.pdf */ #if !defined(MBEDTLS_CONFIG_FILE) @@ -39,6 +41,7 @@ #include "mbedtls/x509_crt.h" #include "mbedtls/oid.h" +#include "mbedtls/platform_util.h" #include @@ -75,10 +78,18 @@ #endif /* !_WIN32 || EFIX64 || EFI32 */ #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} +/* + * Item in a verification chain: cert and flags for it + */ +typedef struct { + mbedtls_x509_crt *crt; + uint32_t flags; +} x509_crt_verify_chain_item; + +/* + * Max size of verification chain: end-entity + intermediates + trusted root + */ +#define X509_MAX_VERIFY_CHAIN_SIZE ( MBEDTLS_X509_MAX_INTERMEDIATE_CA + 2 ) /* * Default profile @@ -147,7 +158,7 @@ const mbedtls_x509_crt_profile mbedtls_x509_crt_profile_suiteb = /* * Check md_alg against profile - * Return 0 if md_alg acceptable for this profile, -1 otherwise + * Return 0 if md_alg is acceptable for this profile, -1 otherwise */ static int x509_profile_check_md_alg( const mbedtls_x509_crt_profile *profile, mbedtls_md_type_t md_alg ) @@ -163,7 +174,7 @@ static int x509_profile_check_md_alg( const mbedtls_x509_crt_profile *profile, /* * Check pk_alg against profile - * Return 0 if pk_alg acceptable for this profile, -1 otherwise + * Return 0 if pk_alg is acceptable for this profile, -1 otherwise */ static int x509_profile_check_pk_alg( const mbedtls_x509_crt_profile *profile, mbedtls_pk_type_t pk_alg ) @@ -179,12 +190,13 @@ static int x509_profile_check_pk_alg( const mbedtls_x509_crt_profile *profile, /* * Check key against profile - * Return 0 if pk_alg acceptable for this profile, -1 otherwise + * Return 0 if pk is acceptable for this profile, -1 otherwise */ static int x509_profile_check_key( const mbedtls_x509_crt_profile *profile, - mbedtls_pk_type_t pk_alg, const mbedtls_pk_context *pk ) { + const mbedtls_pk_type_t pk_alg = mbedtls_pk_get_type( pk ); + #if defined(MBEDTLS_RSA_C) if( pk_alg == MBEDTLS_PK_RSA || pk_alg == MBEDTLS_PK_RSASSA_PSS ) { @@ -200,7 +212,7 @@ static int x509_profile_check_key( const mbedtls_x509_crt_profile *profile, pk_alg == MBEDTLS_PK_ECKEY || pk_alg == MBEDTLS_PK_ECKEY_DH ) { - mbedtls_ecp_group_id gid = mbedtls_pk_ec( *pk )->grp.id; + const mbedtls_ecp_group_id gid = mbedtls_pk_ec( *pk )->grp.id; if( gid == MBEDTLS_ECP_DP_NONE ) return( -1 ); @@ -215,6 +227,153 @@ static int x509_profile_check_key( const mbedtls_x509_crt_profile *profile, return( -1 ); } +/* + * Like memcmp, but case-insensitive and always returns -1 if different + */ +static int x509_memcasecmp( const void *s1, const void *s2, size_t len ) +{ + size_t i; + unsigned char diff; + const unsigned char *n1 = s1, *n2 = s2; + + for( i = 0; i < len; i++ ) + { + diff = n1[i] ^ n2[i]; + + if( diff == 0 ) + continue; + + if( diff == 32 && + ( ( n1[i] >= 'a' && n1[i] <= 'z' ) || + ( n1[i] >= 'A' && n1[i] <= 'Z' ) ) ) + { + continue; + } + + return( -1 ); + } + + return( 0 ); +} + +/* + * Return 0 if name matches wildcard, -1 otherwise + */ +static int x509_check_wildcard( const char *cn, const mbedtls_x509_buf *name ) +{ + size_t i; + size_t cn_idx = 0, cn_len = strlen( cn ); + + /* We can't have a match if there is no wildcard to match */ + if( name->len < 3 || name->p[0] != '*' || name->p[1] != '.' ) + return( -1 ); + + for( i = 0; i < cn_len; ++i ) + { + if( cn[i] == '.' ) + { + cn_idx = i; + break; + } + } + + if( cn_idx == 0 ) + return( -1 ); + + if( cn_len - cn_idx == name->len - 1 && + x509_memcasecmp( name->p + 1, cn + cn_idx, name->len - 1 ) == 0 ) + { + return( 0 ); + } + + return( -1 ); +} + +/* + * Compare two X.509 strings, case-insensitive, and allowing for some encoding + * variations (but not all). + * + * Return 0 if equal, -1 otherwise. + */ +static int x509_string_cmp( const mbedtls_x509_buf *a, const mbedtls_x509_buf *b ) +{ + if( a->tag == b->tag && + a->len == b->len && + memcmp( a->p, b->p, b->len ) == 0 ) + { + return( 0 ); + } + + if( ( a->tag == MBEDTLS_ASN1_UTF8_STRING || a->tag == MBEDTLS_ASN1_PRINTABLE_STRING ) && + ( b->tag == MBEDTLS_ASN1_UTF8_STRING || b->tag == MBEDTLS_ASN1_PRINTABLE_STRING ) && + a->len == b->len && + x509_memcasecmp( a->p, b->p, b->len ) == 0 ) + { + return( 0 ); + } + + return( -1 ); +} + +/* + * Compare two X.509 Names (aka rdnSequence). + * + * See RFC 5280 section 7.1, though we don't implement the whole algorithm: + * we sometimes return unequal when the full algorithm would return equal, + * but never the other way. (In particular, we don't do Unicode normalisation + * or space folding.) + * + * Return 0 if equal, -1 otherwise. + */ +static int x509_name_cmp( const mbedtls_x509_name *a, const mbedtls_x509_name *b ) +{ + /* Avoid recursion, it might not be optimised by the compiler */ + while( a != NULL || b != NULL ) + { + if( a == NULL || b == NULL ) + return( -1 ); + + /* type */ + if( a->oid.tag != b->oid.tag || + a->oid.len != b->oid.len || + memcmp( a->oid.p, b->oid.p, b->oid.len ) != 0 ) + { + return( -1 ); + } + + /* value */ + if( x509_string_cmp( &a->val, &b->val ) != 0 ) + return( -1 ); + + /* structure of the list of sets */ + if( a->next_merged != b->next_merged ) + return( -1 ); + + a = a->next; + b = b->next; + } + + /* a == NULL == b */ + return( 0 ); +} + +/* + * Reset (init or clear) a verify_chain + */ +static void x509_crt_verify_chain_reset( + mbedtls_x509_crt_verify_chain *ver_chain ) +{ + size_t i; + + for( i = 0; i < MBEDTLS_X509_MAX_VERIFY_CHAIN_SIZE; i++ ) + { + ver_chain->items[i].crt = NULL; + ver_chain->items[i].flags = (uint32_t) -1; + } + + ver_chain->len = 0; +} + /* * Version ::= INTEGER { v1(0), v2(1), v3(2) } */ @@ -234,7 +393,7 @@ static int x509_get_version( unsigned char **p, return( 0 ); } - return( ret ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); } end = *p + len; @@ -301,7 +460,7 @@ static int x509_get_uid( unsigned char **p, if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) return( 0 ); - return( ret ); + return( MBEDTLS_ERR_X509_INVALID_FORMAT + ret ); } uid->p = *p; @@ -540,14 +699,13 @@ static int x509_get_crt_ext( unsigned char **p, size_t len; unsigned char *end_ext_data, *end_ext_octet; - if( ( ret = mbedtls_x509_get_ext( p, end, &crt->v3_ext, 3 ) ) != 0 ) - { - if( ret == MBEDTLS_ERR_ASN1_UNEXPECTED_TAG ) - return( 0 ); + if( *p == end ) + return( 0 ); + if( ( ret = mbedtls_x509_get_ext( p, end, &crt->v3_ext, 3 ) ) != 0 ) return( ret ); - } + end = crt->v3_ext.p + crt->v3_ext.len; while( *p < end ) { /* @@ -1104,7 +1262,7 @@ int mbedtls_x509_crt_parse_file( mbedtls_x509_crt *chain, const char *path ) ret = mbedtls_x509_crt_parse( chain, buf, n ); - mbedtls_zeroize( buf, n ); + mbedtls_platform_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); @@ -1280,7 +1438,7 @@ static int x509_info_subject_alt_name( char **buf, size_t *size, } #define CERT_TYPE(type,name) \ - if( ns_cert_type & type ) \ + if( ns_cert_type & (type) ) \ PRINT_ITEM( name ); static int x509_info_cert_type( char **buf, size_t *size, @@ -1307,7 +1465,7 @@ static int x509_info_cert_type( char **buf, size_t *size, } #define KEY_USAGE(code,name) \ - if( key_usage & code ) \ + if( key_usage & (code) ) \ PRINT_ITEM( name ); static int x509_info_key_usage( char **buf, size_t *size, @@ -1364,204 +1522,75 @@ static int x509_info_ext_key_usage( char **buf, size_t *size, } /* - * Like memcmp, but case-insensitive and always returns -1 if different + * Return an informational string about the certificate. */ -static int x509_memcasecmp( const void *s1, const void *s2, size_t len ) +#define BEFORE_COLON 18 +#define BC "18" +int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix, + const mbedtls_x509_crt *crt ) { - size_t i; - unsigned char diff; - const unsigned char *n1 = s1, *n2 = s2; + int ret; + size_t n; + char *p; + char key_size_str[BEFORE_COLON]; - for( i = 0; i < len; i++ ) + p = buf; + n = size; + + if( NULL == crt ) { - diff = n1[i] ^ n2[i]; + ret = mbedtls_snprintf( p, n, "\nCertificate is uninitialised!\n" ); + MBEDTLS_X509_SAFE_SNPRINTF; - if( diff == 0 ) - continue; + return( (int) ( size - n ) ); + } - if( diff == 32 && - ( ( n1[i] >= 'a' && n1[i] <= 'z' ) || - ( n1[i] >= 'A' && n1[i] <= 'Z' ) ) ) - { - continue; - } + ret = mbedtls_snprintf( p, n, "%scert. version : %d\n", + prefix, crt->version ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_snprintf( p, n, "%sserial number : ", + prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; - return( -1 ); - } + ret = mbedtls_x509_serial_gets( p, n, &crt->serial ); + MBEDTLS_X509_SAFE_SNPRINTF; - return( 0 ); -} + ret = mbedtls_snprintf( p, n, "\n%sissuer name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_x509_dn_gets( p, n, &crt->issuer ); + MBEDTLS_X509_SAFE_SNPRINTF; -/* - * Return 0 if name matches wildcard, -1 otherwise - */ -static int x509_check_wildcard( const char *cn, mbedtls_x509_buf *name ) -{ - size_t i; - size_t cn_idx = 0, cn_len = strlen( cn ); + ret = mbedtls_snprintf( p, n, "\n%ssubject name : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; + ret = mbedtls_x509_dn_gets( p, n, &crt->subject ); + MBEDTLS_X509_SAFE_SNPRINTF; - if( name->len < 3 || name->p[0] != '*' || name->p[1] != '.' ) - return( 0 ); + ret = mbedtls_snprintf( p, n, "\n%sissued on : " \ + "%04d-%02d-%02d %02d:%02d:%02d", prefix, + crt->valid_from.year, crt->valid_from.mon, + crt->valid_from.day, crt->valid_from.hour, + crt->valid_from.min, crt->valid_from.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; - for( i = 0; i < cn_len; ++i ) - { - if( cn[i] == '.' ) - { - cn_idx = i; - break; - } - } + ret = mbedtls_snprintf( p, n, "\n%sexpires on : " \ + "%04d-%02d-%02d %02d:%02d:%02d", prefix, + crt->valid_to.year, crt->valid_to.mon, + crt->valid_to.day, crt->valid_to.hour, + crt->valid_to.min, crt->valid_to.sec ); + MBEDTLS_X509_SAFE_SNPRINTF; - if( cn_idx == 0 ) - return( -1 ); + ret = mbedtls_snprintf( p, n, "\n%ssigned using : ", prefix ); + MBEDTLS_X509_SAFE_SNPRINTF; - if( cn_len - cn_idx == name->len - 1 && - x509_memcasecmp( name->p + 1, cn + cn_idx, name->len - 1 ) == 0 ) + ret = mbedtls_x509_sig_alg_gets( p, n, &crt->sig_oid, crt->sig_pk, + crt->sig_md, crt->sig_opts ); + MBEDTLS_X509_SAFE_SNPRINTF; + + /* Key size */ + if( ( ret = mbedtls_x509_key_size_helper( key_size_str, BEFORE_COLON, + mbedtls_pk_get_name( &crt->pk ) ) ) != 0 ) { - return( 0 ); - } - - return( -1 ); -} - -/* - * Compare two X.509 strings, case-insensitive, and allowing for some encoding - * variations (but not all). - * - * Return 0 if equal, -1 otherwise. - */ -static int x509_string_cmp( const mbedtls_x509_buf *a, const mbedtls_x509_buf *b ) -{ - if( a->tag == b->tag && - a->len == b->len && - memcmp( a->p, b->p, b->len ) == 0 ) - { - return( 0 ); - } - - if( ( a->tag == MBEDTLS_ASN1_UTF8_STRING || a->tag == MBEDTLS_ASN1_PRINTABLE_STRING ) && - ( b->tag == MBEDTLS_ASN1_UTF8_STRING || b->tag == MBEDTLS_ASN1_PRINTABLE_STRING ) && - a->len == b->len && - x509_memcasecmp( a->p, b->p, b->len ) == 0 ) - { - return( 0 ); - } - - return( -1 ); -} - -/* - * Compare two X.509 Names (aka rdnSequence). - * - * See RFC 5280 section 7.1, though we don't implement the whole algorithm: - * we sometimes return unequal when the full algorithm would return equal, - * but never the other way. (In particular, we don't do Unicode normalisation - * or space folding.) - * - * Return 0 if equal, -1 otherwise. - */ -static int x509_name_cmp( const mbedtls_x509_name *a, const mbedtls_x509_name *b ) -{ - /* Avoid recursion, it might not be optimised by the compiler */ - while( a != NULL || b != NULL ) - { - if( a == NULL || b == NULL ) - return( -1 ); - - /* type */ - if( a->oid.tag != b->oid.tag || - a->oid.len != b->oid.len || - memcmp( a->oid.p, b->oid.p, b->oid.len ) != 0 ) - { - return( -1 ); - } - - /* value */ - if( x509_string_cmp( &a->val, &b->val ) != 0 ) - return( -1 ); - - /* structure of the list of sets */ - if( a->next_merged != b->next_merged ) - return( -1 ); - - a = a->next; - b = b->next; - } - - /* a == NULL == b */ - return( 0 ); -} - -/* - * Return an informational string about the certificate. - */ -#define BEFORE_COLON 18 -#define BC "18" -int mbedtls_x509_crt_info( char *buf, size_t size, const char *prefix, - const mbedtls_x509_crt *crt ) -{ - int ret; - size_t n; - char *p; - char key_size_str[BEFORE_COLON]; - - p = buf; - n = size; - - if( NULL == crt ) - { - ret = mbedtls_snprintf( p, n, "\nCertificate is uninitialised!\n" ); - MBEDTLS_X509_SAFE_SNPRINTF; - - return( (int) ( size - n ) ); - } - - ret = mbedtls_snprintf( p, n, "%scert. version : %d\n", - prefix, crt->version ); - MBEDTLS_X509_SAFE_SNPRINTF; - ret = mbedtls_snprintf( p, n, "%sserial number : ", - prefix ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_x509_serial_gets( p, n, &crt->serial ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_snprintf( p, n, "\n%sissuer name : ", prefix ); - MBEDTLS_X509_SAFE_SNPRINTF; - ret = mbedtls_x509_dn_gets( p, n, &crt->issuer ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_snprintf( p, n, "\n%ssubject name : ", prefix ); - MBEDTLS_X509_SAFE_SNPRINTF; - ret = mbedtls_x509_dn_gets( p, n, &crt->subject ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_snprintf( p, n, "\n%sissued on : " \ - "%04d-%02d-%02d %02d:%02d:%02d", prefix, - crt->valid_from.year, crt->valid_from.mon, - crt->valid_from.day, crt->valid_from.hour, - crt->valid_from.min, crt->valid_from.sec ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_snprintf( p, n, "\n%sexpires on : " \ - "%04d-%02d-%02d %02d:%02d:%02d", prefix, - crt->valid_to.year, crt->valid_to.mon, - crt->valid_to.day, crt->valid_to.hour, - crt->valid_to.min, crt->valid_to.sec ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_snprintf( p, n, "\n%ssigned using : ", prefix ); - MBEDTLS_X509_SAFE_SNPRINTF; - - ret = mbedtls_x509_sig_alg_gets( p, n, &crt->sig_oid, crt->sig_pk, - crt->sig_md, crt->sig_opts ); - MBEDTLS_X509_SAFE_SNPRINTF; - - /* Key size */ - if( ( ret = mbedtls_x509_key_size_helper( key_size_str, BEFORE_COLON, - mbedtls_pk_get_name( &crt->pk ) ) ) != 0 ) - { - return( ret ); + return( ret ); } ret = mbedtls_snprintf( p, n, "\n%s%-" BC "s: %d bits", prefix, key_size_str, @@ -1819,7 +1848,7 @@ static int x509_crt_verifycrl( mbedtls_x509_crt *crt, mbedtls_x509_crt *ca, break; } - if( x509_profile_check_key( profile, crl_list->sig_pk, &ca->pk ) != 0 ) + if( x509_profile_check_key( profile, &ca->pk ) != 0 ) flags |= MBEDTLS_X509_BADCERT_BAD_KEY; if( mbedtls_pk_verify_ext( crl_list->sig_pk, crl_list->sig_opts, &ca->pk, @@ -1855,16 +1884,52 @@ static int x509_crt_verifycrl( mbedtls_x509_crt *crt, mbedtls_x509_crt *ca, } #endif /* MBEDTLS_X509_CRL_PARSE_C */ +/* + * Check the signature of a certificate by its parent + */ +static int x509_crt_check_signature( const mbedtls_x509_crt *child, + mbedtls_x509_crt *parent, + mbedtls_x509_crt_restart_ctx *rs_ctx ) +{ + const mbedtls_md_info_t *md_info; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + + md_info = mbedtls_md_info_from_type( child->sig_md ); + if( mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ) != 0 ) + { + /* Note: this can't happen except after an internal error */ + return( -1 ); + } + + /* Skip expensive computation on obvious mismatch */ + if( ! mbedtls_pk_can_do( &parent->pk, child->sig_pk ) ) + return( -1 ); + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && child->sig_pk == MBEDTLS_PK_ECDSA ) + { + return( mbedtls_pk_verify_restartable( &parent->pk, + child->sig_md, hash, mbedtls_md_get_size( md_info ), + child->sig.p, child->sig.len, &rs_ctx->pk ) ); + } +#else + (void) rs_ctx; +#endif + + return( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &parent->pk, + child->sig_md, hash, mbedtls_md_get_size( md_info ), + child->sig.p, child->sig.len ) ); +} + /* * Check if 'parent' is a suitable parent (signing CA) for 'child'. * Return 0 if yes, -1 if not. * * top means parent is a locally-trusted certificate - * bottom means child is the end entity cert */ static int x509_crt_check_parent( const mbedtls_x509_crt *child, const mbedtls_x509_crt *parent, - int top, int bottom ) + int top ) { int need_ca_bit; @@ -1879,14 +1944,6 @@ static int x509_crt_check_parent( const mbedtls_x509_crt *child, if( top && parent->version < 3 ) need_ca_bit = 0; - /* Exception: self-signed end-entity certs that are locally trusted. */ - if( top && bottom && - child->raw.len == parent->raw.len && - memcmp( child->raw.p, parent->raw.p, child->raw.len ) == 0 ) - { - need_ca_bit = 0; - } - if( need_ca_bit && ! parent->ca_istrue ) return( -1 ); @@ -1902,103 +1959,130 @@ static int x509_crt_check_parent( const mbedtls_x509_crt *child, } /* - * Verify a certificate with no parent inside the chain - * (either the parent is a trusted root, or there is no parent) + * Find a suitable parent for child in candidates, or return NULL. + * + * Here suitable is defined as: + * 1. subject name matches child's issuer + * 2. if necessary, the CA bit is set and key usage allows signing certs + * 3. for trusted roots, the signature is correct + * (for intermediates, the signature is checked and the result reported) + * 4. pathlen constraints are satisfied + * + * If there's a suitable candidate which is also time-valid, return the first + * such. Otherwise, return the first suitable candidate (or NULL if there is + * none). + * + * The rationale for this rule is that someone could have a list of trusted + * roots with two versions on the same root with different validity periods. + * (At least one user reported having such a list and wanted it to just work.) + * The reason we don't just require time-validity is that generally there is + * only one version, and if it's expired we want the flags to state that + * rather than NOT_TRUSTED, as would be the case if we required it here. * - * See comments for mbedtls_x509_crt_verify_with_profile() - * (also for notation used below) + * The rationale for rule 3 (signature for trusted roots) is that users might + * have two versions of the same CA with different keys in their list, and the + * way we select the correct one is by checking the signature (as we don't + * rely on key identifier extensions). (This is one way users might choose to + * handle key rollover, another relies on self-issued certs, see [SIRO].) * - * This function is called in two cases: - * - child was found to have a parent in trusted roots, in which case we're - * called with trust_ca pointing directly to that parent (not the full list) - * - this is cases 1, 2 and 3 of the comment on verify_with_profile() - * - case 1 is special as child and trust_ca point to copies of the same - * certificate then - * - child was found to have no parent either in the chain or in trusted CAs - * - this is cases 4 and 5 of the comment on verify_with_profile() + * Arguments: + * - [in] child: certificate for which we're looking for a parent + * - [in] candidates: chained list of potential parents + * - [out] r_parent: parent found (or NULL) + * - [out] r_signature_is_good: 1 if child signature by parent is valid, or 0 + * - [in] top: 1 if candidates consists of trusted roots, ie we're at the top + * of the chain, 0 otherwise + * - [in] path_cnt: number of intermediates seen so far + * - [in] self_cnt: number of self-signed intermediates seen so far + * (will never be greater than path_cnt) + * - [in-out] rs_ctx: context for restarting operations * - * For historical reasons, the function currently does not assume that - * trust_ca points directly to the right root in the first case, and it - * doesn't know in which case it starts, so it always starts by searching for - * a parent in trust_ca. + * Return value: + * - 0 on success + * - MBEDTLS_ERR_ECP_IN_PROGRESS otherwise */ -static int x509_crt_verify_top( - mbedtls_x509_crt *child, mbedtls_x509_crt *trust_ca, - mbedtls_x509_crl *ca_crl, - const mbedtls_x509_crt_profile *profile, - int path_cnt, int self_cnt, uint32_t *flags, - int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), - void *p_vrfy ) +static int x509_crt_find_parent_in( + mbedtls_x509_crt *child, + mbedtls_x509_crt *candidates, + mbedtls_x509_crt **r_parent, + int *r_signature_is_good, + int top, + unsigned path_cnt, + unsigned self_cnt, + mbedtls_x509_crt_restart_ctx *rs_ctx ) { int ret; - uint32_t ca_flags = 0; - int check_path_cnt; - unsigned char hash[MBEDTLS_MD_MAX_SIZE]; - const mbedtls_md_info_t *md_info; - mbedtls_x509_crt *future_past_ca = NULL; - - if( mbedtls_x509_time_is_past( &child->valid_to ) ) - *flags |= MBEDTLS_X509_BADCERT_EXPIRED; - - if( mbedtls_x509_time_is_future( &child->valid_from ) ) - *flags |= MBEDTLS_X509_BADCERT_FUTURE; - - if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_MD; + mbedtls_x509_crt *parent, *fallback_parent; + int signature_is_good, fallback_signature_is_good; - if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_PK; +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /* did we have something in progress? */ + if( rs_ctx != NULL && rs_ctx->parent != NULL ) + { + /* restore saved state */ + parent = rs_ctx->parent; + fallback_parent = rs_ctx->fallback_parent; + fallback_signature_is_good = rs_ctx->fallback_signature_is_good; - /* - * Child is the top of the chain. Check against the trust_ca list. - */ - *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + /* clear saved state */ + rs_ctx->parent = NULL; + rs_ctx->fallback_parent = NULL; + rs_ctx->fallback_signature_is_good = 0; - md_info = mbedtls_md_info_from_type( child->sig_md ); - if( mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ) != 0 ) - { - /* Note: this can't happen except after an internal error */ - /* Cannot check signature, no need to try any CA */ - trust_ca = NULL; + /* resume where we left */ + goto check_signature; } +#endif - for( /* trust_ca */ ; trust_ca != NULL; trust_ca = trust_ca->next ) + fallback_parent = NULL; + fallback_signature_is_good = 0; + + for( parent = candidates; parent != NULL; parent = parent->next ) { - if( x509_crt_check_parent( child, trust_ca, 1, path_cnt == 0 ) != 0 ) + /* basic parenting skills (name, CA bit, key usage) */ + if( x509_crt_check_parent( child, parent, top ) != 0 ) continue; - check_path_cnt = path_cnt + 1; - - /* - * Reduce check_path_cnt to check against if top of the chain is - * the same as the trusted CA - */ - if( child->subject_raw.len == trust_ca->subject_raw.len && - memcmp( child->subject_raw.p, trust_ca->subject_raw.p, - child->subject_raw.len ) == 0 ) + /* +1 because stored max_pathlen is 1 higher that the actual value */ + if( parent->max_pathlen > 0 && + (size_t) parent->max_pathlen < 1 + path_cnt - self_cnt ) { - check_path_cnt--; + continue; } - /* Self signed certificates do not count towards the limit */ - if( trust_ca->max_pathlen > 0 && - trust_ca->max_pathlen < check_path_cnt - self_cnt ) + /* Signature */ +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +check_signature: +#endif + ret = x509_crt_check_signature( child, parent, rs_ctx ); + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) { - continue; + /* save state */ + rs_ctx->parent = parent; + rs_ctx->fallback_parent = fallback_parent; + rs_ctx->fallback_signature_is_good = fallback_signature_is_good; + + return( ret ); } +#else + (void) ret; +#endif - if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &trust_ca->pk, - child->sig_md, hash, mbedtls_md_get_size( md_info ), - child->sig.p, child->sig.len ) != 0 ) - { + signature_is_good = ret == 0; + if( top && ! signature_is_good ) continue; - } - if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) || - mbedtls_x509_time_is_future( &trust_ca->valid_from ) ) + /* optional time check */ + if( mbedtls_x509_time_is_past( &parent->valid_to ) || + mbedtls_x509_time_is_future( &parent->valid_from ) ) { - if ( future_past_ca == NULL ) - future_past_ca = trust_ca; + if( fallback_parent == NULL ) + { + fallback_parent = parent; + fallback_signature_is_good = signature_is_good; + } continue; } @@ -2006,197 +2090,409 @@ static int x509_crt_verify_top( break; } - if( trust_ca != NULL || ( trust_ca = future_past_ca ) != NULL ) + if( parent != NULL ) { - /* - * Top of chain is signed by a trusted CA - */ - *flags &= ~MBEDTLS_X509_BADCERT_NOT_TRUSTED; - - if( x509_profile_check_key( profile, child->sig_pk, &trust_ca->pk ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + *r_parent = parent; + *r_signature_is_good = signature_is_good; + } + else + { + *r_parent = fallback_parent; + *r_signature_is_good = fallback_signature_is_good; } - /* - * If top of chain is not the same as the trusted CA send a verify request - * to the callback for any issues with validity and CRL presence for the - * trusted CA certificate. - */ - if( trust_ca != NULL && - ( child->subject_raw.len != trust_ca->subject_raw.len || - memcmp( child->subject_raw.p, trust_ca->subject_raw.p, - child->subject_raw.len ) != 0 ) ) + return( 0 ); +} + +/* + * Find a parent in trusted CAs or the provided chain, or return NULL. + * + * Searches in trusted CAs first, and return the first suitable parent found + * (see find_parent_in() for definition of suitable). + * + * Arguments: + * - [in] child: certificate for which we're looking for a parent, followed + * by a chain of possible intermediates + * - [in] trust_ca: list of locally trusted certificates + * - [out] parent: parent found (or NULL) + * - [out] parent_is_trusted: 1 if returned `parent` is trusted, or 0 + * - [out] signature_is_good: 1 if child signature by parent is valid, or 0 + * - [in] path_cnt: number of links in the chain so far (EE -> ... -> child) + * - [in] self_cnt: number of self-signed certs in the chain so far + * (will always be no greater than path_cnt) + * - [in-out] rs_ctx: context for restarting operations + * + * Return value: + * - 0 on success + * - MBEDTLS_ERR_ECP_IN_PROGRESS otherwise + */ +static int x509_crt_find_parent( + mbedtls_x509_crt *child, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crt **parent, + int *parent_is_trusted, + int *signature_is_good, + unsigned path_cnt, + unsigned self_cnt, + mbedtls_x509_crt_restart_ctx *rs_ctx ) +{ + int ret; + mbedtls_x509_crt *search_list; + + *parent_is_trusted = 1; + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /* restore then clear saved state if we have some stored */ + if( rs_ctx != NULL && rs_ctx->parent_is_trusted != -1 ) { -#if defined(MBEDTLS_X509_CRL_PARSE_C) - /* Check trusted CA's CRL for the chain's top crt */ - *flags |= x509_crt_verifycrl( child, trust_ca, ca_crl, profile ); -#else - ((void) ca_crl); + *parent_is_trusted = rs_ctx->parent_is_trusted; + rs_ctx->parent_is_trusted = -1; + } #endif - if( mbedtls_x509_time_is_past( &trust_ca->valid_to ) ) - ca_flags |= MBEDTLS_X509_BADCERT_EXPIRED; + while( 1 ) { + search_list = *parent_is_trusted ? trust_ca : child->next; - if( mbedtls_x509_time_is_future( &trust_ca->valid_from ) ) - ca_flags |= MBEDTLS_X509_BADCERT_FUTURE; + ret = x509_crt_find_parent_in( child, search_list, + parent, signature_is_good, + *parent_is_trusted, + path_cnt, self_cnt, rs_ctx ); - if( NULL != f_vrfy ) +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) { - if( ( ret = f_vrfy( p_vrfy, trust_ca, path_cnt + 1, - &ca_flags ) ) != 0 ) - { - return( ret ); - } + /* save state */ + rs_ctx->parent_is_trusted = *parent_is_trusted; + return( ret ); } +#else + (void) ret; +#endif + + /* stop here if found or already in second iteration */ + if( *parent != NULL || *parent_is_trusted == 0 ) + break; + + /* prepare second iteration */ + *parent_is_trusted = 0; } - /* Call callback on top cert */ - if( NULL != f_vrfy ) + /* extra precaution against mistakes in the caller */ + if( *parent == NULL ) { - if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 ) - return( ret ); + *parent_is_trusted = 0; + *signature_is_good = 0; } - *flags |= ca_flags; - return( 0 ); } /* - * Verify a certificate with a parent inside the chain + * Check if an end-entity certificate is locally trusted * - * See comments for mbedtls_x509_crt_verify_with_profile() + * Currently we require such certificates to be self-signed (actually only + * check for self-issued as self-signatures are not checked) */ -static int x509_crt_verify_child( - mbedtls_x509_crt *child, mbedtls_x509_crt *parent, - mbedtls_x509_crt *trust_ca, mbedtls_x509_crl *ca_crl, - const mbedtls_x509_crt_profile *profile, - int path_cnt, int self_cnt, uint32_t *flags, - int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), - void *p_vrfy ) +static int x509_crt_check_ee_locally_trusted( + mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca ) { - int ret; - uint32_t parent_flags = 0; - unsigned char hash[MBEDTLS_MD_MAX_SIZE]; - mbedtls_x509_crt *grandparent; - const mbedtls_md_info_t *md_info; + mbedtls_x509_crt *cur; - /* Counting intermediate self signed certificates */ - if( ( path_cnt != 0 ) && x509_name_cmp( &child->issuer, &child->subject ) == 0 ) - self_cnt++; + /* must be self-issued */ + if( x509_name_cmp( &crt->issuer, &crt->subject ) != 0 ) + return( -1 ); - /* path_cnt is 0 for the first intermediate CA */ - if( 1 + path_cnt > MBEDTLS_X509_MAX_INTERMEDIATE_CA ) + /* look for an exact match with trusted cert */ + for( cur = trust_ca; cur != NULL; cur = cur->next ) { - /* return immediately as the goal is to avoid unbounded recursion */ - return( MBEDTLS_ERR_X509_FATAL_ERROR ); + if( crt->raw.len == cur->raw.len && + memcmp( crt->raw.p, cur->raw.p, crt->raw.len ) == 0 ) + { + return( 0 ); + } } - if( mbedtls_x509_time_is_past( &child->valid_to ) ) - *flags |= MBEDTLS_X509_BADCERT_EXPIRED; + /* too bad */ + return( -1 ); +} + +/* + * Build and verify a certificate chain + * + * Given a peer-provided list of certificates EE, C1, ..., Cn and + * a list of trusted certs R1, ... Rp, try to build and verify a chain + * EE, Ci1, ... Ciq [, Rj] + * such that every cert in the chain is a child of the next one, + * jumping to a trusted root as early as possible. + * + * Verify that chain and return it with flags for all issues found. + * + * Special cases: + * - EE == Rj -> return a one-element list containing it + * - EE, Ci1, ..., Ciq cannot be continued with a trusted root + * -> return that chain with NOT_TRUSTED set on Ciq + * + * Tests for (aspects of) this function should include at least: + * - trusted EE + * - EE -> trusted root + * - EE -> intermedate CA -> trusted root + * - if relevant: EE untrusted + * - if relevant: EE -> intermediate, untrusted + * with the aspect under test checked at each relevant level (EE, int, root). + * For some aspects longer chains are required, but usually length 2 is + * enough (but length 1 is not in general). + * + * Arguments: + * - [in] crt: the cert list EE, C1, ..., Cn + * - [in] trust_ca: the trusted list R1, ..., Rp + * - [in] ca_crl, profile: as in verify_with_profile() + * - [out] ver_chain: the built and verified chain + * Only valid when return value is 0, may contain garbage otherwise! + * Restart note: need not be the same when calling again to resume. + * - [in-out] rs_ctx: context for restarting operations + * + * Return value: + * - non-zero if the chain could not be fully built and examined + * - 0 is the chain was successfully built and examined, + * even if it was found to be invalid + */ +static int x509_crt_verify_chain( + mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + mbedtls_x509_crt_verify_chain *ver_chain, + mbedtls_x509_crt_restart_ctx *rs_ctx ) +{ + /* Don't initialize any of those variables here, so that the compiler can + * catch potential issues with jumping ahead when restarting */ + int ret; + uint32_t *flags; + mbedtls_x509_crt_verify_chain_item *cur; + mbedtls_x509_crt *child; + mbedtls_x509_crt *parent; + int parent_is_trusted; + int child_is_trusted; + int signature_is_good; + unsigned self_cnt; + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + /* resume if we had an operation in progress */ + if( rs_ctx != NULL && rs_ctx->in_progress == x509_crt_rs_find_parent ) + { + /* restore saved state */ + *ver_chain = rs_ctx->ver_chain; /* struct copy */ + self_cnt = rs_ctx->self_cnt; + + /* restore derived state */ + cur = &ver_chain->items[ver_chain->len - 1]; + child = cur->crt; + flags = &cur->flags; + + goto find_parent; + } +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + + child = crt; + self_cnt = 0; + parent_is_trusted = 0; + child_is_trusted = 0; + + while( 1 ) { + /* Add certificate to the verification chain */ + cur = &ver_chain->items[ver_chain->len]; + cur->crt = child; + cur->flags = 0; + ver_chain->len++; + flags = &cur->flags; + + /* Check time-validity (all certificates) */ + if( mbedtls_x509_time_is_past( &child->valid_to ) ) + *flags |= MBEDTLS_X509_BADCERT_EXPIRED; + + if( mbedtls_x509_time_is_future( &child->valid_from ) ) + *flags |= MBEDTLS_X509_BADCERT_FUTURE; + + /* Stop here for trusted roots (but not for trusted EE certs) */ + if( child_is_trusted ) + return( 0 ); + + /* Check signature algorithm: MD & PK algs */ + if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_MD; - if( mbedtls_x509_time_is_future( &child->valid_from ) ) - *flags |= MBEDTLS_X509_BADCERT_FUTURE; + if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_PK; - if( x509_profile_check_md_alg( profile, child->sig_md ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_MD; + /* Special case: EE certs that are locally trusted */ + if( ver_chain->len == 1 && + x509_crt_check_ee_locally_trusted( child, trust_ca ) == 0 ) + { + return( 0 ); + } - if( x509_profile_check_pk_alg( profile, child->sig_pk ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_PK; +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +find_parent: +#endif + /* Look for a parent in trusted CAs or up the chain */ + ret = x509_crt_find_parent( child, trust_ca, &parent, + &parent_is_trusted, &signature_is_good, + ver_chain->len - 1, self_cnt, rs_ctx ); - md_info = mbedtls_md_info_from_type( child->sig_md ); - if( mbedtls_md( md_info, child->tbs.p, child->tbs.len, hash ) != 0 ) - { - /* Note: this can't happen except after an internal error */ - *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; - } - else - { - if( x509_profile_check_key( profile, child->sig_pk, &parent->pk ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && ret == MBEDTLS_ERR_ECP_IN_PROGRESS ) + { + /* save state */ + rs_ctx->in_progress = x509_crt_rs_find_parent; + rs_ctx->self_cnt = self_cnt; + rs_ctx->ver_chain = *ver_chain; /* struct copy */ - if( mbedtls_pk_verify_ext( child->sig_pk, child->sig_opts, &parent->pk, - child->sig_md, hash, mbedtls_md_get_size( md_info ), - child->sig.p, child->sig.len ) != 0 ) + return( ret ); + } +#else + (void) ret; +#endif + + /* No parent? We're done here */ + if( parent == NULL ) { *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + return( 0 ); + } + + /* Count intermediate self-issued (not necessarily self-signed) certs. + * These can occur with some strategies for key rollover, see [SIRO], + * and should be excluded from max_pathlen checks. */ + if( ver_chain->len != 1 && + x509_name_cmp( &child->issuer, &child->subject ) == 0 ) + { + self_cnt++; } - } + + /* path_cnt is 0 for the first intermediate CA, + * and if parent is trusted it's not an intermediate CA */ + if( ! parent_is_trusted && + ver_chain->len > MBEDTLS_X509_MAX_INTERMEDIATE_CA ) + { + /* return immediately to avoid overflow the chain array */ + return( MBEDTLS_ERR_X509_FATAL_ERROR ); + } + + /* signature was checked while searching parent */ + if( ! signature_is_good ) + *flags |= MBEDTLS_X509_BADCERT_NOT_TRUSTED; + + /* check size of signing key */ + if( x509_profile_check_key( profile, &parent->pk ) != 0 ) + *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; #if defined(MBEDTLS_X509_CRL_PARSE_C) - /* Check trusted CA's CRL for the given crt */ - *flags |= x509_crt_verifycrl(child, parent, ca_crl, profile ); + /* Check trusted CA's CRL for the given crt */ + *flags |= x509_crt_verifycrl( child, parent, ca_crl, profile ); +#else + (void) ca_crl; #endif - /* Look for a grandparent in trusted CAs */ - for( grandparent = trust_ca; - grandparent != NULL; - grandparent = grandparent->next ) + /* prepare for next iteration */ + child = parent; + parent = NULL; + child_is_trusted = parent_is_trusted; + signature_is_good = 0; + } +} + +/* + * Check for CN match + */ +static int x509_crt_check_cn( const mbedtls_x509_buf *name, + const char *cn, size_t cn_len ) +{ + /* try exact match */ + if( name->len == cn_len && + x509_memcasecmp( cn, name->p, cn_len ) == 0 ) { - if( x509_crt_check_parent( parent, grandparent, - 0, path_cnt == 0 ) == 0 ) - break; + return( 0 ); } - if( grandparent != NULL ) + /* try wildcard match */ + if( x509_check_wildcard( cn, name ) == 0 ) { - ret = x509_crt_verify_top( parent, grandparent, ca_crl, profile, - path_cnt + 1, self_cnt, &parent_flags, f_vrfy, p_vrfy ); - if( ret != 0 ) - return( ret ); + return( 0 ); } - else + + return( -1 ); +} + +/* + * Verify the requested CN - only call this if cn is not NULL! + */ +static void x509_crt_verify_name( const mbedtls_x509_crt *crt, + const char *cn, + uint32_t *flags ) +{ + const mbedtls_x509_name *name; + const mbedtls_x509_sequence *cur; + size_t cn_len = strlen( cn ); + + if( crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME ) { - /* Look for a grandparent upwards the chain */ - for( grandparent = parent->next; - grandparent != NULL; - grandparent = grandparent->next ) + for( cur = &crt->subject_alt_names; cur != NULL; cur = cur->next ) { - /* +2 because the current step is not yet accounted for - * and because max_pathlen is one higher than it should be. - * Also self signed certificates do not count to the limit. */ - if( grandparent->max_pathlen > 0 && - grandparent->max_pathlen < 2 + path_cnt - self_cnt ) - { - continue; - } - - if( x509_crt_check_parent( parent, grandparent, - 0, path_cnt == 0 ) == 0 ) + if( x509_crt_check_cn( &cur->buf, cn, cn_len ) == 0 ) break; } - /* Is our parent part of the chain or at the top? */ - if( grandparent != NULL ) - { - ret = x509_crt_verify_child( parent, grandparent, trust_ca, ca_crl, - profile, path_cnt + 1, self_cnt, &parent_flags, - f_vrfy, p_vrfy ); - if( ret != 0 ) - return( ret ); - } - else + if( cur == NULL ) + *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; + } + else + { + for( name = &crt->subject; name != NULL; name = name->next ) { - ret = x509_crt_verify_top( parent, trust_ca, ca_crl, profile, - path_cnt + 1, self_cnt, &parent_flags, - f_vrfy, p_vrfy ); - if( ret != 0 ) - return( ret ); + if( MBEDTLS_OID_CMP( MBEDTLS_OID_AT_CN, &name->oid ) == 0 && + x509_crt_check_cn( &name->val, cn, cn_len ) == 0 ) + { + break; + } } + + if( name == NULL ) + *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; } +} - /* child is verified to be a child of the parent, call verify callback */ - if( NULL != f_vrfy ) - if( ( ret = f_vrfy( p_vrfy, child, path_cnt, flags ) ) != 0 ) - return( ret ); +/* + * Merge the flags for all certs in the chain, after calling callback + */ +static int x509_crt_merge_flags_with_cb( + uint32_t *flags, + const mbedtls_x509_crt_verify_chain *ver_chain, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy ) +{ + int ret; + unsigned i; + uint32_t cur_flags; + const mbedtls_x509_crt_verify_chain_item *cur; - *flags |= parent_flags; + for( i = ver_chain->len; i != 0; --i ) + { + cur = &ver_chain->items[i-1]; + cur_flags = cur->flags; + + if( NULL != f_vrfy ) + if( ( ret = f_vrfy( p_vrfy, cur->crt, (int) i-1, &cur_flags ) ) != 0 ) + return( ret ); + + *flags |= cur_flags; + } return( 0 ); } /* - * Verify the certificate validity + * Verify the certificate validity (default profile, not restartable) */ int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt, mbedtls_x509_crt *trust_ca, @@ -2205,41 +2501,13 @@ int mbedtls_x509_crt_verify( mbedtls_x509_crt *crt, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy ) { - return( mbedtls_x509_crt_verify_with_profile( crt, trust_ca, ca_crl, - &mbedtls_x509_crt_profile_default, cn, flags, f_vrfy, p_vrfy ) ); + return( mbedtls_x509_crt_verify_restartable( crt, trust_ca, ca_crl, + &mbedtls_x509_crt_profile_default, cn, flags, + f_vrfy, p_vrfy, NULL ) ); } - /* - * Verify the certificate validity, with profile - * - * The chain building/verification is spread accross 4 functions: - * - this one - * - x509_crt_verify_child() - * - x509_crt_verify_top() - * - x509_crt_check_parent() - * - * There are five main cases to consider. Let's introduce some notation: - * - E means the end-entity certificate - * - I an intermediate CA - * - R the trusted root CA this chain anchors to - * - T the list of trusted roots (R and possible some others) - * - * The main cases with the calling sequence of the crt_verify_xxx() are: - * 1. E = R (explicitly trusted EE cert) - * verify(E, T) -> verify_top(E, R) - * 2. E -> R (EE signed by trusted root) - * verify(E, T) -> verify_top(E, R) - * 3. E -> I -> R (EE signed by intermediate signed by trusted root) - * verify(E, T) -> verify_child(E, I, T) -> verify_top(I, R) - * (plus variant with multiple intermediates) - * 4. E -> I (EE signed by intermediate that's not trusted) - * verify(E, T) -> verify_child(E, I, T) -> verify_top(I, T) - * (plus variant with multiple intermediates) - * 5. E (EE not trusted) - * verify(E, T) -> verify_top(E, T) - * - * Note: this notation and case numbering is also used in x509_crt_verify_top() + * Verify the certificate validity (user-chosen profile, not restartable) */ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, mbedtls_x509_crt *trust_ca, @@ -2249,15 +2517,37 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), void *p_vrfy ) { - size_t cn_len; + return( mbedtls_x509_crt_verify_restartable( crt, trust_ca, ca_crl, + profile, cn, flags, f_vrfy, p_vrfy, NULL ) ); +} + +/* + * Verify the certificate validity, with profile, restartable version + * + * This function: + * - checks the requested CN (if any) + * - checks the type and size of the EE cert's key, + * as that isn't done as part of chain building/verification currently + * - builds and verifies the chain + * - then calls the callback and merges the flags + */ +int mbedtls_x509_crt_verify_restartable( mbedtls_x509_crt *crt, + mbedtls_x509_crt *trust_ca, + mbedtls_x509_crl *ca_crl, + const mbedtls_x509_crt_profile *profile, + const char *cn, uint32_t *flags, + int (*f_vrfy)(void *, mbedtls_x509_crt *, int, uint32_t *), + void *p_vrfy, + mbedtls_x509_crt_restart_ctx *rs_ctx ) +{ int ret; - int pathlen = 0, selfsigned = 0; - mbedtls_x509_crt *parent; - mbedtls_x509_name *name; - mbedtls_x509_sequence *cur = NULL; mbedtls_pk_type_t pk_type; + mbedtls_x509_crt_verify_chain ver_chain; + uint32_t ee_flags; *flags = 0; + ee_flags = 0; + x509_crt_verify_chain_reset( &ver_chain ); if( profile == NULL ) { @@ -2265,106 +2555,38 @@ int mbedtls_x509_crt_verify_with_profile( mbedtls_x509_crt *crt, goto exit; } + /* check name if requested */ if( cn != NULL ) - { - name = &crt->subject; - cn_len = strlen( cn ); - - if( crt->ext_types & MBEDTLS_X509_EXT_SUBJECT_ALT_NAME ) - { - cur = &crt->subject_alt_names; - - while( cur != NULL ) - { - if( cur->buf.len == cn_len && - x509_memcasecmp( cn, cur->buf.p, cn_len ) == 0 ) - break; - - if( cur->buf.len > 2 && - memcmp( cur->buf.p, "*.", 2 ) == 0 && - x509_check_wildcard( cn, &cur->buf ) == 0 ) - { - break; - } - - cur = cur->next; - } - - if( cur == NULL ) - *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; - } - else - { - while( name != NULL ) - { - if( MBEDTLS_OID_CMP( MBEDTLS_OID_AT_CN, &name->oid ) == 0 ) - { - if( name->val.len == cn_len && - x509_memcasecmp( name->val.p, cn, cn_len ) == 0 ) - break; - - if( name->val.len > 2 && - memcmp( name->val.p, "*.", 2 ) == 0 && - x509_check_wildcard( cn, &name->val ) == 0 ) - break; - } - - name = name->next; - } - - if( name == NULL ) - *flags |= MBEDTLS_X509_BADCERT_CN_MISMATCH; - } - } + x509_crt_verify_name( crt, cn, &ee_flags ); /* Check the type and size of the key */ pk_type = mbedtls_pk_get_type( &crt->pk ); if( x509_profile_check_pk_alg( profile, pk_type ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_PK; + ee_flags |= MBEDTLS_X509_BADCERT_BAD_PK; - if( x509_profile_check_key( profile, pk_type, &crt->pk ) != 0 ) - *flags |= MBEDTLS_X509_BADCERT_BAD_KEY; + if( x509_profile_check_key( profile, &crt->pk ) != 0 ) + ee_flags |= MBEDTLS_X509_BADCERT_BAD_KEY; - /* Look for a parent in trusted CAs */ - for( parent = trust_ca; parent != NULL; parent = parent->next ) - { - if( x509_crt_check_parent( crt, parent, 0, pathlen == 0 ) == 0 ) - break; - } + /* Check the chain */ + ret = x509_crt_verify_chain( crt, trust_ca, ca_crl, profile, + &ver_chain, rs_ctx ); - if( parent != NULL ) - { - ret = x509_crt_verify_top( crt, parent, ca_crl, profile, - pathlen, selfsigned, flags, f_vrfy, p_vrfy ); - if( ret != 0 ) - goto exit; - } - else - { - /* Look for a parent upwards the chain */ - for( parent = crt->next; parent != NULL; parent = parent->next ) - if( x509_crt_check_parent( crt, parent, 0, pathlen == 0 ) == 0 ) - break; + if( ret != 0 ) + goto exit; - /* Are we part of the chain or at the top? */ - if( parent != NULL ) - { - ret = x509_crt_verify_child( crt, parent, trust_ca, ca_crl, profile, - pathlen, selfsigned, flags, f_vrfy, p_vrfy ); - if( ret != 0 ) - goto exit; - } - else - { - ret = x509_crt_verify_top( crt, trust_ca, ca_crl, profile, - pathlen, selfsigned, flags, f_vrfy, p_vrfy ); - if( ret != 0 ) - goto exit; - } - } + /* Merge end-entity flags */ + ver_chain.items[0].flags |= ee_flags; + + /* Build final flags, calling callback on the way if any */ + ret = x509_crt_merge_flags_with_cb( flags, &ver_chain, f_vrfy, p_vrfy ); exit: +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + if( rs_ctx != NULL && ret != MBEDTLS_ERR_ECP_IN_PROGRESS ) + mbedtls_x509_crt_restart_free( rs_ctx ); +#endif + /* prevent misuse of the vrfy callback - VERIFY_FAILED would be ignored by * the SSL module for authmode optional, but non-zero return from the * callback means a fatal error so it shouldn't be ignored */ @@ -2419,7 +2641,7 @@ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ) { name_prv = name_cur; name_cur = name_cur->next; - mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_platform_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); mbedtls_free( name_prv ); } @@ -2428,7 +2650,7 @@ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ) { name_prv = name_cur; name_cur = name_cur->next; - mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_platform_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); mbedtls_free( name_prv ); } @@ -2437,7 +2659,8 @@ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ) { seq_prv = seq_cur; seq_cur = seq_cur->next; - mbedtls_zeroize( seq_prv, sizeof( mbedtls_x509_sequence ) ); + mbedtls_platform_zeroize( seq_prv, + sizeof( mbedtls_x509_sequence ) ); mbedtls_free( seq_prv ); } @@ -2446,13 +2669,14 @@ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ) { seq_prv = seq_cur; seq_cur = seq_cur->next; - mbedtls_zeroize( seq_prv, sizeof( mbedtls_x509_sequence ) ); + mbedtls_platform_zeroize( seq_prv, + sizeof( mbedtls_x509_sequence ) ); mbedtls_free( seq_prv ); } if( cert_cur->raw.p != NULL ) { - mbedtls_zeroize( cert_cur->raw.p, cert_cur->raw.len ); + mbedtls_platform_zeroize( cert_cur->raw.p, cert_cur->raw.len ); mbedtls_free( cert_cur->raw.p ); } @@ -2466,11 +2690,43 @@ void mbedtls_x509_crt_free( mbedtls_x509_crt *crt ) cert_prv = cert_cur; cert_cur = cert_cur->next; - mbedtls_zeroize( cert_prv, sizeof( mbedtls_x509_crt ) ); + mbedtls_platform_zeroize( cert_prv, sizeof( mbedtls_x509_crt ) ); if( cert_prv != crt ) mbedtls_free( cert_prv ); } while( cert_cur != NULL ); } +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) +/* + * Initialize a restart context + */ +void mbedtls_x509_crt_restart_init( mbedtls_x509_crt_restart_ctx *ctx ) +{ + mbedtls_pk_restart_init( &ctx->pk ); + + ctx->parent = NULL; + ctx->fallback_parent = NULL; + ctx->fallback_signature_is_good = 0; + + ctx->parent_is_trusted = -1; + + ctx->in_progress = x509_crt_rs_none; + ctx->self_cnt = 0; + x509_crt_verify_chain_reset( &ctx->ver_chain ); +} + +/* + * Free the components of a restart context + */ +void mbedtls_x509_crt_restart_free( mbedtls_x509_crt_restart_ctx *ctx ) +{ + if( ctx == NULL ) + return; + + mbedtls_pk_restart_free( &ctx->pk ); + mbedtls_x509_crt_restart_init( ctx ); +} +#endif /* MBEDTLS_ECDSA_C && MBEDTLS_ECP_RESTARTABLE */ + #endif /* MBEDTLS_X509_CRT_PARSE_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/x509_csr.c b/3rdparty/mbedtls/mbedtls/library/x509_csr.c index 779098d4e9..c8c08c87b2 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509_csr.c +++ b/3rdparty/mbedtls/mbedtls/library/x509_csr.c @@ -39,6 +39,7 @@ #include "mbedtls/x509_csr.h" #include "mbedtls/oid.h" +#include "mbedtls/platform_util.h" #include @@ -60,11 +61,6 @@ #include #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * Version ::= INTEGER { v1(0) } */ @@ -283,15 +279,24 @@ int mbedtls_x509_csr_parse( mbedtls_x509_csr *csr, const unsigned char *buf, siz { mbedtls_pem_init( &pem ); ret = mbedtls_pem_read_buffer( &pem, - "-----BEGIN CERTIFICATE REQUEST-----", - "-----END CERTIFICATE REQUEST-----", - buf, NULL, 0, &use_len ); + "-----BEGIN CERTIFICATE REQUEST-----", + "-----END CERTIFICATE REQUEST-----", + buf, NULL, 0, &use_len ); + if( ret == MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) + { + ret = mbedtls_pem_read_buffer( &pem, + "-----BEGIN NEW CERTIFICATE REQUEST-----", + "-----END NEW CERTIFICATE REQUEST-----", + buf, NULL, 0, &use_len ); + } if( ret == 0 ) + { /* * Was PEM encoded, parse the result */ ret = mbedtls_x509_csr_parse_der( csr, pem.buf, pem.buflen ); + } mbedtls_pem_free( &pem ); if( ret != MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT ) @@ -316,7 +321,7 @@ int mbedtls_x509_csr_parse_file( mbedtls_x509_csr *csr, const char *path ) ret = mbedtls_x509_csr_parse( csr, buf, n ); - mbedtls_zeroize( buf, n ); + mbedtls_platform_zeroize( buf, n ); mbedtls_free( buf ); return( ret ); @@ -398,17 +403,17 @@ void mbedtls_x509_csr_free( mbedtls_x509_csr *csr ) { name_prv = name_cur; name_cur = name_cur->next; - mbedtls_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); + mbedtls_platform_zeroize( name_prv, sizeof( mbedtls_x509_name ) ); mbedtls_free( name_prv ); } if( csr->raw.p != NULL ) { - mbedtls_zeroize( csr->raw.p, csr->raw.len ); + mbedtls_platform_zeroize( csr->raw.p, csr->raw.len ); mbedtls_free( csr->raw.p ); } - mbedtls_zeroize( csr, sizeof( mbedtls_x509_csr ) ); + mbedtls_platform_zeroize( csr, sizeof( mbedtls_x509_csr ) ); } #endif /* MBEDTLS_X509_CSR_PARSE_C */ diff --git a/3rdparty/mbedtls/mbedtls/library/x509write_crt.c b/3rdparty/mbedtls/mbedtls/library/x509write_crt.c index de7bf0c70f..b42269f825 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509write_crt.c +++ b/3rdparty/mbedtls/mbedtls/library/x509write_crt.c @@ -37,6 +37,7 @@ #include "mbedtls/oid.h" #include "mbedtls/asn1write.h" #include "mbedtls/sha1.h" +#include "mbedtls/platform_util.h" #include @@ -44,11 +45,6 @@ #include "mbedtls/pem.h" #endif /* MBEDTLS_PEM_WRITE_C */ -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - void mbedtls_x509write_crt_init( mbedtls_x509write_cert *ctx ) { memset( ctx, 0, sizeof( mbedtls_x509write_cert ) ); @@ -65,7 +61,7 @@ void mbedtls_x509write_crt_free( mbedtls_x509write_cert *ctx ) mbedtls_asn1_free_named_data_list( &ctx->issuer ); mbedtls_asn1_free_named_data_list( &ctx->extensions ); - mbedtls_zeroize( ctx, sizeof( mbedtls_x509write_cert ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_x509write_cert ) ); } void mbedtls_x509write_crt_set_version( mbedtls_x509write_cert *ctx, int version ) @@ -222,26 +218,51 @@ int mbedtls_x509write_crt_set_authority_key_identifier( mbedtls_x509write_cert * } #endif /* MBEDTLS_SHA1_C */ +static size_t crt_get_unused_bits_for_named_bitstring( unsigned char bitstring, + size_t bit_offset ) +{ + size_t unused_bits; + + /* Count the unused bits removing trailing 0s */ + for( unused_bits = bit_offset; unused_bits < 8; unused_bits++ ) + if( ( ( bitstring >> unused_bits ) & 0x1 ) != 0 ) + break; + + return( unused_bits ); +} + int mbedtls_x509write_crt_set_key_usage( mbedtls_x509write_cert *ctx, unsigned int key_usage ) { unsigned char buf[4], ku; unsigned char *c; int ret; - - /* We currently only support 7 bits, from 0x80 to 0x02 */ - if( ( key_usage & ~0xfe ) != 0 ) + size_t unused_bits; + const unsigned int allowed_bits = MBEDTLS_X509_KU_DIGITAL_SIGNATURE | + MBEDTLS_X509_KU_NON_REPUDIATION | + MBEDTLS_X509_KU_KEY_ENCIPHERMENT | + MBEDTLS_X509_KU_DATA_ENCIPHERMENT | + MBEDTLS_X509_KU_KEY_AGREEMENT | + MBEDTLS_X509_KU_KEY_CERT_SIGN | + MBEDTLS_X509_KU_CRL_SIGN; + + /* Check that nothing other than the allowed flags is set */ + if( ( key_usage & ~allowed_bits ) != 0 ) return( MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE ); c = buf + 4; - ku = (unsigned char) key_usage; + ku = (unsigned char)key_usage; + unused_bits = crt_get_unused_bits_for_named_bitstring( ku, 1 ); + ret = mbedtls_asn1_write_bitstring( &c, buf, &ku, 8 - unused_bits ); - if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &ku, 7 ) ) != 4 ) + if( ret < 0 ) return( ret ); + else if( ret < 3 || ret > 4 ) + return( MBEDTLS_ERR_X509_INVALID_FORMAT ); ret = mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_KEY_USAGE, MBEDTLS_OID_SIZE( MBEDTLS_OID_KEY_USAGE ), - 1, buf, 4 ); + 1, c, (size_t)ret ); if( ret != 0 ) return( ret ); @@ -253,16 +274,22 @@ int mbedtls_x509write_crt_set_ns_cert_type( mbedtls_x509write_cert *ctx, { unsigned char buf[4]; unsigned char *c; + size_t unused_bits; int ret; c = buf + 4; - if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &ns_cert_type, 8 ) ) != 4 ) + unused_bits = crt_get_unused_bits_for_named_bitstring( ns_cert_type, 0 ); + ret = mbedtls_asn1_write_bitstring( &c, + buf, + &ns_cert_type, + 8 - unused_bits ); + if( ret < 3 || ret > 4 ) return( ret ); ret = mbedtls_x509write_crt_set_extension( ctx, MBEDTLS_OID_NS_CERT_TYPE, MBEDTLS_OID_SIZE( MBEDTLS_OID_NS_CERT_TYPE ), - 0, buf, 4 ); + 0, c, (size_t)ret ); if( ret != 0 ) return( ret ); diff --git a/3rdparty/mbedtls/mbedtls/library/x509write_csr.c b/3rdparty/mbedtls/mbedtls/library/x509write_csr.c index e80053828f..d70ba0ed92 100644 --- a/3rdparty/mbedtls/mbedtls/library/x509write_csr.c +++ b/3rdparty/mbedtls/mbedtls/library/x509write_csr.c @@ -35,6 +35,7 @@ #include "mbedtls/x509_csr.h" #include "mbedtls/oid.h" #include "mbedtls/asn1write.h" +#include "mbedtls/platform_util.h" #include #include @@ -43,11 +44,6 @@ #include "mbedtls/pem.h" #endif -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - void mbedtls_x509write_csr_init( mbedtls_x509write_csr *ctx ) { memset( ctx, 0, sizeof( mbedtls_x509write_csr ) ); @@ -58,7 +54,7 @@ void mbedtls_x509write_csr_free( mbedtls_x509write_csr *ctx ) mbedtls_asn1_free_named_data_list( &ctx->subject ); mbedtls_asn1_free_named_data_list( &ctx->extensions ); - mbedtls_zeroize( ctx, sizeof( mbedtls_x509write_csr ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_x509write_csr ) ); } void mbedtls_x509write_csr_set_md_alg( mbedtls_x509write_csr *ctx, mbedtls_md_type_t md_alg ) @@ -85,20 +81,39 @@ int mbedtls_x509write_csr_set_extension( mbedtls_x509write_csr *ctx, 0, val, val_len ); } +static size_t csr_get_unused_bits_for_named_bitstring( unsigned char bitstring, + size_t bit_offset ) +{ + size_t unused_bits; + + /* Count the unused bits removing trailing 0s */ + for( unused_bits = bit_offset; unused_bits < 8; unused_bits++ ) + if( ( ( bitstring >> unused_bits ) & 0x1 ) != 0 ) + break; + + return( unused_bits ); +} + int mbedtls_x509write_csr_set_key_usage( mbedtls_x509write_csr *ctx, unsigned char key_usage ) { unsigned char buf[4]; unsigned char *c; + size_t unused_bits; int ret; c = buf + 4; - if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &key_usage, 7 ) ) != 4 ) + unused_bits = csr_get_unused_bits_for_named_bitstring( key_usage, 0 ); + ret = mbedtls_asn1_write_bitstring( &c, buf, &key_usage, 8 - unused_bits ); + + if( ret < 0 ) return( ret ); + else if( ret < 3 || ret > 4 ) + return( MBEDTLS_ERR_X509_INVALID_FORMAT ); ret = mbedtls_x509write_csr_set_extension( ctx, MBEDTLS_OID_KEY_USAGE, MBEDTLS_OID_SIZE( MBEDTLS_OID_KEY_USAGE ), - buf, 4 ); + c, (size_t)ret ); if( ret != 0 ) return( ret ); @@ -110,16 +125,25 @@ int mbedtls_x509write_csr_set_ns_cert_type( mbedtls_x509write_csr *ctx, { unsigned char buf[4]; unsigned char *c; + size_t unused_bits; int ret; c = buf + 4; - if( ( ret = mbedtls_asn1_write_bitstring( &c, buf, &ns_cert_type, 8 ) ) != 4 ) + unused_bits = csr_get_unused_bits_for_named_bitstring( ns_cert_type, 0 ); + ret = mbedtls_asn1_write_bitstring( &c, + buf, + &ns_cert_type, + 8 - unused_bits ); + + if( ret < 0 ) + return( ret ); + else if( ret < 3 || ret > 4 ) return( ret ); ret = mbedtls_x509write_csr_set_extension( ctx, MBEDTLS_OID_NS_CERT_TYPE, MBEDTLS_OID_SIZE( MBEDTLS_OID_NS_CERT_TYPE ), - buf, 4 ); + c, (size_t)ret ); if( ret != 0 ) return( ret ); diff --git a/3rdparty/mbedtls/mbedtls/library/xtea.c b/3rdparty/mbedtls/mbedtls/library/xtea.c index fe0a3509f6..a33707bc17 100644 --- a/3rdparty/mbedtls/mbedtls/library/xtea.c +++ b/3rdparty/mbedtls/mbedtls/library/xtea.c @@ -28,6 +28,7 @@ #if defined(MBEDTLS_XTEA_C) #include "mbedtls/xtea.h" +#include "mbedtls/platform_util.h" #include @@ -42,11 +43,6 @@ #if !defined(MBEDTLS_XTEA_ALT) -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; -} - /* * 32-bit integer manipulation macros (big endian) */ @@ -80,7 +76,7 @@ void mbedtls_xtea_free( mbedtls_xtea_context *ctx ) if( ctx == NULL ) return; - mbedtls_zeroize( ctx, sizeof( mbedtls_xtea_context ) ); + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_xtea_context ) ); } /* diff --git a/3rdparty/mbedtls/mbedtls/programs/Makefile b/3rdparty/mbedtls/mbedtls/programs/Makefile index 25f184f8c3..28c747b769 100644 --- a/3rdparty/mbedtls/mbedtls/programs/Makefile +++ b/3rdparty/mbedtls/mbedtls/programs/Makefile @@ -4,9 +4,11 @@ CFLAGS ?= -O2 WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement +WARNING_CXXFLAGS ?= -Wall -W LDFLAGS ?= LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 +LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -D_FILE_OFFSET_BITS=64 LOCAL_LDFLAGS = -L../library \ -lmbedtls$(SHARED_SUFFIX) \ -lmbedx509$(SHARED_SUFFIX) \ @@ -65,8 +67,10 @@ APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \ ssl/ssl_mail_client$(EXEXT) random/gen_entropy$(EXEXT) \ random/gen_random_havege$(EXEXT) \ random/gen_random_ctr_drbg$(EXEXT) \ - test/ssl_cert_test$(EXEXT) test/benchmark$(EXEXT) \ + test/benchmark$(EXEXT) \ test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \ + test/zeroize$(EXEXT) \ + test/query_compile_time_config$(EXEXT) \ util/pem2der$(EXEXT) util/strerror$(EXEXT) \ x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \ x509/cert_req$(EXEXT) x509/cert_write$(EXEXT) \ @@ -76,6 +80,10 @@ ifdef PTHREAD APPS += ssl/ssl_pthread_server$(EXEXT) endif +ifdef TEST_CPP +APPS += test/cpp_dummy_build$(EXEXT) +endif + .SILENT: .PHONY: all clean list @@ -205,17 +213,17 @@ ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP) echo " CC ssl/ssl_client1.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(DEP) +ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c ssl/query_config.c $(DEP) echo " CC ssl/ssl_client2.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ ssl/ssl_server$(EXEXT): ssl/ssl_server.c $(DEP) echo " CC ssl/ssl_server.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c $(DEP) +ssl/ssl_server2$(EXEXT): ssl/ssl_server2.c ssl/query_config.c $(DEP) echo " CC ssl/ssl_server2.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_server2.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ ssl/ssl_fork_server$(EXEXT): ssl/ssl_fork_server.c $(DEP) echo " CC ssl/ssl_fork_server.c" @@ -233,14 +241,14 @@ ssl/mini_client$(EXEXT): ssl/mini_client.c $(DEP) echo " CC ssl/mini_client.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/mini_client.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -test/ssl_cert_test$(EXEXT): test/ssl_cert_test.c $(DEP) - echo " CC test/ssl_cert_test.c" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/ssl_cert_test.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - test/benchmark$(EXEXT): test/benchmark.c $(DEP) echo " CC test/benchmark.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/benchmark.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ +test/cpp_dummy_build$(EXEXT): test/cpp_dummy_build.cpp $(DEP) + echo " CXX test/cpp_dummy_build.cpp" + $(CXX) $(LOCAL_CXXFLAGS) $(CXXFLAGS) test/cpp_dummy_build.cpp $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + test/selftest$(EXEXT): test/selftest.c $(DEP) echo " CC test/selftest.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/selftest.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ @@ -249,6 +257,14 @@ test/udp_proxy$(EXEXT): test/udp_proxy.c $(DEP) echo " CC test/udp_proxy.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/udp_proxy.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ +test/zeroize$(EXEXT): test/zeroize.c $(DEP) + echo " CC test/zeroize.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/zeroize.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + +test/query_compile_time_config$(EXEXT): test/query_compile_time_config.c ssl/query_config.c $(DEP) + echo " CC test/query_compile_time_config.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) test/query_compile_time_config.c ssl/query_config.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + util/pem2der$(EXEXT): util/pem2der.c $(DEP) echo " CC util/pem2der.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) util/pem2der.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ diff --git a/3rdparty/mbedtls/mbedtls/programs/README.md b/3rdparty/mbedtls/mbedtls/programs/README.md new file mode 100644 index 0000000000..d26349d0f1 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/programs/README.md @@ -0,0 +1,123 @@ +Mbed TLS sample programs +======================== + +This subdirectory mostly contains sample programs that illustrate specific features of the library, as well as a few test and support programs. + +## Symmetric cryptography (AES) examples + +* [`aes/aescrypt2.c`](aes/aescrypt2.c): file encryption and authentication with a key derived from a low-entropy secret, demonstrating the low-level AES interface, the digest interface and HMAC. + Warning: this program illustrates how to use low-level functions in the library. It should not be taken as an example of how to build a secure encryption mechanism. To derive a key from a low-entropy secret such as a password, use a standard key stretching mechanism such as PBKDF2 (provided by the `pkcs5` module). To encrypt and authenticate data, use a standard mode such as GCM or CCM (both available as library module). + +* [`aes/crypt_and_hash.c`](aes/crypt_and_hash.c): file encryption and authentication, demonstrating the generic cipher interface and the generic hash interface. + +## Hash (digest) examples + +* [`hash/generic_sum.c`](hash/generic_sum.c): file hash calculator and verifier, demonstrating the message digest (`md`) interface. + +* [`hash/hello.c`](hash/hello.c): hello-world program for MD5. + +## Public-key cryptography examples + +### Generic public-key cryptography (`pk`) examples + +* [`pkey/gen_key.c`](pkey/gen_key.c): generates a key for any of the supported public-key algorithms (RSA or ECC) and writes it to a file that can be used by the other pk sample programs. + +* [`pkey/key_app.c`](pkey/key_app.c): loads a PEM or DER public key or private key file and dumps its content. + +* [`pkey/key_app_writer.c`](pkey/key_app_writer.c): loads a PEM or DER public key or private key file and writes it to a new PEM or DER file. + +* [`pkey/pk_encrypt.c`](pkey/pk_encrypt.c), [`pkey/pk_decrypt.c`](pkey/pk_decrypt.c): loads a PEM or DER public/private key file and uses the key to encrypt/decrypt a short string through the generic public-key interface. + +* [`pkey/pk_sign.c`](pkey/pk_sign.c), [`pkey/pk_verify.c`](pkey/pk_verify.c): loads a PEM or DER private/public key file and uses the key to sign/verify a short string. + +### ECDSA and RSA signature examples + +* [`pkey/ecdsa.c`](pkey/ecdsa.c): generates an ECDSA key, signs a fixed message and verifies the signature. + +* [`pkey/rsa_encrypt.c`](pkey/rsa_encrypt.c), [`pkey/rsa_decrypt.c`](pkey/rsa_decrypt.c): loads an RSA public/private key and uses it to encrypt/decrypt a short string through the low-level RSA interface. + +* [`pkey/rsa_genkey.c`](pkey/rsa_genkey.c): generates an RSA key and writes it to a file that can be used with the other RSA sample programs. + +* [`pkey/rsa_sign.c`](pkey/rsa_sign.c), [`pkey/rsa_verify.c`](pkey/rsa_verify.c): loads an RSA private/public key and uses it to sign/verify a short string with the RSA PKCS#1 v1.5 algorithm. + +* [`pkey/rsa_sign_pss.c`](pkey/rsa_sign_pss.c), [`pkey/rsa_verify_pss.c`](pkey/rsa_verify_pss.c): loads an RSA private/public key and uses it to sign/verify a short string with the RSASSA-PSS algorithm. + +### Diffie-Hellman key exchange examples + +* [`pkey/dh_client.c`](pkey/dh_client.c), [`pkey/dh_server.c`](pkey/dh_server.c): secure channel demonstrators (client, server). This pair of programs illustrates how to set up a secure channel using RSA for authentication and Diffie-Hellman to generate a shared AES session key. + +* [`pkey/ecdh_curve25519.c`](pkey/ecdh_curve25519.c): demonstration of a elliptic curve Diffie-Hellman (ECDH) key agreement. + +### Bignum (`mpi`) usage examples + +* [`pkey/dh_genprime.c`](pkey/dh_genprime.c): shows how to use the bignum (`mpi`) interface to generate Diffie-Hellman parameters. + +* [`pkey/mpi_demo.c`](pkey/mpi_demo.c): demonstrates operations on big integers. + +## Random number generator (RNG) examples + +* [`random/gen_entropy.c`](random/gen_entropy.c): shows how to use the default entropy sources to generate random data. + Note: most applications should only use the entropy generator to seed a cryptographic pseudorandom generator, as illustrated by `random/gen_random_ctr_drbg.c`. + +* [`random/gen_random_ctr_drbg.c`](random/gen_random_ctr_drbg.c): shows how to use the default entropy sources to seed a pseudorandom generator, and how to use the resulting random generator to generate random data. + +* [`random/gen_random_havege.c`](random/gen_random_havege.c): demonstrates the HAVEGE entropy collector. + +## SSL/TLS examples + +### SSL/TLS sample applications + +* [`ssl/dtls_client.c`](ssl/dtls_client.c): a simple DTLS client program, which sends one datagram to the server and reads one datagram in response. + +* [`ssl/dtls_server.c`](ssl/dtls_server.c): a simple DTLS server program, which expects one datagram from the client and writes one datagram in response. This program supports DTLS cookies for hello verification. + +* [`ssl/mini_client.c`](ssl/mini_client.c): a minimalistic SSL client, which sends a short string and disconnects. This is primarily intended as a benchmark; for a better example of a typical TLS client, see `ssl/ssl_client1.c`. + +* [`ssl/ssl_client1.c`](ssl/ssl_client1.c): a simple HTTPS client that sends a fixed request and displays the response. + +* [`ssl/ssl_fork_server.c`](ssl/ssl_fork_server.c): a simple HTTPS server using one process per client to send a fixed response. This program requires a Unix/POSIX environment implementing the `fork` system call. + +* [`ssl/ssl_mail_client.c`](ssl/ssl_mail_client.c): a simple SMTP-over-TLS or SMTP-STARTTLS client. This client sends an email with fixed content. + +* [`ssl/ssl_pthread_server.c`](ssl/ssl_pthread_server.c): a simple HTTPS server using one thread per client to send a fixed response. This program requires the pthread library. + +* [`ssl/ssl_server.c`](ssl/ssl_server.c): a simple HTTPS server that sends a fixed response. It serves a single client at a time. + +### SSL/TLS feature demonstrators + +Note: unlike most of the other programs under the `programs/` directory, these two programs are not intended as a basis for writing an application. They combine most of the features supported by the library, and most applications require only a few features. To write a new application, we recommended that you start with `ssl_client1.c` or `ssl_server.c`, and then look inside `ssl/ssl_client2.c` or `ssl/ssl_server2.c` to see how to use the specific features that your application needs. + +* [`ssl/ssl_client2.c`](ssl/ssl_client2.c): an HTTPS client that sends a fixed request and displays the response, with options to select TLS protocol features and Mbed TLS library features. + +* [`ssl/ssl_server2.c`](ssl/ssl_server2.c): an HTTPS server that sends a fixed response, with options to select TLS protocol features and Mbed TLS library features. + +In addition to providing options for testing client-side features, the `ssl_client2` program has options that allow you to trigger certain behaviors in the server. For example, there are options to select ciphersuites, or to force a renegotiation. These options are useful for testing the corresponding features in a TLS server. Likewise, `ssl_server2` has options to activate certain behaviors that are useful for testing a TLS client. + +## Test utilities + +* [`test/benchmark.c`](test/benchmark.c): benchmark for cryptographic algorithms. + +* [`test/selftest.c`](test/selftest.c): runs the self-test function in each library module. + +* [`test/udp_proxy.c`](test/udp_proxy.c): a UDP proxy that can inject certain failures (delay, duplicate, drop). Useful for testing DTLS. + +* [`test/zeroize.c`](test/zeroize.c): a test program for `mbedtls_platform_zeroize`, used by [`tests/scripts/test_zeroize.gdb`](tests/scripts/test_zeroize.gdb). + +## Development utilities + +* [`util/pem2der.c`](util/pem2der.c): a PEM to DER converter. Mbed TLS can read PEM files directly, but this utility can be useful for interacting with other tools or with minimal Mbed TLS builds that lack PEM support. + +* [`util/strerror.c`](util/strerror.c): prints the error description corresponding to an integer status returned by an Mbed TLS function. + +## X.509 certificate examples + +* [`x509/cert_app.c`](x509/cert_app.c): connects to a TLS server and verifies its certificate chain. + +* [`x509/cert_req.c`](x509/cert_req.c): generates a certificate signing request (CSR) for a private key. + +* [`x509/cert_write.c`](x509/cert_write.c): signs a certificate signing request, or self-signs a certificate. + +* [`x509/crl_app.c`](x509/crl_app.c): loads and dumps a certificate revocation list (CRL). + +* [`x509/req_app.c`](x509/req_app.c): loads and dumps a certificate signing request (CSR). + diff --git a/3rdparty/mbedtls/mbedtls/programs/aes/aescrypt2.c b/3rdparty/mbedtls/mbedtls/programs/aes/aescrypt2.c index 9e98f1df0a..bdeac3afc8 100644 --- a/3rdparty/mbedtls/mbedtls/programs/aes/aescrypt2.c +++ b/3rdparty/mbedtls/mbedtls/programs/aes/aescrypt2.c @@ -19,6 +19,11 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +/* Enable definition of fileno() even when compiling with -std=c99. Must be + * set before config.h, which pulls in glibc's features.h indirectly. + * Harmless on other platforms. */ +#define _POSIX_C_SOURCE 1 + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -32,12 +37,14 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ #include "mbedtls/aes.h" #include "mbedtls/md.h" +#include "mbedtls/platform_util.h" #include #include @@ -73,10 +80,17 @@ int main( void ) } #else -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); } +#endif int main( int argc, char *argv[] ) { @@ -451,13 +465,13 @@ int main( int argc, char *argv[] ) the case when the user has missed or reordered some, in which case the key might not be in argv[4]. */ for( i = 0; i < (unsigned int) argc; i++ ) - mbedtls_zeroize( argv[i], strlen( argv[i] ) ); + mbedtls_platform_zeroize( argv[i], strlen( argv[i] ) ); - mbedtls_zeroize( IV, sizeof( IV ) ); - mbedtls_zeroize( key, sizeof( key ) ); - mbedtls_zeroize( tmp, sizeof( tmp ) ); - mbedtls_zeroize( buffer, sizeof( buffer ) ); - mbedtls_zeroize( digest, sizeof( digest ) ); + mbedtls_platform_zeroize( IV, sizeof( IV ) ); + mbedtls_platform_zeroize( key, sizeof( key ) ); + mbedtls_platform_zeroize( tmp, sizeof( tmp ) ); + mbedtls_platform_zeroize( buffer, sizeof( buffer ) ); + mbedtls_platform_zeroize( digest, sizeof( digest ) ); mbedtls_aes_free( &aes_ctx ); mbedtls_md_free( &sha_ctx ); diff --git a/3rdparty/mbedtls/mbedtls/programs/aes/crypt_and_hash.c b/3rdparty/mbedtls/mbedtls/programs/aes/crypt_and_hash.c index 5024f4a6f1..f58e6166dc 100644 --- a/3rdparty/mbedtls/mbedtls/programs/aes/crypt_and_hash.c +++ b/3rdparty/mbedtls/mbedtls/programs/aes/crypt_and_hash.c @@ -20,6 +20,11 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +/* Enable definition of fileno() even when compiling with -std=c99. Must be + * set before config.h, which pulls in glibc's features.h indirectly. + * Harmless on other platforms. */ +#define _POSIX_C_SOURCE 1 + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -33,6 +38,7 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -41,6 +47,7 @@ defined(MBEDTLS_FS_IO) #include "mbedtls/cipher.h" #include "mbedtls/md.h" +#include "mbedtls/platform_util.h" #include #include @@ -75,10 +82,17 @@ int main( void ) } #else -/* Implementation that should never be optimized out by the compiler */ -static void mbedtls_zeroize( void *v, size_t n ) { - volatile unsigned char *p = v; while( n-- ) *p++ = 0; +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); } +#endif int main( int argc, char *argv[] ) { @@ -548,13 +562,13 @@ int main( int argc, char *argv[] ) the case when the user has missed or reordered some, in which case the key might not be in argv[6]. */ for( i = 0; i < argc; i++ ) - mbedtls_zeroize( argv[i], strlen( argv[i] ) ); + mbedtls_platform_zeroize( argv[i], strlen( argv[i] ) ); - mbedtls_zeroize( IV, sizeof( IV ) ); - mbedtls_zeroize( key, sizeof( key ) ); - mbedtls_zeroize( buffer, sizeof( buffer ) ); - mbedtls_zeroize( output, sizeof( output ) ); - mbedtls_zeroize( digest, sizeof( digest ) ); + mbedtls_platform_zeroize( IV, sizeof( IV ) ); + mbedtls_platform_zeroize( key, sizeof( key ) ); + mbedtls_platform_zeroize( buffer, sizeof( buffer ) ); + mbedtls_platform_zeroize( output, sizeof( output ) ); + mbedtls_platform_zeroize( digest, sizeof( digest ) ); mbedtls_cipher_free( &cipher_ctx ); mbedtls_md_free( &md_ctx ); diff --git a/3rdparty/mbedtls/mbedtls/programs/hash/generic_sum.c b/3rdparty/mbedtls/mbedtls/programs/hash/generic_sum.c index bbe8d92a20..4b7fe37be5 100644 --- a/3rdparty/mbedtls/mbedtls/programs/hash/generic_sum.c +++ b/3rdparty/mbedtls/mbedtls/programs/hash/generic_sum.c @@ -32,6 +32,7 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -50,6 +51,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static int generic_wrapper( const mbedtls_md_info_t *md_info, char *filename, unsigned char *sum ) { int ret = mbedtls_md_file( md_info, filename, sum ); diff --git a/3rdparty/mbedtls/mbedtls/programs/hash/hello.c b/3rdparty/mbedtls/mbedtls/programs/hash/hello.c index 2e8c2244d7..6046f868cd 100644 --- a/3rdparty/mbedtls/mbedtls/programs/hash/hello.c +++ b/3rdparty/mbedtls/mbedtls/programs/hash/hello.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif @@ -46,6 +47,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( void ) { int i, ret; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/dh_client.c b/3rdparty/mbedtls/mbedtls/programs/pkey/dh_client.c index 3dadf48e6f..1dce31aa7b 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/dh_client.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/dh_client.c @@ -32,6 +32,7 @@ #include #define mbedtls_printf printf #define mbedtls_time_t time_t +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -70,6 +71,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( void ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/dh_genprime.c b/3rdparty/mbedtls/mbedtls/programs/pkey/dh_genprime.c index dbe9153386..cca43ca59a 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/dh_genprime.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/dh_genprime.c @@ -32,6 +32,7 @@ #include #define mbedtls_printf printf #define mbedtls_time_t time_t +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -68,6 +69,18 @@ int main( void ) */ #define GENERATOR "4" +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char **argv ) { int ret = 1; @@ -156,7 +169,7 @@ int main( int argc, char **argv ) goto exit; } - if( ( ret = mbedtls_mpi_is_prime( &Q, mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) + if( ( ret = mbedtls_mpi_is_prime_ext( &Q, 50, mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_mpi_is_prime returned %d\n\n", ret ); goto exit; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/dh_server.c b/3rdparty/mbedtls/mbedtls/programs/pkey/dh_server.c index c4e2c391e2..a797e60702 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/dh_server.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/dh_server.c @@ -32,6 +32,7 @@ #include #define mbedtls_printf printf #define mbedtls_time_t time_t +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -70,6 +71,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( void ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/ecdh_curve25519.c b/3rdparty/mbedtls/mbedtls/programs/pkey/ecdh_curve25519.c index 5db04088f9..9267c7ef5a 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/ecdh_curve25519.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/ecdh_curve25519.c @@ -31,16 +31,17 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ -#if !defined(MBEDTLS_ECDH_C) || \ +#if !defined(MBEDTLS_ECDH_C) || !defined(MBEDTLS_ECDH_LEGACY_CONTEXT) || \ !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) || \ !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C) int main( void ) { - mbedtls_printf( "MBEDTLS_ECDH_C and/or " + mbedtls_printf( "MBEDTLS_ECDH_C and/or MBEDTLS_ECDH_LEGACY_CONTEXT and/or " "MBEDTLS_ECP_DP_CURVE25519_ENABLED and/or " "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C " "not defined\n" ); @@ -52,6 +53,18 @@ int main( void ) #include "mbedtls/ctr_drbg.h" #include "mbedtls/ecdh.h" +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { int ret = 1; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/ecdsa.c b/3rdparty/mbedtls/mbedtls/programs/pkey/ecdsa.c index c653df9e42..4471a201e5 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/ecdsa.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/ecdsa.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -99,6 +100,18 @@ static void dump_pubkey( const char *title, mbedtls_ecdsa_context *key ) #define dump_pubkey( a, b ) #endif +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { int ret = 1; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/gen_key.c b/3rdparty/mbedtls/mbedtls/programs/pkey/gen_key.c index 31abb0cb8e..35fc1498fb 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/gen_key.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/gen_key.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -135,6 +136,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/key_app.c b/3rdparty/mbedtls/mbedtls/programs/pkey/key_app.c index 027b95f9d1..0bd61e481b 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/key_app.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/key_app.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -73,6 +74,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/key_app_writer.c b/3rdparty/mbedtls/mbedtls/programs/pkey/key_app_writer.c index cd0c230644..b81530cebc 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/key_app_writer.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/key_app_writer.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -96,6 +97,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ @@ -175,7 +189,7 @@ static int write_private_key( mbedtls_pk_context *key, const char *output_file ) return( ret ); len = ret; - c = output_buf + sizeof(output_buf) - len - 1; + c = output_buf + sizeof(output_buf) - len; } if( ( f = fopen( output_file, "w" ) ) == NULL ) diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/mpi_demo.c b/3rdparty/mbedtls/mbedtls/programs/pkey/mpi_demo.c index 365bdc4806..80573c0ed0 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/mpi_demo.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/mpi_demo.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -48,6 +49,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( void ) { int ret = 1; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_decrypt.c b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_decrypt.c index 1d8c959a09..978f39ef1d 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_decrypt.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_decrypt.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -59,6 +60,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_encrypt.c b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_encrypt.c index 22dedba103..806c59aae8 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_encrypt.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_encrypt.c @@ -32,6 +32,7 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -59,6 +60,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_sign.c b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_sign.c index 7ec46752ad..7354082f11 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_sign.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_sign.c @@ -32,6 +32,7 @@ #include #define mbedtls_snprintf snprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -59,6 +60,18 @@ int main( void ) #include #include +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_verify.c b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_verify.c index 3c7709f9d5..9fcf029b8a 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/pk_verify.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/pk_verify.c @@ -32,6 +32,7 @@ #include #define mbedtls_snprintf snprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -55,6 +56,18 @@ int main( void ) #include #include +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_decrypt.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_decrypt.c index 0a252d2ada..dc8a9200d5 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_decrypt.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_decrypt.c @@ -58,6 +58,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_encrypt.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_encrypt.c index 411657a07c..e9effe806a 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_encrypt.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_encrypt.c @@ -58,6 +58,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_genkey.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_genkey.c index 3359e14074..81867ee9e5 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_genkey.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_genkey.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -62,6 +63,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( void ) { int ret = 1; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign.c index b16fe5d226..f014872027 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign.c @@ -33,6 +33,7 @@ #define mbedtls_fprintf fprintf #define mbedtls_printf printf #define mbedtls_snprintf snprintf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -55,6 +56,18 @@ int main( void ) #include #include +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign_pss.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign_pss.c index b0b0f7ecf4..51317457b3 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign_pss.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_sign_pss.c @@ -32,6 +32,7 @@ #include #define mbedtls_snprintf snprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -54,12 +55,23 @@ int main( void ) #include "mbedtls/ctr_drbg.h" #include "mbedtls/md.h" #include "mbedtls/rsa.h" -#include "mbedtls/md.h" #include "mbedtls/x509.h" #include #include +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify.c index 6f88345f2e..5d1c0851e1 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify.c @@ -32,6 +32,7 @@ #include #define mbedtls_printf printf #define mbedtls_snprintf snprintf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -54,6 +55,18 @@ int main( void ) #include #include +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify_pss.c b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify_pss.c index 7c9c68f229..34122ca4f3 100644 --- a/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify_pss.c +++ b/3rdparty/mbedtls/mbedtls/programs/pkey/rsa_verify_pss.c @@ -32,6 +32,7 @@ #include #define mbedtls_snprintf snprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -59,6 +60,18 @@ int main( void ) #include #include +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/random/gen_entropy.c b/3rdparty/mbedtls/mbedtls/programs/random/gen_entropy.c index a1eb3868a4..3b350ede2f 100644 --- a/3rdparty/mbedtls/mbedtls/programs/random/gen_entropy.c +++ b/3rdparty/mbedtls/mbedtls/programs/random/gen_entropy.c @@ -32,6 +32,7 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -49,6 +50,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/random/gen_random_ctr_drbg.c b/3rdparty/mbedtls/mbedtls/programs/random/gen_random_ctr_drbg.c index 5ade946a74..a50402f19f 100644 --- a/3rdparty/mbedtls/mbedtls/programs/random/gen_random_ctr_drbg.c +++ b/3rdparty/mbedtls/mbedtls/programs/random/gen_random_ctr_drbg.c @@ -32,6 +32,7 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -52,6 +53,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/random/gen_random_havege.c b/3rdparty/mbedtls/mbedtls/programs/random/gen_random_havege.c index 3fb3f01963..ef888ff61b 100644 --- a/3rdparty/mbedtls/mbedtls/programs/random/gen_random_havege.c +++ b/3rdparty/mbedtls/mbedtls/programs/random/gen_random_havege.c @@ -32,6 +32,7 @@ #include #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -50,6 +51,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { FILE *f; diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/CMakeLists.txt b/3rdparty/mbedtls/mbedtls/programs/ssl/CMakeLists.txt index 1e65633412..803920cde6 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/CMakeLists.txt +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/CMakeLists.txt @@ -34,12 +34,14 @@ add_executable(ssl_client1 ssl_client1.c) target_link_libraries(ssl_client1 ${libs}) add_executable(ssl_client2 ssl_client2.c) +target_sources(ssl_client2 PUBLIC query_config.c) target_link_libraries(ssl_client2 ${libs}) add_executable(ssl_server ssl_server.c) target_link_libraries(ssl_server ${libs}) add_executable(ssl_server2 ssl_server2.c) +target_sources(ssl_server2 PUBLIC query_config.c) target_link_libraries(ssl_server2 ${libs}) add_executable(ssl_fork_server ssl_fork_server.c) diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_client.c b/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_client.c index c29ab34a60..90db06ca9d 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_client.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_client.c @@ -31,6 +31,9 @@ #include #define mbedtls_printf printf #define mbedtls_fprintf fprintf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #if !defined(MBEDTLS_SSL_CLI_C) || !defined(MBEDTLS_SSL_PROTO_DTLS) || \ @@ -79,6 +82,18 @@ int main( void ) #define DEBUG_LEVEL 0 +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_server.c b/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_server.c index b4ad6b53aa..dd21fbf47b 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_server.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/dtls_server.c @@ -32,6 +32,9 @@ #define mbedtls_printf printf #define mbedtls_fprintf fprintf #define mbedtls_time_t time_t +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* Uncomment out the following line to default to IPv4 and disable IPv6 */ @@ -88,6 +91,18 @@ int main( void ) #define READ_TIMEOUT_MS 10000 /* 5 seconds */ #define DEBUG_LEVEL 0 +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/mini_client.c b/3rdparty/mbedtls/mbedtls/programs/ssl/mini_client.c index 290455e9ae..ff3612885c 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/mini_client.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/mini_client.c @@ -26,6 +26,17 @@ #include MBEDTLS_CONFIG_FILE #endif +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif + /* * We're creating and connecting the socket "manually" rather than using the * NET module, in order to avoid the overhead of getaddrinfo() which tends to @@ -44,13 +55,6 @@ !defined(MBEDTLS_NET_C) || !defined(MBEDTLS_SSL_CLI_C) || \ !defined(UNIX) -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#define mbedtls_printf printf -#endif - int main( void ) { mbedtls_printf( "MBEDTLS_CTR_DRBG_C and/or MBEDTLS_ENTROPY_C and/or " @@ -60,12 +64,6 @@ int main( void ) } #else -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#endif - #include #include "mbedtls/net_sockets.h" @@ -168,6 +166,18 @@ enum exit_codes ssl_write_failed, }; +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( void ) { int ret = exit_ok; diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/query_config.c b/3rdparty/mbedtls/mbedtls/programs/ssl/query_config.c new file mode 100644 index 0000000000..6e281977e8 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/query_config.c @@ -0,0 +1,2515 @@ +/* + * Query Mbed TLS compile time configurations from config.h + * + * Copyright (C) 2018, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ + +/* + * Include all the headers with public APIs in case they define a macro to its + * default value when that configuration is not set in the config.h. + */ +#include "mbedtls/aes.h" +#include "mbedtls/aesni.h" +#include "mbedtls/arc4.h" +#include "mbedtls/aria.h" +#include "mbedtls/asn1.h" +#include "mbedtls/asn1write.h" +#include "mbedtls/base64.h" +#include "mbedtls/bignum.h" +#include "mbedtls/blowfish.h" +#include "mbedtls/camellia.h" +#include "mbedtls/ccm.h" +#include "mbedtls/certs.h" +#include "mbedtls/chacha20.h" +#include "mbedtls/chachapoly.h" +#include "mbedtls/cipher.h" +#include "mbedtls/cmac.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/debug.h" +#include "mbedtls/des.h" +#include "mbedtls/dhm.h" +#include "mbedtls/ecdh.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/ecjpake.h" +#include "mbedtls/ecp.h" +#include "mbedtls/entropy.h" +#include "mbedtls/entropy_poll.h" +#include "mbedtls/error.h" +#include "mbedtls/gcm.h" +#include "mbedtls/havege.h" +#include "mbedtls/hkdf.h" +#include "mbedtls/hmac_drbg.h" +#include "mbedtls/md.h" +#include "mbedtls/md2.h" +#include "mbedtls/md4.h" +#include "mbedtls/md5.h" +#include "mbedtls/memory_buffer_alloc.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/nist_kw.h" +#include "mbedtls/oid.h" +#include "mbedtls/padlock.h" +#include "mbedtls/pem.h" +#include "mbedtls/pk.h" +#include "mbedtls/pkcs11.h" +#include "mbedtls/pkcs12.h" +#include "mbedtls/pkcs5.h" +#include "mbedtls/platform_time.h" +#include "mbedtls/platform_util.h" +#include "mbedtls/poly1305.h" +#include "mbedtls/ripemd160.h" +#include "mbedtls/rsa.h" +#include "mbedtls/sha1.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_cache.h" +#include "mbedtls/ssl_ciphersuites.h" +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/ssl_internal.h" +#include "mbedtls/ssl_ticket.h" +#include "mbedtls/threading.h" +#include "mbedtls/timing.h" +#include "mbedtls/version.h" +#include "mbedtls/x509.h" +#include "mbedtls/x509_crl.h" +#include "mbedtls/x509_crt.h" +#include "mbedtls/x509_csr.h" +#include "mbedtls/xtea.h" + +#include + +/* + * Helper macros to convert a macro or its expansion into a string + * WARNING: This does not work for expanding function-like macros. However, + * Mbed TLS does not currently have configuration options used in this fashion. + */ +#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro) +#define MACRO_NAME_TO_STR(macro) \ + mbedtls_printf( "%s", strlen( #macro "" ) > 0 ? #macro "\n" : "" ) + +#if defined(_MSC_VER) +/* + * Visual Studio throws the warning 4003 because many Mbed TLS feature macros + * are defined empty. This means that from the preprocessor's point of view + * the macro MBEDTLS_EXPANSION_TO_STR is being invoked without arguments as + * some macros expand to nothing. We suppress that specific warning to get a + * clean build and to ensure that tests treating warnings as errors do not + * fail. + */ +#pragma warning(push) +#pragma warning(disable:4003) +#endif /* _MSC_VER */ + +int query_config( const char *config ) +{ +#if defined(MBEDTLS_HAVE_ASM) + if( strcmp( "MBEDTLS_HAVE_ASM", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HAVE_ASM ); + return( 0 ); + } +#endif /* MBEDTLS_HAVE_ASM */ + +#if defined(MBEDTLS_NO_UDBL_DIVISION) + if( strcmp( "MBEDTLS_NO_UDBL_DIVISION", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NO_UDBL_DIVISION ); + return( 0 ); + } +#endif /* MBEDTLS_NO_UDBL_DIVISION */ + +#if defined(MBEDTLS_NO_64BIT_MULTIPLICATION) + if( strcmp( "MBEDTLS_NO_64BIT_MULTIPLICATION", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NO_64BIT_MULTIPLICATION ); + return( 0 ); + } +#endif /* MBEDTLS_NO_64BIT_MULTIPLICATION */ + +#if defined(MBEDTLS_HAVE_SSE2) + if( strcmp( "MBEDTLS_HAVE_SSE2", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HAVE_SSE2 ); + return( 0 ); + } +#endif /* MBEDTLS_HAVE_SSE2 */ + +#if defined(MBEDTLS_HAVE_TIME) + if( strcmp( "MBEDTLS_HAVE_TIME", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HAVE_TIME ); + return( 0 ); + } +#endif /* MBEDTLS_HAVE_TIME */ + +#if defined(MBEDTLS_HAVE_TIME_DATE) + if( strcmp( "MBEDTLS_HAVE_TIME_DATE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HAVE_TIME_DATE ); + return( 0 ); + } +#endif /* MBEDTLS_HAVE_TIME_DATE */ + +#if defined(MBEDTLS_PLATFORM_MEMORY) + if( strcmp( "MBEDTLS_PLATFORM_MEMORY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_MEMORY ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_MEMORY */ + +#if defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) + if( strcmp( "MBEDTLS_PLATFORM_NO_STD_FUNCTIONS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_NO_STD_FUNCTIONS ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_NO_STD_FUNCTIONS */ + +#if defined(MBEDTLS_PLATFORM_EXIT_ALT) + if( strcmp( "MBEDTLS_PLATFORM_EXIT_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_EXIT_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_EXIT_ALT */ + +#if defined(MBEDTLS_PLATFORM_TIME_ALT) + if( strcmp( "MBEDTLS_PLATFORM_TIME_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_TIME_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_TIME_ALT */ + +#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) + if( strcmp( "MBEDTLS_PLATFORM_FPRINTF_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_FPRINTF_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */ + +#if defined(MBEDTLS_PLATFORM_PRINTF_ALT) + if( strcmp( "MBEDTLS_PLATFORM_PRINTF_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_PRINTF_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_PRINTF_ALT */ + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_ALT) + if( strcmp( "MBEDTLS_PLATFORM_SNPRINTF_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_SNPRINTF_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_SNPRINTF_ALT */ + +#if defined(MBEDTLS_PLATFORM_NV_SEED_ALT) + if( strcmp( "MBEDTLS_PLATFORM_NV_SEED_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_NV_SEED_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_NV_SEED_ALT */ + +#if defined(MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT) + if( strcmp( "MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_SETUP_TEARDOWN_ALT */ + +#if defined(MBEDTLS_DEPRECATED_WARNING) + if( strcmp( "MBEDTLS_DEPRECATED_WARNING", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DEPRECATED_WARNING ); + return( 0 ); + } +#endif /* MBEDTLS_DEPRECATED_WARNING */ + +#if defined(MBEDTLS_DEPRECATED_REMOVED) + if( strcmp( "MBEDTLS_DEPRECATED_REMOVED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DEPRECATED_REMOVED ); + return( 0 ); + } +#endif /* MBEDTLS_DEPRECATED_REMOVED */ + +#if defined(MBEDTLS_CHECK_PARAMS) + if( strcmp( "MBEDTLS_CHECK_PARAMS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CHECK_PARAMS ); + return( 0 ); + } +#endif /* MBEDTLS_CHECK_PARAMS */ + +#if defined(MBEDTLS_TIMING_ALT) + if( strcmp( "MBEDTLS_TIMING_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_TIMING_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_TIMING_ALT */ + +#if defined(MBEDTLS_AES_ALT) + if( strcmp( "MBEDTLS_AES_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_AES_ALT */ + +#if defined(MBEDTLS_ARC4_ALT) + if( strcmp( "MBEDTLS_ARC4_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ARC4_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ARC4_ALT */ + +#if defined(MBEDTLS_ARIA_ALT) + if( strcmp( "MBEDTLS_ARIA_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ARIA_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ARIA_ALT */ + +#if defined(MBEDTLS_BLOWFISH_ALT) + if( strcmp( "MBEDTLS_BLOWFISH_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_BLOWFISH_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_BLOWFISH_ALT */ + +#if defined(MBEDTLS_CAMELLIA_ALT) + if( strcmp( "MBEDTLS_CAMELLIA_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CAMELLIA_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_CAMELLIA_ALT */ + +#if defined(MBEDTLS_CCM_ALT) + if( strcmp( "MBEDTLS_CCM_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CCM_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_CCM_ALT */ + +#if defined(MBEDTLS_CHACHA20_ALT) + if( strcmp( "MBEDTLS_CHACHA20_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CHACHA20_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_CHACHA20_ALT */ + +#if defined(MBEDTLS_CHACHAPOLY_ALT) + if( strcmp( "MBEDTLS_CHACHAPOLY_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CHACHAPOLY_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_CHACHAPOLY_ALT */ + +#if defined(MBEDTLS_CMAC_ALT) + if( strcmp( "MBEDTLS_CMAC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CMAC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_CMAC_ALT */ + +#if defined(MBEDTLS_DES_ALT) + if( strcmp( "MBEDTLS_DES_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DES_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_DES_ALT */ + +#if defined(MBEDTLS_DHM_ALT) + if( strcmp( "MBEDTLS_DHM_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DHM_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_DHM_ALT */ + +#if defined(MBEDTLS_ECJPAKE_ALT) + if( strcmp( "MBEDTLS_ECJPAKE_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECJPAKE_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECJPAKE_ALT */ + +#if defined(MBEDTLS_GCM_ALT) + if( strcmp( "MBEDTLS_GCM_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_GCM_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_GCM_ALT */ + +#if defined(MBEDTLS_NIST_KW_ALT) + if( strcmp( "MBEDTLS_NIST_KW_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NIST_KW_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_NIST_KW_ALT */ + +#if defined(MBEDTLS_MD2_ALT) + if( strcmp( "MBEDTLS_MD2_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD2_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_MD2_ALT */ + +#if defined(MBEDTLS_MD4_ALT) + if( strcmp( "MBEDTLS_MD4_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD4_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_MD4_ALT */ + +#if defined(MBEDTLS_MD5_ALT) + if( strcmp( "MBEDTLS_MD5_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD5_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_MD5_ALT */ + +#if defined(MBEDTLS_POLY1305_ALT) + if( strcmp( "MBEDTLS_POLY1305_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_POLY1305_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_POLY1305_ALT */ + +#if defined(MBEDTLS_RIPEMD160_ALT) + if( strcmp( "MBEDTLS_RIPEMD160_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_RIPEMD160_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_RIPEMD160_ALT */ + +#if defined(MBEDTLS_RSA_ALT) + if( strcmp( "MBEDTLS_RSA_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_RSA_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_RSA_ALT */ + +#if defined(MBEDTLS_SHA1_ALT) + if( strcmp( "MBEDTLS_SHA1_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA1_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_SHA1_ALT */ + +#if defined(MBEDTLS_SHA256_ALT) + if( strcmp( "MBEDTLS_SHA256_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA256_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_SHA256_ALT */ + +#if defined(MBEDTLS_SHA512_ALT) + if( strcmp( "MBEDTLS_SHA512_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA512_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_SHA512_ALT */ + +#if defined(MBEDTLS_XTEA_ALT) + if( strcmp( "MBEDTLS_XTEA_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_XTEA_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_XTEA_ALT */ + +#if defined(MBEDTLS_ECP_ALT) + if( strcmp( "MBEDTLS_ECP_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_ALT */ + +#if defined(MBEDTLS_MD2_PROCESS_ALT) + if( strcmp( "MBEDTLS_MD2_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD2_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_MD2_PROCESS_ALT */ + +#if defined(MBEDTLS_MD4_PROCESS_ALT) + if( strcmp( "MBEDTLS_MD4_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD4_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_MD4_PROCESS_ALT */ + +#if defined(MBEDTLS_MD5_PROCESS_ALT) + if( strcmp( "MBEDTLS_MD5_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD5_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_MD5_PROCESS_ALT */ + +#if defined(MBEDTLS_RIPEMD160_PROCESS_ALT) + if( strcmp( "MBEDTLS_RIPEMD160_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_RIPEMD160_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_RIPEMD160_PROCESS_ALT */ + +#if defined(MBEDTLS_SHA1_PROCESS_ALT) + if( strcmp( "MBEDTLS_SHA1_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA1_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_SHA1_PROCESS_ALT */ + +#if defined(MBEDTLS_SHA256_PROCESS_ALT) + if( strcmp( "MBEDTLS_SHA256_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA256_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_SHA256_PROCESS_ALT */ + +#if defined(MBEDTLS_SHA512_PROCESS_ALT) + if( strcmp( "MBEDTLS_SHA512_PROCESS_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA512_PROCESS_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_SHA512_PROCESS_ALT */ + +#if defined(MBEDTLS_DES_SETKEY_ALT) + if( strcmp( "MBEDTLS_DES_SETKEY_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DES_SETKEY_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_DES_SETKEY_ALT */ + +#if defined(MBEDTLS_DES_CRYPT_ECB_ALT) + if( strcmp( "MBEDTLS_DES_CRYPT_ECB_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DES_CRYPT_ECB_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_DES_CRYPT_ECB_ALT */ + +#if defined(MBEDTLS_DES3_CRYPT_ECB_ALT) + if( strcmp( "MBEDTLS_DES3_CRYPT_ECB_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DES3_CRYPT_ECB_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_DES3_CRYPT_ECB_ALT */ + +#if defined(MBEDTLS_AES_SETKEY_ENC_ALT) + if( strcmp( "MBEDTLS_AES_SETKEY_ENC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_SETKEY_ENC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_AES_SETKEY_ENC_ALT */ + +#if defined(MBEDTLS_AES_SETKEY_DEC_ALT) + if( strcmp( "MBEDTLS_AES_SETKEY_DEC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_SETKEY_DEC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_AES_SETKEY_DEC_ALT */ + +#if defined(MBEDTLS_AES_ENCRYPT_ALT) + if( strcmp( "MBEDTLS_AES_ENCRYPT_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_ENCRYPT_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_AES_ENCRYPT_ALT */ + +#if defined(MBEDTLS_AES_DECRYPT_ALT) + if( strcmp( "MBEDTLS_AES_DECRYPT_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_DECRYPT_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_AES_DECRYPT_ALT */ + +#if defined(MBEDTLS_ECDH_GEN_PUBLIC_ALT) + if( strcmp( "MBEDTLS_ECDH_GEN_PUBLIC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDH_GEN_PUBLIC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECDH_GEN_PUBLIC_ALT */ + +#if defined(MBEDTLS_ECDH_COMPUTE_SHARED_ALT) + if( strcmp( "MBEDTLS_ECDH_COMPUTE_SHARED_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDH_COMPUTE_SHARED_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECDH_COMPUTE_SHARED_ALT */ + +#if defined(MBEDTLS_ECDSA_VERIFY_ALT) + if( strcmp( "MBEDTLS_ECDSA_VERIFY_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDSA_VERIFY_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECDSA_VERIFY_ALT */ + +#if defined(MBEDTLS_ECDSA_SIGN_ALT) + if( strcmp( "MBEDTLS_ECDSA_SIGN_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDSA_SIGN_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECDSA_SIGN_ALT */ + +#if defined(MBEDTLS_ECDSA_GENKEY_ALT) + if( strcmp( "MBEDTLS_ECDSA_GENKEY_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDSA_GENKEY_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECDSA_GENKEY_ALT */ + +#if defined(MBEDTLS_ECP_INTERNAL_ALT) + if( strcmp( "MBEDTLS_ECP_INTERNAL_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_INTERNAL_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_INTERNAL_ALT */ + +#if defined(MBEDTLS_ECP_RANDOMIZE_JAC_ALT) + if( strcmp( "MBEDTLS_ECP_RANDOMIZE_JAC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_RANDOMIZE_JAC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_RANDOMIZE_JAC_ALT */ + +#if defined(MBEDTLS_ECP_ADD_MIXED_ALT) + if( strcmp( "MBEDTLS_ECP_ADD_MIXED_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_ADD_MIXED_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_ADD_MIXED_ALT */ + +#if defined(MBEDTLS_ECP_DOUBLE_JAC_ALT) + if( strcmp( "MBEDTLS_ECP_DOUBLE_JAC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DOUBLE_JAC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DOUBLE_JAC_ALT */ + +#if defined(MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT) + if( strcmp( "MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT */ + +#if defined(MBEDTLS_ECP_NORMALIZE_JAC_ALT) + if( strcmp( "MBEDTLS_ECP_NORMALIZE_JAC_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_NORMALIZE_JAC_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_NORMALIZE_JAC_ALT */ + +#if defined(MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT) + if( strcmp( "MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DOUBLE_ADD_MXZ_ALT */ + +#if defined(MBEDTLS_ECP_RANDOMIZE_MXZ_ALT) + if( strcmp( "MBEDTLS_ECP_RANDOMIZE_MXZ_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_RANDOMIZE_MXZ_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_RANDOMIZE_MXZ_ALT */ + +#if defined(MBEDTLS_ECP_NORMALIZE_MXZ_ALT) + if( strcmp( "MBEDTLS_ECP_NORMALIZE_MXZ_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_NORMALIZE_MXZ_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_NORMALIZE_MXZ_ALT */ + +#if defined(MBEDTLS_TEST_NULL_ENTROPY) + if( strcmp( "MBEDTLS_TEST_NULL_ENTROPY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_TEST_NULL_ENTROPY ); + return( 0 ); + } +#endif /* MBEDTLS_TEST_NULL_ENTROPY */ + +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + if( strcmp( "MBEDTLS_ENTROPY_HARDWARE_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_HARDWARE_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */ + +#if defined(MBEDTLS_AES_ROM_TABLES) + if( strcmp( "MBEDTLS_AES_ROM_TABLES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_ROM_TABLES ); + return( 0 ); + } +#endif /* MBEDTLS_AES_ROM_TABLES */ + +#if defined(MBEDTLS_AES_FEWER_TABLES) + if( strcmp( "MBEDTLS_AES_FEWER_TABLES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_FEWER_TABLES ); + return( 0 ); + } +#endif /* MBEDTLS_AES_FEWER_TABLES */ + +#if defined(MBEDTLS_CAMELLIA_SMALL_MEMORY) + if( strcmp( "MBEDTLS_CAMELLIA_SMALL_MEMORY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CAMELLIA_SMALL_MEMORY ); + return( 0 ); + } +#endif /* MBEDTLS_CAMELLIA_SMALL_MEMORY */ + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + if( strcmp( "MBEDTLS_CIPHER_MODE_CBC", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_MODE_CBC ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + if( strcmp( "MBEDTLS_CIPHER_MODE_CFB", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_MODE_CFB ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + if( strcmp( "MBEDTLS_CIPHER_MODE_CTR", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_MODE_CTR ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_CIPHER_MODE_OFB) + if( strcmp( "MBEDTLS_CIPHER_MODE_OFB", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_MODE_OFB ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + +#if defined(MBEDTLS_CIPHER_MODE_XTS) + if( strcmp( "MBEDTLS_CIPHER_MODE_XTS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_MODE_XTS ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + +#if defined(MBEDTLS_CIPHER_NULL_CIPHER) + if( strcmp( "MBEDTLS_CIPHER_NULL_CIPHER", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_NULL_CIPHER ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_NULL_CIPHER */ + +#if defined(MBEDTLS_CIPHER_PADDING_PKCS7) + if( strcmp( "MBEDTLS_CIPHER_PADDING_PKCS7", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_PADDING_PKCS7 ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_PADDING_PKCS7 */ + +#if defined(MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS) + if( strcmp( "MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */ + +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN) + if( strcmp( "MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */ + +#if defined(MBEDTLS_CIPHER_PADDING_ZEROS) + if( strcmp( "MBEDTLS_CIPHER_PADDING_ZEROS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_PADDING_ZEROS ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_PADDING_ZEROS */ + +#if defined(MBEDTLS_ENABLE_WEAK_CIPHERSUITES) + if( strcmp( "MBEDTLS_ENABLE_WEAK_CIPHERSUITES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENABLE_WEAK_CIPHERSUITES ); + return( 0 ); + } +#endif /* MBEDTLS_ENABLE_WEAK_CIPHERSUITES */ + +#if defined(MBEDTLS_REMOVE_ARC4_CIPHERSUITES) + if( strcmp( "MBEDTLS_REMOVE_ARC4_CIPHERSUITES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_REMOVE_ARC4_CIPHERSUITES ); + return( 0 ); + } +#endif /* MBEDTLS_REMOVE_ARC4_CIPHERSUITES */ + +#if defined(MBEDTLS_REMOVE_3DES_CIPHERSUITES) + if( strcmp( "MBEDTLS_REMOVE_3DES_CIPHERSUITES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_REMOVE_3DES_CIPHERSUITES ); + return( 0 ); + } +#endif /* MBEDTLS_REMOVE_3DES_CIPHERSUITES */ + +#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP192R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP192R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP224R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP224R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP256R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP256R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP384R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP384R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP521R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP521R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP192K1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP192K1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP224K1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP224K1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_SECP256K1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_SECP256K1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_BP256R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_BP256R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_BP384R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_BP384R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_BP512R1_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_BP512R1_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_CURVE25519_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_CURVE25519_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_CURVE25519_ENABLED */ + +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) + if( strcmp( "MBEDTLS_ECP_DP_CURVE448_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_DP_CURVE448_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_DP_CURVE448_ENABLED */ + +#if defined(MBEDTLS_ECP_NIST_OPTIM) + if( strcmp( "MBEDTLS_ECP_NIST_OPTIM", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_NIST_OPTIM ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_NIST_OPTIM */ + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( strcmp( "MBEDTLS_ECP_RESTARTABLE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_RESTARTABLE ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_RESTARTABLE */ + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + if( strcmp( "MBEDTLS_ECDSA_DETERMINISTIC", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDSA_DETERMINISTIC ); + return( 0 ); + } +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ + +#if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_PSK_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_PSK_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_RSA_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED */ + +#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) + if( strcmp( "MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED ); + return( 0 ); + } +#endif /* MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ + +#if defined(MBEDTLS_PK_PARSE_EC_EXTENDED) + if( strcmp( "MBEDTLS_PK_PARSE_EC_EXTENDED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PK_PARSE_EC_EXTENDED ); + return( 0 ); + } +#endif /* MBEDTLS_PK_PARSE_EC_EXTENDED */ + +#if defined(MBEDTLS_ERROR_STRERROR_DUMMY) + if( strcmp( "MBEDTLS_ERROR_STRERROR_DUMMY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ERROR_STRERROR_DUMMY ); + return( 0 ); + } +#endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ + +#if defined(MBEDTLS_GENPRIME) + if( strcmp( "MBEDTLS_GENPRIME", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_GENPRIME ); + return( 0 ); + } +#endif /* MBEDTLS_GENPRIME */ + +#if defined(MBEDTLS_FS_IO) + if( strcmp( "MBEDTLS_FS_IO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_FS_IO ); + return( 0 ); + } +#endif /* MBEDTLS_FS_IO */ + +#if defined(MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES) + if( strcmp( "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES ); + return( 0 ); + } +#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */ + +#if defined(MBEDTLS_NO_PLATFORM_ENTROPY) + if( strcmp( "MBEDTLS_NO_PLATFORM_ENTROPY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NO_PLATFORM_ENTROPY ); + return( 0 ); + } +#endif /* MBEDTLS_NO_PLATFORM_ENTROPY */ + +#if defined(MBEDTLS_ENTROPY_FORCE_SHA256) + if( strcmp( "MBEDTLS_ENTROPY_FORCE_SHA256", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_FORCE_SHA256 ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_FORCE_SHA256 */ + +#if defined(MBEDTLS_ENTROPY_NV_SEED) + if( strcmp( "MBEDTLS_ENTROPY_NV_SEED", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_NV_SEED ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_NV_SEED */ + +#if defined(MBEDTLS_MEMORY_DEBUG) + if( strcmp( "MBEDTLS_MEMORY_DEBUG", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MEMORY_DEBUG ); + return( 0 ); + } +#endif /* MBEDTLS_MEMORY_DEBUG */ + +#if defined(MBEDTLS_MEMORY_BACKTRACE) + if( strcmp( "MBEDTLS_MEMORY_BACKTRACE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MEMORY_BACKTRACE ); + return( 0 ); + } +#endif /* MBEDTLS_MEMORY_BACKTRACE */ + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) + if( strcmp( "MBEDTLS_PK_RSA_ALT_SUPPORT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PK_RSA_ALT_SUPPORT ); + return( 0 ); + } +#endif /* MBEDTLS_PK_RSA_ALT_SUPPORT */ + +#if defined(MBEDTLS_PKCS1_V15) + if( strcmp( "MBEDTLS_PKCS1_V15", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PKCS1_V15 ); + return( 0 ); + } +#endif /* MBEDTLS_PKCS1_V15 */ + +#if defined(MBEDTLS_PKCS1_V21) + if( strcmp( "MBEDTLS_PKCS1_V21", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PKCS1_V21 ); + return( 0 ); + } +#endif /* MBEDTLS_PKCS1_V21 */ + +#if defined(MBEDTLS_RSA_NO_CRT) + if( strcmp( "MBEDTLS_RSA_NO_CRT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_RSA_NO_CRT ); + return( 0 ); + } +#endif /* MBEDTLS_RSA_NO_CRT */ + +#if defined(MBEDTLS_SELF_TEST) + if( strcmp( "MBEDTLS_SELF_TEST", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SELF_TEST ); + return( 0 ); + } +#endif /* MBEDTLS_SELF_TEST */ + +#if defined(MBEDTLS_SHA256_SMALLER) + if( strcmp( "MBEDTLS_SHA256_SMALLER", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA256_SMALLER ); + return( 0 ); + } +#endif /* MBEDTLS_SHA256_SMALLER */ + +#if defined(MBEDTLS_SSL_ALL_ALERT_MESSAGES) + if( strcmp( "MBEDTLS_SSL_ALL_ALERT_MESSAGES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_ALL_ALERT_MESSAGES ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_ALL_ALERT_MESSAGES */ + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( strcmp( "MBEDTLS_SSL_ASYNC_PRIVATE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_ASYNC_PRIVATE ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + +#if defined(MBEDTLS_SSL_DEBUG_ALL) + if( strcmp( "MBEDTLS_SSL_DEBUG_ALL", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DEBUG_ALL ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DEBUG_ALL */ + +#if defined(MBEDTLS_SSL_ENCRYPT_THEN_MAC) + if( strcmp( "MBEDTLS_SSL_ENCRYPT_THEN_MAC", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_ENCRYPT_THEN_MAC ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_ENCRYPT_THEN_MAC */ + +#if defined(MBEDTLS_SSL_EXTENDED_MASTER_SECRET) + if( strcmp( "MBEDTLS_SSL_EXTENDED_MASTER_SECRET", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_EXTENDED_MASTER_SECRET ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_EXTENDED_MASTER_SECRET */ + +#if defined(MBEDTLS_SSL_FALLBACK_SCSV) + if( strcmp( "MBEDTLS_SSL_FALLBACK_SCSV", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_FALLBACK_SCSV ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_FALLBACK_SCSV */ + +#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) + if( strcmp( "MBEDTLS_SSL_HW_RECORD_ACCEL", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_HW_RECORD_ACCEL ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */ + +#if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) + if( strcmp( "MBEDTLS_SSL_CBC_RECORD_SPLITTING", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CBC_RECORD_SPLITTING ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */ + +#if defined(MBEDTLS_SSL_RENEGOTIATION) + if( strcmp( "MBEDTLS_SSL_RENEGOTIATION", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_RENEGOTIATION ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_RENEGOTIATION */ + +#if defined(MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO) + if( strcmp( "MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO */ + +#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE) + if( strcmp( "MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE */ + +#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) + if( strcmp( "MBEDTLS_SSL_MAX_FRAGMENT_LENGTH", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_MAX_FRAGMENT_LENGTH ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_MAX_FRAGMENT_LENGTH */ + +#if defined(MBEDTLS_SSL_PROTO_SSL3) + if( strcmp( "MBEDTLS_SSL_PROTO_SSL3", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_PROTO_SSL3 ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_PROTO_SSL3 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1) + if( strcmp( "MBEDTLS_SSL_PROTO_TLS1", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_PROTO_TLS1 ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_PROTO_TLS1 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_1) + if( strcmp( "MBEDTLS_SSL_PROTO_TLS1_1", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_PROTO_TLS1_1 ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_1 */ + +#if defined(MBEDTLS_SSL_PROTO_TLS1_2) + if( strcmp( "MBEDTLS_SSL_PROTO_TLS1_2", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_PROTO_TLS1_2 ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_PROTO_TLS1_2 */ + +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( strcmp( "MBEDTLS_SSL_PROTO_DTLS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_PROTO_DTLS ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_PROTO_DTLS */ + +#if defined(MBEDTLS_SSL_ALPN) + if( strcmp( "MBEDTLS_SSL_ALPN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_ALPN ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_ALPN */ + +#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) + if( strcmp( "MBEDTLS_SSL_DTLS_ANTI_REPLAY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DTLS_ANTI_REPLAY ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DTLS_ANTI_REPLAY */ + +#if defined(MBEDTLS_SSL_DTLS_HELLO_VERIFY) + if( strcmp( "MBEDTLS_SSL_DTLS_HELLO_VERIFY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DTLS_HELLO_VERIFY ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DTLS_HELLO_VERIFY */ + +#if defined(MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE) + if( strcmp( "MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE */ + +#if defined(MBEDTLS_SSL_DTLS_BADMAC_LIMIT) + if( strcmp( "MBEDTLS_SSL_DTLS_BADMAC_LIMIT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DTLS_BADMAC_LIMIT ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DTLS_BADMAC_LIMIT */ + +#if defined(MBEDTLS_SSL_SESSION_TICKETS) + if( strcmp( "MBEDTLS_SSL_SESSION_TICKETS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_SESSION_TICKETS ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_SESSION_TICKETS */ + +#if defined(MBEDTLS_SSL_EXPORT_KEYS) + if( strcmp( "MBEDTLS_SSL_EXPORT_KEYS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_EXPORT_KEYS ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_EXPORT_KEYS */ + +#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION) + if( strcmp( "MBEDTLS_SSL_SERVER_NAME_INDICATION", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_SERVER_NAME_INDICATION ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_SERVER_NAME_INDICATION */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC) + if( strcmp( "MBEDTLS_SSL_TRUNCATED_HMAC", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_TRUNCATED_HMAC ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC */ + +#if defined(MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT) + if( strcmp( "MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT */ + +#if defined(MBEDTLS_THREADING_ALT) + if( strcmp( "MBEDTLS_THREADING_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_THREADING_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_THREADING_ALT */ + +#if defined(MBEDTLS_THREADING_PTHREAD) + if( strcmp( "MBEDTLS_THREADING_PTHREAD", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_THREADING_PTHREAD ); + return( 0 ); + } +#endif /* MBEDTLS_THREADING_PTHREAD */ + +#if defined(MBEDTLS_VERSION_FEATURES) + if( strcmp( "MBEDTLS_VERSION_FEATURES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_VERSION_FEATURES ); + return( 0 ); + } +#endif /* MBEDTLS_VERSION_FEATURES */ + +#if defined(MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3) + if( strcmp( "MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 ); + return( 0 ); + } +#endif /* MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 */ + +#if defined(MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION) + if( strcmp( "MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION ); + return( 0 ); + } +#endif /* MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION */ + +#if defined(MBEDTLS_X509_CHECK_KEY_USAGE) + if( strcmp( "MBEDTLS_X509_CHECK_KEY_USAGE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CHECK_KEY_USAGE ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CHECK_KEY_USAGE */ + +#if defined(MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE) + if( strcmp( "MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */ + +#if defined(MBEDTLS_X509_RSASSA_PSS_SUPPORT) + if( strcmp( "MBEDTLS_X509_RSASSA_PSS_SUPPORT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_RSASSA_PSS_SUPPORT ); + return( 0 ); + } +#endif /* MBEDTLS_X509_RSASSA_PSS_SUPPORT */ + +#if defined(MBEDTLS_ZLIB_SUPPORT) + if( strcmp( "MBEDTLS_ZLIB_SUPPORT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ZLIB_SUPPORT ); + return( 0 ); + } +#endif /* MBEDTLS_ZLIB_SUPPORT */ + +#if defined(MBEDTLS_AESNI_C) + if( strcmp( "MBEDTLS_AESNI_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AESNI_C ); + return( 0 ); + } +#endif /* MBEDTLS_AESNI_C */ + +#if defined(MBEDTLS_AES_C) + if( strcmp( "MBEDTLS_AES_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_AES_C ); + return( 0 ); + } +#endif /* MBEDTLS_AES_C */ + +#if defined(MBEDTLS_ARC4_C) + if( strcmp( "MBEDTLS_ARC4_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ARC4_C ); + return( 0 ); + } +#endif /* MBEDTLS_ARC4_C */ + +#if defined(MBEDTLS_ASN1_PARSE_C) + if( strcmp( "MBEDTLS_ASN1_PARSE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ASN1_PARSE_C ); + return( 0 ); + } +#endif /* MBEDTLS_ASN1_PARSE_C */ + +#if defined(MBEDTLS_ASN1_WRITE_C) + if( strcmp( "MBEDTLS_ASN1_WRITE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ASN1_WRITE_C ); + return( 0 ); + } +#endif /* MBEDTLS_ASN1_WRITE_C */ + +#if defined(MBEDTLS_BASE64_C) + if( strcmp( "MBEDTLS_BASE64_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_BASE64_C ); + return( 0 ); + } +#endif /* MBEDTLS_BASE64_C */ + +#if defined(MBEDTLS_BIGNUM_C) + if( strcmp( "MBEDTLS_BIGNUM_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_BIGNUM_C ); + return( 0 ); + } +#endif /* MBEDTLS_BIGNUM_C */ + +#if defined(MBEDTLS_BLOWFISH_C) + if( strcmp( "MBEDTLS_BLOWFISH_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_BLOWFISH_C ); + return( 0 ); + } +#endif /* MBEDTLS_BLOWFISH_C */ + +#if defined(MBEDTLS_CAMELLIA_C) + if( strcmp( "MBEDTLS_CAMELLIA_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CAMELLIA_C ); + return( 0 ); + } +#endif /* MBEDTLS_CAMELLIA_C */ + +#if defined(MBEDTLS_ARIA_C) + if( strcmp( "MBEDTLS_ARIA_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ARIA_C ); + return( 0 ); + } +#endif /* MBEDTLS_ARIA_C */ + +#if defined(MBEDTLS_CCM_C) + if( strcmp( "MBEDTLS_CCM_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CCM_C ); + return( 0 ); + } +#endif /* MBEDTLS_CCM_C */ + +#if defined(MBEDTLS_CERTS_C) + if( strcmp( "MBEDTLS_CERTS_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CERTS_C ); + return( 0 ); + } +#endif /* MBEDTLS_CERTS_C */ + +#if defined(MBEDTLS_CHACHA20_C) + if( strcmp( "MBEDTLS_CHACHA20_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CHACHA20_C ); + return( 0 ); + } +#endif /* MBEDTLS_CHACHA20_C */ + +#if defined(MBEDTLS_CHACHAPOLY_C) + if( strcmp( "MBEDTLS_CHACHAPOLY_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CHACHAPOLY_C ); + return( 0 ); + } +#endif /* MBEDTLS_CHACHAPOLY_C */ + +#if defined(MBEDTLS_CIPHER_C) + if( strcmp( "MBEDTLS_CIPHER_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CIPHER_C ); + return( 0 ); + } +#endif /* MBEDTLS_CIPHER_C */ + +#if defined(MBEDTLS_CMAC_C) + if( strcmp( "MBEDTLS_CMAC_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CMAC_C ); + return( 0 ); + } +#endif /* MBEDTLS_CMAC_C */ + +#if defined(MBEDTLS_CTR_DRBG_C) + if( strcmp( "MBEDTLS_CTR_DRBG_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_C ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_C */ + +#if defined(MBEDTLS_DEBUG_C) + if( strcmp( "MBEDTLS_DEBUG_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DEBUG_C ); + return( 0 ); + } +#endif /* MBEDTLS_DEBUG_C */ + +#if defined(MBEDTLS_DES_C) + if( strcmp( "MBEDTLS_DES_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DES_C ); + return( 0 ); + } +#endif /* MBEDTLS_DES_C */ + +#if defined(MBEDTLS_DHM_C) + if( strcmp( "MBEDTLS_DHM_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_DHM_C ); + return( 0 ); + } +#endif /* MBEDTLS_DHM_C */ + +#if defined(MBEDTLS_ECDH_C) + if( strcmp( "MBEDTLS_ECDH_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDH_C ); + return( 0 ); + } +#endif /* MBEDTLS_ECDH_C */ + +#if defined(MBEDTLS_ECDSA_C) + if( strcmp( "MBEDTLS_ECDSA_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECDSA_C ); + return( 0 ); + } +#endif /* MBEDTLS_ECDSA_C */ + +#if defined(MBEDTLS_ECJPAKE_C) + if( strcmp( "MBEDTLS_ECJPAKE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECJPAKE_C ); + return( 0 ); + } +#endif /* MBEDTLS_ECJPAKE_C */ + +#if defined(MBEDTLS_ECP_C) + if( strcmp( "MBEDTLS_ECP_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_C ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_C */ + +#if defined(MBEDTLS_ENTROPY_C) + if( strcmp( "MBEDTLS_ENTROPY_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_C ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_C */ + +#if defined(MBEDTLS_ERROR_C) + if( strcmp( "MBEDTLS_ERROR_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ERROR_C ); + return( 0 ); + } +#endif /* MBEDTLS_ERROR_C */ + +#if defined(MBEDTLS_GCM_C) + if( strcmp( "MBEDTLS_GCM_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_GCM_C ); + return( 0 ); + } +#endif /* MBEDTLS_GCM_C */ + +#if defined(MBEDTLS_HAVEGE_C) + if( strcmp( "MBEDTLS_HAVEGE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HAVEGE_C ); + return( 0 ); + } +#endif /* MBEDTLS_HAVEGE_C */ + +#if defined(MBEDTLS_HKDF_C) + if( strcmp( "MBEDTLS_HKDF_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HKDF_C ); + return( 0 ); + } +#endif /* MBEDTLS_HKDF_C */ + +#if defined(MBEDTLS_HMAC_DRBG_C) + if( strcmp( "MBEDTLS_HMAC_DRBG_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HMAC_DRBG_C ); + return( 0 ); + } +#endif /* MBEDTLS_HMAC_DRBG_C */ + +#if defined(MBEDTLS_NIST_KW_C) + if( strcmp( "MBEDTLS_NIST_KW_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NIST_KW_C ); + return( 0 ); + } +#endif /* MBEDTLS_NIST_KW_C */ + +#if defined(MBEDTLS_MD_C) + if( strcmp( "MBEDTLS_MD_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD_C ); + return( 0 ); + } +#endif /* MBEDTLS_MD_C */ + +#if defined(MBEDTLS_MD2_C) + if( strcmp( "MBEDTLS_MD2_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD2_C ); + return( 0 ); + } +#endif /* MBEDTLS_MD2_C */ + +#if defined(MBEDTLS_MD4_C) + if( strcmp( "MBEDTLS_MD4_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD4_C ); + return( 0 ); + } +#endif /* MBEDTLS_MD4_C */ + +#if defined(MBEDTLS_MD5_C) + if( strcmp( "MBEDTLS_MD5_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MD5_C ); + return( 0 ); + } +#endif /* MBEDTLS_MD5_C */ + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) + if( strcmp( "MBEDTLS_MEMORY_BUFFER_ALLOC_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MEMORY_BUFFER_ALLOC_C ); + return( 0 ); + } +#endif /* MBEDTLS_MEMORY_BUFFER_ALLOC_C */ + +#if defined(MBEDTLS_NET_C) + if( strcmp( "MBEDTLS_NET_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_NET_C ); + return( 0 ); + } +#endif /* MBEDTLS_NET_C */ + +#if defined(MBEDTLS_OID_C) + if( strcmp( "MBEDTLS_OID_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_OID_C ); + return( 0 ); + } +#endif /* MBEDTLS_OID_C */ + +#if defined(MBEDTLS_PADLOCK_C) + if( strcmp( "MBEDTLS_PADLOCK_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PADLOCK_C ); + return( 0 ); + } +#endif /* MBEDTLS_PADLOCK_C */ + +#if defined(MBEDTLS_PEM_PARSE_C) + if( strcmp( "MBEDTLS_PEM_PARSE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PEM_PARSE_C ); + return( 0 ); + } +#endif /* MBEDTLS_PEM_PARSE_C */ + +#if defined(MBEDTLS_PEM_WRITE_C) + if( strcmp( "MBEDTLS_PEM_WRITE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PEM_WRITE_C ); + return( 0 ); + } +#endif /* MBEDTLS_PEM_WRITE_C */ + +#if defined(MBEDTLS_PK_C) + if( strcmp( "MBEDTLS_PK_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PK_C ); + return( 0 ); + } +#endif /* MBEDTLS_PK_C */ + +#if defined(MBEDTLS_PK_PARSE_C) + if( strcmp( "MBEDTLS_PK_PARSE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PK_PARSE_C ); + return( 0 ); + } +#endif /* MBEDTLS_PK_PARSE_C */ + +#if defined(MBEDTLS_PK_WRITE_C) + if( strcmp( "MBEDTLS_PK_WRITE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PK_WRITE_C ); + return( 0 ); + } +#endif /* MBEDTLS_PK_WRITE_C */ + +#if defined(MBEDTLS_PKCS5_C) + if( strcmp( "MBEDTLS_PKCS5_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PKCS5_C ); + return( 0 ); + } +#endif /* MBEDTLS_PKCS5_C */ + +#if defined(MBEDTLS_PKCS11_C) + if( strcmp( "MBEDTLS_PKCS11_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PKCS11_C ); + return( 0 ); + } +#endif /* MBEDTLS_PKCS11_C */ + +#if defined(MBEDTLS_PKCS12_C) + if( strcmp( "MBEDTLS_PKCS12_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PKCS12_C ); + return( 0 ); + } +#endif /* MBEDTLS_PKCS12_C */ + +#if defined(MBEDTLS_PLATFORM_C) + if( strcmp( "MBEDTLS_PLATFORM_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_C ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_C */ + +#if defined(MBEDTLS_POLY1305_C) + if( strcmp( "MBEDTLS_POLY1305_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_POLY1305_C ); + return( 0 ); + } +#endif /* MBEDTLS_POLY1305_C */ + +#if defined(MBEDTLS_RIPEMD160_C) + if( strcmp( "MBEDTLS_RIPEMD160_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_RIPEMD160_C ); + return( 0 ); + } +#endif /* MBEDTLS_RIPEMD160_C */ + +#if defined(MBEDTLS_RSA_C) + if( strcmp( "MBEDTLS_RSA_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_RSA_C ); + return( 0 ); + } +#endif /* MBEDTLS_RSA_C */ + +#if defined(MBEDTLS_SHA1_C) + if( strcmp( "MBEDTLS_SHA1_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA1_C ); + return( 0 ); + } +#endif /* MBEDTLS_SHA1_C */ + +#if defined(MBEDTLS_SHA256_C) + if( strcmp( "MBEDTLS_SHA256_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA256_C ); + return( 0 ); + } +#endif /* MBEDTLS_SHA256_C */ + +#if defined(MBEDTLS_SHA512_C) + if( strcmp( "MBEDTLS_SHA512_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SHA512_C ); + return( 0 ); + } +#endif /* MBEDTLS_SHA512_C */ + +#if defined(MBEDTLS_SSL_CACHE_C) + if( strcmp( "MBEDTLS_SSL_CACHE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CACHE_C ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_CACHE_C */ + +#if defined(MBEDTLS_SSL_COOKIE_C) + if( strcmp( "MBEDTLS_SSL_COOKIE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_COOKIE_C ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_COOKIE_C */ + +#if defined(MBEDTLS_SSL_TICKET_C) + if( strcmp( "MBEDTLS_SSL_TICKET_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_TICKET_C ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_TICKET_C */ + +#if defined(MBEDTLS_SSL_CLI_C) + if( strcmp( "MBEDTLS_SSL_CLI_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CLI_C ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_CLI_C */ + +#if defined(MBEDTLS_SSL_SRV_C) + if( strcmp( "MBEDTLS_SSL_SRV_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_SRV_C ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_SRV_C */ + +#if defined(MBEDTLS_SSL_TLS_C) + if( strcmp( "MBEDTLS_SSL_TLS_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_TLS_C ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_TLS_C */ + +#if defined(MBEDTLS_THREADING_C) + if( strcmp( "MBEDTLS_THREADING_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_THREADING_C ); + return( 0 ); + } +#endif /* MBEDTLS_THREADING_C */ + +#if defined(MBEDTLS_TIMING_C) + if( strcmp( "MBEDTLS_TIMING_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_TIMING_C ); + return( 0 ); + } +#endif /* MBEDTLS_TIMING_C */ + +#if defined(MBEDTLS_VERSION_C) + if( strcmp( "MBEDTLS_VERSION_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_VERSION_C ); + return( 0 ); + } +#endif /* MBEDTLS_VERSION_C */ + +#if defined(MBEDTLS_X509_USE_C) + if( strcmp( "MBEDTLS_X509_USE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_USE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_USE_C */ + +#if defined(MBEDTLS_X509_CRT_PARSE_C) + if( strcmp( "MBEDTLS_X509_CRT_PARSE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CRT_PARSE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CRT_PARSE_C */ + +#if defined(MBEDTLS_X509_CRL_PARSE_C) + if( strcmp( "MBEDTLS_X509_CRL_PARSE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CRL_PARSE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CRL_PARSE_C */ + +#if defined(MBEDTLS_X509_CSR_PARSE_C) + if( strcmp( "MBEDTLS_X509_CSR_PARSE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CSR_PARSE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CSR_PARSE_C */ + +#if defined(MBEDTLS_X509_CREATE_C) + if( strcmp( "MBEDTLS_X509_CREATE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CREATE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CREATE_C */ + +#if defined(MBEDTLS_X509_CRT_WRITE_C) + if( strcmp( "MBEDTLS_X509_CRT_WRITE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CRT_WRITE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CRT_WRITE_C */ + +#if defined(MBEDTLS_X509_CSR_WRITE_C) + if( strcmp( "MBEDTLS_X509_CSR_WRITE_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_CSR_WRITE_C ); + return( 0 ); + } +#endif /* MBEDTLS_X509_CSR_WRITE_C */ + +#if defined(MBEDTLS_XTEA_C) + if( strcmp( "MBEDTLS_XTEA_C", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_XTEA_C ); + return( 0 ); + } +#endif /* MBEDTLS_XTEA_C */ + +#if defined(MBEDTLS_MPI_WINDOW_SIZE) + if( strcmp( "MBEDTLS_MPI_WINDOW_SIZE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MPI_WINDOW_SIZE ); + return( 0 ); + } +#endif /* MBEDTLS_MPI_WINDOW_SIZE */ + +#if defined(MBEDTLS_MPI_MAX_SIZE) + if( strcmp( "MBEDTLS_MPI_MAX_SIZE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MPI_MAX_SIZE ); + return( 0 ); + } +#endif /* MBEDTLS_MPI_MAX_SIZE */ + +#if defined(MBEDTLS_CTR_DRBG_ENTROPY_LEN) + if( strcmp( "MBEDTLS_CTR_DRBG_ENTROPY_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_ENTROPY_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_ENTROPY_LEN */ + +#if defined(MBEDTLS_CTR_DRBG_RESEED_INTERVAL) + if( strcmp( "MBEDTLS_CTR_DRBG_RESEED_INTERVAL", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_RESEED_INTERVAL ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_RESEED_INTERVAL */ + +#if defined(MBEDTLS_CTR_DRBG_MAX_INPUT) + if( strcmp( "MBEDTLS_CTR_DRBG_MAX_INPUT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_MAX_INPUT ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_MAX_INPUT */ + +#if defined(MBEDTLS_CTR_DRBG_MAX_REQUEST) + if( strcmp( "MBEDTLS_CTR_DRBG_MAX_REQUEST", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_MAX_REQUEST ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_MAX_REQUEST */ + +#if defined(MBEDTLS_CTR_DRBG_MAX_SEED_INPUT) + if( strcmp( "MBEDTLS_CTR_DRBG_MAX_SEED_INPUT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_MAX_SEED_INPUT ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_MAX_SEED_INPUT */ + +#if defined(MBEDTLS_CTR_DRBG_USE_128_BIT_KEY) + if( strcmp( "MBEDTLS_CTR_DRBG_USE_128_BIT_KEY", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ); + return( 0 ); + } +#endif /* MBEDTLS_CTR_DRBG_USE_128_BIT_KEY */ + +#if defined(MBEDTLS_HMAC_DRBG_RESEED_INTERVAL) + if( strcmp( "MBEDTLS_HMAC_DRBG_RESEED_INTERVAL", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HMAC_DRBG_RESEED_INTERVAL ); + return( 0 ); + } +#endif /* MBEDTLS_HMAC_DRBG_RESEED_INTERVAL */ + +#if defined(MBEDTLS_HMAC_DRBG_MAX_INPUT) + if( strcmp( "MBEDTLS_HMAC_DRBG_MAX_INPUT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HMAC_DRBG_MAX_INPUT ); + return( 0 ); + } +#endif /* MBEDTLS_HMAC_DRBG_MAX_INPUT */ + +#if defined(MBEDTLS_HMAC_DRBG_MAX_REQUEST) + if( strcmp( "MBEDTLS_HMAC_DRBG_MAX_REQUEST", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HMAC_DRBG_MAX_REQUEST ); + return( 0 ); + } +#endif /* MBEDTLS_HMAC_DRBG_MAX_REQUEST */ + +#if defined(MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT) + if( strcmp( "MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT ); + return( 0 ); + } +#endif /* MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT */ + +#if defined(MBEDTLS_ECP_MAX_BITS) + if( strcmp( "MBEDTLS_ECP_MAX_BITS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_MAX_BITS ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_MAX_BITS */ + +#if defined(MBEDTLS_ECP_WINDOW_SIZE) + if( strcmp( "MBEDTLS_ECP_WINDOW_SIZE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_WINDOW_SIZE ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_WINDOW_SIZE */ + +#if defined(MBEDTLS_ECP_FIXED_POINT_OPTIM) + if( strcmp( "MBEDTLS_ECP_FIXED_POINT_OPTIM", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ECP_FIXED_POINT_OPTIM ); + return( 0 ); + } +#endif /* MBEDTLS_ECP_FIXED_POINT_OPTIM */ + +#if defined(MBEDTLS_ENTROPY_MAX_SOURCES) + if( strcmp( "MBEDTLS_ENTROPY_MAX_SOURCES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_MAX_SOURCES ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_MAX_SOURCES */ + +#if defined(MBEDTLS_ENTROPY_MAX_GATHER) + if( strcmp( "MBEDTLS_ENTROPY_MAX_GATHER", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_MAX_GATHER ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_MAX_GATHER */ + +#if defined(MBEDTLS_ENTROPY_MIN_HARDWARE) + if( strcmp( "MBEDTLS_ENTROPY_MIN_HARDWARE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_ENTROPY_MIN_HARDWARE ); + return( 0 ); + } +#endif /* MBEDTLS_ENTROPY_MIN_HARDWARE */ + +#if defined(MBEDTLS_MEMORY_ALIGN_MULTIPLE) + if( strcmp( "MBEDTLS_MEMORY_ALIGN_MULTIPLE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_MEMORY_ALIGN_MULTIPLE ); + return( 0 ); + } +#endif /* MBEDTLS_MEMORY_ALIGN_MULTIPLE */ + +#if defined(MBEDTLS_PLATFORM_STD_MEM_HDR) + if( strcmp( "MBEDTLS_PLATFORM_STD_MEM_HDR", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_MEM_HDR ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_MEM_HDR */ + +#if defined(MBEDTLS_PLATFORM_STD_CALLOC) + if( strcmp( "MBEDTLS_PLATFORM_STD_CALLOC", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_CALLOC ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_CALLOC */ + +#if defined(MBEDTLS_PLATFORM_STD_FREE) + if( strcmp( "MBEDTLS_PLATFORM_STD_FREE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_FREE ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_FREE */ + +#if defined(MBEDTLS_PLATFORM_STD_EXIT) + if( strcmp( "MBEDTLS_PLATFORM_STD_EXIT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_EXIT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_EXIT */ + +#if defined(MBEDTLS_PLATFORM_STD_TIME) + if( strcmp( "MBEDTLS_PLATFORM_STD_TIME", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_TIME ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_TIME */ + +#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) + if( strcmp( "MBEDTLS_PLATFORM_STD_FPRINTF", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_FPRINTF ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_FPRINTF */ + +#if defined(MBEDTLS_PLATFORM_STD_PRINTF) + if( strcmp( "MBEDTLS_PLATFORM_STD_PRINTF", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_PRINTF ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_PRINTF */ + +#if defined(MBEDTLS_PLATFORM_STD_SNPRINTF) + if( strcmp( "MBEDTLS_PLATFORM_STD_SNPRINTF", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_SNPRINTF ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_SNPRINTF */ + +#if defined(MBEDTLS_PLATFORM_STD_EXIT_SUCCESS) + if( strcmp( "MBEDTLS_PLATFORM_STD_EXIT_SUCCESS", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_EXIT_SUCCESS ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_EXIT_SUCCESS */ + +#if defined(MBEDTLS_PLATFORM_STD_EXIT_FAILURE) + if( strcmp( "MBEDTLS_PLATFORM_STD_EXIT_FAILURE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_EXIT_FAILURE ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_EXIT_FAILURE */ + +#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_READ) + if( strcmp( "MBEDTLS_PLATFORM_STD_NV_SEED_READ", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_NV_SEED_READ ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_NV_SEED_READ */ + +#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_WRITE) + if( strcmp( "MBEDTLS_PLATFORM_STD_NV_SEED_WRITE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_NV_SEED_WRITE ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_NV_SEED_WRITE */ + +#if defined(MBEDTLS_PLATFORM_STD_NV_SEED_FILE) + if( strcmp( "MBEDTLS_PLATFORM_STD_NV_SEED_FILE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_STD_NV_SEED_FILE ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_STD_NV_SEED_FILE */ + +#if defined(MBEDTLS_PLATFORM_CALLOC_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_CALLOC_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_CALLOC_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_CALLOC_MACRO */ + +#if defined(MBEDTLS_PLATFORM_FREE_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_FREE_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_FREE_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_FREE_MACRO */ + +#if defined(MBEDTLS_PLATFORM_EXIT_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_EXIT_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_EXIT_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_EXIT_MACRO */ + +#if defined(MBEDTLS_PLATFORM_TIME_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_TIME_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_TIME_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_TIME_MACRO */ + +#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_TIME_TYPE_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_TIME_TYPE_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */ + +#if defined(MBEDTLS_PLATFORM_FPRINTF_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_FPRINTF_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_FPRINTF_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_FPRINTF_MACRO */ + +#if defined(MBEDTLS_PLATFORM_PRINTF_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_PRINTF_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_PRINTF_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_PRINTF_MACRO */ + +#if defined(MBEDTLS_PLATFORM_SNPRINTF_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_SNPRINTF_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_SNPRINTF_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_SNPRINTF_MACRO */ + +#if defined(MBEDTLS_PLATFORM_NV_SEED_READ_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_NV_SEED_READ_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_NV_SEED_READ_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_NV_SEED_READ_MACRO */ + +#if defined(MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO) + if( strcmp( "MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO */ + +#if defined(MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT) + if( strcmp( "MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT */ + +#if defined(MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES) + if( strcmp( "MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_CACHE_DEFAULT_MAX_ENTRIES */ + +#if defined(MBEDTLS_SSL_MAX_CONTENT_LEN) + if( strcmp( "MBEDTLS_SSL_MAX_CONTENT_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_MAX_CONTENT_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_MAX_CONTENT_LEN */ + +#if defined(MBEDTLS_SSL_IN_CONTENT_LEN) + if( strcmp( "MBEDTLS_SSL_IN_CONTENT_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_IN_CONTENT_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_IN_CONTENT_LEN */ + +#if defined(MBEDTLS_SSL_OUT_CONTENT_LEN) + if( strcmp( "MBEDTLS_SSL_OUT_CONTENT_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_OUT_CONTENT_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_OUT_CONTENT_LEN */ + +#if defined(MBEDTLS_SSL_DTLS_MAX_BUFFERING) + if( strcmp( "MBEDTLS_SSL_DTLS_MAX_BUFFERING", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DTLS_MAX_BUFFERING ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DTLS_MAX_BUFFERING */ + +#if defined(MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME) + if( strcmp( "MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME */ + +#if defined(MBEDTLS_PSK_MAX_LEN) + if( strcmp( "MBEDTLS_PSK_MAX_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PSK_MAX_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_PSK_MAX_LEN */ + +#if defined(MBEDTLS_SSL_COOKIE_TIMEOUT) + if( strcmp( "MBEDTLS_SSL_COOKIE_TIMEOUT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_SSL_COOKIE_TIMEOUT ); + return( 0 ); + } +#endif /* MBEDTLS_SSL_COOKIE_TIMEOUT */ + +#if defined(MBEDTLS_X509_MAX_INTERMEDIATE_CA) + if( strcmp( "MBEDTLS_X509_MAX_INTERMEDIATE_CA", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_MAX_INTERMEDIATE_CA ); + return( 0 ); + } +#endif /* MBEDTLS_X509_MAX_INTERMEDIATE_CA */ + +#if defined(MBEDTLS_X509_MAX_FILE_PATH_LEN) + if( strcmp( "MBEDTLS_X509_MAX_FILE_PATH_LEN", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_X509_MAX_FILE_PATH_LEN ); + return( 0 ); + } +#endif /* MBEDTLS_X509_MAX_FILE_PATH_LEN */ + +#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES) + if( strcmp( "MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES ); + return( 0 ); + } +#endif /* MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES */ + +#if defined(MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE) + if( strcmp( "MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE ); + return( 0 ); + } +#endif /* MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE */ + +#if defined(MBEDTLS_PLATFORM_ZEROIZE_ALT) + if( strcmp( "MBEDTLS_PLATFORM_ZEROIZE_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_ZEROIZE_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */ + +#if defined(MBEDTLS_PLATFORM_GMTIME_R_ALT) + if( strcmp( "MBEDTLS_PLATFORM_GMTIME_R_ALT", config ) == 0 ) + { + MACRO_EXPANSION_TO_STR( MBEDTLS_PLATFORM_GMTIME_R_ALT ); + return( 0 ); + } +#endif /* MBEDTLS_PLATFORM_GMTIME_R_ALT */ + + /* If the symbol is not found, return an error */ + return( 1 ); +} + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client1.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client1.c index bf7c0132af..646909f114 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client1.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client1.c @@ -34,6 +34,7 @@ #define mbedtls_time_t time_t #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -70,6 +71,18 @@ int main( void ) #define DEBUG_LEVEL 1 +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client2.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client2.c index 81514321ff..255d4b2f0b 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client2.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_client2.c @@ -35,6 +35,9 @@ #define mbedtls_printf printf #define mbedtls_fprintf fprintf #define mbedtls_snprintf snprintf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #if !defined(MBEDTLS_ENTROPY_C) || \ @@ -73,6 +76,7 @@ int main( void ) #define DFL_REQUEST_SIZE -1 #define DFL_DEBUG_LEVEL 0 #define DFL_NBIO 0 +#define DFL_EVENT 0 #define DFL_READ_TIMEOUT 0 #define DFL_MAX_RESEND 0 #define DFL_CA_FILE "" @@ -82,6 +86,7 @@ int main( void ) #define DFL_PSK "" #define DFL_PSK_IDENTITY "Client_identity" #define DFL_ECJPAKE_PW NULL +#define DFL_EC_MAX_OPS -1 #define DFL_FORCE_CIPHER 0 #define DFL_RENEGOTIATION MBEDTLS_SSL_RENEGOTIATION_DISABLED #define DFL_ALLOW_LEGACY -2 @@ -105,6 +110,8 @@ int main( void ) #define DFL_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM #define DFL_HS_TO_MIN 0 #define DFL_HS_TO_MAX 0 +#define DFL_DTLS_MTU -1 +#define DFL_DGRAM_PACKING 1 #define DFL_FALLBACK -1 #define DFL_EXTENDED_MS -1 #define DFL_ETM -1 @@ -117,8 +124,10 @@ int main( void ) #define USAGE_IO \ " ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \ " default: \"\" (pre-loaded)\n" \ + " use \"none\" to skip loading any top-level CAs.\n" \ " ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \ " default: \"\" (pre-loaded) (overrides ca_file)\n" \ + " use \"none\" to skip loading any top-level CAs.\n" \ " crt_file=%%s Your own cert and chain (in bottom to top order, top may be omitted)\n" \ " default: \"\" (pre-loaded)\n" \ " key_file=%%s default: \"\" (pre-loaded)\n" @@ -197,7 +206,11 @@ int main( void ) #define USAGE_DTLS \ " dtls=%%d default: 0 (TLS)\n" \ " hs_timeout=%%d-%%d default: (library default: 1000-60000)\n" \ - " range of DTLS handshake timeouts in millisecs\n" + " range of DTLS handshake timeouts in millisecs\n" \ + " mtu=%%d default: (library default: unlimited)\n" \ + " dgram_packing=%%d default: 1 (allowed)\n" \ + " allow or forbid packing of multiple\n" \ + " records within a single datgram.\n" #else #define USAGE_DTLS "" #endif @@ -238,6 +251,13 @@ int main( void ) #define USAGE_ECJPAKE "" #endif +#if defined(MBEDTLS_ECP_RESTARTABLE) +#define USAGE_ECRESTART \ + " ec_max_ops=%%s default: library default (restart disabled)\n" +#else +#define USAGE_ECRESTART "" +#endif + #define USAGE \ "\n usage: ssl_client2 param=<>...\n" \ "\n acceptable parameters:\n" \ @@ -251,22 +271,25 @@ int main( void ) " application data message is sent followed by\n" \ " a second non-empty message before attempting\n" \ " to read a response from the server\n" \ - " debug_level=%%d default: 0 (disabled)\n" \ - " nbio=%%d default: 0 (blocking I/O)\n" \ - " options: 1 (non-blocking), 2 (added delays)\n" \ - " read_timeout=%%d default: 0 ms (no timeout)\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ + " nbio=%%d default: 0 (blocking I/O)\n" \ + " options: 1 (non-blocking), 2 (added delays)\n" \ + " event=%%d default: 0 (loop)\n" \ + " options: 1 (level-triggered, implies nbio=1),\n" \ + " read_timeout=%%d default: 0 ms (no timeout)\n" \ " max_resend=%%d default: 0 (no resend on timeout)\n" \ "\n" \ USAGE_DTLS \ "\n" \ - " auth_mode=%%s default: (library default: none)\n" \ + " auth_mode=%%s default: (library default: none)\n" \ " options: none, optional, required\n" \ USAGE_IO \ "\n" \ USAGE_PSK \ USAGE_ECJPAKE \ + USAGE_ECRESTART \ "\n" \ - " allow_legacy=%%d default: (library default: no)\n" \ + " allow_legacy=%%d default: (library default: no)\n" \ USAGE_RENEGO \ " exchanges=%%d default: 1\n" \ " reconnect=%%d default: 0 (disabled)\n" \ @@ -291,11 +314,27 @@ int main( void ) " options: ssl3, tls1, tls1_1, tls1_2, dtls1, dtls1_2\n" \ "\n" \ " force_ciphersuite= default: all enabled\n"\ + " query_config= return 0 if the specified\n" \ + " configuration macro is defined and 1\n" \ + " otherwise. The expansion of the macro\n" \ + " is printed if it is defined\n" \ " acceptable ciphersuite names:\n" #define ALPN_LIST_SIZE 10 #define CURVE_LIST_SIZE 20 +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ @@ -306,7 +345,8 @@ struct options const char *server_port; /* port on which the ssl service runs */ int debug_level; /* level of debugging */ int nbio; /* should I/O be blocking? */ - uint32_t read_timeout; /* timeout on mbedtls_ssl_read() in milliseconds */ + int event; /* loop or event-driven IO? level or edge triggered? */ + uint32_t read_timeout; /* timeout on mbedtls_ssl_read() in milliseconds */ int max_resend; /* DTLS times to resend on read timeout */ const char *request_page; /* page on server to request */ int request_size; /* pad request with header to requested size */ @@ -317,6 +357,7 @@ struct options const char *psk; /* the pre-shared key */ const char *psk_identity; /* the pre-shared key identity */ const char *ecjpake_pw; /* the EC J-PAKE password */ + int ec_max_ops; /* EC consecutive operations limit */ int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ int renegotiation; /* enable / disable renegotiation */ int allow_legacy; /* allow legacy renegotiation */ @@ -341,11 +382,15 @@ struct options int transport; /* TLS or DTLS? */ uint32_t hs_to_min; /* Initial value of DTLS handshake timer */ uint32_t hs_to_max; /* Max value of DTLS handshake timer */ + int dtls_mtu; /* UDP Maximum tranport unit for DTLS */ int fallback; /* is this a fallback connection? */ + int dgram_packing; /* allow/forbid datagram packing */ int extended_ms; /* negotiate extended master secret? */ int etm; /* negotiate encrypt then mac? */ } opt; +int query_config( const char *config ); + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) @@ -357,7 +402,8 @@ static void my_debug( void *ctx, int level, if( *p == '/' || *p == '\\' ) basename = p + 1; - mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str ); + mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", + basename, line, level, str ); fflush( (FILE *) ctx ); } @@ -403,7 +449,8 @@ static int my_send( void *ctx, const unsigned char *buf, size_t len ) /* * Enabled if debug_level > 1 in code below */ -static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags ) +static int my_verify( void *data, mbedtls_x509_crt *crt, + int depth, uint32_t *flags ) { char buf[1024]; ((void) data); @@ -440,6 +487,57 @@ static int ssl_sig_hashes_for_test[] = { }; #endif /* MBEDTLS_X509_CRT_PARSE_C */ +/* + * Wait for an event from the underlying transport or the timer + * (Used in event-driven IO mode). + */ +#if !defined(MBEDTLS_TIMING_C) +int idle( mbedtls_net_context *fd, + int idle_reason ) +#else +int idle( mbedtls_net_context *fd, + mbedtls_timing_delay_context *timer, + int idle_reason ) +#endif +{ + + int ret; + int poll_type = 0; + + if( idle_reason == MBEDTLS_ERR_SSL_WANT_WRITE ) + poll_type = MBEDTLS_NET_POLL_WRITE; + else if( idle_reason == MBEDTLS_ERR_SSL_WANT_READ ) + poll_type = MBEDTLS_NET_POLL_READ; +#if !defined(MBEDTLS_TIMING_C) + else + return( 0 ); +#endif + + while( 1 ) + { + /* Check if timer has expired */ +#if defined(MBEDTLS_TIMING_C) + if( timer != NULL && + mbedtls_timing_get_delay( timer ) == 2 ) + { + break; + } +#endif /* MBEDTLS_TIMING_C */ + + /* Check if underlying transport became available */ + if( poll_type != 0 ) + { + ret = mbedtls_net_poll( fd, poll_type, 0 ); + if( ret < 0 ) + return( ret ); + if( ret == poll_type ) + break; + } + } + + return( 0 ); +} + int main( int argc, char *argv[] ) { int ret = 0, len, tail_len, i, written, frags, retry_left; @@ -525,6 +623,7 @@ int main( int argc, char *argv[] ) opt.server_port = DFL_SERVER_PORT; opt.debug_level = DFL_DEBUG_LEVEL; opt.nbio = DFL_NBIO; + opt.event = DFL_EVENT; opt.read_timeout = DFL_READ_TIMEOUT; opt.max_resend = DFL_MAX_RESEND; opt.request_page = DFL_REQUEST_PAGE; @@ -536,6 +635,7 @@ int main( int argc, char *argv[] ) opt.psk = DFL_PSK; opt.psk_identity = DFL_PSK_IDENTITY; opt.ecjpake_pw = DFL_ECJPAKE_PW; + opt.ec_max_ops = DFL_EC_MAX_OPS; opt.force_ciphersuite[0]= DFL_FORCE_CIPHER; opt.renegotiation = DFL_RENEGOTIATION; opt.allow_legacy = DFL_ALLOW_LEGACY; @@ -559,9 +659,11 @@ int main( int argc, char *argv[] ) opt.transport = DFL_TRANSPORT; opt.hs_to_min = DFL_HS_TO_MIN; opt.hs_to_max = DFL_HS_TO_MAX; + opt.dtls_mtu = DFL_DTLS_MTU; opt.fallback = DFL_FALLBACK; opt.extended_ms = DFL_EXTENDED_MS; opt.etm = DFL_ETM; + opt.dgram_packing = DFL_DGRAM_PACKING; for( i = 1; i < argc; i++ ) { @@ -598,6 +700,12 @@ int main( int argc, char *argv[] ) if( opt.nbio < 0 || opt.nbio > 2 ) goto usage; } + else if( strcmp( p, "event" ) == 0 ) + { + opt.event = atoi( q ); + if( opt.event < 0 || opt.event > 2 ) + goto usage; + } else if( strcmp( p, "read_timeout" ) == 0 ) opt.read_timeout = atoi( q ); else if( strcmp( p, "max_resend" ) == 0 ) @@ -629,6 +737,8 @@ int main( int argc, char *argv[] ) opt.psk_identity = q; else if( strcmp( p, "ecjpake_pw" ) == 0 ) opt.ecjpake_pw = q; + else if( strcmp( p, "ec_max_ops" ) == 0 ) + opt.ec_max_ops = atoi( q ); else if( strcmp( p, "force_ciphersuite" ) == 0 ) { opt.force_ciphersuite[0] = mbedtls_ssl_get_ciphersuite_id( q ); @@ -642,16 +752,23 @@ int main( int argc, char *argv[] ) } else if( strcmp( p, "renegotiation" ) == 0 ) { - opt.renegotiation = (atoi( q )) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED : - MBEDTLS_SSL_RENEGOTIATION_DISABLED; + opt.renegotiation = (atoi( q )) ? + MBEDTLS_SSL_RENEGOTIATION_ENABLED : + MBEDTLS_SSL_RENEGOTIATION_DISABLED; } else if( strcmp( p, "allow_legacy" ) == 0 ) { switch( atoi( q ) ) { - case -1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE; break; - case 0: opt.allow_legacy = MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION; break; - case 1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION; break; + case -1: + opt.allow_legacy = MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE; + break; + case 0: + opt.allow_legacy = MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION; + break; + case 1: + opt.allow_legacy = MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION; + break; default: goto usage; } } @@ -708,8 +825,12 @@ int main( int argc, char *argv[] ) { switch( atoi( q ) ) { - case 0: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_DISABLED; break; - case 1: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; break; + case 0: + opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_DISABLED; + break; + case 1: + opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; + break; default: goto usage; } } @@ -852,6 +973,21 @@ int main( int argc, char *argv[] ) if( opt.hs_to_min == 0 || opt.hs_to_max < opt.hs_to_min ) goto usage; } + else if( strcmp( p, "mtu" ) == 0 ) + { + opt.dtls_mtu = atoi( q ); + if( opt.dtls_mtu < 0 ) + goto usage; + } + else if( strcmp( p, "dgram_packing" ) == 0 ) + { + opt.dgram_packing = atoi( q ); + if( opt.dgram_packing != 0 && + opt.dgram_packing != 1 ) + { + goto usage; + } + } else if( strcmp( p, "recsplit" ) == 0 ) { opt.recsplit = atoi( q ); @@ -864,10 +1000,23 @@ int main( int argc, char *argv[] ) if( opt.dhmlen < 0 ) goto usage; } + else if( strcmp( p, "query_config" ) == 0 ) + { + return query_config( q ); + } else goto usage; } + /* Event-driven IO is incompatible with the above custom + * receive and send functions, as the polling builds on + * refers to the underlying net_context. */ + if( opt.event == 1 && opt.nbio != 1 ) + { + mbedtls_printf( "Warning: event-driven IO mandates nbio=1 - overwrite\n" ); + opt.nbio = 1; + } + #if defined(MBEDTLS_DEBUG_C) mbedtls_debug_set_threshold( opt.debug_level ); #endif @@ -875,19 +1024,20 @@ int main( int argc, char *argv[] ) if( opt.force_ciphersuite[0] > 0 ) { const mbedtls_ssl_ciphersuite_t *ciphersuite_info; - ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( opt.force_ciphersuite[0] ); + ciphersuite_info = + mbedtls_ssl_ciphersuite_from_id( opt.force_ciphersuite[0] ); if( opt.max_version != -1 && ciphersuite_info->min_minor_ver > opt.max_version ) { - mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + mbedtls_printf( "forced ciphersuite not allowed with this protocol version\n" ); ret = 2; goto usage; } if( opt.min_version != -1 && ciphersuite_info->max_minor_ver < opt.min_version ) { - mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + mbedtls_printf( "forced ciphersuite not allowed with this protocol version\n" ); ret = 2; goto usage; } @@ -913,7 +1063,7 @@ int main( int argc, char *argv[] ) { if( opt.arc4 == MBEDTLS_SSL_ARC4_DISABLED ) { - mbedtls_printf("forced RC4 ciphersuite with RC4 disabled\n"); + mbedtls_printf( "forced RC4 ciphersuite with RC4 disabled\n" ); ret = 2; goto usage; } @@ -933,7 +1083,7 @@ int main( int argc, char *argv[] ) if( strlen( opt.psk ) % 2 != 0 ) { - mbedtls_printf("pre-shared key not valid hex\n"); + mbedtls_printf( "pre-shared key not valid hex\n" ); goto exit; } @@ -950,7 +1100,7 @@ int main( int argc, char *argv[] ) c -= 'A' - 10; else { - mbedtls_printf("pre-shared key not valid hex\n"); + mbedtls_printf( "pre-shared key not valid hex\n" ); goto exit; } psk[ j / 2 ] = c << 4; @@ -964,7 +1114,7 @@ int main( int argc, char *argv[] ) c -= 'A' - 10; else { - mbedtls_printf("pre-shared key not valid hex\n"); + mbedtls_printf( "pre-shared key not valid hex\n" ); goto exit; } psk[ j / 2 ] |= c; @@ -1055,11 +1205,12 @@ int main( int argc, char *argv[] ) fflush( stdout ); mbedtls_entropy_init( &entropy ); - if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, - (const unsigned char *) pers, - strlen( pers ) ) ) != 0 ) + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, + &entropy, (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", + -ret ); goto exit; } @@ -1072,20 +1223,22 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Loading the CA root certificate ..." ); fflush( stdout ); + if( strcmp( opt.ca_path, "none" ) == 0 || + strcmp( opt.ca_file, "none" ) == 0 ) + { + ret = 0; + } + else #if defined(MBEDTLS_FS_IO) if( strlen( opt.ca_path ) ) - if( strcmp( opt.ca_path, "none" ) == 0 ) - ret = 0; - else - ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); + ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); else if( strlen( opt.ca_file ) ) - if( strcmp( opt.ca_file, "none" ) == 0 ) - ret = 0; - else - ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); + ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); else #endif #if defined(MBEDTLS_CERTS_C) + { +#if defined(MBEDTLS_PEM_PARSE_C) for( i = 0; mbedtls_test_cas[i] != NULL; i++ ) { ret = mbedtls_x509_crt_parse( &cacert, @@ -1094,15 +1247,27 @@ int main( int argc, char *argv[] ) if( ret != 0 ) break; } + if( ret == 0 ) +#endif /* MBEDTLS_PEM_PARSE_C */ + for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ ) + { + ret = mbedtls_x509_crt_parse_der( &cacert, + (const unsigned char *) mbedtls_test_cas_der[i], + mbedtls_test_cas_der_len[i] ); + if( ret != 0 ) + break; + } + } #else { ret = 1; - mbedtls_printf("MBEDTLS_CERTS_C not defined."); + mbedtls_printf( "MBEDTLS_CERTS_C not defined." ); } -#endif +#endif /* MBEDTLS_CERTS_C */ if( ret < 0 ) { - mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", + -ret ); goto exit; } @@ -1116,49 +1281,53 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Loading the client cert. and key..." ); fflush( stdout ); + if( strcmp( opt.crt_file, "none" ) == 0 ) + ret = 0; + else #if defined(MBEDTLS_FS_IO) if( strlen( opt.crt_file ) ) - if( strcmp( opt.crt_file, "none" ) == 0 ) - ret = 0; - else - ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file ); + ret = mbedtls_x509_crt_parse_file( &clicert, opt.crt_file ); else #endif #if defined(MBEDTLS_CERTS_C) - ret = mbedtls_x509_crt_parse( &clicert, (const unsigned char *) mbedtls_test_cli_crt, + ret = mbedtls_x509_crt_parse( &clicert, + (const unsigned char *) mbedtls_test_cli_crt, mbedtls_test_cli_crt_len ); #else { ret = 1; - mbedtls_printf("MBEDTLS_CERTS_C not defined."); + mbedtls_printf( "MBEDTLS_CERTS_C not defined." ); } #endif if( ret != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", + -ret ); goto exit; } + if( strcmp( opt.key_file, "none" ) == 0 ) + ret = 0; + else #if defined(MBEDTLS_FS_IO) if( strlen( opt.key_file ) ) - if( strcmp( opt.key_file, "none" ) == 0 ) - ret = 0; - else - ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" ); + ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, "" ); else #endif #if defined(MBEDTLS_CERTS_C) - ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_cli_key, + ret = mbedtls_pk_parse_key( &pkey, + (const unsigned char *) mbedtls_test_cli_key, mbedtls_test_cli_key_len, NULL, 0 ); #else { ret = 1; - mbedtls_printf("MBEDTLS_CERTS_C not defined."); + mbedtls_printf( "MBEDTLS_CERTS_C not defined." ); } #endif if( ret != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", + -ret ); goto exit; } @@ -1176,11 +1345,13 @@ int main( int argc, char *argv[] ) opt.server_addr, opt.server_port ); fflush( stdout ); - if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port, - opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? - MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + if( ( ret = mbedtls_net_connect( &server_fd, + opt.server_addr, opt.server_port, + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? + MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n", + -ret ); goto exit; } @@ -1190,7 +1361,8 @@ int main( int argc, char *argv[] ) ret = mbedtls_net_set_block( &server_fd ); if( ret != 0 ) { - mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", + -ret ); goto exit; } @@ -1207,7 +1379,8 @@ int main( int argc, char *argv[] ) opt.transport, MBEDTLS_SSL_PRESET_DEFAULT ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_config_defaults returned -0x%x\n\n", + -ret ); goto exit; } @@ -1230,13 +1403,18 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_SSL_PROTO_DTLS) if( opt.hs_to_min != DFL_HS_TO_MIN || opt.hs_to_max != DFL_HS_TO_MAX ) - mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min, opt.hs_to_max ); + mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min, + opt.hs_to_max ); + + if( opt.dgram_packing != DFL_DGRAM_PACKING ) + mbedtls_ssl_set_datagram_packing( &ssl, opt.dgram_packing ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) if( ( ret = mbedtls_ssl_conf_max_frag_len( &conf, opt.mfl_code ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_conf_max_frag_len returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_max_frag_len returned %d\n\n", + ret ); goto exit; } #endif @@ -1259,8 +1437,8 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_SSL_CBC_RECORD_SPLITTING) if( opt.recsplit != DFL_RECSPLIT ) mbedtls_ssl_conf_cbc_record_splitting( &conf, opt.recsplit - ? MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED - : MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED ); + ? MBEDTLS_SSL_CBC_RECORD_SPLITTING_ENABLED + : MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED ); #endif #if defined(MBEDTLS_DHM_C) @@ -1272,7 +1450,8 @@ int main( int argc, char *argv[] ) if( opt.alpn_string != NULL ) if( ( ret = mbedtls_ssl_conf_alpn_protocols( &conf, alpn_list ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_conf_alpn_protocols returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_alpn_protocols returned %d\n\n", + ret ); goto exit; } #endif @@ -1311,7 +1490,8 @@ int main( int argc, char *argv[] ) { if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &clicert, &pkey ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", + ret ); goto exit; } } @@ -1330,16 +1510,19 @@ int main( int argc, char *argv[] ) (const unsigned char *) opt.psk_identity, strlen( opt.psk_identity ) ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_conf_psk returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_psk returned %d\n\n", + ret ); goto exit; } #endif if( opt.min_version != DFL_MIN_VERSION ) - mbedtls_ssl_conf_min_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, opt.min_version ); + mbedtls_ssl_conf_min_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, + opt.min_version ); if( opt.max_version != DFL_MAX_VERSION ) - mbedtls_ssl_conf_max_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, opt.max_version ); + mbedtls_ssl_conf_max_version( &conf, MBEDTLS_SSL_MAJOR_VERSION_3, + opt.max_version ); #if defined(MBEDTLS_SSL_FALLBACK_SCSV) if( opt.fallback != DFL_FALLBACK ) @@ -1348,14 +1531,16 @@ int main( int argc, char *argv[] ) if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_setup returned -0x%x\n\n", + -ret ); goto exit; } #if defined(MBEDTLS_X509_CRT_PARSE_C) if( ( ret = mbedtls_ssl_set_hostname( &ssl, opt.server_name ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hostname returned %d\n\n", + ret ); goto exit; } #endif @@ -1367,7 +1552,8 @@ int main( int argc, char *argv[] ) (const unsigned char *) opt.ecjpake_pw, strlen( opt.ecjpake_pw ) ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_set_hs_ecjpake_password returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_set_hs_ecjpake_password returned %d\n\n", + ret ); goto exit; } } @@ -1376,14 +1562,25 @@ int main( int argc, char *argv[] ) if( opt.nbio == 2 ) mbedtls_ssl_set_bio( &ssl, &server_fd, my_send, my_recv, NULL ); else - mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, + mbedtls_ssl_set_bio( &ssl, &server_fd, + mbedtls_net_send, mbedtls_net_recv, opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL ); +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( opt.dtls_mtu != DFL_DTLS_MTU ) + mbedtls_ssl_set_mtu( &ssl, opt.dtls_mtu ); +#endif + #if defined(MBEDTLS_TIMING_C) mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay ); #endif +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( opt.ec_max_ops != DFL_EC_MAX_OPS ) + mbedtls_ecp_set_max_ops( opt.ec_max_ops ); +#endif + mbedtls_printf( " ok\n" ); /* @@ -1394,9 +1591,12 @@ int main( int argc, char *argv[] ) while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) { - if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE && + ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n", + -ret ); if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ) mbedtls_printf( " Unable to verify the server's certificate. " @@ -1408,10 +1608,28 @@ int main( int argc, char *argv[] ) mbedtls_printf( "\n" ); goto exit; } + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) + continue; +#endif + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + ret = idle( &server_fd, &timer, ret ); +#else + ret = idle( &server_fd, ret ); +#endif + if( ret != 0 ) + goto exit; + } } mbedtls_printf( " ok\n [ Protocol is %s ]\n [ Ciphersuite is %s ]\n", - mbedtls_ssl_get_version( &ssl ), mbedtls_ssl_get_ciphersuite( &ssl ) ); + mbedtls_ssl_get_version( &ssl ), + mbedtls_ssl_get_ciphersuite( &ssl ) ); if( ( ret = mbedtls_ssl_get_record_expansion( &ssl ) ) >= 0 ) mbedtls_printf( " [ Record expansion is %d ]\n", ret ); @@ -1439,7 +1657,8 @@ int main( int argc, char *argv[] ) if( ( ret = mbedtls_ssl_get_session( &ssl, &saved_session ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_get_session returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_get_session returned -0x%x\n\n", + -ret ); goto exit; } @@ -1458,7 +1677,8 @@ int main( int argc, char *argv[] ) mbedtls_printf( " failed\n" ); - mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); + mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), + " ! ", flags ); mbedtls_printf( "%s\n", vrfy_buf ); } @@ -1486,11 +1706,29 @@ int main( int argc, char *argv[] ) while( ( ret = mbedtls_ssl_renegotiate( &ssl ) ) != 0 ) { if( ret != MBEDTLS_ERR_SSL_WANT_READ && - ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + ret != MBEDTLS_ERR_SSL_WANT_WRITE && + ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n", + ret ); goto exit; } + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) + continue; +#endif + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &server_fd, &timer, ret ); +#else + idle( &server_fd, ret ); +#endif + } + } mbedtls_printf( " ok\n" ); } @@ -1541,11 +1779,23 @@ int main( int argc, char *argv[] ) len - written ) ) < 0 ) { if( ret != MBEDTLS_ERR_SSL_WANT_READ && - ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + ret != MBEDTLS_ERR_SSL_WANT_WRITE && + ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_write returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned -0x%x\n\n", + -ret ); goto exit; } + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &server_fd, &timer, ret ); +#else + idle( &server_fd, ret ); +#endif + } } frags++; @@ -1555,13 +1805,34 @@ int main( int argc, char *argv[] ) } else /* Not stream, so datagram */ { - do ret = mbedtls_ssl_write( &ssl, buf, len ); - while( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + while( 1 ) + { + ret = mbedtls_ssl_write( &ssl, buf, len ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) + continue; +#endif + + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + break; + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &server_fd, &timer, ret ); +#else + idle( &server_fd, ret ); +#endif + } + } if( ret < 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", + ret ); goto exit; } @@ -1576,7 +1847,8 @@ int main( int argc, char *argv[] ) } buf[written] = '\0'; - mbedtls_printf( " %d bytes written in %d fragments\n\n%s\n", written, frags, (char *) buf ); + mbedtls_printf( " %d bytes written in %d fragments\n\n%s\n", + written, frags, (char *) buf ); /* Send a non-empty request if request_size == 0 */ if ( len == 0 ) @@ -1602,9 +1874,25 @@ int main( int argc, char *argv[] ) memset( buf, 0, sizeof( buf ) ); ret = mbedtls_ssl_read( &ssl, buf, len ); +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) + continue; +#endif + if( ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + { + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &server_fd, &timer, ret ); +#else + idle( &server_fd, ret ); +#endif + } continue; + } if( ret <= 0 ) { @@ -1622,7 +1910,8 @@ int main( int argc, char *argv[] ) goto reconnect; default: - mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", -ret ); + mbedtls_printf( " mbedtls_ssl_read returned -0x%x\n", + -ret ); goto exit; } } @@ -1646,9 +1935,29 @@ int main( int argc, char *argv[] ) len = sizeof( buf ) - 1; memset( buf, 0, sizeof( buf ) ); - do ret = mbedtls_ssl_read( &ssl, buf, len ); - while( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + while( 1 ) + { + ret = mbedtls_ssl_read( &ssl, buf, len ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + if( ret == MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) + continue; +#endif + + if( ret != MBEDTLS_ERR_SSL_WANT_READ && + ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + break; + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &server_fd, &timer, ret ); +#else + idle( &server_fd, ret ); +#endif + } + } if( ret <= 0 ) { @@ -1689,18 +1998,31 @@ int main( int argc, char *argv[] ) if( ( ret = mbedtls_ssl_session_reset( &ssl ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n", + -ret ); goto exit; } while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) { if( ret != MBEDTLS_ERR_SSL_WANT_READ && - ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + ret != MBEDTLS_ERR_SSL_WANT_WRITE && + ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", + -ret ); goto exit; } + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &server_fd, &timer, ret ); +#else + idle( &server_fd, ret ); +#endif + } } mbedtls_printf( " ok\n" ); @@ -1747,21 +2069,25 @@ int main( int argc, char *argv[] ) if( ( ret = mbedtls_ssl_session_reset( &ssl ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_session_reset returned -0x%x\n\n", + -ret ); goto exit; } if( ( ret = mbedtls_ssl_set_session( &ssl, &saved_session ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_conf_session returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_conf_session returned %d\n\n", + ret ); goto exit; } - if( ( ret = mbedtls_net_connect( &server_fd, opt.server_addr, opt.server_port, - opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? - MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) + if( ( ret = mbedtls_net_connect( &server_fd, + opt.server_addr, opt.server_port, + opt.transport == MBEDTLS_SSL_TRANSPORT_STREAM ? + MBEDTLS_NET_PROTO_TCP : MBEDTLS_NET_PROTO_UDP ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_net_connect returned -0x%x\n\n", + -ret ); goto exit; } @@ -1772,16 +2098,18 @@ int main( int argc, char *argv[] ) if( ret != 0 ) { mbedtls_printf( " failed\n ! net_set_(non)block() returned -0x%x\n\n", - -ret ); + -ret ); goto exit; } while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) { if( ret != MBEDTLS_ERR_SSL_WANT_READ && - ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + ret != MBEDTLS_ERR_SSL_WANT_WRITE && + ret != MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", + -ret ); goto exit; } } diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_fork_server.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_fork_server.c index 1c3a80600c..b6f1cc4fdd 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_fork_server.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_fork_server.c @@ -33,6 +33,7 @@ #define mbedtls_fprintf fprintf #define mbedtls_printf printf #define mbedtls_time_t time_t +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -86,6 +87,18 @@ int main( void ) #define DEBUG_LEVEL 0 +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_mail_client.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_mail_client.c index 7214dc2631..c73297c2ab 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_mail_client.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_mail_client.c @@ -19,6 +19,11 @@ * This file is part of mbed TLS (https://tls.mbed.org) */ +/* Enable definition of gethostname() even when compiling with -std=c99. Must + * be set before config.h, which pulls in glibc's features.h indirectly. + * Harmless on other platforms. */ +#define _POSIX_C_SOURCE 200112L + #if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else @@ -34,6 +39,7 @@ #define mbedtls_time_t time_t #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -104,9 +110,9 @@ int main( void ) #if defined(MBEDTLS_BASE64_C) #define USAGE_AUTH \ - " authentication=%%d default: 0 (disabled)\n" \ - " user_name=%%s default: \"user\"\n" \ - " user_pwd=%%s default: \"password\"\n" + " authentication=%%d default: 0 (disabled)\n" \ + " user_name=%%s default: \"" DFL_USER_NAME "\"\n" \ + " user_pwd=%%s default: \"" DFL_USER_PWD "\"\n" #else #define USAGE_AUTH \ " authentication options disabled. (Require MBEDTLS_BASE64_C)\n" @@ -123,19 +129,31 @@ int main( void ) #endif /* MBEDTLS_FS_IO */ #define USAGE \ - "\n usage: ssl_mail_client param=<>...\n" \ - "\n acceptable parameters:\n" \ - " server_name=%%s default: localhost\n" \ - " server_port=%%d default: 4433\n" \ - " debug_level=%%d default: 0 (disabled)\n" \ + "\n usage: ssl_mail_client param=<>...\n" \ + "\n acceptable parameters:\n" \ + " server_name=%%s default: " DFL_SERVER_NAME "\n" \ + " server_port=%%d default: " DFL_SERVER_PORT "\n" \ + " debug_level=%%d default: 0 (disabled)\n" \ " mode=%%d default: 0 (SSL/TLS) (1 for STARTTLS)\n" \ - USAGE_AUTH \ - " mail_from=%%s default: \"\"\n" \ - " mail_to=%%s default: \"\"\n" \ - USAGE_IO \ - " force_ciphersuite= default: all enabled\n"\ + USAGE_AUTH \ + " mail_from=%%s default: \"\"\n" \ + " mail_to=%%s default: \"\"\n" \ + USAGE_IO \ + " force_ciphersuite= default: all enabled\n" \ " acceptable ciphersuite names:\n" +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ @@ -306,7 +324,7 @@ static int write_and_get_response( mbedtls_net_context *sock_fd, unsigned char * mbedtls_printf("\n%s", buf); if( len && ( ret = mbedtls_net_send( sock_fd, buf, len ) ) <= 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); + mbedtls_printf( " failed\n ! mbedtls_net_send returned %d\n\n", ret ); return -1; } @@ -318,7 +336,7 @@ static int write_and_get_response( mbedtls_net_context *sock_fd, unsigned char * if( ret <= 0 ) { - mbedtls_printf( "failed\n ! read returned %d\n\n", ret ); + mbedtls_printf( "failed\n ! mbedtls_net_recv returned %d\n\n", ret ); return -1; } diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_pthread_server.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_pthread_server.c index 9a05ad8fd3..b5026959a6 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_pthread_server.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_pthread_server.c @@ -30,9 +30,13 @@ #include "mbedtls/platform.h" #else #include +#include #define mbedtls_fprintf fprintf #define mbedtls_printf printf #define mbedtls_snprintf snprintf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ @@ -77,6 +81,18 @@ int main( void ) #include "mbedtls/memory_buffer_alloc.h" #endif +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + #define HTTP_RESPONSE \ "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \ "

        mbed TLS Test Server

        \r\n" \ diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server.c index dcdafbb869..1852b2badf 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server.c @@ -34,6 +34,9 @@ #define mbedtls_time_t time_t #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_CERTS_C) || \ @@ -80,6 +83,18 @@ int main( void ) #define DEBUG_LEVEL 0 +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) diff --git a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server2.c b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server2.c index b6e8a1d146..a4c5fab4b6 100644 --- a/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server2.c +++ b/3rdparty/mbedtls/mbedtls/programs/ssl/ssl_server2.c @@ -36,6 +36,9 @@ #define mbedtls_calloc calloc #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #if !defined(MBEDTLS_ENTROPY_C) || \ @@ -106,6 +109,7 @@ int main( void ) #define DFL_RESPONSE_SIZE -1 #define DFL_DEBUG_LEVEL 0 #define DFL_NBIO 0 +#define DFL_EVENT 0 #define DFL_READ_TIMEOUT 0 #define DFL_CA_FILE "" #define DFL_CA_PATH "" @@ -113,6 +117,10 @@ int main( void ) #define DFL_KEY_FILE "" #define DFL_CRT_FILE2 "" #define DFL_KEY_FILE2 "" +#define DFL_ASYNC_OPERATIONS "-" +#define DFL_ASYNC_PRIVATE_DELAY1 ( -1 ) +#define DFL_ASYNC_PRIVATE_DELAY2 ( -1 ) +#define DFL_ASYNC_PRIVATE_ERROR ( 0 ) #define DFL_PSK "" #define DFL_PSK_IDENTITY "Client_identity" #define DFL_ECJPAKE_PW NULL @@ -146,7 +154,9 @@ int main( void ) #define DFL_ANTI_REPLAY -1 #define DFL_HS_TO_MIN 0 #define DFL_HS_TO_MAX 0 +#define DFL_DTLS_MTU -1 #define DFL_BADMAC_LIMIT -1 +#define DFL_DGRAM_PACKING 1 #define DFL_EXTENDED_MS -1 #define DFL_ETM -1 @@ -178,8 +188,10 @@ int main( void ) #define USAGE_IO \ " ca_file=%%s The single file containing the top-level CA(s) you fully trust\n" \ " default: \"\" (pre-loaded)\n" \ + " use \"none\" to skip loading any top-level CAs.\n" \ " ca_path=%%s The path containing the top-level CA(s) you fully trust\n" \ " default: \"\" (pre-loaded) (overrides ca_file)\n" \ + " use \"none\" to skip loading any top-level CAs.\n" \ " crt_file=%%s Your own cert and chain (in bottom to top order, top may be omitted)\n" \ " default: see note after key_file2\n" \ " key_file=%%s default: see note after key_file2\n" \ @@ -200,9 +212,25 @@ int main( void ) #define USAGE_IO "" #endif /* MBEDTLS_X509_CRT_PARSE_C */ +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +#define USAGE_SSL_ASYNC \ + " async_operations=%%c... d=decrypt, s=sign (default: -=off)\n" \ + " async_private_delay1=%%d Asynchronous delay for key_file or preloaded key\n" \ + " async_private_delay2=%%d Asynchronous delay for key_file2 and sni\n" \ + " default: -1 (not asynchronous)\n" \ + " async_private_error=%%d Async callback error injection (default=0=none,\n" \ + " 1=start, 2=cancel, 3=resume, negative=first time only)" +#else +#define USAGE_SSL_ASYNC "" +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) -#define USAGE_PSK \ - " psk=%%s default: \"\" (in hex, without 0x)\n" \ +#define USAGE_PSK \ + " psk=%%s default: \"\" (in hex, without 0x)\n" \ + " psk_list=%%s default: \"\"\n" \ + " A list of (PSK identity, PSK value) pairs.\n" \ + " The PSK values are in hex, without 0x.\n" \ + " id1,psk1[,id2,psk2[,...]]\n" \ " psk_identity=%%s default: \"Client_identity\"\n" #else #define USAGE_PSK "" @@ -225,8 +253,14 @@ int main( void ) #endif /* MBEDTLS_SSL_CACHE_C */ #if defined(SNI_OPTION) +#if defined(MBEDTLS_X509_CRL_PARSE_C) +#define SNI_CRL ",crl" +#else +#define SNI_CRL "" +#endif + #define USAGE_SNI \ - " sni=%%s name1,cert1,key1,ca1,crl1,auth1[,...]\n" \ + " sni=%%s name1,cert1,key1,ca1"SNI_CRL",auth1[,...]\n" \ " default: disabled\n" #else #define USAGE_SNI "" @@ -281,7 +315,11 @@ int main( void ) #define USAGE_DTLS \ " dtls=%%d default: 0 (TLS)\n" \ " hs_timeout=%%d-%%d default: (library default: 1000-60000)\n" \ - " range of DTLS handshake timeouts in millisecs\n" + " range of DTLS handshake timeouts in millisecs\n" \ + " mtu=%%d default: (library default: unlimited)\n" \ + " dgram_packing=%%d default: 1 (allowed)\n" \ + " allow or forbid packing of multiple\n" \ + " records within a single datgram.\n" #else #define USAGE_DTLS "" #endif @@ -341,6 +379,8 @@ int main( void ) " increases buffer_size if bigger\n"\ " nbio=%%d default: 0 (blocking I/O)\n" \ " options: 1 (non-blocking), 2 (added delays)\n" \ + " event=%%d default: 0 (loop)\n" \ + " options: 1 (level-triggered, implies nbio=1),\n" \ " read_timeout=%%d default: 0 ms (no timeout)\n" \ "\n" \ USAGE_DTLS \ @@ -353,6 +393,7 @@ int main( void ) " cert_req_ca_list=%%d default: 1 (send ca list)\n" \ " options: 1 (send ca list), 0 (don't send)\n" \ USAGE_IO \ + USAGE_SSL_ASYNC \ USAGE_SNI \ "\n" \ USAGE_PSK \ @@ -382,6 +423,10 @@ int main( void ) " in order from ssl3 to tls1_2\n" \ " default: all enabled\n" \ " force_ciphersuite= default: all enabled\n" \ + " query_config= return 0 if the specified\n" \ + " configuration macro is defined and 1\n" \ + " otherwise. The expansion of the macro\n" \ + " is printed if it is defined\n" \ " acceptable ciphersuite names:\n" @@ -400,6 +445,18 @@ int main( void ) (out_be)[(i) + 7] = (unsigned char)( ( (in_le) >> 0 ) & 0xFF ); \ } +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ @@ -409,6 +466,7 @@ struct options const char *server_port; /* port on which the ssl service runs */ int debug_level; /* level of debugging */ int nbio; /* should I/O be blocking? */ + int event; /* loop or event-driven IO? level or edge triggered? */ uint32_t read_timeout; /* timeout on mbedtls_ssl_read() in milliseconds */ int response_size; /* pad response with header to requested size */ uint16_t buffer_size; /* IO buffer size */ @@ -418,6 +476,10 @@ struct options const char *key_file; /* the file with the server key */ const char *crt_file2; /* the file with the 2nd server certificate */ const char *key_file2; /* the file with the 2nd server key */ + const char *async_operations; /* supported SSL asynchronous operations */ + int async_private_delay1; /* number of times f_async_resume needs to be called for key 1, or -1 for no async */ + int async_private_delay2; /* number of times f_async_resume needs to be called for key 2, or -1 for no async */ + int async_private_error; /* inject error in async private callback */ const char *psk; /* the pre-shared key */ const char *psk_identity; /* the pre-shared key identity */ char *psk_list; /* list of PSK id/key pairs for callback */ @@ -453,9 +515,13 @@ struct options int anti_replay; /* Use anti-replay for DTLS? -1 for default */ uint32_t hs_to_min; /* Initial value of DTLS handshake timer */ uint32_t hs_to_max; /* Max value of DTLS handshake timer */ + int dtls_mtu; /* UDP Maximum tranport unit for DTLS */ + int dgram_packing; /* allow/forbid datagram packing */ int badmac_limit; /* Limit of records with bad MAC */ } opt; +int query_config( const char *config ); + static void my_debug( void *ctx, int level, const char *file, int line, const char *str ) @@ -528,11 +594,14 @@ static int get_auth_mode( const char *s ) * Used by sni_parse and psk_parse to handle coma-separated lists */ #define GET_ITEM( dst ) \ - dst = p; \ - while( *p != ',' ) \ - if( ++p > end ) \ - goto error; \ - *p++ = '\0'; + do \ + { \ + (dst) = p; \ + while( *p != ',' ) \ + if( ++p > end ) \ + goto error; \ + *p++ = '\0'; \ + } while( 0 ) #if defined(SNI_OPTION) typedef struct _sni_entry sni_entry; @@ -561,10 +630,10 @@ void sni_free( sni_entry *head ) mbedtls_x509_crt_free( cur->ca ); mbedtls_free( cur->ca ); - +#if defined(MBEDTLS_X509_CRL_PARSE_C) mbedtls_x509_crl_free( cur->crl ); mbedtls_free( cur->crl ); - +#endif next = cur->next; mbedtls_free( cur ); cur = next; @@ -583,7 +652,10 @@ sni_entry *sni_parse( char *sni_string ) sni_entry *cur = NULL, *new = NULL; char *p = sni_string; char *end = p; - char *crt_file, *key_file, *ca_file, *crl_file, *auth_str; + char *crt_file, *key_file, *ca_file, *auth_str; +#if defined(MBEDTLS_X509_CRL_PARSE_C) + char *crl_file; +#endif while( *end != '\0' ) ++end; @@ -601,7 +673,9 @@ sni_entry *sni_parse( char *sni_string ) GET_ITEM( crt_file ); GET_ITEM( key_file ); GET_ITEM( ca_file ); +#if defined(MBEDTLS_X509_CRL_PARSE_C) GET_ITEM( crl_file ); +#endif GET_ITEM( auth_str ); if( ( new->cert = mbedtls_calloc( 1, sizeof( mbedtls_x509_crt ) ) ) == NULL || @@ -626,6 +700,7 @@ sni_entry *sni_parse( char *sni_string ) goto error; } +#if defined(MBEDTLS_X509_CRL_PARSE_C) if( strcmp( crl_file, "-" ) != 0 ) { if( ( new->crl = mbedtls_calloc( 1, sizeof( mbedtls_x509_crl ) ) ) == NULL ) @@ -636,6 +711,7 @@ sni_entry *sni_parse( char *sni_string ) if( mbedtls_x509_crl_parse_file( new->crl, crl_file ) != 0 ) goto error; } +#endif if( strcmp( auth_str, "-" ) != 0 ) { @@ -689,15 +765,18 @@ int sni_callback( void *p_info, mbedtls_ssl_context *ssl, #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) -#define HEX2NUM( c ) \ - if( c >= '0' && c <= '9' ) \ - c -= '0'; \ - else if( c >= 'a' && c <= 'f' ) \ - c -= 'a' - 10; \ - else if( c >= 'A' && c <= 'F' ) \ - c -= 'A' - 10; \ - else \ - return( -1 ); +#define HEX2NUM( c ) \ + do \ + { \ + if( (c) >= '0' && (c) <= '9' ) \ + (c) -= '0'; \ + else if( (c) >= 'a' && (c) <= 'f' ) \ + (c) -= 'a' - 10; \ + else if( (c) >= 'A' && (c) <= 'F' ) \ + (c) -= 'A' - 10; \ + else \ + return( -1 ); \ + } while( 0 ) /* * Convert a hex string to bytes. @@ -849,6 +928,294 @@ static int ssl_sig_hashes_for_test[] = { }; #endif /* MBEDTLS_X509_CRT_PARSE_C */ +/** Return true if \p ret is a status code indicating that there is an + * operation in progress on an SSL connection, and false if it indicates + * success or a fatal error. + * + * The possible operations in progress are: + * + * - A read, when the SSL input buffer does not contain a full message. + * - A write, when the SSL output buffer contains some data that has not + * been sent over the network yet. + * - An asynchronous callback that has not completed yet. */ +static int mbedtls_status_is_ssl_in_progress( int ret ) +{ + return( ret == MBEDTLS_ERR_SSL_WANT_READ || + ret == MBEDTLS_ERR_SSL_WANT_WRITE || + ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ); +} + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) +typedef struct +{ + mbedtls_x509_crt *cert; /*!< Certificate corresponding to the key */ + mbedtls_pk_context *pk; /*!< Private key */ + unsigned delay; /*!< Number of resume steps to go through */ + unsigned pk_owned : 1; /*!< Whether to free the pk object on exit */ +} ssl_async_key_slot_t; + +typedef enum { + SSL_ASYNC_INJECT_ERROR_NONE = 0, /*!< Let the callbacks succeed */ + SSL_ASYNC_INJECT_ERROR_START, /*!< Inject error during start */ + SSL_ASYNC_INJECT_ERROR_CANCEL, /*!< Close the connection after async start */ + SSL_ASYNC_INJECT_ERROR_RESUME, /*!< Inject error during resume */ +#define SSL_ASYNC_INJECT_ERROR_MAX SSL_ASYNC_INJECT_ERROR_RESUME +} ssl_async_inject_error_t; + +typedef struct +{ + ssl_async_key_slot_t slots[4]; /* key, key2, sni1, sni2 */ + size_t slots_used; + ssl_async_inject_error_t inject_error; + int (*f_rng)(void *, unsigned char *, size_t); + void *p_rng; +} ssl_async_key_context_t; + +int ssl_async_set_key( ssl_async_key_context_t *ctx, + mbedtls_x509_crt *cert, + mbedtls_pk_context *pk, + int pk_take_ownership, + unsigned delay ) +{ + if( ctx->slots_used >= sizeof( ctx->slots ) / sizeof( *ctx->slots ) ) + return( -1 ); + ctx->slots[ctx->slots_used].cert = cert; + ctx->slots[ctx->slots_used].pk = pk; + ctx->slots[ctx->slots_used].delay = delay; + ctx->slots[ctx->slots_used].pk_owned = pk_take_ownership; + ++ctx->slots_used; + return( 0 ); +} + +#define SSL_ASYNC_INPUT_MAX_SIZE 512 + +typedef enum +{ + ASYNC_OP_SIGN, + ASYNC_OP_DECRYPT, +} ssl_async_operation_type_t; +/* Note that the enum above and the array below need to be kept in sync! + * `ssl_async_operation_names[op]` is the name of op for each value `op` + * of type `ssl_async_operation_type_t`. */ +static const char *const ssl_async_operation_names[] = +{ + "sign", + "decrypt", +}; + +typedef struct +{ + unsigned slot; + ssl_async_operation_type_t operation_type; + mbedtls_md_type_t md_alg; + unsigned char input[SSL_ASYNC_INPUT_MAX_SIZE]; + size_t input_len; + unsigned remaining_delay; +} ssl_async_operation_context_t; + +static int ssl_async_start( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *cert, + ssl_async_operation_type_t op_type, + mbedtls_md_type_t md_alg, + const unsigned char *input, + size_t input_len ) +{ + ssl_async_key_context_t *config_data = + mbedtls_ssl_conf_get_async_config_data( ssl->conf ); + unsigned slot; + ssl_async_operation_context_t *ctx = NULL; + const char *op_name = ssl_async_operation_names[op_type]; + + { + char dn[100]; + if( mbedtls_x509_dn_gets( dn, sizeof( dn ), &cert->subject ) > 0 ) + mbedtls_printf( "Async %s callback: looking for DN=%s\n", + op_name, dn ); + } + + /* Look for a private key that matches the public key in cert. + * Since this test code has the private key inside Mbed TLS, + * we call mbedtls_pk_check_pair to match a private key with the + * public key. */ + for( slot = 0; slot < config_data->slots_used; slot++ ) + { + if( mbedtls_pk_check_pair( &cert->pk, + config_data->slots[slot].pk ) == 0 ) + break; + } + if( slot == config_data->slots_used ) + { + mbedtls_printf( "Async %s callback: no key matches this certificate.\n", + op_name ); + return( MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH ); + } + mbedtls_printf( "Async %s callback: using key slot %u, delay=%u.\n", + op_name, slot, config_data->slots[slot].delay ); + + if( config_data->inject_error == SSL_ASYNC_INJECT_ERROR_START ) + { + mbedtls_printf( "Async %s callback: injected error\n", op_name ); + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + } + + if( input_len > SSL_ASYNC_INPUT_MAX_SIZE ) + return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA ); + + ctx = mbedtls_calloc( 1, sizeof( *ctx ) ); + if( ctx == NULL ) + return( MBEDTLS_ERR_SSL_ALLOC_FAILED ); + ctx->slot = slot; + ctx->operation_type = op_type; + ctx->md_alg = md_alg; + memcpy( ctx->input, input, input_len ); + ctx->input_len = input_len; + ctx->remaining_delay = config_data->slots[slot].delay; + mbedtls_ssl_set_async_operation_data( ssl, ctx ); + + if( ctx->remaining_delay == 0 ) + return( 0 ); + else + return( MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ); +} + +static int ssl_async_sign( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *cert, + mbedtls_md_type_t md_alg, + const unsigned char *hash, + size_t hash_len ) +{ + return( ssl_async_start( ssl, cert, + ASYNC_OP_SIGN, md_alg, + hash, hash_len ) ); +} + +static int ssl_async_decrypt( mbedtls_ssl_context *ssl, + mbedtls_x509_crt *cert, + const unsigned char *input, + size_t input_len ) +{ + return( ssl_async_start( ssl, cert, + ASYNC_OP_DECRYPT, MBEDTLS_MD_NONE, + input, input_len ) ); +} + +static int ssl_async_resume( mbedtls_ssl_context *ssl, + unsigned char *output, + size_t *output_len, + size_t output_size ) +{ + ssl_async_operation_context_t *ctx = mbedtls_ssl_get_async_operation_data( ssl ); + ssl_async_key_context_t *config_data = + mbedtls_ssl_conf_get_async_config_data( ssl->conf ); + ssl_async_key_slot_t *key_slot = &config_data->slots[ctx->slot]; + int ret; + const char *op_name; + + if( ctx->remaining_delay > 0 ) + { + --ctx->remaining_delay; + mbedtls_printf( "Async resume (slot %u): call %u more times.\n", + ctx->slot, ctx->remaining_delay ); + return( MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS ); + } + + switch( ctx->operation_type ) + { + case ASYNC_OP_DECRYPT: + ret = mbedtls_pk_decrypt( key_slot->pk, + ctx->input, ctx->input_len, + output, output_len, output_size, + config_data->f_rng, config_data->p_rng ); + break; + case ASYNC_OP_SIGN: + ret = mbedtls_pk_sign( key_slot->pk, + ctx->md_alg, + ctx->input, ctx->input_len, + output, output_len, + config_data->f_rng, config_data->p_rng ); + break; + default: + mbedtls_printf( "Async resume (slot %u): unknown operation type %ld. This shouldn't happen.\n", + ctx->slot, (long) ctx->operation_type ); + mbedtls_free( ctx ); + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + break; + } + + op_name = ssl_async_operation_names[ctx->operation_type]; + + if( config_data->inject_error == SSL_ASYNC_INJECT_ERROR_RESUME ) + { + mbedtls_printf( "Async resume callback: %s done but injected error\n", + op_name ); + mbedtls_free( ctx ); + return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE ); + } + + mbedtls_printf( "Async resume (slot %u): %s done, status=%d.\n", + ctx->slot, op_name, ret ); + mbedtls_free( ctx ); + return( ret ); +} + +static void ssl_async_cancel( mbedtls_ssl_context *ssl ) +{ + ssl_async_operation_context_t *ctx = mbedtls_ssl_get_async_operation_data( ssl ); + mbedtls_printf( "Async cancel callback.\n" ); + mbedtls_free( ctx ); +} +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + +/* + * Wait for an event from the underlying transport or the timer + * (Used in event-driven IO mode). + */ +#if !defined(MBEDTLS_TIMING_C) +int idle( mbedtls_net_context *fd, + int idle_reason ) +#else +int idle( mbedtls_net_context *fd, + mbedtls_timing_delay_context *timer, + int idle_reason ) +#endif +{ + int ret; + int poll_type = 0; + + if( idle_reason == MBEDTLS_ERR_SSL_WANT_WRITE ) + poll_type = MBEDTLS_NET_POLL_WRITE; + else if( idle_reason == MBEDTLS_ERR_SSL_WANT_READ ) + poll_type = MBEDTLS_NET_POLL_READ; +#if !defined(MBEDTLS_TIMING_C) + else + return( 0 ); +#endif + + while( 1 ) + { + /* Check if timer has expired */ +#if defined(MBEDTLS_TIMING_C) + if( timer != NULL && + mbedtls_timing_get_delay( timer ) == 2 ) + { + break; + } +#endif /* MBEDTLS_TIMING_C */ + + /* Check if underlying transport became available */ + if( poll_type != 0 ) + { + ret = mbedtls_net_poll( fd, poll_type, 0 ); + if( ret < 0 ) + return( ret ); + if( ret == poll_type ) + break; + } + } + + return( 0 ); +} + int main( int argc, char *argv[] ) { int ret = 0, len, written, frags, exchanges_left; @@ -887,7 +1254,10 @@ int main( int argc, char *argv[] ) mbedtls_x509_crt srvcert2; mbedtls_pk_context pkey2; int key_cert_init = 0, key_cert_init2 = 0; -#endif +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + ssl_async_key_context_t ssl_async_keys; +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ +#endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) mbedtls_dhm_context dhm; #endif @@ -933,6 +1303,9 @@ int main( int argc, char *argv[] ) mbedtls_pk_init( &pkey ); mbedtls_x509_crt_init( &srvcert2 ); mbedtls_pk_init( &pkey2 ); +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + memset( &ssl_async_keys, 0, sizeof( ssl_async_keys ) ); +#endif #endif #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) mbedtls_dhm_init( &dhm ); @@ -982,6 +1355,7 @@ int main( int argc, char *argv[] ) opt.server_addr = DFL_SERVER_ADDR; opt.server_port = DFL_SERVER_PORT; opt.debug_level = DFL_DEBUG_LEVEL; + opt.event = DFL_EVENT; opt.response_size = DFL_RESPONSE_SIZE; opt.nbio = DFL_NBIO; opt.read_timeout = DFL_READ_TIMEOUT; @@ -991,6 +1365,10 @@ int main( int argc, char *argv[] ) opt.key_file = DFL_KEY_FILE; opt.crt_file2 = DFL_CRT_FILE2; opt.key_file2 = DFL_KEY_FILE2; + opt.async_operations = DFL_ASYNC_OPERATIONS; + opt.async_private_delay1 = DFL_ASYNC_PRIVATE_DELAY1; + opt.async_private_delay2 = DFL_ASYNC_PRIVATE_DELAY2; + opt.async_private_error = DFL_ASYNC_PRIVATE_ERROR; opt.psk = DFL_PSK; opt.psk_identity = DFL_PSK_IDENTITY; opt.psk_list = DFL_PSK_LIST; @@ -1024,6 +1402,8 @@ int main( int argc, char *argv[] ) opt.anti_replay = DFL_ANTI_REPLAY; opt.hs_to_min = DFL_HS_TO_MIN; opt.hs_to_max = DFL_HS_TO_MAX; + opt.dtls_mtu = DFL_DTLS_MTU; + opt.dgram_packing = DFL_DGRAM_PACKING; opt.badmac_limit = DFL_BADMAC_LIMIT; opt.extended_ms = DFL_EXTENDED_MS; opt.etm = DFL_ETM; @@ -1061,6 +1441,12 @@ int main( int argc, char *argv[] ) if( opt.nbio < 0 || opt.nbio > 2 ) goto usage; } + else if( strcmp( p, "event" ) == 0 ) + { + opt.event = atoi( q ); + if( opt.event < 0 || opt.event > 2 ) + goto usage; + } else if( strcmp( p, "read_timeout" ) == 0 ) opt.read_timeout = atoi( q ); else if( strcmp( p, "buffer_size" ) == 0 ) @@ -1091,6 +1477,25 @@ int main( int argc, char *argv[] ) opt.key_file2 = q; else if( strcmp( p, "dhm_file" ) == 0 ) opt.dhm_file = q; +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + else if( strcmp( p, "async_operations" ) == 0 ) + opt.async_operations = q; + else if( strcmp( p, "async_private_delay1" ) == 0 ) + opt.async_private_delay1 = atoi( q ); + else if( strcmp( p, "async_private_delay2" ) == 0 ) + opt.async_private_delay2 = atoi( q ); + else if( strcmp( p, "async_private_error" ) == 0 ) + { + int n = atoi( q ); + if( n < -SSL_ASYNC_INJECT_ERROR_MAX || + n > SSL_ASYNC_INJECT_ERROR_MAX ) + { + ret = 2; + goto usage; + } + opt.async_private_error = n; + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ else if( strcmp( p, "psk" ) == 0 ) opt.psk = q; else if( strcmp( p, "psk_identity" ) == 0 ) @@ -1116,16 +1521,23 @@ int main( int argc, char *argv[] ) opt.version_suites = q; else if( strcmp( p, "renegotiation" ) == 0 ) { - opt.renegotiation = (atoi( q )) ? MBEDTLS_SSL_RENEGOTIATION_ENABLED : - MBEDTLS_SSL_RENEGOTIATION_DISABLED; + opt.renegotiation = (atoi( q )) ? + MBEDTLS_SSL_RENEGOTIATION_ENABLED : + MBEDTLS_SSL_RENEGOTIATION_DISABLED; } else if( strcmp( p, "allow_legacy" ) == 0 ) { switch( atoi( q ) ) { - case -1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE; break; - case 0: opt.allow_legacy = MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION; break; - case 1: opt.allow_legacy = MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION; break; + case -1: + opt.allow_legacy = MBEDTLS_SSL_LEGACY_BREAK_HANDSHAKE; + break; + case 0: + opt.allow_legacy = MBEDTLS_SSL_LEGACY_NO_RENEGOTIATION; + break; + case 1: + opt.allow_legacy = MBEDTLS_SSL_LEGACY_ALLOW_RENEGOTIATION; + break; default: goto usage; } } @@ -1282,8 +1694,12 @@ int main( int argc, char *argv[] ) { switch( atoi( q ) ) { - case 0: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_DISABLED; break; - case 1: opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; break; + case 0: + opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_DISABLED; + break; + case 1: + opt.extended_ms = MBEDTLS_SSL_EXTENDED_MS_ENABLED; + break; default: goto usage; } } @@ -1348,14 +1764,42 @@ int main( int argc, char *argv[] ) if( opt.hs_to_min == 0 || opt.hs_to_max < opt.hs_to_min ) goto usage; } + else if( strcmp( p, "mtu" ) == 0 ) + { + opt.dtls_mtu = atoi( q ); + if( opt.dtls_mtu < 0 ) + goto usage; + } + else if( strcmp( p, "dgram_packing" ) == 0 ) + { + opt.dgram_packing = atoi( q ); + if( opt.dgram_packing != 0 && + opt.dgram_packing != 1 ) + { + goto usage; + } + } else if( strcmp( p, "sni" ) == 0 ) { opt.sni = q; } + else if( strcmp( p, "query_config" ) == 0 ) + { + return query_config( q ); + } else goto usage; } + /* Event-driven IO is incompatible with the above custom + * receive and send functions, as the polling builds on + * refers to the underlying net_context. */ + if( opt.event == 1 && opt.nbio != 1 ) + { + mbedtls_printf( "Warning: event-driven IO mandates nbio=1 - overwrite\n" ); + opt.nbio = 1; + } + #if defined(MBEDTLS_DEBUG_C) mbedtls_debug_set_threshold( opt.debug_level ); #endif @@ -1370,19 +1814,20 @@ int main( int argc, char *argv[] ) if( opt.force_ciphersuite[0] > 0 ) { const mbedtls_ssl_ciphersuite_t *ciphersuite_info; - ciphersuite_info = mbedtls_ssl_ciphersuite_from_id( opt.force_ciphersuite[0] ); + ciphersuite_info = + mbedtls_ssl_ciphersuite_from_id( opt.force_ciphersuite[0] ); if( opt.max_version != -1 && ciphersuite_info->min_minor_ver > opt.max_version ) { - mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + mbedtls_printf( "forced ciphersuite not allowed with this protocol version\n" ); ret = 2; goto usage; } if( opt.min_version != -1 && ciphersuite_info->max_minor_ver < opt.min_version ) { - mbedtls_printf("forced ciphersuite not allowed with this protocol version\n"); + mbedtls_printf( "forced ciphersuite not allowed with this protocol version\n" ); ret = 2; goto usage; } @@ -1561,11 +2006,12 @@ int main( int argc, char *argv[] ) fflush( stdout ); mbedtls_entropy_init( &entropy ); - if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, - (const unsigned char *) pers, - strlen( pers ) ) ) != 0 ) + if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, + &entropy, (const unsigned char *) pers, + strlen( pers ) ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%x\n", + -ret ); goto exit; } @@ -1578,20 +2024,22 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Loading the CA root certificate ..." ); fflush( stdout ); + if( strcmp( opt.ca_path, "none" ) == 0 || + strcmp( opt.ca_file, "none" ) == 0 ) + { + ret = 0; + } + else #if defined(MBEDTLS_FS_IO) if( strlen( opt.ca_path ) ) - if( strcmp( opt.ca_path, "none" ) == 0 ) - ret = 0; - else - ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); + ret = mbedtls_x509_crt_parse_path( &cacert, opt.ca_path ); else if( strlen( opt.ca_file ) ) - if( strcmp( opt.ca_file, "none" ) == 0 ) - ret = 0; - else - ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); + ret = mbedtls_x509_crt_parse_file( &cacert, opt.ca_file ); else #endif #if defined(MBEDTLS_CERTS_C) + { +#if defined(MBEDTLS_PEM_PARSE_C) for( i = 0; mbedtls_test_cas[i] != NULL; i++ ) { ret = mbedtls_x509_crt_parse( &cacert, @@ -1600,12 +2048,23 @@ int main( int argc, char *argv[] ) if( ret != 0 ) break; } + if( ret == 0 ) +#endif /* MBEDTLS_PEM_PARSE_C */ + for( i = 0; mbedtls_test_cas_der[i] != NULL; i++ ) + { + ret = mbedtls_x509_crt_parse_der( &cacert, + (const unsigned char *) mbedtls_test_cas_der[i], + mbedtls_test_cas_der_len[i] ); + if( ret != 0 ) + break; + } + } #else { ret = 1; - mbedtls_printf("MBEDTLS_CERTS_C not defined."); + mbedtls_printf( "MBEDTLS_CERTS_C not defined." ); } -#endif +#endif /* MBEDTLS_CERTS_C */ if( ret < 0 ) { mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); @@ -1662,7 +2121,7 @@ int main( int argc, char *argv[] ) if( ( ret = mbedtls_pk_parse_keyfile( &pkey2, opt.key_file2, "" ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile(2) returned -0x%x\n\n", - -ret ); + -ret ); goto exit; } } @@ -1680,8 +2139,7 @@ int main( int argc, char *argv[] ) strcmp( opt.key_file2, "none" ) != 0 ) { #if !defined(MBEDTLS_CERTS_C) - mbedtls_printf( "Not certificated or key provided, and \n" - "MBEDTLS_CERTS_C not defined!\n" ); + mbedtls_printf( "Not certificated or key provided, and \nMBEDTLS_CERTS_C not defined!\n" ); goto exit; #else #if defined(MBEDTLS_RSA_C) @@ -1689,14 +2147,16 @@ int main( int argc, char *argv[] ) (const unsigned char *) mbedtls_test_srv_crt_rsa, mbedtls_test_srv_crt_rsa_len ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", + -ret ); goto exit; } if( ( ret = mbedtls_pk_parse_key( &pkey, (const unsigned char *) mbedtls_test_srv_key_rsa, mbedtls_test_srv_key_rsa_len, NULL, 0 ) ) != 0 ) { - mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n", + -ret ); goto exit; } key_cert_init = 2; @@ -1706,14 +2166,16 @@ int main( int argc, char *argv[] ) (const unsigned char *) mbedtls_test_srv_crt_ec, mbedtls_test_srv_crt_ec_len ) ) != 0 ) { - mbedtls_printf( " failed\n ! x509_crt_parse2 returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! x509_crt_parse2 returned -0x%x\n\n", + -ret ); goto exit; } if( ( ret = mbedtls_pk_parse_key( &pkey2, (const unsigned char *) mbedtls_test_srv_key_ec, mbedtls_test_srv_key_ec_len, NULL, 0 ) ) != 0 ) { - mbedtls_printf( " failed\n ! pk_parse_key2 returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! pk_parse_key2 returned -0x%x\n\n", + -ret ); goto exit; } key_cert_init2 = 2; @@ -1812,6 +2274,9 @@ int main( int argc, char *argv[] ) #if defined(MBEDTLS_SSL_PROTO_DTLS) if( opt.hs_to_min != DFL_HS_TO_MIN || opt.hs_to_max != DFL_HS_TO_MAX ) mbedtls_ssl_conf_handshake_timeout( &conf, opt.hs_to_min, opt.hs_to_max ); + + if( opt.dgram_packing != DFL_DGRAM_PACKING ) + mbedtls_ssl_set_datagram_packing( &ssl, opt.dgram_packing ); #endif /* MBEDTLS_SSL_PROTO_DTLS */ #if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH) @@ -1967,22 +2432,109 @@ int main( int argc, char *argv[] ) mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); } if( key_cert_init ) - if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) + { + mbedtls_pk_context *pk = &pkey; +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( opt.async_private_delay1 >= 0 ) + { + ret = ssl_async_set_key( &ssl_async_keys, &srvcert, pk, 0, + opt.async_private_delay1 ); + if( ret < 0 ) + { + mbedtls_printf( " Test error: ssl_async_set_key failed (%d)\n", + ret ); + goto exit; + } + pk = NULL; + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, pk ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); goto exit; } + } if( key_cert_init2 ) - if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert2, &pkey2 ) ) != 0 ) + { + mbedtls_pk_context *pk = &pkey2; +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( opt.async_private_delay2 >= 0 ) + { + ret = ssl_async_set_key( &ssl_async_keys, &srvcert2, pk, 0, + opt.async_private_delay2 ); + if( ret < 0 ) + { + mbedtls_printf( " Test error: ssl_async_set_key failed (%d)\n", + ret ); + goto exit; + } + pk = NULL; + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert2, pk ) ) != 0 ) { mbedtls_printf( " failed\n ! mbedtls_ssl_conf_own_cert returned %d\n\n", ret ); goto exit; } -#endif + } + +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( opt.async_operations[0] != '-' ) + { + mbedtls_ssl_async_sign_t *sign = NULL; + mbedtls_ssl_async_decrypt_t *decrypt = NULL; + const char *r; + for( r = opt.async_operations; *r; r++ ) + { + switch( *r ) + { + case 'd': + decrypt = ssl_async_decrypt; + break; + case 's': + sign = ssl_async_sign; + break; + } + } + ssl_async_keys.inject_error = ( opt.async_private_error < 0 ? + - opt.async_private_error : + opt.async_private_error ); + ssl_async_keys.f_rng = mbedtls_ctr_drbg_random; + ssl_async_keys.p_rng = &ctr_drbg; + mbedtls_ssl_conf_async_private_cb( &conf, + sign, + decrypt, + ssl_async_resume, + ssl_async_cancel, + &ssl_async_keys ); + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ +#endif /* MBEDTLS_X509_CRT_PARSE_C */ #if defined(SNI_OPTION) if( opt.sni != NULL ) + { mbedtls_ssl_conf_sni( &conf, sni_callback, sni_info ); +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( opt.async_private_delay2 >= 0 ) + { + sni_entry *cur; + for( cur = sni_info; cur != NULL; cur = cur->next ) + { + ret = ssl_async_set_key( &ssl_async_keys, + cur->cert, cur->key, 1, + opt.async_private_delay2 ); + if( ret < 0 ) + { + mbedtls_printf( " Test error: ssl_async_set_key failed (%d)\n", + ret ); + goto exit; + } + cur->key = NULL; + } + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + } #endif #if defined(MBEDTLS_ECP_C) @@ -2043,6 +2595,11 @@ int main( int argc, char *argv[] ) mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL ); +#if defined(MBEDTLS_SSL_PROTO_DTLS) + if( opt.dtls_mtu != DFL_DTLS_MTU ) + mbedtls_ssl_set_mtu( &ssl, opt.dtls_mtu ); +#endif + #if defined(MBEDTLS_TIMING_C) mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, mbedtls_timing_get_delay ); @@ -2123,8 +2680,8 @@ int main( int argc, char *argv[] ) if( ( ret = mbedtls_ssl_set_client_transport_id( &ssl, client_ip, cliip_len ) ) != 0 ) { - mbedtls_printf( " failed\n ! " - "mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", -ret ); + mbedtls_printf( " failed\n ! mbedtls_ssl_set_client_transport_id() returned -0x%x\n\n", + -ret ); goto exit; } } @@ -2152,9 +2709,32 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Performing the SSL/TLS handshake..." ); fflush( stdout ); - do ret = mbedtls_ssl_handshake( &ssl ); - while( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + while( ( ret = mbedtls_ssl_handshake( &ssl ) ) != 0 ) + { +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( ret == MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS && + ssl_async_keys.inject_error == SSL_ASYNC_INJECT_ERROR_CANCEL ) + { + mbedtls_printf( " cancelling on injected error\n" ); + break; + } +#endif /* MBEDTLS_SSL_ASYNC_PRIVATE */ + + if( ! mbedtls_status_is_ssl_in_progress( ret ) ) + break; + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + ret = idle( &client_fd, &timer, ret ); +#else + ret = idle( &client_fd, ret ); +#endif + if( ret != 0 ) + goto reset; + } + } if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED ) { @@ -2178,6 +2758,11 @@ int main( int argc, char *argv[] ) } #endif +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + if( opt.async_private_error < 0 ) + /* Injected error only the first time round, to test reset */ + ssl_async_keys.inject_error = SSL_ASYNC_INJECT_ERROR_NONE; +#endif goto reset; } else /* ret == 0 */ @@ -2258,9 +2843,19 @@ int main( int argc, char *argv[] ) memset( buf, 0, opt.buffer_size ); ret = mbedtls_ssl_read( &ssl, buf, len ); - if( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE ) + if( mbedtls_status_is_ssl_in_progress( ret ) ) + { + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &client_fd, &timer, ret ); +#else + idle( &client_fd, ret ); +#endif + } + continue; + } if( ret <= 0 ) { @@ -2348,9 +2943,38 @@ int main( int argc, char *argv[] ) len = opt.buffer_size - 1; memset( buf, 0, opt.buffer_size ); - do ret = mbedtls_ssl_read( &ssl, buf, len ); - while( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + do + { + /* Without the call to `mbedtls_ssl_check_pending`, it might + * happen that the client sends application data in the same + * datagram as the Finished message concluding the handshake. + * In this case, the application data would be ready to be + * processed while the underlying transport wouldn't signal + * any further incoming data. + * + * See the test 'Event-driven I/O: session-id resume, UDP packing' + * in tests/ssl-opt.sh. + */ + + /* For event-driven IO, wait for socket to become available */ + if( mbedtls_ssl_check_pending( &ssl ) == 0 && + opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &client_fd, &timer, MBEDTLS_ERR_SSL_WANT_READ ); +#else + idle( &client_fd, MBEDTLS_ERR_SSL_WANT_READ ); +#endif + } + + ret = mbedtls_ssl_read( &ssl, buf, len ); + + /* Note that even if `mbedtls_ssl_check_pending` returns true, + * it can happen that the subsequent call to `mbedtls_ssl_read` + * returns `MBEDTLS_ERR_SSL_WANT_READ`, because the pending messages + * might be discarded (e.g. because they are retransmissions). */ + } + while( mbedtls_status_is_ssl_in_progress( ret ) ); if( ret <= 0 ) { @@ -2385,12 +3009,21 @@ int main( int argc, char *argv[] ) while( ( ret = mbedtls_ssl_renegotiate( &ssl ) ) != 0 ) { - if( ret != MBEDTLS_ERR_SSL_WANT_READ && - ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + if( ! mbedtls_status_is_ssl_in_progress( ret ) ) { mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n", ret ); goto reset; } + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &client_fd, &timer, ret ); +#else + idle( &client_fd, ret ); +#endif + } } mbedtls_printf( " ok\n" ); @@ -2438,20 +3071,43 @@ int main( int argc, char *argv[] ) goto reset; } - if( ret != MBEDTLS_ERR_SSL_WANT_READ && - ret != MBEDTLS_ERR_SSL_WANT_WRITE ) + if( ! mbedtls_status_is_ssl_in_progress( ret ) ) { mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret ); goto reset; } + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &client_fd, &timer, ret ); +#else + idle( &client_fd, ret ); +#endif + } } } } else /* Not stream, so datagram */ { - do ret = mbedtls_ssl_write( &ssl, buf, len ); - while( ret == MBEDTLS_ERR_SSL_WANT_READ || - ret == MBEDTLS_ERR_SSL_WANT_WRITE ); + while( 1 ) + { + ret = mbedtls_ssl_write( &ssl, buf, len ); + + if( ! mbedtls_status_is_ssl_in_progress( ret ) ) + break; + + /* For event-driven IO, wait for socket to become available */ + if( opt.event == 1 /* level triggered IO */ ) + { +#if defined(MBEDTLS_TIMING_C) + idle( &client_fd, &timer, ret ); +#else + idle( &client_fd, ret ); +#endif + } + } if( ret < 0 ) { @@ -2517,6 +3173,17 @@ int main( int argc, char *argv[] ) mbedtls_x509_crt_free( &srvcert2 ); mbedtls_pk_free( &pkey2 ); #endif +#if defined(MBEDTLS_SSL_ASYNC_PRIVATE) + for( i = 0; (size_t) i < ssl_async_keys.slots_used; i++ ) + { + if( ssl_async_keys.slots[i].pk_owned ) + { + mbedtls_pk_free( ssl_async_keys.slots[i].pk ); + mbedtls_free( ssl_async_keys.slots[i].pk ); + ssl_async_keys.slots[i].pk = NULL; + } + } +#endif #if defined(SNI_OPTION) sni_free( sni_info ); #endif diff --git a/3rdparty/mbedtls/mbedtls/programs/test/CMakeLists.txt b/3rdparty/mbedtls/mbedtls/programs/test/CMakeLists.txt index 0ed7145466..282ef58aaf 100644 --- a/3rdparty/mbedtls/mbedtls/programs/test/CMakeLists.txt +++ b/3rdparty/mbedtls/mbedtls/programs/test/CMakeLists.txt @@ -16,12 +16,21 @@ target_link_libraries(selftest ${libs}) add_executable(benchmark benchmark.c) target_link_libraries(benchmark ${libs}) -add_executable(ssl_cert_test ssl_cert_test.c) -target_link_libraries(ssl_cert_test ${libs}) +if(TEST_CPP) + add_executable(cpp_dummy_build cpp_dummy_build.cpp) + target_link_libraries(cpp_dummy_build ${libs}) +endif() add_executable(udp_proxy udp_proxy.c) target_link_libraries(udp_proxy ${libs}) -install(TARGETS selftest benchmark ssl_cert_test udp_proxy +add_executable(zeroize zeroize.c) +target_link_libraries(zeroize ${libs}) + +add_executable(query_compile_time_config query_compile_time_config.c) +target_sources(query_compile_time_config PUBLIC ../ssl/query_config.c) +target_link_libraries(query_compile_time_config ${libs}) + +install(TARGETS selftest benchmark udp_proxy query_compile_time_config DESTINATION "bin" PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/3rdparty/mbedtls/mbedtls/programs/test/benchmark.c b/3rdparty/mbedtls/mbedtls/programs/test/benchmark.c index 20e3c2e391..e31faafeb3 100644 --- a/3rdparty/mbedtls/mbedtls/programs/test/benchmark.c +++ b/3rdparty/mbedtls/mbedtls/programs/test/benchmark.c @@ -29,10 +29,14 @@ #include "mbedtls/platform.h" #else #include +#include #define mbedtls_exit exit #define mbedtls_printf printf #define mbedtls_snprintf snprintf #define mbedtls_free free +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #if !defined(MBEDTLS_TIMING_C) @@ -54,21 +58,29 @@ int main( void ) #include "mbedtls/sha1.h" #include "mbedtls/sha256.h" #include "mbedtls/sha512.h" + #include "mbedtls/arc4.h" #include "mbedtls/des.h" #include "mbedtls/aes.h" +#include "mbedtls/aria.h" #include "mbedtls/blowfish.h" #include "mbedtls/camellia.h" +#include "mbedtls/chacha20.h" #include "mbedtls/gcm.h" #include "mbedtls/ccm.h" +#include "mbedtls/chachapoly.h" #include "mbedtls/cmac.h" +#include "mbedtls/poly1305.h" + #include "mbedtls/havege.h" #include "mbedtls/ctr_drbg.h" #include "mbedtls/hmac_drbg.h" + #include "mbedtls/rsa.h" #include "mbedtls/dhm.h" #include "mbedtls/ecdsa.h" #include "mbedtls/ecdh.h" + #include "mbedtls/error.h" #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) @@ -93,8 +105,9 @@ int main( void ) #define OPTIONS \ "md4, md5, ripemd160, sha1, sha256, sha512,\n" \ - "arc4, des3, des, camellia, blowfish,\n" \ - "aes_cbc, aes_gcm, aes_ccm, aes_cmac, des3_cmac,\n" \ + "arc4, des3, des, camellia, blowfish, chacha20,\n" \ + "aes_cbc, aes_gcm, aes_ccm, aes_ctx, chachapoly,\n" \ + "aes_cmac, des3_cmac, poly1305\n" \ "havege, ctr_drbg, hmac_drbg\n" \ "rsa, dhm, ecdsa, ecdh.\n" @@ -110,25 +123,34 @@ int main( void ) #define TIME_AND_TSC( TITLE, CODE ) \ do { \ unsigned long ii, jj, tsc; \ + int ret = 0; \ \ mbedtls_printf( HEADER_FORMAT, TITLE ); \ fflush( stdout ); \ \ mbedtls_set_alarm( 1 ); \ - for( ii = 1; ! mbedtls_timing_alarmed; ii++ ) \ + for( ii = 1; ret == 0 && ! mbedtls_timing_alarmed; ii++ ) \ { \ - CODE; \ + ret = CODE; \ } \ \ tsc = mbedtls_timing_hardclock(); \ - for( jj = 0; jj < 1024; jj++ ) \ + for( jj = 0; ret == 0 && jj < 1024; jj++ ) \ { \ - CODE; \ + ret = CODE; \ } \ \ - mbedtls_printf( "%9lu KiB/s, %9lu cycles/byte\n", \ - ii * BUFSIZE / 1024, \ - ( mbedtls_timing_hardclock() - tsc ) / ( jj * BUFSIZE ) ); \ + if( ret != 0 ) \ + { \ + PRINT_ERROR; \ + } \ + else \ + { \ + mbedtls_printf( "%9lu KiB/s, %9lu cycles/byte\n", \ + ii * BUFSIZE / 1024, \ + ( mbedtls_timing_hardclock() - tsc ) \ + / ( jj * BUFSIZE ) ); \ + } \ } while( 0 ) #if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG) @@ -141,7 +163,7 @@ do { \ #define MEMORY_MEASURE_PRINT( title_len ) \ mbedtls_memory_buffer_alloc_max_get( &max_used, &max_blocks ); \ - for( ii = 12 - title_len; ii != 0; ii-- ) mbedtls_printf( " " ); \ + for( ii = 12 - (title_len); ii != 0; ii-- ) mbedtls_printf( " " ); \ max_used -= prv_used; \ max_blocks -= prv_blocks; \ max_bytes = max_used + MEM_BLOCK_OVERHEAD * max_blocks; \ @@ -228,12 +250,26 @@ unsigned char buf[BUFSIZE]; typedef struct { char md4, md5, ripemd160, sha1, sha256, sha512, arc4, des3, des, - aes_cbc, aes_gcm, aes_ccm, aes_cmac, des3_cmac, - camellia, blowfish, + aes_cbc, aes_gcm, aes_ccm, aes_xts, chachapoly, + aes_cmac, des3_cmac, + aria, camellia, blowfish, chacha20, + poly1305, havege, ctr_drbg, hmac_drbg, rsa, dhm, ecdsa, ecdh; } todo_list; +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + int main( int argc, char *argv[] ) { int i; @@ -274,18 +310,28 @@ int main( int argc, char *argv[] ) todo.des = 1; else if( strcmp( argv[i], "aes_cbc" ) == 0 ) todo.aes_cbc = 1; + else if( strcmp( argv[i], "aes_xts" ) == 0 ) + todo.aes_xts = 1; else if( strcmp( argv[i], "aes_gcm" ) == 0 ) todo.aes_gcm = 1; else if( strcmp( argv[i], "aes_ccm" ) == 0 ) todo.aes_ccm = 1; + else if( strcmp( argv[i], "chachapoly" ) == 0 ) + todo.chachapoly = 1; else if( strcmp( argv[i], "aes_cmac" ) == 0 ) todo.aes_cmac = 1; else if( strcmp( argv[i], "des3_cmac" ) == 0 ) todo.des3_cmac = 1; + else if( strcmp( argv[i], "aria" ) == 0 ) + todo.aria = 1; else if( strcmp( argv[i], "camellia" ) == 0 ) todo.camellia = 1; else if( strcmp( argv[i], "blowfish" ) == 0 ) todo.blowfish = 1; + else if( strcmp( argv[i], "chacha20" ) == 0 ) + todo.chacha20 = 1; + else if( strcmp( argv[i], "poly1305" ) == 0 ) + todo.poly1305 = 1; else if( strcmp( argv[i], "havege" ) == 0 ) todo.havege = 1; else if( strcmp( argv[i], "ctr_drbg" ) == 0 ) @@ -419,6 +465,29 @@ int main( int argc, char *argv[] ) mbedtls_aes_free( &aes ); } #endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + if( todo.aes_xts ) + { + int keysize; + mbedtls_aes_xts_context ctx; + + mbedtls_aes_xts_init( &ctx ); + for( keysize = 128; keysize <= 256; keysize += 128 ) + { + mbedtls_snprintf( title, sizeof( title ), "AES-XTS-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_aes_xts_setkey_enc( &ctx, tmp, keysize * 2 ); + + TIME_AND_TSC( title, + mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, BUFSIZE, + tmp, buf, buf ) ); + + mbedtls_aes_xts_free( &ctx ); + } + } +#endif #if defined(MBEDTLS_GCM_C) if( todo.aes_gcm ) { @@ -465,6 +534,26 @@ int main( int argc, char *argv[] ) } } #endif +#if defined(MBEDTLS_CHACHAPOLY_C) + if( todo.chachapoly ) + { + mbedtls_chachapoly_context chachapoly; + + mbedtls_chachapoly_init( &chachapoly ); + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + + mbedtls_snprintf( title, sizeof( title ), "ChaCha20-Poly1305" ); + + mbedtls_chachapoly_setkey( &chachapoly, tmp ); + + TIME_AND_TSC( title, + mbedtls_chachapoly_encrypt_and_tag( &chachapoly, + BUFSIZE, tmp, NULL, 0, buf, buf, tmp ) ); + + mbedtls_chachapoly_free( &chachapoly ); + } +#endif #if defined(MBEDTLS_CMAC_C) if( todo.aes_cmac ) { @@ -498,6 +587,28 @@ int main( int argc, char *argv[] ) #endif /* MBEDTLS_CMAC_C */ #endif /* MBEDTLS_AES_C */ +#if defined(MBEDTLS_ARIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC) + if( todo.aria ) + { + int keysize; + mbedtls_aria_context aria; + mbedtls_aria_init( &aria ); + for( keysize = 128; keysize <= 256; keysize += 64 ) + { + mbedtls_snprintf( title, sizeof( title ), "ARIA-CBC-%d", keysize ); + + memset( buf, 0, sizeof( buf ) ); + memset( tmp, 0, sizeof( tmp ) ); + mbedtls_aria_setkey_enc( &aria, tmp, keysize ); + + TIME_AND_TSC( title, + mbedtls_aria_crypt_cbc( &aria, MBEDTLS_ARIA_ENCRYPT, + BUFSIZE, tmp, buf, buf ) ); + } + mbedtls_aria_free( &aria ); + } +#endif + #if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC) if( todo.camellia ) { @@ -520,6 +631,20 @@ int main( int argc, char *argv[] ) } #endif +#if defined(MBEDTLS_CHACHA20_C) + if ( todo.chacha20 ) + { + TIME_AND_TSC( "ChaCha20", mbedtls_chacha20_crypt( buf, buf, 0U, BUFSIZE, buf, buf ) ); + } +#endif + +#if defined(MBEDTLS_POLY1305_C) + if ( todo.poly1305 ) + { + TIME_AND_TSC( "Poly1305", mbedtls_poly1305_mac( buf, buf, BUFSIZE, buf ) ); + } +#endif + #if defined(MBEDTLS_BLOWFISH_C) && defined(MBEDTLS_CIPHER_MODE_CBC) if( todo.blowfish ) { @@ -564,15 +689,13 @@ int main( int argc, char *argv[] ) if( mbedtls_ctr_drbg_seed( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) mbedtls_exit(1); TIME_AND_TSC( "CTR_DRBG (NOPR)", - if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); + mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) ); if( mbedtls_ctr_drbg_seed( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) mbedtls_exit(1); mbedtls_ctr_drbg_set_prediction_resistance( &ctr_drbg, MBEDTLS_CTR_DRBG_PR_ON ); TIME_AND_TSC( "CTR_DRBG (PR)", - if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); + mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) ); mbedtls_ctr_drbg_free( &ctr_drbg ); } #endif @@ -592,16 +715,14 @@ int main( int argc, char *argv[] ) if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) mbedtls_exit(1); TIME_AND_TSC( "HMAC_DRBG SHA-1 (NOPR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); + mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) ); if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) mbedtls_exit(1); mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg, MBEDTLS_HMAC_DRBG_PR_ON ); TIME_AND_TSC( "HMAC_DRBG SHA-1 (PR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); + mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) ); #endif #if defined(MBEDTLS_SHA256_C) @@ -611,16 +732,14 @@ int main( int argc, char *argv[] ) if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) mbedtls_exit(1); TIME_AND_TSC( "HMAC_DRBG SHA-256 (NOPR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); + mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) ); if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) mbedtls_exit(1); mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg, MBEDTLS_HMAC_DRBG_PR_ON ); TIME_AND_TSC( "HMAC_DRBG SHA-256 (PR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); + mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) ); #endif mbedtls_hmac_drbg_free( &hmac_drbg ); } @@ -759,13 +878,20 @@ int main( int argc, char *argv[] ) } #endif -#if defined(MBEDTLS_ECDH_C) +#if defined(MBEDTLS_ECDH_C) && defined(MBEDTLS_ECDH_LEGACY_CONTEXT) if( todo.ecdh ) { mbedtls_ecdh_context ecdh; -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) mbedtls_mpi z; + const mbedtls_ecp_curve_info montgomery_curve_list[] = { +#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) + { MBEDTLS_ECP_DP_CURVE25519, 0, 0, "Curve25519" }, +#endif +#if defined(MBEDTLS_ECP_DP_CURVE448_ENABLED) + { MBEDTLS_ECP_DP_CURVE448, 0, 0, "Curve448" }, #endif + { MBEDTLS_ECP_DP_NONE, 0, 0, 0 } + }; const mbedtls_ecp_curve_info *curve_info; size_t olen; @@ -794,26 +920,31 @@ int main( int argc, char *argv[] ) mbedtls_ecdh_free( &ecdh ); } - /* Curve25519 needs to be handled separately */ -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - mbedtls_ecdh_init( &ecdh ); - mbedtls_mpi_init( &z ); - - if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || - mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 ) + /* Montgomery curves need to be handled separately */ + for ( curve_info = montgomery_curve_list; + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++ ) { - mbedtls_exit( 1 ); - } + mbedtls_ecdh_init( &ecdh ); + mbedtls_mpi_init( &z ); - TIME_PUBLIC( "ECDHE-Curve25519", "handshake", - ret |= mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, - myrand, NULL ); - ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, - myrand, NULL ) ); + if( mbedtls_ecp_group_load( &ecdh.grp, curve_info->grp_id ) != 0 || + mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 ) + { + mbedtls_exit( 1 ); + } - mbedtls_ecdh_free( &ecdh ); - mbedtls_mpi_free( &z ); -#endif + mbedtls_snprintf( title, sizeof(title), "ECDHE-%s", + curve_info->name ); + TIME_PUBLIC( title, "handshake", + ret |= mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, + myrand, NULL ); + ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, + myrand, NULL ) ); + + mbedtls_ecdh_free( &ecdh ); + mbedtls_mpi_free( &z ); + } for( curve_info = mbedtls_ecp_curve_list(); curve_info->grp_id != MBEDTLS_ECP_DP_NONE; @@ -840,26 +971,31 @@ int main( int argc, char *argv[] ) mbedtls_ecdh_free( &ecdh ); } - /* Curve25519 needs to be handled separately */ -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - mbedtls_ecdh_init( &ecdh ); - mbedtls_mpi_init( &z ); - - if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || - mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, - myrand, NULL ) != 0 || - mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 ) + /* Montgomery curves need to be handled separately */ + for ( curve_info = montgomery_curve_list; + curve_info->grp_id != MBEDTLS_ECP_DP_NONE; + curve_info++) { - mbedtls_exit( 1 ); - } + mbedtls_ecdh_init( &ecdh ); + mbedtls_mpi_init( &z ); - TIME_PUBLIC( "ECDH-Curve25519", "handshake", - ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, - myrand, NULL ) ); + if( mbedtls_ecp_group_load( &ecdh.grp, curve_info->grp_id ) != 0 || + mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, + myrand, NULL ) != 0 || + mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 ) + { + mbedtls_exit( 1 ); + } - mbedtls_ecdh_free( &ecdh ); - mbedtls_mpi_free( &z ); -#endif + mbedtls_snprintf( title, sizeof(title), "ECDH-%s", + curve_info->name ); + TIME_PUBLIC( title, "handshake", + ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, + myrand, NULL ) ); + + mbedtls_ecdh_free( &ecdh ); + mbedtls_mpi_free( &z ); + } } #endif diff --git a/3rdparty/mbedtls/mbedtls/programs/test/cpp_dummy_build.cpp b/3rdparty/mbedtls/mbedtls/programs/test/cpp_dummy_build.cpp new file mode 100644 index 0000000000..c652884046 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/programs/test/cpp_dummy_build.cpp @@ -0,0 +1,119 @@ +/* + * This program is a dummy C++ program to ensure Mbed TLS library header files + * can be included and built with a C++ compiler. + * + * Copyright (C) 2018, ARM Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "mbedtls/aes.h" +#include "mbedtls/aesni.h" +#include "mbedtls/arc4.h" +#include "mbedtls/aria.h" +#include "mbedtls/asn1.h" +#include "mbedtls/asn1write.h" +#include "mbedtls/base64.h" +#include "mbedtls/bignum.h" +#include "mbedtls/blowfish.h" +#include "mbedtls/bn_mul.h" +#include "mbedtls/camellia.h" +#include "mbedtls/ccm.h" +#include "mbedtls/certs.h" +#include "mbedtls/chacha20.h" +#include "mbedtls/chachapoly.h" +#include "mbedtls/check_config.h" +#include "mbedtls/cipher.h" +#include "mbedtls/cipher_internal.h" +#include "mbedtls/cmac.h" +#include "mbedtls/compat-1.3.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/debug.h" +#include "mbedtls/des.h" +#include "mbedtls/dhm.h" +#include "mbedtls/ecdh.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/ecjpake.h" +#include "mbedtls/ecp.h" +#include "mbedtls/ecp_internal.h" +#include "mbedtls/entropy.h" +#include "mbedtls/entropy_poll.h" +#include "mbedtls/error.h" +#include "mbedtls/gcm.h" +#include "mbedtls/havege.h" +#include "mbedtls/hkdf.h" +#include "mbedtls/hmac_drbg.h" +#include "mbedtls/md.h" +#include "mbedtls/md2.h" +#include "mbedtls/md4.h" +#include "mbedtls/md5.h" +#include "mbedtls/md_internal.h" +#include "mbedtls/net.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/nist_kw.h" +#include "mbedtls/oid.h" +#include "mbedtls/padlock.h" +#include "mbedtls/pem.h" +#include "mbedtls/pk.h" +#include "mbedtls/pk_internal.h" +#include "mbedtls/pkcs11.h" +#include "mbedtls/pkcs12.h" +#include "mbedtls/pkcs5.h" +#include "mbedtls/platform_time.h" +#include "mbedtls/platform_util.h" +#include "mbedtls/poly1305.h" +#include "mbedtls/ripemd160.h" +#include "mbedtls/rsa.h" +#include "mbedtls/rsa_internal.h" +#include "mbedtls/sha1.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_cache.h" +#include "mbedtls/ssl_ciphersuites.h" +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/ssl_internal.h" +#include "mbedtls/ssl_ticket.h" +#include "mbedtls/threading.h" +#include "mbedtls/timing.h" +#include "mbedtls/version.h" +#include "mbedtls/x509.h" +#include "mbedtls/x509_crl.h" +#include "mbedtls/x509_crt.h" +#include "mbedtls/x509_csr.h" +#include "mbedtls/xtea.h" + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#endif + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) +#include "mbedtls/memory_buffer_alloc.h" +#endif + +int main() +{ + mbedtls_platform_context *ctx = NULL; + mbedtls_platform_setup(ctx); + mbedtls_printf("CPP Build test\n"); + mbedtls_platform_teardown(ctx); +} diff --git a/3rdparty/mbedtls/mbedtls/programs/test/query_compile_time_config.c b/3rdparty/mbedtls/mbedtls/programs/test/query_compile_time_config.c new file mode 100644 index 0000000000..17becf27f1 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/programs/test/query_compile_time_config.c @@ -0,0 +1,56 @@ +/* + * Query the Mbed TLS compile time configuration + * + * Copyright (C) 2018, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#include +#define mbedtls_printf printf +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif + +#define USAGE \ + "usage: %s \n\n" \ + "This program takes one command line argument which corresponds to\n" \ + "the string representation of a Mbed TLS compile time configuration.\n" \ + "The value 0 will be returned if this configuration is defined in the\n" \ + "Mbed TLS build and the macro expansion of that configuration will be\n" \ + "printed (if any). Otherwise, 1 will be returned.\n" + +int query_config( const char *config ); + +int main( int argc, char *argv[] ) +{ + if ( argc != 2 ) + { + mbedtls_printf( USAGE, argv[0] ); + return( MBEDTLS_EXIT_FAILURE ); + } + + return( query_config( argv[1] ) ); +} diff --git a/3rdparty/mbedtls/mbedtls/programs/test/selftest.c b/3rdparty/mbedtls/mbedtls/programs/test/selftest.c index 72a37342fd..9d3ea7ec0a 100644 --- a/3rdparty/mbedtls/mbedtls/programs/test/selftest.c +++ b/3rdparty/mbedtls/mbedtls/programs/test/selftest.c @@ -44,6 +44,10 @@ #include "mbedtls/des.h" #include "mbedtls/aes.h" #include "mbedtls/camellia.h" +#include "mbedtls/aria.h" +#include "mbedtls/chacha20.h" +#include "mbedtls/poly1305.h" +#include "mbedtls/chachapoly.h" #include "mbedtls/base64.h" #include "mbedtls/bignum.h" #include "mbedtls/rsa.h" @@ -53,6 +57,7 @@ #include "mbedtls/ecp.h" #include "mbedtls/ecjpake.h" #include "mbedtls/timing.h" +#include "mbedtls/nist_kw.h" #include @@ -72,6 +77,18 @@ #include "mbedtls/memory_buffer_alloc.h" #endif +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret ) { int ret; @@ -204,9 +221,21 @@ const selftest_t selftests[] = #if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C) {"ccm", mbedtls_ccm_self_test}, #endif +#if defined(MBEDTLS_NIST_KW_C) && defined(MBEDTLS_AES_C) + {"nist_kw", mbedtls_nist_kw_self_test}, +#endif #if defined(MBEDTLS_CMAC_C) {"cmac", mbedtls_cmac_self_test}, #endif +#if defined(MBEDTLS_CHACHA20_C) + {"chacha20", mbedtls_chacha20_self_test}, +#endif +#if defined(MBEDTLS_POLY1305_C) + {"poly1305", mbedtls_poly1305_self_test}, +#endif +#if defined(MBEDTLS_CHACHAPOLY_C) + {"chacha20-poly1305", mbedtls_chachapoly_self_test}, +#endif #if defined(MBEDTLS_BASE64_C) {"base64", mbedtls_base64_self_test}, #endif @@ -225,6 +254,9 @@ const selftest_t selftests[] = #if defined(MBEDTLS_CAMELLIA_C) {"camellia", mbedtls_camellia_self_test}, #endif +#if defined(MBEDTLS_ARIA_C) + {"aria", mbedtls_aria_self_test}, +#endif #if defined(MBEDTLS_CTR_DRBG_C) {"ctr_drbg", mbedtls_ctr_drbg_self_test}, #endif diff --git a/3rdparty/mbedtls/mbedtls/programs/test/ssl_cert_test.c b/3rdparty/mbedtls/mbedtls/programs/test/ssl_cert_test.c deleted file mode 100644 index fd3526f7fe..0000000000 --- a/3rdparty/mbedtls/mbedtls/programs/test/ssl_cert_test.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - * SSL certificate functionality tests - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#if !defined(MBEDTLS_CONFIG_FILE) -#include "mbedtls/config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#include -#define mbedtls_snprintf snprintf -#define mbedtls_printf printf -#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS -#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE -#endif /* MBEDTLS_PLATFORM_C */ - -#if defined(MBEDTLS_RSA_C) && defined(MBEDTLS_X509_CRT_PARSE_C) && \ - defined(MBEDTLS_FS_IO) && defined(MBEDTLS_X509_CRL_PARSE_C) -#include "mbedtls/certs.h" -#include "mbedtls/x509_crt.h" - -#include -#include -#endif - -#define MAX_CLIENT_CERTS 8 - -#if !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_X509_CRT_PARSE_C) || \ - !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_X509_CRL_PARSE_C) -int main( void ) -{ - mbedtls_printf("MBEDTLS_RSA_C and/or MBEDTLS_X509_CRT_PARSE_C " - "MBEDTLS_FS_IO and/or MBEDTLS_X509_CRL_PARSE_C " - "not defined.\n"); - return( 0 ); -} -#else -const char *client_certificates[MAX_CLIENT_CERTS] = -{ - "client1.crt", - "client2.crt", - "server1.crt", - "server2.crt", - "cert_sha224.crt", - "cert_sha256.crt", - "cert_sha384.crt", - "cert_sha512.crt" -}; - -const char *client_private_keys[MAX_CLIENT_CERTS] = -{ - "client1.key", - "client2.key", - "server1.key", - "server2.key", - "cert_digest.key", - "cert_digest.key", - "cert_digest.key", - "cert_digest.key" -}; - -int main( void ) -{ - int ret = 1, i; - int exit_code = MBEDTLS_EXIT_FAILURE; - mbedtls_x509_crt cacert; - mbedtls_x509_crl crl; - char buf[10240]; - - mbedtls_x509_crt_init( &cacert ); - mbedtls_x509_crl_init( &crl ); - - /* - * 1.1. Load the trusted CA - */ - mbedtls_printf( "\n . Loading the CA root certificate ..." ); - fflush( stdout ); - - /* - * Alternatively, you may load the CA certificates from a .pem or - * .crt file by calling mbedtls_x509_crt_parse_file( &cacert, "myca.crt" ). - */ - ret = mbedtls_x509_crt_parse_file( &cacert, "ssl/test-ca/test-ca.crt" ); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned %d\n\n", ret ); - goto exit; - } - - mbedtls_printf( " ok\n" ); - - mbedtls_x509_crt_info( buf, 1024, "CRT: ", &cacert ); - mbedtls_printf("%s\n", buf ); - - /* - * 1.2. Load the CRL - */ - mbedtls_printf( " . Loading the CRL ..." ); - fflush( stdout ); - - ret = mbedtls_x509_crl_parse_file( &crl, "ssl/test-ca/crl.pem" ); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_x509_crl_parse_file returned %d\n\n", ret ); - goto exit; - } - - mbedtls_printf( " ok\n" ); - - mbedtls_x509_crl_info( buf, 1024, "CRL: ", &crl ); - mbedtls_printf("%s\n", buf ); - - for( i = 0; i < MAX_CLIENT_CERTS; i++ ) - { - /* - * 1.3. Load own certificate - */ - char name[512]; - uint32_t flags; - mbedtls_x509_crt clicert; - mbedtls_pk_context pk; - - mbedtls_x509_crt_init( &clicert ); - mbedtls_pk_init( &pk ); - - mbedtls_snprintf(name, 512, "ssl/test-ca/%s", client_certificates[i]); - - mbedtls_printf( " . Loading the client certificate %s...", name ); - fflush( stdout ); - - ret = mbedtls_x509_crt_parse_file( &clicert, name ); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_x509_crt_parse_file returned %d\n\n", ret ); - goto exit; - } - - mbedtls_printf( " ok\n" ); - - /* - * 1.4. Verify certificate validity with CA certificate - */ - mbedtls_printf( " . Verify the client certificate with CA certificate..." ); - fflush( stdout ); - - ret = mbedtls_x509_crt_verify( &clicert, &cacert, &crl, NULL, &flags, NULL, - NULL ); - if( ret != 0 ) - { - if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED ) - { - char vrfy_buf[512]; - - mbedtls_printf( " failed\n" ); - mbedtls_x509_crt_verify_info( vrfy_buf, sizeof( vrfy_buf ), " ! ", flags ); - mbedtls_printf( "%s\n", vrfy_buf ); - } - else - { - mbedtls_printf( " failed\n ! mbedtls_x509_crt_verify returned %d\n\n", ret ); - goto exit; - } - } - - mbedtls_printf( " ok\n" ); - - /* - * 1.5. Load own private key - */ - mbedtls_snprintf(name, 512, "ssl/test-ca/%s", client_private_keys[i]); - - mbedtls_printf( " . Loading the client private key %s...", name ); - fflush( stdout ); - - ret = mbedtls_pk_parse_keyfile( &pk, name, NULL ); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned %d\n\n", ret ); - goto exit; - } - - mbedtls_printf( " ok\n" ); - - /* - * 1.6. Verify certificate validity with private key - */ - mbedtls_printf( " . Verify the client certificate with private key..." ); - fflush( stdout ); - - - /* EC NOT IMPLEMENTED YET */ - if( ! mbedtls_pk_can_do( &clicert.pk, MBEDTLS_PK_RSA ) ) - { - mbedtls_printf( " failed\n ! certificate's key is not RSA\n\n" ); - goto exit; - } - - ret = mbedtls_mpi_cmp_mpi(&mbedtls_pk_rsa( pk )->N, &mbedtls_pk_rsa( clicert.pk )->N); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_mpi_cmp_mpi for N returned %d\n\n", ret ); - goto exit; - } - - ret = mbedtls_mpi_cmp_mpi(&mbedtls_pk_rsa( pk )->E, &mbedtls_pk_rsa( clicert.pk )->E); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_mpi_cmp_mpi for E returned %d\n\n", ret ); - goto exit; - } - - ret = mbedtls_rsa_check_privkey( mbedtls_pk_rsa( pk ) ); - if( ret != 0 ) - { - mbedtls_printf( " failed\n ! mbedtls_rsa_check_privkey returned %d\n\n", ret ); - goto exit; - } - - mbedtls_printf( " ok\n" ); - - mbedtls_x509_crt_free( &clicert ); - mbedtls_pk_free( &pk ); - } - - exit_code = MBEDTLS_EXIT_SUCCESS; - -exit: - mbedtls_x509_crt_free( &cacert ); - mbedtls_x509_crl_free( &crl ); - -#if defined(_WIN32) - mbedtls_printf( " + Press Enter to exit this program.\n" ); - fflush( stdout ); getchar(); -#endif - - return( exit_code ); -} -#endif /* MBEDTLS_RSA_C && MBEDTLS_X509_CRT_PARSE_C && MBEDTLS_FS_IO && - MBEDTLS_X509_CRL_PARSE_C */ diff --git a/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy.c b/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy.c index 1865b0f1b9..e96e91bf56 100644 --- a/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy.c +++ b/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy.c @@ -40,6 +40,8 @@ #define mbedtls_time time #define mbedtls_time_t time_t #define mbedtls_printf printf +#define mbedtls_calloc calloc +#define mbedtls_free free #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -55,6 +57,7 @@ int main( void ) #include "mbedtls/net_sockets.h" #include "mbedtls/error.h" #include "mbedtls/ssl.h" +#include "mbedtls/timing.h" #include @@ -76,17 +79,21 @@ int main( void ) #include #endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ -/* For gettimeofday() */ -#if !defined(_WIN32) -#include -#endif - #define MAX_MSG_SIZE 16384 + 2048 /* max record/datagram size */ #define DFL_SERVER_ADDR "localhost" #define DFL_SERVER_PORT "4433" #define DFL_LISTEN_ADDR "localhost" #define DFL_LISTEN_PORT "5556" +#define DFL_PACK 0 + +#if defined(MBEDTLS_TIMING_C) +#define USAGE_PACK \ + " pack=%%d default: 0 (don't pack)\n" \ + " options: t > 0 (pack for t milliseconds)\n" +#else +#define USAGE_PACK +#endif #define USAGE \ "\n usage: udp_proxy param=<>...\n" \ @@ -101,20 +108,39 @@ int main( void ) " delay=%%d default: 0 (no delayed packets)\n" \ " delay about 1:N packets randomly\n" \ " delay_ccs=0/1 default: 0 (don't delay ChangeCipherSpec)\n" \ + " delay_cli=%%s Handshake message from client that should be\n"\ + " delayed. Possible values are 'ClientHello',\n" \ + " 'Certificate', 'CertificateVerify', and\n" \ + " 'ClientKeyExchange'.\n" \ + " May be used multiple times, even for the same\n"\ + " message, in which case the respective message\n"\ + " gets delayed multiple times.\n" \ + " delay_srv=%%s Handshake message from server that should be\n"\ + " delayed. Possible values are 'HelloRequest',\n"\ + " 'ServerHello', 'ServerHelloDone', 'Certificate'\n"\ + " 'ServerKeyExchange', 'NewSessionTicket',\n"\ + " 'HelloVerifyRequest' and ''CertificateRequest'.\n"\ + " May be used multiple times, even for the same\n"\ + " message, in which case the respective message\n"\ + " gets delayed multiple times.\n" \ " drop=%%d default: 0 (no dropped packets)\n" \ " drop about 1:N packets randomly\n" \ " mtu=%%d default: 0 (unlimited)\n" \ " drop packets larger than N bytes\n" \ " bad_ad=0/1 default: 0 (don't add bad ApplicationData)\n" \ " protect_hvr=0/1 default: 0 (don't protect HelloVerifyRequest)\n" \ - " protect_len=%%d default: (don't protect packets of this size)\n" \ + " protect_len=%%d default: (don't protect packets of this size)\n" \ "\n" \ " seed=%%d default: (use current time)\n" \ + USAGE_PACK \ "\n" /* * global options */ + +#define MAX_DELAYED_HS 10 + static struct options { const char *server_addr; /* address to forward packets to */ @@ -125,12 +151,19 @@ static struct options int duplicate; /* duplicate 1 in N packets (none if 0) */ int delay; /* delay 1 packet in N (none if 0) */ int delay_ccs; /* delay ChangeCipherSpec */ + char* delay_cli[MAX_DELAYED_HS]; /* handshake types of messages from + * client that should be delayed. */ + uint8_t delay_cli_cnt; /* Number of entries in delay_cli. */ + char* delay_srv[MAX_DELAYED_HS]; /* handshake types of messages from + * server that should be delayed. */ + uint8_t delay_srv_cnt; /* Number of entries in delay_srv. */ int drop; /* drop 1 packet in N (none if 0) */ int mtu; /* drop packets larger than this */ int bad_ad; /* inject corrupted ApplicationData record */ int protect_hvr; /* never drop or delay HelloVerifyRequest */ int protect_len; /* never drop/delay packet of the given size*/ - + unsigned pack; /* merge packets into single datagram for + * at most \c merge milliseconds if > 0 */ unsigned int seed; /* seed for "random" events */ } opt; @@ -154,8 +187,14 @@ static void get_options( int argc, char *argv[] ) opt.server_port = DFL_SERVER_PORT; opt.listen_addr = DFL_LISTEN_ADDR; opt.listen_port = DFL_LISTEN_PORT; + opt.pack = DFL_PACK; /* Other members default to 0 */ + opt.delay_cli_cnt = 0; + opt.delay_srv_cnt = 0; + memset( opt.delay_cli, 0, sizeof( opt.delay_cli ) ); + memset( opt.delay_srv, 0, sizeof( opt.delay_srv ) ); + for( i = 1; i < argc; i++ ) { p = argv[i]; @@ -189,12 +228,58 @@ static void get_options( int argc, char *argv[] ) if( opt.delay_ccs < 0 || opt.delay_ccs > 1 ) exit_usage( p, q ); } + else if( strcmp( p, "delay_cli" ) == 0 || + strcmp( p, "delay_srv" ) == 0 ) + { + uint8_t *delay_cnt; + char **delay_list; + size_t len; + char *buf; + + if( strcmp( p, "delay_cli" ) == 0 ) + { + delay_cnt = &opt.delay_cli_cnt; + delay_list = opt.delay_cli; + } + else + { + delay_cnt = &opt.delay_srv_cnt; + delay_list = opt.delay_srv; + } + + if( *delay_cnt == MAX_DELAYED_HS ) + { + mbedtls_printf( " too many uses of %s: only %d allowed\n", + p, MAX_DELAYED_HS ); + exit_usage( p, NULL ); + } + + len = strlen( q ); + buf = mbedtls_calloc( 1, len + 1 ); + if( buf == NULL ) + { + mbedtls_printf( " Allocation failure\n" ); + exit( 1 ); + } + memcpy( buf, q, len + 1 ); + + delay_list[ (*delay_cnt)++ ] = buf; + } else if( strcmp( p, "drop" ) == 0 ) { opt.drop = atoi( q ); if( opt.drop < 0 || opt.drop > 20 || opt.drop == 1 ) exit_usage( p, q ); } + else if( strcmp( p, "pack" ) == 0 ) + { +#if defined(MBEDTLS_TIMING_C) + opt.pack = (unsigned) atoi( q ); +#else + mbedtls_printf( " option pack only defined if MBEDTLS_TIMING_C is enabled\n" ); + exit( 1 ); +#endif + } else if( strcmp( p, "mtu" ) == 0 ) { opt.mtu = atoi( q ); @@ -269,25 +354,122 @@ static const char *msg_type( unsigned char *msg, size_t len ) } } +#if defined(MBEDTLS_TIMING_C) /* Return elapsed time in milliseconds since the first call */ -static unsigned long ellapsed_time( void ) +static unsigned ellapsed_time( void ) { -#if defined(_WIN32) - return( 0 ); -#else - static struct timeval ref = { 0, 0 }; - struct timeval now; + static int initialized = 0; + static struct mbedtls_timing_hr_time hires; - if( ref.tv_sec == 0 && ref.tv_usec == 0 ) + if( initialized == 0 ) { - gettimeofday( &ref, NULL ); + (void) mbedtls_timing_get_timer( &hires, 1 ); + initialized = 1; return( 0 ); } - gettimeofday( &now, NULL ); - return( 1000 * ( now.tv_sec - ref.tv_sec ) - + ( now.tv_usec - ref.tv_usec ) / 1000 ); -#endif + return( mbedtls_timing_get_timer( &hires, 0 ) ); +} + +typedef struct +{ + mbedtls_net_context *ctx; + + const char *description; + + unsigned packet_lifetime; + unsigned num_datagrams; + + unsigned char data[MAX_MSG_SIZE]; + size_t len; + +} ctx_buffer; + +static ctx_buffer outbuf[2]; + +static int ctx_buffer_flush( ctx_buffer *buf ) +{ + int ret; + + mbedtls_printf( " %05u flush %s: %u bytes, %u datagrams, last %u ms\n", + ellapsed_time(), buf->description, + (unsigned) buf->len, buf->num_datagrams, + ellapsed_time() - buf->packet_lifetime ); + + ret = mbedtls_net_send( buf->ctx, buf->data, buf->len ); + + buf->len = 0; + buf->num_datagrams = 0; + + return( ret ); +} + +static unsigned ctx_buffer_time_remaining( ctx_buffer *buf ) +{ + unsigned const cur_time = ellapsed_time(); + + if( buf->num_datagrams == 0 ) + return( (unsigned) -1 ); + + if( cur_time - buf->packet_lifetime >= opt.pack ) + return( 0 ); + + return( opt.pack - ( cur_time - buf->packet_lifetime ) ); +} + +static int ctx_buffer_append( ctx_buffer *buf, + const unsigned char * data, + size_t len ) +{ + int ret; + + if( len > (size_t) INT_MAX ) + return( -1 ); + + if( len > sizeof( buf->data ) ) + { + mbedtls_printf( " ! buffer size %u too large (max %u)\n", + (unsigned) len, (unsigned) sizeof( buf->data ) ); + return( -1 ); + } + + if( sizeof( buf->data ) - buf->len < len ) + { + if( ( ret = ctx_buffer_flush( buf ) ) <= 0 ) + return( ret ); + } + + memcpy( buf->data + buf->len, data, len ); + + buf->len += len; + if( ++buf->num_datagrams == 1 ) + buf->packet_lifetime = ellapsed_time(); + + return( (int) len ); +} +#endif /* MBEDTLS_TIMING_C */ + +static int dispatch_data( mbedtls_net_context *ctx, + const unsigned char * data, + size_t len ) +{ +#if defined(MBEDTLS_TIMING_C) + ctx_buffer *buf = NULL; + if( opt.pack > 0 ) + { + if( outbuf[0].ctx == ctx ) + buf = &outbuf[0]; + else if( outbuf[1].ctx == ctx ) + buf = &outbuf[1]; + + if( buf == NULL ) + return( -1 ); + + return( ctx_buffer_append( buf, data, len ) ); + } +#endif /* MBEDTLS_TIMING_C */ + + return( mbedtls_net_send( ctx, data, len ) ); } typedef struct @@ -302,12 +484,22 @@ typedef struct /* Print packet. Outgoing packets come with a reason (forward, dupl, etc.) */ void print_packet( const packet *p, const char *why ) { +#if defined(MBEDTLS_TIMING_C) if( why == NULL ) - mbedtls_printf( " %05lu %s %s (%u bytes)\n", + mbedtls_printf( " %05u dispatch %s %s (%u bytes)\n", ellapsed_time(), p->way, p->type, p->len ); else - mbedtls_printf( " %s %s (%u bytes): %s\n", + mbedtls_printf( " %05u dispatch %s %s (%u bytes): %s\n", + ellapsed_time(), p->way, p->type, p->len, why ); +#else + if( why == NULL ) + mbedtls_printf( " dispatch %s %s (%u bytes)\n", + p->way, p->type, p->len ); + else + mbedtls_printf( " dispatch %s %s (%u bytes): %s\n", p->way, p->type, p->len, why ); +#endif + fflush( stdout ); } @@ -322,20 +514,28 @@ int send_packet( const packet *p, const char *why ) { unsigned char buf[MAX_MSG_SIZE]; memcpy( buf, p->buf, p->len ); - ++buf[p->len - 1]; - print_packet( p, "corrupted" ); - if( ( ret = mbedtls_net_send( dst, buf, p->len ) ) <= 0 ) + if( p->len <= 13 ) { - mbedtls_printf( " ! mbedtls_net_send returned %d\n", ret ); + mbedtls_printf( " ! can't corrupt empty AD record" ); + } + else + { + ++buf[13]; + print_packet( p, "corrupted" ); + } + + if( ( ret = dispatch_data( dst, buf, p->len ) ) <= 0 ) + { + mbedtls_printf( " ! dispatch returned %d\n", ret ); return( ret ); } } print_packet( p, why ); - if( ( ret = mbedtls_net_send( dst, p->buf, p->len ) ) <= 0 ) + if( ( ret = dispatch_data( dst, p->buf, p->len ) ) <= 0 ) { - mbedtls_printf( " ! mbedtls_net_send returned %d\n", ret ); + mbedtls_printf( " ! dispatch returned %d\n", ret ); return( ret ); } @@ -346,9 +546,9 @@ int send_packet( const packet *p, const char *why ) { print_packet( p, "duplicated" ); - if( ( ret = mbedtls_net_send( dst, p->buf, p->len ) ) <= 0 ) + if( ( ret = dispatch_data( dst, p->buf, p->len ) ) <= 0 ) { - mbedtls_printf( " ! mbedtls_net_send returned %d\n", ret ); + mbedtls_printf( " ! dispatch returned %d\n", ret ); return( ret ); } } @@ -356,11 +556,37 @@ int send_packet( const packet *p, const char *why ) return( 0 ); } -static packet prev; +#define MAX_DELAYED_MSG 5 +static size_t prev_len; +static packet prev[MAX_DELAYED_MSG]; void clear_pending( void ) { - memset( &prev, 0, sizeof( packet ) ); + memset( &prev, 0, sizeof( prev ) ); + prev_len = 0; +} + +void delay_packet( packet *delay ) +{ + if( prev_len == MAX_DELAYED_MSG ) + return; + + memcpy( &prev[prev_len++], delay, sizeof( packet ) ); +} + +int send_delayed() +{ + uint8_t offset; + int ret; + for( offset = 0; offset < prev_len; offset++ ) + { + ret = send_packet( &prev[offset], "delayed" ); + if( ret != 0 ) + return( ret ); + } + + clear_pending(); + return( 0 ); } /* @@ -372,32 +598,17 @@ void clear_pending( void ) static unsigned char dropped[2048] = { 0 }; #define DROP_MAX 2 -/* - * OpenSSL groups packets in a datagram the first time it sends them, but not - * when it resends them. Count every record as seen the first time. - */ +/* We only drop packets at the level of entire datagrams, not at the level + * of records. In particular, if the peer changes the way it packs multiple + * records into a single datagram, we don't necessarily count the number of + * times a record has been dropped correctly. However, the only known reason + * why a peer would change datagram packing is disabling the latter on + * retransmission, in which case we'd drop involved records at most + * DROP_MAX + 1 times. */ void update_dropped( const packet *p ) { size_t id = p->len % sizeof( dropped ); - const unsigned char *end = p->buf + p->len; - const unsigned char *cur = p->buf; - size_t len = ( ( cur[11] << 8 ) | cur[12] ) + 13; - ++dropped[id]; - - /* Avoid counting single record twice */ - if( len == p->len ) - return; - - while( cur < end ) - { - len = ( ( cur[11] << 8 ) | cur[12] ) + 13; - - id = len % sizeof( dropped ); - ++dropped[id]; - - cur += len; - } } int handle_message( const char *way, @@ -408,6 +619,10 @@ int handle_message( const char *way, packet cur; size_t id; + uint8_t delay_idx; + char ** delay_list; + uint8_t delay_list_len; + /* receive packet */ if( ( ret = mbedtls_net_recv( src, cur.buf, sizeof( cur.buf ) ) ) <= 0 ) { @@ -423,6 +638,37 @@ int handle_message( const char *way, id = cur.len % sizeof( dropped ); + if( strcmp( way, "S <- C" ) == 0 ) + { + delay_list = opt.delay_cli; + delay_list_len = opt.delay_cli_cnt; + } + else + { + delay_list = opt.delay_srv; + delay_list_len = opt.delay_srv_cnt; + } + + /* Check if message type is in the list of messages + * that should be delayed */ + for( delay_idx = 0; delay_idx < delay_list_len; delay_idx++ ) + { + if( delay_list[ delay_idx ] == NULL ) + continue; + + if( strcmp( delay_list[ delay_idx ], cur.type ) == 0 ) + { + /* Delay message */ + delay_packet( &cur ); + + /* Remove entry from list */ + mbedtls_free( delay_list[delay_idx] ); + delay_list[delay_idx] = NULL; + + return( 0 ); + } + } + /* do we want to drop, delay, or forward it? */ if( ( opt.mtu != 0 && cur.len > (unsigned) opt.mtu ) || @@ -442,12 +688,11 @@ int handle_message( const char *way, strcmp( cur.type, "ApplicationData" ) != 0 && ! ( opt.protect_hvr && strcmp( cur.type, "HelloVerifyRequest" ) == 0 ) && - prev.dst == NULL && cur.len != (size_t) opt.protect_len && dropped[id] < DROP_MAX && rand() % opt.delay == 0 ) ) { - memcpy( &prev, &cur, sizeof( packet ) ); + delay_packet( &cur ); } else { @@ -455,14 +700,10 @@ int handle_message( const char *way, if( ( ret = send_packet( &cur, "forwarded" ) ) != 0 ) return( ret ); - /* send previously delayed message if any */ - if( prev.dst != NULL ) - { - ret = send_packet( &prev, "delayed" ); - memset( &prev, 0, sizeof( packet ) ); - if( ret != 0 ) - return( ret ); - } + /* send previously delayed messages if any */ + ret = send_delayed(); + if( ret != 0 ) + return( ret ); } return( 0 ); @@ -472,9 +713,16 @@ int main( int argc, char *argv[] ) { int ret = 1; int exit_code = MBEDTLS_EXIT_FAILURE; + uint8_t delay_idx; mbedtls_net_context listen_fd, client_fd, server_fd; +#if defined( MBEDTLS_TIMING_C ) + struct timeval tm; +#endif + + struct timeval *tm_ptr = NULL; + int nb_fds; fd_set read_fds; @@ -563,14 +811,65 @@ int main( int argc, char *argv[] ) nb_fds = listen_fd.fd; ++nb_fds; +#if defined(MBEDTLS_TIMING_C) + if( opt.pack > 0 ) + { + outbuf[0].ctx = &server_fd; + outbuf[0].description = "S <- C"; + outbuf[0].num_datagrams = 0; + outbuf[0].len = 0; + + outbuf[1].ctx = &client_fd; + outbuf[1].description = "S -> C"; + outbuf[1].num_datagrams = 0; + outbuf[1].len = 0; + } +#endif /* MBEDTLS_TIMING_C */ + while( 1 ) { +#if defined(MBEDTLS_TIMING_C) + if( opt.pack > 0 ) + { + unsigned max_wait_server, max_wait_client, max_wait; + max_wait_server = ctx_buffer_time_remaining( &outbuf[0] ); + max_wait_client = ctx_buffer_time_remaining( &outbuf[1] ); + + max_wait = (unsigned) -1; + + if( max_wait_server == 0 ) + ctx_buffer_flush( &outbuf[0] ); + else + max_wait = max_wait_server; + + if( max_wait_client == 0 ) + ctx_buffer_flush( &outbuf[1] ); + else + { + if( max_wait_client < max_wait ) + max_wait = max_wait_client; + } + + if( max_wait != (unsigned) -1 ) + { + tm.tv_sec = max_wait / 1000; + tm.tv_usec = ( max_wait % 1000 ) * 1000; + + tm_ptr = &tm; + } + else + { + tm_ptr = NULL; + } + } +#endif /* MBEDTLS_TIMING_C */ + FD_ZERO( &read_fds ); FD_SET( server_fd.fd, &read_fds ); FD_SET( client_fd.fd, &read_fds ); FD_SET( listen_fd.fd, &read_fds ); - if( ( ret = select( nb_fds, &read_fds, NULL, NULL, NULL ) ) <= 0 ) + if( ( ret = select( nb_fds, &read_fds, NULL, NULL, tm_ptr ) ) < 0 ) { perror( "select" ); goto exit; @@ -592,6 +891,7 @@ int main( int argc, char *argv[] ) &client_fd, &server_fd ) ) != 0 ) goto accept; } + } exit_code = MBEDTLS_EXIT_SUCCESS; @@ -608,6 +908,12 @@ int main( int argc, char *argv[] ) } #endif + for( delay_idx = 0; delay_idx < MAX_DELAYED_HS; delay_idx++ ) + { + mbedtls_free( opt.delay_cli + delay_idx ); + mbedtls_free( opt.delay_srv + delay_idx ); + } + mbedtls_net_free( &client_fd ); mbedtls_net_free( &server_fd ); mbedtls_net_free( &listen_fd ); diff --git a/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy_wrapper.sh b/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy_wrapper.sh new file mode 100755 index 0000000000..29033d5d17 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/programs/test/udp_proxy_wrapper.sh @@ -0,0 +1,117 @@ +#!/bin/sh +# -*-sh-basic-offset: 4-*- +# Usage: udp_proxy_wrapper.sh [PROXY_PARAM...] -- [SERVER_PARAM...] + +set -u + +MBEDTLS_BASE="$(dirname -- "$0")/../.." +TPXY_BIN="$MBEDTLS_BASE/programs/test/udp_proxy" +SRV_BIN="$MBEDTLS_BASE/programs/ssl/ssl_server2" + +: ${VERBOSE:=0} + +stop_proxy() { + if [ -n "${tpxy_pid:-}" ]; then + echo + echo " * Killing proxy (pid $tpxy_pid) ..." + kill $tpxy_pid + fi +} + +stop_server() { + if [ -n "${srv_pid:-}" ]; then + echo + echo " * Killing server (pid $srv_pid) ..." + kill $srv_pid >/dev/null 2>/dev/null + fi +} + +cleanup() { + stop_server + stop_proxy + exit 129 +} + +trap cleanup INT TERM HUP + +# Extract the proxy parameters +tpxy_cmd_snippet='"$TPXY_BIN"' +while [ $# -ne 0 ] && [ "$1" != "--" ]; do + tail="$1" quoted="" + while [ -n "$tail" ]; do + case "$tail" in + *\'*) quoted="${quoted}${tail%%\'*}'\\''" tail="${tail#*\'}";; + *) quoted="${quoted}${tail}"; tail=; false;; + esac + done + tpxy_cmd_snippet="$tpxy_cmd_snippet '$quoted'" + shift +done +unset tail quoted +if [ $# -eq 0 ]; then + echo " * No server arguments (must be preceded by \" -- \") - exit" + exit 3 +fi +shift + +dtls_enabled= +ipv6_in_use= +server_port_orig= +server_addr_orig= +for param; do + case "$param" in + server_port=*) server_port_orig="${param#*=}";; + server_addr=*:*) server_addr_orig="${param#*=}"; ipv6_in_use=1;; + server_addr=*) server_addr_orig="${param#*=}";; + dtls=[!0]*) dtls_enabled=1;; + esac +done + +if [ -z "$dtls_enabled" ] || [ -n "$ipv6_in_use" ]; then + echo >&2 "$0: Couldn't find DTLS enabling, or IPv6 is in use - immediate fallback to server application..." + if [ $VERBOSE -gt 0 ]; then + echo "[ $SRV_BIN $* ]" + fi + exec "$SRV_BIN" "$@" +fi + +if [ -z "$server_port_orig" ]; then + server_port_orig=4433 +fi +echo " * Server port: $server_port_orig" +tpxy_cmd_snippet="$tpxy_cmd_snippet \"listen_port=\$server_port_orig\"" +tpxy_cmd_snippet="$tpxy_cmd_snippet \"server_port=\$server_port\"" + +if [ -n "$server_addr_orig" ]; then + echo " * Server address: $server_addr_orig" + tpxy_cmd_snippet="$tpxy_cmd_snippet \"server_addr=\$server_addr_orig\"" + tpxy_cmd_snippet="$tpxy_cmd_snippet \"listen_addr=\$server_addr_orig\"" +fi + +server_port=$(( server_port_orig + 1 )) +set -- "$@" "server_port=$server_port" +echo " * Intermediate port: $server_port" + +echo " * Start proxy in background ..." +if [ $VERBOSE -gt 0 ]; then + echo "[ $tpxy_cmd_snippet ]" +fi +eval exec "$tpxy_cmd_snippet" >/dev/null 2>&1 & +tpxy_pid=$! + +if [ $VERBOSE -gt 0 ]; then + echo " * Proxy ID: $TPXY_PID" +fi + +echo " * Starting server ..." +if [ $VERBOSE -gt 0 ]; then + echo "[ $SRV_BIN $* ]" +fi + +exec "$SRV_BIN" "$@" >&2 & +srv_pid=$! + +wait $srv_pid + +stop_proxy +return 0 diff --git a/3rdparty/mbedtls/mbedtls/programs/test/zeroize.c b/3rdparty/mbedtls/mbedtls/programs/test/zeroize.c new file mode 100644 index 0000000000..29cc0ac3c1 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/programs/test/zeroize.c @@ -0,0 +1,101 @@ +/* + * Zeroize application for debugger-driven testing + * + * This is a simple test application used for debugger-driven testing to check + * whether calls to mbedtls_platform_zeroize() are being eliminated by compiler + * optimizations. This application is used by the GDB script at + * tests/scripts/test_zeroize.gdb under the assumption that the code does not + * change often (as opposed to the library code) because the script sets a + * breakpoint at the last return statement in the main() function of this + * program. The debugger facilities are then used to manually inspect the + * memory and verify that the call to mbedtls_platform_zeroize() was not + * eliminated. + * + * Copyright (C) 2018, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif + +#include "mbedtls/platform_util.h" + +#define BUFFER_LEN 1024 + +void usage( void ) +{ + mbedtls_printf( "Zeroize is a simple program to assist with testing\n" ); + mbedtls_printf( "the mbedtls_platform_zeroize() function by using the\n" ); + mbedtls_printf( "debugger. This program takes a file as input and\n" ); + mbedtls_printf( "prints the first %d characters. Usage:\n\n", BUFFER_LEN ); + mbedtls_printf( " zeroize \n" ); +} + +int main( int argc, char** argv ) +{ + int exit_code = MBEDTLS_EXIT_FAILURE; + FILE *fp; + char buf[BUFFER_LEN]; + char *p = buf; + char *end = p + BUFFER_LEN; + int c; + + if( argc != 2 ) + { + mbedtls_printf( "This program takes exactly 1 agument\n" ); + usage(); + return( exit_code ); + } + + fp = fopen( argv[1], "r" ); + if( fp == NULL ) + { + mbedtls_printf( "Could not open file '%s'\n", argv[1] ); + return( exit_code ); + } + + while( ( c = fgetc( fp ) ) != EOF && p < end - 1 ) + *p++ = (char)c; + *p = '\0'; + + if( p - buf != 0 ) + { + mbedtls_printf( "%s\n", buf ); + exit_code = MBEDTLS_EXIT_SUCCESS; + } + else + mbedtls_printf( "The file is empty!\n" ); + + fclose( fp ); + mbedtls_platform_zeroize( buf, sizeof( buf ) ); + + return( exit_code ); +} diff --git a/3rdparty/mbedtls/mbedtls/programs/util/pem2der.c b/3rdparty/mbedtls/mbedtls/programs/util/pem2der.c index 73a9fb5e09..0cc9d06644 100644 --- a/3rdparty/mbedtls/mbedtls/programs/util/pem2der.c +++ b/3rdparty/mbedtls/mbedtls/programs/util/pem2der.c @@ -33,6 +33,7 @@ #define mbedtls_free free #define mbedtls_calloc calloc #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -63,6 +64,19 @@ int main( void ) return( 0 ); } #else + +#if defined(MBEDTLS_CHECK_PARAMS) +#define mbedtls_exit exit +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ diff --git a/3rdparty/mbedtls/mbedtls/programs/x509/cert_app.c b/3rdparty/mbedtls/mbedtls/programs/x509/cert_app.c index c57ecca031..626c4d101e 100644 --- a/3rdparty/mbedtls/mbedtls/programs/x509/cert_app.c +++ b/3rdparty/mbedtls/mbedtls/programs/x509/cert_app.c @@ -34,6 +34,7 @@ #define mbedtls_time_t time_t #define mbedtls_fprintf fprintf #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -99,6 +100,18 @@ int main( void ) " permissive=%%d default: 0 (disabled)\n" \ "\n" +#if defined(MBEDTLS_CHECK_PARAMS) +#define mbedtls_exit exit +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ diff --git a/3rdparty/mbedtls/mbedtls/programs/x509/cert_req.c b/3rdparty/mbedtls/mbedtls/programs/x509/cert_req.c index a32ac505f2..b2052ecf16 100644 --- a/3rdparty/mbedtls/mbedtls/programs/x509/cert_req.c +++ b/3rdparty/mbedtls/mbedtls/programs/x509/cert_req.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -59,16 +60,21 @@ int main( void ) #include #define DFL_FILENAME "keyfile.key" +#define DFL_PASSWORD NULL #define DFL_DEBUG_LEVEL 0 #define DFL_OUTPUT_FILENAME "cert.req" #define DFL_SUBJECT_NAME "CN=Cert,O=mbed TLS,C=UK" #define DFL_KEY_USAGE 0 +#define DFL_FORCE_KEY_USAGE 0 #define DFL_NS_CERT_TYPE 0 +#define DFL_FORCE_NS_CERT_TYPE 0 +#define DFL_MD_ALG MBEDTLS_MD_SHA256 #define USAGE \ "\n usage: cert_req param=<>...\n" \ "\n acceptable parameters:\n" \ " filename=%%s default: keyfile.key\n" \ + " password=%%s default: NULL\n" \ " debug_level=%%d default: 0 (disabled)\n" \ " output_file=%%s default: cert.req\n" \ " subject_name=%%s default: CN=Cert,O=mbed TLS,C=UK\n" \ @@ -81,6 +87,8 @@ int main( void ) " key_agreement\n" \ " key_cert_sign\n" \ " crl_sign\n" \ + " force_key_usage=0/1 default: off\n" \ + " Add KeyUsage even if it is empty\n" \ " ns_cert_type=%%s default: (empty)\n" \ " Comma-separated-list of values:\n" \ " ssl_client\n" \ @@ -90,19 +98,41 @@ int main( void ) " ssl_ca\n" \ " email_ca\n" \ " object_signing_ca\n" \ + " force_ns_cert_type=0/1 default: off\n" \ + " Add NsCertType even if it is empty\n" \ + " md=%%s default: SHA256\n" \ + " possible values:\n" \ + " MD2, MD4, MD5, SHA1\n" \ + " SHA224, SHA256\n" \ + " SHA384, SHA512\n" \ "\n" +#if defined(MBEDTLS_CHECK_PARAMS) +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ struct options { const char *filename; /* filename of the key file */ + const char *password; /* password for the key file */ int debug_level; /* level of debugging */ const char *output_file; /* where to store the constructed key file */ const char *subject_name; /* subject name for certificate request */ unsigned char key_usage; /* key usage flags */ + int force_key_usage; /* Force adding the KeyUsage extension */ unsigned char ns_cert_type; /* NS cert type */ + int force_ns_cert_type; /* Force adding NsCertType extension */ + mbedtls_md_type_t md_alg; /* Hash algorithm used for signature. */ } opt; int write_certificate_request( mbedtls_x509write_csr *req, const char *output_file, @@ -151,7 +181,6 @@ int main( int argc, char *argv[] ) * Set to sane values */ mbedtls_x509write_csr_init( &req ); - mbedtls_x509write_csr_set_md_alg( &req, MBEDTLS_MD_SHA256 ); mbedtls_pk_init( &key ); mbedtls_ctr_drbg_init( &ctr_drbg ); memset( buf, 0, sizeof( buf ) ); @@ -164,11 +193,15 @@ int main( int argc, char *argv[] ) } opt.filename = DFL_FILENAME; + opt.password = DFL_PASSWORD; opt.debug_level = DFL_DEBUG_LEVEL; opt.output_file = DFL_OUTPUT_FILENAME; opt.subject_name = DFL_SUBJECT_NAME; opt.key_usage = DFL_KEY_USAGE; + opt.force_key_usage = DFL_FORCE_KEY_USAGE; opt.ns_cert_type = DFL_NS_CERT_TYPE; + opt.force_ns_cert_type = DFL_FORCE_NS_CERT_TYPE; + opt.md_alg = DFL_MD_ALG; for( i = 1; i < argc; i++ ) { @@ -180,6 +213,8 @@ int main( int argc, char *argv[] ) if( strcmp( p, "filename" ) == 0 ) opt.filename = q; + else if( strcmp( p, "password" ) == 0 ) + opt.password = q; else if( strcmp( p, "output_file" ) == 0 ) opt.output_file = q; else if( strcmp( p, "debug_level" ) == 0 ) @@ -192,6 +227,61 @@ int main( int argc, char *argv[] ) { opt.subject_name = q; } + else if( strcmp( p, "md" ) == 0 ) + { + if( strcmp( q, "SHA256" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_SHA256; + } + else if( strcmp( q, "SHA224" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_SHA224; + } + else +#if defined(MBEDTLS_MD5_C) + if( strcmp( q, "MD5" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_MD5; + } + else +#endif /* MBEDTLS_MD5_C */ +#if defined(MBEDTLS_MD4_C) + if( strcmp( q, "MD4" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_MD4; + } + else +#endif /* MBEDTLS_MD5_C */ +#if defined(MBEDTLS_MD2_C) + if( strcmp( q, "MD2" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_MD2; + } + else +#endif /* MBEDTLS_MD2_C */ +#if defined(MBEDTLS_SHA1_C) + if( strcmp( q, "SHA1" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_SHA1; + } + else +#endif /* MBEDTLS_SHA1_C */ +#if defined(MBEDTLS_SHA512_C) + if( strcmp( q, "SHA384" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_SHA384; + } + else + if( strcmp( q, "SHA512" ) == 0 ) + { + opt.md_alg = MBEDTLS_MD_SHA512; + } + else +#endif /* MBEDTLS_SHA512_C */ + { + goto usage; + } + } else if( strcmp( p, "key_usage" ) == 0 ) { while( q != NULL ) @@ -219,6 +309,15 @@ int main( int argc, char *argv[] ) q = r; } } + else if( strcmp( p, "force_key_usage" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.force_key_usage = 0; break; + case 1: opt.force_key_usage = 1; break; + default: goto usage; + } + } else if( strcmp( p, "ns_cert_type" ) == 0 ) { while( q != NULL ) @@ -246,14 +345,25 @@ int main( int argc, char *argv[] ) q = r; } } + else if( strcmp( p, "force_ns_cert_type" ) == 0 ) + { + switch( atoi( q ) ) + { + case 0: opt.force_ns_cert_type = 0; break; + case 1: opt.force_ns_cert_type = 1; break; + default: goto usage; + } + } else goto usage; } - if( opt.key_usage ) + mbedtls_x509write_csr_set_md_alg( &req, opt.md_alg ); + + if( opt.key_usage || opt.force_key_usage == 1 ) mbedtls_x509write_csr_set_key_usage( &req, opt.key_usage ); - if( opt.ns_cert_type ) + if( opt.ns_cert_type || opt.force_ns_cert_type == 1 ) mbedtls_x509write_csr_set_ns_cert_type( &req, opt.ns_cert_type ); /* @@ -293,7 +403,7 @@ int main( int argc, char *argv[] ) mbedtls_printf( " . Loading the private key ..." ); fflush( stdout ); - ret = mbedtls_pk_parse_keyfile( &key, opt.filename, NULL ); + ret = mbedtls_pk_parse_keyfile( &key, opt.filename, opt.password ); if( ret != 0 ) { diff --git a/3rdparty/mbedtls/mbedtls/programs/x509/cert_write.c b/3rdparty/mbedtls/mbedtls/programs/x509/cert_write.c index 527d9ec74d..497c3376b6 100644 --- a/3rdparty/mbedtls/mbedtls/programs/x509/cert_write.c +++ b/3rdparty/mbedtls/mbedtls/programs/x509/cert_write.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -120,7 +121,7 @@ int main( void ) " max_pathlen=%%d default: -1 (none)\n" \ " md=%%s default: SHA256\n" \ " Supported values:\n" \ - " MD5, SHA1, SHA256, SHA512\n"\ + " MD2, MD4, MD5, SHA1, SHA256, SHA512\n"\ " version=%%d default: 3\n" \ " Possible values: 1, 2, 3\n"\ " subject_identifier=%%s default: 1\n" \ @@ -153,6 +154,18 @@ int main( void ) " object_signing_ca\n" \ "\n" +#if defined(MBEDTLS_CHECK_PARAMS) +#define mbedtls_exit exit +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ @@ -359,6 +372,10 @@ int main( int argc, char *argv[] ) opt.md = MBEDTLS_MD_SHA256; else if( strcmp( q, "SHA512" ) == 0 ) opt.md = MBEDTLS_MD_SHA512; + else if( strcmp( q, "MD2" ) == 0 ) + opt.md = MBEDTLS_MD_MD2; + else if( strcmp( q, "MD4" ) == 0 ) + opt.md = MBEDTLS_MD_MD4; else if( strcmp( q, "MD5" ) == 0 ) opt.md = MBEDTLS_MD_MD5; else @@ -610,11 +627,7 @@ int main( int argc, char *argv[] ) // if( strlen( opt.issuer_crt ) ) { - if( !mbedtls_pk_can_do( &issuer_crt.pk, MBEDTLS_PK_RSA ) || - mbedtls_mpi_cmp_mpi( &mbedtls_pk_rsa( issuer_crt.pk )->N, - &mbedtls_pk_rsa( *issuer_key )->N ) != 0 || - mbedtls_mpi_cmp_mpi( &mbedtls_pk_rsa( issuer_crt.pk )->E, - &mbedtls_pk_rsa( *issuer_key )->E ) != 0 ) + if( mbedtls_pk_check_pair( &issuer_crt.pk, issuer_key ) != 0 ) { mbedtls_printf( " failed\n ! issuer_key does not match " "issuer certificate\n\n" ); diff --git a/3rdparty/mbedtls/mbedtls/programs/x509/crl_app.c b/3rdparty/mbedtls/mbedtls/programs/x509/crl_app.c index f8316835fb..a95157067e 100644 --- a/3rdparty/mbedtls/mbedtls/programs/x509/crl_app.c +++ b/3rdparty/mbedtls/mbedtls/programs/x509/crl_app.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -60,6 +61,18 @@ int main( void ) " filename=%%s default: crl.pem\n" \ "\n" +#if defined(MBEDTLS_CHECK_PARAMS) +#define mbedtls_exit exit +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ diff --git a/3rdparty/mbedtls/mbedtls/programs/x509/req_app.c b/3rdparty/mbedtls/mbedtls/programs/x509/req_app.c index 0f20c85f59..04ad119f79 100644 --- a/3rdparty/mbedtls/mbedtls/programs/x509/req_app.c +++ b/3rdparty/mbedtls/mbedtls/programs/x509/req_app.c @@ -31,6 +31,7 @@ #include #include #define mbedtls_printf printf +#define mbedtls_exit exit #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif /* MBEDTLS_PLATFORM_C */ @@ -60,6 +61,18 @@ int main( void ) " filename=%%s default: cert.req\n" \ "\n" +#if defined(MBEDTLS_CHECK_PARAMS) +#define mbedtls_exit exit +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + mbedtls_printf( "%s:%i: Input param failed - %s\n", + file, line, failure_condition ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); +} +#endif + /* * global options */ diff --git a/3rdparty/mbedtls/mbedtls/scripts/abi_check.py b/3rdparty/mbedtls/mbedtls/scripts/abi_check.py new file mode 100755 index 0000000000..502c7ae02e --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/scripts/abi_check.py @@ -0,0 +1,406 @@ +#!/usr/bin/env python3 +""" +This file is part of Mbed TLS (https://tls.mbed.org) + +Copyright (c) 2018, Arm Limited, All Rights Reserved + +Purpose + +This script is a small wrapper around the abi-compliance-checker and +abi-dumper tools, applying them to compare the ABI and API of the library +files from two different Git revisions within an Mbed TLS repository. +The results of the comparison are either formatted as HTML and stored at +a configurable location, or are given as a brief list of problems. +Returns 0 on success, 1 on ABI/API non-compliance, and 2 if there is an error +while running the script. Note: must be run from Mbed TLS root. +""" + +import os +import sys +import traceback +import shutil +import subprocess +import argparse +import logging +import tempfile +import fnmatch +from types import SimpleNamespace + +import xml.etree.ElementTree as ET + + +class AbiChecker(object): + """API and ABI checker.""" + + def __init__(self, old_version, new_version, configuration): + """Instantiate the API/ABI checker. + + old_version: RepoVersion containing details to compare against + new_version: RepoVersion containing details to check + configuration.report_dir: directory for output files + configuration.keep_all_reports: if false, delete old reports + configuration.brief: if true, output shorter report to stdout + configuration.skip_file: path to file containing symbols and types to skip + """ + self.repo_path = "." + self.log = None + self.verbose = configuration.verbose + self._setup_logger() + self.report_dir = os.path.abspath(configuration.report_dir) + self.keep_all_reports = configuration.keep_all_reports + self.can_remove_report_dir = not (os.path.exists(self.report_dir) or + self.keep_all_reports) + self.old_version = old_version + self.new_version = new_version + self.skip_file = configuration.skip_file + self.brief = configuration.brief + self.git_command = "git" + self.make_command = "make" + + @staticmethod + def check_repo_path(): + current_dir = os.path.realpath('.') + root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + if current_dir != root_dir: + raise Exception("Must be run from Mbed TLS root") + + def _setup_logger(self): + self.log = logging.getLogger() + if self.verbose: + self.log.setLevel(logging.DEBUG) + else: + self.log.setLevel(logging.INFO) + self.log.addHandler(logging.StreamHandler()) + + @staticmethod + def check_abi_tools_are_installed(): + for command in ["abi-dumper", "abi-compliance-checker"]: + if not shutil.which(command): + raise Exception("{} not installed, aborting".format(command)) + + def _get_clean_worktree_for_git_revision(self, version): + """Make a separate worktree with version.revision checked out. + Do not modify the current worktree.""" + git_worktree_path = tempfile.mkdtemp() + if version.repository: + self.log.debug( + "Checking out git worktree for revision {} from {}".format( + version.revision, version.repository + ) + ) + fetch_output = subprocess.check_output( + [self.git_command, "fetch", + version.repository, version.revision], + cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + self.log.debug(fetch_output.decode("utf-8")) + worktree_rev = "FETCH_HEAD" + else: + self.log.debug("Checking out git worktree for revision {}".format( + version.revision + )) + worktree_rev = version.revision + worktree_output = subprocess.check_output( + [self.git_command, "worktree", "add", "--detach", + git_worktree_path, worktree_rev], + cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + self.log.debug(worktree_output.decode("utf-8")) + return git_worktree_path + + def _update_git_submodules(self, git_worktree_path, version): + """If the crypto submodule is present, initialize it. + if version.crypto_revision exists, update it to that revision, + otherwise update it to the default revision""" + update_output = subprocess.check_output( + [self.git_command, "submodule", "update", "--init", '--recursive'], + cwd=git_worktree_path, + stderr=subprocess.STDOUT + ) + self.log.debug(update_output.decode("utf-8")) + if not (os.path.exists(os.path.join(git_worktree_path, "crypto")) + and version.crypto_revision): + return + + if version.crypto_repository: + fetch_output = subprocess.check_output( + [self.git_command, "fetch", version.crypto_repository, + version.crypto_revision], + cwd=os.path.join(git_worktree_path, "crypto"), + stderr=subprocess.STDOUT + ) + self.log.debug(fetch_output.decode("utf-8")) + crypto_rev = "FETCH_HEAD" + else: + crypto_rev = version.crypto_revision + + checkout_output = subprocess.check_output( + [self.git_command, "checkout", crypto_rev], + cwd=os.path.join(git_worktree_path, "crypto"), + stderr=subprocess.STDOUT + ) + self.log.debug(checkout_output.decode("utf-8")) + + def _build_shared_libraries(self, git_worktree_path, version): + """Build the shared libraries in the specified worktree.""" + my_environment = os.environ.copy() + my_environment["CFLAGS"] = "-g -Og" + my_environment["SHARED"] = "1" + if os.path.exists(os.path.join(git_worktree_path, "crypto")): + my_environment["USE_CRYPTO_SUBMODULE"] = "1" + make_output = subprocess.check_output( + [self.make_command, "lib"], + env=my_environment, + cwd=git_worktree_path, + stderr=subprocess.STDOUT + ) + self.log.debug(make_output.decode("utf-8")) + for root, _dirs, files in os.walk(git_worktree_path): + for file in fnmatch.filter(files, "*.so"): + version.modules[os.path.splitext(file)[0]] = ( + os.path.join(root, file) + ) + + def _get_abi_dumps_from_shared_libraries(self, version): + """Generate the ABI dumps for the specified git revision. + The shared libraries must have been built and the module paths + present in version.modules.""" + for mbed_module, module_path in version.modules.items(): + output_path = os.path.join( + self.report_dir, "{}-{}-{}.dump".format( + mbed_module, version.revision, version.version + ) + ) + abi_dump_command = [ + "abi-dumper", + module_path, + "-o", output_path, + "-lver", version.revision + ] + abi_dump_output = subprocess.check_output( + abi_dump_command, + stderr=subprocess.STDOUT + ) + self.log.debug(abi_dump_output.decode("utf-8")) + version.abi_dumps[mbed_module] = output_path + + def _cleanup_worktree(self, git_worktree_path): + """Remove the specified git worktree.""" + shutil.rmtree(git_worktree_path) + worktree_output = subprocess.check_output( + [self.git_command, "worktree", "prune"], + cwd=self.repo_path, + stderr=subprocess.STDOUT + ) + self.log.debug(worktree_output.decode("utf-8")) + + def _get_abi_dump_for_ref(self, version): + """Generate the ABI dumps for the specified git revision.""" + git_worktree_path = self._get_clean_worktree_for_git_revision(version) + self._update_git_submodules(git_worktree_path, version) + self._build_shared_libraries(git_worktree_path, version) + self._get_abi_dumps_from_shared_libraries(version) + self._cleanup_worktree(git_worktree_path) + + def _remove_children_with_tag(self, parent, tag): + children = parent.getchildren() + for child in children: + if child.tag == tag: + parent.remove(child) + else: + self._remove_children_with_tag(child, tag) + + def _remove_extra_detail_from_report(self, report_root): + for tag in ['test_info', 'test_results', 'problem_summary', + 'added_symbols', 'affected']: + self._remove_children_with_tag(report_root, tag) + + for report in report_root: + for problems in report.getchildren()[:]: + if not problems.getchildren(): + report.remove(problems) + + def get_abi_compatibility_report(self): + """Generate a report of the differences between the reference ABI + and the new ABI. ABI dumps from self.old_version and self.new_version + must be available.""" + compatibility_report = "" + compliance_return_code = 0 + shared_modules = list(set(self.old_version.modules.keys()) & + set(self.new_version.modules.keys())) + for mbed_module in shared_modules: + output_path = os.path.join( + self.report_dir, "{}-{}-{}.html".format( + mbed_module, self.old_version.revision, + self.new_version.revision + ) + ) + abi_compliance_command = [ + "abi-compliance-checker", + "-l", mbed_module, + "-old", self.old_version.abi_dumps[mbed_module], + "-new", self.new_version.abi_dumps[mbed_module], + "-strict", + "-report-path", output_path, + ] + if self.skip_file: + abi_compliance_command += ["-skip-symbols", self.skip_file, + "-skip-types", self.skip_file] + if self.brief: + abi_compliance_command += ["-report-format", "xml", + "-stdout"] + try: + subprocess.check_output( + abi_compliance_command, + stderr=subprocess.STDOUT + ) + except subprocess.CalledProcessError as err: + if err.returncode == 1: + compliance_return_code = 1 + if self.brief: + self.log.info( + "Compatibility issues found for {}".format(mbed_module) + ) + report_root = ET.fromstring(err.output.decode("utf-8")) + self._remove_extra_detail_from_report(report_root) + self.log.info(ET.tostring(report_root).decode("utf-8")) + else: + self.can_remove_report_dir = False + compatibility_report += ( + "Compatibility issues found for {}, " + "for details see {}\n".format(mbed_module, output_path) + ) + else: + raise err + else: + compatibility_report += ( + "No compatibility issues for {}\n".format(mbed_module) + ) + if not (self.keep_all_reports or self.brief): + os.remove(output_path) + for version in [self.old_version, self.new_version]: + for mbed_module, mbed_module_dump in version.abi_dumps.items(): + os.remove(mbed_module_dump) + if self.can_remove_report_dir: + os.rmdir(self.report_dir) + self.log.info(compatibility_report) + return compliance_return_code + + def check_for_abi_changes(self): + """Generate a report of ABI differences + between self.old_rev and self.new_rev.""" + self.check_repo_path() + self.check_abi_tools_are_installed() + self._get_abi_dump_for_ref(self.old_version) + self._get_abi_dump_for_ref(self.new_version) + return self.get_abi_compatibility_report() + + +def run_main(): + try: + parser = argparse.ArgumentParser( + description=( + """This script is a small wrapper around the + abi-compliance-checker and abi-dumper tools, applying them + to compare the ABI and API of the library files from two + different Git revisions within an Mbed TLS repository. + The results of the comparison are either formatted as HTML and + stored at a configurable location, or are given as a brief list + of problems. Returns 0 on success, 1 on ABI/API non-compliance, + and 2 if there is an error while running the script. + Note: must be run from Mbed TLS root.""" + ) + ) + parser.add_argument( + "-v", "--verbose", action="store_true", + help="set verbosity level", + ) + parser.add_argument( + "-r", "--report-dir", type=str, default="reports", + help="directory where reports are stored, default is reports", + ) + parser.add_argument( + "-k", "--keep-all-reports", action="store_true", + help="keep all reports, even if there are no compatibility issues", + ) + parser.add_argument( + "-o", "--old-rev", type=str, help="revision for old version.", + required=True, + ) + parser.add_argument( + "-or", "--old-repo", type=str, help="repository for old version." + ) + parser.add_argument( + "-oc", "--old-crypto-rev", type=str, + help="revision for old crypto submodule." + ) + parser.add_argument( + "-ocr", "--old-crypto-repo", type=str, + help="repository for old crypto submodule." + ) + parser.add_argument( + "-n", "--new-rev", type=str, help="revision for new version", + required=True, + ) + parser.add_argument( + "-nr", "--new-repo", type=str, help="repository for new version." + ) + parser.add_argument( + "-nc", "--new-crypto-rev", type=str, + help="revision for new crypto version" + ) + parser.add_argument( + "-ncr", "--new-crypto-repo", type=str, + help="repository for new crypto submodule." + ) + parser.add_argument( + "-s", "--skip-file", type=str, + help="path to file containing symbols and types to skip" + ) + parser.add_argument( + "-b", "--brief", action="store_true", + help="output only the list of issues to stdout, instead of a full report", + ) + abi_args = parser.parse_args() + if os.path.isfile(abi_args.report_dir): + print("Error: {} is not a directory".format(abi_args.report_dir)) + parser.exit() + old_version = SimpleNamespace( + version="old", + repository=abi_args.old_repo, + revision=abi_args.old_rev, + crypto_repository=abi_args.old_crypto_repo, + crypto_revision=abi_args.old_crypto_rev, + abi_dumps={}, + modules={} + ) + new_version = SimpleNamespace( + version="new", + repository=abi_args.new_repo, + revision=abi_args.new_rev, + crypto_repository=abi_args.new_crypto_repo, + crypto_revision=abi_args.new_crypto_rev, + abi_dumps={}, + modules={} + ) + configuration = SimpleNamespace( + verbose=abi_args.verbose, + report_dir=abi_args.report_dir, + keep_all_reports=abi_args.keep_all_reports, + brief=abi_args.brief, + skip_file=abi_args.skip_file + ) + abi_check = AbiChecker(old_version, new_version, configuration) + return_code = abi_check.check_for_abi_changes() + sys.exit(return_code) + except Exception: # pylint: disable=broad-except + # Print the backtrace and exit explicitly so as to exit with + # status 2, not 1. + traceback.print_exc() + sys.exit(2) + + +if __name__ == "__main__": + run_main() diff --git a/3rdparty/mbedtls/mbedtls/scripts/bump_version.sh b/3rdparty/mbedtls/mbedtls/scripts/bump_version.sh index fc8b800c44..c39a86a5e7 100755 --- a/3rdparty/mbedtls/mbedtls/scripts/bump_version.sh +++ b/3rdparty/mbedtls/mbedtls/scripts/bump_version.sh @@ -132,6 +132,9 @@ done [ $VERBOSE ] && echo "Re-generating library/error.c" scripts/generate_errors.pl +[ $VERBOSE ] && echo "Re-generating programs/ssl/query_config.c" +scripts/generate_query_config.pl + [ $VERBOSE ] && echo "Re-generating library/version_features.c" scripts/generate_features.pl diff --git a/3rdparty/mbedtls/mbedtls/scripts/config.pl b/3rdparty/mbedtls/mbedtls/scripts/config.pl index 468aeb93e1..42ec6f81b5 100755 --- a/3rdparty/mbedtls/mbedtls/scripts/config.pl +++ b/3rdparty/mbedtls/mbedtls/scripts/config.pl @@ -29,6 +29,7 @@ # MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES # MBEDTLS_NO_PLATFORM_ENTROPY # MBEDTLS_REMOVE_ARC4_CIPHERSUITES +# MBEDTLS_REMOVE_3DES_CIPHERSUITES # MBEDTLS_SSL_HW_RECORD_ACCEL # MBEDTLS_RSA_NO_CRT # MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 @@ -89,12 +90,14 @@ MBEDTLS_NO_PLATFORM_ENTROPY MBEDTLS_RSA_NO_CRT MBEDTLS_REMOVE_ARC4_CIPHERSUITES +MBEDTLS_REMOVE_3DES_CIPHERSUITES MBEDTLS_SSL_HW_RECORD_ACCEL MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION MBEDTLS_ZLIB_SUPPORT MBEDTLS_PKCS11_C MBEDTLS_NO_UDBL_DIVISION +MBEDTLS_NO_64BIT_MULTIPLICATION _ALT\s*$ ); diff --git a/3rdparty/mbedtls/mbedtls/scripts/data_files/query_config.fmt b/3rdparty/mbedtls/mbedtls/scripts/data_files/query_config.fmt new file mode 100644 index 0000000000..064da4c388 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/scripts/data_files/query_config.fmt @@ -0,0 +1,139 @@ +/* + * Query Mbed TLS compile time configurations from config.h + * + * Copyright (C) 2018, Arm Limited, All Rights Reserved + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_printf printf +#endif /* MBEDTLS_PLATFORM_C */ + +/* + * Include all the headers with public APIs in case they define a macro to its + * default value when that configuration is not set in the config.h. + */ +#include "mbedtls/aes.h" +#include "mbedtls/aesni.h" +#include "mbedtls/arc4.h" +#include "mbedtls/aria.h" +#include "mbedtls/asn1.h" +#include "mbedtls/asn1write.h" +#include "mbedtls/base64.h" +#include "mbedtls/bignum.h" +#include "mbedtls/blowfish.h" +#include "mbedtls/camellia.h" +#include "mbedtls/ccm.h" +#include "mbedtls/certs.h" +#include "mbedtls/chacha20.h" +#include "mbedtls/chachapoly.h" +#include "mbedtls/cipher.h" +#include "mbedtls/cmac.h" +#include "mbedtls/ctr_drbg.h" +#include "mbedtls/debug.h" +#include "mbedtls/des.h" +#include "mbedtls/dhm.h" +#include "mbedtls/ecdh.h" +#include "mbedtls/ecdsa.h" +#include "mbedtls/ecjpake.h" +#include "mbedtls/ecp.h" +#include "mbedtls/entropy.h" +#include "mbedtls/entropy_poll.h" +#include "mbedtls/error.h" +#include "mbedtls/gcm.h" +#include "mbedtls/havege.h" +#include "mbedtls/hkdf.h" +#include "mbedtls/hmac_drbg.h" +#include "mbedtls/md.h" +#include "mbedtls/md2.h" +#include "mbedtls/md4.h" +#include "mbedtls/md5.h" +#include "mbedtls/memory_buffer_alloc.h" +#include "mbedtls/net_sockets.h" +#include "mbedtls/nist_kw.h" +#include "mbedtls/oid.h" +#include "mbedtls/padlock.h" +#include "mbedtls/pem.h" +#include "mbedtls/pk.h" +#include "mbedtls/pkcs11.h" +#include "mbedtls/pkcs12.h" +#include "mbedtls/pkcs5.h" +#include "mbedtls/platform_time.h" +#include "mbedtls/platform_util.h" +#include "mbedtls/poly1305.h" +#include "mbedtls/ripemd160.h" +#include "mbedtls/rsa.h" +#include "mbedtls/sha1.h" +#include "mbedtls/sha256.h" +#include "mbedtls/sha512.h" +#include "mbedtls/ssl.h" +#include "mbedtls/ssl_cache.h" +#include "mbedtls/ssl_ciphersuites.h" +#include "mbedtls/ssl_cookie.h" +#include "mbedtls/ssl_internal.h" +#include "mbedtls/ssl_ticket.h" +#include "mbedtls/threading.h" +#include "mbedtls/timing.h" +#include "mbedtls/version.h" +#include "mbedtls/x509.h" +#include "mbedtls/x509_crl.h" +#include "mbedtls/x509_crt.h" +#include "mbedtls/x509_csr.h" +#include "mbedtls/xtea.h" + +#include + +/* + * Helper macros to convert a macro or its expansion into a string + * WARNING: This does not work for expanding function-like macros. However, + * Mbed TLS does not currently have configuration options used in this fashion. + */ +#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro) +#define MACRO_NAME_TO_STR(macro) \ + mbedtls_printf( "%s", strlen( #macro "" ) > 0 ? #macro "\n" : "" ) + +#if defined(_MSC_VER) +/* + * Visual Studio throws the warning 4003 because many Mbed TLS feature macros + * are defined empty. This means that from the preprocessor's point of view + * the macro MBEDTLS_EXPANSION_TO_STR is being invoked without arguments as + * some macros expand to nothing. We suppress that specific warning to get a + * clean build and to ensure that tests treating warnings as errors do not + * fail. + */ +#pragma warning(push) +#pragma warning(disable:4003) +#endif /* _MSC_VER */ + +int query_config( const char *config ) +{ +CHECK_CONFIG /* If the symbol is not found, return an error */ + return( 1 ); +} + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ diff --git a/3rdparty/mbedtls/mbedtls/scripts/data_files/vs2010-app-template.vcxproj b/3rdparty/mbedtls/mbedtls/scripts/data_files/vs2010-app-template.vcxproj index de18f9d85d..fac9812e63 100644 --- a/3rdparty/mbedtls/mbedtls/scripts/data_files/vs2010-app-template.vcxproj +++ b/3rdparty/mbedtls/mbedtls/scripts/data_files/vs2010-app-template.vcxproj @@ -18,8 +18,7 @@ x64 - - + diff --git a/3rdparty/mbedtls/mbedtls/scripts/footprint.sh b/3rdparty/mbedtls/mbedtls/scripts/footprint.sh index d38e50af27..c08ef1c902 100755 --- a/3rdparty/mbedtls/mbedtls/scripts/footprint.sh +++ b/3rdparty/mbedtls/mbedtls/scripts/footprint.sh @@ -11,7 +11,6 @@ # # Configurations included: # default include/mbedtls/config.h -# yotta yotta/module/mbedtls/config.h # thread configs/config-thread.h # suite-b configs/config-suite-b.h # psk configs/config-ccm-psk-tls1_2.h @@ -102,11 +101,7 @@ log "mbed TLS $MBEDTLS_VERSION$GIT_VERSION" log "$( arm-none-eabi-gcc --version | head -n1 )" log "CFLAGS=$ARMGCC_FLAGS" -# creates the yotta config -yotta/create-module.sh >/dev/null - doit default include/mbedtls/config.h -doit yotta yotta/module/mbedtls/config.h doit thread configs/config-thread.h doit suite-b configs/config-suite-b.h doit psk configs/config-ccm-psk-tls1_2.h diff --git a/3rdparty/mbedtls/mbedtls/scripts/generate_errors.pl b/3rdparty/mbedtls/mbedtls/scripts/generate_errors.pl index 4f0ad31f1b..0c1f7e16ec 100755 --- a/3rdparty/mbedtls/mbedtls/scripts/generate_errors.pl +++ b/3rdparty/mbedtls/mbedtls/scripts/generate_errors.pl @@ -29,10 +29,10 @@ my $error_format_file = $data_dir.'/error.fmt'; -my @low_level_modules = qw( AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH - CAMELLIA CCM CMAC CTR_DRBG DES - ENTROPY GCM HMAC_DRBG MD2 MD4 MD5 - NET OID PADLOCK PBKDF2 RIPEMD160 +my @low_level_modules = qw( AES ARC4 ARIA ASN1 BASE64 BIGNUM BLOWFISH + CAMELLIA CCM CHACHA20 CHACHAPOLY CMAC CTR_DRBG DES + ENTROPY GCM HKDF HMAC_DRBG MD2 MD4 MD5 + NET OID PADLOCK PBKDF2 PLATFORM POLY1305 RIPEMD160 SHA1 SHA256 SHA512 THREADING XTEA ); my @high_level_modules = qw( CIPHER DHM ECP MD PEM PK PKCS12 PKCS5 diff --git a/3rdparty/mbedtls/mbedtls/scripts/generate_query_config.pl b/3rdparty/mbedtls/mbedtls/scripts/generate_query_config.pl new file mode 100755 index 0000000000..f15e03a358 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/scripts/generate_query_config.pl @@ -0,0 +1,75 @@ +#! /usr/bin/env perl + +# Generate query_config.c +# +# The file query_config.c contains a C function that can be used to check if +# a configuration macro is defined and to retrieve its expansion in string +# form (if any). This facilitates querying the compile time configuration of +# the library, for example, for testing. +# +# The query_config.c is generated from the current configuration at +# include/mbedtls/config.h. The idea is that the config.h contains ALL the +# compile time configurations available in Mbed TLS (commented or uncommented). +# This script extracts the configuration macros from the config.h and this +# information is used to automatically generate the body of the query_config() +# function by using the template in scripts/data_files/query_config.fmt. +# +# Usage: ./scripts/generate_query_config.pl without arguments + +use strict; + +my $config_file = "./include/mbedtls/config.h"; + +my $query_config_format_file = "./scripts/data_files/query_config.fmt"; +my $query_config_file = "./programs/ssl/query_config.c"; + +# Excluded macros from the generated query_config.c. For example, macros that +# have commas or function-like macros cannot be transformed into strings easily +# using the preprocessor, so they should be excluded or the preprocessor will +# throw errors. +my @excluded = qw( +MBEDTLS_SSL_CIPHERSUITES +MBEDTLS_PARAM_FAILED +); +my $excluded_re = join '|', @excluded; + +open(CONFIG_FILE, "$config_file") or die "Opening config file '$config_file': $!"; + +# This variable will contain the string to replace in the CHECK_CONFIG of the +# format file +my $config_check = ""; + +while (my $line = ) { + if ($line =~ /^(\/\/)?\s*#\s*define\s+(MBEDTLS_\w+).*/) { + my $name = $2; + + # Skip over the macro that prevents multiple inclusion + next if "MBEDTLS_CONFIG_H" eq $name; + + # Skip over the macro if it is in the ecluded list + next if $name =~ /$excluded_re/; + + $config_check .= "#if defined($name)\n"; + $config_check .= " if( strcmp( \"$name\", config ) == 0 )\n"; + $config_check .= " {\n"; + $config_check .= " MACRO_EXPANSION_TO_STR( $name );\n"; + $config_check .= " return( 0 );\n"; + $config_check .= " }\n"; + $config_check .= "#endif /* $name */\n"; + $config_check .= "\n"; + } +} + +# Read the full format file into a string +local $/; +open(FORMAT_FILE, "$query_config_format_file") or die "Opening query config format file '$query_config_format_file': $!"; +my $query_config_format = ; +close(FORMAT_FILE); + +# Replace the body of the query_config() function with the code we just wrote +$query_config_format =~ s/CHECK_CONFIG/$config_check/g; + +# Rewrite the query_config.c file +open(QUERY_CONFIG_FILE, ">$query_config_file") or die "Opening destination file '$query_config_file': $!"; +print QUERY_CONFIG_FILE $query_config_format; +close(QUERY_CONFIG_FILE); diff --git a/3rdparty/mbedtls/mbedtls/scripts/generate_visualc_files.pl b/3rdparty/mbedtls/mbedtls/scripts/generate_visualc_files.pl index 811c71f474..9913976749 100755 --- a/3rdparty/mbedtls/mbedtls/scripts/generate_visualc_files.pl +++ b/3rdparty/mbedtls/mbedtls/scripts/generate_visualc_files.pl @@ -93,8 +93,14 @@ sub gen_app { $path =~ s!/!\\!g; (my $appname = $path) =~ s/.*\\//; + my $srcs = "\n \r"; + if( $appname eq "ssl_client2" or $appname eq "ssl_server2" or + $appname eq "query_compile_time_config" ) { + $srcs .= "\n \r"; + } + my $content = $template; - $content =~ s//$path/g; + $content =~ s//$srcs/g; $content =~ s//$appname/g; $content =~ s//$guid/g; diff --git a/3rdparty/mbedtls/mbedtls/scripts/output_env.sh b/3rdparty/mbedtls/mbedtls/scripts/output_env.sh index e9ad8c5d7a..c809d46fe3 100755 --- a/3rdparty/mbedtls/mbedtls/scripts/output_env.sh +++ b/3rdparty/mbedtls/mbedtls/scripts/output_env.sh @@ -83,6 +83,11 @@ if [ -n "${OPENSSL_LEGACY+set}" ]; then echo fi +if [ -n "${OPENSSL_NEXT+set}" ]; then + print_version "$OPENSSL_NEXT" "version" "openssl next version not found!" + echo +fi + : ${GNUTLS_CLI:=gnutls-cli} print_version "$GNUTLS_CLI" "--version" "gnuTLS client not found!" "head -n 1" echo diff --git a/3rdparty/mbedtls/mbedtls/tests/CMakeLists.txt b/3rdparty/mbedtls/mbedtls/tests/CMakeLists.txt index 9fd4916bbd..a8e7523e50 100644 --- a/3rdparty/mbedtls/mbedtls/tests/CMakeLists.txt +++ b/3rdparty/mbedtls/mbedtls/tests/CMakeLists.txt @@ -15,6 +15,18 @@ if(NOT PERL_FOUND) message(FATAL_ERROR "Cannot build test suites without Perl") endif() +# Enable definition of various functions used throughout the testsuite +# (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless +# on non-POSIX platforms. +add_definitions("-D_POSIX_C_SOURCE=200809L") + +# Test suites caught by SKIP_TEST_SUITES are built but not executed. +# "foo" as a skip pattern skips "test_suite_foo" and "test_suite_foo.bar" +# but not "test_suite_foobar". +string(REGEX REPLACE "[ ,;]" "|" SKIP_TEST_SUITES_REGEX "${SKIP_TEST_SUITES}") +string(REPLACE "." "\\." SKIP_TEST_SUITES_REGEX "${SKIP_TEST_SUITES_REGEX}") +set(SKIP_TEST_SUITES_REGEX "^(${SKIP_TEST_SUITES_REGEX})(\$|\\.)") + function(add_test_suite suite_name) if(ARGV1) set(data_name ${ARGV1}) @@ -24,14 +36,18 @@ function(add_test_suite suite_name) add_custom_command( OUTPUT test_suite_${data_name}.c - COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.pl ${CMAKE_CURRENT_SOURCE_DIR}/suites test_suite_${suite_name} test_suite_${data_name} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_code.pl mbedtls suites/helpers.function suites/main_test.function suites/test_suite_${suite_name}.function suites/test_suite_${data_name}.data + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py -f ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function -d ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data -t ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function -p ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function -s ${CMAKE_CURRENT_SOURCE_DIR}/suites --helpers-file ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function -o . + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_executable(test_suite_${data_name} test_suite_${data_name}.c) target_link_libraries(test_suite_${data_name} ${libs}) - add_test(${data_name}-suite test_suite_${data_name} --verbose) + if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX}) + message(STATUS "The test suite ${data_name} will not be executed.") + else() + add_test(${data_name}-suite test_suite_${data_name} --verbose) + endif() endfunction(add_test_suite) if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG) @@ -47,20 +63,28 @@ endif(MSVC) add_test_suite(aes aes.ecb) add_test_suite(aes aes.cbc) add_test_suite(aes aes.cfb) +add_test_suite(aes aes.ofb) add_test_suite(aes aes.rest) +add_test_suite(aes aes.xts) add_test_suite(arc4) +add_test_suite(aria) add_test_suite(asn1write) add_test_suite(base64) add_test_suite(blowfish) add_test_suite(camellia) add_test_suite(ccm) +add_test_suite(chacha20) +add_test_suite(chachapoly) add_test_suite(cipher cipher.aes) add_test_suite(cipher cipher.arc4) add_test_suite(cipher cipher.blowfish) add_test_suite(cipher cipher.camellia) add_test_suite(cipher cipher.ccm) +add_test_suite(cipher cipher.chacha20) +add_test_suite(cipher cipher.chachapoly) add_test_suite(cipher cipher.des) add_test_suite(cipher cipher.gcm) +add_test_suite(cipher cipher.misc) add_test_suite(cipher cipher.null) add_test_suite(cipher cipher.padding) add_test_suite(cmac) @@ -81,6 +105,8 @@ add_test_suite(gcm gcm.aes128_de) add_test_suite(gcm gcm.aes192_de) add_test_suite(gcm gcm.aes256_de) add_test_suite(gcm gcm.camellia) +add_test_suite(gcm gcm.misc) +add_test_suite(hkdf) add_test_suite(hmac_drbg hmac_drbg.misc) add_test_suite(hmac_drbg hmac_drbg.no_reseed) add_test_suite(hmac_drbg hmac_drbg.nopr) @@ -89,6 +115,7 @@ add_test_suite(md) add_test_suite(mdx) add_test_suite(memory_buffer_alloc) add_test_suite(mpi) +add_test_suite(nist_kw) add_test_suite(pem) add_test_suite(pkcs1_v15) add_test_suite(pkcs1_v21) @@ -96,6 +123,7 @@ add_test_suite(pkcs5) add_test_suite(pk) add_test_suite(pkparse) add_test_suite(pkwrite) +add_test_suite(poly1305) add_test_suite(shax) add_test_suite(ssl) add_test_suite(timing) diff --git a/3rdparty/mbedtls/mbedtls/tests/Makefile b/3rdparty/mbedtls/mbedtls/tests/Makefile index d85617fdca..4ef74177b9 100644 --- a/3rdparty/mbedtls/mbedtls/tests/Makefile +++ b/3rdparty/mbedtls/mbedtls/tests/Makefile @@ -7,11 +7,16 @@ WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wno-unused-function -W LDFLAGS ?= LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64 -LOCAL_LDFLAGS = -L../library \ +LOCAL_LDFLAGS = -L../library \ -lmbedtls$(SHARED_SUFFIX) \ -lmbedx509$(SHARED_SUFFIX) \ -lmbedcrypto$(SHARED_SUFFIX) +# Enable definition of various functions used throughout the testsuite +# (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless +# on non-POSIX platforms. +LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L + ifndef SHARED DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a else @@ -34,10 +39,13 @@ LOCAL_LDFLAGS += -lws2_32 ifdef SHARED SHARED_SUFFIX=.$(DLEXT) endif +PYTHON ?= python else DLEXT ?= so EXEXT= SHARED_SUFFIX= +# python2 for POSIX since FreeBSD has only python2 as default. +PYTHON ?= python2 endif # Zlib shared library extensions: @@ -45,406 +53,87 @@ ifdef ZLIB LOCAL_LDFLAGS += -lz endif -APPS = test_suite_aes.ecb$(EXEXT) test_suite_aes.cbc$(EXEXT) \ - test_suite_aes.cfb$(EXEXT) test_suite_aes.rest$(EXEXT) \ - test_suite_arc4$(EXEXT) test_suite_asn1write$(EXEXT) \ - test_suite_base64$(EXEXT) test_suite_blowfish$(EXEXT) \ - test_suite_camellia$(EXEXT) test_suite_ccm$(EXEXT) \ - test_suite_cmac$(EXEXT) \ - test_suite_cipher.aes$(EXEXT) \ - test_suite_cipher.arc4$(EXEXT) test_suite_cipher.ccm$(EXEXT) \ - test_suite_cipher.gcm$(EXEXT) \ - test_suite_cipher.blowfish$(EXEXT) \ - test_suite_cipher.camellia$(EXEXT) \ - test_suite_cipher.des$(EXEXT) test_suite_cipher.null$(EXEXT) \ - test_suite_cipher.padding$(EXEXT) \ - test_suite_ctr_drbg$(EXEXT) test_suite_debug$(EXEXT) \ - test_suite_des$(EXEXT) test_suite_dhm$(EXEXT) \ - test_suite_ecdh$(EXEXT) test_suite_ecdsa$(EXEXT) \ - test_suite_ecjpake$(EXEXT) test_suite_ecp$(EXEXT) \ - test_suite_error$(EXEXT) test_suite_entropy$(EXEXT) \ - test_suite_gcm.aes128_de$(EXEXT) \ - test_suite_gcm.aes192_de$(EXEXT) \ - test_suite_gcm.aes256_de$(EXEXT) \ - test_suite_gcm.aes128_en$(EXEXT) \ - test_suite_gcm.aes192_en$(EXEXT) \ - test_suite_gcm.aes256_en$(EXEXT) \ - test_suite_gcm.camellia$(EXEXT) \ - test_suite_hmac_drbg.misc$(EXEXT) \ - test_suite_hmac_drbg.no_reseed$(EXEXT) \ - test_suite_hmac_drbg.nopr$(EXEXT) \ - test_suite_hmac_drbg.pr$(EXEXT) \ - test_suite_md$(EXEXT) test_suite_mdx$(EXEXT) \ - test_suite_memory_buffer_alloc$(EXEXT) \ - test_suite_mpi$(EXEXT) \ - test_suite_pem$(EXEXT) test_suite_pkcs1_v15$(EXEXT) \ - test_suite_pkcs1_v21$(EXEXT) test_suite_pkcs5$(EXEXT) \ - test_suite_pkparse$(EXEXT) test_suite_pkwrite$(EXEXT) \ - test_suite_pk$(EXEXT) \ - test_suite_rsa$(EXEXT) test_suite_shax$(EXEXT) \ - test_suite_ssl$(EXEXT) test_suite_timing$(EXEXT) \ - test_suite_x509parse$(EXEXT) test_suite_x509write$(EXEXT) \ - test_suite_xtea$(EXEXT) test_suite_version$(EXEXT) +# A test application is built for each suites/test_suite_*.data file. +# Application name is same as .data file's base name and can be +# constructed by stripping path 'suites/' and extension .data. +APPS = $(basename $(subst suites/,,$(wildcard suites/test_suite_*.data))) + +# Construct executable name by adding OS specific suffix $(EXEXT). +BINARIES := $(addsuffix $(EXEXT),$(APPS)) .SILENT: .PHONY: all check test clean -all: $(APPS) +all: $(BINARIES) $(DEP): $(MAKE) -C ../library -# invoke perl explicitly for the sake of mingw32-make - -test_suite_aes.ecb.c : suites/test_suite_aes.function suites/test_suite_aes.ecb.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_aes test_suite_aes.ecb - -test_suite_aes.cbc.c : suites/test_suite_aes.function suites/test_suite_aes.cbc.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_aes test_suite_aes.cbc - -test_suite_aes.cfb.c : suites/test_suite_aes.function suites/test_suite_aes.cfb.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_aes test_suite_aes.cfb - -test_suite_aes.rest.c : suites/test_suite_aes.function suites/test_suite_aes.rest.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_aes test_suite_aes.rest - -test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes - -test_suite_cipher.arc4.c : suites/test_suite_cipher.function suites/test_suite_cipher.arc4.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.arc4 - -test_suite_cipher.ccm.c : suites/test_suite_cipher.function suites/test_suite_cipher.ccm.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.ccm - -test_suite_cipher.gcm.c : suites/test_suite_cipher.function suites/test_suite_cipher.gcm.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.gcm - -test_suite_cipher.blowfish.c : suites/test_suite_cipher.function suites/test_suite_cipher.blowfish.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.blowfish - -test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia - -test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des - -test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null - -test_suite_cipher.padding.c : suites/test_suite_cipher.function suites/test_suite_cipher.padding.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.padding - -test_suite_gcm.aes128_de.c : suites/test_suite_gcm.function suites/test_suite_gcm.aes128_de.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.aes128_de - -test_suite_gcm.aes192_de.c : suites/test_suite_gcm.function suites/test_suite_gcm.aes192_de.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.aes192_de - -test_suite_gcm.aes256_de.c : suites/test_suite_gcm.function suites/test_suite_gcm.aes256_de.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.aes256_de - -test_suite_gcm.aes128_en.c : suites/test_suite_gcm.function suites/test_suite_gcm.aes128_en.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.aes128_en - -test_suite_gcm.aes192_en.c : suites/test_suite_gcm.function suites/test_suite_gcm.aes192_en.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.aes192_en - -test_suite_gcm.aes256_en.c : suites/test_suite_gcm.function suites/test_suite_gcm.aes256_en.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.aes256_en - -test_suite_gcm.camellia.c : suites/test_suite_gcm.function suites/test_suite_gcm.camellia.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.camellia - -test_suite_hmac_drbg.misc.c : suites/test_suite_hmac_drbg.function suites/test_suite_hmac_drbg.misc.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_hmac_drbg test_suite_hmac_drbg.misc +C_FILES := $(addsuffix .c,$(APPS)) -test_suite_hmac_drbg.no_reseed.c : suites/test_suite_hmac_drbg.function suites/test_suite_hmac_drbg.no_reseed.data scripts/generate_code.pl suites/helpers.function suites/main_test.function +# Wildcard target for test code generation: +# A .c file is generated for each .data file in the suites/ directory. Each .c +# file depends on a .data and .function file from suites/ directory. Following +# nameing convention is followed: +# +# C file | Depends on +#----------------------------------------------------------------------------- +# foo.c | suites/foo.function suites/foo.data +# foo.bar.c | suites/foo.function suites/foo.bar.data +# +# Note above that .c and .data files have same base name. +# However, corresponding .function file's base name is the word before first +# dot in .c file's base name. +# +.SECONDEXPANSION: +%.c: suites/$$(firstword $$(subst ., ,$$*)).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/host_test.function echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_hmac_drbg test_suite_hmac_drbg.no_reseed - -test_suite_hmac_drbg.nopr.c : suites/test_suite_hmac_drbg.function suites/test_suite_hmac_drbg.nopr.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_hmac_drbg test_suite_hmac_drbg.nopr - -test_suite_hmac_drbg.pr.c : suites/test_suite_hmac_drbg.function suites/test_suite_hmac_drbg.pr.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites test_suite_hmac_drbg test_suite_hmac_drbg.pr - -%.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function suites/main_test.function - echo " Gen $@" - perl scripts/generate_code.pl suites $* $* - -test_suite_aes.ecb$(EXEXT): test_suite_aes.ecb.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_aes.cbc$(EXEXT): test_suite_aes.cbc.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_aes.cfb$(EXEXT): test_suite_aes.cfb.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_aes.rest$(EXEXT): test_suite_aes.rest.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_arc4$(EXEXT): test_suite_arc4.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_asn1write$(EXEXT): test_suite_asn1write.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_base64$(EXEXT): test_suite_base64.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_blowfish$(EXEXT): test_suite_blowfish.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_camellia$(EXEXT): test_suite_camellia.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ccm$(EXEXT): test_suite_ccm.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cmac$(EXEXT): test_suite_cmac.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cipher.aes$(EXEXT): test_suite_cipher.aes.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cipher.arc4$(EXEXT): test_suite_cipher.arc4.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cipher.ccm$(EXEXT): test_suite_cipher.ccm.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ + $(PYTHON) scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \ + -d suites/$*.data \ + -t suites/main_test.function \ + -p suites/host_test.function \ + -s suites \ + --helpers-file suites/helpers.function \ + -o . -test_suite_cipher.gcm$(EXEXT): test_suite_cipher.gcm.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -test_suite_cipher.blowfish$(EXEXT): test_suite_cipher.blowfish.c $(DEP) +$(BINARIES): %$(EXEXT): %.c $(DEP) echo " CC $<" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -test_suite_cipher.camellia$(EXEXT): test_suite_cipher.camellia.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cipher.des$(EXEXT): test_suite_cipher.des.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cipher.null$(EXEXT): test_suite_cipher.null.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_cipher.padding$(EXEXT): test_suite_cipher.padding.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ctr_drbg$(EXEXT): test_suite_ctr_drbg.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_des$(EXEXT): test_suite_des.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_dhm$(EXEXT): test_suite_dhm.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ecdh$(EXEXT): test_suite_ecdh.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ecdsa$(EXEXT): test_suite_ecdsa.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ecjpake$(EXEXT): test_suite_ecjpake.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ecp$(EXEXT): test_suite_ecp.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_entropy$(EXEXT): test_suite_entropy.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_error$(EXEXT): test_suite_error.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.aes128_de$(EXEXT): test_suite_gcm.aes128_de.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.aes192_de$(EXEXT): test_suite_gcm.aes192_de.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.aes256_de$(EXEXT): test_suite_gcm.aes256_de.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.aes128_en$(EXEXT): test_suite_gcm.aes128_en.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.aes192_en$(EXEXT): test_suite_gcm.aes192_en.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.aes256_en$(EXEXT): test_suite_gcm.aes256_en.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_gcm.camellia$(EXEXT): test_suite_gcm.camellia.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_hmac_drbg.misc$(EXEXT): test_suite_hmac_drbg.misc.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_hmac_drbg.no_reseed$(EXEXT): test_suite_hmac_drbg.no_reseed.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_hmac_drbg.nopr$(EXEXT): test_suite_hmac_drbg.nopr.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_hmac_drbg.pr$(EXEXT): test_suite_hmac_drbg.pr.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_md$(EXEXT): test_suite_md.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_mdx$(EXEXT): test_suite_mdx.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_memory_buffer_alloc$(EXEXT): test_suite_memory_buffer_alloc.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_mpi$(EXEXT): test_suite_mpi.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pem$(EXEXT): test_suite_pem.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pkcs1_v15$(EXEXT): test_suite_pkcs1_v15.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pkcs1_v21$(EXEXT): test_suite_pkcs1_v21.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pkcs5$(EXEXT): test_suite_pkcs5.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pkparse$(EXEXT): test_suite_pkparse.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pkwrite$(EXEXT): test_suite_pkwrite.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_pk$(EXEXT): test_suite_pk.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_rsa$(EXEXT): test_suite_rsa.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_shax$(EXEXT): test_suite_shax.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_ssl$(EXEXT): test_suite_ssl.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_timing$(EXEXT): test_suite_timing.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_x509parse$(EXEXT): test_suite_x509parse.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_x509write$(EXEXT): test_suite_x509write.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_xtea$(EXEXT): test_suite_xtea.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_debug$(EXEXT): test_suite_debug.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ - -test_suite_version$(EXEXT): test_suite_version.c $(DEP) - echo " CC $<" - $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ clean: ifndef WINDOWS - rm -f $(APPS) *.c + rm -rf $(BINARIES) *.c *.datax TESTS else - del /Q /F *.c *.exe + del /Q /F *.c *.exe *.datax +ifneq ($(wildcard TESTS/.*),) + rmdir /Q /S TESTS +endif endif -check: $(APPS) - perl scripts/run-test-suites.pl +# Test suites caught by SKIP_TEST_SUITES are built but not executed. +check: $(BINARIES) + perl scripts/run-test-suites.pl --skip=$(SKIP_TEST_SUITES) test: check + +# Create separate targets for generating embedded tests. +EMBEDDED_TESTS := $(addprefix embedded_,$(APPS)) + +# Generate test code for target. + +.SECONDEXPANSION: +$(EMBEDDED_TESTS): embedded_%: suites/$$(firstword $$(subst ., ,$$*)).function suites/%.data scripts/generate_test_code.py suites/helpers.function suites/main_test.function suites/target_test.function + echo " Gen ./TESTS/mbedtls/$*/$*.c" + $(PYTHON) scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \ + -d suites/$*.data \ + -t suites/main_test.function \ + -p suites/target_test.function \ + -s suites \ + --helpers-file suites/helpers.function \ + -o ./TESTS/mbedtls/$* + +generate-target-tests: $(EMBEDDED_TESTS) + diff --git a/3rdparty/mbedtls/mbedtls/tests/compat.sh b/3rdparty/mbedtls/mbedtls/tests/compat.sh index a2b2d5ba12..35983cd7ec 100755 --- a/3rdparty/mbedtls/mbedtls/tests/compat.sh +++ b/3rdparty/mbedtls/mbedtls/tests/compat.sh @@ -42,6 +42,9 @@ if ( which $GNUTLS_CLI && which $GNUTLS_SERV ) >/dev/null 2>&1; then PEER_GNUTLS="" else PEER_GNUTLS=" GnuTLS" + if [ $MINOR -lt 4 ]; then + GNUTLS_MINOR_LT_FOUR='x' + fi fi fi else @@ -53,7 +56,14 @@ MODES="tls1 tls1_1 tls1_2 dtls1 dtls1_2" VERIFIES="NO YES" TYPES="ECDSA RSA PSK" FILTER="" -EXCLUDE='NULL\|DES-CBC-\|RC4\|ARCFOUR' # avoid plain DES but keep 3DES-EDE-CBC (mbedTLS), DES-CBC3 (OpenSSL) +# exclude: +# - NULL: excluded from our default config +# - RC4, single-DES: requires legacy OpenSSL/GnuTLS versions +# avoid plain DES but keep 3DES-EDE-CBC (mbedTLS), DES-CBC3 (OpenSSL) +# - ARIA: not in default config.h + requires OpenSSL >= 1.1.1 +# - ChachaPoly: requires OpenSSL >= 1.1.0 +# - 3DES: not in default config +EXCLUDE='NULL\|DES\|RC4\|ARCFOUR\|ARIA\|CHACHA20-POLY1305' VERBOSE="" MEMCHECK=0 PEERS="OpenSSL$PEER_GNUTLS mbedTLS" @@ -226,6 +236,9 @@ reset_ciphersuites() G_CIPHERS="" } +# Ciphersuites that can be used with all peers. +# Since we currently have three possible peers, each ciphersuite should appear +# three times: in each peer's list (with the name that this peer uses). add_common_ciphersuites() { case $TYPE in @@ -422,6 +435,16 @@ add_common_ciphersuites() esac } +# Ciphersuites usable only with Mbed TLS and OpenSSL +# Each ciphersuite should appear two times, once with its OpenSSL name, once +# with its Mbed TLS name. +# +# NOTE: for some reason RSA-PSK doesn't work with OpenSSL, +# so RSA-PSK ciphersuites need to go in other sections, see +# https://github.com/ARMmbed/mbedtls/issues/1419 +# +# ChachaPoly suites are here rather than in "common", as they were added in +# GnuTLS in 3.5.0 and the CI only has 3.4.x so far. add_openssl_ciphersuites() { case $TYPE in @@ -451,12 +474,18 @@ add_openssl_ciphersuites() TLS-ECDH-ECDSA-WITH-AES-256-CBC-SHA384 \ TLS-ECDH-ECDSA-WITH-AES-128-GCM-SHA256 \ TLS-ECDH-ECDSA-WITH-AES-256-GCM-SHA384 \ + TLS-ECDHE-ECDSA-WITH-ARIA-256-GCM-SHA384 \ + TLS-ECDHE-ECDSA-WITH-ARIA-128-GCM-SHA256 \ + TLS-ECDHE-ECDSA-WITH-CHACHA20-POLY1305-SHA256 \ " O_CIPHERS="$O_CIPHERS \ ECDH-ECDSA-AES128-SHA256 \ ECDH-ECDSA-AES256-SHA384 \ ECDH-ECDSA-AES128-GCM-SHA256 \ ECDH-ECDSA-AES256-GCM-SHA384 \ + ECDHE-ECDSA-ARIA256-GCM-SHA384 \ + ECDHE-ECDSA-ARIA128-GCM-SHA256 \ + ECDHE-ECDSA-CHACHA20-POLY1305 \ " fi ;; @@ -470,13 +499,60 @@ add_openssl_ciphersuites() DES-CBC-SHA \ EDH-RSA-DES-CBC-SHA \ " + if [ `minor_ver "$MODE"` -ge 3 ] + then + M_CIPHERS="$M_CIPHERS \ + TLS-ECDHE-RSA-WITH-ARIA-256-GCM-SHA384 \ + TLS-DHE-RSA-WITH-ARIA-256-GCM-SHA384 \ + TLS-RSA-WITH-ARIA-256-GCM-SHA384 \ + TLS-ECDHE-RSA-WITH-ARIA-128-GCM-SHA256 \ + TLS-DHE-RSA-WITH-ARIA-128-GCM-SHA256 \ + TLS-RSA-WITH-ARIA-128-GCM-SHA256 \ + TLS-DHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ + TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256 \ + " + O_CIPHERS="$O_CIPHERS \ + ECDHE-ARIA256-GCM-SHA384 \ + DHE-RSA-ARIA256-GCM-SHA384 \ + ARIA256-GCM-SHA384 \ + ECDHE-ARIA128-GCM-SHA256 \ + DHE-RSA-ARIA128-GCM-SHA256 \ + ARIA128-GCM-SHA256 \ + DHE-RSA-CHACHA20-POLY1305 \ + ECDHE-RSA-CHACHA20-POLY1305 \ + " + fi ;; "PSK") + if [ `minor_ver "$MODE"` -ge 3 ] + then + M_CIPHERS="$M_CIPHERS \ + TLS-DHE-PSK-WITH-ARIA-256-GCM-SHA384 \ + TLS-DHE-PSK-WITH-ARIA-128-GCM-SHA256 \ + TLS-PSK-WITH-ARIA-256-GCM-SHA384 \ + TLS-PSK-WITH-ARIA-128-GCM-SHA256 \ + TLS-PSK-WITH-CHACHA20-POLY1305-SHA256 \ + TLS-ECDHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ + TLS-DHE-PSK-WITH-CHACHA20-POLY1305-SHA256 \ + " + O_CIPHERS="$O_CIPHERS \ + DHE-PSK-ARIA256-GCM-SHA384 \ + DHE-PSK-ARIA128-GCM-SHA256 \ + PSK-ARIA256-GCM-SHA384 \ + PSK-ARIA128-GCM-SHA256 \ + DHE-PSK-CHACHA20-POLY1305 \ + ECDHE-PSK-CHACHA20-POLY1305 \ + PSK-CHACHA20-POLY1305 \ + " + fi ;; esac } +# Ciphersuites usable only with Mbed TLS and GnuTLS +# Each ciphersuite should appear two times, once with its GnuTLS name, once +# with its Mbed TLS name. add_gnutls_ciphersuites() { case $TYPE in @@ -489,12 +565,20 @@ add_gnutls_ciphersuites() TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-CBC-SHA384 \ TLS-ECDHE-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ TLS-ECDHE-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ + TLS-ECDHE-ECDSA-WITH-AES-128-CCM \ + TLS-ECDHE-ECDSA-WITH-AES-256-CCM \ + TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ + TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 \ " G_CIPHERS="$G_CIPHERS \ +ECDHE-ECDSA:+CAMELLIA-128-CBC:+SHA256 \ +ECDHE-ECDSA:+CAMELLIA-256-CBC:+SHA384 \ +ECDHE-ECDSA:+CAMELLIA-128-GCM:+AEAD \ +ECDHE-ECDSA:+CAMELLIA-256-GCM:+AEAD \ + +ECDHE-ECDSA:+AES-128-CCM:+AEAD \ + +ECDHE-ECDSA:+AES-256-CCM:+AEAD \ + +ECDHE-ECDSA:+AES-128-CCM-8:+AEAD \ + +ECDHE-ECDSA:+AES-256-CCM-8:+AEAD \ " fi ;; @@ -524,6 +608,14 @@ add_gnutls_ciphersuites() TLS-DHE-RSA-WITH-CAMELLIA-256-GCM-SHA384 \ TLS-RSA-WITH-CAMELLIA-128-GCM-SHA256 \ TLS-RSA-WITH-CAMELLIA-256-GCM-SHA384 \ + TLS-RSA-WITH-AES-128-CCM \ + TLS-RSA-WITH-AES-256-CCM \ + TLS-DHE-RSA-WITH-AES-128-CCM \ + TLS-DHE-RSA-WITH-AES-256-CCM \ + TLS-RSA-WITH-AES-128-CCM-8 \ + TLS-RSA-WITH-AES-256-CCM-8 \ + TLS-DHE-RSA-WITH-AES-128-CCM-8 \ + TLS-DHE-RSA-WITH-AES-256-CCM-8 \ " G_CIPHERS="$G_CIPHERS \ +ECDHE-RSA:+CAMELLIA-128-CBC:+SHA256 \ @@ -538,6 +630,14 @@ add_gnutls_ciphersuites() +DHE-RSA:+CAMELLIA-256-GCM:+AEAD \ +RSA:+CAMELLIA-128-GCM:+AEAD \ +RSA:+CAMELLIA-256-GCM:+AEAD \ + +RSA:+AES-128-CCM:+AEAD \ + +RSA:+AES-256-CCM:+AEAD \ + +RSA:+AES-128-CCM-8:+AEAD \ + +RSA:+AES-256-CCM-8:+AEAD \ + +DHE-RSA:+AES-128-CCM:+AEAD \ + +DHE-RSA:+AES-256-CCM:+AEAD \ + +DHE-RSA:+AES-128-CCM-8:+AEAD \ + +DHE-RSA:+AES-256-CCM-8:+AEAD \ " fi ;; @@ -609,6 +709,14 @@ add_gnutls_ciphersuites() TLS-PSK-WITH-AES-256-GCM-SHA384 \ TLS-DHE-PSK-WITH-AES-128-GCM-SHA256 \ TLS-DHE-PSK-WITH-AES-256-GCM-SHA384 \ + TLS-PSK-WITH-AES-128-CCM \ + TLS-PSK-WITH-AES-256-CCM \ + TLS-DHE-PSK-WITH-AES-128-CCM \ + TLS-DHE-PSK-WITH-AES-256-CCM \ + TLS-PSK-WITH-AES-128-CCM-8 \ + TLS-PSK-WITH-AES-256-CCM-8 \ + TLS-DHE-PSK-WITH-AES-128-CCM-8 \ + TLS-DHE-PSK-WITH-AES-256-CCM-8 \ TLS-RSA-PSK-WITH-CAMELLIA-128-GCM-SHA256 \ TLS-RSA-PSK-WITH-CAMELLIA-256-GCM-SHA384 \ TLS-PSK-WITH-CAMELLIA-128-GCM-SHA256 \ @@ -639,6 +747,14 @@ add_gnutls_ciphersuites() +PSK:+AES-256-GCM:+AEAD \ +DHE-PSK:+AES-128-GCM:+AEAD \ +DHE-PSK:+AES-256-GCM:+AEAD \ + +PSK:+AES-128-CCM:+AEAD \ + +PSK:+AES-256-CCM:+AEAD \ + +DHE-PSK:+AES-128-CCM:+AEAD \ + +DHE-PSK:+AES-256-CCM:+AEAD \ + +PSK:+AES-128-CCM-8:+AEAD \ + +PSK:+AES-256-CCM-8:+AEAD \ + +DHE-PSK:+AES-128-CCM-8:+AEAD \ + +DHE-PSK:+AES-256-CCM-8:+AEAD \ +RSA-PSK:+CAMELLIA-128-GCM:+AEAD \ +RSA-PSK:+CAMELLIA-256-GCM:+AEAD \ +PSK:+CAMELLIA-128-GCM:+AEAD \ @@ -661,6 +777,9 @@ add_gnutls_ciphersuites() esac } +# Ciphersuites usable only with Mbed TLS (not currently supported by another +# peer usable in this script). This provide only very rudimentaty testing, as +# this is not interop testing, but it's better than nothing. add_mbedtls_ciphersuites() { case $TYPE in @@ -678,26 +797,26 @@ add_mbedtls_ciphersuites() M_CIPHERS="$M_CIPHERS \ TLS-ECDH-ECDSA-WITH-CAMELLIA-128-GCM-SHA256 \ TLS-ECDH-ECDSA-WITH-CAMELLIA-256-GCM-SHA384 \ - TLS-ECDHE-ECDSA-WITH-AES-128-CCM \ - TLS-ECDHE-ECDSA-WITH-AES-256-CCM \ - TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ - TLS-ECDHE-ECDSA-WITH-AES-256-CCM-8 \ + TLS-ECDHE-ECDSA-WITH-ARIA-256-CBC-SHA384 \ + TLS-ECDHE-ECDSA-WITH-ARIA-128-CBC-SHA256 \ + TLS-ECDH-ECDSA-WITH-ARIA-256-GCM-SHA384 \ + TLS-ECDH-ECDSA-WITH-ARIA-128-GCM-SHA256 \ + TLS-ECDH-ECDSA-WITH-ARIA-256-CBC-SHA384 \ + TLS-ECDH-ECDSA-WITH-ARIA-128-CBC-SHA256 \ " fi ;; "RSA") - if [ "$MODE" = "tls1_2" ]; + if [ `minor_ver "$MODE"` -ge 3 ] then M_CIPHERS="$M_CIPHERS \ - TLS-RSA-WITH-AES-128-CCM \ - TLS-RSA-WITH-AES-256-CCM \ - TLS-DHE-RSA-WITH-AES-128-CCM \ - TLS-DHE-RSA-WITH-AES-256-CCM \ - TLS-RSA-WITH-AES-128-CCM-8 \ - TLS-RSA-WITH-AES-256-CCM-8 \ - TLS-DHE-RSA-WITH-AES-128-CCM-8 \ - TLS-DHE-RSA-WITH-AES-256-CCM-8 \ + TLS-ECDHE-RSA-WITH-ARIA-256-CBC-SHA384 \ + TLS-DHE-RSA-WITH-ARIA-256-CBC-SHA384 \ + TLS-ECDHE-RSA-WITH-ARIA-128-CBC-SHA256 \ + TLS-DHE-RSA-WITH-ARIA-128-CBC-SHA256 \ + TLS-RSA-WITH-ARIA-256-CBC-SHA384 \ + TLS-RSA-WITH-ARIA-128-CBC-SHA256 \ " fi ;; @@ -715,17 +834,20 @@ add_mbedtls_ciphersuites() TLS-RSA-PSK-WITH-NULL-SHA \ " fi - if [ "$MODE" = "tls1_2" ]; + if [ `minor_ver "$MODE"` -ge 3 ] then M_CIPHERS="$M_CIPHERS \ - TLS-PSK-WITH-AES-128-CCM \ - TLS-PSK-WITH-AES-256-CCM \ - TLS-DHE-PSK-WITH-AES-128-CCM \ - TLS-DHE-PSK-WITH-AES-256-CCM \ - TLS-PSK-WITH-AES-128-CCM-8 \ - TLS-PSK-WITH-AES-256-CCM-8 \ - TLS-DHE-PSK-WITH-AES-128-CCM-8 \ - TLS-DHE-PSK-WITH-AES-256-CCM-8 \ + TLS-RSA-PSK-WITH-ARIA-256-CBC-SHA384 \ + TLS-RSA-PSK-WITH-ARIA-128-CBC-SHA256 \ + TLS-PSK-WITH-ARIA-256-CBC-SHA384 \ + TLS-PSK-WITH-ARIA-128-CBC-SHA256 \ + TLS-RSA-PSK-WITH-ARIA-256-GCM-SHA384 \ + TLS-RSA-PSK-WITH-ARIA-128-GCM-SHA256 \ + TLS-ECDHE-PSK-WITH-ARIA-256-CBC-SHA384 \ + TLS-ECDHE-PSK-WITH-ARIA-128-CBC-SHA256 \ + TLS-DHE-PSK-WITH-ARIA-256-CBC-SHA384 \ + TLS-DHE-PSK-WITH-ARIA-128-CBC-SHA256 \ + TLS-RSA-PSK-WITH-CHACHA20-POLY1305-SHA256 \ " fi ;; @@ -761,10 +883,17 @@ setup_arguments() exit 1; esac + # GnuTLS < 3.4 will choke if we try to allow CCM-8 + if [ -z "${GNUTLS_MINOR_LT_FOUR-}" ]; then + G_PRIO_CCM="+AES-256-CCM-8:+AES-128-CCM-8:" + else + G_PRIO_CCM="" + fi + M_SERVER_ARGS="server_port=$PORT server_addr=0.0.0.0 force_version=$MODE arc4=1" O_SERVER_ARGS="-accept $PORT -cipher NULL,ALL -$MODE -dhparam data_files/dhparams.pem" G_SERVER_ARGS="-p $PORT --http $G_MODE" - G_SERVER_PRIO="NORMAL:+ARCFOUR-128:+NULL:+MD5:+PSK:+DHE-PSK:+ECDHE-PSK:+RSA-PSK:-VERS-TLS-ALL:$G_PRIO_MODE" + G_SERVER_PRIO="NORMAL:${G_PRIO_CCM}+ARCFOUR-128:+NULL:+MD5:+PSK:+DHE-PSK:+ECDHE-PSK:+RSA-PSK:-VERS-TLS-ALL:$G_PRIO_MODE" # with OpenSSL 1.0.1h, -www, -WWW and -HTTP break DTLS handshakes if is_dtls "$MODE"; then diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/Makefile b/3rdparty/mbedtls/mbedtls/tests/data_files/Makefile index 2a7a50c2e1..09db60c83f 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/Makefile +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/Makefile @@ -14,6 +14,7 @@ OPENSSL ?= openssl FAKETIME ?= faketime MBEDTLS_CERT_WRITE ?= $(PWD)/../../programs/x509/cert_write +MBEDTLS_CERT_REQ ?= $(PWD)/../../programs/x509/cert_req ## Build the generated test data. Note that since the final outputs ## are committed to the repository, this target should do nothing on a @@ -37,16 +38,38 @@ test_ca_key_file_rsa = test-ca.key test_ca_pwd_rsa = PolarSSLTest test_ca_config_file = test-ca.opensslconf -test-ca.csr: $(test_ca_key_file_rsa) $(test_ca_config_file) - $(OPENSSL) req -new -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Test CA" -out $@ -all_intermediate += test-ca.csr -test-ca-sha1.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr - $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha1 -in test-ca.csr -out $@ +test-ca.req.sha256: $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$(test_ca_key_file_rsa) password=$(test_ca_pwd_rsa) subject_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" md=SHA256 +all_intermediate += test-ca.req.sha256 + +test-ca.crt: $(test_ca_key_file_rsa) test-ca.req.sha256 + $(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144400 not_after=20210212144400 md=SHA1 version=3 output_file=$@ +all_final += test-ca.crt + +test-ca.crt.der: test-ca.crt + $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ +all_final += test-ca.crt.der + +test-ca.key.der: $(test_ca_key_file_rsa) + $(OPENSSL) pkey -in $< -out $@ -inform PEM -outform DER -passin "pass:$(test_ca_pwd_rsa)" +all_final += test-ca.key.der + +test-ca-sha1.crt: $(test_ca_key_file_rsa) test-ca.req.sha256 + $(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144400 not_after=20210212144400 md=SHA1 version=3 output_file=$@ all_final += test-ca-sha1.crt -test-ca-sha256.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr - $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha256 -in test-ca.csr -out $@ + +test-ca-sha1.crt.der: test-ca-sha1.crt + $(OPENSSL) x509 -in $< -out $@ -inform PEM -outform DER +all_final += test-ca-sha1.crt.der + +test-ca-sha256.crt: $(test_ca_key_file_rsa) test-ca.req.sha256 + $(MBEDTLS_CERT_WRITE) is_ca=1 serial=3 request_file=test-ca.req.sha256 selfsign=1 issuer_name="C=NL,O=PolarSSL,CN=PolarSSL Test CA" issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144400 not_after=20210212144400 md=SHA256 version=3 output_file=$@ all_final += test-ca-sha256.crt +test-ca-sha256.crt.der: test-ca-sha256.crt + $(OPENSSL) x509 -in $< -out $@ -inform PEM -outform DER +all_final += test-ca-sha256.crt.der + test_ca_key_file_rsa_alt = test-ca-alt.key $(test_ca_key_file_rsa_alt): @@ -67,6 +90,24 @@ all_final += test-ca-good-alt.crt test_ca_crt_file_ec = test-ca2.crt test_ca_key_file_ec = test-ca2.key +test-ca2.crt.der: $(test_ca_crt_file_ec) + $(OPENSSL) x509 -in $(test_ca_crt_file_ec) -out $@ -inform PEM -outform DER +all_final += test-ca2.crt.der + + test-ca2.key.der: $(test_ca_key_file_ec) + $(OPENSSL) pkey -in $(test_ca_key_file_ec) -out $@ -inform PEM -outform DER +all_final += test-ca2.key.der + +test_ca_crt_cat12 = test-ca_cat12.crt +$(test_ca_crt_cat12): $(test_ca_crt) $(test_ca_crt_file_ec) + cat $(test_ca_crt) $(test_ca_crt_file_ec) > $@ +all_final += $(test_ca_crt_cat12) + +test_ca_crt_cat21 = test-ca_cat21.crt +$(test_ca_crt_cat21): $(test_ca_crt) $(test_ca_crt_file_ec) + cat $(test_ca_crt_file_ec) $(test_ca_crt) > $@ +all_final += $(test_ca_crt_cat21) + test-int-ca.csr: test-int-ca.key $(test_ca_config_file) $(OPENSSL) req -new -config $(test_ca_config_file) -key test-int-ca.key -subj "/C=NL/O=PolarSSL/CN=PolarSSL Test Intermediate CA" -out $@ all_intermediate += test-int-ca.csr @@ -85,21 +126,23 @@ cli_crt_key_file_rsa = cli-rsa.key cli_crt_extensions_file = cli.opensslconf cli-rsa.csr: $(cli_crt_key_file_rsa) - $(OPENSSL) req -new -key $(cli_crt_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Client 2" -out $@ + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Client 2" md=SHA1 all_intermediate += cli-rsa.csr -cli-rsa-sha1.crt: $(cli_crt_key_file_rsa) test-ca-sha1.crt cli-rsa.csr - $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha1.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha1 -in cli-rsa.csr -out $@ -all_final += cli-rsa-sha1.crt -cli-rsa-sha256.crt: $(cli_crt_key_file_rsa) test-ca-sha256.crt cli-rsa.csr - $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in cli-rsa.csr -out $@ + +cli-rsa-sha1.crt: cli-rsa.csr + $(MBEDTLS_CERT_WRITE) request_file=$< serial=4 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@ + +cli-rsa-sha256.crt: cli-rsa.csr + $(MBEDTLS_CERT_WRITE) request_file=$< serial=4 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA256 version=3 output_file=$@ all_final += cli-rsa-sha256.crt -server2-rsa.csr: server2.key - $(OPENSSL) req -new -key server2.key -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=localhost" -out $@ -all_intermediate += server2-rsa.csr -server2-sha256.crt: server2-rsa.csr - $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in server2-rsa.csr -out $@ -all_final += server2-sha256.crt +cli-rsa-sha256.crt.der: cli-rsa-sha256.crt + $(OPENSSL) x509 -in $< -out $@ -inform PEM -outform DER +all_final += cli-rsa-sha256.crt.der + + cli-rsa.key.der: $(cli_crt_key_file_rsa) + $(OPENSSL) pkey -in $< -out $@ -inform PEM -outform DER +all_final += cli-rsa.key.der test_ca_int_rsa1 = test-int-ca.crt @@ -113,12 +156,28 @@ server7-future.crt: server7.csr $(test_ca_int_rsa1) $(FAKETIME) -f +3653d $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA $(test_ca_int_rsa1) -CAkey test-int-ca.key -set_serial 16 -days 3653 -sha256 -in server7.csr | cat - $(test_ca_int_rsa1) > $@ all_final += server7-future.crt server7-badsign.crt: server7.crt $(test_ca_int_rsa1) - { head -n-2 server7.crt; tail -n-2 server7.crt | sed -e '1s/0\(=*\)$$/_\1/' -e '1s/[^_=]\(=*\)$$/0\1/' -e '1s/_/1/'; cat test-int-ca.crt; } > server7-badsign.crt + { head -n-2 $<; tail -n-2 $< | sed -e '1s/0\(=*\)$$/_\1/' -e '1s/[^_=]\(=*\)$$/0\1/' -e '1s/_/1/'; cat $(test_ca_int_rsa1); } > $@ all_final += server7-badsign.crt server7_int-ca-exp.crt: server7.crt test-int-ca-exp.crt cat server7.crt test-int-ca-exp.crt > $@ all_final += server7_int-ca-exp.crt +cli2.crt.der: cli2.crt + $(OPENSSL) x509 -in $< -out $@ -inform PEM -outform DER +all_final += cli2.crt.der + + cli2.key.der: cli2.key + $(OPENSSL) pkey -in $< -out $@ -inform PEM -outform DER +all_final += cli2.key.der + + server5.crt.der: server5.crt + $(OPENSSL) x509 -in $< -out $@ -inform PEM -outform DER +all_final += server5.crt.der + + server5.key.der: server5.key + $(OPENSSL) pkey -in $< -out $@ -inform PEM -outform DER +all_final += server5.key.der + server5-ss-expired.crt: server5.key $(FAKETIME) -f -3653d $(OPENSSL) req -x509 -new -subj "/C=UK/O=mbed TLS/OU=testsuite/CN=localhost" -days 3653 -sha256 -key $< -out $@ all_final += server5-ss-expired.crt @@ -128,8 +187,34 @@ server5-ss-forgeca.crt: server5.key $(FAKETIME) '2015-09-01 14:08:43' $(OPENSSL) req -x509 -new -subj "/C=UK/O=mbed TLS/CN=mbed TLS Test intermediate CA 3" -set_serial 77 -config $(test_ca_config_file) -extensions noext_ca -days 3650 -sha256 -key $< -out $@ all_final += server5-ss-forgeca.crt - - +server10-badsign.crt: server10.crt + { head -n-2 $<; tail -n-2 $< | sed -e '1s/0\(=*\)$$/_\1/' -e '1s/[^_=]\(=*\)$$/0\1/' -e '1s/_/1/'; } > $@ +all_final += server10-badsign.crt +server10-bs_int3.pem: server10-badsign.crt test-int-ca3.crt + cat server10-badsign.crt test-int-ca3.crt > $@ +all_final += server10-bs_int3.pem +test-int-ca3-badsign.crt: test-int-ca3.crt + { head -n-2 $<; tail -n-2 $< | sed -e '1s/0\(=*\)$$/_\1/' -e '1s/[^_=]\(=*\)$$/0\1/' -e '1s/_/1/'; } > $@ +all_final += test-int-ca3-badsign.crt +server10_int3-bs.pem: server10.crt test-int-ca3-badsign.crt + cat server10.crt test-int-ca3-badsign.crt > $@ +all_final += server10_int3-bs.pem + +rsa_pkcs1_2048_public.pem: server8.key + $(OPENSSL) rsa -in $< -outform PEM -RSAPublicKey_out -out $@ +all_final += rsa_pkcs1_2048_public.pem + +rsa_pkcs1_2048_public.der: rsa_pkcs1_2048_public.pem + $(OPENSSL) rsa -RSAPublicKey_in -in $< -outform DER -RSAPublicKey_out -out $@ +all_final += rsa_pkcs1_2048_public.der + +rsa_pkcs8_2048_public.pem: server8.key + $(OPENSSL) rsa -in $< -outform PEM -pubout -out $@ +all_final += rsa_pkcs8_2048_public.pem + +rsa_pkcs8_2048_public.der: rsa_pkcs8_2048_public.pem + $(OPENSSL) rsa -pubin -in $< -outform DER -pubout -out $@ +all_final += rsa_pkcs8_2048_public.der ################################################################ #### Generate various RSA keys @@ -701,6 +786,106 @@ ec_prv.pk8param.pem: ec_prv.pk8param.der $(OPENSSL) pkey -in $< -inform DER -out $@ all_final += ec_prv.pk8param.pem +# server5* + +# The use of 'Server 1' in the DN is intentional here, as the DN is hardcoded in the x509_write test suite.' +server5.req.ku.sha1: server5.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< key_usage=digital_signature,non_repudiation subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server5.req.ku.sha1 + +################################################################ +### Generate CSRs for X.509 write test suite +################################################################ + +server1.req.cert_type: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< ns_cert_type=ssl_server subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.cert_type + +server1.req.key_usage: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< key_usage=digital_signature,non_repudiation,key_encipherment subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.key_usage + +server1.req.ku-ct: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< key_usage=digital_signature,non_repudiation,key_encipherment ns_cert_type=ssl_server subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.ku-ct + +server1.req.key_usage_empty: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 force_key_usage=1 +all_final += server1.req.key_usage_empty + +server1.req.cert_type_empty: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 force_ns_cert_type=1 +all_final += server1.req.cert_type_empty + +################################################################ +### Generate CSRs for X.509 write test suite +################################################################ + +server1.req.sha1: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.sha1 + +server1.req.md4: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=MD4 +all_final += server1.req.md4 + +server1.req.md5: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=MD5 +all_final += server1.req.md5 + +server1.req.sha224: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA224 +all_final += server1.req.sha224 + +server1.req.sha256: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA256 +all_final += server1.req.sha256 + +server1.req.sha384: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA384 +all_final += server1.req.sha384 + +server1.req.sha512: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA512 +all_final += server1.req.sha512 + +server1.req.cert_type: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< ns_cert_type=ssl_server subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.cert_type + +server1.req.key_usage: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< key_usage=digital_signature,non_repudiation,key_encipherment subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.key_usage + +server1.req.ku-ct: server1.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< key_usage=digital_signature,non_repudiation,key_encipherment ns_cert_type=ssl_server subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server1.req.ku-ct + +# server2* + +server2.req.sha256: server2.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=localhost" md=SHA256 +all_intermediate += server2.req.sha256 + +server2.crt.der: server2.crt + $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ +all_final += server2.crt.der + +server2-sha256.crt.der: server2-sha256.crt + $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ +all_final += server2-sha256.crt.der + +server2.key.der: server2.key + $(OPENSSL) pkey -in $< -out $@ -inform PEM -outform DER +all_final += server2.key.der + +# server5* + +# The use of 'Server 1' in the DN is intentional here, as the DN is hardcoded in the x509_write test suite.' +server5.req.ku.sha1: server5.key + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< key_usage=digital_signature,non_repudiation subject_name="C=NL,O=PolarSSL,CN=PolarSSL Server 1" md=SHA1 +all_final += server5.req.ku.sha1 + ################################################################ ### Generate certificates for CRT write check tests ################################################################ @@ -717,36 +902,34 @@ test_ca_server1_db = test-ca.server1.db test_ca_server1_serial = test-ca.server1.serial test_ca_server1_config_file = test-ca.server1.opensslconf -server1.csr: server1.key server1_csr.opensslconf - $(OPENSSL) req -keyform PEM -key server1.key -config server1_csr.opensslconf -out $@ -new -all_final += server1.csr +# server1* -server1.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@ -server1.noauthid.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 authority_identifier=0 version=3 output_file=$@ -server1.der: server1.crt +server1.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@ +server1.noauthid.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 authority_identifier=0 version=3 output_file=$@ +server1.crt.der: server1.crt $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ -all_final += server1.crt server1.noauthid.crt server1.der +all_final += server1.crt server1.noauthid.crt server1.crt.der -server1.key_usage.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 key_usage=digital_signature,non_repudiation,key_encipherment version=3 output_file=$@ -server1.key_usage_noauthid.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 key_usage=digital_signature,non_repudiation,key_encipherment authority_identifier=0 version=3 output_file=$@ +server1.key_usage.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 key_usage=digital_signature,non_repudiation,key_encipherment version=3 output_file=$@ +server1.key_usage_noauthid.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 key_usage=digital_signature,non_repudiation,key_encipherment authority_identifier=0 version=3 output_file=$@ server1.key_usage.der: server1.key_usage.crt $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ all_final += server1.key_usage.crt server1.key_usage_noauthid.crt server1.key_usage.der -server1.cert_type.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 ns_cert_type=ssl_server version=3 output_file=$@ -server1.cert_type_noauthid.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 ns_cert_type=ssl_server authority_identifier=0 version=3 output_file=$@ +server1.cert_type.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 ns_cert_type=ssl_server version=3 output_file=$@ +server1.cert_type_noauthid.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 ns_cert_type=ssl_server authority_identifier=0 version=3 output_file=$@ server1.cert_type.der: server1.cert_type.crt $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ all_final += server1.cert_type.crt server1.cert_type_noauthid.crt server1.cert_type.der -server1.v1.crt: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) - $(MBEDTLS_CERT_WRITE) request_file=server1.csr issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 version=1 output_file=$@ +server1.v1.crt: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) + $(MBEDTLS_CERT_WRITE) request_file=server1.req.sha256 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) version=1 not_before=20110212144406 not_after=20210212144406 md=SHA1 version=1 output_file=$@ server1.v1.der: server1.v1.crt $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ all_final += server1.v1.crt server1.v1.der @@ -754,11 +937,11 @@ all_final += server1.v1.crt server1.v1.der # OpenSSL-generated certificates for comparison # Also provide certificates in DER format to allow # direct binary comparison using e.g. dumpasn1 -server1.crt.openssl server1.key_usage.crt.openssl server1.cert_type.crt.openssl: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_server1_config_file) +server1.crt.openssl server1.key_usage.crt.openssl server1.cert_type.crt.openssl: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_server1_config_file) echo "01" > $(test_ca_server1_serial) rm -f $(test_ca_server1_db) touch $(test_ca_server1_db) - $(OPENSSL) ca -batch -passin "pass:$(test_ca_pwd_rsa)" -config $(test_ca_server1_config_file) -in server1.csr -extensions v3_ext -extfile $@.v3_ext -out $@ + $(OPENSSL) ca -batch -passin "pass:$(test_ca_pwd_rsa)" -config $(test_ca_server1_config_file) -in server1.req.sha256 -extensions v3_ext -extfile $@.v3_ext -out $@ server1.der.openssl: server1.crt.openssl $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ server1.key_usage.der.openssl: server1.key_usage.crt.openssl @@ -766,17 +949,53 @@ server1.key_usage.der.openssl: server1.key_usage.crt.openssl server1.cert_type.der.openssl: server1.cert_type.crt.openssl $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ -server1.v1.crt.openssl: server1.key server1.csr $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_server1_config_file) +server1.v1.crt.openssl: server1.key server1.req.sha256 $(test_ca_crt) $(test_ca_key_file_rsa) $(test_ca_server1_config_file) echo "01" > $(test_ca_server1_serial) rm -f $(test_ca_server1_db) touch $(test_ca_server1_db) - $(OPENSSL) ca -batch -passin "pass:$(test_ca_pwd_rsa)" -config $(test_ca_server1_config_file) -in server1.csr -out $@ + $(OPENSSL) ca -batch -passin "pass:$(test_ca_pwd_rsa)" -config $(test_ca_server1_config_file) -in server1.req.sha256 -out $@ server1.v1.der.openssl: server1.v1.crt.openssl $(OPENSSL) x509 -inform PEM -in $< -outform DER -out $@ -server1_all: server1.csr server1.crt server1.noauthid.crt server1.crt.openssl server1.v1.crt server1.v1.crt.openssl server1.key_usage.crt server1.key_usage_noauthid.crt server1.key_usage.crt.openssl server1.cert_type.crt server1.cert_type_noauthid.crt server1.cert_type.crt.openssl server1.der server1.der.openssl server1.v1.der server1.v1.der.openssl server1.key_usage.der server1.key_usage.der.openssl server1.cert_type.der server1.cert_type.der.openssl +server1_all: server1.crt server1.noauthid.crt server1.crt.openssl server1.v1.crt server1.v1.crt.openssl server1.key_usage.crt server1.key_usage_noauthid.crt server1.key_usage.crt.openssl server1.cert_type.crt server1.cert_type_noauthid.crt server1.cert_type.crt.openssl server1.der server1.der.openssl server1.v1.der server1.v1.der.openssl server1.key_usage.der server1.key_usage.der.openssl server1.cert_type.der server1.cert_type.der.openssl + +# server2* + +server2.crt: server2.req.sha256 + $(MBEDTLS_CERT_WRITE) request_file=server2.req.sha256 serial=2 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA1 version=3 output_file=$@ +all_final += server2.crt + +server2-sha256.crt: server2.req.sha256 + $(MBEDTLS_CERT_WRITE) request_file=server2.req.sha256 serial=2 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20110212144406 not_after=20210212144406 md=SHA256 version=3 output_file=$@ +all_final += server2-sha256.crt + +# MD2, MD4, MD5 test certificates + +cert_md_test_key = $(cli_crt_key_file_rsa) + +cert_md2.csr: $(cert_md_test_key) + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Cert MD2" md=MD2 +all_intermediate += cert_md2.csr + +cert_md2.crt: cert_md2.csr + $(MBEDTLS_CERT_WRITE) request_file=$< serial=9 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20000101121212 not_after=20300101121212 md=MD2 version=3 output_file=$@ +all_final += cert_md2.crt + +cert_md4.csr: $(cert_md_test_key) + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Cert MD4" md=MD4 +all_intermediate += cert_md4.csr + +cert_md4.crt: cert_md4.csr + $(MBEDTLS_CERT_WRITE) request_file=$< serial=5 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20000101121212 not_after=20300101121212 md=MD4 version=3 output_file=$@ +all_final += cert_md4.crt +cert_md5.csr: $(cert_md_test_key) + $(MBEDTLS_CERT_REQ) output_file=$@ filename=$< subject_name="C=NL,O=PolarSSL,CN=PolarSSL Cert MD5" md=MD5 +all_intermediate += cert_md5.csr +cert_md5.crt: cert_md5.csr + $(MBEDTLS_CERT_WRITE) request_file=$< serial=6 issuer_crt=$(test_ca_crt) issuer_key=$(test_ca_key_file_rsa) issuer_pwd=$(test_ca_pwd_rsa) not_before=20000101121212 not_after=20300101121212 md=MD5 version=3 output_file=$@ +all_final += cert_md5.crt ################################################################ #### Meta targets diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/Readme-x509.txt b/3rdparty/mbedtls/mbedtls/tests/data_files/Readme-x509.txt index b56346ab37..6f54ed0c1c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/Readme-x509.txt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/Readme-x509.txt @@ -16,11 +16,13 @@ The files test-ca_cat12 and test-ca_cat21 contain them concatenated both ways. Two intermediate CAs are signed by them: - test-int-ca.crt "C=NL, O=PolarSSL, CN=PolarSSL Test Intermediate CA" uses RSA-4096, signed by test-ca2 + - test-int-ca-exp.crt is a copy that is expired - test-int-ca2.crt "C=NL, O=PolarSSL, CN=PolarSSL Test Intermediate EC CA" - uses an EC key with NIST P-256, signed by test-ca + uses an EC key with NIST P-384, signed by test-ca A third intermediate CA is signed by test-int-ca2.crt: - test-int-ca3.crt "C=UK, O=mbed TLS, CN=mbed TLS Test intermediate CA 3" + uses an EC key with NIST P-256, signed by test-int-ca2 Finally, other CAs for specific purposes: - enco-ca-prstr.pem: has its CN encoded as a printable string, but child cert @@ -65,21 +67,41 @@ List of certificates: - server2*.crt: 1 R L: misc - server3.crt: 1 E L: EC cert signed by RSA CA - server4.crt: 2 R L: RSA cert signed by EC CA -- server5*.crt: 2* E L: misc *(except server5-selfsigned) +- server5*.crt: 2* E L: misc *(except -selfsigned and -ss-*) -sha*: hashes - -eku*: extendeKeyUsage (cli/srv = www client/server, cs = codesign, etc) - -ku*: keyUsage (ds = signatures, ke/ka = key exchange/agreement) + .eku*: extendeKeyUsage (cli/srv = www client/server, cs = codesign, etc) + .ku*: keyUsage (ds = signatures, ke/ka = key exchange/agreement) + .req*: CSR, not certificate + -der*: trailing bytes in der (?) + -badsign.crt: S5 with corrupted signature + -expired.crt: S5 with "not after" date in the past + -future.crt: S5 with "not before" date in the future + -selfsigned.crt: Self-signed cert with S5 key + -ss-expired.crt: Self-signed cert with S5 key, expired + -ss-forgeca.crt: Copy of test-int-ca3 self-signed with S5 key - server6-ss-child.crt: O E: "child" of non-CA server5-selfsigned - server6.crt, server6.pem: 2 E L C: revoked -- server7*.crt: I1 E L P1*: EC signed by RSA signed by EC - *P1 except 7.crt, P2 _int-ca_ca2.crt - *_space: with PEM error(s) - _spurious: has spurious cert in its chain (S7 + I2 + I1) +- server7.crt: I1 E L P1(usually): EC signed by RSA signed by EC + -badsign.crt: S7 with corrupted signature + I1 + -expired.crt: S7 with "not after" date in the past + I1 + -future.crt: S7 with "not before" date in the future + I1 + _int-ca-exp.crt: S7 + expired I1 + _int-ca.crt: S7 + I1 + _int-ca_ca2.crt: S7 + I1 + 2 + _all_space.crt: S7 + I1 both with misplaced spaces (invalid PEM) + _pem_space.crt: S7 with misplace space (invalid PEM) + I1 + _trailing_space.crt: S7 + I1 both with trainling space (valid PEM) + _spurious_int-ca.crt: S7 + I2(spurious) + I1 - server8*.crt: I2 R L: RSA signed by EC signed by RSA (P1 for _int-ca2) - server9*.crt: 1 R C* L P1*: signed using RSASSA-PSS *CRL for: 9.crt, -badsign, -with-ca (P1) -- server10*.crt: I3 E L P2/P3 - _spurious: S10 + I3 + I1(spurious) + I2 +- server10.crt: I3 E L + -badsign.crt: S10 with corrupted signature + -bs_int3.pem: S10-badsign + I3 + _int3-bs.pem: S10 + I3-badsign + _int3_int-ca2.crt: S10 + I3 + I2 + _int3_int-ca2_ca.crt: S10 + I3 + I2 + 1 + _int3_spurious_int-ca2.crt: S10 + I3 + I1(spurious) + I2 Certificate revocation lists ---------------------------- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md2.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md2.crt index bfea77b6f3..94b89afce3 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md2.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md2.crt @@ -1,77 +1,20 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 9 (0x9) - Signature Algorithm: md2WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Jul 12 10:56:59 2009 GMT - Not After : Jul 12 10:56:59 2011 GMT - Subject: C=NL, O=PolarSSL, CN=PolarSSL Cert MD2 - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:dc:13:74:81:c6:12:f6:67:5d:a1:66:72:ed:dc: - 79:b6:58:5c:32:58:b3:d4:14:fd:6c:02:61:9e:0b: - 99:46:63:a3:0a:41:d4:42:33:21:e6:ed:43:07:5a: - 1d:a2:3b:64:29:a8:2a:c1:66:28:00:59:d8:0c:49: - 2d:30:b7:3d:8c:bb:60:62:31:83:27:7f:4b:95:92: - 2e:a0:d6:c6:84:94:4b:b3:e4:a6:cc:ff:32:3a:c5: - ec:4c:c9:24:58:bf:b3:33:77:6a:b5:17:8b:02:10: - 29:8e:95:aa:91:60:17:43:42:87:a8:7c:da:09:83: - 98:9d:7a:65:5e:20:52:07:2e:65:a5:31:fd:d9:74: - 1e:00:c9:ae:9d:81:56:8b:08:0a:f5:1e:9c:dc:a2: - 5e:6c:db:ff:11:83:15:f4:d1:24:57:9b:0f:eb:35: - c9:f1:aa:46:4e:74:7f:fe:1d:b0:91:1f:89:4a:84: - cb:df:75:e3:cd:77:82:62:09:e5:9f:6d:29:de:2e: - 25:d8:48:b6:20:be:51:97:4c:2d:20:65:2d:2a:50: - 9e:24:5d:72:95:e0:a2:06:41:8c:61:e4:50:57:74: - 96:b1:29:b5:a1:88:37:f1:5c:9e:b2:9e:8e:83:8d: - 72:3b:b5:5c:fe:bb:12:89:72:5c:a1:f9:d8:18:29: - b2:27 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - X509v3 Subject Key Identifier: - B7:51:D4:E5:20:D5:45:54:F4:C5:51:1B:E0:82:B5:61:05:AF:9B:B6 - X509v3 Authority Key Identifier: - keyid:CF:22:31:27:91:D8:C2:54:FF:1E:DA:D9:EE:8A:C5:89:32:AD:0C:21 - - Signature Algorithm: md2WithRSAEncryption - 28:5a:dd:48:fb:ec:80:fe:de:b7:20:c0:4c:05:a9:4b:51:e9: - a7:d1:4b:5e:76:42:d2:5d:9a:14:19:3b:cb:f9:91:d7:0f:11: - c9:cd:dd:00:8b:2c:76:73:22:a0:19:49:81:63:40:30:48:27: - 62:90:ca:b8:dc:33:35:b3:4b:58:ca:dc:07:66:87:2e:ea:44: - 2a:6a:13:67:7a:32:5e:48:1d:88:88:c5:70:e6:e7:ec:1b:2f: - a7:f4:61:71:29:f6:66:93:30:60:7e:b3:4c:01:c8:2c:53:ce: - 00:11:ec:bf:f6:f2:ce:51:97:d8:ed:ed:dc:c9:6b:b8:19:15: - c8:9a:61:6d:12:9a:99:25:d8:03:1d:a6:4c:20:a5:f8:46:a3: - 05:32:bb:1a:8e:1a:65:0d:f3:13:35:1d:6f:73:28:31:12:d7: - c4:9e:73:a0:a7:ce:82:25:d1:40:e8:1b:77:60:f3:3e:81:7f: - 19:ee:cf:97:4d:c8:c3:35:9b:72:98:3b:c3:35:43:14:0a:04: - 21:7b:f7:db:e6:5f:ce:21:d1:ce:bf:b7:ef:c1:63:21:c2:78: - e1:37:aa:b1:e0:31:b3:b6:63:4c:fd:66:c8:e6:cf:f8:d9:97: - 2f:cf:92:81:3f:d4:bf:ec:e2:ad:6e:39:c7:a6:a8:e0:32:b0: - 2e:0d:e1:30 -----BEGIN CERTIFICATE----- MIIDPzCCAiegAwIBAgIBCTANBgkqhkiG9w0BAQIFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MDkwNzEyMTA1NjU5WhcNMTEwNzEyMTA1NjU5WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIENlcnQgTUQyMIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3BN0gcYS9mddoWZy7dx5tlhcMliz -1BT9bAJhnguZRmOjCkHUQjMh5u1DB1odojtkKagqwWYoAFnYDEktMLc9jLtgYjGD -J39LlZIuoNbGhJRLs+SmzP8yOsXsTMkkWL+zM3dqtReLAhApjpWqkWAXQ0KHqHza -CYOYnXplXiBSBy5lpTH92XQeAMmunYFWiwgK9R6c3KJebNv/EYMV9NEkV5sP6zXJ -8apGTnR//h2wkR+JSoTL33XjzXeCYgnln20p3i4l2Ei2IL5Rl0wtIGUtKlCeJF1y -leCiBkGMYeRQV3SWsSm1oYg38Vyesp6Og41yO7Vc/rsSiXJcofnYGCmyJwIDAQAB -o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBS3UdTlINVFVPTFURvggrVhBa+btjAf -BgNVHSMEGDAWgBTPIjEnkdjCVP8e2tnuisWJMq0MITANBgkqhkiG9w0BAQIFAAOC -AQEAKFrdSPvsgP7etyDATAWpS1Hpp9FLXnZC0l2aFBk7y/mR1w8Ryc3dAIssdnMi -oBlJgWNAMEgnYpDKuNwzNbNLWMrcB2aHLupEKmoTZ3oyXkgdiIjFcObn7Bsvp/Rh -cSn2ZpMwYH6zTAHILFPOABHsv/byzlGX2O3t3MlruBkVyJphbRKamSXYAx2mTCCl -+EajBTK7Go4aZQ3zEzUdb3MoMRLXxJ5zoKfOgiXRQOgbd2DzPoF/Ge7Pl03IwzWb -cpg7wzVDFAoEIXv32+ZfziHRzr+378FjIcJ44TeqseAxs7ZjTP1myObP+NmXL8+S -gT/Uv+zirW45x6ao4DKwLg3hMA== +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MDAwMTAxMTIxMjEyWhcNMzAwMTAxMTIxMjEyWjA8MQswCQYDVQQGEwJOTDERMA8G +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENlcnQgTUQyMIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f +M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu +1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw +MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v +4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/ +/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB +o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf +BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQIFAAOC +AQEAXLWqy34iaZ2YV+5eE1QMV/9m9nQI2X/yumRH1MT1R3oYde/YDV7+HSOM6qLs +qSgH1DSyXv1YnJww2OyTtAVhPalICLjVjUQCyeUCiFpAIO6Xz1VE6v4GMFLqhlV1 +Nox9dDtR5Go2zwPaH64Ze9GxuDZfW+VnPRNgYOrqqCBnuhnp2uPRfOewus2AAo50 +dx1XTooCEqElQlB9EIPWbvPdJZjRjruCUtDbz+oxG4J4Ml4KCYm+/MyXNPqxV9+H +5A9oQltuHMWasMWSfXeimQI5PPpdjndmJOhfT4RGmvTw/uNC/Xuy1kPxXQKoocz6 +93U8RQvyJxdIPtQuARNMRZ7G+Q== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md4.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md4.crt index 16f166b815..7d0f7cb1b4 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md4.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md4.crt @@ -1,77 +1,20 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 5 (0x5) - Signature Algorithm: md4WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Feb 12 14:44:07 2011 GMT - Not After : Feb 12 14:44:07 2021 GMT - Subject: C=NL, O=PolarSSL, CN=PolarSSL Cert MD4 - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:b9:3c:4a:c5:c8:a3:8e:90:17:a4:9e:52:aa:71: - 75:26:61:80:e7:c7:b5:6d:8c:ff:aa:b6:41:26:b7: - be:11:ad:5c:73:16:0c:64:11:48:04:ff:d6:e1:3b: - 05:db:89:bb:b3:97:09:d5:1c:14:dd:68:87:39:b0: - 3d:71:cb:e2:76:d0:1a:d8:18:2d:80:1b:54:f6:e5: - 44:9a:f1:cb:af:61:2e:df:49:0d:9d:09:b7:ed:b1: - fd:3c:fd:3c:fa:24:cf:5d:bf:7c:e4:53:e7:25:b5: - ea:44:22:e9:26:d3:ea:20:94:9e:e6:61:67:ba:2e: - 07:67:0b:03:2f:a2:09:ed:f0:33:8f:0b:ce:10:ef: - 67:a4:c6:08:da:c1:ed:c2:3f:d7:4a:dd:15:3d:f9: - 5e:1c:81:60:46:3e:b5:b3:3d:2f:a6:de:47:1c:bc: - 92:ae:eb:df:27:6b:16:56:b7:dc:ec:d1:55:57:a5: - 6e:ec:75:25:f5:b7:7b:df:ab:d2:3a:5a:91:98:7d: - 97:17:0b:13:0a:a7:6b:4a:8b:c1:47:30:fb:3a:f8: - 41:04:d5:c1:df:b8:1d:bf:7b:01:a5:65:a2:e0:1e: - 36:b7:a6:5c:cc:30:5a:f8:cd:6f:cd:f1:19:62:25: - ca:01:e3:35:7f:fa:20:f5:dc:fd:69:b2:6a:00:7d: - 17:f7 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - X509v3 Subject Key Identifier: - 7D:E4:9C:6B:E6:F9:71:7D:46:D2:12:3D:AD:6B:1D:FD:C2:AA:78:4C - X509v3 Authority Key Identifier: - keyid:B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - - Signature Algorithm: md4WithRSAEncryption - 94:db:e1:86:71:2d:43:d6:51:61:a7:95:bc:e8:73:da:ff:e4: - fd:41:0f:5c:de:14:f4:c4:ba:5d:2c:30:2c:a6:dc:2d:e8:87: - 45:f1:c5:fe:d1:4a:64:99:19:09:2f:72:7c:3f:8d:c8:31:22: - dd:0a:69:03:3d:12:8c:4d:c3:f7:a3:c5:d1:5d:c9:ff:4b:83: - 6b:d6:b4:e5:d8:ce:94:5e:ec:bf:68:c5:b2:63:8e:5c:cb:f3: - 8d:62:73:82:62:7e:df:db:7d:0b:8d:21:10:db:9a:a1:62:4d: - 46:42:d1:bb:38:32:ef:c1:fc:a1:e2:7f:60:08:37:32:20:2c: - 7c:a2:c9:12:0d:89:fe:2b:15:08:91:79:e2:a9:79:a4:da:cd: - 81:43:01:e2:09:2d:1a:f4:16:ef:af:4d:50:46:5e:2d:dd:48: - 27:10:c0:42:b7:a5:9e:c2:1f:6e:50:36:03:ed:95:77:9a:a3: - d9:4c:d7:23:93:b1:24:2a:63:27:28:7a:de:3d:59:d2:92:c8: - 8f:f6:39:1d:65:ab:09:78:05:46:90:a9:f6:10:b1:ef:c8:8c: - 4d:7d:8d:f2:78:b7:88:15:09:7e:df:e9:87:a8:64:c1:95:53: - fb:da:05:b7:62:bc:ad:fb:d9:a4:a9:06:6c:6b:98:01:b9:39: - 78:d3:4e:87 -----BEGIN CERTIFICATE----- MIIDPzCCAiegAwIBAgIBBTANBgkqhkiG9w0BAQMFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTEwMjEyMTQ0NDA3WhcNMjEwMjEyMTQ0NDA3WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIENlcnQgTUQ0MIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuTxKxcijjpAXpJ5SqnF1JmGA58e1 -bYz/qrZBJre+Ea1ccxYMZBFIBP/W4TsF24m7s5cJ1RwU3WiHObA9ccvidtAa2Bgt -gBtU9uVEmvHLr2Eu30kNnQm37bH9PP08+iTPXb985FPnJbXqRCLpJtPqIJSe5mFn -ui4HZwsDL6IJ7fAzjwvOEO9npMYI2sHtwj/XSt0VPfleHIFgRj61sz0vpt5HHLyS -ruvfJ2sWVrfc7NFVV6Vu7HUl9bd736vSOlqRmH2XFwsTCqdrSovBRzD7OvhBBNXB -37gdv3sBpWWi4B42t6ZczDBa+M1vzfEZYiXKAeM1f/og9dz9abJqAH0X9wIDAQAB -o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBR95Jxr5vlxfUbSEj2tax39wqp4TDAf +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MDAwMTAxMTIxMjEyWhcNMzAwMTAxMTIxMjEyWjA8MQswCQYDVQQGEwJOTDERMA8G +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENlcnQgTUQ0MIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f +M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu +1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw +MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v +4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/ +/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB +o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQMFAAOC -AQEAlNvhhnEtQ9ZRYaeVvOhz2v/k/UEPXN4U9MS6XSwwLKbcLeiHRfHF/tFKZJkZ -CS9yfD+NyDEi3QppAz0SjE3D96PF0V3J/0uDa9a05djOlF7sv2jFsmOOXMvzjWJz -gmJ+39t9C40hENuaoWJNRkLRuzgy78H8oeJ/YAg3MiAsfKLJEg2J/isVCJF54ql5 -pNrNgUMB4gktGvQW769NUEZeLd1IJxDAQrelnsIfblA2A+2Vd5qj2UzXI5OxJCpj -Jyh63j1Z0pLIj/Y5HWWrCXgFRpCp9hCx78iMTX2N8ni3iBUJft/ph6hkwZVT+9oF -t2K8rfvZpKkGbGuYAbk5eNNOhw== +AQEArXIW7Dy1hBXMKY8/TAfACqkFZzbGDJdD5ohQknENk6FzUHVw9SVibhi5J+nh +/mhUhoczFg78T8ZopDcsPHKQTuy0LNcLWhZDD4S4CJCibmsf+8BWmPcSp1tsS9Zj +etO5qNuUarL74W+rRa3qQcCXcglYTubv/PcCV+LGVqZ4XDlO5EBFJJREAREzG+iK +Epm2y0mi1WTwjy7m7rxYHs5i5ybDHDDwU55H5wh50Vs4/vDx2kZab2K9gx6V2ggY +CCYmRWKQHdI4XZBkpYFbbREZxMY4Y5c2PUMlr8GUq6s6eu9/GvmnIx/+EySSfxgv +9GpN+gnyx03hjYNGO7iX8nPnXA== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md5.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md5.crt index 13d43f1acb..e514fd631c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md5.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/cert_md5.crt @@ -1,77 +1,20 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 6 (0x6) - Signature Algorithm: md5WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Feb 12 14:44:07 2011 GMT - Not After : Feb 12 14:44:07 2021 GMT - Subject: C=NL, O=PolarSSL, CN=PolarSSL Cert MD5 - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:b9:3c:4a:c5:c8:a3:8e:90:17:a4:9e:52:aa:71: - 75:26:61:80:e7:c7:b5:6d:8c:ff:aa:b6:41:26:b7: - be:11:ad:5c:73:16:0c:64:11:48:04:ff:d6:e1:3b: - 05:db:89:bb:b3:97:09:d5:1c:14:dd:68:87:39:b0: - 3d:71:cb:e2:76:d0:1a:d8:18:2d:80:1b:54:f6:e5: - 44:9a:f1:cb:af:61:2e:df:49:0d:9d:09:b7:ed:b1: - fd:3c:fd:3c:fa:24:cf:5d:bf:7c:e4:53:e7:25:b5: - ea:44:22:e9:26:d3:ea:20:94:9e:e6:61:67:ba:2e: - 07:67:0b:03:2f:a2:09:ed:f0:33:8f:0b:ce:10:ef: - 67:a4:c6:08:da:c1:ed:c2:3f:d7:4a:dd:15:3d:f9: - 5e:1c:81:60:46:3e:b5:b3:3d:2f:a6:de:47:1c:bc: - 92:ae:eb:df:27:6b:16:56:b7:dc:ec:d1:55:57:a5: - 6e:ec:75:25:f5:b7:7b:df:ab:d2:3a:5a:91:98:7d: - 97:17:0b:13:0a:a7:6b:4a:8b:c1:47:30:fb:3a:f8: - 41:04:d5:c1:df:b8:1d:bf:7b:01:a5:65:a2:e0:1e: - 36:b7:a6:5c:cc:30:5a:f8:cd:6f:cd:f1:19:62:25: - ca:01:e3:35:7f:fa:20:f5:dc:fd:69:b2:6a:00:7d: - 17:f7 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - X509v3 Subject Key Identifier: - 7D:E4:9C:6B:E6:F9:71:7D:46:D2:12:3D:AD:6B:1D:FD:C2:AA:78:4C - X509v3 Authority Key Identifier: - keyid:B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - - Signature Algorithm: md5WithRSAEncryption - 92:13:81:0c:ff:ac:ab:98:52:6c:28:c9:c6:3e:80:c6:ec:77: - d0:13:e1:a2:29:1d:2f:b7:c5:95:41:83:60:d9:50:9c:d0:d6: - 09:f7:0f:97:cd:c0:e6:b2:68:fa:31:c9:2a:a3:d3:1e:53:ae: - 79:dc:35:ba:b0:d9:e5:7a:37:1b:2a:92:fa:d2:59:90:43:1b: - 6a:91:c1:db:36:da:e9:39:d3:f5:ac:e3:46:01:ca:55:04:17: - 1a:b1:97:28:e8:ff:1b:e7:e1:10:c9:b5:31:d8:ce:a6:89:6a: - 4a:df:78:7b:02:2f:83:b3:41:d5:ef:0b:b6:44:ff:32:a6:cf: - 1b:c2:f4:b0:75:66:a9:da:6f:7c:a5:e3:c6:c1:3a:2f:bf:f8: - 12:6f:04:2c:37:f2:4e:fc:b9:09:ff:a4:5b:40:19:e9:58:91: - 64:82:d6:ad:b9:7f:c0:12:c2:ce:b7:b6:ba:fb:10:a2:3f:74: - 97:10:39:d4:dc:4a:e5:5c:f7:e5:3a:d9:68:d7:17:6b:f5:51: - 08:b4:a2:30:0d:cc:36:10:6d:4e:1d:22:cc:48:d1:38:44:ba: - cc:2b:47:99:f7:c6:8b:41:24:f3:f1:2c:10:1a:f2:88:bb:b2: - e0:fd:44:26:3d:ad:ea:af:1d:d0:00:56:41:4e:f4:b0:3b:9d: - 32:6f:48:c7 -----BEGIN CERTIFICATE----- MIIDPzCCAiegAwIBAgIBBjANBgkqhkiG9w0BAQQFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTEwMjEyMTQ0NDA3WhcNMjEwMjEyMTQ0NDA3WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIENlcnQgTUQ1MIIBIjAN -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuTxKxcijjpAXpJ5SqnF1JmGA58e1 -bYz/qrZBJre+Ea1ccxYMZBFIBP/W4TsF24m7s5cJ1RwU3WiHObA9ccvidtAa2Bgt -gBtU9uVEmvHLr2Eu30kNnQm37bH9PP08+iTPXb985FPnJbXqRCLpJtPqIJSe5mFn -ui4HZwsDL6IJ7fAzjwvOEO9npMYI2sHtwj/XSt0VPfleHIFgRj61sz0vpt5HHLyS -ruvfJ2sWVrfc7NFVV6Vu7HUl9bd736vSOlqRmH2XFwsTCqdrSovBRzD7OvhBBNXB -37gdv3sBpWWi4B42t6ZczDBa+M1vzfEZYiXKAeM1f/og9dz9abJqAH0X9wIDAQAB -o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBR95Jxr5vlxfUbSEj2tax39wqp4TDAf +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MDAwMTAxMTIxMjEyWhcNMzAwMTAxMTIxMjEyWjA8MQswCQYDVQQGEwJOTDERMA8G +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENlcnQgTUQ1MIIBIjAN +BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f +M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu +1C93KYRhTYJQj6eVSHD1bk2y1RPD0hrt5kPqQhTrdOrA7R/UV06p86jt0uDBMHEw +MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v +4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/ +/DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB +o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQQFAAOC -AQEAkhOBDP+sq5hSbCjJxj6Axux30BPhoikdL7fFlUGDYNlQnNDWCfcPl83A5rJo -+jHJKqPTHlOuedw1urDZ5Xo3GyqS+tJZkEMbapHB2zba6TnT9azjRgHKVQQXGrGX -KOj/G+fhEMm1MdjOpolqSt94ewIvg7NB1e8LtkT/MqbPG8L0sHVmqdpvfKXjxsE6 -L7/4Em8ELDfyTvy5Cf+kW0AZ6ViRZILWrbl/wBLCzre2uvsQoj90lxA51NxK5Vz3 -5TrZaNcXa/VRCLSiMA3MNhBtTh0izEjROES6zCtHmffGi0Ek8/EsEBryiLuy4P1E -Jj2t6q8d0ABWQU70sDudMm9Ixw== +AQEAF4QcMshVtVbYgvvU7f2lWakubbAISM/k+FW/f7u63m0MSSoSFeYflBOC1Wf4 +imgDEnWcWTH5V7sxsLNogxfpfTuFUaKfHeQmRhAK4UgqbDEs4dZvgo3wZ/w92G0/ +QNntJefnqaFiITXZTn6J8hxeoEq4QbucbWgeY6fTAwXtIv40BvMOSakkuIFAyIvV +90VY1j4vnx0/xv5lIBAxah1HdtXhqtDu/sUfdCtWX5SCcVUwwM3gZ4Q1ZdWQmlvF +737ZG7XaINxsDaI04sJxc7qvuRYhLdCwUPnZL5TGEQJ8jNa/39eEbnkvs7hbTU98 +6qG8UAYsSI7aMe1j7DZpkoPL9w== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha1.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha1.crt index 906f6dfa77..ffbe21a175 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha1.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha1.crt @@ -1,7 +1,7 @@ -----BEGIN CERTIFICATE----- -MIIDhTCCAm2gAwIBAgIBBDANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER +MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA1MTMwNzEwWhcNMjcwNTA2MTMwNzEwWjA8MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu @@ -9,13 +9,12 @@ M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v 4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/ /DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB -o4GSMIGPMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITBjBgNVHSMEXDBa -gBS0WuSls97SUva51aaVD+s+vMf9/6E/pD0wOzELMAkGA1UEBhMCTkwxETAPBgNV -BAoMCFBvbGFyU1NMMRkwFwYDVQQDDBBQb2xhclNTTCBUZXN0IENBggEAMAkGA1Ud -EwQCMAAwDQYJKoZIhvcNAQEFBQADggEBAE/yq2fOqjI0jm52TwdVsTUvZ+B2s16u -C4Qj/c89iZ7VfplpOAEV9+G6gHm/gf2O7Jgj0yXfFugQ2d+lR70cH64JFn9N1Rg9 -gCo5EDBLourI8R0Kkg9zdlShBv7giwqg667Qjsu+oEWVerICOqNQGolotYSZvmtJ -7RiD8I4MXB4Qt0sSjxE897pvc4ODem10zXzvedv/q11q1mUn2L1fFc1dGIguk1fn -I/XP87FCapRobUTYrF6IvdqFaUMQ7lF3GiUIvjDPb4Wt1CyHhi/tu/SfV3fmX3rs -19UeGnvC7AdQ+OwLt3nEIlSpqVKPXHKfRKZg1WzZNgCQtNB1SrZAzFc= +o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf +BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQUFAAOC +AQEAX0vLL6qw6zYaO7a1ZXXJhWL8/vm1+yz5HrnXPX62xBD7P+cVGrOoNbD1QAj9 +otOpUsWYmHRvhotO42oqPsnoPA0JpGRR2elbTrcK9uDxg6PWwoix3uHPRuXdRIsU +jee2TcGilXgJw1HDvJ04E5qowAtAgOcE41ZraAN43GHO2PjxcXEEoWzqSqvlUrv3 +AOaCTn9X73izMRgPbQBnJjknIzoYwWgVFaDEW/lZE0+LLa99/mxFFUBhYzAY+h/R +rmtslJIyIzTd3sLo+XZ0hNtlBM0u1okOspSWtmoNdSiJDZMJ4LL71xuJYG46Sl/0 +1hH/1pZigeufZgYrQgqG8oHT4A== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt index a0fc11e202..c81f98fb31 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt @@ -1,7 +1,7 @@ -----BEGIN CERTIFICATE----- -MIIDhTCCAm2gAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER +MIIDPzCCAiegAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA1MTMwNzU5WhcNMjcwNTA2MTMwNzU5WjA8MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIENsaWVudCAyMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyHTEzLn5tXnpRdkUYLB9u5Pyax6f M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu @@ -9,13 +9,12 @@ M60Nj4o8VmXl3ETZzGaFB9X4J7BKNdBjngpuG7fa8H6r7gwQk4ZJGDTzqCrSV/Uu MjDV0/YI0FZPRo7yX/k9Z5GIMC5Cst99++UMd//sMcB4j7/Cf8qtbCHWjdmLao5v 4Jv4EFbMs44TFeY0BGbH7vk2DmqV9gmaBmf0ZXH4yqSxJeD+PIs1BGe64E92hfx/ /DZrtenNLQNiTrM9AM+vdqBpVoNq0qjU51Bx5rU2BXcFbXvI5MT9TNUhXwIDAQAB -o4GSMIGPMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITBjBgNVHSMEXDBa -gBS0WuSls97SUva51aaVD+s+vMf9/6E/pD0wOzELMAkGA1UEBhMCTkwxETAPBgNV -BAoMCFBvbGFyU1NMMRkwFwYDVQQDDBBQb2xhclNTTCBUZXN0IENBggEAMAkGA1Ud -EwQCMAAwDQYJKoZIhvcNAQELBQADggEBAC7yO786NvcHpK8UovKIG9cB32oSQQom -LoR0eHDRzdqEkoq7yGZufHFiRAAzbMqJfogRtxlrWAeB4y/jGaMBV25IbFOIcH2W -iCEaMMbG+VQLKNvuC63kmw/Zewc9ThM6Pa1Hcy0axT0faf1B/U01j0FIcw/6mTfK -D8w48OIwc1yr0JtutCVjig5DC0yznGMt32RyseOLcUe+lfq005v2PAiCozr5X8rE -ofGZpiM2NqRPePgYy+Vc75Zk28xkRQq1ncprgQb3S4vTsZdScpM9hLf+eMlrgqlj -c5PLSkXBeLE5+fedkyfTaLxxQlgCpuoOhKBm04/R1pWNzUHyqagjO9Q= +o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBRxoQBzckAvVHZeM/xSj7zx3WtGITAf +BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQsFAAOC +AQEAlHabem2Tu69VUN7EipwnQn1dIHdgvT5i+iQHpSxY1crPnBbAeSdAXwsVEqLQ +gOOIAQD5VIITNuoGgo4i+4OpNh9u7ZkpRHla+/swsfrFWRRbBNP5Bcu74AGLstwU +zM8gIkBiyfM1Q1qDQISV9trlCG6O8vh8dp/rbI3rfzo99BOHXgFCrzXjCuW4vDsF +r+Dao26bX3sJ6UnEWg1H3o2x6PpUcvQ36h71/bz4TEbbUUEpe02V4QWuL+wrhHJL +U7o3SVE3Og7jPF8sat0a50YUWhwEFI256m02KAXLg89ueUyYKEr6rNwhcvXJpvU9 +giIVvd0Sbjjnn7NC4VDbcXV8vw== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt.der new file mode 100644 index 0000000000..8fa3d1b5f0 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.key.der new file mode 100644 index 0000000000..8ef5a0464a Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa-sha256.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa.key.der new file mode 100644 index 0000000000..8ef5a0464a Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/cli-rsa.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli2.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/cli2.crt.der new file mode 100644 index 0000000000..6ad236e2f0 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/cli2.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/cli2.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/cli2.key.der new file mode 100644 index 0000000000..acba6a0276 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/cli2.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs1_2048_public.der b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs1_2048_public.der new file mode 100644 index 0000000000..b6865144ab Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs1_2048_public.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs1_2048_public.pem b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs1_2048_public.pem new file mode 100644 index 0000000000..9040cb04d4 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs1_2048_public.pem @@ -0,0 +1,8 @@ +-----BEGIN RSA PUBLIC KEY----- +MIIBCgKCAQEA2xx/LgvNv87RdRCgorjOfariBeB62ERjj7W9wLAZuTe4GUoO8V10 +gGdGhwbeW38GA73BjV4HFdRb9Nzlzz35wREsrmq5ir0dZ2YX6k692xWagofk8HjD +o4WHsP2fqZlf4zPszOoLtWFe8Ul+P6Mt6gEMzEKadpvE0DfTsRcBYQEWWX4cF8NT +/dFyy0xgFdp94uqtUO+O4ovUandV1nDZa7vx7jkEOKO94tHgZmvinEeZ6Sjmtvwu +ymdDhOjVg9admGsBPoHcPHrK+fOc99YoGyd4fMPQ1WOngTSJrSVqvfLq7fpX/OU0 +xsEPcS3SCBAbrURB4P55oGOTirFd6bDubwIDAQAB +-----END RSA PUBLIC KEY----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_1024_public.der b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_1024_public.der new file mode 100644 index 0000000000..fe429985bf Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_1024_public.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_2048_public.der b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_2048_public.der new file mode 100644 index 0000000000..8644a5647e Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_2048_public.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_2048_public.pem b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_2048_public.pem new file mode 100644 index 0000000000..f1e29cc6e1 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/rsa_pkcs8_2048_public.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2xx/LgvNv87RdRCgorjO +fariBeB62ERjj7W9wLAZuTe4GUoO8V10gGdGhwbeW38GA73BjV4HFdRb9Nzlzz35 +wREsrmq5ir0dZ2YX6k692xWagofk8HjDo4WHsP2fqZlf4zPszOoLtWFe8Ul+P6Mt +6gEMzEKadpvE0DfTsRcBYQEWWX4cF8NT/dFyy0xgFdp94uqtUO+O4ovUandV1nDZ +a7vx7jkEOKO94tHgZmvinEeZ6SjmtvwuymdDhOjVg9admGsBPoHcPHrK+fOc99Yo +Gyd4fMPQ1WOngTSJrSVqvfLq7fpX/OU0xsEPcS3SCBAbrURB4P55oGOTirFd6bDu +bwIDAQAB +-----END PUBLIC KEY----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1-ms.req.sha256 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1-ms.req.sha256 new file mode 100644 index 0000000000..b0d9414a25 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1-ms.req.sha256 @@ -0,0 +1,16 @@ +-----BEGIN NEW CERTIFICATE REQUEST----- +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow +GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ +ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ +HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF +W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs +FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ +DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBCwUA +A4IBAQBY/1nnYQ3ThVyeZb1Z2wLYoHZ5rfeJCedyP7N/gjJZjhrMbwioUft2uHpb ++OZQfxRXJTbtj/1wpRMCoUMLWzapS7/xGx3IjoPtl42aM4M+xVYvbLjExL13kUAr +eE4JWcMIbTEPol2zSdX/LuB+m27jEp5VsvM2ty9qOw/T4iKwjFSe6pcYZ2spks19 +3ltgjnaamwqKcN9zUA3IERTsWjr5exKYgfXm2OeeuSP0tHr7Dh+w/2XA9dGcLhrm +TA4P8QjIgSDlyzmhYYmsrioFPuCfdi1uzs8bxmbLXbiCGZ8TDMy5oLqLo1K+j2pF +ox+ATHKxQ/XpRQP+2OTb9sw1kM59 +-----END NEW CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type.crt index 91c3a90213..fb59ab8bd6 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type.crt @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE----- MIIDUjCCAjqgAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/ uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf @@ -11,10 +11,10 @@ lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB o2AwXjAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAf BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zARBglghkgBhvhCAQEEBAMC -AEAwDQYJKoZIhvcNAQEFBQADggEBAJ28VuktjDGkUWcVpM/W+YjohFDay676Yozx -BbBLU3QZiDkcdXZbX/jOaKKBGWrjWiB6txchV4XrlvEtVtPgPrQLil2xaD20LOqJ -e/ZEFIAIndf06CAcimdQaPD6mww04v3gZw3cwPQd/aMQCw9tm93tyf6YU4uIh/o8 -evG1ZBrNHRyiW18kbuueLNZ2daYQIISRJSIFrAERacfOvA8r7yXJCqZnB6AU5j9u -V+ySNW3sdZIOTfs1nWKU6SECWo72dd89Yvs7wCf3NSZNM2UemLeOjQOmZIHBiR8L -PAhDxhra5B/QBKaWeTVQohEvKz75pLAWouUGIKlgHiqJ4cvBGcg= +BkAwDQYJKoZIhvcNAQEFBQADggEBAK1WXZYd6k7/zE2NcszT6rxNaSixPZrDYzRt +Iz5rpH33IHkCdR956/ExCcDMqGNVtKtBdr8kw3+jzyPQhwyHVPNv4C/cgt0C89Pf +qZLQGuEPVp1X4tzEY2Kno9c1tllLVzJdvz1mRhSb9z5CWQKNMT+8MMl3k+0NZ4LT +NEx4gTZxYEsAGEuO/Yij9ctxp4RdSP585FXgiMC00ieMe/aJxlOIgpIhuWdu0KPP +G5guYd4hQ9ZrGVOGdjv2cZbh4DuQOsCwU9in/e1RKFV6eMmyOdvLJ4jkTauwkGJG +lCclZZQwzGawOiMl2OYPUia5bkaEsdE/0QW/lf36lco8CNjpUfY= -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type_noauthid.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type_noauthid.crt index ed8b80baaf..0082b148ca 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type_noauthid.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.cert_type_noauthid.crt @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE----- MIIDMTCCAhmgAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/ uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf @@ -10,11 +10,11 @@ CrFTxjB+FTms+Vruf5KepgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTr lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB oz8wPTAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAR -BglghkgBhvhCAQEEBAMCAEAwDQYJKoZIhvcNAQEFBQADggEBABNT+r+6vvlpjtyz -mewrGOKPt5iwb8w2aReJ0AWuyQzTiduN26MhXq93cXHV0pHj2rD7MfiBEwBSWnf9 -FcxkE0g77GVyM9Vs9Uy/MspIqOce7JD0c36G4EI8lYce2TYwQLE9CGNl+LDxqkLy -prijXBl/FaD+IO/SNMr3VVnfFEZqPUxg+BSTaGgD+52Z7B4nPP0xGPjlW367RGDv -9dIkr1thve2WOeC9ixxl9K/864I7/0GdbgKSf77xl3/5vnQUOY7kugRvkvxWIgHS -HNVnmEN2I2Nb0M8lQNF1sFDbpFwVbh9CkBF5LJNesy0VWd67Ho6EntPEb7vBFF/x -jz0b2l4= +BglghkgBhvhCAQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADggEBAGl6bYCGKvDCvfSU +PTyaiFPNGXV98AnIG0Hu4EJjs1owBU/Yf8UdFbWJtOymR80SbzmeQ6rEIoY1oXDA +o9Y8yRgW8t25Wmq/0DCu/5P0/L6asstLTxLG4qajClVwqDLEqZNixmq8QorAOtK1 +JngFA+A5jzc70Ikl9+Hbx/2SEMrCpo0QLSco7KDK7XpNOHbkRz2AqSm0se4jDMP1 +Cwd2UtcpctIZEbECZo6S9WrVMqIhRF1Y5FeauBA2ORvGIHohaYJ9VzYWYXIp7N8d +QXGv+M7ffpZiERcRr8lxtboPnTXKlv1mLCEX7g+KuiJQUm4OGfTCd5VHzWM7O5Id +b+IvZD0= -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt index d81b26afcf..dfc92b3ee3 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE----- MIIDPzCCAiegAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/ uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf @@ -11,10 +11,10 @@ lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB o00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAf BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zANBgkqhkiG9w0BAQUFAAOC -AQEAvc+WwZUemsJu2IiI2Cp6liA+UAvIx98dQe3kZs2zAoF9VwQbXcYzWQ/BILkj -NImKbPL9x0g2jIDn4ZvGYFywMwIO/d++YbwYiQw42/v7RiMy94zBPnzeHi86dy/0 -jpOOJUx3IXRsGLdyjb/1T11klcFqGnARiK+8VYolMPP6afKvLXX7K4kiUpsFQhUp -E5VeM5pV1Mci2ETOJau2cO40FJvI/C9W/wR+GAArMaw2fxG77E3laaa0LAOlexM6 -A4KOb5f5cGTM5Ih6tEF5FVq3/9vzNIYMa1FqzacBLZF8zSHYLEimXBdzjBoN4qDU -/WzRyYRBRjAI49mzHX6raleqnw== +AQEAm9GKWy4Z6eS483GoR5omwx32meCStm/vFuW+nozRwqwTG5d2Etx4TPnz73s8 +fMtM1QB0QbfBDDHxfGymEsKwICmCkJszKE7c03j3mkddrrvN2eIYiL6358S3yHMj +iLVCraRUoEm01k7iytjxrcKb//hxFvHoxD1tdMqbuvjMlTS86kJSrkUMDw68UzfL +jvo3oVjiexfasjsICXFNoncjthKtS7v4zrsgXNPz92h58NgXnDtQU+Eb9tVA9kUs +Ln/az3v5DdgrNoAO60zK1zYAmekLil7pgba/jBLPeAQ2fZVgFxttKv33nUnUBzKA +Od8i323fM5dQS1qQpBjBc/5fPw== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt.der new file mode 100644 index 0000000000..fcf45cd7cc Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage.crt index 8f4e59f2dd..b5a2532c2e 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage.crt @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE----- MIIDTzCCAjegAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/ uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf @@ -10,11 +10,11 @@ CrFTxjB+FTms+Vruf5KepgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTr lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB o10wWzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAf -BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zAOBgNVHQ8BAf8EBAMCAeAw -DQYJKoZIhvcNAQEFBQADggEBABKC/1x0m57EY4H412ue3ghCWgg07VcRKamnUSTs -tnqI5T0mSvuPrxhINdQB6360ibctBkXP3S9rxGHiUdeK/JqxYs2YamCs50TSWpon -p4Hzcmjsw1YgXsQ6pmYwkzU03zqs361gt7JSOzL2dN0IjwIy47qfLQb/AXhX2Ims -7gBuqVpYqJuSHR0qsN/c6WgIE3IrbK1MB6CJTkxBfcSc5E4oUIBHmww+RSVLOczM -nGk3U13dmfG0ndhMtrMyyxBZZSUwoZLjRZ6J5mHSv+k8oo1PYQeiivNEP53mgVaY -ha0gLUIk6zNBRpY1uUmxQ+RQSMIyYPBb1RedHn2s8El2mlo= +BgNVHSMEGDAWgBS0WuSls97SUva51aaVD+s+vMf9/zAOBgNVHQ8BAf8EBAMCBeAw +DQYJKoZIhvcNAQEFBQADggEBAE6xegEHvwuQ8I4YCLX7oXmDJiDb7m2nMin+um0v +TMqHAE3B9GvdWGUgMIEMf76ee7OMDzxfzM2vyNGemB0rn1djEv+knJBSdMQKD9X8 +tkT8cPqMHlRMYYbFFkkZEOeqeihZXQdUORao9ZSXrokYwv+Fr+PAmiUJEmkZHbA1 +Gqp6tPfGxJ2ah50Og9oAPwyND6kvE2o++Dth2evjljPCPM2Gw5kjQGw3V9CAUyUo +KtLrtZdOeRHRCWCf3UQ/tYkG70tY/+grftrHqKB2E4qkmDiCPS9sEpa7jOGT6e4k +jGVeZFNZZ10mD2Svr3xl/60++c7yLxrquujo8NOTCVcshfs= -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage_noauthid.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage_noauthid.crt index d66e515352..c82a979729 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage_noauthid.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.key_usage_noauthid.crt @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE----- MIIDLjCCAhagAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/ uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf @@ -10,11 +10,11 @@ CrFTxjB+FTms+Vruf5KepgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTr lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB ozwwOjAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAO -BgNVHQ8BAf8EBAMCAeAwDQYJKoZIhvcNAQEFBQADggEBAJZRIISo4+rDvHXXaS43 -shfSkyJyur588mNJFzty1WVfhaIkwjMIGHeGlHS29fwgPsBUgelZ3Qv3J7wsm42+ -3BwQet0l36FIBIJtFhcrTGlaCFUo/5bZJUPGgiOFB9ec/8lOszVlX8cH34UimWqg -q2wXRGoXWPbuRnUWlJhI2bAv5ri9Mt7Rs4nK4wyS1ZjC8ByXMn4tk3yMjkUEqu0o -37zoQiF+FJApu0eTKK5goA2hisyfCX9eJMppAbcyvJwoj/AmiBkXW8J3kEMJtLmZ -VoxXYknnXumxBLxUrGuamR/3cmbaJHIHE1Dqox7hB+9miyp4lue1/uXHCocGAIeF -JTo= +BgNVHQ8BAf8EBAMCBeAwDQYJKoZIhvcNAQEFBQADggEBAKuveVlnjgJIkiH6HqZk ++oGpLPxpcoMEMskzyFxTfjP4L2Mj798qydBbobyVJdH5p/sIpcHsI0xajM/dcZKS +7b28KVwxOk+87DtwCikFT+jzWPe8fzowqsNAaKtvtDQnLYh8u2tDT1vhABwgTVAy +aHCzs+nm3o36NPSN9K+wmI+r1KFnhjtyOQ++7M8wRRT5jrC+1tYicjsnVMu07yB5 +04C99Fa3MToilg66Jos95U3gBF5GbSfDXYtd3/etNMkUiG8FEZJlkhKbTO+4E03a +X6+z2VojrAroYyO/F5ZlaC3/CsMQ8Zcate64nH/Lu/U78XAo8iKz5DLLOPBqodER +z4A= -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.noauthid.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.noauthid.crt index 99c004f623..f778ae9e49 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.noauthid.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.noauthid.crt @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE----- MIIDHjCCAgagAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA8MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGjAYBgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN +A1UECgwIUG9sYXJTU0wxGjAYBgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMIIBIjAN BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqQIfPUBq1VVTi/027oJlLhVhXom/ uOhFkNvuiBZS0/FDUEeWEllkh2v9K+BG+XO+3c+S4ZFb7Wagb4kpeUWA0INq1UFD d185fAkER4KwVzlw7aPsFRkeqDMIR8EFQqn9TMO0390GH00QUUBncxMPQPhtgSVf @@ -10,10 +10,10 @@ CrFTxjB+FTms+Vruf5KepgVb5xOXhbUjktnUJAbVCSWJdQfdphqPPwkZvq1lLGTr lZvc/kFeF6babFtpzAK6FCwWJJxK3M3Q91Jnc/EtoCP9fvQxyi1wyokLBNsupk9w bp7OvViJ4lNZnm5akmXiiD8MlBmj3eXonZUT7Snbq3AS3FrKaxerUoJUsQIDAQAB oywwKjAJBgNVHRMEAjAAMB0GA1UdDgQWBBQfdNY/KcF0dEU7BRIsPai9Q1kCpjAN -BgkqhkiG9w0BAQUFAAOCAQEAUMDKviuchRc4ICoVwi9LFyfQjxFQLgjnX1UYSqc5 -UptiJsDpbJ+TMbOhNBs7YRV7ju61J33ax1fqgcFWkc2M2Vsqzz9+3zJlQoQuOLxH -5C6v5/rhUEV9HMy3K5SIa/BVem9osWvMwDnB8g5k3wCZAnOuFcT6ttvzRqz6Oh9d -avozrYHsATzPXBal41Gf95cNVcJ1pn/JgE4EOijMqmAPldVbCqfXLl6TB0nJS6dm -q9z73DGrVQlOwmCVI+qD2POJI67LuQ0g6Y0WVMxsWilMppt+UrEknMzk4O4qOaUs -1B20vI/bN4XPDnw58psazdoBxFL+fAk5MbTNKETNHjBsIg== +BgkqhkiG9w0BAQUFAAOCAQEAaf6oVaFgPEUYjT6cNoMf3p4Ja7EKr2Lp9jX0aV0D +Q4WwTg/QG3OVBX9IdK+ezAPuBRE7YWFKfbUR5MajWQt0MQPKXh0u7Tr4Z5JG3lXH +P/QzYZqTkSD9zlb0MHvYUl1T/Ulc4Ws7qSvf3iocvtSAZJIxNi9hxu2nXk2N4OGY +zyTONjlBtKjXa1THHKZzA5o1e4n2crtCDzXJFVqLeeIwW4zAqepXhGU1nepbazNP +B3IYzD+JM36XiDPAlci7ZDwpXHrT6fqlBOtfrUH+NAHXCSG2WT+6B4nVZW/P/Qrv +Hxrq4lP5fgpyX4jxa4UFW9YwRaUN7IAWuZL5dWINbiJZbg== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type index 5677f32bec..39ff3fdba3 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type @@ -1,17 +1,17 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICpTCCAY0CAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICpTCCAY0CAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAkMCIGCSqGSIb3DQEJDjEV -MBMwEQYJYIZIAYb4QgEBBAQDAgBAMA0GCSqGSIb3DQEBBQUAA4IBAQB95Pkjpg/N -Jbgl5nZcAk8maGMpUFlrhJS4kGutQKZugNX9v8cfABW905IHYXV1dm6zxVcyeqZM -FiOgbV943fu5JbufoazdYXnnR2/iKMigqX4CzZrK3F5ZzegxkfDIfDrn/shC+rWb -SS5WBVLJ3QNj9vwn3/b66IRbp/ViOwHx7+9JT4K/rLId/ynjYf2T57AsmNd/jptc -Zs19fGgtrUXweWkliEZN2zE47Cc53jkx6+Li4TNs4Bjk5P/aXrCP0fBwgGt2K6YW -dQ/nr0PwIbXzVlgUukSTHkJJfhF4Y/WqcUfOPrRdw+zxOLusJ9nzJBR0FOohcBxM -kPBVna0dze/o +MBMwEQYJYIZIAYb4QgEBBAQDAgZAMA0GCSqGSIb3DQEBBQUAA4IBAQBErZcEaEEO +hLbRVuB3+N5by0mogdJsatJFSgW2/VztLvQBYu0O+VmTbZwCAWejA8U+cr6uPlyf +b4lDqj3W+XykeK9bSzoSr1yNO2VAcE74Y0ZrSz2yXMfT5R9IyKqQZspaKD8MOmYH +BqUH9o/phnGcaEG5xeSfhM1O/YNZuGnlLDQBGwT5puHOaLfjECvs8eZLopIWEBlD +QkRlhYqZBwhGZ8D/TxqG4teFtnBX5FG7UoSSVuneBrkREQM7ElhtD9jCWjfMnqm1 +59G84OycClwaKU7/Dm6zeMGDyFoMksBud7lyDHMhxvwSbzb1JR5v8iBsmVY2dhHt +Ot3Fx2be0gIr -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type_empty b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type_empty new file mode 100644 index 0000000000..70fd11133c --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.cert_type_empty @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICpDCCAYwCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ +ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ +HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF +W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs +FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ +DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAjMCEGCSqGSIb3DQEJDjEU +MBIwEAYJYIZIAYb4QgEBBAMDAQAwDQYJKoZIhvcNAQEFBQADggEBACU0LLDBIMgG +B7gyNANHv42RovhQdzmUulqJPHNHx3v9G17F00bEykJb/r3awW6l5fhY/6oPydsY +hnWEM6VVCUkJ6Zqm2/wE49uaNTbFd9JU4OywRBfjHHSTOGnYFg+BYSfwaIkSCkx2 +kVhyklFm7My5wkyDPpFSU2tTfgsgaQMyTm93a2kxM7qJ/X3gFDG8o7R0vyojFVSI +mwsF9QsC6N9cygdFx23zCB0KsJ9KfmBqaTsdbKh8BsocYm5FJCw4WS/CBrCWBj+z +N7yEJj4SR5F+P7sFc5I0HANov5wQe8E3+WxxQt8jcqIje6DlaaGja44cXOzvFQyx +Hg/6H5EtBQc= +-----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage index 053aed909b..30e4812437 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage @@ -1,17 +1,17 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICnzCCAYcCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICnzCCAYcCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAeMBwGCSqGSIb3DQEJDjEP -MA0wCwYDVR0PBAQDAgHgMA0GCSqGSIb3DQEBBQUAA4IBAQCj6jCu0wE5OQ1JGQwZ -FNwPqZrvKntSq2yLIbgmGxwlvDLxOzn0KmidSFiKRqh0KXwj9siodlz5C0d9tUqq -7xUXg+j+wDHqUV8zo42Jke+UmWXFPpnXx/fDFGTITdLSn8ZDxkt31ESLTEVZvPFD -odm+C+zWJtKpyL+9op4KvyBQ1MZ9nWZpwMaK4g4mdtOIsz75gMa74w8ZT7VzhGMY -cZGmafsl7x++GDDtf0oCPgrj9xy+Ovv/GyUBaB+6lweflTfPDTRSoN0meFlP5ynF -vqcBM5JKH2FUQIizfc9o6Z8tKxe9FCov3x8szAuoMRA7bjhVngeQIrEkTcaQBvBY -NalC +MA0wCwYDVR0PBAQDAgXgMA0GCSqGSIb3DQEBBQUAA4IBAQBsJ3v1Ar2X28GJsRSJ +WRQwFQwIbR/D0cHrwTf0ZfZttClytuc18JZlwkH3EG/rNkWaFp6MKIZoRMOBuSPc +MNvvKIo4nPaeouDPruymx0gNenlyRL3D4OZpBO/BmQIQjbUKWFbzEnEqvwvMDUnG +8w7UjPSFcxj2HzENr62HLPKKnVpL3nDXWK1a2A77KF9aMxyoWQ6FXb2xPD9cJjdo +c1jwskQbgosQzKKwwp5yxq0zRD3EAGw4A78mgHMfgFprq9e9azaB0JeyFG2Vn0t0 +L+vfiDEVQ3eJXSCen1kEVyHRju8g53UcSgd+JicWFboFj2/mJBuyW6yM++RGA9B5 +Zd62 -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage_empty b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage_empty new file mode 100644 index 0000000000..47e56bf1ef --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.key_usage_empty @@ -0,0 +1,17 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIICnjCCAYYCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ +ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ +HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF +W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs +FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ +DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAdMBsGCSqGSIb3DQEJDjEO +MAwwCgYDVR0PBAMDAQAwDQYJKoZIhvcNAQEFBQADggEBAAqQ/EU/3oMt7YW4vWgm +0Q7F4v7DrFEoVMWfBzNWhMNIijzoaWKY8jwseZMzu8aCNQlJnM7c9FJF+OCgS7L5 +0ctwzjfCOi5I5cKgqv8WpuMZWHXNtB7YtjUWIZVri/RazCncZEwJGCKQjmQYrGJm +Qmu2+D+DWY+nEW47ZfDH9jOJtatnREjSNsKzc44L9zUaEy3bi+m455XGH+ABmeb7 +Iqmguh10xUyY6rEOFEuqvFyFr5g1eb53Rr5CQxGfw1j+2bbSh+rVb6Ehf9LAijyu +Ygqa91hGab/CjykS6HMrD91ouWtt2Rt3zCKo4Xxe8dlAszKB4W83M9OgDVVpiCfC +t3A= +-----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.ku-ct b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.ku-ct index 0e057d58aa..ebd01f5cca 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.ku-ct +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.ku-ct @@ -1,17 +1,17 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICsjCCAZoCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICsjCCAZoCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAxMC8GCSqGSIb3DQEJDjEi -MCAwCwYDVR0PBAQDAgHgMBEGCWCGSAGG+EIBAQQEAwIAQDANBgkqhkiG9w0BAQUF -AAOCAQEANlNG9hW852OzVKj2Z8TtU9jxstAoSCH9yc9Coj4Vw2TTjs1zcuBWsMl1 -2bf2I6ZvEH6ZhcQY7i7nyHQyPlqE4l6U9D8ct967QN7smuAHNY2HiQ2++eCBTHck -PdtGJAzIvNlXcoqNi8UC5fGepNtI1usNo41SKMvbg6nGA5gdcQKk7CVlk8lrD0qI -Xn/HvjSRoDE4ZGxAtNvPXWorGSxtgcy8EMPoXVUab5fNt8q//x/NQ4yEQKPrexmR -IuOiQ8VW8QZtkORGpZbGSvskU0WfKANui4zCcXYRc4mVR4Wf0C+fyHeihhjslSnT -RbC7nQn5HSHp31qJlr80QodywaK1Dg== +MCAwCwYDVR0PBAQDAgXgMBEGCWCGSAGG+EIBAQQEAwIGQDANBgkqhkiG9w0BAQUF +AAOCAQEAWUMyIXHi4BbIxOeCD/Vtu9LGV8ENMV7dwYVEQcwrt1AHahtYgUtkoGcP +lOPqg1lbg22bu8dLPoY4HAzxCOAGs27otWL5LlE9M5QPH1RedEycmOuYrMl6K988 +hfDBJ+OkgCShcM91+udrc0gpDEI7N01A+fmukQ6EiaQjIf7HME/EKQqhEuEQMXHC +GBvdNuEF5BfV3aAYuT+xfdXDU2ZWwXXWAHGmVh3ntnhtEG6SnXSnBATU2wa4tpBd +KLbEbcsiy2uj0OLJlvG6LqsNggtkD58GCGpLpaVxdW80yw+f/krwLpeyocE1KGcT +7eX+9yhLe9NIZojvevw+53dNE7BUfw== -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md4 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md4 index 44c53d7606..15585499c8 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md4 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md4 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBAwUA -A4IBAQAPPUzYvUA+HQTteMhkGcuD6XtsZ3i2gQdDGgLUxtMAVFw+/5ZS6l+WqPgq -WQIOsEINPHnjUAMz5pjbFdFqu7X5G29THa2da0Ua2bJO/bu3CZ6EksGmclqaQ2Zl -vfkWaI3bfPFh8eKHF+F5oaVp0gHviCakNqxot4rrZdL8pnJC5JJ+f76y6SgHYOao -SGCv1gYURhIsX0gWCqldsCwxJQFEig9HISUcXViGGVnLdshUtuKL9yNZ/HNAOuOk -7N7a7ur8KMmvar1jkTq+zKSSuSrzmU2JvxFdqU0Gr7A35jgnVG8sj66L4lAcwdoG -sP8OmC1hWh4U3avH6EHdEG8lw0U7 +A4IBAQAu8SbWDi5udXrs/lljV+jdHky2BFuVFNxZgj5QvLslffdx2/Tj4MVCsqkY +tAcy5g/urW1WwHcnJ20PRgt60m3BSUJffdKF/kgRyTN1oBFpApHGAJEHPahR/3Mz +hMBk4D/r6lga60iUhIfky8o8KU+ovHXROHzGfYaVySatpyJW6tkJOz/1ZKLI4s4K +HGLFxKBd6bvyuMSCpV31J7ZHPQfSH38VEEaTLJ2QOltWDX5k4DlL/F3I5K4VFWOm +DMndMXkb7LhL9jcaJJRzEmbX3aMdt2aXhQt2LDFMnMCeSHI014URnQd6IzRQYZPp +qGZf2UmuJdLeIMzSNX2rZ+SVDX9o -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md5 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md5 index 950f5c4bd7..57714ede37 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md5 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.md5 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBBAUA -A4IBAQAQx+EjsPUUYac3t1v24lPOYqrKM52XYDwSnwW5Okjn+YxJowZyd8gfzmfp -vp4+//h5P3VlQDwaXeMTgKCizjf+jdACNJe60/RxYpYFKrvy67ZSr/h7fhdm52Jz -/tSCbh6FwH1075loBuWLuzD7Pvm1X1FJmbp2ceaJozDnXTAKFdVTqdiRYwyg4iPl -krhONGNe132aYZtFssdjSCim+bB+/sagR3SuJPoQ+8EjDXYG75n4ZVa4dAcjVoYk -pg0YK5cuH1FHCXOBO4N1+G0skL8AZwlv+rhKQk6lpGt+AQ8LSjCz2zHUnfpaXXWp -s1dq9ufjbJdaHDjkBY1gZ3BMmXPw +A4IBAQCEiv3QM4xyKhYTsoOjyzQdXMhsXK3Kpw+Rh874Hf6pXHxUaYy7xLUZUx6K +x5Bvem1HMHAdmOqYTzsE9ZblAMZNRwv/CKGS3pvMkx/VZwXQhFGlHLFG//fPrgl3 +j4dt20QsWP8LnL4LweYSYI1wt1rjgYRHeF6bG/VIck6BIYQhKOGlzIwWUmfAGym6 +q4SYrd+ObZullSarGGSfNKjIUEpYtfQBz31f5tRsyzSps7oG4uc7Xba4qnl2o9FN +lWOMEER79QGwr7+T41FTHFztFddfJ06CCjoRCfEn0Tcsg11tSMS0851oLkMm8RyY +aozIzO82R3Em7aPhZBiBDy3wZC2l -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha1 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha1 index f4c61bc578..578ec7f79a 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha1 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha1 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBBQUA -A4IBAQCACO1GoBxMdGoWLtk0USbZIJkJidvraTyuuVMMvTaRHAseepNZWtbI2VjZ -8BYFKnY9uSX4uozODi5Tkv2dCSwAFFJs7bsALqpjqfU1kwQSbfLoT8twf7o51Zw8 -LAEKW0GpifhI4NJAaIeh5EyfMeXH5RFAz31T95Eat56eLcewDK5nWUdQx/KkkSIb -AFKqPKz8F9KS1tEty5UYmC1QV+q7NG1aOrWcuqvszpyUbsz/u32QH0Lp7E3lXMt1 -vyFfAsA6KBLTUmyTVQHz4snQAb5CFNLOrXnHbtjem7ZmhDzE1DS/7o8NK49zuXUW -YUMPRpZDSNUpIBmZs2NBTARSEc04 +A4IBAQCiYQMOv2ALPUeg8wHKn9L5SdDbNxOzuMwhYsCYTw2TJMQO7NLUq6icEzxY +pUIIFt60JUQjZHxQSY3y9cSivwKXQA7pPfaPaFC/aMA2GxG23t2eaIWNQX8MfcWf +XAa8bl/vmC1MTov+mP2DGoXRiKYORrEInyDS2RaTathvHckcAv25nCIx7wYO9tC9 +LUwyoE9bhiQ7fo3KFlz4dK1HukyCM/FoPbJuL7NgdzmKVPyYCLh5Ah+TTD6+sltz +dFc4fj28w1v3jsBXz+tLrgFQidzuUI2poxt5UwU9TKY0dAJaTCtfIRcXW3h6DGG7 +EDR6rim6sbIQkGzYvGqs4TNoJOR+ -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha224 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha224 index e52196dbce..a4f2af4c1d 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha224 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha224 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBDgUA -A4IBAQAed2cYY9P/xJNHBrHDxjeh5uFyDskCvw06Kvy8FJt6G/0ncnfhSpPnevao -UPf2jk07iMIFiaDDKc3yg4H2Uh44+Ud2YdAxHYWttKnvj43XSoWSnmUDEiUqgPAP -C4EmgPEfsxtj+nI5fwIGEvfb3mJ31FJxnSJREcaH8uqyXW4vfF8e0o+9gdM+aTw/ -OJj+dYvepfIpB+1jIq1srr9NLJjKlvHBhQFbIcIgQXJKcw5z04hgjdoSuQckMO5z -3gVaaHfjCJQT1tDWfjLTCceDoJPskeo7xbDvXnCho+ZLtyMesoCvOEeZLJhDYTlw -H5jw6f9GW8Q9XP+EQcf6ZhtmYLrU +A4IBAQArYR2mLKU5lsHyAyGHr4PlmC/cfePmCRyC/mj1riGTjDlNC2X3J1VZDqKb +U/uUxLudP7sbuttRksIAREATT74Pa40bMWiPUlBfA/M2mFTmKb/91uXeIISW8DL3 +xM/5BCDrhnZ/cjP23gKDgJRk+IGBNhYZDGz50TIBbDJ2e4GDkFjzANngUW64UcCQ +7hZOYtnYLBnoRvPwtal5jZqHwsgaPPePXu+SQ8mfuAJwJ78MOCAaKw0IP1h1OnPG +iubdl34lSIaYWwbHTdjaqUSQG3SSs4oxEvluYymrpZ6XGKXtphJXEPdTRiLu9d9l +A5NYVgvqHFQPmuXS92zrGzB788pV -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha256 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha256 index 804c4a5510..6d21dc5d94 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha256 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha256 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBCwUA -A4IBAQBY/1nnYQ3ThVyeZb1Z2wLYoHZ5rfeJCedyP7N/gjJZjhrMbwioUft2uHpb -+OZQfxRXJTbtj/1wpRMCoUMLWzapS7/xGx3IjoPtl42aM4M+xVYvbLjExL13kUAr -eE4JWcMIbTEPol2zSdX/LuB+m27jEp5VsvM2ty9qOw/T4iKwjFSe6pcYZ2spks19 -3ltgjnaamwqKcN9zUA3IERTsWjr5exKYgfXm2OeeuSP0tHr7Dh+w/2XA9dGcLhrm -TA4P8QjIgSDlyzmhYYmsrioFPuCfdi1uzs8bxmbLXbiCGZ8TDMy5oLqLo1K+j2pF -ox+ATHKxQ/XpRQP+2OTb9sw1kM59 +A4IBAQCVlSU7qeKri7E3u8JCZbCyjsGJTH9iHYyeDZ/nDLig7iKGYvyNmyzJ76Qu ++EntSmL2OtL95Yqooc6h1AQHzoCs+SO2wPoTUs3Ypi9r7vNNVO3ZnnxVtGgqCRVA +W+z9W4p2mHXQhgW1HkuLa5JD1SvJViyZbx9z3ie1BQ9NVKfv++ArPIv70zBtA7O3 +PZNG1JYN30Esz7RsCDRHbz6Npvu9ggUQL/U3mvQQ+Yo+xhwu1yFV+dRH7PebBeQv +vjcD2fXDabeofK3zztIpUIyUULX0GGClM9jslgJ/ZHUlArWKpLZph0AgF1Dzts// +M6c/sRw7gtjXmV0zq2tf2fL4+e2b -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha384 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha384 index 7c764f7a8d..b857af7f15 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha384 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha384 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBDAUA -A4IBAQA/XVYxhCWWWExy+O5y/zI1121L5MPjrlLypgP+ZDU8TUq8fusryYAgVATo -njpff6RF9QTKZhouFmgwicEnE6Xuw1LZt4SWskEyISMsTemx3eiY3YSu7uqpMIIh -h5ht1qGxkFZaLG0REIlUWqVTKk9oWLOg6pv+qees00SAn031Vc2C3++ctQONUrko -fc8aAGAi9DvSuFkfjhZkp8Fr4d7buHQPmJiYxRp27K5NbVxrr0GCB3wh7ruGc8Mc -K+PNQvoz425dHK3dHzeoIWD2Ka25mbjglbW1rqAdTkZSYH2QqZTHsKCr0u5iPtSD -gF7K0AMuT2LIeSs1p82n+cLF78fz +A4IBAQBy35zHYLiYaScq1niQkzQ/BScUbdiWd2V90isBsB5Q3NjVoJl/yCaMrla3 +2XfrutpFpdqwenl5jM0o6+enKCmfur+z2/ije69Dju2aBd6A62cx1AEvFiMq7lyF +4DYJ32+2ty6KA8EhzE3NFs7zKXxmD5ybp+oXNEvXoeU3W8a+Ld5c1K/n+Ipa0TUy +cFBs6dCsbYO9wI6npwWqC5Hc9r/0zziMFO+4N5VORdYUFqObq4vCYOMXETpl8ryu +lGZorNUoJ7vV55T31CDqEtb0EE+nO+nT4agfDobncYjvc3WpQuLtUB4UwR5gpZl6 +ZI+j4uwikOgGO9gcx4IjaRP3q63F -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha512 b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha512 index 43d709533f..85d52460db 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha512 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.req.sha512 @@ -1,16 +1,16 @@ -----BEGIN CERTIFICATE REQUEST----- -MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoTCFBvbGFyU1NMMRow -GAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP +MIICgTCCAWkCAQAwPDELMAkGA1UEBhMCTkwxETAPBgNVBAoMCFBvbGFyU1NMMRow +GAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb7ogWUtPxQ1BHlhJZ ZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJBEeCsFc5cO2j7BUZ HqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8YwfhU5rPla7n+SnqYF W+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5BXhem2mxbacwCuhQs FiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1YieJTWZ5uWpJl4og/ DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAAaAAMA0GCSqGSIb3DQEBDQUA -A4IBAQBH78JrIboWUlOiUzEwxuYkaRBr22DfdSHlNVjnenrTsSsSdfPenfrUbs42 -NfzhJtvLBnDMs9olsiyPNKZnROmjl/4Da5ScVBfdA7oSImwdsaL0krAju8lJosy7 -ypqNejQQDgjL00HkaVyqjnEWY68enAkaK64suQ4w0pkGmtdZyg0nBiH1VI72PcPR -Fu2wxSkvvYj+BcHVAY/GWRMTHw1mkmsQna7AsZ1MFIF3ycIW5Fom6d0wpB6clJ3M -vNTBc7kZIR1BQyblyU96acesxJURJn5xO9Yf9OSsTbd7Xm5xK6DpQWxFFEgdVtir -hSAqtp54nVnLe4QihmVAlM8zt2ON +A4IBAQBb8jNpt0nkNVWstVoOCepQSF5R1R9hF0yEr7mk3HB9oO/nK07R1Oamgjw+ +CHQReTSjIKUX53o7ZwNZB5E+jBDsGz/2Yyj/vxNHJFk2exELtW30he8K2omVHE1F +XESbftCssWLNpTSDq6ME12+llkEDtgCtkv69oRUkuuF5ESUSZRGIZN4Vledm8SM1 +uGFtaG/PXbBbtUaNwNISDeIWDKRtbuca5web+QEi1djiUH21ZWIGEpOy7mtkYmRs +Qt1D32FoaqFNhafiaxNIXO11yd4lgpaDDlmrOSBsELcTIF9916o3DwMeVXy0GONW +BrwaO8q8rg+C+xvMY7858Kk8kwjb -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.v1.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.v1.crt index b13be43516..e85ed30fc4 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server1.v1.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server1.v1.crt @@ -1,18 +1,18 @@ -----BEGIN CERTIFICATE----- MIIC6zCCAdMCAQEwDQYJKoZIhvcNAQEFBQAwOzELMAkGA1UEBhMCTkwxETAPBgNV -BAoTCFBvbGFyU1NMMRkwFwYDVQQDExBQb2xhclNTTCBUZXN0IENBMB4XDTExMDIx -MjE0NDQwNloXDTIxMDIxMjE0NDQwNlowPDELMAkGA1UEBhMCTkwxETAPBgNVBAoT -CFBvbGFyU1NMMRowGAYDVQQDExFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZI +BAoMCFBvbGFyU1NMMRkwFwYDVQQDDBBQb2xhclNTTCBUZXN0IENBMB4XDTExMDIx +MjE0NDQwNloXDTIxMDIxMjE0NDQwNlowPDELMAkGA1UEBhMCTkwxETAPBgNVBAoM +CFBvbGFyU1NMMRowGAYDVQQDDBFQb2xhclNTTCBTZXJ2ZXIgMTCCASIwDQYJKoZI hvcNAQEBBQADggEPADCCAQoCggEBAKkCHz1AatVVU4v9Nu6CZS4VYV6Jv7joRZDb 7ogWUtPxQ1BHlhJZZIdr/SvgRvlzvt3PkuGRW+1moG+JKXlFgNCDatVBQ3dfOXwJ BEeCsFc5cO2j7BUZHqgzCEfBBUKp/UzDtN/dBh9NEFFAZ3MTD0D4bYElXwqxU8Yw fhU5rPla7n+SnqYFW+cTl4W1I5LZ1CQG1QkliXUH3aYajz8JGb6tZSxk65Wb3P5B Xhem2mxbacwCuhQsFiScStzN0PdSZ3PxLaAj/X70McotcMqJCwTbLqZPcG6ezr1Y ieJTWZ5uWpJl4og/DJQZo93l6J2VE+0p26twEtxaymsXq1KCVLECAwEAATANBgkq -hkiG9w0BAQUFAAOCAQEAPMRfR9ql7b06b5DdNyJhD96lBzuVSUOW2MgVHT2Vs7NB -tk5L1htpA5N4uaIeyt6YM0xU0nHdHUKaywNcDiXcnzvRoctGWiWdpcEvdA0rYRF5 -T4MGPpjEuLJcG3aTU8mV8wUEbrY6IEnSpC1G9iasjhkwAF7pb/Ic8+/riwmPD/Fh -zBrRfBCgi5VXbX9IvY+yQHRVRal8y+n4eh9/hFxBKDbvuidFropGzcuparEwCIRi -U7L/7aZ3A5wsQp9GPDliSjpeYCf5tok/bvjG4xU041pGQ7yVNpu2mEIoqDz9v+Ay -IKqsWradEnFG/1ov78a2RB+2+iIPE4iCDtmKUkgPjQ== +hkiG9w0BAQUFAAOCAQEAOKzKoIMPjmKis0WH0t9/Bn5cMAPsBAgeqROeWqAs1N7j +FIpCoyQW43t1rAtga946X6/IanTuLKScPkhNrcX4ASn0+DzaNxVelumjjfD6NEcn +/Fnq0a+5oNcqXrM9lCBtqFnGcDoFJq3VMA3P+YCqZ9ZaYy30mOkZRVlddMQCpk7g +RxVBLEaPL1DlSmR1hIvsHQ51DGU6xEnbrxGn19dFf1yfC+vnf5mhKPB8XGWd+IjZ +WkYsfmBe2hwH58XNvVf0suX9aQS16vwqpPbPi3wQ2d3cX1/vCCW4cCYW7Pytc3Op +pBjHEIkmil2/30+Rqk4SbZvo99MMPGIOREOJ81sNRw== -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server10-badsign.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server10-badsign.crt new file mode 100644 index 0000000000..eca171f351 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server10-badsign.crt @@ -0,0 +1,10 @@ +-----BEGIN CERTIFICATE----- +MIIBWjCCAQCgAwIBAgIBSzAKBggqhkjOPQQDAjBKMQswCQYDVQQGEwJVSzERMA8G +A1UEChMIbWJlZCBUTFMxKDAmBgNVBAMTH21iZWQgVExTIFRlc3QgaW50ZXJtZWRp +YXRlIENBIDMwHhcNMTUwOTAxMTM0NzU1WhcNMjUwODI5MTM0NzU1WjAUMRIwEAYD +VQQDEwlsb2NhbGhvc3QwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQcbffp2qXq +oZyychmoCRxzrd4Vu96m47NPBehtEC46aTeXgDnBdf++znABrAtfXBRNQz8ARIeY +Bmskr22rlKjyow0wCzAJBgNVHRMEAjAAMAoGCCqGSM49BAMCA0gAMEUCIQDLc+Io +rg8VxEbCgVv8iH+kOIEn9MjhpvKzvwUoV+6rjQIgZU/RXAyc1a+H2+soGfNEIOBQ +AzO3pJx7WJAApZuBX10= +-----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server10-bs_int3.pem b/3rdparty/mbedtls/mbedtls/tests/data_files/server10-bs_int3.pem new file mode 100644 index 0000000000..b84cee7c32 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server10-bs_int3.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIBWjCCAQCgAwIBAgIBSzAKBggqhkjOPQQDAjBKMQswCQYDVQQGEwJVSzERMA8G +A1UEChMIbWJlZCBUTFMxKDAmBgNVBAMTH21iZWQgVExTIFRlc3QgaW50ZXJtZWRp +YXRlIENBIDMwHhcNMTUwOTAxMTM0NzU1WhcNMjUwODI5MTM0NzU1WjAUMRIwEAYD +VQQDEwlsb2NhbGhvc3QwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQcbffp2qXq +oZyychmoCRxzrd4Vu96m47NPBehtEC46aTeXgDnBdf++znABrAtfXBRNQz8ARIeY +Bmskr22rlKjyow0wCzAJBgNVHRMEAjAAMAoGCCqGSM49BAMCA0gAMEUCIQDLc+Io +rg8VxEbCgVv8iH+kOIEn9MjhpvKzvwUoV+6rjQIgZU/RXAyc1a+H2+soGfNEIOBQ +AzO3pJx7WJAApZuBX10= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIBtDCCATqgAwIBAgIBTTAKBggqhkjOPQQDAjBLMQswCQYDVQQGEwJOTDERMA8G +A1UEChMIUG9sYXJTU0wxKTAnBgNVBAMTIFBvbGFyU1NMIFRlc3QgSW50ZXJtZWRp +YXRlIEVDIENBMB4XDTE1MDkwMTE0MDg0M1oXDTI1MDgyOTE0MDg0M1owSjELMAkG +A1UEBhMCVUsxETAPBgNVBAoTCG1iZWQgVExTMSgwJgYDVQQDEx9tYmVkIFRMUyBU +ZXN0IGludGVybWVkaWF0ZSBDQSAzMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE +732fWHLNPMPsP1U1ibXvb55erlEVMlpXBGsj+KYwVqU1XCmW9Z9hhP7X/5js/DX9 +2J/utoHyjUtVpQOzdTrbsaMQMA4wDAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAgNo +ADBlAjAJRxbGRas3NBmk9MnGWXg7PT1xnRELHRWWIvfLdVQt06l1/xFg3ZuPdQdt +Qh7CK80CMQD7wa1o1a8qyDKBfLN636uKmKGga0E+vYXBeFCy9oARBangGCB0B2vt +pz590JvGWfM= +-----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server10.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server10.crt new file mode 100644 index 0000000000..96a4040cef --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server10.crt @@ -0,0 +1,10 @@ +-----BEGIN CERTIFICATE----- +MIIBWjCCAQCgAwIBAgIBSzAKBggqhkjOPQQDAjBKMQswCQYDVQQGEwJVSzERMA8G +A1UEChMIbWJlZCBUTFMxKDAmBgNVBAMTH21iZWQgVExTIFRlc3QgaW50ZXJtZWRp +YXRlIENBIDMwHhcNMTUwOTAxMTM0NzU1WhcNMjUwODI5MTM0NzU1WjAUMRIwEAYD +VQQDEwlsb2NhbGhvc3QwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQcbffp2qXq +oZyychmoCRxzrd4Vu96m47NPBehtEC46aTeXgDnBdf++znABrAtfXBRNQz8ARIeY +Bmskr22rlKjyow0wCzAJBgNVHRMEAjAAMAoGCCqGSM49BAMCA0gAMEUCIQDLc+Io +rg8VxEbCgVv8iH+kOIEn9MjhpvKzvwUoV+6rjQIgZU/RXAyc1a+H2+soGfNEIOBQ +AzO3pJx7WJAApZuBX1Q= +-----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server10_int3-bs.pem b/3rdparty/mbedtls/mbedtls/tests/data_files/server10_int3-bs.pem new file mode 100644 index 0000000000..a9e06150bd --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server10_int3-bs.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIBWjCCAQCgAwIBAgIBSzAKBggqhkjOPQQDAjBKMQswCQYDVQQGEwJVSzERMA8G +A1UEChMIbWJlZCBUTFMxKDAmBgNVBAMTH21iZWQgVExTIFRlc3QgaW50ZXJtZWRp +YXRlIENBIDMwHhcNMTUwOTAxMTM0NzU1WhcNMjUwODI5MTM0NzU1WjAUMRIwEAYD +VQQDEwlsb2NhbGhvc3QwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQcbffp2qXq +oZyychmoCRxzrd4Vu96m47NPBehtEC46aTeXgDnBdf++znABrAtfXBRNQz8ARIeY +Bmskr22rlKjyow0wCzAJBgNVHRMEAjAAMAoGCCqGSM49BAMCA0gAMEUCIQDLc+Io +rg8VxEbCgVv8iH+kOIEn9MjhpvKzvwUoV+6rjQIgZU/RXAyc1a+H2+soGfNEIOBQ +AzO3pJx7WJAApZuBX1Q= +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIIBtDCCATqgAwIBAgIBTTAKBggqhkjOPQQDAjBLMQswCQYDVQQGEwJOTDERMA8G +A1UEChMIUG9sYXJTU0wxKTAnBgNVBAMTIFBvbGFyU1NMIFRlc3QgSW50ZXJtZWRp +YXRlIEVDIENBMB4XDTE1MDkwMTE0MDg0M1oXDTI1MDgyOTE0MDg0M1owSjELMAkG +A1UEBhMCVUsxETAPBgNVBAoTCG1iZWQgVExTMSgwJgYDVQQDEx9tYmVkIFRMUyBU +ZXN0IGludGVybWVkaWF0ZSBDQSAzMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE +732fWHLNPMPsP1U1ibXvb55erlEVMlpXBGsj+KYwVqU1XCmW9Z9hhP7X/5js/DX9 +2J/utoHyjUtVpQOzdTrbsaMQMA4wDAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAgNo +ADBlAjAJRxbGRas3NBmk9MnGWXg7PT1xnRELHRWWIvfLdVQt06l1/xFg3ZuPdQdt +Qh7CK80CMQD7wa1o1a8qyDKBfLN636uKmKGga0E+vYXBeFCy9oARBangGCB0B2vt +pz590JvGWf0= +-----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt index 006d9dbed1..f8a5b8b979 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt @@ -1,21 +1,20 @@ -----BEGIN CERTIFICATE----- -MIIDfTCCAmWgAwIBAgIBBDANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER +MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA5MTM1MTA1WhcNMjcwNTEwMTM1MTA1WjA0MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya -HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaOBkjCBjzAd -BgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwYwYDVR0jBFwwWoAUtFrkpbPe -0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNVBAYTAk5MMREwDwYDVQQKDAhQb2xh -clNTTDEZMBcGA1UEAwwQUG9sYXJTU0wgVGVzdCBDQYIBADAJBgNVHRMEAjAAMA0G -CSqGSIb3DQEBCwUAA4IBAQAQf85QSjAeP+l6hirPorUL+k/3BznAh/6RXdveBO3K -uwtqK5qI59+3N+ZLXP7fr2Z5eO8qpchRgNNwT0LKglAEXGWn30PYI1GKSiqAaK0X -CUNIrxV3qKqOLbtqP1dMdiwsmiHYrN8E9UdysObedE2yDNLpTMHPJBZ+k6FowTyZ -IpUuabkxMBFxmLv+nOBDOiaCzintEcdJdY4F6p5j8jwMvVNVAXNfxAEwa0MoVRTt -/GORvq4ZEfsatVA+HRi602m+dZETTWKSODrj8AuQcG8/i1AOhk3C1WNOFKj/ZSfB -2P6EQmhLeRp4bO+3rG73T3R2yn0PZYQ7ZrjFPPKqgu+n +HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD +VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw +FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQELBQADggEBAGGEshT5 +kvnRmLVScVeUEdwIrvW7ezbGbUvJ8VxeJ79/HSjlLiGbMc4uUathwtzEdi9R/4C5 +DXBNeEPTkbB+fhG1W06iHYj/Dp8+aaG7fuDxKVKHVZSqBnmQLn73ymyclZNHii5A +3nTS8WUaHAzxN/rajOtoM7aH1P9tULpHrl+7HOeLMpxUnwI12ZqZaLIzxbcdJVcr +ra2F00aXCGkYVLvyvbZIq7LC+yVysej5gCeQYD7VFOEks0jhFjrS06gP0/XnWv6v +eBoPez9d+CCjkrhseiWzXOiriIMICX48EloO/DrsMRAtvlwq7EDz4QhILz6ffndm +e4K1cVANRPN2o9Y= -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt.der new file mode 100644 index 0000000000..e66ad3676a Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/server2-sha256.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt index dca4c24230..33393ee1b1 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt @@ -1,65 +1,8 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 2 (0x2) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Feb 12 14:44:06 2011 GMT - Not After : Feb 12 14:44:06 2021 GMT - Subject: C=NL, O=PolarSSL, CN=localhost - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:c1:4d:a3:dd:e7:cd:1d:d1:04:d7:49:72:b8:99: - ac:0e:78:e4:3a:3c:4a:cf:3a:13:16:d0:5a:e4:cd: - a3:00:88:a7:ee:1e:6b:96:a7:52:b4:90:ef:2d:72: - 7a:3e:24:9a:fc:b6:34:ac:24:f5:77:e0:26:64:8c: - 9c:b0:28:7d:a1:da:ea:8c:e6:c9:1c:96:bc:fe:c1: - 04:52:b3:36:d4:a3:fa:e1:b1:76:d8:90:c1:61:b4: - 66:52:36:a2:26:53:aa:ab:74:5e:07:7d:19:82:db: - 2a:d8:1f:a0:d9:0d:1c:2d:49:66:f7:5b:25:73:46: - e8:0b:8a:4f:69:0c:b5:00:90:e1:da:82:10:66:7d: - ae:54:2b:8b:65:79:91:a1:e2:61:c3:cd:40:49:08: - ee:68:0c:f1:8b:86:d2:46:bf:d0:b8:aa:11:03:1e: - 7f:56:a8:1a:1e:44:18:0f:0f:85:8b:da:8b:44:5e: - e2:18:c6:62:2f:c7:66:8d:fa:5d:d8:7d:f3:27:89: - 29:01:c5:90:0e:3f:27:f1:30:c8:4a:0e:ef:d6:de: - c7:c7:27:6b:c7:05:3d:7a:c4:02:3c:9a:1d:3e:0f: - e8:34:98:5b:cb:73:4b:52:96:d8:11:a2:2c:80:88: - 69:39:5a:d3:0f:b0:de:59:2f:11:c7:f7:ea:12:01: - 30:97 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:FALSE - X509v3 Subject Key Identifier: - A5:05:E8:64:B8:DC:DF:60:0F:50:12:4D:60:A8:64:AF:4D:8B:43:93 - X509v3 Authority Key Identifier: - keyid:B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - - Signature Algorithm: sha1WithRSAEncryption - 9c:67:5c:29:58:a0:79:1b:a7:bd:1c:a8:1a:ec:19:72:f2:6c: - 0e:f8:73:36:ce:e5:17:4b:12:01:6c:ee:b1:d5:4b:da:fe:73: - 6f:77:96:e4:bf:29:d9:62:2d:27:19:a8:0c:d8:57:29:70:51: - f4:56:bc:a3:28:5a:11:d8:2a:9d:dd:10:84:b8:c5:35:e4:eb: - fe:73:5f:18:6f:f5:1c:3c:48:67:3c:aa:7e:af:21:31:e4:d5: - 2d:66:3d:eb:ed:7a:48:1a:b1:8e:58:89:64:2e:33:78:78:61: - 59:51:1f:71:c7:10:c0:03:d5:39:c0:7b:17:d7:1c:70:c5:40: - 67:be:05:dd:62:01:bc:f5:fe:c1:fd:1f:c9:78:4a:dc:17:e9: - e8:2f:4c:ad:cc:c1:74:70:90:a9:2f:8c:a6:84:0c:0f:40:4d: - b6:71:d2:62:3c:2c:6b:31:4a:e0:aa:7b:da:fd:77:28:e6:b6: - d7:78:ec:9d:69:d5:1b:a5:cf:70:8b:cd:a4:5c:54:8b:92:45: - 14:1f:68:3f:27:78:cf:5c:d5:2f:e2:27:f6:a6:4d:5a:89:c4: - 0d:4a:39:d3:92:e7:bf:34:5a:13:df:48:0a:c0:fa:0e:2a:02: - 64:a3:7a:57:37:a7:8c:16:a6:16:bc:ce:1b:98:c2:35:6e:5f: - a2:47:1b:47 -----BEGIN CERTIFICATE----- MIIDNzCCAh+gAwIBAgIBAjANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDA2WhcNMjEwMjEyMTQ0NDA2WjA0MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxEjAQBgNVBAMTCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN +A1UECgwIUG9sYXJTU0wxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN AQEBBQADggEPADCCAQoCggEBAMFNo93nzR3RBNdJcriZrA545Do8Ss86ExbQWuTN owCIp+4ea5anUrSQ7y1yej4kmvy2NKwk9XfgJmSMnLAofaHa6ozmyRyWvP7BBFKz NtSj+uGxdtiQwWG0ZlI2oiZTqqt0Xgd9GYLbKtgfoNkNHC1JZvdbJXNG6AuKT2kM @@ -67,11 +10,11 @@ tQCQ4dqCEGZ9rlQri2V5kaHiYcPNQEkI7mgM8YuG0ka/0LiqEQMef1aoGh5EGA8P hYvai0Re4hjGYi/HZo36Xdh98yeJKQHFkA4/J/EwyEoO79bex8cna8cFPXrEAjya HT4P6DSYW8tzS1KW2BGiLICIaTla0w+w3lkvEcf36hIBMJcCAwEAAaNNMEswCQYD VR0TBAIwADAdBgNVHQ4EFgQUpQXoZLjc32APUBJNYKhkr02LQ5MwHwYDVR0jBBgw -FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQADggEBAJxnXClY -oHkbp70cqBrsGXLybA74czbO5RdLEgFs7rHVS9r+c293luS/KdliLScZqAzYVylw -UfRWvKMoWhHYKp3dEIS4xTXk6/5zXxhv9Rw8SGc8qn6vITHk1S1mPevtekgasY5Y -iWQuM3h4YVlRH3HHEMAD1TnAexfXHHDFQGe+Bd1iAbz1/sH9H8l4StwX6egvTK3M -wXRwkKkvjKaEDA9ATbZx0mI8LGsxSuCqe9r9dyjmttd47J1p1Rulz3CLzaRcVIuS -RRQfaD8neM9c1S/iJ/amTVqJxA1KOdOS5780WhPfSArA+g4qAmSjelc3p4wWpha8 -zhuYwjVuX6JHG0c= +FoAUtFrkpbPe0lL2udWmlQ/rPrzH/f8wDQYJKoZIhvcNAQEFBQADggEBAAFzC0rF +y6De8WMcdgQrEw3AhBHFjzqnxZw1ene4IBSC7lTw8rBSy3jOWQdPUWn+0y/pCeeF +kti6sevFdl1hLemGtd4q+T9TKEKGg3ND4ARfB5AUZZ9uEHq8WBkiwus5clGS17Qd +dS/TOisB59tQruLx1E1bPLtBKyqk4koC5WAULJwfpswGSyWJTpYwIpxcWE3D2tBu +UB6MZfXZFzWmWEOyKbeoXjXe8GBCGgHLywvYDsGQ36HSGtEsAvR2QaTLSxWYcfk1 +fbDn4jSWkb4yZy1r01UEigFQtONieGwRFaUqEcFJHJvEEGVgh9keaVlOj2vrwf5r +4mN4lW7gLdenN6g= -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt.der new file mode 100644 index 0000000000..ec03190e12 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/server2.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server2.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/server2.key.der new file mode 100644 index 0000000000..9905ce76bf Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/server2.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server5.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/server5.crt.der new file mode 100644 index 0000000000..08d8dd311b Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/server5.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server5.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/server5.key.der new file mode 100644 index 0000000000..6bd4ebb81c Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/server5.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/server5.req.ku.sha1 b/3rdparty/mbedtls/mbedtls/tests/data_files/server5.req.ku.sha1 index 7556d1a052..3281c94608 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/server5.req.ku.sha1 +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/server5.req.ku.sha1 @@ -1,8 +1,8 @@ -----BEGIN CERTIFICATE REQUEST----- -MIIBFjCBvAIBADA8MQswCQYDVQQGEwJOTDERMA8GA1UEChMIUG9sYXJTU0wxGjAY -BgNVBAMTEVBvbGFyU1NMIFNlcnZlciAxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD +MIIBFjCBvAIBADA8MQswCQYDVQQGEwJOTDERMA8GA1UECgwIUG9sYXJTU0wxGjAY +BgNVBAMMEVBvbGFyU1NMIFNlcnZlciAxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD QgAEN8xW2XYJHlpyPsdZLf8gbu58+QaRdNCtFLX3aCJZYpJO5QDYIxH/6i/SNF1d Fr2KiMJrdw1VzYoqDvoByLTt/6AeMBwGCSqGSIb3DQEJDjEPMA0wCwYDVR0PBAQD -AgHAMAsGByqGSM49BAEFAANIADBFAiBjnnD7nwsFnCL+MpPPFJE3K/Tgj+5rAgXj -e5UejDX2CAIhAKdbigWJL/ZatvG9CFHq7ykrRns2x8JEXehWu8DsXdx9 +AgbAMAsGByqGSM49BAEFAANIADBFAiEAnIKF+xKk0iEuN4MHd4FZWNvrznLQgkeg +2n8ejjreTzcCIAH34z2TycuMpWQRhpV+YT988pBWR67LAg7REyZnjSAB -----END CERTIFICATE REQUEST----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-alt-good.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-alt-good.crt index 50c1453582..f9beba0329 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-alt-good.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-alt-good.crt @@ -20,9 +20,9 @@ QHOkQQQJM9UoV0fEA1N5lsc9uSQxPmZCVMw/W+MFIEkH6nbgh0bM/qjcaqDsWXyT n5RutVDPESLLKaZxeR7J8srX/0nzhOiPIX+hDRWqhwQLxVkkRs6MxVDoiw== -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA0MTY1NzAxWhcNMjcwNTA1MTY1NzAxWjA7MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny @@ -30,13 +30,12 @@ mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/MGMGA1UdIwRcMFqA -FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE -CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T -BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAHK/HHrTZMnnVMpde1io+voAtql7j -4sRhLrjD7o3THtwRbDa2diCvpq0Sq23Ng2LMYoXsOxoL/RQK3iN7UKxV3MKPEr0w -XQS+kKQqiT2bsfrjnWMVHZtUOMpm6FNqcdGm/Rss3vKda2lcKl8kUnq/ylc1+QbB -G6A6tUvQcr2ZyWfVg+mM5XkhTrOOXus2OLikb4WwEtJTJRNE0f+yPODSUz0/vT57 -ApH0CnB80bYJshYHPHHymOtleAB8KSYtqm75g/YNobjnjB6cm4HkW3OZRVIl6fYY -n20NRVA1Vjs6GAROr4NqW4k/+LofY9y0LLDE+p0oIEKXIsIvhPr39swxSA== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBCwUA +A4IBAQB2W2dIy4q4KysbrTL4HIaOqu62RceGuQ/KhyiI6O0ndCtQ/PgCBqHHTP8u +8F1X2ivb60ynHV6baMLPI4Kf1k4MONtLSf/++1qh0Gdycd3A8IDAfy0YnC1F3OPK +vWO/cZGitKoTbEpP4y4Rng3sFCDndRCWIRIDOEEW/H3lCcfL7sOQojdLl85ajFkh +YvcDqjmnTcspUnuq9Y00C7porXJthZwz1S18qVjcFNk0zEhVMUbupSrdXVmKtOJW +MWZjgcA+OXzcnb2hSKWbhjykH/u6/PqkuHPkD723rwXbmHdxRVS9CW57kDkn5ezJ +5pE6Sam4qFsCNFJNBV9FRf3ZBMFi -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-good-alt.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-good-alt.crt index 9edf4c228a..f360a7696c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-good-alt.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-good-alt.crt @@ -1,7 +1,7 @@ -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA0MTY1NzAxWhcNMjcwNTA1MTY1NzAxWjA7MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny @@ -9,15 +9,14 @@ mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/MGMGA1UdIwRcMFqA -FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE -CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T -BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAHK/HHrTZMnnVMpde1io+voAtql7j -4sRhLrjD7o3THtwRbDa2diCvpq0Sq23Ng2LMYoXsOxoL/RQK3iN7UKxV3MKPEr0w -XQS+kKQqiT2bsfrjnWMVHZtUOMpm6FNqcdGm/Rss3vKda2lcKl8kUnq/ylc1+QbB -G6A6tUvQcr2ZyWfVg+mM5XkhTrOOXus2OLikb4WwEtJTJRNE0f+yPODSUz0/vT57 -ApH0CnB80bYJshYHPHHymOtleAB8KSYtqm75g/YNobjnjB6cm4HkW3OZRVIl6fYY -n20NRVA1Vjs6GAROr4NqW4k/+LofY9y0LLDE+p0oIEKXIsIvhPr39swxSA== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBCwUA +A4IBAQB2W2dIy4q4KysbrTL4HIaOqu62RceGuQ/KhyiI6O0ndCtQ/PgCBqHHTP8u +8F1X2ivb60ynHV6baMLPI4Kf1k4MONtLSf/++1qh0Gdycd3A8IDAfy0YnC1F3OPK +vWO/cZGitKoTbEpP4y4Rng3sFCDndRCWIRIDOEEW/H3lCcfL7sOQojdLl85ajFkh +YvcDqjmnTcspUnuq9Y00C7porXJthZwz1S18qVjcFNk0zEhVMUbupSrdXVmKtOJW +MWZjgcA+OXzcnb2hSKWbhjykH/u6/PqkuHPkD723rwXbmHdxRVS9CW57kDkn5ezJ +5pE6Sam4qFsCNFJNBV9FRf3ZBMFi -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt index 7cb35d48b2..e8b537c727 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt @@ -1,7 +1,7 @@ -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA0MTY1NzAxWhcNMjcwNTA1MTY1NzAxWjA7MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny @@ -9,13 +9,12 @@ mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/MGMGA1UdIwRcMFqA -FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE -CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T -BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAfDd5khSv/+K3De9qmH/ID3CVapGS -EN5MlXS5vvGCjZSA41MuXkUl11akKHXQ9aLlp85OZUdGbfQ5wwCoj/MymbT4fES2 -1dI8O1oI3PZI/0dqEvQETlIwSoZV2c/oaPRfh2E99v2+8FNIaZOfV2MX1n9+6AdO -W2nlK2oklozXSYg6KWtISr8N8Ofew2LQ9+riFlrrdaxsr8CoJqPqMDTq7FUmkDmO -oHize/h9bFksIunKoVQHa8P4w/W9bnR69nziyhZotbwOOkAWVnIyEM9QnaKWXeIy -rP6ewcTQjNYkguHJ8RY9rW+5bdaSY4EljSqZ3P3F+zo8P6sVi3qSlai5lQ== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBBQUA +A4IBAQABE3OEPfEd/bcJW5ZdU3/VgPNS4tMzh8gnJP/V2FcvFtGylMpQq6YnEBYI +yBHAL4DRvlMY5rnXGBp3ODR8MpqHC6AquRTCLzjS57iYff//4QFQqW9n92zctspv +czkaPKgjqo1No3Uq0Xaz10rcxyTUPrf5wNVRZ2V0KvllvAAVSzbI4mpdUXztjhST +S5A2BeWQAAOr0zq1F7TSRVJpJs7jmB2ai/igkh1IAjcuwV6VwlP+sbw0gjQ0NpGM +iHpnlzRAi/tIbtOvMIGOBU2TIfax/5jq1agUx5aPmT5TWAiJPOOP6l5xXnDwxeYS +NWqiX9GyusBZjezaCaHabjDLU0qQ -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt.der new file mode 100644 index 0000000000..039fb9e430 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha1.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt index b14e405dd2..9b08fe20a6 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt @@ -1,7 +1,7 @@ -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQsFADA7MQswCQYDVQQGEwJOTDER MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN -MTcwNTA0MTY1NzAxWhcNMjcwNTA1MTY1NzAxWjA7MQswCQYDVQQGEwJOTDERMA8G +MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny @@ -9,13 +9,12 @@ mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/MGMGA1UdIwRcMFqA -FLRa5KWz3tJS9rnVppUP6z68x/3/oT+kPTA7MQswCQYDVQQGEwJOTDERMA8GA1UE -CgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0GCAQAwDAYDVR0T -BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAHK/HHrTZMnnVMpde1io+voAtql7j -4sRhLrjD7o3THtwRbDa2diCvpq0Sq23Ng2LMYoXsOxoL/RQK3iN7UKxV3MKPEr0w -XQS+kKQqiT2bsfrjnWMVHZtUOMpm6FNqcdGm/Rss3vKda2lcKl8kUnq/ylc1+QbB -G6A6tUvQcr2ZyWfVg+mM5XkhTrOOXus2OLikb4WwEtJTJRNE0f+yPODSUz0/vT57 -ApH0CnB80bYJshYHPHHymOtleAB8KSYtqm75g/YNobjnjB6cm4HkW3OZRVIl6fYY -n20NRVA1Vjs6GAROr4NqW4k/+LofY9y0LLDE+p0oIEKXIsIvhPr39swxSA== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBCwUA +A4IBAQB2W2dIy4q4KysbrTL4HIaOqu62RceGuQ/KhyiI6O0ndCtQ/PgCBqHHTP8u +8F1X2ivb60ynHV6baMLPI4Kf1k4MONtLSf/++1qh0Gdycd3A8IDAfy0YnC1F3OPK +vWO/cZGitKoTbEpP4y4Rng3sFCDndRCWIRIDOEEW/H3lCcfL7sOQojdLl85ajFkh +YvcDqjmnTcspUnuq9Y00C7porXJthZwz1S18qVjcFNk0zEhVMUbupSrdXVmKtOJW +MWZjgcA+OXzcnb2hSKWbhjykH/u6/PqkuHPkD723rwXbmHdxRVS9CW57kDkn5ezJ +5pE6Sam4qFsCNFJNBV9FRf3ZBMFi -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt.der new file mode 100644 index 0000000000..80a47e8d32 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca-sha256.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt index f0eee2b829..e8b537c727 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt @@ -1,80 +1,20 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 0 (0x0) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Feb 12 14:44:00 2011 GMT - Not After : Feb 12 14:44:00 2021 GMT - Subject: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:c0:df:37:fc:17:bb:e0:96:9d:3f:86:de:96:32: - 7d:44:a5:16:a0:cd:21:f1:99:d4:ec:ea:cb:7c:18: - 58:08:94:a5:ec:9b:c5:8b:df:1a:1e:99:38:99:87: - 1e:7b:c0:8d:39:df:38:5d:70:78:07:d3:9e:d9:93: - e8:b9:72:51:c5:ce:a3:30:52:a9:f2:e7:40:70:14: - cb:44:a2:72:0b:c2:e5:40:f9:3e:e5:a6:0e:b3:f9: - ec:4a:63:c0:b8:29:00:74:9c:57:3b:a8:a5:04:90: - 71:f1:bd:83:d9:3f:d6:a5:e2:3c:2a:8f:ef:27:60: - c3:c6:9f:cb:ba:ec:60:7d:b7:e6:84:32:be:4f:fb: - 58:26:22:03:5b:d4:b4:d5:fb:f5:e3:96:2e:70:c0: - e4:2e:bd:fc:2e:ee:e2:41:55:c0:34:2e:7d:24:72: - 69:cb:47:b1:14:40:83:7d:67:f4:86:f6:31:ab:f1: - 79:a4:b2:b5:2e:12:f9:84:17:f0:62:6f:27:3e:13: - 58:b1:54:0d:21:9a:73:37:a1:30:cf:6f:92:dc:f6: - e9:fc:ac:db:2e:28:d1:7e:02:4b:23:a0:15:f2:38: - 65:64:09:ea:0c:6e:8e:1b:17:a0:71:c8:b3:9b:c9: - ab:e9:c3:f2:cf:87:96:8f:80:02:32:9e:99:58:6f: - a2:d5 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:TRUE - X509v3 Subject Key Identifier: - B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - X509v3 Authority Key Identifier: - keyid:B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - DirName:/C=NL/O=PolarSSL/CN=PolarSSL Test CA - serial:00 - - Signature Algorithm: sha1WithRSAEncryption - b8:fd:54:d8:00:54:90:8b:25:b0:27:dd:95:cd:a2:f7:84:07: - 1d:87:89:4a:c4:78:11:d8:07:b5:d7:22:50:8e:48:eb:62:7a: - 32:89:be:63:47:53:ff:b6:be:f1:2e:8c:54:c0:99:3f:a0:b9: - 37:23:72:5f:0d:46:59:8f:d8:47:cd:97:4c:9f:07:0c:12:62: - 09:3a:24:e4:36:d9:e9:2c:da:38:d0:73:75:61:d7:c1:6c:26: - 8b:9b:e0:d5:dc:67:ed:8c:6b:33:d7:74:22:3c:4c:db:b5:8d: - 2a:ce:2c:0d:08:59:05:09:05:a6:39:9f:b3:67:1b:e2:83:e5: - e1:8f:53:f6:67:93:c7:f9:6f:76:44:58:12:e8:3a:d4:97:e7: - e9:c0:3e:a8:7a:72:3d:87:53:1f:e5:2c:84:84:e7:9a:9e:7f: - 66:d9:1f:9b:f5:13:48:b0:4d:14:d1:de:b2:24:d9:78:7d:f5: - 35:cc:58:19:d1:d2:99:ef:4d:73:f8:1f:89:d4:5a:d0:52:ce: - 09:f5:b1:46:51:6a:00:8e:3b:cc:6f:63:01:00:99:ed:9d:a6: - 08:60:cd:32:18:d0:73:e0:58:71:d9:e5:d2:53:d7:8d:d0:ca: - e9:5d:2a:0a:0d:5d:55:ec:21:50:17:16:e6:06:4a:cd:5e:de: - f7:e0:e9:54 -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G +A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny 50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH -/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV -BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz -dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ -SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H -DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF -pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf -m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ -7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBBQUA +A4IBAQABE3OEPfEd/bcJW5ZdU3/VgPNS4tMzh8gnJP/V2FcvFtGylMpQq6YnEBYI +yBHAL4DRvlMY5rnXGBp3ODR8MpqHC6AquRTCLzjS57iYff//4QFQqW9n92zctspv +czkaPKgjqo1No3Uq0Xaz10rcxyTUPrf5wNVRZ2V0KvllvAAVSzbI4mpdUXztjhST +S5A2BeWQAAOr0zq1F7TSRVJpJs7jmB2ai/igkh1IAjcuwV6VwlP+sbw0gjQ0NpGM +iHpnlzRAi/tIbtOvMIGOBU2TIfax/5jq1agUx5aPmT5TWAiJPOOP6l5xXnDwxeYS +NWqiX9GyusBZjezaCaHabjDLU0qQ -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt.der new file mode 100644 index 0000000000..039fb9e430 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.key.der new file mode 100644 index 0000000000..4678a1ab39 Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.crt.der b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.crt.der new file mode 100644 index 0000000000..bb0b51f9dc Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.crt.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.key.der b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.key.der new file mode 100644 index 0000000000..bf64141aae Binary files /dev/null and b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.key.der differ diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.key.enc b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.key.enc new file mode 100644 index 0000000000..bb70990126 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca2.key.enc @@ -0,0 +1,9 @@ +-----BEGIN EC PRIVATE KEY----- +Proc-Type: 4,ENCRYPTED +DEK-Info: DES-EDE3-CBC,307EAB469933D64E + +IxbrRmKcAzctJqPdTQLA4SWyBYYGYJVkYEna+F7Pa5t5Yg/gKADrFKcm6B72e7DG +ihExtZI648s0zdYw6qSJ74vrPSuWDe5qm93BqsfVH9svtCzWHW0pm1p0KTBCFfUq +UsuWTITwJImcnlAs1gaRZ3sAWm7cOUidL0fo2G0fYUFNcYoCSLffCFTEHBuPnagb +a77x/sY1Bvii8S9/XhDTb6pTMx06wzrm +-----END EC PRIVATE KEY----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat12.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat12.crt index 5e4bf063d9..d989e3b133 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat12.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat12.crt @@ -1,82 +1,22 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 0 (0x0) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Feb 12 14:44:00 2011 GMT - Not After : Feb 12 14:44:00 2021 GMT - Subject: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:c0:df:37:fc:17:bb:e0:96:9d:3f:86:de:96:32: - 7d:44:a5:16:a0:cd:21:f1:99:d4:ec:ea:cb:7c:18: - 58:08:94:a5:ec:9b:c5:8b:df:1a:1e:99:38:99:87: - 1e:7b:c0:8d:39:df:38:5d:70:78:07:d3:9e:d9:93: - e8:b9:72:51:c5:ce:a3:30:52:a9:f2:e7:40:70:14: - cb:44:a2:72:0b:c2:e5:40:f9:3e:e5:a6:0e:b3:f9: - ec:4a:63:c0:b8:29:00:74:9c:57:3b:a8:a5:04:90: - 71:f1:bd:83:d9:3f:d6:a5:e2:3c:2a:8f:ef:27:60: - c3:c6:9f:cb:ba:ec:60:7d:b7:e6:84:32:be:4f:fb: - 58:26:22:03:5b:d4:b4:d5:fb:f5:e3:96:2e:70:c0: - e4:2e:bd:fc:2e:ee:e2:41:55:c0:34:2e:7d:24:72: - 69:cb:47:b1:14:40:83:7d:67:f4:86:f6:31:ab:f1: - 79:a4:b2:b5:2e:12:f9:84:17:f0:62:6f:27:3e:13: - 58:b1:54:0d:21:9a:73:37:a1:30:cf:6f:92:dc:f6: - e9:fc:ac:db:2e:28:d1:7e:02:4b:23:a0:15:f2:38: - 65:64:09:ea:0c:6e:8e:1b:17:a0:71:c8:b3:9b:c9: - ab:e9:c3:f2:cf:87:96:8f:80:02:32:9e:99:58:6f: - a2:d5 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:TRUE - X509v3 Subject Key Identifier: - B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - X509v3 Authority Key Identifier: - keyid:B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - DirName:/C=NL/O=PolarSSL/CN=PolarSSL Test CA - serial:00 - - Signature Algorithm: sha1WithRSAEncryption - b8:fd:54:d8:00:54:90:8b:25:b0:27:dd:95:cd:a2:f7:84:07: - 1d:87:89:4a:c4:78:11:d8:07:b5:d7:22:50:8e:48:eb:62:7a: - 32:89:be:63:47:53:ff:b6:be:f1:2e:8c:54:c0:99:3f:a0:b9: - 37:23:72:5f:0d:46:59:8f:d8:47:cd:97:4c:9f:07:0c:12:62: - 09:3a:24:e4:36:d9:e9:2c:da:38:d0:73:75:61:d7:c1:6c:26: - 8b:9b:e0:d5:dc:67:ed:8c:6b:33:d7:74:22:3c:4c:db:b5:8d: - 2a:ce:2c:0d:08:59:05:09:05:a6:39:9f:b3:67:1b:e2:83:e5: - e1:8f:53:f6:67:93:c7:f9:6f:76:44:58:12:e8:3a:d4:97:e7: - e9:c0:3e:a8:7a:72:3d:87:53:1f:e5:2c:84:84:e7:9a:9e:7f: - 66:d9:1f:9b:f5:13:48:b0:4d:14:d1:de:b2:24:d9:78:7d:f5: - 35:cc:58:19:d1:d2:99:ef:4d:73:f8:1f:89:d4:5a:d0:52:ce: - 09:f5:b1:46:51:6a:00:8e:3b:cc:6f:63:01:00:99:ed:9d:a6: - 08:60:cd:32:18:d0:73:e0:58:71:d9:e5:d2:53:d7:8d:d0:ca: - e9:5d:2a:0a:0d:5d:55:ec:21:50:17:16:e6:06:4a:cd:5e:de: - f7:e0:e9:54 -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G +A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny 50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH -/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV -BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz -dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ -SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H -DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF -pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf -m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ -7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBBQUA +A4IBAQABE3OEPfEd/bcJW5ZdU3/VgPNS4tMzh8gnJP/V2FcvFtGylMpQq6YnEBYI +yBHAL4DRvlMY5rnXGBp3ODR8MpqHC6AquRTCLzjS57iYff//4QFQqW9n92zctspv +czkaPKgjqo1No3Uq0Xaz10rcxyTUPrf5wNVRZ2V0KvllvAAVSzbI4mpdUXztjhST +S5A2BeWQAAOr0zq1F7TSRVJpJs7jmB2ai/igkh1IAjcuwV6VwlP+sbw0gjQ0NpGM +iHpnlzRAi/tIbtOvMIGOBU2TIfax/5jq1agUx5aPmT5TWAiJPOOP6l5xXnDwxeYS +NWqiX9GyusBZjezaCaHabjDLU0qQ -----END CERTIFICATE----- -----BEGIN CERTIFICATE----- MIICUjCCAdegAwIBAgIJAMFD4n5iQ8zoMAoGCCqGSM49BAMCMD4xCzAJBgNVBAYT diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat21.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat21.crt index 5630789eb8..97b4d2c9e7 100644 --- a/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat21.crt +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-ca_cat21.crt @@ -13,83 +13,23 @@ CgYIKoZIzj0EAwIDaQAwZgIxAMO0YnNWKJUAfXgSJtJxexn4ipg+kv4znuR50v56 t4d0PCu412mUC6Nnd7izvtE2MgIxAP1nnJQjZ8BWukszFQDG48wxCCyci9qpdSMv uCjn8pwUOkABXK8Mss90fzCfCEOtIA== -----END CERTIFICATE----- -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 0 (0x0) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Validity - Not Before: Feb 12 14:44:00 2011 GMT - Not After : Feb 12 14:44:00 2021 GMT - Subject: C=NL, O=PolarSSL, CN=PolarSSL Test CA - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:c0:df:37:fc:17:bb:e0:96:9d:3f:86:de:96:32: - 7d:44:a5:16:a0:cd:21:f1:99:d4:ec:ea:cb:7c:18: - 58:08:94:a5:ec:9b:c5:8b:df:1a:1e:99:38:99:87: - 1e:7b:c0:8d:39:df:38:5d:70:78:07:d3:9e:d9:93: - e8:b9:72:51:c5:ce:a3:30:52:a9:f2:e7:40:70:14: - cb:44:a2:72:0b:c2:e5:40:f9:3e:e5:a6:0e:b3:f9: - ec:4a:63:c0:b8:29:00:74:9c:57:3b:a8:a5:04:90: - 71:f1:bd:83:d9:3f:d6:a5:e2:3c:2a:8f:ef:27:60: - c3:c6:9f:cb:ba:ec:60:7d:b7:e6:84:32:be:4f:fb: - 58:26:22:03:5b:d4:b4:d5:fb:f5:e3:96:2e:70:c0: - e4:2e:bd:fc:2e:ee:e2:41:55:c0:34:2e:7d:24:72: - 69:cb:47:b1:14:40:83:7d:67:f4:86:f6:31:ab:f1: - 79:a4:b2:b5:2e:12:f9:84:17:f0:62:6f:27:3e:13: - 58:b1:54:0d:21:9a:73:37:a1:30:cf:6f:92:dc:f6: - e9:fc:ac:db:2e:28:d1:7e:02:4b:23:a0:15:f2:38: - 65:64:09:ea:0c:6e:8e:1b:17:a0:71:c8:b3:9b:c9: - ab:e9:c3:f2:cf:87:96:8f:80:02:32:9e:99:58:6f: - a2:d5 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Basic Constraints: - CA:TRUE - X509v3 Subject Key Identifier: - B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - X509v3 Authority Key Identifier: - keyid:B4:5A:E4:A5:B3:DE:D2:52:F6:B9:D5:A6:95:0F:EB:3E:BC:C7:FD:FF - DirName:/C=NL/O=PolarSSL/CN=PolarSSL Test CA - serial:00 - - Signature Algorithm: sha1WithRSAEncryption - b8:fd:54:d8:00:54:90:8b:25:b0:27:dd:95:cd:a2:f7:84:07: - 1d:87:89:4a:c4:78:11:d8:07:b5:d7:22:50:8e:48:eb:62:7a: - 32:89:be:63:47:53:ff:b6:be:f1:2e:8c:54:c0:99:3f:a0:b9: - 37:23:72:5f:0d:46:59:8f:d8:47:cd:97:4c:9f:07:0c:12:62: - 09:3a:24:e4:36:d9:e9:2c:da:38:d0:73:75:61:d7:c1:6c:26: - 8b:9b:e0:d5:dc:67:ed:8c:6b:33:d7:74:22:3c:4c:db:b5:8d: - 2a:ce:2c:0d:08:59:05:09:05:a6:39:9f:b3:67:1b:e2:83:e5: - e1:8f:53:f6:67:93:c7:f9:6f:76:44:58:12:e8:3a:d4:97:e7: - e9:c0:3e:a8:7a:72:3d:87:53:1f:e5:2c:84:84:e7:9a:9e:7f: - 66:d9:1f:9b:f5:13:48:b0:4d:14:d1:de:b2:24:d9:78:7d:f5: - 35:cc:58:19:d1:d2:99:ef:4d:73:f8:1f:89:d4:5a:d0:52:ce: - 09:f5:b1:46:51:6a:00:8e:3b:cc:6f:63:01:00:99:ed:9d:a6: - 08:60:cd:32:18:d0:73:e0:58:71:d9:e5:d2:53:d7:8d:d0:ca: - e9:5d:2a:0a:0d:5d:55:ec:21:50:17:16:e6:06:4a:cd:5e:de: - f7:e0:e9:54 -----BEGIN CERTIFICATE----- -MIIDhzCCAm+gAwIBAgIBADANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER -MA8GA1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwHhcN +MIIDQTCCAimgAwIBAgIBAzANBgkqhkiG9w0BAQUFADA7MQswCQYDVQQGEwJOTDER +MA8GA1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwHhcN MTEwMjEyMTQ0NDAwWhcNMjEwMjEyMTQ0NDAwWjA7MQswCQYDVQQGEwJOTDERMA8G -A1UEChMIUG9sYXJTU0wxGTAXBgNVBAMTEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G +A1UECgwIUG9sYXJTU0wxGTAXBgNVBAMMEFBvbGFyU1NMIFRlc3QgQ0EwggEiMA0G CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDA3zf8F7vglp0/ht6WMn1EpRagzSHx mdTs6st8GFgIlKXsm8WL3xoemTiZhx57wI053zhdcHgH057Zk+i5clHFzqMwUqny 50BwFMtEonILwuVA+T7lpg6z+exKY8C4KQB0nFc7qKUEkHHxvYPZP9al4jwqj+8n YMPGn8u67GB9t+aEMr5P+1gmIgNb1LTV+/Xjli5wwOQuvfwu7uJBVcA0Ln0kcmnL R7EUQIN9Z/SG9jGr8XmksrUuEvmEF/Bibyc+E1ixVA0hmnM3oTDPb5Lc9un8rNsu KNF+AksjoBXyOGVkCeoMbo4bF6BxyLObyavpw/LPh5aPgAIynplYb6LVAgMBAAGj -gZUwgZIwDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUtFrkpbPe0lL2udWmlQ/rPrzH -/f8wYwYDVR0jBFwwWoAUtFrkpbPe0lL2udWmlQ/rPrzH/f+hP6Q9MDsxCzAJBgNV -BAYTAk5MMREwDwYDVQQKEwhQb2xhclNTTDEZMBcGA1UEAxMQUG9sYXJTU0wgVGVz -dCBDQYIBADANBgkqhkiG9w0BAQUFAAOCAQEAuP1U2ABUkIslsCfdlc2i94QHHYeJ -SsR4EdgHtdciUI5I62J6Mom+Y0dT/7a+8S6MVMCZP6C5NyNyXw1GWY/YR82XTJ8H -DBJiCTok5DbZ6SzaONBzdWHXwWwmi5vg1dxn7YxrM9d0IjxM27WNKs4sDQhZBQkF -pjmfs2cb4oPl4Y9T9meTx/lvdkRYEug61Jfn6cA+qHpyPYdTH+UshITnmp5/Ztkf -m/UTSLBNFNHesiTZeH31NcxYGdHSme9Nc/gfidRa0FLOCfWxRlFqAI47zG9jAQCZ -7Z2mCGDNMhjQc+BYcdnl0lPXjdDK6V0qCg1dVewhUBcW5gZKzV7e9+DpVA== +UDBOMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFLRa5KWz3tJS9rnVppUP6z68x/3/ +MB8GA1UdIwQYMBaAFLRa5KWz3tJS9rnVppUP6z68x/3/MA0GCSqGSIb3DQEBBQUA +A4IBAQABE3OEPfEd/bcJW5ZdU3/VgPNS4tMzh8gnJP/V2FcvFtGylMpQq6YnEBYI +yBHAL4DRvlMY5rnXGBp3ODR8MpqHC6AquRTCLzjS57iYff//4QFQqW9n92zctspv +czkaPKgjqo1No3Uq0Xaz10rcxyTUPrf5wNVRZ2V0KvllvAAVSzbI4mpdUXztjhST +S5A2BeWQAAOr0zq1F7TSRVJpJs7jmB2ai/igkh1IAjcuwV6VwlP+sbw0gjQ0NpGM +iHpnlzRAi/tIbtOvMIGOBU2TIfax/5jq1agUx5aPmT5TWAiJPOOP6l5xXnDwxeYS +NWqiX9GyusBZjezaCaHabjDLU0qQ -----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/data_files/test-int-ca3-badsign.crt b/3rdparty/mbedtls/mbedtls/tests/data_files/test-int-ca3-badsign.crt new file mode 100644 index 0000000000..2087056e8e --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/data_files/test-int-ca3-badsign.crt @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBtDCCATqgAwIBAgIBTTAKBggqhkjOPQQDAjBLMQswCQYDVQQGEwJOTDERMA8G +A1UEChMIUG9sYXJTU0wxKTAnBgNVBAMTIFBvbGFyU1NMIFRlc3QgSW50ZXJtZWRp +YXRlIEVDIENBMB4XDTE1MDkwMTE0MDg0M1oXDTI1MDgyOTE0MDg0M1owSjELMAkG +A1UEBhMCVUsxETAPBgNVBAoTCG1iZWQgVExTMSgwJgYDVQQDEx9tYmVkIFRMUyBU +ZXN0IGludGVybWVkaWF0ZSBDQSAzMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE +732fWHLNPMPsP1U1ibXvb55erlEVMlpXBGsj+KYwVqU1XCmW9Z9hhP7X/5js/DX9 +2J/utoHyjUtVpQOzdTrbsaMQMA4wDAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAgNo +ADBlAjAJRxbGRas3NBmk9MnGWXg7PT1xnRELHRWWIvfLdVQt06l1/xFg3ZuPdQdt +Qh7CK80CMQD7wa1o1a8qyDKBfLN636uKmKGga0E+vYXBeFCy9oARBangGCB0B2vt +pz590JvGWf0= +-----END CERTIFICATE----- diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/all.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/all.sh index 391de195be..7eaefe9995 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/all.sh +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/all.sh @@ -35,9 +35,9 @@ # * GNU Make # * CMake # * GCC and Clang (recent enough for using ASan with gcc and MemSan with clang, or valgrind) +# * G++ # * arm-gcc and mingw-gcc # * ArmCC 5 and ArmCC 6, unless invoked with --no-armcc -# * Yotta build dependencies, unless invoked with --no-yotta # * OpenSSL and GnuTLS command line tools, recent enough for the # interoperability tests. If they don't support SSLv3 then a legacy # version of these tools must be present as well (search for LEGACY @@ -55,21 +55,46 @@ # Notes for maintainers # --------------------- # +# The bulk of the code is organized into functions that follow one of the +# following naming conventions: +# * pre_XXX: things to do before running the tests, in order. +# * component_XXX: independent components. They can be run in any order. +# * component_check_XXX: quick tests that aren't worth parallelizing. +# * component_build_XXX: build things but don't run them. +# * component_test_XXX: build and test. +# * support_XXX: if support_XXX exists and returns false then +# component_XXX is not run by default. +# * post_XXX: things to do after running the tests. +# * other: miscellaneous support functions. +# +# Each component must start by invoking `msg` with a short informative message. +# +# The framework performs some cleanup tasks after each component. This +# means that components can assume that the working directory is in a +# cleaned-up state, and don't need to perform the cleanup themselves. +# * Run `make clean`. +# * Restore `include/mbedtks/config.h` from a backup made before running +# the component. +# * Check out `Makefile`, `library/Makefile`, `programs/Makefile` and +# `tests/Makefile` from git. This cleans up after an in-tree use of +# CMake. +# +# Any command that is expected to fail must be protected so that the +# script keeps running in --keep-going mode despite `set -e`. In keep-going +# mode, if a protected command fails, this is logged as a failure and the +# script will exit with a failure status once it has run all components. +# Commands can be protected in any of the following ways: +# * `make` is a function which runs the `make` command with protection. +# Note that you must write `make VAR=value`, not `VAR=value make`, +# because the `VAR=value make` syntax doesn't work with functions. +# * Put `report_status` before the command to protect it. +# * Put `if_build_successful` before a command. This protects it, and +# additionally skips it if a prior invocation of `make` in the same +# component failed. +# # The tests are roughly in order from fastest to slowest. This doesn't # have to be exact, but in general you should add slower tests towards # the end and fast checks near the beginning. -# -# Sanity checks have the following form: -# 1. msg "short description of what is about to be done" -# 2. run sanity check (failure stops the script) -# -# Build or build-and-test steps have the following form: -# 1. msg "short description of what is about to be done" -# 2. cleanup -# 3. preparation (config.pl, cmake, ...) (failure stops the script) -# 4. make -# 5. Run tests if relevant. All tests must be prefixed with -# if_build_successful for the sake of --keep-going. @@ -80,60 +105,101 @@ # Abort on errors (and uninitialised variables) set -eu -if [ "$( uname )" != "Linux" ]; then - echo "This script only works in Linux" >&2 - exit 1 -elif [ -d library -a -d include -a -d tests ]; then :; else - echo "Must be run from mbed TLS root" >&2 - exit 1 -fi +pre_check_environment () { + if [ -d library -a -d include -a -d tests ]; then :; else + echo "Must be run from mbed TLS root" >&2 + exit 1 + fi +} -CONFIG_H='include/mbedtls/config.h' -CONFIG_BAK="$CONFIG_H.bak" - -MEMORY=0 -FORCE=0 -KEEP_GOING=0 -RUN_ARMCC=1 -YOTTA=1 - -# Default commands, can be overriden by the environment -: ${OPENSSL:="openssl"} -: ${OPENSSL_LEGACY:="$OPENSSL"} -: ${GNUTLS_CLI:="gnutls-cli"} -: ${GNUTLS_SERV:="gnutls-serv"} -: ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} -: ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} -: ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} -: ${ARMC5_BIN_DIR:=/usr/bin} -: ${ARMC6_BIN_DIR:=/usr/bin} - -# if MAKEFLAGS is not set add the -j option to speed up invocations of make -if [ -n "${MAKEFLAGS+set}" ]; then - export MAKEFLAGS="-j" -fi +pre_initialize_variables () { + CONFIG_H='include/mbedtls/config.h' + CONFIG_BAK="$CONFIG_H.bak" + + MEMORY=0 + FORCE=0 + KEEP_GOING=0 + + # Default commands, can be overriden by the environment + : ${OPENSSL:="openssl"} + : ${OPENSSL_LEGACY:="$OPENSSL"} + : ${OPENSSL_NEXT:="$OPENSSL"} + : ${GNUTLS_CLI:="gnutls-cli"} + : ${GNUTLS_SERV:="gnutls-serv"} + : ${GNUTLS_LEGACY_CLI:="$GNUTLS_CLI"} + : ${GNUTLS_LEGACY_SERV:="$GNUTLS_SERV"} + : ${OUT_OF_SOURCE_DIR:=./mbedtls_out_of_source_build} + : ${ARMC5_BIN_DIR:=/usr/bin} + : ${ARMC6_BIN_DIR:=/usr/bin} + + # if MAKEFLAGS is not set add the -j option to speed up invocations of make + if [ -z "${MAKEFLAGS+set}" ]; then + export MAKEFLAGS="-j" + fi + + # Gather the list of available components. These are the functions + # defined in this script whose name starts with "component_". + # Parse the script with sed, because in sh there is no way to list + # defined functions. + ALL_COMPONENTS=$(sed -n 's/^ *component_\([0-9A-Z_a-z]*\) *().*/\1/p' <"$0") + + # Exclude components that are not supported on this platform. + SUPPORTED_COMPONENTS= + for component in $ALL_COMPONENTS; do + case $(type "support_$component" 2>&1) in + *' function'*) + if ! support_$component; then continue; fi;; + esac + SUPPORTED_COMPONENTS="$SUPPORTED_COMPONENTS $component" + done +} + +# Test whether the component $1 is included in the command line patterns. +is_component_included() +{ + set -f + for pattern in $COMMAND_LINE_COMPONENTS; do + set +f + case ${1#component_} in $pattern) return 0;; esac + done + set +f + return 1 +} usage() { cat < Directory used for CMake out-of-source build tests. --random-seed Use a random seed value for randomized tests (default). -r|--release-test Run this script in release mode. This fixes the seed value to 1. -s|--seed Integer seed value to use for this test run. - --yotta Build yotta module (on by default). Tool path options: --armc5-bin-dir= ARM Compiler 5 bin directory. @@ -144,6 +210,7 @@ Tool path options: --gnutls-legacy-serv= GnuTLS server executable to use for legacy tests. --openssl= OpenSSL executable to use for most tests. --openssl-legacy= OpenSSL executable to use for legacy tests e.g. SSLv3. + --openssl-next= OpenSSL executable to use for recent things like ARIA EOF } @@ -157,7 +224,7 @@ cleanup() command make clean # Remove CMake artefacts - find . -name .git -prune -o -name yotta -prune -o \ + find . -name .git -prune \ -iname CMakeFiles -exec rm -rf {} \+ -o \ \( -iname cmake_install.cmake -o \ -iname CTestTestfile.cmake -o \ @@ -190,25 +257,27 @@ trap 'fatal_signal TERM' TERM msg() { + if [ -n "${current_component:-}" ]; then + current_section="${current_component#component_}: $1" + else + current_section="$1" + fi echo "" echo "******************************************************************" - echo "* $1 " + echo "* $current_section " printf "* "; date echo "******************************************************************" - current_section=$1 } -if [ $RUN_ARMCC -ne 0 ]; then - armc6_build_test() - { - FLAGS="$1" +armc6_build_test() +{ + FLAGS="$1" - msg "build: ARM Compiler 6 ($FLAGS), make" - ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ - WARNING_CFLAGS='-xc -std=c99' make lib - make clean - } -fi + msg "build: ARM Compiler 6 ($FLAGS), make" + ARM_TOOL_VARIANT="ult" CC="$ARMC6_CC" AR="$ARMC6_AR" CFLAGS="$FLAGS" \ + WARNING_CFLAGS='-xc -std=c99' make lib + make clean +} err_msg() { @@ -225,72 +294,103 @@ check_tools() done } -while [ $# -gt 0 ]; do - case "$1" in - --armcc) RUN_ARMCC=1;; - --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; - --armc6-bin-dir) shift; ARMC6_BIN_DIR="$1";; - --force|-f) FORCE=1;; - --gnutls-cli) shift; GNUTLS_CLI="$1";; - --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; - --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; - --gnutls-serv) shift; GNUTLS_SERV="$1";; - --help|-h) usage; exit;; - --keep-going|-k) KEEP_GOING=1;; - --memory|-m) MEMORY=1;; - --no-armcc) RUN_ARMCC=0;; - --no-force) FORCE=0;; - --no-keep-going) KEEP_GOING=0;; - --no-memory) MEMORY=0;; - --no-yotta) YOTTA=0;; - --openssl) shift; OPENSSL="$1";; - --openssl-legacy) shift; OPENSSL_LEGACY="$1";; - --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; - --random-seed) unset SEED;; - --release-test|-r) SEED=1;; - --seed|-s) shift; SEED="$1";; - --yotta) YOTTA=1;; - *) - echo >&2 "Unknown option: $1" - echo >&2 "Run $0 --help for usage." - exit 120 - ;; - esac - shift -done +check_headers_in_cpp () { + ls include/mbedtls | grep "\.h$" >headers.txt + &2 "Unknown option: $1" + echo >&2 "Run $0 --help for usage." + exit 120 + ;; + *) COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS $1";; + esac + shift + done - if [ $YOTTA -ne 0 ] && [ -d yotta/module ]; then - err_msg "Warning - there is an existing yotta module in the directory 'yotta/module'" - echo "You can either delete your work and retry, or force the test to overwrite the" - echo "test by rerunning the script as: $0 --force" - exit 1 + # With no list of components, run everything. + if [ -z "$COMMAND_LINE_COMPONENTS" ]; then + all_except=1 fi - if [ -d "$OUT_OF_SOURCE_DIR" ]; then - echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 - echo "You can either delete this directory manually, or force the test by rerunning" - echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" - exit 1 + # --no-armcc is a legacy option. The modern way is --except '*_armcc*'. + # Ignore it if components are listed explicitly on the command line. + if [ -n "$no_armcc" ] && [ $all_except -eq 1 ]; then + COMMAND_LINE_COMPONENTS="$COMMAND_LINE_COMPONENTS *_armcc*" fi - if ! git diff-files --quiet include/mbedtls/config.h; then - err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " - echo "You can either delete or preserve your work, or force the test by rerunning the" - echo "script as: $0 --force" - exit 1 + # Build the list of components to run. + RUN_COMPONENTS= + for component in $SUPPORTED_COMPONENTS; do + if is_component_included "$component"; [ $? -eq $all_except ]; then + RUN_COMPONENTS="$RUN_COMPONENTS $component" + fi + done + + unset all_except + unset no_armcc +} + +pre_check_git () { + if [ $FORCE -eq 1 ]; then + rm -rf "$OUT_OF_SOURCE_DIR" + git checkout-index -f -q $CONFIG_H + cleanup + else + + if [ -d "$OUT_OF_SOURCE_DIR" ]; then + echo "Warning - there is an existing directory at '$OUT_OF_SOURCE_DIR'" >&2 + echo "You can either delete this directory manually, or force the test by rerunning" + echo "the script as: $0 --force --out-of-source-dir $OUT_OF_SOURCE_DIR" + exit 1 + fi + + if ! git diff --quiet include/mbedtls/config.h; then + err_msg "Warning - the configuration file 'include/mbedtls/config.h' has been edited. " + echo "You can either delete or preserve your work, or force the test by rerunning the" + echo "script as: $0 --force" + exit 1 + fi fi -fi +} -build_status=0 -if [ $KEEP_GOING -eq 1 ]; then +pre_setup_keep_going () { failure_summary= failure_count=0 start_red= @@ -344,53 +444,98 @@ $text" echo "Killed by SIG$1." fi } -else - record_status () { - "$@" - } -fi +} + if_build_succeeded () { if [ $build_status -eq 0 ]; then record_status "$@" fi } -msg "info: $0 configuration" -echo "MEMORY: $MEMORY" -echo "FORCE: $FORCE" -echo "SEED: ${SEED-"UNSET"}" -echo "OPENSSL: $OPENSSL" -echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" -echo "GNUTLS_CLI: $GNUTLS_CLI" -echo "GNUTLS_SERV: $GNUTLS_SERV" -echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" -echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" -echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" -echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" - -ARMC5_CC="$ARMC5_BIN_DIR/armcc" -ARMC5_AR="$ARMC5_BIN_DIR/armar" -ARMC6_CC="$ARMC6_BIN_DIR/armclang" -ARMC6_AR="$ARMC6_BIN_DIR/armar" - -# To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh -# we just export the variables they require -export OPENSSL_CMD="$OPENSSL" -export GNUTLS_CLI="$GNUTLS_CLI" -export GNUTLS_SERV="$GNUTLS_SERV" - -# Avoid passing --seed flag in every call to ssl-opt.sh -if [ -n "${SEED-}" ]; then - export SEED -fi +# to be used instead of ! for commands run with +# record_status or if_build_succeeded +not() { + ! "$@" +} + +pre_print_configuration () { + msg "info: $0 configuration" + echo "MEMORY: $MEMORY" + echo "FORCE: $FORCE" + echo "SEED: ${SEED-"UNSET"}" + echo "OPENSSL: $OPENSSL" + echo "OPENSSL_LEGACY: $OPENSSL_LEGACY" + echo "OPENSSL_NEXT: $OPENSSL_NEXT" + echo "GNUTLS_CLI: $GNUTLS_CLI" + echo "GNUTLS_SERV: $GNUTLS_SERV" + echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" + echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" + echo "ARMC5_BIN_DIR: $ARMC5_BIN_DIR" + echo "ARMC6_BIN_DIR: $ARMC6_BIN_DIR" +} # Make sure the tools we need are available. -check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \ - "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \ - "arm-none-eabi-gcc" "i686-w64-mingw32-gcc" -if [ $RUN_ARMCC -ne 0 ]; then - check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR" -fi +pre_check_tools () { + # Build the list of variables to pass to output_env.sh. + set env + + case " $RUN_COMPONENTS " in + # Require OpenSSL and GnuTLS if running any tests (as opposed to + # only doing builds). Not all tests run OpenSSL and GnuTLS, but this + # is a good enough approximation in practice. + *" test_"*) + # To avoid setting OpenSSL and GnuTLS for each call to compat.sh + # and ssl-opt.sh, we just export the variables they require. + export OPENSSL_CMD="$OPENSSL" + export GNUTLS_CLI="$GNUTLS_CLI" + export GNUTLS_SERV="$GNUTLS_SERV" + # Avoid passing --seed flag in every call to ssl-opt.sh + if [ -n "${SEED-}" ]; then + export SEED + fi + set "$@" OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" + set "$@" GNUTLS_CLI="$GNUTLS_CLI" GNUTLS_SERV="$GNUTLS_SERV" + set "$@" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" + set "$@" GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" + check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$OPENSSL_NEXT" \ + "$GNUTLS_CLI" "$GNUTLS_SERV" \ + "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" + ;; + esac + + case " $RUN_COMPONENTS " in + *_doxygen[_\ ]*) check_tools "doxygen" "dot";; + esac + + case " $RUN_COMPONENTS " in + *_arm_none_eabi_gcc[_\ ]*) check_tools "arm-none-eabi-gcc";; + esac + + case " $RUN_COMPONENTS " in + *_mingw[_\ ]*) check_tools "i686-w64-mingw32-gcc";; + esac + + case " $RUN_COMPONENTS " in + *" test_zeroize "*) check_tools "gdb";; + esac + + case " $RUN_COMPONENTS " in + *_armcc*) + ARMC5_CC="$ARMC5_BIN_DIR/armcc" + ARMC5_AR="$ARMC5_BIN_DIR/armar" + ARMC6_CC="$ARMC6_BIN_DIR/armclang" + ARMC6_AR="$ARMC6_BIN_DIR/armar" + check_tools "$ARMC5_CC" "$ARMC5_AR" "$ARMC6_CC" "$ARMC6_AR";; + esac + + msg "info: output_env.sh" + case $RUN_COMPONENTS in + *_armcc*) + set "$@" ARMC5_CC="$ARMC5_CC" ARMC6_CC="$ARMC6_CC" RUN_ARMCC=1;; + *) set "$@" RUN_ARMCC=0;; + esac + "$@" scripts/output_env.sh +} @@ -409,32 +554,35 @@ fi # # Indicative running times are given for reference. -msg "info: output_env.sh" -OPENSSL="$OPENSSL" OPENSSL_LEGACY="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_CLI" \ - GNUTLS_SERV="$GNUTLS_SERV" GNUTLS_LEGACY_CLI="$GNUTLS_LEGACY_CLI" \ - GNUTLS_LEGACY_SERV="$GNUTLS_LEGACY_SERV" ARMC5_CC="$ARMC5_CC" \ - ARMC6_CC="$ARMC6_CC" RUN_ARMCC="$RUN_ARMCC" scripts/output_env.sh - -msg "test: recursion.pl" # < 1s -record_status tests/scripts/recursion.pl library/*.c +component_check_recursion () { + msg "test: recursion.pl" # < 1s + record_status tests/scripts/recursion.pl library/*.c +} -msg "test: freshness of generated source files" # < 1s -record_status tests/scripts/check-generated-files.sh +component_check_generated_files () { + msg "test: freshness of generated source files" # < 1s + record_status tests/scripts/check-generated-files.sh +} -msg "test: doxygen markup outside doxygen blocks" # < 1s -record_status tests/scripts/check-doxy-blocks.pl +component_check_doxy_blocks () { + msg "test: doxygen markup outside doxygen blocks" # < 1s + record_status tests/scripts/check-doxy-blocks.pl +} -msg "test: check-files.py" # < 1s -cleanup -record_status tests/scripts/check-files.py +component_check_files () { + msg "test: check-files.py" # < 1s + record_status tests/scripts/check-files.py +} -msg "test/build: declared and exported names" # < 3s -cleanup -record_status tests/scripts/check-names.sh +component_check_names () { + msg "test/build: declared and exported names" # < 3s + record_status tests/scripts/check-names.sh -v +} -msg "test: doxygen warnings" # ~ 3s -cleanup -record_status tests/scripts/doxygen.sh +component_check_doxygen_warnings () { + msg "test: doxygen warnings" # ~ 3s + record_status tests/scripts/doxygen.sh +} @@ -442,345 +590,553 @@ record_status tests/scripts/doxygen.sh #### Build and test many configurations and targets ################################################################ -if [ $RUN_ARMCC -ne 0 ] && [ $YOTTA -ne 0 ]; then - # Note - use of yotta is deprecated, and yotta also requires armcc to be on the - # path, and uses whatever version of armcc it finds there. - msg "build: create and build yotta module" # ~ 30s - cleanup - record_status tests/scripts/yotta-build.sh -fi +component_test_default_out_of_box () { + msg "build: make, default config (out-of-box)" # ~1min + make -msg "build: cmake, gcc, ASan" # ~ 1 min 50s -cleanup -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make + msg "test: main suites make, default config (out-of-box)" # ~10s + make test -msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s -make test + msg "selftest: make, default config (out-of-box)" # ~10s + programs/test/selftest +} -msg "test: ssl-opt.sh (ASan build)" # ~ 1 min -if_build_succeeded tests/ssl-opt.sh +component_test_default_cmake_gcc_asan () { + msg "build: cmake, gcc, ASan" # ~ 1 min 50s + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s -record_status tests/scripts/test-ref-configs.pl + msg "test: main suites (inc. selftests) (ASan build)" # ~ 50s + make test + + msg "test: ssl-opt.sh (ASan build)" # ~ 1 min + if_build_succeeded tests/ssl-opt.sh -msg "build: with ASan (rebuild after ref-configs)" # ~ 1 min -make + msg "test: compat.sh (ASan build)" # ~ 6 min + if_build_succeeded tests/compat.sh +} -msg "test: compat.sh (ASan build)" # ~ 6 min -if_build_succeeded tests/compat.sh +component_test_ref_configs () { + msg "test/build: ref-configs (ASan build)" # ~ 6 min 20s + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + record_status tests/scripts/test-ref-configs.pl +} -msg "build: Default + SSLv3 (ASan build)" # ~ 6 min -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make +component_test_sslv3 () { + msg "build: Default + SSLv3 (ASan build)" # ~ 6 min + scripts/config.pl set MBEDTLS_SSL_PROTO_SSL3 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s -make test + msg "test: SSLv3 - main suites (inc. selftests) (ASan build)" # ~ 50s + make test -msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min -if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' -if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' + msg "build: SSLv3 - compat.sh (ASan build)" # ~ 6 min + if_build_succeeded tests/compat.sh -m 'tls1 tls1_1 tls1_2 dtls1 dtls1_2' + if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" tests/compat.sh -m 'ssl3' -msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min -if_build_succeeded tests/ssl-opt.sh + msg "build: SSLv3 - ssl-opt.sh (ASan build)" # ~ 6 min + if_build_succeeded tests/ssl-opt.sh +} -msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make +component_test_no_renegotiation () { + msg "build: Default + !MBEDTLS_SSL_RENEGOTIATION (ASan build)" # ~ 6 min + scripts/config.pl unset MBEDTLS_SSL_RENEGOTIATION + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s -make test + msg "test: !MBEDTLS_SSL_RENEGOTIATION - main suites (inc. selftests) (ASan build)" # ~ 50s + make test -msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min -if_build_succeeded tests/ssl-opt.sh + msg "test: !MBEDTLS_SSL_RENEGOTIATION - ssl-opt.sh (ASan build)" # ~ 6 min + if_build_succeeded tests/ssl-opt.sh +} -msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl set MBEDTLS_RSA_NO_CRT -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make +component_test_no_pem_no_fs () { + msg "build: Default + !MBEDTLS_PEM_PARSE_C + !MBEDTLS_FS_IO (ASan build)" + scripts/config.pl unset MBEDTLS_PEM_PARSE_C + scripts/config.pl unset MBEDTLS_FS_IO + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s -make test + msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - main suites (inc. selftests) (ASan build)" # ~ 50s + make test -msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s -if_build_succeeded tests/ssl-opt.sh -f RSA + msg "test: !MBEDTLS_PEM_PARSE_C !MBEDTLS_FS_IO - ssl-opt.sh (ASan build)" # ~ 6 min + if_build_succeeded tests/ssl-opt.sh +} -msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min -if_build_succeeded tests/compat.sh -t RSA +component_test_rsa_no_crt () { + msg "build: Default + RSA_NO_CRT (ASan build)" # ~ 6 min + scripts/config.pl set MBEDTLS_RSA_NO_CRT + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "build: cmake, full config, clang" # ~ 50s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests -CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . -make + msg "test: RSA_NO_CRT - main suites (inc. selftests) (ASan build)" # ~ 50s + make test -msg "test: main suites (full config)" # ~ 5s -make test + msg "test: RSA_NO_CRT - RSA-related part of ssl-opt.sh (ASan build)" # ~ 5s + if_build_succeeded tests/ssl-opt.sh -f RSA -msg "test: ssl-opt.sh default (full config)" # ~ 1s -if_build_succeeded tests/ssl-opt.sh -f Default + msg "test: RSA_NO_CRT - RSA-related part of compat.sh (ASan build)" # ~ 3 min + if_build_succeeded tests/compat.sh -t RSA +} -msg "test: compat.sh RC4, DES & NULL (full config)" # ~ 2 min -if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR' +component_test_small_ssl_out_content_len () { + msg "build: small SSL_OUT_CONTENT_LEN (ASan build)" + scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 + scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl set MBEDTLS_DEPRECATED_WARNING -# Build with -O -Wextra to catch a maximum of issues. -make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs -make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests - -msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s -# No cleanup, just tweak the configuration and rebuild -make clean -scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING -scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED -# Build with -O -Wextra to catch a maximum of issues. -make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs -make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests - -msg "test/build: curves.pl (gcc)" # ~ 4 min -cleanup -record_status tests/scripts/curves.pl + msg "test: small SSL_OUT_CONTENT_LEN - ssl-opt.sh MFL and large packet tests" + if_build_succeeded tests/ssl-opt.sh -f "Max fragment\|Large packet" +} -msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min -cleanup -record_status tests/scripts/depends-hashes.pl +component_test_small_ssl_in_content_len () { + msg "build: small SSL_IN_CONTENT_LEN (ASan build)" + scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 4096 + scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 16384 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min -cleanup -record_status tests/scripts/depends-pkalgs.pl + msg "test: small SSL_IN_CONTENT_LEN - ssl-opt.sh MFL tests" + if_build_succeeded tests/ssl-opt.sh -f "Max fragment" +} -msg "test/build: key-exchanges (gcc)" # ~ 1 min -cleanup -record_status tests/scripts/key-exchanges.pl +component_test_small_ssl_dtls_max_buffering () { + msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0" + scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 1000 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "build: Unix make, -Os (gcc)" # ~ 30s -cleanup -make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' + msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #0 - ssl-opt.sh specific reordering test" + if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" +} -# Full configuration build, without platform support, file IO and net sockets. -# This should catch missing mbedtls_printf definitions, and by disabling file -# IO, it should catch missing '#include ' -msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_PLATFORM_C -scripts/config.pl unset MBEDTLS_NET_C -scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY -scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT -scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT -scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT -scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT -scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT -scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED -scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C -scripts/config.pl unset MBEDTLS_FS_IO -# Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, -# to re-enable platform integration features otherwise disabled in C99 builds -make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs -make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test - -# catch compile bugs in _uninit functions -msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS -scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED -make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' +component_test_small_mbedtls_ssl_dtls_max_buffering () { + msg "build: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1" + scripts/config.pl set MBEDTLS_SSL_DTLS_MAX_BUFFERING 240 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_SSL_SRV_C -make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' + msg "test: small MBEDTLS_SSL_DTLS_MAX_BUFFERING #1 - ssl-opt.sh specific reordering test" + if_build_succeeded tests/ssl-opt.sh -f "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" +} -msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_SSL_CLI_C -make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' - -# Note, C99 compliance can also be tested with the sockets support disabled, -# as that requires a POSIX platform (which isn't the same as C99). -msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. -scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux -make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib +component_test_full_cmake_clang () { + msg "build: cmake, full config, clang" # ~ 50s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests + CC=clang cmake -D CMAKE_BUILD_TYPE:String=Check -D ENABLE_TESTING=On . + make -msg "build: default config except MFL extension (ASan build)" # ~ 30s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make + msg "test: main suites (full config)" # ~ 5s + make test -msg "test: ssl-opt.sh, MFL-related tests" -if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" + msg "test: ssl-opt.sh default, ECJPAKE, SSL async (full config)" # ~ 1s + if_build_succeeded tests/ssl-opt.sh -f 'Default\|ECJPAKE\|SSL async private' -msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY -scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES -scripts/config.pl set MBEDTLS_ENTROPY_C -scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED -scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT -scripts/config.pl unset MBEDTLS_HAVEGE_C -CC=gcc cmake -D UNSAFE_BUILD=ON -D CMAKE_C_FLAGS:String="-fsanitize=address -fno-common -O3" . -make - -msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" -make test - -msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl set MBEDTLS_PLATFORM_MEMORY -scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc -scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make + msg "test: compat.sh RC4, DES, 3DES & NULL (full config)" # ~ 2 min + if_build_succeeded env OPENSSL_CMD="$OPENSSL_LEGACY" GNUTLS_CLI="$GNUTLS_LEGACY_CLI" GNUTLS_SERV="$GNUTLS_LEGACY_SERV" tests/compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR' + + msg "test: compat.sh ARIA + ChachaPoly" + if_build_succeeded env OPENSSL_CMD="$OPENSSL_NEXT" tests/compat.sh -e '^$' -f 'ARIA\|CHACHA' +} + +component_build_deprecated () { + msg "build: make, full config + DEPRECATED_WARNING, gcc -O" # ~ 30s + scripts/config.pl full + scripts/config.pl set MBEDTLS_DEPRECATED_WARNING + # Build with -O -Wextra to catch a maximum of issues. + make CC=gcc CFLAGS='-O -Werror -Wall -Wextra' lib programs + make CC=gcc CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests -msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" -make test + msg "build: make, full config + DEPRECATED_REMOVED, clang -O" # ~ 30s + # No cleanup, just tweak the configuration and rebuild + make clean + scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING + scripts/config.pl set MBEDTLS_DEPRECATED_REMOVED + # Build with -O -Wextra to catch a maximum of issues. + make CC=clang CFLAGS='-O -Werror -Wall -Wextra' lib programs + make CC=clang CFLAGS='-O -Werror -Wall -Wextra -Wno-unused-function' tests +} + + +component_test_depends_curves () { + msg "test/build: curves.pl (gcc)" # ~ 4 min + record_status tests/scripts/curves.pl +} -if uname -a | grep -F Linux >/dev/null; then +component_test_depends_hashes () { + msg "test/build: depends-hashes.pl (gcc)" # ~ 2 min + record_status tests/scripts/depends-hashes.pl +} + +component_test_depends_pkalgs () { + msg "test/build: depends-pkalgs.pl (gcc)" # ~ 2 min + record_status tests/scripts/depends-pkalgs.pl +} + +component_build_key_exchanges () { + msg "test/build: key-exchanges (gcc)" # ~ 1 min + record_status tests/scripts/key-exchanges.pl +} + +component_build_default_make_gcc_and_cxx () { + msg "build: Unix make, -Os (gcc)" # ~ 30s + make CC=gcc CFLAGS='-Werror -Wall -Wextra -Os' + + msg "test: verify header list in cpp_dummy_build.cpp" + record_status check_headers_in_cpp + + msg "build: Unix make, incremental g++" + make TEST_CPP=1 +} + +component_test_check_params_without_platform () { + msg "build+test: MBEDTLS_CHECK_PARAMS without MBEDTLS_PLATFORM_C" + scripts/config.pl full # includes CHECK_PARAMS + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C + scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY + scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl unset MBEDTLS_PLATFORM_C + make CC=gcc CFLAGS='-Werror -O1' all test +} + +component_test_check_params_silent () { + msg "build+test: MBEDTLS_CHECK_PARAMS with alternative MBEDTLS_PARAM_FAILED()" + scripts/config.pl full # includes CHECK_PARAMS + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests + sed -i 's/.*\(#define MBEDTLS_PARAM_FAILED( cond )\).*/\1/' "$CONFIG_H" + make CC=gcc CFLAGS='-Werror -O1' all test +} + +component_test_no_platform () { + # Full configuration build, without platform support, file IO and net sockets. + # This should catch missing mbedtls_printf definitions, and by disabling file + # IO, it should catch missing '#include ' + msg "build: full config except platform/fsio/net, make, gcc, C99" # ~ 30s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_PLATFORM_C + scripts/config.pl unset MBEDTLS_NET_C + scripts/config.pl unset MBEDTLS_PLATFORM_MEMORY + scripts/config.pl unset MBEDTLS_PLATFORM_PRINTF_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_FPRINTF_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_SNPRINTF_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT + scripts/config.pl unset MBEDTLS_PLATFORM_EXIT_ALT + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C + scripts/config.pl unset MBEDTLS_FS_IO + # Note, _DEFAULT_SOURCE needs to be defined for platforms using glibc version >2.19, + # to re-enable platform integration features otherwise disabled in C99 builds + make CC=gcc CFLAGS='-Werror -Wall -Wextra -std=c99 -pedantic -O0 -D_DEFAULT_SOURCE' lib programs + make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' test +} + +component_build_no_std_function () { + # catch compile bugs in _uninit functions + msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s + scripts/config.pl full + scripts/config.pl set MBEDTLS_PLATFORM_NO_STD_FUNCTIONS + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' +} + +component_build_no_ssl_srv () { + msg "build: full config except ssl_srv.c, make, gcc" # ~ 30s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_SSL_SRV_C + make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' +} + +component_build_no_ssl_cli () { + msg "build: full config except ssl_cli.c, make, gcc" # ~ 30s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_SSL_CLI_C + make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0' +} + +component_build_no_sockets () { + # Note, C99 compliance can also be tested with the sockets support disabled, + # as that requires a POSIX platform (which isn't the same as C99). + msg "build: full config except net_sockets.c, make, gcc -std=c99 -pedantic" # ~ 30s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_NET_C # getaddrinfo() undeclared, etc. + scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY # uses syscall() on GNU/Linux + make CC=gcc CFLAGS='-Werror -Wall -Wextra -O0 -std=c99 -pedantic' lib +} + +component_test_no_max_fragment_length () { + # Run max fragment length tests with MFL disabled + msg "build: default config except MFL extension (ASan build)" # ~ 30s + scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + + msg "test: ssl-opt.sh, MFL-related tests" + if_build_succeeded tests/ssl-opt.sh -f "Max fragment length" +} + +component_test_no_max_fragment_length_small_ssl_out_content_len () { + msg "build: no MFL extension, small SSL_OUT_CONTENT_LEN (ASan build)" + scripts/config.pl unset MBEDTLS_SSL_MAX_FRAGMENT_LENGTH + scripts/config.pl set MBEDTLS_SSL_IN_CONTENT_LEN 16384 + scripts/config.pl set MBEDTLS_SSL_OUT_CONTENT_LEN 4096 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + + msg "test: MFL tests (disabled MFL extension case) & large packet tests" + if_build_succeeded tests/ssl-opt.sh -f "Max fragment length\|Large buffer" +} + +component_test_null_entropy () { + msg "build: default config with MBEDTLS_TEST_NULL_ENTROPY (ASan build)" + scripts/config.pl set MBEDTLS_TEST_NULL_ENTROPY + scripts/config.pl set MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES + scripts/config.pl set MBEDTLS_ENTROPY_C + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl unset MBEDTLS_ENTROPY_HARDWARE_ALT + scripts/config.pl unset MBEDTLS_HAVEGE_C + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan -D UNSAFE_BUILD=ON . + make + + msg "test: MBEDTLS_TEST_NULL_ENTROPY - main suites (inc. selftests) (ASan build)" + make test +} + +component_test_platform_calloc_macro () { + msg "build: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" + scripts/config.pl set MBEDTLS_PLATFORM_MEMORY + scripts/config.pl set MBEDTLS_PLATFORM_CALLOC_MACRO calloc + scripts/config.pl set MBEDTLS_PLATFORM_FREE_MACRO free + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make + + msg "test: MBEDTLS_PLATFORM_{CALLOC/FREE}_MACRO enabled (ASan build)" + make test +} + +component_test_aes_fewer_tables () { + msg "build: default config with AES_FEWER_TABLES enabled" + scripts/config.pl set MBEDTLS_AES_FEWER_TABLES + make CC=gcc CFLAGS='-Werror -Wall -Wextra' + + msg "test: AES_FEWER_TABLES" + make test +} + +component_test_aes_rom_tables () { + msg "build: default config with AES_ROM_TABLES enabled" + scripts/config.pl set MBEDTLS_AES_ROM_TABLES + make CC=gcc CFLAGS='-Werror -Wall -Wextra' + + msg "test: AES_ROM_TABLES" + make test +} + +component_test_aes_fewer_tables_and_rom_tables () { + msg "build: default config with AES_ROM_TABLES and AES_FEWER_TABLES enabled" + scripts/config.pl set MBEDTLS_AES_FEWER_TABLES + scripts/config.pl set MBEDTLS_AES_ROM_TABLES + make CC=gcc CFLAGS='-Werror -Wall -Wextra' + + msg "test: AES_FEWER_TABLES + AES_ROM_TABLES" + make test +} + +component_test_make_shared () { msg "build/test: make shared" # ~ 40s - cleanup make SHARED=1 all check -fi +} -if uname -a | grep -F x86_64 >/dev/null; then +component_test_m32_o0 () { # Build once with -O0, to compile out the i386 specific inline assembly msg "build: i386, make, gcc -O0 (ASan build)" # ~ 30s - cleanup - cp "$CONFIG_H" "$CONFIG_BAK" scripts/config.pl full make CC=gcc CFLAGS='-O0 -Werror -Wall -Wextra -m32 -fsanitize=address' msg "test: i386, make, gcc -O0 (ASan build)" make test +} +support_test_m32_o0 () { + case $(uname -m) in + *64*) true;; + *) false;; + esac +} +component_test_m32_o1 () { # Build again with -O1, to compile in the i386 specific inline assembly msg "build: i386, make, gcc -O1 (ASan build)" # ~ 30s - cleanup - cp "$CONFIG_H" "$CONFIG_BAK" scripts/config.pl full + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C + scripts/config.pl unset MBEDTLS_MEMORY_DEBUG make CC=gcc CFLAGS='-O1 -Werror -Wall -Wextra -m32 -fsanitize=address' msg "test: i386, make, gcc -O1 (ASan build)" make test + msg "test ssl-opt.sh, i386, make, gcc-O1" + if_build_succeeded tests/ssl-opt.sh +} +support_test_m32_o1 () { + support_test_m32_o0 "$@" +} + +component_test_mx32 () { msg "build: 64-bit ILP32, make, gcc" # ~ 30s - cleanup - cp "$CONFIG_H" "$CONFIG_BAK" scripts/config.pl full make CC=gcc CFLAGS='-Werror -Wall -Wextra -mx32' msg "test: 64-bit ILP32, make, gcc" make test -fi # x86_64 +} +support_test_mx32 () { + case $(uname -m) in + amd64|x86_64) true;; + *) false;; + esac +} -msg "build: gcc, force 32-bit bignum limbs" -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl unset MBEDTLS_HAVE_ASM -scripts/config.pl unset MBEDTLS_AESNI_C -scripts/config.pl unset MBEDTLS_PADLOCK_C -make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' +component_test_min_mpi_window_size () { + msg "build: Default + MBEDTLS_MPI_WINDOW_SIZE=1 (ASan build)" # ~ 10s + scripts/config.pl set MBEDTLS_MPI_WINDOW_SIZE 1 + CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . + make -msg "test: gcc, force 32-bit bignum limbs" -make test + msg "test: MBEDTLS_MPI_WINDOW_SIZE=1 - main suites (inc. selftests) (ASan build)" # ~ 10s + make test +} -msg "build: gcc, force 64-bit bignum limbs" -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl unset MBEDTLS_HAVE_ASM -scripts/config.pl unset MBEDTLS_AESNI_C -scripts/config.pl unset MBEDTLS_PADLOCK_C -make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' +component_test_have_int32 () { + msg "build: gcc, force 32-bit bignum limbs" + scripts/config.pl unset MBEDTLS_HAVE_ASM + scripts/config.pl unset MBEDTLS_AESNI_C + scripts/config.pl unset MBEDTLS_PADLOCK_C + make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT32' -msg "test: gcc, force 64-bit bignum limbs" -make test + msg "test: gcc, force 32-bit bignum limbs" + make test +} + +component_test_have_int64 () { + msg "build: gcc, force 64-bit bignum limbs" + scripts/config.pl unset MBEDTLS_HAVE_ASM + scripts/config.pl unset MBEDTLS_AESNI_C + scripts/config.pl unset MBEDTLS_PADLOCK_C + make CC=gcc CFLAGS='-Werror -Wall -Wextra -DMBEDTLS_HAVE_INT64' + + msg "test: gcc, force 64-bit bignum limbs" + make test +} + +component_test_no_udbl_division () { + msg "build: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests + scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION + make CFLAGS='-Werror -O1' + + msg "test: MBEDTLS_NO_UDBL_DIVISION native" # ~ 10s + make test +} + +component_test_no_64bit_multiplication () { + msg "build: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # too slow for tests + scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION + make CFLAGS='-Werror -O1' + + msg "test: MBEDTLS_NO_64BIT_MULTIPLICATION native" # ~ 10s + make test +} + +component_build_arm_none_eabi_gcc () { + msg "build: arm-none-eabi-gcc, make" # ~ 10s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_NET_C + scripts/config.pl unset MBEDTLS_TIMING_C + scripts/config.pl unset MBEDTLS_FS_IO + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY + # following things are not in the default config + scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c + scripts/config.pl unset MBEDTLS_THREADING_PTHREAD + scripts/config.pl unset MBEDTLS_THREADING_C + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit + make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib +} + +component_build_arm_none_eabi_gcc_no_udbl_division () { + msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_NET_C + scripts/config.pl unset MBEDTLS_TIMING_C + scripts/config.pl unset MBEDTLS_FS_IO + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY + # following things are not in the default config + scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c + scripts/config.pl unset MBEDTLS_THREADING_PTHREAD + scripts/config.pl unset MBEDTLS_THREADING_C + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit + scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION + make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib + echo "Checking that software 64-bit division is not required" + if_build_succeeded not grep __aeabi_uldiv library/*.o +} + +component_build_arm_none_eabi_gcc_no_64bit_multiplication () { + msg "build: arm-none-eabi-gcc MBEDTLS_NO_64BIT_MULTIPLICATION, make" # ~ 10s + scripts/config.pl full + scripts/config.pl unset MBEDTLS_NET_C + scripts/config.pl unset MBEDTLS_TIMING_C + scripts/config.pl unset MBEDTLS_FS_IO + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY + # following things are not in the default config + scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c + scripts/config.pl unset MBEDTLS_THREADING_PTHREAD + scripts/config.pl unset MBEDTLS_THREADING_C + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit + scripts/config.pl set MBEDTLS_NO_64BIT_MULTIPLICATION + make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -O1 -march=armv6-m -mthumb' lib + echo "Checking that software 64-bit multiplication is not required" + if_build_succeeded not grep __aeabi_lmul library/*.o +} + +component_build_armcc () { + msg "build: ARM Compiler 5, make" + scripts/config.pl full + scripts/config.pl unset MBEDTLS_NET_C + scripts/config.pl unset MBEDTLS_TIMING_C + scripts/config.pl unset MBEDTLS_FS_IO + scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED + scripts/config.pl unset MBEDTLS_HAVE_TIME + scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE + scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY + # following things are not in the default config + scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING + scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c + scripts/config.pl unset MBEDTLS_THREADING_PTHREAD + scripts/config.pl unset MBEDTLS_THREADING_C + scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h + scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit + scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME -msg "build: arm-none-eabi-gcc, make" # ~ 10s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_NET_C -scripts/config.pl unset MBEDTLS_TIMING_C -scripts/config.pl unset MBEDTLS_FS_IO -scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED -scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY -# following things are not in the default config -scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c -scripts/config.pl unset MBEDTLS_THREADING_PTHREAD -scripts/config.pl unset MBEDTLS_THREADING_C -scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h -scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit -make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib - -msg "build: arm-none-eabi-gcc -DMBEDTLS_NO_UDBL_DIVISION, make" # ~ 10s -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_NET_C -scripts/config.pl unset MBEDTLS_TIMING_C -scripts/config.pl unset MBEDTLS_FS_IO -scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED -scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY -# following things are not in the default config -scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c -scripts/config.pl unset MBEDTLS_THREADING_PTHREAD -scripts/config.pl unset MBEDTLS_THREADING_C -scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h -scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit -scripts/config.pl set MBEDTLS_NO_UDBL_DIVISION -make CC=arm-none-eabi-gcc AR=arm-none-eabi-ar LD=arm-none-eabi-ld CFLAGS='-Werror -Wall -Wextra' lib -echo "Checking that software 64-bit division is not required" -! grep __aeabi_uldiv library/*.o - -msg "build: ARM Compiler 5, make" -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl full -scripts/config.pl unset MBEDTLS_NET_C -scripts/config.pl unset MBEDTLS_TIMING_C -scripts/config.pl unset MBEDTLS_FS_IO -scripts/config.pl unset MBEDTLS_ENTROPY_NV_SEED -scripts/config.pl unset MBEDTLS_HAVE_TIME -scripts/config.pl unset MBEDTLS_HAVE_TIME_DATE -scripts/config.pl set MBEDTLS_NO_PLATFORM_ENTROPY -# following things are not in the default config -scripts/config.pl unset MBEDTLS_DEPRECATED_WARNING -scripts/config.pl unset MBEDTLS_HAVEGE_C # depends on timing.c -scripts/config.pl unset MBEDTLS_THREADING_PTHREAD -scripts/config.pl unset MBEDTLS_THREADING_C -scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h -scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit -scripts/config.pl unset MBEDTLS_PLATFORM_TIME_ALT # depends on MBEDTLS_HAVE_TIME - -if [ $RUN_ARMCC -ne 0 ]; then make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS='--strict --c99' lib make clean @@ -798,46 +1154,33 @@ if [ $RUN_ARMCC -ne 0 ]; then # ARM Compiler 6 - Target ARMv8-A - AArch64 armc6_build_test "--target=aarch64-arm-none-eabi -march=armv8.2-a" -fi - -msg "build: allow SHA1 in certificates by default" -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES -make CFLAGS='-Werror -Wall -Wextra' -msg "test: allow SHA1 in certificates by default" -make test -if_build_succeeded tests/ssl-opt.sh -f SHA-1 - -msg "build: Default + MBEDTLS_RSA_NO_CRT (ASan build)" # ~ 6 min -cleanup -cp "$CONFIG_H" "$CONFIG_BAK" -scripts/config.pl set MBEDTLS_RSA_NO_CRT -CC=gcc cmake -D CMAKE_BUILD_TYPE:String=Asan . -make - -msg "test: MBEDTLS_RSA_NO_CRT - main suites (inc. selftests) (ASan build)" -make test +} -msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s -cleanup -make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs +component_test_allow_sha1 () { + msg "build: allow SHA1 in certificates by default" + scripts/config.pl set MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES + make CFLAGS='-Werror -Wall -Wextra' + msg "test: allow SHA1 in certificates by default" + make test + if_build_succeeded tests/ssl-opt.sh -f SHA-1 +} -# note Make tests only builds the tests, but doesn't run them -make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests -make WINDOWS_BUILD=1 clean +component_build_mingw () { + msg "build: Windows cross build - mingw64, make (Link Library)" # ~ 30s + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 lib programs -msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s -make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs -make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests -make WINDOWS_BUILD=1 clean + # note Make tests only builds the tests, but doesn't run them + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror' WINDOWS_BUILD=1 tests + make WINDOWS_BUILD=1 clean -# MemSan currently only available on Linux 64 bits -if uname -a | grep 'Linux.*x86_64' >/dev/null; then + msg "build: Windows cross build - mingw64, make (DLL)" # ~ 30s + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 lib programs + make CC=i686-w64-mingw32-gcc AR=i686-w64-mingw32-ar LD=i686-w64-minggw32-ld CFLAGS='-Werror -Wall -Wextra' WINDOWS_BUILD=1 SHARED=1 tests + make WINDOWS_BUILD=1 clean +} +component_test_memsan () { msg "build: MSan (clang)" # ~ 1 min 20s - cleanup - cp "$CONFIG_H" "$CONFIG_BAK" scripts/config.pl unset MBEDTLS_AESNI_C # memsan doesn't grok asm CC=clang cmake -D CMAKE_BUILD_TYPE:String=MemSan . make @@ -854,21 +1197,18 @@ if uname -a | grep 'Linux.*x86_64' >/dev/null; then msg "test: compat.sh (MSan)" # ~ 6 min 20s if_build_succeeded tests/compat.sh fi +} -else # no MemSan - +component_test_valgrind () { msg "build: Release (clang)" - cleanup CC=clang cmake -D CMAKE_BUILD_TYPE:String=Release . make msg "test: main suites valgrind (Release)" make memcheck - # Optional part(s) - # Currently broken, programs don't seem to receive signals - # under valgrind on OS X - + # Optional parts (slow; currently broken on OS X because programs don't + # seem to receive signals under valgrind on OS X). if [ "$MEMORY" -gt 0 ]; then msg "test: ssl-opt.sh --memcheck (Release)" if_build_succeeded tests/ssl-opt.sh --memcheck @@ -878,41 +1218,126 @@ else # no MemSan msg "test: compat.sh --memcheck (Release)" if_build_succeeded tests/compat.sh --memcheck fi +} -fi # MemSan +component_test_cmake_out_of_source () { + msg "build: cmake 'out-of-source' build" + MBEDTLS_ROOT_DIR="$PWD" + mkdir "$OUT_OF_SOURCE_DIR" + cd "$OUT_OF_SOURCE_DIR" + cmake "$MBEDTLS_ROOT_DIR" + make -msg "build: cmake 'out-of-source' build" -cleanup -MBEDTLS_ROOT_DIR="$PWD" -mkdir "$OUT_OF_SOURCE_DIR" -cd "$OUT_OF_SOURCE_DIR" -cmake "$MBEDTLS_ROOT_DIR" -make - -msg "test: cmake 'out-of-source' build" -make test -# Test an SSL option that requires an auxiliary script in test/scripts/. -# Also ensure that there are no error messages such as -# "No such file or directory", which would indicate that some required -# file is missing (ssl-opt.sh tolerates the absence of some files so -# may exit with status 0 but emit errors). -if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err -if [ -s ssl-opt.err ]; then - cat ssl-opt.err >&2 - record_status [ ! -s ssl-opt.err ] - rm ssl-opt.err -fi -cd "$MBEDTLS_ROOT_DIR" -rm -rf "$OUT_OF_SOURCE_DIR" -unset MBEDTLS_ROOT_DIR + msg "test: cmake 'out-of-source' build" + make test + # Test an SSL option that requires an auxiliary script in test/scripts/. + # Also ensure that there are no error messages such as + # "No such file or directory", which would indicate that some required + # file is missing (ssl-opt.sh tolerates the absence of some files so + # may exit with status 0 but emit errors). + if_build_succeeded ./tests/ssl-opt.sh -f 'Fallback SCSV: beginning of list' 2>ssl-opt.err + if [ -s ssl-opt.err ]; then + cat ssl-opt.err >&2 + record_status [ ! -s ssl-opt.err ] + rm ssl-opt.err + fi + cd "$MBEDTLS_ROOT_DIR" + rm -rf "$OUT_OF_SOURCE_DIR" + unset MBEDTLS_ROOT_DIR +} + +component_test_zeroize () { + # Test that the function mbedtls_platform_zeroize() is not optimized away by + # different combinations of compilers and optimization flags by using an + # auxiliary GDB script. Unfortunately, GDB does not return error values to the + # system in all cases that the script fails, so we must manually search the + # output to check whether the pass string is present and no failure strings + # were printed. + + # Don't try to disable ASLR. We don't care about ASLR here. We do care + # about a spurious message if Gdb tries and fails, so suppress that. + gdb_disable_aslr= + if [ -z "$(gdb -batch -nw -ex 'set disable-randomization off' 2>&1)" ]; then + gdb_disable_aslr='set disable-randomization off' + fi + for optimization_flag in -O2 -O3 -Ofast -Os; do + for compiler in clang gcc; do + msg "test: $compiler $optimization_flag, mbedtls_platform_zeroize()" + make programs CC="$compiler" DEBUG=1 CFLAGS="$optimization_flag" + if_build_succeeded gdb -ex "$gdb_disable_aslr" -x tests/scripts/test_zeroize.gdb -nw -batch -nx 2>&1 | tee test_zeroize.log + if_build_succeeded grep "The buffer was correctly zeroized" test_zeroize.log + if_build_succeeded not grep -i "error" test_zeroize.log + rm -f test_zeroize.log + make clean + done + done + + unset gdb_disable_aslr +} + +support_check_python_files () { + type pylint3 >/dev/null 2>/dev/null +} +component_check_python_files () { + msg "Lint: Python scripts" + record_status tests/scripts/check-python-files.sh +} +component_check_generate_test_code () { + msg "uint test: generate_test_code.py" + record_status ./tests/scripts/test_generate_test_code.py +} ################################################################ #### Termination ################################################################ -msg "Done, cleaning up" +post_report () { + msg "Done, cleaning up" + cleanup + + final_report +} + + + +################################################################ +#### Run all the things +################################################################ + +# Run one component and clean up afterwards. +run_component () { + # Back up the configuration in case the component modifies it. + # The cleanup function will restore it. + cp -p "$CONFIG_H" "$CONFIG_BAK" + current_component="$1" + "$@" + cleanup +} + +# Preliminary setup +pre_check_environment +pre_initialize_variables +pre_parse_command_line "$@" + +pre_check_git +build_status=0 +if [ $KEEP_GOING -eq 1 ]; then + pre_setup_keep_going +else + record_status () { + "$@" + } +fi +pre_print_configuration +pre_check_tools cleanup -final_report +# Run the requested tests. +for component in $RUN_COMPONENTS; do + run_component "component_$component" +done + +# We're done. +post_report diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/basic-build-test.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/basic-build-test.sh index fbe757d9ef..8990dfbea6 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/basic-build-test.sh +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/basic-build-test.sh @@ -91,7 +91,10 @@ OPENSSL_CMD="$OPENSSL_LEGACY" \ OPENSSL_CMD="$OPENSSL_LEGACY" \ GNUTLS_CLI="$GNUTLS_LEGACY_CLI" \ GNUTLS_SERV="$GNUTLS_LEGACY_SERV" \ - sh compat.sh -e '3DES\|DES-CBC3' -f 'NULL\|DES\|RC4\|ARCFOUR' | \ + sh compat.sh -e '^$' -f 'NULL\|DES\|RC4\|ARCFOUR' | \ + tee -a compat-test-$TEST_OUTPUT +OPENSSL_CMD="$OPENSSL_NEXT" \ + sh compat.sh -e '^$' -f 'ARIA\|CHACHA' | \ tee -a compat-test-$TEST_OUTPUT echo diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/check-files.py b/3rdparty/mbedtls/mbedtls/tests/scripts/check-files.py index 7ea321f880..00fd0edfb7 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/check-files.py +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/check-files.py @@ -19,14 +19,23 @@ import sys -class IssueTracker(object): - """Base class for issue tracking. Issues should inherit from this and - overwrite either issue_with_line if they check the file line by line, or - overwrite check_file_for_issue if they check the file as a whole.""" +class FileIssueTracker(object): + """Base class for file-wide issue tracking. + + To implement a checker that processes a file as a whole, inherit from + this class and implement `check_file_for_issue` and define ``heading``. + + ``files_exemptions``: files whose name ends with a string in this set + will not be checked. + + ``heading``: human-readable description of the issue + """ + + files_exemptions = frozenset() + # heading must be defined in derived classes. + # pylint: disable=no-member def __init__(self): - self.heading = "" - self.files_exemptions = [] self.files_with_issues = {} def should_check_file(self, filepath): @@ -35,23 +44,14 @@ def should_check_file(self, filepath): return False return True - def issue_with_line(self, line): - raise NotImplementedError - def check_file_for_issue(self, filepath): - with open(filepath, "rb") as f: - for i, line in enumerate(iter(f.readline, b"")): - self.check_file_line(filepath, line, i + 1) + raise NotImplementedError def record_issue(self, filepath, line_number): if filepath not in self.files_with_issues.keys(): self.files_with_issues[filepath] = [] self.files_with_issues[filepath].append(line_number) - def check_file_line(self, filepath, line, line_number): - if self.issue_with_line(line): - self.record_issue(filepath, line_number) - def output_file_issues(self, logger): if self.files_with_issues.values(): logger.info(self.heading) @@ -64,24 +64,44 @@ def output_file_issues(self, logger): logger.info(filename) logger.info("") +class LineIssueTracker(FileIssueTracker): + """Base class for line-by-line issue tracking. -class PermissionIssueTracker(IssueTracker): + To implement a checker that processes files line by line, inherit from + this class and implement `line_with_issue`. + """ - def __init__(self): - super().__init__() - self.heading = "Incorrect permissions:" + def issue_with_line(self, line, filepath): + raise NotImplementedError + + def check_file_line(self, filepath, line, line_number): + if self.issue_with_line(line, filepath): + self.record_issue(filepath, line_number) + + def check_file_for_issue(self, filepath): + with open(filepath, "rb") as f: + for i, line in enumerate(iter(f.readline, b"")): + self.check_file_line(filepath, line, i + 1) + +class PermissionIssueTracker(FileIssueTracker): + """Track files with bad permissions. + + Files that are not executable scripts must not be executable.""" + + heading = "Incorrect permissions:" def check_file_for_issue(self, filepath): - if not (os.access(filepath, os.X_OK) == - filepath.endswith((".sh", ".pl", ".py"))): + is_executable = os.access(filepath, os.X_OK) + should_be_executable = filepath.endswith((".sh", ".pl", ".py")) + if is_executable != should_be_executable: self.files_with_issues[filepath] = None -class EndOfFileNewlineIssueTracker(IssueTracker): +class EndOfFileNewlineIssueTracker(FileIssueTracker): + """Track files that end with an incomplete line + (no newline character at the end of the last line).""" - def __init__(self): - super().__init__() - self.heading = "Missing newline at end of file:" + heading = "Missing newline at end of file:" def check_file_for_issue(self, filepath): with open(filepath, "rb") as f: @@ -89,11 +109,11 @@ def check_file_for_issue(self, filepath): self.files_with_issues[filepath] = None -class Utf8BomIssueTracker(IssueTracker): +class Utf8BomIssueTracker(FileIssueTracker): + """Track files that start with a UTF-8 BOM. + Files should be ASCII or UTF-8. Valid UTF-8 does not start with a BOM.""" - def __init__(self): - super().__init__() - self.heading = "UTF-8 BOM present:" + heading = "UTF-8 BOM present:" def check_file_for_issue(self, filepath): with open(filepath, "rb") as f: @@ -101,77 +121,76 @@ def check_file_for_issue(self, filepath): self.files_with_issues[filepath] = None -class LineEndingIssueTracker(IssueTracker): +class LineEndingIssueTracker(LineIssueTracker): + """Track files with non-Unix line endings (i.e. files with CR).""" - def __init__(self): - super().__init__() - self.heading = "Non Unix line endings:" + heading = "Non Unix line endings:" - def issue_with_line(self, line): + def issue_with_line(self, line, _filepath): return b"\r" in line -class TrailingWhitespaceIssueTracker(IssueTracker): +class TrailingWhitespaceIssueTracker(LineIssueTracker): + """Track lines with trailing whitespace.""" - def __init__(self): - super().__init__() - self.heading = "Trailing whitespace:" - self.files_exemptions = [".md"] + heading = "Trailing whitespace:" + files_exemptions = frozenset(".md") - def issue_with_line(self, line): + def issue_with_line(self, line, _filepath): return line.rstrip(b"\r\n") != line.rstrip() -class TabIssueTracker(IssueTracker): +class TabIssueTracker(LineIssueTracker): + """Track lines with tabs.""" - def __init__(self): - super().__init__() - self.heading = "Tabs present:" - self.files_exemptions = [ - "Makefile", "generate_visualc_files.pl" - ] + heading = "Tabs present:" + files_exemptions = frozenset([ + "Makefile", + "generate_visualc_files.pl", + ]) - def issue_with_line(self, line): + def issue_with_line(self, line, _filepath): return b"\t" in line -class MergeArtifactIssueTracker(IssueTracker): +class MergeArtifactIssueTracker(LineIssueTracker): + """Track lines with merge artifacts. + These are leftovers from a ``git merge`` that wasn't fully edited.""" - def __init__(self): - super().__init__() - self.heading = "Merge artifact:" + heading = "Merge artifact:" - def issue_with_line(self, filepath, line): + def issue_with_line(self, line, _filepath): # Detect leftover git conflict markers. if line.startswith(b'<<<<<<< ') or line.startswith(b'>>>>>>> '): return True if line.startswith(b'||||||| '): # from merge.conflictStyle=diff3 return True if line.rstrip(b'\r\n') == b'=======' and \ - not filepath.endswith('.md'): + not _filepath.endswith('.md'): return True return False - def check_file_line(self, filepath, line, line_number): - if self.issue_with_line(filepath, line): - self.record_issue(filepath, line_number) - -class TodoIssueTracker(IssueTracker): +class TodoIssueTracker(LineIssueTracker): + """Track lines containing ``TODO``.""" - def __init__(self): - super().__init__() - self.heading = "TODO present:" - self.files_exemptions = [ - __file__, "benchmark.c", "pull_request_template.md" - ] + heading = "TODO present:" + files_exemptions = frozenset([ + os.path.basename(__file__), + "benchmark.c", + "pull_request_template.md", + ]) - def issue_with_line(self, line): + def issue_with_line(self, line, _filepath): return b"todo" in line.lower() class IntegrityChecker(object): + """Sanity-check files under the current directory.""" def __init__(self, log_file): + """Instantiate the sanity checker. + Check files under the current directory. + Write a report of issues to log_file.""" self.check_repo_path() self.logger = None self.setup_logger(log_file) @@ -183,7 +202,6 @@ def __init__(self, log_file): self.excluded_paths = list(map(os.path.normpath, [ 'cov-int', 'examples', - 'yotta/module' ])) self.issues_to_check = [ PermissionIssueTracker(), @@ -196,7 +214,8 @@ def __init__(self, log_file): TodoIssueTracker(), ] - def check_repo_path(self): + @staticmethod + def check_repo_path(): if not all(os.path.isdir(d) for d in ["include", "library", "tests"]): raise Exception("Must be run from Mbed TLS root") diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/check-generated-files.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/check-generated-files.sh index 4976bacf5c..065ea33a2a 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/check-generated-files.sh +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/check-generated-files.sh @@ -65,5 +65,6 @@ check() } check scripts/generate_errors.pl library/error.c +check scripts/generate_query_config.pl programs/ssl/query_config.c check scripts/generate_features.pl library/version_features.c check scripts/generate_visualc_files.pl visualc/VS2010 diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/check-names.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/check-names.sh index 4c66440e25..90ecfd2726 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/check-names.sh +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/check-names.sh @@ -2,26 +2,42 @@ # # This file is part of mbed TLS (https://tls.mbed.org) # -# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved -# -# Purpose -# -# This script confirms that the naming of all symbols and identifiers in mbed -# TLS are consistent with the house style and are also self-consistent. -# +# Copyright (c) 2015-2019, ARM Limited, All Rights Reserved + set -eu +if [ $# -ne 0 ] && [ "$1" = "--help" ]; then + cat </dev/null; then :; else echo "This script requires GNU grep.">&2 exit 1 fi +trace= +if [ $# -ne 0 ] && [ "$1" = "-v" ]; then + shift + trace='-x' + exec 2>check-names.err + trap 'echo "FAILED UNEXPECTEDLY, status=$?"; + cat check-names.err' EXIT + set -x +fi + printf "Analysing source code...\n" -tests/scripts/list-macros.sh +sh $trace tests/scripts/list-macros.sh tests/scripts/list-enum-consts.pl -tests/scripts/list-identifiers.sh -tests/scripts/list-symbols.sh +sh $trace tests/scripts/list-identifiers.sh +sh $trace tests/scripts/list-symbols.sh FAIL=0 @@ -40,7 +56,7 @@ diff macros identifiers | sed -n -e 's/< //p' > actual-macros for THING in actual-macros enum-consts; do printf "Names of $THING: " test -r $THING - BAD=$( grep -v '^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$\|^YOTTA_[0-9A-Z_]*[0-9A-Z]$' $THING || true ) + BAD=$( grep -v '^MBEDTLS_[0-9A-Z_]*[0-9A-Z]$' $THING || true ) if [ "x$BAD" = "x" ]; then echo "PASS" else @@ -82,6 +98,12 @@ else FAIL=1 fi +if [ -n "$trace" ]; then + set +x + trap - EXIT + rm check-names.err +fi + printf "\nOverall: " if [ "$FAIL" -eq 0 ]; then rm macros actual-macros enum-consts identifiers exported-symbols diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/check-python-files.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/check-python-files.sh new file mode 100755 index 0000000000..9290418224 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/check-python-files.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env sh + +# This file is part of Mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2018, Arm Limited, All Rights Reserved +# +# Purpose: +# +# Run 'pylint' on Python files for programming errors and helps enforcing +# PEP8 coding standards. + +pylint3 -j 2 scripts/*.py tests/scripts/*.py diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/generate_code.pl b/3rdparty/mbedtls/mbedtls/tests/scripts/generate_code.pl deleted file mode 100755 index e489a0055e..0000000000 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/generate_code.pl +++ /dev/null @@ -1,411 +0,0 @@ -#!/usr/bin/env perl - -# generate_code.pl -# -# This file is part of mbed TLS (https://tls.mbed.org) -# -# Copyright (c) 2009-2016, ARM Limited, All Rights Reserved -# -# Purpose -# -# Generates the test suite code given inputs of the test suite directory that -# contain the test suites, and the test suite file names for the test code and -# test data. -# -# Usage: generate_code.pl [main code file] -# -# Structure of files -# -# - main code file - 'main_test.function' -# Template file that contains the main() function for the test suite, -# test dispatch code as well as support functions. It contains the -# following symbols which are substituted by this script during -# processing: -# TESTCASE_FILENAME -# TESTCODE_FILENAME -# SUITE_PRE_DEP -# MAPPING_CODE -# FUNCTION CODE -# SUITE_POST_DEP -# DEP_CHECK_CODE -# DISPATCH_FUNCTION -# !LINE_NO! -# -# - common helper code file - 'helpers.function' -# Common helper functions -# -# - test suite code file - file name in the form 'test_suite_xxx.function' -# Code file that contains the actual test cases. The file contains a -# series of code sequences delimited by the following: -# BEGIN_HEADER / END_HEADER - list of headers files -# BEGIN_SUITE_HELPERS / END_SUITE_HELPERS - helper functions common to -# the test suite -# BEGIN_CASE / END_CASE - the test cases in the test suite. Each test -# case contains at least one function that is used to create the -# dispatch code. -# -# - test data file - file name in the form 'test_suite_xxxx.data' -# The test case parameters to to be used in execution of the test. The -# file name is used to replace the symbol 'TESTCASE_FILENAME' in the main -# code file above. -# -# A test data file consists of a sequence of paragraphs separated by -# a single empty line. Line breaks may be in Unix (LF) or Windows (CRLF) -# format. Lines starting with the character '#' are ignored -# (the parser behaves as if they were not present). -# -# Each paragraph describes one test case and must consist of: (1) one -# line which is the test case name; (2) an optional line starting with -# the 11-character prefix "depends_on:"; (3) a line containing the test -# function to execute and its parameters. -# -# A depends_on: line consists of a list of compile-time options -# separated by the character ':', with no whitespace. The test case -# is executed only if this compilation option is enabled in config.h. -# -# The last line of each paragraph contains a test function name and -# a list of parameters separated by the character ':'. Running the -# test case calls this function with the specified parameters. Each -# parameter may either be an integer written in decimal or hexadecimal, -# or a string surrounded by double quotes which may not contain the -# ':' character. -# - -use strict; - -my $suite_dir = shift or die "Missing suite directory"; -my $suite_name = shift or die "Missing suite name"; -my $data_name = shift or die "Missing data name"; -my $test_main_file = do { my $arg = shift; defined($arg) ? $arg : $suite_dir."/main_test.function" }; -my $test_file = $data_name.".c"; -my $test_common_helper_file = $suite_dir."/helpers.function"; -my $test_case_file = $suite_dir."/".$suite_name.".function"; -my $test_case_data = $suite_dir."/".$data_name.".data"; - -my $line_separator = $/; -undef $/; - - -# -# Open and read in the input files -# - -open(TEST_HELPERS, "$test_common_helper_file") or die "Opening test helpers -'$test_common_helper_file': $!"; -my $test_common_helpers = ; -close(TEST_HELPERS); - -open(TEST_MAIN, "$test_main_file") or die "Opening test main '$test_main_file': $!"; -my @test_main_lines = split/^/, ; -my $test_main; -my $index = 2; -for my $line (@test_main_lines) { - $line =~ s/!LINE_NO!/$index/; - $test_main = $test_main.$line; - $index++; -} -close(TEST_MAIN); - -open(TEST_CASES, "$test_case_file") or die "Opening test cases '$test_case_file': $!"; -my @test_cases_lines = split/^/, ; -my $test_cases; -my $index = 2; -for my $line (@test_cases_lines) { - if ($line =~ /^\/\* BEGIN_SUITE_HELPERS .*\*\//) - { - $line = $line."#line $index \"$test_case_file\"\n"; - } - - if ($line =~ /^\/\* BEGIN_CASE .*\*\//) - { - $line = $line."#line $index \"$test_case_file\"\n"; - } - - $line =~ s/!LINE_NO!/$index/; - - $test_cases = $test_cases.$line; - $index++; -} - -close(TEST_CASES); - -open(TEST_DATA, "$test_case_data") or die "Opening test data '$test_case_data': $!"; -my $test_data = ; -close(TEST_DATA); - - -# -# Find the headers, dependencies, and suites in the test cases file -# - -my ( $suite_header ) = $test_cases =~ /\/\* BEGIN_HEADER \*\/\n(.*?)\n\/\* END_HEADER \*\//s; -my ( $suite_defines ) = $test_cases =~ /\/\* BEGIN_DEPENDENCIES\n \* (.*?)\n \* END_DEPENDENCIES/s; -my ( $suite_helpers ) = $test_cases =~ /\/\* BEGIN_SUITE_HELPERS \*\/\n(.*?)\n\/\* END_SUITE_HELPERS \*\//s; - -my $requirements; -if ($suite_defines =~ /^depends_on:/) -{ - ( $requirements ) = $suite_defines =~ /^depends_on:(.*)$/; -} - -my @var_req_arr = split(/:/, $requirements); -my $suite_pre_code; -my $suite_post_code; -my $dispatch_code; -my $mapping_code; -my %mapping_values; - -while (@var_req_arr) -{ - my $req = shift @var_req_arr; - $req =~ s/(!?)(.*)/$1defined($2)/; - - $suite_pre_code .= "#if $req\n"; - $suite_post_code .= "#endif /* $req */\n"; -} - -$/ = $line_separator; - -open(TEST_FILE, ">$test_file") or die "Opening destination file '$test_file': $!"; -print TEST_FILE << "END"; -/* - * *** THIS FILE HAS BEEN MACHINE GENERATED *** - * - * This file has been machine generated using the script: $0 - * - * Test file : $test_file - * - * The following files were used to create this file. - * - * Main code file : $test_main_file - * Helper file : $test_common_helper_file - * Test suite file : $test_case_file - * Test suite data : $test_case_data - * - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#if !defined(MBEDTLS_CONFIG_FILE) -#include -#else -#include MBEDTLS_CONFIG_FILE -#endif - - -/*----------------------------------------------------------------------------*/ -/* Common helper code */ - -$test_common_helpers - - -/*----------------------------------------------------------------------------*/ -/* Test Suite Code */ - -$suite_pre_code -$suite_header -$suite_helpers -$suite_post_code - -END - -$test_main =~ s/SUITE_PRE_DEP/$suite_pre_code/; -$test_main =~ s/SUITE_POST_DEP/$suite_post_code/; - -while($test_cases =~ /\/\* BEGIN_CASE *([\w:]*) \*\/\n(.*?)\n\/\* END_CASE \*\//msg) -{ - my $function_deps = $1; - my $function_decl = $2; - - # Sanity checks of function - if ($function_decl !~ /^#line\s*.*\nvoid /) - { - die "Test function does not have 'void' as return type.\n" . - "Function declaration:\n" . - $function_decl; - } - if ($function_decl !~ /^(#line\s*.*)\nvoid (\w+)\(\s*(.*?)\s*\)\s*{(.*)}/ms) - { - die "Function declaration not in expected format\n"; - } - my $line_directive = $1; - my $function_name = $2; - my $function_params = $3; - my $function_pre_code; - my $function_post_code; - my $param_defs; - my $param_checks; - my @dispatch_params; - my @var_def_arr = split(/,\s*/, $function_params); - my $i = 1; - my $mapping_regex = "".$function_name; - my $mapping_count = 0; - - $function_decl =~ s/(^#line\s*.*)\nvoid /$1\nvoid test_suite_/; - - # Add exit label if not present - if ($function_decl !~ /^exit:$/m) - { - $function_decl =~ s/}\s*$/\nexit:\n return;\n}/; - } - - if ($function_deps =~ /^depends_on:/) - { - ( $function_deps ) = $function_deps =~ /^depends_on:(.*)$/; - } - - foreach my $req (split(/:/, $function_deps)) - { - $function_pre_code .= "#ifdef $req\n"; - $function_post_code .= "#endif /* $req */\n"; - } - - foreach my $def (@var_def_arr) - { - # Handle the different parameter types - if( substr($def, 0, 4) eq "int " ) - { - $param_defs .= " int param$i;\n"; - $param_checks .= " if( verify_int( params[$i], ¶m$i ) != 0 ) return( DISPATCH_INVALID_TEST_DATA );\n"; - push @dispatch_params, "param$i"; - - $mapping_regex .= ":([\\d\\w |\\+\\-\\(\\)]+)"; - $mapping_count++; - } - elsif( substr($def, 0, 6) eq "char *" ) - { - $param_defs .= " char *param$i = params[$i];\n"; - $param_checks .= " if( verify_string( ¶m$i ) != 0 ) return( DISPATCH_INVALID_TEST_DATA );\n"; - push @dispatch_params, "param$i"; - $mapping_regex .= ":(?:\\\\.|[^:\n])+"; - } - else - { - die "Parameter declaration not of supported type (int, char *)\n"; - } - $i++; - - } - - # Find non-integer values we should map for this function - if( $mapping_count) - { - my @res = $test_data =~ /^$mapping_regex/msg; - foreach my $value (@res) - { - next unless ($value !~ /^\d+$/); - if ( $mapping_values{$value} ) { - ${ $mapping_values{$value} }{$function_pre_code} = 1; - } else { - $mapping_values{$value} = { $function_pre_code => 1 }; - } - } - } - - my $call_params = join ", ", @dispatch_params; - my $param_count = @var_def_arr + 1; - $dispatch_code .= << "END"; -if( strcmp( params[0], "$function_name" ) == 0 ) -{ -$function_pre_code -$param_defs - if( cnt != $param_count ) - { - mbedtls_fprintf( stderr, "\\nIncorrect argument count (%d != %d)\\n", cnt, $param_count ); - return( DISPATCH_INVALID_TEST_DATA ); - } - -$param_checks - test_suite_$function_name( $call_params ); - return ( DISPATCH_TEST_SUCCESS ); -$function_post_code - return ( DISPATCH_UNSUPPORTED_SUITE ); -} -else -END - - my $function_code = $function_pre_code . $function_decl . "\n" . - $function_post_code; - $test_main =~ s/FUNCTION_CODE/$function_code\nFUNCTION_CODE/; -} - -# Find specific case dependencies that we should be able to check -# and make check code -my $dep_check_code; - -my @res = $test_data =~ /^depends_on:([!:\w]+)/msg; -my %case_deps; -foreach my $deps (@res) -{ - foreach my $dep (split(/:/, $deps)) - { - $case_deps{$dep} = 1; - } -} -while( my ($key, $value) = each(%case_deps) ) -{ - if( substr($key, 0, 1) eq "!" ) - { - my $key = substr($key, 1); - $dep_check_code .= << "END"; - if( strcmp( str, "!$key" ) == 0 ) - { -#if !defined($key) - return( DEPENDENCY_SUPPORTED ); -#else - return( DEPENDENCY_NOT_SUPPORTED ); -#endif - } -END - } - else - { - $dep_check_code .= << "END"; - if( strcmp( str, "$key" ) == 0 ) - { -#if defined($key) - return( DEPENDENCY_SUPPORTED ); -#else - return( DEPENDENCY_NOT_SUPPORTED ); -#endif - } -END - } -} - -# Make mapping code -while( my ($key, $value) = each(%mapping_values) ) -{ - my $key_mapping_code = << "END"; - if( strcmp( str, "$key" ) == 0 ) - { - *value = ( $key ); - return( KEY_VALUE_MAPPING_FOUND ); - } -END - - # handle depenencies, unless used at least one without depends - if ($value->{""}) { - $mapping_code .= $key_mapping_code; - next; - } - for my $ifdef ( keys %$value ) { - (my $endif = $ifdef) =~ s!ifdef!endif //!g; - $mapping_code .= $ifdef . $key_mapping_code . $endif; - } -} - -$dispatch_code =~ s/^(.+)/ $1/mg; - -$test_main =~ s/TESTCASE_FILENAME/$test_case_data/g; -$test_main =~ s/TESTCODE_FILENAME/$test_case_file/g; -$test_main =~ s/FUNCTION_CODE//; -$test_main =~ s/DEP_CHECK_CODE/$dep_check_code/; -$test_main =~ s/DISPATCH_FUNCTION/$dispatch_code/; -$test_main =~ s/MAPPING_CODE/$mapping_code/; - -print TEST_FILE << "END"; -$test_main -END - -close(TEST_FILE); diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/generate_test_code.py b/3rdparty/mbedtls/mbedtls/tests/scripts/generate_test_code.py new file mode 100755 index 0000000000..1fff09992c --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/generate_test_code.py @@ -0,0 +1,1152 @@ +#!/usr/bin/env python3 +# Test suites code generator. +# +# Copyright (C) 2018, Arm Limited, All Rights Reserved +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This file is part of Mbed TLS (https://tls.mbed.org) + +""" +This script is a key part of Mbed TLS test suites framework. For +understanding the script it is important to understand the +framework. This doc string contains a summary of the framework +and explains the function of this script. + +Mbed TLS test suites: +===================== +Scope: +------ +The test suites focus on unit testing the crypto primitives and also +include x509 parser tests. Tests can be added to test any Mbed TLS +module. However, the framework is not capable of testing SSL +protocol, since that requires full stack execution and that is best +tested as part of the system test. + +Test case definition: +--------------------- +Tests are defined in a test_suite_[.].data +file. A test definition contains: + test name + optional build macro dependencies + test function + test parameters + +Test dependencies are build macros that can be specified to indicate +the build config in which the test is valid. For example if a test +depends on a feature that is only enabled by defining a macro. Then +that macro should be specified as a dependency of the test. + +Test function is the function that implements the test steps. This +function is specified for different tests that perform same steps +with different parameters. + +Test parameters are specified in string form separated by ':'. +Parameters can be of type string, binary data specified as hex +string and integer constants specified as integer, macro or +as an expression. Following is an example test definition: + + AES 128 GCM Encrypt and decrypt 8 bytes + depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C + enc_dec_buf:MBEDTLS_CIPHER_AES_128_GCM:"AES-128-GCM":128:8:-1 + +Test functions: +--------------- +Test functions are coded in C in test_suite_.function files. +Functions file is itself not compilable and contains special +format patterns to specify test suite dependencies, start and end +of functions and function dependencies. Check any existing functions +file for example. + +Execution: +---------- +Tests are executed in 3 steps: +- Generating test_suite_[.].c file + for each corresponding .data file. +- Building each source file into executables. +- Running each executable and printing report. + +Generating C test source requires more than just the test functions. +Following extras are required: +- Process main() +- Reading .data file and dispatching test cases. +- Platform specific test case execution +- Dependency checking +- Integer expression evaluation +- Test function dispatch + +Build dependencies and integer expressions (in the test parameters) +are specified as strings in the .data file. Their run time value is +not known at the generation stage. Hence, they need to be translated +into run time evaluations. This script generates the run time checks +for dependencies and integer expressions. + +Similarly, function names have to be translated into function calls. +This script also generates code for function dispatch. + +The extra code mentioned here is either generated by this script +or it comes from the input files: helpers file, platform file and +the template file. + +Helper file: +------------ +Helpers file contains common helper/utility functions and data. + +Platform file: +-------------- +Platform file contains platform specific setup code and test case +dispatch code. For example, host_test.function reads test data +file from host's file system and dispatches tests. +In case of on-target target_test.function tests are not dispatched +on target. Target code is kept minimum and only test functions are +dispatched. Test case dispatch is done on the host using tools like +Greentea. + +Template file: +--------- +Template file for example main_test.function is a template C file in +which generated code and code from input files is substituted to +generate a compilable C file. It also contains skeleton functions for +dependency checks, expression evaluation and function dispatch. These +functions are populated with checks and return codes by this script. + +Template file contains "replacement" fields that are formatted +strings processed by Python string.Template.substitute() method. + +This script: +============ +Core function of this script is to fill the template file with +code that is generated or read from helpers and platform files. + +This script replaces following fields in the template and generates +the test source file: + +$test_common_helpers <-- All common code from helpers.function + is substituted here. +$functions_code <-- Test functions are substituted here + from the input test_suit_xyz.function + file. C preprocessor checks are generated + for the build dependencies specified + in the input file. This script also + generates wrappers for the test + functions with code to expand the + string parameters read from the data + file. +$expression_code <-- This script enumerates the + expressions in the .data file and + generates code to handle enumerated + expression Ids and return the values. +$dep_check_code <-- This script enumerates all + build dependencies and generate + code to handle enumerated build + dependency Id and return status: if + the dependency is defined or not. +$dispatch_code <-- This script enumerates the functions + specified in the input test data file + and generates the initializer for the + function table in the template + file. +$platform_code <-- Platform specific setup and test + dispatch code. + +""" + + +import io +import os +import re +import sys +import string +import argparse + + +BEGIN_HEADER_REGEX = r'/\*\s*BEGIN_HEADER\s*\*/' +END_HEADER_REGEX = r'/\*\s*END_HEADER\s*\*/' + +BEGIN_SUITE_HELPERS_REGEX = r'/\*\s*BEGIN_SUITE_HELPERS\s*\*/' +END_SUITE_HELPERS_REGEX = r'/\*\s*END_SUITE_HELPERS\s*\*/' + +BEGIN_DEP_REGEX = r'BEGIN_DEPENDENCIES' +END_DEP_REGEX = r'END_DEPENDENCIES' + +BEGIN_CASE_REGEX = r'/\*\s*BEGIN_CASE\s*(?P.*?)\s*\*/' +END_CASE_REGEX = r'/\*\s*END_CASE\s*\*/' + +DEPENDENCY_REGEX = r'depends_on:(?P.*)' +C_IDENTIFIER_REGEX = r'!?[a-z_][a-z0-9_]*' +CONDITION_OPERATOR_REGEX = r'[!=]=|[<>]=?' +# forbid 0ddd which might be accidentally octal or accidentally decimal +CONDITION_VALUE_REGEX = r'[-+]?(0x[0-9a-f]+|0|[1-9][0-9]*)' +CONDITION_REGEX = r'({})(?:\s*({})\s*({}))?$'.format(C_IDENTIFIER_REGEX, + CONDITION_OPERATOR_REGEX, + CONDITION_VALUE_REGEX) +TEST_FUNCTION_VALIDATION_REGEX = r'\s*void\s+(?P\w+)\s*\(' +INT_CHECK_REGEX = r'int\s+.*' +CHAR_CHECK_REGEX = r'char\s*\*\s*.*' +DATA_T_CHECK_REGEX = r'data_t\s*\*\s*.*' +FUNCTION_ARG_LIST_END_REGEX = r'.*\)' +EXIT_LABEL_REGEX = r'^exit:' + + +class GeneratorInputError(Exception): + """ + Exception to indicate error in the input files to this script. + This includes missing patterns, test function names and other + parsing errors. + """ + pass + + +class FileWrapper(io.FileIO, object): + """ + This class extends built-in io.FileIO class with attribute line_no, + that indicates line number for the line that is read. + """ + + def __init__(self, file_name): + """ + Instantiate the base class and initialize the line number to 0. + + :param file_name: File path to open. + """ + super(FileWrapper, self).__init__(file_name, 'r') + self._line_no = 0 + + def next(self): + """ + Python 2 iterator method. This method overrides base class's + next method and extends the next method to count the line + numbers as each line is read. + + It works for both Python 2 and Python 3 by checking iterator + method name in the base iterator object. + + :return: Line read from file. + """ + parent = super(FileWrapper, self) + if hasattr(parent, '__next__'): + line = parent.__next__() # Python 3 + else: + line = parent.next() # Python 2 # pylint: disable=no-member + if line is not None: + self._line_no += 1 + # Convert byte array to string with correct encoding and + # strip any whitespaces added in the decoding process. + return line.decode(sys.getdefaultencoding()).rstrip() + '\n' + return None + + # Python 3 iterator method + __next__ = next + + def get_line_no(self): + """ + Gives current line number. + """ + return self._line_no + + line_no = property(get_line_no) + + +def split_dep(dep): + """ + Split NOT character '!' from dependency. Used by gen_dependencies() + + :param dep: Dependency list + :return: string tuple. Ex: ('!', MACRO) for !MACRO and ('', MACRO) for + MACRO. + """ + return ('!', dep[1:]) if dep[0] == '!' else ('', dep) + + +def gen_dependencies(dependencies): + """ + Test suite data and functions specifies compile time dependencies. + This function generates C preprocessor code from the input + dependency list. Caller uses the generated preprocessor code to + wrap dependent code. + A dependency in the input list can have a leading '!' character + to negate a condition. '!' is separated from the dependency using + function split_dep() and proper preprocessor check is generated + accordingly. + + :param dependencies: List of dependencies. + :return: if defined and endif code with macro annotations for + readability. + """ + dep_start = ''.join(['#if %sdefined(%s)\n' % (x, y) for x, y in + map(split_dep, dependencies)]) + dep_end = ''.join(['#endif /* %s */\n' % + x for x in reversed(dependencies)]) + + return dep_start, dep_end + + +def gen_dependencies_one_line(dependencies): + """ + Similar to gen_dependencies() but generates dependency checks in one line. + Useful for generating code with #else block. + + :param dependencies: List of dependencies. + :return: Preprocessor check code + """ + defines = '#if ' if dependencies else '' + defines += ' && '.join(['%sdefined(%s)' % (x, y) for x, y in map( + split_dep, dependencies)]) + return defines + + +def gen_function_wrapper(name, local_vars, args_dispatch): + """ + Creates test function wrapper code. A wrapper has the code to + unpack parameters from parameters[] array. + + :param name: Test function name + :param local_vars: Local variables declaration code + :param args_dispatch: List of dispatch arguments. + Ex: ['(char *)params[0]', '*((int *)params[1])'] + :return: Test function wrapper. + """ + # Then create the wrapper + wrapper = ''' +void {name}_wrapper( void ** params ) +{{ +{unused_params}{locals} + {name}( {args} ); +}} +'''.format(name=name, + unused_params='' if args_dispatch else ' (void)params;\n', + args=', '.join(args_dispatch), + locals=local_vars) + return wrapper + + +def gen_dispatch(name, dependencies): + """ + Test suite code template main_test.function defines a C function + array to contain test case functions. This function generates an + initializer entry for a function in that array. The entry is + composed of a compile time check for the test function + dependencies. At compile time the test function is assigned when + dependencies are met, else NULL is assigned. + + :param name: Test function name + :param dependencies: List of dependencies + :return: Dispatch code. + """ + if dependencies: + preprocessor_check = gen_dependencies_one_line(dependencies) + dispatch_code = ''' +{preprocessor_check} + {name}_wrapper, +#else + NULL, +#endif +'''.format(preprocessor_check=preprocessor_check, name=name) + else: + dispatch_code = ''' + {name}_wrapper, +'''.format(name=name) + + return dispatch_code + + +def parse_until_pattern(funcs_f, end_regex): + """ + Matches pattern end_regex to the lines read from the file object. + Returns the lines read until end pattern is matched. + + :param funcs_f: file object for .function file + :param end_regex: Pattern to stop parsing + :return: Lines read before the end pattern + """ + headers = '#line %d "%s"\n' % (funcs_f.line_no + 1, funcs_f.name) + for line in funcs_f: + if re.search(end_regex, line): + break + headers += line + else: + raise GeneratorInputError("file: %s - end pattern [%s] not found!" % + (funcs_f.name, end_regex)) + + return headers + + +def validate_dependency(dependency): + """ + Validates a C macro and raises GeneratorInputError on invalid input. + :param dependency: Input macro dependency + :return: input dependency stripped of leading & trailing white spaces. + """ + dependency = dependency.strip() + if not re.match(CONDITION_REGEX, dependency, re.I): + raise GeneratorInputError('Invalid dependency %s' % dependency) + return dependency + + +def parse_dependencies(inp_str): + """ + Parses dependencies out of inp_str, validates them and returns a + list of macros. + + :param inp_str: Input string with macros delimited by ':'. + :return: list of dependencies + """ + dependencies = [dep for dep in map(validate_dependency, + inp_str.split(':'))] + return dependencies + + +def parse_suite_dependencies(funcs_f): + """ + Parses test suite dependencies specified at the top of a + .function file, that starts with pattern BEGIN_DEPENDENCIES + and end with END_DEPENDENCIES. Dependencies are specified + after pattern 'depends_on:' and are delimited by ':'. + + :param funcs_f: file object for .function file + :return: List of test suite dependencies. + """ + dependencies = [] + for line in funcs_f: + match = re.search(DEPENDENCY_REGEX, line.strip()) + if match: + try: + dependencies = parse_dependencies(match.group('dependencies')) + except GeneratorInputError as error: + raise GeneratorInputError( + str(error) + " - %s:%d" % (funcs_f.name, funcs_f.line_no)) + if re.search(END_DEP_REGEX, line): + break + else: + raise GeneratorInputError("file: %s - end dependency pattern [%s]" + " not found!" % (funcs_f.name, + END_DEP_REGEX)) + + return dependencies + + +def parse_function_dependencies(line): + """ + Parses function dependencies, that are in the same line as + comment BEGIN_CASE. Dependencies are specified after pattern + 'depends_on:' and are delimited by ':'. + + :param line: Line from .function file that has dependencies. + :return: List of dependencies. + """ + dependencies = [] + match = re.search(BEGIN_CASE_REGEX, line) + dep_str = match.group('depends_on') + if dep_str: + match = re.search(DEPENDENCY_REGEX, dep_str) + if match: + dependencies += parse_dependencies(match.group('dependencies')) + + return dependencies + + +def parse_function_arguments(line): + """ + Parses test function signature for validation and generates + a dispatch wrapper function that translates input test vectors + read from the data file into test function arguments. + + :param line: Line from .function file that has a function + signature. + :return: argument list, local variables for + wrapper function and argument dispatch code. + """ + args = [] + local_vars = '' + args_dispatch = [] + arg_idx = 0 + # Remove characters before arguments + line = line[line.find('(') + 1:] + # Process arguments, ex: arg1, arg2 ) + # This script assumes that the argument list is terminated by ')' + # i.e. the test functions will not have a function pointer + # argument. + for arg in line[:line.find(')')].split(','): + arg = arg.strip() + if arg == '': + continue + if re.search(INT_CHECK_REGEX, arg.strip()): + args.append('int') + args_dispatch.append('*( (int *) params[%d] )' % arg_idx) + elif re.search(CHAR_CHECK_REGEX, arg.strip()): + args.append('char*') + args_dispatch.append('(char *) params[%d]' % arg_idx) + elif re.search(DATA_T_CHECK_REGEX, arg.strip()): + args.append('hex') + # create a structure + pointer_initializer = '(uint8_t *) params[%d]' % arg_idx + len_initializer = '*( (uint32_t *) params[%d] )' % (arg_idx+1) + local_vars += """ data_t data%d = {%s, %s}; +""" % (arg_idx, pointer_initializer, len_initializer) + + args_dispatch.append('&data%d' % arg_idx) + arg_idx += 1 + else: + raise ValueError("Test function arguments can only be 'int', " + "'char *' or 'data_t'\n%s" % line) + arg_idx += 1 + + return args, local_vars, args_dispatch + + +def generate_function_code(name, code, local_vars, args_dispatch, + dependencies): + """ + Generate function code with preprocessor checks and parameter dispatch + wrapper. + + :param name: Function name + :param code: Function code + :param local_vars: Local variables for function wrapper + :param args_dispatch: Argument dispatch code + :param dependencies: Preprocessor dependencies list + :return: Final function code + """ + # Add exit label if not present + if code.find('exit:') == -1: + split_code = code.rsplit('}', 1) + if len(split_code) == 2: + code = """exit: + ; +}""".join(split_code) + + code += gen_function_wrapper(name, local_vars, args_dispatch) + preprocessor_check_start, preprocessor_check_end = \ + gen_dependencies(dependencies) + return preprocessor_check_start + code + preprocessor_check_end + + +def parse_function_code(funcs_f, dependencies, suite_dependencies): + """ + Parses out a function from function file object and generates + function and dispatch code. + + :param funcs_f: file object of the functions file. + :param dependencies: List of dependencies + :param suite_dependencies: List of test suite dependencies + :return: Function name, arguments, function code and dispatch code. + """ + line_directive = '#line %d "%s"\n' % (funcs_f.line_no + 1, funcs_f.name) + code = '' + has_exit_label = False + for line in funcs_f: + # Check function signature. Function signature may be split + # across multiple lines. Here we try to find the start of + # arguments list, then remove '\n's and apply the regex to + # detect function start. + up_to_arg_list_start = code + line[:line.find('(') + 1] + match = re.match(TEST_FUNCTION_VALIDATION_REGEX, + up_to_arg_list_start.replace('\n', ' '), re.I) + if match: + # check if we have full signature i.e. split in more lines + name = match.group('func_name') + if not re.match(FUNCTION_ARG_LIST_END_REGEX, line): + for lin in funcs_f: + line += lin + if re.search(FUNCTION_ARG_LIST_END_REGEX, line): + break + args, local_vars, args_dispatch = parse_function_arguments( + line) + code += line + break + code += line + else: + raise GeneratorInputError("file: %s - Test functions not found!" % + funcs_f.name) + + # Prefix test function name with 'test_' + code = code.replace(name, 'test_' + name, 1) + name = 'test_' + name + + for line in funcs_f: + if re.search(END_CASE_REGEX, line): + break + if not has_exit_label: + has_exit_label = \ + re.search(EXIT_LABEL_REGEX, line.strip()) is not None + code += line + else: + raise GeneratorInputError("file: %s - end case pattern [%s] not " + "found!" % (funcs_f.name, END_CASE_REGEX)) + + code = line_directive + code + code = generate_function_code(name, code, local_vars, args_dispatch, + dependencies) + dispatch_code = gen_dispatch(name, suite_dependencies + dependencies) + return (name, args, code, dispatch_code) + + +def parse_functions(funcs_f): + """ + Parses a test_suite_xxx.function file and returns information + for generating a C source file for the test suite. + + :param funcs_f: file object of the functions file. + :return: List of test suite dependencies, test function dispatch + code, function code and a dict with function identifiers + and arguments info. + """ + suite_helpers = '' + suite_dependencies = [] + suite_functions = '' + func_info = {} + function_idx = 0 + dispatch_code = '' + for line in funcs_f: + if re.search(BEGIN_HEADER_REGEX, line): + suite_helpers += parse_until_pattern(funcs_f, END_HEADER_REGEX) + elif re.search(BEGIN_SUITE_HELPERS_REGEX, line): + suite_helpers += parse_until_pattern(funcs_f, + END_SUITE_HELPERS_REGEX) + elif re.search(BEGIN_DEP_REGEX, line): + suite_dependencies += parse_suite_dependencies(funcs_f) + elif re.search(BEGIN_CASE_REGEX, line): + try: + dependencies = parse_function_dependencies(line) + except GeneratorInputError as error: + raise GeneratorInputError( + "%s:%d: %s" % (funcs_f.name, funcs_f.line_no, + str(error))) + func_name, args, func_code, func_dispatch =\ + parse_function_code(funcs_f, dependencies, suite_dependencies) + suite_functions += func_code + # Generate dispatch code and enumeration info + if func_name in func_info: + raise GeneratorInputError( + "file: %s - function %s re-declared at line %d" % + (funcs_f.name, func_name, funcs_f.line_no)) + func_info[func_name] = (function_idx, args) + dispatch_code += '/* Function Id: %d */\n' % function_idx + dispatch_code += func_dispatch + function_idx += 1 + + func_code = (suite_helpers + + suite_functions).join(gen_dependencies(suite_dependencies)) + return suite_dependencies, dispatch_code, func_code, func_info + + +def escaped_split(inp_str, split_char): + """ + Split inp_str on character split_char but ignore if escaped. + Since, return value is used to write back to the intermediate + data file, any escape characters in the input are retained in the + output. + + :param inp_str: String to split + :param split_char: Split character + :return: List of splits + """ + if len(split_char) > 1: + raise ValueError('Expected split character. Found string!') + out = re.sub(r'(\\.)|' + split_char, + lambda m: m.group(1) or '\n', inp_str, + len(inp_str)).split('\n') + out = [x for x in out if x] + return out + + +def parse_test_data(data_f): + """ + Parses .data file for each test case name, test function name, + test dependencies and test arguments. This information is + correlated with the test functions file for generating an + intermediate data file replacing the strings for test function + names, dependencies and integer constant expressions with + identifiers. Mainly for optimising space for on-target + execution. + + :param data_f: file object of the data file. + :return: Generator that yields test name, function name, + dependency list and function argument list. + """ + __state_read_name = 0 + __state_read_args = 1 + state = __state_read_name + dependencies = [] + name = '' + for line in data_f: + line = line.strip() + # Skip comments + if line.startswith('#'): + continue + + # Blank line indicates end of test + if not line: + if state == __state_read_args: + raise GeneratorInputError("[%s:%d] Newline before arguments. " + "Test function and arguments " + "missing for %s" % + (data_f.name, data_f.line_no, name)) + continue + + if state == __state_read_name: + # Read test name + name = line + state = __state_read_args + elif state == __state_read_args: + # Check dependencies + match = re.search(DEPENDENCY_REGEX, line) + if match: + try: + dependencies = parse_dependencies( + match.group('dependencies')) + except GeneratorInputError as error: + raise GeneratorInputError( + str(error) + " - %s:%d" % + (data_f.name, data_f.line_no)) + else: + # Read test vectors + parts = escaped_split(line, ':') + test_function = parts[0] + args = parts[1:] + yield name, test_function, dependencies, args + dependencies = [] + state = __state_read_name + if state == __state_read_args: + raise GeneratorInputError("[%s:%d] Newline before arguments. " + "Test function and arguments missing for " + "%s" % (data_f.name, data_f.line_no, name)) + + +def gen_dep_check(dep_id, dep): + """ + Generate code for checking dependency with the associated + identifier. + + :param dep_id: Dependency identifier + :param dep: Dependency macro + :return: Dependency check code + """ + if dep_id < 0: + raise GeneratorInputError("Dependency Id should be a positive " + "integer.") + _not, dep = ('!', dep[1:]) if dep[0] == '!' else ('', dep) + if not dep: + raise GeneratorInputError("Dependency should not be an empty string.") + + dependency = re.match(CONDITION_REGEX, dep, re.I) + if not dependency: + raise GeneratorInputError('Invalid dependency %s' % dep) + + _defined = '' if dependency.group(2) else 'defined' + _cond = dependency.group(2) if dependency.group(2) else '' + _value = dependency.group(3) if dependency.group(3) else '' + + dep_check = ''' + case {id}: + {{ +#if {_not}{_defined}({macro}{_cond}{_value}) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + }} + break;'''.format(_not=_not, _defined=_defined, + macro=dependency.group(1), id=dep_id, + _cond=_cond, _value=_value) + return dep_check + + +def gen_expression_check(exp_id, exp): + """ + Generates code for evaluating an integer expression using + associated expression Id. + + :param exp_id: Expression Identifier + :param exp: Expression/Macro + :return: Expression check code + """ + if exp_id < 0: + raise GeneratorInputError("Expression Id should be a positive " + "integer.") + if not exp: + raise GeneratorInputError("Expression should not be an empty string.") + exp_code = ''' + case {exp_id}: + {{ + *out_value = {expression}; + }} + break;'''.format(exp_id=exp_id, expression=exp) + return exp_code + + +def write_dependencies(out_data_f, test_dependencies, unique_dependencies): + """ + Write dependencies to intermediate test data file, replacing + the string form with identifiers. Also, generates dependency + check code. + + :param out_data_f: Output intermediate data file + :param test_dependencies: Dependencies + :param unique_dependencies: Mutable list to track unique dependencies + that are global to this re-entrant function. + :return: returns dependency check code. + """ + dep_check_code = '' + if test_dependencies: + out_data_f.write('depends_on') + for dep in test_dependencies: + if dep not in unique_dependencies: + unique_dependencies.append(dep) + dep_id = unique_dependencies.index(dep) + dep_check_code += gen_dep_check(dep_id, dep) + else: + dep_id = unique_dependencies.index(dep) + out_data_f.write(':' + str(dep_id)) + out_data_f.write('\n') + return dep_check_code + + +def write_parameters(out_data_f, test_args, func_args, unique_expressions): + """ + Writes test parameters to the intermediate data file, replacing + the string form with identifiers. Also, generates expression + check code. + + :param out_data_f: Output intermediate data file + :param test_args: Test parameters + :param func_args: Function arguments + :param unique_expressions: Mutable list to track unique + expressions that are global to this re-entrant function. + :return: Returns expression check code. + """ + expression_code = '' + for i, _ in enumerate(test_args): + typ = func_args[i] + val = test_args[i] + + # check if val is a non literal int val (i.e. an expression) + if typ == 'int' and not re.match(r'(\d+|0x[0-9a-f]+)$', + val, re.I): + typ = 'exp' + if val not in unique_expressions: + unique_expressions.append(val) + # exp_id can be derived from len(). But for + # readability and consistency with case of existing + # let's use index(). + exp_id = unique_expressions.index(val) + expression_code += gen_expression_check(exp_id, val) + val = exp_id + else: + val = unique_expressions.index(val) + out_data_f.write(':' + typ + ':' + str(val)) + out_data_f.write('\n') + return expression_code + + +def gen_suite_dep_checks(suite_dependencies, dep_check_code, expression_code): + """ + Generates preprocessor checks for test suite dependencies. + + :param suite_dependencies: Test suite dependencies read from the + .function file. + :param dep_check_code: Dependency check code + :param expression_code: Expression check code + :return: Dependency and expression code guarded by test suite + dependencies. + """ + if suite_dependencies: + preprocessor_check = gen_dependencies_one_line(suite_dependencies) + dep_check_code = ''' +{preprocessor_check} +{code} +#endif +'''.format(preprocessor_check=preprocessor_check, code=dep_check_code) + expression_code = ''' +{preprocessor_check} +{code} +#endif +'''.format(preprocessor_check=preprocessor_check, code=expression_code) + return dep_check_code, expression_code + + +def gen_from_test_data(data_f, out_data_f, func_info, suite_dependencies): + """ + This function reads test case name, dependencies and test vectors + from the .data file. This information is correlated with the test + functions file for generating an intermediate data file replacing + the strings for test function names, dependencies and integer + constant expressions with identifiers. Mainly for optimising + space for on-target execution. + It also generates test case dependency check code and expression + evaluation code. + + :param data_f: Data file object + :param out_data_f: Output intermediate data file + :param func_info: Dict keyed by function and with function id + and arguments info + :param suite_dependencies: Test suite dependencies + :return: Returns dependency and expression check code + """ + unique_dependencies = [] + unique_expressions = [] + dep_check_code = '' + expression_code = '' + for test_name, function_name, test_dependencies, test_args in \ + parse_test_data(data_f): + out_data_f.write(test_name + '\n') + + # Write dependencies + dep_check_code += write_dependencies(out_data_f, test_dependencies, + unique_dependencies) + + # Write test function name + test_function_name = 'test_' + function_name + if test_function_name not in func_info: + raise GeneratorInputError("Function %s not found!" % + test_function_name) + func_id, func_args = func_info[test_function_name] + out_data_f.write(str(func_id)) + + # Write parameters + if len(test_args) != len(func_args): + raise GeneratorInputError("Invalid number of arguments in test " + "%s. See function %s signature." % + (test_name, function_name)) + expression_code += write_parameters(out_data_f, test_args, func_args, + unique_expressions) + + # Write a newline as test case separator + out_data_f.write('\n') + + dep_check_code, expression_code = gen_suite_dep_checks( + suite_dependencies, dep_check_code, expression_code) + return dep_check_code, expression_code + + +def add_input_info(funcs_file, data_file, template_file, + c_file, snippets): + """ + Add generator input info in snippets. + + :param funcs_file: Functions file object + :param data_file: Data file object + :param template_file: Template file object + :param c_file: Output C file object + :param snippets: Dictionary to contain code pieces to be + substituted in the template. + :return: + """ + snippets['test_file'] = c_file + snippets['test_main_file'] = template_file + snippets['test_case_file'] = funcs_file + snippets['test_case_data_file'] = data_file + + +def read_code_from_input_files(platform_file, helpers_file, + out_data_file, snippets): + """ + Read code from input files and create substitutions for replacement + strings in the template file. + + :param platform_file: Platform file object + :param helpers_file: Helper functions file object + :param out_data_file: Output intermediate data file object + :param snippets: Dictionary to contain code pieces to be + substituted in the template. + :return: + """ + # Read helpers + with open(helpers_file, 'r') as help_f, open(platform_file, 'r') as \ + platform_f: + snippets['test_common_helper_file'] = helpers_file + snippets['test_common_helpers'] = help_f.read() + snippets['test_platform_file'] = platform_file + snippets['platform_code'] = platform_f.read().replace( + 'DATA_FILE', out_data_file.replace('\\', '\\\\')) # escape '\' + + +def write_test_source_file(template_file, c_file, snippets): + """ + Write output source file with generated source code. + + :param template_file: Template file name + :param c_file: Output source file + :param snippets: Generated and code snippets + :return: + """ + with open(template_file, 'r') as template_f, open(c_file, 'w') as c_f: + for line_no, line in enumerate(template_f.readlines(), 1): + # Update line number. +1 as #line directive sets next line number + snippets['line_no'] = line_no + 1 + code = string.Template(line).substitute(**snippets) + c_f.write(code) + + +def parse_function_file(funcs_file, snippets): + """ + Parse function file and generate function dispatch code. + + :param funcs_file: Functions file name + :param snippets: Dictionary to contain code pieces to be + substituted in the template. + :return: + """ + with FileWrapper(funcs_file) as funcs_f: + suite_dependencies, dispatch_code, func_code, func_info = \ + parse_functions(funcs_f) + snippets['functions_code'] = func_code + snippets['dispatch_code'] = dispatch_code + return suite_dependencies, func_info + + +def generate_intermediate_data_file(data_file, out_data_file, + suite_dependencies, func_info, snippets): + """ + Generates intermediate data file from input data file and + information read from functions file. + + :param data_file: Data file name + :param out_data_file: Output/Intermediate data file + :param suite_dependencies: List of suite dependencies. + :param func_info: Function info parsed from functions file. + :param snippets: Dictionary to contain code pieces to be + substituted in the template. + :return: + """ + with FileWrapper(data_file) as data_f, \ + open(out_data_file, 'w') as out_data_f: + dep_check_code, expression_code = gen_from_test_data( + data_f, out_data_f, func_info, suite_dependencies) + snippets['dep_check_code'] = dep_check_code + snippets['expression_code'] = expression_code + + +def generate_code(**input_info): + """ + Generates C source code from test suite file, data file, common + helpers file and platform file. + + input_info expands to following parameters: + funcs_file: Functions file object + data_file: Data file object + template_file: Template file object + platform_file: Platform file object + helpers_file: Helper functions file object + suites_dir: Test suites dir + c_file: Output C file object + out_data_file: Output intermediate data file object + :return: + """ + funcs_file = input_info['funcs_file'] + data_file = input_info['data_file'] + template_file = input_info['template_file'] + platform_file = input_info['platform_file'] + helpers_file = input_info['helpers_file'] + suites_dir = input_info['suites_dir'] + c_file = input_info['c_file'] + out_data_file = input_info['out_data_file'] + for name, path in [('Functions file', funcs_file), + ('Data file', data_file), + ('Template file', template_file), + ('Platform file', platform_file), + ('Helpers code file', helpers_file), + ('Suites dir', suites_dir)]: + if not os.path.exists(path): + raise IOError("ERROR: %s [%s] not found!" % (name, path)) + + snippets = {'generator_script': os.path.basename(__file__)} + read_code_from_input_files(platform_file, helpers_file, + out_data_file, snippets) + add_input_info(funcs_file, data_file, template_file, + c_file, snippets) + suite_dependencies, func_info = parse_function_file(funcs_file, snippets) + generate_intermediate_data_file(data_file, out_data_file, + suite_dependencies, func_info, snippets) + write_test_source_file(template_file, c_file, snippets) + + +def main(): + """ + Command line parser. + + :return: + """ + parser = argparse.ArgumentParser( + description='Dynamically generate test suite code.') + + parser.add_argument("-f", "--functions-file", + dest="funcs_file", + help="Functions file", + metavar="FUNCTIONS_FILE", + required=True) + + parser.add_argument("-d", "--data-file", + dest="data_file", + help="Data file", + metavar="DATA_FILE", + required=True) + + parser.add_argument("-t", "--template-file", + dest="template_file", + help="Template file", + metavar="TEMPLATE_FILE", + required=True) + + parser.add_argument("-s", "--suites-dir", + dest="suites_dir", + help="Suites dir", + metavar="SUITES_DIR", + required=True) + + parser.add_argument("--helpers-file", + dest="helpers_file", + help="Helpers file", + metavar="HELPERS_FILE", + required=True) + + parser.add_argument("-p", "--platform-file", + dest="platform_file", + help="Platform code file", + metavar="PLATFORM_FILE", + required=True) + + parser.add_argument("-o", "--out-dir", + dest="out_dir", + help="Dir where generated code and scripts are copied", + metavar="OUT_DIR", + required=True) + + args = parser.parse_args() + + data_file_name = os.path.basename(args.data_file) + data_name = os.path.splitext(data_file_name)[0] + + out_c_file = os.path.join(args.out_dir, data_name + '.c') + out_data_file = os.path.join(args.out_dir, data_name + '.datax') + + out_c_file_dir = os.path.dirname(out_c_file) + out_data_file_dir = os.path.dirname(out_data_file) + for directory in [out_c_file_dir, out_data_file_dir]: + if not os.path.exists(directory): + os.makedirs(directory) + + generate_code(funcs_file=args.funcs_file, data_file=args.data_file, + template_file=args.template_file, + platform_file=args.platform_file, + helpers_file=args.helpers_file, suites_dir=args.suites_dir, + c_file=out_c_file, out_data_file=out_data_file) + + +if __name__ == "__main__": + try: + main() + except GeneratorInputError as err: + sys.exit("%s: input error: %s" % + (os.path.basename(sys.argv[0]), str(err))) diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/list-identifiers.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/list-identifiers.sh index 130d9d63f6..cc9c54fad6 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/list-identifiers.sh +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/list-identifiers.sh @@ -1,4 +1,10 @@ -#!/bin/sh +#!/bin/bash +# +# Create a file named identifiers containing identifiers from internal header +# files or all header files, based on --internal flag. +# Outputs the line count of the file to stdout. +# +# Usage: list-identifiers.sh [ -i | --internal ] set -eu @@ -7,7 +13,29 @@ if [ -d include/mbedtls ]; then :; else exit 1 fi -HEADERS=$( ls include/mbedtls/*.h | egrep -v 'compat-1\.3\.h|bn_mul' ) +INTERNAL="" + +until [ -z "${1-}" ] +do + case "$1" in + -i|--internal) + INTERNAL="1" + ;; + *) + # print error + echo "Unknown argument: '$1'" + exit 1 + ;; + esac + shift +done + +if [ $INTERNAL ] +then + HEADERS=$( ls include/mbedtls/*_internal.h | egrep -v 'compat-1\.3\.h|bn_mul' ) +else + HEADERS=$( ls include/mbedtls/*.h | egrep -v 'compat-1\.3\.h|bn_mul' ) +fi rm -f identifiers diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/list-symbols.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/list-symbols.sh index c258719429..930722c1bb 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/list-symbols.sh +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/list-symbols.sh @@ -14,8 +14,21 @@ fi cp include/mbedtls/config.h include/mbedtls/config.h.bak scripts/config.pl full -CFLAGS=-fno-asynchronous-unwind-tables make clean lib >/dev/null 2>&1 +make clean +make_ret= +CFLAGS=-fno-asynchronous-unwind-tables make lib \ + >list-symbols.make.log 2>&1 || + { + make_ret=$? + echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make lib" + cat list-symbols.make.log >&2 + } +rm list-symbols.make.log mv include/mbedtls/config.h.bak include/mbedtls/config.h +if [ -n "$make_ret" ]; then + exit "$make_ret" +fi + if uname | grep -F Darwin >/dev/null; then nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p' elif uname | grep -F Linux >/dev/null; then diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/mbedtls_test.py b/3rdparty/mbedtls/mbedtls/tests/scripts/mbedtls_test.py new file mode 100755 index 0000000000..ac2912d4c9 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/mbedtls_test.py @@ -0,0 +1,379 @@ +# Greentea host test script for Mbed TLS on-target test suite testing. +# +# Copyright (C) 2018, Arm Limited, All Rights Reserved +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This file is part of Mbed TLS (https://tls.mbed.org) + + +""" +Mbed TLS on-target test suite tests are implemented as Greentea +tests. Greentea tests are implemented in two parts: target test and +host test. Target test is a C application that is built for the +target platform and executes on the target. Host test is a Python +class derived from mbed_host_tests.BaseHostTest. Target communicates +with the host over serial for the test data and sends back the result. + +Python tool mbedgt (Greentea) is responsible for flashing the test +binary on to the target and dynamically loading this host test module. + +Greentea documentation can be found here: +https://github.com/ARMmbed/greentea +""" + + +import re +import os +import binascii + +from mbed_host_tests import BaseHostTest, event_callback # pylint: disable=import-error + + +class TestDataParserError(Exception): + """Indicates error in test data, read from .data file.""" + pass + + +class TestDataParser(object): + """ + Parses test name, dependencies, test function name and test parameters + from the data file. + """ + + def __init__(self): + """ + Constructor + """ + self.tests = [] + + def parse(self, data_file): + """ + Data file parser. + + :param data_file: Data file path + """ + with open(data_file, 'r') as data_f: + self.__parse(data_f) + + @staticmethod + def __escaped_split(inp_str, split_char): + """ + Splits inp_str on split_char except when escaped. + + :param inp_str: String to split + :param split_char: Split character + :return: List of splits + """ + split_colon_fn = lambda x: re.sub(r'\\' + split_char, split_char, x) + if len(split_char) > 1: + raise ValueError('Expected split character. Found string!') + out = map(split_colon_fn, re.split(r'(?> x) & 0xff) for x in [24, 16, 8, 0]]) + return data_bytes + + def test_vector_to_bytes(self, function_id, dependencies, parameters): + """ + Converts test vector into a byte array that can be sent to the target. + + :param function_id: Test Function Identifier + :param dependencies: Dependency list + :param parameters: Test function input parameters + :return: Byte array and its length + """ + data_bytes = bytearray([len(dependencies)]) + if dependencies: + data_bytes += bytearray(dependencies) + data_bytes += bytearray([function_id, len(parameters)]) + for typ, param in parameters: + if typ == 'int' or typ == 'exp': + i = int(param) + data_bytes += 'I' if typ == 'int' else 'E' + self.align_32bit(data_bytes) + data_bytes += self.int32_to_big_endian_bytes(i) + elif typ == 'char*': + param = param.strip('"') + i = len(param) + 1 # + 1 for null termination + data_bytes += 'S' + self.align_32bit(data_bytes) + data_bytes += self.int32_to_big_endian_bytes(i) + data_bytes += bytearray(list(param)) + data_bytes += '\0' # Null terminate + elif typ == 'hex': + binary_data = self.hex_str_bytes(param) + data_bytes += 'H' + self.align_32bit(data_bytes) + i = len(binary_data) + data_bytes += self.int32_to_big_endian_bytes(i) + data_bytes += binary_data + length = self.int32_to_big_endian_bytes(len(data_bytes)) + return data_bytes, length + + def run_next_test(self): + """ + Fetch next test information and execute the test. + + """ + self.test_index += 1 + self.dep_index = 0 + if self.test_index < len(self.tests): + name, function_id, dependencies, args = self.tests[self.test_index] + self.run_test(name, function_id, dependencies, args) + else: + self.notify_complete(self.suite_passed) + + def run_test(self, name, function_id, dependencies, args): + """ + Execute the test on target by sending next test information. + + :param name: Test name + :param function_id: function identifier + :param dependencies: Dependencies list + :param args: test parameters + :return: + """ + self.log("Running: %s" % name) + + param_bytes, length = self.test_vector_to_bytes(function_id, + dependencies, args) + self.send_kv(length, param_bytes) + + @staticmethod + def get_result(value): + """ + Converts result from string type to integer + :param value: Result code in string + :return: Integer result code. Value is from the test status + constants defined under the MbedTlsTest class. + """ + try: + return int(value) + except ValueError: + ValueError("Result should return error number. " + "Instead received %s" % value) + + @event_callback('GO') + def on_go(self, _key, _value, _timestamp): + """ + Sent by the target to start first test. + + :param _key: Event key + :param _value: Value. ignored + :param _timestamp: Timestamp ignored. + :return: + """ + self.run_next_test() + + @event_callback("R") + def on_result(self, _key, value, _timestamp): + """ + Handle result. Prints test start, finish required by Greentea + to detect test execution. + + :param _key: Event key + :param value: Value. ignored + :param _timestamp: Timestamp ignored. + :return: + """ + int_val = self.get_result(value) + name, _, _, _ = self.tests[self.test_index] + self.log('{{__testcase_start;%s}}' % name) + self.log('{{__testcase_finish;%s;%d;%d}}' % (name, int_val == 0, + int_val != 0)) + if int_val != 0: + self.suite_passed = False + self.run_next_test() + + @event_callback("F") + def on_failure(self, _key, value, _timestamp): + """ + Handles test execution failure. That means dependency not supported or + Test function not supported. Hence marking test as skipped. + + :param _key: Event key + :param value: Value. ignored + :param _timestamp: Timestamp ignored. + :return: + """ + int_val = self.get_result(value) + if int_val in self.error_str: + err = self.error_str[int_val] + else: + err = 'Unknown error' + # For skip status, do not write {{__testcase_finish;...}} + self.log("Error: %s" % err) + self.run_next_test() diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/run-test-suites.pl b/3rdparty/mbedtls/mbedtls/tests/scripts/run-test-suites.pl index d0d4046215..1c9dc1dfcb 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/run-test-suites.pl +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/run-test-suites.pl @@ -4,19 +4,24 @@ # # This file is part of mbed TLS (https://tls.mbed.org) # -# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved -# -# Purpose -# -# Executes all the available test suites, and provides a basic summary of the -# results. -# -# Usage: run-test-suites.pl [-v] -# -# Options : -# -v|--verbose - Provide a pass/fail/skip breakdown per test suite and -# in total -# +# Copyright (c) 2015-2018, ARM Limited, All Rights Reserved + +=head1 SYNOPSIS + +Execute all the test suites and print a summary of the results. + + run-test-suites.pl [[-v|--verbose] [VERBOSITY]] [--skip=SUITE[...]] + +Options: + + -v|--verbose Print detailed failure information. + -v 2|--verbose=2 Print detailed failure information and summary messages. + -v 3|--verbose=3 Print detailed information about every test case. + --skip=SUITE[,SUITE...] + Skip the specified SUITE(s). This option can be used + multiple times. + +=cut use warnings; use strict; @@ -24,10 +29,15 @@ use utf8; use open qw(:std utf8); -use Getopt::Long; +use Getopt::Long qw(:config auto_help gnu_compat); +use Pod::Usage; my $verbose = 0; -GetOptions( "verbose|v:1" => \$verbose ); +my @skip_patterns = (); +GetOptions( + 'skip=s' => \@skip_patterns, + 'verbose|v:1' => \$verbose, + ) or die; # All test suites = executable files, excluding source files, debug # and profiling information, etc. We can't just grep {! /\./} because @@ -36,6 +46,17 @@ @suites = grep { !/\.c$/ && !/\.data$/ && -f } @suites; die "$0: no test suite found\n" unless @suites; +# "foo" as a skip pattern skips "test_suite_foo" and "test_suite_foo.bar" +# but not "test_suite_foobar". +my $skip_re = + ( '\Atest_suite_(' . + join('|', map { + s/[ ,;]/|/g; # allow any of " ,;|" as separators + s/\./\./g; # "." in the input means ".", not "any character" + $_ + } @skip_patterns) . + ')(\z|\.)' ); + # in case test suites are linked dynamically $ENV{'LD_LIBRARY_PATH'} = '../library'; $ENV{'DYLD_LIBRARY_PATH'} = '../library'; @@ -45,6 +66,7 @@ my ($failed_suites, $total_tests_run, $failed, $suite_cases_passed, $suite_cases_failed, $suite_cases_skipped, $total_cases_passed, $total_cases_failed, $total_cases_skipped ); +my $suites_skipped = 0; sub pad_print_center { my( $width, $padchar, $string ) = @_; @@ -55,6 +77,12 @@ sub pad_print_center { for my $suite (@suites) { print "$suite ", "." x ( 72 - length($suite) - 2 - 4 ), " "; + if( $suite =~ /$skip_re/o ) { + print "SKIP\n"; + ++$suites_skipped; + next; + } + my $command = "$prefix$suite"; if( $verbose ) { $command .= ' -v'; @@ -101,7 +129,10 @@ sub pad_print_center { print "-" x 72, "\n"; print $failed_suites ? "FAILED" : "PASSED"; -printf " (%d suites, %d tests run)\n", scalar @suites, $total_tests_run; +printf( " (%d suites, %d tests run%s)\n", + scalar(@suites) - $suites_skipped, + $total_tests_run, + $suites_skipped ? ", $suites_skipped suites skipped" : "" ); if( $verbose > 1 ) { print " test cases passed :", $total_cases_passed, "\n"; @@ -111,8 +142,11 @@ sub pad_print_center { "\n"; print " of available tests :", ( $total_cases_passed + $total_cases_failed + $total_cases_skipped ), - "\n" + "\n"; + if( $suites_skipped != 0 ) { + print "Note: $suites_skipped suites were skipped.\n"; } +} exit( $failed_suites ? 1 : 0 ); diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/test-ref-configs.pl b/3rdparty/mbedtls/mbedtls/tests/scripts/test-ref-configs.pl index e1d2184ce1..80d5f38751 100755 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/test-ref-configs.pl +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/test-ref-configs.pl @@ -23,8 +23,6 @@ 'config-suite-b.h' => { 'compat' => "-m tls1_2 -f 'ECDHE-ECDSA.*AES.*GCM' -p mbedTLS", }, - 'config-picocoin.h' => { - }, 'config-ccm-psk-tls1_2.h' => { 'compat' => '-m tls1_2 -f \'^TLS-PSK-WITH-AES-...-CCM-8\'', }, diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/test_generate_test_code.py b/3rdparty/mbedtls/mbedtls/tests/scripts/test_generate_test_code.py new file mode 100755 index 0000000000..6d7113e18b --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/test_generate_test_code.py @@ -0,0 +1,1755 @@ +#!/usr/bin/env python3 +# Unit test for generate_test_code.py +# +# Copyright (C) 2018, Arm Limited, All Rights Reserved +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# This file is part of Mbed TLS (https://tls.mbed.org) + +""" +Unit tests for generate_test_code.py +""" + +# pylint: disable=wrong-import-order +try: + # Python 2 + from StringIO import StringIO +except ImportError: + # Python 3 + from io import StringIO +from unittest import TestCase, main as unittest_main +try: + # Python 2 + from mock import patch +except ImportError: + # Python 3 + from unittest.mock import patch +# pylint: enable=wrong-import-order +from generate_test_code import gen_dependencies, gen_dependencies_one_line +from generate_test_code import gen_function_wrapper, gen_dispatch +from generate_test_code import parse_until_pattern, GeneratorInputError +from generate_test_code import parse_suite_dependencies +from generate_test_code import parse_function_dependencies +from generate_test_code import parse_function_arguments, parse_function_code +from generate_test_code import parse_functions, END_HEADER_REGEX +from generate_test_code import END_SUITE_HELPERS_REGEX, escaped_split +from generate_test_code import parse_test_data, gen_dep_check +from generate_test_code import gen_expression_check, write_dependencies +from generate_test_code import write_parameters, gen_suite_dep_checks +from generate_test_code import gen_from_test_data + + +class GenDep(TestCase): + """ + Test suite for function gen_dep() + """ + + def test_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = ['DEP1', 'DEP2'] + dep_start, dep_end = gen_dependencies(dependencies) + preprocessor1, preprocessor2 = dep_start.splitlines() + endif1, endif2 = dep_end.splitlines() + self.assertEqual(preprocessor1, '#if defined(DEP1)', + 'Preprocessor generated incorrectly') + self.assertEqual(preprocessor2, '#if defined(DEP2)', + 'Preprocessor generated incorrectly') + self.assertEqual(endif1, '#endif /* DEP2 */', + 'Preprocessor generated incorrectly') + self.assertEqual(endif2, '#endif /* DEP1 */', + 'Preprocessor generated incorrectly') + + def test_disabled_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = ['!DEP1', '!DEP2'] + dep_start, dep_end = gen_dependencies(dependencies) + preprocessor1, preprocessor2 = dep_start.splitlines() + endif1, endif2 = dep_end.splitlines() + self.assertEqual(preprocessor1, '#if !defined(DEP1)', + 'Preprocessor generated incorrectly') + self.assertEqual(preprocessor2, '#if !defined(DEP2)', + 'Preprocessor generated incorrectly') + self.assertEqual(endif1, '#endif /* !DEP2 */', + 'Preprocessor generated incorrectly') + self.assertEqual(endif2, '#endif /* !DEP1 */', + 'Preprocessor generated incorrectly') + + def test_mixed_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = ['!DEP1', 'DEP2'] + dep_start, dep_end = gen_dependencies(dependencies) + preprocessor1, preprocessor2 = dep_start.splitlines() + endif1, endif2 = dep_end.splitlines() + self.assertEqual(preprocessor1, '#if !defined(DEP1)', + 'Preprocessor generated incorrectly') + self.assertEqual(preprocessor2, '#if defined(DEP2)', + 'Preprocessor generated incorrectly') + self.assertEqual(endif1, '#endif /* DEP2 */', + 'Preprocessor generated incorrectly') + self.assertEqual(endif2, '#endif /* !DEP1 */', + 'Preprocessor generated incorrectly') + + def test_empty_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = [] + dep_start, dep_end = gen_dependencies(dependencies) + self.assertEqual(dep_start, '', 'Preprocessor generated incorrectly') + self.assertEqual(dep_end, '', 'Preprocessor generated incorrectly') + + def test_large_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = [] + count = 10 + for i in range(count): + dependencies.append('DEP%d' % i) + dep_start, dep_end = gen_dependencies(dependencies) + self.assertEqual(len(dep_start.splitlines()), count, + 'Preprocessor generated incorrectly') + self.assertEqual(len(dep_end.splitlines()), count, + 'Preprocessor generated incorrectly') + + +class GenDepOneLine(TestCase): + """ + Test Suite for testing gen_dependencies_one_line() + """ + + def test_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = ['DEP1', 'DEP2'] + dep_str = gen_dependencies_one_line(dependencies) + self.assertEqual(dep_str, '#if defined(DEP1) && defined(DEP2)', + 'Preprocessor generated incorrectly') + + def test_disabled_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = ['!DEP1', '!DEP2'] + dep_str = gen_dependencies_one_line(dependencies) + self.assertEqual(dep_str, '#if !defined(DEP1) && !defined(DEP2)', + 'Preprocessor generated incorrectly') + + def test_mixed_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = ['!DEP1', 'DEP2'] + dep_str = gen_dependencies_one_line(dependencies) + self.assertEqual(dep_str, '#if !defined(DEP1) && defined(DEP2)', + 'Preprocessor generated incorrectly') + + def test_empty_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = [] + dep_str = gen_dependencies_one_line(dependencies) + self.assertEqual(dep_str, '', 'Preprocessor generated incorrectly') + + def test_large_dependencies_list(self): + """ + Test that gen_dep() correctly creates dependencies for given + dependency list. + :return: + """ + dependencies = [] + count = 10 + for i in range(count): + dependencies.append('DEP%d' % i) + dep_str = gen_dependencies_one_line(dependencies) + expected = '#if ' + ' && '.join(['defined(%s)' % + x for x in dependencies]) + self.assertEqual(dep_str, expected, + 'Preprocessor generated incorrectly') + + +class GenFunctionWrapper(TestCase): + """ + Test Suite for testing gen_function_wrapper() + """ + + def test_params_unpack(self): + """ + Test that params are properly unpacked in the function call. + + :return: + """ + code = gen_function_wrapper('test_a', '', ('a', 'b', 'c', 'd')) + expected = ''' +void test_a_wrapper( void ** params ) +{ + + test_a( a, b, c, d ); +} +''' + self.assertEqual(code, expected) + + def test_local(self): + """ + Test that params are properly unpacked in the function call. + + :return: + """ + code = gen_function_wrapper('test_a', + 'int x = 1;', ('x', 'b', 'c', 'd')) + expected = ''' +void test_a_wrapper( void ** params ) +{ +int x = 1; + test_a( x, b, c, d ); +} +''' + self.assertEqual(code, expected) + + def test_empty_params(self): + """ + Test that params are properly unpacked in the function call. + + :return: + """ + code = gen_function_wrapper('test_a', '', ()) + expected = ''' +void test_a_wrapper( void ** params ) +{ + (void)params; + + test_a( ); +} +''' + self.assertEqual(code, expected) + + +class GenDispatch(TestCase): + """ + Test suite for testing gen_dispatch() + """ + + def test_dispatch(self): + """ + Test that dispatch table entry is generated correctly. + :return: + """ + code = gen_dispatch('test_a', ['DEP1', 'DEP2']) + expected = ''' +#if defined(DEP1) && defined(DEP2) + test_a_wrapper, +#else + NULL, +#endif +''' + self.assertEqual(code, expected) + + def test_empty_dependencies(self): + """ + Test empty dependency list. + :return: + """ + code = gen_dispatch('test_a', []) + expected = ''' + test_a_wrapper, +''' + self.assertEqual(code, expected) + + +class StringIOWrapper(StringIO, object): + """ + file like class to mock file object in tests. + """ + def __init__(self, file_name, data, line_no=0): + """ + Init file handle. + + :param file_name: + :param data: + :param line_no: + """ + super(StringIOWrapper, self).__init__(data) + self.line_no = line_no + self.name = file_name + + def next(self): + """ + Iterator method. This method overrides base class's + next method and extends the next method to count the line + numbers as each line is read. + + :return: Line read from file. + """ + parent = super(StringIOWrapper, self) + if getattr(parent, 'next', None): + # Python 2 + line = parent.next() + else: + # Python 3 + line = parent.__next__() + return line + + # Python 3 + __next__ = next + + def readline(self, length=0): + """ + Wrap the base class readline. + + :param length: + :return: + """ + # pylint: disable=unused-argument + line = super(StringIOWrapper, self).readline() + if line is not None: + self.line_no += 1 + return line + + +class ParseUntilPattern(TestCase): + """ + Test Suite for testing parse_until_pattern(). + """ + + def test_suite_headers(self): + """ + Test that suite headers are parsed correctly. + + :return: + """ + data = '''#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +/* END_HEADER */ +''' + expected = '''#line 1 "test_suite_ut.function" +#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +''' + stream = StringIOWrapper('test_suite_ut.function', data, line_no=0) + headers = parse_until_pattern(stream, END_HEADER_REGEX) + self.assertEqual(headers, expected) + + def test_line_no(self): + """ + Test that #line is set to correct line no. in source .function file. + + :return: + """ + data = '''#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +/* END_HEADER */ +''' + offset_line_no = 5 + expected = '''#line %d "test_suite_ut.function" +#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +''' % (offset_line_no + 1) + stream = StringIOWrapper('test_suite_ut.function', data, + offset_line_no) + headers = parse_until_pattern(stream, END_HEADER_REGEX) + self.assertEqual(headers, expected) + + def test_no_end_header_comment(self): + """ + Test that InvalidFileFormat is raised when end header comment is + missing. + :return: + """ + data = '''#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 + +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(GeneratorInputError, parse_until_pattern, stream, + END_HEADER_REGEX) + + +class ParseSuiteDependencies(TestCase): + """ + Test Suite for testing parse_suite_dependencies(). + """ + + def test_suite_dependencies(self): + """ + + :return: + """ + data = ''' + * depends_on:MBEDTLS_ECP_C + * END_DEPENDENCIES + */ +''' + expected = ['MBEDTLS_ECP_C'] + stream = StringIOWrapper('test_suite_ut.function', data) + dependencies = parse_suite_dependencies(stream) + self.assertEqual(dependencies, expected) + + def test_no_end_dep_comment(self): + """ + Test that InvalidFileFormat is raised when end dep comment is missing. + :return: + """ + data = ''' +* depends_on:MBEDTLS_ECP_C +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(GeneratorInputError, parse_suite_dependencies, + stream) + + def test_dependencies_split(self): + """ + Test that InvalidFileFormat is raised when end dep comment is missing. + :return: + """ + data = ''' + * depends_on:MBEDTLS_ECP_C:A:B: C : D :F : G: !H + * END_DEPENDENCIES + */ +''' + expected = ['MBEDTLS_ECP_C', 'A', 'B', 'C', 'D', 'F', 'G', '!H'] + stream = StringIOWrapper('test_suite_ut.function', data) + dependencies = parse_suite_dependencies(stream) + self.assertEqual(dependencies, expected) + + +class ParseFuncDependencies(TestCase): + """ + Test Suite for testing parse_function_dependencies() + """ + + def test_function_dependencies(self): + """ + Test that parse_function_dependencies() correctly parses function + dependencies. + :return: + """ + line = '/* BEGIN_CASE ' \ + 'depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */' + expected = ['MBEDTLS_ENTROPY_NV_SEED', 'MBEDTLS_FS_IO'] + dependencies = parse_function_dependencies(line) + self.assertEqual(dependencies, expected) + + def test_no_dependencies(self): + """ + Test that parse_function_dependencies() correctly parses function + dependencies. + :return: + """ + line = '/* BEGIN_CASE */' + dependencies = parse_function_dependencies(line) + self.assertEqual(dependencies, []) + + def test_tolerance(self): + """ + Test that parse_function_dependencies() correctly parses function + dependencies. + :return: + """ + line = '/* BEGIN_CASE depends_on:MBEDTLS_FS_IO: A : !B:C : F*/' + dependencies = parse_function_dependencies(line) + self.assertEqual(dependencies, ['MBEDTLS_FS_IO', 'A', '!B', 'C', 'F']) + + +class ParseFuncSignature(TestCase): + """ + Test Suite for parse_function_arguments(). + """ + + def test_int_and_char_params(self): + """ + Test int and char parameters parsing + :return: + """ + line = 'void entropy_threshold( char * a, int b, int result )' + args, local, arg_dispatch = parse_function_arguments(line) + self.assertEqual(args, ['char*', 'int', 'int']) + self.assertEqual(local, '') + self.assertEqual(arg_dispatch, ['(char *) params[0]', + '*( (int *) params[1] )', + '*( (int *) params[2] )']) + + def test_hex_params(self): + """ + Test hex parameters parsing + :return: + """ + line = 'void entropy_threshold( char * a, data_t * h, int result )' + args, local, arg_dispatch = parse_function_arguments(line) + self.assertEqual(args, ['char*', 'hex', 'int']) + self.assertEqual(local, + ' data_t data1 = {(uint8_t *) params[1], ' + '*( (uint32_t *) params[2] )};\n') + self.assertEqual(arg_dispatch, ['(char *) params[0]', + '&data1', + '*( (int *) params[3] )']) + + def test_unsupported_arg(self): + """ + Test unsupported arguments (not among int, char * and data_t) + :return: + """ + line = 'void entropy_threshold( char * a, data_t * h, char result )' + self.assertRaises(ValueError, parse_function_arguments, line) + + def test_no_params(self): + """ + Test no parameters. + :return: + """ + line = 'void entropy_threshold()' + args, local, arg_dispatch = parse_function_arguments(line) + self.assertEqual(args, []) + self.assertEqual(local, '') + self.assertEqual(arg_dispatch, []) + + +class ParseFunctionCode(TestCase): + """ + Test suite for testing parse_function_code() + """ + + def assert_raises_regex(self, exp, regex, func, *args): + """ + Python 2 & 3 portable wrapper of assertRaisesRegex(p)? function. + + :param exp: Exception type expected to be raised by cb. + :param regex: Expected exception message + :param func: callable object under test + :param args: variable positional arguments + """ + parent = super(ParseFunctionCode, self) + + # Pylint does not appreciate that the super method called + # conditionally can be available in other Python version + # then that of Pylint. + # Workaround is to call the method via getattr. + # Pylint ignores that the method got via getattr is + # conditionally executed. Method has to be a callable. + # Hence, using a dummy callable for getattr default. + dummy = lambda *x: None + # First Python 3 assertRaisesRegex is checked, since Python 2 + # assertRaisesRegexp is also available in Python 3 but is + # marked deprecated. + for name in ('assertRaisesRegex', 'assertRaisesRegexp'): + method = getattr(parent, name, dummy) + if method is not dummy: + method(exp, regex, func, *args) + break + else: + raise AttributeError(" 'ParseFunctionCode' object has no attribute" + " 'assertRaisesRegex' or 'assertRaisesRegexp'" + ) + + def test_no_function(self): + """ + Test no test function found. + :return: + """ + data = ''' +No +test +function +''' + stream = StringIOWrapper('test_suite_ut.function', data) + err_msg = 'file: test_suite_ut.function - Test functions not found!' + self.assert_raises_regex(GeneratorInputError, err_msg, + parse_function_code, stream, [], []) + + def test_no_end_case_comment(self): + """ + Test missing end case. + :return: + """ + data = ''' +void test_func() +{ +} +''' + stream = StringIOWrapper('test_suite_ut.function', data) + err_msg = r'file: test_suite_ut.function - '\ + 'end case pattern .*? not found!' + self.assert_raises_regex(GeneratorInputError, err_msg, + parse_function_code, stream, [], []) + + @patch("generate_test_code.parse_function_arguments") + def test_function_called(self, + parse_function_arguments_mock): + """ + Test parse_function_code() + :return: + """ + parse_function_arguments_mock.return_value = ([], '', []) + data = ''' +void test_func() +{ +} +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(GeneratorInputError, parse_function_code, + stream, [], []) + self.assertTrue(parse_function_arguments_mock.called) + parse_function_arguments_mock.assert_called_with('void test_func()\n') + + @patch("generate_test_code.gen_dispatch") + @patch("generate_test_code.gen_dependencies") + @patch("generate_test_code.gen_function_wrapper") + @patch("generate_test_code.parse_function_arguments") + def test_return(self, parse_function_arguments_mock, + gen_function_wrapper_mock, + gen_dependencies_mock, + gen_dispatch_mock): + """ + Test generated code. + :return: + """ + parse_function_arguments_mock.return_value = ([], '', []) + gen_function_wrapper_mock.return_value = '' + gen_dependencies_mock.side_effect = gen_dependencies + gen_dispatch_mock.side_effect = gen_dispatch + data = ''' +void func() +{ + ba ba black sheep + have you any wool +} +/* END_CASE */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + name, arg, code, dispatch_code = parse_function_code(stream, [], []) + + self.assertTrue(parse_function_arguments_mock.called) + parse_function_arguments_mock.assert_called_with('void func()\n') + gen_function_wrapper_mock.assert_called_with('test_func', '', []) + self.assertEqual(name, 'test_func') + self.assertEqual(arg, []) + expected = '''#line 1 "test_suite_ut.function" + +void test_func() +{ + ba ba black sheep + have you any wool +exit: + ; +} +''' + self.assertEqual(code, expected) + self.assertEqual(dispatch_code, "\n test_func_wrapper,\n") + + @patch("generate_test_code.gen_dispatch") + @patch("generate_test_code.gen_dependencies") + @patch("generate_test_code.gen_function_wrapper") + @patch("generate_test_code.parse_function_arguments") + def test_with_exit_label(self, parse_function_arguments_mock, + gen_function_wrapper_mock, + gen_dependencies_mock, + gen_dispatch_mock): + """ + Test when exit label is present. + :return: + """ + parse_function_arguments_mock.return_value = ([], '', []) + gen_function_wrapper_mock.return_value = '' + gen_dependencies_mock.side_effect = gen_dependencies + gen_dispatch_mock.side_effect = gen_dispatch + data = ''' +void func() +{ + ba ba black sheep + have you any wool +exit: + yes sir yes sir + 3 bags full +} +/* END_CASE */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + _, _, code, _ = parse_function_code(stream, [], []) + + expected = '''#line 1 "test_suite_ut.function" + +void test_func() +{ + ba ba black sheep + have you any wool +exit: + yes sir yes sir + 3 bags full +} +''' + self.assertEqual(code, expected) + + def test_non_void_function(self): + """ + Test invalid signature (non void). + :return: + """ + data = 'int entropy_threshold( char * a, data_t * h, int result )' + err_msg = 'file: test_suite_ut.function - Test functions not found!' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assert_raises_regex(GeneratorInputError, err_msg, + parse_function_code, stream, [], []) + + @patch("generate_test_code.gen_dispatch") + @patch("generate_test_code.gen_dependencies") + @patch("generate_test_code.gen_function_wrapper") + @patch("generate_test_code.parse_function_arguments") + def test_functio_name_on_newline(self, parse_function_arguments_mock, + gen_function_wrapper_mock, + gen_dependencies_mock, + gen_dispatch_mock): + """ + Test when exit label is present. + :return: + """ + parse_function_arguments_mock.return_value = ([], '', []) + gen_function_wrapper_mock.return_value = '' + gen_dependencies_mock.side_effect = gen_dependencies + gen_dispatch_mock.side_effect = gen_dispatch + data = ''' +void + + +func() +{ + ba ba black sheep + have you any wool +exit: + yes sir yes sir + 3 bags full +} +/* END_CASE */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + _, _, code, _ = parse_function_code(stream, [], []) + + expected = '''#line 1 "test_suite_ut.function" + +void + + +test_func() +{ + ba ba black sheep + have you any wool +exit: + yes sir yes sir + 3 bags full +} +''' + self.assertEqual(code, expected) + + +class ParseFunction(TestCase): + """ + Test Suite for testing parse_functions() + """ + + @patch("generate_test_code.parse_until_pattern") + def test_begin_header(self, parse_until_pattern_mock): + """ + Test that begin header is checked and parse_until_pattern() is called. + :return: + """ + def stop(*_unused): + """Stop when parse_until_pattern is called.""" + raise Exception + parse_until_pattern_mock.side_effect = stop + data = '''/* BEGIN_HEADER */ +#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +/* END_HEADER */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(Exception, parse_functions, stream) + parse_until_pattern_mock.assert_called_with(stream, END_HEADER_REGEX) + self.assertEqual(stream.line_no, 1) + + @patch("generate_test_code.parse_until_pattern") + def test_begin_helper(self, parse_until_pattern_mock): + """ + Test that begin helper is checked and parse_until_pattern() is called. + :return: + """ + def stop(*_unused): + """Stop when parse_until_pattern is called.""" + raise Exception + parse_until_pattern_mock.side_effect = stop + data = '''/* BEGIN_SUITE_HELPERS */ +void print_hello_world() +{ + printf("Hello World!\n"); +} +/* END_SUITE_HELPERS */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(Exception, parse_functions, stream) + parse_until_pattern_mock.assert_called_with(stream, + END_SUITE_HELPERS_REGEX) + self.assertEqual(stream.line_no, 1) + + @patch("generate_test_code.parse_suite_dependencies") + def test_begin_dep(self, parse_suite_dependencies_mock): + """ + Test that begin dep is checked and parse_suite_dependencies() is + called. + :return: + """ + def stop(*_unused): + """Stop when parse_until_pattern is called.""" + raise Exception + parse_suite_dependencies_mock.side_effect = stop + data = '''/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_ECP_C + * END_DEPENDENCIES + */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(Exception, parse_functions, stream) + parse_suite_dependencies_mock.assert_called_with(stream) + self.assertEqual(stream.line_no, 1) + + @patch("generate_test_code.parse_function_dependencies") + def test_begin_function_dep(self, func_mock): + """ + Test that begin dep is checked and parse_function_dependencies() is + called. + :return: + """ + def stop(*_unused): + """Stop when parse_until_pattern is called.""" + raise Exception + func_mock.side_effect = stop + + dependencies_str = '/* BEGIN_CASE ' \ + 'depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */\n' + data = '''%svoid test_func() +{ +} +''' % dependencies_str + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(Exception, parse_functions, stream) + func_mock.assert_called_with(dependencies_str) + self.assertEqual(stream.line_no, 1) + + @patch("generate_test_code.parse_function_code") + @patch("generate_test_code.parse_function_dependencies") + def test_return(self, func_mock1, func_mock2): + """ + Test that begin case is checked and parse_function_code() is called. + :return: + """ + func_mock1.return_value = [] + in_func_code = '''void test_func() +{ +} +''' + func_dispatch = ''' + test_func_wrapper, +''' + func_mock2.return_value = 'test_func', [],\ + in_func_code, func_dispatch + dependencies_str = '/* BEGIN_CASE ' \ + 'depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */\n' + data = '''%svoid test_func() +{ +} +''' % dependencies_str + stream = StringIOWrapper('test_suite_ut.function', data) + suite_dependencies, dispatch_code, func_code, func_info = \ + parse_functions(stream) + func_mock1.assert_called_with(dependencies_str) + func_mock2.assert_called_with(stream, [], []) + self.assertEqual(stream.line_no, 5) + self.assertEqual(suite_dependencies, []) + expected_dispatch_code = '''/* Function Id: 0 */ + + test_func_wrapper, +''' + self.assertEqual(dispatch_code, expected_dispatch_code) + self.assertEqual(func_code, in_func_code) + self.assertEqual(func_info, {'test_func': (0, [])}) + + def test_parsing(self): + """ + Test case parsing. + :return: + """ + data = '''/* BEGIN_HEADER */ +#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_ECP_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */ +void func1() +{ +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */ +void func2() +{ +} +/* END_CASE */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + suite_dependencies, dispatch_code, func_code, func_info = \ + parse_functions(stream) + self.assertEqual(stream.line_no, 23) + self.assertEqual(suite_dependencies, ['MBEDTLS_ECP_C']) + + expected_dispatch_code = '''/* Function Id: 0 */ + +#if defined(MBEDTLS_ECP_C) && defined(MBEDTLS_ENTROPY_NV_SEED) && defined(MBEDTLS_FS_IO) + test_func1_wrapper, +#else + NULL, +#endif +/* Function Id: 1 */ + +#if defined(MBEDTLS_ECP_C) && defined(MBEDTLS_ENTROPY_NV_SEED) && defined(MBEDTLS_FS_IO) + test_func2_wrapper, +#else + NULL, +#endif +''' + self.assertEqual(dispatch_code, expected_dispatch_code) + expected_func_code = '''#if defined(MBEDTLS_ECP_C) +#line 2 "test_suite_ut.function" +#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +#if defined(MBEDTLS_ENTROPY_NV_SEED) +#if defined(MBEDTLS_FS_IO) +#line 13 "test_suite_ut.function" +void test_func1() +{ +exit: + ; +} + +void test_func1_wrapper( void ** params ) +{ + (void)params; + + test_func1( ); +} +#endif /* MBEDTLS_FS_IO */ +#endif /* MBEDTLS_ENTROPY_NV_SEED */ +#if defined(MBEDTLS_ENTROPY_NV_SEED) +#if defined(MBEDTLS_FS_IO) +#line 19 "test_suite_ut.function" +void test_func2() +{ +exit: + ; +} + +void test_func2_wrapper( void ** params ) +{ + (void)params; + + test_func2( ); +} +#endif /* MBEDTLS_FS_IO */ +#endif /* MBEDTLS_ENTROPY_NV_SEED */ +#endif /* MBEDTLS_ECP_C */ +''' + self.assertEqual(func_code, expected_func_code) + self.assertEqual(func_info, {'test_func1': (0, []), + 'test_func2': (1, [])}) + + def test_same_function_name(self): + """ + Test name conflict. + :return: + """ + data = '''/* BEGIN_HEADER */ +#include "mbedtls/ecp.h" + +#define ECP_PF_UNKNOWN -1 +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_ECP_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */ +void func() +{ +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */ +void func() +{ +} +/* END_CASE */ +''' + stream = StringIOWrapper('test_suite_ut.function', data) + self.assertRaises(GeneratorInputError, parse_functions, stream) + + +class EscapedSplit(TestCase): + """ + Test suite for testing escaped_split(). + Note: Since escaped_split() output is used to write back to the + intermediate data file. Any escape characters in the input are + retained in the output. + """ + + def test_invalid_input(self): + """ + Test when input split character is not a character. + :return: + """ + self.assertRaises(ValueError, escaped_split, '', 'string') + + def test_empty_string(self): + """ + Test empty string input. + :return: + """ + splits = escaped_split('', ':') + self.assertEqual(splits, []) + + def test_no_escape(self): + """ + Test with no escape character. The behaviour should be same as + str.split() + :return: + """ + test_str = 'yahoo:google' + splits = escaped_split(test_str, ':') + self.assertEqual(splits, test_str.split(':')) + + def test_escaped_input(self): + """ + Test input that has escaped delimiter. + :return: + """ + test_str = r'yahoo\:google:facebook' + splits = escaped_split(test_str, ':') + self.assertEqual(splits, [r'yahoo\:google', 'facebook']) + + def test_escaped_escape(self): + """ + Test input that has escaped delimiter. + :return: + """ + test_str = r'yahoo\\:google:facebook' + splits = escaped_split(test_str, ':') + self.assertEqual(splits, [r'yahoo\\', 'google', 'facebook']) + + def test_all_at_once(self): + """ + Test input that has escaped delimiter. + :return: + """ + test_str = r'yahoo\\:google:facebook\:instagram\\:bbc\\:wikipedia' + splits = escaped_split(test_str, ':') + self.assertEqual(splits, [r'yahoo\\', r'google', + r'facebook\:instagram\\', + r'bbc\\', r'wikipedia']) + + +class ParseTestData(TestCase): + """ + Test suite for parse test data. + """ + + def test_parser(self): + """ + Test that tests are parsed correctly from data file. + :return: + """ + data = """ +Diffie-Hellman full exchange #1 +dhm_do_dhm:10:"23":10:"5" + +Diffie-Hellman full exchange #2 +dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622" + +Diffie-Hellman full exchange #3 +dhm_do_dhm:10:"9345098382739712938719287391879381271":10:"9345098792137312973297123912791271" + +Diffie-Hellman selftest +dhm_selftest: +""" + stream = StringIOWrapper('test_suite_ut.function', data) + tests = [(name, test_function, dependencies, args) + for name, test_function, dependencies, args in + parse_test_data(stream)] + test1, test2, test3, test4 = tests + self.assertEqual(test1[0], 'Diffie-Hellman full exchange #1') + self.assertEqual(test1[1], 'dhm_do_dhm') + self.assertEqual(test1[2], []) + self.assertEqual(test1[3], ['10', '"23"', '10', '"5"']) + + self.assertEqual(test2[0], 'Diffie-Hellman full exchange #2') + self.assertEqual(test2[1], 'dhm_do_dhm') + self.assertEqual(test2[2], []) + self.assertEqual(test2[3], ['10', '"93450983094850938450983409623"', + '10', '"9345098304850938450983409622"']) + + self.assertEqual(test3[0], 'Diffie-Hellman full exchange #3') + self.assertEqual(test3[1], 'dhm_do_dhm') + self.assertEqual(test3[2], []) + self.assertEqual(test3[3], ['10', + '"9345098382739712938719287391879381271"', + '10', + '"9345098792137312973297123912791271"']) + + self.assertEqual(test4[0], 'Diffie-Hellman selftest') + self.assertEqual(test4[1], 'dhm_selftest') + self.assertEqual(test4[2], []) + self.assertEqual(test4[3], []) + + def test_with_dependencies(self): + """ + Test that tests with dependencies are parsed. + :return: + """ + data = """ +Diffie-Hellman full exchange #1 +depends_on:YAHOO +dhm_do_dhm:10:"23":10:"5" + +Diffie-Hellman full exchange #2 +dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622" + +""" + stream = StringIOWrapper('test_suite_ut.function', data) + tests = [(name, function_name, dependencies, args) + for name, function_name, dependencies, args in + parse_test_data(stream)] + test1, test2 = tests + self.assertEqual(test1[0], 'Diffie-Hellman full exchange #1') + self.assertEqual(test1[1], 'dhm_do_dhm') + self.assertEqual(test1[2], ['YAHOO']) + self.assertEqual(test1[3], ['10', '"23"', '10', '"5"']) + + self.assertEqual(test2[0], 'Diffie-Hellman full exchange #2') + self.assertEqual(test2[1], 'dhm_do_dhm') + self.assertEqual(test2[2], []) + self.assertEqual(test2[3], ['10', '"93450983094850938450983409623"', + '10', '"9345098304850938450983409622"']) + + def test_no_args(self): + """ + Test GeneratorInputError is raised when test function name and + args line is missing. + :return: + """ + data = """ +Diffie-Hellman full exchange #1 +depends_on:YAHOO + + +Diffie-Hellman full exchange #2 +dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622" + +""" + stream = StringIOWrapper('test_suite_ut.function', data) + err = None + try: + for _, _, _, _ in parse_test_data(stream): + pass + except GeneratorInputError as err: + self.assertEqual(type(err), GeneratorInputError) + + def test_incomplete_data(self): + """ + Test GeneratorInputError is raised when test function name + and args line is missing. + :return: + """ + data = """ +Diffie-Hellman full exchange #1 +depends_on:YAHOO +""" + stream = StringIOWrapper('test_suite_ut.function', data) + err = None + try: + for _, _, _, _ in parse_test_data(stream): + pass + except GeneratorInputError as err: + self.assertEqual(type(err), GeneratorInputError) + + +class GenDepCheck(TestCase): + """ + Test suite for gen_dep_check(). It is assumed this function is + called with valid inputs. + """ + + def test_gen_dep_check(self): + """ + Test that dependency check code generated correctly. + :return: + """ + expected = """ + case 5: + { +#if defined(YAHOO) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break;""" + out = gen_dep_check(5, 'YAHOO') + self.assertEqual(out, expected) + + def test_not_defined_dependency(self): + """ + Test dependency with !. + :return: + """ + expected = """ + case 5: + { +#if !defined(YAHOO) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break;""" + out = gen_dep_check(5, '!YAHOO') + self.assertEqual(out, expected) + + def test_empty_dependency(self): + """ + Test invalid dependency input. + :return: + """ + self.assertRaises(GeneratorInputError, gen_dep_check, 5, '!') + + def test_negative_dep_id(self): + """ + Test invalid dependency input. + :return: + """ + self.assertRaises(GeneratorInputError, gen_dep_check, -1, 'YAHOO') + + +class GenExpCheck(TestCase): + """ + Test suite for gen_expression_check(). It is assumed this function + is called with valid inputs. + """ + + def test_gen_exp_check(self): + """ + Test that expression check code generated correctly. + :return: + """ + expected = """ + case 5: + { + *out_value = YAHOO; + } + break;""" + out = gen_expression_check(5, 'YAHOO') + self.assertEqual(out, expected) + + def test_invalid_expression(self): + """ + Test invalid expression input. + :return: + """ + self.assertRaises(GeneratorInputError, gen_expression_check, 5, '') + + def test_negative_exp_id(self): + """ + Test invalid expression id. + :return: + """ + self.assertRaises(GeneratorInputError, gen_expression_check, + -1, 'YAHOO') + + +class WriteDependencies(TestCase): + """ + Test suite for testing write_dependencies. + """ + + def test_no_test_dependencies(self): + """ + Test when test dependencies input is empty. + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_dependencies = [] + dep_check_code = write_dependencies(stream, [], unique_dependencies) + self.assertEqual(dep_check_code, '') + self.assertEqual(len(unique_dependencies), 0) + self.assertEqual(stream.getvalue(), '') + + def test_unique_dep_ids(self): + """ + + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_dependencies = [] + dep_check_code = write_dependencies(stream, ['DEP3', 'DEP2', 'DEP1'], + unique_dependencies) + expect_dep_check_code = ''' + case 0: + { +#if defined(DEP3) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break; + case 1: + { +#if defined(DEP2) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break; + case 2: + { +#if defined(DEP1) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break;''' + self.assertEqual(dep_check_code, expect_dep_check_code) + self.assertEqual(len(unique_dependencies), 3) + self.assertEqual(stream.getvalue(), 'depends_on:0:1:2\n') + + def test_dep_id_repeat(self): + """ + + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_dependencies = [] + dep_check_code = '' + dep_check_code += write_dependencies(stream, ['DEP3', 'DEP2'], + unique_dependencies) + dep_check_code += write_dependencies(stream, ['DEP2', 'DEP1'], + unique_dependencies) + dep_check_code += write_dependencies(stream, ['DEP1', 'DEP3'], + unique_dependencies) + expect_dep_check_code = ''' + case 0: + { +#if defined(DEP3) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break; + case 1: + { +#if defined(DEP2) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break; + case 2: + { +#if defined(DEP1) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break;''' + self.assertEqual(dep_check_code, expect_dep_check_code) + self.assertEqual(len(unique_dependencies), 3) + self.assertEqual(stream.getvalue(), + 'depends_on:0:1\ndepends_on:1:2\ndepends_on:2:0\n') + + +class WriteParams(TestCase): + """ + Test Suite for testing write_parameters(). + """ + + def test_no_params(self): + """ + Test with empty test_args + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_expressions = [] + expression_code = write_parameters(stream, [], [], unique_expressions) + self.assertEqual(len(unique_expressions), 0) + self.assertEqual(expression_code, '') + self.assertEqual(stream.getvalue(), '\n') + + def test_no_exp_param(self): + """ + Test when there is no macro or expression in the params. + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_expressions = [] + expression_code = write_parameters(stream, ['"Yahoo"', '"abcdef00"', + '0'], + ['char*', 'hex', 'int'], + unique_expressions) + self.assertEqual(len(unique_expressions), 0) + self.assertEqual(expression_code, '') + self.assertEqual(stream.getvalue(), + ':char*:"Yahoo":hex:"abcdef00":int:0\n') + + def test_hex_format_int_param(self): + """ + Test int parameter in hex format. + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_expressions = [] + expression_code = write_parameters(stream, + ['"Yahoo"', '"abcdef00"', '0xAA'], + ['char*', 'hex', 'int'], + unique_expressions) + self.assertEqual(len(unique_expressions), 0) + self.assertEqual(expression_code, '') + self.assertEqual(stream.getvalue(), + ':char*:"Yahoo":hex:"abcdef00":int:0xAA\n') + + def test_with_exp_param(self): + """ + Test when there is macro or expression in the params. + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_expressions = [] + expression_code = write_parameters(stream, + ['"Yahoo"', '"abcdef00"', '0', + 'MACRO1', 'MACRO2', 'MACRO3'], + ['char*', 'hex', 'int', + 'int', 'int', 'int'], + unique_expressions) + self.assertEqual(len(unique_expressions), 3) + self.assertEqual(unique_expressions, ['MACRO1', 'MACRO2', 'MACRO3']) + expected_expression_code = ''' + case 0: + { + *out_value = MACRO1; + } + break; + case 1: + { + *out_value = MACRO2; + } + break; + case 2: + { + *out_value = MACRO3; + } + break;''' + self.assertEqual(expression_code, expected_expression_code) + self.assertEqual(stream.getvalue(), + ':char*:"Yahoo":hex:"abcdef00":int:0:exp:0:exp:1' + ':exp:2\n') + + def test_with_repeat_calls(self): + """ + Test when write_parameter() is called with same macro or expression. + :return: + """ + stream = StringIOWrapper('test_suite_ut.data', '') + unique_expressions = [] + expression_code = '' + expression_code += write_parameters(stream, + ['"Yahoo"', 'MACRO1', 'MACRO2'], + ['char*', 'int', 'int'], + unique_expressions) + expression_code += write_parameters(stream, + ['"abcdef00"', 'MACRO2', 'MACRO3'], + ['hex', 'int', 'int'], + unique_expressions) + expression_code += write_parameters(stream, + ['0', 'MACRO3', 'MACRO1'], + ['int', 'int', 'int'], + unique_expressions) + self.assertEqual(len(unique_expressions), 3) + self.assertEqual(unique_expressions, ['MACRO1', 'MACRO2', 'MACRO3']) + expected_expression_code = ''' + case 0: + { + *out_value = MACRO1; + } + break; + case 1: + { + *out_value = MACRO2; + } + break; + case 2: + { + *out_value = MACRO3; + } + break;''' + self.assertEqual(expression_code, expected_expression_code) + expected_data_file = ''':char*:"Yahoo":exp:0:exp:1 +:hex:"abcdef00":exp:1:exp:2 +:int:0:exp:2:exp:0 +''' + self.assertEqual(stream.getvalue(), expected_data_file) + + +class GenTestSuiteDependenciesChecks(TestCase): + """ + Test suite for testing gen_suite_dep_checks() + """ + def test_empty_suite_dependencies(self): + """ + Test with empty suite_dependencies list. + + :return: + """ + dep_check_code, expression_code = \ + gen_suite_dep_checks([], 'DEP_CHECK_CODE', 'EXPRESSION_CODE') + self.assertEqual(dep_check_code, 'DEP_CHECK_CODE') + self.assertEqual(expression_code, 'EXPRESSION_CODE') + + def test_suite_dependencies(self): + """ + Test with suite_dependencies list. + + :return: + """ + dep_check_code, expression_code = \ + gen_suite_dep_checks(['SUITE_DEP'], 'DEP_CHECK_CODE', + 'EXPRESSION_CODE') + expected_dep_check_code = ''' +#if defined(SUITE_DEP) +DEP_CHECK_CODE +#endif +''' + expected_expression_code = ''' +#if defined(SUITE_DEP) +EXPRESSION_CODE +#endif +''' + self.assertEqual(dep_check_code, expected_dep_check_code) + self.assertEqual(expression_code, expected_expression_code) + + def test_no_dep_no_exp(self): + """ + Test when there are no dependency and expression code. + :return: + """ + dep_check_code, expression_code = gen_suite_dep_checks([], '', '') + self.assertEqual(dep_check_code, '') + self.assertEqual(expression_code, '') + + +class GenFromTestData(TestCase): + """ + Test suite for gen_from_test_data() + """ + + @staticmethod + @patch("generate_test_code.write_dependencies") + @patch("generate_test_code.write_parameters") + @patch("generate_test_code.gen_suite_dep_checks") + def test_intermediate_data_file(func_mock1, + write_parameters_mock, + write_dependencies_mock): + """ + Test that intermediate data file is written with expected data. + :return: + """ + data = ''' +My test +depends_on:DEP1 +func1:0 +''' + data_f = StringIOWrapper('test_suite_ut.data', data) + out_data_f = StringIOWrapper('test_suite_ut.datax', '') + func_info = {'test_func1': (1, ('int',))} + suite_dependencies = [] + write_parameters_mock.side_effect = write_parameters + write_dependencies_mock.side_effect = write_dependencies + func_mock1.side_effect = gen_suite_dep_checks + gen_from_test_data(data_f, out_data_f, func_info, suite_dependencies) + write_dependencies_mock.assert_called_with(out_data_f, + ['DEP1'], ['DEP1']) + write_parameters_mock.assert_called_with(out_data_f, ['0'], + ('int',), []) + expected_dep_check_code = ''' + case 0: + { +#if defined(DEP1) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break;''' + func_mock1.assert_called_with( + suite_dependencies, expected_dep_check_code, '') + + def test_function_not_found(self): + """ + Test that AssertError is raised when function info in not found. + :return: + """ + data = ''' +My test +depends_on:DEP1 +func1:0 +''' + data_f = StringIOWrapper('test_suite_ut.data', data) + out_data_f = StringIOWrapper('test_suite_ut.datax', '') + func_info = {'test_func2': (1, ('int',))} + suite_dependencies = [] + self.assertRaises(GeneratorInputError, gen_from_test_data, + data_f, out_data_f, func_info, suite_dependencies) + + def test_different_func_args(self): + """ + Test that AssertError is raised when no. of parameters and + function args differ. + :return: + """ + data = ''' +My test +depends_on:DEP1 +func1:0 +''' + data_f = StringIOWrapper('test_suite_ut.data', data) + out_data_f = StringIOWrapper('test_suite_ut.datax', '') + func_info = {'test_func2': (1, ('int', 'hex'))} + suite_dependencies = [] + self.assertRaises(GeneratorInputError, gen_from_test_data, data_f, + out_data_f, func_info, suite_dependencies) + + def test_output(self): + """ + Test that intermediate data file is written with expected data. + :return: + """ + data = ''' +My test 1 +depends_on:DEP1 +func1:0:0xfa:MACRO1:MACRO2 + +My test 2 +depends_on:DEP1:DEP2 +func2:"yahoo":88:MACRO1 +''' + data_f = StringIOWrapper('test_suite_ut.data', data) + out_data_f = StringIOWrapper('test_suite_ut.datax', '') + func_info = {'test_func1': (0, ('int', 'int', 'int', 'int')), + 'test_func2': (1, ('char*', 'int', 'int'))} + suite_dependencies = [] + dep_check_code, expression_code = \ + gen_from_test_data(data_f, out_data_f, func_info, + suite_dependencies) + expected_dep_check_code = ''' + case 0: + { +#if defined(DEP1) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break; + case 1: + { +#if defined(DEP2) + ret = DEPENDENCY_SUPPORTED; +#else + ret = DEPENDENCY_NOT_SUPPORTED; +#endif + } + break;''' + expected_data = '''My test 1 +depends_on:0 +0:int:0:int:0xfa:exp:0:exp:1 + +My test 2 +depends_on:0:1 +1:char*:"yahoo":int:88:exp:0 + +''' + expected_expression_code = ''' + case 0: + { + *out_value = MACRO1; + } + break; + case 1: + { + *out_value = MACRO2; + } + break;''' + self.assertEqual(dep_check_code, expected_dep_check_code) + self.assertEqual(out_data_f.getvalue(), expected_data) + self.assertEqual(expression_code, expected_expression_code) + + +if __name__ == '__main__': + unittest_main() diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/test_zeroize.gdb b/3rdparty/mbedtls/mbedtls/tests/scripts/test_zeroize.gdb new file mode 100644 index 0000000000..2f995d2a3b --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/scripts/test_zeroize.gdb @@ -0,0 +1,71 @@ +# test_zeroize.gdb +# +# This file is part of Mbed TLS (https://tls.mbed.org) +# +# Copyright (c) 2018, Arm Limited, All Rights Reserved +# +# Purpose +# +# Run a test using the debugger to check that the mbedtls_platform_zeroize() +# function in platform_util.h is not being optimized out by the compiler. To do +# so, the script loads the test program at programs/test/zeroize.c and sets a +# breakpoint at the last return statement in main(). When the breakpoint is +# hit, the debugger manually checks the contents to be zeroized and checks that +# it is actually cleared. +# +# The mbedtls_platform_zeroize() test is debugger driven because there does not +# seem to be a mechanism to reliably check whether the zeroize calls are being +# eliminated by compiler optimizations from within the compiled program. The +# problem is that a compiler would typically remove what it considers to be +# "unecessary" assignments as part of redundant code elimination. To identify +# such code, the compilar will create some form dependency graph between +# reads and writes to variables (among other situations). It will then use this +# data structure to remove redundant code that does not have an impact on the +# program's observable behavior. In the case of mbedtls_platform_zeroize(), an +# intelligent compiler could determine that this function clears a block of +# memory that is not accessed later in the program, so removing the call to +# mbedtls_platform_zeroize() does not have an observable behavior. However, +# inserting a test after a call to mbedtls_platform_zeroize() to check whether +# the block of memory was correctly zeroed would force the compiler to not +# eliminate the mbedtls_platform_zeroize() call. If this does not occur, then +# the compiler potentially has a bug. +# +# Note: This test requires that the test program is compiled with -g3. +# +# WARNING: There does not seem to be a mechanism in GDB scripts to set a +# breakpoint at the end of a function (probably because there are a lot of +# complications as function can have multiple exit points, etc). Therefore, it +# was necessary to hard-code the line number of the breakpoint in the zeroize.c +# test app. The assumption is that zeroize.c is a simple test app that does not +# change often (as opposed to the actual library code), so the breakpoint line +# number does not need to be updated often. + +set confirm off + +file ./programs/test/zeroize +break zeroize.c:100 + +set args ./programs/test/zeroize.c +run + +set $i = 0 +set $len = sizeof(buf) +set $buf = buf + +while $i < $len + if $buf[$i++] != 0 + echo The buffer at was not zeroized\n + quit 1 + end +end + +echo The buffer was correctly zeroized\n + +continue + +if $_exitcode != 0 + echo The program did not terminate correctly\n + quit 1 +end + +quit 0 diff --git a/3rdparty/mbedtls/mbedtls/tests/scripts/yotta-build.sh b/3rdparty/mbedtls/mbedtls/tests/scripts/yotta-build.sh deleted file mode 100755 index 4bae34aa34..0000000000 --- a/3rdparty/mbedtls/mbedtls/tests/scripts/yotta-build.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -# yotta-build.sh -# -# This file is part of mbed TLS (https://tls.mbed.org) -# -# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved -# -# Purpose -# -# To run test builds of the yotta module for all supported targets. - -set -eu - -check_tools() -{ - for TOOL in "$@"; do - if ! `hash "$TOOL" >/dev/null 2>&1`; then - echo "$TOOL not found!" >&2 - exit 1 - fi - done -} - -yotta_build() -{ - TARGET=$1 - - echo; echo "*** $TARGET (release) ***" - yt -t $TARGET build - - echo; echo "*** $TARGET (debug) ***" - yt -t $TARGET build -d -} - -# Make sure the tools we need are available. -check_tools "arm-none-eabi-gcc" "armcc" "yotta" - -yotta/create-module.sh -cd yotta/module -yt update || true # needs network - -if uname -a | grep 'Linux.*x86' >/dev/null; then - yotta_build x86-linux-native -fi -if uname -a | grep 'Darwin.*x86' >/dev/null; then - yotta_build x86-osx-native -fi - -# armcc build tests. -yotta_build frdm-k64f-armcc -#yotta_build nordic-nrf51822-16k-armcc - -# arm-none-eabi-gcc build tests. -yotta_build frdm-k64f-gcc -#yotta_build st-nucleo-f401re-gcc # dirent -#yotta_build stm32f429i-disco-gcc # fails in mbed-hal-st-stm32f4 -#yotta_build nordic-nrf51822-16k-gcc # fails in minar-platform -#yotta_build bbc-microbit-classic-gcc # fails in minar-platform -#yotta_build st-stm32f439zi-gcc # fails in mbed-hal-st-stm32f4 -#yotta_build st-stm32f429i-disco-gcc # fails in mbed-hal-st-stm32f4 diff --git a/3rdparty/mbedtls/mbedtls/tests/ssl-opt.sh b/3rdparty/mbedtls/mbedtls/tests/ssl-opt.sh index ae98ae9862..d2f36e6933 100755 --- a/3rdparty/mbedtls/mbedtls/tests/ssl-opt.sh +++ b/3rdparty/mbedtls/mbedtls/tests/ssl-opt.sh @@ -21,6 +21,11 @@ set -u +if cd $( dirname $0 ); then :; else + echo "cd $( dirname $0 ) failed" >&2 + exit 1 +fi + # default values, can be overriden by the environment : ${P_SRV:=../programs/ssl/ssl_server2} : ${P_CLI:=../programs/ssl/ssl_client2} @@ -36,6 +41,28 @@ G_SRV="$GNUTLS_SERV --x509certfile data_files/server5.crt --x509keyfile data_fil G_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_CLI --x509cafile data_files/test-ca_cat12.crt" TCP_CLIENT="$PERL scripts/tcp_client.pl" +# alternative versions of OpenSSL and GnuTLS (no default path) + +if [ -n "${OPENSSL_LEGACY:-}" ]; then + O_LEGACY_SRV="$OPENSSL_LEGACY s_server -www -cert data_files/server5.crt -key data_files/server5.key" + O_LEGACY_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_LEGACY s_client" +else + O_LEGACY_SRV=false + O_LEGACY_CLI=false +fi + +if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then + G_NEXT_SRV="$GNUTLS_NEXT_SERV --x509certfile data_files/server5.crt --x509keyfile data_files/server5.key" +else + G_NEXT_SRV=false +fi + +if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then + G_NEXT_CLI="echo 'GET / HTTP/1.0' | $GNUTLS_NEXT_CLI --x509cafile data_files/test-ca_cat12.crt" +else + G_NEXT_CLI=false +fi + TESTS=0 FAILS=0 SKIPS=0 @@ -115,6 +142,14 @@ get_options() { done } +# Skip next test; use this macro to skip tests which are legitimate +# in theory and expected to be re-introduced at some point, but +# aren't expected to succeed at the moment due to problems outside +# our control (such as bugs in other TLS implementations). +skip_next_test() { + SKIP_NEXT="YES" +} + # skip next test if the flag is not enabled in config.h requires_config_enabled() { if grep "^#define $1" $CONFIG_H > /dev/null; then :; else @@ -129,6 +164,39 @@ requires_config_disabled() { fi } +get_config_value_or_default() { + # This function uses the query_config command line option to query the + # required Mbed TLS compile time configuration from the ssl_server2 + # program. The command will always return a success value if the + # configuration is defined and the value will be printed to stdout. + # + # Note that if the configuration is not defined or is defined to nothing, + # the output of this function will be an empty string. + ${P_SRV} "query_config=${1}" +} + +requires_config_value_at_least() { + VAL="$( get_config_value_or_default "$1" )" + if [ -z "$VAL" ]; then + # Should never happen + echo "Mbed TLS configuration $1 is not defined" + exit 1 + elif [ "$VAL" -lt "$2" ]; then + SKIP_NEXT="YES" + fi +} + +requires_config_value_at_most() { + VAL=$( get_config_value_or_default "$1" ) + if [ -z "$VAL" ]; then + # Should never happen + echo "Mbed TLS configuration $1 is not defined" + exit 1 + elif [ "$VAL" -gt "$2" ]; then + SKIP_NEXT="YES" + fi +} + # skip next test if OpenSSL doesn't support FALLBACK_SCSV requires_openssl_with_fallback_scsv() { if [ -z "${OPENSSL_HAS_FBSCSV:-}" ]; then @@ -158,6 +226,34 @@ requires_gnutls() { fi } +# skip next test if GnuTLS-next isn't available +requires_gnutls_next() { + if [ -z "${GNUTLS_NEXT_AVAILABLE:-}" ]; then + if ( which "${GNUTLS_NEXT_CLI:-}" && which "${GNUTLS_NEXT_SERV:-}" ) >/dev/null 2>&1; then + GNUTLS_NEXT_AVAILABLE="YES" + else + GNUTLS_NEXT_AVAILABLE="NO" + fi + fi + if [ "$GNUTLS_NEXT_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + +# skip next test if OpenSSL-legacy isn't available +requires_openssl_legacy() { + if [ -z "${OPENSSL_LEGACY_AVAILABLE:-}" ]; then + if which "${OPENSSL_LEGACY:-}" >/dev/null 2>&1; then + OPENSSL_LEGACY_AVAILABLE="YES" + else + OPENSSL_LEGACY_AVAILABLE="NO" + fi + fi + if [ "$OPENSSL_LEGACY_AVAILABLE" = "NO" ]; then + SKIP_NEXT="YES" + fi +} + # skip next test if IPv6 isn't available on this host requires_ipv6() { if [ -z "${HAS_IPV6:-}" ]; then @@ -178,6 +274,40 @@ requires_ipv6() { fi } +# skip next test if it's i686 or uname is not available +requires_not_i686() { + if [ -z "${IS_I686:-}" ]; then + IS_I686="YES" + if which "uname" >/dev/null 2>&1; then + if [ -z "$(uname -a | grep i686)" ]; then + IS_I686="NO" + fi + fi + fi + if [ "$IS_I686" = "YES" ]; then + SKIP_NEXT="YES" + fi +} + +# Calculate the input & output maximum content lengths set in the config +MAX_CONTENT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN || echo "16384") +MAX_IN_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_IN_CONTENT_LEN || echo "$MAX_CONTENT_LEN") +MAX_OUT_LEN=$( ../scripts/config.pl get MBEDTLS_SSL_OUT_CONTENT_LEN || echo "$MAX_CONTENT_LEN") + +if [ "$MAX_IN_LEN" -lt "$MAX_CONTENT_LEN" ]; then + MAX_CONTENT_LEN="$MAX_IN_LEN" +fi +if [ "$MAX_OUT_LEN" -lt "$MAX_CONTENT_LEN" ]; then + MAX_CONTENT_LEN="$MAX_OUT_LEN" +fi + +# skip the next test if the SSL output buffer is less than 16KB +requires_full_size_output_buffer() { + if [ "$MAX_OUT_LEN" -ne 16384 ]; then + SKIP_NEXT="YES" + fi +} + # skip the next test if valgrind is in use not_with_valgrind() { if [ "$MEMCHECK" -gt 0 ]; then @@ -423,6 +553,20 @@ run_test() { CLI_EXPECT="$3" shift 3 + # Check if test uses files + TEST_USES_FILES=$(echo "$SRV_CMD $CLI_CMD" | grep "\.\(key\|crt\|pem\)" ) + if [ ! -z "$TEST_USES_FILES" ]; then + requires_config_enabled MBEDTLS_FS_IO + fi + + # should we skip? + if [ "X$SKIP_NEXT" = "XYES" ]; then + SKIP_NEXT="NO" + echo "SKIP" + SKIPS=$(( $SKIPS + 1 )) + return + fi + # fix client port if [ -n "$PXY_CMD" ]; then CLI_CMD=$( echo "$CLI_CMD" | sed s/+SRV_PORT/$PXY_PORT/g ) @@ -465,9 +609,12 @@ run_test() { eval "$CLI_CMD" >> $CLI_OUT 2>&1 & wait_client_done + sleep 0.05 + # terminate the server (and the proxy) kill $SRV_PID wait $SRV_PID + if [ -n "$PXY_CMD" ]; then kill $PXY_PID >/dev/null 2>&1 wait $PXY_PID @@ -626,24 +773,22 @@ cleanup() { # MAIN # -if cd $( dirname $0 ); then :; else - echo "cd $( dirname $0 ) failed" >&2 - exit 1 -fi - get_options "$@" # sanity checks, avoid an avalanche of errors -if [ ! -x "$P_SRV" ]; then - echo "Command '$P_SRV' is not an executable file" +P_SRV_BIN="${P_SRV%%[ ]*}" +P_CLI_BIN="${P_CLI%%[ ]*}" +P_PXY_BIN="${P_PXY%%[ ]*}" +if [ ! -x "$P_SRV_BIN" ]; then + echo "Command '$P_SRV_BIN' is not an executable file" exit 1 fi -if [ ! -x "$P_CLI" ]; then - echo "Command '$P_CLI' is not an executable file" +if [ ! -x "$P_CLI_BIN" ]; then + echo "Command '$P_CLI_BIN' is not an executable file" exit 1 fi -if [ ! -x "$P_PXY" ]; then - echo "Command '$P_PXY' is not an executable file" +if [ ! -x "$P_PXY_BIN" ]; then + echo "Command '$P_PXY_BIN' is not an executable file" exit 1 fi if [ "$MEMCHECK" -gt 0 ]; then @@ -693,7 +838,20 @@ P_PXY="$P_PXY server_addr=127.0.0.1 server_port=$SRV_PORT listen_addr=127.0.0.1 O_SRV="$O_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem" O_CLI="$O_CLI -connect localhost:+SRV_PORT" G_SRV="$G_SRV -p $SRV_PORT" -G_CLI="$G_CLI -p +SRV_PORT localhost" +G_CLI="$G_CLI -p +SRV_PORT" + +if [ -n "${OPENSSL_LEGACY:-}" ]; then + O_LEGACY_SRV="$O_LEGACY_SRV -accept $SRV_PORT -dhparam data_files/dhparams.pem" + O_LEGACY_CLI="$O_LEGACY_CLI -connect localhost:+SRV_PORT" +fi + +if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then + G_NEXT_SRV="$G_NEXT_SRV -p $SRV_PORT" +fi + +if [ -n "${GNUTLS_NEXT_CLI:-}" ]; then + G_NEXT_CLI="$G_NEXT_CLI -p +SRV_PORT" +fi # Allow SHA-1, because many of our test certificates use it P_SRV="$P_SRV allow_sha1=1" @@ -720,7 +878,7 @@ run_test "Default" \ "$P_CLI" \ 0 \ -s "Protocol is TLSv1.2" \ - -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \ + -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" \ -s "client hello v3, signature_algorithm ext: 6" \ -s "ECDHE curve: secp521r1" \ -S "error" \ @@ -731,20 +889,14 @@ run_test "Default, DTLS" \ "$P_CLI dtls=1" \ 0 \ -s "Protocol is DTLSv1.2" \ - -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" + -s "Ciphersuite is TLS-ECDHE-RSA-WITH-CHACHA20-POLY1305-SHA256" # Test current time in ServerHello requires_config_enabled MBEDTLS_HAVE_TIME -run_test "Default, ServerHello contains gmt_unix_time" \ +run_test "ServerHello contains gmt_unix_time" \ "$P_SRV debug_level=3" \ "$P_CLI debug_level=3" \ 0 \ - -s "Protocol is TLSv1.2" \ - -s "Ciphersuite is TLS-ECDHE-ECDSA-WITH-AES-256-GCM-SHA384" \ - -s "client hello v3, signature_algorithm ext: 6" \ - -s "ECDHE curve: secp521r1" \ - -S "error" \ - -C "error" \ -f "check_server_hello_time" \ -F "check_server_hello_time" @@ -849,6 +1001,35 @@ run_test "SHA-256 allowed by default in client certificate" \ "$P_CLI key_file=data_files/cli-rsa.key crt_file=data_files/cli-rsa-sha256.crt" \ 0 +# Tests for datagram packing +run_test "DTLS: multiple records in same datagram, client and server" \ + "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \ + 0 \ + -c "next record in same datagram" \ + -s "next record in same datagram" + +run_test "DTLS: multiple records in same datagram, client only" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=1 debug_level=2" \ + 0 \ + -s "next record in same datagram" \ + -C "next record in same datagram" + +run_test "DTLS: multiple records in same datagram, server only" \ + "$P_SRV dtls=1 dgram_packing=1 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ + 0 \ + -S "next record in same datagram" \ + -c "next record in same datagram" + +run_test "DTLS: multiple records in same datagram, neither client nor server" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ + 0 \ + -S "next record in same datagram" \ + -C "next record in same datagram" + # Tests for Truncated HMAC extension run_test "Truncated HMAC: client default, server default" \ @@ -1621,28 +1802,22 @@ run_test "Session resume using cache, DTLS: openssl server" \ # Tests for Max Fragment Length extension -MAX_CONTENT_LEN_EXPECT='16384' -MAX_CONTENT_LEN_CONFIG=$( ../scripts/config.pl get MBEDTLS_SSL_MAX_CONTENT_LEN) - -if [ -n "$MAX_CONTENT_LEN_CONFIG" ] && [ "$MAX_CONTENT_LEN_CONFIG" -ne "$MAX_CONTENT_LEN_EXPECT" ]; then - printf "The ${CONFIG_H} file contains a value for the configuration of\n" - printf "MBEDTLS_SSL_MAX_CONTENT_LEN that is different from the script’s\n" - printf "test value of ${MAX_CONTENT_LEN_EXPECT}. \n" - printf "\n" - printf "The tests assume this value and if it changes, the tests in this\n" - printf "script should also be adjusted.\n" - printf "\n" - +if [ "$MAX_CONTENT_LEN" -lt "4096" ]; then + printf "${CONFIG_H} defines MBEDTLS_SSL_MAX_CONTENT_LEN to be less than 4096. Fragment length tests will fail.\n" exit 1 fi +if [ $MAX_CONTENT_LEN -ne 16384 ]; then + printf "Using non-default maximum content length $MAX_CONTENT_LEN\n" +fi + requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH run_test "Max fragment length: enabled, default" \ "$P_SRV debug_level=3" \ "$P_CLI debug_level=3" \ 0 \ - -c "Maximum fragment length is 16384" \ - -s "Maximum fragment length is 16384" \ + -c "Maximum fragment length is $MAX_CONTENT_LEN" \ + -s "Maximum fragment length is $MAX_CONTENT_LEN" \ -C "client hello, adding max_fragment_length extension" \ -S "found max fragment length extension" \ -S "server hello, max_fragment_length extension" \ @@ -1651,46 +1826,50 @@ run_test "Max fragment length: enabled, default" \ requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH run_test "Max fragment length: enabled, default, larger message" \ "$P_SRV debug_level=3" \ - "$P_CLI debug_level=3 request_size=16385" \ + "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 0 \ - -c "Maximum fragment length is 16384" \ - -s "Maximum fragment length is 16384" \ + -c "Maximum fragment length is $MAX_CONTENT_LEN" \ + -s "Maximum fragment length is $MAX_CONTENT_LEN" \ -C "client hello, adding max_fragment_length extension" \ -S "found max fragment length extension" \ -S "server hello, max_fragment_length extension" \ -C "found max_fragment_length extension" \ - -c "16385 bytes written in 2 fragments" \ - -s "16384 bytes read" \ + -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \ + -s "$MAX_CONTENT_LEN bytes read" \ -s "1 bytes read" requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH run_test "Max fragment length, DTLS: enabled, default, larger message" \ "$P_SRV debug_level=3 dtls=1" \ - "$P_CLI debug_level=3 dtls=1 request_size=16385" \ + "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 1 \ - -c "Maximum fragment length is 16384" \ - -s "Maximum fragment length is 16384" \ + -c "Maximum fragment length is $MAX_CONTENT_LEN" \ + -s "Maximum fragment length is $MAX_CONTENT_LEN" \ -C "client hello, adding max_fragment_length extension" \ -S "found max fragment length extension" \ -S "server hello, max_fragment_length extension" \ -C "found max_fragment_length extension" \ -c "fragment larger than.*maximum " +# Run some tests with MBEDTLS_SSL_MAX_FRAGMENT_LENGTH disabled +# (session fragment length will be 16384 regardless of mbedtls +# content length configuration.) + requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH run_test "Max fragment length: disabled, larger message" \ "$P_SRV debug_level=3" \ - "$P_CLI debug_level=3 request_size=16385" \ + "$P_CLI debug_level=3 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 0 \ -C "Maximum fragment length is 16384" \ -S "Maximum fragment length is 16384" \ - -c "16385 bytes written in 2 fragments" \ - -s "16384 bytes read" \ + -c "$(( $MAX_CONTENT_LEN + 1)) bytes written in 2 fragments" \ + -s "$MAX_CONTENT_LEN bytes read" \ -s "1 bytes read" requires_config_disabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH run_test "Max fragment length DTLS: disabled, larger message" \ "$P_SRV debug_level=3 dtls=1" \ - "$P_CLI debug_level=3 dtls=1 request_size=16385" \ + "$P_CLI debug_level=3 dtls=1 request_size=$(( $MAX_CONTENT_LEN + 1))" \ 1 \ -C "Maximum fragment length is 16384" \ -S "Maximum fragment length is 16384" \ @@ -1713,7 +1892,7 @@ run_test "Max fragment length: used by server" \ "$P_SRV debug_level=3 max_frag_len=4096" \ "$P_CLI debug_level=3" \ 0 \ - -c "Maximum fragment length is 16384" \ + -c "Maximum fragment length is $MAX_CONTENT_LEN" \ -s "Maximum fragment length is 4096" \ -C "client hello, adding max_fragment_length extension" \ -S "found max fragment length extension" \ @@ -2217,7 +2396,7 @@ run_test "Renego ext: gnutls server unsafe, client break legacy" \ requires_gnutls run_test "Renego ext: gnutls client strict, server default" \ "$P_SRV debug_level=3" \ - "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION" \ + "$G_CLI --priority=NORMAL:%SAFE_RENEGOTIATION localhost" \ 0 \ -s "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \ -s "server hello, secure renegotiation extension" @@ -2225,7 +2404,7 @@ run_test "Renego ext: gnutls client strict, server default" \ requires_gnutls run_test "Renego ext: gnutls client unsafe, server default" \ "$P_SRV debug_level=3" \ - "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ + "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \ 0 \ -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \ -S "server hello, secure renegotiation extension" @@ -2233,7 +2412,7 @@ run_test "Renego ext: gnutls client unsafe, server default" \ requires_gnutls run_test "Renego ext: gnutls client unsafe, server break legacy" \ "$P_SRV debug_level=3 allow_legacy=-1" \ - "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION" \ + "$G_CLI --priority=NORMAL:%DISABLE_SAFE_RENEGOTIATION localhost" \ 1 \ -S "received TLS_EMPTY_RENEGOTIATION_INFO\|found renegotiation extension" \ -S "server hello, secure renegotiation extension" @@ -2244,7 +2423,7 @@ requires_gnutls run_test "DER format: no trailing bytes" \ "$P_SRV crt_file=data_files/server5-der0.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2252,7 +2431,7 @@ requires_gnutls run_test "DER format: with a trailing zero byte" \ "$P_SRV crt_file=data_files/server5-der1a.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2260,7 +2439,7 @@ requires_gnutls run_test "DER format: with a trailing random byte" \ "$P_SRV crt_file=data_files/server5-der1b.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2268,7 +2447,7 @@ requires_gnutls run_test "DER format: with 2 trailing random bytes" \ "$P_SRV crt_file=data_files/server5-der2.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2276,7 +2455,7 @@ requires_gnutls run_test "DER format: with 4 trailing random bytes" \ "$P_SRV crt_file=data_files/server5-der4.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2284,7 +2463,7 @@ requires_gnutls run_test "DER format: with 8 trailing random bytes" \ "$P_SRV crt_file=data_files/server5-der8.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2292,7 +2471,7 @@ requires_gnutls run_test "DER format: with 9 trailing random bytes" \ "$P_SRV crt_file=data_files/server5-der9.crt \ key_file=data_files/server5.key" \ - "$G_CLI " \ + "$G_CLI localhost" \ 0 \ -c "Handshake was completed" \ @@ -2581,6 +2760,7 @@ if [ -n "$MAX_IM_CA_CONFIG" ] && [ "$MAX_IM_CA_CONFIG" -ne "$MAX_IM_CA" ]; then exit 1 fi +requires_full_size_output_buffer run_test "Authentication: server max_int chain, client default" \ "$P_SRV crt_file=data_files/dir-maxpath/c09.pem \ key_file=data_files/dir-maxpath/09.key" \ @@ -2588,6 +2768,7 @@ run_test "Authentication: server max_int chain, client default" \ 0 \ -C "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: server max_int+1 chain, client default" \ "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ key_file=data_files/dir-maxpath/10.key" \ @@ -2595,6 +2776,7 @@ run_test "Authentication: server max_int+1 chain, client default" \ 1 \ -c "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: server max_int+1 chain, client optional" \ "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ key_file=data_files/dir-maxpath/10.key" \ @@ -2603,6 +2785,7 @@ run_test "Authentication: server max_int+1 chain, client optional" \ 1 \ -c "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: server max_int+1 chain, client none" \ "$P_SRV crt_file=data_files/dir-maxpath/c10.pem \ key_file=data_files/dir-maxpath/10.key" \ @@ -2611,6 +2794,7 @@ run_test "Authentication: server max_int+1 chain, client none" \ 0 \ -C "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: client max_int+1 chain, server default" \ "$P_SRV ca_file=data_files/dir-maxpath/00.crt" \ "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ @@ -2618,6 +2802,7 @@ run_test "Authentication: client max_int+1 chain, server default" \ 0 \ -S "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: client max_int+1 chain, server optional" \ "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=optional" \ "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ @@ -2625,6 +2810,7 @@ run_test "Authentication: client max_int+1 chain, server optional" \ 1 \ -s "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: client max_int+1 chain, server required" \ "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \ "$P_CLI crt_file=data_files/dir-maxpath/c10.pem \ @@ -2632,6 +2818,7 @@ run_test "Authentication: client max_int+1 chain, server required" \ 1 \ -s "X509 - A fatal error occured" +requires_full_size_output_buffer run_test "Authentication: client max_int chain, server required" \ "$P_SRV ca_file=data_files/dir-maxpath/00.crt auth_mode=required" \ "$P_CLI crt_file=data_files/dir-maxpath/c09.pem \ @@ -3051,6 +3238,118 @@ run_test "Non-blocking I/O: session-id resume" \ -C "mbedtls_ssl_handshake returned" \ -c "Read from server: .* bytes read" +# Tests for event-driven I/O: exercise a variety of handshake flows + +run_test "Event-driven I/O: basic handshake" \ + "$P_SRV event=1 tickets=0 auth_mode=none" \ + "$P_CLI event=1 tickets=0" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O: client auth" \ + "$P_SRV event=1 tickets=0 auth_mode=required" \ + "$P_CLI event=1 tickets=0" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O: ticket" \ + "$P_SRV event=1 tickets=1 auth_mode=none" \ + "$P_CLI event=1 tickets=1" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O: ticket + client auth" \ + "$P_SRV event=1 tickets=1 auth_mode=required" \ + "$P_CLI event=1 tickets=1" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O: ticket + client auth + resume" \ + "$P_SRV event=1 tickets=1 auth_mode=required" \ + "$P_CLI event=1 tickets=1 reconnect=1" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O: ticket + resume" \ + "$P_SRV event=1 tickets=1 auth_mode=none" \ + "$P_CLI event=1 tickets=1 reconnect=1" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O: session-id resume" \ + "$P_SRV event=1 tickets=0 auth_mode=none" \ + "$P_CLI event=1 tickets=0 reconnect=1" \ + 0 \ + -S "mbedtls_ssl_handshake returned" \ + -C "mbedtls_ssl_handshake returned" \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: basic handshake" \ + "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \ + "$P_CLI dtls=1 event=1 tickets=0" \ + 0 \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: client auth" \ + "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \ + "$P_CLI dtls=1 event=1 tickets=0" \ + 0 \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: ticket" \ + "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \ + "$P_CLI dtls=1 event=1 tickets=1" \ + 0 \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: ticket + client auth" \ + "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \ + "$P_CLI dtls=1 event=1 tickets=1" \ + 0 \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: ticket + client auth + resume" \ + "$P_SRV dtls=1 event=1 tickets=1 auth_mode=required" \ + "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \ + 0 \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: ticket + resume" \ + "$P_SRV dtls=1 event=1 tickets=1 auth_mode=none" \ + "$P_CLI dtls=1 event=1 tickets=1 reconnect=1" \ + 0 \ + -c "Read from server: .* bytes read" + +run_test "Event-driven I/O, DTLS: session-id resume" \ + "$P_SRV dtls=1 event=1 tickets=0 auth_mode=none" \ + "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \ + 0 \ + -c "Read from server: .* bytes read" + +# This test demonstrates the need for the mbedtls_ssl_check_pending function. +# During session resumption, the client will send its ApplicationData record +# within the same datagram as the Finished messages. In this situation, the +# server MUST NOT idle on the underlying transport after handshake completion, +# because the ApplicationData request has already been queued internally. +run_test "Event-driven I/O, DTLS: session-id resume, UDP packing" \ + -p "$P_PXY pack=50" \ + "$P_SRV dtls=1 event=1 tickets=0 auth_mode=required" \ + "$P_CLI dtls=1 event=1 tickets=0 reconnect=1" \ + 0 \ + -c "Read from server: .* bytes read" + # Tests for version negotiation run_test "Version check: all -> 1.2" \ @@ -3708,26 +4007,37 @@ run_test "ECJPAKE: working, DTLS, nolog" \ # Tests for ciphersuites per version requires_config_enabled MBEDTLS_SSL_PROTO_SSL3 +requires_config_enabled MBEDTLS_CAMELLIA_C +requires_config_enabled MBEDTLS_AES_C run_test "Per-version suites: SSL3" \ - "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ + "$P_SRV min_version=ssl3 version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ "$P_CLI force_version=ssl3" \ 0 \ - -c "Ciphersuite is TLS-RSA-WITH-3DES-EDE-CBC-SHA" + -c "Ciphersuite is TLS-RSA-WITH-CAMELLIA-128-CBC-SHA" +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1 +requires_config_enabled MBEDTLS_CAMELLIA_C +requires_config_enabled MBEDTLS_AES_C run_test "Per-version suites: TLS 1.0" \ - "$P_SRV arc4=1 version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ + "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ "$P_CLI force_version=tls1 arc4=1" \ 0 \ -c "Ciphersuite is TLS-RSA-WITH-AES-256-CBC-SHA" +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +requires_config_enabled MBEDTLS_CAMELLIA_C +requires_config_enabled MBEDTLS_AES_C run_test "Per-version suites: TLS 1.1" \ - "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ + "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ "$P_CLI force_version=tls1_1" \ 0 \ -c "Ciphersuite is TLS-RSA-WITH-AES-128-CBC-SHA" +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +requires_config_enabled MBEDTLS_CAMELLIA_C +requires_config_enabled MBEDTLS_AES_C run_test "Per-version suites: TLS 1.2" \ - "$P_SRV version_suites=TLS-RSA-WITH-3DES-EDE-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ + "$P_SRV version_suites=TLS-RSA-WITH-CAMELLIA-128-CBC-SHA,TLS-RSA-WITH-AES-256-CBC-SHA,TLS-RSA-WITH-AES-128-CBC-SHA,TLS-RSA-WITH-AES-128-GCM-SHA256" \ "$P_CLI force_version=tls1_2" \ 0 \ -c "Ciphersuite is TLS-RSA-WITH-AES-128-GCM-SHA256" @@ -3736,15 +4046,15 @@ run_test "Per-version suites: TLS 1.2" \ requires_gnutls run_test "ClientHello without extensions, SHA-1 allowed" \ - "$P_SRV debug_level=3" \ - "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \ + "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt" \ + "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \ 0 \ -s "dumping 'client hello extensions' (0 bytes)" requires_gnutls run_test "ClientHello without extensions, SHA-1 forbidden in certificates on server" \ "$P_SRV debug_level=3 key_file=data_files/server2.key crt_file=data_files/server2.crt allow_sha1=0" \ - "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION" \ + "$G_CLI --priority=NORMAL:%NO_EXTENSIONS:%DISABLE_SAFE_RENEGOTIATION localhost" \ 0 \ -s "dumping 'client hello extensions' (0 bytes)" @@ -4352,14 +4662,19 @@ run_test "SSLv3 with extensions, server side" \ # Test for large client packets +# How many fragments do we expect to write $1 bytes? +fragments_for_write() { + echo "$(( ( $1 + $MAX_OUT_LEN - 1 ) / $MAX_OUT_LEN ))" +} + requires_config_enabled MBEDTLS_SSL_PROTO_SSL3 run_test "Large client packet SSLv3 BlockCipher" \ "$P_SRV min_version=ssl3" \ "$P_CLI request_size=16384 force_version=ssl3 recsplit=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_PROTO_SSL3 run_test "Large client packet SSLv3 StreamCipher" \ @@ -4367,23 +4682,23 @@ run_test "Large client packet SSLv3 StreamCipher" \ "$P_CLI request_size=16384 force_version=ssl3 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.0 BlockCipher" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.0 BlockCipher, without EtM" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \ @@ -4391,8 +4706,8 @@ run_test "Large client packet TLS 1.0 BlockCipher, truncated MAC" \ "$P_CLI request_size=16384 force_version=tls1 recsplit=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC" \ @@ -4400,21 +4715,21 @@ run_test "Large client packet TLS 1.0 BlockCipher, without EtM, truncated MAC "$P_CLI request_size=16384 force_version=tls1 etm=0 recsplit=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.0 StreamCipher" \ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ "$P_CLI request_size=16384 force_version=tls1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.0 StreamCipher, without EtM" \ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ "$P_CLI request_size=16384 force_version=tls1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \ @@ -4422,7 +4737,7 @@ run_test "Large client packet TLS 1.0 StreamCipher, truncated MAC" \ "$P_CLI request_size=16384 force_version=tls1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MAC" \ @@ -4430,23 +4745,23 @@ run_test "Large client packet TLS 1.0 StreamCipher, without EtM, truncated MA "$P_CLI request_size=16384 force_version=tls1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.1 BlockCipher" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.1 BlockCipher, without EtM" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_1 etm=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \ @@ -4454,7 +4769,7 @@ run_test "Large client packet TLS 1.1 BlockCipher, truncated MAC" \ "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC" \ @@ -4462,23 +4777,23 @@ run_test "Large client packet TLS 1.1 BlockCipher, without EtM, truncated MAC "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.1 StreamCipher" \ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.1 StreamCipher, without EtM" \ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \ @@ -4486,7 +4801,7 @@ run_test "Large client packet TLS 1.1 StreamCipher, truncated MAC" \ "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MAC" \ @@ -4494,31 +4809,31 @@ run_test "Large client packet TLS 1.1 StreamCipher, without EtM, truncated MA "$P_CLI request_size=16384 force_version=tls1_1 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 BlockCipher" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 BlockCipher, without EtM" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_2 etm=0 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 BlockCipher larger MAC" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-256-CBC-SHA384" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \ @@ -4526,7 +4841,7 @@ run_test "Large client packet TLS 1.2 BlockCipher, truncated MAC" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC" \ @@ -4534,23 +4849,23 @@ run_test "Large client packet TLS 1.2 BlockCipher, without EtM, truncated MAC "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA trunc_hmac=1 etm=0" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 StreamCipher" \ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 StreamCipher, without EtM" \ "$P_SRV arc4=1 force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA etm=0" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \ @@ -4558,7 +4873,7 @@ run_test "Large client packet TLS 1.2 StreamCipher, truncated MAC" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1" \ 0 \ - -s "Read from client: 16384 bytes read" + -s "Read from client: $MAX_CONTENT_LEN bytes read" requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MAC" \ @@ -4566,74 +4881,24 @@ run_test "Large client packet TLS 1.2 StreamCipher, without EtM, truncated MA "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-RC4-128-SHA trunc_hmac=1 etm=0" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 AEAD" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CCM" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" run_test "Large client packet TLS 1.2 AEAD shorter tag" \ "$P_SRV" \ "$P_CLI request_size=16384 force_version=tls1_2 \ force_ciphersuite=TLS-RSA-WITH-AES-256-CCM-8" \ 0 \ - -c "16384 bytes written in 1 fragments" \ - -s "Read from client: 16384 bytes read" - -# Tests for ECC extensions (rfc 4492) - -requires_config_enabled MBEDTLS_AES_C -requires_config_enabled MBEDTLS_CIPHER_MODE_CBC -requires_config_enabled MBEDTLS_SHA256_C -requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -run_test "Force a non ECC ciphersuite in the client side" \ - "$P_SRV debug_level=3" \ - "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \ - 0 \ - -C "client hello, adding supported_elliptic_curves extension" \ - -C "client hello, adding supported_point_formats extension" \ - -S "found supported elliptic curves extension" \ - -S "found supported point formats extension" - -requires_config_enabled MBEDTLS_AES_C -requires_config_enabled MBEDTLS_CIPHER_MODE_CBC -requires_config_enabled MBEDTLS_SHA256_C -requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -run_test "Force a non ECC ciphersuite in the server side" \ - "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \ - "$P_CLI debug_level=3" \ - 0 \ - -C "found supported_point_formats extension" \ - -S "server hello, supported_point_formats extension" - -requires_config_enabled MBEDTLS_AES_C -requires_config_enabled MBEDTLS_CIPHER_MODE_CBC -requires_config_enabled MBEDTLS_SHA256_C -requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -run_test "Force an ECC ciphersuite in the client side" \ - "$P_SRV debug_level=3" \ - "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ - 0 \ - -c "client hello, adding supported_elliptic_curves extension" \ - -c "client hello, adding supported_point_formats extension" \ - -s "found supported elliptic curves extension" \ - -s "found supported point formats extension" - -requires_config_enabled MBEDTLS_AES_C -requires_config_enabled MBEDTLS_CIPHER_MODE_CBC -requires_config_enabled MBEDTLS_SHA256_C -requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -run_test "Force an ECC ciphersuite in the server side" \ - "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ - "$P_CLI debug_level=3" \ - 0 \ - -c "found supported_point_formats extension" \ - -s "server hello, supported_point_formats extension" + -c "16384 bytes written in $(fragments_for_write 16384) fragments" \ + -s "Read from client: $MAX_CONTENT_LEN bytes read" # Test for large server packets requires_config_enabled MBEDTLS_SSL_PROTO_SSL3 @@ -4880,44 +5145,577 @@ run_test "Large server packet TLS 1.2 AEAD shorter tag" \ 0 \ -c "Read from server: 16384 bytes read" -# Tests for DTLS HelloVerifyRequest +# Tests for restartable ECC -run_test "DTLS cookie: enabled" \ - "$P_SRV dtls=1 debug_level=2" \ - "$P_CLI dtls=1 debug_level=2" \ +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, default" \ + "$P_SRV auth_mode=required" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1" \ 0 \ - -s "cookie verification failed" \ - -s "cookie verification passed" \ - -S "cookie verification skipped" \ - -c "received hello verify request" \ - -s "hello verification requested" \ - -S "SSL - The requested feature is not available" + -C "x509_verify_cert.*4b00" \ + -C "mbedtls_pk_verify.*4b00" \ + -C "mbedtls_ecdh_make_public.*4b00" \ + -C "mbedtls_pk_sign.*4b00" -run_test "DTLS cookie: disabled" \ - "$P_SRV dtls=1 debug_level=2 cookies=0" \ - "$P_CLI dtls=1 debug_level=2" \ +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=0" \ + "$P_SRV auth_mode=required" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1 ec_max_ops=0" \ 0 \ - -S "cookie verification failed" \ - -S "cookie verification passed" \ - -s "cookie verification skipped" \ - -C "received hello verify request" \ - -S "hello verification requested" \ - -S "SSL - The requested feature is not available" + -C "x509_verify_cert.*4b00" \ + -C "mbedtls_pk_verify.*4b00" \ + -C "mbedtls_ecdh_make_public.*4b00" \ + -C "mbedtls_pk_sign.*4b00" -run_test "DTLS cookie: default (failing)" \ - "$P_SRV dtls=1 debug_level=2 cookies=-1" \ - "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \ - 1 \ - -s "cookie verification failed" \ - -S "cookie verification passed" \ - -S "cookie verification skipped" \ - -C "received hello verify request" \ - -S "hello verification requested" \ - -s "SSL - The requested feature is not available" +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=65535" \ + "$P_SRV auth_mode=required" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1 ec_max_ops=65535" \ + 0 \ + -C "x509_verify_cert.*4b00" \ + -C "mbedtls_pk_verify.*4b00" \ + -C "mbedtls_ecdh_make_public.*4b00" \ + -C "mbedtls_pk_sign.*4b00" -requires_ipv6 -run_test "DTLS cookie: enabled, IPv6" \ - "$P_SRV dtls=1 debug_level=2 server_addr=::1" \ +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=1000" \ + "$P_SRV auth_mode=required" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1 ec_max_ops=1000" \ + 0 \ + -c "x509_verify_cert.*4b00" \ + -c "mbedtls_pk_verify.*4b00" \ + -c "mbedtls_ecdh_make_public.*4b00" \ + -c "mbedtls_pk_sign.*4b00" + +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=1000, badsign" \ + "$P_SRV auth_mode=required \ + crt_file=data_files/server5-badsign.crt \ + key_file=data_files/server5.key" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1 ec_max_ops=1000" \ + 1 \ + -c "x509_verify_cert.*4b00" \ + -C "mbedtls_pk_verify.*4b00" \ + -C "mbedtls_ecdh_make_public.*4b00" \ + -C "mbedtls_pk_sign.*4b00" \ + -c "! The certificate is not correctly signed by the trusted CA" \ + -c "! mbedtls_ssl_handshake returned" \ + -c "X509 - Certificate verification failed" + +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=1000, auth_mode=optional badsign" \ + "$P_SRV auth_mode=required \ + crt_file=data_files/server5-badsign.crt \ + key_file=data_files/server5.key" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1 ec_max_ops=1000 auth_mode=optional" \ + 0 \ + -c "x509_verify_cert.*4b00" \ + -c "mbedtls_pk_verify.*4b00" \ + -c "mbedtls_ecdh_make_public.*4b00" \ + -c "mbedtls_pk_sign.*4b00" \ + -c "! The certificate is not correctly signed by the trusted CA" \ + -C "! mbedtls_ssl_handshake returned" \ + -C "X509 - Certificate verification failed" + +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=1000, auth_mode=none badsign" \ + "$P_SRV auth_mode=required \ + crt_file=data_files/server5-badsign.crt \ + key_file=data_files/server5.key" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + debug_level=1 ec_max_ops=1000 auth_mode=none" \ + 0 \ + -C "x509_verify_cert.*4b00" \ + -c "mbedtls_pk_verify.*4b00" \ + -c "mbedtls_ecdh_make_public.*4b00" \ + -c "mbedtls_pk_sign.*4b00" \ + -C "! The certificate is not correctly signed by the trusted CA" \ + -C "! mbedtls_ssl_handshake returned" \ + -C "X509 - Certificate verification failed" + +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: DTLS, max_ops=1000" \ + "$P_SRV auth_mode=required dtls=1" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + dtls=1 debug_level=1 ec_max_ops=1000" \ + 0 \ + -c "x509_verify_cert.*4b00" \ + -c "mbedtls_pk_verify.*4b00" \ + -c "mbedtls_ecdh_make_public.*4b00" \ + -c "mbedtls_pk_sign.*4b00" + +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=1000 no client auth" \ + "$P_SRV" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + debug_level=1 ec_max_ops=1000" \ + 0 \ + -c "x509_verify_cert.*4b00" \ + -c "mbedtls_pk_verify.*4b00" \ + -c "mbedtls_ecdh_make_public.*4b00" \ + -C "mbedtls_pk_sign.*4b00" + +requires_config_enabled MBEDTLS_ECP_RESTARTABLE +run_test "EC restart: TLS, max_ops=1000, ECDHE-PSK" \ + "$P_SRV psk=abc123" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-PSK-WITH-AES-128-CBC-SHA256 \ + psk=abc123 debug_level=1 ec_max_ops=1000" \ + 0 \ + -C "x509_verify_cert.*4b00" \ + -C "mbedtls_pk_verify.*4b00" \ + -C "mbedtls_ecdh_make_public.*4b00" \ + -C "mbedtls_pk_sign.*4b00" + +# Tests of asynchronous private key support in SSL + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, delay=0" \ + "$P_SRV \ + async_operations=s async_private_delay1=0 async_private_delay2=0" \ + "$P_CLI" \ + 0 \ + -s "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): sign done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, delay=1" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1" \ + "$P_CLI" \ + 0 \ + -s "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): call 0 more times." \ + -s "Async resume (slot [0-9]): sign done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, delay=2" \ + "$P_SRV \ + async_operations=s async_private_delay1=2 async_private_delay2=2" \ + "$P_CLI" \ + 0 \ + -s "Async sign callback: using key slot " \ + -U "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): call 1 more times." \ + -s "Async resume (slot [0-9]): call 0 more times." \ + -s "Async resume (slot [0-9]): sign done, status=0" + +# Test that the async callback correctly signs the 36-byte hash of TLS 1.0/1.1 +# with RSA PKCS#1v1.5 as used in TLS 1.0/1.1. +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +run_test "SSL async private: sign, RSA, TLS 1.1" \ + "$P_SRV key_file=data_files/server2.key crt_file=data_files/server2.crt \ + async_operations=s async_private_delay1=0 async_private_delay2=0" \ + "$P_CLI force_version=tls1_1" \ + 0 \ + -s "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): sign done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, SNI" \ + "$P_SRV debug_level=3 \ + async_operations=s async_private_delay1=0 async_private_delay2=0 \ + crt_file=data_files/server5.crt key_file=data_files/server5.key \ + sni=localhost,data_files/server2.crt,data_files/server2.key,-,-,-,polarssl.example,data_files/server1-nospace.crt,data_files/server1.key,-,-,-" \ + "$P_CLI server_name=polarssl.example" \ + 0 \ + -s "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): sign done, status=0" \ + -s "parse ServerName extension" \ + -c "issuer name *: C=NL, O=PolarSSL, CN=PolarSSL Test CA" \ + -c "subject name *: C=NL, O=PolarSSL, CN=polarssl.example" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt, delay=0" \ + "$P_SRV \ + async_operations=d async_private_delay1=0 async_private_delay2=0" \ + "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 0 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume (slot [0-9]): decrypt done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt, delay=1" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1" \ + "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 0 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume (slot [0-9]): call 0 more times." \ + -s "Async resume (slot [0-9]): decrypt done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt RSA-PSK, delay=0" \ + "$P_SRV psk=abc123 \ + async_operations=d async_private_delay1=0 async_private_delay2=0" \ + "$P_CLI psk=abc123 \ + force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume (slot [0-9]): decrypt done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt RSA-PSK, delay=1" \ + "$P_SRV psk=abc123 \ + async_operations=d async_private_delay1=1 async_private_delay2=1" \ + "$P_CLI psk=abc123 \ + force_ciphersuite=TLS-RSA-PSK-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume (slot [0-9]): call 0 more times." \ + -s "Async resume (slot [0-9]): decrypt done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign callback not present" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1" \ + "$P_CLI; [ \$? -eq 1 ] && + $P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 0 \ + -S "Async sign callback" \ + -s "! mbedtls_ssl_handshake returned" \ + -s "The own private key or pre-shared key is not set, but needed" \ + -s "Async resume (slot [0-9]): decrypt done, status=0" \ + -s "Successful connection" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt callback not present" \ + "$P_SRV debug_level=1 \ + async_operations=s async_private_delay1=1 async_private_delay2=1" \ + "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA; + [ \$? -eq 1 ] && $P_CLI" \ + 0 \ + -S "Async decrypt callback" \ + -s "! mbedtls_ssl_handshake returned" \ + -s "got no RSA private key" \ + -s "Async resume (slot [0-9]): sign done, status=0" \ + -s "Successful connection" + +# key1: ECDSA, key2: RSA; use key1 from slot 0 +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: slot 0 used with key1" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async sign callback: using key slot 0," \ + -s "Async resume (slot 0): call 0 more times." \ + -s "Async resume (slot 0): sign done, status=0" + +# key1: ECDSA, key2: RSA; use key2 from slot 0 +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: slot 0 used with key2" \ + "$P_SRV \ + async_operations=s async_private_delay2=1 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async sign callback: using key slot 0," \ + -s "Async resume (slot 0): call 0 more times." \ + -s "Async resume (slot 0): sign done, status=0" + +# key1: ECDSA, key2: RSA; use key2 from slot 1 +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: slot 1 used with key2" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async sign callback: using key slot 1," \ + -s "Async resume (slot 1): call 0 more times." \ + -s "Async resume (slot 1): sign done, status=0" + +# key1: ECDSA, key2: RSA; use key2 directly +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: fall back to transparent key" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + key_file2=data_files/server2.key crt_file2=data_files/server2.crt " \ + "$P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async sign callback: no key matches this certificate." + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, error in start" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + async_private_error=1" \ + "$P_CLI" \ + 1 \ + -s "Async sign callback: injected error" \ + -S "Async resume" \ + -S "Async cancel" \ + -s "! mbedtls_ssl_handshake returned" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, cancel after start" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + async_private_error=2" \ + "$P_CLI" \ + 1 \ + -s "Async sign callback: using key slot " \ + -S "Async resume" \ + -s "Async cancel" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, error in resume" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + async_private_error=3" \ + "$P_CLI" \ + 1 \ + -s "Async sign callback: using key slot " \ + -s "Async resume callback: sign done but injected error" \ + -S "Async cancel" \ + -s "! mbedtls_ssl_handshake returned" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt, error in start" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1 \ + async_private_error=1" \ + "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 1 \ + -s "Async decrypt callback: injected error" \ + -S "Async resume" \ + -S "Async cancel" \ + -s "! mbedtls_ssl_handshake returned" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt, cancel after start" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1 \ + async_private_error=2" \ + "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 1 \ + -s "Async decrypt callback: using key slot " \ + -S "Async resume" \ + -s "Async cancel" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: decrypt, error in resume" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1 \ + async_private_error=3" \ + "$P_CLI force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 1 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume callback: decrypt done but injected error" \ + -S "Async cancel" \ + -s "! mbedtls_ssl_handshake returned" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: cancel after start then operate correctly" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + async_private_error=-2" \ + "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \ + 0 \ + -s "Async cancel" \ + -s "! mbedtls_ssl_handshake returned" \ + -s "Async resume" \ + -s "Successful connection" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: error in resume then operate correctly" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + async_private_error=-3" \ + "$P_CLI; [ \$? -eq 1 ] && $P_CLI" \ + 0 \ + -s "! mbedtls_ssl_handshake returned" \ + -s "Async resume" \ + -s "Successful connection" + +# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: cancel after start then fall back to transparent key" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_error=-2 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256; + [ \$? -eq 1 ] && + $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async sign callback: using key slot 0" \ + -S "Async resume" \ + -s "Async cancel" \ + -s "! mbedtls_ssl_handshake returned" \ + -s "Async sign callback: no key matches this certificate." \ + -s "Successful connection" + +# key1: ECDSA, key2: RSA; use key1 through async, then key2 directly +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +run_test "SSL async private: sign, error in resume then fall back to transparent key" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_error=-3 \ + key_file=data_files/server5.key crt_file=data_files/server5.crt \ + key_file2=data_files/server2.key crt_file2=data_files/server2.crt" \ + "$P_CLI force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256; + [ \$? -eq 1 ] && + $P_CLI force_ciphersuite=TLS-ECDHE-RSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -s "Async resume" \ + -s "! mbedtls_ssl_handshake returned" \ + -s "Async sign callback: no key matches this certificate." \ + -s "Successful connection" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +run_test "SSL async private: renegotiation: client-initiated; sign" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + exchanges=2 renegotiation=1" \ + "$P_CLI exchanges=2 renegotiation=1 renegotiate=1" \ + 0 \ + -s "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): sign done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +run_test "SSL async private: renegotiation: server-initiated; sign" \ + "$P_SRV \ + async_operations=s async_private_delay1=1 async_private_delay2=1 \ + exchanges=2 renegotiation=1 renegotiate=1" \ + "$P_CLI exchanges=2 renegotiation=1" \ + 0 \ + -s "Async sign callback: using key slot " \ + -s "Async resume (slot [0-9]): sign done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +run_test "SSL async private: renegotiation: client-initiated; decrypt" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1 \ + exchanges=2 renegotiation=1" \ + "$P_CLI exchanges=2 renegotiation=1 renegotiate=1 \ + force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 0 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume (slot [0-9]): decrypt done, status=0" + +requires_config_enabled MBEDTLS_SSL_ASYNC_PRIVATE +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +run_test "SSL async private: renegotiation: server-initiated; decrypt" \ + "$P_SRV \ + async_operations=d async_private_delay1=1 async_private_delay2=1 \ + exchanges=2 renegotiation=1 renegotiate=1" \ + "$P_CLI exchanges=2 renegotiation=1 \ + force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ + 0 \ + -s "Async decrypt callback: using key slot " \ + -s "Async resume (slot [0-9]): decrypt done, status=0" + +# Tests for ECC extensions (rfc 4492) + +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CIPHER_MODE_CBC +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +run_test "Force a non ECC ciphersuite in the client side" \ + "$P_SRV debug_level=3" \ + "$P_CLI debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -C "client hello, adding supported_elliptic_curves extension" \ + -C "client hello, adding supported_point_formats extension" \ + -S "found supported elliptic curves extension" \ + -S "found supported point formats extension" + +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CIPHER_MODE_CBC +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_RSA_ENABLED +run_test "Force a non ECC ciphersuite in the server side" \ + "$P_SRV debug_level=3 force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA256" \ + "$P_CLI debug_level=3" \ + 0 \ + -C "found supported_point_formats extension" \ + -S "server hello, supported_point_formats extension" + +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CIPHER_MODE_CBC +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +run_test "Force an ECC ciphersuite in the client side" \ + "$P_SRV debug_level=3" \ + "$P_CLI debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ + 0 \ + -c "client hello, adding supported_elliptic_curves extension" \ + -c "client hello, adding supported_point_formats extension" \ + -s "found supported elliptic curves extension" \ + -s "found supported point formats extension" + +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CIPHER_MODE_CBC +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED +run_test "Force an ECC ciphersuite in the server side" \ + "$P_SRV debug_level=3 force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256" \ + "$P_CLI debug_level=3" \ + 0 \ + -c "found supported_point_formats extension" \ + -s "server hello, supported_point_formats extension" + +# Tests for DTLS HelloVerifyRequest + +run_test "DTLS cookie: enabled" \ + "$P_SRV dtls=1 debug_level=2" \ + "$P_CLI dtls=1 debug_level=2" \ + 0 \ + -s "cookie verification failed" \ + -s "cookie verification passed" \ + -S "cookie verification skipped" \ + -c "received hello verify request" \ + -s "hello verification requested" \ + -S "SSL - The requested feature is not available" + +run_test "DTLS cookie: disabled" \ + "$P_SRV dtls=1 debug_level=2 cookies=0" \ + "$P_CLI dtls=1 debug_level=2" \ + 0 \ + -S "cookie verification failed" \ + -S "cookie verification passed" \ + -s "cookie verification skipped" \ + -C "received hello verify request" \ + -S "hello verification requested" \ + -S "SSL - The requested feature is not available" + +run_test "DTLS cookie: default (failing)" \ + "$P_SRV dtls=1 debug_level=2 cookies=-1" \ + "$P_CLI dtls=1 debug_level=2 hs_timeout=100-400" \ + 1 \ + -s "cookie verification failed" \ + -S "cookie verification passed" \ + -S "cookie verification skipped" \ + -C "received hello verify request" \ + -S "hello verification requested" \ + -s "SSL - The requested feature is not available" + +requires_ipv6 +run_test "DTLS cookie: enabled, IPv6" \ + "$P_SRV dtls=1 debug_level=2 server_addr=::1" \ "$P_CLI dtls=1 debug_level=2 server_addr=::1" \ 0 \ -s "cookie verification failed" \ @@ -5100,6 +5898,951 @@ run_test "DTLS reassembly: fragmentation, nbio (openssl server)" \ -c "found fragmented DTLS handshake message" \ -C "error" +# Tests for sending fragmented handshake messages with DTLS +# +# Use client auth when we need the client to send large messages, +# and use large cert chains on both sides too (the long chains we have all use +# both RSA and ECDSA, but ideally we should have long chains with either). +# Sizes reached (UDP payload): +# - 2037B for server certificate +# - 1542B for client certificate +# - 1013B for newsessionticket +# - all others below 512B +# All those tests assume MAX_CONTENT_LEN is at least 2048 + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: none (for reference)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=4096" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=4096" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -C "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: server only (max_frag_len)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=1024" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=2048" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# With the MFL extension, the server has no way of forcing +# the client to not exceed a certain MTU; hence, the following +# test can't be replicated with an MTU proxy such as the one +# `client-initiated, server only (max_frag_len)` below. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: server only (more) (max_frag_len)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=512" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=4096" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: client-initiated, server only (max_frag_len)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=none \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=2048" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=1024" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# While not required by the standard defining the MFL extension +# (according to which it only applies to records, not to datagrams), +# Mbed TLS will never send datagrams larger than MFL + { Max record expansion }, +# as otherwise there wouldn't be any means to communicate MTU restrictions +# to the peer. +# The next test checks that no datagrams significantly larger than the +# negotiated MFL are sent. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: client-initiated, server only (max_frag_len), proxy MTU" \ + -p "$P_PXY mtu=1110" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=none \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=2048" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=1024" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: client-initiated, both (max_frag_len)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=2048" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=1024" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# While not required by the standard defining the MFL extension +# (according to which it only applies to records, not to datagrams), +# Mbed TLS will never send datagrams larger than MFL + { Max record expansion }, +# as otherwise there wouldn't be any means to communicate MTU restrictions +# to the peer. +# The next test checks that no datagrams significantly larger than the +# negotiated MFL are sent. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH +run_test "DTLS fragmenting: client-initiated, both (max_frag_len), proxy MTU" \ + -p "$P_PXY mtu=1110" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + max_frag_len=2048" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + max_frag_len=1024" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +run_test "DTLS fragmenting: none (for reference) (MTU)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + mtu=4096" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + mtu=4096" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -C "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +run_test "DTLS fragmenting: client (MTU)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=3500-60000 \ + mtu=4096" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=3500-60000 \ + mtu=1024" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -C "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +run_test "DTLS fragmenting: server (MTU)" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + mtu=512" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + mtu=2048" \ + 0 \ + -S "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +run_test "DTLS fragmenting: both (MTU=1024)" \ + -p "$P_PXY mtu=1024" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + mtu=1024" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=2500-60000 \ + mtu=1024" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 512 with full config. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: both (MTU=512)" \ + -p "$P_PXY mtu=512" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=2500-60000 \ + mtu=512" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=2500-60000 \ + mtu=512" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Test for automatic MTU reduction on repeated resend. +# Forcing ciphersuite for this test to fit the MTU of 508 with full config. +# The ratio of max/min timeout should ideally equal 4 to accept two +# retransmissions, but in some cases (like both the server and client using +# fragmentation and auto-reduction) an extra retransmission might occur, +# hence the ratio of 8. +not_with_valgrind +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: proxy MTU: auto-reduction" \ + -p "$P_PXY mtu=508" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=400-3200" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=400-3200" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 508 with full config. +only_with_valgrind +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: proxy MTU: auto-reduction" \ + -p "$P_PXY mtu=508" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-10000" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=250-10000" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend +# OTOH the client might resend if the server is to slow to reset after sending +# a HelloVerifyRequest, so only check for no retransmission server-side +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=1024)" \ + -p "$P_PXY mtu=1024" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=10000-60000 \ + mtu=1024" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=10000-60000 \ + mtu=1024" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 512 with full config. +# the proxy shouldn't drop or mess up anything, so we shouldn't need to resend +# OTOH the client might resend if the server is to slow to reset after sending +# a HelloVerifyRequest, so only check for no retransmission server-side +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: proxy MTU, simple handshake (MTU=512)" \ + -p "$P_PXY mtu=512" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=10000-60000 \ + mtu=512" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=10000-60000 \ + mtu=512" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=1024)" \ + -p "$P_PXY mtu=1024" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=10000-60000 \ + mtu=1024 nbio=2" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=10000-60000 \ + mtu=1024 nbio=2" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 512 with full config. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: proxy MTU, simple handshake, nbio (MTU=512)" \ + -p "$P_PXY mtu=512" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=10000-60000 \ + mtu=512 nbio=2" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=10000-60000 \ + mtu=512 nbio=2" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 1450 with full config. +# This ensures things still work after session_reset(). +# It also exercises the "resumed handshake" flow. +# Since we don't support reading fragmented ClientHello yet, +# up the MTU to 1450 (larger than ClientHello with session ticket, +# but still smaller than client's Certificate to ensure fragmentation). +# An autoreduction on the client-side might happen if the server is +# slow to reset, therefore omitting '-C "autoreduction"' below. +# reco_delay avoids races where the client reconnects before the server has +# resumed listening, which would result in a spurious autoreduction. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: proxy MTU, resumed handshake" \ + -p "$P_PXY mtu=1450" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=10000-60000 \ + mtu=1450" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=10000-60000 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + mtu=1450 reconnect=1 reco_delay=1" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# An autoreduction on the client-side might happen if the server is +# slow to reset, therefore omitting '-C "autoreduction"' below. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +requires_config_enabled MBEDTLS_CHACHAPOLY_C +run_test "DTLS fragmenting: proxy MTU, ChachaPoly renego" \ + -p "$P_PXY mtu=512" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + exchanges=2 renegotiation=1 \ + hs_timeout=10000-60000 \ + mtu=512" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + exchanges=2 renegotiation=1 renegotiate=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=10000-60000 \ + mtu=512" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# An autoreduction on the client-side might happen if the server is +# slow to reset, therefore omitting '-C "autoreduction"' below. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +run_test "DTLS fragmenting: proxy MTU, AES-GCM renego" \ + -p "$P_PXY mtu=512" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + exchanges=2 renegotiation=1 \ + hs_timeout=10000-60000 \ + mtu=512" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + exchanges=2 renegotiation=1 renegotiate=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=10000-60000 \ + mtu=512" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# An autoreduction on the client-side might happen if the server is +# slow to reset, therefore omitting '-C "autoreduction"' below. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CCM_C +run_test "DTLS fragmenting: proxy MTU, AES-CCM renego" \ + -p "$P_PXY mtu=1024" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + exchanges=2 renegotiation=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CCM-8 \ + hs_timeout=10000-60000 \ + mtu=1024" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + exchanges=2 renegotiation=1 renegotiate=1 \ + hs_timeout=10000-60000 \ + mtu=1024" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# An autoreduction on the client-side might happen if the server is +# slow to reset, therefore omitting '-C "autoreduction"' below. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CIPHER_MODE_CBC +requires_config_enabled MBEDTLS_SSL_ENCRYPT_THEN_MAC +run_test "DTLS fragmenting: proxy MTU, AES-CBC EtM renego" \ + -p "$P_PXY mtu=1024" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + exchanges=2 renegotiation=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 \ + hs_timeout=10000-60000 \ + mtu=1024" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + exchanges=2 renegotiation=1 renegotiate=1 \ + hs_timeout=10000-60000 \ + mtu=1024" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# An autoreduction on the client-side might happen if the server is +# slow to reset, therefore omitting '-C "autoreduction"' below. +not_with_valgrind # spurious autoreduction due to timeout +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SHA256_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_SSL_RENEGOTIATION +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_CIPHER_MODE_CBC +run_test "DTLS fragmenting: proxy MTU, AES-CBC non-EtM renego" \ + -p "$P_PXY mtu=1024" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + exchanges=2 renegotiation=1 \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256 etm=0 \ + hs_timeout=10000-60000 \ + mtu=1024" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + exchanges=2 renegotiation=1 renegotiate=1 \ + hs_timeout=10000-60000 \ + mtu=1024" \ + 0 \ + -S "autoreduction" \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 512 with full config. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +client_needs_more_time 2 +run_test "DTLS fragmenting: proxy MTU + 3d" \ + -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \ + "$P_SRV dgram_packing=0 dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-10000 mtu=512" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=250-10000 mtu=512" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# Forcing ciphersuite for this test to fit the MTU of 512 with full config. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA +requires_config_enabled MBEDTLS_AES_C +requires_config_enabled MBEDTLS_GCM_C +client_needs_more_time 2 +run_test "DTLS fragmenting: proxy MTU + 3d, nbio" \ + -p "$P_PXY mtu=512 drop=8 delay=8 duplicate=8" \ + "$P_SRV dtls=1 debug_level=2 auth_mode=required \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-10000 mtu=512 nbio=2" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + force_ciphersuite=TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256 \ + hs_timeout=250-10000 mtu=512 nbio=2" \ + 0 \ + -s "found fragmented DTLS handshake message" \ + -c "found fragmented DTLS handshake message" \ + -C "error" + +# interop tests for DTLS fragmentating with reliable connection +# +# here and below we just want to test that the we fragment in a way that +# pleases other implementations, so we don't need the peer to fragment +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +requires_gnutls +run_test "DTLS fragmenting: gnutls server, DTLS 1.2" \ + "$G_SRV -u" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + mtu=512 force_version=dtls1_2" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +requires_gnutls +run_test "DTLS fragmenting: gnutls server, DTLS 1.0" \ + "$G_SRV -u" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + mtu=512 force_version=dtls1" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +# We use --insecure for the GnuTLS client because it expects +# the hostname / IP it connects to to be the name used in the +# certificate obtained from the server. Here, however, it +# connects to 127.0.0.1 while our test certificates use 'localhost' +# as the server name in the certificate. This will make the +# certifiate validation fail, but passing --insecure makes +# GnuTLS continue the connection nonetheless. +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +requires_gnutls +requires_not_i686 +run_test "DTLS fragmenting: gnutls client, DTLS 1.2" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + mtu=512 force_version=dtls1_2" \ + "$G_CLI -u --insecure 127.0.0.1" \ + 0 \ + -s "fragmenting handshake message" + +# See previous test for the reason to use --insecure +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +requires_gnutls +requires_not_i686 +run_test "DTLS fragmenting: gnutls client, DTLS 1.0" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + mtu=512 force_version=dtls1" \ + "$G_CLI -u --insecure 127.0.0.1" \ + 0 \ + -s "fragmenting handshake message" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +run_test "DTLS fragmenting: openssl server, DTLS 1.2" \ + "$O_SRV -dtls1_2 -verify 10" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + mtu=512 force_version=dtls1_2" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +run_test "DTLS fragmenting: openssl server, DTLS 1.0" \ + "$O_SRV -dtls1 -verify 10" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + mtu=512 force_version=dtls1" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +run_test "DTLS fragmenting: openssl client, DTLS 1.2" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + mtu=512 force_version=dtls1_2" \ + "$O_CLI -dtls1_2" \ + 0 \ + -s "fragmenting handshake message" + +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +run_test "DTLS fragmenting: openssl client, DTLS 1.0" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + mtu=512 force_version=dtls1" \ + "$O_CLI -dtls1" \ + 0 \ + -s "fragmenting handshake message" + +# interop tests for DTLS fragmentating with unreliable connection +# +# again we just want to test that the we fragment in a way that +# pleases other implementations, so we don't need the peer to fragment +requires_gnutls_next +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.2" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$G_NEXT_SRV -u" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +requires_gnutls_next +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, gnutls server, DTLS 1.0" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$G_NEXT_SRV -u" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +requires_gnutls_next +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.2" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \ + "$G_NEXT_CLI -u --insecure 127.0.0.1" \ + 0 \ + -s "fragmenting handshake message" + +requires_gnutls_next +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, gnutls client, DTLS 1.0" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1" \ + "$G_NEXT_CLI -u --insecure 127.0.0.1" \ + 0 \ + -s "fragmenting handshake message" + +## Interop test with OpenSSL might trigger a bug in recent versions (including +## all versions installed on the CI machines), reported here: +## Bug report: https://github.com/openssl/openssl/issues/6902 +## They should be re-enabled once a fixed version of OpenSSL is available +## (this should happen in some 1.1.1_ release according to the ticket). +skip_next_test +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.2" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$O_SRV -dtls1_2 -verify 10" \ + "$P_CLI dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +skip_next_test +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, openssl server, DTLS 1.0" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$O_SRV -dtls1 -verify 10" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + crt_file=data_files/server8_int-ca2.crt \ + key_file=data_files/server8.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1" \ + 0 \ + -c "fragmenting handshake message" \ + -C "error" + +skip_next_test +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.2" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$P_SRV dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1_2" \ + "$O_CLI -dtls1_2" \ + 0 \ + -s "fragmenting handshake message" + +# -nbio is added to prevent s_client from blocking in case of duplicated +# messages at the end of the handshake +skip_next_test +requires_config_enabled MBEDTLS_SSL_PROTO_DTLS +requires_config_enabled MBEDTLS_RSA_C +requires_config_enabled MBEDTLS_ECDSA_C +requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_1 +client_needs_more_time 4 +run_test "DTLS fragmenting: 3d, openssl client, DTLS 1.0" \ + -p "$P_PXY drop=8 delay=8 duplicate=8" \ + "$P_SRV dgram_packing=0 dtls=1 debug_level=2 \ + crt_file=data_files/server7_int-ca.crt \ + key_file=data_files/server7.key \ + hs_timeout=250-60000 mtu=512 force_version=dtls1" \ + "$O_CLI -nbio -dtls1" \ + 0 \ + -s "fragmenting handshake message" + # Tests for specific things with "unreliable" UDP connection not_with_valgrind # spurious resend due to timeout @@ -5121,35 +6864,51 @@ run_test "DTLS proxy: reference" \ not_with_valgrind # spurious resend due to timeout run_test "DTLS proxy: duplicate every packet" \ -p "$P_PXY duplicate=1" \ - "$P_SRV dtls=1 debug_level=2" \ - "$P_CLI dtls=1 debug_level=2" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 0 \ -c "replayed record" \ -s "replayed record" \ - -c "discarding invalid record" \ - -s "discarding invalid record" \ + -c "record from another epoch" \ + -s "record from another epoch" \ -S "resend" \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" run_test "DTLS proxy: duplicate every packet, server anti-replay off" \ -p "$P_PXY duplicate=1" \ - "$P_SRV dtls=1 debug_level=2 anti_replay=0" \ - "$P_CLI dtls=1 debug_level=2" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=2 anti_replay=0" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ 0 \ -c "replayed record" \ -S "replayed record" \ - -c "discarding invalid record" \ - -s "discarding invalid record" \ + -c "record from another epoch" \ + -s "record from another epoch" \ -c "resend" \ -s "resend" \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" +run_test "DTLS proxy: multiple records in same datagram" \ + -p "$P_PXY pack=50" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ + 0 \ + -c "next record in same datagram" \ + -s "next record in same datagram" + +run_test "DTLS proxy: multiple records in same datagram, duplicate every packet" \ + -p "$P_PXY pack=50 duplicate=1" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=2" \ + 0 \ + -c "next record in same datagram" \ + -s "next record in same datagram" + run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \ -p "$P_PXY bad_ad=1" \ - "$P_SRV dtls=1 debug_level=1" \ - "$P_CLI dtls=1 debug_level=1 read_timeout=100" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=1" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \ 0 \ -c "discarding invalid record (mac)" \ -s "discarding invalid record (mac)" \ @@ -5160,8 +6919,8 @@ run_test "DTLS proxy: inject invalid AD record, default badmac_limit" \ run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \ -p "$P_PXY bad_ad=1" \ - "$P_SRV dtls=1 debug_level=1 badmac_limit=1" \ - "$P_CLI dtls=1 debug_level=1 read_timeout=100" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=1" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \ 1 \ -C "discarding invalid record (mac)" \ -S "discarding invalid record (mac)" \ @@ -5172,8 +6931,8 @@ run_test "DTLS proxy: inject invalid AD record, badmac_limit 1" \ run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \ -p "$P_PXY bad_ad=1" \ - "$P_SRV dtls=1 debug_level=1 badmac_limit=2" \ - "$P_CLI dtls=1 debug_level=1 read_timeout=100" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100" \ 0 \ -c "discarding invalid record (mac)" \ -s "discarding invalid record (mac)" \ @@ -5184,8 +6943,8 @@ run_test "DTLS proxy: inject invalid AD record, badmac_limit 2" \ run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\ -p "$P_PXY bad_ad=1" \ - "$P_SRV dtls=1 debug_level=1 badmac_limit=2 exchanges=2" \ - "$P_CLI dtls=1 debug_level=1 read_timeout=100 exchanges=2" \ + "$P_SRV dtls=1 dgram_packing=0 debug_level=1 badmac_limit=2 exchanges=2" \ + "$P_CLI dtls=1 dgram_packing=0 debug_level=1 read_timeout=100 exchanges=2" \ 1 \ -c "discarding invalid record (mac)" \ -s "discarding invalid record (mac)" \ @@ -5196,24 +6955,190 @@ run_test "DTLS proxy: inject invalid AD record, badmac_limit 2, exchanges 2"\ run_test "DTLS proxy: delay ChangeCipherSpec" \ -p "$P_PXY delay_ccs=1" \ - "$P_SRV dtls=1 debug_level=1" \ - "$P_CLI dtls=1 debug_level=1" \ + "$P_SRV dtls=1 debug_level=1 dgram_packing=0" \ + "$P_CLI dtls=1 debug_level=1 dgram_packing=0" \ 0 \ -c "record from another epoch" \ -s "record from another epoch" \ - -c "discarding invalid record" \ - -s "discarding invalid record" \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" +# Tests for reordering support with DTLS + +run_test "DTLS reordering: Buffer out-of-order handshake message on client" \ + -p "$P_PXY delay_srv=ServerHello" \ + "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -c "Buffering HS message" \ + -c "Next handshake message has been buffered - load"\ + -S "Buffering HS message" \ + -S "Next handshake message has been buffered - load"\ + -C "Injecting buffered CCS message" \ + -C "Remember CCS message" \ + -S "Injecting buffered CCS message" \ + -S "Remember CCS message" + +run_test "DTLS reordering: Buffer out-of-order handshake message fragment on client" \ + -p "$P_PXY delay_srv=ServerHello" \ + "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -c "Buffering HS message" \ + -c "found fragmented DTLS handshake message"\ + -c "Next handshake message 1 not or only partially bufffered" \ + -c "Next handshake message has been buffered - load"\ + -S "Buffering HS message" \ + -S "Next handshake message has been buffered - load"\ + -C "Injecting buffered CCS message" \ + -C "Remember CCS message" \ + -S "Injecting buffered CCS message" \ + -S "Remember CCS message" + +# The client buffers the ServerKeyExchange before receiving the fragmented +# Certificate message; at the time of writing, together these are aroudn 1200b +# in size, so that the bound below ensures that the certificate can be reassembled +# while keeping the ServerKeyExchange. +requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1300 +run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next" \ + -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \ + "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -c "Buffering HS message" \ + -c "Next handshake message has been buffered - load"\ + -C "attempt to make space by freeing buffered messages" \ + -S "Buffering HS message" \ + -S "Next handshake message has been buffered - load"\ + -C "Injecting buffered CCS message" \ + -C "Remember CCS message" \ + -S "Injecting buffered CCS message" \ + -S "Remember CCS message" + +# The size constraints ensure that the delayed certificate message can't +# be reassembled while keeping the ServerKeyExchange message, but it can +# when dropping it first. +requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 900 +requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 1299 +run_test "DTLS reordering: Buffer out-of-order hs msg before reassembling next, free buffered msg" \ + -p "$P_PXY delay_srv=Certificate delay_srv=Certificate" \ + "$P_SRV mtu=512 dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -c "Buffering HS message" \ + -c "attempt to make space by freeing buffered future messages" \ + -c "Enough space available after freeing buffered HS messages" \ + -S "Buffering HS message" \ + -S "Next handshake message has been buffered - load"\ + -C "Injecting buffered CCS message" \ + -C "Remember CCS message" \ + -S "Injecting buffered CCS message" \ + -S "Remember CCS message" + +run_test "DTLS reordering: Buffer out-of-order handshake message on server" \ + -p "$P_PXY delay_cli=Certificate" \ + "$P_SRV dgram_packing=0 auth_mode=required cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -C "Buffering HS message" \ + -C "Next handshake message has been buffered - load"\ + -s "Buffering HS message" \ + -s "Next handshake message has been buffered - load" \ + -C "Injecting buffered CCS message" \ + -C "Remember CCS message" \ + -S "Injecting buffered CCS message" \ + -S "Remember CCS message" + +run_test "DTLS reordering: Buffer out-of-order CCS message on client"\ + -p "$P_PXY delay_srv=NewSessionTicket" \ + "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -C "Buffering HS message" \ + -C "Next handshake message has been buffered - load"\ + -S "Buffering HS message" \ + -S "Next handshake message has been buffered - load" \ + -c "Injecting buffered CCS message" \ + -c "Remember CCS message" \ + -S "Injecting buffered CCS message" \ + -S "Remember CCS message" + +run_test "DTLS reordering: Buffer out-of-order CCS message on server"\ + -p "$P_PXY delay_cli=ClientKeyExchange" \ + "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -C "Buffering HS message" \ + -C "Next handshake message has been buffered - load"\ + -S "Buffering HS message" \ + -S "Next handshake message has been buffered - load" \ + -C "Injecting buffered CCS message" \ + -C "Remember CCS message" \ + -s "Injecting buffered CCS message" \ + -s "Remember CCS message" + +run_test "DTLS reordering: Buffer encrypted Finished message" \ + -p "$P_PXY delay_ccs=1" \ + "$P_SRV dgram_packing=0 cookies=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 \ + hs_timeout=2500-60000" \ + 0 \ + -s "Buffer record from epoch 1" \ + -s "Found buffered record from current epoch - load" \ + -c "Buffer record from epoch 1" \ + -c "Found buffered record from current epoch - load" + +# In this test, both the fragmented NewSessionTicket and the ChangeCipherSpec +# from the server are delayed, so that the encrypted Finished message +# is received and buffered. When the fragmented NewSessionTicket comes +# in afterwards, the encrypted Finished message must be freed in order +# to make space for the NewSessionTicket to be reassembled. +# This works only in very particular circumstances: +# - MBEDTLS_SSL_DTLS_MAX_BUFFERING must be large enough to allow buffering +# of the NewSessionTicket, but small enough to also allow buffering of +# the encrypted Finished message. +# - The MTU setting on the server must be so small that the NewSessionTicket +# needs to be fragmented. +# - All messages sent by the server must be small enough to be either sent +# without fragmentation or be reassembled within the bounds of +# MBEDTLS_SSL_DTLS_MAX_BUFFERING. Achieve this by testing with a PSK-based +# handshake, omitting CRTs. +requires_config_value_at_least "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 240 +requires_config_value_at_most "MBEDTLS_SSL_DTLS_MAX_BUFFERING" 280 +run_test "DTLS reordering: Buffer encrypted Finished message, drop for fragmented NewSessionTicket" \ + -p "$P_PXY delay_srv=NewSessionTicket delay_srv=NewSessionTicket delay_ccs=1" \ + "$P_SRV mtu=190 dgram_packing=0 psk=abc123 psk_identity=foo cookies=0 dtls=1 debug_level=2" \ + "$P_CLI dgram_packing=0 dtls=1 debug_level=2 force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 psk=abc123 psk_identity=foo" \ + 0 \ + -s "Buffer record from epoch 1" \ + -s "Found buffered record from current epoch - load" \ + -c "Buffer record from epoch 1" \ + -C "Found buffered record from current epoch - load" \ + -c "Enough space available after freeing future epoch record" + # Tests for "randomly unreliable connection": try a variety of flows and peers client_needs_more_time 2 run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 0 \ -s "Extra-header:" \ @@ -5222,8 +7147,8 @@ run_test "DTLS proxy: 3d (drop, delay, duplicate), \"short\" PSK handshake" \ client_needs_more_time 2 run_test "DTLS proxy: 3d, \"short\" RSA handshake" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 \ force_ciphersuite=TLS-RSA-WITH-AES-128-CBC-SHA" \ 0 \ -s "Extra-header:" \ @@ -5232,8 +7157,8 @@ run_test "DTLS proxy: 3d, \"short\" RSA handshake" \ client_needs_more_time 2 run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none" \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \ 0 \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" @@ -5241,8 +7166,8 @@ run_test "DTLS proxy: 3d, \"short\" (no ticket, no cli_auth) FS handshake" \ client_needs_more_time 2 run_test "DTLS proxy: 3d, FS, client auth" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=required" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0" \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=required" \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0" \ 0 \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" @@ -5250,8 +7175,8 @@ run_test "DTLS proxy: 3d, FS, client auth" \ client_needs_more_time 2 run_test "DTLS proxy: 3d, FS, ticket" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=none" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=none" \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \ 0 \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" @@ -5259,8 +7184,8 @@ run_test "DTLS proxy: 3d, FS, ticket" \ client_needs_more_time 2 run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=1 auth_mode=required" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=1" \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1 auth_mode=required" \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=1" \ 0 \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" @@ -5268,9 +7193,9 @@ run_test "DTLS proxy: 3d, max handshake (FS, ticket + client auth)" \ client_needs_more_time 2 run_test "DTLS proxy: 3d, max handshake, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 nbio=2 tickets=1 \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1 \ auth_mode=required" \ - "$P_CLI dtls=1 hs_timeout=250-10000 nbio=2 tickets=1" \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 nbio=2 tickets=1" \ 0 \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" @@ -5278,9 +7203,9 @@ run_test "DTLS proxy: 3d, max handshake, nbio" \ client_needs_more_time 4 run_test "DTLS proxy: 3d, min handshake, resumption" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123 debug_level=3" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 0 \ @@ -5292,9 +7217,9 @@ run_test "DTLS proxy: 3d, min handshake, resumption" \ client_needs_more_time 4 run_test "DTLS proxy: 3d, min handshake, resumption, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123 debug_level=3 nbio=2" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ debug_level=3 reconnect=1 read_timeout=1000 max_resend=10 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8 nbio=2" \ 0 \ @@ -5307,9 +7232,9 @@ client_needs_more_time 4 requires_config_enabled MBEDTLS_SSL_RENEGOTIATION run_test "DTLS proxy: 3d, min handshake, client-initiated renego" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123 renegotiation=1 debug_level=2" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ renegotiate=1 debug_level=2 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 0 \ @@ -5322,9 +7247,9 @@ client_needs_more_time 4 requires_config_enabled MBEDTLS_SSL_RENEGOTIATION run_test "DTLS proxy: 3d, min handshake, client-initiated renego, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123 renegotiation=1 debug_level=2" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ renegotiate=1 debug_level=2 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 0 \ @@ -5337,10 +7262,10 @@ client_needs_more_time 4 requires_config_enabled MBEDTLS_SSL_RENEGOTIATION run_test "DTLS proxy: 3d, min handshake, server-initiated renego" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \ debug_level=2" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ renegotiation=1 exchanges=4 debug_level=2 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 0 \ @@ -5353,10 +7278,10 @@ client_needs_more_time 4 requires_config_enabled MBEDTLS_SSL_RENEGOTIATION run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$P_SRV dtls=1 hs_timeout=250-10000 tickets=0 auth_mode=none \ + "$P_SRV dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 auth_mode=none \ psk=abc123 renegotiate=1 renegotiation=1 exchanges=4 \ debug_level=2 nbio=2" \ - "$P_CLI dtls=1 hs_timeout=250-10000 tickets=0 psk=abc123 \ + "$P_CLI dtls=1 dgram_packing=0 hs_timeout=500-10000 tickets=0 psk=abc123 \ renegotiation=1 exchanges=4 debug_level=2 nbio=2 \ force_ciphersuite=TLS-PSK-WITH-AES-128-CCM-8" \ 0 \ @@ -5365,30 +7290,38 @@ run_test "DTLS proxy: 3d, min handshake, server-initiated renego, nbio" \ -s "Extra-header:" \ -c "HTTP/1.0 200 OK" +## Interop tests with OpenSSL might trigger a bug in recent versions (including +## all versions installed on the CI machines), reported here: +## Bug report: https://github.com/openssl/openssl/issues/6902 +## They should be re-enabled once a fixed version of OpenSSL is available +## (this should happen in some 1.1.1_ release according to the ticket). +skip_next_test client_needs_more_time 6 not_with_valgrind # risk of non-mbedtls peer timing out run_test "DTLS proxy: 3d, openssl server" \ -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \ "$O_SRV -dtls1 -mtu 2048" \ - "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \ + "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \ 0 \ -c "HTTP/1.0 200 OK" +skip_next_test # see above client_needs_more_time 8 not_with_valgrind # risk of non-mbedtls peer timing out run_test "DTLS proxy: 3d, openssl server, fragmentation" \ -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \ "$O_SRV -dtls1 -mtu 768" \ - "$P_CLI dtls=1 hs_timeout=250-60000 tickets=0" \ + "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 tickets=0" \ 0 \ -c "HTTP/1.0 200 OK" +skip_next_test # see above client_needs_more_time 8 not_with_valgrind # risk of non-mbedtls peer timing out run_test "DTLS proxy: 3d, openssl server, fragmentation, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5 protect_hvr=1" \ "$O_SRV -dtls1 -mtu 768" \ - "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2 tickets=0" \ + "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2 tickets=0" \ 0 \ -c "HTTP/1.0 200 OK" @@ -5398,29 +7331,29 @@ not_with_valgrind # risk of non-mbedtls peer timing out run_test "DTLS proxy: 3d, gnutls server" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ "$G_SRV -u --mtu 2048 -a" \ - "$P_CLI dtls=1 hs_timeout=250-60000" \ + "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \ 0 \ -s "Extra-header:" \ -c "Extra-header:" -requires_gnutls +requires_gnutls_next client_needs_more_time 8 not_with_valgrind # risk of non-mbedtls peer timing out run_test "DTLS proxy: 3d, gnutls server, fragmentation" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$G_SRV -u --mtu 512" \ - "$P_CLI dtls=1 hs_timeout=250-60000" \ + "$G_NEXT_SRV -u --mtu 512" \ + "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000" \ 0 \ -s "Extra-header:" \ -c "Extra-header:" -requires_gnutls +requires_gnutls_next client_needs_more_time 8 not_with_valgrind # risk of non-mbedtls peer timing out run_test "DTLS proxy: 3d, gnutls server, fragmentation, nbio" \ -p "$P_PXY drop=5 delay=5 duplicate=5" \ - "$G_SRV -u --mtu 512" \ - "$P_CLI dtls=1 hs_timeout=250-60000 nbio=2" \ + "$G_NEXT_SRV -u --mtu 512" \ + "$P_CLI dgram_packing=0 dtls=1 hs_timeout=500-60000 nbio=2" \ 0 \ -s "Extra-header:" \ -c "Extra-header:" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/helpers.function b/3rdparty/mbedtls/mbedtls/tests/suites/helpers.function index eef41c79a6..1255ff4be4 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/helpers.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/helpers.function @@ -1,4 +1,4 @@ -#line 1 "helpers.function" +#line 2 "suites/helpers.function" /*----------------------------------------------------------------------------*/ /* Headers */ @@ -23,8 +23,15 @@ #include "mbedtls/memory_buffer_alloc.h" #endif +#if defined(MBEDTLS_CHECK_PARAMS) +#include "mbedtls/platform_util.h" +#include +#endif + #ifdef _MSC_VER #include +typedef UINT8 uint8_t; +typedef INT32 int32_t; typedef UINT32 uint32_t; #define strncasecmp _strnicmp #define strcasecmp _stricmp @@ -36,35 +43,170 @@ typedef UINT32 uint32_t; #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#include #endif -/*----------------------------------------------------------------------------*/ -/* Constants */ - -#define DEPENDENCY_SUPPORTED 0 -#define DEPENDENCY_NOT_SUPPORTED 1 - -#define KEY_VALUE_MAPPING_FOUND 0 -#define KEY_VALUE_MAPPING_NOT_FOUND -1 +/* Type for Hex parameters */ +typedef struct data_tag +{ + uint8_t * x; + uint32_t len; +} data_t; -#define DISPATCH_TEST_SUCCESS 0 -#define DISPATCH_TEST_FN_NOT_FOUND 1 -#define DISPATCH_INVALID_TEST_DATA 2 -#define DISPATCH_UNSUPPORTED_SUITE 3 +/*----------------------------------------------------------------------------*/ +/* Status and error constants */ + +#define DEPENDENCY_SUPPORTED 0 /* Dependency supported by build */ +#define KEY_VALUE_MAPPING_FOUND 0 /* Integer expression found */ +#define DISPATCH_TEST_SUCCESS 0 /* Test dispatch successful */ + +#define KEY_VALUE_MAPPING_NOT_FOUND -1 /* Integer expression not found */ +#define DEPENDENCY_NOT_SUPPORTED -2 /* Dependency not supported */ +#define DISPATCH_TEST_FN_NOT_FOUND -3 /* Test function not found */ +#define DISPATCH_INVALID_TEST_DATA -4 /* Invalid test parameter type. + Only int, string, binary data + and integer expressions are + allowed */ +#define DISPATCH_UNSUPPORTED_SUITE -5 /* Test suite not supported by the + build */ + +typedef enum +{ + PARAMFAIL_TESTSTATE_IDLE = 0, /* No parameter failure call test */ + PARAMFAIL_TESTSTATE_PENDING, /* Test call to the parameter failure + * is pending */ + PARAMFAIL_TESTSTATE_CALLED /* The test call to the parameter + * failure function has been made */ +} paramfail_test_state_t; /*----------------------------------------------------------------------------*/ /* Macros */ -#define TEST_ASSERT( TEST ) \ - do { \ - if( ! (TEST) ) \ - { \ - test_fail( #TEST, __LINE__, __FILE__ ); \ - goto exit; \ - } \ +/** + * \brief This macro tests the expression passed to it as a test step or + * individual test in a test case. + * + * It allows a library function to return a value and return an error + * code that can be tested. + * + * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure + * callback, MBEDTLS_PARAM_FAILED(), will be assumed to be a test + * failure. + * + * This macro is not suitable for negative parameter validation tests, + * as it assumes the test step will not create an error. + * + * \param TEST The test expression to be tested. + */ +#define TEST_ASSERT( TEST ) \ + do { \ + if( ! (TEST) ) \ + { \ + test_fail( #TEST, __LINE__, __FILE__ ); \ + goto exit; \ + } \ } while( 0 ) +#if defined(MBEDTLS_CHECK_PARAMS) && !defined(MBEDTLS_PARAM_FAILED_ALT) +/** + * \brief This macro tests the statement passed to it as a test step or + * individual test in a test case. The macro assumes the test will fail + * and will generate an error. + * + * It allows a library function to return a value and tests the return + * code on return to confirm the given error code was returned. + * + * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure + * callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the + * expected failure, and the test will pass. + * + * This macro is intended for negative parameter validation tests, + * where the failing function may return an error value or call + * MBEDTLS_PARAM_FAILED() to indicate the error. + * + * \param PARAM_ERROR_VALUE The expected error code. + * + * \param TEST The test expression to be tested. + */ +#define TEST_INVALID_PARAM_RET( PARAM_ERR_VALUE, TEST ) \ + do { \ + test_info.paramfail_test_state = PARAMFAIL_TESTSTATE_PENDING; \ + if( (TEST) != (PARAM_ERR_VALUE) || \ + test_info.paramfail_test_state != PARAMFAIL_TESTSTATE_CALLED ) \ + { \ + test_fail( #TEST, __LINE__, __FILE__ ); \ + goto exit; \ + } \ + } while( 0 ) + +/** + * \brief This macro tests the statement passed to it as a test step or + * individual test in a test case. The macro assumes the test will fail + * and will generate an error. + * + * It assumes the library function under test cannot return a value and + * assumes errors can only be indicated byt calls to + * MBEDTLS_PARAM_FAILED(). + * + * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure + * callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the + * expected failure. If MBEDTLS_CHECK_PARAMS is not enabled, no test + * can be made. + * + * This macro is intended for negative parameter validation tests, + * where the failing function can only return an error by calling + * MBEDTLS_PARAM_FAILED() to indicate the error. + * + * \param TEST The test expression to be tested. + */ +#define TEST_INVALID_PARAM( TEST ) \ + do { \ + memcpy(jmp_tmp, param_fail_jmp, sizeof(jmp_buf)); \ + if( setjmp( param_fail_jmp ) == 0 ) \ + { \ + TEST; \ + test_fail( #TEST, __LINE__, __FILE__ ); \ + goto exit; \ + } \ + memcpy(param_fail_jmp, jmp_tmp, sizeof(jmp_buf)); \ + } while( 0 ) +#endif /* MBEDTLS_CHECK_PARAMS && !MBEDTLS_PARAM_FAILED_ALT */ + +/** + * \brief This macro tests the statement passed to it as a test step or + * individual test in a test case. The macro assumes the test will not fail. + * + * It assumes the library function under test cannot return a value and + * assumes errors can only be indicated by calls to + * MBEDTLS_PARAM_FAILED(). + * + * When MBEDTLS_CHECK_PARAMS is enabled, calls to the parameter failure + * callback, MBEDTLS_PARAM_FAILED(), are assumed to indicate the + * expected failure. If MBEDTLS_CHECK_PARAMS is not enabled, no test + * can be made. + * + * This macro is intended to test that functions returning void + * accept all of the parameter values they're supposed to accept - eg + * that they don't call MBEDTLS_PARAM_FAILED() when a parameter + * that's allowed to be NULL happens to be NULL. + * + * Note: for functions that return something other that void, + * checking that they accept all the parameters they're supposed to + * accept is best done by using TEST_ASSERT() and checking the return + * value as well. + * + * Note: this macro is available even when #MBEDTLS_CHECK_PARAMS is + * disabled, as it makes sense to check that the functions accept all + * legal values even if this option is disabled - only in that case, + * the test is more about whether the function segfaults than about + * whether it invokes MBEDTLS_PARAM_FAILED(). + * + * \param TEST The test expression to be tested. + */ +#define TEST_VALID_PARAM( TEST ) \ + TEST_ASSERT( ( TEST, 1 ) ); + #define assert(a) if( !( a ) ) \ { \ mbedtls_fprintf( stderr, "Assertion Failed at %s:%d - %s\n", \ @@ -99,9 +241,9 @@ typedef UINT32 uint32_t; /*----------------------------------------------------------------------------*/ /* Global variables */ - static struct { + paramfail_test_state_t paramfail_test_state; int failed; const char *test; const char *filename; @@ -109,6 +251,14 @@ static struct } test_info; +#if defined(MBEDTLS_PLATFORM_C) +mbedtls_platform_context platform_ctx; +#endif + +#if defined(MBEDTLS_CHECK_PARAMS) +jmp_buf param_fail_jmp; +jmp_buf jmp_tmp; +#endif /*----------------------------------------------------------------------------*/ /* Helper flags for complex dependencies */ @@ -128,6 +278,54 @@ test_info; /*----------------------------------------------------------------------------*/ /* Helper Functions */ +static void test_fail( const char *test, int line_no, const char* filename ) +{ + test_info.failed = 1; + test_info.test = test; + test_info.line_no = line_no; + test_info.filename = filename; +} + +static int platform_setup() +{ + int ret = 0; +#if defined(MBEDTLS_PLATFORM_C) + ret = mbedtls_platform_setup( &platform_ctx ); +#endif /* MBEDTLS_PLATFORM_C */ + return( ret ); +} + +static void platform_teardown() +{ +#if defined(MBEDTLS_PLATFORM_C) + mbedtls_platform_teardown( &platform_ctx ); +#endif /* MBEDTLS_PLATFORM_C */ +} + +#if defined(MBEDTLS_CHECK_PARAMS) +void mbedtls_param_failed( const char *failure_condition, + const char *file, + int line ) +{ + /* If we are testing the callback function... */ + if( test_info.paramfail_test_state == PARAMFAIL_TESTSTATE_PENDING ) + { + test_info.paramfail_test_state = PARAMFAIL_TESTSTATE_CALLED; + } + else + { + /* ...else we treat this as an error */ + + /* Record the location of the failure, but not as a failure yet, in case + * it was part of the test */ + test_fail( failure_condition, line, file ); + test_info.failed = 0; + + longjmp( param_fail_jmp, 1 ); + } +} +#endif + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) static int redirect_output( FILE** out_stream, const char* path ) { @@ -144,6 +342,7 @@ static int redirect_output( FILE** out_stream, const char* path ) if( *out_stream == NULL ) { + close( stdout_fd ); return -1; } @@ -416,10 +615,21 @@ static int rnd_pseudo_rand( void *rng_state, unsigned char *output, size_t len ) return( 0 ); } -static void test_fail( const char *test, int line_no, const char* filename ) +int hexcmp( uint8_t * a, uint8_t * b, uint32_t a_len, uint32_t b_len ) { - test_info.failed = 1; - test_info.test = test; - test_info.line_no = line_no; - test_info.filename = filename; + int ret = 0; + uint32_t i = 0; + + if( a_len != b_len ) + return( -1 ); + + for( i = 0; i < a_len; i++ ) + { + if( a[i] != b[i] ) + { + ret = -1; + break; + } + } + return ret; } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/host_test.function b/3rdparty/mbedtls/mbedtls/tests/suites/host_test.function new file mode 100644 index 0000000000..3c43032083 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/host_test.function @@ -0,0 +1,672 @@ +#line 2 "suites/host_test.function" + +/** + * \brief Verifies that string is in string parameter format i.e. "" + * It also strips enclosing '"' from the input string. + * + * \param str String parameter. + * + * \return 0 if success else 1 + */ +int verify_string( char **str ) +{ + if( ( *str )[0] != '"' || + ( *str )[strlen( *str ) - 1] != '"' ) + { + mbedtls_fprintf( stderr, + "Expected string (with \"\") for parameter and got: %s\n", *str ); + return( -1 ); + } + + ( *str )++; + ( *str )[strlen( *str ) - 1] = '\0'; + + return( 0 ); +} + +/** + * \brief Verifies that string is an integer. Also gives the converted + * integer value. + * + * \param str Input string. + * \param value Pointer to int for output value. + * + * \return 0 if success else 1 + */ +int verify_int( char *str, int *value ) +{ + size_t i; + int minus = 0; + int digits = 1; + int hex = 0; + + for( i = 0; i < strlen( str ); i++ ) + { + if( i == 0 && str[i] == '-' ) + { + minus = 1; + continue; + } + + if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) && + str[i - 1] == '0' && ( str[i] == 'x' || str[i] == 'X' ) ) + { + hex = 1; + continue; + } + + if( ! ( ( str[i] >= '0' && str[i] <= '9' ) || + ( hex && ( ( str[i] >= 'a' && str[i] <= 'f' ) || + ( str[i] >= 'A' && str[i] <= 'F' ) ) ) ) ) + { + digits = 0; + break; + } + } + + if( digits ) + { + if( hex ) + *value = strtol( str, NULL, 16 ); + else + *value = strtol( str, NULL, 10 ); + + return( 0 ); + } + + mbedtls_fprintf( stderr, + "Expected integer for parameter and got: %s\n", str ); + return( KEY_VALUE_MAPPING_NOT_FOUND ); +} + + +/** + * \brief Usage string. + * + */ +#define USAGE \ + "Usage: %s [OPTIONS] files...\n\n" \ + " Command line arguments:\n" \ + " files... One or more test data files. If no file is\n" \ + " specified the following default test case\n" \ + " file is used:\n" \ + " %s\n\n" \ + " Options:\n" \ + " -v | --verbose Display full information about each test\n" \ + " -h | --help Display this information\n\n", \ + argv[0], \ + "TESTCASE_FILENAME" + + +/** + * \brief Read a line from the passed file pointer. + * + * \param f FILE pointer + * \param buf Pointer to memory to hold read line. + * \param len Length of the buf. + * + * \return 0 if success else -1 + */ +int get_line( FILE *f, char *buf, size_t len ) +{ + char *ret; + int i = 0, str_len = 0, has_string = 0; + + /* Read until we get a valid line */ + do + { + ret = fgets( buf, len, f ); + if( ret == NULL ) + return( -1 ); + + str_len = strlen( buf ); + + /* Skip empty line and comment */ + if ( str_len == 0 || buf[0] == '#' ) + continue; + has_string = 0; + for ( i = 0; i < str_len; i++ ) + { + char c = buf[i]; + if ( c != ' ' && c != '\t' && c != '\n' && + c != '\v' && c != '\f' && c != '\r' ) + { + has_string = 1; + break; + } + } + } while( !has_string ); + + /* Strip new line and carriage return */ + ret = buf + strlen( buf ); + if( ret-- > buf && *ret == '\n' ) + *ret = '\0'; + if( ret-- > buf && *ret == '\r' ) + *ret = '\0'; + + return( 0 ); +} + +/** + * \brief Splits string delimited by ':'. Ignores '\:'. + * + * \param buf Input string + * \param len Input string length + * \param params Out params found + * \param params_len Out params array len + * + * \return Count of strings found. + */ +static int parse_arguments( char *buf, size_t len, char **params, + size_t params_len ) +{ + size_t cnt = 0, i; + char *cur = buf; + char *p = buf, *q; + + params[cnt++] = cur; + + while( *p != '\0' && p < ( buf + len ) ) + { + if( *p == '\\' ) + { + p++; + p++; + continue; + } + if( *p == ':' ) + { + if( p + 1 < buf + len ) + { + cur = p + 1; + assert( cnt < params_len ); + params[cnt++] = cur; + } + *p = '\0'; + } + + p++; + } + + /* Replace newlines, question marks and colons in strings */ + for( i = 0; i < cnt; i++ ) + { + p = params[i]; + q = params[i]; + + while( *p != '\0' ) + { + if( *p == '\\' && *( p + 1 ) == 'n' ) + { + p += 2; + *( q++ ) = '\n'; + } + else if( *p == '\\' && *( p + 1 ) == ':' ) + { + p += 2; + *( q++ ) = ':'; + } + else if( *p == '\\' && *( p + 1 ) == '?' ) + { + p += 2; + *( q++ ) = '?'; + } + else + *( q++ ) = *( p++ ); + } + *q = '\0'; + } + + return( cnt ); +} + +/** + * \brief Converts parameters into test function consumable parameters. + * Example: Input: {"int", "0", "char*", "Hello", + * "hex", "abef", "exp", "1"} + * Output: { + * 0, // Verified int + * "Hello", // Verified string + * 2, { 0xab, 0xef },// Converted len,hex pair + * 9600 // Evaluated expression + * } + * + * + * \param cnt Parameter array count. + * \param params Out array of found parameters. + * \param int_params_store Memory for storing processed integer parameters. + * + * \return 0 for success else 1 + */ +static int convert_params( size_t cnt , char ** params , int * int_params_store ) +{ + char ** cur = params; + char ** out = params; + int ret = DISPATCH_TEST_SUCCESS; + + while ( cur < params + cnt ) + { + char * type = *cur++; + char * val = *cur++; + + if ( strcmp( type, "char*" ) == 0 ) + { + if ( verify_string( &val ) == 0 ) + { + *out++ = val; + } + else + { + ret = ( DISPATCH_INVALID_TEST_DATA ); + break; + } + } + else if ( strcmp( type, "int" ) == 0 ) + { + if ( verify_int( val, int_params_store ) == 0 ) + { + *out++ = (char *) int_params_store++; + } + else + { + ret = ( DISPATCH_INVALID_TEST_DATA ); + break; + } + } + else if ( strcmp( type, "hex" ) == 0 ) + { + if ( verify_string( &val ) == 0 ) + { + *int_params_store = unhexify( (unsigned char *) val, val ); + *out++ = val; + *out++ = (char *)(int_params_store++); + } + else + { + ret = ( DISPATCH_INVALID_TEST_DATA ); + break; + } + } + else if ( strcmp( type, "exp" ) == 0 ) + { + int exp_id = strtol( val, NULL, 10 ); + if ( get_expression ( exp_id, int_params_store ) == 0 ) + { + *out++ = (char *)int_params_store++; + } + else + { + ret = ( DISPATCH_INVALID_TEST_DATA ); + break; + } + } + else + { + ret = ( DISPATCH_INVALID_TEST_DATA ); + break; + } + } + return( ret ); +} + +/** + * \brief Tests snprintf implementation with test input. + * + * \note + * At high optimization levels (e.g. gcc -O3), this function may be + * inlined in run_test_snprintf. This can trigger a spurious warning about + * potential misuse of snprintf from gcc -Wformat-truncation (observed with + * gcc 7.2). This warning makes tests in run_test_snprintf redundant on gcc + * only. They are still valid for other compilers. Avoid this warning by + * forbidding inlining of this function by gcc. + * + * \param n Buffer test length. + * \param ref_buf Expected buffer. + * \param ref_ret Expected snprintf return value. + * + * \return 0 for success else 1 + */ +#if defined(__GNUC__) +__attribute__((__noinline__)) +#endif +static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret ) +{ + int ret; + char buf[10] = "xxxxxxxxx"; + const char ref[10] = "xxxxxxxxx"; + + if( n >= sizeof( buf ) ) + return( -1 ); + ret = mbedtls_snprintf( buf, n, "%s", "123" ); + if( ret < 0 || (size_t) ret >= n ) + ret = -1; + + if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 || + ref_ret != ret || + memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 ) + { + return( 1 ); + } + + return( 0 ); +} + +/** + * \brief Tests snprintf implementation. + * + * \param none + * + * \return 0 for success else 1 + */ +static int run_test_snprintf( void ) +{ + return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 || + test_snprintf( 1, "", -1 ) != 0 || + test_snprintf( 2, "1", -1 ) != 0 || + test_snprintf( 3, "12", -1 ) != 0 || + test_snprintf( 4, "123", 3 ) != 0 || + test_snprintf( 5, "123", 3 ) != 0 ); +} + + +/** + * \brief Desktop implementation of execute_tests(). + * Parses command line and executes tests from + * supplied or default data file. + * + * \param argc Command line argument count. + * \param argv Argument array. + * + * \return Program exit status. + */ +int execute_tests( int argc , const char ** argv ) +{ + /* Local Configurations and options */ + const char *default_filename = "DATA_FILE"; + const char *test_filename = NULL; + const char **test_files = NULL; + int testfile_count = 0; + int option_verbose = 0; + int function_id = 0; + + /* Other Local variables */ + int arg_index = 1; + const char *next_arg; + int testfile_index, ret, i, cnt; + int total_errors = 0, total_tests = 0, total_skipped = 0; + FILE *file; + char buf[5000]; + char *params[50]; + /* Store for proccessed integer params. */ + int int_params[50]; + void *pointer; +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + int stdout_fd = -1; +#endif /* __unix__ || __APPLE__ __MACH__ */ + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ + !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) + unsigned char alloc_buf[1000000]; + mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof( alloc_buf ) ); +#endif + + /* + * The C standard doesn't guarantee that all-bits-0 is the representation + * of a NULL pointer. We do however use that in our code for initializing + * structures, which should work on every modern platform. Let's be sure. + */ + memset( &pointer, 0, sizeof( void * ) ); + if( pointer != NULL ) + { + mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" ); + return( 1 ); + } + + /* + * Make sure we have a snprintf that correctly zero-terminates + */ + if( run_test_snprintf() != 0 ) + { + mbedtls_fprintf( stderr, "the snprintf implementation is broken\n" ); + return( 1 ); + } + + while( arg_index < argc ) + { + next_arg = argv[arg_index]; + + if( strcmp( next_arg, "--verbose" ) == 0 || + strcmp( next_arg, "-v" ) == 0 ) + { + option_verbose = 1; + } + else if( strcmp(next_arg, "--help" ) == 0 || + strcmp(next_arg, "-h" ) == 0 ) + { + mbedtls_fprintf( stdout, USAGE ); + mbedtls_exit( EXIT_SUCCESS ); + } + else + { + /* Not an option, therefore treat all further arguments as the file + * list. + */ + test_files = &argv[ arg_index ]; + testfile_count = argc - arg_index; + } + + arg_index++; + } + + /* If no files were specified, assume a default */ + if ( test_files == NULL || testfile_count == 0 ) + { + test_files = &default_filename; + testfile_count = 1; + } + + /* Initialize the struct that holds information about the last test */ + memset( &test_info, 0, sizeof( test_info ) ); + + /* Now begin to execute the tests in the testfiles */ + for ( testfile_index = 0; + testfile_index < testfile_count; + testfile_index++ ) + { + int unmet_dep_count = 0; + char *unmet_dependencies[20]; + + test_filename = test_files[ testfile_index ]; + + file = fopen( test_filename, "r" ); + if( file == NULL ) + { + mbedtls_fprintf( stderr, "Failed to open test file: %s\n", + test_filename ); + return( 1 ); + } + + while( !feof( file ) ) + { + if( unmet_dep_count > 0 ) + { + mbedtls_fprintf( stderr, + "FATAL: Dep count larger than zero at start of loop\n" ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); + } + unmet_dep_count = 0; + + if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) + break; + mbedtls_fprintf( stdout, "%s%.66s", test_info.failed ? "\n" : "", buf ); + mbedtls_fprintf( stdout, " " ); + for( i = strlen( buf ) + 1; i < 67; i++ ) + mbedtls_fprintf( stdout, "." ); + mbedtls_fprintf( stdout, " " ); + fflush( stdout ); + + total_tests++; + + if( ( ret = get_line( file, buf, sizeof( buf ) ) ) != 0 ) + break; + cnt = parse_arguments( buf, strlen( buf ), params, + sizeof( params ) / sizeof( params[0] ) ); + + if( strcmp( params[0], "depends_on" ) == 0 ) + { + for( i = 1; i < cnt; i++ ) + { + int dep_id = strtol( params[i], NULL, 10 ); + if( dep_check( dep_id ) != DEPENDENCY_SUPPORTED ) + { + if( 0 == option_verbose ) + { + /* Only one count is needed if not verbose */ + unmet_dep_count++; + break; + } + + unmet_dependencies[ unmet_dep_count ] = strdup( params[i] ); + if( unmet_dependencies[ unmet_dep_count ] == NULL ) + { + mbedtls_fprintf( stderr, "FATAL: Out of memory\n" ); + mbedtls_exit( MBEDTLS_EXIT_FAILURE ); + } + unmet_dep_count++; + } + } + + if( ( ret = get_line( file, buf, sizeof( buf ) ) ) != 0 ) + break; + cnt = parse_arguments( buf, strlen( buf ), params, + sizeof( params ) / sizeof( params[0] ) ); + } + + // If there are no unmet dependencies execute the test + if( unmet_dep_count == 0 ) + { + test_info.failed = 0; + test_info.paramfail_test_state = PARAMFAIL_TESTSTATE_IDLE; + +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + /* Suppress all output from the library unless we're verbose + * mode + */ + if( !option_verbose ) + { + stdout_fd = redirect_output( &stdout, "/dev/null" ); + if( stdout_fd == -1 ) + { + /* Redirection has failed with no stdout so exit */ + exit( 1 ); + } + } +#endif /* __unix__ || __APPLE__ __MACH__ */ + + function_id = strtol( params[0], NULL, 10 ); + if ( (ret = check_test( function_id )) == DISPATCH_TEST_SUCCESS ) + { + ret = convert_params( cnt - 1, params + 1, int_params ); + if ( DISPATCH_TEST_SUCCESS == ret ) + { + ret = dispatch_test( function_id, (void **)( params + 1 ) ); + } + } + +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + if( !option_verbose && restore_output( &stdout, stdout_fd ) ) + { + /* Redirection has failed with no stdout so exit */ + exit( 1 ); + } +#endif /* __unix__ || __APPLE__ __MACH__ */ + + } + + if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE ) + { + total_skipped++; + mbedtls_fprintf( stdout, "----" ); + + if( 1 == option_verbose && ret == DISPATCH_UNSUPPORTED_SUITE ) + { + mbedtls_fprintf( stdout, "\n Test Suite not enabled" ); + } + + if( 1 == option_verbose && unmet_dep_count > 0 ) + { + mbedtls_fprintf( stdout, "\n Unmet dependencies: " ); + for( i = 0; i < unmet_dep_count; i++ ) + { + mbedtls_fprintf( stdout, "%s ", + unmet_dependencies[i] ); + free( unmet_dependencies[i] ); + } + } + mbedtls_fprintf( stdout, "\n" ); + fflush( stdout ); + + unmet_dep_count = 0; + } + else if( ret == DISPATCH_TEST_SUCCESS ) + { + if( test_info.failed == 0 ) + { + mbedtls_fprintf( stdout, "PASS\n" ); + } + else + { + total_errors++; + mbedtls_fprintf( stdout, "FAILED\n" ); + mbedtls_fprintf( stdout, " %s\n at line %d, %s\n", + test_info.test, test_info.line_no, + test_info.filename ); + } + fflush( stdout ); + } + else if( ret == DISPATCH_INVALID_TEST_DATA ) + { + mbedtls_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" ); + fclose( file ); + mbedtls_exit( 2 ); + } + else if( ret == DISPATCH_TEST_FN_NOT_FOUND ) + { + mbedtls_fprintf( stderr, "FAILED: FATAL TEST FUNCTION NOT FUND\n" ); + fclose( file ); + mbedtls_exit( 2 ); + } + else + total_errors++; + } + fclose( file ); + + /* In case we encounter early end of file */ + for( i = 0; i < unmet_dep_count; i++ ) + free( unmet_dependencies[i] ); + } + + mbedtls_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n"); + if( total_errors == 0 ) + mbedtls_fprintf( stdout, "PASSED" ); + else + mbedtls_fprintf( stdout, "FAILED" ); + + mbedtls_fprintf( stdout, " (%d / %d tests (%d skipped))\n", + total_tests - total_errors, total_tests, total_skipped ); + +#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ + !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) +#if defined(MBEDTLS_MEMORY_DEBUG) + mbedtls_memory_buffer_alloc_status(); +#endif + mbedtls_memory_buffer_alloc_free(); +#endif + +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) + if( stdout_fd != -1 ) + close_output( stdout ); +#endif /* __unix__ || __APPLE__ __MACH__ */ + + return( total_errors != 0 ); +} diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/main_test.function b/3rdparty/mbedtls/mbedtls/tests/suites/main_test.function index 042085f0ba..ca4783dcf7 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/main_test.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/main_test.function @@ -1,537 +1,258 @@ -#line 1 "main_test.function" -SUITE_PRE_DEP -#define TEST_SUITE_ACTIVE - -int verify_string( char **str ) -{ - if( (*str)[0] != '"' || - (*str)[strlen( *str ) - 1] != '"' ) - { - mbedtls_fprintf( stderr, - "Expected string (with \"\") for parameter and got: %s\n", *str ); - return( -1 ); - } - - (*str)++; - (*str)[strlen( *str ) - 1] = '\0'; +#line 2 "suites/main_test.function" +/* + * *** THIS FILE HAS BEEN MACHINE GENERATED *** + * + * This file has been machine generated using the script: + * $generator_script + * + * Test file : $test_file + * + * The following files were used to create this file. + * + * Main code file : $test_main_file + * Platform code file : $test_platform_file + * Helper file : $test_common_helper_file + * Test suite file : $test_case_file + * Test suite data : $test_case_data_file + * + * + * This file is part of Mbed TLS (https://tls.mbed.org) + */ - return( 0 ); -} +#if !defined(MBEDTLS_CONFIG_FILE) +#include +#else +#include MBEDTLS_CONFIG_FILE +#endif -int verify_int( char *str, int *value ) -{ - size_t i; - int minus = 0; - int digits = 1; - int hex = 0; - for( i = 0; i < strlen( str ); i++ ) - { - if( i == 0 && str[i] == '-' ) - { - minus = 1; - continue; - } - - if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) && - str[i - 1] == '0' && str[i] == 'x' ) - { - hex = 1; - continue; - } - - if( ! ( ( str[i] >= '0' && str[i] <= '9' ) || - ( hex && ( ( str[i] >= 'a' && str[i] <= 'f' ) || - ( str[i] >= 'A' && str[i] <= 'F' ) ) ) ) ) - { - digits = 0; - break; - } - } +/*----------------------------------------------------------------------------*/ +/* Common helper code */ - if( digits ) - { - if( hex ) - *value = strtol( str, NULL, 16 ); - else - *value = strtol( str, NULL, 10 ); +$test_common_helpers - return( 0 ); - } +#line $line_no "suites/main_test.function" -MAPPING_CODE - mbedtls_fprintf( stderr, - "Expected integer for parameter and got: %s\n", str ); - return( KEY_VALUE_MAPPING_NOT_FOUND ); -} +/*----------------------------------------------------------------------------*/ +/* Test Suite Code */ -/*----------------------------------------------------------------------------*/ -/* Test Case code */ +#define TEST_SUITE_ACTIVE -FUNCTION_CODE -SUITE_POST_DEP +$functions_code -#line !LINE_NO! "main_test.function" +#line $line_no "suites/main_test.function" /*----------------------------------------------------------------------------*/ /* Test dispatch code */ -int dep_check( char *str ) -{ - if( str == NULL ) - return( 1 ); - -DEP_CHECK_CODE -#line !LINE_NO! "main_test.function" - return( DEPENDENCY_NOT_SUPPORTED ); -} - -int dispatch_test(int cnt, char *params[50]) +/** + * \brief Evaluates an expression/macro into its literal integer value. + * For optimizing space for embedded targets each expression/macro + * is identified by a unique identifier instead of string literals. + * Identifiers and evaluation code is generated by script: + * $generator_script + * + * \param exp_id Expression identifier. + * \param out_value Pointer to int to hold the integer. + * + * \return 0 if exp_id is found. 1 otherwise. + */ +int get_expression( int32_t exp_id, int32_t * out_value ) { - int ret; - ((void) cnt); - ((void) params); + int ret = KEY_VALUE_MAPPING_FOUND; -#if defined(TEST_SUITE_ACTIVE) - ret = DISPATCH_TEST_SUCCESS; + (void) exp_id; + (void) out_value; - // Cast to void to avoid compiler warnings - (void)ret; - -DISPATCH_FUNCTION + switch( exp_id ) { -#line !LINE_NO! "main_test.function" - mbedtls_fprintf( stdout, - "FAILED\nSkipping unknown test function '%s'\n", - params[0] ); - fflush( stdout ); - ret = DISPATCH_TEST_FN_NOT_FOUND; +$expression_code +#line $line_no "suites/main_test.function" + default: + { + ret = KEY_VALUE_MAPPING_NOT_FOUND; + } + break; } -#else - ret = DISPATCH_UNSUPPORTED_SUITE; -#endif return( ret ); } -/*----------------------------------------------------------------------------*/ -/* Main Test code */ - -#line !LINE_NO! "main_test.function" - -#define USAGE \ - "Usage: %s [OPTIONS] files...\n\n" \ - " Command line arguments:\n" \ - " files... One or more test data file. If no file is specified\n" \ - " the followimg default test case is used:\n" \ - " %s\n\n" \ - " Options:\n" \ - " -v | --verbose Display full information about each test\n" \ - " -h | --help Display this information\n\n", \ - argv[0], \ - "TESTCASE_FILENAME" - - -/** Retrieve one input line into buf, which must have room for len - * bytes. The trailing line break (if any) is stripped from the result. - * Lines beginning with the character '#' are skipped. Lines that are - * more than len-1 bytes long including the trailing line break are - * truncated; note that the following bytes remain in the input stream. +/** + * \brief Checks if the dependency i.e. the compile flag is set. + * For optimizing space for embedded targets each dependency + * is identified by a unique identifier instead of string literals. + * Identifiers and check code is generated by script: + * $generator_script * - * \return 0 on success, -1 on error or end of file + * \param exp_id Dependency identifier. + * + * \return DEPENDENCY_SUPPORTED if set else DEPENDENCY_NOT_SUPPORTED */ -int get_line( FILE *f, char *buf, size_t len ) +int dep_check( int dep_id ) { - char *ret; + int ret = DEPENDENCY_NOT_SUPPORTED; + + (void) dep_id; - do + switch( dep_id ) { - ret = fgets( buf, len, f ); - if( ret == NULL ) - return( -1 ); +$dep_check_code +#line $line_no "suites/main_test.function" + default: + break; } - while( buf[0] == '#' ); + return( ret ); +} - ret = buf + strlen( buf ); - if( ret-- > buf && *ret == '\n' ) - *ret = '\0'; - if( ret-- > buf && *ret == '\r' ) - *ret = '\0'; - return( 0 ); -} +/** + * \brief Function pointer type for test function wrappers. + * + * + * \param void ** Pointer to void pointers. Represents an array of test + * function parameters. + * + * \return void + */ +typedef void (*TestWrapper_t)( void ** ); -int parse_arguments( char *buf, size_t len, char *params[50] ) -{ - int cnt = 0, i; - char *cur = buf; - char *p = buf, *q; - params[cnt++] = cur; +/** + * \brief Table of test function wrappers. Used by dispatch_test(). + * This table is populated by script: + * $generator_script + * + */ +TestWrapper_t test_funcs[] = +{ +$dispatch_code +#line $line_no "suites/main_test.function" +}; - while( *p != '\0' && p < buf + len ) +/** + * \brief Execute the test function. + * + * This is a wrapper function around the test function execution + * to allow the setjmp() call used to catch any calls to the + * parameter failure callback, to be used. Calls to setjmp() + * can invalidate the state of any local auto variables. + * + * \param fp Function pointer to the test function + * \param params Parameters to pass + * + */ +void execute_function_ptr(TestWrapper_t fp, void **params) +{ +#if defined(MBEDTLS_CHECK_PARAMS) + if ( setjmp( param_fail_jmp ) == 0 ) { - if( *p == '\\' ) - { - p++; - p++; - continue; - } - if( *p == ':' ) - { - if( p + 1 < buf + len ) - { - cur = p + 1; - params[cnt++] = cur; - } - *p = '\0'; - } - - p++; + fp( params ); } - - /* Replace newlines, question marks and colons in strings */ - for( i = 0; i < cnt; i++ ) + else { - p = params[i]; - q = params[i]; - - while( *p != '\0' ) - { - if( *p == '\\' && *(p + 1) == 'n' ) - { - p += 2; - *(q++) = '\n'; - } - else if( *p == '\\' && *(p + 1) == ':' ) - { - p += 2; - *(q++) = ':'; - } - else if( *p == '\\' && *(p + 1) == '?' ) - { - p += 2; - *(q++) = '?'; - } - else - *(q++) = *(p++); - } - *q = '\0'; + /* Unexpected parameter validation error */ + test_info.failed = 1; } - return( cnt ); + memset( param_fail_jmp, 0, sizeof(jmp_buf) ); +#else + fp( params ); +#endif } -static int test_snprintf( size_t n, const char ref_buf[10], int ref_ret ) +/** + * \brief Dispatches test functions based on function index. + * + * \param exp_id Test function index. + * + * \return DISPATCH_TEST_SUCCESS if found + * DISPATCH_TEST_FN_NOT_FOUND if not found + * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. + */ +int dispatch_test( int func_idx, void ** params ) { - int ret; - char buf[10] = "xxxxxxxxx"; - const char ref[10] = "xxxxxxxxx"; + int ret = DISPATCH_TEST_SUCCESS; + TestWrapper_t fp = NULL; - ret = mbedtls_snprintf( buf, n, "%s", "123" ); - if( ret < 0 || (size_t) ret >= n ) - ret = -1; - - if( strncmp( ref_buf, buf, sizeof( buf ) ) != 0 || - ref_ret != ret || - memcmp( buf + n, ref + n, sizeof( buf ) - n ) != 0 ) + if ( func_idx < (int)( sizeof( test_funcs ) / sizeof( TestWrapper_t ) ) ) { - return( 1 ); + fp = test_funcs[func_idx]; + if ( fp ) + execute_function_ptr(fp, params); + else + ret = DISPATCH_UNSUPPORTED_SUITE; + } + else + { + ret = DISPATCH_TEST_FN_NOT_FOUND; } - return( 0 ); + return( ret ); } -static int run_test_snprintf( void ) -{ - return( test_snprintf( 0, "xxxxxxxxx", -1 ) != 0 || - test_snprintf( 1, "", -1 ) != 0 || - test_snprintf( 2, "1", -1 ) != 0 || - test_snprintf( 3, "12", -1 ) != 0 || - test_snprintf( 4, "123", 3 ) != 0 || - test_snprintf( 5, "123", 3 ) != 0 ); -} -int main(int argc, const char *argv[]) +/** + * \brief Checks if test function is supported + * + * \param exp_id Test function index. + * + * \return DISPATCH_TEST_SUCCESS if found + * DISPATCH_TEST_FN_NOT_FOUND if not found + * DISPATCH_UNSUPPORTED_SUITE if not compile time enabled. + */ +int check_test( int func_idx ) { - /* Local Configurations and options */ - const char *default_filename = "TESTCASE_FILENAME"; - const char *test_filename = NULL; - const char **test_files = NULL; - int testfile_count = 0; - int option_verbose = 0; - - /* Other Local variables */ - int arg_index = 1; - const char *next_arg; - int testfile_index, ret, i, cnt; - int total_errors = 0, total_tests = 0, total_skipped = 0; - FILE *file; - char buf[5000]; - char *params[50]; - void *pointer; -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) - int stdout_fd = -1; -#endif /* __unix__ || __APPLE__ __MACH__ */ - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ - !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) - unsigned char alloc_buf[1000000]; - mbedtls_memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) ); -#endif - - /* - * The C standard doesn't guarantee that all-bits-0 is the representation - * of a NULL pointer. We do however use that in our code for initializing - * structures, which should work on every modern platform. Let's be sure. - */ - memset( &pointer, 0, sizeof( void * ) ); - if( pointer != NULL ) - { - mbedtls_fprintf( stderr, "all-bits-zero is not a NULL pointer\n" ); - return( 1 ); - } + int ret = DISPATCH_TEST_SUCCESS; + TestWrapper_t fp = NULL; - /* - * Make sure we have a snprintf that correctly zero-terminates - */ - if( run_test_snprintf() != 0 ) + if ( func_idx < (int)( sizeof(test_funcs)/sizeof( TestWrapper_t ) ) ) { - mbedtls_fprintf( stderr, "the snprintf implementation is broken\n" ); - return( 0 ); + fp = test_funcs[func_idx]; + if ( fp == NULL ) + ret = DISPATCH_UNSUPPORTED_SUITE; } - - while( arg_index < argc) - { - next_arg = argv[ arg_index ]; - - if( strcmp(next_arg, "--verbose" ) == 0 || - strcmp(next_arg, "-v" ) == 0 ) - { - option_verbose = 1; - } - else if( strcmp(next_arg, "--help" ) == 0 || - strcmp(next_arg, "-h" ) == 0 ) - { - mbedtls_fprintf( stdout, USAGE ); - mbedtls_exit( EXIT_SUCCESS ); - } - else - { - /* Not an option, therefore treat all further arguments as the file - * list. - */ - test_files = &argv[ arg_index ]; - testfile_count = argc - arg_index; - } - - arg_index++; - } - - /* If no files were specified, assume a default */ - if ( test_files == NULL || testfile_count == 0 ) + else { - test_files = &default_filename; - testfile_count = 1; + ret = DISPATCH_TEST_FN_NOT_FOUND; } - /* Initialize the struct that holds information about the last test */ - memset( &test_info, 0, sizeof( test_info ) ); + return( ret ); +} - /* Now begin to execute the tests in the testfiles */ - for ( testfile_index = 0; - testfile_index < testfile_count; - testfile_index++ ) - { - int unmet_dep_count = 0; - char *unmet_dependencies[20]; - - test_filename = test_files[ testfile_index ]; - - file = fopen( test_filename, "r" ); - if( file == NULL ) - { - mbedtls_fprintf( stderr, "Failed to open test file: %s\n", - test_filename ); - return( 1 ); - } - - while( !feof( file ) ) - { - if( unmet_dep_count > 0 ) - { - mbedtls_fprintf( stderr, - "FATAL: Dep count larger than zero at start of loop\n" ); - mbedtls_exit( MBEDTLS_EXIT_FAILURE ); - } - unmet_dep_count = 0; - - if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) - break; - mbedtls_fprintf( stdout, "%s%.66s", test_info.failed ? "\n" : "", buf ); - mbedtls_fprintf( stdout, " " ); - for( i = strlen( buf ) + 1; i < 67; i++ ) - mbedtls_fprintf( stdout, "." ); - mbedtls_fprintf( stdout, " " ); - fflush( stdout ); - - total_tests++; - - if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) - break; - cnt = parse_arguments( buf, strlen(buf), params ); - - if( strcmp( params[0], "depends_on" ) == 0 ) - { - for( i = 1; i < cnt; i++ ) - { - if( dep_check( params[i] ) != DEPENDENCY_SUPPORTED ) - { - if( 0 == option_verbose ) - { - /* Only one count is needed if not verbose */ - unmet_dep_count++; - break; - } - - unmet_dependencies[ unmet_dep_count ] = strdup(params[i]); - if( unmet_dependencies[ unmet_dep_count ] == NULL ) - { - mbedtls_fprintf( stderr, "FATAL: Out of memory\n" ); - mbedtls_exit( MBEDTLS_EXIT_FAILURE ); - } - unmet_dep_count++; - } - } - - if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) - break; - cnt = parse_arguments( buf, strlen(buf), params ); - } - - // If there are no unmet dependencies execute the test - if( unmet_dep_count == 0 ) - { - test_info.failed = 0; - -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) - /* Suppress all output from the library unless we're verbose - * mode - */ - if( !option_verbose ) - { - stdout_fd = redirect_output( &stdout, "/dev/null" ); - if( stdout_fd == -1 ) - { - /* Redirection has failed with no stdout so exit */ - exit( 1 ); - } - } -#endif /* __unix__ || __APPLE__ __MACH__ */ - - ret = dispatch_test( cnt, params ); - -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) - if( !option_verbose && restore_output( &stdout, stdout_fd ) ) - { - /* Redirection has failed with no stdout so exit */ - exit( 1 ); - } -#endif /* __unix__ || __APPLE__ __MACH__ */ - - } - - if( unmet_dep_count > 0 || ret == DISPATCH_UNSUPPORTED_SUITE ) - { - total_skipped++; - mbedtls_fprintf( stdout, "----" ); - - if( 1 == option_verbose && ret == DISPATCH_UNSUPPORTED_SUITE ) - { - mbedtls_fprintf( stdout, "\n Test Suite not enabled" ); - } - - if( 1 == option_verbose && unmet_dep_count > 0 ) - { - mbedtls_fprintf( stdout, "\n Unmet dependencies: " ); - for( i = 0; i < unmet_dep_count; i++ ) - { - mbedtls_fprintf(stdout, "%s ", - unmet_dependencies[i]); - free(unmet_dependencies[i]); - } - } - mbedtls_fprintf( stdout, "\n" ); - fflush( stdout ); - - unmet_dep_count = 0; - } - else if( ret == DISPATCH_TEST_SUCCESS ) - { - if( test_info.failed == 0 ) - { - mbedtls_fprintf( stdout, "PASS\n" ); - } - else - { - total_errors++; - mbedtls_fprintf( stdout, "FAILED\n" ); - mbedtls_fprintf( stdout, " %s\n at line %d, %s\n", - test_info.test, test_info.line_no, - test_info.filename ); - } - fflush( stdout ); - } - else if( ret == DISPATCH_INVALID_TEST_DATA ) - { - mbedtls_fprintf( stderr, "FAILED: FATAL PARSE ERROR\n" ); - fclose( file ); - mbedtls_exit( 2 ); - } - else - total_errors++; - - if( ( ret = get_line( file, buf, sizeof( buf ) ) ) != 0 ) - break; - if( strlen( buf ) != 0 ) - { - mbedtls_fprintf( stderr, "Should be empty %d\n", - (int) strlen( buf ) ); - return( 1 ); - } - } - fclose( file ); - - /* In case we encounter early end of file */ - for( i = 0; i < unmet_dep_count; i++ ) - free( unmet_dependencies[i] ); - } - mbedtls_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n"); - if( total_errors == 0 ) - mbedtls_fprintf( stdout, "PASSED" ); - else - mbedtls_fprintf( stdout, "FAILED" ); +$platform_code - mbedtls_fprintf( stdout, " (%d / %d tests (%d skipped))\n", - total_tests - total_errors, total_tests, total_skipped ); +#line $line_no "suites/main_test.function" -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \ - !defined(TEST_SUITE_MEMORY_BUFFER_ALLOC) -#if defined(MBEDTLS_MEMORY_DEBUG) - mbedtls_memory_buffer_alloc_status(); -#endif - mbedtls_memory_buffer_alloc_free(); -#endif +/*----------------------------------------------------------------------------*/ +/* Main Test code */ -#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) - if( stdout_fd != -1 ) - close_output( stdout ); -#endif /* __unix__ || __APPLE__ __MACH__ */ - return( total_errors != 0 ); +/** + * \brief Program main. Invokes platform specific execute_tests(). + * + * \param argc Command line arguments count. + * \param argv Array of command line arguments. + * + * \return Exit code. + */ +int main( int argc, const char *argv[] ) +{ + int ret = platform_setup(); + if( ret != 0 ) + { + mbedtls_fprintf( stderr, + "FATAL: Failed to initialize platform - error %d\n", + ret ); + return( -1 ); + } + ret = execute_tests( argc, argv ); + platform_teardown(); + return( ret ); } + diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/target_test.function b/3rdparty/mbedtls/mbedtls/tests/suites/target_test.function new file mode 100644 index 0000000000..56abf29489 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/target_test.function @@ -0,0 +1,413 @@ +#line 2 "suites/target_test.function" + +#include "greentea-client/test_env.h" + +/** + * \brief Increments pointer and asserts that it does not overflow. + * + * \param p Pointer to byte array + * \param start Pointer to start of byte array + * \param len Length of byte array + * \param step Increment size + * + */ +#define INCR_ASSERT(p, start, len, step) do \ +{ \ + assert( ( p ) >= ( start ) ); \ + assert( sizeof( *( p ) ) == sizeof( *( start ) ) ); \ + /* <= is checked to support use inside a loop where \ + pointer is incremented after reading data. */ \ + assert( (uint32_t)( ( ( p ) - ( start ) ) + ( step ) ) <= ( len ) );\ + ( p ) += ( step ); \ +} \ +while( 0 ) + + +/** + * \brief 4 byte align unsigned char pointer + * + * \param p Pointer to byte array + * \param start Pointer to start of byte array + * \param len Length of byte array + * + */ +#define ALIGN_32BIT(p, start, len) do \ +{ \ + uint32_t align = ( - (uintptr_t)( p ) ) % 4; \ + INCR_ASSERT( ( p ), ( start ), ( len ), align );\ +} \ +while( 0 ) + + +/** + * \brief Verify dependencies. Dependency identifiers are + * encoded in the buffer as 8 bit unsigned integers. + * + * \param count Number of dependencies. + * \param dep_p Pointer to buffer. + * + * \return DEPENDENCY_SUPPORTED if success else DEPENDENCY_NOT_SUPPORTED. + */ +int verify_dependencies( uint8_t count, uint8_t * dep_p ) +{ + uint8_t i; + for ( i = 0; i < count; i++ ) + { + if ( dep_check( (int)(dep_p[i]) ) != DEPENDENCY_SUPPORTED ) + return( DEPENDENCY_NOT_SUPPORTED ); + } + return( DEPENDENCY_SUPPORTED ); +} + + +/** + * \brief Receives unsigned integer on serial interface. + * Integers are encoded in network order. + * + * \param none + * + * \return unsigned int + */ +uint32_t receive_uint32() +{ + uint32_t value; + value = (uint8_t)greentea_getc() << 24; + value |= (uint8_t)greentea_getc() << 16; + value |= (uint8_t)greentea_getc() << 8; + value |= (uint8_t)greentea_getc(); + return( (uint32_t)value ); +} + +/** + * \brief Parses out an unsigned 32 int value from the byte array. + * Integers are encoded in network order. + * + * \param p Pointer to byte array + * + * \return unsigned int + */ +uint32_t parse_uint32( uint8_t * p ) +{ + uint32_t value; + value = *p++ << 24; + value |= *p++ << 16; + value |= *p++ << 8; + value |= *p; + return( value ); +} + + +/** + * \brief Receives test data on serial as greentea key,value pair: + * {{;}} + * + * \param data_len Out pointer to hold received data length. + * + * \return Byte array. + */ +uint8_t * receive_data( uint32_t * data_len ) +{ + uint32_t i = 0, errors = 0; + char c; + uint8_t * data = NULL; + + /* Read opening braces */ + i = 0; + while ( i < 2 ) + { + c = greentea_getc(); + /* Ignore any prevous CR LF characters */ + if ( c == '\n' || c == '\r' ) + continue; + i++; + if ( c != '{' ) + return( NULL ); + } + + /* Read data length */ + *data_len = receive_uint32(); + data = (uint8_t *)malloc( *data_len ); + assert( data != NULL ); + + greentea_getc(); // read ';' received after key i.e. *data_len + + for( i = 0; i < *data_len; i++ ) + data[i] = greentea_getc(); + + /* Read closing braces */ + for( i = 0; i < 2; i++ ) + { + c = greentea_getc(); + if ( c != '}' ) + { + errors++; + break; + } + } + + if ( errors ) + { + free( data ); + data = NULL; + *data_len = 0; + } + + return( data ); +} + +/** + * \brief Parse the received byte array and count the number of arguments + * to the test function passed as type hex. + * + * \param count Parameter count + * \param data Received Byte array + * \param data_len Byte array length + * + * \return count of hex params + */ +uint32_t find_hex_count( uint8_t count, uint8_t * data, uint32_t data_len ) +{ + uint32_t i = 0, sz = 0; + char c; + uint8_t * p = NULL; + uint32_t hex_count = 0; + + p = data; + + for( i = 0; i < count; i++ ) + { + c = (char)*p; + INCR_ASSERT( p, data, data_len, 1 ); + + /* Align p to 4 bytes for int, expression, string len or hex length */ + ALIGN_32BIT( p, data, data_len ); + + /* Network to host conversion */ + sz = (int32_t)parse_uint32( p ); + + INCR_ASSERT( p, data, data_len, sizeof( int32_t ) ); + + if ( c == 'H' || c == 'S' ) + { + INCR_ASSERT( p, data, data_len, sz ); + hex_count += ( c == 'H' )?1:0; + } + } + + return( hex_count ); +} + +/** + * \brief Parses received byte array for test parameters. + * + * \param count Parameter count + * \param data Received Byte array + * \param data_len Byte array length + * \param error Parsing error out variable. + * + * \return Array of parsed parameters allocated on heap. + * Note: Caller has the responsibility to delete + * the memory after use. + */ +void ** parse_parameters( uint8_t count, uint8_t * data, uint32_t data_len, + int * error ) +{ + uint32_t i = 0, hex_count = 0; + char c; + void ** params = NULL; + void ** cur = NULL; + uint8_t * p = NULL; + + hex_count = find_hex_count(count, data, data_len); + + params = (void **)malloc( sizeof( void *) * ( count + hex_count ) ); + assert( params != NULL ); + cur = params; + + p = data; + + /* Parameters */ + for( i = 0; i < count; i++ ) + { + c = (char)*p; + INCR_ASSERT( p, data, data_len, 1 ); + + /* Align p to 4 bytes for int, expression, string len or hex length */ + ALIGN_32BIT( p, data, data_len ); + + /* Network to host conversion */ + *( (int32_t *)p ) = (int32_t)parse_uint32( p ); + + switch( c ) + { + case 'E': + { + if ( get_expression( *( (int32_t *)p ), (int32_t *)p ) ) + { + *error = KEY_VALUE_MAPPING_NOT_FOUND; + goto exit; + } + } /* Intentional fall through */ + case 'I': + { + *cur++ = (void *)p; + INCR_ASSERT( p, data, data_len, sizeof( int32_t ) ); + } + break; + case 'H': /* Intentional fall through */ + case 'S': + { + uint32_t * sz = (uint32_t *)p; + INCR_ASSERT( p, data, data_len, sizeof( int32_t ) ); + *cur++ = (void *)p; + if ( c == 'H' ) + *cur++ = (void *)sz; + INCR_ASSERT( p, data, data_len, ( *sz ) ); + } + break; + default: + { + *error = DISPATCH_INVALID_TEST_DATA; + goto exit; + } + break; + } + } + +exit: + if ( *error ) + { + free( params ); + params = NULL; + } + + return( params ); +} + +/** + * \brief Sends greentea key and int value pair to host. + * + * \param key key string + * \param value integer value + * + * \return void + */ +void send_key_integer( char * key, int value ) +{ + char str[50]; + snprintf( str, sizeof( str ), "%d", value ); + greentea_send_kv( key, str ); +} + +/** + * \brief Sends test setup failure to the host. + * + * \param failure Test set failure + * + * \return void + */ +void send_failure( int failure ) +{ + send_key_integer( "F", failure ); +} + +/** + * \brief Sends test status to the host. + * + * \param status Test status (PASS=0/FAIL=!0) + * + * \return void + */ +void send_status( int status ) +{ + send_key_integer( "R", status ); +} + + +/** + * \brief Embedded implementation of execute_tests(). + * Ignores command line and received test data + * on serial. + * + * \param argc not used + * \param argv not used + * + * \return Program exit status. + */ +int execute_tests( int args, const char ** argv ) +{ + int ret = 0; + uint32_t data_len = 0; + uint8_t count = 0, function_id; + void ** params = NULL; + uint8_t * data = NULL, * p = NULL; + + GREENTEA_SETUP( 180, "mbedtls_test" ); + greentea_send_kv( "GO", " " ); + + while ( 1 ) + { + ret = 0; + test_info.failed = 0; + data_len = 0; + + data = receive_data( &data_len ); + if ( data == NULL ) + continue; + p = data; + + do + { + /* Read dependency count */ + count = *p; + assert( count < data_len ); + INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) ); + ret = verify_dependencies( count, p ); + if ( ret != DEPENDENCY_SUPPORTED ) + break; + + if ( count ) + INCR_ASSERT( p, data, data_len, count ); + + /* Read function id */ + function_id = *p; + INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) ); + if ( ( ret = check_test( function_id ) ) != DISPATCH_TEST_SUCCESS ) + break; + + /* Read number of parameters */ + count = *p; + INCR_ASSERT( p, data, data_len, sizeof( uint8_t ) ); + + /* Parse parameters if present */ + if ( count ) + { + params = parse_parameters( count, p, data_len - ( p - data ), &ret ); + if ( ret ) + break; + } + + ret = dispatch_test( function_id, params ); + } + while ( 0 ); + + if ( data ) + { + free( data ); + data = NULL; + } + + if ( params ) + { + free( params ); + params = NULL; + } + + if ( ret ) + send_failure( ret ); + else + send_status( test_info.failed ); + } + return( 0 ); +} + diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.function index c5f0eaac97..da8c1e9359 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.function @@ -8,32 +8,22 @@ */ /* BEGIN_CASE */ -void aes_encrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string, int setkey_result ) +void aes_encrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string, int setkey_result ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; - int key_len; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); - mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); + mbedtls_aes_init( &ctx ); - TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ) == setkey_result ); + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == setkey_result ); if( setkey_result == 0 ) { - TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_ENCRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_ENCRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); } exit: @@ -42,32 +32,22 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void aes_decrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string, int setkey_result ) +void aes_decrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string, int setkey_result ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; - int key_len; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); - mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); + mbedtls_aes_init( &ctx ); - TEST_ASSERT( mbedtls_aes_setkey_dec( &ctx, key_str, key_len * 8 ) == setkey_result ); + TEST_ASSERT( mbedtls_aes_setkey_dec( &ctx, key_str->x, key_str->len * 8 ) == setkey_result ); if( setkey_result == 0 ) { - TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_DECRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( mbedtls_aes_crypt_ecb( &ctx, MBEDTLS_AES_DECRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); } exit: @@ -76,36 +56,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void aes_encrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, +void aes_encrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; - int key_len, data_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); - mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - data_len = unhexify( src_str, hex_src_string ); + mbedtls_aes_init( &ctx ); - mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_ENCRYPT, data_len, iv_str, src_str, output ) == cbc_result ); + mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, data_len ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -114,36 +81,22 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void aes_decrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, +void aes_decrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; - int key_len, data_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - data_len = unhexify( src_str, hex_src_string ); - - mbedtls_aes_setkey_dec( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_DECRYPT, data_len, iv_str, src_str, output ) == cbc_result ); + mbedtls_aes_setkey_dec( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_crypt_cbc( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0) { - hexify( dst_str, output, data_len ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -151,35 +104,144 @@ exit: } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */ +void aes_encrypt_xts( char *hex_key_string, char *hex_data_unit_string, + char *hex_src_string, char *hex_dst_string ) +{ + enum { AES_BLOCK_SIZE = 16 }; + unsigned char *data_unit = NULL; + unsigned char *key = NULL; + unsigned char *src = NULL; + unsigned char *dst = NULL; + unsigned char *output = NULL; + mbedtls_aes_xts_context ctx; + size_t key_len, src_len, dst_len, data_unit_len; + + mbedtls_aes_xts_init( &ctx ); + + data_unit = unhexify_alloc( hex_data_unit_string, &data_unit_len ); + TEST_ASSERT( data_unit_len == AES_BLOCK_SIZE ); + + key = unhexify_alloc( hex_key_string, &key_len ); + TEST_ASSERT( key_len % 2 == 0 ); + + src = unhexify_alloc( hex_src_string, &src_len ); + dst = unhexify_alloc( hex_dst_string, &dst_len ); + TEST_ASSERT( src_len == dst_len ); + + output = zero_alloc( dst_len ); + + TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == 0 ); + TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, src_len, + data_unit, src, output ) == 0 ); + + TEST_ASSERT( memcmp( output, dst, dst_len ) == 0 ); + +exit: + mbedtls_aes_xts_free( &ctx ); + mbedtls_free( data_unit ); + mbedtls_free( key ); + mbedtls_free( src ); + mbedtls_free( dst ); + mbedtls_free( output ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */ +void aes_decrypt_xts( char *hex_key_string, char *hex_data_unit_string, + char *hex_dst_string, char *hex_src_string ) +{ + enum { AES_BLOCK_SIZE = 16 }; + unsigned char *data_unit = NULL; + unsigned char *key = NULL; + unsigned char *src = NULL; + unsigned char *dst = NULL; + unsigned char *output = NULL; + mbedtls_aes_xts_context ctx; + size_t key_len, src_len, dst_len, data_unit_len; + + mbedtls_aes_xts_init( &ctx ); + + data_unit = unhexify_alloc( hex_data_unit_string, &data_unit_len ); + TEST_ASSERT( data_unit_len == AES_BLOCK_SIZE ); + + key = unhexify_alloc( hex_key_string, &key_len ); + TEST_ASSERT( key_len % 2 == 0 ); + + src = unhexify_alloc( hex_src_string, &src_len ); + dst = unhexify_alloc( hex_dst_string, &dst_len ); + TEST_ASSERT( src_len == dst_len ); + + output = zero_alloc( dst_len ); + + TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == 0 ); + TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, src_len, + data_unit, src, output ) == 0 ); + + TEST_ASSERT( memcmp( output, dst, dst_len ) == 0 ); + +exit: + mbedtls_aes_xts_free( &ctx ); + mbedtls_free( data_unit ); + mbedtls_free( key ); + mbedtls_free( src ); + mbedtls_free( dst ); + mbedtls_free( output ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */ +void aes_crypt_xts_size( int size, int retval ) +{ + mbedtls_aes_xts_context ctx; + const unsigned char src[16] = { 0 }; + unsigned char output[16]; + unsigned char data_unit[16]; + size_t length = size; + + mbedtls_aes_xts_init( &ctx ); + memset( data_unit, 0x00, sizeof( data_unit ) ); + + + /* Valid pointers are passed for builds with MBEDTLS_CHECK_PARAMS, as + * otherwise we wouldn't get to the size check we're interested in. */ + TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, length, data_unit, src, output ) == retval ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */ +void aes_crypt_xts_keysize( int size, int retval ) +{ + mbedtls_aes_xts_context ctx; + const unsigned char key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + size_t key_len = size; + + mbedtls_aes_xts_init( &ctx ); + + TEST_ASSERT( mbedtls_aes_xts_setkey_enc( &ctx, key, key_len * 8 ) == retval ); + TEST_ASSERT( mbedtls_aes_xts_setkey_dec( &ctx, key, key_len * 8 ) == retval ); +exit: + mbedtls_aes_xts_free( &ctx ); +} +/* END_CASE */ + + /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void aes_encrypt_cfb128( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void aes_encrypt_cfb128( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; size_t iv_offset = 0; - int key_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - unhexify( src_str, hex_src_string ); - mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); @@ -187,34 +249,21 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void aes_decrypt_cfb128( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void aes_decrypt_cfb128( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; size_t iv_offset = 0; - int key_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - unhexify( src_str, hex_src_string ); - mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_crypt_cfb128( &ctx, MBEDTLS_AES_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); @@ -222,33 +271,20 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void aes_encrypt_cfb8( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void aes_encrypt_cfb8( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; - int key_len, src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_aes_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); - mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_ENCRYPT, src_len, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, src_len ); + mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); exit: mbedtls_aes_free( &ctx ); @@ -256,41 +292,338 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void aes_decrypt_cfb8( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void aes_decrypt_cfb8( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_aes_context ctx; - int key_len, src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_aes_init( &ctx ); + + mbedtls_aes_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == 0 ); + + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); + +exit: + mbedtls_aes_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_OFB */ +void aes_encrypt_ofb( int fragment_size, char *hex_key_string, + char *hex_iv_string, char *hex_src_string, + char *hex_dst_string ) +{ + unsigned char key_str[32]; + unsigned char iv_str[16]; + unsigned char src_str[64]; + unsigned char dst_str[64]; + unsigned char output[32]; + mbedtls_aes_context ctx; + size_t iv_offset = 0; + int in_buffer_len; + unsigned char* src_str_next; + int key_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aes_init( &ctx ); + + TEST_ASSERT( strlen( hex_key_string ) <= ( 32 * 2 ) ); + TEST_ASSERT( strlen( hex_iv_string ) <= ( 16 * 2 ) ); + TEST_ASSERT( strlen( hex_src_string ) <= ( 64 * 2 ) ); + TEST_ASSERT( strlen( hex_dst_string ) <= ( 64 * 2 ) ); + key_len = unhexify( key_str, hex_key_string ); unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); + in_buffer_len = unhexify( src_str, hex_src_string ); + + TEST_ASSERT( mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ) == 0 ); + src_str_next = src_str; + + while( in_buffer_len > 0 ) + { + TEST_ASSERT( mbedtls_aes_crypt_ofb( &ctx, fragment_size, &iv_offset, + iv_str, src_str_next, output ) == 0 ); - mbedtls_aes_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_aes_crypt_cfb8( &ctx, MBEDTLS_AES_DECRYPT, src_len, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, src_len ); + hexify( dst_str, output, fragment_size ); + TEST_ASSERT( strncmp( (char *) dst_str, hex_dst_string, + ( 2 * fragment_size ) ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + in_buffer_len -= fragment_size; + hex_dst_string += ( fragment_size * 2 ); + src_str_next += fragment_size; + + if( in_buffer_len < fragment_size ) + fragment_size = in_buffer_len; + } exit: mbedtls_aes_free( &ctx ); } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void aes_check_params( ) +{ + mbedtls_aes_context aes_ctx; +#if defined(MBEDTLS_CIPHER_MODE_XTS) + mbedtls_aes_xts_context xts_ctx; +#endif + const unsigned char key[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + const unsigned char in[16] = { 0 }; + unsigned char out[16]; + size_t size; + const int valid_mode = MBEDTLS_AES_ENCRYPT; + const int invalid_mode = 42; + + TEST_INVALID_PARAM( mbedtls_aes_init( NULL ) ); +#if defined(MBEDTLS_CIPHER_MODE_XTS) + TEST_INVALID_PARAM( mbedtls_aes_xts_init( NULL ) ); +#endif + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_setkey_enc( NULL, key, 128 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_setkey_enc( &aes_ctx, NULL, 128 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_setkey_dec( NULL, key, 128 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_setkey_dec( &aes_ctx, NULL, 128 ) ); + +#if defined(MBEDTLS_CIPHER_MODE_XTS) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_xts_setkey_enc( NULL, key, 128 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_xts_setkey_enc( &xts_ctx, NULL, 128 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_xts_setkey_dec( NULL, key, 128 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_xts_setkey_dec( &xts_ctx, NULL, 128 ) ); +#endif + + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ecb( NULL, + valid_mode, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ecb( &aes_ctx, + invalid_mode, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ecb( &aes_ctx, + valid_mode, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ecb( &aes_ctx, + valid_mode, in, NULL ) ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cbc( NULL, + valid_mode, 16, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cbc( &aes_ctx, + invalid_mode, 16, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cbc( &aes_ctx, + valid_mode, 16, + NULL, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cbc( &aes_ctx, + valid_mode, 16, + out, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cbc( &aes_ctx, + valid_mode, 16, + out, in, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_XTS) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_xts( NULL, + valid_mode, 16, + in, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_xts( &xts_ctx, + invalid_mode, 16, + in, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_xts( &xts_ctx, + valid_mode, 16, + NULL, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_xts( &xts_ctx, + valid_mode, 16, + in, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_xts( &xts_ctx, + valid_mode, 16, + in, in, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_XTS */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb128( NULL, + valid_mode, 16, + &size, out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb128( &aes_ctx, + invalid_mode, 16, + &size, out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb128( &aes_ctx, + valid_mode, 16, + NULL, out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb128( &aes_ctx, + valid_mode, 16, + &size, NULL, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb128( &aes_ctx, + valid_mode, 16, + &size, out, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb128( &aes_ctx, + valid_mode, 16, + &size, out, in, NULL ) ); + + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb8( NULL, + valid_mode, 16, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb8( &aes_ctx, + invalid_mode, 16, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb8( &aes_ctx, + valid_mode, 16, + NULL, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb8( &aes_ctx, + valid_mode, 16, + out, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_cfb8( &aes_ctx, + valid_mode, 16, + out, in, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_OFB) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ofb( NULL, 16, + &size, out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ofb( &aes_ctx, 16, + NULL, out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ofb( &aes_ctx, 16, + &size, NULL, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ofb( &aes_ctx, 16, + &size, out, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ofb( &aes_ctx, 16, + &size, out, in, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_OFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ctr( NULL, 16, &size, out, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ctr( &aes_ctx, 16, NULL, out, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, NULL, + out, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out, + NULL, in, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out, + out, NULL, out ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_AES_BAD_INPUT_DATA, + mbedtls_aes_crypt_ctr( &aes_ctx, 16, &size, out, + out, in, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ +} +/* END_CASE */ + +/* BEGIN_CASE */ +void aes_misc_params( ) +{ +#if defined(MBEDTLS_CIPHER_MODE_CBC) || \ + defined(MBEDTLS_CIPHER_MODE_XTS) || \ + defined(MBEDTLS_CIPHER_MODE_CFB) || \ + defined(MBEDTLS_CIPHER_MODE_OFB) + mbedtls_aes_context aes_ctx; + const unsigned char in[16] = { 0 }; + unsigned char out[16]; +#endif +#if defined(MBEDTLS_CIPHER_MODE_XTS) + mbedtls_aes_xts_context xts_ctx; +#endif +#if defined(MBEDTLS_CIPHER_MODE_CFB) || \ + defined(MBEDTLS_CIPHER_MODE_OFB) + size_t size; +#endif + + /* These calls accept NULL */ + TEST_VALID_PARAM( mbedtls_aes_free( NULL ) ); +#if defined(MBEDTLS_CIPHER_MODE_XTS) + TEST_VALID_PARAM( mbedtls_aes_xts_free( NULL ) ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT, + 15, + out, in, out ) + == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); + TEST_ASSERT( mbedtls_aes_crypt_cbc( &aes_ctx, MBEDTLS_AES_ENCRYPT, + 17, + out, in, out ) + == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_XTS) + TEST_ASSERT( mbedtls_aes_crypt_xts( &xts_ctx, MBEDTLS_AES_ENCRYPT, + 15, + in, in, out ) + == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); + TEST_ASSERT( mbedtls_aes_crypt_xts( &xts_ctx, MBEDTLS_AES_ENCRYPT, + (1 << 24) + 1, + in, in, out ) + == MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + size = 16; + TEST_ASSERT( mbedtls_aes_crypt_cfb128( &aes_ctx, MBEDTLS_AES_ENCRYPT, 16, + &size, out, in, out ) + == MBEDTLS_ERR_AES_BAD_INPUT_DATA ); +#endif + +#if defined(MBEDTLS_CIPHER_MODE_OFB) + size = 16; + TEST_ASSERT( mbedtls_aes_crypt_ofb( &aes_ctx, 16, &size, out, in, out ) + == MBEDTLS_ERR_AES_BAD_INPUT_DATA ); +#endif +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void aes_selftest() +void aes_selftest( ) { TEST_ASSERT( mbedtls_aes_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.ofb.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.ofb.data new file mode 100644 index 0000000000..4b9d80e8d9 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.ofb.data @@ -0,0 +1,35 @@ +# NIST Special Publication 800-38A +# Recommendation for Block Cipher Modes of Operation +# Test Vectors - Appendix F, Section F.4 +OFB-AES128.Encrypt - Single block +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"2b7e151628aed2a6abf7158809cf4f3c":"000102030405060708090a0b0c0d0e0f":"6bc1bee22e409f96e93d7e117393172a":"3b3fd92eb72dad20333449f8e83cfb4a" + +OFB-AES128.Encrypt - Partial blocks - 7 bytes +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:5:"2b7e151628aed2a6abf7158809cf4f3c":"000102030405060708090a0b0c0d0e0f":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710":"3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e" + +OFB-AES128.Encrypt - Test NIST SP800-38A - F.4.1 +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"2b7e151628aed2a6abf7158809cf4f3c":"000102030405060708090a0b0c0d0e0f":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710":"3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e" + +OFB-AES128.Decrypt - Test NIST SP800-38A - F.4.2 +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"2b7e151628aed2a6abf7158809cf4f3c":"000102030405060708090a0b0c0d0e0f":"3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710" + +OFB-AES192.Encrypt - Test NIST SP800-38A - F.4.3 +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b":"000102030405060708090a0b0c0d0e0f":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710":"cdc80d6fddf18cab34c25909c99a4174fcc28b8d4c63837c09e81700c11004018d9a9aeac0f6596f559c6d4daf59a5f26d9f200857ca6c3e9cac524bd9acc92a" + +OFB-AES192.Decrypt - Test NIST SP800-38A - F.4.4 +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b":"000102030405060708090a0b0c0d0e0f":"cdc80d6fddf18cab34c25909c99a4174fcc28b8d4c63837c09e81700c11004018d9a9aeac0f6596f559c6d4daf59a5f26d9f200857ca6c3e9cac524bd9acc92a":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710" + +OFB-AES256.Encrypt - Test NIST SP800-38A - F.4.5 +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4":"000102030405060708090a0b0c0d0e0f":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710":"dc7e84bfda79164b7ecd8486985d38604febdc6740d20b3ac88f6ad82a4fb08d71ab47a086e86eedf39d1c5bba97c4080126141d67f37be8538f5a8be740e484" + +OFB-AES256.Decrypt - Test NIST SP800-38A - F.4.6 +depends_on:MBEDTLS_CIPHER_MODE_OFB +aes_encrypt_ofb:16:"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4":"000102030405060708090a0b0c0d0e0f":"dc7e84bfda79164b7ecd8486985d38604febdc6740d20b3ac88f6ad82a4fb08d71ab47a086e86eedf39d1c5bba97c4080126141d67f37be8538f5a8be740e484":"6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710" + diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.rest.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.rest.data index bbb222f101..6a76b43eb8 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.rest.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.rest.data @@ -10,6 +10,12 @@ aes_encrypt_cbc:"000000000000000000000000000000000000000000000000000000000000000 AES-256-CBC Decrypt (Invalid input length) aes_decrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"623a52fcea5d443e48d9181ab32c74":"":MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH +AES - Optional Parameter Validation (MBEDTLS_CHECK_PARAMS) +aes_check_params: + +AES - Mandatory Parameter Validation and Valid Parameters +aes_misc_params: + AES Selftest depends_on:MBEDTLS_SELF_TEST aes_selftest: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.xts.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.xts.data new file mode 100644 index 0000000000..647819e0de --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aes.xts.data @@ -0,0 +1,158 @@ +# +# Tests for expected errors (negative tests) +# +AES-128-XTS Encrypt Fail Sector Too Small (by 16 bytes) +aes_crypt_xts_size:0:MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH + +AES-128-XTS Encrypt Fail Sector Too Small (by 1 byte) +aes_crypt_xts_size:15:MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH + +AES-128-XTS Encrypt Fail Sector Too Large (by 1 byte) +aes_crypt_xts_size:16777217:MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH + +AES-128-XTS Encrypt Fail Sector Too Large (by 1 block) +aes_crypt_xts_size:16777232:MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH + +AES-0-XTS Setkey Fail Invalid Key Length +aes_crypt_xts_keysize:0:MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + +AES-4-XTS Setkey Fail Invalid Key Length +aes_crypt_xts_keysize:1:MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + +AES-64-XTS Setkey Fail Invalid Key Length +aes_crypt_xts_keysize:16:MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + +AES-192-XTS Setkey Fail Invalid Key Length +aes_crypt_xts_keysize:48:MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + +AES-384-XTS Setkey Fail Invalid Key Length +aes_crypt_xts_keysize:96:MBEDTLS_ERR_AES_INVALID_KEY_LENGTH + +# +# IEEE P1619/D16 Annex B Test Vectors +# http://grouper.ieee.org/groups/1619/email/pdf00086.pdf +# +# 128-bit keys with 32 byte sector +# +AES-128-XTS Encrypt IEEE P1619/D16 Vector 1 +aes_encrypt_xts:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"0000000000000000000000000000000000000000000000000000000000000000":"917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 2 +aes_encrypt_xts:"1111111111111111111111111111111122222222222222222222222222222222":"33333333330000000000000000000000":"4444444444444444444444444444444444444444444444444444444444444444":"c454185e6a16936e39334038acef838bfb186fff7480adc4289382ecd6d394f0" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 3 +aes_encrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f022222222222222222222222222222222":"33333333330000000000000000000000":"4444444444444444444444444444444444444444444444444444444444444444":"af85336b597afc1a900b2eb21ec949d292df4c047e0b21532186a5971a227a89" + +# +# 128-bit keys with 512 byte sector +# +AES-128-XTS Encrypt IEEE P1619/D16 Vector 4 +aes_encrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"00000000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"27a7479befa1d476489f308cd4cfa6e2a96e4bbe3208ff25287dd3819616e89cc78cf7f5e543445f8333d8fa7f56000005279fa5d8b5e4ad40e736ddb4d35412328063fd2aab53e5ea1e0a9f332500a5df9487d07a5c92cc512c8866c7e860ce93fdf166a24912b422976146ae20ce846bb7dc9ba94a767aaef20c0d61ad02655ea92dc4c4e41a8952c651d33174be51a10c421110e6d81588ede82103a252d8a750e8768defffed9122810aaeb99f9172af82b604dc4b8e51bcb08235a6f4341332e4ca60482a4ba1a03b3e65008fc5da76b70bf1690db4eae29c5f1badd03c5ccf2a55d705ddcd86d449511ceb7ec30bf12b1fa35b913f9f747a8afd1b130e94bff94effd01a91735ca1726acd0b197c4e5b03393697e126826fb6bbde8ecc1e08298516e2c9ed03ff3c1b7860f6de76d4cecd94c8119855ef5297ca67e9f3e7ff72b1e99785ca0a7e7720c5b36dc6d72cac9574c8cbbc2f801e23e56fd344b07f22154beba0f08ce8891e643ed995c94d9a69c9f1b5f499027a78572aeebd74d20cc39881c213ee770b1010e4bea718846977ae119f7a023ab58cca0ad752afe656bb3c17256a9f6e9bf19fdd5a38fc82bbe872c5539edb609ef4f79c203ebb140f2e583cb2ad15b4aa5b655016a8449277dbd477ef2c8d6c017db738b18deb4a427d1923ce3ff262735779a418f20a282df920147beabe421ee5319d0568" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 5 +aes_encrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"01000000000000000000000000000000":"27a7479befa1d476489f308cd4cfa6e2a96e4bbe3208ff25287dd3819616e89cc78cf7f5e543445f8333d8fa7f56000005279fa5d8b5e4ad40e736ddb4d35412328063fd2aab53e5ea1e0a9f332500a5df9487d07a5c92cc512c8866c7e860ce93fdf166a24912b422976146ae20ce846bb7dc9ba94a767aaef20c0d61ad02655ea92dc4c4e41a8952c651d33174be51a10c421110e6d81588ede82103a252d8a750e8768defffed9122810aaeb99f9172af82b604dc4b8e51bcb08235a6f4341332e4ca60482a4ba1a03b3e65008fc5da76b70bf1690db4eae29c5f1badd03c5ccf2a55d705ddcd86d449511ceb7ec30bf12b1fa35b913f9f747a8afd1b130e94bff94effd01a91735ca1726acd0b197c4e5b03393697e126826fb6bbde8ecc1e08298516e2c9ed03ff3c1b7860f6de76d4cecd94c8119855ef5297ca67e9f3e7ff72b1e99785ca0a7e7720c5b36dc6d72cac9574c8cbbc2f801e23e56fd344b07f22154beba0f08ce8891e643ed995c94d9a69c9f1b5f499027a78572aeebd74d20cc39881c213ee770b1010e4bea718846977ae119f7a023ab58cca0ad752afe656bb3c17256a9f6e9bf19fdd5a38fc82bbe872c5539edb609ef4f79c203ebb140f2e583cb2ad15b4aa5b655016a8449277dbd477ef2c8d6c017db738b18deb4a427d1923ce3ff262735779a418f20a282df920147beabe421ee5319d0568":"264d3ca8512194fec312c8c9891f279fefdd608d0c027b60483a3fa811d65ee59d52d9e40ec5672d81532b38b6b089ce951f0f9c35590b8b978d175213f329bb1c2fd30f2f7f30492a61a532a79f51d36f5e31a7c9a12c286082ff7d2394d18f783e1a8e72c722caaaa52d8f065657d2631fd25bfd8e5baad6e527d763517501c68c5edc3cdd55435c532d7125c8614deed9adaa3acade5888b87bef641c4c994c8091b5bcd387f3963fb5bc37aa922fbfe3df4e5b915e6eb514717bdd2a74079a5073f5c4bfd46adf7d282e7a393a52579d11a028da4d9cd9c77124f9648ee383b1ac763930e7162a8d37f350b2f74b8472cf09902063c6b32e8c2d9290cefbd7346d1c779a0df50edcde4531da07b099c638e83a755944df2aef1aa31752fd323dcb710fb4bfbb9d22b925bc3577e1b8949e729a90bbafeacf7f7879e7b1147e28ba0bae940db795a61b15ecf4df8db07b824bb062802cc98a9545bb2aaeed77cb3fc6db15dcd7d80d7d5bc406c4970a3478ada8899b329198eb61c193fb6275aa8ca340344a75a862aebe92eee1ce032fd950b47d7704a3876923b4ad62844bf4a09c4dbe8b4397184b7471360c9564880aedddb9baa4af2e75394b08cd32ff479c57a07d3eab5d54de5f9738b8d27f27a9f0ab11799d7b7ffefb2704c95c6ad12c39f1e867a4b7b1d7818a4b753dfd2a89ccb45e001a03a867b187f225dd" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 6 +aes_encrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"02000000000000000000000000000000":"264d3ca8512194fec312c8c9891f279fefdd608d0c027b60483a3fa811d65ee59d52d9e40ec5672d81532b38b6b089ce951f0f9c35590b8b978d175213f329bb1c2fd30f2f7f30492a61a532a79f51d36f5e31a7c9a12c286082ff7d2394d18f783e1a8e72c722caaaa52d8f065657d2631fd25bfd8e5baad6e527d763517501c68c5edc3cdd55435c532d7125c8614deed9adaa3acade5888b87bef641c4c994c8091b5bcd387f3963fb5bc37aa922fbfe3df4e5b915e6eb514717bdd2a74079a5073f5c4bfd46adf7d282e7a393a52579d11a028da4d9cd9c77124f9648ee383b1ac763930e7162a8d37f350b2f74b8472cf09902063c6b32e8c2d9290cefbd7346d1c779a0df50edcde4531da07b099c638e83a755944df2aef1aa31752fd323dcb710fb4bfbb9d22b925bc3577e1b8949e729a90bbafeacf7f7879e7b1147e28ba0bae940db795a61b15ecf4df8db07b824bb062802cc98a9545bb2aaeed77cb3fc6db15dcd7d80d7d5bc406c4970a3478ada8899b329198eb61c193fb6275aa8ca340344a75a862aebe92eee1ce032fd950b47d7704a3876923b4ad62844bf4a09c4dbe8b4397184b7471360c9564880aedddb9baa4af2e75394b08cd32ff479c57a07d3eab5d54de5f9738b8d27f27a9f0ab11799d7b7ffefb2704c95c6ad12c39f1e867a4b7b1d7818a4b753dfd2a89ccb45e001a03a867b187f225dd":"fa762a3680b76007928ed4a4f49a9456031b704782e65e16cecb54ed7d017b5e18abd67b338e81078f21edb7868d901ebe9c731a7c18b5e6dec1d6a72e078ac9a4262f860beefa14f4e821018272e411a951502b6e79066e84252c3346f3aa62344351a291d4bedc7a07618bdea2af63145cc7a4b8d4070691ae890cd65733e7946e9021a1dffc4c59f159425ee6d50ca9b135fa6162cea18a939838dc000fb386fad086acce5ac07cb2ece7fd580b00cfa5e98589631dc25e8e2a3daf2ffdec26531659912c9d8f7a15e5865ea8fb5816d6207052bd7128cd743c12c8118791a4736811935eb982a532349e31dd401e0b660a568cb1a4711f552f55ded59f1f15bf7196b3ca12a91e488ef59d64f3a02bf45239499ac6176ae321c4a211ec545365971c5d3f4f09d4eb139bfdf2073d33180b21002b65cc9865e76cb24cd92c874c24c18350399a936ab3637079295d76c417776b94efce3a0ef7206b15110519655c956cbd8b2489405ee2b09a6b6eebe0c53790a12a8998378b33a5b71159625f4ba49d2a2fdba59fbf0897bc7aabd8d707dc140a80f0f309f835d3da54ab584e501dfa0ee977fec543f74186a802b9a37adb3e8291eca04d66520d229e60401e7282bef486ae059aa70696e0e305d777140a7a883ecdcb69b9ff938e8a4231864c69ca2c2043bed007ff3e605e014bcf518138dc3a25c5e236171a2d01d6" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 7 +aes_encrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"fd000000000000000000000000000000":"8e41b78c390b5af9d758bb214a67e9f6bf7727b09ac6124084c37611398fa45daad94868600ed391fb1acd4857a95b466e62ef9f4b377244d1c152e7b30d731aad30c716d214b707aed99eb5b5e580b3e887cf7497465651d4b60e6042051da3693c3b78c14489543be8b6ad0ba629565bba202313ba7b0d0c94a3252b676f46cc02ce0f8a7d34c0ed229129673c1f61aed579d08a9203a25aac3a77e9db60267996db38df637356d9dcd1632e369939f2a29d89345c66e05066f1a3677aef18dea4113faeb629e46721a66d0a7e785d3e29af2594eb67dfa982affe0aac058f6e15864269b135418261fc3afb089472cf68c45dd7f231c6249ba0255e1e033833fc4d00a3fe02132d7bc3873614b8aee34273581ea0325c81f0270affa13641d052d36f0757d484014354d02d6883ca15c24d8c3956b1bd027bcf41f151fd8023c5340e5606f37e90fdb87c86fb4fa634b3718a30bace06a66eaf8f63c4aa3b637826a87fe8cfa44282e92cb1615af3a28e53bc74c7cba1a0977be9065d0c1a5dec6c54ae38d37f37aa35283e048e5530a85c4e7a29d7b92ec0c3169cdf2a805c7604bce60049b9fb7b8eaac10f51ae23794ceba68bb58112e293b9b692ca721b37c662f8574ed4dba6f88e170881c82cddc1034a0ca7e284bf0962b6b26292d836fa9f73c1ac770eef0f2d3a1eaf61d3e03555fd424eedd67e18a18094f888":"d55f684f81f4426e9fde92a5ff02df2ac896af63962888a97910c1379e20b0a3b1db613fb7fe2e07004329ea5c22bfd33e3dbe4cf58cc608c2c26c19a2e2fe22f98732c2b5cb844cc6c0702d91e1d50fc4382a7eba5635cd602432a2306ac4ce82f8d70c8d9bc15f918fe71e74c622d5cf71178bf6e0b9cc9f2b41dd8dbe441c41cd0c73a6dc47a348f6702f9d0e9b1b1431e948e299b9ec2272ab2c5f0c7be86affa5dec87a0bee81d3d50007edaa2bcfccb35605155ff36ed8edd4a40dcd4b243acd11b2b987bdbfaf91a7cac27e9c5aea525ee53de7b2d3332c8644402b823e94a7db26276d2d23aa07180f76b4fd29b9c0823099c9d62c519880aee7e9697617c1497d47bf3e571950311421b6b734d38b0db91eb85331b91ea9f61530f54512a5a52a4bad589eb69781d537f23297bb459bdad2948a29e1550bf4787e0be95bb173cf5fab17dab7a13a052a63453d97ccec1a321954886b7a1299faaeecae35c6eaaca753b041b5e5f093bf83397fd21dd6b3012066fcc058cc32c3b09d7562dee29509b5839392c9ff05f51f3166aaac4ac5f238038a3045e6f72e48ef0fe8bc675e82c318a268e43970271bf119b81bf6a982746554f84e72b9f00280a320a08142923c23c883423ff949827f29bbacdc1ccdb04938ce6098c95ba6b32528f4ef78eed778b2e122ddfd1cbdd11d1c0a6783e011fc536d63d053260637" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 8 +aes_encrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"fe000000000000000000000000000000":"d55f684f81f4426e9fde92a5ff02df2ac896af63962888a97910c1379e20b0a3b1db613fb7fe2e07004329ea5c22bfd33e3dbe4cf58cc608c2c26c19a2e2fe22f98732c2b5cb844cc6c0702d91e1d50fc4382a7eba5635cd602432a2306ac4ce82f8d70c8d9bc15f918fe71e74c622d5cf71178bf6e0b9cc9f2b41dd8dbe441c41cd0c73a6dc47a348f6702f9d0e9b1b1431e948e299b9ec2272ab2c5f0c7be86affa5dec87a0bee81d3d50007edaa2bcfccb35605155ff36ed8edd4a40dcd4b243acd11b2b987bdbfaf91a7cac27e9c5aea525ee53de7b2d3332c8644402b823e94a7db26276d2d23aa07180f76b4fd29b9c0823099c9d62c519880aee7e9697617c1497d47bf3e571950311421b6b734d38b0db91eb85331b91ea9f61530f54512a5a52a4bad589eb69781d537f23297bb459bdad2948a29e1550bf4787e0be95bb173cf5fab17dab7a13a052a63453d97ccec1a321954886b7a1299faaeecae35c6eaaca753b041b5e5f093bf83397fd21dd6b3012066fcc058cc32c3b09d7562dee29509b5839392c9ff05f51f3166aaac4ac5f238038a3045e6f72e48ef0fe8bc675e82c318a268e43970271bf119b81bf6a982746554f84e72b9f00280a320a08142923c23c883423ff949827f29bbacdc1ccdb04938ce6098c95ba6b32528f4ef78eed778b2e122ddfd1cbdd11d1c0a6783e011fc536d63d053260637":"72efc1ebfe1ee25975a6eb3aa8589dda2b261f1c85bdab442a9e5b2dd1d7c3957a16fc08e526d4b1223f1b1232a11af274c3d70dac57f83e0983c498f1a6f1aecb021c3e70085a1e527f1ce41ee5911a82020161529cd82773762daf5459de94a0a82adae7e1703c808543c29ed6fb32d9e004327c1355180c995a07741493a09c21ba01a387882da4f62534b87bb15d60d197201c0fd3bf30c1500a3ecfecdd66d8721f90bcc4c17ee925c61b0a03727a9c0d5f5ca462fbfa0af1c2513a9d9d4b5345bd27a5f6e653f751693e6b6a2b8ead57d511e00e58c45b7b8d005af79288f5c7c22fd4f1bf7a898b03a5634c6a1ae3f9fae5de4f296a2896b23e7ed43ed14fa5a2803f4d28f0d3ffcf24757677aebdb47bb388378708948a8d4126ed1839e0da29a537a8c198b3c66ab00712dd261674bf45a73d67f76914f830ca014b65596f27e4cf62de66125a5566df9975155628b400fbfb3a29040ed50faffdbb18aece7c5c44693260aab386c0a37b11b114f1c415aebb653be468179428d43a4d8bc3ec38813eca30a13cf1bb18d524f1992d44d8b1a42ea30b22e6c95b199d8d182f8840b09d059585c31ad691fa0619ff038aca2c39a943421157361717c49d322028a74648113bd8c9d7ec77cf3c89c1ec8718ceff8516d96b34c3c614f10699c9abc4ed0411506223bea16af35c883accdbe1104eef0cfdb54e12fb230a" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 9 +aes_encrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"ff000000000000000000000000000000":"72efc1ebfe1ee25975a6eb3aa8589dda2b261f1c85bdab442a9e5b2dd1d7c3957a16fc08e526d4b1223f1b1232a11af274c3d70dac57f83e0983c498f1a6f1aecb021c3e70085a1e527f1ce41ee5911a82020161529cd82773762daf5459de94a0a82adae7e1703c808543c29ed6fb32d9e004327c1355180c995a07741493a09c21ba01a387882da4f62534b87bb15d60d197201c0fd3bf30c1500a3ecfecdd66d8721f90bcc4c17ee925c61b0a03727a9c0d5f5ca462fbfa0af1c2513a9d9d4b5345bd27a5f6e653f751693e6b6a2b8ead57d511e00e58c45b7b8d005af79288f5c7c22fd4f1bf7a898b03a5634c6a1ae3f9fae5de4f296a2896b23e7ed43ed14fa5a2803f4d28f0d3ffcf24757677aebdb47bb388378708948a8d4126ed1839e0da29a537a8c198b3c66ab00712dd261674bf45a73d67f76914f830ca014b65596f27e4cf62de66125a5566df9975155628b400fbfb3a29040ed50faffdbb18aece7c5c44693260aab386c0a37b11b114f1c415aebb653be468179428d43a4d8bc3ec38813eca30a13cf1bb18d524f1992d44d8b1a42ea30b22e6c95b199d8d182f8840b09d059585c31ad691fa0619ff038aca2c39a943421157361717c49d322028a74648113bd8c9d7ec77cf3c89c1ec8718ceff8516d96b34c3c614f10699c9abc4ed0411506223bea16af35c883accdbe1104eef0cfdb54e12fb230a":"3260ae8dad1f4a32c5cafe3ab0eb95549d461a67ceb9e5aa2d3afb62dece0553193ba50c75be251e08d1d08f1088576c7efdfaaf3f459559571e12511753b07af073f35da06af0ce0bbf6b8f5ccc5cea500ec1b211bd51f63b606bf6528796ca12173ba39b8935ee44ccce646f90a45bf9ccc567f0ace13dc2d53ebeedc81f58b2e41179dddf0d5a5c42f5d8506c1a5d2f8f59f3ea873cbcd0eec19acbf325423bd3dcb8c2b1bf1d1eaed0eba7f0698e4314fbeb2f1566d1b9253008cbccf45a2b0d9c5c9c21474f4076e02be26050b99dee4fd68a4cf890e496e4fcae7b70f94ea5a9062da0daeba1993d2ccd1dd3c244b8428801495a58b216547e7e847c46d1d756377b6242d2e5fb83bf752b54e0df71e889f3a2bb0f4c10805bf3c590376e3c24e22ff57f7fa965577375325cea5d920db94b9c336b455f6e894c01866fe9fbb8c8d3f70a2957285f6dfb5dcd8cbf54782f8fe7766d4723819913ac773421e3a31095866bad22c86a6036b2518b2059b4229d18c8c2ccbdf906c6cc6e82464ee57bddb0bebcb1dc645325bfb3e665ef7251082c88ebb1cf203bd779fdd38675713c8daadd17e1cabee432b09787b6ddf3304e38b731b45df5df51b78fcfb3d32466028d0ba36555e7e11ab0ee0666061d1645d962444bc47a38188930a84b4d561395c73c087021927ca638b7afc8a8679ccb84c26555440ec7f10445cd" + +# +# 256-bit keys with 512 byte sector +# +AES-256-XTS Encrypt IEEE P1619/D16 Vector 10 +aes_encrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ff000000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"1c3b3a102f770386e4836c99e370cf9bea00803f5e482357a4ae12d414a3e63b5d31e276f8fe4a8d66b317f9ac683f44680a86ac35adfc3345befecb4bb188fd5776926c49a3095eb108fd1098baec70aaa66999a72a82f27d848b21d4a741b0c5cd4d5fff9dac89aeba122961d03a757123e9870f8acf1000020887891429ca2a3e7a7d7df7b10355165c8b9a6d0a7de8b062c4500dc4cd120c0f7418dae3d0b5781c34803fa75421c790dfe1de1834f280d7667b327f6c8cd7557e12ac3a0f93ec05c52e0493ef31a12d3d9260f79a289d6a379bc70c50841473d1a8cc81ec583e9645e07b8d9670655ba5bbcfecc6dc3966380ad8fecb17b6ba02469a020a84e18e8f84252070c13e9f1f289be54fbc481457778f616015e1327a02b140f1505eb309326d68378f8374595c849d84f4c333ec4423885143cb47bd71c5edae9be69a2ffeceb1bec9de244fbe15992b11b77c040f12bd8f6a975a44a0f90c29a9abc3d4d893927284c58754cce294529f8614dcd2aba991925fedc4ae74ffac6e333b93eb4aff0479da9a410e4450e0dd7ae4c6e2910900575da401fc07059f645e8b7e9bfdef33943054ff84011493c27b3429eaedb4ed5376441a77ed43851ad77f16f541dfd269d50d6a5f14fb0aab1cbb4c1550be97f7ab4066193c4caa773dad38014bd2092fa755c824bb5e54c4f36ffda9fcea70b9c6e693e148c151" + +AES-256-XTS Encrypt IEEE P1619/D16 Vector 11 +aes_encrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffff0000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"77a31251618a15e6b92d1d66dffe7b50b50bad552305ba0217a610688eff7e11e1d0225438e093242d6db274fde801d4cae06f2092c728b2478559df58e837c2469ee4a4fa794e4bbc7f39bc026e3cb72c33b0888f25b4acf56a2a9804f1ce6d3d6e1dc6ca181d4b546179d55544aa7760c40d06741539c7e3cd9d2f6650b2013fd0eeb8c2b8e3d8d240ccae2d4c98320a7442e1c8d75a42d6e6cfa4c2eca1798d158c7aecdf82490f24bb9b38e108bcda12c3faf9a21141c3613b58367f922aaa26cd22f23d708dae699ad7cb40a8ad0b6e2784973dcb605684c08b8d6998c69aac049921871ebb65301a4619ca80ecb485a31d744223ce8ddc2394828d6a80470c092f5ba413c3378fa6054255c6f9df4495862bbb3287681f931b687c888abf844dfc8fc28331e579928cd12bd2390ae123cf03818d14dedde5c0c24c8ab018bfca75ca096f2d531f3d1619e785f1ada437cab92e980558b3dce1474afb75bfedbf8ff54cb2618e0244c9ac0d3c66fb51598cd2db11f9be39791abe447c63094f7c453b7ff87cb5bb36b7c79efb0872d17058b83b15ab0866ad8a58656c5a7e20dbdf308b2461d97c0ec0024a2715055249cf3b478ddd4740de654f75ca686e0d7345c69ed50cdc2a8b332b1f8824108ac937eb050585608ee734097fc09054fbff89eeaeea791f4a7ab1f9868294a4f9e27b42af8100cb9d59cef9645803" + +AES-256-XTS Encrypt IEEE P1619/D16 Vector 12 +aes_encrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffffff00000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"e387aaa58ba483afa7e8eb469778317ecf4cf573aa9d4eac23f2cdf914e4e200a8b490e42ee646802dc6ee2b471b278195d60918ececb44bf79966f83faba0499298ebc699c0c8634715a320bb4f075d622e74c8c932004f25b41e361025b5a87815391f6108fc4afa6a05d9303c6ba68a128a55705d415985832fdeaae6c8e19110e84d1b1f199a2692119edc96132658f09da7c623efcec712537a3d94c0bf5d7e352ec94ae5797fdb377dc1551150721adf15bd26a8efc2fcaad56881fa9e62462c28f30ae1ceaca93c345cf243b73f542e2074a705bd2643bb9f7cc79bb6e7091ea6e232df0f9ad0d6cf502327876d82207abf2115cdacf6d5a48f6c1879a65b115f0f8b3cb3c59d15dd8c769bc014795a1837f3901b5845eb491adfefe097b1fa30a12fc1f65ba22905031539971a10f2f36c321bb51331cdefb39e3964c7ef079994f5b69b2edd83a71ef549971ee93f44eac3938fcdd61d01fa71799da3a8091c4c48aa9ed263ff0749df95d44fef6a0bb578ec69456aa5408ae32c7af08ad7ba8921287e3bbee31b767be06a0e705c864a769137df28292283ea81a2480241b44d9921cdbec1bc28dc1fda114bd8e5217ac9d8ebafa720e9da4f9ace231cc949e5b96fe76ffc21063fddc83a6b8679c00d35e09576a875305bed5f36ed242c8900dd1fa965bc950dfce09b132263a1eef52dd6888c309f5a7d712826" + +AES-256-XTS Encrypt IEEE P1619/D16 Vector 13 +aes_encrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffffffff000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"bf53d2dade78e822a4d949a9bc6766b01b06a8ef70d26748c6a7fc36d80ae4c5520f7c4ab0ac8544424fa405162fef5a6b7f229498063618d39f0003cb5fb8d1c86b643497da1ff945c8d3bedeca4f479702a7a735f043ddb1d6aaade3c4a0ac7ca7f3fa5279bef56f82cd7a2f38672e824814e10700300a055e1630b8f1cb0e919f5e942010a416e2bf48cb46993d3cb6a51c19bacf864785a00bc2ecff15d350875b246ed53e68be6f55bd7e05cfc2b2ed6432198a6444b6d8c247fab941f569768b5c429366f1d3f00f0345b96123d56204c01c63b22ce78baf116e525ed90fdea39fa469494d3866c31e05f295ff21fea8d4e6e13d67e47ce722e9698a1c1048d68ebcde76b86fcf976eab8aa9790268b7068e017a8b9b749409514f1053027fd16c3786ea1bac5f15cb79711ee2abe82f5cf8b13ae73030ef5b9e4457e75d1304f988d62dd6fc4b94ed38ba831da4b7634971b6cd8ec325d9c61c00f1df73627ed3745a5e8489f3a95c69639c32cd6e1d537a85f75cc844726e8a72fc0077ad22000f1d5078f6b866318c668f1ad03d5a5fced5219f2eabbd0aa5c0f460d183f04404a0d6f469558e81fab24a167905ab4c7878502ad3e38fdbe62a41556cec37325759533ce8f25f367c87bb5578d667ae93f9e2fd99bcbc5f2fbba88cf6516139420fcff3b7361d86322c4bd84c82f335abb152c4a93411373aaa8220" + +AES-256-XTS Encrypt IEEE P1619/D16 Vector 14 +aes_encrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffffffffff0000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"64497e5a831e4a932c09be3e5393376daa599548b816031d224bbf50a818ed2350eae7e96087c8a0db51ad290bd00c1ac1620857635bf246c176ab463be30b808da548081ac847b158e1264be25bb0910bbc92647108089415d45fab1b3d2604e8a8eff1ae4020cfa39936b66827b23f371b92200be90251e6d73c5f86de5fd4a950781933d79a28272b782a2ec313efdfcc0628f43d744c2dc2ff3dcb66999b50c7ca895b0c64791eeaa5f29499fb1c026f84ce5b5c72ba1083cddb5ce45434631665c333b60b11593fb253c5179a2c8db813782a004856a1653011e93fb6d876c18366dd8683f53412c0c180f9c848592d593f8609ca736317d356e13e2bff3a9f59cd9aeb19cd482593d8c46128bb32423b37a9adfb482b99453fbe25a41bf6feb4aa0bef5ed24bf73c762978025482c13115e4015aac992e5613a3b5c2f685b84795cb6e9b2656d8c88157e52c42f978d8634c43d06fea928f2822e465aa6576e9bf419384506cc3ce3c54ac1a6f67dc66f3b30191e698380bc999b05abce19dc0c6dcc2dd001ec535ba18deb2df1a101023108318c75dc98611a09dc48a0acdec676fabdf222f07e026f059b672b56e5cbc8e1d21bbd867dd927212054681d70ea737134cdfce93b6f82ae22423274e58a0821cc5502e2d0ab4585e94de6975be5e0b4efce51cd3e70c25a1fbbbd609d273ad5b0d59631c531f6a0a57b9" + +# +# 128-bit keys with sector size not evenly divisible by 16 bytes +# +AES-128-XTS Encrypt IEEE P1619/D16 Vector 15 +aes_encrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f10":"6c1625db4671522d3d7599601de7ca09ed" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 16 +aes_encrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f1011":"d069444b7a7e0cab09e24447d24deb1fedbf" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 17 +aes_encrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f101112":"e5df1351c0544ba1350b3363cd8ef4beedbf9d" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 18 +aes_encrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f10111213":"9d84c813f719aa2c7be3f66171c7c5c2edbf9dac" + +AES-128-XTS Encrypt IEEE P1619/D16 Vector 19 +aes_encrypt_xts:"e0e1e2e3e4e5e6e7e8e9eaebecedeeefc0c1c2c3c4c5c6c7c8c9cacbcccdcecf":"21436587a90000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"38b45812ef43a05bd957e545907e223b954ab4aaf088303ad910eadf14b42be68b2461149d8c8ba85f992be970bc621f1b06573f63e867bf5875acafa04e42ccbd7bd3c2a0fb1fff791ec5ec36c66ae4ac1e806d81fbf709dbe29e471fad38549c8e66f5345d7c1eb94f405d1ec785cc6f6a68f6254dd8339f9d84057e01a17741990482999516b5611a38f41bb6478e6f173f320805dd71b1932fc333cb9ee39936beea9ad96fa10fb4112b901734ddad40bc1878995f8e11aee7d141a2f5d48b7a4e1e7f0b2c04830e69a4fd1378411c2f287edf48c6c4e5c247a19680f7fe41cefbd49b582106e3616cbbe4dfb2344b2ae9519391f3e0fb4922254b1d6d2d19c6d4d537b3a26f3bcc51588b32f3eca0829b6a5ac72578fb814fb43cf80d64a233e3f997a3f02683342f2b33d25b492536b93becb2f5e1a8b82f5b883342729e8ae09d16938841a21a97fb543eea3bbff59f13c1a18449e398701c1ad51648346cbc04c27bb2da3b93a1372ccae548fb53bee476f9e9c91773b1bb19828394d55d3e1a20ed69113a860b6829ffa847224604435070221b257e8dff783615d2cae4803a93aa4334ab482a0afac9c0aeda70b45a481df5dec5df8cc0f423c77a5fd46cd312021d4b438862419a791be03bb4d97c0e59578542531ba466a83baf92cefc151b5cc1611a167893819b63fb8a6b18e86de60290fa72b797b0ce59f3" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 1 +aes_decrypt_xts:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"0000000000000000000000000000000000000000000000000000000000000000":"917cf69ebd68b2ec9b9fe9a3eadda692cd43d2f59598ed858c02c2652fbf922e" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 2 +aes_decrypt_xts:"1111111111111111111111111111111122222222222222222222222222222222":"33333333330000000000000000000000":"4444444444444444444444444444444444444444444444444444444444444444":"c454185e6a16936e39334038acef838bfb186fff7480adc4289382ecd6d394f0" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 3 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"00000000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"27a7479befa1d476489f308cd4cfa6e2a96e4bbe3208ff25287dd3819616e89cc78cf7f5e543445f8333d8fa7f56000005279fa5d8b5e4ad40e736ddb4d35412328063fd2aab53e5ea1e0a9f332500a5df9487d07a5c92cc512c8866c7e860ce93fdf166a24912b422976146ae20ce846bb7dc9ba94a767aaef20c0d61ad02655ea92dc4c4e41a8952c651d33174be51a10c421110e6d81588ede82103a252d8a750e8768defffed9122810aaeb99f9172af82b604dc4b8e51bcb08235a6f4341332e4ca60482a4ba1a03b3e65008fc5da76b70bf1690db4eae29c5f1badd03c5ccf2a55d705ddcd86d449511ceb7ec30bf12b1fa35b913f9f747a8afd1b130e94bff94effd01a91735ca1726acd0b197c4e5b03393697e126826fb6bbde8ecc1e08298516e2c9ed03ff3c1b7860f6de76d4cecd94c8119855ef5297ca67e9f3e7ff72b1e99785ca0a7e7720c5b36dc6d72cac9574c8cbbc2f801e23e56fd344b07f22154beba0f08ce8891e643ed995c94d9a69c9f1b5f499027a78572aeebd74d20cc39881c213ee770b1010e4bea718846977ae119f7a023ab58cca0ad752afe656bb3c17256a9f6e9bf19fdd5a38fc82bbe872c5539edb609ef4f79c203ebb140f2e583cb2ad15b4aa5b655016a8449277dbd477ef2c8d6c017db738b18deb4a427d1923ce3ff262735779a418f20a282df920147beabe421ee5319d0568" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 4 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"00000000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"27a7479befa1d476489f308cd4cfa6e2a96e4bbe3208ff25287dd3819616e89cc78cf7f5e543445f8333d8fa7f56000005279fa5d8b5e4ad40e736ddb4d35412328063fd2aab53e5ea1e0a9f332500a5df9487d07a5c92cc512c8866c7e860ce93fdf166a24912b422976146ae20ce846bb7dc9ba94a767aaef20c0d61ad02655ea92dc4c4e41a8952c651d33174be51a10c421110e6d81588ede82103a252d8a750e8768defffed9122810aaeb99f9172af82b604dc4b8e51bcb08235a6f4341332e4ca60482a4ba1a03b3e65008fc5da76b70bf1690db4eae29c5f1badd03c5ccf2a55d705ddcd86d449511ceb7ec30bf12b1fa35b913f9f747a8afd1b130e94bff94effd01a91735ca1726acd0b197c4e5b03393697e126826fb6bbde8ecc1e08298516e2c9ed03ff3c1b7860f6de76d4cecd94c8119855ef5297ca67e9f3e7ff72b1e99785ca0a7e7720c5b36dc6d72cac9574c8cbbc2f801e23e56fd344b07f22154beba0f08ce8891e643ed995c94d9a69c9f1b5f499027a78572aeebd74d20cc39881c213ee770b1010e4bea718846977ae119f7a023ab58cca0ad752afe656bb3c17256a9f6e9bf19fdd5a38fc82bbe872c5539edb609ef4f79c203ebb140f2e583cb2ad15b4aa5b655016a8449277dbd477ef2c8d6c017db738b18deb4a427d1923ce3ff262735779a418f20a282df920147beabe421ee5319d0568" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 5 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"01000000000000000000000000000000":"27a7479befa1d476489f308cd4cfa6e2a96e4bbe3208ff25287dd3819616e89cc78cf7f5e543445f8333d8fa7f56000005279fa5d8b5e4ad40e736ddb4d35412328063fd2aab53e5ea1e0a9f332500a5df9487d07a5c92cc512c8866c7e860ce93fdf166a24912b422976146ae20ce846bb7dc9ba94a767aaef20c0d61ad02655ea92dc4c4e41a8952c651d33174be51a10c421110e6d81588ede82103a252d8a750e8768defffed9122810aaeb99f9172af82b604dc4b8e51bcb08235a6f4341332e4ca60482a4ba1a03b3e65008fc5da76b70bf1690db4eae29c5f1badd03c5ccf2a55d705ddcd86d449511ceb7ec30bf12b1fa35b913f9f747a8afd1b130e94bff94effd01a91735ca1726acd0b197c4e5b03393697e126826fb6bbde8ecc1e08298516e2c9ed03ff3c1b7860f6de76d4cecd94c8119855ef5297ca67e9f3e7ff72b1e99785ca0a7e7720c5b36dc6d72cac9574c8cbbc2f801e23e56fd344b07f22154beba0f08ce8891e643ed995c94d9a69c9f1b5f499027a78572aeebd74d20cc39881c213ee770b1010e4bea718846977ae119f7a023ab58cca0ad752afe656bb3c17256a9f6e9bf19fdd5a38fc82bbe872c5539edb609ef4f79c203ebb140f2e583cb2ad15b4aa5b655016a8449277dbd477ef2c8d6c017db738b18deb4a427d1923ce3ff262735779a418f20a282df920147beabe421ee5319d0568":"264d3ca8512194fec312c8c9891f279fefdd608d0c027b60483a3fa811d65ee59d52d9e40ec5672d81532b38b6b089ce951f0f9c35590b8b978d175213f329bb1c2fd30f2f7f30492a61a532a79f51d36f5e31a7c9a12c286082ff7d2394d18f783e1a8e72c722caaaa52d8f065657d2631fd25bfd8e5baad6e527d763517501c68c5edc3cdd55435c532d7125c8614deed9adaa3acade5888b87bef641c4c994c8091b5bcd387f3963fb5bc37aa922fbfe3df4e5b915e6eb514717bdd2a74079a5073f5c4bfd46adf7d282e7a393a52579d11a028da4d9cd9c77124f9648ee383b1ac763930e7162a8d37f350b2f74b8472cf09902063c6b32e8c2d9290cefbd7346d1c779a0df50edcde4531da07b099c638e83a755944df2aef1aa31752fd323dcb710fb4bfbb9d22b925bc3577e1b8949e729a90bbafeacf7f7879e7b1147e28ba0bae940db795a61b15ecf4df8db07b824bb062802cc98a9545bb2aaeed77cb3fc6db15dcd7d80d7d5bc406c4970a3478ada8899b329198eb61c193fb6275aa8ca340344a75a862aebe92eee1ce032fd950b47d7704a3876923b4ad62844bf4a09c4dbe8b4397184b7471360c9564880aedddb9baa4af2e75394b08cd32ff479c57a07d3eab5d54de5f9738b8d27f27a9f0ab11799d7b7ffefb2704c95c6ad12c39f1e867a4b7b1d7818a4b753dfd2a89ccb45e001a03a867b187f225dd" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 6 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"02000000000000000000000000000000":"264d3ca8512194fec312c8c9891f279fefdd608d0c027b60483a3fa811d65ee59d52d9e40ec5672d81532b38b6b089ce951f0f9c35590b8b978d175213f329bb1c2fd30f2f7f30492a61a532a79f51d36f5e31a7c9a12c286082ff7d2394d18f783e1a8e72c722caaaa52d8f065657d2631fd25bfd8e5baad6e527d763517501c68c5edc3cdd55435c532d7125c8614deed9adaa3acade5888b87bef641c4c994c8091b5bcd387f3963fb5bc37aa922fbfe3df4e5b915e6eb514717bdd2a74079a5073f5c4bfd46adf7d282e7a393a52579d11a028da4d9cd9c77124f9648ee383b1ac763930e7162a8d37f350b2f74b8472cf09902063c6b32e8c2d9290cefbd7346d1c779a0df50edcde4531da07b099c638e83a755944df2aef1aa31752fd323dcb710fb4bfbb9d22b925bc3577e1b8949e729a90bbafeacf7f7879e7b1147e28ba0bae940db795a61b15ecf4df8db07b824bb062802cc98a9545bb2aaeed77cb3fc6db15dcd7d80d7d5bc406c4970a3478ada8899b329198eb61c193fb6275aa8ca340344a75a862aebe92eee1ce032fd950b47d7704a3876923b4ad62844bf4a09c4dbe8b4397184b7471360c9564880aedddb9baa4af2e75394b08cd32ff479c57a07d3eab5d54de5f9738b8d27f27a9f0ab11799d7b7ffefb2704c95c6ad12c39f1e867a4b7b1d7818a4b753dfd2a89ccb45e001a03a867b187f225dd":"fa762a3680b76007928ed4a4f49a9456031b704782e65e16cecb54ed7d017b5e18abd67b338e81078f21edb7868d901ebe9c731a7c18b5e6dec1d6a72e078ac9a4262f860beefa14f4e821018272e411a951502b6e79066e84252c3346f3aa62344351a291d4bedc7a07618bdea2af63145cc7a4b8d4070691ae890cd65733e7946e9021a1dffc4c59f159425ee6d50ca9b135fa6162cea18a939838dc000fb386fad086acce5ac07cb2ece7fd580b00cfa5e98589631dc25e8e2a3daf2ffdec26531659912c9d8f7a15e5865ea8fb5816d6207052bd7128cd743c12c8118791a4736811935eb982a532349e31dd401e0b660a568cb1a4711f552f55ded59f1f15bf7196b3ca12a91e488ef59d64f3a02bf45239499ac6176ae321c4a211ec545365971c5d3f4f09d4eb139bfdf2073d33180b21002b65cc9865e76cb24cd92c874c24c18350399a936ab3637079295d76c417776b94efce3a0ef7206b15110519655c956cbd8b2489405ee2b09a6b6eebe0c53790a12a8998378b33a5b71159625f4ba49d2a2fdba59fbf0897bc7aabd8d707dc140a80f0f309f835d3da54ab584e501dfa0ee977fec543f74186a802b9a37adb3e8291eca04d66520d229e60401e7282bef486ae059aa70696e0e305d777140a7a883ecdcb69b9ff938e8a4231864c69ca2c2043bed007ff3e605e014bcf518138dc3a25c5e236171a2d01d6" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 7 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"fd000000000000000000000000000000":"8e41b78c390b5af9d758bb214a67e9f6bf7727b09ac6124084c37611398fa45daad94868600ed391fb1acd4857a95b466e62ef9f4b377244d1c152e7b30d731aad30c716d214b707aed99eb5b5e580b3e887cf7497465651d4b60e6042051da3693c3b78c14489543be8b6ad0ba629565bba202313ba7b0d0c94a3252b676f46cc02ce0f8a7d34c0ed229129673c1f61aed579d08a9203a25aac3a77e9db60267996db38df637356d9dcd1632e369939f2a29d89345c66e05066f1a3677aef18dea4113faeb629e46721a66d0a7e785d3e29af2594eb67dfa982affe0aac058f6e15864269b135418261fc3afb089472cf68c45dd7f231c6249ba0255e1e033833fc4d00a3fe02132d7bc3873614b8aee34273581ea0325c81f0270affa13641d052d36f0757d484014354d02d6883ca15c24d8c3956b1bd027bcf41f151fd8023c5340e5606f37e90fdb87c86fb4fa634b3718a30bace06a66eaf8f63c4aa3b637826a87fe8cfa44282e92cb1615af3a28e53bc74c7cba1a0977be9065d0c1a5dec6c54ae38d37f37aa35283e048e5530a85c4e7a29d7b92ec0c3169cdf2a805c7604bce60049b9fb7b8eaac10f51ae23794ceba68bb58112e293b9b692ca721b37c662f8574ed4dba6f88e170881c82cddc1034a0ca7e284bf0962b6b26292d836fa9f73c1ac770eef0f2d3a1eaf61d3e03555fd424eedd67e18a18094f888":"d55f684f81f4426e9fde92a5ff02df2ac896af63962888a97910c1379e20b0a3b1db613fb7fe2e07004329ea5c22bfd33e3dbe4cf58cc608c2c26c19a2e2fe22f98732c2b5cb844cc6c0702d91e1d50fc4382a7eba5635cd602432a2306ac4ce82f8d70c8d9bc15f918fe71e74c622d5cf71178bf6e0b9cc9f2b41dd8dbe441c41cd0c73a6dc47a348f6702f9d0e9b1b1431e948e299b9ec2272ab2c5f0c7be86affa5dec87a0bee81d3d50007edaa2bcfccb35605155ff36ed8edd4a40dcd4b243acd11b2b987bdbfaf91a7cac27e9c5aea525ee53de7b2d3332c8644402b823e94a7db26276d2d23aa07180f76b4fd29b9c0823099c9d62c519880aee7e9697617c1497d47bf3e571950311421b6b734d38b0db91eb85331b91ea9f61530f54512a5a52a4bad589eb69781d537f23297bb459bdad2948a29e1550bf4787e0be95bb173cf5fab17dab7a13a052a63453d97ccec1a321954886b7a1299faaeecae35c6eaaca753b041b5e5f093bf83397fd21dd6b3012066fcc058cc32c3b09d7562dee29509b5839392c9ff05f51f3166aaac4ac5f238038a3045e6f72e48ef0fe8bc675e82c318a268e43970271bf119b81bf6a982746554f84e72b9f00280a320a08142923c23c883423ff949827f29bbacdc1ccdb04938ce6098c95ba6b32528f4ef78eed778b2e122ddfd1cbdd11d1c0a6783e011fc536d63d053260637" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 8 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"fe000000000000000000000000000000":"d55f684f81f4426e9fde92a5ff02df2ac896af63962888a97910c1379e20b0a3b1db613fb7fe2e07004329ea5c22bfd33e3dbe4cf58cc608c2c26c19a2e2fe22f98732c2b5cb844cc6c0702d91e1d50fc4382a7eba5635cd602432a2306ac4ce82f8d70c8d9bc15f918fe71e74c622d5cf71178bf6e0b9cc9f2b41dd8dbe441c41cd0c73a6dc47a348f6702f9d0e9b1b1431e948e299b9ec2272ab2c5f0c7be86affa5dec87a0bee81d3d50007edaa2bcfccb35605155ff36ed8edd4a40dcd4b243acd11b2b987bdbfaf91a7cac27e9c5aea525ee53de7b2d3332c8644402b823e94a7db26276d2d23aa07180f76b4fd29b9c0823099c9d62c519880aee7e9697617c1497d47bf3e571950311421b6b734d38b0db91eb85331b91ea9f61530f54512a5a52a4bad589eb69781d537f23297bb459bdad2948a29e1550bf4787e0be95bb173cf5fab17dab7a13a052a63453d97ccec1a321954886b7a1299faaeecae35c6eaaca753b041b5e5f093bf83397fd21dd6b3012066fcc058cc32c3b09d7562dee29509b5839392c9ff05f51f3166aaac4ac5f238038a3045e6f72e48ef0fe8bc675e82c318a268e43970271bf119b81bf6a982746554f84e72b9f00280a320a08142923c23c883423ff949827f29bbacdc1ccdb04938ce6098c95ba6b32528f4ef78eed778b2e122ddfd1cbdd11d1c0a6783e011fc536d63d053260637":"72efc1ebfe1ee25975a6eb3aa8589dda2b261f1c85bdab442a9e5b2dd1d7c3957a16fc08e526d4b1223f1b1232a11af274c3d70dac57f83e0983c498f1a6f1aecb021c3e70085a1e527f1ce41ee5911a82020161529cd82773762daf5459de94a0a82adae7e1703c808543c29ed6fb32d9e004327c1355180c995a07741493a09c21ba01a387882da4f62534b87bb15d60d197201c0fd3bf30c1500a3ecfecdd66d8721f90bcc4c17ee925c61b0a03727a9c0d5f5ca462fbfa0af1c2513a9d9d4b5345bd27a5f6e653f751693e6b6a2b8ead57d511e00e58c45b7b8d005af79288f5c7c22fd4f1bf7a898b03a5634c6a1ae3f9fae5de4f296a2896b23e7ed43ed14fa5a2803f4d28f0d3ffcf24757677aebdb47bb388378708948a8d4126ed1839e0da29a537a8c198b3c66ab00712dd261674bf45a73d67f76914f830ca014b65596f27e4cf62de66125a5566df9975155628b400fbfb3a29040ed50faffdbb18aece7c5c44693260aab386c0a37b11b114f1c415aebb653be468179428d43a4d8bc3ec38813eca30a13cf1bb18d524f1992d44d8b1a42ea30b22e6c95b199d8d182f8840b09d059585c31ad691fa0619ff038aca2c39a943421157361717c49d322028a74648113bd8c9d7ec77cf3c89c1ec8718ceff8516d96b34c3c614f10699c9abc4ed0411506223bea16af35c883accdbe1104eef0cfdb54e12fb230a" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 9 +aes_decrypt_xts:"2718281828459045235360287471352631415926535897932384626433832795":"ff000000000000000000000000000000":"72efc1ebfe1ee25975a6eb3aa8589dda2b261f1c85bdab442a9e5b2dd1d7c3957a16fc08e526d4b1223f1b1232a11af274c3d70dac57f83e0983c498f1a6f1aecb021c3e70085a1e527f1ce41ee5911a82020161529cd82773762daf5459de94a0a82adae7e1703c808543c29ed6fb32d9e004327c1355180c995a07741493a09c21ba01a387882da4f62534b87bb15d60d197201c0fd3bf30c1500a3ecfecdd66d8721f90bcc4c17ee925c61b0a03727a9c0d5f5ca462fbfa0af1c2513a9d9d4b5345bd27a5f6e653f751693e6b6a2b8ead57d511e00e58c45b7b8d005af79288f5c7c22fd4f1bf7a898b03a5634c6a1ae3f9fae5de4f296a2896b23e7ed43ed14fa5a2803f4d28f0d3ffcf24757677aebdb47bb388378708948a8d4126ed1839e0da29a537a8c198b3c66ab00712dd261674bf45a73d67f76914f830ca014b65596f27e4cf62de66125a5566df9975155628b400fbfb3a29040ed50faffdbb18aece7c5c44693260aab386c0a37b11b114f1c415aebb653be468179428d43a4d8bc3ec38813eca30a13cf1bb18d524f1992d44d8b1a42ea30b22e6c95b199d8d182f8840b09d059585c31ad691fa0619ff038aca2c39a943421157361717c49d322028a74648113bd8c9d7ec77cf3c89c1ec8718ceff8516d96b34c3c614f10699c9abc4ed0411506223bea16af35c883accdbe1104eef0cfdb54e12fb230a":"3260ae8dad1f4a32c5cafe3ab0eb95549d461a67ceb9e5aa2d3afb62dece0553193ba50c75be251e08d1d08f1088576c7efdfaaf3f459559571e12511753b07af073f35da06af0ce0bbf6b8f5ccc5cea500ec1b211bd51f63b606bf6528796ca12173ba39b8935ee44ccce646f90a45bf9ccc567f0ace13dc2d53ebeedc81f58b2e41179dddf0d5a5c42f5d8506c1a5d2f8f59f3ea873cbcd0eec19acbf325423bd3dcb8c2b1bf1d1eaed0eba7f0698e4314fbeb2f1566d1b9253008cbccf45a2b0d9c5c9c21474f4076e02be26050b99dee4fd68a4cf890e496e4fcae7b70f94ea5a9062da0daeba1993d2ccd1dd3c244b8428801495a58b216547e7e847c46d1d756377b6242d2e5fb83bf752b54e0df71e889f3a2bb0f4c10805bf3c590376e3c24e22ff57f7fa965577375325cea5d920db94b9c336b455f6e894c01866fe9fbb8c8d3f70a2957285f6dfb5dcd8cbf54782f8fe7766d4723819913ac773421e3a31095866bad22c86a6036b2518b2059b4229d18c8c2ccbdf906c6cc6e82464ee57bddb0bebcb1dc645325bfb3e665ef7251082c88ebb1cf203bd779fdd38675713c8daadd17e1cabee432b09787b6ddf3304e38b731b45df5df51b78fcfb3d32466028d0ba36555e7e11ab0ee0666061d1645d962444bc47a38188930a84b4d561395c73c087021927ca638b7afc8a8679ccb84c26555440ec7f10445cd" + +AES-256-XTS Decrypt IEEE P1619/D16 Vector 10 +aes_decrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ff000000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"1c3b3a102f770386e4836c99e370cf9bea00803f5e482357a4ae12d414a3e63b5d31e276f8fe4a8d66b317f9ac683f44680a86ac35adfc3345befecb4bb188fd5776926c49a3095eb108fd1098baec70aaa66999a72a82f27d848b21d4a741b0c5cd4d5fff9dac89aeba122961d03a757123e9870f8acf1000020887891429ca2a3e7a7d7df7b10355165c8b9a6d0a7de8b062c4500dc4cd120c0f7418dae3d0b5781c34803fa75421c790dfe1de1834f280d7667b327f6c8cd7557e12ac3a0f93ec05c52e0493ef31a12d3d9260f79a289d6a379bc70c50841473d1a8cc81ec583e9645e07b8d9670655ba5bbcfecc6dc3966380ad8fecb17b6ba02469a020a84e18e8f84252070c13e9f1f289be54fbc481457778f616015e1327a02b140f1505eb309326d68378f8374595c849d84f4c333ec4423885143cb47bd71c5edae9be69a2ffeceb1bec9de244fbe15992b11b77c040f12bd8f6a975a44a0f90c29a9abc3d4d893927284c58754cce294529f8614dcd2aba991925fedc4ae74ffac6e333b93eb4aff0479da9a410e4450e0dd7ae4c6e2910900575da401fc07059f645e8b7e9bfdef33943054ff84011493c27b3429eaedb4ed5376441a77ed43851ad77f16f541dfd269d50d6a5f14fb0aab1cbb4c1550be97f7ab4066193c4caa773dad38014bd2092fa755c824bb5e54c4f36ffda9fcea70b9c6e693e148c151" + +AES-256-XTS Decrypt IEEE P1619/D16 Vector 11 +aes_decrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffff0000000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"77a31251618a15e6b92d1d66dffe7b50b50bad552305ba0217a610688eff7e11e1d0225438e093242d6db274fde801d4cae06f2092c728b2478559df58e837c2469ee4a4fa794e4bbc7f39bc026e3cb72c33b0888f25b4acf56a2a9804f1ce6d3d6e1dc6ca181d4b546179d55544aa7760c40d06741539c7e3cd9d2f6650b2013fd0eeb8c2b8e3d8d240ccae2d4c98320a7442e1c8d75a42d6e6cfa4c2eca1798d158c7aecdf82490f24bb9b38e108bcda12c3faf9a21141c3613b58367f922aaa26cd22f23d708dae699ad7cb40a8ad0b6e2784973dcb605684c08b8d6998c69aac049921871ebb65301a4619ca80ecb485a31d744223ce8ddc2394828d6a80470c092f5ba413c3378fa6054255c6f9df4495862bbb3287681f931b687c888abf844dfc8fc28331e579928cd12bd2390ae123cf03818d14dedde5c0c24c8ab018bfca75ca096f2d531f3d1619e785f1ada437cab92e980558b3dce1474afb75bfedbf8ff54cb2618e0244c9ac0d3c66fb51598cd2db11f9be39791abe447c63094f7c453b7ff87cb5bb36b7c79efb0872d17058b83b15ab0866ad8a58656c5a7e20dbdf308b2461d97c0ec0024a2715055249cf3b478ddd4740de654f75ca686e0d7345c69ed50cdc2a8b332b1f8824108ac937eb050585608ee734097fc09054fbff89eeaeea791f4a7ab1f9868294a4f9e27b42af8100cb9d59cef9645803" + +AES-256-XTS Decrypt IEEE P1619/D16 Vector 12 +aes_decrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffffff00000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"e387aaa58ba483afa7e8eb469778317ecf4cf573aa9d4eac23f2cdf914e4e200a8b490e42ee646802dc6ee2b471b278195d60918ececb44bf79966f83faba0499298ebc699c0c8634715a320bb4f075d622e74c8c932004f25b41e361025b5a87815391f6108fc4afa6a05d9303c6ba68a128a55705d415985832fdeaae6c8e19110e84d1b1f199a2692119edc96132658f09da7c623efcec712537a3d94c0bf5d7e352ec94ae5797fdb377dc1551150721adf15bd26a8efc2fcaad56881fa9e62462c28f30ae1ceaca93c345cf243b73f542e2074a705bd2643bb9f7cc79bb6e7091ea6e232df0f9ad0d6cf502327876d82207abf2115cdacf6d5a48f6c1879a65b115f0f8b3cb3c59d15dd8c769bc014795a1837f3901b5845eb491adfefe097b1fa30a12fc1f65ba22905031539971a10f2f36c321bb51331cdefb39e3964c7ef079994f5b69b2edd83a71ef549971ee93f44eac3938fcdd61d01fa71799da3a8091c4c48aa9ed263ff0749df95d44fef6a0bb578ec69456aa5408ae32c7af08ad7ba8921287e3bbee31b767be06a0e705c864a769137df28292283ea81a2480241b44d9921cdbec1bc28dc1fda114bd8e5217ac9d8ebafa720e9da4f9ace231cc949e5b96fe76ffc21063fddc83a6b8679c00d35e09576a875305bed5f36ed242c8900dd1fa965bc950dfce09b132263a1eef52dd6888c309f5a7d712826" + +AES-256-XTS Decrypt IEEE P1619/D16 Vector 13 +aes_decrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffffffff000000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"bf53d2dade78e822a4d949a9bc6766b01b06a8ef70d26748c6a7fc36d80ae4c5520f7c4ab0ac8544424fa405162fef5a6b7f229498063618d39f0003cb5fb8d1c86b643497da1ff945c8d3bedeca4f479702a7a735f043ddb1d6aaade3c4a0ac7ca7f3fa5279bef56f82cd7a2f38672e824814e10700300a055e1630b8f1cb0e919f5e942010a416e2bf48cb46993d3cb6a51c19bacf864785a00bc2ecff15d350875b246ed53e68be6f55bd7e05cfc2b2ed6432198a6444b6d8c247fab941f569768b5c429366f1d3f00f0345b96123d56204c01c63b22ce78baf116e525ed90fdea39fa469494d3866c31e05f295ff21fea8d4e6e13d67e47ce722e9698a1c1048d68ebcde76b86fcf976eab8aa9790268b7068e017a8b9b749409514f1053027fd16c3786ea1bac5f15cb79711ee2abe82f5cf8b13ae73030ef5b9e4457e75d1304f988d62dd6fc4b94ed38ba831da4b7634971b6cd8ec325d9c61c00f1df73627ed3745a5e8489f3a95c69639c32cd6e1d537a85f75cc844726e8a72fc0077ad22000f1d5078f6b866318c668f1ad03d5a5fced5219f2eabbd0aa5c0f460d183f04404a0d6f469558e81fab24a167905ab4c7878502ad3e38fdbe62a41556cec37325759533ce8f25f367c87bb5578d667ae93f9e2fd99bcbc5f2fbba88cf6516139420fcff3b7361d86322c4bd84c82f335abb152c4a93411373aaa8220" + +AES-256-XTS Decrypt IEEE P1619/D16 Vector 14 +aes_decrypt_xts:"27182818284590452353602874713526624977572470936999595749669676273141592653589793238462643383279502884197169399375105820974944592":"ffffffffff0000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"64497e5a831e4a932c09be3e5393376daa599548b816031d224bbf50a818ed2350eae7e96087c8a0db51ad290bd00c1ac1620857635bf246c176ab463be30b808da548081ac847b158e1264be25bb0910bbc92647108089415d45fab1b3d2604e8a8eff1ae4020cfa39936b66827b23f371b92200be90251e6d73c5f86de5fd4a950781933d79a28272b782a2ec313efdfcc0628f43d744c2dc2ff3dcb66999b50c7ca895b0c64791eeaa5f29499fb1c026f84ce5b5c72ba1083cddb5ce45434631665c333b60b11593fb253c5179a2c8db813782a004856a1653011e93fb6d876c18366dd8683f53412c0c180f9c848592d593f8609ca736317d356e13e2bff3a9f59cd9aeb19cd482593d8c46128bb32423b37a9adfb482b99453fbe25a41bf6feb4aa0bef5ed24bf73c762978025482c13115e4015aac992e5613a3b5c2f685b84795cb6e9b2656d8c88157e52c42f978d8634c43d06fea928f2822e465aa6576e9bf419384506cc3ce3c54ac1a6f67dc66f3b30191e698380bc999b05abce19dc0c6dcc2dd001ec535ba18deb2df1a101023108318c75dc98611a09dc48a0acdec676fabdf222f07e026f059b672b56e5cbc8e1d21bbd867dd927212054681d70ea737134cdfce93b6f82ae22423274e58a0821cc5502e2d0ab4585e94de6975be5e0b4efce51cd3e70c25a1fbbbd609d273ad5b0d59631c531f6a0a57b9" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 15 +aes_decrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f10":"6c1625db4671522d3d7599601de7ca09ed" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 16 +aes_decrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f1011":"d069444b7a7e0cab09e24447d24deb1fedbf" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 17 +aes_decrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f101112":"e5df1351c0544ba1350b3363cd8ef4beedbf9d" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 18 +aes_decrypt_xts:"fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0":"9a785634120000000000000000000000":"000102030405060708090a0b0c0d0e0f10111213":"9d84c813f719aa2c7be3f66171c7c5c2edbf9dac" + +AES-128-XTS Decrypt IEEE P1619/D16 Vector 19 +aes_decrypt_xts:"e0e1e2e3e4e5e6e7e8e9eaebecedeeefc0c1c2c3c4c5c6c7c8c9cacbcccdcecf":"21436587a90000000000000000000000":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"38b45812ef43a05bd957e545907e223b954ab4aaf088303ad910eadf14b42be68b2461149d8c8ba85f992be970bc621f1b06573f63e867bf5875acafa04e42ccbd7bd3c2a0fb1fff791ec5ec36c66ae4ac1e806d81fbf709dbe29e471fad38549c8e66f5345d7c1eb94f405d1ec785cc6f6a68f6254dd8339f9d84057e01a17741990482999516b5611a38f41bb6478e6f173f320805dd71b1932fc333cb9ee39936beea9ad96fa10fb4112b901734ddad40bc1878995f8e11aee7d141a2f5d48b7a4e1e7f0b2c04830e69a4fd1378411c2f287edf48c6c4e5c247a19680f7fe41cefbd49b582106e3616cbbe4dfb2344b2ae9519391f3e0fb4922254b1d6d2d19c6d4d537b3a26f3bcc51588b32f3eca0829b6a5ac72578fb814fb43cf80d64a233e3f997a3f02683342f2b33d25b492536b93becb2f5e1a8b82f5b883342729e8ae09d16938841a21a97fb543eea3bbff59f13c1a18449e398701c1ad51648346cbc04c27bb2da3b93a1372ccae548fb53bee476f9e9c91773b1bb19828394d55d3e1a20ed69113a860b6829ffa847224604435070221b257e8dff783615d2cae4803a93aa4334ab482a0afac9c0aeda70b45a481df5dec5df8cc0f423c77a5fd46cd312021d4b438862419a791be03bb4d97c0e59578542531ba466a83baf92cefc151b5cc1611a167893819b63fb8a6b18e86de60290fa72b797b0ce59f3" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_arc4.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_arc4.function index a4b401b62b..ae3b032b3b 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_arc4.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_arc4.function @@ -8,30 +8,20 @@ */ /* BEGIN_CASE */ -void mbedtls_arc4_crypt( char *hex_src_string, char *hex_key_string, - char *hex_dst_string ) +void mbedtls_arc4_crypt( data_t * src_str, data_t * key_str, + data_t * hex_dst_string ) { - unsigned char src_str[1000]; - unsigned char key_str[1000]; unsigned char dst_str[1000]; - unsigned char dst_hexstr[2000]; - int src_len, key_len; mbedtls_arc4_context ctx; - memset(src_str, 0x00, 1000); - memset(key_str, 0x00, 1000); memset(dst_str, 0x00, 1000); - memset(dst_hexstr, 0x00, 2000); mbedtls_arc4_init( &ctx ); - src_len = unhexify( src_str, hex_src_string ); - key_len = unhexify( key_str, hex_key_string ); - mbedtls_arc4_setup(&ctx, key_str, key_len); - TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_len, src_str, dst_str ) == 0 ); - hexify( dst_hexstr, dst_str, src_len ); + mbedtls_arc4_setup(&ctx, key_str->x, key_str->len); + TEST_ASSERT( mbedtls_arc4_crypt(&ctx, src_str->len, src_str->x, dst_str ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_hexstr, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( dst_str, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); exit: mbedtls_arc4_free( &ctx ); @@ -39,7 +29,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void arc4_selftest() +void arc4_selftest( ) { TEST_ASSERT( mbedtls_arc4_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aria.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aria.data new file mode 100644 index 0000000000..2da0b30c20 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aria.data @@ -0,0 +1,104 @@ +ARIA - Valid parameters +aria_valid_param: + +ARIA - Invalid parameters +aria_invalid_param: + +ARIA-128-ECB Encrypt - RFC 5794 +aria_encrypt_ecb:"000102030405060708090a0b0c0d0e0f":"00112233445566778899aabbccddeeff":"d718fbd6ab644c739da95f3be6451778":0 + +ARIA-128-ECB Decrypt - RFC 5794 +aria_decrypt_ecb:"000102030405060708090a0b0c0d0e0f":"d718fbd6ab644c739da95f3be6451778":"00112233445566778899aabbccddeeff":0 + +ARIA-192-ECB Encrypt - RFC 5794 +aria_encrypt_ecb:"000102030405060708090a0b0c0d0e0f1011121314151617":"00112233445566778899aabbccddeeff":"26449c1805dbe7aa25a468ce263a9e79":0 + +ARIA-192-ECB Decrypt - RFC 5794 +aria_decrypt_ecb:"000102030405060708090a0b0c0d0e0f1011121314151617":"26449c1805dbe7aa25a468ce263a9e79":"00112233445566778899aabbccddeeff":0 + +ARIA-256-ECB_Encrypt - RFC 5794 +aria_encrypt_ecb:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f":"00112233445566778899aabbccddeeff":"f92bd7c79fb72e2f2b8f80c1972d24fc":0 + +ARIA-256-ECB_Decrypt - RFC 5794 +aria_decrypt_ecb:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f":"f92bd7c79fb72e2f2b8f80c1972d24fc":"00112233445566778899aabbccddeeff":0 + +ARIA-128-ECB Decrypt - RFC 5794 +aria_decrypt_ecb:"000102030405060708090a0b0c0d0e0f":"d718fbd6ab644c739da95f3be6451778":"00112233445566778899aabbccddeeff":0 + +ARIA-192-ECB Decrypt - RFC 5794 +aria_decrypt_ecb:"000102030405060708090a0b0c0d0e0f1011121314151617":"26449c1805dbe7aa25a468ce263a9e79":"00112233445566778899aabbccddeeff":0 + +ARIA-256-ECB Decrypt - RFC 5794 +aria_decrypt_ecb:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f":"f92bd7c79fb72e2f2b8f80c1972d24fc":"00112233445566778899aabbccddeeff":0 + +ARIA-128-ECB Encrypt - Official Test Vectors 1.0 +aria_encrypt_ecb:"00112233445566778899aabbccddeeff":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"c6ecd08e22c30abdb215cf74e2075e6e29ccaac63448708d331b2f816c51b17d9e133d1528dbf0af5787c7f3a3f5c2bf6b6f345907a3055612ce072ff54de7d788424da6e8ccfe8172b391be499354165665ba7864917000a6eeb2ecb4a698edfc7887e7f556377614ab0a282293e6d884dbb84206cdb16ed1754e77a1f243fd086953f752cc1e46c7c794ae85537dcaec8dd721f55c93b6edfe2adea43873e8":0 + +ARIA-128-ECB Decrypt - Official Test Vectors 1.0 +aria_decrypt_ecb:"00112233445566778899aabbccddeeff":"c6ecd08e22c30abdb215cf74e2075e6e29ccaac63448708d331b2f816c51b17d9e133d1528dbf0af5787c7f3a3f5c2bf6b6f345907a3055612ce072ff54de7d788424da6e8ccfe8172b391be499354165665ba7864917000a6eeb2ecb4a698edfc7887e7f556377614ab0a282293e6d884dbb84206cdb16ed1754e77a1f243fd086953f752cc1e46c7c794ae85537dcaec8dd721f55c93b6edfe2adea43873e8":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-192-ECB Encrypt - Official Test Vectors 1.0 +aria_encrypt_ecb:"00112233445566778899aabbccddeeff0011223344556677":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"8d1470625f59ebacb0e55b534b3e462b5f23d33bff78f46c3c15911f4a21809aaccad80b4bda915aa9dae6bcebe06a6c83f77fd5391acfe61de2f646b5d447edbfd5bb49b12fbb9145b227895a757b2af1f7188734863d7b8b6ede5a5b2f06a0a233c8523d2db778fb31b0e311f32700152f33861e9d040c83b5eb40cd88ea49975709dc629365a189f78a3ec40345fc6a5a307a8f9a4413091e007eca5645a0":0 + +ARIA-192-ECB Decrypt - Official Test Vectors 1.0 +aria_decrypt_ecb:"00112233445566778899aabbccddeeff0011223344556677":"8d1470625f59ebacb0e55b534b3e462b5f23d33bff78f46c3c15911f4a21809aaccad80b4bda915aa9dae6bcebe06a6c83f77fd5391acfe61de2f646b5d447edbfd5bb49b12fbb9145b227895a757b2af1f7188734863d7b8b6ede5a5b2f06a0a233c8523d2db778fb31b0e311f32700152f33861e9d040c83b5eb40cd88ea49975709dc629365a189f78a3ec40345fc6a5a307a8f9a4413091e007eca5645a0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-256-ECB Encrypt - Official Test Vectors 1.0 +aria_encrypt_ecb:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"58a875e6044ad7fffa4f58420f7f442d8e191016f28e79aefc01e204773280d7018e5f7a938ec30711719953bae86542cd7ebc752474c1a5f6eaaace2a7e29462ee7dfa5afdb84177ead95ccd4b4bb6e1ed17b9534cff0a5fc2941429cfee2ee49c7adbeb7e9d1b0d2a8531d942079596a27ed79f5b1dd13ecd604b07a48885a3afa0627a0e4e60a3c703af292f1baa77b702f16c54aa74bc727ea95c7468b00":0 + +ARIA-256-ECB Decrypt - Official Test Vectors 1.0 +aria_decrypt_ecb:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"58a875e6044ad7fffa4f58420f7f442d8e191016f28e79aefc01e204773280d7018e5f7a938ec30711719953bae86542cd7ebc752474c1a5f6eaaace2a7e29462ee7dfa5afdb84177ead95ccd4b4bb6e1ed17b9534cff0a5fc2941429cfee2ee49c7adbeb7e9d1b0d2a8531d942079596a27ed79f5b1dd13ecd604b07a48885a3afa0627a0e4e60a3c703af292f1baa77b702f16c54aa74bc727ea95c7468b00":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-128-CBC Encrypt - Official Test Vectors 1.0 +aria_encrypt_cbc:"00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"49d61860b14909109cef0d22a9268134fadf9fb23151e9645fba75018bdb1538b53334634bbf7d4cd4b5377033060c155fe3948ca75de1031e1d85619e0ad61eb419a866b3c2dbfd10a4ed18b22149f75897f0b8668b0c1c542c687778835fb7cd46e45f85eaa7072437dd9fa6793d6f8d4ccefc4eb1ac641ac1bd30b18c6d64c49bca137eb21c2e04da62712ca2b4f540c57112c38791852cfac7a5d19ed83a":0 + +ARIA-128-CBC Decrypt - Official Test Vectors 1.0 +aria_decrypt_cbc:"00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"49d61860b14909109cef0d22a9268134fadf9fb23151e9645fba75018bdb1538b53334634bbf7d4cd4b5377033060c155fe3948ca75de1031e1d85619e0ad61eb419a866b3c2dbfd10a4ed18b22149f75897f0b8668b0c1c542c687778835fb7cd46e45f85eaa7072437dd9fa6793d6f8d4ccefc4eb1ac641ac1bd30b18c6d64c49bca137eb21c2e04da62712ca2b4f540c57112c38791852cfac7a5d19ed83a":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-192-CBC Encrypt - Official Test Vectors 1.0 +aria_encrypt_cbc:"00112233445566778899aabbccddeeff0011223344556677":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"afe6cf23974b533c672a826264ea785f4e4f7f780dc7f3f1e0962b80902386d514e9c3e77259de92dd1102ffab086c1ea52a71260db5920a83295c25320e421147ca45d532f327b856ea947cd2196ae2e040826548b4c891b0ed0ca6e714dbc4631998d548110d666b3d54c2a091955c6f05beb4f62309368696c9791fc4c551564a2637f194346ec45fbca6c72a5b4612e208d531d6c34cc5c64eac6bd0cf8c":0 + +ARIA-192-CBC Decrypt - Official Test Vectors 1.0 +aria_decrypt_cbc:"00112233445566778899aabbccddeeff0011223344556677":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"afe6cf23974b533c672a826264ea785f4e4f7f780dc7f3f1e0962b80902386d514e9c3e77259de92dd1102ffab086c1ea52a71260db5920a83295c25320e421147ca45d532f327b856ea947cd2196ae2e040826548b4c891b0ed0ca6e714dbc4631998d548110d666b3d54c2a091955c6f05beb4f62309368696c9791fc4c551564a2637f194346ec45fbca6c72a5b4612e208d531d6c34cc5c64eac6bd0cf8c":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-256-CBC Encrypt - Official Test Vectors 1.0 +aria_encrypt_cbc:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"523a8a806ae621f155fdd28dbc34e1ab7b9b42432ad8b2efb96e23b13f0a6e52f36185d50ad002c5f601bee5493f118b243ee2e313642bffc3902e7b2efd9a12fa682edd2d23c8b9c5f043c18b17c1ec4b5867918270fbec1027c19ed6af833da5d620994668ca22f599791d292dd6273b2959082aafb7a996167cce1eec5f0cfd15f610d87e2dda9ba68ce1260ca54b222491418374294e7909b1e8551cd8de":0 + +ARIA-256-CBC Decrypt - Official Test Vectors 1.0 +aria_decrypt_cbc:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"523a8a806ae621f155fdd28dbc34e1ab7b9b42432ad8b2efb96e23b13f0a6e52f36185d50ad002c5f601bee5493f118b243ee2e313642bffc3902e7b2efd9a12fa682edd2d23c8b9c5f043c18b17c1ec4b5867918270fbec1027c19ed6af833da5d620994668ca22f599791d292dd6273b2959082aafb7a996167cce1eec5f0cfd15f610d87e2dda9ba68ce1260ca54b222491418374294e7909b1e8551cd8de":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-128-CTR Encrypt - Official Test Vectors 1.0 +aria_encrypt_ctr:"00112233445566778899aabbccddeeff":"00000000000000000000000000000000":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"ac5d7de805a0bf1c57c854501af60fa11497e2a34519dea1569e91e5b5ccae2ff3bfa1bf975f4571f48be191613546c3911163c085f871f0e7ae5f2a085b81851c2a3ddf20ecb8fa51901aec8ee4ba32a35dab67bb72cd9140ad188a967ac0fbbdfa94ea6cce47dcf8525ab5a814cfeb2bb60ee2b126e2d9d847c1a9e96f9019e3e6a7fe40d3829afb73db1cc245646addb62d9b907baaafbe46a73dbc131d3d":0 + +ARIA-192-CTR Encrypt - Official Test Vectors 1.0 +aria_encrypt_ctr:"00112233445566778899aabbccddeeff0011223344556677":"00000000000000000000000000000000":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"08625ca8fe569c19ba7af3760a6ed1cef4d199263e999dde14082dbba7560b79a4c6b456b8707dce751f9854f18893dfdb3f4e5afa539733e6f1e70b98ba37891f8f81e95df8efc26c7ce043504cb18958b865e4e316cd2aa1c97f31bf23dc046ef326b95a692a191ba0f2a41c5fe9ae070f236ff7078e703b42666caafbdd20bad74ac4c20c0f46c7ca24c151716575c947da16c90cfe1bf217a41cfebe7531":0 + +ARIA-192-CTR Decrypt - Official Test Vectors 1.0 +aria_decrypt_ctr:"00112233445566778899aabbccddeeff0011223344556677":"00000000000000000000000000000000":"08625ca8fe569c19ba7af3760a6ed1cef4d199263e999dde14082dbba7560b79a4c6b456b8707dce751f9854f18893dfdb3f4e5afa539733e6f1e70b98ba37891f8f81e95df8efc26c7ce043504cb18958b865e4e316cd2aa1c97f31bf23dc046ef326b95a692a191ba0f2a41c5fe9ae070f236ff7078e703b42666caafbdd20bad74ac4c20c0f46c7ca24c151716575c947da16c90cfe1bf217a41cfebe7531":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-256-CTR Encrypt - Official Test Vectors 1.0 +aria_encrypt_ctr:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"00000000000000000000000000000000":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"30026c329666141721178b99c0a1f1b2f06940253f7b3089e2a30ea86aa3c88f5940f05ad7ee41d71347bb7261e348f18360473fdf7d4e7723bffb4411cc13f6cdd89f3bc7b9c768145022c7a74f14d7c305cd012a10f16050c23f1ae5c23f45998d13fbaa041e51619577e0772764896a5d4516d8ffceb3bf7e05f613edd9a60cdcedaff9cfcaf4e00d445a54334f73ab2cad944e51d266548e61c6eb0aa1cd":0 + +ARIA-256-CTR Decrypt - Official Test Vectors 1.0 +aria_decrypt_ctr:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"00000000000000000000000000000000":"30026c329666141721178b99c0a1f1b2f06940253f7b3089e2a30ea86aa3c88f5940f05ad7ee41d71347bb7261e348f18360473fdf7d4e7723bffb4411cc13f6cdd89f3bc7b9c768145022c7a74f14d7c305cd012a10f16050c23f1ae5c23f45998d13fbaa041e51619577e0772764896a5d4516d8ffceb3bf7e05f613edd9a60cdcedaff9cfcaf4e00d445a54334f73ab2cad944e51d266548e61c6eb0aa1cd":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-128-CFB128 Encrypt - Official Test Vectors 1.0 +aria_encrypt_cfb128:"00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"3720e53ba7d615383406b09f0a05a200c07c21e6370f413a5d132500a68285017c61b434c7b7ca9685a51071861e4d4bb873b599b479e2d573dddeafba89f812ac6a9e44d554078eb3be94839db4b33da3f59c063123a7ef6f20e10579fa4fd239100ca73b52d4fcafeadee73f139f78f9b7614c2b3b9dbe010f87db06a89a9435f79ce8121431371f4e87b984e0230c22a6dacb32fc42dcc6accef33285bf11":0 + +ARIA-128-CFB128 Decrypt - Official Test Vectors 1.0 +aria_decrypt_cfb128:"00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"3720e53ba7d615383406b09f0a05a200c07c21e6370f413a5d132500a68285017c61b434c7b7ca9685a51071861e4d4bb873b599b479e2d573dddeafba89f812ac6a9e44d554078eb3be94839db4b33da3f59c063123a7ef6f20e10579fa4fd239100ca73b52d4fcafeadee73f139f78f9b7614c2b3b9dbe010f87db06a89a9435f79ce8121431371f4e87b984e0230c22a6dacb32fc42dcc6accef33285bf11":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-192-CFB128 Encrypt - Official Test Vectors 1.0 +aria_encrypt_cfb128:"00112233445566778899aabbccddeeff0011223344556677":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"4171f7192bf4495494d2736129640f5c4d87a9a213664c9448477c6ecc2013598d9766952dd8c3868f17e36ef66fd84bfa45d1593d2d6ee3ea2115047d710d4fb66187caa3a315b3c8ea2d313962edcfe5a3e2028d5ba9a09fd5c65c19d3440e477f0cab0628ec6902c73ee02f1afee9f80115be7b9df82d1e28228e28581a20560e195cbb9e2b327bf56fd2d0ae5502e42c13e9b4015d4da42dc859252e7da4":0 + +ARIA-192-CFB128 Decrypt - Official Test Vectors 1.0 +aria_decrypt_cfb128:"00112233445566778899aabbccddeeff0011223344556677":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"4171f7192bf4495494d2736129640f5c4d87a9a213664c9448477c6ecc2013598d9766952dd8c3868f17e36ef66fd84bfa45d1593d2d6ee3ea2115047d710d4fb66187caa3a315b3c8ea2d313962edcfe5a3e2028d5ba9a09fd5c65c19d3440e477f0cab0628ec6902c73ee02f1afee9f80115be7b9df82d1e28228e28581a20560e195cbb9e2b327bf56fd2d0ae5502e42c13e9b4015d4da42dc859252e7da4":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA-256-CFB128 Encrypt - Official Test Vectors 1.0 +aria_encrypt_cfb128:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":"26834705b0f2c0e2588d4a7f09009635f28bb93d8c31f870ec1e0bdb082b66fa402dd9c202be300c4517d196b14d4ce11dce97f7aaba54341b0d872cc9b63753a3e8556a14be6f7b3e27e3cfc39caf80f2a355aa50dc83c09c7b11828694f8e4aa726c528976b53f2c877f4991a3a8d28adb63bd751846ffb2350265e179d4990753ae8485ff9b4133ddad5875b84a90cbcfa62a045d726df71b6bda0eeca0be":0 + +ARIA-256-CFB128 Decrypt - Official Test Vectors 1.0 +aria_decrypt_cfb128:"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff":"0f1e2d3c4b5a69788796a5b4c3d2e1f0":"26834705b0f2c0e2588d4a7f09009635f28bb93d8c31f870ec1e0bdb082b66fa402dd9c202be300c4517d196b14d4ce11dce97f7aaba54341b0d872cc9b63753a3e8556a14be6f7b3e27e3cfc39caf80f2a355aa50dc83c09c7b11828694f8e4aa726c528976b53f2c877f4991a3a8d28adb63bd751846ffb2350265e179d4990753ae8485ff9b4133ddad5875b84a90cbcfa62a045d726df71b6bda0eeca0be":"11111111aaaaaaaa11111111bbbbbbbb11111111cccccccc11111111dddddddd22222222aaaaaaaa22222222bbbbbbbb22222222cccccccc22222222dddddddd33333333aaaaaaaa33333333bbbbbbbb33333333cccccccc33333333dddddddd44444444aaaaaaaa44444444bbbbbbbb44444444cccccccc44444444dddddddd55555555aaaaaaaa55555555bbbbbbbb55555555cccccccc55555555dddddddd":0 + +ARIA Selftest +aria_selftest: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aria.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aria.function new file mode 100644 index 0000000000..7e35f154b5 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_aria.function @@ -0,0 +1,527 @@ +/* BEGIN_HEADER */ +#include "mbedtls/aria.h" + +/* Maxium size of data used by test vectors + * WARNING: to be adapted if and when adding larger test cases */ +#define ARIA_MAX_DATASIZE 160 + +/* Maximum sizes of hexified things */ +#define ARIA_MAX_KEY_STR ( 2 * MBEDTLS_ARIA_MAX_KEYSIZE + 1 ) +#define ARIA_BLOCK_STR ( 2 * MBEDTLS_ARIA_BLOCKSIZE + 1 ) +#define ARIA_MAX_DATA_STR ( 2 * ARIA_MAX_DATASIZE + 1 ) +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_ARIA_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void aria_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_aria_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void aria_invalid_param( ) +{ + mbedtls_aria_context ctx; + unsigned char key[128 / 8] = { 0 }; + unsigned char input[MBEDTLS_ARIA_BLOCKSIZE] = { 0 }; + unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] = { 0 }; + unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE] = { 0 }; + size_t iv_off = 0; + + ((void) iv_off); + ((void) iv); + + TEST_INVALID_PARAM( mbedtls_aria_init( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_setkey_enc( NULL, key, + sizeof( key ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_setkey_enc( &ctx, NULL, + sizeof( key ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_setkey_dec( NULL, key, + sizeof( key ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_setkey_dec( &ctx, NULL, + sizeof( key ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ecb( NULL, input, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ecb( &ctx, NULL, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ecb( &ctx, input, NULL ) ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cbc( NULL, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cbc( &ctx, + 42 /* invalid mode */, + sizeof( input ), + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cbc( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + NULL, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cbc( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + iv, + NULL, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cbc( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + iv, + input, + NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cfb128( NULL, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + &iv_off, + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cfb128( &ctx, + 42, /* invalid mode */ + sizeof( input ), + &iv_off, + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cfb128( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + NULL, + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cfb128( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + &iv_off, + NULL, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cfb128( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + &iv_off, + iv, + NULL, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_cfb128( &ctx, + MBEDTLS_ARIA_ENCRYPT, + sizeof( input ), + &iv_off, + iv, + input, + NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ctr( NULL, + sizeof( input ), + &iv_off, + iv, + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ctr( &ctx, + sizeof( input ), + NULL, + iv, + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ctr( &ctx, + sizeof( input ), + &iv_off, + NULL, + iv, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ctr( &ctx, + sizeof( input ), + &iv_off, + iv, + NULL, + input, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ctr( &ctx, + sizeof( input ), + &iv_off, + iv, + iv, + NULL, + output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ARIA_BAD_INPUT_DATA, + mbedtls_aria_crypt_ctr( &ctx, + sizeof( input ), + &iv_off, + iv, + iv, + input, + NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +exit: + return; + +} +/* END_CASE */ + +/* BEGIN_CASE */ +void aria_encrypt_ecb( char *hex_key_string, char *hex_src_string, + char *hex_dst_string, int setkey_result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + mbedtls_aria_context ctx; + int key_len, data_len, i; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + data_len = unhexify( src_str, hex_src_string ); + + TEST_ASSERT( mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 ) + == setkey_result ); + if( setkey_result == 0 ) + { + for( i = 0; i < data_len; i += MBEDTLS_ARIA_BLOCKSIZE ) + { + TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i ) + == 0 ); + } + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + } + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void aria_decrypt_ecb( char *hex_key_string, char *hex_src_string, + char *hex_dst_string, int setkey_result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + mbedtls_aria_context ctx; + int key_len, data_len, i; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + data_len = unhexify( src_str, hex_src_string ); + + TEST_ASSERT( mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 ) + == setkey_result ); + if( setkey_result == 0 ) + { + for( i = 0; i < data_len; i += MBEDTLS_ARIA_BLOCKSIZE ) + { + TEST_ASSERT( mbedtls_aria_crypt_ecb( &ctx, src_str + i, output + i ) + == 0 ); + } + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + } + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ +void aria_encrypt_cbc( char *hex_key_string, char *hex_iv_string, + char *hex_src_string, char *hex_dst_string, + int cbc_result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char iv_str[ARIA_BLOCK_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + mbedtls_aria_context ctx; + int key_len, data_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + unhexify( iv_str, hex_iv_string ); + data_len = unhexify( src_str, hex_src_string ); + + mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 ); + TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_ENCRYPT, data_len, + iv_str, src_str, output ) + == cbc_result ); + if( cbc_result == 0 ) + { + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + } + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ +void aria_decrypt_cbc( char *hex_key_string, char *hex_iv_string, + char *hex_src_string, char *hex_dst_string, + int cbc_result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char iv_str[ARIA_BLOCK_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + mbedtls_aria_context ctx; + int key_len, data_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + unhexify( iv_str, hex_iv_string ); + data_len = unhexify( src_str, hex_src_string ); + + mbedtls_aria_setkey_dec( &ctx, key_str, key_len * 8 ); + TEST_ASSERT( mbedtls_aria_crypt_cbc( &ctx, MBEDTLS_ARIA_DECRYPT, data_len, + iv_str, src_str, output ) + == cbc_result ); + if( cbc_result == 0 ) + { + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + } + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ +void aria_encrypt_cfb128( char *hex_key_string, char *hex_iv_string, + char *hex_src_string, char *hex_dst_string, + int result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char iv_str[ARIA_BLOCK_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + mbedtls_aria_context ctx; + size_t iv_offset = 0; + int key_len, data_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + unhexify( iv_str, hex_iv_string ); + data_len = unhexify( src_str, hex_src_string ); + + mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 ); + TEST_ASSERT( mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_ENCRYPT, + data_len, &iv_offset, iv_str, + src_str, output ) + == result ); + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ +void aria_decrypt_cfb128( char *hex_key_string, char *hex_iv_string, + char *hex_src_string, char *hex_dst_string, + int result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char iv_str[ARIA_BLOCK_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + mbedtls_aria_context ctx; + size_t iv_offset = 0; + int key_len, data_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + unhexify( iv_str, hex_iv_string ); + data_len = unhexify( src_str, hex_src_string ); + + mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 ); + TEST_ASSERT( mbedtls_aria_crypt_cfb128( &ctx, MBEDTLS_ARIA_DECRYPT, + data_len, &iv_offset, iv_str, + src_str, output ) + == result ); + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CTR */ +void aria_encrypt_ctr( char *hex_key_string, char *hex_iv_string, + char *hex_src_string, char *hex_dst_string, + int result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char iv_str[ARIA_BLOCK_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + unsigned char blk[MBEDTLS_ARIA_BLOCKSIZE]; + mbedtls_aria_context ctx; + size_t iv_offset = 0; + int key_len, data_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + unhexify( iv_str, hex_iv_string ); + data_len = unhexify( src_str, hex_src_string ); + + mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 ); + TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str, + blk, src_str, output ) + == result ); + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CTR */ +void aria_decrypt_ctr( char *hex_key_string, char *hex_iv_string, + char *hex_src_string, char *hex_dst_string, + int result ) +{ + unsigned char key_str[ARIA_MAX_KEY_STR]; + unsigned char iv_str[ARIA_BLOCK_STR]; + unsigned char src_str[ARIA_MAX_DATA_STR]; + unsigned char dst_str[ARIA_MAX_DATA_STR]; + unsigned char output[ARIA_MAX_DATASIZE]; + unsigned char blk[MBEDTLS_ARIA_BLOCKSIZE]; + mbedtls_aria_context ctx; + size_t iv_offset = 0; + int key_len, data_len; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( iv_str, 0x00, sizeof( iv_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + mbedtls_aria_init( &ctx ); + + key_len = unhexify( key_str, hex_key_string ); + unhexify( iv_str, hex_iv_string ); + data_len = unhexify( src_str, hex_src_string ); + + mbedtls_aria_setkey_enc( &ctx, key_str, key_len * 8 ); + TEST_ASSERT( mbedtls_aria_crypt_ctr( &ctx, data_len, &iv_offset, iv_str, + blk, src_str, output ) + == result ); + hexify( dst_str, output, data_len ); + + TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + +exit: + mbedtls_aria_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ +void aria_selftest() +{ + TEST_ASSERT( mbedtls_aria_self_test( 1 ) == 0 ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_asn1write.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_asn1write.function index 2ff9398a54..57a9741254 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_asn1write.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_asn1write.function @@ -11,24 +11,20 @@ */ /* BEGIN_CASE */ -void mbedtls_asn1_write_octet_string( char *hex_str, char *hex_asn1, - int buf_len, int result ) +void mbedtls_asn1_write_octet_string( data_t * str, data_t * asn1, + int buf_len, int result ) { int ret; unsigned char buf[150]; - unsigned char str[150] = { 0 }; - unsigned char asn1[150] = { 0 }; - size_t str_len, asn1_len, i; + size_t i; unsigned char *p; memset( buf, GUARD_VAL, sizeof( buf ) ); - str_len = unhexify( str, hex_str ); - asn1_len = unhexify( asn1, hex_asn1 ); p = buf + GUARD_LEN + buf_len; - ret = mbedtls_asn1_write_octet_string( &p, buf + GUARD_LEN, str, str_len ); + ret = mbedtls_asn1_write_octet_string( &p, buf + GUARD_LEN, str->x, str->len ); /* Check for buffer overwrite on both sides */ for( i = 0; i < GUARD_LEN; i++ ) @@ -39,28 +35,27 @@ void mbedtls_asn1_write_octet_string( char *hex_str, char *hex_asn1, if( result >= 0 ) { - TEST_ASSERT( (size_t) ret == asn1_len ); - TEST_ASSERT( p + asn1_len == buf + GUARD_LEN + buf_len ); + TEST_ASSERT( (size_t) ret == asn1->len ); + TEST_ASSERT( p + asn1->len == buf + GUARD_LEN + buf_len ); - TEST_ASSERT( memcmp( p, asn1, asn1_len ) == 0 ); + TEST_ASSERT( memcmp( p, asn1->x, asn1->len ) == 0 ); } } /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_asn1_write_ia5_string( char *str, char *hex_asn1, - int buf_len, int result ) +void mbedtls_asn1_write_ia5_string( char * str, data_t * asn1, + int buf_len, int result ) { int ret; unsigned char buf[150]; - unsigned char asn1[150] = { 0 }; - size_t str_len, asn1_len, i; + size_t str_len; + size_t i; unsigned char *p; memset( buf, GUARD_VAL, sizeof( buf ) ); str_len = strlen( str ); - asn1_len = unhexify( asn1, hex_asn1 ); p = buf + GUARD_LEN + buf_len; @@ -75,27 +70,25 @@ void mbedtls_asn1_write_ia5_string( char *str, char *hex_asn1, if( result >= 0 ) { - TEST_ASSERT( (size_t) ret == asn1_len ); - TEST_ASSERT( p + asn1_len == buf + GUARD_LEN + buf_len ); + TEST_ASSERT( (size_t) ret == asn1->len ); + TEST_ASSERT( p + asn1->len == buf + GUARD_LEN + buf_len ); - TEST_ASSERT( memcmp( p, asn1, asn1_len ) == 0 ); + TEST_ASSERT( memcmp( p, asn1->x, asn1->len ) == 0 ); } } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ASN1PARSE_C */ -void mbedtls_asn1_write_len( int len, char *check_str, int buf_len, +void mbedtls_asn1_write_len( int len, data_t * asn1, int buf_len, int result ) { int ret; unsigned char buf[150]; - unsigned char asn1[150]; unsigned char *p; - size_t asn1_len, i, read_len; + size_t i; + size_t read_len; memset( buf, GUARD_VAL, sizeof( buf ) ); - memset( asn1, 0, sizeof( asn1 ) ); - asn1_len = unhexify( asn1, check_str ); p = buf + GUARD_LEN + buf_len; @@ -112,10 +105,9 @@ void mbedtls_asn1_write_len( int len, char *check_str, int buf_len, if( result >= 0 ) { - TEST_ASSERT( (size_t) ret == asn1_len ); - TEST_ASSERT( p + asn1_len == buf + GUARD_LEN + buf_len ); + TEST_ASSERT( p + asn1->len == buf + GUARD_LEN + buf_len ); - TEST_ASSERT( memcmp( p, asn1, asn1_len ) == 0 ); + TEST_ASSERT( memcmp( p, asn1->x, asn1->len ) == 0 ); /* Read back with mbedtls_asn1_get_len() to check */ ret = mbedtls_asn1_get_len( &p, buf + GUARD_LEN + buf_len, &read_len ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_base64.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_base64.function index 77fa7fdedf..3a8bf430f3 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_base64.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_base64.function @@ -8,8 +8,8 @@ */ /* BEGIN_CASE */ -void mbedtls_base64_encode( char *src_string, char *dst_string, int dst_buf_size, - int result ) +void mbedtls_base64_encode( char * src_string, char * dst_string, + int dst_buf_size, int result ) { unsigned char src_str[1000]; unsigned char dst_str[1000]; @@ -28,7 +28,7 @@ void mbedtls_base64_encode( char *src_string, char *dst_string, int dst_buf_size /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_base64_decode( char *src_string, char *dst_string, int result ) +void mbedtls_base64_decode( char * src_string, char * dst_string, int result ) { unsigned char src_str[1000]; unsigned char dst_str[1000]; @@ -49,16 +49,15 @@ void mbedtls_base64_decode( char *src_string, char *dst_string, int result ) /* END_CASE */ /* BEGIN_CASE */ -void base64_encode_hex( char *src_hex, char *dst, int dst_buf_size, +void base64_encode_hex( data_t * src, char * dst, int dst_buf_size, int result ) { - unsigned char *src = NULL, *res = NULL; - size_t len, src_len; + unsigned char *res = NULL; + size_t len; - src = unhexify_alloc( src_hex, &src_len ); res = zero_alloc( dst_buf_size ); - TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src, src_len ) == result ); + TEST_ASSERT( mbedtls_base64_encode( res, dst_buf_size, &len, src->x, src->len ) == result ); if( result == 0 ) { TEST_ASSERT( len == strlen( dst ) ); @@ -66,45 +65,39 @@ void base64_encode_hex( char *src_hex, char *dst, int dst_buf_size, } exit: - mbedtls_free( src ); mbedtls_free( res ); } /* END_CASE */ /* BEGIN_CASE */ -void base64_decode_hex( char *src, char *dst_hex, int dst_buf_size, +void base64_decode_hex( char * src, data_t * dst, int dst_buf_size, int result ) { - unsigned char *dst = NULL, *res = NULL; - size_t len, dst_len; + unsigned char *res = NULL; + size_t len; - dst = unhexify_alloc( dst_hex, &dst_len ); res = zero_alloc( dst_buf_size ); TEST_ASSERT( mbedtls_base64_decode( res, dst_buf_size, &len, (unsigned char *) src, strlen( src ) ) == result ); if( result == 0 ) { - TEST_ASSERT( len == dst_len ); - TEST_ASSERT( memcmp( dst, res, len ) == 0 ); + TEST_ASSERT( len == dst->len ); + TEST_ASSERT( memcmp( dst->x, res, len ) == 0 ); } exit: - mbedtls_free( dst ); mbedtls_free( res ); } /* END_CASE */ /* BEGIN_CASE */ -void base64_decode_hex_src( char *src_hex, char *dst_ref, int result ) +void base64_decode_hex_src( data_t * src, char * dst_ref, int result ) { unsigned char dst[1000] = { 0 }; - unsigned char *src; - size_t src_len, len; - - src = unhexify_alloc( src_hex, &src_len ); + size_t len; - TEST_ASSERT( mbedtls_base64_decode( dst, sizeof( dst ), &len, src, src_len ) == result ); + TEST_ASSERT( mbedtls_base64_decode( dst, sizeof( dst ), &len, src->x, src->len ) == result ); if( result == 0 ) { TEST_ASSERT( len == strlen( dst_ref ) ); @@ -112,12 +105,12 @@ void base64_decode_hex_src( char *src_hex, char *dst_ref, int result ) } exit: - mbedtls_free( src ); + ;; } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void base64_selftest() +void base64_selftest( ) { TEST_ASSERT( mbedtls_base64_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.data index 1ba311f590..fd172d3b2c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.data @@ -1,3 +1,9 @@ +BLOWFISH - Valid parameters +blowfish_valid_param: + +BLOWFISH - Invalid parameters +blowfish_invalid_param: + BLOWFISH-ECB Encrypt SSLeay reference #1 blowfish_encrypt_ecb:"0000000000000000":"0000000000000000":"4ef997456198dd78":0 @@ -203,13 +209,13 @@ BLOWFISH-ECB Decrypt SSLeay reference #34 blowfish_decrypt_ecb:"fedcba9876543210":"6b5c5a9c5d9e0a5a":"ffffffffffffffff":0 BLOWFISH-SETKEY Setkey SSLeay reference #1 -blowfish_encrypt_ecb:"f0":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH +blowfish_encrypt_ecb:"f0":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA BLOWFISH-SETKEY Setkey SSLeay reference #2 -blowfish_encrypt_ecb:"f0e1":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH +blowfish_encrypt_ecb:"f0e1":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA BLOWFISH-SETKEY Setkey SSLeay reference #3 -blowfish_encrypt_ecb:"f0e1d2":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH +blowfish_encrypt_ecb:"f0e1d2":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA BLOWFISH-SETKEY Setkey SSLeay reference #4 blowfish_encrypt_ecb:"f0e1d2c3":"fedcba9876543210":"be1e639408640f05":0 @@ -281,7 +287,7 @@ BLOWFISH-SETKEY Setkey 448 bits blowfish_encrypt_ecb:"f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566778899aabbccddeeff0123456789abcdef0102030405060708090a0b0c0d0e0fff":"fedcba9876543210":"2fb3ab7f0ee91b69":0 BLOWFISH-SETKEY Setkey 456 bits -blowfish_encrypt_ecb:"f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566778899aabbccddeeff0123456789abcdef0102030405060708090a0b0c0d0e0fffff":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH +blowfish_encrypt_ecb:"f0e1d2c3b4a5968778695a4b3c2d1e0f00112233445566778899aabbccddeeff0123456789abcdef0102030405060708090a0b0c0d0e0fffff":"fedcba9876543210":"":MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA BLOWFISH-CBC Encrypt blowfish_encrypt_cbc:"0123456789ABCDEFF0E1D2C3B4A59687":"FEDCBA9876543210":"37363534333231204E6F77206973207468652074696D6520666F722000000000":"6b77b4d63006dee605b156e27403979358deb9e7154616d959f1652bd5ff92cc":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.function index e3c2252906..7a93cd1395 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_blowfish.function @@ -8,32 +8,180 @@ */ /* BEGIN_CASE */ -void blowfish_encrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string, int setkey_result ) +void blowfish_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_blowfish_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void blowfish_invalid_param( ) +{ + mbedtls_blowfish_context ctx; + unsigned char buf[16] = { 0 }; + size_t const valid_keylength = sizeof( buf ) * 8; + size_t valid_mode = MBEDTLS_BLOWFISH_ENCRYPT; + size_t invalid_mode = 42; + size_t off; + ((void) off); + + TEST_INVALID_PARAM( mbedtls_blowfish_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_blowfish_free( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_setkey( NULL, + buf, + valid_keylength ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_setkey( &ctx, + NULL, + valid_keylength ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ecb( NULL, + valid_mode, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ecb( &ctx, + invalid_mode, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ecb( &ctx, + valid_mode, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ecb( &ctx, + valid_mode, + buf, NULL ) ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cbc( NULL, + valid_mode, + sizeof( buf ), + buf, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cbc( &ctx, + invalid_mode, + sizeof( buf ), + buf, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cbc( &ctx, + valid_mode, + sizeof( buf ), + NULL, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cbc( &ctx, + valid_mode, + sizeof( buf ), + buf, NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cbc( &ctx, + valid_mode, + sizeof( buf ), + buf, buf, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cfb64( NULL, + valid_mode, + sizeof( buf ), + &off, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cfb64( &ctx, + invalid_mode, + sizeof( buf ), + &off, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cfb64( &ctx, + valid_mode, + sizeof( buf ), + NULL, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cfb64( &ctx, + valid_mode, + sizeof( buf ), + &off, NULL, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cfb64( &ctx, + valid_mode, + sizeof( buf ), + &off, buf, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_cfb64( &ctx, + valid_mode, + sizeof( buf ), + &off, buf, + buf, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ctr( NULL, + sizeof( buf ), + &off, + buf, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ctr( &ctx, + sizeof( buf ), + NULL, + buf, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ctr( &ctx, + sizeof( buf ), + &off, + NULL, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ctr( &ctx, + sizeof( buf ), + &off, + buf, NULL, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ctr( &ctx, + sizeof( buf ), + &off, + buf, buf, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA, + mbedtls_blowfish_crypt_ctr( &ctx, + sizeof( buf ), + &off, + buf, buf, + buf, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE */ +void blowfish_encrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string, int setkey_result ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; - int key_len; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ) == setkey_result ); + TEST_ASSERT( mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ) == setkey_result ); if( setkey_result == 0 ) { - TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); } exit: @@ -42,32 +190,22 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void blowfish_decrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string, int setkey_result ) +void blowfish_decrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string, int setkey_result ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; - int key_len; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ) == setkey_result ); + TEST_ASSERT( mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ) == setkey_result ); if( setkey_result == 0 ) { - TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + TEST_ASSERT( mbedtls_blowfish_crypt_ecb( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); } exit: @@ -76,37 +214,24 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void blowfish_encrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, +void blowfish_encrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; - int key_len, data_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - data_len = unhexify( src_str, hex_src_string ); - mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ); + mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ); - TEST_ASSERT( mbedtls_blowfish_crypt_cbc( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, data_len , iv_str, src_str, output ) == cbc_result ); + TEST_ASSERT( mbedtls_blowfish_crypt_cbc( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->len , iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, data_len ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -115,36 +240,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void blowfish_decrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, +void blowfish_decrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; - int key_len, data_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - data_len = unhexify( src_str, hex_src_string ); - mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_blowfish_crypt_cbc( &ctx, MBEDTLS_BLOWFISH_DECRYPT, data_len , iv_str, src_str, output ) == cbc_result ); + mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_blowfish_crypt_cbc( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->len , iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0) { - hexify( dst_str, output, data_len ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -153,34 +265,22 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void blowfish_encrypt_cfb64( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void blowfish_encrypt_cfb64( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string + ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; size_t iv_offset = 0; - int key_len, src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); - mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_len, &iv_offset, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, src_len ); + mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_ENCRYPT, src_str->len, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); exit: mbedtls_blowfish_free( &ctx ); @@ -188,34 +288,22 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void blowfish_decrypt_cfb64( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void blowfish_decrypt_cfb64( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string + ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; size_t iv_offset = 0; - int key_len, src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); - mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_len, &iv_offset, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, src_len ); + mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_blowfish_crypt_cfb64( &ctx, MBEDTLS_BLOWFISH_DECRYPT, src_str->len, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); exit: mbedtls_blowfish_free( &ctx ); @@ -223,36 +311,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CTR */ -void blowfish_encrypt_ctr( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void blowfish_encrypt_ctr( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; unsigned char stream_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_blowfish_context ctx; size_t iv_offset = 0; - int key_len, src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); memset(stream_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_blowfish_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); - mbedtls_blowfish_setkey( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_blowfish_crypt_ctr( &ctx, src_len, &iv_offset, iv_str, stream_str, src_str, output ) == 0 ); - hexify( dst_str, output, src_len ); + mbedtls_blowfish_setkey( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_blowfish_crypt_ctr( &ctx, src_str->len, &iv_offset, iv_str->x, stream_str, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); exit: mbedtls_blowfish_free( &ctx ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.data index 14298387a0..671d57002a 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.data @@ -1,3 +1,9 @@ +Camellia - Valid parameters +camellia_valid_param: + +Camellia - Invalid parameters +camellia_invalid_param: + Camellia-128-ECB Encrypt RFC3713 #1 camellia_encrypt_ecb:"0123456789abcdeffedcba9876543210":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43":0 @@ -185,10 +191,10 @@ depends_on:MBEDTLS_CIPHER_MODE_CFB camellia_decrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"555FC3F34BDD2D54C62D9E3BF338C1C4":"F69F2445DF4F9B17AD2B417BE66C3710":"5953ADCE14DB8C7F39F1BD39F359BFFA" Camellia-ECB Encrypt (Invalid key length) -camellia_encrypt_ecb:"0123456789abcdeffedcba98765432":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43":MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH +camellia_encrypt_ecb:"0123456789abcdeffedcba98765432":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43":MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA Camellia-ECB Decrypt (Invalid key length) -camellia_decrypt_ecb:"0123456789abcdeffedcba98765432":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43":MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH +camellia_decrypt_ecb:"0123456789abcdeffedcba98765432":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43":MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA Camellia-256-CBC Encrypt (Invalid input length) camellia_encrypt_cbc:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"ffffffffffffffe000000000000000":"":MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.function index 9df6482a8d..9408348151 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_camellia.function @@ -8,32 +8,188 @@ */ /* BEGIN_CASE */ -void camellia_encrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string, int setkey_result ) +void camellia_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_camellia_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void camellia_invalid_param( ) +{ + mbedtls_camellia_context ctx; + unsigned char buf[16] = { 0 }; + const size_t valid_keybits = 128; + const int invalid_mode = 42; + const int valid_mode = MBEDTLS_CAMELLIA_ENCRYPT; + size_t off; + ((void) off); + + TEST_INVALID_PARAM( mbedtls_camellia_init( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_setkey_enc( NULL, + buf, + valid_keybits ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_setkey_enc( &ctx, + NULL, + valid_keybits ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_setkey_dec( NULL, + buf, + valid_keybits ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_setkey_dec( &ctx, + NULL, + valid_keybits ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ecb( NULL, + valid_mode, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ecb( &ctx, + invalid_mode, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ecb( &ctx, + valid_mode, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ecb( &ctx, + valid_mode, + buf, NULL ) ); + +#if defined(MBEDTLS_CIPHER_MODE_CBC) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cbc( NULL, + valid_mode, + sizeof( buf ), + buf, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cbc( &ctx, + invalid_mode, + sizeof( buf ), + buf, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cbc( &ctx, + valid_mode, + sizeof( buf ), + NULL, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cbc( &ctx, + valid_mode, + sizeof( buf ), + buf, NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cbc( &ctx, + valid_mode, + sizeof( buf ), + buf, buf, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cfb128( NULL, + valid_mode, + sizeof( buf ), + &off, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cfb128( &ctx, + invalid_mode, + sizeof( buf ), + &off, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cfb128( &ctx, + valid_mode, + sizeof( buf ), + NULL, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cfb128( &ctx, + valid_mode, + sizeof( buf ), + &off, NULL, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cfb128( &ctx, + valid_mode, + sizeof( buf ), + &off, buf, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_cfb128( &ctx, + valid_mode, + sizeof( buf ), + &off, buf, + buf, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ctr( NULL, + sizeof( buf ), + &off, + buf, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ctr( &ctx, + sizeof( buf ), + NULL, + buf, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ctr( &ctx, + sizeof( buf ), + &off, + NULL, buf, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ctr( &ctx, + sizeof( buf ), + &off, + buf, NULL, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ctr( &ctx, + sizeof( buf ), + &off, + buf, buf, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA, + mbedtls_camellia_crypt_ctr( &ctx, + sizeof( buf ), + &off, + buf, buf, + buf, NULL ) ); +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE */ +void camellia_encrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string, int setkey_result ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_camellia_context ctx; - int key_len; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_camellia_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_camellia_setkey_enc( &ctx, key_str, key_len * 8 ) == setkey_result ); + TEST_ASSERT( mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 ) == setkey_result ); if( setkey_result == 0 ) { - TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); } exit: @@ -42,32 +198,22 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void camellia_decrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string, int setkey_result ) +void camellia_decrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string, int setkey_result ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_camellia_context ctx; - int key_len; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_camellia_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_camellia_setkey_dec( &ctx, key_str, key_len * 8 ) == setkey_result ); + TEST_ASSERT( mbedtls_camellia_setkey_dec( &ctx, key_str->x, key_str->len * 8 ) == setkey_result ); if( setkey_result == 0 ) { - TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + TEST_ASSERT( mbedtls_camellia_crypt_ecb( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); } exit: @@ -76,36 +222,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void camellia_encrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, +void camellia_encrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_camellia_context ctx; - int key_len, data_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_camellia_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - data_len = unhexify( src_str, hex_src_string ); - mbedtls_camellia_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_camellia_crypt_cbc( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, data_len, iv_str, src_str, output) == cbc_result ); + mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_camellia_crypt_cbc( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, src_str->len, iv_str->x, src_str->x, output) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, data_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -114,36 +247,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void camellia_decrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, +void camellia_decrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_camellia_context ctx; - int key_len, data_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_camellia_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - data_len = unhexify( src_str, hex_src_string ); - mbedtls_camellia_setkey_dec( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_camellia_crypt_cbc( &ctx, MBEDTLS_CAMELLIA_DECRYPT, data_len, iv_str, src_str, output ) == cbc_result ); + mbedtls_camellia_setkey_dec( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_camellia_crypt_cbc( &ctx, MBEDTLS_CAMELLIA_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, data_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -152,34 +272,22 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void camellia_encrypt_cfb128( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void camellia_encrypt_cfb128( data_t * key_str, data_t * iv_str, + data_t * src_str, + data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_camellia_context ctx; size_t iv_offset = 0; - int key_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_camellia_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - unhexify( src_str, hex_src_string ); - mbedtls_camellia_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); exit: mbedtls_camellia_free( &ctx ); @@ -187,34 +295,22 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CFB */ -void camellia_decrypt_cfb128( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void camellia_decrypt_cfb128( data_t * key_str, data_t * iv_str, + data_t * src_str, + data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_camellia_context ctx; size_t iv_offset = 0; - int key_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_camellia_init( &ctx ); - key_len = unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - unhexify( src_str, hex_src_string ); - mbedtls_camellia_setkey_enc( &ctx, key_str, key_len * 8 ); - TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_DECRYPT, 16, &iv_offset, iv_str, src_str, output ) == 0 ); - hexify( dst_str, output, 16 ); + mbedtls_camellia_setkey_enc( &ctx, key_str->x, key_str->len * 8 ); + TEST_ASSERT( mbedtls_camellia_crypt_cfb128( &ctx, MBEDTLS_CAMELLIA_DECRYPT, 16, &iv_offset, iv_str->x, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 16, hex_dst_string->len ) == 0 ); exit: mbedtls_camellia_free( &ctx ); @@ -222,7 +318,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void camellia_selftest() +void camellia_selftest( ) { TEST_ASSERT( mbedtls_camellia_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.data index 90ba42d83c..ac9c565da2 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.data @@ -1,6 +1,12 @@ CCM self test mbedtls_ccm_self_test: +CCM - Invalid parameters +ccm_invalid_param: + +CCM - Valid parameters +ccm_valid_param: + CCM init #1 AES-128: OK depends_on:MBEDTLS_AES_C mbedtls_ccm_setkey:MBEDTLS_CIPHER_ID_AES:128:0 @@ -36,11 +42,45 @@ CCM lengths #6 tag length not even ccm_lengths:5:10:5:7:MBEDTLS_ERR_CCM_BAD_INPUT CCM lenghts #7 AD too long (2^16 - 2^8 + 1) +depends_on:!MBEDTLS_CCM_ALT ccm_lengths:5:10:65281:8:MBEDTLS_ERR_CCM_BAD_INPUT CCM lengths #8 msg too long for this IV length (2^16, q = 2) ccm_lengths:65536:13:5:8:MBEDTLS_ERR_CCM_BAD_INPUT +CCM lengths #9 tag length 0 +ccm_lengths:5:10:5:0:MBEDTLS_ERR_CCM_BAD_INPUT + +CCM* fixed tag lengths #1 all OK +ccm_star_lengths:5:10:5:8:0 + +CCM* fixed tag lengths #2 all OK - tag length 0 +ccm_star_lengths:5:10:5:0:0 + +CCM* encrypt and tag #1 +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"":"ACDE480000000001":"00000005":2:"08D0842143010000000048DEAC020500000055CF000051525354":"223BC1EC841AB553":0 + +CCM* encrypt and tag #2 +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"61626364":"ACDE480000000001":"00000005":4:"69DC842143020000000048DEAC010000000048DEAC0405000000":"D43E022B":0 + +CCM* encrypt and tag #3 +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"CE":"ACDE480000000001":"00000005":6:"2BDC842143020000000048DEACFFFF010000000048DEAC060500000001":"D84FDE529061F9C6F1":0 + +CCM* auth decrypt tag #1 +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"223BC1EC841AB553":"ACDE480000000001":"00000005":2:"08D0842143010000000048DEAC020500000055CF000051525354":"":0 + +CCM* auth decrypt tag #2 +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"D43E022B":"ACDE480000000001":"00000005":4:"69DC842143020000000048DEAC010000000048DEAC0405000000":"61626364":0 + +CCM* auth decrypt tag #3 +depends_on:MBEDTLS_AES_C +mbedtls_ccm_star_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"D84FDE529061F9C6F1":"ACDE480000000001":"00000005":6:"2BDC842143020000000048DEACFFFF010000000048DEAC060500000001":"CE":0 + CCM encrypt and tag RFC 3610 #1 depends_on:MBEDTLS_AES_C mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E":"00000003020100A0A1A2A3A4A5":"0001020304050607":"588C979A61C663D2F066D0C2C0F989806D5F6B61DAC38417E8D12CFDF926E0" @@ -1003,387 +1043,387 @@ mbedtls_ccm_encrypt_and_tag:MBEDTLS_CIPHER_ID_AES:"2e6e34070caf1b8820ed39edfa834 CCM auth decrypt tag NIST DVPT AES-128 #1 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4ae701103c63deca5b5a3939d7d05992":"02209f55":"5a8aa485c316e9":"":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4ae701103c63deca5b5a3939d7d05992":"02209f55":"5a8aa485c316e9":"":4:0:"" CCM auth decrypt tag NIST DVPT AES-128 #2 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4ae701103c63deca5b5a3939d7d05992":"9a04c241":"3796cf51b87266":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4ae701103c63deca5b5a3939d7d05992":"9a04c241":"3796cf51b87266":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #3 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"75d582db43ce9b13ab4b6f7f14341330":"5a8aa485c316e9":"":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"75d582db43ce9b13ab4b6f7f14341330":"5a8aa485c316e9":"":16:0:"" CCM auth decrypt tag NIST DVPT AES-128 #4 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"3a65e03af37b81d05acc7ec1bc39deb0":"3796cf51b87266":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"3a65e03af37b81d05acc7ec1bc39deb0":"3796cf51b87266":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #5 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"90156f3f":"5a8aa485c316e9403aff859fbb":"":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"90156f3f":"5a8aa485c316e9403aff859fbb":"":4:0:"" CCM auth decrypt tag NIST DVPT AES-128 #6 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"88909016":"a16a2e741f1cd9717285b6d882":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3":"88909016":"a16a2e741f1cd9717285b6d882":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #7 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"fb04dc5a44c6bb000f2440f5154364b4":"5a8aa485c316e9403aff859fbb":"":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"fb04dc5a44c6bb000f2440f5154364b4":"5a8aa485c316e9403aff859fbb":"":16:0:"" CCM auth decrypt tag NIST DVPT AES-128 #8 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"5447075bf42a59b91f08064738b015ab":"a16a2e741f1cd9717285b6d882":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"5447075bf42a59b91f08064738b015ab":"a16a2e741f1cd9717285b6d882":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #9 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"a90e8ea44085ced791b2fdb7fd44b5cf0bd7d27718029bb703e1fa6b":"5a8aa485c316e9":"":4:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"a90e8ea44085ced791b2fdb7fd44b5cf0bd7d27718029bb703e1fa6b":"5a8aa485c316e9":"":4:0:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" CCM auth decrypt tag NIST DVPT AES-128 #10 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"50aafe0578c115c4a8e126ff7b3ccb64dce8ccaa8ceda69f23e5d81c":"31f8fa25827d48":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd":"50aafe0578c115c4a8e126ff7b3ccb64dce8ccaa8ceda69f23e5d81c":"31f8fa25827d48":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #11 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"24ab9eeb0e5508cae80074f1070ee188a637171860881f1f2d9a3fbc210595b7b8b1b41523111a8e":"5a8aa485c316e9":"":16:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"24ab9eeb0e5508cae80074f1070ee188a637171860881f1f2d9a3fbc210595b7b8b1b41523111a8e":"5a8aa485c316e9":"":16:0:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" CCM auth decrypt tag NIST DVPT AES-128 #12 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"7ebfda6fa5da1dbffd82dc29b875798fbcef8ba0084fbd2463af747cc88a001fa94e060290f209c4":"31f8fa25827d48":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"7ebfda6fa5da1dbffd82dc29b875798fbcef8ba0084fbd2463af747cc88a001fa94e060290f209c4":"31f8fa25827d48":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #13 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"4a550134f94455979ec4bf89ad2bd80d25a77ae94e456134a3e138b9":"5a8aa485c316e9403aff859fbb":"":4:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"4a550134f94455979ec4bf89ad2bd80d25a77ae94e456134a3e138b9":"5a8aa485c316e9403aff859fbb":"":4:0:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" CCM auth decrypt tag NIST DVPT AES-128 #14 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"118ec53dd1bfbe52d5b9fe5dfebecf2ee674ec983eada654091a5ae9":"49004912fdd7269279b1f06a89":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d5243":"118ec53dd1bfbe52d5b9fe5dfebecf2ee674ec983eada654091a5ae9":"49004912fdd7269279b1f06a89":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #15 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb6a9a970b9beb2ac1bd4fd62168f8378a":"5a8aa485c316e9403aff859fbb":"":16:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb6a9a970b9beb2ac1bd4fd62168f8378a":"5a8aa485c316e9403aff859fbb":"":16:0:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" CCM auth decrypt tag NIST DVPT AES-128 #16 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"0c56a503aa2c12e87450d45a7b714db980fd348f327c0065a65666144994bad0c8195bcb4ade1337":"49004912fdd7269279b1f06a89":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"0c56a503aa2c12e87450d45a7b714db980fd348f327c0065a65666144994bad0c8195bcb4ade1337":"49004912fdd7269279b1f06a89":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #17 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"782e4318":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"782e4318":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:0:"" CCM auth decrypt tag NIST DVPT AES-128 #18 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"a04f270a":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe4829":"a04f270a":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #19 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"41b476013f45e4a781f253a6f3b1e530":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"41b476013f45e4a781f253a6f3b1e530":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:0:"" CCM auth decrypt tag NIST DVPT AES-128 #20 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"f9f018fcd125822616083fffebc4c8e6":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"f9f018fcd125822616083fffebc4c8e6":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #21 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"9f69f24f":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"9f69f24f":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:0:"" CCM auth decrypt tag NIST DVPT AES-128 #22 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"e17afaa4":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b":"e17afaa4":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"1859ac36a40a6b28b34266253627797a":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"1859ac36a40a6b28b34266253627797a":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:0:"" CCM auth decrypt tag NIST DVPT AES-128 #24 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"edf8b46eb69ac0044116019dec183072":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"edf8b46eb69ac0044116019dec183072":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #25 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"6be31860ca271ef448de8f8d8b39346daf4b81d7e92d65b338f125fa":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"6be31860ca271ef448de8f8d8b39346daf4b81d7e92d65b338f125fa":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:0:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" CCM auth decrypt tag NIST DVPT AES-128 #26 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"4cc57a9927a6bc401441870d3193bf89ebd163f5c01501c728a66b69":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c7571":"4cc57a9927a6bc401441870d3193bf89ebd163f5c01501c728a66b69":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #27 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"b351ab96b2e45515254558d5212673ee6c776d42dbca3b512cf3a20b7fd7c49e6e79bef475c2906f":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"b351ab96b2e45515254558d5212673ee6c776d42dbca3b512cf3a20b7fd7c49e6e79bef475c2906f":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:0:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" CCM auth decrypt tag NIST DVPT AES-128 #28 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"df1a5285caa41b4bb47f6e5ceceba4e82721828d68427a3081d18ca149d6766bfaccec88f194eb5b":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"df1a5285caa41b4bb47f6e5ceceba4e82721828d68427a3081d18ca149d6766bfaccec88f194eb5b":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #29 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"934f893824e880f743d196b22d1f340a52608155087bd28ac25e5329":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"934f893824e880f743d196b22d1f340a52608155087bd28ac25e5329":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:0:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" CCM auth decrypt tag NIST DVPT AES-128 #30 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"f43ba9d834ad85dfab3f1c0c27c3441fe4e411a38a261a6559b3b3ee":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728c":"f43ba9d834ad85dfab3f1c0c27c3441fe4e411a38a261a6559b3b3ee":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-128 #31 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0e":"50038b5fdd364ee747b70d00bd36840ece4ea19998123375c0a458bfcafa3b2609afe0f825cbf503":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0e":"50038b5fdd364ee747b70d00bd36840ece4ea19998123375c0a458bfcafa3b2609afe0f825cbf503":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:0:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" CCM auth decrypt tag NIST DVPT AES-128 #32 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0e":"78ed8ff6b5a1255d0fbd0a719a9c27b059ff5f83d0c4962c390042ba8bb5f6798dab01c5afad7306":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0e":"78ed8ff6b5a1255d0fbd0a719a9c27b059ff5f83d0c4962c390042ba8bb5f6798dab01c5afad7306":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #1 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"9d4b7f3b":"5a8aa485c316e9":"":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"9d4b7f3b":"5a8aa485c316e9":"":4:0:"" CCM auth decrypt tag NIST DVPT AES-192 #2 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"80745de9":"3796cf51b87266":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"80745de9":"3796cf51b87266":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #3 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"17223038fa99d53681ca1beabe78d1b4":"5a8aa485c316e9":"":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"17223038fa99d53681ca1beabe78d1b4":"5a8aa485c316e9":"":16:0:"" CCM auth decrypt tag NIST DVPT AES-192 #4 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"d0e1eeef4d2a264536bb1c2c1bde7c35":"3796cf51b87266":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"d0e1eeef4d2a264536bb1c2c1bde7c35":"3796cf51b87266":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #5 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"fe69ed84":"5a8aa485c316e9403aff859fbb":"":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"fe69ed84":"5a8aa485c316e9403aff859fbb":"":4:0:"" CCM auth decrypt tag NIST DVPT AES-192 #6 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"db7ffc82":"a16a2e741f1cd9717285b6d882":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"db7ffc82":"a16a2e741f1cd9717285b6d882":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #7 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"0c66a8e547ed4f8c2c9a9a1eb5d455b9":"5a8aa485c316e9403aff859fbb":"":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"0c66a8e547ed4f8c2c9a9a1eb5d455b9":"5a8aa485c316e9403aff859fbb":"":16:0:"" CCM auth decrypt tag NIST DVPT AES-192 #8 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"38757b3a61a4dc97ca3ab88bf1240695":"a16a2e741f1cd9717285b6d882":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"38757b3a61a4dc97ca3ab88bf1240695":"a16a2e741f1cd9717285b6d882":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #9 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138cddc93a54":"5a8aa485c316e9":"":4:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"411986d04d6463100bff03f7d0bde7ea2c3488784378138cddc93a54":"5a8aa485c316e9":"":4:0:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" CCM auth decrypt tag NIST DVPT AES-192 #10 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"32b649ab56162e55d4148a1292d6a225a988eb1308298273b6889036":"31f8fa25827d48":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"32b649ab56162e55d4148a1292d6a225a988eb1308298273b6889036":"31f8fa25827d48":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #11 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"cba4b4aeb85f0492fd8d905c4a6d8233139833373ef188a8c5a5ebecf7ac8607fe412189e83d9d20":"5a8aa485c316e9":"":16:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"cba4b4aeb85f0492fd8d905c4a6d8233139833373ef188a8c5a5ebecf7ac8607fe412189e83d9d20":"5a8aa485c316e9":"":16:0:"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" CCM auth decrypt tag NIST DVPT AES-192 #12 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"ca62713728b5c9d652504b0ae8fd4fee5d297ee6a8d19cb6e699f15f14d34dcaf9ba8ed4b877c97d":"31f8fa25827d48":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"ca62713728b5c9d652504b0ae8fd4fee5d297ee6a8d19cb6e699f15f14d34dcaf9ba8ed4b877c97d":"31f8fa25827d48":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #13 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"042653c674ef2a90f7fb11d30848e530ae59478f1051633a34fad277":"5a8aa485c316e9403aff859fbb":"":4:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"042653c674ef2a90f7fb11d30848e530ae59478f1051633a34fad277":"5a8aa485c316e9403aff859fbb":"":4:0:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" CCM auth decrypt tag NIST DVPT AES-192 #14 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"1902d9769a7ba3d3268e1257395c8c2e5f98eef295dcbfa5a35df775":"49004912fdd7269279b1f06a89":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"1902d9769a7ba3d3268e1257395c8c2e5f98eef295dcbfa5a35df775":"49004912fdd7269279b1f06a89":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #15 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"a5b7d8cca2069908d1ed88e6a9fe2c9bede3131dad54671ea7ade30a07d185692ab0ebdf4c78cf7a":"5a8aa485c316e9403aff859fbb":"":16:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"a5b7d8cca2069908d1ed88e6a9fe2c9bede3131dad54671ea7ade30a07d185692ab0ebdf4c78cf7a":"5a8aa485c316e9403aff859fbb":"":16:0:"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" CCM auth decrypt tag NIST DVPT AES-192 #16 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"9a98617fb97a0dfe466be692272dcdaec1c5443a3b51312ef042c86363cc05afb98c66e16be8a445":"49004912fdd7269279b1f06a89":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"9a98617fb97a0dfe466be692272dcdaec1c5443a3b51312ef042c86363cc05afb98c66e16be8a445":"49004912fdd7269279b1f06a89":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #17 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"1d089a5f":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"1d089a5f":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:0:"" CCM auth decrypt tag NIST DVPT AES-192 #18 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"2f46022a":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"2f46022a":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #19 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5280a2137fee3deefcfe9b63a1199fb3":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5280a2137fee3deefcfe9b63a1199fb3":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:0:"" CCM auth decrypt tag NIST DVPT AES-192 #20 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"d40a7318c5f2d82f838c0beeefe0d598":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"d40a7318c5f2d82f838c0beeefe0d598":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #21 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5e0eaebd":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5e0eaebd":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:0:"" CCM auth decrypt tag NIST DVPT AES-192 #22 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"71b7fc33":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"71b7fc33":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"d07ccf9fdc3d33aa94cda3d230da707c":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"d07ccf9fdc3d33aa94cda3d230da707c":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:0:"" CCM auth decrypt tag NIST DVPT AES-192 #24 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"65fe32b649dc328c9f531584897e85b3":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"65fe32b649dc328c9f531584897e85b3":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #25 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"9f6ca4af9b159148c889a6584d1183ea26e2614874b0504575dea8d1":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"9f6ca4af9b159148c889a6584d1183ea26e2614874b0504575dea8d1":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":4:0:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" CCM auth decrypt tag NIST DVPT AES-192 #26 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"84d8212e9cfc2121252baa3b065b1edcf50497b9594db1ebd7965825":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"84d8212e9cfc2121252baa3b065b1edcf50497b9594db1ebd7965825":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #27 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"6aab64c4787599d8f213446beadb16e08dba60e97f56dbd14d1d980d6fe0fb44b421992662b97975":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"6aab64c4787599d8f213446beadb16e08dba60e97f56dbd14d1d980d6fe0fb44b421992662b97975":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":16:0:"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" CCM auth decrypt tag NIST DVPT AES-192 #28 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"4980b2ee49b1aaf393175f5ab9bae95ec7904557dfa206603c51d36c826f01384100886198a7f6a3":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"4980b2ee49b1aaf393175f5ab9bae95ec7904557dfa206603c51d36c826f01384100886198a7f6a3":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #29 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"16e543d0e20615ff0df15acd9927ddfe40668a54bb854cccc25e9fce":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"16e543d0e20615ff0df15acd9927ddfe40668a54bb854cccc25e9fce":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":4:0:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" CCM auth decrypt tag NIST DVPT AES-192 #30 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"df35b109caf690656ae278bbd8f8bba687a2ce11b105dae98ecedb3e":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"df35b109caf690656ae278bbd8f8bba687a2ce11b105dae98ecedb3e":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-192 #31 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"c5b0b2ef17498c5570eb335df4588032958ba3d69bf6f3178464a6f7fa2b76744e8e8d95691cecb8":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"c5b0b2ef17498c5570eb335df4588032958ba3d69bf6f3178464a6f7fa2b76744e8e8d95691cecb8":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":16:0:"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" CCM auth decrypt tag NIST DVPT AES-192 #32 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"d1f0518929f4ae2f0543de2a7dfe4bb0110bb3057e524a1c06bd6dc2e6bcc3436cffb969ae900388":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"d1f0518929f4ae2f0543de2a7dfe4bb0110bb3057e524a1c06bd6dc2e6bcc3436cffb969ae900388":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #1 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"469c90bb":"a544218dadd3c1":"":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"469c90bb":"a544218dadd3c1":"":4:0:"" CCM auth decrypt tag NIST DVPT AES-256 #2 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"46a908ed":"d3d5424e20fbec":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"46a908ed":"d3d5424e20fbec":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #3 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"8207eb14d33855a52acceed17dbcbf6e":"a544218dadd3c1":"":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"8207eb14d33855a52acceed17dbcbf6e":"a544218dadd3c1":"":16:0:"" CCM auth decrypt tag NIST DVPT AES-256 #4 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"60f8e127cb4d30db6df0622158cd931d":"d3d5424e20fbec":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"60f8e127cb4d30db6df0622158cd931d":"d3d5424e20fbec":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #5 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"8a19a133":"a544218dadd3c10583db49cf39":"":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"8a19a133":"a544218dadd3c10583db49cf39":"":4:0:"" CCM auth decrypt tag NIST DVPT AES-256 #6 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"2e317f1b":"3c0e2815d37d844f7ac240ba9d":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"2e317f1b":"3c0e2815d37d844f7ac240ba9d":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #7 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"97e1a8dd4259ccd2e431e057b0397fcf":"a544218dadd3c10583db49cf39":"":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"97e1a8dd4259ccd2e431e057b0397fcf":"a544218dadd3c10583db49cf39":"":16:0:"" CCM auth decrypt tag NIST DVPT AES-256 #8 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"5a9596c511ea6a8671adefc4f2157d8b":"3c0e2815d37d844f7ac240ba9d":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"5a9596c511ea6a8671adefc4f2157d8b":"3c0e2815d37d844f7ac240ba9d":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #9 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"64a1341679972dc5869fcf69b19d5c5ea50aa0b5e985f5b722aa8d59":"a544218dadd3c1":"":4:"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"64a1341679972dc5869fcf69b19d5c5ea50aa0b5e985f5b722aa8d59":"a544218dadd3c1":"":4:0:"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" CCM auth decrypt tag NIST DVPT AES-256 #10 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"c5b7f802bffc498c1626e3774f1d9f94045dfd8e1a10a20277d00a75":"bfcda8b5a2d0d2":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"c5b7f802bffc498c1626e3774f1d9f94045dfd8e1a10a20277d00a75":"bfcda8b5a2d0d2":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #11 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"bc51c3925a960e7732533e4ef3a4f69ee6826de952bcb0fd374f3bb6db8377ebfc79674858c4f305":"a544218dadd3c1":"":16:"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"bc51c3925a960e7732533e4ef3a4f69ee6826de952bcb0fd374f3bb6db8377ebfc79674858c4f305":"a544218dadd3c1":"":16:0:"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" CCM auth decrypt tag NIST DVPT AES-256 #12 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"afa1fa8e8a70e26b02161150556d604101fdf423f332c3363275f2a4907d51b734fe7238cebbd48f":"bfcda8b5a2d0d2":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"afa1fa8e8a70e26b02161150556d604101fdf423f332c3363275f2a4907d51b734fe7238cebbd48f":"bfcda8b5a2d0d2":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #13 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"63e00d30e4b08fd2a1cc8d70fab327b2368e77a93be4f4123d14fb3f":"a544218dadd3c10583db49cf39":"":4:"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"63e00d30e4b08fd2a1cc8d70fab327b2368e77a93be4f4123d14fb3f":"a544218dadd3c10583db49cf39":"":4:0:"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" CCM auth decrypt tag NIST DVPT AES-256 #14 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"bb5425b3869b76856ec58e39886fb6f6f2ac13fe44cb132d8d0c0099":"894dcaa61008eb8fb052c60d41":"":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"bb5425b3869b76856ec58e39886fb6f6f2ac13fe44cb132d8d0c0099":"894dcaa61008eb8fb052c60d41":"":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #15 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"f0050ad16392021a3f40207bed3521fb1e9f808f49830c423a578d179902f912f9ea1afbce1120b3":"a544218dadd3c10583db49cf39":"":16:"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"f0050ad16392021a3f40207bed3521fb1e9f808f49830c423a578d179902f912f9ea1afbce1120b3":"a544218dadd3c10583db49cf39":"":16:0:"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" CCM auth decrypt tag NIST DVPT AES-256 #16 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"c408190d0fbf5034f83b24a8ed9657331a7ce141de4fae769084607b83bd06e6442eac8dacf583cc":"894dcaa61008eb8fb052c60d41":"":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"c408190d0fbf5034f83b24a8ed9657331a7ce141de4fae769084607b83bd06e6442eac8dacf583cc":"894dcaa61008eb8fb052c60d41":"":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #17 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"92d00fbe":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"92d00fbe":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":4:0:"" CCM auth decrypt tag NIST DVPT AES-256 #18 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"9143e5c4":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"9143e5c4":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #19 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"93af11a08379eb37a16aa2837f09d69d":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"93af11a08379eb37a16aa2837f09d69d":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":16:0:"" CCM auth decrypt tag NIST DVPT AES-256 #20 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"d19b0c14ec686a7961ca7c386d125a65":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"d19b0c14ec686a7961ca7c386d125a65":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #21 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"866d4227":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":4:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"866d4227":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":4:0:"" CCM auth decrypt tag NIST DVPT AES-256 #22 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"94cb1127":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"94cb1127":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"867b0d87cf6e0f718200a97b4f6d5ad5":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":16:"" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"867b0d87cf6e0f718200a97b4f6d5ad5":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":16:0:"" CCM auth decrypt tag NIST DVPT AES-256 #24 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"677a040d46ee3f2b7838273bdad14f16":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"677a040d46ee3f2b7838273bdad14f16":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #25 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"c2fe12658139f5d0dd22cadf2e901695b579302a72fc56083ebc7720":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":4:"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"c2fe12658139f5d0dd22cadf2e901695b579302a72fc56083ebc7720":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":4:0:"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" CCM auth decrypt tag NIST DVPT AES-256 #26 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"94748ba81229e53c38583a8564b23ebbafc6f6efdf4c2a81c44db2c9":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"94748ba81229e53c38583a8564b23ebbafc6f6efdf4c2a81c44db2c9":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #27 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"3341168eb8c48468c414347fb08f71d2086f7c2d1bd581ce1ac68bd42f5ec7fa7e068cc0ecd79c2a":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":16:"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"3341168eb8c48468c414347fb08f71d2086f7c2d1bd581ce1ac68bd42f5ec7fa7e068cc0ecd79c2a":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":16:0:"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" CCM auth decrypt tag NIST DVPT AES-256 #28 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"d543acda712b898cbb27b8f598b2e4438ce587a836e2785147c3338a2400809e739b63ba8227d2f9":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"d543acda712b898cbb27b8f598b2e4438ce587a836e2785147c3338a2400809e739b63ba8227d2f9":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #29 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"c0ea400b599561e7905b99262b4565d5c3dc49fad84d7c69ef891339":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":4:"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"c0ea400b599561e7905b99262b4565d5c3dc49fad84d7c69ef891339":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":4:0:"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" CCM auth decrypt tag NIST DVPT AES-256 #30 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"60871e03ea0eb968536c99f926ea24ef43d41272ad9fb7f63d488623":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":4:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"60871e03ea0eb968536c99f926ea24ef43d41272ad9fb7f63d488623":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":4:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM auth decrypt tag NIST DVPT AES-256 #31 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"8d34cdca37ce77be68f65baf3382e31efa693e63f914a781367f30f2eaad8c063ca50795acd90203":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":16:"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"8d34cdca37ce77be68f65baf3382e31efa693e63f914a781367f30f2eaad8c063ca50795acd90203":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":16:0:"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" CCM auth decrypt tag NIST DVPT AES-256 #32 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C -mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"516c0095cc3d85fd55e48da17c592e0c7014b9daafb82bdc4b41096dfdbe9cc1ab610f8f3e038d16":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":16:"FAIL" +mbedtls_ccm_auth_decrypt:MBEDTLS_CIPHER_ID_AES:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"516c0095cc3d85fd55e48da17c592e0c7014b9daafb82bdc4b41096dfdbe9cc1ab610f8f3e038d16":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":16:MBEDTLS_ERR_CCM_AUTH_FAILED:"" CCM-Camellia encrypt and tag RFC 5528 #1 depends_on:MBEDTLS_CAMELLIA_C diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.function index 2f5c77c2c7..16f9f8e3ba 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ccm.function @@ -8,7 +8,7 @@ */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST:MBEDTLS_AES_C */ -void mbedtls_ccm_self_test( ) +void mbedtls_ccm_self_test( ) { TEST_ASSERT( mbedtls_ccm_self_test( 1 ) == 0 ); } @@ -74,19 +74,139 @@ exit: } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_AES_C */ +void ccm_star_lengths( int msg_len, int iv_len, int add_len, int tag_len, + int res ) +{ + mbedtls_ccm_context ctx; + unsigned char key[16]; + unsigned char msg[10]; + unsigned char iv[14]; + unsigned char add[10]; + unsigned char out[10]; + unsigned char tag[18]; + int decrypt_ret; + + mbedtls_ccm_init( &ctx ); + + memset( key, 0, sizeof( key ) ); + memset( msg, 0, sizeof( msg ) ); + memset( iv, 0, sizeof( iv ) ); + memset( add, 0, sizeof( add ) ); + memset( out, 0, sizeof( out ) ); + memset( tag, 0, sizeof( tag ) ); + + TEST_ASSERT( mbedtls_ccm_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, + key, 8 * sizeof( key ) ) == 0 ); + + TEST_ASSERT( mbedtls_ccm_star_encrypt_and_tag( &ctx, msg_len, iv, iv_len, + add, add_len, msg, out, tag, tag_len ) == res ); + + decrypt_ret = mbedtls_ccm_star_auth_decrypt( &ctx, msg_len, iv, iv_len, add, + add_len, msg, out, tag, tag_len ); + + if( res == 0 && tag_len != 0 ) + TEST_ASSERT( decrypt_ret == MBEDTLS_ERR_CCM_AUTH_FAILED ); + else + TEST_ASSERT( decrypt_ret == res ); + +exit: + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_encrypt_and_tag( int cipher_id, data_t * key, + data_t * msg, data_t * iv, + data_t * add, data_t * result ) +{ + mbedtls_ccm_context ctx; + size_t tag_len; + uint8_t * msg_n_tag = (uint8_t *)malloc( result->len + 2 ); + + mbedtls_ccm_init( &ctx ); + + memset( msg_n_tag, 0, result->len + 2 ); + memcpy( msg_n_tag, msg->x, msg->len ); + + tag_len = result->len - msg->len; + + TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 ); + + /* Test with input == output */ + TEST_ASSERT( mbedtls_ccm_encrypt_and_tag( &ctx, msg->len, iv->x, iv->len, add->x, add->len, + msg_n_tag, msg_n_tag, msg_n_tag + msg->len, tag_len ) == 0 ); + + TEST_ASSERT( memcmp( msg_n_tag, result->x, result->len ) == 0 ); + + /* Check we didn't write past the end */ + TEST_ASSERT( msg_n_tag[result->len] == 0 && msg_n_tag[result->len + 1] == 0 ); + +exit: + mbedtls_ccm_free( &ctx ); + free( msg_n_tag ); +} +/* END_CASE */ + /* BEGIN_CASE */ -void mbedtls_ccm_encrypt_and_tag( int cipher_id, - char *key_hex, char *msg_hex, - char *iv_hex, char *add_hex, - char *result_hex ) +void mbedtls_ccm_auth_decrypt( int cipher_id, data_t * key, + data_t * msg, data_t * iv, + data_t * add, int tag_len, int result, + data_t * hex_msg ) +{ + unsigned char tag[16]; + mbedtls_ccm_context ctx; + + mbedtls_ccm_init( &ctx ); + + memset( tag, 0x00, sizeof( tag ) ); + + msg->len -= tag_len; + memcpy( tag, msg->x + msg->len, tag_len ); + + TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key->x, key->len * 8 ) == 0 ); + + /* Test with input == output */ + TEST_ASSERT( mbedtls_ccm_auth_decrypt( &ctx, msg->len, iv->x, iv->len, add->x, add->len, + msg->x, msg->x, msg->x + msg->len, tag_len ) == result ); + + if( result == 0 ) + { + TEST_ASSERT( memcmp( msg->x, hex_msg->x, hex_msg->len ) == 0 ); + } + else + { + size_t i; + + for( i = 0; i < msg->len; i++ ) + TEST_ASSERT( msg->x[i] == 0 ); + } + + /* Check we didn't write past the end (where the original tag is) */ + TEST_ASSERT( memcmp( msg->x + msg->len, tag, tag_len ) == 0 ); + +exit: + mbedtls_ccm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ccm_star_encrypt_and_tag( int cipher_id, + char *key_hex, char *msg_hex, + char *source_address_hex, char *frame_counter_hex, + int sec_level, char *add_hex, + char *result_hex, int output_ret ) { unsigned char key[32]; unsigned char msg[50]; unsigned char iv[13]; unsigned char add[32]; unsigned char result[50]; + unsigned char source_address[8]; + unsigned char frame_counter[4]; mbedtls_ccm_context ctx; - size_t key_len, msg_len, iv_len, add_len, tag_len, result_len; + size_t i, key_len, msg_len, iv_len, add_len, result_len, source_address_len, frame_counter_len, tag_len; + int ret; mbedtls_ccm_init( &ctx ); @@ -95,19 +215,36 @@ void mbedtls_ccm_encrypt_and_tag( int cipher_id, memset( iv, 0x00, sizeof( iv ) ); memset( add, 0x00, sizeof( add ) ); memset( result, 0x00, sizeof( result ) ); + memset( source_address, 0x00, sizeof( source_address ) ); + memset( frame_counter, 0x00, sizeof( frame_counter ) ); key_len = unhexify( key, key_hex ); msg_len = unhexify( msg, msg_hex ); - iv_len = unhexify( iv, iv_hex ); add_len = unhexify( add, add_hex ); result_len = unhexify( result, result_hex ); - tag_len = result_len - msg_len; + source_address_len = unhexify( source_address, source_address_hex ); + frame_counter_len = unhexify( frame_counter, frame_counter_hex ); + + if( sec_level % 4 == 0) + tag_len = 0; + else + tag_len = 1 << ( sec_level % 4 + 1); + + for( i = 0; i < source_address_len; i++ ) + iv[i] = source_address[i]; + + for( i = 0; i < frame_counter_len; i++ ) + iv[source_address_len + i] = frame_counter[i]; + + iv[source_address_len + frame_counter_len] = sec_level; + iv_len = sizeof( iv ); TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key, key_len * 8 ) == 0 ); - /* Test with input == output */ - TEST_ASSERT( mbedtls_ccm_encrypt_and_tag( &ctx, msg_len, iv, iv_len, add, add_len, - msg, msg, msg + msg_len, tag_len ) == 0 ); + ret = mbedtls_ccm_star_encrypt_and_tag( &ctx, msg_len, iv, iv_len, + add, add_len, msg, msg, msg + msg_len, tag_len ); + + TEST_ASSERT( ret == output_ret ); TEST_ASSERT( memcmp( msg, result, result_len ) == 0 ); @@ -120,10 +257,11 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ccm_auth_decrypt( int cipher_id, - char *key_hex, char *msg_hex, - char *iv_hex, char *add_hex, - int tag_len, char *result_hex ) +void mbedtls_ccm_star_auth_decrypt( int cipher_id, + char *key_hex, char *msg_hex, + char *source_address_hex, char *frame_counter_hex, + int sec_level, char *add_hex, + char *result_hex, int output_ret ) { unsigned char key[32]; unsigned char msg[50]; @@ -131,8 +269,10 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, unsigned char add[32]; unsigned char tag[16]; unsigned char result[50]; + unsigned char source_address[8]; + unsigned char frame_counter[4]; mbedtls_ccm_context ctx; - size_t key_len, msg_len, iv_len, add_len, result_len; + size_t i, key_len, msg_len, iv_len, add_len, tag_len, result_len, source_address_len, frame_counter_len; int ret; mbedtls_ccm_init( &ctx ); @@ -141,44 +281,43 @@ void mbedtls_ccm_auth_decrypt( int cipher_id, memset( msg, 0x00, sizeof( msg ) ); memset( iv, 0x00, sizeof( iv ) ); memset( add, 0x00, sizeof( add ) ); - memset( tag, 0x00, sizeof( tag ) ); memset( result, 0x00, sizeof( result ) ); + memset( source_address, 0x00, sizeof( source_address ) ); + memset( frame_counter, 0x00, sizeof( frame_counter ) ); + memset( tag, 0x00, sizeof( tag ) ); key_len = unhexify( key, key_hex ); msg_len = unhexify( msg, msg_hex ); - iv_len = unhexify( iv, iv_hex ); add_len = unhexify( add, add_hex ); - msg_len -= tag_len; - memcpy( tag, msg + msg_len, tag_len ); + result_len = unhexify( result, result_hex ); + source_address_len = unhexify( source_address, source_address_hex ); + frame_counter_len = unhexify( frame_counter, frame_counter_hex ); - if( strcmp( "FAIL", result_hex ) == 0 ) - { - ret = MBEDTLS_ERR_CCM_AUTH_FAILED; - result_len = -1; - } + if( sec_level % 4 == 0) + tag_len = 0; else - { - ret = 0; - result_len = unhexify( result, result_hex ); - } + tag_len = 1 << ( sec_level % 4 + 1); + + for( i = 0; i < source_address_len; i++ ) + iv[i] = source_address[i]; + + for( i = 0; i < frame_counter_len; i++ ) + iv[source_address_len + i] = frame_counter[i]; + + iv[source_address_len + frame_counter_len] = sec_level; + iv_len = sizeof( iv ); + + msg_len -= tag_len; + memcpy( tag, msg + msg_len, tag_len ); TEST_ASSERT( mbedtls_ccm_setkey( &ctx, cipher_id, key, key_len * 8 ) == 0 ); - /* Test with input == output */ - TEST_ASSERT( mbedtls_ccm_auth_decrypt( &ctx, msg_len, iv, iv_len, add, add_len, - msg, msg, msg + msg_len, tag_len ) == ret ); + ret = mbedtls_ccm_star_auth_decrypt( &ctx, msg_len, iv, iv_len, + add, add_len, msg, msg, msg + msg_len, tag_len ); - if( ret == 0 ) - { - TEST_ASSERT( memcmp( msg, result, result_len ) == 0 ); - } - else - { - size_t i; + TEST_ASSERT( ret == output_ret ); - for( i = 0; i < msg_len; i++ ) - TEST_ASSERT( msg[i] == 0 ); - } + TEST_ASSERT( memcmp( msg, result, result_len ) == 0 ); /* Check we didn't write past the end (where the original tag is) */ TEST_ASSERT( memcmp( msg + msg_len, tag, tag_len ) == 0 ); @@ -187,3 +326,216 @@ exit: mbedtls_ccm_free( &ctx ); } /* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void ccm_invalid_param( ) +{ + struct mbedtls_ccm_context ctx; + unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + mbedtls_cipher_id_t valid_cipher = MBEDTLS_CIPHER_ID_AES; + int valid_len = sizeof(valid_buffer); + int valid_bitlen = valid_len * 8; + + mbedtls_ccm_init( &ctx ); + + /* mbedtls_ccm_init() */ + TEST_INVALID_PARAM( mbedtls_ccm_init( NULL ) ); + + /* mbedtls_ccm_setkey() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_setkey( NULL, valid_cipher, valid_buffer, valid_bitlen ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_setkey( &ctx, valid_cipher, NULL, valid_bitlen ) ); + + /* mbedtls_ccm_encrypt_and_tag() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_encrypt_and_tag( NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_encrypt_and_tag( &ctx, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, NULL, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + NULL, valid_len ) ); + + /* mbedtls_ccm_star_encrypt_and_tag() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_encrypt_and_tag( NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, NULL, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_encrypt_and_tag( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + NULL, valid_len ) ); + + /* mbedtls_ccm_auth_decrypt() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_auth_decrypt( NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_auth_decrypt( &ctx, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, NULL, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + NULL, valid_len ) ); + + /* mbedtls_ccm_star_auth_decrypt() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_auth_decrypt( NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_auth_decrypt( &ctx, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_buffer, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, NULL, + valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CCM_BAD_INPUT, + mbedtls_ccm_star_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + NULL, valid_len ) ); + +exit: + mbedtls_ccm_free( &ctx ); + return; +} +/* END_CASE */ + +/* BEGIN_CASE */ +void ccm_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_ccm_free( NULL ) ); +exit: + return; +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chacha20.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chacha20.data new file mode 100644 index 0000000000..3f9033eeb2 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chacha20.data @@ -0,0 +1,29 @@ +ChaCha20 RFC 7539 Example and Test Vector (Encrypt) +chacha20_crypt:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f":"000000000000004a00000000":1:"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d" + +ChaCha20 RFC 7539 Example and Test Vector (Decrypt) +chacha20_crypt:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f":"000000000000004a00000000":1:"6e2e359a2568f98041ba0728dd0d6981e97e7aec1d4360c20a27afccfd9fae0bf91b65c5524733ab8f593dabcd62b3571639d624e65152ab8f530c359f0861d807ca0dbf500d6a6156a38e088a22b65e52bc514d16ccf806818ce91ab77937365af90bbf74a35be6b40b8eedf2785e42874d":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e" + +ChaCha20 RFC 7539 Test Vector #1 (Encrypt) +chacha20_crypt:"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000":0:"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000":"76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586" + +ChaCha20 RFC 7539 Test Vector #1 (Decrypt) +chacha20_crypt:"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000":0:"76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + +ChaCha20 RFC 7539 Test Vector #2 (Encrypt) +chacha20_crypt:"0000000000000000000000000000000000000000000000000000000000000001":"000000000000000000000002":1:"416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f":"a3fbf07df3fa2fde4f376ca23e82737041605d9f4f4f57bd8cff2c1d4b7955ec2a97948bd3722915c8f3d337f7d370050e9e96d647b7c39f56e031ca5eb6250d4042e02785ececfa4b4bb5e8ead0440e20b6e8db09d881a7c6132f420e52795042bdfa7773d8a9051447b3291ce1411c680465552aa6c405b7764d5e87bea85ad00f8449ed8f72d0d662ab052691ca66424bc86d2df80ea41f43abf937d3259dc4b2d0dfb48a6c9139ddd7f76966e928e635553ba76c5c879d7b35d49eb2e62b0871cdac638939e25e8a1e0ef9d5280fa8ca328b351c3c765989cbcf3daa8b6ccc3aaf9f3979c92b3720fc88dc95ed84a1be059c6499b9fda236e7e818b04b0bc39c1e876b193bfe5569753f88128cc08aaa9b63d1a16f80ef2554d7189c411f5869ca52c5b83fa36ff216b9c1d30062bebcfd2dc5bce0911934fda79a86f6e698ced759c3ff9b6477338f3da4f9cd8514ea9982ccafb341b2384dd902f3d1ab7ac61dd29c6f21ba5b862f3730e37cfdc4fd806c22f221" + +ChaCha20 RFC 7539 Test Vector #2 (Decrypt) +chacha20_crypt:"0000000000000000000000000000000000000000000000000000000000000001":"000000000000000000000002":1:"a3fbf07df3fa2fde4f376ca23e82737041605d9f4f4f57bd8cff2c1d4b7955ec2a97948bd3722915c8f3d337f7d370050e9e96d647b7c39f56e031ca5eb6250d4042e02785ececfa4b4bb5e8ead0440e20b6e8db09d881a7c6132f420e52795042bdfa7773d8a9051447b3291ce1411c680465552aa6c405b7764d5e87bea85ad00f8449ed8f72d0d662ab052691ca66424bc86d2df80ea41f43abf937d3259dc4b2d0dfb48a6c9139ddd7f76966e928e635553ba76c5c879d7b35d49eb2e62b0871cdac638939e25e8a1e0ef9d5280fa8ca328b351c3c765989cbcf3daa8b6ccc3aaf9f3979c92b3720fc88dc95ed84a1be059c6499b9fda236e7e818b04b0bc39c1e876b193bfe5569753f88128cc08aaa9b63d1a16f80ef2554d7189c411f5869ca52c5b83fa36ff216b9c1d30062bebcfd2dc5bce0911934fda79a86f6e698ced759c3ff9b6477338f3da4f9cd8514ea9982ccafb341b2384dd902f3d1ab7ac61dd29c6f21ba5b862f3730e37cfdc4fd806c22f221":"416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f" + +ChaCha20 RFC 7539 Test Vector #3 (Encrypt) +chacha20_crypt:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000000000000000002":42:"2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e":"62e6347f95ed87a45ffae7426f27a1df5fb69110044c0d73118effa95b01e5cf166d3df2d721caf9b21e5fb14c616871fd84c54f9d65b283196c7fe4f60553ebf39c6402c42234e32a356b3e764312a61a5532055716ead6962568f87d3f3f7704c6a8d1bcd1bf4d50d6154b6da731b187b58dfd728afa36757a797ac188d1" + +ChaCha20 RFC 7539 Test Vector #3 (Decrypt) +chacha20_crypt:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000000000000000002":42:"62e6347f95ed87a45ffae7426f27a1df5fb69110044c0d73118effa95b01e5cf166d3df2d721caf9b21e5fb14c616871fd84c54f9d65b283196c7fe4f60553ebf39c6402c42234e32a356b3e764312a61a5532055716ead6962568f87d3f3f7704c6a8d1bcd1bf4d50d6154b6da731b187b58dfd728afa36757a797ac188d1":"2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e" + +ChaCha20 Paremeter Validation +chacha20_bad_params: + +ChaCha20 Selftest +chacha20_self_test: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chacha20.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chacha20.function new file mode 100644 index 0000000000..49b389c7f0 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chacha20.function @@ -0,0 +1,136 @@ +/* BEGIN_HEADER */ +#include "mbedtls/chacha20.h" +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_CHACHA20_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void chacha20_crypt( char *hex_key_string, + char *hex_nonce_string, + int counter, + char *hex_src_string, + char *hex_dst_string ) +{ + unsigned char key_str[32]; /* size set by the standard */ + unsigned char nonce_str[12]; /* size set by the standard */ + unsigned char src_str[375]; /* max size of binary input */ + unsigned char dst_str[751]; /* hex expansion of the above */ + unsigned char output[751]; + size_t key_len; + size_t nonce_len; + size_t src_len; + size_t dst_len; + mbedtls_chacha20_context ctx; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( nonce_str, 0x00, sizeof( nonce_str ) ); + memset( src_str, 0x00, sizeof( src_str ) ); + memset( dst_str, 0x00, sizeof( dst_str ) ); + memset( output, 0x00, sizeof( output ) ); + + key_len = unhexify( key_str, hex_key_string ); + nonce_len = unhexify( nonce_str, hex_nonce_string ); + src_len = unhexify( src_str, hex_src_string ); + dst_len = unhexify( dst_str, hex_dst_string ); + + TEST_ASSERT( src_len == dst_len ); + TEST_ASSERT( key_len == 32U ); + TEST_ASSERT( nonce_len == 12U ); + + /* + * Test the integrated API + */ + TEST_ASSERT( mbedtls_chacha20_crypt( key_str, nonce_str, counter, src_len, src_str, output ) == 0 ); + + hexify( dst_str, output, src_len ); + TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 ); + + /* + * Test the streaming API + */ + mbedtls_chacha20_init( &ctx ); + + TEST_ASSERT( mbedtls_chacha20_setkey( &ctx, key_str ) == 0 ); + + TEST_ASSERT( mbedtls_chacha20_starts( &ctx, nonce_str, counter ) == 0 ); + + memset( output, 0x00, sizeof( output ) ); + TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_len, src_str, output ) == 0 ); + + hexify( dst_str, output, src_len ); + TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 ); + + /* + * Test the streaming API again, piecewise + */ + + /* Don't free/init the context nor set the key again, + * in order to test that starts() does the right thing. */ + TEST_ASSERT( mbedtls_chacha20_starts( &ctx, nonce_str, counter ) == 0 ); + + memset( output, 0x00, sizeof( output ) ); + TEST_ASSERT( mbedtls_chacha20_update( &ctx, 1, src_str, output ) == 0 ); + TEST_ASSERT( mbedtls_chacha20_update( &ctx, src_len - 1, src_str + 1, output + 1 ) == 0 ); + + hexify( dst_str, output, src_len ); + TEST_ASSERT( strcmp( (char*) dst_str, hex_dst_string ) == 0 ); + + mbedtls_chacha20_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void chacha20_bad_params() +{ + unsigned char key[32]; + unsigned char nonce[12]; + unsigned char src[1]; + unsigned char dst[1]; + uint32_t counter = 0; + size_t len = sizeof( src ); + mbedtls_chacha20_context ctx; + + TEST_INVALID_PARAM( mbedtls_chacha20_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_chacha20_free( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_setkey( NULL, key ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_setkey( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_starts( NULL, nonce, counter ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_starts( &ctx, NULL, counter ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_update( NULL, 0, src, dst ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_update( &ctx, len, NULL, dst ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_update( &ctx, len, src, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_crypt( NULL, nonce, counter, 0, src, dst ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_crypt( key, NULL, counter, 0, src, dst ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_crypt( key, nonce, counter, len, NULL, dst ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA, + mbedtls_chacha20_crypt( key, nonce, counter, len, src, NULL ) ); + +exit: + return; + +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ +void chacha20_self_test() +{ + TEST_ASSERT( mbedtls_chacha20_self_test( 1 ) == 0 ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chachapoly.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chachapoly.data new file mode 100644 index 0000000000..34cb568311 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chachapoly.data @@ -0,0 +1,27 @@ +ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Encrypt) +mbedtls_chachapoly_enc:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"1ae10b594f09e26a7e902ecbd0600691" + +ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Decrypt) +mbedtls_chachapoly_dec:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"1ae10b594f09e26a7e902ecbd0600691":0 + +ChaCha20-Poly1305 RFC 7539 Example and Test Vector (Decrypt, not authentic) +mbedtls_chachapoly_dec:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":"070000004041424344454647":"50515253c0c1c2c3c4c5c6c7":"d31a8d34648e60db7b86afbc53ef7ec2a4aded51296e08fea9e2b5a736ee62d63dbea45e8ca9671282fafb69da92728b1a71de0a9e060b2905d6a5b67ecd3b3692ddbd7f2d778b8c9803aee328091b58fab324e4fad675945585808b4831d7bc3ff4def08e4b7a9de576d26586cec64b6116":"4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756c64206f6666657220796f75206f6e6c79206f6e652074697020666f7220746865206675747572652c2073756e73637265656e20776f756c642062652069742e":"1ae10b594f09e26a7e902ecbd0600690":MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED + +ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Encrypt) +mbedtls_chachapoly_enc:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"eead9d67890cbb22392336fea1851f38" + +ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Decrypt) +mbedtls_chachapoly_dec:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"eead9d67890cbb22392336fea1851f38":0 + +ChaCha20-Poly1305 RFC 7539 Test Vector #1 (Decrypt, not authentic) +mbedtls_chachapoly_dec:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"fead9d67890cbb22392336fea1851f38":MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED + +ChaCha20-Poly1305 State Flow +chachapoly_state: + +ChaCha20-Poly1305 Parameter Validation +chachapoly_bad_params: + +ChaCha20-Poly1305 Selftest +depends_on:MBEDTLS_SELF_TEST +chachapoly_selftest: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chachapoly.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chachapoly.function new file mode 100644 index 0000000000..8e56bf69a3 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_chachapoly.function @@ -0,0 +1,337 @@ +/* BEGIN_HEADER */ +#include "mbedtls/chachapoly.h" +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_CHACHAPOLY_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void mbedtls_chachapoly_enc( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string ) +{ + unsigned char key_str[32]; /* size set by the standard */ + unsigned char nonce_str[12]; /* size set by the standard */ + unsigned char aad_str[12]; /* max size of test data so far */ + unsigned char input_str[265]; /* max size of binary input/output so far */ + unsigned char output_str[265]; + unsigned char output[265]; + unsigned char mac_str[16]; /* size set by the standard */ + unsigned char mac[16]; /* size set by the standard */ + size_t input_len; + size_t output_len; + size_t aad_len; + size_t key_len; + size_t nonce_len; + size_t mac_len; + mbedtls_chachapoly_context ctx; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( nonce_str, 0x00, sizeof( nonce_str ) ); + memset( aad_str, 0x00, sizeof( aad_str ) ); + memset( input_str, 0x00, sizeof( input_str ) ); + memset( output_str, 0x00, sizeof( output_str ) ); + memset( mac_str, 0x00, sizeof( mac_str ) ); + + aad_len = unhexify( aad_str, hex_aad_string ); + input_len = unhexify( input_str, hex_input_string ); + output_len = unhexify( output_str, hex_output_string ); + key_len = unhexify( key_str, hex_key_string ); + nonce_len = unhexify( nonce_str, hex_nonce_string ); + mac_len = unhexify( mac_str, hex_mac_string ); + + TEST_ASSERT( key_len == 32 ); + TEST_ASSERT( nonce_len == 12 ); + TEST_ASSERT( mac_len == 16 ); + + mbedtls_chachapoly_init( &ctx ); + + TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str ) == 0 ); + + TEST_ASSERT( mbedtls_chachapoly_encrypt_and_tag( &ctx, + input_len, nonce_str, + aad_str, aad_len, + input_str, output, mac ) == 0 ); + + TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 ); + TEST_ASSERT( memcmp( mac_str, mac, 16U ) == 0 ); + +exit: + mbedtls_chachapoly_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_chachapoly_dec( char *hex_key_string, char *hex_nonce_string, char *hex_aad_string, char *hex_input_string, char *hex_output_string, char *hex_mac_string, int ret_exp ) +{ + unsigned char key_str[32]; /* size set by the standard */ + unsigned char nonce_str[12]; /* size set by the standard */ + unsigned char aad_str[12]; /* max size of test data so far */ + unsigned char input_str[265]; /* max size of binary input/output so far */ + unsigned char output_str[265]; + unsigned char output[265]; + unsigned char mac_str[16]; /* size set by the standard */ + size_t input_len; + size_t output_len; + size_t aad_len; + size_t key_len; + size_t nonce_len; + size_t mac_len; + int ret; + mbedtls_chachapoly_context ctx; + + memset( key_str, 0x00, sizeof( key_str ) ); + memset( nonce_str, 0x00, sizeof( nonce_str ) ); + memset( aad_str, 0x00, sizeof( aad_str ) ); + memset( input_str, 0x00, sizeof( input_str ) ); + memset( output_str, 0x00, sizeof( output_str ) ); + memset( mac_str, 0x00, sizeof( mac_str ) ); + + aad_len = unhexify( aad_str, hex_aad_string ); + input_len = unhexify( input_str, hex_input_string ); + output_len = unhexify( output_str, hex_output_string ); + key_len = unhexify( key_str, hex_key_string ); + nonce_len = unhexify( nonce_str, hex_nonce_string ); + mac_len = unhexify( mac_str, hex_mac_string ); + + TEST_ASSERT( key_len == 32 ); + TEST_ASSERT( nonce_len == 12 ); + TEST_ASSERT( mac_len == 16 ); + + mbedtls_chachapoly_init( &ctx ); + + TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key_str ) == 0 ); + + ret = mbedtls_chachapoly_auth_decrypt( &ctx, + input_len, nonce_str, + aad_str, aad_len, + mac_str, input_str, output ); + + TEST_ASSERT( ret == ret_exp ); + if( ret_exp == 0 ) + { + TEST_ASSERT( memcmp( output_str, output, output_len ) == 0 ); + } + +exit: + mbedtls_chachapoly_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void chachapoly_bad_params() +{ + unsigned char key[32]; + unsigned char nonce[12]; + unsigned char aad[1]; + unsigned char input[1]; + unsigned char output[1]; + unsigned char mac[16]; + size_t input_len = sizeof( input ); + size_t aad_len = sizeof( aad ); + mbedtls_chachapoly_context ctx; + + memset( key, 0x00, sizeof( key ) ); + memset( nonce, 0x00, sizeof( nonce ) ); + memset( aad, 0x00, sizeof( aad ) ); + memset( input, 0x00, sizeof( input ) ); + memset( output, 0x00, sizeof( output ) ); + memset( mac, 0x00, sizeof( mac ) ); + + TEST_INVALID_PARAM( mbedtls_chachapoly_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_chachapoly_free( NULL ) ); + + /* setkey */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_setkey( NULL, key ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_setkey( &ctx, NULL ) ); + + /* encrypt_and_tag */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_encrypt_and_tag( NULL, + 0, nonce, + aad, 0, + input, output, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_encrypt_and_tag( &ctx, + 0, NULL, + aad, 0, + input, output, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_encrypt_and_tag( &ctx, + 0, nonce, + NULL, aad_len, + input, output, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_encrypt_and_tag( &ctx, + input_len, nonce, + aad, 0, + NULL, output, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_encrypt_and_tag( &ctx, + input_len, nonce, + aad, 0, + input, NULL, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_encrypt_and_tag( &ctx, + 0, nonce, + aad, 0, + input, output, NULL ) ); + + /* auth_decrypt */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_auth_decrypt( NULL, + 0, nonce, + aad, 0, + mac, input, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_auth_decrypt( &ctx, + 0, NULL, + aad, 0, + mac, input, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_auth_decrypt( &ctx, + 0, nonce, + NULL, aad_len, + mac, input, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_auth_decrypt( &ctx, + 0, nonce, + aad, 0, + NULL, input, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_auth_decrypt( &ctx, + input_len, nonce, + aad, 0, + mac, NULL, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_auth_decrypt( &ctx, + input_len, nonce, + aad, 0, + mac, input, NULL ) ); + + /* starts */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_starts( NULL, nonce, + MBEDTLS_CHACHAPOLY_ENCRYPT ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_starts( &ctx, NULL, + MBEDTLS_CHACHAPOLY_ENCRYPT ) ); + + /* update_aad */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_update_aad( NULL, aad, + aad_len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_update_aad( &ctx, NULL, + aad_len ) ); + + /* update */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_update( NULL, input_len, + input, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_update( &ctx, input_len, + NULL, output ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_update( &ctx, input_len, + input, NULL ) ); + + /* finish */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_finish( NULL, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_chachapoly_finish( &ctx, NULL ) ); + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE */ +void chachapoly_state() +{ + unsigned char key[32]; + unsigned char nonce[12]; + unsigned char aad[1]; + unsigned char input[1]; + unsigned char output[1]; + unsigned char mac[16]; + size_t input_len = sizeof( input ); + size_t aad_len = sizeof( aad ); + mbedtls_chachapoly_context ctx; + + memset( key, 0x00, sizeof( key ) ); + memset( nonce, 0x00, sizeof( nonce ) ); + memset( aad, 0x00, sizeof( aad ) ); + memset( input, 0x00, sizeof( input ) ); + memset( output, 0x00, sizeof( output ) ); + memset( mac, 0x00, sizeof( mac ) ); + + /* Initial state: finish, update, update_aad forbidden */ + mbedtls_chachapoly_init( &ctx ); + + TEST_ASSERT( mbedtls_chachapoly_finish( &ctx, mac ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + TEST_ASSERT( mbedtls_chachapoly_update( &ctx, input_len, input, output ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + TEST_ASSERT( mbedtls_chachapoly_update_aad( &ctx, aad, aad_len ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + + /* Still initial state: finish, update, update_aad forbidden */ + TEST_ASSERT( mbedtls_chachapoly_setkey( &ctx, key ) + == 0 ); + + TEST_ASSERT( mbedtls_chachapoly_finish( &ctx, mac ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + TEST_ASSERT( mbedtls_chachapoly_update( &ctx, input_len, input, output ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + TEST_ASSERT( mbedtls_chachapoly_update_aad( &ctx, aad, aad_len ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + + /* Starts -> finish OK */ + TEST_ASSERT( mbedtls_chachapoly_starts( &ctx, nonce, MBEDTLS_CHACHAPOLY_ENCRYPT ) + == 0 ); + TEST_ASSERT( mbedtls_chachapoly_finish( &ctx, mac ) + == 0 ); + + /* After finish: update, update_aad forbidden */ + TEST_ASSERT( mbedtls_chachapoly_update( &ctx, input_len, input, output ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + TEST_ASSERT( mbedtls_chachapoly_update_aad( &ctx, aad, aad_len ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + + /* Starts -> update* OK */ + TEST_ASSERT( mbedtls_chachapoly_starts( &ctx, nonce, MBEDTLS_CHACHAPOLY_ENCRYPT ) + == 0 ); + TEST_ASSERT( mbedtls_chachapoly_update( &ctx, input_len, input, output ) + == 0 ); + TEST_ASSERT( mbedtls_chachapoly_update( &ctx, input_len, input, output ) + == 0 ); + + /* After update: update_aad forbidden */ + TEST_ASSERT( mbedtls_chachapoly_update_aad( &ctx, aad, aad_len ) + == MBEDTLS_ERR_CHACHAPOLY_BAD_STATE ); + + /* Starts -> update_aad* -> finish OK */ + TEST_ASSERT( mbedtls_chachapoly_starts( &ctx, nonce, MBEDTLS_CHACHAPOLY_ENCRYPT ) + == 0 ); + TEST_ASSERT( mbedtls_chachapoly_update_aad( &ctx, aad, aad_len ) + == 0 ); + TEST_ASSERT( mbedtls_chachapoly_update_aad( &ctx, aad, aad_len ) + == 0 ); + TEST_ASSERT( mbedtls_chachapoly_finish( &ctx, mac ) + == 0 ); + +exit: + mbedtls_chachapoly_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ +void chachapoly_selftest() +{ + TEST_ASSERT( mbedtls_chachapoly_self_test( 1 ) == 0 ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.aes.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.aes.data index b93d4de9a9..1b3450128f 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.aes.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.aes.data @@ -1,6 +1,6 @@ Decrypt empty buffer depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7 -dec_empty_buf: +dec_empty_buf:MBEDTLS_CIPHER_AES_128_CBC AES-128 CBC - Encrypt and decrypt 0 bytes with PKCS7 padding depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7 @@ -414,7 +414,7 @@ AES-128 CFB - Encrypt and decrypt 32 bytes depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CFB enc_dec_buf:MBEDTLS_CIPHER_AES_128_CFB128:"AES-128-CFB128":128:32:-1 -AES-128 CFB - Encrypt and decrypt 32 bytes +AES-128 CFB - Encrypt and decrypt 33 bytes depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CFB enc_dec_buf:MBEDTLS_CIPHER_AES_128_CFB128:"AES-128-CFB128":128:33:-1 @@ -474,6 +474,382 @@ AES-128 CFB - Encrypt and decrypt 32 bytes in multiple parts 1 depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CFB enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_CFB128:128:16:16:-1:16:16:16:16 +AES-128 OFB - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:0:-1 + +AES-128 OFB - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:1:-1 + +AES-128 OFB - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:2:-1 + +AES-128 OFB - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:7:-1 + +AES-128 OFB - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:8:-1 + +AES-128 OFB - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:9:-1 + +AES-128 OFB - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:15:-1 + +AES-128 OFB - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:16:-1 + +AES-128 OFB - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:17:-1 + +AES-128 OFB - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:31:-1 + +AES-128 OFB - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:32:-1 + +AES-128 OFB - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:33:-1 + +AES-128 OFB - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:47:-1 + +AES-128 OFB - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:48:-1 + +AES-128 OFB - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_128_OFB:"AES-128-OFB":128:49:-1 + +AES-128 OFB - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:0:0:-1:0:0:0:0 + +AES-128 OFB - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:1:0:-1:1:0:1:0 + +AES-128 OFB - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:0:1:-1:0:1:0:1 + +AES-128 OFB - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:16:0:-1:16:0:16:0 + +AES-128 OFB - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:0:16:-1:0:16:0:16 + +AES-128 OFB - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:1:15:-1:1:15:1:15 + +AES-128 OFB - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:15:1:-1:15:1:15:1 + +AES-128 OFB - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:15:7:-1:15:7:15:7 + +AES-128 OFB - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:16:6:-1:16:6:16:6 + +AES-128 OFB - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:17:6:-1:17:6:17:6 + +AES-128 OFB - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_128_OFB:128:16:16:-1:16:16:16:16 + +AES-192 OFB - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:0:-1 + +AES-192 OFB - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:1:-1 + +AES-192 OFB - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:2:-1 + +AES-192 OFB - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:7:-1 + +AES-192 OFB - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:8:-1 + +AES-192 OFB - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:9:-1 + +AES-192 OFB - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:15:-1 + +AES-192 OFB - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:16:-1 + +AES-192 OFB - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:17:-1 + +AES-192 OFB - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:31:-1 + +AES-192 OFB - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:32:-1 + +AES-192 OFB - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:33:-1 + +AES-192 OFB - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:47:-1 + +AES-192 OFB - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:48:-1 + +AES-192 OFB - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_192_OFB:"AES-192-OFB":192:49:-1 + +AES-192 OFB - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:0:0:-1:0:0:0:0 + +AES-192 OFB - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:1:0:-1:1:0:1:0 + +AES-192 OFB - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:0:1:-1:0:1:0:1 + +AES-192 OFB - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:16:0:-1:16:0:16:0 + +AES-192 OFB - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:0:16:-1:0:16:0:16 + +AES-192 OFB - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:1:15:-1:1:15:1:15 + +AES-192 OFB - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:15:1:-1:15:1:15:1 + +AES-192 OFB - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:15:7:-1:15:7:15:7 + +AES-192 OFB - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:16:6:-1:16:6:16:6 + +AES-192 OFB - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:17:6:-1:17:6:17:6 + +AES-192 OFB - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_192_OFB:192:16:16:-1:16:16:16:16 + +AES-256 OFB - Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:0:-1 + +AES-256 OFB - Encrypt and decrypt 1 byte +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:1:-1 + +AES-256 OFB - Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:2:-1 + +AES-256 OFB - Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:7:-1 + +AES-256 OFB - Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:8:-1 + +AES-256 OFB - Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:9:-1 + +AES-256 OFB - Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:15:-1 + +AES-256 OFB - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:16:-1 + +AES-256 OFB - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:17:-1 + +AES-256 OFB - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:31:-1 + +AES-256 OFB - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:32:-1 + +AES-256 OFB - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:33:-1 + +AES-256 OFB - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:47:-1 + +AES-256 OFB - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:48:-1 + +AES-256 OFB - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf:MBEDTLS_CIPHER_AES_256_OFB:"AES-256-OFB":256:49:-1 + +AES-256 OFB - Encrypt and decrypt 0 bytes in multiple parts +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:0:0:-1:0:0:0:0 + +AES-256 OFB - Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:1:0:-1:1:0:1:0 + +AES-256 OFB - Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:0:1:-1:0:1:0:1 + +AES-256 OFB - Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:16:0:-1:16:0:16:0 + +AES-256 OFB - Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:0:16:-1:0:16:0:16 + +AES-256 OFB - Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:1:15:-1:1:15:1:15 + +AES-256 OFB - Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:15:1:-1:15:1:15:1 + +AES-256 OFB - Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:15:7:-1:15:7:15:7 + +AES-256 OFB - Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:16:6:-1:16:6:16:6 + +AES-256 OFB - Encrypt and decrypt 23 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:17:6:-1:17:6:17:6 + +AES-256 OFB - Encrypt and decrypt 32 bytes in multiple parts 1 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +enc_dec_buf_multipart:MBEDTLS_CIPHER_AES_256_OFB:256:16:16:-1:16:16:16:16 + +AES-128 XTS - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:16:-1 + +AES-128 XTS - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:17:-1 + +AES-128 XTS - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:31:-1 + +AES-128 XTS - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:32:-1 + +AES-128 XTS - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:33:-1 + +AES-128 XTS - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:47:-1 + +AES-128 XTS - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:48:-1 + +AES-128 XTS - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_128_XTS:"AES-128-XTS":256:49:-1 + +AES-256 XTS - Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:16:-1 + +AES-256 XTS - Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:17:-1 + +AES-256 XTS - Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:31:-1 + +AES-256 XTS - Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:32:-1 + +AES-256 XTS - Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:33:-1 + +AES-256 XTS - Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:47:-1 + +AES-256 XTS - Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:48:-1 + +AES-256 XTS - Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_XTS +enc_dec_buf:MBEDTLS_CIPHER_AES_256_XTS:"AES-256-XTS":512:49:-1 + AES-128 CTR - Encrypt and decrypt 0 bytes depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CTR enc_dec_buf:MBEDTLS_CIPHER_AES_128_CTR:"AES-128-CTR":128:0:-1 @@ -518,7 +894,7 @@ AES-128 CTR - Encrypt and decrypt 32 bytes depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CTR enc_dec_buf:MBEDTLS_CIPHER_AES_128_CTR:"AES-128-CTR":128:32:-1 -AES-128 CTR - Encrypt and decrypt 32 bytes +AES-128 CTR - Encrypt and decrypt 33 bytes depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CTR enc_dec_buf:MBEDTLS_CIPHER_AES_128_CTR:"AES-128-CTR":128:33:-1 @@ -814,6 +1190,18 @@ AES Decrypt test vector #6 depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CFB decrypt_test_vec:MBEDTLS_CIPHER_AES_256_CFB128:-1:"ffffffffff800000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"be66cfea2fecd6bf0ec7b4352c99bcaa":"00000000000000000000000000000000":"":"":0:0 +AES Decrypt test vector #7 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +decrypt_test_vec:MBEDTLS_CIPHER_AES_128_OFB:-1:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"3B3FD92EB72DAD20333449F8E83CFB4A7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e":"6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710":"":"":0:0: + +AES Decrypt test vector #8 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +decrypt_test_vec:MBEDTLS_CIPHER_AES_192_OFB:-1:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"000102030405060708090A0B0C0D0E0F":"CDC80D6FDDF18CAB34C25909C99A4174fcc28b8d4c63837c09e81700c11004018d9a9aeac0f6596f559c6d4daf59a5f26d9f200857ca6c3e9cac524bd9acc92a":"6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710":"":"":0:0: + +AES Decrypt test vector #9 +depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_OFB +decrypt_test_vec:MBEDTLS_CIPHER_AES_256_OFB:-1:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"000102030405060708090A0B0C0D0E0F":"DC7E84BFDA79164B7ECD8486985D38604febdc6740d20b3ac88f6ad82a4fb08d71ab47a086e86eedf39d1c5bba97c4080126141d67f37be8538f5a8be740e484":"6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17AD2B417BE66C3710":"":"":0:0: + AES-128-ECB Encrypt NIST KAT #1 depends_on:MBEDTLS_AES_C test_vec_ecb:MBEDTLS_CIPHER_AES_128_ECB:MBEDTLS_ENCRYPT:"00000000000000000000000000000000":"f34481ec3cc627bacd5dc3fb08f273e6":"0336763e966d92595a567cc9ce537f5e":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.ccm.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.ccm.data index dc44091927..264ce9925e 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.ccm.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.ccm.data @@ -1,480 +1,480 @@ AES-128-CCM test vector NIST #1 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4ae701103c63deca5b5a3939d7d05992":"5a8aa485c316e9":"":"":"02209f55":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4ae701103c63deca5b5a3939d7d05992":"5a8aa485c316e9":"":"":"02209f55":"":"" AES-128-CCM test vector NIST #2 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4ae701103c63deca5b5a3939d7d05992":"3796cf51b87266":"":"":"9a04c241":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4ae701103c63deca5b5a3939d7d05992":"3796cf51b87266":"":"":"9a04c241":"FAIL":"" AES-128-CCM test vector NIST #3 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"5a8aa485c316e9":"":"":"75d582db43ce9b13ab4b6f7f14341330":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"5a8aa485c316e9":"":"":"75d582db43ce9b13ab4b6f7f14341330":"":"" AES-128-CCM test vector NIST #4 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"3796cf51b87266":"":"":"3a65e03af37b81d05acc7ec1bc39deb0":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"3796cf51b87266":"":"":"3a65e03af37b81d05acc7ec1bc39deb0":"FAIL":"" AES-128-CCM test vector NIST #5 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"5a8aa485c316e9403aff859fbb":"":"":"90156f3f":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"5a8aa485c316e9403aff859fbb":"":"":"90156f3f":"":"" AES-128-CCM test vector NIST #6 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"a16a2e741f1cd9717285b6d882":"":"":"88909016":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3":"a16a2e741f1cd9717285b6d882":"":"":"88909016":"FAIL":"" AES-128-CCM test vector NIST #7 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"5a8aa485c316e9403aff859fbb":"":"":"fb04dc5a44c6bb000f2440f5154364b4":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"5a8aa485c316e9403aff859fbb":"":"":"fb04dc5a44c6bb000f2440f5154364b4":"":"" AES-128-CCM test vector NIST #8 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"a16a2e741f1cd9717285b6d882":"":"":"5447075bf42a59b91f08064738b015ab":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"a16a2e741f1cd9717285b6d882":"":"":"5447075bf42a59b91f08064738b015ab":"FAIL":"" AES-128-CCM test vector NIST #9 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"5a8aa485c316e9":"":"a90e8ea44085ced791b2fdb7fd44b5cf0bd7d27718029bb7":"03e1fa6b":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"5a8aa485c316e9":"":"a90e8ea44085ced791b2fdb7fd44b5cf0bd7d27718029bb7":"03e1fa6b":"":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" AES-128-CCM test vector NIST #10 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"31f8fa25827d48":"":"50aafe0578c115c4a8e126ff7b3ccb64dce8ccaa8ceda69f":"23e5d81c":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"19ebfde2d5468ba0a3031bde629b11fd":"31f8fa25827d48":"":"50aafe0578c115c4a8e126ff7b3ccb64dce8ccaa8ceda69f":"23e5d81c":"FAIL":"" AES-128-CCM test vector NIST #11 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"5a8aa485c316e9":"":"24ab9eeb0e5508cae80074f1070ee188a637171860881f1f":"2d9a3fbc210595b7b8b1b41523111a8e":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"5a8aa485c316e9":"":"24ab9eeb0e5508cae80074f1070ee188a637171860881f1f":"2d9a3fbc210595b7b8b1b41523111a8e":"":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" AES-128-CCM test vector NIST #12 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"31f8fa25827d48":"":"7ebfda6fa5da1dbffd82dc29b875798fbcef8ba0084fbd24":"63af747cc88a001fa94e060290f209c4":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"31f8fa25827d48":"":"7ebfda6fa5da1dbffd82dc29b875798fbcef8ba0084fbd24":"63af747cc88a001fa94e060290f209c4":"FAIL":"" AES-128-CCM test vector NIST #13 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"5a8aa485c316e9403aff859fbb":"":"4a550134f94455979ec4bf89ad2bd80d25a77ae94e456134":"a3e138b9":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"5a8aa485c316e9403aff859fbb":"":"4a550134f94455979ec4bf89ad2bd80d25a77ae94e456134":"a3e138b9":"":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" AES-128-CCM test vector NIST #14 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"49004912fdd7269279b1f06a89":"":"118ec53dd1bfbe52d5b9fe5dfebecf2ee674ec983eada654":"091a5ae9":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"197afb02ffbd8f699dacae87094d5243":"49004912fdd7269279b1f06a89":"":"118ec53dd1bfbe52d5b9fe5dfebecf2ee674ec983eada654":"091a5ae9":"FAIL":"" AES-128-CCM test vector NIST #15 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9403aff859fbb":"":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb":"6a9a970b9beb2ac1bd4fd62168f8378a":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9403aff859fbb":"":"4bfe4e35784f0a65b545477e5e2f4bae0e1e6fa717eaf2cb":"6a9a970b9beb2ac1bd4fd62168f8378a":"":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" AES-128-CCM test vector NIST #16 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"49004912fdd7269279b1f06a89":"":"0c56a503aa2c12e87450d45a7b714db980fd348f327c0065":"a65666144994bad0c8195bcb4ade1337":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"49004912fdd7269279b1f06a89":"":"0c56a503aa2c12e87450d45a7b714db980fd348f327c0065":"a65666144994bad0c8195bcb4ade1337":"FAIL":"" AES-128-CCM test vector NIST #17 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"782e4318":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"782e4318":"":"" AES-128-CCM test vector NIST #18 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"a04f270a":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"90929a4b0ac65b350ad1591611fe4829":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"a04f270a":"FAIL":"" AES-128-CCM test vector NIST #19 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"41b476013f45e4a781f253a6f3b1e530":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"41b476013f45e4a781f253a6f3b1e530":"":"" AES-128-CCM test vector NIST #20 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"f9f018fcd125822616083fffebc4c8e6":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"f9f018fcd125822616083fffebc4c8e6":"FAIL":"" AES-128-CCM test vector NIST #21 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"9f69f24f":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"9f69f24f":"":"" AES-128-CCM test vector NIST #22 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"e17afaa4":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"e17afaa4":"FAIL":"" AES-128-CCM test vector NIST #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"1859ac36a40a6b28b34266253627797a":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"1859ac36a40a6b28b34266253627797a":"":"" AES-128-CCM test vector NIST #24 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"edf8b46eb69ac0044116019dec183072":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"edf8b46eb69ac0044116019dec183072":"FAIL":"" AES-128-CCM test vector NIST #25 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"6be31860ca271ef448de8f8d8b39346daf4b81d7e92d65b3":"38f125fa":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"6be31860ca271ef448de8f8d8b39346daf4b81d7e92d65b3":"38f125fa":"":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" AES-128-CCM test vector NIST #26 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"4cc57a9927a6bc401441870d3193bf89ebd163f5c01501c7":"28a66b69":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"f9fdca4ac64fe7f014de0f43039c7571":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"4cc57a9927a6bc401441870d3193bf89ebd163f5c01501c7":"28a66b69":"FAIL":"" AES-128-CCM test vector NIST #27 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"b351ab96b2e45515254558d5212673ee6c776d42dbca3b51":"2cf3a20b7fd7c49e6e79bef475c2906f":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"b351ab96b2e45515254558d5212673ee6c776d42dbca3b51":"2cf3a20b7fd7c49e6e79bef475c2906f":"":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" AES-128-CCM test vector NIST #28 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"df1a5285caa41b4bb47f6e5ceceba4e82721828d68427a30":"81d18ca149d6766bfaccec88f194eb5b":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"df1a5285caa41b4bb47f6e5ceceba4e82721828d68427a30":"81d18ca149d6766bfaccec88f194eb5b":"FAIL":"" AES-128-CCM test vector NIST #29 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"934f893824e880f743d196b22d1f340a52608155087bd28a":"c25e5329":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"934f893824e880f743d196b22d1f340a52608155087bd28a":"c25e5329":"":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" AES-128-CCM test vector NIST #30 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"f43ba9d834ad85dfab3f1c0c27c3441fe4e411a38a261a65":"59b3b3ee":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"a7aa635ea51b0bb20a092bd5573e728c":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"f43ba9d834ad85dfab3f1c0c27c3441fe4e411a38a261a65":"59b3b3ee":"FAIL":"" AES-128-CCM test vector NIST #31 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"26511fb51fcfa75cb4b44da75a6e5a0e":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"50038b5fdd364ee747b70d00bd36840ece4ea19998123375":"c0a458bfcafa3b2609afe0f825cbf503":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"26511fb51fcfa75cb4b44da75a6e5a0e":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"50038b5fdd364ee747b70d00bd36840ece4ea19998123375":"c0a458bfcafa3b2609afe0f825cbf503":"":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" AES-128-CCM test vector NIST #32 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"26511fb51fcfa75cb4b44da75a6e5a0e":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"78ed8ff6b5a1255d0fbd0a719a9c27b059ff5f83d0c4962c":"390042ba8bb5f6798dab01c5afad7306":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_128_CCM:"26511fb51fcfa75cb4b44da75a6e5a0e":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"78ed8ff6b5a1255d0fbd0a719a9c27b059ff5f83d0c4962c":"390042ba8bb5f6798dab01c5afad7306":"FAIL":"" AES-192-CCM test vector NIST #1 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"5a8aa485c316e9":"":"":"9d4b7f3b":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"5a8aa485c316e9":"":"":"9d4b7f3b":"":"" AES-192-CCM test vector NIST #2 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"3796cf51b87266":"":"":"80745de9":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"c98ad7f38b2c7e970c9b965ec87a08208384718f78206c6c":"3796cf51b87266":"":"":"80745de9":"FAIL":"" AES-192-CCM test vector NIST #3 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"5a8aa485c316e9":"":"":"17223038fa99d53681ca1beabe78d1b4":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"5a8aa485c316e9":"":"":"17223038fa99d53681ca1beabe78d1b4":"":"" AES-192-CCM test vector NIST #4 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"3796cf51b87266":"":"":"d0e1eeef4d2a264536bb1c2c1bde7c35":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"3796cf51b87266":"":"":"d0e1eeef4d2a264536bb1c2c1bde7c35":"FAIL":"" AES-192-CCM test vector NIST #5 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"5a8aa485c316e9403aff859fbb":"":"":"fe69ed84":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"5a8aa485c316e9403aff859fbb":"":"":"fe69ed84":"":"" AES-192-CCM test vector NIST #6 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"a16a2e741f1cd9717285b6d882":"":"":"db7ffc82":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"4bb3c4a4f893ad8c9bdc833c325d62b3d3ad1bccf9282a65":"a16a2e741f1cd9717285b6d882":"":"":"db7ffc82":"FAIL":"" AES-192-CCM test vector NIST #7 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"5a8aa485c316e9403aff859fbb":"":"":"0c66a8e547ed4f8c2c9a9a1eb5d455b9":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"5a8aa485c316e9403aff859fbb":"":"":"0c66a8e547ed4f8c2c9a9a1eb5d455b9":"":"" AES-192-CCM test vector NIST #8 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"a16a2e741f1cd9717285b6d882":"":"":"38757b3a61a4dc97ca3ab88bf1240695":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"a16a2e741f1cd9717285b6d882":"":"":"38757b3a61a4dc97ca3ab88bf1240695":"FAIL":"" AES-192-CCM test vector NIST #9 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"5a8aa485c316e9":"":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"ddc93a54":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"5a8aa485c316e9":"":"411986d04d6463100bff03f7d0bde7ea2c3488784378138c":"ddc93a54":"":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" AES-192-CCM test vector NIST #10 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"31f8fa25827d48":"":"32b649ab56162e55d4148a1292d6a225a988eb1308298273":"b6889036":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"19ebfde2d5468ba0a3031bde629b11fd4094afcb205393fa":"31f8fa25827d48":"":"32b649ab56162e55d4148a1292d6a225a988eb1308298273":"b6889036":"FAIL":"" AES-192-CCM test vector NIST #11 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"5a8aa485c316e9":"":"cba4b4aeb85f0492fd8d905c4a6d8233139833373ef188a8":"c5a5ebecf7ac8607fe412189e83d9d20":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"5a8aa485c316e9":"":"cba4b4aeb85f0492fd8d905c4a6d8233139833373ef188a8":"c5a5ebecf7ac8607fe412189e83d9d20":"":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22" AES-192-CCM test vector NIST #12 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"31f8fa25827d48":"":"ca62713728b5c9d652504b0ae8fd4fee5d297ee6a8d19cb6":"e699f15f14d34dcaf9ba8ed4b877c97d":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"31f8fa25827d48":"":"ca62713728b5c9d652504b0ae8fd4fee5d297ee6a8d19cb6":"e699f15f14d34dcaf9ba8ed4b877c97d":"FAIL":"" AES-192-CCM test vector NIST #13 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"5a8aa485c316e9403aff859fbb":"":"042653c674ef2a90f7fb11d30848e530ae59478f1051633a":"34fad277":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"5a8aa485c316e9403aff859fbb":"":"042653c674ef2a90f7fb11d30848e530ae59478f1051633a":"34fad277":"":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" AES-192-CCM test vector NIST #14 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"49004912fdd7269279b1f06a89":"":"1902d9769a7ba3d3268e1257395c8c2e5f98eef295dcbfa5":"a35df775":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"197afb02ffbd8f699dacae87094d524324576b99844f75e1":"49004912fdd7269279b1f06a89":"":"1902d9769a7ba3d3268e1257395c8c2e5f98eef295dcbfa5":"a35df775":"FAIL":"" AES-192-CCM test vector NIST #15 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"5a8aa485c316e9403aff859fbb":"":"a5b7d8cca2069908d1ed88e6a9fe2c9bede3131dad54671e":"a7ade30a07d185692ab0ebdf4c78cf7a":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"5a8aa485c316e9403aff859fbb":"":"a5b7d8cca2069908d1ed88e6a9fe2c9bede3131dad54671e":"a7ade30a07d185692ab0ebdf4c78cf7a":"":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697" AES-192-CCM test vector NIST #16 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"49004912fdd7269279b1f06a89":"":"9a98617fb97a0dfe466be692272dcdaec1c5443a3b51312e":"f042c86363cc05afb98c66e16be8a445":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"49004912fdd7269279b1f06a89":"":"9a98617fb97a0dfe466be692272dcdaec1c5443a3b51312e":"f042c86363cc05afb98c66e16be8a445":"FAIL":"" AES-192-CCM test vector NIST #17 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"1d089a5f":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"1d089a5f":"":"" AES-192-CCM test vector NIST #18 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"2f46022a":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"90929a4b0ac65b350ad1591611fe48297e03956f6083e451":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"2f46022a":"FAIL":"" AES-192-CCM test vector NIST #19 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"5280a2137fee3deefcfe9b63a1199fb3":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"":"5280a2137fee3deefcfe9b63a1199fb3":"":"" AES-192-CCM test vector NIST #20 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"d40a7318c5f2d82f838c0beeefe0d598":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"a265480ca88d5f":"a2248a882ecbf850daf91933a389e78e81623d233dfd47bf8321361a38f138fe":"":"d40a7318c5f2d82f838c0beeefe0d598":"FAIL":"" AES-192-CCM test vector NIST #21 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"5e0eaebd":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"5e0eaebd":"":"" AES-192-CCM test vector NIST #22 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"71b7fc33":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"6a798d7c5e1a72b43e20ad5c7b08567b12ab744b61c070e2":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"71b7fc33":"FAIL":"" AES-192-CCM test vector NIST #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"d07ccf9fdc3d33aa94cda3d230da707c":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"":"d07ccf9fdc3d33aa94cda3d230da707c":"":"" AES-192-CCM test vector NIST #24 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"65fe32b649dc328c9f531584897e85b3":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"8739b4bea1a099fe547499cbc6":"f6107696edb332b2ea059d8860fee26be42e5e12e1a4f79a8d0eafce1b2278a7":"":"65fe32b649dc328c9f531584897e85b3":"FAIL":"" AES-192-CCM test vector NIST #25 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"9f6ca4af9b159148c889a6584d1183ea26e2614874b05045":"75dea8d1":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"9f6ca4af9b159148c889a6584d1183ea26e2614874b05045":"75dea8d1":"":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" AES-192-CCM test vector NIST #26 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"84d8212e9cfc2121252baa3b065b1edcf50497b9594db1eb":"d7965825":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"f9fdca4ac64fe7f014de0f43039c757194d544ce5d15eed4":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"84d8212e9cfc2121252baa3b065b1edcf50497b9594db1eb":"d7965825":"FAIL":"" AES-192-CCM test vector NIST #27 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"6aab64c4787599d8f213446beadb16e08dba60e97f56dbd1":"4d1d980d6fe0fb44b421992662b97975":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"5a8aa485c316e9":"3796cf51b8726652a4204733b8fbb047cf00fb91a9837e22ec22b1a268f88e2c":"6aab64c4787599d8f213446beadb16e08dba60e97f56dbd1":"4d1d980d6fe0fb44b421992662b97975":"":"a265480ca88d5f536db0dc6abc40faf0d05be7a966977768" AES-192-CCM test vector NIST #28 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"4980b2ee49b1aaf393175f5ab9bae95ec7904557dfa20660":"3c51d36c826f01384100886198a7f6a3":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"fdd2d6f503c915":"5b92394f21ddc3ad49d9b0881b829a5935cb3a4d23e292a62fb66b5e7ab7020e":"4980b2ee49b1aaf393175f5ab9bae95ec7904557dfa20660":"3c51d36c826f01384100886198a7f6a3":"FAIL":"" AES-192-CCM test vector NIST #29 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"16e543d0e20615ff0df15acd9927ddfe40668a54bb854ccc":"c25e9fce":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"16e543d0e20615ff0df15acd9927ddfe40668a54bb854ccc":"c25e9fce":"":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" AES-192-CCM test vector NIST #30 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"df35b109caf690656ae278bbd8f8bba687a2ce11b105dae9":"8ecedb3e":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"a7aa635ea51b0bb20a092bd5573e728ccd4b3e8cdd2ab33d":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"df35b109caf690656ae278bbd8f8bba687a2ce11b105dae9":"8ecedb3e":"FAIL":"" AES-192-CCM test vector NIST #31 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"c5b0b2ef17498c5570eb335df4588032958ba3d69bf6f317":"8464a6f7fa2b76744e8e8d95691cecb8":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"5a8aa485c316e9403aff859fbb":"a16a2e741f1cd9717285b6d882c1fc53655e9773761ad697a7ee6410184c7982":"c5b0b2ef17498c5570eb335df4588032958ba3d69bf6f317":"8464a6f7fa2b76744e8e8d95691cecb8":"":"8739b4bea1a099fe547499cbc6d1b13d849b8084c9b6acc5" AES-192-CCM test vector NIST #32 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"d1f0518929f4ae2f0543de2a7dfe4bb0110bb3057e524a1c":"06bd6dc2e6bcc3436cffb969ae900388":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_192_CCM:"26511fb51fcfa75cb4b44da75a6e5a0eb8d9c8f3b906f886":"0812757ad0cc4d17c4cfe7a642":"ec6c44a7e94e51a3ca6dee229098391575ec7213c85267fbf7492fdbeee61b10":"d1f0518929f4ae2f0543de2a7dfe4bb0110bb3057e524a1c":"06bd6dc2e6bcc3436cffb969ae900388":"FAIL":"" AES-256-CCM test vector NIST #1 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"a544218dadd3c1":"":"":"469c90bb":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"a544218dadd3c1":"":"":"469c90bb":"":"" AES-256-CCM test vector NIST #2 (P=0, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"d3d5424e20fbec":"":"":"46a908ed":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"eda32f751456e33195f1f499cf2dc7c97ea127b6d488f211ccc5126fbb24afa6":"d3d5424e20fbec":"":"":"46a908ed":"FAIL":"" AES-256-CCM test vector NIST #3 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"a544218dadd3c1":"":"":"8207eb14d33855a52acceed17dbcbf6e":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"a544218dadd3c1":"":"":"8207eb14d33855a52acceed17dbcbf6e":"":"" AES-256-CCM test vector NIST #4 (P=0, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"d3d5424e20fbec":"":"":"60f8e127cb4d30db6df0622158cd931d":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"d3d5424e20fbec":"":"":"60f8e127cb4d30db6df0622158cd931d":"FAIL":"" AES-256-CCM test vector NIST #5 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"a544218dadd3c10583db49cf39":"":"":"8a19a133":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"a544218dadd3c10583db49cf39":"":"":"8a19a133":"":"" AES-256-CCM test vector NIST #6 (P=0, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"3c0e2815d37d844f7ac240ba9d":"":"":"2e317f1b":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"e1b8a927a95efe94656677b692662000278b441c79e879dd5c0ddc758bdc9ee8":"3c0e2815d37d844f7ac240ba9d":"":"":"2e317f1b":"FAIL":"" AES-256-CCM test vector NIST #7 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"a544218dadd3c10583db49cf39":"":"":"97e1a8dd4259ccd2e431e057b0397fcf":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"a544218dadd3c10583db49cf39":"":"":"97e1a8dd4259ccd2e431e057b0397fcf":"":"" AES-256-CCM test vector NIST #8 (P=0, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"3c0e2815d37d844f7ac240ba9d":"":"":"5a9596c511ea6a8671adefc4f2157d8b":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"3c0e2815d37d844f7ac240ba9d":"":"":"5a9596c511ea6a8671adefc4f2157d8b":"FAIL":"" AES-256-CCM test vector NIST #9 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"a544218dadd3c1":"":"64a1341679972dc5869fcf69b19d5c5ea50aa0b5e985f5b7":"22aa8d59":"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"a544218dadd3c1":"":"64a1341679972dc5869fcf69b19d5c5ea50aa0b5e985f5b7":"22aa8d59":"":"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" AES-256-CCM test vector NIST #10 (P=24, N=7, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"bfcda8b5a2d0d2":"":"c5b7f802bffc498c1626e3774f1d9f94045dfd8e1a10a202":"77d00a75":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"af063639e66c284083c5cf72b70d8bc277f5978e80d9322d99f2fdc718cda569":"bfcda8b5a2d0d2":"":"c5b7f802bffc498c1626e3774f1d9f94045dfd8e1a10a202":"77d00a75":"FAIL":"" AES-256-CCM test vector NIST #11 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"a544218dadd3c1":"":"bc51c3925a960e7732533e4ef3a4f69ee6826de952bcb0fd":"374f3bb6db8377ebfc79674858c4f305":"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"a544218dadd3c1":"":"bc51c3925a960e7732533e4ef3a4f69ee6826de952bcb0fd":"374f3bb6db8377ebfc79674858c4f305":"":"d3d5424e20fbec43ae495353ed830271515ab104f8860c98" AES-256-CCM test vector NIST #12 (P=24, N=7, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"bfcda8b5a2d0d2":"":"afa1fa8e8a70e26b02161150556d604101fdf423f332c336":"3275f2a4907d51b734fe7238cebbd48f":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"bfcda8b5a2d0d2":"":"afa1fa8e8a70e26b02161150556d604101fdf423f332c336":"3275f2a4907d51b734fe7238cebbd48f":"FAIL":"" AES-256-CCM test vector NIST #13 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"a544218dadd3c10583db49cf39":"":"63e00d30e4b08fd2a1cc8d70fab327b2368e77a93be4f412":"3d14fb3f":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"a544218dadd3c10583db49cf39":"":"63e00d30e4b08fd2a1cc8d70fab327b2368e77a93be4f412":"3d14fb3f":"":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" AES-256-CCM test vector NIST #14 (P=24, N=13, A=0, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"894dcaa61008eb8fb052c60d41":"":"bb5425b3869b76856ec58e39886fb6f6f2ac13fe44cb132d":"8d0c0099":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"f7079dfa3b5c7b056347d7e437bcded683abd6e2c9e069d333284082cbb5d453":"894dcaa61008eb8fb052c60d41":"":"bb5425b3869b76856ec58e39886fb6f6f2ac13fe44cb132d":"8d0c0099":"FAIL":"" AES-256-CCM test vector NIST #15 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"a544218dadd3c10583db49cf39":"":"f0050ad16392021a3f40207bed3521fb1e9f808f49830c42":"3a578d179902f912f9ea1afbce1120b3":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"a544218dadd3c10583db49cf39":"":"f0050ad16392021a3f40207bed3521fb1e9f808f49830c42":"3a578d179902f912f9ea1afbce1120b3":"":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e" AES-256-CCM test vector NIST #16 (P=24, N=13, A=0, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"894dcaa61008eb8fb052c60d41":"":"c408190d0fbf5034f83b24a8ed9657331a7ce141de4fae76":"9084607b83bd06e6442eac8dacf583cc":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"894dcaa61008eb8fb052c60d41":"":"c408190d0fbf5034f83b24a8ed9657331a7ce141de4fae76":"9084607b83bd06e6442eac8dacf583cc":"FAIL":"" AES-256-CCM test vector NIST #17 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"":"92d00fbe":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"":"92d00fbe":"":"" AES-256-CCM test vector NIST #18 (P=0, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":"":"9143e5c4":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"1b0e8df63c57f05d9ac457575ea764524b8610ae5164e6215f426f5a7ae6ede4":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":"":"9143e5c4":"FAIL":"" AES-256-CCM test vector NIST #19 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"":"93af11a08379eb37a16aa2837f09d69d":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"":"93af11a08379eb37a16aa2837f09d69d":"":"" AES-256-CCM test vector NIST #20 (P=0, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":"":"d19b0c14ec686a7961ca7c386d125a65":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"78c46e3249ca28":"232e957c65ffa11988e830d4617d500f1c4a35c1221f396c41ab214f074ca2dc":"":"d19b0c14ec686a7961ca7c386d125a65":"FAIL":"" AES-256-CCM test vector NIST #21 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"":"866d4227":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"":"866d4227":"":"" AES-256-CCM test vector NIST #22 (P=0, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":"":"94cb1127":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"a4bc10b1a62c96d459fbaf3a5aa3face7313bb9e1253e696f96a7a8e36801088":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":"":"94cb1127":"FAIL":"" AES-256-CCM test vector NIST #23 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"":"867b0d87cf6e0f718200a97b4f6d5ad5":"" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"":"867b0d87cf6e0f718200a97b4f6d5ad5":"":"" AES-256-CCM test vector NIST #24 (P=0, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":"":"677a040d46ee3f2b7838273bdad14f16":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"e8de970f6ee8e80ede933581b5":"89f8b068d34f56bc49d839d8e47b347e6dae737b903b278632447e6c0485d26a":"":"677a040d46ee3f2b7838273bdad14f16":"FAIL":"" AES-256-CCM test vector NIST #25 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"c2fe12658139f5d0dd22cadf2e901695b579302a72fc5608":"3ebc7720":"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"c2fe12658139f5d0dd22cadf2e901695b579302a72fc5608":"3ebc7720":"":"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" AES-256-CCM test vector NIST #26 (P=24, N=7, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":"94748ba81229e53c38583a8564b23ebbafc6f6efdf4c2a81":"c44db2c9":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"8c5cf3457ff22228c39c051c4e05ed4093657eb303f859a9d4b0f8be0127d88a":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":"94748ba81229e53c38583a8564b23ebbafc6f6efdf4c2a81":"c44db2c9":"FAIL":"" AES-256-CCM test vector NIST #27 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"3341168eb8c48468c414347fb08f71d2086f7c2d1bd581ce":"1ac68bd42f5ec7fa7e068cc0ecd79c2a":"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"a544218dadd3c1":"d3d5424e20fbec43ae495353ed830271515ab104f8860c988d15b6d36c038eab":"3341168eb8c48468c414347fb08f71d2086f7c2d1bd581ce":"1ac68bd42f5ec7fa7e068cc0ecd79c2a":"":"78c46e3249ca28e1ef0531d80fd37c124d9aecb7be6668e3" AES-256-CCM test vector NIST #28 (P=24, N=7, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":"d543acda712b898cbb27b8f598b2e4438ce587a836e27851":"47c3338a2400809e739b63ba8227d2f9":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"6ba004fd176791":"5a053b2a1bb87e85d56527bfcdcd3ecafb991bb10e4c862bb0751c700a29f54b":"d543acda712b898cbb27b8f598b2e4438ce587a836e27851":"47c3338a2400809e739b63ba8227d2f9":"FAIL":"" AES-256-CCM test vector NIST #29 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"c0ea400b599561e7905b99262b4565d5c3dc49fad84d7c69":"ef891339":"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"c0ea400b599561e7905b99262b4565d5c3dc49fad84d7c69":"ef891339":"":"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" AES-256-CCM test vector NIST #30 (P=24, N=13, A=32, T=4) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":"60871e03ea0eb968536c99f926ea24ef43d41272ad9fb7f6":"3d488623":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"705334e30f53dd2f92d190d2c1437c8772f940c55aa35e562214ed45bd458ffe":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":"60871e03ea0eb968536c99f926ea24ef43d41272ad9fb7f6":"3d488623":"FAIL":"" AES-256-CCM test vector NIST #31 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"8d34cdca37ce77be68f65baf3382e31efa693e63f914a781":"367f30f2eaad8c063ca50795acd90203":"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"a544218dadd3c10583db49cf39":"3c0e2815d37d844f7ac240ba9d6e3a0b2a86f706e885959e09a1005e024f6907":"8d34cdca37ce77be68f65baf3382e31efa693e63f914a781":"367f30f2eaad8c063ca50795acd90203":"":"e8de970f6ee8e80ede933581b5bcf4d837e2b72baa8b00c3" AES-256-CCM test vector NIST #32 (P=24, N=13, A=32, T=16) depends_on:MBEDTLS_AES_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":"516c0095cc3d85fd55e48da17c592e0c7014b9daafb82bdc":"4b41096dfdbe9cc1ab610f8f3e038d16":"FAIL" +auth_crypt_tv:MBEDTLS_CIPHER_AES_256_CCM:"314a202f836f9f257e22d8c11757832ae5131d357a72df88f3eff0ffcee0da4e":"8fa501c5dd9ac9b868144c9fa5":"5bb40e3bb72b4509324a7edc852f72535f1f6283156e63f6959ffaf39dcde800":"516c0095cc3d85fd55e48da17c592e0c7014b9daafb82bdc":"4b41096dfdbe9cc1ab610f8f3e038d16":"FAIL":"" Camellia-CCM test vector RFC 5528 #1 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"0001020304050607":"BA737185E719310492F38A5F1251DA55FAFBC949848A0D":"FCAECE746B3DB9AD":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000003020100A0A1A2A3A4A5":"0001020304050607":"BA737185E719310492F38A5F1251DA55FAFBC949848A0D":"FCAECE746B3DB9AD":"":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E" Camellia-CCM test vector RFC 5528 #2 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000004030201A0A1A2A3A4A5":"0001020304050607":"5D2564BF8EAFE1D99526EC016D1BF0424CFBD2CD62848F33":"60B2295DF24283E8":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000004030201A0A1A2A3A4A5":"0001020304050607":"5D2564BF8EAFE1D99526EC016D1BF0424CFBD2CD62848F33":"60B2295DF24283E8":"":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" Camellia-CCM test vector RFC 5528 #3 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000005040302A0A1A2A3A4A5":"0001020304050607":"81F663D6C7787817F9203608B982AD15DC2BBD87D756F79204":"F551D6682F23AA46":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000005040302A0A1A2A3A4A5":"0001020304050607":"81F663D6C7787817F9203608B982AD15DC2BBD87D756F79204":"F551D6682F23AA46":"":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20" Camellia-CCM test vector RFC 5528 #4 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000006050403A0A1A2A3A4A5":"000102030405060708090A0B":"CAEF1E827211B08F7BD90F08C77288C070A4A0":"8B3A933A63E497A0":"0C0D0E0F101112131415161718191A1B1C1D1E" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000006050403A0A1A2A3A4A5":"000102030405060708090A0B":"CAEF1E827211B08F7BD90F08C77288C070A4A0":"8B3A933A63E497A0":"":"0C0D0E0F101112131415161718191A1B1C1D1E" Camellia-CCM test vector RFC 5528 #5 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000007060504A0A1A2A3A4A5":"000102030405060708090A0B":"2AD3BAD94FC52E92BE438E827C1023B96A8A7725":"8FA17BA7F331DB09":"0C0D0E0F101112131415161718191A1B1C1D1E1F" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000007060504A0A1A2A3A4A5":"000102030405060708090A0B":"2AD3BAD94FC52E92BE438E827C1023B96A8A7725":"8FA17BA7F331DB09":"":"0C0D0E0F101112131415161718191A1B1C1D1E1F" Camellia-CCM test vector RFC 5528 #6 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000008070605A0A1A2A3A4A5":"000102030405060708090A0B":"FEA5480BA53FA8D3C34422AACE4DE67FFA3BB73BAB":"AB36A1EE4FE0FE28":"0C0D0E0F101112131415161718191A1B1C1D1E1F20" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000008070605A0A1A2A3A4A5":"000102030405060708090A0B":"FEA5480BA53FA8D3C34422AACE4DE67FFA3BB73BAB":"AB36A1EE4FE0FE28":"":"0C0D0E0F101112131415161718191A1B1C1D1E1F20" Camellia-CCM test vector RFC 5528 #7 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000009080706A0A1A2A3A4A5":"0001020304050607":"54532026E54C119A8D36D9EC6E1ED97416C8708C4B5C2C":"ACAFA3BCCF7A4EBF9573":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"00000009080706A0A1A2A3A4A5":"0001020304050607":"54532026E54C119A8D36D9EC6E1ED97416C8708C4B5C2C":"ACAFA3BCCF7A4EBF9573":"":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E" Camellia-CCM test vector RFC 5528 #8 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000A090807A0A1A2A3A4A5":"0001020304050607":"8AD19B001A87D148F4D92BEF34525CCCE3A63C6512A6F575":"7388E4913EF14701F441":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000A090807A0A1A2A3A4A5":"0001020304050607":"8AD19B001A87D148F4D92BEF34525CCCE3A63C6512A6F575":"7388E4913EF14701F441":"":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" Camellia-CCM test vector RFC 5528 #9 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000B0A0908A0A1A2A3A4A5":"0001020304050607":"5DB08D62407E6E31D60F9CA2C60474219AC0BE50C0D4A57787":"94D6E230CD25C9FEBF87":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000B0A0908A0A1A2A3A4A5":"0001020304050607":"5DB08D62407E6E31D60F9CA2C60474219AC0BE50C0D4A57787":"94D6E230CD25C9FEBF87":"":"08090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20" Camellia-CCM test vector RFC 5528 #10 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000C0B0A09A0A1A2A3A4A5":"000102030405060708090A0B":"DB118CCEC1B8761C877CD8963A67D6F3BBBC5C":"D09299EB11F312F23237":"0C0D0E0F101112131415161718191A1B1C1D1E" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000C0B0A09A0A1A2A3A4A5":"000102030405060708090A0B":"DB118CCEC1B8761C877CD8963A67D6F3BBBC5C":"D09299EB11F312F23237":"":"0C0D0E0F101112131415161718191A1B1C1D1E" Camellia-CCM test vector RFC 5528 #11 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000D0C0B0AA0A1A2A3A4A5":"000102030405060708090A0B":"7CC83D8DC49103525B483DC5CA7EA9AB812B7056":"079DAFFADA16CCCF2C4E":"0C0D0E0F101112131415161718191A1B1C1D1E1F" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000D0C0B0AA0A1A2A3A4A5":"000102030405060708090A0B":"7CC83D8DC49103525B483DC5CA7EA9AB812B7056":"079DAFFADA16CCCF2C4E":"":"0C0D0E0F101112131415161718191A1B1C1D1E1F" Camellia-CCM test vector RFC 5528 #12 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000E0D0C0BA0A1A2A3A4A5":"000102030405060708090A0B":"2CD35B8820D23E7AA351B0E92FC79367238B2CC748":"CBB94C2947793D64AF75":"0C0D0E0F101112131415161718191A1B1C1D1E1F20" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF":"0000000E0D0C0BA0A1A2A3A4A5":"000102030405060708090A0B":"2CD35B8820D23E7AA351B0E92FC79367238B2CC748":"CBB94C2947793D64AF75":"":"0C0D0E0F101112131415161718191A1B1C1D1E1F20" Camellia-CCM test vector RFC 5528 #13 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00A970110E1927B160B6A31C1C":"6B7F464507FAE496":"A435D727348DDD22907F7EB8F5FDBB4D939DA6524DB4F6":"4558C02D25B127EE":"C6B5F3E6CA2311AEF7472B203E735EA561ADB17D56C5A3" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00A970110E1927B160B6A31C1C":"6B7F464507FAE496":"A435D727348DDD22907F7EB8F5FDBB4D939DA6524DB4F6":"4558C02D25B127EE":"":"C6B5F3E6CA2311AEF7472B203E735EA561ADB17D56C5A3" Camellia-CCM test vector RFC 5528 #14 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"0083CD8CE0CB42B160B6A31C1C":"986605B43DF15DE7":"8AE052508FBECA932E346F05E0DC0DFBCF939EAFFA3E587C":"867D6E1C48703806":"01F6CE6764C574483BB02E6BBF1E0ABD26A22572B4D80EE7" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"0083CD8CE0CB42B160B6A31C1C":"986605B43DF15DE7":"8AE052508FBECA932E346F05E0DC0DFBCF939EAFFA3E587C":"867D6E1C48703806":"":"01F6CE6764C574483BB02E6BBF1E0ABD26A22572B4D80EE7" Camellia-CCM test vector RFC 5528 #15 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"005F54950B18F2B160B6A31C1C":"48F2E7E1A7671A51":"08B67EE21C8BF26E473E408599E9C0836D6AF0BB18DF55466C":"A80878A790476DE5":"CDF1D8406FC2E9014953897005FBFB8BA57276F92404608E08" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"005F54950B18F2B160B6A31C1C":"48F2E7E1A7671A51":"08B67EE21C8BF26E473E408599E9C0836D6AF0BB18DF55466C":"A80878A790476DE5":"":"CDF1D8406FC2E9014953897005FBFB8BA57276F92404608E08" Camellia-CCM test vector RFC 5528 #16 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00EC600863319AB160B6A31C1C":"DE97DF3B8CBD6D8E5030DA4C":"63B78B4967B19EDBB733CD1114F64EB2260893":"68C354828D950CC5":"B005DCFA0B59181426A961685A993D8C43185B" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00EC600863319AB160B6A31C1C":"DE97DF3B8CBD6D8E5030DA4C":"63B78B4967B19EDBB733CD1114F64EB2260893":"68C354828D950CC5":"":"B005DCFA0B59181426A961685A993D8C43185B" Camellia-CCM test vector RFC 5528 #17 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"0060CFF1A31EA1B160B6A31C1C":"A5EE93E457DF05466E782DCF":"0BC6BBE2A8B909F4629EE6DC148DA44410E18AF4":"3147383276F66A9F":"2E20211298105F129D5ED95B93F72D30B2FACCD7" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"0060CFF1A31EA1B160B6A31C1C":"A5EE93E457DF05466E782DCF":"0BC6BBE2A8B909F4629EE6DC148DA44410E18AF4":"3147383276F66A9F":"":"2E20211298105F129D5ED95B93F72D30B2FACCD7" Camellia-CCM test vector RFC 5528 #18 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"000F85CD995C97B160B6A31C1C":"24AA1BF9A5CD876182A25074":"222AD632FA31D6AF970C345F7E77CA3BD0DC25B340":"A1A3D31F8D4B44B7":"2645941E75632D3491AF0FC0C9876C3BE4AA7468C9" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"000F85CD995C97B160B6A31C1C":"24AA1BF9A5CD876182A25074":"222AD632FA31D6AF970C345F7E77CA3BD0DC25B340":"A1A3D31F8D4B44B7":"":"2645941E75632D3491AF0FC0C9876C3BE4AA7468C9" Camellia-CCM test vector RFC 5528 #19 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00C29B2CAAC4CDB160B6A31C1C":"691946B9CA07BE87":"05B8E1B9C49CFD56CF130AA6251DC2ECC06CCC508FE697":"A0066D57C84BEC182768":"070135A6437C9DB120CD61D8F6C39C3EA125FD95A0D23D" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00C29B2CAAC4CDB160B6A31C1C":"691946B9CA07BE87":"05B8E1B9C49CFD56CF130AA6251DC2ECC06CCC508FE697":"A0066D57C84BEC182768":"":"070135A6437C9DB120CD61D8F6C39C3EA125FD95A0D23D" Camellia-CCM test vector RFC 5528 #20 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"002C6B7595EE62B160B6A31C1C":"D0C54ECB84627DC4":"54CEB968DEE23611575EC003DFAA1CD48849BDF5AE2EDB6B":"7FA775B150ED4383C5A9":"C8C0880E6C636E20093DD6594217D2E18877DB264E71A5CC" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"002C6B7595EE62B160B6A31C1C":"D0C54ECB84627DC4":"54CEB968DEE23611575EC003DFAA1CD48849BDF5AE2EDB6B":"7FA775B150ED4383C5A9":"":"C8C0880E6C636E20093DD6594217D2E18877DB264E71A5CC" Camellia-CCM test vector RFC 5528 #21 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00C53CD4C2AA24B160B6A31C1C":"E285E0E4808CDA3D":"B1404546BF667210CA28E309B39BD6CA7E9FC8285FE698D43C":"D20A02E0BDCAED2010D3":"F75DAA0710C4E64297794DC2B7D2A20757B1AA4E448002FFAB" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00C53CD4C2AA24B160B6A31C1C":"E285E0E4808CDA3D":"B1404546BF667210CA28E309B39BD6CA7E9FC8285FE698D43C":"D20A02E0BDCAED2010D3":"":"F75DAA0710C4E64297794DC2B7D2A20757B1AA4E448002FFAB" Camellia-CCM test vector RFC 5528 #22 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00BEE9267FBADCB160B6A31C1C":"6CAEF9941141570D7C813405":"94C8959C11569A297831A721005857AB61B87A":"2DEA0936B6EB5F625F5D":"C238822FAC5F98FF929405B0AD127A4E41854E" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00BEE9267FBADCB160B6A31C1C":"6CAEF9941141570D7C813405":"94C8959C11569A297831A721005857AB61B87A":"2DEA0936B6EB5F625F5D":"":"C238822FAC5F98FF929405B0AD127A4E41854E" Camellia-CCM test vector RFC 5528 #23 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00DFA8B1245007B160B6A31C1C":"36A52CF16B19A2037AB7011E":"5869E3AAD2447C74E0FC05F9A4EA74577F4DE8CA":"8924764296AD04119CE7":"4DBF3E774AD245E5D5891F9D1C32A0AE022C85D7" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"00DFA8B1245007B160B6A31C1C":"36A52CF16B19A2037AB7011E":"5869E3AAD2447C74E0FC05F9A4EA74577F4DE8CA":"8924764296AD04119CE7":"":"4DBF3E774AD245E5D5891F9D1C32A0AE022C85D7" Camellia-CCM test vector RFC 5528 #24 depends_on:MBEDTLS_CAMELLIA_C:MBEDTLS_CCM_C -auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"003B8FD8D3A937B160B6A31C1C":"A4D499F78419728C19178B0C":"4B198156393B0F7796086AAFB454F8C3F034CCA966":"945F1FCEA7E11BEE6A2F":"9DC9EDAE2FF5DF8636E8C6DE0EED55F7867E33337D" +auth_crypt_tv:MBEDTLS_CIPHER_CAMELLIA_128_CCM:"D75C2778078CA93D971F96FDE720F4CD":"003B8FD8D3A937B160B6A31C1C":"A4D499F78419728C19178B0C":"4B198156393B0F7796086AAFB454F8C3F034CCA966":"945F1FCEA7E11BEE6A2F":"":"9DC9EDAE2FF5DF8636E8C6DE0EED55F7867E33337D" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.chacha20.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.chacha20.data new file mode 100644 index 0000000000..11de1038af --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.chacha20.data @@ -0,0 +1,111 @@ +Chacha20 RFC 7539 Test Vector #1 +depends_on:MBEDTLS_CHACHA20_C +decrypt_test_vec:MBEDTLS_CIPHER_CHACHA20:-1:"0000000000000000000000000000000000000000000000000000000000000000":"000000000000000000000000":"76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000":"":"":0:0 + +ChaCha20 Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:0:-1 + +ChaCha20 Encrypt and decrypt 1 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:1:-1 + +ChaCha20 Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:2:-1 + +ChaCha20 Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:7:-1 + +ChaCha20 Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:8:-1 + +ChaCha20 Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:9:-1 + +ChaCha20 Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:15:-1 + +ChaCha20 Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:16:-1 + +ChaCha20 Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:17:-1 + +ChaCha20 Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:31:-1 + +ChaCha20 Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:32:-1 + +ChaCha20 Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:33:-1 + +ChaCha20 Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:47:-1 + +ChaCha20 Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:48:-1 + +ChaCha20 Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":256:49:-1 + +ChaCha20 Encrypt and decrypt 0 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:0:0:-1:0:0:0:0 + +ChaCha20 Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:1:0:-1:1:0:1:0 + +ChaCha20 Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:0:1:-1:0:1:0:1 + +ChaCha20 Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:16:0:-1:16:0:16:0 + +ChaCha20 Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:0:16:-1:0:16:0:16 + +ChaCha20 Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:1:15:-1:1:15:1:15 + +ChaCha20 Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:15:1:-1:15:1:15:1 + +ChaCha20 Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:15:7:-1:15:7:15:7 + +ChaCha20 Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:7:15:-1:7:15:7:15 + +ChaCha20 Encrypt and decrypt 22 bytes in multiple parts 3 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:16:6:-1:16:6:16:6 + +ChaCha20 Encrypt and decrypt 22 bytes in multiple parts 4 +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:6:16:-1:6:16:6:16 + +ChaCha20 Encrypt and decrypt 32 bytes in multiple parts +depends_on:MBEDTLS_CHACHA20_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:16:16:-1:16:16:16:16 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.chachapoly.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.chachapoly.data new file mode 100644 index 0000000000..61c485125c --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.chachapoly.data @@ -0,0 +1,123 @@ +Decrypt empty buffer +depends_on:MBEDTLS_CHACHAPOLY_C +dec_empty_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305 + +ChaCha20+Poly1305 Encrypt and decrypt 0 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:0:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 1 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:1:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 2 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:2:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 7 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:7:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 8 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:8:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 9 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:9:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 15 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:15:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 16 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:16:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 17 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:17:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 31 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:31:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 32 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:32:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 33 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:33:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 47 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:47:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 48 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:48:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 49 bytes +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":256:49:-1 + +ChaCha20+Poly1305 Encrypt and decrypt 0 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:0:0:-1:0:0:0:0 + +ChaCha20+Poly1305 Encrypt and decrypt 1 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:1:0:-1:1:0:1:0 + +ChaCha20+Poly1305 Encrypt and decrypt 1 bytes in multiple parts 2 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:0:1:-1:0:1:0:1 + +ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:0:-1:16:0:16:0 + +ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 2 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:0:16:-1:0:16:0:16 + +ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 3 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:1:15:-1:1:15:1:15 + +ChaCha20+Poly1305 Encrypt and decrypt 16 bytes in multiple parts 4 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:15:1:-1:15:1:15:1 + +ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 1 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:15:7:-1:15:7:15:7 + +ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 2 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:7:15:-1:7:15:7:15 + +ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 3 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:6:-1:16:6:16:6 + +ChaCha20+Poly1305 Encrypt and decrypt 22 bytes in multiple parts 4 +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:6:16:-1:6:16:6:16 + +ChaCha20+Poly1305 Encrypt and decrypt 32 bytes in multiple parts +depends_on:MBEDTLS_CHACHAPOLY_C +enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20_POLY1305:256:16:16:-1:16:16:16:16 + +ChaCha20+Poly1305 RFC 7539 Test Vector #1 +depends_on:MBEDTLS_CHACHAPOLY_C +auth_crypt_tv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"eead9d67890cbb22392336fea1851f38":"":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d" + +ChaCha20+Poly1305 RFC 7539 Test Vector #1 Unauthentic (1st bit flipped) +depends_on:MBEDTLS_CHACHAPOLY_C +auth_crypt_tv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"f33388860000000000004e91":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"6ead9d67890cbb22392336fea1851f38":"FAIL":"" + +Chacha20+Poly1305 RFC 7539 Test Vector #1 (streaming) +depends_on:MBEDTLS_CHACHAPOLY_C +decrypt_test_vec:MBEDTLS_CIPHER_CHACHA20_POLY1305:-1:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"000000000102030405060708":"64a0861575861af460f062c79be643bd5e805cfd345cf389f108670ac76c8cb24c6cfc18755d43eea09ee94e382d26b0bdb7b73c321b0100d4f03b7f355894cf332f830e710b97ce98c8a84abd0b948114ad176e008d33bd60f982b1ff37c8559797a06ef4f0ef61c186324e2b3506383606907b6a7c02b0f9f6157b53c867e4b9166c767b804d46a59b5216cde7a4e99040c5a40433225ee282a1b0a06c523eaf4534d7f83fa1155b0047718cbc546a0d072b04b3564eea1b422273f548271a0bb2316053fa76991955ebd63159434ecebb4e466dae5a1073a6727627097a1049e617d91d361094fa68f0ff77987130305beaba2eda04df997b714d6c6f2c29a6ad5cb4022b02709b":"496e7465726e65742d4472616674732061726520647261667420646f63756d656e74732076616c696420666f722061206d6178696d756d206f6620736978206d6f6e74687320616e64206d617920626520757064617465642c207265706c616365642c206f72206f62736f6c65746564206279206f7468657220646f63756d656e747320617420616e792074696d652e20497420697320696e617070726f70726961746520746f2075736520496e7465726e65742d447261667473206173207265666572656e6365206d6174657269616c206f7220746f2063697465207468656d206f74686572207468616e206173202fe2809c776f726b20696e2070726f67726573732e2fe2809d":"f33388860000000000004e91":"eead9d67890cbb22392336fea1851f38":0:0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.function index 343dd78635..02bf5f7ee1 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.function @@ -12,7 +12,7 @@ */ /* BEGIN_CASE */ -void mbedtls_cipher_list( ) +void mbedtls_cipher_list( ) { const int *cipher_type; @@ -22,77 +22,469 @@ void mbedtls_cipher_list( ) /* END_CASE */ /* BEGIN_CASE */ -void cipher_null_args( ) +void cipher_invalid_param_unconditional( ) { - mbedtls_cipher_context_t ctx; - const mbedtls_cipher_info_t *info = mbedtls_cipher_info_from_type( *( mbedtls_cipher_list() ) ); - unsigned char buf[1] = { 0 }; - size_t olen; - - mbedtls_cipher_init( &ctx ); - - TEST_ASSERT( mbedtls_cipher_get_block_size( NULL ) == 0 ); - TEST_ASSERT( mbedtls_cipher_get_block_size( &ctx ) == 0 ); - - TEST_ASSERT( mbedtls_cipher_get_cipher_mode( NULL ) == MBEDTLS_MODE_NONE ); - TEST_ASSERT( mbedtls_cipher_get_cipher_mode( &ctx ) == MBEDTLS_MODE_NONE ); - - TEST_ASSERT( mbedtls_cipher_get_iv_size( NULL ) == 0 ); - TEST_ASSERT( mbedtls_cipher_get_iv_size( &ctx ) == 0 ); - - TEST_ASSERT( mbedtls_cipher_info_from_string( NULL ) == NULL ); - - TEST_ASSERT( mbedtls_cipher_setup( &ctx, NULL ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_setup( NULL, info ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + mbedtls_cipher_context_t valid_ctx; + mbedtls_cipher_context_t invalid_ctx; + mbedtls_operation_t valid_operation = MBEDTLS_ENCRYPT; + mbedtls_cipher_padding_t valid_mode = MBEDTLS_PADDING_ZEROS; + unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; + int valid_size = sizeof(valid_buffer); + int valid_bitlen = valid_size * 8; + const mbedtls_cipher_info_t *valid_info = mbedtls_cipher_info_from_type( + *( mbedtls_cipher_list() ) ); + size_t size_t_var; + + (void)valid_mode; /* In some configurations this is unused */ + + mbedtls_cipher_init( &valid_ctx ); + mbedtls_cipher_setup( &valid_ctx, valid_info ); + mbedtls_cipher_init( &invalid_ctx ); + + /* mbedtls_cipher_setup() */ + TEST_ASSERT( mbedtls_cipher_setup( &valid_ctx, NULL ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* mbedtls_cipher_get_block_size() */ + TEST_ASSERT( mbedtls_cipher_get_block_size( &invalid_ctx ) == 0 ); + + /* mbedtls_cipher_get_cipher_mode() */ + TEST_ASSERT( mbedtls_cipher_get_cipher_mode( &invalid_ctx ) == + MBEDTLS_MODE_NONE ); + + /* mbedtls_cipher_get_iv_size() */ + TEST_ASSERT( mbedtls_cipher_get_iv_size( &invalid_ctx ) == 0 ); + + /* mbedtls_cipher_get_type() */ + TEST_ASSERT( + mbedtls_cipher_get_type( &invalid_ctx ) == + MBEDTLS_CIPHER_NONE); + + /* mbedtls_cipher_get_name() */ + TEST_ASSERT( mbedtls_cipher_get_name( &invalid_ctx ) == 0 ); + + /* mbedtls_cipher_get_key_bitlen() */ + TEST_ASSERT( mbedtls_cipher_get_key_bitlen( &invalid_ctx ) == + MBEDTLS_KEY_LENGTH_NONE ); + + /* mbedtls_cipher_get_operation() */ + TEST_ASSERT( mbedtls_cipher_get_operation( &invalid_ctx ) == + MBEDTLS_OPERATION_NONE ); + + /* mbedtls_cipher_setkey() */ + TEST_ASSERT( + mbedtls_cipher_setkey( &invalid_ctx, + valid_buffer, + valid_bitlen, + valid_operation ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* mbedtls_cipher_set_iv() */ + TEST_ASSERT( + mbedtls_cipher_set_iv( &invalid_ctx, + valid_buffer, + valid_size ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* mbedtls_cipher_reset() */ + TEST_ASSERT( mbedtls_cipher_reset( &invalid_ctx ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) + /* mbedtls_cipher_update_ad() */ + TEST_ASSERT( + mbedtls_cipher_update_ad( &invalid_ctx, + valid_buffer, + valid_size ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +#endif /* defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) */ - TEST_ASSERT( mbedtls_cipher_setkey( NULL, buf, 0, MBEDTLS_ENCRYPT ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_setkey( &ctx, buf, 0, MBEDTLS_ENCRYPT ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - - TEST_ASSERT( mbedtls_cipher_set_iv( NULL, buf, 0 ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_set_iv( &ctx, buf, 0 ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - - TEST_ASSERT( mbedtls_cipher_reset( NULL ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_reset( &ctx ) == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - -#if defined(MBEDTLS_GCM_C) - TEST_ASSERT( mbedtls_cipher_update_ad( NULL, buf, 0 ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_update_ad( &ctx, buf, 0 ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) + /* mbedtls_cipher_set_padding_mode() */ + TEST_ASSERT( mbedtls_cipher_set_padding_mode( &invalid_ctx, valid_mode ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); #endif - TEST_ASSERT( mbedtls_cipher_update( NULL, buf, 0, buf, &olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_update( &ctx, buf, 0, buf, &olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + /* mbedtls_cipher_update() */ + TEST_ASSERT( + mbedtls_cipher_update( &invalid_ctx, + valid_buffer, + valid_size, + valid_buffer, + &size_t_var ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* mbedtls_cipher_finish() */ + TEST_ASSERT( + mbedtls_cipher_finish( &invalid_ctx, + valid_buffer, + &size_t_var ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) + /* mbedtls_cipher_write_tag() */ + TEST_ASSERT( + mbedtls_cipher_write_tag( &invalid_ctx, + valid_buffer, + valid_size ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); + + /* mbedtls_cipher_check_tag() */ + TEST_ASSERT( + mbedtls_cipher_check_tag( &invalid_ctx, + valid_buffer, + valid_size ) == + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +#endif /* defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) */ - TEST_ASSERT( mbedtls_cipher_finish( NULL, buf, &olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_finish( &ctx, buf, &olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +exit: + mbedtls_cipher_free( &invalid_ctx ); + mbedtls_cipher_free( &valid_ctx ); +} +/* END_CASE */ -#if defined(MBEDTLS_GCM_C) - TEST_ASSERT( mbedtls_cipher_write_tag( NULL, buf, olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_write_tag( &ctx, buf, olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void cipher_invalid_param_conditional( ) +{ + mbedtls_cipher_context_t valid_ctx; + + mbedtls_operation_t valid_operation = MBEDTLS_ENCRYPT; + mbedtls_operation_t invalid_operation = 100; + mbedtls_cipher_padding_t valid_mode = MBEDTLS_PADDING_ZEROS; + unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }; + int valid_size = sizeof(valid_buffer); + int valid_bitlen = valid_size * 8; + const mbedtls_cipher_info_t *valid_info = mbedtls_cipher_info_from_type( + *( mbedtls_cipher_list() ) ); + + size_t size_t_var; + + (void)valid_mode; /* In some configurations this is unused */ + + /* mbedtls_cipher_init() */ + TEST_VALID_PARAM( mbedtls_cipher_init( &valid_ctx ) ); + TEST_INVALID_PARAM( mbedtls_cipher_init( NULL ) ); + + /* mbedtls_cipher_setup() */ + TEST_VALID_PARAM( mbedtls_cipher_setup( &valid_ctx, valid_info ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_setup( NULL, valid_info ) ); + + /* mbedtls_cipher_get_block_size() */ + TEST_INVALID_PARAM_RET( 0, mbedtls_cipher_get_block_size( NULL ) ); + + /* mbedtls_cipher_get_cipher_mode() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_MODE_NONE, + mbedtls_cipher_get_cipher_mode( NULL ) ); + + /* mbedtls_cipher_get_iv_size() */ + TEST_INVALID_PARAM_RET( 0, mbedtls_cipher_get_iv_size( NULL ) ); + + /* mbedtls_cipher_get_type() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_CIPHER_NONE, + mbedtls_cipher_get_type( NULL ) ); + + /* mbedtls_cipher_get_name() */ + TEST_INVALID_PARAM_RET( 0, mbedtls_cipher_get_name( NULL ) ); + + /* mbedtls_cipher_get_key_bitlen() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_KEY_LENGTH_NONE, + mbedtls_cipher_get_key_bitlen( NULL ) ); + + /* mbedtls_cipher_get_operation() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_OPERATION_NONE, + mbedtls_cipher_get_operation( NULL ) ); + + /* mbedtls_cipher_setkey() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_setkey( NULL, + valid_buffer, + valid_bitlen, + valid_operation ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_setkey( &valid_ctx, + NULL, + valid_bitlen, + valid_operation ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_setkey( &valid_ctx, + valid_buffer, + valid_bitlen, + invalid_operation ) ); + + /* mbedtls_cipher_set_iv() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_set_iv( NULL, + valid_buffer, + valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_set_iv( &valid_ctx, + NULL, + valid_size ) ); + + /* mbedtls_cipher_reset() */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_reset( NULL ) ); + +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) + /* mbedtls_cipher_update_ad() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_update_ad( NULL, + valid_buffer, + valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_update_ad( &valid_ctx, + NULL, + valid_size ) ); +#endif /* defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) */ - TEST_ASSERT( mbedtls_cipher_check_tag( NULL, buf, olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); - TEST_ASSERT( mbedtls_cipher_check_tag( &ctx, buf, olen ) - == MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ); +#if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) + /* mbedtls_cipher_set_padding_mode() */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_set_padding_mode( NULL, valid_mode ) ); #endif + + /* mbedtls_cipher_update() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_update( NULL, + valid_buffer, + valid_size, + valid_buffer, + &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_update( &valid_ctx, + NULL, valid_size, + valid_buffer, + &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_update( &valid_ctx, + valid_buffer, valid_size, + NULL, + &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_update( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, + NULL ) ); + + /* mbedtls_cipher_finish() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_finish( NULL, + valid_buffer, + &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_finish( &valid_ctx, + NULL, + &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_finish( &valid_ctx, + valid_buffer, + NULL ) ); + +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) + /* mbedtls_cipher_write_tag() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_write_tag( NULL, + valid_buffer, + valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_write_tag( &valid_ctx, + NULL, + valid_size ) ); + + /* mbedtls_cipher_check_tag() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_check_tag( NULL, + valid_buffer, + valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_check_tag( &valid_ctx, + NULL, + valid_size ) ); +#endif /* defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) */ + + /* mbedtls_cipher_crypt() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_crypt( NULL, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_crypt( &valid_ctx, + NULL, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_crypt( &valid_ctx, + valid_buffer, valid_size, + NULL, valid_size, + valid_buffer, &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_crypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + NULL, &size_t_var ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_crypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, NULL ) ); + +#if defined(MBEDTLS_CIPHER_MODE_AEAD) + /* mbedtls_cipher_auth_encrypt() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( NULL, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( &valid_ctx, + NULL, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( &valid_ctx, + valid_buffer, valid_size, + NULL, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + NULL, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + NULL, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, NULL, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_encrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + NULL, valid_size ) ); + + /* mbedtls_cipher_auth_decrypt() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( NULL, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( &valid_ctx, + NULL, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( &valid_ctx, + valid_buffer, valid_size, + NULL, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + NULL, valid_size, + valid_buffer, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + NULL, &size_t_var, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, NULL, + valid_buffer, valid_size ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA, + mbedtls_cipher_auth_decrypt( &valid_ctx, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, valid_size, + valid_buffer, &size_t_var, + NULL, valid_size ) ); +#endif /* defined(MBEDTLS_CIPHER_MODE_AEAD) */ + + /* mbedtls_cipher_free() */ + TEST_VALID_PARAM( mbedtls_cipher_free( NULL ) ); +exit: + TEST_VALID_PARAM( mbedtls_cipher_free( &valid_ctx ) ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_AES_C */ -void cipher_special_behaviours( ) +void cipher_special_behaviours( ) { const mbedtls_cipher_info_t *cipher_info; mbedtls_cipher_context_t ctx; @@ -141,11 +533,11 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void enc_dec_buf( int cipher_id, char *cipher_string, int key_len, +void enc_dec_buf( int cipher_id, char * cipher_string, int key_len, int length_val, int pad_mode ) { size_t length = length_val, outlen, total_len, i, block_size; - unsigned char key[32]; + unsigned char key[64]; unsigned char iv[16]; unsigned char ad[13]; unsigned char tag[16]; @@ -206,7 +598,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len, TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) ); -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, ad, sizeof( ad ) - i ) ); TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, ad, sizeof( ad ) - i ) ); #endif @@ -226,7 +618,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len, TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) ); total_len += outlen; -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) TEST_ASSERT( 0 == mbedtls_cipher_write_tag( &ctx_enc, tag, sizeof( tag ) ) ); #endif @@ -247,7 +639,7 @@ void enc_dec_buf( int cipher_id, char *cipher_string, int key_len, TEST_ASSERT( 0 == mbedtls_cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) ); total_len += outlen; -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) TEST_ASSERT( 0 == mbedtls_cipher_check_tag( &ctx_dec, tag, sizeof( tag ) ) ); #endif @@ -266,8 +658,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void enc_fail( int cipher_id, int pad_mode, int key_len, - int length_val, int ret ) +void enc_fail( int cipher_id, int pad_mode, int key_len, int length_val, + int ret ) { size_t length = length_val; unsigned char key[32]; @@ -303,7 +695,7 @@ void enc_fail( int cipher_id, int pad_mode, int key_len, #endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, 16 ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) ); -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, NULL, 0 ) ); #endif @@ -318,7 +710,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void dec_empty_buf() +void dec_empty_buf( int cipher ) { unsigned char key[32]; unsigned char iv[16]; @@ -331,6 +723,8 @@ void dec_empty_buf() size_t outlen = 0; + int expected_ret; + memset( key, 0, 32 ); memset( iv , 0, 16 ); @@ -340,26 +734,44 @@ void dec_empty_buf() memset( decbuf, 0, 64 ); /* Initialise context */ - cipher_info = mbedtls_cipher_info_from_type( MBEDTLS_CIPHER_AES_128_CBC ); + cipher_info = mbedtls_cipher_info_from_type( cipher ); TEST_ASSERT( NULL != cipher_info); + TEST_ASSERT( sizeof(key) * 8 >= cipher_info->key_bitlen ); TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx_dec, cipher_info ) ); - TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_dec, key, 128, MBEDTLS_DECRYPT ) ); + TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx_dec, + key, cipher_info->key_bitlen, + MBEDTLS_DECRYPT ) ); TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx_dec, iv, 16 ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) ); -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) ); #endif /* decode 0-byte string */ TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) ); TEST_ASSERT( 0 == outlen ); - TEST_ASSERT( MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED == mbedtls_cipher_finish( - &ctx_dec, decbuf + outlen, &outlen ) ); + + if ( cipher_info->mode == MBEDTLS_MODE_CBC || + cipher_info->mode == MBEDTLS_MODE_ECB ) + { + /* CBC and ECB ciphers need a full block of input. */ + expected_ret = MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED; + } + else + { + /* Non-CBC and non-ECB ciphers are OK with decrypting empty buffers and + * return success, not MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED, when + * decrypting an empty buffer. */ + expected_ret = 0; + } + + TEST_ASSERT( expected_ret == mbedtls_cipher_finish( + &ctx_dec, decbuf + outlen, &outlen ) ); TEST_ASSERT( 0 == outlen ); exit: @@ -427,7 +839,7 @@ void enc_dec_buf_multipart( int cipher_id, int key_len, int first_length_val, TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_dec ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx_enc ) ); -#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_dec, NULL, 0 ) ); TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx_enc, NULL, 0 ) ); #endif @@ -482,80 +894,56 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void decrypt_test_vec( int cipher_id, int pad_mode, - char *hex_key, char *hex_iv, - char *hex_cipher, char *hex_clear, - char *hex_ad, char *hex_tag, +void decrypt_test_vec( int cipher_id, int pad_mode, data_t * key, + data_t * iv, data_t * cipher, + data_t * clear, data_t * ad, data_t * tag, int finish_result, int tag_result ) { - unsigned char key[50]; - unsigned char iv[50]; - unsigned char cipher[200]; - unsigned char clear[200]; - unsigned char ad[200]; - unsigned char tag[20]; - size_t key_len, iv_len, cipher_len, clear_len; -#if defined(MBEDTLS_GCM_C) - size_t ad_len, tag_len; -#endif + unsigned char output[265]; mbedtls_cipher_context_t ctx; - unsigned char output[200]; size_t outlen, total_len; mbedtls_cipher_init( &ctx ); - memset( key, 0x00, sizeof( key ) ); - memset( iv, 0x00, sizeof( iv ) ); - memset( cipher, 0x00, sizeof( cipher ) ); - memset( clear, 0x00, sizeof( clear ) ); - memset( ad, 0x00, sizeof( ad ) ); - memset( tag, 0x00, sizeof( tag ) ); memset( output, 0x00, sizeof( output ) ); - key_len = unhexify( key, hex_key ); - iv_len = unhexify( iv, hex_iv ); - cipher_len = unhexify( cipher, hex_cipher ); - clear_len = unhexify( clear, hex_clear ); -#if defined(MBEDTLS_GCM_C) - ad_len = unhexify( ad, hex_ad ); - tag_len = unhexify( tag, hex_tag ); -#else - ((void) hex_ad); - ((void) hex_tag); +#if !defined(MBEDTLS_GCM_C) && !defined(MBEDTLS_CHACHAPOLY_C) + ((void) ad); + ((void) tag); #endif /* Prepare context */ TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx, mbedtls_cipher_info_from_type( cipher_id ) ) ); - TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, MBEDTLS_DECRYPT ) ); + TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key->x, 8 * key->len, MBEDTLS_DECRYPT ) ); #if defined(MBEDTLS_CIPHER_MODE_WITH_PADDING) if( pad_mode != -1 ) TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, pad_mode ) ); #else (void) pad_mode; #endif /* MBEDTLS_CIPHER_MODE_WITH_PADDING */ - TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv, iv_len ) ); + TEST_ASSERT( 0 == mbedtls_cipher_set_iv( &ctx, iv->x, iv->len ) ); TEST_ASSERT( 0 == mbedtls_cipher_reset( &ctx ) ); -#if defined(MBEDTLS_GCM_C) - TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, ad, ad_len ) ); +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) + TEST_ASSERT( 0 == mbedtls_cipher_update_ad( &ctx, ad->x, ad->len ) ); #endif - /* decode buffer and check tag */ + /* decode buffer and check tag->x */ total_len = 0; - TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, cipher, cipher_len, output, &outlen ) ); + TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, cipher->x, cipher->len, output, &outlen ) ); total_len += outlen; TEST_ASSERT( finish_result == mbedtls_cipher_finish( &ctx, output + outlen, &outlen ) ); total_len += outlen; -#if defined(MBEDTLS_GCM_C) - TEST_ASSERT( tag_result == mbedtls_cipher_check_tag( &ctx, tag, tag_len ) ); +#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_CHACHAPOLY_C) + TEST_ASSERT( tag_result == mbedtls_cipher_check_tag( &ctx, tag->x, tag->len ) ); #endif /* check plaintext only if everything went fine */ if( 0 == finish_result && 0 == tag_result ) { - TEST_ASSERT( total_len == clear_len ); - TEST_ASSERT( 0 == memcmp( output, clear, clear_len ) ); + TEST_ASSERT( total_len == clear->len ); + TEST_ASSERT( 0 == memcmp( output, clear->x, clear->len ) ); } exit: @@ -564,56 +952,38 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_AEAD */ -void auth_crypt_tv( int cipher_id, char *hex_key, char *hex_iv, - char *hex_ad, char *hex_cipher, - char *hex_tag, char *hex_clear ) +void auth_crypt_tv( int cipher_id, data_t * key, data_t * iv, + data_t * ad, data_t * cipher, data_t * tag, + char * result, data_t * clear ) { int ret; - unsigned char key[50]; - unsigned char iv[50]; - unsigned char cipher[200]; - unsigned char clear[200]; - unsigned char ad[200]; - unsigned char tag[20]; + unsigned char output[267]; /* above + 2 (overwrite check) */ unsigned char my_tag[20]; - size_t key_len, iv_len, cipher_len, clear_len, ad_len, tag_len; mbedtls_cipher_context_t ctx; - unsigned char output[200]; size_t outlen; mbedtls_cipher_init( &ctx ); - memset( key, 0x00, sizeof( key ) ); - memset( iv, 0x00, sizeof( iv ) ); - memset( cipher, 0x00, sizeof( cipher ) ); - memset( clear, 0x00, sizeof( clear ) ); - memset( ad, 0x00, sizeof( ad ) ); - memset( tag, 0x00, sizeof( tag ) ); - memset( my_tag, 0xFF, sizeof( my_tag ) ); memset( output, 0xFF, sizeof( output ) ); + memset( my_tag, 0xFF, sizeof( my_tag ) ); - key_len = unhexify( key, hex_key ); - iv_len = unhexify( iv, hex_iv ); - cipher_len = unhexify( cipher, hex_cipher ); - ad_len = unhexify( ad, hex_ad ); - tag_len = unhexify( tag, hex_tag ); /* Prepare context */ TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx, mbedtls_cipher_info_from_type( cipher_id ) ) ); - TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, MBEDTLS_DECRYPT ) ); + TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key->x, 8 * key->len, MBEDTLS_DECRYPT ) ); - /* decode buffer and check tag */ - ret = mbedtls_cipher_auth_decrypt( &ctx, iv, iv_len, ad, ad_len, - cipher, cipher_len, output, &outlen, - tag, tag_len ); + /* decode buffer and check tag->x */ + ret = mbedtls_cipher_auth_decrypt( &ctx, iv->x, iv->len, ad->x, ad->len, + cipher->x, cipher->len, output, &outlen, + tag->x, tag->len ); /* make sure we didn't overwrite */ TEST_ASSERT( output[outlen + 0] == 0xFF ); TEST_ASSERT( output[outlen + 1] == 0xFF ); /* make sure the message is rejected if it should be */ - if( strcmp( hex_clear, "FAIL" ) == 0 ) + if( strcmp( result, "FAIL" ) == 0 ) { TEST_ASSERT( ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED ); goto exit; @@ -622,28 +992,30 @@ void auth_crypt_tv( int cipher_id, char *hex_key, char *hex_iv, /* otherwise, make sure it was decrypted properly */ TEST_ASSERT( ret == 0 ); - clear_len = unhexify( clear, hex_clear ); - TEST_ASSERT( outlen == clear_len ); - TEST_ASSERT( memcmp( output, clear, clear_len ) == 0 ); + TEST_ASSERT( outlen == clear->len ); + TEST_ASSERT( memcmp( output, clear->x, clear->len ) == 0 ); + + /* then encrypt the clear->x and make sure we get the same ciphertext and tag->x */ + TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key->x, 8 * key->len, + MBEDTLS_ENCRYPT ) ); - /* then encrypt the clear and make sure we get the same ciphertext and tag */ memset( output, 0xFF, sizeof( output ) ); outlen = 0; - ret = mbedtls_cipher_auth_encrypt( &ctx, iv, iv_len, ad, ad_len, - clear, clear_len, output, &outlen, - my_tag, tag_len ); + ret = mbedtls_cipher_auth_encrypt( &ctx, iv->x, iv->len, ad->x, ad->len, + clear->x, clear->len, output, &outlen, + my_tag, tag->len ); TEST_ASSERT( ret == 0 ); - TEST_ASSERT( outlen == clear_len ); - TEST_ASSERT( memcmp( output, cipher, clear_len ) == 0 ); - TEST_ASSERT( memcmp( my_tag, tag, tag_len ) == 0 ); + TEST_ASSERT( outlen == cipher->len ); + TEST_ASSERT( memcmp( output, cipher->x, cipher->len ) == 0 ); + TEST_ASSERT( memcmp( my_tag, tag->x, tag->len ) == 0 ); /* make sure we didn't overwrite */ TEST_ASSERT( output[outlen + 0] == 0xFF ); TEST_ASSERT( output[outlen + 1] == 0xFF ); - TEST_ASSERT( my_tag[tag_len + 0] == 0xFF ); - TEST_ASSERT( my_tag[tag_len + 1] == 0xFF ); + TEST_ASSERT( my_tag[tag->len + 0] == 0xFF ); + TEST_ASSERT( my_tag[tag->len + 1] == 0xFF ); exit: @@ -652,38 +1024,26 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void test_vec_ecb( int cipher_id, int operation, char *hex_key, - char *hex_input, char *hex_result, - int finish_result ) +void test_vec_ecb( int cipher_id, int operation, data_t * key, + data_t * input, data_t * result, int finish_result + ) { - unsigned char key[50]; - unsigned char input[16]; - unsigned char result[16]; - size_t key_len; mbedtls_cipher_context_t ctx; unsigned char output[32]; size_t outlen; mbedtls_cipher_init( &ctx ); - memset( key, 0x00, sizeof( key ) ); - memset( input, 0x00, sizeof( input ) ); - memset( result, 0x00, sizeof( result ) ); memset( output, 0x00, sizeof( output ) ); /* Prepare context */ TEST_ASSERT( 0 == mbedtls_cipher_setup( &ctx, mbedtls_cipher_info_from_type( cipher_id ) ) ); - key_len = unhexify( key, hex_key ); - TEST_ASSERT( unhexify( input, hex_input ) == - (int) mbedtls_cipher_get_block_size( &ctx ) ); - TEST_ASSERT( unhexify( result, hex_result ) == - (int) mbedtls_cipher_get_block_size( &ctx ) ); - TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key, 8 * key_len, operation ) ); + TEST_ASSERT( 0 == mbedtls_cipher_setkey( &ctx, key->x, 8 * key->len, operation ) ); - TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, input, + TEST_ASSERT( 0 == mbedtls_cipher_update( &ctx, input->x, mbedtls_cipher_get_block_size( &ctx ), output, &outlen ) ); TEST_ASSERT( outlen == mbedtls_cipher_get_block_size( &ctx ) ); @@ -693,7 +1053,7 @@ void test_vec_ecb( int cipher_id, int operation, char *hex_key, /* check plaintext only if everything went fine */ if( 0 == finish_result ) - TEST_ASSERT( 0 == memcmp( output, result, + TEST_ASSERT( 0 == memcmp( output, result->x, mbedtls_cipher_get_block_size( &ctx ) ) ); exit: @@ -770,12 +1130,12 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void check_padding( int pad_mode, char *input_str, int ret, int dlen_check ) +void check_padding( int pad_mode, data_t * input, int ret, int dlen_check + ) { mbedtls_cipher_info_t cipher_info; mbedtls_cipher_context_t ctx; - unsigned char input[16]; - size_t ilen, dlen; + size_t dlen; /* build a fake context just for getting access to get_padding */ mbedtls_cipher_init( &ctx ); @@ -784,9 +1144,8 @@ void check_padding( int pad_mode, char *input_str, int ret, int dlen_check ) TEST_ASSERT( 0 == mbedtls_cipher_set_padding_mode( &ctx, pad_mode ) ); - ilen = unhexify( input, input_str ); - TEST_ASSERT( ret == ctx.get_padding( input, ilen, &dlen ) ); + TEST_ASSERT( ret == ctx.get_padding( input->x, input->len, &dlen ) ); if( 0 == ret ) TEST_ASSERT( dlen == (size_t) dlen_check ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.misc.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.misc.data new file mode 100644 index 0000000000..25bfd407df --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.misc.data @@ -0,0 +1,5 @@ +CIPHER - Conditional invalid parameter checks +cipher_invalid_param_conditional: + +CIPHER - Unconditional invalid parameter checks +cipher_invalid_param_unconditional: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.padding.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.padding.data index 1c0ba09801..dc4c9d70b5 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.padding.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cipher.padding.data @@ -1,9 +1,6 @@ Cipher list mbedtls_cipher_list: -Cipher null/uninitialised arguments -cipher_null_args: - Set padding with AES-CBC depends_on:MBEDTLS_AES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_CIPHER_PADDING_PKCS7 set_padding:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_PADDING_PKCS7:0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cmac.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cmac.function index 4b31ab2ffd..cabf1070c1 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cmac.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_cmac.function @@ -9,14 +9,14 @@ */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void mbedtls_cmac_self_test( ) +void mbedtls_cmac_self_test( ) { TEST_ASSERT( mbedtls_cmac_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_cmac_null_args( ) +void mbedtls_cmac_null_args( ) { mbedtls_cipher_context_t ctx; const mbedtls_cipher_info_t *cipher_info; @@ -99,8 +99,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_cmac_setkey( int cipher_type, int key_size, - int result ) +void mbedtls_cmac_setkey( int cipher_type, int key_size, int result ) { const mbedtls_cipher_info_t *cipher_info; unsigned char key[32]; @@ -120,32 +119,19 @@ void mbedtls_cmac_setkey( int cipher_type, int key_size, /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_cmac_multiple_blocks( int cipher_type, - char *key_string, int keybits, - int block_size, - char *block1_string, int block1_len, - char *block2_string, int block2_len, - char *block3_string, int block3_len, - char *block4_string, int block4_len, - char *expected_result_string ) +void mbedtls_cmac_multiple_blocks( int cipher_type, data_t * key, + int keybits, int block_size, + data_t * block1, int block1_len, + data_t * block2, int block2_len, + data_t * block3, int block3_len, + data_t * block4, int block4_len, + data_t * expected_result ) { - unsigned char key[100]; - unsigned char block1[100]; - unsigned char block2[100]; - unsigned char block3[100]; - unsigned char block4[100]; - unsigned char expected_result[100]; const mbedtls_cipher_info_t *cipher_info; mbedtls_cipher_context_t ctx; unsigned char output[MBEDTLS_CIPHER_BLKSIZE_MAX]; /* Convert the test parameters to binary data */ - unhexify( key, key_string ); - unhexify( block1, block1_string ); - unhexify( block2, block2_string ); - unhexify( block3, block3_string ); - unhexify( block4, block4_string ); - unhexify( expected_result, expected_result_string ); mbedtls_cipher_init( &ctx ); @@ -162,34 +148,34 @@ void mbedtls_cmac_multiple_blocks( int cipher_type, TEST_ASSERT( mbedtls_cipher_setup( &ctx, cipher_info ) == 0 ); TEST_ASSERT( mbedtls_cipher_cmac_starts( &ctx, - (const unsigned char*)key, + (const unsigned char*)key->x, keybits ) == 0 ); /* Multiple partial and complete blocks. A negative length means skip the * update operation */ if( block1_len >= 0) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block1, + (unsigned char*)block1->x, block1_len ) == 0); if( block2_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block2, + (unsigned char*)block2->x, block2_len ) == 0); if( block3_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block3, + (unsigned char*)block3->x, block3_len ) == 0); if( block4_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block4, + (unsigned char*)block4->x, block4_len ) == 0); TEST_ASSERT( mbedtls_cipher_cmac_finish( &ctx, output ) == 0 ); - TEST_ASSERT( memcmp( output, expected_result, block_size ) == 0 ); + TEST_ASSERT( memcmp( output, expected_result->x, block_size ) == 0 ); exit: mbedtls_cipher_free( &ctx ); @@ -198,41 +184,31 @@ exit: /* BEGIN_CASE */ void mbedtls_cmac_multiple_operations_same_key( int cipher_type, - char *key_string, int keybits, - int block_size, - char *block_a1_string, int block_a1_len, - char *block_a2_string, int block_a2_len, - char *block_a3_string, int block_a3_len, - char *expected_result_a_string, - char *block_b1_string, int block_b1_len, - char *block_b2_string, int block_b2_len, - char *block_b3_string, int block_b3_len, - char *expected_result_b_string ) + data_t * key, int keybits, + int block_size, + data_t * block_a1, + int block_a1_len, + data_t * block_a2, + int block_a2_len, + data_t * block_a3, + int block_a3_len, + data_t * expected_result_a, + data_t * block_b1, + int block_b1_len, + data_t * block_b2, + int block_b2_len, + data_t * block_b3, + int block_b3_len, + data_t * expected_result_b + ) { - unsigned char key[100]; - unsigned char block_a1[100]; - unsigned char block_a2[100]; - unsigned char block_a3[100]; - unsigned char block_b1[100]; - unsigned char block_b2[100]; - unsigned char block_b3[100]; - unsigned char expected_result_a[100], expected_result_b[100]; const mbedtls_cipher_info_t *cipher_info; mbedtls_cipher_context_t ctx; unsigned char output[MBEDTLS_CIPHER_BLKSIZE_MAX]; /* Convert the test parameters to binary data */ - unhexify( key, key_string ); - unhexify( block_a1, block_a1_string ); - unhexify( block_a2, block_a2_string ); - unhexify( block_a3, block_a3_string ); - unhexify( block_b1, block_b1_string ); - unhexify( block_b2, block_b2_string ); - unhexify( block_b3, block_b3_string ); - unhexify( expected_result_a, expected_result_a_string ); - unhexify( expected_result_b, expected_result_b_string ); mbedtls_cipher_init( &ctx ); @@ -252,7 +228,7 @@ void mbedtls_cmac_multiple_operations_same_key( int cipher_type, TEST_ASSERT( mbedtls_cipher_setup( &ctx, cipher_info ) == 0 ); TEST_ASSERT( mbedtls_cipher_cmac_starts( &ctx, - (const unsigned char*)key, + (const unsigned char*)key->x, keybits ) == 0 ); /* Sequence A */ @@ -261,22 +237,22 @@ void mbedtls_cmac_multiple_operations_same_key( int cipher_type, * update operation */ if( block_a1_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block_a1, + (unsigned char*)block_a1->x, block_a1_len ) == 0); if( block_a2_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block_a2, + (unsigned char*)block_a2->x, block_a2_len ) == 0); if( block_a3_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block_a3, + (unsigned char*)block_a3->x, block_a3_len ) == 0); TEST_ASSERT( mbedtls_cipher_cmac_finish( &ctx, output ) == 0 ); - TEST_ASSERT( memcmp( output, expected_result_a, block_size ) == 0 ); + TEST_ASSERT( memcmp( output, expected_result_a->x, block_size ) == 0 ); TEST_ASSERT( mbedtls_cipher_cmac_reset( &ctx ) == 0 ); @@ -286,22 +262,22 @@ void mbedtls_cmac_multiple_operations_same_key( int cipher_type, * update operation */ if( block_b1_len >= 0) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block_b1, + (unsigned char*)block_b1->x, block_b1_len ) == 0); if( block_b2_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block_b2, + (unsigned char*)block_b2->x, block_b2_len ) == 0); if( block_b3_len >= 0 ) TEST_ASSERT( mbedtls_cipher_cmac_update( &ctx, - (unsigned char*)block_b3, + (unsigned char*)block_b3->x, block_b3_len ) == 0); TEST_ASSERT( mbedtls_cipher_cmac_finish( &ctx, output ) == 0 ); - TEST_ASSERT( memcmp( output, expected_result_b, block_size ) == 0 ); + TEST_ASSERT( memcmp( output, expected_result_b->x, block_size ) == 0 ); exit: mbedtls_cipher_free( &ctx ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.data index 666165851e..d2307bf109 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.data @@ -1,722 +1,1074 @@ +CTR_DRBG_withDF.pdf: AES-256, PR=no, perso=no, add=no +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"202122232425262728292a2b2c2d2e2f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f":"":"":"8da6cc59e703ced07d58d96e5b6d7836c32599735b734f88c1a73b53c7a6d82e" + +CTR_DRBG_withDF.pdf: AES-256, PR=no, perso=no, add=yes +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"202122232425262728292a2b2c2d2e2f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f":"a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf":"81daaf9800c34ff0a104e51d87e36f5b17eb14b9abc5064cadda976ec4f77d34" + +CTR_DRBG_withDF.pdf: AES-256, PR=no, perso=yes, add=no +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"202122232425262728292a2b2c2d2e2f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f":"":"":"bb2a0f5f0ca6d30634ba6068eb94aae8701437db7223a1b5afe8771547da3cee" + +CTR_DRBG_withDF.pdf: AES-256, PR=no, perso=yes, add=yes +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"202122232425262728292a2b2c2d2e2f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f":"a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf":"98a28e3b1ba363c9daf0f6887a1cf52b833d3354d77a7c10837dd63dd2e645f8" + +CTR_DRBG_withDF.pdf: AES-256, PR=yes, perso=no, add=no +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_pr:"202122232425262728292a2b2c2d2e2f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef":"":"":"259dc78ccfaec4210c30af815e4f75a5662b7da4b41013bdc00302dfb6076492" + +CTR_DRBG_withDF.pdf: AES-256, PR=yes, perso=no, add=yes +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_pr:"202122232425262728292a2b2c2d2e2f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f":"a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf":"386debbbf091bbf0502957b0329938fb836b82e594a2f5fdd5eb28d4e35528f4" + +CTR_DRBG_withDF.pdf: AES-256, PR=yes, perso=yes, add=no +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_pr:"202122232425262728292a2b2c2d2e2f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef":"":"":"601f95384f0d85946301d1eace8f645a825ce38f1e2565b0c0c439448e9ca8ac" + +CTR_DRBG_withDF.pdf: AES-256, PR=yes, perso=yes, add=yes +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_pr:"202122232425262728292a2b2c2d2e2f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f":"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeafc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeef":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f":"a0a1a2a3a4a5a6a7a8a9aaabacadaeafb0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecf":"738e99c95af59519aad37ff3d5180986adebab6e95836725097e50a8d1d0bd28" + CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"d254fcff021e69d229c9cfad85fa486c":"c18081a65d44021619b3f180b1c920026a546f0c7081498b6ea662526d51b1cb583bfad5375ffbc9ff46d219c7223e95459d82e1e7229f633169d26b57474fa337c9981c0bfb91314d55b9e91c5a5ee49392cfc52312d5562c4a6effdc10d068":"":"":"34011656b429008f3563ecb5f2590723" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #1 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"7be87545266dadd1d73546c0927afc8d":"a7f38c750bd6ff41c4e79f5b7dd3024d58ca3f1f4c096486c4a73c4f74a2410c4c9c5143eb8c09df842ba4427f385bbf65c350b0bf2c87242c7a23c8c2e0e419e44e500c250f6bc0dc25ec0ce929c4ad5ffb7a87950c618f8cee1af4831b4b8e":"":"":"d5b1da77f36ce58510b75dfde71dbd5d" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #2 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"3771416b162f4d9c5f48a05b7aa73938":"d20a0e5cdb714f01b48e00bae51909f345af05de13217e5d55fc6c2d705aea550420d9a458594d825b71e16b36130020cf5948fe813462061c1a222d1ff0e1e4b3d21ae8eee31d3260330d668d24ef3c8941b8720e8591b7deec4bd35a3a1f1a":"":"":"3cbd7d53ac1772c959311419adad836e" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #3 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"f2bad8f7dab3f5886faa1cf6e1f52c87":"4df54a483b4510ed76049faae14b962fbb16459d1f6b4f4dbeca85deded6018361223c893f9442719c51eb5695e1304a1c2be8c05d0846b6510a9525a28831a8efcbd82aa50540d7e7864e2b8a42d44380cdc6e02eebb48d0b5a840b7cdd6e04":"":"":"0062d822bc549bea292c37846340789b" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #4 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"1c5760aa0fd4ce308735b28682b67246":"89defd4445061c080e4762afac194b9f79c4bb1ed88c961af41d9d37bd388a1d45c82ca46f404348a2ae5e22ce00aa35ebc7c5051d8800890d44d25284489efcbd1f5e2b16e403f6921f71bbdfcf7b9aeddef65bc92fbd1cb9e4ea389aee5179":"":"":"3baf81155548afca67d57c503d00a5b4" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #5 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"b72b9451a5e866e226978623d36b3491":"2713d74affed98e3433559e17d240288bb1a1790904cd7754cad97007e205a157b8ddca704a3624413f2ec8361ccd85442fb0b7cc60a247f0fd102cef44677321514ea4186d0203ab7387925d0222800ce2078c4588bc50cdfccbc04fbecd593":"":"":"047a50890c282e26bfede4c0904f5369" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #6 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"91b955a3e7eccd7f07290cba4464baff":"b160465448894c7d5ee1963bb3e1a2f3f75fcd167ffa332c41c4c91c1830b7c07413bd580302958aa6fa81588ad2b3173698a4afafda468acb368dbbd524207196b9a3be37ac21ba7a072b4c8223492ee18b48551524d5c3449c5c8d3517212e":"":"":"af2c062fedb98ee599ae1f47fc202071" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #7 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"d08114670c4f6016a4cf9d2da3e3a674":"38dfbfb52c185acf74de00b5a50f0cd9688286747ab340cfe9ad30d38b390fd2443bfd7ea93941d8262ae0f66b0eab4ff64ba59a2ff940c3c26fda103e0d798dbcaa1318e842143975673af8408b5af48dfbaa56ca4f9ddc87100028b4a95549":"":"":"55030fef65c679ecaffb0dc070bfd4d2" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #8 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"e2af9abe8770e33798a5f05b22057d24":"88fb2a8020e604ea64a620f4704078857062cc97e24604c30de4c70cbf5e5bea0f0db79d16f4db636a2d6cd992c5890389a40cfe93967eac609e5b9f66788944285758547c7136ef2ee3b38724ed340d61763d0d5991ece4924bb72483b96945":"":"":"a44f0cfa383916811fffb2e0cfc9bfc3" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #9 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"ae30f1642753c5cb6e118d7ff5d59f1d":"340def3420b608420d81b4ea8252a3d86d3e1dd7597e6063ed923a73a7b8e981e6079f7f0c42deb9f4ef11d2f3581abadf44b06d882afdc47896777ce8dafd85ec040f7873d0e25c4be709c614a28b708e547266ac8f07f5fdb450d63bc0c999":"":"":"c7e7670145573581842bd1f3e0c6e90b" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #10 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"711ecfe467d6f83bcc82e566729669af":"21d6c822706d1af09e4d233c0ebac7f4ec60c7be2500dd41a85a19b2dc5c7da27f8a82164bd2a644218cb5ac283c547da1064784413eed5ecf32fadd00357abaae81225ac8d0391ead533362cff56798825445d639b0b45e0312aa7047c00b4d":"":"":"d3a0d2c457f5e9d1328a9e1d22b6eaf6" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #11 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"f9b22152bc0eff1ebf0bfafeea40aecf":"4ee32f0aeadb3936e17f1aa3b18c10f773def5f83500c2ba96f84408a2521c1258f6be9aa5cee528746629aa2b8118ac41dd98ef1b3de31d26b8c2ad3442081203f5ef21df409df3381fbf2e064fbaec64d731dc93b3218e34bb3b03bfd88373":"":"":"86009b14c4906a409abe6ca9b0718cbe" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #12 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"5174e76e904ff1471367ccace9c66ed9":"fa81535670275e8ab74121377cf88a4742dd0d7a99cf06eb9c2b4fe2b03423dbe441201144c22a9fc0ca49f5ef614987a2271cc1089d10ee01b25163c090a1f263797e4f130920cdc3b890a078e8abbb070ded2e8fd717f4389f06ff2c10d180":"":"":"18d6fcd35457d2678175df36df5e215d" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #13 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"73c372f60519e8eca371eaa13fb54f88":"930c290a797b85d58b52d0d92356436977b2f636f07d5a80c987fb7eea6b750cceb9eb87860547ab4029865a6810fc5c3663c4e369f290994461d2e9c7160a8b5985853bd9088b3e969f988fe6923b3994040eeee09ad353b969d58938237cfe":"":"":"f62c7cfbe74555744790bcc7930e03c3" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,0) #14 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"75ba8ddeef24f9f5b00b426a362c4f02":"7065d128ddb2fc6ea31f4110b6c0934ed112c51d74a4a0741a0843d8befac22902a01353322674c3d58935144a0f8f171a99dbeab71272ff7518c46cc7ebb573adbf95bff8ec68eeba5e8ec1221655aed8420086bda89c7de34f217dce73ccab":"":"":"700761857ea2763e8739b8f6f6481d1c" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"14051b57277bc3d3bbae51bdecfb9f5d":"82c80d922c47bbec0f664dd623e22a11a3b84d308351e45e30ee286e89547d22c43e17b3ca0fa08f77eef1001ba696932e9ee890e7aac4661c138e5b5ce36773d3120c35f8c94e0a78ffbf407a63ca435392e17c07461522fdc1f63f037aacff":"b70e7c1c4b8e0f1770e05b29a93f9d7a6540f23ab84136b05b161d85e5f19251":"5a737c128bd69f927f8f3ad68f93f6356d5f4ec0e36b6b50ced43dcd5c44dbc2":"a4e6c754194a09614994b36ecce33b55" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #1 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"4526b268128ea35f8558b4e1d08388f2":"952f3f179cbbda27ebd30f4fc31bf96baccb2adbaa9c090bc0f37044a44e85b3bc668cd3533faaf56b5da9242844d65733f7ac1f55c38b175749b88e18d19672b7bdab54e0ababdd4519fb07e0c25578f64ad40d0beb0a26275d5e2f4906aa70":"6b167c7cebea2e585ab974b60c4d305a113102ca8c3dc87651665728c4c675ad":"a038f1ca1f420eae449791f13be4901bfb91e41e052e02635b1f1817bd8969b1":"745ec376282e20fd1f9151f7040ed94a" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #2 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"c1aafa90f394e0ba9a528032dc6780d3":"75fd042bfd994de2c92e5aa505945ec93bd7cf366d86a356723fca3c9479ee17fb59c6ca8ba89784d43f06cdad113e5081e02427ee0714439d88dc1a6257fc91d99c1a15e92527847ab10883cc8f471cad8cf0882f5b6d33a846a00dee154012":"c704164ce80a400cb2f54d1b2d7efa20f32b699fa881bfc7b56cfd7c4bee1ea6":"f3baff4b6f42c8e75b70c2a72a027b14a99ae49a5a47c7af0f538843c94e1a69":"7af9113cd607cdb4c6534f401fe4e96c" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #3 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"e6e726b72e7b264a36ec0cd60d4578b5":"0c3c6dd706076d6484478347559b495d7ee898c39cde06027bc99f7bf69ce1140ca04602265e1308af6dd6446a1cf151749b22a99e8a05d30cc3ccd00e663bc1bc37e08ee62834fcc52a4bc8c1d6442544187484f81dc729417d5bedfcab5a54":"d84b978483c0bd8f8c231d92ea88ac21e6e667215804b15725a7ed32f7fc5dd7":"9a8971f6c559f7f197c73a94a92f957d1919ad305f4167c56fe729d50e5754a5":"e16ee5bceca30f1fbcadb5de2d7cfc42" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #4 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"0272d86db283244eb7ee0ed8c8054b89":"a08ce39f2f671e1f934821a8db9070f39a734a7a20e70307fccca17db15bb4e8a421600df11d1a6e7806a14826739322c8043649ea707180f1d00dea752c2c36398030519465864c4d38163f5b0dd5be07dbc0ae29693ad4a67ca69f28414634":"aa97055cf46ba26465dfb3ef1cf93191625c352768b2d8e34459499a27502e50":"dddd0007eb29fdf942220e920ca0637db4b91cbf898efd2696576ff6bfacb9d1":"9db0057e39ca6e0f16e79b4f8a0ed5c7" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #5 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"4ad8f72a0d0e28a758722b20e3017d7e":"89af36a1c53f730c1b818b26aa510627b17e6f9da51c8e53930de883b7cc7a3e8c3c463c910646ac3ff08f05bca8e340daf9a322d133ae453fdf7e6860a27ff4495c89875431ba9de3e4f3247cda8c62acc86f7066448f639d8ba8b5249337f8":"9d060b7ed63bdb59263c75ebe6a54bf3a4ac9c9926ca8fb49caa905a2651eead":"016099232dc44bb7cdb492f4955ab1aabc5dc0b5731447cea2eb1d92e41482d1":"4b658e95adae4bf0c418fded4431c27f" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #6 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"aa19b944c2e1b9d27933bc87322bdf14":"dc8c60dd42c85fed86cb32af035bbde5737526eb07991397c853256f2f0cb311bce70e1c5e32fc3510402d7d7e3de36fa5e584234daf391bc53cc651e001ab7fcf760679b3c82057f9d09bfdcab8e158d4daa63b20c0e1102f7a06bf5a2788dd":"6b98fec5f7de8098ff9df80f62473c73831edace832a767abf5965ea8bf789ba":"cc998bd5752f9c96ec35d9658cc8b3833dd6ab80c7accd6777c06c2cf7c01e59":"fc58833e0e27f7705e4937dd2aadb238" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #7 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"10c8c17a25041e2ef0d3cc80671e4cfe":"513fb96b6164ece801e52855aad28cb80131e7872d8432d27a974fb62d8d0100bb7ebcb8f5c066e230377a8847d6798c3d8090469b9719a80ac956ac33186b00eb8ca64c5530421f93932bc7c98ee92651e85dab562483bdb189676802726647":"240f36a0a598fe2116ffa682824f25acc35132f137f5221bc0ff05b501f5fd97":"22a5eb5aa00309a762ab60a8c2647eebe1083f8905104b5d375ed1661b4c8478":"145a16109ec39b0615a9916d07f0854e" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #8 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"cea0c3c12be683c0f27693650a6a3d7d":"df8bc70e45fe14abb02c1b9a9754c37497fc2f67709edd854196fc4d074b12797ce7cb292f14cb1d6904abf32bf229299db5ccf5a791a3b8cd3e40a64f38f6b57df759a863e09d7676d2f3ff2762cdab221151000dba32a67f38cab93d5b7a55":"bf2ac545d94e318066ff88f39791a8385e1a8539e99ac4fa5a6b97a4caead9d4":"846efef8672d256c63aa05a61de86a1bbc6950de8bfb9808d1c1066aef7f7d70":"8d8f0389d41adcac8ca7b61fc02409c3" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #9 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"1b782af2545352631983dc89945ffc37":"51930fb7095edef3fc20aca2a24127f03d3c4b983329e013ad8a35016f581dd7b2d11bafbf971c1fdefd95a0024195e6e90a60ec39b1a8dbe0cb0c3aabf9cf56b662efc722b2dffa6c3be651f199cbc3da2315b4d55aeafd1492283889e1c34f":"1b6295986f6fb55dc4c4c19a3dba41066fdc0297d50fb14e9501ba4378d662ed":"6e66ff63fc457014550b85210a18f00beab765f9e12aa16818f29d1449620d28":"78dfcb662736a831efaa592153a9aff9" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #10 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"6580f6df5c8de7c4a105c11ed44435c2":"d37403db6f84a7ba162e1cc351fe2e44d674ae8606280c9dac3e3975f30cbe1c9925e502a9804b91aada5cc97b259b90ccb5b8103394d9a28f0709fc9b5ffe9d73ad3672e02064ea68cebe3face5d823ee605c46c173db591135f564558dab4c":"97486a5e6ce6c6cf9d3f9a313d346cbc34b2bd54db80c5f8d74d6f6939f89519":"8377fcb52556f9974f1aa325d6e141d7b81355bd160abbc86e0007571b3c1904":"77031d3474303470dca9336b1692c504" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #11 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"f5303f148d6d6faca90aa88b07ab2ba9":"a0de51b8efa44b8245dba31d78f7840b2b7abced4e265b4cd9628eabc6ebbccb0f118dd8cc958b36dc959e22c4a03dafa212eeedec7d25ee6c5961187bee83b1ed3a75c7bdd9d0713b16cc67e68231f4cb274c8f3dfcc7e5d288c426a0d43b8f":"8d1fddc11dbad007e9b14679a5599e5e8a836197f14d010f3329d164c02d46d6":"9ceb6570568455d42a7397f8ca8b8af7a961a33a73770544cca563c04bc919ca":"9882f0bd1f6129a78b51d108e752b2d9" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #12 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"5a799c58985aa2898cc8fe8e5bc4a9f8":"dbdbef9d217e9051025c321b628c1cc823d508ffdd13fc4edbe8677658a57ef5b64395a6b7d62c0e93dc0956ee0217ec48ae054f1d4680023cc1b2af666efa9e1458cf6b0dae72eef2392e93687bd1fb5f366bb2cdd12937ad09724e39db4189":"8c179b35739e75719e74f7c3e038bc06eb3e212d6ade85275cfebf12b2dce2a2":"af617f2e228adde3edaf52a7e5979476dbb9cd2956a1737d93a16563bbbb4888":"49a04f3b4ef052747c7f4e77c91603e8" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #13 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"8f5b51983a8156a529f559ac3afebbf0":"bf22b182d39622e941017285adbdfe446c3d1a72601d0e5a15674f3b1b260170b1b2ab6b588a0267d86776a5d4ce80e132d7135a581af75ea6de65153680e28ce35ce78d0917b4932000d62260149e5a3ae72bc250548390b664f53c697dac45":"4cbb5b2d6e666d5dd3dd99b951ea435cae5a75d2e1eb41a48c775829b860e98b":"a4b4171c2592516404434932ad0a8ee67bd776a03479b507c406405b3d8962bc":"cab49631733f06e3fb3e0898e5ad22e7" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,0,256) #14 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"9f305a77cbaec1ab408cfc0eb89c6cbb":"1e50fada1e76a0d243e6f64c36a173ddc1f47a1dab834f5cd492568792958d5be22cce3110c8e8958b47f07b5c63f86b254942361d4d553e47d36103f47cd7f0bbee27d2e238b1d85671afe8284ee1fd2a431a5f69b2df73e95341c3a2e4fe4b":"c254f3b40e773eb09053b226820f68cafa3458ad403ad36f715245a854752a93":"699e177b7be3353c45ce7b7a0d573b00087d700a9f2c1cd2e370e05d4ddadc86":"bb6b02b25a496f29245315f58a16febc" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"e09f65dcffc0d3a4d84bacc41617a4e46ce5184eca011049ab657566f728e4aa28315ffac166ebe50e1269b01c95b3a2":"545a783ae97d827ed0b81d9752ad0f7e965f511b1f5dae0f872e9ec37cfe63af86c1d15e153887989b605773b16ad5505e65f617cfa8ef46547c4c3f9d0c4fd0b6e1cff5ca0f1929266fe43ba8f45ad664cfe5e90903a9cb722b42ae8989c148":"":"":"1e77d7cc18775fef9a3d3e00903da01b" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #1 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"056cd44c8847d89da05fbef95e9660d589046b0c02f9b42c17fd8b069f831c73cd896005ec080113589b6f07be6e42ea":"dde6c0850fe642602eb222ca7371213c598cef8c3e71e0593ea8edb54e1bed130b9b0aebe0893093b950c52f56eb9b338aa4bd01dae030515726ece1bf751660b4a3602da6400e4b94edebba646b5c3d4e64ceea1c4f14b7a19f0142783247df":"":"":"a790ab939e63555d02ea1e9696051725" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #2 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"73c72c7dfe138ef4b9817d41b9722b3940762b59bda26b3f6bb8b30583e01d088a29726b71d36ffeebdb387010cb1bb6":"6fe09520e26f5abece0fceadc54913c650a9f55725af45a9a5f373d09b9970b8706b9041d0189a204f6a4eb527dfa86584a3bee3265b809c3932ae5e7228194a3cf7592fc9301c833b45a53be32b9caec9f0f91ba86519f12b0b235f68419c1e":"":"":"798d997f46ff7cc4206994085340325e" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #3 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"cdba7c7033c34852b7bc1a6b33edab36f41d563bd0395d1001c02ffc0c42ec8595ed2b5ddabc923372e3b6bb457833fa":"532960c23c8c8b2146576dde52fadc985134914abf42ca1c5f47206937fda41289ae5d9f935dc4ce45f77cad230a4f345599e3bae4071188324483a0b93593c96d8b6ac6c0d8b52f8795c44171f0d8cd0b1e85dc75ce8abe65d5f25460166ba0":"":"":"9d48160aca60f1a82baaa8a7d804a3d8" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #4 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"02cef01aca992f60aa12db4b2c441689e4972a6f9deaf3663082afed642c1502b67b42d490af1c52c7e6eaf459882eca":"9216c9a833f81953792260a688eb7c3dfc85565ae6a6033203741a763db056247808e0ecd5ba1fc4549c3a757eba535adc786e810ddaae9a2714d31f5154f2c3ee81108669f1239f4f4efd6e18aabfa2d88f0ac25f4740108f6cfebffeb2d857":"":"":"d6378bcf43be1ad42da83780c1dab314" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #5 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"d7d80084e9d1fbb9315c3bce1510dbf22cf11fa54177d913a3b04b64cb30957395bd6f3d7e3d866d1be41b29db9ed81d":"80d4741e4e646748bb65e1289f1f9b3c21bffec4d0a666b301f199d76b4a83464583057079b069946b03d6ac81ebf9e6fa8d4081120f18bf58286a0c4de7576f36f3c7c353126f481a065ac28bdf28e13cd0c1e7911db6343c47d613f1750dc6":"":"":"9165a92ed92248b2d237d9f46d39bde8" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #6 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"df5a68d3bede467fd69716f5f8fbac297594b8573921afb864ba76aaa6dd89e83b89e359a5a0dd1aac9b4acb9573d218":"52df6336f93781115c2a77bd8f99cb717871fe14707947a21f6093dd9205bc378acf61329f8831369b4b1af0a9edfb25d74f5863f26859ad9c920767b113c47ed2690053bf9a2f7c7a67a8d680e08865720b9e9f7b6ae697e3c93e66f24b6ddc":"":"":"c542cf248a163bbceee7b9f1453bd90b" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #7 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"2945527372ff71edfa5776f55f7e4a247544aa6de974e81b2eba5552843ab6dfa248695f4f3225a43d4bf3672c3a6b2e":"aa560af2132cbd0624a69c7a7e733cd59a4f2d4e61d2b830087bd88f30fa792c7e4d3168fa86a10f7619d5b9dcf4f7bb08b350ba6a6bfc0fdfb7ee7aca07260c9a11abe49963c36efaefa94d2978ed09472bf93cc873d0f24c000762bb1402cd":"":"":"33af0134eeca279dce5e69c2cda3f3f4" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #8 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"b30cb767125674f6099a5cf7cb2e4f5b6c1cd1e32ffc1e393b1c5698b52b37f971f12521a7c1ffaaf3233d5391bc4c86":"2d42b00248d95d9378a2aece40d636bc1ab22edaaa64daa34335195a9efa4c1b58f13ac184ca2be52e15c3a977abde2aa505243fc106c4ea6f0671fe0f209b106ea8965645af73d8ebb8a80251db2967149c701cfe1d157cc189b03bf1bff1ac":"":"":"1e10eff9ceebc7e5f66e5213cb07fca4" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #9 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"c962a2da4524f08adcdd5ceddc04e669ad6154aee06164645e80c832506b98f9919451c7ec1d3a6a9704f83def8f6e2d":"a1ff68a85e437475b1b518821dbaac1730071a4ddd3255361778194fb0cfe3293e38df81527d8b8da15d03acb26467b6b53d7952441b79f95b633f4a979d998fd0417b9193023288b657d30c0cb2dada264addf9d13f1f8ed10b74e2dd2b56b3":"":"":"58990069b72b7557c234d5caf4334853" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #10 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"a3cc1fe561d03a055e8eedaa0e713be490c4bd4c6839a5b98c2ac0139bf215bdc46783d2a3e6b9d15d9b7a8bfe15104b":"207267911c12125cb3012230e4fafd257777ccbfb91653f77e4c1287574f9b79d81af7fb304790349dd457983cc99b48d5f4677ccd979fcc6e545cbf5b5c8b98102c9a89ae354349dbdee31a362d47c7cdae128034c0f4c3e71e298fe1af33c6":"":"":"ffd1d259acd79111a6fb508181272831" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #11 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"ecf186071b81e0ed384d4ebfb5bf261b4054e2e6072b51d21dfb6817adc51ff1c8956ff3612767538cdc8d73fade78b3":"3b9aec9f8bf8495004c5e4e731e5c347988e787caf003f001e68584e3510a6abdedffa15895702c2d57c304300f4f0af80a89bcc36b3cea2f08a0740236b80cfd2ea6e5cfe4144bc4ae09270fb6bc58c313dbaaedc16d643fc0565171f963222":"":"":"a2d917f5ec39a090b55d51713006e49d" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #12 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"3fcedba86089709aa638d00713150df781d4a93e85f155338e90ff537bcbf017f37a2d62259f5d8cc40ddfb041592539":"6b1e9d45c2ec598de7527b6414a339f26192fc4e3f5eff4b3a3e2a80ee0f2e9743031804d1be12b3c7ff6fbc222db1d97226890addeef0e1579a860e2279292c2f769416b7068f582f6ffc192ae4c4f1eeb41d5f77f0a612b059c47aef8e3d8e":"":"":"aa414799c51957de97c0070fb00eb919" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #13 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"f4c45fb8f58b7ebf73a0cd81c6a26686977558d4b8bf1cedfc6bd3754de6aaed5008fd72208437c54d8feb9a16ce3224":"6d170cf472ea07da6146a7087ed15d3f5b6ad72b8c99e46bae3b89e49a6e63467199ee16096516c2362dbd181bf5343a29fd0932d72eeb019fc3bfea3a3b01ffc2b985e341cfb6479d9dc71e2197b5cffc402587182e5fe93b5a8cf75eac2e42":"":"":"f557f627688fe63c119cf0f25274aa74" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,0) #14 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"7120742a7807b66c5a9b50995d5494a5b9451bb795393c0d8a30ae665879269408f8297d49ab87410a7f16a65a54b1cb":"c08a6f9797ea668cd14ba6338cb5d23c0921e637e66a96259f78e33e45aafd035edb44394cb459453b9b48beac1e32d3b6f281473cda42fb6fd6c6b9858e7a4143d81bfc2faf4ef4b632c473be50a87b982815be589a91ca750dc875a0808b89":"":"":"521973eac38e81de4e41ccc35db6193d" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"add2bbbab76589c3216c55332b36ffa46ecae72072d3845a32d34b2472c4632b9d12240c23268e8316370bd1064f686d":"6168fc1af0b5956b85099b743f1378493b85ec93133ba94f96ab2ce4c88fdd6a0b23afdff162d7d34397f87704a84220bdf60fc1172f9f54bb561786680ebaa9bf6c592a0d440fae9a5e0373d8a6e1cf25613824869e53e8a4df56f406079c0f":"7e084abbe3217cc923d2f8b07398ba847423ab068ae222d37bce9bd24a76b8de":"946bc99fab8dc5ec71881d008c8968e4c8077736176d7978c7064e99042829c3":"224ab4b8b6ee7db19ec9f9a0d9e29700" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #1 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"8964ebde61f0c4e23f8e91244ae9682ed0b17e424edd4c025b461a2d209a538583f29465df3f89cf04f703b771ff5c90":"4db8e8a27fe7a0378e37d4cc01b6a465d34be91f48c52fdc1023ef2ea1241082f522805bc8777fda6c10e3d441b58f648edcd7d4df3df8c8a398d7b005c4fd6f41c9b033bd38fc5f577069251529b58273f6a9175feb3978798fdeb78a043232":"5eb3fb44784f181852d80fcf7c2e3b8414ae797f7b9b013b59cf86b9d3a19006":"3eec358f7f9e789e4ad5a78dd73987addbf3ae5b06d826cec2d54425289dc9af":"9a66c015d2550e3f78c44b901075fabb" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #2 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"98784aa794df5400890e6803f06d886aeb0833b1fea28a5f7952397aa21092ceafdb9194079f3609bc68233147c778e7":"7338521e8e127e70da259b37f5f5cdf83079bdb4024234b8ceecfba8d8c3f1c8510ff91f3bd08f2c54f11b534048a320a15ba0fccec8da34d4ef7f49ade4847814c859831907992d0adab27046324d4d9a853eb986b8de25b34ea74eb3d11048":"b14c5314aac11cb43f45730e474b84fbf5d1480d94d0699b80e3570f6636aa72":"d6208912348236feee1d258092283dd9db75899769dd109cc2f0f26d88dcc6bf":"5ec75fdd1ed3a742328e11344784b681" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #3 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"fe9b7df306c4ccd02afd6142c6650418325617945147de436a55e78aa45866116d6678e013a0e2c5a13e0d01fbd84039":"c4da56f4239fde0bc49b1d852cb36c80205f9e99e5995a80be04bbbba15f25b8d054c397a34cff1326a71f0acc4f7942795cabc3fa46339dc54b4bf7f11c095af8503004d97c485acec8815d1404674592c896ecfabefcbf222f4fe5a3ced0af":"086d09a6ee20c69bf5c054ebc6250f06097c8da1a932fb3d4b1fb5f40af6268a":"44e64b14c49ebb75c536329bb41ab198848849ca121c960db99f7b26330b1f6d":"7aa3a7e159d194399fc8ef9eb531a704" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #4 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"c0d47ee2328185df2c299d270e11fee26df753a5b4f899fdc0dff79eb50748232f9f79cf3f5e9bd4a26a48e743843b02":"a6b5dd5f1bad95331caae5852be50a26267af655c98feb8b66c45a8ae2ddfca270ab0d8023e43e6e22a7b5904d63482f045e85556b9c105cde0f3eb7b1fff1026086c80b195196803b5f664362b659578894d6551fb7c4566eec02202fdc298f":"3b575d028046e7f6005dfcdfcdcf03ff77a9cacd2516bcdff7f3601a9a951317":"f13b58daed46f5bf3c62b518ab5c508dd2bc3e33d132939049421ff29c31c4f0":"8469dfa89453d1481abedd6cc62e4e44" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #5 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"a0db812a939fbf3942b00be018cff4578b9fb62629c766a50f3518fe634100b1cbc4244ae843fe32125c53b653705457":"7e3dca20a7a977b6616a684e309015cf6a37edd0d85819fe91d074c915b0c9540a8aa486f58685b064851d6164150b1c1b0e2e545c6358d28b2f5263b2fd12c503d271ab6de76d4fa4c604cae469335840328008d8ce5545586b9ea6b21da4f9":"554b297bc32866a52884fabfc6d837690de30467b8f9158b258869e6f4ed0831":"4f688cba5908e0699b33b508847f7dac32f233e6f02cf093efdacae74259f3b6":"9696dd6ed5875cdef4a918a6686455a8" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #6 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"ff6cd20443a32c9e938f2a617bbb969ba54040b12723b0d452a669b584ba16ffaacbe38af62b5a62e0c67d165d022344":"efcf7536f32932526fe82b3a2333508404727878723fc09cbd902581d82463cf6acf1ddf4217ea6404469193e8db0e7e8c864ae655b49c6a095f80f1ab16985453f0fb729c119d8a3b820034626a93b1f70eb99b6cd8c990dda34a1c6a4b6eea":"8d412208091b987ee0781ff679c50dbab9ef389156f570f27aaf3e699bdade48":"501381ce5e7718c92ee73e9c247965dd5f0bbde013c4b5e625e9af8907e40566":"4f323934adb8a2096f17d5c4d7444078" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #7 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"bd14779153ed9696d3e5143c50b2050b6acd3ea2f8b670ef0e5f4bedf01705727bf9e64ae859214abe6ef497163f0236":"bfb0931b05a3fe232614e1b1c3060b3b07fb75d23ac10190a47a7245a6ecad5f3834e6727b75acc37e9d512d01a4a9cef6cb17eb97e4d1d7c1df572296972f0437a89c19894f721cbe085cf3b89767291a82b999bf3925357d860f181a3681ce":"0b5dc1cdfc40cfdc225798da773411dc9a8779316ceb18d1e8f13809466c6366":"843eb7297570e536b5760c3158adb27c0c426c77d798c08314f53b59aa72d08b":"1e703f3122455a40536c39f9ea3ceaa6" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #8 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"64b155fd4b8634663a7e8a602e2b9fe2477be74692643ccfd0b316a025ea6f1fc0dfd0833248cb011082be36cba3c5d1":"a5b15cb1e039d7bbe2db80a32d4f402c7d3c59a45b05255401d1122770dbdb9894841964d5cadc9ae9af007d63e870d0510078885ca402bd222f16d2d27892e23292b65cf370b15d5e5a739ddd13e3e27f7c2e2b945f8e21897c3bbf05d8b043":"aea2fe995be77dfdca6ebaa1c05ba4c84d0e6b9a87905c398a3dfe08aeb26d38":"f4e9e7eb0eea4e2d419de6ad2909d36ec06c79097884bf98981e86dedae366ba":"4a28955dc97936b1c0aed0751a1afed5" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #9 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"e6c08e8b8d8e418477087911610096f7e0422083a376a77198e9c60fb2dc8c14aff33d7835878b65322f1561738b1ebb":"d4e0347c2158b882eb1e165f7f2aa1324d6606fe259ca730b2a3367435cb93b89108e49bd97355215063f63e78e8926b264c8a97571fd4d55882364915b7bd544254c25c2b67cdd979737c7811bcdeef5b052d8fe05a89b3291ef669d5579a61":"6607541177bc0c5f278c11cb2dcb187fc9f2c9a9e8eefa657ba92dee12d84b07":"7a439c8593b927867cfa853949e592baea0eeb394b0e2fe9ab0876243b7e11e2":"420888122f2e0334757c4af87bbc28a4" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #10 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"4413ff775c9b7d9a3003e0b727e34554e0f615471d52aeb4a059777b372d60332a1a4bcaf906e598581bc5a369b2c933":"a21cf567362fed0edddfd0b1c2d85ff6d2db5484fca8bf90a82da2ab76efcac9286e417628496f37effda150ef4912125aac68aac72e6f900a70192d4ef0b4cc4e9419c93ffb245965ae30c5f8abe20f732d76080bde5a1c6b3f075eb35622d1":"b924d145fc3ecd76f000f12638ef0a49a5d4cf887aa93fc9e5c536febc454f2d":"73dbb40b257e6598744f9107c8e7ff51a080407fc9e80d39d9a4db94f167c116":"84457ea753771ad7c97ce9c03ab08f43" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #11 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"5e409d56afb6940f9ffa45e0f92ef4972acedd3557b8e0f5418e302f2720ae5289294176045ad3096ea68db634cf5597":"c5a63c886af7ed7496473a6ae2f27f056c7e61c9aca8c5d095af11b2efe1a6b43344f92b37c7b6977ddbef1273e9511d9305fcbe7f32bc6a62f28d34841350362d2717dd00467224a35985b9fecc2739acd198743849dbfa97f458e2e7d6b1dc":"7fda133a23e929b17548a05013ff9c7085c5af9c979057b8f961ba7514509ff3":"bd061292b6bc3d3e71ed01af091f0169f70f23862efccd9e76345ff607dff3ec":"75b35dab3ad5e35c10ee39529a7f840f" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #12 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"ed2a52169791d7c7d332cf258ea4847c359335f9a6839ee767a8f76800ba28e94858cc9b7f526e62a93603fa2b1caa6b":"0a6155ff422ff6ae9814f81bf353bd3454d0c9892f9f3d730dcd8c87626f813cbe1dff1922fe73e4a319be53f4ec05e965c27f239b1e51869069a7e7cdd916fc1fd6f640bfe4b761a8040f8db37fb5ee7508e7d226c7695fb2a8bd791fe49ef2":"14073a1b4f07f3b594fa43d0c8781b8089dd2d9b8ad266e0321aaa6b71a0d058":"4247fc6886e8657b84369cf14469b42aa371d57d27093ee724f87bf20fa9e4e6":"f2aea2bc23e7c70f4ee2f7b60c59d24d" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #13 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"f0d3a46501da7ab23d8688725f53f4289ce3bfa627646fe301533ec585f866caafb8131e95460566270f68cd25e1f153":"223d49f99a56cfcf2eb8cca39a8a82ee306c6272d521257f3d7d2a87699111e442fc55a399994d57373141f2207d43a8bbc1e086d67343b7dc2a891853c860fe43fb6be32cf035aca582bf5590cb5001b09b4976ea617fa7bd56da81fdef2df9":"7d12673cad5ad5003400fb94547e2b987e934acf6b930c0e7aec72634bfb8388":"e8583b9983b3ac589a6bb7a8405edfc05d7aa5874a8643f9ac30a3d8945a9f96":"ce72c0ea0e76be6bc82331c9bddd7ffb" CTR_DRBG NIST Validation (AES-256 use df,True,256,128,256,256) #14 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_validate_pr:"1e4644df1d01f9a0f31d1d0c67bc9fb9a1ee2223fbfb25520d3881cde2b183b73fe1a8cc5f17796cf22aaaed57607420":"cdac62b5e4ccee8609b1f4b7a8733e69068c71219b6292ecb318b9d3479516807af280cfa20e455d5e96eb6794a3b963957f3c099fd1e1199706d36a06011836af890f3b7b15cda6346a06fdd0f194de40bfbec12b021b02eeabaa34d35b30a3":"8169251ea55cce534c6efd0e8a2956d32ed73be71d12477cea8e0f1ab8251b50":"865d14cb37dd160a3f02f56ac32738f9e350da9e789a1f280ee7b7961ec918a7":"ff11ba8349daa9b9c87cf6ab4c2adfd7" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #0 -ctr_drbg_validate_nopr:"1b54b8ff0642bff521f15c1c0b665f3f":"5a194d5e2b31581454def675fb7958fec7db873e5689fc9d03217c68d8033820f9e65e04d856f3a9c44a4cbdc1d00846f5983d771c1b137e4e0f9d8ef409f92e":"":"":"":"a054303d8a7ea9889d903e077c6f218f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1b54b8ff0642bff521f15c1c0b665f3f":"5a194d5e2b31581454def675fb7958fec7db873e5689fc9d03217c68d8033820f9e65e04d856f3a9c44a4cbdc1d00846f5983d771c1b137e4e0f9d8ef409f92e":"":"":"":"a054303d8a7ea9889d903e077c6f218f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #1 -ctr_drbg_validate_nopr:"90bc3b555b9d6b6aeb1774a583f98cad":"93b7055d7888ae234bfb431e379069d00ae810fbd48f2e06c204beae3b0bfaf091d1d0e853525ead0e7f79abb0f0bf68064576339c3585cfd6d9b55d4f39278d":"":"":"":"aaf27fc2bf64b0320dd3564bb9b03377" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"90bc3b555b9d6b6aeb1774a583f98cad":"93b7055d7888ae234bfb431e379069d00ae810fbd48f2e06c204beae3b0bfaf091d1d0e853525ead0e7f79abb0f0bf68064576339c3585cfd6d9b55d4f39278d":"":"":"":"aaf27fc2bf64b0320dd3564bb9b03377" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #2 -ctr_drbg_validate_nopr:"4a2a7dcbde58b8b3c3f4697beb67bba2":"58364ceefad37581c518b7d42ac4f9aae22befd84cbc986c08d1fb20d3bd2400a899bafd470278fad8f0a50f8490af29f938471b4075654fda577dad20fa01ca":"":"":"":"20c5117a8aca72ee5ab91468daf44f29" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"4a2a7dcbde58b8b3c3f4697beb67bba2":"58364ceefad37581c518b7d42ac4f9aae22befd84cbc986c08d1fb20d3bd2400a899bafd470278fad8f0a50f8490af29f938471b4075654fda577dad20fa01ca":"":"":"":"20c5117a8aca72ee5ab91468daf44f29" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #3 -ctr_drbg_validate_nopr:"911faab1347ae2b3093a607c8bc77bfe":"2f044b8651e1c9d99317084cc6c4fa1f502dd62466a57d4b88bc0d703cabc562708201ac19cdb5cf918fae29c009fb1a2cf42fd714cc9a53ca5acb715482456a":"":"":"":"aae0c0ac97f53d222b83578a2b3dd05d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"911faab1347ae2b3093a607c8bc77bfe":"2f044b8651e1c9d99317084cc6c4fa1f502dd62466a57d4b88bc0d703cabc562708201ac19cdb5cf918fae29c009fb1a2cf42fd714cc9a53ca5acb715482456a":"":"":"":"aae0c0ac97f53d222b83578a2b3dd05d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #4 -ctr_drbg_validate_nopr:"f959f1bc100ae30088017fae51289d8e":"77d0f0efbc7ca794a51dff96e85b8e7dfd4875fbfb6e5593ae17908bfbddc313e051cb7d659c838180d834fdd987ae3c7f605aaa1b3a936575384b002a35dd98":"":"":"":"5d80bc3fffa42b89ccb390e8447e33e5" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"f959f1bc100ae30088017fae51289d8e":"77d0f0efbc7ca794a51dff96e85b8e7dfd4875fbfb6e5593ae17908bfbddc313e051cb7d659c838180d834fdd987ae3c7f605aaa1b3a936575384b002a35dd98":"":"":"":"5d80bc3fffa42b89ccb390e8447e33e5" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #5 -ctr_drbg_validate_nopr:"45a8bb33062783eede09b05a35bd44dd":"6bb14dc34f669759f8fa5453c4899eb5ac4e33a69e35e89b19a46dbd0888429d1367f7f3191e911b3b355b6e3b2426e242ef4140ddcc9676371101209662f253":"":"":"":"0dfa9955a13a9c57a3546a04108b8e9e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"45a8bb33062783eede09b05a35bd44dd":"6bb14dc34f669759f8fa5453c4899eb5ac4e33a69e35e89b19a46dbd0888429d1367f7f3191e911b3b355b6e3b2426e242ef4140ddcc9676371101209662f253":"":"":"":"0dfa9955a13a9c57a3546a04108b8e9e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #6 -ctr_drbg_validate_nopr:"0ada129f9948073d628c11274cec3f69":"b3d01bcb1ec747fdb7feb5a7de92807afa4338aba1c81ce1eb50955e125af46b19aed891366ec0f70b079037a5aeb33f07f4c894fdcda3ff41e2867ace1aa05c":"":"":"":"f34710c9ebf9d5aaa5f797fd85a1c413" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0ada129f9948073d628c11274cec3f69":"b3d01bcb1ec747fdb7feb5a7de92807afa4338aba1c81ce1eb50955e125af46b19aed891366ec0f70b079037a5aeb33f07f4c894fdcda3ff41e2867ace1aa05c":"":"":"":"f34710c9ebf9d5aaa5f797fd85a1c413" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #7 -ctr_drbg_validate_nopr:"052a5ad4cd38de90e5d3c2fc430fa51e":"98482e58e44b8e4a6b09fa02c05fcc491da03a479a7fad13a83b6080d30b3b255e01a43568a9d6dd5cecf99b0ce9fd594d69eff8fa88159b2da24c33ba81a14d":"":"":"":"3f55144eec263aed50f9c9a641538e55" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"052a5ad4cd38de90e5d3c2fc430fa51e":"98482e58e44b8e4a6b09fa02c05fcc491da03a479a7fad13a83b6080d30b3b255e01a43568a9d6dd5cecf99b0ce9fd594d69eff8fa88159b2da24c33ba81a14d":"":"":"":"3f55144eec263aed50f9c9a641538e55" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #8 -ctr_drbg_validate_nopr:"004cd2f28f083d1cee68975d5cbbbe4f":"6238d448015e86aa16af62cdc287f1c17b78a79809fa00b8c655e06715cd2b935bf4df966e3ec1f14b28cc1d080f882a7215e258430c91a4a0a2aa98d7cd8053":"":"":"":"b137119dbbd9d752a8dfceec05b884b6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"004cd2f28f083d1cee68975d5cbbbe4f":"6238d448015e86aa16af62cdc287f1c17b78a79809fa00b8c655e06715cd2b935bf4df966e3ec1f14b28cc1d080f882a7215e258430c91a4a0a2aa98d7cd8053":"":"":"":"b137119dbbd9d752a8dfceec05b884b6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #9 -ctr_drbg_validate_nopr:"f985b3ea2d8b15db26a71895a2ff57cd":"50d3c4ecb1d6e95aebb87e9e8a5c869c11fb945dfad2e45ee90fb61931fcedd47d6005aa5df24bb9efc11bbb96bb21065d44e2532a1e17493f974a4bf8f8b580":"":"":"":"eb419628fbc441ae6a03e26aeecb34a6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"f985b3ea2d8b15db26a71895a2ff57cd":"50d3c4ecb1d6e95aebb87e9e8a5c869c11fb945dfad2e45ee90fb61931fcedd47d6005aa5df24bb9efc11bbb96bb21065d44e2532a1e17493f974a4bf8f8b580":"":"":"":"eb419628fbc441ae6a03e26aeecb34a6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #10 -ctr_drbg_validate_nopr:"100f196991b6e96f8b96a3456f6e2baf":"d27cbeac39a6c899938197f0e61dc90be3a3a20fa5c5e1f7a76adde00598e59555c1e9fd102d4b52e1ae9fb004be8944bad85c58e341d1bee014057da98eb3bc":"":"":"":"e3e09d0ed827e4f24a20553fd1087c9d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"100f196991b6e96f8b96a3456f6e2baf":"d27cbeac39a6c899938197f0e61dc90be3a3a20fa5c5e1f7a76adde00598e59555c1e9fd102d4b52e1ae9fb004be8944bad85c58e341d1bee014057da98eb3bc":"":"":"":"e3e09d0ed827e4f24a20553fd1087c9d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #11 -ctr_drbg_validate_nopr:"88f55d9ba8fef7828483298321133fec":"16f9f5354d624c5ab1f82c750e05f51f2a2eeca7e5b774fd96148ddba3b38d34ba7f1472567c52087252480d305ad1c69e4aac8472a154ae03511d0e8aac905a":"":"":"":"07cd821012ef03f16d8510c23b86baf3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"88f55d9ba8fef7828483298321133fec":"16f9f5354d624c5ab1f82c750e05f51f2a2eeca7e5b774fd96148ddba3b38d34ba7f1472567c52087252480d305ad1c69e4aac8472a154ae03511d0e8aac905a":"":"":"":"07cd821012ef03f16d8510c23b86baf3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #12 -ctr_drbg_validate_nopr:"126479abd70b25acd891e1c4c92044f9":"70afbc83bf9ff09535d6f0ddc51278ad7909f11e6f198b59132c9e269deb41ba901c62346283e293b8714fd3241ae870f974ff33c35f9aff05144be039d24e50":"":"":"":"0f90df350741d88552a5b03b6488e9fb" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"126479abd70b25acd891e1c4c92044f9":"70afbc83bf9ff09535d6f0ddc51278ad7909f11e6f198b59132c9e269deb41ba901c62346283e293b8714fd3241ae870f974ff33c35f9aff05144be039d24e50":"":"":"":"0f90df350741d88552a5b03b6488e9fb" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #13 -ctr_drbg_validate_nopr:"a45f2fca553089fe04e7832059dc7976":"5e5a9e1e3cb80738c238464ede1b6b6a321261a3b006a98a79265ad1f635573bba48dccf17b12f6868478252f556b77c3ec57a3bf6bb6599429453db2d050352":"":"":"":"6eb85ae2406c43814b687f74f4e942bc" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a45f2fca553089fe04e7832059dc7976":"5e5a9e1e3cb80738c238464ede1b6b6a321261a3b006a98a79265ad1f635573bba48dccf17b12f6868478252f556b77c3ec57a3bf6bb6599429453db2d050352":"":"":"":"6eb85ae2406c43814b687f74f4e942bc" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #14 -ctr_drbg_validate_nopr:"52dbb43241002415966eaec2615aba27":"31cfe60e5ed12ff37d7f2270963def598726320c02b910b5c6c795e2209b4b4a95866c64cb097af1d6404d1e6182edf9600e1855345375b201801d6f4c4e4b32":"":"":"":"2a270f5ef815665ddd07527c48719ab1" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"52dbb43241002415966eaec2615aba27":"31cfe60e5ed12ff37d7f2270963def598726320c02b910b5c6c795e2209b4b4a95866c64cb097af1d6404d1e6182edf9600e1855345375b201801d6f4c4e4b32":"":"":"":"2a270f5ef815665ddd07527c48719ab1" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #0 -ctr_drbg_validate_nopr:"176200bb44808b5400b24e1b5f56cf73":"f84d395b1734eac4600dbc36f6b1e1599bc7f2608dc8ecb3a55369d7b1b122a09f5ac9c16d9a2be37d2ff70a9bba732fc3785b23ff4ade3c8404da3f09f95a8f":"aef28c9169e9af74c73432d4aa6f5dff9ea4a53433de2ecb9bf380a8868c86e1":"0626ae19763c5313b627a8d65cf1cfba46dfd6773242738b9b81fde8d566ade1":"63c160ed6a6c1fffd0586f52fa488a9055533930b36d4fa5ea3467cda9ffe198":"e8f91633725d786081625fb99336a993" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"176200bb44808b5400b24e1b5f56cf73":"f84d395b1734eac4600dbc36f6b1e1599bc7f2608dc8ecb3a55369d7b1b122a09f5ac9c16d9a2be37d2ff70a9bba732fc3785b23ff4ade3c8404da3f09f95a8f":"aef28c9169e9af74c73432d4aa6f5dff9ea4a53433de2ecb9bf380a8868c86e1":"0626ae19763c5313b627a8d65cf1cfba46dfd6773242738b9b81fde8d566ade1":"63c160ed6a6c1fffd0586f52fa488a9055533930b36d4fa5ea3467cda9ffe198":"e8f91633725d786081625fb99336a993" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #1 -ctr_drbg_validate_nopr:"19c3d16197ac93bf58c4110c9e864804":"50755cc0178c68ae70befd7744f6f1e3f6a59b3bbe484a744436079c7fae8d83c4965516fb952c63e1d0561d92cccc56037465815c9e549c9adce4a064877128":"5cb82d2c297404f3db1909480c597dd081d94ca282ba9370786a50f3cbab6a9b":"96d130faf1a971920c2bf57bcd6c02d5a4af7d3c840706081e4a50e55f38bf96":"1b0d04f179690a30d501e8f6f82201dbab6d972ece2a0edfb5ca66a8c9bcf47d":"4628b26492e5cb3b21956d4160f0b911" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"19c3d16197ac93bf58c4110c9e864804":"50755cc0178c68ae70befd7744f6f1e3f6a59b3bbe484a744436079c7fae8d83c4965516fb952c63e1d0561d92cccc56037465815c9e549c9adce4a064877128":"5cb82d2c297404f3db1909480c597dd081d94ca282ba9370786a50f3cbab6a9b":"96d130faf1a971920c2bf57bcd6c02d5a4af7d3c840706081e4a50e55f38bf96":"1b0d04f179690a30d501e8f6f82201dbab6d972ece2a0edfb5ca66a8c9bcf47d":"4628b26492e5cb3b21956d4160f0b911" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #2 -ctr_drbg_validate_nopr:"4b1edd0f53bf4e012def80efd740140b":"e50c31ebbb735c4a53fc0535647ae1fff7a5ac4fa4068ba90f1fa03ca4ddedecd5b1898d5e38185054b0de7e348034b57067a82a478b0057e0c46de4a7280cd9":"e7154ec1f7ac369d0bd41238f603b5315314d1dc82f71191de9e74364226eb09":"9444238bd27c45128a25d55e0734d3adafecccb2c24abdaa50ac2ca479c3830b":"ab2488c8b7e819d8ce5ec1ffb77efc770453970d6b852b496426d5db05c03947":"a488a87c04eb1c7586b8141ed45e7761" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"4b1edd0f53bf4e012def80efd740140b":"e50c31ebbb735c4a53fc0535647ae1fff7a5ac4fa4068ba90f1fa03ca4ddedecd5b1898d5e38185054b0de7e348034b57067a82a478b0057e0c46de4a7280cd9":"e7154ec1f7ac369d0bd41238f603b5315314d1dc82f71191de9e74364226eb09":"9444238bd27c45128a25d55e0734d3adafecccb2c24abdaa50ac2ca479c3830b":"ab2488c8b7e819d8ce5ec1ffb77efc770453970d6b852b496426d5db05c03947":"a488a87c04eb1c7586b8141ed45e7761" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #3 -ctr_drbg_validate_nopr:"1f89c914649ae8a234c0e9230f3460f9":"5e029c173dc28ab19851a8db008efbcf862f4187fca84e4e6f5ba686e3005dba5b95c5a0bcf78fb35ada347af58ec0aca09ed4799cd8a734739f3c425273e441":"b51f5fd5888552af0e9b667c2750c79106ce37c00c850afbe3776746d8c3bce1":"9b132a2cbffb8407aa06954ae6ebee265f986666757b5453601207e0cbb4871b":"f1c435e2ebf083a222218ee4602263872a2d3e097b536a8cc32a5a2220b8065f":"a065cc203881254ca81bd9595515e705" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1f89c914649ae8a234c0e9230f3460f9":"5e029c173dc28ab19851a8db008efbcf862f4187fca84e4e6f5ba686e3005dba5b95c5a0bcf78fb35ada347af58ec0aca09ed4799cd8a734739f3c425273e441":"b51f5fd5888552af0e9b667c2750c79106ce37c00c850afbe3776746d8c3bce1":"9b132a2cbffb8407aa06954ae6ebee265f986666757b5453601207e0cbb4871b":"f1c435e2ebf083a222218ee4602263872a2d3e097b536a8cc32a5a2220b8065f":"a065cc203881254ca81bd9595515e705" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #4 -ctr_drbg_validate_nopr:"0ef2be2d00a16051404fc2a0faa74fdc":"b66c882ae02c5215ed3bcd9e9a40934b09bf48a15fe7558c9d9ceb0ebec63625ea18f7c3ab341d9f7edd8e1d8816edecb34dbd71ae02771327b5ebc74613dadd":"1ebe9893957a5c4a707793906d31bb201e88d88a22abd6baa6461fc61def7ffb":"f81e26744834413cb95af8d438d0050c7c968f929a33e35ee5c6715a0a520950":"687a848b2b6c715a0e613b3f3bb16cf2f056543eb9dd6b8aee8de8aa6fd8a1e6":"a6c4a7e99d08cc847ac0b8c8bcf22ec0" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0ef2be2d00a16051404fc2a0faa74fdc":"b66c882ae02c5215ed3bcd9e9a40934b09bf48a15fe7558c9d9ceb0ebec63625ea18f7c3ab341d9f7edd8e1d8816edecb34dbd71ae02771327b5ebc74613dadd":"1ebe9893957a5c4a707793906d31bb201e88d88a22abd6baa6461fc61def7ffb":"f81e26744834413cb95af8d438d0050c7c968f929a33e35ee5c6715a0a520950":"687a848b2b6c715a0e613b3f3bb16cf2f056543eb9dd6b8aee8de8aa6fd8a1e6":"a6c4a7e99d08cc847ac0b8c8bcf22ec0" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #5 -ctr_drbg_validate_nopr:"eb2439d156c4f51fb1943c26f27de8af":"ad153fd266d9f73b21f4e5e88d3d13ba8325abdec427d5d8f671cfccdbd3510e9774d59a14d9b5472b217b7bcf355436a51965d2dff7c4ac586ab812f20d326e":"e24bd6b69a40fa0a02cefbbaa282f8f63a80e154be338d1b913418d4ff7a810d":"fd40baf11d7cdd77641a2b46916cb0c12980e02612ef59fb6fe7dabbbe7a85c0":"a40019e3b85d7d5775e793dd4c09b2bdc8253694b1dcb73e63a18b066a7f7d0c":"7cd8d2710147a0b7f053bb271edf07b5" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"eb2439d156c4f51fb1943c26f27de8af":"ad153fd266d9f73b21f4e5e88d3d13ba8325abdec427d5d8f671cfccdbd3510e9774d59a14d9b5472b217b7bcf355436a51965d2dff7c4ac586ab812f20d326e":"e24bd6b69a40fa0a02cefbbaa282f8f63a80e154be338d1b913418d4ff7a810d":"fd40baf11d7cdd77641a2b46916cb0c12980e02612ef59fb6fe7dabbbe7a85c0":"a40019e3b85d7d5775e793dd4c09b2bdc8253694b1dcb73e63a18b066a7f7d0c":"7cd8d2710147a0b7f053bb271edf07b5" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #6 -ctr_drbg_validate_nopr:"b23796d88ee5ae75ff2ba4fbbd5e2de8":"b249d2d9b269b58c5355710aaae98be12d8fb2e79046b4e6deeec28adad7e789999847e20de11f7c3277216374f117e3e006bdf99bb8631aa4c4c542cd482840":"79f0214b6b0c5ffb21b1d521498b71d22c67be4607c16300ab8dde3b52498097":"582be1e080264b3e68ec184347a5b6db1e8be1811578206e14ad84029fe39f71":"f5e9c3356810793f461f889d8c5003b1c0b20a284cb348301ce7b2dd7a1c7dd7":"1aa8cf54994be6b329e9eb897007abf0" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b23796d88ee5ae75ff2ba4fbbd5e2de8":"b249d2d9b269b58c5355710aaae98be12d8fb2e79046b4e6deeec28adad7e789999847e20de11f7c3277216374f117e3e006bdf99bb8631aa4c4c542cd482840":"79f0214b6b0c5ffb21b1d521498b71d22c67be4607c16300ab8dde3b52498097":"582be1e080264b3e68ec184347a5b6db1e8be1811578206e14ad84029fe39f71":"f5e9c3356810793f461f889d8c5003b1c0b20a284cb348301ce7b2dd7a1c7dd7":"1aa8cf54994be6b329e9eb897007abf0" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #7 -ctr_drbg_validate_nopr:"081db0b1620a56afd87c2fd2bebb1db3":"3f1e90d88870a0bd03364036b655495e3e7d51bf67fb64ba0cbf003430af5585f5936b84ab3b8a55c02b8b6c54bea09cf2d77691858c5818991383add5f0c644":"5b98bc83ae8bed5c49cb71689dc39fee38d5d08bdfa2a01cee9d61e9f3d1e115":"aad3e58fdd98aa60fc2cae0df3fc734fff01a07f29f69c5ffeb96d299200d0d8":"bad9039ebb7c3a44061353542a2b1c1a89b3e9b493e9f59e438bfc80de3d1836":"8d01e3dc48b28f016fc34655c54be81f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"081db0b1620a56afd87c2fd2bebb1db3":"3f1e90d88870a0bd03364036b655495e3e7d51bf67fb64ba0cbf003430af5585f5936b84ab3b8a55c02b8b6c54bea09cf2d77691858c5818991383add5f0c644":"5b98bc83ae8bed5c49cb71689dc39fee38d5d08bdfa2a01cee9d61e9f3d1e115":"aad3e58fdd98aa60fc2cae0df3fc734fff01a07f29f69c5ffeb96d299200d0d8":"bad9039ebb7c3a44061353542a2b1c1a89b3e9b493e9f59e438bfc80de3d1836":"8d01e3dc48b28f016fc34655c54be81f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #8 -ctr_drbg_validate_nopr:"a8427443d9c34abcdcca061a2bbcff52":"b0e9b2192adc8912653d90a634d5d40c53ca4383290a8764bdf92667f859d833c3e72ad0ff41e07fe257b1ead11649be655c58a5df233114e7eda2558b7214d7":"c6cad9fb17ada437d195d1f8b6a7fa463e20050e94024170d2ffc34b80a50108":"be461a9c1a72ebaf28ee732219e3ca54cbee36921daaa946917a7c63279a6b0e":"b6d110d6b746d7ccf7a48a4337ba341d52508d0336d017ae20377977163c1a20":"16ccd63dbf7b24b6b427126b863f7c86" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a8427443d9c34abcdcca061a2bbcff52":"b0e9b2192adc8912653d90a634d5d40c53ca4383290a8764bdf92667f859d833c3e72ad0ff41e07fe257b1ead11649be655c58a5df233114e7eda2558b7214d7":"c6cad9fb17ada437d195d1f8b6a7fa463e20050e94024170d2ffc34b80a50108":"be461a9c1a72ebaf28ee732219e3ca54cbee36921daaa946917a7c63279a6b0e":"b6d110d6b746d7ccf7a48a4337ba341d52508d0336d017ae20377977163c1a20":"16ccd63dbf7b24b6b427126b863f7c86" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #9 -ctr_drbg_validate_nopr:"86bd02976e6c50656372b8c212cf0a7a":"89900b0febf6b4e19ab8fc5babb4122a8aad86d658d0c2f98988c99fbd8530ff4ad365bd5fddaa15f96537bd72deb5384405b610e6ebae83e848307051fd6c82":"41bf3794ee54647a48a2588fdfdea686f1af6792e957d42f181f2631b207ac0c":"c4478afbea4eecb225448f069b02a74c2a222698c68e37eb144aff9e457f9610":"41a99e0d3f5b767f9bedcb2f878a5d99d42856bed29042d568b04e347624bf7f":"863337529aac9ab1e9f7f8187ea7aa7d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"86bd02976e6c50656372b8c212cf0a7a":"89900b0febf6b4e19ab8fc5babb4122a8aad86d658d0c2f98988c99fbd8530ff4ad365bd5fddaa15f96537bd72deb5384405b610e6ebae83e848307051fd6c82":"41bf3794ee54647a48a2588fdfdea686f1af6792e957d42f181f2631b207ac0c":"c4478afbea4eecb225448f069b02a74c2a222698c68e37eb144aff9e457f9610":"41a99e0d3f5b767f9bedcb2f878a5d99d42856bed29042d568b04e347624bf7f":"863337529aac9ab1e9f7f8187ea7aa7d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #10 -ctr_drbg_validate_nopr:"e809ef8d4c3d82575833d51ac69481b2":"3e831b7715ce202c95ec85337e2c0061d972169955bd96fbe1f758508c0336b3226260ea5e66f943b538eb115ffe4d5e534cbe58262a610528641629bc12fc75":"4d40c6a961168445c1691fea02ebd693cb4b3f74b03d45a350c65f0aaccb118b":"b07dc50e6ca7544ed6fdebd8f00ed5fa9b1f2213b477de8568eb92dddaabfe3f":"cbac982aa9f1830d0dc7373d9907670f561642adb1888f66b4150d3487bf0b8d":"2814be767d79778ebb82a096976f30db" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e809ef8d4c3d82575833d51ac69481b2":"3e831b7715ce202c95ec85337e2c0061d972169955bd96fbe1f758508c0336b3226260ea5e66f943b538eb115ffe4d5e534cbe58262a610528641629bc12fc75":"4d40c6a961168445c1691fea02ebd693cb4b3f74b03d45a350c65f0aaccb118b":"b07dc50e6ca7544ed6fdebd8f00ed5fa9b1f2213b477de8568eb92dddaabfe3f":"cbac982aa9f1830d0dc7373d9907670f561642adb1888f66b4150d3487bf0b8d":"2814be767d79778ebb82a096976f30db" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #11 -ctr_drbg_validate_nopr:"ad71caa50420d213b25f5558e0dc1170":"6a3fd23e7dc934e6de6eb4cc846c0dc3cf35ea4be3f561c34666aed1bbd6331004afba5a5b83fff1e7b8a957fbee7cd9f8142326c796ca129ec9fbacf295b882":"3042dd041b89aaa61f185fdda706c77667515c037f2a88c6d47f23ddadc828ae":"9b1e3f72aaab66b202f17c5cc075cfba7242817b2b38c19fe8924ca325b826ea":"8660b503329aaea56acdb73ca83763299bac0f30264702cb9d52cbaf3d71d69d":"c204a3174784d82b664e9a1c0a13ffa6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ad71caa50420d213b25f5558e0dc1170":"6a3fd23e7dc934e6de6eb4cc846c0dc3cf35ea4be3f561c34666aed1bbd6331004afba5a5b83fff1e7b8a957fbee7cd9f8142326c796ca129ec9fbacf295b882":"3042dd041b89aaa61f185fdda706c77667515c037f2a88c6d47f23ddadc828ae":"9b1e3f72aaab66b202f17c5cc075cfba7242817b2b38c19fe8924ca325b826ea":"8660b503329aaea56acdb73ca83763299bac0f30264702cb9d52cbaf3d71d69d":"c204a3174784d82b664e9a1c0a13ffa6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #12 -ctr_drbg_validate_nopr:"5fd6606b08e7e625af788814bef7f263":"baf8750e07194fc7172c736e0fdea0a632810d45602dff17ce37adf106d652f87e31b6bd24d21481c86444d8109586118672a6f93731b7438a3f0f39648b83a3":"3c37193d40e79ce8d569d8aa7ef80aabaa294f1b6d5a8341805f5ac67a6abf42":"c7033b3b68be178d120379e7366980d076c73280e629dd6e82f5af1af258931b":"452218a426a58463940785a67cb34799a1787f39d376c9e56e4a3f2215785dad":"561e16a8b297e458c4ec39ba43f0b67e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"5fd6606b08e7e625af788814bef7f263":"baf8750e07194fc7172c736e0fdea0a632810d45602dff17ce37adf106d652f87e31b6bd24d21481c86444d8109586118672a6f93731b7438a3f0f39648b83a3":"3c37193d40e79ce8d569d8aa7ef80aabaa294f1b6d5a8341805f5ac67a6abf42":"c7033b3b68be178d120379e7366980d076c73280e629dd6e82f5af1af258931b":"452218a426a58463940785a67cb34799a1787f39d376c9e56e4a3f2215785dad":"561e16a8b297e458c4ec39ba43f0b67e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #13 -ctr_drbg_validate_nopr:"08def734914ecf74b9eccb5dfaa045b8":"6697f889fcf6dae16881dc1e540e5c07f9461d409acee31842b04f93c00efbba670dfbf6040c1c2e29ad89064eae283fd6d431832f356e492bc5b2049f229892":"a6ac87af21efd3508990aac51d36243d46237b3755a0e68680adb59e19e8ae23":"0052152872b21615775431eb51889a264fed6ca44fa0436b72a419b91f92604c":"ebadf71565d9a8cc2621403c36e6411e7bed67193a843b90ccf2f7aa9f229ca2":"c83fa5df210b63f4bf4a0aca63650aab" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"08def734914ecf74b9eccb5dfaa045b8":"6697f889fcf6dae16881dc1e540e5c07f9461d409acee31842b04f93c00efbba670dfbf6040c1c2e29ad89064eae283fd6d431832f356e492bc5b2049f229892":"a6ac87af21efd3508990aac51d36243d46237b3755a0e68680adb59e19e8ae23":"0052152872b21615775431eb51889a264fed6ca44fa0436b72a419b91f92604c":"ebadf71565d9a8cc2621403c36e6411e7bed67193a843b90ccf2f7aa9f229ca2":"c83fa5df210b63f4bf4a0aca63650aab" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #14 -ctr_drbg_validate_nopr:"6437862e93060def199029ff2182f1e5":"719d1afcb6dc8ca26cba6a7c10f59cf82345b2a0c631a7879812d6f2d2663b49f9e92daecb81ff7c0790205d66694526477d6de54a269f542cb5e77fe4bc8db3":"5c961db0ac2ea8caf62c9acc44465dcfb4d721fcb2cd3e1c76cdcb61bfaa7e75":"24eabd392d37493e306705d0b287be11a4d72dd4b9577ac4098ef0dae69b0000":"9e4f05c1b85613e97958bc3863e521331b2bd78fdf2585f84607bf2238e82415":"21aaae76dc97c9bf7cf858054839653e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"6437862e93060def199029ff2182f1e5":"719d1afcb6dc8ca26cba6a7c10f59cf82345b2a0c631a7879812d6f2d2663b49f9e92daecb81ff7c0790205d66694526477d6de54a269f542cb5e77fe4bc8db3":"5c961db0ac2ea8caf62c9acc44465dcfb4d721fcb2cd3e1c76cdcb61bfaa7e75":"24eabd392d37493e306705d0b287be11a4d72dd4b9577ac4098ef0dae69b0000":"9e4f05c1b85613e97958bc3863e521331b2bd78fdf2585f84607bf2238e82415":"21aaae76dc97c9bf7cf858054839653e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #0 -ctr_drbg_validate_nopr:"cd7a1981c1b7079c1c38f5aeee86db22207cb9faed8c576b1724ca7817aa6abfb26c42a019eb4c2f4064f0587ea2b952":"7f88c3805ae0857c5cbb085a5d6259d26fb3a88dfe7084172ec959066f26296a800953ce19a24785b6acef451c4ce4c2dfb565cbe057f21b054a28633afbdd97":"":"":"":"76c1cdb0b95af271b52ac3b0c9289146" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"cd7a1981c1b7079c1c38f5aeee86db22207cb9faed8c576b1724ca7817aa6abfb26c42a019eb4c2f4064f0587ea2b952":"7f88c3805ae0857c5cbb085a5d6259d26fb3a88dfe7084172ec959066f26296a800953ce19a24785b6acef451c4ce4c2dfb565cbe057f21b054a28633afbdd97":"":"":"":"76c1cdb0b95af271b52ac3b0c9289146" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #1 -ctr_drbg_validate_nopr:"0ccdac2fd65a86bf8f8e9ddcabffb9d29a935139f627c165a815b23137eeee94cbb21be86ac5117379177d37728db6fd":"6f61703f92d3192cd982b2e52a8683e0d62918d51b12e084deae06c4a8e08ecfb3d2d30a980a70b083710bc45d9d407966b52829cf3813cc970b859aa4c871fe":"":"":"":"e6c73e159d73c2ba8950cd77acb39c10" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0ccdac2fd65a86bf8f8e9ddcabffb9d29a935139f627c165a815b23137eeee94cbb21be86ac5117379177d37728db6fd":"6f61703f92d3192cd982b2e52a8683e0d62918d51b12e084deae06c4a8e08ecfb3d2d30a980a70b083710bc45d9d407966b52829cf3813cc970b859aa4c871fe":"":"":"":"e6c73e159d73c2ba8950cd77acb39c10" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #2 -ctr_drbg_validate_nopr:"fbbcc4abfd671296de3e0dcf409a139e35deae126c1941bf1afcc8d3da3a2d65f54a6d317bb6d683a3a77f6266b007ff":"c662ed723e7041877542fdcf629533d4a74393eb4dae4f3ec06d2d1c0d37ed7f519609a8485cb8deb578ae4cbb45c98ef7f2f2e677363e89fb3744286db6bfc1":"":"":"":"9d934d34417c6d0858f4a3faacbe759e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"fbbcc4abfd671296de3e0dcf409a139e35deae126c1941bf1afcc8d3da3a2d65f54a6d317bb6d683a3a77f6266b007ff":"c662ed723e7041877542fdcf629533d4a74393eb4dae4f3ec06d2d1c0d37ed7f519609a8485cb8deb578ae4cbb45c98ef7f2f2e677363e89fb3744286db6bfc1":"":"":"":"9d934d34417c6d0858f4a3faacbe759e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #3 -ctr_drbg_validate_nopr:"1b824790b6b22b246bcc1bcfbbb61a76045476672f917b72e79cca358e650eb29ed49fb0a5739e097f5f5336d46fc619":"c57a5686486ebacc2422236b19110c754795a869a8157901cf71303de1adc6af16a952190a395d6c20e155e690f41922f6f721dc8e93da81afb844f68714cba7":"":"":"":"13e7bf23d88f3bb5a5106a8227c8c456" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1b824790b6b22b246bcc1bcfbbb61a76045476672f917b72e79cca358e650eb29ed49fb0a5739e097f5f5336d46fc619":"c57a5686486ebacc2422236b19110c754795a869a8157901cf71303de1adc6af16a952190a395d6c20e155e690f41922f6f721dc8e93da81afb844f68714cba7":"":"":"":"13e7bf23d88f3bb5a5106a8227c8c456" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #4 -ctr_drbg_validate_nopr:"2ea7861e374232cb8ceecbbd9a18fc1f63c31f833fe394f1e19c8ef61092a56f28342fa5b591f7b951583d50c12ef081":"6a0873634094be7028b885c345cd5016295eec5e524f069de6510ae8ac843dba2cc05c10baa8aad75eac8e8d1a8570f4d2a3cf718914a199deb3edf8c993a822":"":"":"":"c008f46a242ae0babad17268c9e0839a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2ea7861e374232cb8ceecbbd9a18fc1f63c31f833fe394f1e19c8ef61092a56f28342fa5b591f7b951583d50c12ef081":"6a0873634094be7028b885c345cd5016295eec5e524f069de6510ae8ac843dba2cc05c10baa8aad75eac8e8d1a8570f4d2a3cf718914a199deb3edf8c993a822":"":"":"":"c008f46a242ae0babad17268c9e0839a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #5 -ctr_drbg_validate_nopr:"39caa986b82b5303d98e07b211ddc5ce89a67506095cad1aeed63b8bfe0d9c3d3c906f0c05cfb6b26bab4af7d03c9e1a":"f2059f7fb797e8e22de14dac783c56942a33d092c1ab68a762528ae8d74b7ad0690694ede462edbd6527550677b6d080d80cdabe51c963d5d6830a4ae04c993f":"":"":"":"202d3b2870be8f29b518f2e3e52f1564" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"39caa986b82b5303d98e07b211ddc5ce89a67506095cad1aeed63b8bfe0d9c3d3c906f0c05cfb6b26bab4af7d03c9e1a":"f2059f7fb797e8e22de14dac783c56942a33d092c1ab68a762528ae8d74b7ad0690694ede462edbd6527550677b6d080d80cdabe51c963d5d6830a4ae04c993f":"":"":"":"202d3b2870be8f29b518f2e3e52f1564" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #6 -ctr_drbg_validate_nopr:"a4e25102c1b04bafd66bfe1ce4a4b340797f776f54a2b3afe351eede44e75c28e3525155f837e7974269d398048c83c3":"0a03b7d026fab3773e9724dacb436197954b770eca3060535f2f8152aa136942915304dede1de0f5e89bd91d8e92531b5e39373013628fea4ee7622b9255d179":"":"":"":"be21cab637218ddffa3510c86271db7f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a4e25102c1b04bafd66bfe1ce4a4b340797f776f54a2b3afe351eede44e75c28e3525155f837e7974269d398048c83c3":"0a03b7d026fab3773e9724dacb436197954b770eca3060535f2f8152aa136942915304dede1de0f5e89bd91d8e92531b5e39373013628fea4ee7622b9255d179":"":"":"":"be21cab637218ddffa3510c86271db7f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #7 -ctr_drbg_validate_nopr:"6de33a116425ebfe01f0a0124ad3fad382ca28473f5fc53885639788f9b1a470ab523b649bad87e76dee768f6abacb55":"d88312da6acbe792d087012c0bf3c83f363fa6b7a9dd45c3501009fb47b4cfcfeb7b31386155fe3b967f46e2898a00ecf51ec38b6e420852bef0a16081d778cc":"":"":"":"2c285bfd758f0156e782bb4467f6832c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"6de33a116425ebfe01f0a0124ad3fad382ca28473f5fc53885639788f9b1a470ab523b649bad87e76dee768f6abacb55":"d88312da6acbe792d087012c0bf3c83f363fa6b7a9dd45c3501009fb47b4cfcfeb7b31386155fe3b967f46e2898a00ecf51ec38b6e420852bef0a16081d778cc":"":"":"":"2c285bfd758f0156e782bb4467f6832c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #8 -ctr_drbg_validate_nopr:"b8ab42fd3f6306426602cae0c48eb02ffa7053940389900c17846e1d9726251762095383f2ec3406b3381d94a6d53dd8":"6a7873ccb7afb140e923acbec8256fa78232f40c0c8ba3dcbcf7074d26d6d18a7e78fffda328f097706b6d358048ee6a4728c92a6f62b3f2730a753b7bf5ec1f":"":"":"":"13504a2b09474f90d2e9ef40d1f2d0d5" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b8ab42fd3f6306426602cae0c48eb02ffa7053940389900c17846e1d9726251762095383f2ec3406b3381d94a6d53dd8":"6a7873ccb7afb140e923acbec8256fa78232f40c0c8ba3dcbcf7074d26d6d18a7e78fffda328f097706b6d358048ee6a4728c92a6f62b3f2730a753b7bf5ec1f":"":"":"":"13504a2b09474f90d2e9ef40d1f2d0d5" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #9 -ctr_drbg_validate_nopr:"042b524444b9903c1ecb80af21eef0e884115561a15a1ab2f9f3a322edcbf14174f54d315196a632940c2c6f56612c09":"31ba5f801aeaac790f2480fbd2373a76ba1685ebebc5ae7cd4844733ec3cfb112634b3899104dcc16050e1206f8b3fb787d43d54de2c804fd3d8eb98e512bb00":"":"":"":"0a0484c14e7868178e68d6d5c5f57c5c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"042b524444b9903c1ecb80af21eef0e884115561a15a1ab2f9f3a322edcbf14174f54d315196a632940c2c6f56612c09":"31ba5f801aeaac790f2480fbd2373a76ba1685ebebc5ae7cd4844733ec3cfb112634b3899104dcc16050e1206f8b3fb787d43d54de2c804fd3d8eb98e512bb00":"":"":"":"0a0484c14e7868178e68d6d5c5f57c5c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #10 -ctr_drbg_validate_nopr:"632758f92efaca39615862177c267906ab0424230d481ee0a5aa1a5f66697d3918d4aab3f310b72a7f2d71c0a96b9247":"46dc837620872a5ffa642399213b4eebfb28ca069c5eaaf2a636f5bd647de365c11402b10ecd7780c56d464f56b653e17af8550b90a54adb38173a0b2f9e2ea7":"":"":"":"90432ce3f7b580961abecde259aa5af6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"632758f92efaca39615862177c267906ab0424230d481ee0a5aa1a5f66697d3918d4aab3f310b72a7f2d71c0a96b9247":"46dc837620872a5ffa642399213b4eebfb28ca069c5eaaf2a636f5bd647de365c11402b10ecd7780c56d464f56b653e17af8550b90a54adb38173a0b2f9e2ea7":"":"":"":"90432ce3f7b580961abecde259aa5af6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #11 -ctr_drbg_validate_nopr:"7b389118af3d0f8336b41cf58c2d810f0e5f9940703fd56a46c10a315fb09aafd7670c9e96ffa61e0cb750cb2aa6a7fe":"76e92e9f00fc7d0c525c48739a8b3601c51f8f5996117a7e07497afee36829636e714dbcb84c8f8d57e0850a361a5bdfc21084a1c30fb7797ce6280e057309b7":"":"":"":"7243964051082c0617e200fcbbe7ff45" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"7b389118af3d0f8336b41cf58c2d810f0e5f9940703fd56a46c10a315fb09aafd7670c9e96ffa61e0cb750cb2aa6a7fe":"76e92e9f00fc7d0c525c48739a8b3601c51f8f5996117a7e07497afee36829636e714dbcb84c8f8d57e0850a361a5bdfc21084a1c30fb7797ce6280e057309b7":"":"":"":"7243964051082c0617e200fcbbe7ff45" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #12 -ctr_drbg_validate_nopr:"e50d38434e9dfe3601e7ea1765d9fe777d467d9918974b5599ec19f42d7054b70ff6db63a3403d2fd09333eda17a5e76":"c9aa4739011c60f8e99db0580b3cad4269874d1dda1c81ffa872f01669e8f75215aaad1ccc301c12f90cd240bf99ad42bb06965afb0aa2bd3fcb681c710aa375":"":"":"":"28499495c94c6ceec1bd494e364ad97c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e50d38434e9dfe3601e7ea1765d9fe777d467d9918974b5599ec19f42d7054b70ff6db63a3403d2fd09333eda17a5e76":"c9aa4739011c60f8e99db0580b3cad4269874d1dda1c81ffa872f01669e8f75215aaad1ccc301c12f90cd240bf99ad42bb06965afb0aa2bd3fcb681c710aa375":"":"":"":"28499495c94c6ceec1bd494e364ad97c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #13 -ctr_drbg_validate_nopr:"3253cb074d610db602b0a0d2836df1f20c3ee162d80b90b31660bb86ef3f0789fa857af4f45a5897bdd73c2295f879b6":"b06960a92d32a9e9658d9800de87a3800f3595e173fdc46bef22966264953672e2d7c638cc7b1cada747026726baf6cea4c64ba956be8bb1d1801158bee5e5d4":"":"":"":"b6608d6e5fcb4591a718f9149b79f8f1" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"3253cb074d610db602b0a0d2836df1f20c3ee162d80b90b31660bb86ef3f0789fa857af4f45a5897bdd73c2295f879b6":"b06960a92d32a9e9658d9800de87a3800f3595e173fdc46bef22966264953672e2d7c638cc7b1cada747026726baf6cea4c64ba956be8bb1d1801158bee5e5d4":"":"":"":"b6608d6e5fcb4591a718f9149b79f8f1" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #14 -ctr_drbg_validate_nopr:"83e4733566f90c8d69e6bcbe9fb52521ff3e26f806d9b7b86e9344cca0305dbf106de855240f1d35492cc6d651b8b6ae":"0e0105b12af35ac87cb23cf9ca8fb6a44307c3dcdc5bc890eb5253f4034c1533392a1760c98ba30d7751af93dd865d4bd66fbbeb215d7ff239b700527247775d":"":"":"":"68d64d1522c09a859b9b85b528d0d912" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"83e4733566f90c8d69e6bcbe9fb52521ff3e26f806d9b7b86e9344cca0305dbf106de855240f1d35492cc6d651b8b6ae":"0e0105b12af35ac87cb23cf9ca8fb6a44307c3dcdc5bc890eb5253f4034c1533392a1760c98ba30d7751af93dd865d4bd66fbbeb215d7ff239b700527247775d":"":"":"":"68d64d1522c09a859b9b85b528d0d912" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #0 -ctr_drbg_validate_nopr:"a94da55afdc50ce51c9a3b8a4c4484408b52a24a93c34ea71e1ca705eb829ba65de4d4e07fa3d86b37845ff1c7d5f6d2":"a53e371017439193591e475087aaddd5c1c386cdca0ddb68e002d80fdc401a47dd40e5987b2716731568d276bf0c6715757903d3dede914642ddd467c879c81e":"20f422edf85ca16a01cfbe5f8d6c947fae12a857db2aa9bfc7b36581808d0d46":"7fd81fbd2ab51c115d834e99f65ca54020ed388ed59ee07593fe125e5d73fb75":"cd2cff14693e4c9efdfe260de986004930bab1c65057772a62392c3b74ebc90d":"4f78beb94d978ce9d097feadfafd355e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a94da55afdc50ce51c9a3b8a4c4484408b52a24a93c34ea71e1ca705eb829ba65de4d4e07fa3d86b37845ff1c7d5f6d2":"a53e371017439193591e475087aaddd5c1c386cdca0ddb68e002d80fdc401a47dd40e5987b2716731568d276bf0c6715757903d3dede914642ddd467c879c81e":"20f422edf85ca16a01cfbe5f8d6c947fae12a857db2aa9bfc7b36581808d0d46":"7fd81fbd2ab51c115d834e99f65ca54020ed388ed59ee07593fe125e5d73fb75":"cd2cff14693e4c9efdfe260de986004930bab1c65057772a62392c3b74ebc90d":"4f78beb94d978ce9d097feadfafd355e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #1 -ctr_drbg_validate_nopr:"e8649d4f86b3de85fe39ff04d7afe6e4dd00770931330b27e975a7b1e7b5206ee2f247d50401a372c3a27197fec5da46":"78d7d65c457218a63e2eb1eba287f121c5466728ac4f963aeaabf593b9d72b6376daea6436e55415ad097dee10c40a1ff61fca1c30b8ab51ed11ff090d19ef9a":"cc57adc98b2540664403ad6fd50c9042f0bf0e0b54ed33584ee189e072d0fb8f":"ab2f99e2d983aa8dd05336a090584f4f84d485a4763e00ced42ddda72483cd84":"0ecd7680e2e9f0250a43e28f2f8936d7ef16f45d79c0fa3f69e4fafce4aeb362":"08e38625611bb0fb844f43439550bd7a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e8649d4f86b3de85fe39ff04d7afe6e4dd00770931330b27e975a7b1e7b5206ee2f247d50401a372c3a27197fec5da46":"78d7d65c457218a63e2eb1eba287f121c5466728ac4f963aeaabf593b9d72b6376daea6436e55415ad097dee10c40a1ff61fca1c30b8ab51ed11ff090d19ef9a":"cc57adc98b2540664403ad6fd50c9042f0bf0e0b54ed33584ee189e072d0fb8f":"ab2f99e2d983aa8dd05336a090584f4f84d485a4763e00ced42ddda72483cd84":"0ecd7680e2e9f0250a43e28f2f8936d7ef16f45d79c0fa3f69e4fafce4aeb362":"08e38625611bb0fb844f43439550bd7a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #2 -ctr_drbg_validate_nopr:"6c79e1556889b3c074fc083a120d73784b888c5acb877899f17ce52e424b84178d144441aa9f328c730a951b02b048df":"c78ff6b9fc91cbce246c9fcc2366d5f7dd6d99fb1325d8997f36819232d5fcd12ccafdcbefd01409d90acd0e0ffb7427c820b2d729fe7e845e6a6168fc1af0b5":"60cba10826de22c5e85d06357de63d6b2ff0719694dafca6ab33283f3a4aacdd":"8943c22fb68b30811790a99b9cbb056e1a2c329185a199c76ba5aeceb2fcd769":"70671a50e8387bf232989d904c19215c7535ad2d0c5dec30a744c8d2706be6ec":"f6b94b671cae8dfa8387719bfd75ee84" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"6c79e1556889b3c074fc083a120d73784b888c5acb877899f17ce52e424b84178d144441aa9f328c730a951b02b048df":"c78ff6b9fc91cbce246c9fcc2366d5f7dd6d99fb1325d8997f36819232d5fcd12ccafdcbefd01409d90acd0e0ffb7427c820b2d729fe7e845e6a6168fc1af0b5":"60cba10826de22c5e85d06357de63d6b2ff0719694dafca6ab33283f3a4aacdd":"8943c22fb68b30811790a99b9cbb056e1a2c329185a199c76ba5aeceb2fcd769":"70671a50e8387bf232989d904c19215c7535ad2d0c5dec30a744c8d2706be6ec":"f6b94b671cae8dfa8387719bfd75ee84" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #3 -ctr_drbg_validate_nopr:"f5ab77b2a8e370548b88febfd79772144cd5fc8d78062582addd4ff1e5c10094b390e66b3c4efb087510de1b9d25703f":"21a21c9314b37d4ade4a50a5d85995e0be07e358ed9bca19daa867a8d47847105dca7a424f32f715adb8fea5d3a41cfe388872a42ab18aa5cbcd7bde4adc3f8b":"023d582569a7ff1405e44cf09ceebb9d3254eef72286e4b87e6577a8ab091a06":"39597519872d49fbd186704241ba1dc10b1f84f9296fb61d597dbd655a18f997":"3091c9fe96109b41da63aa5fa00d716b5fa20e96d4f3e0f9c97666a706fa56f1":"1fb57058b3ba8751df5a99f018798983" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"f5ab77b2a8e370548b88febfd79772144cd5fc8d78062582addd4ff1e5c10094b390e66b3c4efb087510de1b9d25703f":"21a21c9314b37d4ade4a50a5d85995e0be07e358ed9bca19daa867a8d47847105dca7a424f32f715adb8fea5d3a41cfe388872a42ab18aa5cbcd7bde4adc3f8b":"023d582569a7ff1405e44cf09ceebb9d3254eef72286e4b87e6577a8ab091a06":"39597519872d49fbd186704241ba1dc10b1f84f9296fb61d597dbd655a18f997":"3091c9fe96109b41da63aa5fa00d716b5fa20e96d4f3e0f9c97666a706fa56f1":"1fb57058b3ba8751df5a99f018798983" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #4 -ctr_drbg_validate_nopr:"f0b79e292d0e393e78b6d6117e06d2e725823fe35bde1146502967a78d99d6bca564f0e2f324272f968be5baab4aeb29":"192054dddac02157a35eb7f75ae8ebdb43d6b969e33942fb16ff06cd6d8a602506c41e4e743b8230e8239b71b31b2d5e3614e3a65d79e91d5b9fc9d2a66f8553":"b12241e90d80f129004287c5b9911a70f7159794e6f9c1023b3b68da9237e8b7":"59e9c3c0f90e91f22c35a3be0c65f16157c569c7e3c78a545d9840f648c60069":"089a59af69f47ddb4191bd27720bb4c29216f738c48c0e14d2b8afd68de63c17":"15287156e544617529e7eede4aa9c70e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"f0b79e292d0e393e78b6d6117e06d2e725823fe35bde1146502967a78d99d6bca564f0e2f324272f968be5baab4aeb29":"192054dddac02157a35eb7f75ae8ebdb43d6b969e33942fb16ff06cd6d8a602506c41e4e743b8230e8239b71b31b2d5e3614e3a65d79e91d5b9fc9d2a66f8553":"b12241e90d80f129004287c5b9911a70f7159794e6f9c1023b3b68da9237e8b7":"59e9c3c0f90e91f22c35a3be0c65f16157c569c7e3c78a545d9840f648c60069":"089a59af69f47ddb4191bd27720bb4c29216f738c48c0e14d2b8afd68de63c17":"15287156e544617529e7eede4aa9c70e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #5 -ctr_drbg_validate_nopr:"e3f33843aecb35d01001ff92ab9a0f1a5431ba9de3e4f3247cda8c62acc86f7066448f639d8ba8b5249337f8c353bbbd":"ef081af1f62400a3d193969d689a40234998afb646d99a7c4b9cbbf47e650cda93a90e754a16fffa25fc2a2edab09720b4520c47309ec4f6d9f76f0162af6cae":"e7cc55b72862544a8661b5034e15587b1e5a45eb5dc744f5fa1db9b267f1c3ff":"882d30c888eb8e344b1d17057074606fe232ceb42eb71055264ede7bb638f2a2":"9ce65e95c1e735fe950e52c324e7551403d0ef70ad865bd31fef1e22b129fdd6":"205e3a53367c4a5183be74bb875fa717" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e3f33843aecb35d01001ff92ab9a0f1a5431ba9de3e4f3247cda8c62acc86f7066448f639d8ba8b5249337f8c353bbbd":"ef081af1f62400a3d193969d689a40234998afb646d99a7c4b9cbbf47e650cda93a90e754a16fffa25fc2a2edab09720b4520c47309ec4f6d9f76f0162af6cae":"e7cc55b72862544a8661b5034e15587b1e5a45eb5dc744f5fa1db9b267f1c3ff":"882d30c888eb8e344b1d17057074606fe232ceb42eb71055264ede7bb638f2a2":"9ce65e95c1e735fe950e52c324e7551403d0ef70ad865bd31fef1e22b129fdd6":"205e3a53367c4a5183be74bb875fa717" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #6 -ctr_drbg_validate_nopr:"f30a18d597d8591a22dee908de95c5af74884b025f39b4f6707d28447d9d0a3114a57bc2d9eed8e621ec75e8ce389a16":"fae3d554d12a14e29de1b622922f27559559ca1518c9f800375a37a212e8b9a653cc3700223e9404d5bf781d15fccf638050a1394592caba001cfc65d61ef90b":"54240edd89016ed27e3bb3977a206836f5ef1fba0f000af95337d79caca9cf71":"250611e51852d933ff1a177b509c05e3228cb9f46dfb7b26848a68aad2ce4779":"f8b602d89fa1a0bfb31d0bd49246b458200a1adb28b64a68f7c197f335d69706":"7b63bfb325bafe7d9ef342cd14ea40a4" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"f30a18d597d8591a22dee908de95c5af74884b025f39b4f6707d28447d9d0a3114a57bc2d9eed8e621ec75e8ce389a16":"fae3d554d12a14e29de1b622922f27559559ca1518c9f800375a37a212e8b9a653cc3700223e9404d5bf781d15fccf638050a1394592caba001cfc65d61ef90b":"54240edd89016ed27e3bb3977a206836f5ef1fba0f000af95337d79caca9cf71":"250611e51852d933ff1a177b509c05e3228cb9f46dfb7b26848a68aad2ce4779":"f8b602d89fa1a0bfb31d0bd49246b458200a1adb28b64a68f7c197f335d69706":"7b63bfb325bafe7d9ef342cd14ea40a4" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #7 -ctr_drbg_validate_nopr:"c8dbc3d39beb612811c52e2b46ef76d2b7bd5d3a90ceddf9fb864fe6f44e36687d88158d61014e192f9a3cd474338e13":"8e60115b4af9c8e5606223792539e9ba87e9ef46cd16fcc09046db1ef8d3c036241cae5d61141711818e9e861dbd833632069ebf5af1bd6d4e513f059ab1efd3":"9b56eba0838457f736fc5efa2cfbe698908340f07d4680e279d21dd530fdc8c8":"62c47ece469a7a409e4b2b76d1c793aaf11654e177cc8bf63faff3e6c5a5395c":"4251597013d0c949c53bbd945477b78aa91baa95f1ff757c3a039ccc4e1f4789":"af2f37160940f0cc27d144a043ddf79b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"c8dbc3d39beb612811c52e2b46ef76d2b7bd5d3a90ceddf9fb864fe6f44e36687d88158d61014e192f9a3cd474338e13":"8e60115b4af9c8e5606223792539e9ba87e9ef46cd16fcc09046db1ef8d3c036241cae5d61141711818e9e861dbd833632069ebf5af1bd6d4e513f059ab1efd3":"9b56eba0838457f736fc5efa2cfbe698908340f07d4680e279d21dd530fdc8c8":"62c47ece469a7a409e4b2b76d1c793aaf11654e177cc8bf63faff3e6c5a5395c":"4251597013d0c949c53bbd945477b78aa91baa95f1ff757c3a039ccc4e1f4789":"af2f37160940f0cc27d144a043ddf79b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #8 -ctr_drbg_validate_nopr:"a37f9ed6c4e8f74ff16046b0678ef7bd24fcdca247b771ea1ce1fd48e3f5d2067e38aaf64ec59f1f49d96fa85e60ef03":"95da91f4185b254322ef0fc852473a9b9e4c274b242ded8a4eae6f1e2badde0664cf57f2128aa3dc83e436f7e80928a01d93bf25011eedf0190d0bf3619cd555":"b4a22f5598f79d34f0b9600763c081b0200ba489da7028ad0283828545c6d594":"fa3edc0962b20a9d9e1d0afcad907c8097c21d7a65c0e47c63d65cea94bf43bd":"49ba791a227e9e391e04225ad67f43f64754daac0b0bb4c6db77320943231ec3":"32f313ded225289793c14a71d1d32c9f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a37f9ed6c4e8f74ff16046b0678ef7bd24fcdca247b771ea1ce1fd48e3f5d2067e38aaf64ec59f1f49d96fa85e60ef03":"95da91f4185b254322ef0fc852473a9b9e4c274b242ded8a4eae6f1e2badde0664cf57f2128aa3dc83e436f7e80928a01d93bf25011eedf0190d0bf3619cd555":"b4a22f5598f79d34f0b9600763c081b0200ba489da7028ad0283828545c6d594":"fa3edc0962b20a9d9e1d0afcad907c8097c21d7a65c0e47c63d65cea94bf43bd":"49ba791a227e9e391e04225ad67f43f64754daac0b0bb4c6db77320943231ec3":"32f313ded225289793c14a71d1d32c9f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #9 -ctr_drbg_validate_nopr:"87f85b9c19eba1d953b6613cf555c21bc74428d9a8fee15e6cd717e240506f3e80860423973a66c61820d4ce1c6bb77d":"f22dd3517350176e35e1b7ecc8c00bea4747f0ac17bda1b1ddf8cdf7be53ff8c326268366e89cf3b023a9646177a0dcca902f0c98bf3840c9cbdf5c0494bee3c":"611caa00f93d4456fd2abb90de4dbcd934afbf1a56c2c4633b704c998f649960":"cba68367dc2fc92250e23e2b1a547fb3231b2beaab5e5a2ee39c5c74c9bab5f5":"f4895c9653b44a96152b893b7c94db80057fb67824d61c5c4186b9d8f16d3d98":"a05de6531a1aa1b2ba3faea8ad6ac209" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"87f85b9c19eba1d953b6613cf555c21bc74428d9a8fee15e6cd717e240506f3e80860423973a66c61820d4ce1c6bb77d":"f22dd3517350176e35e1b7ecc8c00bea4747f0ac17bda1b1ddf8cdf7be53ff8c326268366e89cf3b023a9646177a0dcca902f0c98bf3840c9cbdf5c0494bee3c":"611caa00f93d4456fd2abb90de4dbcd934afbf1a56c2c4633b704c998f649960":"cba68367dc2fc92250e23e2b1a547fb3231b2beaab5e5a2ee39c5c74c9bab5f5":"f4895c9653b44a96152b893b7c94db80057fb67824d61c5c4186b9d8f16d3d98":"a05de6531a1aa1b2ba3faea8ad6ac209" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #10 -ctr_drbg_validate_nopr:"9670deb707caabc888a3b0df7270942934732e02be728a4bedb5fc9ca4d675b2f3b47c7132c364ce6292cef7c19b60c7":"bba34e6f4ee27e5d4e885e59f8bbb0dc7353a8912e66637d7515a66e5398d9a8cbd328fed32f71bdd34c73cdf97e0d211be6dabfb0144e1011fd136cf01ea4e4":"9f55da36babd6ea42082f5f5d4330f023440bb864f8ad5498a29cf89757eaeab":"8013a309058c91c80f4d966f98bce1d4291003ad547e915777a3fce8ae2eaf77":"c83106272d44e832e94c7096c9c11f6342e12ec06d5db336424af73d12451406":"bc8d4d00609662c1163dca930901821d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"9670deb707caabc888a3b0df7270942934732e02be728a4bedb5fc9ca4d675b2f3b47c7132c364ce6292cef7c19b60c7":"bba34e6f4ee27e5d4e885e59f8bbb0dc7353a8912e66637d7515a66e5398d9a8cbd328fed32f71bdd34c73cdf97e0d211be6dabfb0144e1011fd136cf01ea4e4":"9f55da36babd6ea42082f5f5d4330f023440bb864f8ad5498a29cf89757eaeab":"8013a309058c91c80f4d966f98bce1d4291003ad547e915777a3fce8ae2eaf77":"c83106272d44e832e94c7096c9c11f6342e12ec06d5db336424af73d12451406":"bc8d4d00609662c1163dca930901821d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #11 -ctr_drbg_validate_nopr:"6d984c8ab923a7e118447fd53ad287b8f01d1e6112cff12bfb338ecd3ed16bafdd634677c600bdd68f852a946f45c3d9":"ed0e524ed2990ef348dbb15b3f964b12ad3109978d6952ae193b21e94510a47406926620798e71a0ffcbdd2e54ec45509d784a8bfc9d59cb733f9f11fc474b5e":"0a3a32260d04dd7a82fb0873ecae7db5e5a4b6a51b09f4bf8a989e1afacbda3b":"3cbcabb83aab5a3e54836bbf12d3a7862a18e2dffeeb8bdd5770936d61fd839a":"f63b30a3efc0273eba03bf3cf90b1e4ac20b00e53a317dbf77b0fe70960e7c60":"ab9af144e8fad6a978a636ad84e0469e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"6d984c8ab923a7e118447fd53ad287b8f01d1e6112cff12bfb338ecd3ed16bafdd634677c600bdd68f852a946f45c3d9":"ed0e524ed2990ef348dbb15b3f964b12ad3109978d6952ae193b21e94510a47406926620798e71a0ffcbdd2e54ec45509d784a8bfc9d59cb733f9f11fc474b5e":"0a3a32260d04dd7a82fb0873ecae7db5e5a4b6a51b09f4bf8a989e1afacbda3b":"3cbcabb83aab5a3e54836bbf12d3a7862a18e2dffeeb8bdd5770936d61fd839a":"f63b30a3efc0273eba03bf3cf90b1e4ac20b00e53a317dbf77b0fe70960e7c60":"ab9af144e8fad6a978a636ad84e0469e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #12 -ctr_drbg_validate_nopr:"2c59520d6f8ce946dcc5222f4fc80ba83f38df9dce2861412eebb1614245331626e7fb93eedbad33a12e94c276deff0a":"2882d4a30b22659b87ad2d71db1d7cf093ffca80079a4ef21660de9223940969afec70b0384a54b1de9bcca6b43fb182e58d8dfcad82b0df99a8929201476ae9":"d3c17a2d9c5da051b2d1825120814eaee07dfca65ab4df01195c8b1fcea0ed41":"dcc39555b87f31973ae085f83eaf497441d22ab6d87b69e47296b0ab51733687":"9a8a1b4ccf8230e3d3a1be79e60ae06c393fe6b1ca245281825317468ca114c7":"fba523a09c587ecad4e7e7fd81e5ca39" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2c59520d6f8ce946dcc5222f4fc80ba83f38df9dce2861412eebb1614245331626e7fb93eedbad33a12e94c276deff0a":"2882d4a30b22659b87ad2d71db1d7cf093ffca80079a4ef21660de9223940969afec70b0384a54b1de9bcca6b43fb182e58d8dfcad82b0df99a8929201476ae9":"d3c17a2d9c5da051b2d1825120814eaee07dfca65ab4df01195c8b1fcea0ed41":"dcc39555b87f31973ae085f83eaf497441d22ab6d87b69e47296b0ab51733687":"9a8a1b4ccf8230e3d3a1be79e60ae06c393fe6b1ca245281825317468ca114c7":"fba523a09c587ecad4e7e7fd81e5ca39" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #13 -ctr_drbg_validate_nopr:"1c1207f50b645aaed5c16fe36f6aae83af4924e6b98a7e2a2533a584c1bac123f8b6f0e05109e0132950ae97b389001a":"8ae9a5903da32a38b7c6fed92dd0c6a035ca5104a3528d71a3eacc2f1681379724991a0053e8dac65e35f3deee0435e99f86364577c8ebdba321872973dc9790":"568bfee681d7f9be23a175a3cbf441b513829a9cbdf0706c145fdcd7803ce099":"e32cb5fec72c068894aaeabfc1b8d5e0de0b5acdf287a82e130a46e846770dc2":"d4418c333687a1c15cac7d4021f7d8823a114bb98f92c8a6dccc59ff8ad51c1f":"194e3018377cef71610794006b95def5" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1c1207f50b645aaed5c16fe36f6aae83af4924e6b98a7e2a2533a584c1bac123f8b6f0e05109e0132950ae97b389001a":"8ae9a5903da32a38b7c6fed92dd0c6a035ca5104a3528d71a3eacc2f1681379724991a0053e8dac65e35f3deee0435e99f86364577c8ebdba321872973dc9790":"568bfee681d7f9be23a175a3cbf441b513829a9cbdf0706c145fdcd7803ce099":"e32cb5fec72c068894aaeabfc1b8d5e0de0b5acdf287a82e130a46e846770dc2":"d4418c333687a1c15cac7d4021f7d8823a114bb98f92c8a6dccc59ff8ad51c1f":"194e3018377cef71610794006b95def5" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #14 -ctr_drbg_validate_nopr:"28254014c5d6ebf9bd9e5f3946fc98e55fe351deee8fc70333e4f20f1f7719a522b3ea9a4424afe68208d1cc6c128c47":"98a0db985544c33990aee0f69655dba7198e6720ce56ff9d4662e26f0c6b4ee7ab599932c05295f6c5a4011085c5b2c861a5a8ae4f572ce614ff2dafc0fddb34":"64215cbe384f1f4cf548078ffd51f91eee9a8bae5aacdd19ca16bcaaf354f8ad":"2e21df638dabe24aebf62d97e25f701f781d12d0064f2f5a4a44d320c90b7260":"7f936274f74a466cbf69dbfe46db79f3c349377df683cb461f2da3b842ad438e":"25c469cc8407b82f42e34f11db3d8462" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"28254014c5d6ebf9bd9e5f3946fc98e55fe351deee8fc70333e4f20f1f7719a522b3ea9a4424afe68208d1cc6c128c47":"98a0db985544c33990aee0f69655dba7198e6720ce56ff9d4662e26f0c6b4ee7ab599932c05295f6c5a4011085c5b2c861a5a8ae4f572ce614ff2dafc0fddb34":"64215cbe384f1f4cf548078ffd51f91eee9a8bae5aacdd19ca16bcaaf354f8ad":"2e21df638dabe24aebf62d97e25f701f781d12d0064f2f5a4a44d320c90b7260":"7f936274f74a466cbf69dbfe46db79f3c349377df683cb461f2da3b842ad438e":"25c469cc8407b82f42e34f11db3d8462" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #0 -ctr_drbg_validate_nopr:"e26c8a13dae5c2da81023f27ab10b878":"fea104f90c5881df7ad1c863307bad22c98770ecd0d717513a2807682582e3e18e81d7935c8a7bacddd5176e7ca4911b9f8f5b1d9c349152fa215393eb006384":"":"":"":"fd87337c305a0a8ef8eef797601732c2" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e26c8a13dae5c2da81023f27ab10b878":"fea104f90c5881df7ad1c863307bad22c98770ecd0d717513a2807682582e3e18e81d7935c8a7bacddd5176e7ca4911b9f8f5b1d9c349152fa215393eb006384":"":"":"":"fd87337c305a0a8ef8eef797601732c2" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #1 -ctr_drbg_validate_nopr:"8d7dda20a9807804bfc37bd7472d3b0c":"1d723cbc2ff2c115160e7240340adbf31c717696d0fdfecf3ec21150fca00cde477d37e2abbe32f399a505b74d82e502fbff94cecac87e87127d1397d3d76532":"":"":"":"7221761b913b1f50125abca6c3b2f229" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"8d7dda20a9807804bfc37bd7472d3b0c":"1d723cbc2ff2c115160e7240340adbf31c717696d0fdfecf3ec21150fca00cde477d37e2abbe32f399a505b74d82e502fbff94cecac87e87127d1397d3d76532":"":"":"":"7221761b913b1f50125abca6c3b2f229" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #2 -ctr_drbg_validate_nopr:"c02e3b6fd4fea7ec517a232f48aaa8cb":"0820fc21cecba6b2fe053a269a34e6a7637dedaf55ef46d266f672ca7cfd9cc21cd807e2b7f6a1c640b4f059952ae6da7282c5c32959fed39f734a5e88a408d2":"":"":"":"667d4dbefe938d6a662440a17965a334" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"c02e3b6fd4fea7ec517a232f48aaa8cb":"0820fc21cecba6b2fe053a269a34e6a7637dedaf55ef46d266f672ca7cfd9cc21cd807e2b7f6a1c640b4f059952ae6da7282c5c32959fed39f734a5e88a408d2":"":"":"":"667d4dbefe938d6a662440a17965a334" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #3 -ctr_drbg_validate_nopr:"9aee0326f9b16f88a4114e8d49b8e282":"ef0aae3f9c425253205215e5bf0ad70f141ad8cc72a332247cfe989601ca4fc52ba48b82db4d00fe1f279979b5aed1ae2ec2b02d2c921ee2d9cb89e3a900b97d":"":"":"":"651ad783fe3def80a8456552e405b98d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"9aee0326f9b16f88a4114e8d49b8e282":"ef0aae3f9c425253205215e5bf0ad70f141ad8cc72a332247cfe989601ca4fc52ba48b82db4d00fe1f279979b5aed1ae2ec2b02d2c921ee2d9cb89e3a900b97d":"":"":"":"651ad783fe3def80a8456552e405b98d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #4 -ctr_drbg_validate_nopr:"1e7a4961d1cd2fd30f571b92a763c2c5":"a9262ed5b54880cc8ecd4119cce9afe3de8875d403f7ca6b8ed8c88559470b29e644fddd83e127c5f938bc8a425db169c33c5c2d0b0c5133c8f87bbc0b0a7d79":"":"":"":"1124c509ca52693977cf461b0f0a0da9" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1e7a4961d1cd2fd30f571b92a763c2c5":"a9262ed5b54880cc8ecd4119cce9afe3de8875d403f7ca6b8ed8c88559470b29e644fddd83e127c5f938bc8a425db169c33c5c2d0b0c5133c8f87bbc0b0a7d79":"":"":"":"1124c509ca52693977cf461b0f0a0da9" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #5 -ctr_drbg_validate_nopr:"ae0b0d2e84f48c632f031356cdea60ac":"554cf6fad1c376ad6148cd40b53105c16e2f5dd5fa564865b26faa8c318150bfb2294e711735df5eb86ff4b4e778531793bad42403d93a80d05c5421229a53da":"":"":"":"1212e5d3070b1cdf52c0217866481c58" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ae0b0d2e84f48c632f031356cdea60ac":"554cf6fad1c376ad6148cd40b53105c16e2f5dd5fa564865b26faa8c318150bfb2294e711735df5eb86ff4b4e778531793bad42403d93a80d05c5421229a53da":"":"":"":"1212e5d3070b1cdf52c0217866481c58" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #6 -ctr_drbg_validate_nopr:"16b8c7495d43cd2ff5f65ad2ab48ecef":"7cffe2bef0d42374f7263a386b67fba991e59cefd73590cbcde3a4dc635a5a328f1a8e5edd3ada75854f251ee9f2de6cd247f64c6ca4f6c983805aa0fe9d3106":"":"":"":"d3869a9c5004b8a6ae8d8f0f461b602b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"16b8c7495d43cd2ff5f65ad2ab48ecef":"7cffe2bef0d42374f7263a386b67fba991e59cefd73590cbcde3a4dc635a5a328f1a8e5edd3ada75854f251ee9f2de6cd247f64c6ca4f6c983805aa0fe9d3106":"":"":"":"d3869a9c5004b8a6ae8d8f0f461b602b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #7 -ctr_drbg_validate_nopr:"a2d5eff6f73f98e5b04c01967dffa69b":"59759bb91b3c4feb18c0f086269ec52e097b67698f4dfe91ebe8bef851caa35cadb3fd22d1309f13510e1252856c71394a8e210fdbf3c7aae7998865f98e8744":"":"":"":"a1f99bd9522342e963af2ec8eed25c08" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a2d5eff6f73f98e5b04c01967dffa69b":"59759bb91b3c4feb18c0f086269ec52e097b67698f4dfe91ebe8bef851caa35cadb3fd22d1309f13510e1252856c71394a8e210fdbf3c7aae7998865f98e8744":"":"":"":"a1f99bd9522342e963af2ec8eed25c08" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #8 -ctr_drbg_validate_nopr:"ea1f47fe5e281136706419ea9b652967":"0ec7c617f85bec74044111020c977be32ab8050b326ebc03715bbbffa5a34622f2264d4b5141b7883281c21ea91981155a64fb7b902e674e9a41a8a86c32052b":"":"":"":"daf75b8288fc66802b23af5fd04a9434" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ea1f47fe5e281136706419ea9b652967":"0ec7c617f85bec74044111020c977be32ab8050b326ebc03715bbbffa5a34622f2264d4b5141b7883281c21ea91981155a64fb7b902e674e9a41a8a86c32052b":"":"":"":"daf75b8288fc66802b23af5fd04a9434" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #9 -ctr_drbg_validate_nopr:"6f072c681a82c00dcd0d9dd5b7ffa2af":"cd7ce90f0141e80f6bd6ff3d981d8a0a877d0ddae7c98f9091763b5946fc38b64c1ef698485007d53251ad278daf5d4ae94a725d617fc9a45a919a9e785a9849":"":"":"":"39c0144f28c5a490eff6221b62384602" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"6f072c681a82c00dcd0d9dd5b7ffa2af":"cd7ce90f0141e80f6bd6ff3d981d8a0a877d0ddae7c98f9091763b5946fc38b64c1ef698485007d53251ad278daf5d4ae94a725d617fc9a45a919a9e785a9849":"":"":"":"39c0144f28c5a490eff6221b62384602" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #10 -ctr_drbg_validate_nopr:"9d730655366e2aa89ee09332bd0a5053":"854766e842eb165a31551f96008354bca1628a9520d29c3cc4f6a41068bf76d8054b75b7d69f5865266c310b5e9f0290af37c5d94535cb5dc9c854ea1cb36eb7":"":"":"":"baa2a3ed6fdc049d0f158693db8c70ef" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"9d730655366e2aa89ee09332bd0a5053":"854766e842eb165a31551f96008354bca1628a9520d29c3cc4f6a41068bf76d8054b75b7d69f5865266c310b5e9f0290af37c5d94535cb5dc9c854ea1cb36eb7":"":"":"":"baa2a3ed6fdc049d0f158693db8c70ef" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #11 -ctr_drbg_validate_nopr:"3363881611bfd5d16814360e83d8544f":"6abfab14cbf222d553d0e930a38941f6f271b48943ea6f69e796e30135bc9eb30204b77ab416ac066da0a649c8558e5a0eac62f54f2f6e66c207cab461c71510":"":"":"":"5be410ce54288e881acd3e566964df78" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"3363881611bfd5d16814360e83d8544f":"6abfab14cbf222d553d0e930a38941f6f271b48943ea6f69e796e30135bc9eb30204b77ab416ac066da0a649c8558e5a0eac62f54f2f6e66c207cab461c71510":"":"":"":"5be410ce54288e881acd3e566964df78" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #12 -ctr_drbg_validate_nopr:"14e589065423528ff84a1f89507ab519":"0d2e446cad387a962ff2217c7cf4826dcabb997ab7f74f64aa18fbcb69151993f263925ae71f9dfdff122bb61802480f2803930efce01a3f37c97101893c140f":"":"":"":"fc2d3df6c9aae68fb01d8382fcd82104" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"14e589065423528ff84a1f89507ab519":"0d2e446cad387a962ff2217c7cf4826dcabb997ab7f74f64aa18fbcb69151993f263925ae71f9dfdff122bb61802480f2803930efce01a3f37c97101893c140f":"":"":"":"fc2d3df6c9aae68fb01d8382fcd82104" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #13 -ctr_drbg_validate_nopr:"974c5ae90347d839475f0f994f2bf01d":"aa04d9fc56349fdd31d868e9efc2938f9104c0291e55ac0aa0c24ec4609731b8e0ac04b42180bde1af6ad1b26faff8a6de60a8a4a828cd6f8758c54b6037a0ee":"":"":"":"3caec482015003643d5a319a2af48fb4" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"974c5ae90347d839475f0f994f2bf01d":"aa04d9fc56349fdd31d868e9efc2938f9104c0291e55ac0aa0c24ec4609731b8e0ac04b42180bde1af6ad1b26faff8a6de60a8a4a828cd6f8758c54b6037a0ee":"":"":"":"3caec482015003643d5a319a2af48fb4" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #14 -ctr_drbg_validate_nopr:"b3a110587a16c1eafe51128a66816ecf":"203bba645fb5ccee3383cf402e04c713b7a6b6cca8b154e827520daac4ea3a0247bbdc3b2cd853e170587d22c70fb96c320ea71cb80c04826316c7317c797b8a":"":"":"":"9af4f67a30a4346e0cfcf51c45fd2589" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b3a110587a16c1eafe51128a66816ecf":"203bba645fb5ccee3383cf402e04c713b7a6b6cca8b154e827520daac4ea3a0247bbdc3b2cd853e170587d22c70fb96c320ea71cb80c04826316c7317c797b8a":"":"":"":"9af4f67a30a4346e0cfcf51c45fd2589" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #0 -ctr_drbg_validate_nopr:"55546068cd524c51496c5fc9622b64c6":"951e712d057028158831ca8c74d4ae303c6e4641c344a1c80292260bdd9d8e2f5b97606370e95903e3124659de3e3f6e021cd9ccc86aa4a619c0e94b2a9aa3cc":"2d6de8661c7a30a0ca6a20c13c4c04421ba200fbef4f6eb499c17aee1561faf1":"41797b2eeaccb8a002538d3480cb0b76060ee5ba9d7e4a2bb2b201154f61c975":"b744980bb0377e176b07f48e7994fffd7b0d8a539e1f02a5535d2f4051f054f3":"65b9f7382ed578af03efa2008dbdd56f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"55546068cd524c51496c5fc9622b64c6":"951e712d057028158831ca8c74d4ae303c6e4641c344a1c80292260bdd9d8e2f5b97606370e95903e3124659de3e3f6e021cd9ccc86aa4a619c0e94b2a9aa3cc":"2d6de8661c7a30a0ca6a20c13c4c04421ba200fbef4f6eb499c17aee1561faf1":"41797b2eeaccb8a002538d3480cb0b76060ee5ba9d7e4a2bb2b201154f61c975":"b744980bb0377e176b07f48e7994fffd7b0d8a539e1f02a5535d2f4051f054f3":"65b9f7382ed578af03efa2008dbdd56f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #1 -ctr_drbg_validate_nopr:"a0c92565640a3315cac8da6d0458fb07":"6e9b31755c1f45df7d685f86044ab3bc25433a3ff08ab5de7154e06b0867f4e3531ed2e2a15ab63c611fc2894240fdac1d3292d1b36da87caa2080d1c41bcf24":"c6c74690bdee26288d2f87a06435d664431206b23b24f426e847fb892d40d5d5":"4e7dc1adbc8bc16ba7b584c18a0d7e4383c470bff2f320af54ad5ade5f43265b":"c6fb8ee194a339726f5051b91925c6a214079a661ec78358e98fc4f41e8c4724":"c3f849ee7d87291301e11b467fa2162f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a0c92565640a3315cac8da6d0458fb07":"6e9b31755c1f45df7d685f86044ab3bc25433a3ff08ab5de7154e06b0867f4e3531ed2e2a15ab63c611fc2894240fdac1d3292d1b36da87caa2080d1c41bcf24":"c6c74690bdee26288d2f87a06435d664431206b23b24f426e847fb892d40d5d5":"4e7dc1adbc8bc16ba7b584c18a0d7e4383c470bff2f320af54ad5ade5f43265b":"c6fb8ee194a339726f5051b91925c6a214079a661ec78358e98fc4f41e8c4724":"c3f849ee7d87291301e11b467fa2162f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #2 -ctr_drbg_validate_nopr:"63e143bd6a87065a00eea930593f9b29":"62c2c790cb56518ed2d8d65952bbd4ab85a56463495c940b94f403a93338bdc96129feea9335b1a3e0ada7cf4c207f4732013bc6a52db41407bf5d6fe9183b3c":"7b4e9ff0c8f8c90f8b324c7189226d3adccd79df2d0c22b52fb31dbb5dfefba6":"49e1aecf2b96a366325dc1892c016a5535dd2480360a382e9cc78bf75b2bba37":"f4ce1d27e759f3ba4a56aaab713642b4c56810c9995fbfc04ce285429f95a8f4":"513111abaae3069e599b56f7e5fb91d1" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"63e143bd6a87065a00eea930593f9b29":"62c2c790cb56518ed2d8d65952bbd4ab85a56463495c940b94f403a93338bdc96129feea9335b1a3e0ada7cf4c207f4732013bc6a52db41407bf5d6fe9183b3c":"7b4e9ff0c8f8c90f8b324c7189226d3adccd79df2d0c22b52fb31dbb5dfefba6":"49e1aecf2b96a366325dc1892c016a5535dd2480360a382e9cc78bf75b2bba37":"f4ce1d27e759f3ba4a56aaab713642b4c56810c9995fbfc04ce285429f95a8f4":"513111abaae3069e599b56f7e5fb91d1" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #3 -ctr_drbg_validate_nopr:"98dc16e95f97b5b9d8287875774d9d19":"2fab4a629e4b21f27488a0c9ed36fc8e75bee0c386346c6ec59a6f045975e29818440a6638eb3b9e952e19df82d6dc7b8b9c18530aef763d0709b3b55433ddc6":"2e9d2f52a55df05fb8b9549947f8690c9ce410268d1d3aa7d69e63cbb28e4eb8":"57ecdad71d709dcdb1eba6cf36e0ecf04aaccd7527ca44c6f96768968027274f":"7b2da3d1ae252a71bccbb318e0eec95493a236f0dec97f2600de9f0743030529":"841882e4d9346bea32b1216eebc06aac" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"98dc16e95f97b5b9d8287875774d9d19":"2fab4a629e4b21f27488a0c9ed36fc8e75bee0c386346c6ec59a6f045975e29818440a6638eb3b9e952e19df82d6dc7b8b9c18530aef763d0709b3b55433ddc6":"2e9d2f52a55df05fb8b9549947f8690c9ce410268d1d3aa7d69e63cbb28e4eb8":"57ecdad71d709dcdb1eba6cf36e0ecf04aaccd7527ca44c6f96768968027274f":"7b2da3d1ae252a71bccbb318e0eec95493a236f0dec97f2600de9f0743030529":"841882e4d9346bea32b1216eebc06aac" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #4 -ctr_drbg_validate_nopr:"5dbac5c313527d4d0e5ca9b6f5596ed7":"c00b28c78da4f9ce159741437fe7f90e4e23ecd01cd292f197202decbbc823d9ce46b8191c11e8f8d007d38e2ecd93b8bd9bbad5812aaf547ddf4c7a6738b777":"460c54f4c3fe49d9b25b069ff6664517ed3b234890175a59cde5c3bc230c0a9e":"bf5187f1f55ae6711c2bc1884324490bf2d29d29e95cad7a1c295045eed5a310":"28fd8277dcb807741d4d5cb255a8d9a32ef56a880ccf2b3dcca54645bd6f1013":"b488f5c13bb017b0d9de2092d577c76e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"5dbac5c313527d4d0e5ca9b6f5596ed7":"c00b28c78da4f9ce159741437fe7f90e4e23ecd01cd292f197202decbbc823d9ce46b8191c11e8f8d007d38e2ecd93b8bd9bbad5812aaf547ddf4c7a6738b777":"460c54f4c3fe49d9b25b069ff6664517ed3b234890175a59cde5c3bc230c0a9e":"bf5187f1f55ae6711c2bc1884324490bf2d29d29e95cad7a1c295045eed5a310":"28fd8277dcb807741d4d5cb255a8d9a32ef56a880ccf2b3dcca54645bd6f1013":"b488f5c13bb017b0d9de2092d577c76e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #5 -ctr_drbg_validate_nopr:"254d5f5044415c694a89249b0b6e1a2c":"4c1cc9ebe7a03cde31860637d8222faeefa9cbf789fab62e99a98d83084fef29eafcf7177d62d55435a1acb77e7a61ad86c47d1950b8683e167fe3ece3f8c9e8":"71af584657160f0f0b81740ef93017a37c174bee5a02c8967f087fdbfd33bfde":"96e8522f6ed8e8a9772ffb19e9416a1c6293ad6d1ecd317972e2f6258d7d68dd":"3aaa5e4d6af79055742150e630c5e3a46288e216d6607793c021d6705349f96a":"66629af4a0e90550b9bd3811243d6b86" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"254d5f5044415c694a89249b0b6e1a2c":"4c1cc9ebe7a03cde31860637d8222faeefa9cbf789fab62e99a98d83084fef29eafcf7177d62d55435a1acb77e7a61ad86c47d1950b8683e167fe3ece3f8c9e8":"71af584657160f0f0b81740ef93017a37c174bee5a02c8967f087fdbfd33bfde":"96e8522f6ed8e8a9772ffb19e9416a1c6293ad6d1ecd317972e2f6258d7d68dd":"3aaa5e4d6af79055742150e630c5e3a46288e216d6607793c021d6705349f96a":"66629af4a0e90550b9bd3811243d6b86" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #6 -ctr_drbg_validate_nopr:"b46fceed0fcc29665815cc9459971913":"ff62d52aed55d8e966044f7f7c5013b4915197c73668e01b4487c3243bbf5f9248a4fdd6ef0f63b87fc8d1c5d514ff243319b2fbdfa474d5f83b935399655e15":"994d6b5393fbf0351f0bcfb48e1e763b377b732c73bf8e28dec720a2cadcb8a5":"118bb8c7a43b9c30afaf9ce4db3e6a60a3f9d01c30b9ab3572662955808b41e4":"bb47e443090afc32ee34873bd106bf867650adf5b5d90a2e7d0e58ed0ae83e8a":"1865fee6024db510690725f16b938487" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b46fceed0fcc29665815cc9459971913":"ff62d52aed55d8e966044f7f7c5013b4915197c73668e01b4487c3243bbf5f9248a4fdd6ef0f63b87fc8d1c5d514ff243319b2fbdfa474d5f83b935399655e15":"994d6b5393fbf0351f0bcfb48e1e763b377b732c73bf8e28dec720a2cadcb8a5":"118bb8c7a43b9c30afaf9ce4db3e6a60a3f9d01c30b9ab3572662955808b41e4":"bb47e443090afc32ee34873bd106bf867650adf5b5d90a2e7d0e58ed0ae83e8a":"1865fee6024db510690725f16b938487" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #7 -ctr_drbg_validate_nopr:"e1a5dd32fc7cefb281d5d6ce3200f4ca":"bf1ba4166007b53fcaee41f9c54771c8a0b309a52ea7894a005783c1e3e43e2eb9871d7909a1c3567953aabdf75e38c8f5578c51a692d883755102a0c82c7c12":"32e9922bd780303828091a140274d04f879cd821f352bd18bcaa49ffef840010":"01830ddd2f0e323c90830beddedf1480e6c23b0d99c2201871f18cc308ab3139":"f36d792dbde7609b8bf4724d7d71362840b309c5f2961e2537c8b5979a569ae8":"7080e8379a43c2e28e07d0c7ed9705a8" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e1a5dd32fc7cefb281d5d6ce3200f4ca":"bf1ba4166007b53fcaee41f9c54771c8a0b309a52ea7894a005783c1e3e43e2eb9871d7909a1c3567953aabdf75e38c8f5578c51a692d883755102a0c82c7c12":"32e9922bd780303828091a140274d04f879cd821f352bd18bcaa49ffef840010":"01830ddd2f0e323c90830beddedf1480e6c23b0d99c2201871f18cc308ab3139":"f36d792dbde7609b8bf4724d7d71362840b309c5f2961e2537c8b5979a569ae8":"7080e8379a43c2e28e07d0c7ed9705a8" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #8 -ctr_drbg_validate_nopr:"d1b7be857a422b425ae62c61e90a192a":"6ac34c4ce22b644632283ab13e294df2093e939d32411340b046c26fcc449d0fd6d14132c7205df303dbb663190e6e86ad12e14e145b6603308241f38d94eb5d":"aacfe8553d5ffef6abc3fd8f94d796cae2079ff04f7ab1b41982003f02427c7a":"01d2d1bc29d6a6b52bb29bd6652be772096ca23c838c40730d5b4a4f8f735daa":"27af728ee07d3f5902f4e56453b6a9feb308ef14795eb5630b2651debdd36d5b":"b03fbcd03fa1cc69db0a4e3492a52bad" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"d1b7be857a422b425ae62c61e90a192a":"6ac34c4ce22b644632283ab13e294df2093e939d32411340b046c26fcc449d0fd6d14132c7205df303dbb663190e6e86ad12e14e145b6603308241f38d94eb5d":"aacfe8553d5ffef6abc3fd8f94d796cae2079ff04f7ab1b41982003f02427c7a":"01d2d1bc29d6a6b52bb29bd6652be772096ca23c838c40730d5b4a4f8f735daa":"27af728ee07d3f5902f4e56453b6a9feb308ef14795eb5630b2651debdd36d5b":"b03fbcd03fa1cc69db0a4e3492a52bad" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #9 -ctr_drbg_validate_nopr:"a2c49aa6f3f92e36266bf267af5877ed":"5684c3eb99314127078484959314d52b3bc50cb3615c0eef6b48850d98aee04c528b0693be13ed1bb4040e8e96cb13c316143f0815cd68d1bb7931a3d9b88a3d":"566522085426b76bdef152adefd73ef0f76eee4614bc5a4391629ec49e0acffb":"30ef9585148dd2270c41540a4235328de8952f28cf5472df463e88e837419e99":"adc46e0afcf69302f62c84c5c4bfcbb7132f8db118d1a84dc2b910753fe86a2d":"4edc4383977ee91aaa2f5b9ac4257570" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a2c49aa6f3f92e36266bf267af5877ed":"5684c3eb99314127078484959314d52b3bc50cb3615c0eef6b48850d98aee04c528b0693be13ed1bb4040e8e96cb13c316143f0815cd68d1bb7931a3d9b88a3d":"566522085426b76bdef152adefd73ef0f76eee4614bc5a4391629ec49e0acffb":"30ef9585148dd2270c41540a4235328de8952f28cf5472df463e88e837419e99":"adc46e0afcf69302f62c84c5c4bfcbb7132f8db118d1a84dc2b910753fe86a2d":"4edc4383977ee91aaa2f5b9ac4257570" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #10 -ctr_drbg_validate_nopr:"43852c53041a3a4f710435dbd3e4382b":"ab7bca5595084bccdba80ade7ac3df2a0ce198fa49d29414c0249ec3d1c50d271ca74ba5c3521576a89a1964e6deded2d5ba7ff28a364a8f9235981bec1bedfa":"c5612a9540b64fc134074cb36f4c9ea62fff993938709b5d354a917e5265adee":"eee2258aba665aa6d3f5b8c2207f135276f597adb2a0fbfb16a20460e8cc3c68":"a6d6d126bed13dbcf2b327aa884b7260a9c388cb03751dbe9feb28a3fe351d62":"e04c3de51a1ffe8cda89e881c396584b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"43852c53041a3a4f710435dbd3e4382b":"ab7bca5595084bccdba80ade7ac3df2a0ce198fa49d29414c0249ec3d1c50d271ca74ba5c3521576a89a1964e6deded2d5ba7ff28a364a8f9235981bec1bedfa":"c5612a9540b64fc134074cb36f4c9ea62fff993938709b5d354a917e5265adee":"eee2258aba665aa6d3f5b8c2207f135276f597adb2a0fbfb16a20460e8cc3c68":"a6d6d126bed13dbcf2b327aa884b7260a9c388cb03751dbe9feb28a3fe351d62":"e04c3de51a1ffe8cda89e881c396584b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #11 -ctr_drbg_validate_nopr:"52628551ce90c338ed94b655d4f05811":"b3a4a3c4d3d53ffa41b85ce3b8f292b1cc8e5af7488286d4c581005f8c02c5545c09bb08d8470b8cffdf62731b1d4b75c036af7dc4f2f1fc7e9a496f3d235f2d":"f5f9d5b51075b12aa300afdc7b8ea3944fc8cf4d1e95625cc4e42fdfdcbeb169":"60bccbc7345f23733fe8f8eb9760975057238705d9cee33b3269f9bfedd72202":"c0fa3afd6e9decfbffa7ea6678d2481c5f55ec0a35172ff93214b997400e97c3":"5a113906e1ef76b7b75fefbf20d78ef8" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"52628551ce90c338ed94b655d4f05811":"b3a4a3c4d3d53ffa41b85ce3b8f292b1cc8e5af7488286d4c581005f8c02c5545c09bb08d8470b8cffdf62731b1d4b75c036af7dc4f2f1fc7e9a496f3d235f2d":"f5f9d5b51075b12aa300afdc7b8ea3944fc8cf4d1e95625cc4e42fdfdcbeb169":"60bccbc7345f23733fe8f8eb9760975057238705d9cee33b3269f9bfedd72202":"c0fa3afd6e9decfbffa7ea6678d2481c5f55ec0a35172ff93214b997400e97c3":"5a113906e1ef76b7b75fefbf20d78ef8" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #12 -ctr_drbg_validate_nopr:"0e4873c4cbcde280abc6711a66dbb81a":"1ab7c7d8fe8f505e1dd7ddb8e7cda962572f7004b2a14c7a7c5bcf24bd16616e2c42c50ae5db9981ccd7d0c79062ac572d3893486bd0ae1f99cbc1d28a9e4c1e":"e4b89e28663e853f8b380c8a4491b54121fe6927340a74342362c37d8d615b66":"619775878879eff9ee2189790ff6f187baed4ed1b156029b80e7a070a1072a09":"ba3d673e5e41bd1abbc7191cc4b9a945201b8fef0016e4774047ee2abf499e74":"4758fd021c34a5cf6bea760ad09438a0" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0e4873c4cbcde280abc6711a66dbb81a":"1ab7c7d8fe8f505e1dd7ddb8e7cda962572f7004b2a14c7a7c5bcf24bd16616e2c42c50ae5db9981ccd7d0c79062ac572d3893486bd0ae1f99cbc1d28a9e4c1e":"e4b89e28663e853f8b380c8a4491b54121fe6927340a74342362c37d8d615b66":"619775878879eff9ee2189790ff6f187baed4ed1b156029b80e7a070a1072a09":"ba3d673e5e41bd1abbc7191cc4b9a945201b8fef0016e4774047ee2abf499e74":"4758fd021c34a5cf6bea760ad09438a0" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #13 -ctr_drbg_validate_nopr:"0684e8ef93c3363ba535c4e573af1c24":"748a5f5fde271c563a8f8d15520d6818f7ed0efb9b434adf2ff9471b391dd225b37868179ffa9a6e58df3b1b765b8945685a2f966d29648dd86a42078339650b":"e90c82153d2280f1ddb55bd65e7752bf6717fbe08c49414f6c129bf608578db7":"c17e97c93cfabe0b925ca5d22615a06430a201b7595ad0d9967cc89a4777947d":"3d554c430c8928dcdb1f6d5e5a4306b309856a9b78c5f431c55d7ebd519443bb":"d3da71af70e196483c951d95eb3f0135" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0684e8ef93c3363ba535c4e573af1c24":"748a5f5fde271c563a8f8d15520d6818f7ed0efb9b434adf2ff9471b391dd225b37868179ffa9a6e58df3b1b765b8945685a2f966d29648dd86a42078339650b":"e90c82153d2280f1ddb55bd65e7752bf6717fbe08c49414f6c129bf608578db7":"c17e97c93cfabe0b925ca5d22615a06430a201b7595ad0d9967cc89a4777947d":"3d554c430c8928dcdb1f6d5e5a4306b309856a9b78c5f431c55d7ebd519443bb":"d3da71af70e196483c951d95eb3f0135" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #14 -ctr_drbg_validate_nopr:"89b885ddb12abc4f7422334f27c00439":"e2366eec626bfd9cb932bcaa0569de6a7a37cf1dfde1f25d00d1a0c89fe25fea592cbd2af7c8202521fa48e15f7cc7e97e431b222b516a3ad2bb7b55b7fcf7f4":"c77ee92bd17939efe9bee48af66589aee1d9fe4cd6c8ae26b74b3799e35342a6":"23e80d36ca72ecc38551e7e0a4f9502bed0e160f382d802f48fb2714ec6e3315":"6b83f7458dc813ce0b963b231c424e8bced599d002c0ef91a9c20dcc3f172ea5":"81d13a6b79f05137e233e3c3a1091360" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"89b885ddb12abc4f7422334f27c00439":"e2366eec626bfd9cb932bcaa0569de6a7a37cf1dfde1f25d00d1a0c89fe25fea592cbd2af7c8202521fa48e15f7cc7e97e431b222b516a3ad2bb7b55b7fcf7f4":"c77ee92bd17939efe9bee48af66589aee1d9fe4cd6c8ae26b74b3799e35342a6":"23e80d36ca72ecc38551e7e0a4f9502bed0e160f382d802f48fb2714ec6e3315":"6b83f7458dc813ce0b963b231c424e8bced599d002c0ef91a9c20dcc3f172ea5":"81d13a6b79f05137e233e3c3a1091360" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #0 -ctr_drbg_validate_nopr:"ff568be02a46343113f06949a16cc7d9da315aef82f5681f0459650e5e180e65d1d77b00e5ce3e3f9eb6c18efff4db36":"77de4e5db3b308c38c814228583dfd1eb415771f4ae30f9cc2d35b48075286a4e8c2c6f441d1aac496d0d4be395d078519e31cb77d06d6f7fd4c033bc40fd659":"":"":"":"448ac707ba934c909335425de62944d6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ff568be02a46343113f06949a16cc7d9da315aef82f5681f0459650e5e180e65d1d77b00e5ce3e3f9eb6c18efff4db36":"77de4e5db3b308c38c814228583dfd1eb415771f4ae30f9cc2d35b48075286a4e8c2c6f441d1aac496d0d4be395d078519e31cb77d06d6f7fd4c033bc40fd659":"":"":"":"448ac707ba934c909335425de62944d6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #1 -ctr_drbg_validate_nopr:"6f092b85eb9f96427642f69467911172cba6df86e0db08d04e824cde6fb91d9b9af2cea53f42d53c45ee3e69a2327172":"667d3ed9f41a154ea33b55182b8bee4d7d46eff8e890c7036cf7c2665d44c28f9e3a8cff166dabfaf262933d337e729e0b6a60a51d00ba18f877bdc9d0cc659e":"":"":"":"16a200f683ab862947e061cddaac5597" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"6f092b85eb9f96427642f69467911172cba6df86e0db08d04e824cde6fb91d9b9af2cea53f42d53c45ee3e69a2327172":"667d3ed9f41a154ea33b55182b8bee4d7d46eff8e890c7036cf7c2665d44c28f9e3a8cff166dabfaf262933d337e729e0b6a60a51d00ba18f877bdc9d0cc659e":"":"":"":"16a200f683ab862947e061cddaac5597" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #2 -ctr_drbg_validate_nopr:"26e635a6a2b6402b968c1eea13c6a980a0ee9b8497abc14fccdc5bf8439008861f74de2c200505185bf5907d3adc9de2":"80e56f9893beb9f22b2b03caa8f1861d5b31b37f636f2ccbc7e4040ad3073aa20f2f3c6bfefc041df8e57e7100794c42732b6d4b63d8bb51329ca99671d53c7c":"":"":"":"807586c977febcf2ad28fcd45e1a1deb" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"26e635a6a2b6402b968c1eea13c6a980a0ee9b8497abc14fccdc5bf8439008861f74de2c200505185bf5907d3adc9de2":"80e56f9893beb9f22b2b03caa8f1861d5b31b37f636f2ccbc7e4040ad3073aa20f2f3c6bfefc041df8e57e7100794c42732b6d4b63d8bb51329ca99671d53c7c":"":"":"":"807586c977febcf2ad28fcd45e1a1deb" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #3 -ctr_drbg_validate_nopr:"b239c485d319ce964d69bd3dbc5b7ab9cc72ac9134a25e641bcd3c8b6f89e7e08ef2d0a45cf67667a4e2e634b32d73ff":"c963e17ef46b7b2c68756019704ec7435ec093c423600b3f2f99dd8989f8539a11b1b0598e93e84d50b65e816e794421ab546b202e4b224a8494538dda85da82":"":"":"":"2a3218b4d59f99bd3825631a6eefb09c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b239c485d319ce964d69bd3dbc5b7ab9cc72ac9134a25e641bcd3c8b6f89e7e08ef2d0a45cf67667a4e2e634b32d73ff":"c963e17ef46b7b2c68756019704ec7435ec093c423600b3f2f99dd8989f8539a11b1b0598e93e84d50b65e816e794421ab546b202e4b224a8494538dda85da82":"":"":"":"2a3218b4d59f99bd3825631a6eefb09c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #4 -ctr_drbg_validate_nopr:"0239545a23735b803ae7cb7766194917d6cce164f7ec4f65c6ccd5ec1db5297722d4b7466589da4d39f4585856bc1d7e":"71a440b70a2b5ce41b85de27d987fa2a0628d7990dd7cd1460fddc5410ce6e9bb0ae4f90231f45bc71188fd94e4170389a8bbe4a7e781c95c9a97ad78ba7d07b":"":"":"":"9dafaa8b727c4829dda10a831e67419d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0239545a23735b803ae7cb7766194917d6cce164f7ec4f65c6ccd5ec1db5297722d4b7466589da4d39f4585856bc1d7e":"71a440b70a2b5ce41b85de27d987fa2a0628d7990dd7cd1460fddc5410ce6e9bb0ae4f90231f45bc71188fd94e4170389a8bbe4a7e781c95c9a97ad78ba7d07b":"":"":"":"9dafaa8b727c4829dda10a831e67419d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #5 -ctr_drbg_validate_nopr:"237e8916eadd65e3422fe59ab257b7e6957fe24f760b499fbd052241879e8294b01d2169ec2b98f52660d9f5170dee22":"d8908cfc1ea8518c1442e46731f30fdad85399894db262b8f4fdc0dbcbf11b60b60b25d3108f4b169fcbef621a14c635525fa3af8ccef6b91f808479509967f4":"":"":"":"593c39c56bb9e476550299ee8d85d2fc" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"237e8916eadd65e3422fe59ab257b7e6957fe24f760b499fbd052241879e8294b01d2169ec2b98f52660d9f5170dee22":"d8908cfc1ea8518c1442e46731f30fdad85399894db262b8f4fdc0dbcbf11b60b60b25d3108f4b169fcbef621a14c635525fa3af8ccef6b91f808479509967f4":"":"":"":"593c39c56bb9e476550299ee8d85d2fc" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #6 -ctr_drbg_validate_nopr:"28b6639b415c79012c749dc2a0d18433ec36eda55815f0841241453fa11b9d572b7c29208e01dbb0be91e1075f305d7f":"6767c3eb6ba1b19412c32bfe44e4d0317beba10f3abea328cda7b7c14109b72046c8691c1c7b28487037d381f77a3bbc8464a51b87de68bdc50ec9c658f915ab":"":"":"":"e390806219fa727e74a90011b4835ed6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"28b6639b415c79012c749dc2a0d18433ec36eda55815f0841241453fa11b9d572b7c29208e01dbb0be91e1075f305d7f":"6767c3eb6ba1b19412c32bfe44e4d0317beba10f3abea328cda7b7c14109b72046c8691c1c7b28487037d381f77a3bbc8464a51b87de68bdc50ec9c658f915ab":"":"":"":"e390806219fa727e74a90011b4835ed6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #7 -ctr_drbg_validate_nopr:"ce735a8549fc3f9dfc7b96bf0d48936a711439ac7271d715a278718aca9e2fe3c801030bc74b048ac1e40852345e87cc":"510b0dc06e84ceb901c7195c2f00ad7a04bdd75e0ab52b3d2cd47ddfcd89248dd58e3f1aa8c1ffe306f493905f65369eaed2a5b337dff8ac81c4c1e8903a6ad5":"":"":"":"ba871ba5843083b553a57cf8defa39d7" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ce735a8549fc3f9dfc7b96bf0d48936a711439ac7271d715a278718aca9e2fe3c801030bc74b048ac1e40852345e87cc":"510b0dc06e84ceb901c7195c2f00ad7a04bdd75e0ab52b3d2cd47ddfcd89248dd58e3f1aa8c1ffe306f493905f65369eaed2a5b337dff8ac81c4c1e8903a6ad5":"":"":"":"ba871ba5843083b553a57cf8defa39d7" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #8 -ctr_drbg_validate_nopr:"841ea92fa42c06769c5c52fe152d07837b8ff0048392caa5dd045054353d363b25439eb5885e96771dded4005f2baf42":"97511ae52590a0b64b75c37e10b89671880d2d6e8f90780ac27263dbc0e32d0824be5e80a88cf8fc3d4c607eb873c0322d09b9ca3498c4015c53ca6fee890093":"":"":"":"a8fb31362bd997adf4d9116e23dbaf10" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"841ea92fa42c06769c5c52fe152d07837b8ff0048392caa5dd045054353d363b25439eb5885e96771dded4005f2baf42":"97511ae52590a0b64b75c37e10b89671880d2d6e8f90780ac27263dbc0e32d0824be5e80a88cf8fc3d4c607eb873c0322d09b9ca3498c4015c53ca6fee890093":"":"":"":"a8fb31362bd997adf4d9116e23dbaf10" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #9 -ctr_drbg_validate_nopr:"55cd76fa5f004b97bb8e14170f79f52715d18c60f142b06d16e8e06c274798190a79c8b325163989d86323c03dbe0d68":"bafc0ba64669c9a36514bde6169034101f29e2a0a4b9a55c0aae7dff0c5aca2371b523e26dc44bf75493bdaa023d1555294178288b70f1ae72150d9f7265b4e6":"":"":"":"fa16dbdaf01b3c202426adabf61fa64a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"55cd76fa5f004b97bb8e14170f79f52715d18c60f142b06d16e8e06c274798190a79c8b325163989d86323c03dbe0d68":"bafc0ba64669c9a36514bde6169034101f29e2a0a4b9a55c0aae7dff0c5aca2371b523e26dc44bf75493bdaa023d1555294178288b70f1ae72150d9f7265b4e6":"":"":"":"fa16dbdaf01b3c202426adabf61fa64a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #10 -ctr_drbg_validate_nopr:"ff3f3098fa3d2b23b38ed982e7afb61d46b4848c878b9280f8e5ed6bd81176e76f0a2a85071a411829cf84421c22f23e":"92194e2c700fa724489683d0b6ddcf72c89b9c3f3ff584e802ae426be4908b1ade093bcf9baf7738b988dc0fde1739498a97c9610da853a7c83981c6a7b68096":"":"":"":"f85490426dc243ba09f9719bff73545a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ff3f3098fa3d2b23b38ed982e7afb61d46b4848c878b9280f8e5ed6bd81176e76f0a2a85071a411829cf84421c22f23e":"92194e2c700fa724489683d0b6ddcf72c89b9c3f3ff584e802ae426be4908b1ade093bcf9baf7738b988dc0fde1739498a97c9610da853a7c83981c6a7b68096":"":"":"":"f85490426dc243ba09f9719bff73545a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #11 -ctr_drbg_validate_nopr:"7242c1020a63770cccf6f8100970990232a9d11d61c9b0d38fe5e7a568a86252a66481212e5d53c868561298dd5bdeec":"7c3806a32ccf3252ac27a92a07209cd7000b160faa70b9024420b903587d1d77f002d3abe28b563d32ccc502b88f83bc5996f3dbbf0f57835839eadd94563b9d":"":"":"":"2232181f08c1569efaad1a82bcb5f3ba" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"7242c1020a63770cccf6f8100970990232a9d11d61c9b0d38fe5e7a568a86252a66481212e5d53c868561298dd5bdeec":"7c3806a32ccf3252ac27a92a07209cd7000b160faa70b9024420b903587d1d77f002d3abe28b563d32ccc502b88f83bc5996f3dbbf0f57835839eadd94563b9d":"":"":"":"2232181f08c1569efaad1a82bcb5f3ba" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #12 -ctr_drbg_validate_nopr:"a2e445290fed8187df6d2a57e68385bb62d700cb8f140410766b53e69e6a0f2939bbfa7ce091525c9051f064e383a2e1":"fdae5f1ea253108fcb255d215a3ce1dc1d101acf89de4423b75a74619e95f3feaa35b5e0bec430b0ad9567df818989c36c77742129af335c90ceb6dd79c7d2c4":"":"":"":"3841e2d795b17cb9a2081d6016a1a71d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a2e445290fed8187df6d2a57e68385bb62d700cb8f140410766b53e69e6a0f2939bbfa7ce091525c9051f064e383a2e1":"fdae5f1ea253108fcb255d215a3ce1dc1d101acf89de4423b75a74619e95f3feaa35b5e0bec430b0ad9567df818989c36c77742129af335c90ceb6dd79c7d2c4":"":"":"":"3841e2d795b17cb9a2081d6016a1a71d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #13 -ctr_drbg_validate_nopr:"bc885454e385d911336dda9b7a609a6a7079a4a5a860fcd704161c34658bd98685bb03418b7f24f2ed9475eb8ceb232e":"77bef884a91126564b3214029ac6842d86e4c1fa283e33d6828d428377416f66947e39a4a6708e10bfdae8337a6f302420a6649fc109d0f094c18c1e9361375a":"":"":"":"ea20780ed280d8109f811a6a398c3e76" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"bc885454e385d911336dda9b7a609a6a7079a4a5a860fcd704161c34658bd98685bb03418b7f24f2ed9475eb8ceb232e":"77bef884a91126564b3214029ac6842d86e4c1fa283e33d6828d428377416f66947e39a4a6708e10bfdae8337a6f302420a6649fc109d0f094c18c1e9361375a":"":"":"":"ea20780ed280d8109f811a6a398c3e76" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #14 -ctr_drbg_validate_nopr:"c1825cf00cdc2da93adb3e7a33c1f3a76c49166887883744ea2683ddca23f31900f25c434364c992a6d913f753a9c42a":"56940a6fc4823c9e42e8ffed63fc3cf46d0a2b305c236a511b0b5ec7005ecd8989bf2006ebe52ed55845f7cc25d3d0086cece95f0bff6fa7e17ddf474704abfe":"":"":"":"b037c7f0f85f4d7eaeeb17f4c8643a74" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"c1825cf00cdc2da93adb3e7a33c1f3a76c49166887883744ea2683ddca23f31900f25c434364c992a6d913f753a9c42a":"56940a6fc4823c9e42e8ffed63fc3cf46d0a2b305c236a511b0b5ec7005ecd8989bf2006ebe52ed55845f7cc25d3d0086cece95f0bff6fa7e17ddf474704abfe":"":"":"":"b037c7f0f85f4d7eaeeb17f4c8643a74" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #0 -ctr_drbg_validate_nopr:"19b83c0deea6463a3912d21ffc8d8041a5b30640352abc9652770cfca99dc53c9c09942ddd67b91f4da50a8615462ce4":"5d85c56d0d20ee39958a90f301d2f8bb136fa34d09b41a0c9375114a0df9c1dcdb2a62c4be398d9eaf2440949b806f0e5a977da608eeb652a41711d1e9b72655":"9c1db928b95c84cb674060a6d2f6b7a6a5d43e9ee967e9f821bf309ca5f8821f":"a3111cb57365c617df0b0bb3a1aada49ca789bc75903eeb21e42a7d3d0dd0825":"ce7f557c70676987d13aca60bc4585147efeed97be139871a1b29caa1e180af9":"4a49430277d64446e2fa75763eb79ec6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"19b83c0deea6463a3912d21ffc8d8041a5b30640352abc9652770cfca99dc53c9c09942ddd67b91f4da50a8615462ce4":"5d85c56d0d20ee39958a90f301d2f8bb136fa34d09b41a0c9375114a0df9c1dcdb2a62c4be398d9eaf2440949b806f0e5a977da608eeb652a41711d1e9b72655":"9c1db928b95c84cb674060a6d2f6b7a6a5d43e9ee967e9f821bf309ca5f8821f":"a3111cb57365c617df0b0bb3a1aada49ca789bc75903eeb21e42a7d3d0dd0825":"ce7f557c70676987d13aca60bc4585147efeed97be139871a1b29caa1e180af9":"4a49430277d64446e2fa75763eb79ec6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #1 -ctr_drbg_validate_nopr:"239f21be6cda23e8660c8a5e04c79f6dad6f363ac6dcffd9228699ae43fbce5ac3c51645500cb3eae68f0b604dc4472c":"2975a099f7e6530e5576534c25171f39131d6bffb99259f7f2bbf7d77de9fb1e829052b54a9631a733113021692eba1097438347c6de82307a0c2bb308edf065":"d451a54584e6d1d634217379e7e60e67303e19dd4ba63b097899c7349a5a7433":"a33dc24c6a656eb26275415581d568b7c2424a9c5fb9e2944ca35ecbf641f713":"8dfccc62379af46844df136122b72a878d9d61b40ccaa029b09e6b9f0b4d0192":"005e91760d89ecb64b5fc3b0e222fca3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"239f21be6cda23e8660c8a5e04c79f6dad6f363ac6dcffd9228699ae43fbce5ac3c51645500cb3eae68f0b604dc4472c":"2975a099f7e6530e5576534c25171f39131d6bffb99259f7f2bbf7d77de9fb1e829052b54a9631a733113021692eba1097438347c6de82307a0c2bb308edf065":"d451a54584e6d1d634217379e7e60e67303e19dd4ba63b097899c7349a5a7433":"a33dc24c6a656eb26275415581d568b7c2424a9c5fb9e2944ca35ecbf641f713":"8dfccc62379af46844df136122b72a878d9d61b40ccaa029b09e6b9f0b4d0192":"005e91760d89ecb64b5fc3b0e222fca3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #2 -ctr_drbg_validate_nopr:"e326abbe1db3ead3738d2ca4d9f1d62080cd23ff3396f43a0af992bed2420cec6661dfaac83c3c4d83347ac840f7dc14":"37c94d11ed0e93b8199d43d6eb242165dddd12fe39c0bea4cdef6bcfeb5d17bb866f080a9daef128f685fb3bc59c945927fb0aa3e17068515c3c92fbdf04a228":"1ff41405dbb3b12b8ddc973069edc2d2801af0e0dc9bde2cdd35c5b2d4091509":"138b6d2eabef4b32174afb0156ad1df570cf6e5f6ebde5d19cc30daffd9ca4f2":"f27cf7422808c54c58fcdde1cece92f5342c7a10ac43ab3b2e53362b2272e3ad":"506d6fae6fff9f222e65ac86df61a832" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e326abbe1db3ead3738d2ca4d9f1d62080cd23ff3396f43a0af992bed2420cec6661dfaac83c3c4d83347ac840f7dc14":"37c94d11ed0e93b8199d43d6eb242165dddd12fe39c0bea4cdef6bcfeb5d17bb866f080a9daef128f685fb3bc59c945927fb0aa3e17068515c3c92fbdf04a228":"1ff41405dbb3b12b8ddc973069edc2d2801af0e0dc9bde2cdd35c5b2d4091509":"138b6d2eabef4b32174afb0156ad1df570cf6e5f6ebde5d19cc30daffd9ca4f2":"f27cf7422808c54c58fcdde1cece92f5342c7a10ac43ab3b2e53362b2272e3ad":"506d6fae6fff9f222e65ac86df61a832" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #3 -ctr_drbg_validate_nopr:"cb0229d2bb72d910b0169e8f93318905aef8dd93ed91a2f8388545db32db3f2489e7988b50de64c49a9f7feb5abe8630":"514ec8c02439290853434e75e3d0bd159eacd5ac13b8f202cfd5c36cdc0fe99b53a1b7a1619e94eb661ac825a48ea5ef8bb9120dd6efc351e39eb7cc5223f637":"a6ed69c9216c551793107f1bdaa04944f6d76fe4474f64bb08b0ebc10a18f337":"e0bc1cc56fdfeef686e0c7ec359e2e8bd48d76c8643c40d12325328170bbf702":"87c5b23aa3c100ff9e368fc47534ff8fa2f9e2bfd3599519ee6f60164485cf6d":"bd419968f636e374268ccdd62403f79c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"cb0229d2bb72d910b0169e8f93318905aef8dd93ed91a2f8388545db32db3f2489e7988b50de64c49a9f7feb5abe8630":"514ec8c02439290853434e75e3d0bd159eacd5ac13b8f202cfd5c36cdc0fe99b53a1b7a1619e94eb661ac825a48ea5ef8bb9120dd6efc351e39eb7cc5223f637":"a6ed69c9216c551793107f1bdaa04944f6d76fe4474f64bb08b0ebc10a18f337":"e0bc1cc56fdfeef686e0c7ec359e2e8bd48d76c8643c40d12325328170bbf702":"87c5b23aa3c100ff9e368fc47534ff8fa2f9e2bfd3599519ee6f60164485cf6d":"bd419968f636e374268ccdd62403f79c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #4 -ctr_drbg_validate_nopr:"bdd156ef3c4e09b77fe8781c446eac55b562e4ee1b7d15515a966882d4c7fadb0fc7b37554ba03908838db40499ded5b":"9facd9f4587819acb358e4936d9f44b67ddf82616e79a44ffd6a2510f652f6b9cebc1424b5c642362b19f63c615f49686df66a8f80ddffb56ce0c0d8540150fb":"35ea316fe302786f626e3831530622b62eb33a3608d4af3384ecfcbd198f3f05":"8d4fae22290b6ef8618ded1c3412e85fab7b8d17fb9cbd09dbc87f97279cc72d":"2f54928372e4ce447201427a3ae05769ae1c54b2e83bdc86d380a90b07f2890c":"8045e8da88b1bc126785c8a771db5354" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"bdd156ef3c4e09b77fe8781c446eac55b562e4ee1b7d15515a966882d4c7fadb0fc7b37554ba03908838db40499ded5b":"9facd9f4587819acb358e4936d9f44b67ddf82616e79a44ffd6a2510f652f6b9cebc1424b5c642362b19f63c615f49686df66a8f80ddffb56ce0c0d8540150fb":"35ea316fe302786f626e3831530622b62eb33a3608d4af3384ecfcbd198f3f05":"8d4fae22290b6ef8618ded1c3412e85fab7b8d17fb9cbd09dbc87f97279cc72d":"2f54928372e4ce447201427a3ae05769ae1c54b2e83bdc86d380a90b07f2890c":"8045e8da88b1bc126785c8a771db5354" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #5 -ctr_drbg_validate_nopr:"154876298a1b63334624b367da984eb31d7260abe79ced41de35ba68a716233a5df0937b90f89dde7fd55a9693c9031f":"36895f574e9e9d08e6c885d305eb4764c1e5689d1f99c2462b3ebdf659e8ce43818dfc886ec797843bfee361b554cd5f969b0c7b0381b53f4afc1bcadbf7eb1c":"c3a46105c50a167a5b0391053f3814a06c90cea2c1fa9329d97fdbc62887ff6d":"54c7d66c65dbddb4665981bff0f503de37d724362aeb67abce6a870fd6a7398a":"58204ca953cbd46dd6c8870b358cba77c436870db49bcd3e2f92697bb580b460":"cd903c0f11ea701214f91715cfec11a3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"154876298a1b63334624b367da984eb31d7260abe79ced41de35ba68a716233a5df0937b90f89dde7fd55a9693c9031f":"36895f574e9e9d08e6c885d305eb4764c1e5689d1f99c2462b3ebdf659e8ce43818dfc886ec797843bfee361b554cd5f969b0c7b0381b53f4afc1bcadbf7eb1c":"c3a46105c50a167a5b0391053f3814a06c90cea2c1fa9329d97fdbc62887ff6d":"54c7d66c65dbddb4665981bff0f503de37d724362aeb67abce6a870fd6a7398a":"58204ca953cbd46dd6c8870b358cba77c436870db49bcd3e2f92697bb580b460":"cd903c0f11ea701214f91715cfec11a3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #6 -ctr_drbg_validate_nopr:"94e273fde1e699f84aeef343eb0277c50d169bb5496575301021a2be50df6a555d1422ea88e0e4d905158e93fd8d0089":"1cd97b6e6e7f19401e409aea7b3ec33a8faefd71402b8f34a73c1cb1af215e0e87debe68bce590d41c1f90c6ad9db3d30b3901862e076d765ffdf58776e5fb7e":"6ee75e9f9aee6ac93e20f742f20427e5eb9b4ad2ed06fbba8c7b7870a96941ac":"0ba60399893ede284372bc4e0a37702a23b16aa8e5fe70ea95429af87ff291aa":"94bd2b51c32d29cd14e2123221e45ec0cf1f38766fb6bb0716856d0138f6fa39":"831793686abd406f7b385cd59e497b18" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"94e273fde1e699f84aeef343eb0277c50d169bb5496575301021a2be50df6a555d1422ea88e0e4d905158e93fd8d0089":"1cd97b6e6e7f19401e409aea7b3ec33a8faefd71402b8f34a73c1cb1af215e0e87debe68bce590d41c1f90c6ad9db3d30b3901862e076d765ffdf58776e5fb7e":"6ee75e9f9aee6ac93e20f742f20427e5eb9b4ad2ed06fbba8c7b7870a96941ac":"0ba60399893ede284372bc4e0a37702a23b16aa8e5fe70ea95429af87ff291aa":"94bd2b51c32d29cd14e2123221e45ec0cf1f38766fb6bb0716856d0138f6fa39":"831793686abd406f7b385cd59e497b18" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #7 -ctr_drbg_validate_nopr:"5a699113ebf98bff9cb780ce29747a61ba2d7581a5716065d018c89348d7c2ed3f5bba32442cd192c1e37b77b98f5791":"de6d2a3b6ad9af07058d3b1d1976cf61d49566b965eb4e9b74a4cad8e286e7a40b254b860e2e209a8cb4cff3a8e615b84f5ae7505957a758e266a4c3e915d251":"ed18c16a61ba5ecc0755f94c286390a6d46e6e26439dadd36c83ebdee42b4b4c":"7c4550d058b85580be2053fd9d933c87041c5c3f62a5b6b303259dafc90d9041":"ebebfcb9b4b3595e516939ca0688422bbdfc4b9f67b0d6619757cb315b7d7908":"1a5a496aa2268483444b3740c9cc4104" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"5a699113ebf98bff9cb780ce29747a61ba2d7581a5716065d018c89348d7c2ed3f5bba32442cd192c1e37b77b98f5791":"de6d2a3b6ad9af07058d3b1d1976cf61d49566b965eb4e9b74a4cad8e286e7a40b254b860e2e209a8cb4cff3a8e615b84f5ae7505957a758e266a4c3e915d251":"ed18c16a61ba5ecc0755f94c286390a6d46e6e26439dadd36c83ebdee42b4b4c":"7c4550d058b85580be2053fd9d933c87041c5c3f62a5b6b303259dafc90d9041":"ebebfcb9b4b3595e516939ca0688422bbdfc4b9f67b0d6619757cb315b7d7908":"1a5a496aa2268483444b3740c9cc4104" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #8 -ctr_drbg_validate_nopr:"42450f2689b87a3dd940f3b9e3b32d4654c725a24ddd2c22f006694321dacf1980b50f7ac0401626453ec836039bfdc9":"4765399ccbbf3d33433bb992ee29e4381f28d800b05431f1c5b3e949c5db72c582bfe8ba08db1575b866816cabbe5e1d31d8a870ceed49fb75676c97020d1f22":"6ee5a7613c25ecec263a2fd2288948b2df9a05d50040c4031b0653878fdb067f":"68a1038481be7412d6a7c8474d4b2a2535c9b55ea301ee800d5a846127d345cb":"7a1915cf78e6da2dc7840cba40390d668d07571608b77857d2224c4531c17bb8":"80a6c622e64495f9a391f5a8a9c76818" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"42450f2689b87a3dd940f3b9e3b32d4654c725a24ddd2c22f006694321dacf1980b50f7ac0401626453ec836039bfdc9":"4765399ccbbf3d33433bb992ee29e4381f28d800b05431f1c5b3e949c5db72c582bfe8ba08db1575b866816cabbe5e1d31d8a870ceed49fb75676c97020d1f22":"6ee5a7613c25ecec263a2fd2288948b2df9a05d50040c4031b0653878fdb067f":"68a1038481be7412d6a7c8474d4b2a2535c9b55ea301ee800d5a846127d345cb":"7a1915cf78e6da2dc7840cba40390d668d07571608b77857d2224c4531c17bb8":"80a6c622e64495f9a391f5a8a9c76818" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #9 -ctr_drbg_validate_nopr:"873869e194201b822b140bdd7797dd1ed408f2190b759c068b7019e6707f60751e101d3465c4ec57dbf9d1ea7597fa44":"d2f92706ca3fb9ced8183c74704440d7eedee1542c2e812f65afc83f4b62dadf1c51fa68f8d5f457a893211c8afc82c93e6a1e15822eff0d4ada6efd25d271a0":"8d0393d2a1ae8930ea88773adfa47b49060f0bf2d3def2acc57786bfbd1e2d6f":"5bcf5ff4fbd9eaabf8bf82ec7c59b043fd64b0025ad1ab2b384e399b9e13147a":"6e2d05e286c90502a3abf2ee72ab7ffb520ce5facfb27e095787a09a412abec3":"e1ceda71b8feb4b0d14d35bbb57a79a2" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"873869e194201b822b140bdd7797dd1ed408f2190b759c068b7019e6707f60751e101d3465c4ec57dbf9d1ea7597fa44":"d2f92706ca3fb9ced8183c74704440d7eedee1542c2e812f65afc83f4b62dadf1c51fa68f8d5f457a893211c8afc82c93e6a1e15822eff0d4ada6efd25d271a0":"8d0393d2a1ae8930ea88773adfa47b49060f0bf2d3def2acc57786bfbd1e2d6f":"5bcf5ff4fbd9eaabf8bf82ec7c59b043fd64b0025ad1ab2b384e399b9e13147a":"6e2d05e286c90502a3abf2ee72ab7ffb520ce5facfb27e095787a09a412abec3":"e1ceda71b8feb4b0d14d35bbb57a79a2" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #10 -ctr_drbg_validate_nopr:"1fecb5fe87c2a208b4f193e9c3ff810954c554150d544baea1685fb4774320315d5cb651be493ef120ef6966e3e7518c":"34bc292809674352ffb60786dca59ec799188aa401b366a48cdeddf37c12ee4c666f8fb3a0d53df4cd7191166d50ff01d992f94cd92da7a385ffe5795b197ced":"38249fed34a907768eac49267c2c613a65154eec5b73b541d7d7b314b5080061":"115be9cb914b50480fffe078d8170870b56129a0a74271dee063f8b2049e1be3":"69fa6faf7223f5bb1b55f35a544f78181579b1745990053357916fe507e51db6":"60cc92d3ba3ff0715f5627182334ed1b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1fecb5fe87c2a208b4f193e9c3ff810954c554150d544baea1685fb4774320315d5cb651be493ef120ef6966e3e7518c":"34bc292809674352ffb60786dca59ec799188aa401b366a48cdeddf37c12ee4c666f8fb3a0d53df4cd7191166d50ff01d992f94cd92da7a385ffe5795b197ced":"38249fed34a907768eac49267c2c613a65154eec5b73b541d7d7b314b5080061":"115be9cb914b50480fffe078d8170870b56129a0a74271dee063f8b2049e1be3":"69fa6faf7223f5bb1b55f35a544f78181579b1745990053357916fe507e51db6":"60cc92d3ba3ff0715f5627182334ed1b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #11 -ctr_drbg_validate_nopr:"4d283eb5ecd85a1613c975e24832770643613c9a5aee0d8649bc0d68c89cf1ea6ec3a1a22eefd9e212d602c338d64c6e":"4aa6917a5c9f370590d70536fdd89c916fec5e5bcbade8c6a6cfcf5b232c98a6b3e6b79a2dfb0778fbc3f1da7b06044d7b0fa2c04ffc3b71324aca1ee19f936b":"05a7092a684ba7a7fbd33533f9be58a4140a3855d4c5f44a31d665a0720c1739":"557ef1bedc890d1543de6cfeb25642782683d77a46bc8aa0836b07157599c7c3":"e87e45073ff8e36c38b128cd2275a160e431787b5e81f6c2fd7a37909eb72ea5":"31ecfb1bcf3253ba5f71b185a66c7cff" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"4d283eb5ecd85a1613c975e24832770643613c9a5aee0d8649bc0d68c89cf1ea6ec3a1a22eefd9e212d602c338d64c6e":"4aa6917a5c9f370590d70536fdd89c916fec5e5bcbade8c6a6cfcf5b232c98a6b3e6b79a2dfb0778fbc3f1da7b06044d7b0fa2c04ffc3b71324aca1ee19f936b":"05a7092a684ba7a7fbd33533f9be58a4140a3855d4c5f44a31d665a0720c1739":"557ef1bedc890d1543de6cfeb25642782683d77a46bc8aa0836b07157599c7c3":"e87e45073ff8e36c38b128cd2275a160e431787b5e81f6c2fd7a37909eb72ea5":"31ecfb1bcf3253ba5f71b185a66c7cff" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #12 -ctr_drbg_validate_nopr:"a6f488104a6c03e354d5d1805c62dcd3016322d218747fa83f9199e20f6ab1cfbc2b889536bda1187f59b7294d557ff2":"22f8ad57a2dfa8010e2865ad6263823652917b84dfea61f639efdb0fdbb35c6341ca7721095d69686212dffe78410c0d0db94f04756d52e7d76165d5a1d516d9":"fb9951d563f7aa88db545874b1a3049c5f79774d486e7a28aed1ed75f59224a5":"b1ea7c6b53e79e4e947e63086dee32dcc17bc4f27fba6142f8215ec081cdd5c9":"0d12cc0a39bfbf87194e4070f6b54caaabbe48fa192b96cfed2a794d95fa299d":"62a1c5678e6e8fc738d375e2ca48751f" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a6f488104a6c03e354d5d1805c62dcd3016322d218747fa83f9199e20f6ab1cfbc2b889536bda1187f59b7294d557ff2":"22f8ad57a2dfa8010e2865ad6263823652917b84dfea61f639efdb0fdbb35c6341ca7721095d69686212dffe78410c0d0db94f04756d52e7d76165d5a1d516d9":"fb9951d563f7aa88db545874b1a3049c5f79774d486e7a28aed1ed75f59224a5":"b1ea7c6b53e79e4e947e63086dee32dcc17bc4f27fba6142f8215ec081cdd5c9":"0d12cc0a39bfbf87194e4070f6b54caaabbe48fa192b96cfed2a794d95fa299d":"62a1c5678e6e8fc738d375e2ca48751f" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #13 -ctr_drbg_validate_nopr:"9d67e017e0abdd7c079bc0354f33dab696ad64146802f06d6cefd9cdefbf55b197f5899e5efaa269cc0432c87648ce18":"d8be0ec1119ff959c32c9cf29914e3f7bf2b01bdbf806c2d9ba119ae2a2cfb565871762b02ee7bf68f1d280532fd7ae7368517f6f751739b228d23df2f207f35":"74a5e24477e8759bedfbaa196f398777108392efb8c64c65c0c9ecd6cd3b5f04":"70cbc6cfe1d6ab4bc30d66fa162d5d4b3029e4b1b9d759f3eae17fb508e91a46":"d3c538e042f0eb796b4af9b4e65cd850425c72e2c896fcea741c17172faf27d9":"559a5e04b75cec250aac2433176a725e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"9d67e017e0abdd7c079bc0354f33dab696ad64146802f06d6cefd9cdefbf55b197f5899e5efaa269cc0432c87648ce18":"d8be0ec1119ff959c32c9cf29914e3f7bf2b01bdbf806c2d9ba119ae2a2cfb565871762b02ee7bf68f1d280532fd7ae7368517f6f751739b228d23df2f207f35":"74a5e24477e8759bedfbaa196f398777108392efb8c64c65c0c9ecd6cd3b5f04":"70cbc6cfe1d6ab4bc30d66fa162d5d4b3029e4b1b9d759f3eae17fb508e91a46":"d3c538e042f0eb796b4af9b4e65cd850425c72e2c896fcea741c17172faf27d9":"559a5e04b75cec250aac2433176a725e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #14 -ctr_drbg_validate_nopr:"10914608a6d373a26c53ab83014283b678d73dfea65b4a3540af17f2fafa3b3cf698925b423edb9f946b906f43110795":"9ded87d289412dfda8935e5b08ec66b68abd1bae1fc5363e4341f58db954f1f9bc4b681c0d930ba080f85f8fd04c173cb2b77723ce67692efa7ade48b82b6926":"225159b4c679094f277516b2335b1e8b7d0a7ea33fd56822906d481fe412586d":"4967cd401cd466aba0be5f55615ca0d9fb8adbde5cb4e6ae3a0159fcd6c36bf0":"fec14f325b8b458ddf3e7f2e10938f4c2d04c8d9885bb5b9277bdc229c70b354":"1cd5c0bdeb87c79235bead416c565d32" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"10914608a6d373a26c53ab83014283b678d73dfea65b4a3540af17f2fafa3b3cf698925b423edb9f946b906f43110795":"9ded87d289412dfda8935e5b08ec66b68abd1bae1fc5363e4341f58db954f1f9bc4b681c0d930ba080f85f8fd04c173cb2b77723ce67692efa7ade48b82b6926":"225159b4c679094f277516b2335b1e8b7d0a7ea33fd56822906d481fe412586d":"4967cd401cd466aba0be5f55615ca0d9fb8adbde5cb4e6ae3a0159fcd6c36bf0":"fec14f325b8b458ddf3e7f2e10938f4c2d04c8d9885bb5b9277bdc229c70b354":"1cd5c0bdeb87c79235bead416c565d32" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #0 -ctr_drbg_validate_nopr:"b023f6a6f73d4749b36eb54867994432":"2462ad760ddbca4e013688bf61381f190c7b2de57cbeeec81d6ab7b6f067b75adc3545887f8d2aa5d9b9dfcbfa425d610faa9c247eb5d71145f302918e908ae5":"":"":"":"c0620c68515a4618e572db6e4c14473d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b023f6a6f73d4749b36eb54867994432":"2462ad760ddbca4e013688bf61381f190c7b2de57cbeeec81d6ab7b6f067b75adc3545887f8d2aa5d9b9dfcbfa425d610faa9c247eb5d71145f302918e908ae5":"":"":"":"c0620c68515a4618e572db6e4c14473d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #1 -ctr_drbg_validate_nopr:"7e0fcd953c1c8bb8d03d7a0e918fb59d":"56b2e11d5c2d87d2c9c90c285e0041beb4594a6efdd577580095612e50cf47c0b76208337e1e18453082d725629667d86226ab22944bbfb40c38b7986e489adb":"":"":"":"7194eee0d333fa5282dc44db964ecf5b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"7e0fcd953c1c8bb8d03d7a0e918fb59d":"56b2e11d5c2d87d2c9c90c285e0041beb4594a6efdd577580095612e50cf47c0b76208337e1e18453082d725629667d86226ab22944bbfb40c38b7986e489adb":"":"":"":"7194eee0d333fa5282dc44db964ecf5b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #2 -ctr_drbg_validate_nopr:"0130217d4a3945402ed99d7b8504fe4b":"28e592fd9db72b40ae4888078aedde260f6de4f0472a7601258e694d7bb6af6810ff4eabdffb332932765fa1d66650fb78cc2be484c0ba803eb9a2502020e865":"":"":"":"4652f0545385fdbe02d05aec21668608" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0130217d4a3945402ed99d7b8504fe4b":"28e592fd9db72b40ae4888078aedde260f6de4f0472a7601258e694d7bb6af6810ff4eabdffb332932765fa1d66650fb78cc2be484c0ba803eb9a2502020e865":"":"":"":"4652f0545385fdbe02d05aec21668608" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #3 -ctr_drbg_validate_nopr:"07854447e33521d2d997d90c0887f42d":"c561ab6acfbfb98879982ac7add92b80471e0154b77ccc9fd98e7c2013c411e8075948e97ab4db7505797a99d456e54e6585042efeff7e3970e399ea0d27537c":"":"":"":"1a14a810c11b4f0af23c6467c47bbde0" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"07854447e33521d2d997d90c0887f42d":"c561ab6acfbfb98879982ac7add92b80471e0154b77ccc9fd98e7c2013c411e8075948e97ab4db7505797a99d456e54e6585042efeff7e3970e399ea0d27537c":"":"":"":"1a14a810c11b4f0af23c6467c47bbde0" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #4 -ctr_drbg_validate_nopr:"68a8ec01581d6066391f3e5977465026":"747c7e9aace6d4f840c7b5261e0af796c516477421d52850a7072a0ab2c768fcc80c9ba8d18b228e77a7f6131c788a76515fe31aef4ed67376568231a4700fac":"":"":"":"a5723c43743442fae3637bb553891aeb" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"68a8ec01581d6066391f3e5977465026":"747c7e9aace6d4f840c7b5261e0af796c516477421d52850a7072a0ab2c768fcc80c9ba8d18b228e77a7f6131c788a76515fe31aef4ed67376568231a4700fac":"":"":"":"a5723c43743442fae3637bb553891aeb" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #5 -ctr_drbg_validate_nopr:"1459038c60b70bae7af0da6cfab707a2":"9f7d839310846bd452827a185539c0eb0f106acc7bc4de80d3521a970b23483d57826b1484d329a2d1c2ecfeaf8eeffbaa6e1a305e3f1e47b96ad48a711ad1aa":"":"":"":"5fcd6bf108fe68b85f61f85c0556f5c0" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1459038c60b70bae7af0da6cfab707a2":"9f7d839310846bd452827a185539c0eb0f106acc7bc4de80d3521a970b23483d57826b1484d329a2d1c2ecfeaf8eeffbaa6e1a305e3f1e47b96ad48a711ad1aa":"":"":"":"5fcd6bf108fe68b85f61f85c0556f5c0" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #6 -ctr_drbg_validate_nopr:"a3357db173df98da4dd02ee24ce5c303":"f1ce08587ac0338b4d0b8e075b42b6501e77758b30087de028a8622fb7abd7f65e3b4f802d1a472dedb9c1a6dc9263c65918d8b7fafd0ae7e9c39e2e8684af3f":"":"":"":"8a5fa11d8e78fbf1ca4e4ca3e1ae82b8" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a3357db173df98da4dd02ee24ce5c303":"f1ce08587ac0338b4d0b8e075b42b6501e77758b30087de028a8622fb7abd7f65e3b4f802d1a472dedb9c1a6dc9263c65918d8b7fafd0ae7e9c39e2e8684af3f":"":"":"":"8a5fa11d8e78fbf1ca4e4ca3e1ae82b8" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #7 -ctr_drbg_validate_nopr:"212f4c80c7e9287c8d25e3b965f91a3c":"bf1d715b3f56c433827c9cb429bee5ca61c80a8d9b2fd4498e1c86ce703637f8f7f34056ab0039e0baa63320df0ec61de60354f2ece06356d9be3c6d1cdcc4cf":"":"":"":"04ac2f969e828f375b03ee16317e8572" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"212f4c80c7e9287c8d25e3b965f91a3c":"bf1d715b3f56c433827c9cb429bee5ca61c80a8d9b2fd4498e1c86ce703637f8f7f34056ab0039e0baa63320df0ec61de60354f2ece06356d9be3c6d1cdcc4cf":"":"":"":"04ac2f969e828f375b03ee16317e8572" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #8 -ctr_drbg_validate_nopr:"46e85752e0af82fc63932950120e4b5d":"ae4316424fa765179404188eb8839ce84ad8db92cb12f39089a93a2dbdc371e2fdbef1ad080eb354eecdda3a10ea66ef647aa095afa1786c01bd1c9f70d8da4f":"":"":"":"de576284d8ad36b31bd4f8f3da633e36" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"46e85752e0af82fc63932950120e4b5d":"ae4316424fa765179404188eb8839ce84ad8db92cb12f39089a93a2dbdc371e2fdbef1ad080eb354eecdda3a10ea66ef647aa095afa1786c01bd1c9f70d8da4f":"":"":"":"de576284d8ad36b31bd4f8f3da633e36" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #9 -ctr_drbg_validate_nopr:"ec2459b1dd7f50df63e14e40aa4a4e66":"b964a24bf98264327c0b9e2e1c99ed1b35f534be801c996f318bc2074ed2500ba8488c4feb442b507c3220523c0041c9543133379365e65e092850a5e3f96cc9":"":"":"":"4d466e2f388aae40d1b31ce1f8ddc5e8" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ec2459b1dd7f50df63e14e40aa4a4e66":"b964a24bf98264327c0b9e2e1c99ed1b35f534be801c996f318bc2074ed2500ba8488c4feb442b507c3220523c0041c9543133379365e65e092850a5e3f96cc9":"":"":"":"4d466e2f388aae40d1b31ce1f8ddc5e8" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #10 -ctr_drbg_validate_nopr:"acf480d54f4c66d611519b72f2c0dca6":"d5b3277cf8badf6be86af27dd36f23ffc580847c5fcb56c4d8a42339336f185c38ffb86f4d8aa7646c1aaed6c2b0c7ae7e4d435f481d62bb01e632f6bbb2abf9":"":"":"":"746aaa5423ef77ea6b1eda47410262dd" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"acf480d54f4c66d611519b72f2c0dca6":"d5b3277cf8badf6be86af27dd36f23ffc580847c5fcb56c4d8a42339336f185c38ffb86f4d8aa7646c1aaed6c2b0c7ae7e4d435f481d62bb01e632f6bbb2abf9":"":"":"":"746aaa5423ef77ea6b1eda47410262dd" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #11 -ctr_drbg_validate_nopr:"edb80fddc595b234e3c5c03b2be3d721":"94aad8c772201435543efd9013c9f5f022038db6864e9ed4141ea75beb236844da6e6a17109262bc80f528427b37d9da6df03c7dd25be233774384a7f53197ea":"":"":"":"511927f10f800445b705ea3cfe6ec823" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"edb80fddc595b234e3c5c03b2be3d721":"94aad8c772201435543efd9013c9f5f022038db6864e9ed4141ea75beb236844da6e6a17109262bc80f528427b37d9da6df03c7dd25be233774384a7f53197ea":"":"":"":"511927f10f800445b705ea3cfe6ec823" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #12 -ctr_drbg_validate_nopr:"c7790c9888b0e731ca6ccd60c32bb98a":"967050c11050a6d99a5da428d1f0fc8068b29ba4c66965addbfd31b745cb07d2439d268ab32a5fa2b1934bf277ff586506a941768468905ed980537d8baa1d07":"":"":"":"978493f0cece6f94d21863a519e06dbe" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"c7790c9888b0e731ca6ccd60c32bb98a":"967050c11050a6d99a5da428d1f0fc8068b29ba4c66965addbfd31b745cb07d2439d268ab32a5fa2b1934bf277ff586506a941768468905ed980537d8baa1d07":"":"":"":"978493f0cece6f94d21863a519e06dbe" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #13 -ctr_drbg_validate_nopr:"58c75625771df61c48a82590eeed3378":"be3120e8515a98701b4b2fb0667de2bad3f32bcbf10fb9b820956f9aa7ffa1bbbafb70002a9c7fdd1cf7e76a735261798dc60a1163919d58e39ef0c38b54b27b":"":"":"":"90f5c486e7efe932258610e744506487" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"58c75625771df61c48a82590eeed3378":"be3120e8515a98701b4b2fb0667de2bad3f32bcbf10fb9b820956f9aa7ffa1bbbafb70002a9c7fdd1cf7e76a735261798dc60a1163919d58e39ef0c38b54b27b":"":"":"":"90f5c486e7efe932258610e744506487" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,0) #14 -ctr_drbg_validate_nopr:"d3f64c11aa21bb2d12278847547fb11b":"855c0e3a7567730b11e197c136e5c22b1dc7271d4dbe04bcdfd2fc0ef806b3c05b4264ee6c60d526506622ebf6130738dba4bf35c13ce33db19487312ee691fe":"":"":"":"33ed7089ebae738c6a7e6e2390d573e4" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"d3f64c11aa21bb2d12278847547fb11b":"855c0e3a7567730b11e197c136e5c22b1dc7271d4dbe04bcdfd2fc0ef806b3c05b4264ee6c60d526506622ebf6130738dba4bf35c13ce33db19487312ee691fe":"":"":"":"33ed7089ebae738c6a7e6e2390d573e4" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #0 -ctr_drbg_validate_nopr:"132ad1c40afb066620f004f08409c59e":"2e5beadd89b663b3903d3a63c3ab5605bfb1a0045a42430e0220243c51a69f7ff7678c2f8edb7bb4a29b646f3edfaca2463f9defd342da87d22b1b8fdb012fd5":"150deb841d1a4d90e66e85b036d9f5a7efca726b907ae3e8f05e1d1338cdfd32":"fb199beeeaf3939be2a5f9e6ba22f97cdd2c7576e81eccc686facbdf8bb4f2aa":"4293341721f57e4548ce8c003531d38622446c8825904e1b868dcddc626c5164":"66d8f3bfb78186b57136ec2c1602e1ef" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"132ad1c40afb066620f004f08409c59e":"2e5beadd89b663b3903d3a63c3ab5605bfb1a0045a42430e0220243c51a69f7ff7678c2f8edb7bb4a29b646f3edfaca2463f9defd342da87d22b1b8fdb012fd5":"150deb841d1a4d90e66e85b036d9f5a7efca726b907ae3e8f05e1d1338cdfd32":"fb199beeeaf3939be2a5f9e6ba22f97cdd2c7576e81eccc686facbdf8bb4f2aa":"4293341721f57e4548ce8c003531d38622446c8825904e1b868dcddc626c5164":"66d8f3bfb78186b57136ec2c1602e1ef" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #1 -ctr_drbg_validate_nopr:"1c1502ca97c109399a72a77c8d6cc22b":"1d33b1b257a3ae1210fa2099307916a73dd92270769697ea2d7901f56865e3cae1be94b5024d0da3880bce06f0b31231c5a889f8ba3d92a20844b61009db672d":"23eede46eff4a04b08dcc2133e4537b332351f8469630f11b0c8853fb762a4bc":"6fd9f9da108e68aea9d1cecd81c49bcd0e7bedb348890f2248cb31c4277369f7":"76bcc11bd952123f78dd2ba60dd932d49203e418bb832d60b45c083e1e129834":"a1eee46001616f2bf87729895da0d0d1" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"1c1502ca97c109399a72a77c8d6cc22b":"1d33b1b257a3ae1210fa2099307916a73dd92270769697ea2d7901f56865e3cae1be94b5024d0da3880bce06f0b31231c5a889f8ba3d92a20844b61009db672d":"23eede46eff4a04b08dcc2133e4537b332351f8469630f11b0c8853fb762a4bc":"6fd9f9da108e68aea9d1cecd81c49bcd0e7bedb348890f2248cb31c4277369f7":"76bcc11bd952123f78dd2ba60dd932d49203e418bb832d60b45c083e1e129834":"a1eee46001616f2bf87729895da0d0d1" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #2 -ctr_drbg_validate_nopr:"c79c0a1db75e83af258cdf9ead81264d":"5e8cc0fdadc170ed0f5e12f79a6b9e585f9d7c2926c163686a6a724495d88fabcec940d752545cae63f1792dcb966a7325f61997ba8883559ad6f6f8fc09898a":"a2cf6c1c9e4489f504e17f385f08aa82775aa2b0a84abd0b7ee3c6b393d7fd50":"c7529b874e07d4b876196786d510cc038c9e1ab93c461df2474eba484ae6876f":"63c6e7f3548529386c9f47c5aece52ce8454da5db9a807a1b960f7730a61582b":"43b7931e0b3b3769ef8972d0026896a3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"c79c0a1db75e83af258cdf9ead81264d":"5e8cc0fdadc170ed0f5e12f79a6b9e585f9d7c2926c163686a6a724495d88fabcec940d752545cae63f1792dcb966a7325f61997ba8883559ad6f6f8fc09898a":"a2cf6c1c9e4489f504e17f385f08aa82775aa2b0a84abd0b7ee3c6b393d7fd50":"c7529b874e07d4b876196786d510cc038c9e1ab93c461df2474eba484ae6876f":"63c6e7f3548529386c9f47c5aece52ce8454da5db9a807a1b960f7730a61582b":"43b7931e0b3b3769ef8972d0026896a3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #3 -ctr_drbg_validate_nopr:"b44d1dd914e88840bc65a94ee199b3ac":"c3dae1863d323cc78f43ccb3f632fde29130e6b23b843ff5a8d79fddc3c1f92b55cd3dcaf7848d40d189c0de7790bebb889e01be05980dcdf30d2b3333426c50":"41e2fce9b48642a1b9bd1695314adcdd38e1a8afe4891e633c5088c6753438a2":"1eb3f8bbacb0c6b901718bfd7eba29f6f87e1fe056ad442d6d38c1351a684e1f":"85570db773f3f5202967376f91a0a9c09c89cd4eddd58cdc6210335fd5e7acef":"bd53036538d9ed904a49966b5428a2a8" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"b44d1dd914e88840bc65a94ee199b3ac":"c3dae1863d323cc78f43ccb3f632fde29130e6b23b843ff5a8d79fddc3c1f92b55cd3dcaf7848d40d189c0de7790bebb889e01be05980dcdf30d2b3333426c50":"41e2fce9b48642a1b9bd1695314adcdd38e1a8afe4891e633c5088c6753438a2":"1eb3f8bbacb0c6b901718bfd7eba29f6f87e1fe056ad442d6d38c1351a684e1f":"85570db773f3f5202967376f91a0a9c09c89cd4eddd58cdc6210335fd5e7acef":"bd53036538d9ed904a49966b5428a2a8" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #4 -ctr_drbg_validate_nopr:"5ef97f7af7df5cc6fa94f8428ec7be5c":"be67434ac4d77f0f50ec5bacc8112d1480bd9f20d6b4ea768d9b51bb69c1dffcd8c30e4412127644aaa6fc453e59fb633f6a5a8c2f69e40d1863e35d4d4c0227":"a64195b1e56cf97fd81e99fa1833d191faf62f534c874def4b8bed0ae7195ac7":"353cd3a8d9cd92bce82cd8d1cc198baa9276db478b0cfe50249e30c3042ee9db":"393ab4726f088fdfeb4df752e1b2aec678e41fa60781bc5e914296227d6b3dfc":"24bdc2cad5dccd2309425f11a24c8c39" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"5ef97f7af7df5cc6fa94f8428ec7be5c":"be67434ac4d77f0f50ec5bacc8112d1480bd9f20d6b4ea768d9b51bb69c1dffcd8c30e4412127644aaa6fc453e59fb633f6a5a8c2f69e40d1863e35d4d4c0227":"a64195b1e56cf97fd81e99fa1833d191faf62f534c874def4b8bed0ae7195ac7":"353cd3a8d9cd92bce82cd8d1cc198baa9276db478b0cfe50249e30c3042ee9db":"393ab4726f088fdfeb4df752e1b2aec678e41fa60781bc5e914296227d6b3dfc":"24bdc2cad5dccd2309425f11a24c8c39" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #5 -ctr_drbg_validate_nopr:"567130da4e7ecc4db0f035d7ecb11878":"cc070df6aa3623f74afd85b59d1bef2b1fcd9c8093362512ff109ebfe992ed75bd58b5ae1561d702b69065eb3cc0bd328ab698d4c6ca274e96d673309b5df5df":"42033054cefa1f20b3443f8ab7d9635ae8f047b833c8529245ba8b4aa07edba3":"72972fb947bff60df291888ddbfd91e698e0c1c26a346b95fc7c5dac596d0073":"af29b6a13602ba9c6b11f8dbdeb6cb52e211f9cd2fc96e63b61e3c1ec631d2ea":"b0849f8317e043271a3fc5f2eaaaaba2" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"567130da4e7ecc4db0f035d7ecb11878":"cc070df6aa3623f74afd85b59d1bef2b1fcd9c8093362512ff109ebfe992ed75bd58b5ae1561d702b69065eb3cc0bd328ab698d4c6ca274e96d673309b5df5df":"42033054cefa1f20b3443f8ab7d9635ae8f047b833c8529245ba8b4aa07edba3":"72972fb947bff60df291888ddbfd91e698e0c1c26a346b95fc7c5dac596d0073":"af29b6a13602ba9c6b11f8dbdeb6cb52e211f9cd2fc96e63b61e3c1ec631d2ea":"b0849f8317e043271a3fc5f2eaaaaba2" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #6 -ctr_drbg_validate_nopr:"2c20ae36f1e74542ed8b0a177b8050aa":"c4bf7a39caf26dc3f61311f54ab3095493c626a988f5abee2826c67a4f4b4d6a02329c99a6bcb5e387fa160741c871acc2929c1cc07f2f0a7ce1619eb7da1ec4":"97c148dd10c3dd72b1eaaafbe37a9310ed15b23872e9f2b62d1feb91ea81ffe3":"23df0c30c68bf2eeb55d273a596f1f54ed916271595b906e4f7793b7a52f2573":"22f120fa09215105116919aaf8eebcb69eccd5da42feb737018a05268bf08e46":"b7c73b9ceea2e6ca0be6a3773cdd6886" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2c20ae36f1e74542ed8b0a177b8050aa":"c4bf7a39caf26dc3f61311f54ab3095493c626a988f5abee2826c67a4f4b4d6a02329c99a6bcb5e387fa160741c871acc2929c1cc07f2f0a7ce1619eb7da1ec4":"97c148dd10c3dd72b1eaaafbe37a9310ed15b23872e9f2b62d1feb91ea81ffe3":"23df0c30c68bf2eeb55d273a596f1f54ed916271595b906e4f7793b7a52f2573":"22f120fa09215105116919aaf8eebcb69eccd5da42feb737018a05268bf08e46":"b7c73b9ceea2e6ca0be6a3773cdd6886" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #7 -ctr_drbg_validate_nopr:"2076f9e116a2648e1e664b815b1b3674":"979b5aeafe555aeba152ed66e32e30e110df20ee1f227932a72acfb8218aec767941efaefa091c0128dad9b93b06b28fc76e01f275e8ce1c02f0eb567c914f89":"d12fb10b9fa6d2fd0f39cf76294cd44dcbfa80dca7c2f8537c75453d985ef551":"4228a99faf35547a58c1a4d842301dca374f1f13c6fd067b7c1b815863b73158":"a3a7d5f1e2dcf95a90715ec5fd32e7f88c38b0a452b6ccd1f107458db4f74fd6":"8a63a5002a3636b241f0bec14fd9c2ac" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2076f9e116a2648e1e664b815b1b3674":"979b5aeafe555aeba152ed66e32e30e110df20ee1f227932a72acfb8218aec767941efaefa091c0128dad9b93b06b28fc76e01f275e8ce1c02f0eb567c914f89":"d12fb10b9fa6d2fd0f39cf76294cd44dcbfa80dca7c2f8537c75453d985ef551":"4228a99faf35547a58c1a4d842301dca374f1f13c6fd067b7c1b815863b73158":"a3a7d5f1e2dcf95a90715ec5fd32e7f88c38b0a452b6ccd1f107458db4f74fd6":"8a63a5002a3636b241f0bec14fd9c2ac" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #8 -ctr_drbg_validate_nopr:"a71015cf06ddd0a6cd72fa014cf0aee6":"c810cb9db0f169dbc30fda85ccb6d4c40db68d429eeb3653070db7641fbbaba60ef0ff970eaf40887b7e154e2ecd5331de7004689ec604e69927da630a8dd7a7":"5f99f45d8770041703e5a14521c501904fd05ff3340835ac0c41b86442e4939c":"eb7efa6e46ab926ea04c87eb9ce454f5b10717bd9d85305f27d71bea1bc991b3":"cbc80c6171d098fc81023486d327efe2415a0f32e5fa6f6793ce1d0e98783258":"a353f6b350404f3f7b4fb724f84a948a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a71015cf06ddd0a6cd72fa014cf0aee6":"c810cb9db0f169dbc30fda85ccb6d4c40db68d429eeb3653070db7641fbbaba60ef0ff970eaf40887b7e154e2ecd5331de7004689ec604e69927da630a8dd7a7":"5f99f45d8770041703e5a14521c501904fd05ff3340835ac0c41b86442e4939c":"eb7efa6e46ab926ea04c87eb9ce454f5b10717bd9d85305f27d71bea1bc991b3":"cbc80c6171d098fc81023486d327efe2415a0f32e5fa6f6793ce1d0e98783258":"a353f6b350404f3f7b4fb724f84a948a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #9 -ctr_drbg_validate_nopr:"395931837614c322d8488ec6a2c4c919":"831fc8d63592b6ce358c08aeac39d67c3e48b4c2617735b6fe5e9fa44d7aee9d60f2fcf549db239d5bed9c608c94e8f8c23b32901442ac53442127377bdcf205":"eb261c737c0a17c8cb1ae055c143f701b74c96c852e4a76ca3ea045e7efdf5ee":"153276007b3843a897efbf022bd1bcabcf655c7eb8acef9baac710b339ecfd99":"a8a5cb17a2945e5b41ff370cc88ac498389b89b6cd82bb3bbde81c212f7c17d4":"537fc2b73183d2c0c106886937a6609c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"395931837614c322d8488ec6a2c4c919":"831fc8d63592b6ce358c08aeac39d67c3e48b4c2617735b6fe5e9fa44d7aee9d60f2fcf549db239d5bed9c608c94e8f8c23b32901442ac53442127377bdcf205":"eb261c737c0a17c8cb1ae055c143f701b74c96c852e4a76ca3ea045e7efdf5ee":"153276007b3843a897efbf022bd1bcabcf655c7eb8acef9baac710b339ecfd99":"a8a5cb17a2945e5b41ff370cc88ac498389b89b6cd82bb3bbde81c212f7c17d4":"537fc2b73183d2c0c106886937a6609c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #10 -ctr_drbg_validate_nopr:"9a1983859dd6c4cb602970d705952b2b":"68c5cf31f7959ffaa83af9dd55a75ec001befbf835e42a789ac42d39d96128eb6d9b3f07ced15e57e39760390c065fb4425c19ef7184635c18e5ed28256937e1":"e06497a181a5362980579c91d263f630ad4794519a64261ede8b36cf0ac5e713":"714e4fc52aea763e23a1f5b18949ab8fd949f1768560559bccb49d78d51dfab5":"6b6b7f65fd472ad428df2bbb86b85067d0a6f89d9233eea92f5189a9163d0419":"e32af8a81c59dc44540ed8845b447fdb" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"9a1983859dd6c4cb602970d705952b2b":"68c5cf31f7959ffaa83af9dd55a75ec001befbf835e42a789ac42d39d96128eb6d9b3f07ced15e57e39760390c065fb4425c19ef7184635c18e5ed28256937e1":"e06497a181a5362980579c91d263f630ad4794519a64261ede8b36cf0ac5e713":"714e4fc52aea763e23a1f5b18949ab8fd949f1768560559bccb49d78d51dfab5":"6b6b7f65fd472ad428df2bbb86b85067d0a6f89d9233eea92f5189a9163d0419":"e32af8a81c59dc44540ed8845b447fdb" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #11 -ctr_drbg_validate_nopr:"230576e9518fb9a6a8391a84919b0d97":"6193f0e7b33ce19fde922aec9c93f1271ebcdd296d9c8c77029b59afa2064e3159088e07e91c14a4a3dc23b6005dd8ef1425d7d2ae8282a5b30b7498b6754234":"ffaca30a256d18836a0d49bbaad599a28fc7821d71aa91b97158a492d84a6280":"a3da13852d0717afed7c58c52530d2ae047b645a5e7aa8cfabc11478444151ac":"e15fdaeea31c95555fc509d2a266abf78d86ca11aa2f87ce1041142eb9f82bae":"7906f8da1e140345c191dbc2de5ead1b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"230576e9518fb9a6a8391a84919b0d97":"6193f0e7b33ce19fde922aec9c93f1271ebcdd296d9c8c77029b59afa2064e3159088e07e91c14a4a3dc23b6005dd8ef1425d7d2ae8282a5b30b7498b6754234":"ffaca30a256d18836a0d49bbaad599a28fc7821d71aa91b97158a492d84a6280":"a3da13852d0717afed7c58c52530d2ae047b645a5e7aa8cfabc11478444151ac":"e15fdaeea31c95555fc509d2a266abf78d86ca11aa2f87ce1041142eb9f82bae":"7906f8da1e140345c191dbc2de5ead1b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #12 -ctr_drbg_validate_nopr:"e08a3a33adb4399a9be72fead224155f":"cfbe8b1464b00bb9e0d18b04d2040ed9bd822741188812b98a440fbc66ff018ddf6c0ea20c62d01b8237bc7c3da9e3f9fb874fca79a360b4f0f967d8d02083ba":"56f975849197e2eae5a2e6fb445a93c1fadf57280ac27e27c7cbea2cb00c10cc":"0a6d9e2d6e181addab0ea1ee89c65ce557e10fb8e8d43a24cdd27033d3fff507":"823e9400a9f563cc1fa5daf10f4ff1ab8affa18d8371f9cd0e067fcddce8caed":"5ded298f98cffb2e7f5ea97bd50c7e3e" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e08a3a33adb4399a9be72fead224155f":"cfbe8b1464b00bb9e0d18b04d2040ed9bd822741188812b98a440fbc66ff018ddf6c0ea20c62d01b8237bc7c3da9e3f9fb874fca79a360b4f0f967d8d02083ba":"56f975849197e2eae5a2e6fb445a93c1fadf57280ac27e27c7cbea2cb00c10cc":"0a6d9e2d6e181addab0ea1ee89c65ce557e10fb8e8d43a24cdd27033d3fff507":"823e9400a9f563cc1fa5daf10f4ff1ab8affa18d8371f9cd0e067fcddce8caed":"5ded298f98cffb2e7f5ea97bd50c7e3e" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #13 -ctr_drbg_validate_nopr:"11c13b917d9f94fd7a008566d8598e89":"f53343a5a455132df3d1b03db39e44d933855b375d7422ad0d07dfdfb352af28946eb29980793456ec8634bf113e75783246bbd05aa8a7cb5886d372fa012f58":"ff1d8d33083023ffbe28f153bddfa9d9f3c221da16f8f20967d2508fa7752b55":"66a98c7d778d798617e1d31d4bdfabf8d381d38b82125838ddf43fb7f5b27dc6":"407c72d7c890c00b249be00a53ae722e5d8033c84b1e1a6a69d4b278ba5db9eb":"67ab88156f20d03b3a1bc363daefc0c6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"11c13b917d9f94fd7a008566d8598e89":"f53343a5a455132df3d1b03db39e44d933855b375d7422ad0d07dfdfb352af28946eb29980793456ec8634bf113e75783246bbd05aa8a7cb5886d372fa012f58":"ff1d8d33083023ffbe28f153bddfa9d9f3c221da16f8f20967d2508fa7752b55":"66a98c7d778d798617e1d31d4bdfabf8d381d38b82125838ddf43fb7f5b27dc6":"407c72d7c890c00b249be00a53ae722e5d8033c84b1e1a6a69d4b278ba5db9eb":"67ab88156f20d03b3a1bc363daefc0c6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,0,256) #14 -ctr_drbg_validate_nopr:"7b95343a4ac0f8c8b2645c33757a3146":"3d7e2987860cbcba14a12594e1a394ee754c9a7a65cecc990bc79b5e86e672e12f8c144d843e1abca46b4759a11b3d29f4e219077a8696efadee618f254cb80a":"16297534a79c4ae7493178226b29e42a6f1e0066aeaee8b5af65bcefa2ee3ebb":"b429ee986f16fb35fe2c47c03c0918870b4560f4ec4678f9df471cbd7ca6a887":"2b14d612eb00c7fba0d8e23bf91df91daef6f8e279e0050d5497ddf0f3466c76":"8f72c17405163090fe0bd795b65811c6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"7b95343a4ac0f8c8b2645c33757a3146":"3d7e2987860cbcba14a12594e1a394ee754c9a7a65cecc990bc79b5e86e672e12f8c144d843e1abca46b4759a11b3d29f4e219077a8696efadee618f254cb80a":"16297534a79c4ae7493178226b29e42a6f1e0066aeaee8b5af65bcefa2ee3ebb":"b429ee986f16fb35fe2c47c03c0918870b4560f4ec4678f9df471cbd7ca6a887":"2b14d612eb00c7fba0d8e23bf91df91daef6f8e279e0050d5497ddf0f3466c76":"8f72c17405163090fe0bd795b65811c6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #0 -ctr_drbg_validate_nopr:"327290da2e9a19c840de8d33e425efaa5aa7a7afa4e5a812065965478d640f78520cf3c670b098943fec1914d4c8c411":"80bdf18288cb8adb6e3dacb09c553af2e7317c194d37f433eec27e324a0bad752899bda91fd41e5a08acdfd76007aecabc19c95a8bcede310f7320ce97aaad0e":"":"":"":"c26222662ed3a649a1745dee5df4eef0" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"327290da2e9a19c840de8d33e425efaa5aa7a7afa4e5a812065965478d640f78520cf3c670b098943fec1914d4c8c411":"80bdf18288cb8adb6e3dacb09c553af2e7317c194d37f433eec27e324a0bad752899bda91fd41e5a08acdfd76007aecabc19c95a8bcede310f7320ce97aaad0e":"":"":"":"c26222662ed3a649a1745dee5df4eef0" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #1 -ctr_drbg_validate_nopr:"be14f473472db07a43b7f9a517735d7f7ede2aa70dbdb729bc4f578a0dce9d7fe9fd97939cd1ef731262417b5213bd7f":"ac71ff53140c1383eb379e5311e37637af933db494e5e689d065661e9095b8302e4174c392f324fac43695d9381e3cf4626a5347938ed9e21502cbd789cca363":"":"":"":"4bab95f9f05fc36a337b6f2582c2ce98" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"be14f473472db07a43b7f9a517735d7f7ede2aa70dbdb729bc4f578a0dce9d7fe9fd97939cd1ef731262417b5213bd7f":"ac71ff53140c1383eb379e5311e37637af933db494e5e689d065661e9095b8302e4174c392f324fac43695d9381e3cf4626a5347938ed9e21502cbd789cca363":"":"":"":"4bab95f9f05fc36a337b6f2582c2ce98" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #2 -ctr_drbg_validate_nopr:"88c31e24f4f859b668946ce73f8600621a70731440762b3c267ceab52a9d77a23d6f70ddba0e46a786697a906ccb18a3":"bf9bf25a949d447274a8c72f1ae51399521f8aca39b1b37bb7b4d5cf3c67d55ef8dbacfb71aa9c5949416e2868b968883e517215bc20292894f8406ab39c1ea1":"":"":"":"841aaa0b171d1526ef365b9201adbff3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"88c31e24f4f859b668946ce73f8600621a70731440762b3c267ceab52a9d77a23d6f70ddba0e46a786697a906ccb18a3":"bf9bf25a949d447274a8c72f1ae51399521f8aca39b1b37bb7b4d5cf3c67d55ef8dbacfb71aa9c5949416e2868b968883e517215bc20292894f8406ab39c1ea1":"":"":"":"841aaa0b171d1526ef365b9201adbff3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #3 -ctr_drbg_validate_nopr:"8545a0de5ea028c8e5976d5b58fa50079b20ba716f0856cc1af7b98537c895f0266b956542d2b8ca661aef5da1f7f8c5":"686f4f9ee74c3402845fbad9353d7dfeff727584d892eb64bd84b764110cbe4ac8581e7e23acb95caf12979983e8947c570264aec292f1c7b756f7184007dcba":"":"":"":"f6d6ae6449b2984df8bcb69584fb16f3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"8545a0de5ea028c8e5976d5b58fa50079b20ba716f0856cc1af7b98537c895f0266b956542d2b8ca661aef5da1f7f8c5":"686f4f9ee74c3402845fbad9353d7dfeff727584d892eb64bd84b764110cbe4ac8581e7e23acb95caf12979983e8947c570264aec292f1c7b756f7184007dcba":"":"":"":"f6d6ae6449b2984df8bcb69584fb16f3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #4 -ctr_drbg_validate_nopr:"d6cd4b4fb9105374605deac7bb49ad792eb225daa560f2a86f66269bf9afc2ea01b6ee6f0eb4926d2f09329df6e90d79":"5d1b8fa0ca2ee127d1bd41423c17b9a8c736715cc2906818e9216dfd81b7637b66c89b772b55ae707c6effa2d9ce7425df26f966646ab613d5599143cf51e5e8":"":"":"":"c36ab451116d733eb4377de3511db5ce" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"d6cd4b4fb9105374605deac7bb49ad792eb225daa560f2a86f66269bf9afc2ea01b6ee6f0eb4926d2f09329df6e90d79":"5d1b8fa0ca2ee127d1bd41423c17b9a8c736715cc2906818e9216dfd81b7637b66c89b772b55ae707c6effa2d9ce7425df26f966646ab613d5599143cf51e5e8":"":"":"":"c36ab451116d733eb4377de3511db5ce" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #5 -ctr_drbg_validate_nopr:"e73ebae0d0834fdff1829ac3d9722fe9f1bc65b5f652fae5f7615af116440e3d5709b5cddd6065d568c246820de46b09":"2026cf7c1b1fe9645ab8759958ac04fb1d8938b9913c3b7f22da81e398b2c00b1921e1d4edb5d21c4531515cb0f9644fe8068685b9fca813176e6780796e8ded":"":"":"":"98d1dce30593de8a8d5b4d956f6c684b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"e73ebae0d0834fdff1829ac3d9722fe9f1bc65b5f652fae5f7615af116440e3d5709b5cddd6065d568c246820de46b09":"2026cf7c1b1fe9645ab8759958ac04fb1d8938b9913c3b7f22da81e398b2c00b1921e1d4edb5d21c4531515cb0f9644fe8068685b9fca813176e6780796e8ded":"":"":"":"98d1dce30593de8a8d5b4d956f6c684b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #6 -ctr_drbg_validate_nopr:"a53c1813c06b609eff9ddc77204b085ca985f22170b8ecfcbbf45ea11c45c24fcf25bc33150f9f97ce48244d5beb685c":"1d0dd1a87d59c69f28e118e1083d65f1ee0df31f6308a92dcc47503ec4d20a018d9821c6a7d64385724f0e941231426e028efe6d75e53ff8edf095ef1baf2656":"":"":"":"035cec3a24ba7c44e5c19436c2689a75" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a53c1813c06b609eff9ddc77204b085ca985f22170b8ecfcbbf45ea11c45c24fcf25bc33150f9f97ce48244d5beb685c":"1d0dd1a87d59c69f28e118e1083d65f1ee0df31f6308a92dcc47503ec4d20a018d9821c6a7d64385724f0e941231426e028efe6d75e53ff8edf095ef1baf2656":"":"":"":"035cec3a24ba7c44e5c19436c2689a75" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #7 -ctr_drbg_validate_nopr:"16d5b8290693a5c40c5a526dd6d653ac54cabb5608d77bb2cb7d6270b96c2fe2de076716ae8cf0a5c781edbde861dc70":"aa82a5ea33439d0c16a1cc13cbae53b169f4d369bcbdae81a9a38129c65ae0ea4f720576c012f8d7eb1c0202003c39d28453a22e502b4949cf5ba23a727721bf":"":"":"":"de4ed9d163d11e9b52470d078df4c869" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"16d5b8290693a5c40c5a526dd6d653ac54cabb5608d77bb2cb7d6270b96c2fe2de076716ae8cf0a5c781edbde861dc70":"aa82a5ea33439d0c16a1cc13cbae53b169f4d369bcbdae81a9a38129c65ae0ea4f720576c012f8d7eb1c0202003c39d28453a22e502b4949cf5ba23a727721bf":"":"":"":"de4ed9d163d11e9b52470d078df4c869" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #8 -ctr_drbg_validate_nopr:"68bfabdbb821cb978527ff18ce37c96c79ad751756551f36b6991981285a68854ec7f72f548c3395ad3ee40410064d4b":"3da9e9518eb1f1b6268e4597f158844ff672ddb414f7ec23fa66d6c86b90a732a7b3016a3387ec3dbed34eb479413d017932ebf9f2a2fea0b35d2bf4e06718f9":"":"":"":"ec4e3e2b6b8763deb17b8611d1fe7953" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"68bfabdbb821cb978527ff18ce37c96c79ad751756551f36b6991981285a68854ec7f72f548c3395ad3ee40410064d4b":"3da9e9518eb1f1b6268e4597f158844ff672ddb414f7ec23fa66d6c86b90a732a7b3016a3387ec3dbed34eb479413d017932ebf9f2a2fea0b35d2bf4e06718f9":"":"":"":"ec4e3e2b6b8763deb17b8611d1fe7953" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #9 -ctr_drbg_validate_nopr:"171a74ab694a7d7c2baa3ccf103ad94f11094e07a955ae9ac3bad370f1448753e99b63cc23d1878ab66f94136ec2ecac":"72ebeda7342770d03bc0e531754f946ca5cca684c41f9d089fe9147fad93b6154919c5cb2e6d162fbfde7b9ff0aa590a17993ca6c80bd59eee4134fc2ce944d8":"":"":"":"582ab4f105c3e1fed9593f58fc335fc3" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"171a74ab694a7d7c2baa3ccf103ad94f11094e07a955ae9ac3bad370f1448753e99b63cc23d1878ab66f94136ec2ecac":"72ebeda7342770d03bc0e531754f946ca5cca684c41f9d089fe9147fad93b6154919c5cb2e6d162fbfde7b9ff0aa590a17993ca6c80bd59eee4134fc2ce944d8":"":"":"":"582ab4f105c3e1fed9593f58fc335fc3" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #10 -ctr_drbg_validate_nopr:"caed30015b34064762591eba9a59f440566a6621832f650572362229e8a38cd0f5d6d322afd8444132056690d6fa5540":"8e27f0dbeae4613bcf0011105f824ed2ecb150a83a0994f8f6607833755216e016fb175e51d42370afe27b11c18477886b530c95bc31bd1c0f8fe00f61fc15a0":"":"":"":"d42787e97147d457f1590c742443ad92" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"caed30015b34064762591eba9a59f440566a6621832f650572362229e8a38cd0f5d6d322afd8444132056690d6fa5540":"8e27f0dbeae4613bcf0011105f824ed2ecb150a83a0994f8f6607833755216e016fb175e51d42370afe27b11c18477886b530c95bc31bd1c0f8fe00f61fc15a0":"":"":"":"d42787e97147d457f1590c742443ad92" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #11 -ctr_drbg_validate_nopr:"c58d62f8145622cd86cfbda66bc26d2ce4c5610cd9cd1c326b99b60355a6fe751783c07f2cc21ba68f1f20ca70f0ad31":"38a8b685e6bbab67824f4cc72995043ea2854f067f2afaec762c9e78ff9d585a25bc63c8d0d075d06d43f3f694733982d26cbe0648b2d0cf8053918b912c303a":"":"":"":"84001709f15a2fd167c161b5d376d86d" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"c58d62f8145622cd86cfbda66bc26d2ce4c5610cd9cd1c326b99b60355a6fe751783c07f2cc21ba68f1f20ca70f0ad31":"38a8b685e6bbab67824f4cc72995043ea2854f067f2afaec762c9e78ff9d585a25bc63c8d0d075d06d43f3f694733982d26cbe0648b2d0cf8053918b912c303a":"":"":"":"84001709f15a2fd167c161b5d376d86d" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #12 -ctr_drbg_validate_nopr:"dc9719050d5257152d8a7d60d3ef1fc5b8cb1700bafc7de863c019f244779c464b6214f21a2f6d0aa3ca282007615ce5":"f188a1ba21b1791ebf8a08d8ba555e49423d9178a561bcc1672539c3a7ba1d856eae9922c4d96c181ed045d6f1d15e855690cdae451edac60f1ca2021f1fec57":"":"":"":"7540fed313c96261cac255bf83b5ae99" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"dc9719050d5257152d8a7d60d3ef1fc5b8cb1700bafc7de863c019f244779c464b6214f21a2f6d0aa3ca282007615ce5":"f188a1ba21b1791ebf8a08d8ba555e49423d9178a561bcc1672539c3a7ba1d856eae9922c4d96c181ed045d6f1d15e855690cdae451edac60f1ca2021f1fec57":"":"":"":"7540fed313c96261cac255bf83b5ae99" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #13 -ctr_drbg_validate_nopr:"ff057781af4a4a1eefeb26ab38f82a2efb6f065de290ebf225bd693dfb1f97455b49143bdb430324c9d945c48824f6cc":"0ddd0f4a43a7b54d9abb0928a2242c378db7a95a0b206baa642afe5cd55108f412f1d727fd591bca2c76355aa62aa8638cfa1916739bc66e02b9459ccd0881ba":"":"":"":"8b6e74a94fcac0d2f212d3594213fbb6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ff057781af4a4a1eefeb26ab38f82a2efb6f065de290ebf225bd693dfb1f97455b49143bdb430324c9d945c48824f6cc":"0ddd0f4a43a7b54d9abb0928a2242c378db7a95a0b206baa642afe5cd55108f412f1d727fd591bca2c76355aa62aa8638cfa1916739bc66e02b9459ccd0881ba":"":"":"":"8b6e74a94fcac0d2f212d3594213fbb6" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,0) #14 -ctr_drbg_validate_nopr:"ef027327e47fc5875c01cb17d798fdc2b27a5c78000727842f8a516f4e8dd34afc167ae145b1e763bebdca51e2f461a7":"128566fe6c5b5595742190519445c25db85ee0ce29371f4cab213400d479d2bfe27655155be0fa237173abb214f0226a2f1770802dd69485adb25e6d837485e1":"":"":"":"76cd1553b2b73d4ef6043a09fb90d679" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"ef027327e47fc5875c01cb17d798fdc2b27a5c78000727842f8a516f4e8dd34afc167ae145b1e763bebdca51e2f461a7":"128566fe6c5b5595742190519445c25db85ee0ce29371f4cab213400d479d2bfe27655155be0fa237173abb214f0226a2f1770802dd69485adb25e6d837485e1":"":"":"":"76cd1553b2b73d4ef6043a09fb90d679" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #0 -ctr_drbg_validate_nopr:"8e1a59210f876d017109cb90c7d5dd669b375d971266b7320ba8db9bd79b373bcc895974460e08eadd07a00ce7bdade9":"23677c04a2d6ab446b7b3c582a8071654d27859441b10799f08b788378b926ca4306e7cb5c0f9f104c607fbf0c379be49426e53bf5637225b551f0cc694d6593":"19e914ffbc6d872be010d66b17874010ec8b036a3d60d7f7dda5accc6962a542":"bd7a0c09e780e0ad783fd708355b8df77b4454c3d606fb8de053bffa5ecf9021":"d284dc2caf6d214f8909efc9a75297bccfc04353c2788a96f8b752749c7fec0c":"129d256e7db6269e5a0a160d2278f305" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"8e1a59210f876d017109cb90c7d5dd669b375d971266b7320ba8db9bd79b373bcc895974460e08eadd07a00ce7bdade9":"23677c04a2d6ab446b7b3c582a8071654d27859441b10799f08b788378b926ca4306e7cb5c0f9f104c607fbf0c379be49426e53bf5637225b551f0cc694d6593":"19e914ffbc6d872be010d66b17874010ec8b036a3d60d7f7dda5accc6962a542":"bd7a0c09e780e0ad783fd708355b8df77b4454c3d606fb8de053bffa5ecf9021":"d284dc2caf6d214f8909efc9a75297bccfc04353c2788a96f8b752749c7fec0c":"129d256e7db6269e5a0a160d2278f305" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #1 -ctr_drbg_validate_nopr:"00674e633670c9971be7af789d37d5a4ef567b3ca4766722cd8f67e09d21cbbfa08d43ea1aa259999c6a307ae6347d62":"ec47b029643f85ea19388b6e9de6ab22705b060ae10cee71262027d0bdff5efd7393af619bc6658612fabc78439a0bd5a01255563a96013fa130dd06fd0f5442":"5b92bce3f87645126daa4704fd7df98b880aa07743a57399b985ad1a00b1f2fc":"8199de1338c688234c77262ef35423f4695b277726c76d8b5f426399c14d83b5":"eb95f5a4d8400cec2d4e0f548b6e92636b5e284fb6b61766a1f35bb9cdc5df0a":"9fbe95817578eb272aa9da2f509c2a06" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"00674e633670c9971be7af789d37d5a4ef567b3ca4766722cd8f67e09d21cbbfa08d43ea1aa259999c6a307ae6347d62":"ec47b029643f85ea19388b6e9de6ab22705b060ae10cee71262027d0bdff5efd7393af619bc6658612fabc78439a0bd5a01255563a96013fa130dd06fd0f5442":"5b92bce3f87645126daa4704fd7df98b880aa07743a57399b985ad1a00b1f2fc":"8199de1338c688234c77262ef35423f4695b277726c76d8b5f426399c14d83b5":"eb95f5a4d8400cec2d4e0f548b6e92636b5e284fb6b61766a1f35bb9cdc5df0a":"9fbe95817578eb272aa9da2f509c2a06" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #2 -ctr_drbg_validate_nopr:"2553423c3cb0fae8ca54af56f496e9935d5af4738898f77f789a9bee867dfbc6010c4e5bc68da2b922cdd84eea68e1da":"a9bebd13711c0c22c94b3252654854515a9dc015fe69e688fbac9676b3d77ab67e19b020cd2427ac789ca17f656e499be3ba3ab2075ff95247c6355157eebc79":"e74e45fa28697a06dab08545fde0cc26e7eca31c40aa68ee41c4de402fdcc961":"5aa8abf7062079929d6a131cd3844a5fb6514c07061e25cad67677d867297685":"84819109b2e09b46ba3f5464c34b28ce25a186f0e0fd83fe5fa0ab026c01292a":"3846f3406e49040c48b5cfc9cbc75d1a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2553423c3cb0fae8ca54af56f496e9935d5af4738898f77f789a9bee867dfbc6010c4e5bc68da2b922cdd84eea68e1da":"a9bebd13711c0c22c94b3252654854515a9dc015fe69e688fbac9676b3d77ab67e19b020cd2427ac789ca17f656e499be3ba3ab2075ff95247c6355157eebc79":"e74e45fa28697a06dab08545fde0cc26e7eca31c40aa68ee41c4de402fdcc961":"5aa8abf7062079929d6a131cd3844a5fb6514c07061e25cad67677d867297685":"84819109b2e09b46ba3f5464c34b28ce25a186f0e0fd83fe5fa0ab026c01292a":"3846f3406e49040c48b5cfc9cbc75d1a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #3 -ctr_drbg_validate_nopr:"856f1371454bb9aa06be897dcda9b295817c6eeb865a9acb3a89d145bfe29ce5e1b3b12b714571afdfaca7951cd47e33":"a691b8bf6a407c93a36d18aeced4c75f76d8397d4ecbcd4e8f820cb393186897f05c1ef668b027fc78ba6da9bd554cc31a467d47b5e534b5340c7799383ec05c":"2c81d1e94b33164a177d0183d182fe7d23ef4f88444246464e58bdd0de38d82c":"1b5dae81c96771bea091521c0973c5af76a03e3624160e2511e57ff43a1d32a9":"bf5878e2bd139f8f058f3d834acd771514da6d4c5b9ef84466e5a4e0e4b2eaaf":"6a5ea73aad476ce201e173d4d5a7ffcc" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"856f1371454bb9aa06be897dcda9b295817c6eeb865a9acb3a89d145bfe29ce5e1b3b12b714571afdfaca7951cd47e33":"a691b8bf6a407c93a36d18aeced4c75f76d8397d4ecbcd4e8f820cb393186897f05c1ef668b027fc78ba6da9bd554cc31a467d47b5e534b5340c7799383ec05c":"2c81d1e94b33164a177d0183d182fe7d23ef4f88444246464e58bdd0de38d82c":"1b5dae81c96771bea091521c0973c5af76a03e3624160e2511e57ff43a1d32a9":"bf5878e2bd139f8f058f3d834acd771514da6d4c5b9ef84466e5a4e0e4b2eaaf":"6a5ea73aad476ce201e173d4d5a7ffcc" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #4 -ctr_drbg_validate_nopr:"0436075cf8cf62ce623c2301ebd45203c98282611cfa5a12dd7c04525ffa7eb343a607af2f57feb7ce3af97e0abc2285":"1ab9ada5eeebc3fc8e53f358b643476fcfd4dd9f092f21d2bc1c4bb1ffd01a0c5b207aaa09ff76a9cab0aa6ce62b6a65b2650ab448b8bb2e8696a7aa4b6f4e8d":"62f07d1f49e40f7f472985947ac4d8ef2d58216d918f7942b9c70f43daff8972":"37ae758141fbc890ee7e1d0854426b2984fb1c094677e6a61546e9315bab0898":"353d1dd0c8d8656bc418a6a3ace138ecd62819d4e21b8bd87694ea683ec0cc37":"bfee6bb4afc228da981bfe7f0d17578b" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"0436075cf8cf62ce623c2301ebd45203c98282611cfa5a12dd7c04525ffa7eb343a607af2f57feb7ce3af97e0abc2285":"1ab9ada5eeebc3fc8e53f358b643476fcfd4dd9f092f21d2bc1c4bb1ffd01a0c5b207aaa09ff76a9cab0aa6ce62b6a65b2650ab448b8bb2e8696a7aa4b6f4e8d":"62f07d1f49e40f7f472985947ac4d8ef2d58216d918f7942b9c70f43daff8972":"37ae758141fbc890ee7e1d0854426b2984fb1c094677e6a61546e9315bab0898":"353d1dd0c8d8656bc418a6a3ace138ecd62819d4e21b8bd87694ea683ec0cc37":"bfee6bb4afc228da981bfe7f0d17578b" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #5 -ctr_drbg_validate_nopr:"d004a0893bf326d50ee52e04cb3e64409f204f4e9af780d5dd092d04162d088385b1f243000914c62cba3dadf9827c81":"c36004075f5fd078137ea08de6cb15f71aeb9eca21c891cfdf7a8c0d21790c94ffa93be5fa06beb5e82d9fbf173ef9b29c18511fee2455dbbe61d6b01baf024a":"7d313ada131650c7a506d2c194444ed202d568544caa75bbc60e57a0b74c9a10":"791d60238677ff53150cf7074061eac68335c0a7cec7de43ea63a5df0f312cd8":"6754366be264deb9e94f39e92ac2894bd93c1d7e1198d39e6eddccb0ea486f4d":"1c29795f03e3c771603293473e347ab4" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"d004a0893bf326d50ee52e04cb3e64409f204f4e9af780d5dd092d04162d088385b1f243000914c62cba3dadf9827c81":"c36004075f5fd078137ea08de6cb15f71aeb9eca21c891cfdf7a8c0d21790c94ffa93be5fa06beb5e82d9fbf173ef9b29c18511fee2455dbbe61d6b01baf024a":"7d313ada131650c7a506d2c194444ed202d568544caa75bbc60e57a0b74c9a10":"791d60238677ff53150cf7074061eac68335c0a7cec7de43ea63a5df0f312cd8":"6754366be264deb9e94f39e92ac2894bd93c1d7e1198d39e6eddccb0ea486f4d":"1c29795f03e3c771603293473e347ab4" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #6 -ctr_drbg_validate_nopr:"9a8c79b48ada409183f7260aa1415c9ee4e0b662e0fb81b5c56f85d76ed75efac5751dd4de7e7f8b53a36ee0dce2bc9e":"c4d68b76dc0e785823be2da9d339dc900132f12721e8a63ebe92e36d740c5a5e5564c367bff4a52bc70b1c60c86f0bcb7c1d99c414956a259963207184f01246":"04c7060f36569a5d9578c718627fc2695e8d783c0c8aefca2744da6664e67c8c":"1d4b7d587421dea4f7f3e77fcf997607ecfeb6e665a9a184138eb5736b16f516":"8cb8daf9cda230d8d39b829b968aaa5f5d3e3106d8b693227ab1b6201b78a7b8":"faa146098526546927a43fa4a5073e46" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"9a8c79b48ada409183f7260aa1415c9ee4e0b662e0fb81b5c56f85d76ed75efac5751dd4de7e7f8b53a36ee0dce2bc9e":"c4d68b76dc0e785823be2da9d339dc900132f12721e8a63ebe92e36d740c5a5e5564c367bff4a52bc70b1c60c86f0bcb7c1d99c414956a259963207184f01246":"04c7060f36569a5d9578c718627fc2695e8d783c0c8aefca2744da6664e67c8c":"1d4b7d587421dea4f7f3e77fcf997607ecfeb6e665a9a184138eb5736b16f516":"8cb8daf9cda230d8d39b829b968aaa5f5d3e3106d8b693227ab1b6201b78a7b8":"faa146098526546927a43fa4a5073e46" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #7 -ctr_drbg_validate_nopr:"a0736a5a8b0a394625d8985b05e3a9f277c7ba03b253c0e783359a8c4c086121cb46ea469c7756d5f099f5ee8ed16243":"ea7a046fa1760866bcb37fecf9ade7bcea4444662ea782d6f2820b22a96bab97b4c5adcb0a50ced885121b6b85a5074444b1555d9655f4f6ded31fe15281b30e":"47f3655dd05c42454fad68e330aabca49f27c76ba05ef07b6d77fba41153c0ab":"a5d07da3e399cc51d136096599fcbd9779e839b1fd86f21d7d1e23acd91f9fa7":"150b028b64a988fc1ffdfc9e66b4c8dfe4fcd8538ee976c89923638ebad33802":"6ffdc685169b174ad0dd84cdeed050a7" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"a0736a5a8b0a394625d8985b05e3a9f277c7ba03b253c0e783359a8c4c086121cb46ea469c7756d5f099f5ee8ed16243":"ea7a046fa1760866bcb37fecf9ade7bcea4444662ea782d6f2820b22a96bab97b4c5adcb0a50ced885121b6b85a5074444b1555d9655f4f6ded31fe15281b30e":"47f3655dd05c42454fad68e330aabca49f27c76ba05ef07b6d77fba41153c0ab":"a5d07da3e399cc51d136096599fcbd9779e839b1fd86f21d7d1e23acd91f9fa7":"150b028b64a988fc1ffdfc9e66b4c8dfe4fcd8538ee976c89923638ebad33802":"6ffdc685169b174ad0dd84cdeed050a7" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #8 -ctr_drbg_validate_nopr:"d445a3d9332c8577715c1e93f119521bd31a464db08cdbd73d50080d62d5a48fba4cef2dd097ec749973037e33e8d6fa":"da5f9b2db13d0555846c00da96115036bb75ace66d56fc582d6cd0171e3e23335c5c2b8691e58af8899ed0204316479f849ca6f47309cae571ccb42d3d35c166":"79346394f795f05c5a5199423649b8b5345355ef11eb4239db1c767c68afa70a":"c22810de9987b228c19680eb044da22a08032148a6015f358849d6d608a214b9":"7747d68ca8bcb43931f1edce4f8c9727dd56c1d1d2600ad1fb767eb4fbc7b2d6":"f5c40babbec97cb60ba65200e82d7a68" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"d445a3d9332c8577715c1e93f119521bd31a464db08cdbd73d50080d62d5a48fba4cef2dd097ec749973037e33e8d6fa":"da5f9b2db13d0555846c00da96115036bb75ace66d56fc582d6cd0171e3e23335c5c2b8691e58af8899ed0204316479f849ca6f47309cae571ccb42d3d35c166":"79346394f795f05c5a5199423649b8b5345355ef11eb4239db1c767c68afa70a":"c22810de9987b228c19680eb044da22a08032148a6015f358849d6d608a214b9":"7747d68ca8bcb43931f1edce4f8c9727dd56c1d1d2600ad1fb767eb4fbc7b2d6":"f5c40babbec97cb60ba65200e82d7a68" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #9 -ctr_drbg_validate_nopr:"2728be06796e2a77c60a401752cd36e4a051724aa3276a146b4b351017eee79c8257398c612fc1129c0e74ecef455cd3":"d663d2cfcddf40ff61377c3811266d927a5dfc7b73cf549e673e5a15f4056ad1f9733c8ed875ff77928284dc1cdb33accc47971d3626615a45b9a16d9baf426e":"62349efbac4a4747d0e92727c67a6bc7f8404cf746002e7d3eeffb9a9be0bbdc":"381c0cffbdfa61a6af3f11ccd0e543208b584c3f520130e33617564ec7a48cf7":"6974043362f834fd793de07ceebd051599163d50489441005afc9db09a9ab44f":"df7894746c599e02d985b195ca3b4863" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2728be06796e2a77c60a401752cd36e4a051724aa3276a146b4b351017eee79c8257398c612fc1129c0e74ecef455cd3":"d663d2cfcddf40ff61377c3811266d927a5dfc7b73cf549e673e5a15f4056ad1f9733c8ed875ff77928284dc1cdb33accc47971d3626615a45b9a16d9baf426e":"62349efbac4a4747d0e92727c67a6bc7f8404cf746002e7d3eeffb9a9be0bbdc":"381c0cffbdfa61a6af3f11ccd0e543208b584c3f520130e33617564ec7a48cf7":"6974043362f834fd793de07ceebd051599163d50489441005afc9db09a9ab44f":"df7894746c599e02d985b195ca3b4863" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #10 -ctr_drbg_validate_nopr:"2b65b56de410ee82e55bd2bf80e6cee356a37c3a3aa7042df45fa750a74e097b071fc18d6eed96523dd4fbb677b8c729":"bf03a6b3e8e23ff53369b971217dc3d3f4c1211329c94847347b3aa77dc7a3e0670381573527844a1ade786f18631944558defffb9a00900ca55f97ec726126b":"59255e5cd2221316c945bd614471df76d5b2f394b8829de82e5c30bc178565e2":"5739bc14f0f2ef9d3393928aee67b0908adaf587650928916d8ae78b0077a3b3":"6b236cf0ee0dba0c92b26c60235d3868715a80c0efbc0c898b6f0b1ace8146e9":"8374b571d7f2d94ce2bdadeb9d815397" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"2b65b56de410ee82e55bd2bf80e6cee356a37c3a3aa7042df45fa750a74e097b071fc18d6eed96523dd4fbb677b8c729":"bf03a6b3e8e23ff53369b971217dc3d3f4c1211329c94847347b3aa77dc7a3e0670381573527844a1ade786f18631944558defffb9a00900ca55f97ec726126b":"59255e5cd2221316c945bd614471df76d5b2f394b8829de82e5c30bc178565e2":"5739bc14f0f2ef9d3393928aee67b0908adaf587650928916d8ae78b0077a3b3":"6b236cf0ee0dba0c92b26c60235d3868715a80c0efbc0c898b6f0b1ace8146e9":"8374b571d7f2d94ce2bdadeb9d815397" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #11 -ctr_drbg_validate_nopr:"8756ee2c5e381c7c1dc530748b76a6274ef6583090e555d85210e2356feb2974a8f15119a04e9b481cd3bc557a197b8e":"19705743eaaaa0e8890a0faa2e0df37c820d556c7a45f04d76276f9f9ce2e7c133258ae6d1ba9cdf7745d01745763d18dcd1af2c9e9b0bed2806e60f0f9b636c":"2b4a92b682e9a557466af97b735e2ffdbac3bfc31fd5be2cd212cfbd4b8d690a":"e86504f10317bbeab346f3b9e4b310cbe9fbd81a42054f358eacd08cccab6eff":"19ffad856a6675268cc464ca6fdb8afd0912143e552668528d1484c9a54592cf":"f347fd58aff2999530e258be77591701" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"8756ee2c5e381c7c1dc530748b76a6274ef6583090e555d85210e2356feb2974a8f15119a04e9b481cd3bc557a197b8e":"19705743eaaaa0e8890a0faa2e0df37c820d556c7a45f04d76276f9f9ce2e7c133258ae6d1ba9cdf7745d01745763d18dcd1af2c9e9b0bed2806e60f0f9b636c":"2b4a92b682e9a557466af97b735e2ffdbac3bfc31fd5be2cd212cfbd4b8d690a":"e86504f10317bbeab346f3b9e4b310cbe9fbd81a42054f358eacd08cccab6eff":"19ffad856a6675268cc464ca6fdb8afd0912143e552668528d1484c9a54592cf":"f347fd58aff2999530e258be77591701" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #12 -ctr_drbg_validate_nopr:"f58be57e5035d5c455b17a41ccf7542ffd77f5c009e0a737118ed6c4188f78fcbdbe946bf82e1fa50fd81691de82dcf3":"f9939592ab2b31d92ac72673da013a588ea17bbf02cfd6e79d79f8296601633d04ceb005110f266e6100040ef33194858def8b535314c73caa0e48fc4d2f6e2d":"bb1cb21a316d4b88093cbfc7917d614dca97090cdc8bb340d864547cb3e1fef6":"7e42d5439d81680c8edf5c571d548699730cfada33b650a4d510172a42b298bb":"e9e3cf180f72ba2c1a45d0a94b822943612143e0b642398796b0428ae1af6cf5":"d0c83a4bf3517648b441d411ddcb808c" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"f58be57e5035d5c455b17a41ccf7542ffd77f5c009e0a737118ed6c4188f78fcbdbe946bf82e1fa50fd81691de82dcf3":"f9939592ab2b31d92ac72673da013a588ea17bbf02cfd6e79d79f8296601633d04ceb005110f266e6100040ef33194858def8b535314c73caa0e48fc4d2f6e2d":"bb1cb21a316d4b88093cbfc7917d614dca97090cdc8bb340d864547cb3e1fef6":"7e42d5439d81680c8edf5c571d548699730cfada33b650a4d510172a42b298bb":"e9e3cf180f72ba2c1a45d0a94b822943612143e0b642398796b0428ae1af6cf5":"d0c83a4bf3517648b441d411ddcb808c" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #13 -ctr_drbg_validate_nopr:"898064243e44ff67151736ce8bb6f1c759cab4aaca9b87543a1ac984ef955cd5db76c1aa56aff83f1f6799f18fe531cc":"b8d6be3036eeb5657fb10766354d4be897bd27973b3530270ccc02a08169a2e437b30a3635eb6ccb310f319257f58d8aa030c8aab616418e0914a46131306a0c":"37572428df5826e6ae5ce95db4ef63f41e908f685204a7b64edb9f473c41e45c":"28beda0e0e346b447d32208c6b4c42dcd567acfe1e483fb4a95ea82cb8ce55a5":"7a0fffa541d723e16340eeb960b1b9c9aae912477e0ebfac03f8f1a3a8bdc531":"611c9f6fc5193dbe3db96cbcd276168a" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"898064243e44ff67151736ce8bb6f1c759cab4aaca9b87543a1ac984ef955cd5db76c1aa56aff83f1f6799f18fe531cc":"b8d6be3036eeb5657fb10766354d4be897bd27973b3530270ccc02a08169a2e437b30a3635eb6ccb310f319257f58d8aa030c8aab616418e0914a46131306a0c":"37572428df5826e6ae5ce95db4ef63f41e908f685204a7b64edb9f473c41e45c":"28beda0e0e346b447d32208c6b4c42dcd567acfe1e483fb4a95ea82cb8ce55a5":"7a0fffa541d723e16340eeb960b1b9c9aae912477e0ebfac03f8f1a3a8bdc531":"611c9f6fc5193dbe3db96cbcd276168a" CTR_DRBG NIST Validation (AES-256 use df,False,256,128,256,256) #14 -ctr_drbg_validate_nopr:"50de72903b9d99764123ffaa0c721e14ad1ab5c46a34c040f25324ba1d937b8ef10467161fcf2978c2a680ac5570c6d2":"5c9954fd0143e62c3bf2d5734052e3c9370f7b9d75c70f58fe33b12e3997ee2c8db84f8467affd7cfd9a9e7ec60da6f31bf9bf32aedf644e4934bd1fc916bc8d":"d5dc4c9fc7171fcbfdaead558a565ffd55d245a58b22ad1666ee05131e33f49e":"ea3114e92e6a19f53b207a0a54cd363a6d053fed0a827f92556f0a8580f7a342":"53686f069b455af4692888d11fac15cf7b4bd38e198de4e62b7098f875198a75":"9fb0df053e0345e5640aa97fedef50a6" +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_between:"50de72903b9d99764123ffaa0c721e14ad1ab5c46a34c040f25324ba1d937b8ef10467161fcf2978c2a680ac5570c6d2":"5c9954fd0143e62c3bf2d5734052e3c9370f7b9d75c70f58fe33b12e3997ee2c8db84f8467affd7cfd9a9e7ec60da6f31bf9bf32aedf644e4934bd1fc916bc8d":"d5dc4c9fc7171fcbfdaead558a565ffd55d245a58b22ad1666ee05131e33f49e":"ea3114e92e6a19f53b207a0a54cd363a6d053fed0a827f92556f0a8580f7a342":"53686f069b455af4692888d11fac15cf7b4bd38e198de4e62b7098f875198a75":"9fb0df053e0345e5640aa97fedef50a6" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,0) block 1 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"496f25b0f1301b4f501be30380a137eb":"36401940fa8b1fba91a1661f211d78a0b9389a74e5bccfece8d766af1a6d3b14":"":"":"5862eb38bd558dd978a696e6df164782ddd887e7e9a6c9f3f1fbafb78941b535a64912dfd224c6dc7454e5250b3d97165e16260c2faf1cc7735cb75fb4f07e1d" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,256) block 1 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"41c71a24d17d974190982bb7515ce7f5":"8148d65d86513ce7d38923ec2f26b9e7c677dcc8997e325b7372619e753ed944":"55b446046c2d14bdd0cdba4b71873fd4762650695a11507949462da8d964ab6a":"91468f1a097d99ee339462ca916cb4a10f63d53850a4f17f598eac490299b02e":"54603d1a506132bbfa05b153a04f22a1d516cc46323cef15111af221f030f38d6841d4670518b4914a4631af682e7421dffaac986a38e94d92bfa758e2eb101f" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,0) block 2 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"bac0fdc0c417aa269bbdea77e928f9f8":"8b0bcb3f932170416739ea42e7dcdc6fa960645bc018820134f714b3c6912b56":"":"":"d9c4fd81f6621a8cf06d612e9a84b80fa13d098dceaf2c083dc81cd80caedd105c7f2789963a167d72f76e81178001fd93de4623c260fe9eebced89f7b4b047a" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,256) block 2 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"69ff3310141dbf3ece409ade58745113":"d67439abf1e162e5b25941605a8aeba7d686dec133257f6c220e1c595e954a07":"03e795be8379c481cb32534011ca6bf524dc754978ee5ebee475129ad39eca98":"5685c7330f33004515f8c0ab27f2a1cbe0c8a4a6806d6c8486e0217b43e859f2":"a6d22a4370251c51978fedc7e7753c78179ed1943d2ff1b5a374860106041a304b124d47cfa304c909f7d417843846d52dcc7ebcf5c93afef885c893b40c81ed" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,0) block 3 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"aaa46610681167ff8d4d2c51e77911d4":"58a5f79da44b9f23a98a39352972ad16031fe13637bd18d6cb6c9f5269d8e240":"":"":"c1714f89459ce746b151509e5066d4811a06ad06c1e9b13b50c0fc7cdd77ceedc233908ebe1ea8140ec2dc262a43201be667008e081e5476b19b27214111d325" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,256) block 3 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"6ca848651d420fb02f9b66f06b377e59":"001ec3b192ddc765553e15742dffeb21cc7d97a4bcf866e3664d8a5ecb4c2463":"99f139ab5ee4f7eed6148e82d79ad5f2b9fa638d574e5db79b650c0e682ca466":"6e7bf0ae28a797ccbb47101f26bfe5a0b1e450c57aedf731272411fa7b6c4ed4":"865b6dd4363c5940d6228cc90ba8f1a21efbaa99b0c7b37361f7fed7e969a97b68d550dd6ad4bbfaf6626779bfb43c66845c2923df9f55307c8bc9f0a3872fa7" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,0) block 4 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"1c6a80d82012c39c9f14a808643f08e7":"4ee68b3352b874e1cc29375028851dee9d5dfd88a40664c79e2b724fb11b2808":"":"":"7c58d2a5522a88341fb55facefdb6e24840cae283948d53148a384e13b5407d7712c33434bd3d19448b43270c54860bf3495579057c70bff3084dddff08a091d" + +CTR_DRBG CAVS 14.3 (AES-256 no df,no reseed,256,128,0,256) block 4 #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"70bdedbc6825c4fe0a9f7e45290ddd51":"481e505bf7a36f9d96690d49154d98d6a247c14a703dbfed7cf1b7a71bee737f":"5b07610c2c946eda2975a26ddadf7d73e3d287e923d9b1a2d2070776a446d8e6":"2792a988ebb2e768eee0d5c263bcd76a675d6f339e5f1ab2ca595e6b3b4d024a":"303448a355fc0a69a130b6ab194997b220970bf680914913da904e92109dee3d9f23871130c407045cf463ce783a5dfafd603a8384790573af385d479acd7206" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,0) block 1 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"aad471ef3ef1d203":"890eb067acf7382eff80b0c73bc872c6":"":"":"a5514ed7095f64f3d0d3a5760394ab42062f373a25072a6ea6bcfd8489e94af6cf18659fea22ed1ca0a9e33f718b115ee536b12809c31b72b08ddd8be1910fa3" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,128) block 1 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"026c768fd577b92a":"b408cefb5bc7157d3f26cb95a8b1d7ac":"5737ef81dee365b6dadb3feebf5d1084":"3368a516b3431a3daaa60dc8743c8297":"4e909ebb24147a0004063a5e47ee044fead610d62324bd0f963f756fb91361e8b87e3a76a398143fe88130fe1b547b661a6480c711b739f18a9df3ae51d41bc9" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,0) block 2 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"259195269ec11af6":"2d2ab564202918c4ef5b102dda385a18":"":"":"2c5cd79ed87622a91b8654c8903d852242cd49cb5df2d4b4150584301c59f01fd95a702ac157c84cc15f42c8211335672d8ce1291ef9b1def78149a04fa2697c" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,128) block 2 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"b25716931b6e3cc1":"adf5711f93d8c8997349429ccaedae0a":"abf8cd66dd39758b01d7dbb99ab17dc3":"4be0f6b2755377c6e881fbb261b56beb":"d420604dee6467492db5957c86207a708fd242ed67942aed299425335c83b41437418582f41bc7fc0ef0d6927f34d83acd67c70133644fd711dd5a65731f9f02" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,0) block 3 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"38aa5590f6bfaa4b":"2e1724db482232a3e61f92c1c266faf8":"":"":"4438b48a45fb0141e31f0a9624dfe6fcc2f9edc075c0a52bc5fc46d85a966c853feee6af913234b3f9a679f667898dc15a24aaed89f035bfa5da516e435bbad1" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,128) block 3 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"111d8612a0f04e2a":"9bfaefb698b1b5fcc62db2c16498c33a":"aedbe02847b1b08b6a673bdf25b0224c":"9901ead62ce56573b0f71cd020fe3469":"dff8bf2aec531f8532607e738bd79f91d6085cb19568b7b0240ce6a6b371a282bafcdba02137df990535d9ebf0ba77117751626b2678aca7be4decfd6b9d4b38" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,0) block 4 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"e78c5571c5f926f9":"6bdf5332bdce4655d45c2cfea897b000":"":"":"e0715688765a3285e7b7db555f277924e7171f7541bf26122b13dbaaa39f9e2b0345c659583ff8c9cfd888f1abd2f3b36a7c9d47c687b01c819a9f9888542e0f" + +CTR_DRBG CAVS 14.3 (AES-128 use df,no reseed,128,64,0,128) block 4 #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_no_reseed:"7ee2614ead3c128e":"8b80936e69c67edb771c28f9b9452124":"fc35cba97a1e211bc420e8af53f8e13c":"fba438aaa75a3cd4cd0cce399bfec74a":"6721cc1ada5ebc1713f74c759000765652eeb5f3f9c24fb9341b36a369cec1d27ea80d6b73b56047af07138c5a43c99a87753115c471b8587ea65fa2065e3ce0" + +CTR_DRBG CAVS 14.3 (AES-256 use df,False,256,128,0,0) #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_first:"0bf814b411f65ec4866be1abb59d3c32":"2d4c9f46b981c6a0b2b5d8c69391e569ff13851437ebc0fc00d616340252fed593500fae4fa32b86033b7a7bac9d37e710dcc67ca266bc8607d665937766d207":"":"":"":"322dd28670e75c0ea638f3cb68d6a9d6e50ddfd052b772a7b1d78263a7b8978b6740c2b65a9550c3a76325866fa97e16d74006bc96f26249b9f0a90d076f08e5" + +CTR_DRBG CAVS 14.3 (AES-128 use df,False,128,64,0,0) #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_reseed_first:"5209e5b4ed82a234":"0f65da13dca407999d4773c2b4a11d851dea0a12c52bf64339dd291c80d8ca89":"":"":"":"2859cc468a76b08661ffd23b28547ffd0997ad526a0f51261b99ed3a37bd407bf418dbe6c6c3e26ed0ddefcb7474d899bd99f3655427519fc5b4057bcaf306d4" + +CTR_DRBG CAVS 14.3 (AES-256 use df,True,256,128,0,0) #0 +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_pr:"a2d015f22d854e29de278d910c573de5":"16a1f035388cd8d956026e3b0117cb524dd3eb563f9a7720bb7dcb0fc6fbe743cf140bcd4d7130e7e3ea14046c56442b57c43b34ad219553e7105c18f6e561afe27c9f0be60d82d6cc474efb7fc737b16a6895d9a3a45b971d19b743c1a4ac8f":"":"":"b4e8395bcb7503410a94633f70e9904a5b30e62c35bc6dd2a03496c4a49932e184fbffdbcf1de1c72c50d36dc2ae8f04f40f96aae159c3fb816ca16df99b6c3e" + +CTR_DRBG CAVS 14.3 (AES-128 use df,True,128,64,0,0) #0 +depends_on:MBEDTLS_CTR_DRBG_USE_128_BIT_KEY +ctr_drbg_validate_pr:"d4f1f4ae08bcb3e1":"5d4041942bcf68864a4997d8171f1f9fef55a769b7eaf03fe082029bb32a2b9d8239e865c0a42e14b964b9c09de85a20":"":"":"4155320287eedcf7d484c2c2a1e2eb64b9c9ce77c87202a1ae1616c7a5cfd1c687c7a0bfcc85bda48fdd4629fd330c22d0a76076f88fc7cd04037ee06b7af602" CTR_DRBG entropy usage ctr_drbg_entropy_usage: @@ -731,5 +1083,6 @@ CTR_DRBG Special Behaviours ctr_drbg_special_behaviours: CTR_DRBG self test +depends_on:!MBEDTLS_CTR_DRBG_USE_128_BIT_KEY ctr_drbg_selftest: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.function index f17bd3be00..4a97826f63 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ctr_drbg.function @@ -1,14 +1,97 @@ /* BEGIN_HEADER */ +#include "mbedtls/entropy.h" #include "mbedtls/ctr_drbg.h" +#include "string.h" -static int test_offset_idx; +/* Modes for ctr_drbg_validate */ +enum reseed_mode +{ + RESEED_NEVER, /* never reseed */ + RESEED_FIRST, /* instantiate, reseed, generate, generate */ + RESEED_SECOND, /* instantiate, generate, reseed, generate */ + RESEED_ALWAYS /* prediction resistance, no explicit reseed */ +}; + +static size_t test_offset_idx = 0; +static size_t test_max_idx = 0; static int mbedtls_test_entropy_func( void *data, unsigned char *buf, size_t len ) { const unsigned char *p = (unsigned char *) data; + if( test_offset_idx + len > test_max_idx ) + return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED ); memcpy( buf, p + test_offset_idx, len ); test_offset_idx += len; return( 0 ); } + +static void ctr_drbg_validate_internal( int reseed_mode, data_t * nonce, + int entropy_len_arg, data_t * entropy, + data_t * reseed, + data_t * add1, data_t * add2, + data_t * result ) +{ + mbedtls_ctr_drbg_context ctx; + unsigned char buf[64]; + + size_t entropy_chunk_len = (size_t) entropy_len_arg; + + TEST_ASSERT( entropy_chunk_len <= sizeof( buf ) ); + + test_offset_idx = 0; + mbedtls_ctr_drbg_init( &ctx ); + + test_max_idx = entropy->len; + + /* CTR_DRBG_Instantiate(entropy[:entropy->len], nonce, perso, ) + * where nonce||perso = nonce[nonce->len] */ + TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( + &ctx, + mbedtls_test_entropy_func, entropy->x, + nonce->x, nonce->len, + entropy_chunk_len ) == 0 ); + if( reseed_mode == RESEED_ALWAYS ) + mbedtls_ctr_drbg_set_prediction_resistance( + &ctx, + MBEDTLS_CTR_DRBG_PR_ON ); + + if( reseed_mode == RESEED_FIRST ) + { + /* CTR_DRBG_Reseed(entropy[idx:idx+entropy->len], + * reseed[:reseed->len]) */ + TEST_ASSERT( mbedtls_ctr_drbg_reseed( + &ctx, + reseed->x, reseed->len ) == 0 ); + } + + /* CTR_DRBG_Generate(result->len * 8 bits, add1[:add1->len]) -> buf */ + /* Then reseed if prediction resistance is enabled. */ + TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( + &ctx, + buf, result->len, + add1->x, add1->len ) == 0 ); + + + if( reseed_mode == RESEED_SECOND ) + { + /* CTR_DRBG_Reseed(entropy[idx:idx+entropy->len], + * reseed[:reseed->len]) */ + TEST_ASSERT( mbedtls_ctr_drbg_reseed( + &ctx, + reseed->x, reseed->len ) == 0 ); + } + + /* CTR_DRBG_Generate(result->len * 8 bits, add2->x[:add2->len]) -> buf */ + /* Then reseed if prediction resistance is enabled. */ + TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( + &ctx, + buf, result->len, + add2->x, add2->len ) == 0 ); + TEST_ASSERT( memcmp( buf, result->x, result->len ) == 0 ); + +exit: + mbedtls_ctr_drbg_free( &ctx ); +} + /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -49,92 +132,76 @@ exit: } /* END_CASE */ + /* BEGIN_CASE */ -void ctr_drbg_validate_pr( char *add_init_string, char *entropy_string, - char *add1_string, char *add2_string, - char *result_str ) +void ctr_drbg_validate_no_reseed( data_t * add_init, data_t * entropy, + data_t * add1, data_t * add2, + data_t * result_string ) { - unsigned char entropy[512]; - unsigned char add_init[512]; - unsigned char add1[512]; - unsigned char add2[512]; - mbedtls_ctr_drbg_context ctx; - unsigned char buf[512]; - unsigned char output_str[512]; - int add_init_len, add1_len, add2_len; - - mbedtls_ctr_drbg_init( &ctx ); - memset( output_str, 0, 512 ); - - unhexify( entropy, entropy_string ); - add_init_len = unhexify( add_init, add_init_string ); - add1_len = unhexify( add1, add1_string ); - add2_len = unhexify( add2, add2_string ); - - test_offset_idx = 0; - TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( &ctx, mbedtls_test_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 ); - mbedtls_ctr_drbg_set_prediction_resistance( &ctx, MBEDTLS_CTR_DRBG_PR_ON ); - - TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 ); - TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add2, add2_len ) == 0 ); - hexify( output_str, buf, 16 ); - TEST_ASSERT( strcmp( (char *) output_str, result_str ) == 0 ); - -exit: - mbedtls_ctr_drbg_free( &ctx ); + data_t empty = { 0, 0 }; + ctr_drbg_validate_internal( RESEED_NEVER, add_init, + entropy->len, entropy, + &empty, add1, add2, + result_string ); + goto exit; // goto is needed to avoid warning ( no test assertions in func) } /* END_CASE */ /* BEGIN_CASE */ -void ctr_drbg_validate_nopr( char *add_init_string, char *entropy_string, - char *add1_string, char *add_reseed_string, - char *add2_string, char *result_str ) +void ctr_drbg_validate_pr( data_t * add_init, data_t * entropy, + data_t * add1, data_t * add2, + data_t * result_string ) { - unsigned char entropy[512]; - unsigned char add_init[512]; - unsigned char add1[512]; - unsigned char add_reseed[512]; - unsigned char add2[512]; - mbedtls_ctr_drbg_context ctx; - unsigned char buf[512]; - unsigned char output_str[512]; - int add_init_len, add1_len, add_reseed_len, add2_len; - - mbedtls_ctr_drbg_init( &ctx ); - memset( output_str, 0, 512 ); - - unhexify( entropy, entropy_string ); - add_init_len = unhexify( add_init, add_init_string ); - add1_len = unhexify( add1, add1_string ); - add_reseed_len = unhexify( add_reseed, add_reseed_string ); - add2_len = unhexify( add2, add2_string ); - - test_offset_idx = 0; - TEST_ASSERT( mbedtls_ctr_drbg_seed_entropy_len( &ctx, mbedtls_test_entropy_func, entropy, add_init, add_init_len, 32 ) == 0 ); + data_t empty = { 0, 0 }; + ctr_drbg_validate_internal( RESEED_ALWAYS, add_init, + entropy->len / 3, entropy, + &empty, add1, add2, + result_string ); + goto exit; // goto is needed to avoid warning ( no test assertions in func) +} +/* END_CASE */ - TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add1, add1_len ) == 0 ); - TEST_ASSERT( mbedtls_ctr_drbg_reseed( &ctx, add_reseed, add_reseed_len ) == 0 ); - TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx, buf, 16, add2, add2_len ) == 0 ); - hexify( output_str, buf, 16 ); - TEST_ASSERT( strcmp( (char *) output_str, result_str ) == 0 ); +/* BEGIN_CASE */ +void ctr_drbg_validate_reseed_between( data_t * add_init, data_t * entropy, + data_t * add1, data_t * add_reseed, + data_t * add2, data_t * result_string ) +{ + ctr_drbg_validate_internal( RESEED_SECOND, add_init, + entropy->len / 2, entropy, + add_reseed, add1, add2, + result_string ); + goto exit; // goto is needed to avoid warning ( no test assertions in func) +} +/* END_CASE */ -exit: - mbedtls_ctr_drbg_free( &ctx ); +/* BEGIN_CASE */ +void ctr_drbg_validate_reseed_first( data_t * add_init, data_t * entropy, + data_t * add1, data_t * add_reseed, + data_t * add2, data_t * result_string ) +{ + ctr_drbg_validate_internal( RESEED_FIRST, add_init, + entropy->len / 2, entropy, + add_reseed, add1, add2, + result_string ); + goto exit; // goto is needed to avoid warning ( no test assertions in func) } /* END_CASE */ + + /* BEGIN_CASE */ -void ctr_drbg_entropy_usage( ) +void ctr_drbg_entropy_usage( ) { unsigned char out[16]; unsigned char add[16]; unsigned char entropy[1024]; mbedtls_ctr_drbg_context ctx; size_t i, reps = 10; - int last_idx; + size_t last_idx; mbedtls_ctr_drbg_init( &ctx ); test_offset_idx = 0; + test_max_idx = sizeof( entropy ); memset( entropy, 0, sizeof( entropy ) ); memset( out, 0, sizeof( out ) ); memset( add, 0, sizeof( add ) ); @@ -205,7 +272,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ -void ctr_drbg_seed_file( char *path, int ret ) +void ctr_drbg_seed_file( char * path, int ret ) { mbedtls_ctr_drbg_context ctx; @@ -221,7 +288,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void ctr_drbg_selftest( ) +void ctr_drbg_selftest( ) { TEST_ASSERT( mbedtls_ctr_drbg_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_debug.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_debug.function index 98f98b061b..377d630d90 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_debug.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_debug.function @@ -1,5 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/debug.h" +#include "string.h" struct buffer_data { @@ -47,8 +48,8 @@ void string_debug(void *data, int level, const char *file, int line, const char */ /* BEGIN_CASE */ -void debug_print_msg_threshold( int threshold, int level, char *file, int line, - char *result_str ) +void debug_print_msg_threshold( int threshold, int level, char * file, + int line, char * result_str ) { mbedtls_ssl_context ssl; mbedtls_ssl_config conf; @@ -76,8 +77,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_debug_print_ret( char *file, int line, char *text, int value, - char *result_str ) +void mbedtls_debug_print_ret( char * file, int line, char * text, int value, + char * result_str ) { mbedtls_ssl_context ssl; mbedtls_ssl_config conf; @@ -103,28 +104,24 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_debug_print_buf( char *file, int line, char *text, - char *data_string, char *result_str ) +void mbedtls_debug_print_buf( char * file, int line, char * text, + data_t * data, char * result_str ) { - unsigned char data[10000]; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; struct buffer_data buffer; - size_t data_len; mbedtls_ssl_init( &ssl ); mbedtls_ssl_config_init( &conf ); - memset( &data, 0, sizeof( data ) ); memset( buffer.buf, 0, 2000 ); buffer.ptr = buffer.buf; - data_len = unhexify( data, data_string ); TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 ); mbedtls_ssl_conf_dbg( &conf, string_debug, &buffer); - mbedtls_debug_print_buf( &ssl, 0, file, line, text, data, data_len ); + mbedtls_debug_print_buf( &ssl, 0, file, line, text, data->x, data->len ); TEST_ASSERT( strcmp( buffer.buf, result_str ) == 0 ); @@ -135,8 +132,8 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ -void mbedtls_debug_print_crt( char *crt_file, char *file, int line, - char *prefix, char *result_str ) +void mbedtls_debug_print_crt( char * crt_file, char * file, int line, + char * prefix, char * result_str ) { mbedtls_x509_crt crt; mbedtls_ssl_context ssl; @@ -166,8 +163,8 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_BIGNUM_C */ -void mbedtls_debug_print_mpi( int radix, char *value, char *file, int line, - char *prefix, char *result_str ) +void mbedtls_debug_print_mpi( int radix, char * value, char * file, int line, + char * prefix, char * result_str ) { mbedtls_ssl_context ssl; mbedtls_ssl_config conf; diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_des.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_des.function index 2e73a77681..b5acb7b0ff 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_des.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_des.function @@ -8,42 +8,27 @@ */ /* BEGIN_CASE */ -void des_check_weak( char *key_hex, int ret ) +void des_check_weak( data_t * key, int ret ) { - unsigned char key[MBEDTLS_DES_KEY_SIZE]; - - memset( key, 0, sizeof key ); - - unhexify( key, key_hex ); - - TEST_ASSERT( mbedtls_des_key_check_weak( key ) == ret ); + TEST_ASSERT( mbedtls_des_key_check_weak( key->x ) == ret ); } /* END_CASE */ /* BEGIN_CASE */ -void des_encrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string ) +void des_encrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - mbedtls_des_setkey_enc( &ctx, key_str ); - TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + mbedtls_des_setkey_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); exit: mbedtls_des_free( &ctx ); @@ -51,29 +36,20 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void des_decrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string ) +void des_decrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - mbedtls_des_setkey_dec( &ctx, key_str ); - TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + mbedtls_des_setkey_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_crypt_ecb( &ctx, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); exit: mbedtls_des_free( &ctx ); @@ -81,35 +57,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void des_encrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, int cbc_result ) +void des_encrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, + int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des_context ctx; - int src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); - mbedtls_des_setkey_enc( &ctx, key_str ); - TEST_ASSERT( mbedtls_des_crypt_cbc( &ctx, MBEDTLS_DES_ENCRYPT, src_len, iv_str, src_str, output ) == cbc_result ); + mbedtls_des_setkey_enc( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_crypt_cbc( &ctx, MBEDTLS_DES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -118,35 +82,23 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void des_decrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string, int cbc_result ) +void des_decrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string, + int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des_context ctx; - int src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); - mbedtls_des_setkey_dec( &ctx, key_str ); - TEST_ASSERT( mbedtls_des_crypt_cbc( &ctx, MBEDTLS_DES_DECRYPT, src_len, iv_str, src_str, output ) == cbc_result ); + mbedtls_des_setkey_dec( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_des_crypt_cbc( &ctx, MBEDTLS_DES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -155,35 +107,26 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void des3_encrypt_ecb( int key_count, char *hex_key_string, - char *hex_src_string, char *hex_dst_string ) +void des3_encrypt_ecb( int key_count, data_t * key_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des3_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des3_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); if( key_count == 2 ) - mbedtls_des3_set2key_enc( &ctx, key_str ); + mbedtls_des3_set2key_enc( &ctx, key_str->x ); else if( key_count == 3 ) - mbedtls_des3_set3key_enc( &ctx, key_str ); + mbedtls_des3_set3key_enc( &ctx, key_str->x ); else TEST_ASSERT( 0 ); - TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); exit: mbedtls_des3_free( &ctx ); @@ -191,35 +134,26 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void des3_decrypt_ecb( int key_count, char *hex_key_string, - char *hex_src_string, char *hex_dst_string ) +void des3_decrypt_ecb( int key_count, data_t * key_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des3_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des3_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); if( key_count == 2 ) - mbedtls_des3_set2key_dec( &ctx, key_str ); + mbedtls_des3_set2key_dec( &ctx, key_str->x ); else if( key_count == 3 ) - mbedtls_des3_set3key_dec( &ctx, key_str ); + mbedtls_des3_set3key_dec( &ctx, key_str->x ); else TEST_ASSERT( 0 ); - TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + TEST_ASSERT( mbedtls_des3_crypt_ecb( &ctx, src_str->x, output ) == 0 ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); exit: mbedtls_des3_free( &ctx ); @@ -227,43 +161,30 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void des3_encrypt_cbc( int key_count, char *hex_key_string, - char *hex_iv_string, char *hex_src_string, - char *hex_dst_string, int cbc_result ) +void des3_encrypt_cbc( int key_count, data_t * key_str, + data_t * iv_str, data_t * src_str, + data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des3_context ctx; - int src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des3_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); if( key_count == 2 ) - mbedtls_des3_set2key_enc( &ctx, key_str ); + mbedtls_des3_set2key_enc( &ctx, key_str->x ); else if( key_count == 3 ) - mbedtls_des3_set3key_enc( &ctx, key_str ); + mbedtls_des3_set3key_enc( &ctx, key_str->x ); else TEST_ASSERT( 0 ); - TEST_ASSERT( mbedtls_des3_crypt_cbc( &ctx, MBEDTLS_DES_ENCRYPT, src_len, iv_str, src_str, output ) == cbc_result ); + TEST_ASSERT( mbedtls_des3_crypt_cbc( &ctx, MBEDTLS_DES_ENCRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -272,43 +193,30 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void des3_decrypt_cbc( int key_count, char *hex_key_string, - char *hex_iv_string, char *hex_src_string, - char *hex_dst_string, int cbc_result ) +void des3_decrypt_cbc( int key_count, data_t * key_str, + data_t * iv_str, data_t * src_str, + data_t * hex_dst_string, int cbc_result ) { - unsigned char key_str[100]; - unsigned char iv_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_des3_context ctx; - int src_len; - memset(key_str, 0x00, 100); - memset(iv_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); mbedtls_des3_init( &ctx ); - unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - src_len = unhexify( src_str, hex_src_string ); if( key_count == 2 ) - mbedtls_des3_set2key_dec( &ctx, key_str ); + mbedtls_des3_set2key_dec( &ctx, key_str->x ); else if( key_count == 3 ) - mbedtls_des3_set3key_dec( &ctx, key_str ); + mbedtls_des3_set3key_dec( &ctx, key_str->x ); else TEST_ASSERT( 0 ); - TEST_ASSERT( mbedtls_des3_crypt_cbc( &ctx, MBEDTLS_DES_DECRYPT, src_len, iv_str, src_str, output ) == cbc_result ); + TEST_ASSERT( mbedtls_des3_crypt_cbc( &ctx, MBEDTLS_DES_DECRYPT, src_str->len, iv_str->x, src_str->x, output ) == cbc_result ); if( cbc_result == 0 ) { - hexify( dst_str, output, src_len ); - TEST_ASSERT( strcasecmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } exit: @@ -317,7 +225,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void des_key_parity_run() +void des_key_parity_run( ) { int i, j, cnt; unsigned char key[MBEDTLS_DES_KEY_SIZE]; @@ -360,7 +268,7 @@ void des_key_parity_run() /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void des_selftest() +void des_selftest( ) { TEST_ASSERT( mbedtls_des_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.data index 734fd97ac1..edebce087c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.data @@ -1,3 +1,6 @@ +Diffie-Hellman parameter validation +dhm_invalid_params: + Diffie-Hellman full exchange #1 dhm_do_dhm:10:"23":10:"5":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.function index 4fd8fff237..8a05a38dfb 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_dhm.function @@ -7,6 +7,113 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void dhm_invalid_params( ) +{ + mbedtls_dhm_context ctx; + unsigned char buf[42] = { 0 }; + unsigned char *buf_null = NULL; + mbedtls_mpi X; + size_t const buflen = sizeof( buf ); + size_t len; + + TEST_INVALID_PARAM( mbedtls_dhm_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_dhm_free( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_read_params( NULL, + (unsigned char**) &buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_read_params( &ctx, &buf_null, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_read_params( &ctx, NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_read_params( &ctx, + (unsigned char**) &buf, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_params( NULL, buflen, + buf, &len, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_params( &ctx, buflen, + NULL, &len, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_params( &ctx, buflen, + buf, NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_params( &ctx, buflen, + buf, &len, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_set_group( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_set_group( &ctx, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_set_group( &ctx, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_read_public( NULL, buf, buflen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_read_public( &ctx, NULL, buflen ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_public( NULL, buflen, + buf, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_public( &ctx, buflen, + NULL, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_make_public( &ctx, buflen, + buf, buflen, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_calc_secret( NULL, buf, buflen, + &len, rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_calc_secret( &ctx, NULL, buflen, + &len, rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_calc_secret( &ctx, buf, buflen, + NULL, rnd_std_rand, + NULL ) ); + +#if defined(MBEDTLS_ASN1_PARSE_C) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_parse_dhm( NULL, buf, buflen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_parse_dhm( &ctx, NULL, buflen ) ); + +#if defined(MBEDTLS_FS_IO) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_parse_dhmfile( NULL, "" ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA, + mbedtls_dhm_parse_dhmfile( &ctx, NULL ) ); +#endif /* MBEDTLS_FS_IO */ +#endif /* MBEDTLS_ASN1_PARSE_C */ + +exit: + return; +} +/* END_CASE */ + /* BEGIN_CASE */ void dhm_do_dhm( int radix_P, char *input_P, int radix_G, char *input_G, int result ) @@ -100,7 +207,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ -void dhm_file( char *filename, char *p, char *g, int len ) +void dhm_file( char * filename, char * p, char * g, int len ) { mbedtls_dhm_context ctx; mbedtls_mpi P, G; @@ -124,7 +231,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void dhm_selftest() +void dhm_selftest( ) { TEST_ASSERT( mbedtls_dhm_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.data index f7119de416..af25359d33 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.data @@ -1,3 +1,9 @@ +ECDH - Valid parameters +ecdh_valid_param: + +ECDH - Invalid parameters +ecdh_invalid_param: + ECDH primitive random #1 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED ecdh_primitive_random:MBEDTLS_ECP_DP_SECP192R1 @@ -37,3 +43,55 @@ ecdh_exchange:MBEDTLS_ECP_DP_SECP192R1 ECDH exchange #2 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED ecdh_exchange:MBEDTLS_ECP_DP_SECP521R1 + +ECDH restartable rfc 5903 p256 restart enabled max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":1:0:0:0 + +ECDH restartable rfc 5903 p256 restart enabled max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":1:1:1:10000 + +ECDH restartable rfc 5903 p256 restart enabled max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":1:10000:0:0 + +ECDH restartable rfc 5903 p256 restart enabled max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":1:250:2:32 + +ECDH restartable rfc 5903 p256 restart disabled max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":0:0:0:0 + +ECDH restartable rfc 5903 p256 restart disabled max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":0:1:0:0 + +ECDH restartable rfc 5903 p256 restart disabled max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":0:10000:0:0 + +ECDH restartable rfc 5903 p256 restart disabled max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_restart:MBEDTLS_ECP_DP_SECP256R1:"C88F01F510D9AC3F70A292DAA2316DE544E9AAB8AFE84049C62A9C57862D1433":"C6EF9C5D78AE012A011164ACB397CE2088685D8F06BF9BE0B283AB46476BEE53":"D6840F6B42F6EDAFD13116E0E12565202FEF8E9ECE7DCE03812464D04B9442DE":0:250:0:0 + +ECDH exchange legacy context +depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED +ecdh_exchange_legacy:MBEDTLS_ECP_DP_SECP192R1 + +ECDH calc_secret: ours first, SECP256R1 (RFC 5903) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_exchange_calc_secret:MBEDTLS_ECP_DP_SECP256R1:"c6ef9c5d78ae012a011164acb397ce2088685d8f06bf9be0b283ab46476bee53":"04dad0b65394221cf9b051e1feca5787d098dfe637fc90b9ef945d0c37725811805271a0461cdb8252d61f1c456fa3e59ab1f45b33accf5f58389e0577b8990bb3":0:"d6840f6b42f6edafd13116e0e12565202fef8e9ece7dce03812464d04b9442de" + +ECDH calc_secret: theirs first, SECP256R1 (RFC 5903) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdh_exchange_calc_secret:MBEDTLS_ECP_DP_SECP256R1:"c6ef9c5d78ae012a011164acb397ce2088685d8f06bf9be0b283ab46476bee53":"04dad0b65394221cf9b051e1feca5787d098dfe637fc90b9ef945d0c37725811805271a0461cdb8252d61f1c456fa3e59ab1f45b33accf5f58389e0577b8990bb3":1:"d6840f6b42f6edafd13116e0e12565202fef8e9ece7dce03812464d04b9442de" + +ECDH get_params with mismatched groups: our BP256R1, their SECP256R1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_BP256R1_ENABLED +ecdh_exchange_get_params_fail:MBEDTLS_ECP_DP_BP256R1:"1234567812345678123456781234567812345678123456781234567812345678":MBEDTLS_ECP_DP_SECP256R1:"04dad0b65394221cf9b051e1feca5787d098dfe637fc90b9ef945d0c37725811805271a0461cdb8252d61f1c456fa3e59ab1f45b33accf5f58389e0577b8990bb3":0:MBEDTLS_ERR_ECP_BAD_INPUT_DATA + +ECDH get_params with mismatched groups: their SECP256R1, our BP256R1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_BP256R1_ENABLED +ecdh_exchange_get_params_fail:MBEDTLS_ECP_DP_BP256R1:"1234567812345678123456781234567812345678123456781234567812345678":MBEDTLS_ECP_DP_SECP256R1:"04dad0b65394221cf9b051e1feca5787d098dfe637fc90b9ef945d0c37725811805271a0461cdb8252d61f1c456fa3e59ab1f45b33accf5f58389e0577b8990bb3":1:MBEDTLS_ERR_ECP_BAD_INPUT_DATA diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.function index 4c6a97baf0..9a9cf5f7fa 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdh.function @@ -1,5 +1,41 @@ /* BEGIN_HEADER */ #include "mbedtls/ecdh.h" + +static int load_public_key( int grp_id, data_t *point, + mbedtls_ecp_keypair *ecp ) +{ + int ok = 0; + TEST_ASSERT( mbedtls_ecp_group_load( &ecp->grp, grp_id ) == 0 ); + TEST_ASSERT( mbedtls_ecp_point_read_binary( &ecp->grp, + &ecp->Q, + point->x, + point->len ) == 0 ); + TEST_ASSERT( mbedtls_ecp_check_pubkey( &ecp->grp, + &ecp->Q ) == 0 ); + ok = 1; +exit: + return( ok ); +} + +static int load_private_key( int grp_id, data_t *private_key, + mbedtls_ecp_keypair *ecp, + rnd_pseudo_info *rnd_info ) +{ + int ok = 0; + TEST_ASSERT( mbedtls_ecp_group_load( &ecp->grp, grp_id ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_binary( &ecp->d, + private_key->x, + private_key->len ) == 0 ); + TEST_ASSERT( mbedtls_ecp_check_privkey( &ecp->grp, &ecp->d ) == 0 ); + /* Calculate the public key from the private key. */ + TEST_ASSERT( mbedtls_ecp_mul( &ecp->grp, &ecp->Q, &ecp->d, + &ecp->grp.G, + &rnd_pseudo_rand, rnd_info ) == 0 ); + ok = 1; +exit: + return( ok ); +} + /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -7,6 +43,148 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE */ +void ecdh_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_ecdh_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void ecdh_invalid_param( ) +{ + mbedtls_ecp_group grp; + mbedtls_ecdh_context ctx; + mbedtls_mpi m; + mbedtls_ecp_point P; + mbedtls_ecp_keypair kp; + size_t olen; + unsigned char buf[42] = { 0 }; + const unsigned char *buf_null = NULL; + size_t const buflen = sizeof( buf ); + int invalid_side = 42; + mbedtls_ecp_group_id valid_grp = MBEDTLS_ECP_DP_SECP192R1; + + TEST_INVALID_PARAM( mbedtls_ecdh_init( NULL ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + TEST_INVALID_PARAM( mbedtls_ecdh_enable_restart( NULL ) ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_gen_public( NULL, &m, &P, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_gen_public( &grp, NULL, &P, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_gen_public( &grp, &m, NULL, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_gen_public( &grp, &m, &P, + NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_compute_shared( NULL, &m, &P, &m, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_compute_shared( &grp, NULL, &P, &m, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_compute_shared( &grp, &m, NULL, &m, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_compute_shared( &grp, &m, &P, NULL, + rnd_std_rand, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_setup( NULL, valid_grp ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_params( NULL, &olen, + buf, buflen, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_params( &ctx, NULL, + buf, buflen, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_params( &ctx, &olen, + NULL, buflen, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_params( &ctx, &olen, + buf, buflen, + NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_read_params( NULL, + (const unsigned char**) &buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_read_params( &ctx, &buf_null, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_read_params( &ctx, NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_read_params( &ctx, + (const unsigned char**) &buf, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_get_params( NULL, &kp, + MBEDTLS_ECDH_OURS ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_get_params( &ctx, NULL, + MBEDTLS_ECDH_OURS ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_get_params( &ctx, &kp, + invalid_side ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_public( NULL, &olen, + buf, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_public( &ctx, NULL, + buf, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_public( &ctx, &olen, + NULL, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_make_public( &ctx, &olen, + buf, buflen, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_read_public( NULL, buf, buflen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_read_public( &ctx, NULL, buflen ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_calc_secret( NULL, &olen, buf, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_calc_secret( &ctx, NULL, buf, buflen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdh_calc_secret( &ctx, &olen, NULL, buflen, + rnd_std_rand, + NULL ) ); + +exit: + return; +} +/* END_CASE */ + /* BEGIN_CASE */ void ecdh_primitive_random( int id ) { @@ -43,15 +221,13 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void ecdh_primitive_testvec( int id, char *dA_str, char *xA_str, char *yA_str, - char *dB_str, char *xB_str, char *yB_str, - char *z_str ) +void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str, + char * yA_str, data_t * rnd_buf_B, + char * xB_str, char * yB_str, char * z_str ) { mbedtls_ecp_group grp; mbedtls_ecp_point qA, qB; mbedtls_mpi dA, dB, zA, zB, check; - unsigned char rnd_buf_A[MBEDTLS_ECP_MAX_BYTES]; - unsigned char rnd_buf_B[MBEDTLS_ECP_MAX_BYTES]; rnd_buf_info rnd_info_A, rnd_info_B; mbedtls_ecp_group_init( &grp ); @@ -61,36 +237,36 @@ void ecdh_primitive_testvec( int id, char *dA_str, char *xA_str, char *yA_str, TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 ); - rnd_info_A.buf = rnd_buf_A; - rnd_info_A.length = unhexify( rnd_buf_A, dA_str ); + rnd_info_A.buf = rnd_buf_A->x; + rnd_info_A.length = rnd_buf_A->len; - /* Fix rnd_buf_A by shifting it left if necessary */ + /* Fix rnd_buf_A->x by shifting it left if necessary */ if( grp.nbits % 8 != 0 ) { unsigned char shift = 8 - ( grp.nbits % 8 ); size_t i; for( i = 0; i < rnd_info_A.length - 1; i++ ) - rnd_buf_A[i] = rnd_buf_A[i] << shift - | rnd_buf_A[i+1] >> ( 8 - shift ); + rnd_buf_A->x[i] = rnd_buf_A->x[i] << shift + | rnd_buf_A->x[i+1] >> ( 8 - shift ); - rnd_buf_A[rnd_info_A.length-1] <<= shift; + rnd_buf_A->x[rnd_info_A.length-1] <<= shift; } - rnd_info_B.buf = rnd_buf_B; - rnd_info_B.length = unhexify( rnd_buf_B, dB_str ); + rnd_info_B.buf = rnd_buf_B->x; + rnd_info_B.length = rnd_buf_B->len; - /* Fix rnd_buf_B by shifting it left if necessary */ + /* Fix rnd_buf_B->x by shifting it left if necessary */ if( grp.nbits % 8 != 0 ) { unsigned char shift = 8 - ( grp.nbits % 8 ); size_t i; for( i = 0; i < rnd_info_B.length - 1; i++ ) - rnd_buf_B[i] = rnd_buf_B[i] << shift - | rnd_buf_B[i+1] >> ( 8 - shift ); + rnd_buf_B->x[i] = rnd_buf_B->x[i] << shift + | rnd_buf_B->x[i+1] >> ( 8 - shift ); - rnd_buf_B[rnd_info_B.length-1] <<= shift; + rnd_buf_B->x[rnd_info_B.length-1] <<= shift; } TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA, @@ -130,6 +306,171 @@ void ecdh_exchange( int id ) unsigned char buf[1000]; const unsigned char *vbuf; size_t len; + rnd_pseudo_info rnd_info; + unsigned char res_buf[1000]; + size_t res_len; + + mbedtls_ecdh_init( &srv ); + mbedtls_ecdh_init( &cli ); + memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) ); + + TEST_ASSERT( mbedtls_ecdh_setup( &srv, id ) == 0 ); + + memset( buf, 0x00, sizeof( buf ) ); vbuf = buf; + TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000, + &rnd_pseudo_rand, &rnd_info ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 ); + + memset( buf, 0x00, sizeof( buf ) ); + TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000, + &rnd_pseudo_rand, &rnd_info ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 ); + + TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000, + &rnd_pseudo_rand, &rnd_info ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &res_len, res_buf, 1000, + NULL, NULL ) == 0 ); + TEST_ASSERT( len == res_len ); + TEST_ASSERT( memcmp( buf, res_buf, len ) == 0 ); + +exit: + mbedtls_ecdh_free( &srv ); + mbedtls_ecdh_free( &cli ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */ +void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str, + int enable, int max_ops, int min_restart, int max_restart ) +{ + int ret; + mbedtls_ecdh_context srv, cli; + unsigned char buf[1000]; + const unsigned char *vbuf; + size_t len; + unsigned char z[MBEDTLS_ECP_MAX_BYTES]; + size_t z_len; + unsigned char rnd_buf_A[MBEDTLS_ECP_MAX_BYTES]; + unsigned char rnd_buf_B[MBEDTLS_ECP_MAX_BYTES]; + rnd_buf_info rnd_info_A, rnd_info_B; + int cnt_restart; + mbedtls_ecp_group grp; + + mbedtls_ecp_group_init( &grp ); + mbedtls_ecdh_init( &srv ); + mbedtls_ecdh_init( &cli ); + + z_len = unhexify( z, z_str ); + + rnd_info_A.buf = rnd_buf_A; + rnd_info_A.length = unhexify( rnd_buf_A, dA_str ); + + rnd_info_B.buf = rnd_buf_B; + rnd_info_B.length = unhexify( rnd_buf_B, dB_str ); + + /* The ECDH context is not guaranteed ot have an mbedtls_ecp_group structure + * in every configuration, therefore we load it separately. */ + TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 ); + + /* Otherwise we would have to fix the random buffer, + * as in ecdh_primitive_testvec. */ + TEST_ASSERT( grp.nbits % 8 == 0 ); + + TEST_ASSERT( mbedtls_ecdh_setup( &srv, id ) == 0 ); + + /* set up restart parameters */ + mbedtls_ecp_set_max_ops( max_ops ); + + if( enable ) + { + mbedtls_ecdh_enable_restart( &srv ); + mbedtls_ecdh_enable_restart( &cli ); + } + + /* server writes its paramaters */ + memset( buf, 0x00, sizeof( buf ) ); + len = 0; + + cnt_restart = 0; + do { + ret = mbedtls_ecdh_make_params( &srv, &len, buf, sizeof( buf ), + rnd_buffer_rand, &rnd_info_A ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + /* client read server params */ + vbuf = buf; + TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 ); + + /* client writes its key share */ + memset( buf, 0x00, sizeof( buf ) ); + len = 0; + + cnt_restart = 0; + do { + ret = mbedtls_ecdh_make_public( &cli, &len, buf, sizeof( buf ), + rnd_buffer_rand, &rnd_info_B ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + /* server reads client key share */ + TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 ); + + /* server computes shared secret */ + memset( buf, 0, sizeof( buf ) ); + len = 0; + + cnt_restart = 0; + do { + ret = mbedtls_ecdh_calc_secret( &srv, &len, buf, sizeof( buf ), + NULL, NULL ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + TEST_ASSERT( len == z_len ); + TEST_ASSERT( memcmp( buf, z, len ) == 0 ); + + /* client computes shared secret */ + memset( buf, 0, sizeof( buf ) ); + len = 0; + + cnt_restart = 0; + do { + ret = mbedtls_ecdh_calc_secret( &cli, &len, buf, sizeof( buf ), + NULL, NULL ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + TEST_ASSERT( len == z_len ); + TEST_ASSERT( memcmp( buf, z, len ) == 0 ); + +exit: + mbedtls_ecp_group_free( &grp ); + mbedtls_ecdh_free( &srv ); + mbedtls_ecdh_free( &cli ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ECDH_LEGACY_CONTEXT */ +void ecdh_exchange_legacy( int id ) +{ + mbedtls_ecdh_context srv, cli; + unsigned char buf[1000]; + const unsigned char *vbuf; + size_t len; + rnd_pseudo_info rnd_info; mbedtls_ecdh_init( &srv ); @@ -145,12 +486,13 @@ void ecdh_exchange( int id ) memset( buf, 0x00, sizeof( buf ) ); TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000, - &rnd_pseudo_rand, &rnd_info ) == 0 ); + &rnd_pseudo_rand, &rnd_info ) == 0 ); TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 ); TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000, - &rnd_pseudo_rand, &rnd_info ) == 0 ); - TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &len, buf, 1000, NULL, NULL ) == 0 ); + &rnd_pseudo_rand, &rnd_info ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &len, buf, 1000, NULL, + NULL ) == 0 ); TEST_ASSERT( mbedtls_mpi_cmp_mpi( &srv.z, &cli.z ) == 0 ); exit: @@ -158,3 +500,107 @@ exit: mbedtls_ecdh_free( &cli ); } /* END_CASE */ + +/* BEGIN_CASE */ +void ecdh_exchange_calc_secret( int grp_id, + data_t *our_private_key, + data_t *their_point, + int ours_first, + data_t *expected ) +{ + rnd_pseudo_info rnd_info; + mbedtls_ecp_keypair our_key; + mbedtls_ecp_keypair their_key; + mbedtls_ecdh_context ecdh; + unsigned char shared_secret[MBEDTLS_ECP_MAX_BYTES]; + size_t shared_secret_length = 0; + + memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) ); + mbedtls_ecdh_init( &ecdh ); + mbedtls_ecp_keypair_init( &our_key ); + mbedtls_ecp_keypair_init( &their_key ); + + if( ! load_private_key( grp_id, our_private_key, &our_key, &rnd_info ) ) + goto exit; + if( ! load_public_key( grp_id, their_point, &their_key ) ) + goto exit; + + /* Import the keys to the ECDH calculation. */ + if( ours_first ) + { + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &our_key, MBEDTLS_ECDH_OURS ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &their_key, MBEDTLS_ECDH_THEIRS ) == 0 ); + } + else + { + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &their_key, MBEDTLS_ECDH_THEIRS ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &our_key, MBEDTLS_ECDH_OURS ) == 0 ); + } + + /* Perform the ECDH calculation. */ + TEST_ASSERT( mbedtls_ecdh_calc_secret( + &ecdh, + &shared_secret_length, + shared_secret, sizeof( shared_secret ), + &rnd_pseudo_rand, &rnd_info ) == 0 ); + TEST_ASSERT( shared_secret_length == expected->len ); + TEST_ASSERT( memcmp( expected->x, shared_secret, + shared_secret_length ) == 0 ); + +exit: + mbedtls_ecdh_free( &ecdh ); + mbedtls_ecp_keypair_free( &our_key ); + mbedtls_ecp_keypair_free( &their_key ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void ecdh_exchange_get_params_fail( int our_grp_id, + data_t *our_private_key, + int their_grp_id, + data_t *their_point, + int ours_first, + int expected_ret ) +{ + rnd_pseudo_info rnd_info; + mbedtls_ecp_keypair our_key; + mbedtls_ecp_keypair their_key; + mbedtls_ecdh_context ecdh; + + memset( &rnd_info, 0x00, sizeof( rnd_pseudo_info ) ); + mbedtls_ecdh_init( &ecdh ); + mbedtls_ecp_keypair_init( &our_key ); + mbedtls_ecp_keypair_init( &their_key ); + + if( ! load_private_key( our_grp_id, our_private_key, &our_key, &rnd_info ) ) + goto exit; + if( ! load_public_key( their_grp_id, their_point, &their_key ) ) + goto exit; + + if( ours_first ) + { + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &our_key, MBEDTLS_ECDH_OURS ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &their_key, MBEDTLS_ECDH_THEIRS ) == + expected_ret ); + } + else + { + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &their_key, MBEDTLS_ECDH_THEIRS ) == 0 ); + TEST_ASSERT( mbedtls_ecdh_get_params( + &ecdh, &our_key, MBEDTLS_ECDH_OURS ) == + expected_ret ); + } + +exit: + mbedtls_ecdh_free( &ecdh ); + mbedtls_ecp_keypair_free( &our_key ); + mbedtls_ecp_keypair_free( &their_key ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.data index 19c51d35b5..59e209b362 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.data @@ -1,3 +1,6 @@ +ECDSA Parameter validation +ecdsa_invalid_param: + ECDSA primitive random #1 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED ecdsa_prim_random:MBEDTLS_ECP_DP_SECP192R1 @@ -50,7 +53,7 @@ ECDSA write-read random #5 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED ecdsa_write_read_random:MBEDTLS_ECP_DP_SECP521R1 -ECDSA deterministic test vector rfc 6979 p192 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p192 sha1 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA1:"sample":"98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF":"57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64" @@ -58,7 +61,7 @@ ECDSA deterministic test vector rfc 6979 p192 sha224 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA224:"sample":"A1F00DAD97AEEC91C95585F36200C65F3C01812AA60378F5":"E07EC1304C7C6C9DEBBE980B9692668F81D4DE7922A0F97A" -ECDSA deterministic test vector rfc 6979 p192 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p192 sha256 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA256:"sample":"4B0B8CE98A92866A2820E20AA6B75B56382E0F9BFD5ECB55":"CCDB006926EA9565CBADC840829D8C384E06DE1F1E381B85" @@ -66,11 +69,11 @@ ECDSA deterministic test vector rfc 6979 p192 sha384 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA384:"sample":"DA63BF0B9ABCF948FBB1E9167F136145F7A20426DCC287D5":"C3AA2C960972BD7A2003A57E1C4C77F0578F8AE95E31EC5E" -ECDSA deterministic test vector rfc 6979 p192 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p192 sha512 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA512:"sample":"4D60C5AB1996BD848343B31C00850205E2EA6922DAC2E4B8":"3F6E837448F027A1BF4B34E796E32A811CBB4050908D8F67" -ECDSA deterministic test vector rfc 6979 p192 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p192 sha1 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA1:"test":"0F2141A0EBBC44D2E1AF90A50EBCFCE5E197B3B7D4DE036D":"EB18BC9E1F3D7387500CB99CF5F7C157070A8961E38700B7" @@ -78,7 +81,7 @@ ECDSA deterministic test vector rfc 6979 p192 sha224 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA224:"test":"6945A1C1D1B2206B8145548F633BB61CEF04891BAF26ED34":"B7FB7FDFC339C0B9BD61A9F5A8EAF9BE58FC5CBA2CB15293" -ECDSA deterministic test vector rfc 6979 p192 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p192 sha256 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA256:"test":"3A718BD8B4926C3B52EE6BBE67EF79B18CB6EB62B1AD97AE":"5662E6848A4A19B1F1AE2F72ACD4B8BBE50F1EAC65D9124F" @@ -86,11 +89,11 @@ ECDSA deterministic test vector rfc 6979 p192 sha384 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA384:"test":"B234B60B4DB75A733E19280A7A6034BD6B1EE88AF5332367":"7994090B2D59BB782BE57E74A44C9A1C700413F8ABEFE77A" -ECDSA deterministic test vector rfc 6979 p192 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p192 sha512 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"6FAB034934E4C0FC9AE67F5B5659A9D7D1FEFD187EE09FD4":MBEDTLS_MD_SHA512:"test":"FE4F4AE86A58B6507946715934FE2D8FF9D95B6B098FE739":"74CF5605C98FBA0E1EF34D4B5A1577A7DCF59457CAE52290" -ECDSA deterministic test vector rfc 6979 p224 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p224 sha1 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA1:"sample":"22226F9D40A96E19C4A301CE5B74B115303C0F3A4FD30FC257FB57AC":"66D1CDD83E3AF75605DD6E2FEFF196D30AA7ED7A2EDF7AF475403D69" @@ -98,7 +101,7 @@ ECDSA deterministic test vector rfc 6979 p224 sha224 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA224:"sample":"1CDFE6662DDE1E4A1EC4CDEDF6A1F5A2FB7FBD9145C12113E6ABFD3E":"A6694FD7718A21053F225D3F46197CA699D45006C06F871808F43EBC" -ECDSA deterministic test vector rfc 6979 p224 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p224 sha256 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA256:"sample":"61AA3DA010E8E8406C656BC477A7A7189895E7E840CDFE8FF42307BA":"BC814050DAB5D23770879494F9E0A680DC1AF7161991BDE692B10101" @@ -106,11 +109,11 @@ ECDSA deterministic test vector rfc 6979 p224 sha384 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA384:"sample":"0B115E5E36F0F9EC81F1325A5952878D745E19D7BB3EABFABA77E953":"830F34CCDFE826CCFDC81EB4129772E20E122348A2BBD889A1B1AF1D" -ECDSA deterministic test vector rfc 6979 p224 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p224 sha512 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA512:"sample":"074BD1D979D5F32BF958DDC61E4FB4872ADCAFEB2256497CDAC30397":"A4CECA196C3D5A1FF31027B33185DC8EE43F288B21AB342E5D8EB084" -ECDSA deterministic test vector rfc 6979 p224 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p224 sha1 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA1:"test":"DEAA646EC2AF2EA8AD53ED66B2E2DDAA49A12EFD8356561451F3E21C":"95987796F6CF2062AB8135271DE56AE55366C045F6D9593F53787BD2" @@ -118,7 +121,7 @@ ECDSA deterministic test vector rfc 6979 p224 sha224 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA224:"test":"C441CE8E261DED634E4CF84910E4C5D1D22C5CF3B732BB204DBEF019":"902F42847A63BDC5F6046ADA114953120F99442D76510150F372A3F4" -ECDSA deterministic test vector rfc 6979 p224 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p224 sha256 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA256:"test":"AD04DDE87B84747A243A631EA47A1BA6D1FAA059149AD2440DE6FBA6":"178D49B1AE90E3D8B629BE3DB5683915F4E8C99FDF6E666CF37ADCFD" @@ -126,11 +129,11 @@ ECDSA deterministic test vector rfc 6979 p224 sha384 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA384:"test":"389B92682E399B26518A95506B52C03BC9379A9DADF3391A21FB0EA4":"414A718ED3249FF6DBC5B50C27F71F01F070944DA22AB1F78F559AAB" -ECDSA deterministic test vector rfc 6979 p224 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p224 sha512 depends_on:MBEDTLS_ECP_DP_SECP224R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP224R1:"F220266E1105BFE3083E03EC7A3A654651F45E37167E88600BF257C1":MBEDTLS_MD_SHA512:"test":"049F050477C5ADD858CAC56208394B5A55BAEBBE887FDF765047C17C":"077EB13E7005929CEFA3CD0403C7CDCC077ADF4E44F3C41B2F60ECFF" -ECDSA deterministic test vector rfc 6979 p256 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p256 sha1 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA1:"sample":"61340C88C3AAEBEB4F6D667F672CA9759A6CCAA9FA8811313039EE4A35471D32":"6D7F147DAC089441BB2E2FE8F7A3FA264B9C475098FDCF6E00D7C996E1B8B7EB" @@ -138,7 +141,7 @@ ECDSA deterministic test vector rfc 6979 p256 sha224 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA224:"sample":"53B2FFF5D1752B2C689DF257C04C40A587FABABB3F6FC2702F1343AF7CA9AA3F":"B9AFB64FDC03DC1A131C7D2386D11E349F070AA432A4ACC918BEA988BF75C74C" -ECDSA deterministic test vector rfc 6979 p256 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p256 sha256 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA256:"sample":"EFD48B2AACB6A8FD1140DD9CD45E81D69D2C877B56AAF991C34D0EA84EAF3716":"F7CB1C942D657C41D436C7A1B6E29F65F3E900DBB9AFF4064DC4AB2F843ACDA8" @@ -146,11 +149,11 @@ ECDSA deterministic test vector rfc 6979 p256 sha384 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA384:"sample":"0EAFEA039B20E9B42309FB1D89E213057CBF973DC0CFC8F129EDDDC800EF7719":"4861F0491E6998B9455193E34E7B0D284DDD7149A74B95B9261F13ABDE940954" -ECDSA deterministic test vector rfc 6979 p256 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p256 sha512 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA512:"sample":"8496A60B5E9B47C825488827E0495B0E3FA109EC4568FD3F8D1097678EB97F00":"2362AB1ADBE2B8ADF9CB9EDAB740EA6049C028114F2460F96554F61FAE3302FE" -ECDSA deterministic test vector rfc 6979 p256 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p256 sha1 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA1:"test":"0CBCC86FD6ABD1D99E703E1EC50069EE5C0B4BA4B9AC60E409E8EC5910D81A89":"01B9D7B73DFAA60D5651EC4591A0136F87653E0FD780C3B1BC872FFDEAE479B1" @@ -158,7 +161,7 @@ ECDSA deterministic test vector rfc 6979 p256 sha224 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA224:"test":"C37EDB6F0AE79D47C3C27E962FA269BB4F441770357E114EE511F662EC34A692":"C820053A05791E521FCAAD6042D40AEA1D6B1A540138558F47D0719800E18F2D" -ECDSA deterministic test vector rfc 6979 p256 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p256 sha256 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA256:"test":"F1ABB023518351CD71D881567B1EA663ED3EFCF6C5132B354F28D3B0B7D38367":"019F4113742A2B14BD25926B49C649155F267E60D3814B4C0CC84250E46F0083" @@ -166,11 +169,11 @@ ECDSA deterministic test vector rfc 6979 p256 sha384 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA384:"test":"83910E8B48BB0C74244EBDF7F07A1C5413D61472BD941EF3920E623FBCCEBEB6":"8DDBEC54CF8CD5874883841D712142A56A8D0F218F5003CB0296B6B509619F2C" -ECDSA deterministic test vector rfc 6979 p256 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p256 sha512 depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA512:"test":"461D93F31B6540894788FD206C07CFA0CC35F46FA3C91816FFF1040AD1581A04":"39AF9F15DE0DB8D97E72719C74820D304CE5226E32DEDAE67519E840D1194E55" -ECDSA deterministic test vector rfc 6979 p384 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p384 sha1 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA1:"sample":"EC748D839243D6FBEF4FC5C4859A7DFFD7F3ABDDF72014540C16D73309834FA37B9BA002899F6FDA3A4A9386790D4EB2":"A3BCFA947BEEF4732BF247AC17F71676CB31A847B9FF0CBC9C9ED4C1A5B3FACF26F49CA031D4857570CCB5CA4424A443" @@ -178,7 +181,7 @@ ECDSA deterministic test vector rfc 6979 p384 sha224 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA224:"sample":"42356E76B55A6D9B4631C865445DBE54E056D3B3431766D0509244793C3F9366450F76EE3DE43F5A125333A6BE060122":"9DA0C81787064021E78DF658F2FBB0B042BF304665DB721F077A4298B095E4834C082C03D83028EFBF93A3C23940CA8D" -ECDSA deterministic test vector rfc 6979 p384 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p384 sha256 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA256:"sample":"21B13D1E013C7FA1392D03C5F99AF8B30C570C6F98D4EA8E354B63A21D3DAA33BDE1E888E63355D92FA2B3C36D8FB2CD":"F3AA443FB107745BF4BD77CB3891674632068A10CA67E3D45DB2266FA7D1FEEBEFDC63ECCD1AC42EC0CB8668A4FA0AB0" @@ -186,11 +189,11 @@ ECDSA deterministic test vector rfc 6979 p384 sha384 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA384:"sample":"94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C81A648152E44ACF96E36DD1E80FABE46":"99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94FA329C145786E679E7B82C71A38628AC8" -ECDSA deterministic test vector rfc 6979 p384 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p384 sha512 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA512:"sample":"ED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799CFE30F35CC900056D7C99CD7882433709":"512C8CCEEE3890A84058CE1E22DBC2198F42323CE8ACA9135329F03C068E5112DC7CC3EF3446DEFCEB01A45C2667FDD5" -ECDSA deterministic test vector rfc 6979 p384 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p384 sha1 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA1:"test":"4BC35D3A50EF4E30576F58CD96CE6BF638025EE624004A1F7789A8B8E43D0678ACD9D29876DAF46638645F7F404B11C7":"D5A6326C494ED3FF614703878961C0FDE7B2C278F9A65FD8C4B7186201A2991695BA1C84541327E966FA7B50F7382282" @@ -198,7 +201,7 @@ ECDSA deterministic test vector rfc 6979 p384 sha224 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA224:"test":"E8C9D0B6EA72A0E7837FEA1D14A1A9557F29FAA45D3E7EE888FC5BF954B5E62464A9A817C47FF78B8C11066B24080E72":"07041D4A7A0379AC7232FF72E6F77B6DDB8F09B16CCE0EC3286B2BD43FA8C6141C53EA5ABEF0D8231077A04540A96B66" -ECDSA deterministic test vector rfc 6979 p384 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p384 sha256 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA256:"test":"6D6DEFAC9AB64DABAFE36C6BF510352A4CC27001263638E5B16D9BB51D451559F918EEDAF2293BE5B475CC8F0188636B":"2D46F3BECBCC523D5F1A1256BF0C9B024D879BA9E838144C8BA6BAEB4B53B47D51AB373F9845C0514EEFB14024787265" @@ -206,11 +209,11 @@ ECDSA deterministic test vector rfc 6979 p384 sha384 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA384:"test":"8203B63D3C853E8D77227FB377BCF7B7B772E97892A80F36AB775D509D7A5FEB0542A7F0812998DA8F1DD3CA3CF023DB":"DDD0760448D42D8A43AF45AF836FCE4DE8BE06B485E9B61B827C2F13173923E06A739F040649A667BF3B828246BAA5A5" -ECDSA deterministic test vector rfc 6979 p384 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p384 sha512 depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP384R1:"6B9D3DAD2E1B8C1C05B19875B6659F4DE23C3B667BF297BA9AA47740787137D896D5724E4C70A825F872C9EA60D2EDF5":MBEDTLS_MD_SHA512:"test":"A0D5D090C9980FAF3C2CE57B7AE951D31977DD11C775D314AF55F76C676447D06FB6495CD21B4B6E340FC236584FB277":"976984E59B4C77B0E8E4460DCA3D9F20E07B9BB1F63BEEFAF576F6B2E8B224634A2092CD3792E0159AD9CEE37659C736" -ECDSA deterministic test vector rfc 6979 p521 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p521 sha1 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA1:"sample":"0343B6EC45728975EA5CBA6659BBB6062A5FF89EEA58BE3C80B619F322C87910FE092F7D45BB0F8EEE01ED3F20BABEC079D202AE677B243AB40B5431D497C55D75D":"0E7B0E675A9B24413D448B8CC119D2BF7B2D2DF032741C096634D6D65D0DBE3D5694625FB9E8104D3B842C1B0E2D0B98BEA19341E8676AEF66AE4EBA3D5475D5D16" @@ -218,7 +221,7 @@ ECDSA deterministic test vector rfc 6979 p521 sha224 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA224:"sample":"1776331CFCDF927D666E032E00CF776187BC9FDD8E69D0DABB4109FFE1B5E2A30715F4CC923A4A5E94D2503E9ACFED92857B7F31D7152E0F8C00C15FF3D87E2ED2E":"050CB5265417FE2320BBB5A122B8E1A32BD699089851128E360E620A30C7E17BA41A666AF126CE100E5799B153B60528D5300D08489CA9178FB610A2006C254B41F" -ECDSA deterministic test vector rfc 6979 p521 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p521 sha256 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA256:"sample":"1511BB4D675114FE266FC4372B87682BAECC01D3CC62CF2303C92B3526012659D16876E25C7C1E57648F23B73564D67F61C6F14D527D54972810421E7D87589E1A7":"04A171143A83163D6DF460AAF61522695F207A58B95C0644D87E52AA1A347916E4F7A72930B1BC06DBE22CE3F58264AFD23704CBB63B29B931F7DE6C9D949A7ECFC" @@ -226,11 +229,11 @@ ECDSA deterministic test vector rfc 6979 p521 sha384 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA384:"sample":"1EA842A0E17D2DE4F92C15315C63DDF72685C18195C2BB95E572B9C5136CA4B4B576AD712A52BE9730627D16054BA40CC0B8D3FF035B12AE75168397F5D50C67451":"1F21A3CEE066E1961025FB048BD5FE2B7924D0CD797BABE0A83B66F1E35EEAF5FDE143FA85DC394A7DEE766523393784484BDF3E00114A1C857CDE1AA203DB65D61" -ECDSA deterministic test vector rfc 6979 p521 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p521 sha512 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA512:"sample":"0C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F174E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E377FA":"0617CCE7CF5064806C467F678D3B4080D6F1CC50AF26CA209417308281B68AF282623EAA63E5B5C0723D8B8C37FF0777B1A20F8CCB1DCCC43997F1EE0E44DA4A67A" -ECDSA deterministic test vector rfc 6979 p521 mbedtls_sha1 +ECDSA deterministic test vector rfc 6979 p521 sha1 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA1_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA1:"test":"13BAD9F29ABE20DE37EBEB823C252CA0F63361284015A3BF430A46AAA80B87B0693F0694BD88AFE4E661FC33B094CD3B7963BED5A727ED8BD6A3A202ABE009D0367":"1E9BB81FF7944CA409AD138DBBEE228E1AFCC0C890FC78EC8604639CB0DBDC90F717A99EAD9D272855D00162EE9527567DD6A92CBD629805C0445282BBC916797FF" @@ -238,7 +241,7 @@ ECDSA deterministic test vector rfc 6979 p521 sha224 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA224:"test":"1C7ED902E123E6815546065A2C4AF977B22AA8EADDB68B2C1110E7EA44D42086BFE4A34B67DDC0E17E96536E358219B23A706C6A6E16BA77B65E1C595D43CAE17FB":"177336676304FCB343CE028B38E7B4FBA76C1C1B277DA18CAD2A8478B2A9A9F5BEC0F3BA04F35DB3E4263569EC6AADE8C92746E4C82F8299AE1B8F1739F8FD519A4" -ECDSA deterministic test vector rfc 6979 p521 mbedtls_sha256 +ECDSA deterministic test vector rfc 6979 p521 sha256 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA256_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA256:"test":"00E871C4A14F993C6C7369501900C4BC1E9C7B0B4BA44E04868B30B41D8071042EB28C4C250411D0CE08CD197E4188EA4876F279F90B3D8D74A3C76E6F1E4656AA8":"0CD52DBAA33B063C3A6CD8058A1FB0A46A4754B034FCC644766CA14DA8CA5CA9FDE00E88C1AD60CCBA759025299079D7A427EC3CC5B619BFBC828E7769BCD694E86" @@ -246,10 +249,42 @@ ECDSA deterministic test vector rfc 6979 p521 sha384 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA384:"test":"14BEE21A18B6D8B3C93FAB08D43E739707953244FDBE924FA926D76669E7AC8C89DF62ED8975C2D8397A65A49DCC09F6B0AC62272741924D479354D74FF6075578C":"133330865C067A0EAF72362A65E2D7BC4E461E8C8995C3B6226A21BD1AA78F0ED94FE536A0DCA35534F0CD1510C41525D163FE9D74D134881E35141ED5E8E95B979" -ECDSA deterministic test vector rfc 6979 p521 mbedtls_sha512 +ECDSA deterministic test vector rfc 6979 p521 sha512 depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED:MBEDTLS_SHA512_C ecdsa_det_test_vectors:MBEDTLS_ECP_DP_SECP521R1:"0FAD06DAA62BA3B25D2FB40133DA757205DE67F5BB0018FEE8C86E1B68C7E75CAA896EB32F1F47C70855836A6D16FCC1466F6D8FBEC67DB89EC0C08B0E996B83538":MBEDTLS_MD_SHA512:"test":"13E99020ABF5CEE7525D16B69B229652AB6BDF2AFFCAEF38773B4B7D08725F10CDB93482FDCC54EDCEE91ECA4166B2A7C6265EF0CE2BD7051B7CEF945BABD47EE6D":"1FBD0013C674AA79CB39849527916CE301C66EA7CE8B80682786AD60F98F7E78A19CA69EFF5C57400E3B3A0AD66CE0978214D13BAF4E9AC60752F7B155E2DE4DCE3" +ECDSA restartable read-verify: max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdsa_read_restart:MBEDTLS_ECP_DP_SECP256R1:"04e8f573412a810c5f81ecd2d251bb94387e72f28af70dced90ebe75725c97a6428231069c2b1ef78509a22c59044319f6ed3cb750dfe64c2a282b35967a458ad6":"dee9d4d8b0e40a034602d6e638197998060f6e9f353ae1d10c94cd56476d3c92":"304502210098a5a1392abe29e4b0a4da3fefe9af0f8c32e5b839ab52ba6a05da9c3b7edd0f0220596f0e195ae1e58c1e53e9e7f0f030b274348a8c11232101778d89c4943f5ad2":0:0:0 + +ECDSA restartable read-verify: max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdsa_read_restart:MBEDTLS_ECP_DP_SECP256R1:"04e8f573412a810c5f81ecd2d251bb94387e72f28af70dced90ebe75725c97a6428231069c2b1ef78509a22c59044319f6ed3cb750dfe64c2a282b35967a458ad6":"dee9d4d8b0e40a034602d6e638197998060f6e9f353ae1d10c94cd56476d3c92":"304502210098a5a1392abe29e4b0a4da3fefe9af0f8c32e5b839ab52ba6a05da9c3b7edd0f0220596f0e195ae1e58c1e53e9e7f0f030b274348a8c11232101778d89c4943f5ad2":1:42:10000 + +ECDSA restartable read-verify: max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdsa_read_restart:MBEDTLS_ECP_DP_SECP256R1:"04e8f573412a810c5f81ecd2d251bb94387e72f28af70dced90ebe75725c97a6428231069c2b1ef78509a22c59044319f6ed3cb750dfe64c2a282b35967a458ad6":"dee9d4d8b0e40a034602d6e638197998060f6e9f353ae1d10c94cd56476d3c92":"304502210098a5a1392abe29e4b0a4da3fefe9af0f8c32e5b839ab52ba6a05da9c3b7edd0f0220596f0e195ae1e58c1e53e9e7f0f030b274348a8c11232101778d89c4943f5ad2":10000:0:0 + +ECDSA restartable read-verify: max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecdsa_read_restart:MBEDTLS_ECP_DP_SECP256R1:"04e8f573412a810c5f81ecd2d251bb94387e72f28af70dced90ebe75725c97a6428231069c2b1ef78509a22c59044319f6ed3cb750dfe64c2a282b35967a458ad6":"dee9d4d8b0e40a034602d6e638197998060f6e9f353ae1d10c94cd56476d3c92":"304502210098a5a1392abe29e4b0a4da3fefe9af0f8c32e5b839ab52ba6a05da9c3b7edd0f0220596f0e195ae1e58c1e53e9e7f0f030b274348a8c11232101778d89c4943f5ad2":250:4:64 + +ECDSA restartable sign-write: secp256r1 max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +ecdsa_write_restart:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":0:0:0 + +ECDSA restartable sign-write: secp256r1 restart max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +ecdsa_write_restart:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":1:1:10000 + +ECDSA restartable sign-write: secp256r1 restart max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +ecdsa_write_restart:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":10000:0:0 + +ECDSA restartable sign-write: secp256r1 restart max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +ecdsa_write_restart:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":250:2:32 + ECDSA zero private parameter p192 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED ecdsa_prim_test_vectors:MBEDTLS_ECP_DP_SECP192R1:"0":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945":"9E56F509196784D963D1C0A401510EE7ADA3DCC5DEE04B15":"BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9C":"98C6BD12B23EAF5E2A2045132086BE3EB8EBD62ABF6698FF":"57A22B07DEA9530F8DE9471B1DC6624472E8E2844BC25B64":MBEDTLS_ERR_ECP_INVALID_KEY diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.function index 9b1315fbe3..22d92b6dfe 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecdsa.function @@ -7,6 +7,201 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void ecdsa_invalid_param( ) +{ + mbedtls_ecdsa_context ctx; + mbedtls_ecp_keypair key; + mbedtls_ecp_group grp; + mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP192R1; + mbedtls_ecp_point P; + mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256; + mbedtls_mpi m; + size_t slen; + unsigned char buf[42] = { 0 }; + + TEST_INVALID_PARAM( mbedtls_ecdsa_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_ecdsa_free( NULL ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + TEST_INVALID_PARAM( mbedtls_ecdsa_restart_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_ecdsa_restart_free( NULL ) ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign( NULL, &m, &m, &m, + buf, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign( &grp, NULL, &m, &m, + buf, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign( &grp, &m, NULL, &m, + buf, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign( &grp, &m, &m, NULL, + buf, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign( &grp, &m, &m, &m, + NULL, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign( &grp, &m, &m, &m, + buf, sizeof( buf ), + NULL, NULL ) ); + +#if defined(MBEDTLS_ECDSA_DETERMINISTIC) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign_det( NULL, &m, &m, &m, + buf, sizeof( buf ), + valid_md ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign_det( &grp, NULL, &m, &m, + buf, sizeof( buf ), + valid_md ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign_det( &grp, &m, NULL, &m, + buf, sizeof( buf ), + valid_md ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign_det( &grp, &m, &m, NULL, + buf, sizeof( buf ), + valid_md ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_sign_det( &grp, &m, &m, &m, + NULL, sizeof( buf ), + valid_md ) ); +#endif /* MBEDTLS_ECDSA_DETERMINISTIC */ + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_verify( NULL, + buf, sizeof( buf ), + &P, &m, &m ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_verify( &grp, + NULL, sizeof( buf ), + &P, &m, &m ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_verify( &grp, + buf, sizeof( buf ), + NULL, &m, &m ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_verify( &grp, + buf, sizeof( buf ), + &P, NULL, &m ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_verify( &grp, + buf, sizeof( buf ), + &P, &m, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature( NULL, + valid_md, + buf, sizeof( buf ), + buf, &slen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature( &ctx, + valid_md, + NULL, sizeof( buf ), + buf, &slen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature( &ctx, + valid_md, + buf, sizeof( buf ), + NULL, &slen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature( &ctx, + valid_md, + buf, sizeof( buf ), + buf, NULL, + rnd_std_rand, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature_restartable( NULL, + valid_md, + buf, sizeof( buf ), + buf, &slen, + rnd_std_rand, + NULL, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature_restartable( &ctx, + valid_md, + NULL, sizeof( buf ), + buf, &slen, + rnd_std_rand, + NULL, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature_restartable( &ctx, + valid_md, + buf, sizeof( buf ), + NULL, &slen, + rnd_std_rand, + NULL, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_write_signature_restartable( &ctx, + valid_md, + buf, sizeof( buf ), + buf, NULL, + rnd_std_rand, + NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_read_signature( NULL, + buf, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_read_signature( &ctx, + NULL, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_read_signature( &ctx, + buf, sizeof( buf ), + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_read_signature_restartable( NULL, + buf, sizeof( buf ), + buf, sizeof( buf ), + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_read_signature_restartable( &ctx, + NULL, sizeof( buf ), + buf, sizeof( buf ), + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_read_signature_restartable( &ctx, + buf, sizeof( buf ), + NULL, sizeof( buf ), + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_genkey( NULL, valid_group, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_genkey( &ctx, valid_group, + NULL, NULL ) ); + + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_from_keypair( NULL, &key ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecdsa_from_keypair( &ctx, NULL ) ); + +exit: + return; +} +/* END_CASE */ + /* BEGIN_CASE */ void ecdsa_prim_random( int id ) { @@ -14,7 +209,7 @@ void ecdsa_prim_random( int id ) mbedtls_ecp_point Q; mbedtls_mpi d, r, s; rnd_pseudo_info rnd_info; - unsigned char buf[66]; + unsigned char buf[MBEDTLS_MD_MAX_SIZE]; mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &Q ); @@ -40,46 +235,42 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void ecdsa_prim_test_vectors( int id, char *d_str, char *xQ_str, char *yQ_str, - char *k_str, char *hash_str, char *r_str, - char *s_str, int result ) +void ecdsa_prim_test_vectors( int id, char * d_str, char * xQ_str, + char * yQ_str, data_t * rnd_buf, + data_t * hash, char * r_str, char * s_str, + int result ) { mbedtls_ecp_group grp; mbedtls_ecp_point Q; mbedtls_mpi d, r, s, r_check, s_check; - unsigned char hash[66], rnd_buf[66]; - size_t hlen; rnd_buf_info rnd_info; mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &Q ); mbedtls_mpi_init( &d ); mbedtls_mpi_init( &r ); mbedtls_mpi_init( &s ); mbedtls_mpi_init( &r_check ); mbedtls_mpi_init( &s_check ); - memset( hash, 0, sizeof( hash ) ); - memset( rnd_buf, 0, sizeof( rnd_buf ) ); TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 ); TEST_ASSERT( mbedtls_ecp_point_read_string( &Q, 16, xQ_str, yQ_str ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &d, 16, d_str ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &r_check, 16, r_str ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &s_check, 16, s_str ) == 0 ); - hlen = unhexify(hash, hash_str); - rnd_info.buf = rnd_buf; - rnd_info.length = unhexify( rnd_buf, k_str ); + rnd_info.buf = rnd_buf->x; + rnd_info.length = rnd_buf->len; - /* Fix rnd_buf by shifting it left if necessary */ + /* Fix rnd_buf->x by shifting it left if necessary */ if( grp.nbits % 8 != 0 ) { unsigned char shift = 8 - ( grp.nbits % 8 ); size_t i; for( i = 0; i < rnd_info.length - 1; i++ ) - rnd_buf[i] = rnd_buf[i] << shift | rnd_buf[i+1] >> ( 8 - shift ); + rnd_buf->x[i] = rnd_buf->x[i] << shift | rnd_buf->x[i+1] >> ( 8 - shift ); - rnd_buf[rnd_info.length-1] <<= shift; + rnd_buf->x[rnd_info.length-1] <<= shift; } - TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, hash, hlen, + TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, hash->x, hash->len, rnd_buffer_rand, &rnd_info ) == result ); if ( result == 0) @@ -87,7 +278,17 @@ void ecdsa_prim_test_vectors( int id, char *d_str, char *xQ_str, char *yQ_str, TEST_ASSERT( mbedtls_mpi_cmp_mpi( &r, &r_check ) == 0 ); TEST_ASSERT( mbedtls_mpi_cmp_mpi( &s, &s_check ) == 0 ); - TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash, hlen, &Q, &r_check, &s_check ) == 0 ); + TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash->x, hash->len, &Q, &r_check, &s_check ) == 0 ); + + TEST_ASSERT( mbedtls_mpi_sub_int( &r, &r, 1 ) == 0 ); + TEST_ASSERT( mbedtls_mpi_add_int( &s, &s, 1 ) == 0 ); + + TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash->x, hash->len, + &Q, &r, &s_check ) == MBEDTLS_ERR_ECP_VERIFY_FAILED ); + TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash->x, hash->len, + &Q, &r_check, &s ) == MBEDTLS_ERR_ECP_VERIFY_FAILED ); + TEST_ASSERT( mbedtls_ecdsa_verify( &grp, hash->x, hash->len, + &grp.G, &r_check, &s_check ) == MBEDTLS_ERR_ECP_VERIFY_FAILED ); } exit: @@ -99,8 +300,8 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ECDSA_DETERMINISTIC */ -void ecdsa_det_test_vectors( int id, char *d_str, int md_alg, - char *msg, char *r_str, char *s_str ) +void ecdsa_det_test_vectors( int id, char * d_str, int md_alg, char * msg, + char * r_str, char * s_str ) { mbedtls_ecp_group grp; mbedtls_mpi d, r, s, r_check, s_check; @@ -182,17 +383,144 @@ void ecdsa_write_read_random( int id ) /* try modifying r */ sig[10]++; TEST_ASSERT( mbedtls_ecdsa_read_signature( &ctx, hash, sizeof( hash ), - sig, sig_len ) != 0 ); + sig, sig_len ) == MBEDTLS_ERR_ECP_VERIFY_FAILED ); sig[10]--; /* try modifying s */ sig[sig_len - 1]++; TEST_ASSERT( mbedtls_ecdsa_read_signature( &ctx, hash, sizeof( hash ), - sig, sig_len ) != 0 ); + sig, sig_len ) == MBEDTLS_ERR_ECP_VERIFY_FAILED ); + sig[sig_len - 1]--; + +exit: + mbedtls_ecdsa_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */ +void ecdsa_read_restart( int id, char *k_str, char *h_str, char *s_str, + int max_ops, int min_restart, int max_restart ) +{ + mbedtls_ecdsa_context ctx; + mbedtls_ecdsa_restart_ctx rs_ctx; + unsigned char hash[64]; + unsigned char sig[200]; + unsigned char pk[65]; + size_t sig_len, hash_len, pk_len; + int ret, cnt_restart; + + mbedtls_ecdsa_init( &ctx ); + mbedtls_ecdsa_restart_init( &rs_ctx ); + + hash_len = unhexify(hash, h_str); + sig_len = unhexify(sig, s_str); + pk_len = unhexify(pk, k_str); + + TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 ); + TEST_ASSERT( mbedtls_ecp_point_read_binary( &ctx.grp, &ctx.Q, pk, pk_len ) == 0 ); + + mbedtls_ecp_set_max_ops( max_ops ); + + cnt_restart = 0; + do { + ret = mbedtls_ecdsa_read_signature_restartable( &ctx, + hash, hash_len, sig, sig_len, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + /* try modifying r */ + sig[10]++; + do { + ret = mbedtls_ecdsa_read_signature_restartable( &ctx, + hash, hash_len, sig, sig_len, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_VERIFY_FAILED ); + sig[10]--; + + /* try modifying s */ + sig[sig_len - 1]++; + do { + ret = mbedtls_ecdsa_read_signature_restartable( &ctx, + hash, hash_len, sig, sig_len, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_VERIFY_FAILED ); sig[sig_len - 1]--; + /* Do we leak memory when aborting an operation? + * This test only makes sense when we actually restart */ + if( min_restart > 0 ) + { + ret = mbedtls_ecdsa_read_signature_restartable( &ctx, + hash, hash_len, sig, sig_len, &rs_ctx ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + } + exit: mbedtls_ecdsa_free( &ctx ); + mbedtls_ecdsa_restart_free( &rs_ctx ); } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE:MBEDTLS_ECDSA_DETERMINISTIC */ +void ecdsa_write_restart( int id, char *d_str, int md_alg, + char *msg, char *sig_str, + int max_ops, int min_restart, int max_restart ) +{ + int ret, cnt_restart; + mbedtls_ecdsa_restart_ctx rs_ctx; + mbedtls_ecdsa_context ctx; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + unsigned char sig[MBEDTLS_ECDSA_MAX_LEN]; + unsigned char sig_check[MBEDTLS_ECDSA_MAX_LEN]; + size_t hlen, slen, slen_check; + const mbedtls_md_info_t *md_info; + + mbedtls_ecdsa_restart_init( &rs_ctx ); + mbedtls_ecdsa_init( &ctx ); + memset( hash, 0, sizeof( hash ) ); + memset( sig, 0, sizeof( sig ) ); + memset( sig_check, 0, sizeof( sig_check ) ); + + TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &ctx.d, 16, d_str ) == 0 ); + slen_check = unhexify( sig_check, sig_str ); + + md_info = mbedtls_md_info_from_type( md_alg ); + TEST_ASSERT( md_info != NULL ); + + hlen = mbedtls_md_get_size( md_info ); + mbedtls_md( md_info, (const unsigned char *) msg, strlen( msg ), hash ); + + mbedtls_ecp_set_max_ops( max_ops ); + + slen = sizeof( sig ); + cnt_restart = 0; + do { + ret = mbedtls_ecdsa_write_signature_restartable( &ctx, + md_alg, hash, hlen, sig, &slen, NULL, NULL, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( slen == slen_check ); + TEST_ASSERT( memcmp( sig, sig_check, slen ) == 0 ); + + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + /* Do we leak memory when aborting an operation? + * This test only makes sense when we actually restart */ + if( min_restart > 0 ) + { + ret = mbedtls_ecdsa_write_signature_restartable( &ctx, + md_alg, hash, hlen, sig, &slen, NULL, NULL, &rs_ctx ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + } + +exit: + mbedtls_ecdsa_restart_free( &rs_ctx ); + mbedtls_ecdsa_free( &ctx ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.data index 1a772a9658..84c99c9854 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.data @@ -1,3 +1,6 @@ +ECJPAKE parameter validation +ecjpake_invalid_param: + ECJPAKE selftest ecjpake_selftest: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.function index 5c8856b16d..d26729522e 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecjpake.function @@ -98,56 +98,172 @@ cleanup: * END_DEPENDENCIES */ +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void ecjpake_invalid_param( ) +{ + mbedtls_ecjpake_context ctx; + unsigned char buf[42] = { 0 }; + size_t olen; + size_t const len = sizeof( buf ); + mbedtls_ecjpake_role valid_role = MBEDTLS_ECJPAKE_SERVER; + mbedtls_ecjpake_role invalid_role = (mbedtls_ecjpake_role) 42; + mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256; + mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP256R1; + + TEST_INVALID_PARAM( mbedtls_ecjpake_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_ecjpake_free( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_setup( NULL, + valid_role, + valid_md, + valid_group, + buf, len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_setup( &ctx, + invalid_role, + valid_md, + valid_group, + buf, len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_setup( &ctx, + valid_role, + valid_md, + valid_group, + NULL, len ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_check( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_one( NULL, + buf, len, + &olen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_one( &ctx, + NULL, len, + &olen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_one( &ctx, + buf, len, + NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_one( &ctx, + buf, len, + &olen, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_two( NULL, + buf, len, + &olen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_two( &ctx, + NULL, len, + &olen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_two( &ctx, + buf, len, + NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_write_round_two( &ctx, + buf, len, + &olen, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_read_round_one( NULL, + buf, len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_read_round_one( &ctx, + NULL, len ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_read_round_two( NULL, + buf, len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_read_round_two( &ctx, + NULL, len ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_derive_secret( NULL, + buf, len, + &olen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_derive_secret( &ctx, + NULL, len, + &olen, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_derive_secret( &ctx, + buf, len, + NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecjpake_derive_secret( &ctx, + buf, len, + &olen, + NULL, + NULL ) ); + +exit: + return; +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void ecjpake_selftest() +void ecjpake_selftest( ) { TEST_ASSERT( mbedtls_ecjpake_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C */ -void read_round_one( int role, char *data, int ref_ret ) +void read_round_one( int role, data_t * msg, int ref_ret ) { mbedtls_ecjpake_context ctx; - const unsigned char * pw = NULL; const size_t pw_len = 0; - unsigned char *msg; - size_t len; - mbedtls_ecjpake_init( &ctx ); - msg = unhexify_alloc( data, &len ); - TEST_ASSERT( msg != NULL ); - TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, role, MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 ); - TEST_ASSERT( mbedtls_ecjpake_read_round_one( &ctx, msg, len ) == ref_ret ); + TEST_ASSERT( mbedtls_ecjpake_read_round_one( &ctx, msg->x, msg->len ) == ref_ret ); exit: mbedtls_ecjpake_free( &ctx ); - mbedtls_free( msg ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C */ -void read_round_two_cli( char *data, int ref_ret ) +void read_round_two_cli( data_t * msg, int ref_ret ) { mbedtls_ecjpake_context ctx; - const unsigned char * pw = NULL; const size_t pw_len = 0; - unsigned char *msg; - size_t len; - mbedtls_ecjpake_init( &ctx ); - msg = unhexify_alloc( data, &len ); - TEST_ASSERT( msg != NULL ); - TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, MBEDTLS_ECJPAKE_CLIENT, MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 ); @@ -157,30 +273,22 @@ void read_round_two_cli( char *data, int ref_ret ) ADD_SIZE( ecjpake_test_X3 ), ADD_SIZE( ecjpake_test_X4 ) ) == 0 ); - TEST_ASSERT( mbedtls_ecjpake_read_round_two( &ctx, msg, len ) == ref_ret ); + TEST_ASSERT( mbedtls_ecjpake_read_round_two( &ctx, msg->x, msg->len ) == ref_ret ); exit: mbedtls_ecjpake_free( &ctx ); - mbedtls_free( msg ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C */ -void read_round_two_srv( char *data, int ref_ret ) +void read_round_two_srv( data_t * msg, int ref_ret ) { mbedtls_ecjpake_context ctx; - const unsigned char * pw = NULL; const size_t pw_len = 0; - unsigned char *msg; - size_t len; - mbedtls_ecjpake_init( &ctx ); - msg = unhexify_alloc( data, &len ); - TEST_ASSERT( msg != NULL ); - TEST_ASSERT( mbedtls_ecjpake_setup( &ctx, MBEDTLS_ECJPAKE_SERVER, MBEDTLS_MD_SHA256, MBEDTLS_ECP_DP_SECP256R1, pw, pw_len ) == 0 ); @@ -190,10 +298,9 @@ void read_round_two_srv( char *data, int ref_ret ) ADD_SIZE( ecjpake_test_X1 ), ADD_SIZE( ecjpake_test_X2 ) ) == 0 ); - TEST_ASSERT( mbedtls_ecjpake_read_round_two( &ctx, msg, len ) == ref_ret ); + TEST_ASSERT( mbedtls_ecjpake_read_round_two( &ctx, msg->x, msg->len ) == ref_ret ); exit: mbedtls_ecjpake_free( &ctx ); - mbedtls_free( msg ); } /* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.data index a43e7d75dd..30d5ec6f1e 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.data @@ -1,3 +1,9 @@ +ECP valid params +ecp_valid_param: + +ECP invalid params +ecp_invalid_param: + ECP curve info #1 depends_on:MBEDTLS_ECP_DP_BP512R1_ENABLED mbedtls_ecp_curve_info:MBEDTLS_ECP_DP_BP512R1:28:512:"brainpoolP512r1" @@ -46,10 +52,6 @@ ECP check pubkey Koblitz #2 (coordinate not affine) depends_on:MBEDTLS_ECP_DP_SECP224K1_ENABLED ecp_check_pub:MBEDTLS_ECP_DP_SECP224K1:"E2000000000000BB3A13D43B323337383935321F0603551D":"100101FF040830060101FF02010A30220603551D0E041B04636FC0C0":"101":MBEDTLS_ERR_ECP_INVALID_KEY -ECP write binary #0 (zero, bad format) -depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED -ecp_write_binary:MBEDTLS_ECP_DP_SECP192R1:"01":"01":"00":ECP_PF_UNKNOWN:"00":1:MBEDTLS_ERR_ECP_BAD_INPUT_DATA - ECP write binary #1 (zero, uncompressed, buffer just fits) depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED ecp_write_binary:MBEDTLS_ECP_DP_SECP192R1:"01":"01":"00":MBEDTLS_ECP_PF_UNCOMPRESSED:"00":1:0 @@ -135,21 +137,21 @@ depends_on:MBEDTLS_ECP_DP_SECP521R1_ENABLED ecp_tls_write_read_point:MBEDTLS_ECP_DP_SECP521R1 ECP tls read group #1 (record too short) -mbedtls_ecp_tls_read_group:"0313":MBEDTLS_ERR_ECP_BAD_INPUT_DATA:0 +mbedtls_ecp_tls_read_group:"0313":MBEDTLS_ERR_ECP_BAD_INPUT_DATA:0:0 ECP tls read group #2 (bad curve_type) -mbedtls_ecp_tls_read_group:"010013":MBEDTLS_ERR_ECP_BAD_INPUT_DATA:0 +mbedtls_ecp_tls_read_group:"010013":MBEDTLS_ERR_ECP_BAD_INPUT_DATA:0:0 ECP tls read group #3 (unknown curve) -mbedtls_ecp_tls_read_group:"030010":MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE:0 +mbedtls_ecp_tls_read_group:"030010":MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE:0:0 ECP tls read group #4 (OK, buffer just fits) depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_ecp_tls_read_group:"030017":0:256 +mbedtls_ecp_tls_read_group:"030017":0:256:3 ECP tls read group #5 (OK, buffer continues) depends_on:MBEDTLS_ECP_DP_SECP384R1_ENABLED -mbedtls_ecp_tls_read_group:"0300180000":0:384 +mbedtls_ecp_tls_read_group:"0300180000":0:384:3 ECP tls write-read group #1 depends_on:MBEDTLS_ECP_DP_SECP192R1_ENABLED @@ -330,6 +332,10 @@ ECP test vectors Curve25519 depends_on:MBEDTLS_ECP_DP_CURVE25519_ENABLED ecp_test_vec_x:MBEDTLS_ECP_DP_CURVE25519:"5AC99F33632E5A768DE7E81BF854C27C46E3FBF2ABBACD29EC4AFF517369C660":"057E23EA9F1CBE8A27168F6E696A791DE61DD3AF7ACD4EEACC6E7BA514FDA863":"47DC3D214174820E1154B49BC6CDB2ABD45EE95817055D255AA35831B70D3260":"6EB89DA91989AE37C7EAC7618D9E5C4951DBA1D73C285AE1CD26A855020EEF04":"61450CD98E36016B58776A897A9F0AEF738B99F09468B8D6B8511184D53494AB" +ECP test vectors Curve448 (RFC 7748 6.2, after decodeUCoordinate) +depends_on:MBEDTLS_ECP_DP_CURVE448_ENABLED +ecp_test_vec_x:MBEDTLS_ECP_DP_CURVE448:"eb7298a5c0d8c29a1dab27f1a6826300917389449741a974f5bac9d98dc298d46555bce8bae89eeed400584bb046cf75579f51d125498f98":"a01fc432e5807f17530d1288da125b0cd453d941726436c8bbd9c5222c3da7fa639ce03db8d23b274a0721a1aed5227de6e3b731ccf7089b":"ad997351b6106f36b0d1091b929c4c37213e0d2b97e85ebb20c127691d0dad8f1d8175b0723745e639a3cb7044290b99e0e2a0c27a6a301c":"0936f37bc6c1bd07ae3dec7ab5dc06a73ca13242fb343efc72b9d82730b445f3d4b0bd077162a46dcfec6f9b590bfcbcf520cdb029a8b73e":"9d874a5137509a449ad5853040241c5236395435c36424fd560b0cb62b281d285275a740ce32a22dd1740f4aa9161cec95ccc61a18f4ff07" + ECP test vectors secp192k1 depends_on:MBEDTLS_ECP_DP_SECP192K1_ENABLED ecp_test_vect:MBEDTLS_ECP_DP_SECP192K1:"D1E13A359F6E0F0698791938E6D60246030AE4B0D8D4E9DE":"281BCA982F187ED30AD5E088461EBE0A5FADBB682546DF79":"3F68A8E9441FB93A4DD48CB70B504FCC9AA01902EF5BE0F3":"BE97C5D2A1A94D081E3FACE53E65A27108B7467BDF58DE43":"5EB35E922CD693F7947124F5920022C4891C04F6A8B8DCB2":"60ECF73D0FC43E0C42E8E155FFE39F9F0B531F87B34B6C3C":"372F5C5D0E18313C82AEF940EC3AFEE26087A46F1EBAE923":"D5A9F9182EC09CEAEA5F57EA10225EC77FA44174511985FD" @@ -344,3 +350,35 @@ ecp_test_vect:MBEDTLS_ECP_DP_SECP256K1:"923C6D4756CD940CD1E13A359F6E0F0698791938 ECP selftest ecp_selftest: + +ECP restartable mul secp256r1 max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_test_vect_restart:MBEDTLS_ECP_DP_SECP256R1:"814264145F2F56F2E96A8E337A1284993FAF432A5ABCE59E867B7291D507A3AF":"2AF502F3BE8952F2C9B5A8D4160D09E97165BE50BC42AE4A5E8D3B4BA83AEB15":"EB0FAF4CA986C4D38681A0F9872D79D56795BD4BFF6E6DE3C0F5015ECE5EFD85":"2CE1788EC197E096DB95A200CC0AB26A19CE6BCCAD562B8EEE1B593761CF7F41":"DD0F5396219D1EA393310412D19A08F1F5811E9DC8EC8EEA7F80D21C820C2788":"0357DCCD4C804D0D8D33AA42B848834AA5605F9AB0D37239A115BBB647936F50":0:0:0 + +ECP restartable mul secp256r1 max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_test_vect_restart:MBEDTLS_ECP_DP_SECP256R1:"814264145F2F56F2E96A8E337A1284993FAF432A5ABCE59E867B7291D507A3AF":"2AF502F3BE8952F2C9B5A8D4160D09E97165BE50BC42AE4A5E8D3B4BA83AEB15":"EB0FAF4CA986C4D38681A0F9872D79D56795BD4BFF6E6DE3C0F5015ECE5EFD85":"2CE1788EC197E096DB95A200CC0AB26A19CE6BCCAD562B8EEE1B593761CF7F41":"DD0F5396219D1EA393310412D19A08F1F5811E9DC8EC8EEA7F80D21C820C2788":"0357DCCD4C804D0D8D33AA42B848834AA5605F9AB0D37239A115BBB647936F50":1:1:5000 + +ECP restartable mul secp256r1 max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_test_vect_restart:MBEDTLS_ECP_DP_SECP256R1:"814264145F2F56F2E96A8E337A1284993FAF432A5ABCE59E867B7291D507A3AF":"2AF502F3BE8952F2C9B5A8D4160D09E97165BE50BC42AE4A5E8D3B4BA83AEB15":"EB0FAF4CA986C4D38681A0F9872D79D56795BD4BFF6E6DE3C0F5015ECE5EFD85":"2CE1788EC197E096DB95A200CC0AB26A19CE6BCCAD562B8EEE1B593761CF7F41":"DD0F5396219D1EA393310412D19A08F1F5811E9DC8EC8EEA7F80D21C820C2788":"0357DCCD4C804D0D8D33AA42B848834AA5605F9AB0D37239A115BBB647936F50":10000:0:0 + +ECP restartable mul secp256r1 max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_test_vect_restart:MBEDTLS_ECP_DP_SECP256R1:"814264145F2F56F2E96A8E337A1284993FAF432A5ABCE59E867B7291D507A3AF":"2AF502F3BE8952F2C9B5A8D4160D09E97165BE50BC42AE4A5E8D3B4BA83AEB15":"EB0FAF4CA986C4D38681A0F9872D79D56795BD4BFF6E6DE3C0F5015ECE5EFD85":"2CE1788EC197E096DB95A200CC0AB26A19CE6BCCAD562B8EEE1B593761CF7F41":"DD0F5396219D1EA393310412D19A08F1F5811E9DC8EC8EEA7F80D21C820C2788":"0357DCCD4C804D0D8D33AA42B848834AA5605F9AB0D37239A115BBB647936F50":250:2:32 + +ECP restartable muladd secp256r1 max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_muladd_restart:MBEDTLS_ECP_DP_SECP256R1:"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"2B57C0235FB7489768D058FF4911C20FDBE71E3699D91339AFBB903EE17255DC":"C3875E57C85038A0D60370A87505200DC8317C8C534948BEA6559C7C18E6D4CE":"3B4E49C4FDBFC006FF993C81A50EAE221149076D6EC09DDD9FB3B787F85B6483":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":0:0:0 + +ECP restartable muladd secp256r1 max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_muladd_restart:MBEDTLS_ECP_DP_SECP256R1:"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"2B57C0235FB7489768D058FF4911C20FDBE71E3699D91339AFBB903EE17255DC":"C3875E57C85038A0D60370A87505200DC8317C8C534948BEA6559C7C18E6D4CE":"3B4E49C4FDBFC006FF993C81A50EAE221149076D6EC09DDD9FB3B787F85B6483":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":1:1:10000 + +ECP restartable muladd secp256r1 max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_muladd_restart:MBEDTLS_ECP_DP_SECP256R1:"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"2B57C0235FB7489768D058FF4911C20FDBE71E3699D91339AFBB903EE17255DC":"C3875E57C85038A0D60370A87505200DC8317C8C534948BEA6559C7C18E6D4CE":"3B4E49C4FDBFC006FF993C81A50EAE221149076D6EC09DDD9FB3B787F85B6483":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":10000:0:0 + +ECP restartable muladd secp256r1 max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED +ecp_muladd_restart:MBEDTLS_ECP_DP_SECP256R1:"CB28E0999B9C7715FD0A80D8E47A77079716CBBF917DD72E97566EA1C066957C":"2B57C0235FB7489768D058FF4911C20FDBE71E3699D91339AFBB903EE17255DC":"C3875E57C85038A0D60370A87505200DC8317C8C534948BEA6559C7C18E6D4CE":"3B4E49C4FDBFC006FF993C81A50EAE221149076D6EC09DDD9FB3B787F85B6483":"2442A5CC0ECD015FA3CA31DC8E2BBC70BF42D60CBCA20085E0822CB04235E970":"6FC98BD7E50211A4A27102FA3549DF79EBCB4BF246B80945CDDFE7D509BBFD7D":250:4:64 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.function index 99780c0dec..0b2e029915 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ecp.function @@ -2,6 +2,10 @@ #include "mbedtls/ecp.h" #define ECP_PF_UNKNOWN -1 + +#define ECP_PT_RESET( x ) \ + mbedtls_ecp_point_free( x ); \ + mbedtls_ecp_point_init( x ); /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -10,7 +14,352 @@ */ /* BEGIN_CASE */ -void mbedtls_ecp_curve_info( int id, int tls_id, int size, char *name ) +void ecp_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_ecp_group_free( NULL ) ); + TEST_VALID_PARAM( mbedtls_ecp_keypair_free( NULL ) ); + TEST_VALID_PARAM( mbedtls_ecp_point_free( NULL ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + TEST_VALID_PARAM( mbedtls_ecp_restart_free( NULL ) ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void ecp_invalid_param( ) +{ + mbedtls_ecp_group grp; + mbedtls_ecp_keypair kp; + mbedtls_ecp_point P; + mbedtls_mpi m; + const char *x = "deadbeef"; + int valid_fmt = MBEDTLS_ECP_PF_UNCOMPRESSED; + int invalid_fmt = 42; + size_t olen; + unsigned char buf[42] = { 0 }; + const unsigned char *null_buf = NULL; + mbedtls_ecp_group_id valid_group = MBEDTLS_ECP_DP_SECP192R1; +#if defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_ecp_restart_ctx restart_ctx; +#endif /* MBEDTLS_ECP_RESTARTABLE */ + + TEST_INVALID_PARAM( mbedtls_ecp_point_init( NULL ) ); + TEST_INVALID_PARAM( mbedtls_ecp_keypair_init( NULL ) ); + TEST_INVALID_PARAM( mbedtls_ecp_group_init( NULL ) ); + +#if defined(MBEDTLS_ECP_RESTARTABLE) + TEST_INVALID_PARAM( mbedtls_ecp_restart_init( NULL ) ); + TEST_INVALID_PARAM( mbedtls_ecp_check_budget( NULL, &restart_ctx, 42 ) ); +#endif /* MBEDTLS_ECP_RESTARTABLE */ + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_copy( NULL, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_copy( &P, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_group_copy( NULL, &grp ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_group_copy( &grp, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_privkey( NULL, + &m, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_privkey( &grp, + NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_privkey( &grp, + &m, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_set_zero( NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_is_zero( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_cmp( NULL, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_cmp( &P, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_read_string( NULL, 2, + x, x ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_read_string( &P, 2, + NULL, x ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_read_string( &P, 2, + x, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_write_binary( NULL, &P, + valid_fmt, + &olen, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_write_binary( &grp, NULL, + valid_fmt, + &olen, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_write_binary( &grp, &P, + invalid_fmt, + &olen, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_write_binary( &grp, &P, + valid_fmt, + NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_write_binary( &grp, &P, + valid_fmt, + &olen, + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_read_binary( NULL, &P, buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_read_binary( &grp, NULL, buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_point_read_binary( &grp, &P, NULL, + sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_point( NULL, &P, + (const unsigned char **) &buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_point( &grp, NULL, + (const unsigned char **) &buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_point( &grp, &P, &null_buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_point( &grp, &P, NULL, + sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_point( NULL, &P, + valid_fmt, + &olen, + buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_point( &grp, NULL, + valid_fmt, + &olen, + buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_point( &grp, &P, + invalid_fmt, + &olen, + buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_point( &grp, &P, + valid_fmt, + NULL, + buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_point( &grp, &P, + valid_fmt, + &olen, + NULL, + sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_group_load( NULL, valid_group ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_group( NULL, + (const unsigned char **) &buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_group( &grp, NULL, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_group( &grp, &null_buf, + sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_group_id( NULL, + (const unsigned char **) &buf, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_group_id( &valid_group, NULL, + sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_read_group_id( &valid_group, + &null_buf, + sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_group( NULL, &olen, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_group( &grp, NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_tls_write_group( &grp, &olen, + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul( NULL, &P, &m, &P, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul( &grp, NULL, &m, &P, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul( &grp, &P, NULL, &P, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul( &grp, &P, &m, NULL, + rnd_std_rand, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul_restartable( NULL, &P, &m, &P, + rnd_std_rand, NULL , NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul_restartable( &grp, NULL, &m, &P, + rnd_std_rand, NULL , NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul_restartable( &grp, &P, NULL, &P, + rnd_std_rand, NULL , NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_mul_restartable( &grp, &P, &m, NULL, + rnd_std_rand, NULL , NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd( NULL, &P, &m, &P, + &m, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd( &grp, NULL, &m, &P, + &m, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd( &grp, &P, NULL, &P, + &m, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd( &grp, &P, &m, NULL, + &m, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd( &grp, &P, &m, &P, + NULL, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd( &grp, &P, &m, &P, + &m, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd_restartable( NULL, &P, &m, &P, + &m, &P, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd_restartable( &grp, NULL, &m, &P, + &m, &P, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd_restartable( &grp, &P, NULL, &P, + &m, &P, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd_restartable( &grp, &P, &m, NULL, + &m, &P, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd_restartable( &grp, &P, &m, &P, + NULL, &P, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_muladd_restartable( &grp, &P, &m, &P, + &m, NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_check_pubkey( NULL, &P ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_check_pubkey( &grp, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_check_pub_priv( NULL, &kp ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_check_pub_priv( &kp, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_check_privkey( NULL, &m ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_check_privkey( &grp, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair_base( NULL, &P, + &m, &P, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair_base( &grp, NULL, + &m, &P, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair_base( &grp, &P, + NULL, &P, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair_base( &grp, &P, + &m, NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair_base( &grp, &P, + &m, &P, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair( NULL, + &m, &P, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair( &grp, + NULL, &P, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair( &grp, + &m, NULL, + rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_keypair( &grp, + &m, &P, + NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_key( valid_group, NULL, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA, + mbedtls_ecp_gen_key( valid_group, &kp, + NULL, NULL ) ); + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_ecp_curve_info( int id, int tls_id, int size, char * name ) { const mbedtls_ecp_curve_info *by_id, *by_tls, *by_name; @@ -29,7 +378,8 @@ void mbedtls_ecp_curve_info( int id, int tls_id, int size, char *name ) /* END_CASE */ /* BEGIN_CASE */ -void ecp_check_pub( int grp_id, char *x_hex, char *y_hex, char *z_hex, int ret ) +void ecp_check_pub( int grp_id, char * x_hex, char * y_hex, char * z_hex, + int ret ) { mbedtls_ecp_group grp; mbedtls_ecp_point P; @@ -51,10 +401,177 @@ exit: } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */ +void ecp_test_vect_restart( int id, + char *dA_str, char *xA_str, char *yA_str, + char *dB_str, char *xZ_str, char *yZ_str, + int max_ops, int min_restarts, int max_restarts ) +{ + /* + * Test for early restart. Based on test vectors like ecp_test_vect(), + * but for the sake of simplicity only does half of each side. It's + * important to test both base point and random point, though, as memory + * management is different in each case. + * + * Don't try using too precise bounds for restarts as the exact number + * will depend on settings such as MBEDTLS_ECP_FIXED_POINT_OPTIM and + * MBEDTLS_ECP_WINDOW_SIZE, as well as implementation details that may + * change in the future. A factor 2 is a minimum safety margin. + * + * For reference, with mbed TLS 2.4 and default settings, for P-256: + * - Random point mult: ~3250M + * - Cold base point mult: ~3300M + * - Hot base point mult: ~1100M + * With MBEDTLS_ECP_WINDOW_SIZE set to 2 (minimum): + * - Random point mult: ~3850M + */ + mbedtls_ecp_restart_ctx ctx; + mbedtls_ecp_group grp; + mbedtls_ecp_point R, P; + mbedtls_mpi dA, xA, yA, dB, xZ, yZ; + int cnt_restarts; + int ret; + + mbedtls_ecp_restart_init( &ctx ); + mbedtls_ecp_group_init( &grp ); + mbedtls_ecp_point_init( &R ); mbedtls_ecp_point_init( &P ); + mbedtls_mpi_init( &dA ); mbedtls_mpi_init( &xA ); mbedtls_mpi_init( &yA ); + mbedtls_mpi_init( &dB ); mbedtls_mpi_init( &xZ ); mbedtls_mpi_init( &yZ ); + + TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 ); + + TEST_ASSERT( mbedtls_mpi_read_string( &dA, 16, dA_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &xA, 16, xA_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &yA, 16, yA_str ) == 0 ); + + TEST_ASSERT( mbedtls_mpi_read_string( &dB, 16, dB_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &xZ, 16, xZ_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &yZ, 16, yZ_str ) == 0 ); + + mbedtls_ecp_set_max_ops( (unsigned) max_ops ); + + /* Base point case */ + cnt_restarts = 0; + do { + ECP_PT_RESET( &R ); + ret = mbedtls_ecp_mul_restartable( &grp, &R, &dA, &grp.G, NULL, NULL, &ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restarts ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xA ) == 0 ); + TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.Y, &yA ) == 0 ); + + TEST_ASSERT( cnt_restarts >= min_restarts ); + TEST_ASSERT( cnt_restarts <= max_restarts ); + + /* Non-base point case */ + mbedtls_ecp_copy( &P, &R ); + cnt_restarts = 0; + do { + ECP_PT_RESET( &R ); + ret = mbedtls_ecp_mul_restartable( &grp, &R, &dB, &P, NULL, NULL, &ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restarts ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xZ ) == 0 ); + TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.Y, &yZ ) == 0 ); + + TEST_ASSERT( cnt_restarts >= min_restarts ); + TEST_ASSERT( cnt_restarts <= max_restarts ); + + /* Do we leak memory when aborting an operation? + * This test only makes sense when we actually restart */ + if( min_restarts > 0 ) + { + ret = mbedtls_ecp_mul_restartable( &grp, &R, &dB, &P, NULL, NULL, &ctx ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + } + +exit: + mbedtls_ecp_restart_free( &ctx ); + mbedtls_ecp_group_free( &grp ); + mbedtls_ecp_point_free( &R ); mbedtls_ecp_point_free( &P ); + mbedtls_mpi_free( &dA ); mbedtls_mpi_free( &xA ); mbedtls_mpi_free( &yA ); + mbedtls_mpi_free( &dB ); mbedtls_mpi_free( &xZ ); mbedtls_mpi_free( &yZ ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE */ +void ecp_muladd_restart( int id, char *xR_str, char *yR_str, + char *u1_str, char *u2_str, + char *xQ_str, char *yQ_str, + int max_ops, int min_restarts, int max_restarts ) +{ + /* + * Compute R = u1 * G + u2 * Q + * (test vectors mostly taken from ECDSA intermediate results) + * + * See comments at the top of ecp_test_vect_restart() + */ + mbedtls_ecp_restart_ctx ctx; + mbedtls_ecp_group grp; + mbedtls_ecp_point R, Q; + mbedtls_mpi u1, u2, xR, yR; + int cnt_restarts; + int ret; + + mbedtls_ecp_restart_init( &ctx ); + mbedtls_ecp_group_init( &grp ); + mbedtls_ecp_point_init( &R ); + mbedtls_ecp_point_init( &Q ); + mbedtls_mpi_init( &u1 ); mbedtls_mpi_init( &u2 ); + mbedtls_mpi_init( &xR ); mbedtls_mpi_init( &yR ); + + TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 ); + + TEST_ASSERT( mbedtls_mpi_read_string( &u1, 16, u1_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &u2, 16, u2_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &xR, 16, xR_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &yR, 16, yR_str ) == 0 ); + + TEST_ASSERT( mbedtls_mpi_read_string( &Q.X, 16, xQ_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &Q.Y, 16, yQ_str ) == 0 ); + TEST_ASSERT( mbedtls_mpi_lset( &Q.Z, 1 ) == 0 ); + + mbedtls_ecp_set_max_ops( (unsigned) max_ops ); + + cnt_restarts = 0; + do { + ECP_PT_RESET( &R ); + ret = mbedtls_ecp_muladd_restartable( &grp, &R, + &u1, &grp.G, &u2, &Q, &ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restarts ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.X, &xR ) == 0 ); + TEST_ASSERT( mbedtls_mpi_cmp_mpi( &R.Y, &yR ) == 0 ); + + TEST_ASSERT( cnt_restarts >= min_restarts ); + TEST_ASSERT( cnt_restarts <= max_restarts ); + + /* Do we leak memory when aborting an operation? + * This test only makes sense when we actually restart */ + if( min_restarts > 0 ) + { + ret = mbedtls_ecp_muladd_restartable( &grp, &R, + &u1, &grp.G, &u2, &Q, &ctx ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + } + +exit: + mbedtls_ecp_restart_free( &ctx ); + mbedtls_ecp_group_free( &grp ); + mbedtls_ecp_point_free( &R ); + mbedtls_ecp_point_free( &Q ); + mbedtls_mpi_free( &u1 ); mbedtls_mpi_free( &u2 ); + mbedtls_mpi_free( &xR ); mbedtls_mpi_free( &yR ); +} +/* END_CASE */ + /* BEGIN_CASE */ -void ecp_test_vect( int id, char *dA_str, char *xA_str, char *yA_str, - char *dB_str, char *xB_str, char *yB_str, char *xZ_str, - char *yZ_str ) +void ecp_test_vect( int id, char * dA_str, char * xA_str, char * yA_str, + char * dB_str, char * xB_str, char * yB_str, + char * xZ_str, char * yZ_str ) { mbedtls_ecp_group grp; mbedtls_ecp_point R; @@ -107,8 +624,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void ecp_test_vec_x( int id, char *dA_hex, char *xA_hex, - char *dB_hex, char *xB_hex, char *xS_hex ) +void ecp_test_vec_x( int id, char * dA_hex, char * xA_hex, char * dB_hex, + char * xB_hex, char * xS_hex ) { mbedtls_ecp_group grp; mbedtls_ecp_point R; @@ -158,7 +675,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void ecp_fast_mod( int id, char *N_str ) +void ecp_fast_mod( int id, char * N_str ) { mbedtls_ecp_group grp; mbedtls_mpi N, R; @@ -191,16 +708,15 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void ecp_write_binary( int id, char *x, char *y, char *z, int format, - char *out, int blen, int ret ) +void ecp_write_binary( int id, char * x, char * y, char * z, int format, + data_t * out, int blen, int ret ) { mbedtls_ecp_group grp; mbedtls_ecp_point P; - unsigned char buf[256], str[512]; + unsigned char buf[256]; size_t olen; memset( buf, 0, sizeof( buf ) ); - memset( str, 0, sizeof( str ) ); mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &P ); @@ -215,8 +731,7 @@ void ecp_write_binary( int id, char *x, char *y, char *z, int format, if( ret == 0 ) { - hexify( str, buf, olen ); - TEST_ASSERT( strcasecmp( (char *) str, out ) == 0 ); + TEST_ASSERT( hexcmp( buf, out->x, olen, out->len ) == 0 ); } exit: @@ -225,16 +740,13 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void ecp_read_binary( int id, char *input, char *x, char *y, char *z, +void ecp_read_binary( int id, data_t * buf, char * x, char * y, char * z, int ret ) { mbedtls_ecp_group grp; mbedtls_ecp_point P; mbedtls_mpi X, Y, Z; - int ilen; - unsigned char buf[256]; - memset( buf, 0, sizeof( buf ) ); mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &P ); mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); @@ -245,9 +757,7 @@ void ecp_read_binary( int id, char *input, char *x, char *y, char *z, TEST_ASSERT( mbedtls_mpi_read_string( &Y, 16, y ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &Z, 16, z ) == 0 ); - ilen = unhexify( buf, input ); - - TEST_ASSERT( mbedtls_ecp_point_read_binary( &grp, &P, buf, ilen ) == ret ); + TEST_ASSERT( mbedtls_ecp_point_read_binary( &grp, &P, buf->x, buf->len ) == ret ); if( ret == 0 ) { @@ -263,17 +773,14 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ecp_tls_read_point( int id, char *input, char *x, char *y, char *z, - int ret ) +void mbedtls_ecp_tls_read_point( int id, data_t * buf, char * x, char * y, + char * z, int ret ) { mbedtls_ecp_group grp; mbedtls_ecp_point P; mbedtls_mpi X, Y, Z; - size_t ilen; - unsigned char buf[256]; - const unsigned char *vbuf = buf; + const unsigned char *vbuf = buf->x; - memset( buf, 0, sizeof( buf ) ); mbedtls_ecp_group_init( &grp ); mbedtls_ecp_point_init( &P ); mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); @@ -284,16 +791,14 @@ void mbedtls_ecp_tls_read_point( int id, char *input, char *x, char *y, char *z, TEST_ASSERT( mbedtls_mpi_read_string( &Y, 16, y ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &Z, 16, z ) == 0 ); - ilen = unhexify( buf, input ); - - TEST_ASSERT( mbedtls_ecp_tls_read_point( &grp, &P, &vbuf, ilen ) == ret ); + TEST_ASSERT( mbedtls_ecp_tls_read_point( &grp, &P, &vbuf, buf->len ) == ret ); if( ret == 0 ) { TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.X, &X ) == 0 ); TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.Y, &Y ) == 0 ); TEST_ASSERT( mbedtls_mpi_cmp_mpi( &P.Z, &Z ) == 0 ); - TEST_ASSERT( *vbuf == 0x00 ); + TEST_ASSERT( (uint32_t)( vbuf - buf->x ) == buf->len ); } exit: @@ -355,25 +860,22 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ecp_tls_read_group( char *record, int result, int bits ) +void mbedtls_ecp_tls_read_group( data_t * buf, int result, int bits, + int record_len ) { mbedtls_ecp_group grp; - unsigned char buf[10]; - const unsigned char *vbuf = buf; - int len, ret; + const unsigned char *vbuf = buf->x; + int ret; mbedtls_ecp_group_init( &grp ); - memset( buf, 0x00, sizeof( buf ) ); - - len = unhexify( buf, record ); - ret = mbedtls_ecp_tls_read_group( &grp, &vbuf, len ); + ret = mbedtls_ecp_tls_read_group( &grp, &vbuf, buf->len ); TEST_ASSERT( ret == result ); if( ret == 0) { TEST_ASSERT( mbedtls_mpi_bitlen( &grp.P ) == (size_t) bits ); - TEST_ASSERT( *vbuf == 0x00 ); + TEST_ASSERT( vbuf - buf->x == record_len); } exit: @@ -413,7 +915,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ecp_check_privkey( int id, char *key_hex, int ret ) +void mbedtls_ecp_check_privkey( int id, char * key_hex, int ret ) { mbedtls_ecp_group grp; mbedtls_mpi d; @@ -433,8 +935,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_ecp_check_pub_priv( int id_pub, char *Qx_pub, char *Qy_pub, - int id, char *d, char *Qx, char *Qy, int ret ) +void mbedtls_ecp_check_pub_priv( int id_pub, char * Qx_pub, char * Qy_pub, + int id, char * d, char * Qx, char * Qy, + int ret ) { mbedtls_ecp_keypair pub, prv; @@ -506,7 +1009,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void ecp_selftest() +void ecp_selftest( ) { TEST_ASSERT( mbedtls_ecp_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_entropy.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_entropy.function index 2bab796d1c..0b1cfe80d4 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_entropy.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_entropy.function @@ -1,6 +1,7 @@ /* BEGIN_HEADER */ #include "mbedtls/entropy.h" #include "mbedtls/entropy_poll.h" +#include "string.h" /* * Number of calls made to entropy_dummy_source() @@ -124,7 +125,7 @@ static int read_nv_seed( unsigned char *buf, size_t buf_len ) */ /* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */ -void entropy_seed_file( char *path, int ret ) +void entropy_seed_file( char * path, int ret ) { mbedtls_entropy_context ctx; @@ -139,7 +140,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void entropy_too_many_sources( ) +void entropy_too_many_sources( ) { mbedtls_entropy_context ctx; size_t i; @@ -193,7 +194,7 @@ void entropy_func_len( int len, int ret ) /* END_CASE */ /* BEGIN_CASE */ -void entropy_source_fail( char *path ) +void entropy_source_fail( char * path ) { mbedtls_entropy_context ctx; int fail = -1; @@ -260,7 +261,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */ -void nv_seed_file_create() +void nv_seed_file_create( ) { unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; @@ -271,7 +272,7 @@ void nv_seed_file_create() /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO:MBEDTLS_PLATFORM_NV_SEED_ALT */ -void entropy_nv_seed_std_io() +void entropy_nv_seed_std_io( ) { unsigned char io_seed[MBEDTLS_ENTROPY_BLOCK_SIZE]; unsigned char check_seed[MBEDTLS_ENTROPY_BLOCK_SIZE]; @@ -301,7 +302,7 @@ void entropy_nv_seed_std_io() /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_PLATFORM_NV_SEED_ALT:MBEDTLS_ENTROPY_SHA512_ACCUMULATOR */ -void entropy_nv_seed( char *read_seed_str ) +void entropy_nv_seed( data_t * read_seed ) { mbedtls_sha512_context accumulator; mbedtls_entropy_context ctx; @@ -310,7 +311,6 @@ void entropy_nv_seed( char *read_seed_str ) unsigned char entropy[MBEDTLS_ENTROPY_BLOCK_SIZE]; unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE]; unsigned char empty[MBEDTLS_ENTROPY_BLOCK_SIZE]; - unsigned char read_seed[MBEDTLS_ENTROPY_BLOCK_SIZE]; unsigned char check_seed[MBEDTLS_ENTROPY_BLOCK_SIZE]; unsigned char check_entropy[MBEDTLS_ENTROPY_BLOCK_SIZE]; @@ -322,8 +322,7 @@ void entropy_nv_seed( char *read_seed_str ) memset( check_entropy, 3, MBEDTLS_ENTROPY_BLOCK_SIZE ); // Set the initial NV seed to read - unhexify( read_seed, read_seed_str ); - memcpy( buffer_seed, read_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ); + memcpy( buffer_seed, read_seed->x, read_seed->len ); // Make sure we read/write NV seed from our buffers mbedtls_platform_set_nv_seed( buffer_nv_seed_read, buffer_nv_seed_write ); @@ -348,7 +347,7 @@ void entropy_nv_seed( char *read_seed_str ) // First run for updating write_seed header[0] = 0; mbedtls_sha512_update( &accumulator, header, 2 ); - mbedtls_sha512_update( &accumulator, read_seed, MBEDTLS_ENTROPY_BLOCK_SIZE ); + mbedtls_sha512_update( &accumulator, read_seed->x, read_seed->len ); mbedtls_sha512_finish( &accumulator, buf ); memset( &accumulator, 0, sizeof( mbedtls_sha512_context ) ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_error.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_error.function index c99b1fd15c..68831ce51d 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_error.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_error.function @@ -8,7 +8,7 @@ */ /* BEGIN_CASE */ -void error_strerror( int code, char *result_str ) +void error_strerror( int code, char * result_str ) { char buf[500]; diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes128_de.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes128_de.data index 2a2e32f0d3..a42fe859d8 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes128_de.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes128_de.data @@ -1,674 +1,674 @@ AES-GCM NIST Validation (AES-128,128,0,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d785dafea3e966731ef6fc6202262584":"":"d91a46205ee94058b3b8403997592dd2":"":128:"3b92a17c1b9c3578a68cffea5a5b6245":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d785dafea3e966731ef6fc6202262584":"":"d91a46205ee94058b3b8403997592dd2":"":128:"3b92a17c1b9c3578a68cffea5a5b6245":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aec963833b9098de1ababc853ab74d96":"":"4e0ffd93beffd732c6f7d6ad606a2d24":"":128:"e9fcedc176dfe587dc61b2011010cdf1":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aec963833b9098de1ababc853ab74d96":"":"4e0ffd93beffd732c6f7d6ad606a2d24":"":128:"e9fcedc176dfe587dc61b2011010cdf1":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c4fb9e3393681da9cec5ec96f87c5c31":"":"845e910bc055d895879f62101d08b4c7":"":128:"99fb783c497416e4b6e2a5de7c782057":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c4fb9e3393681da9cec5ec96f87c5c31":"":"845e910bc055d895879f62101d08b4c7":"":128:"99fb783c497416e4b6e2a5de7c782057":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2a930f2e09beceacd9919cb76f2ac8d3":"":"340d9af44f6370eff534c653033a785a":"":120:"0c1e5e9c8fe5edfd11f114f3503d63":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2a930f2e09beceacd9919cb76f2ac8d3":"":"340d9af44f6370eff534c653033a785a":"":120:"0c1e5e9c8fe5edfd11f114f3503d63":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe71177e02073b1c407b5724e2263a5e":"":"83c23d20d2a9d4b8f92da96587c96b18":"":120:"43b2ca795420f35f6cb39f5dfa47a2":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe71177e02073b1c407b5724e2263a5e":"":"83c23d20d2a9d4b8f92da96587c96b18":"":120:"43b2ca795420f35f6cb39f5dfa47a2":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b02392fd7f228888c281e59d1eaa15fb":"":"2726344ba8912c737e195424e1e6679e":"":120:"a10b601ca8053536a2af2cc255d2b6":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b02392fd7f228888c281e59d1eaa15fb":"":"2726344ba8912c737e195424e1e6679e":"":120:"a10b601ca8053536a2af2cc255d2b6":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"21895cbafc16b7b8bf5867e88e0853d4":"":"f987ce1005d9bbd31d2452fb80957753":"":112:"952a7e265830d58a6778d68b9450":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"21895cbafc16b7b8bf5867e88e0853d4":"":"f987ce1005d9bbd31d2452fb80957753":"":112:"952a7e265830d58a6778d68b9450":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bb9742bf47f68caf64963d7c10a97b0":"":"34a85669de64e1cd44731905fddbcbc5":"":112:"e9b6be928aa77b2de28b480ae74c":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bb9742bf47f68caf64963d7c10a97b0":"":"34a85669de64e1cd44731905fddbcbc5":"":112:"e9b6be928aa77b2de28b480ae74c":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4e9708e4b37e2e1b5feaf4f5ab54e2a6":"":"1c53a9fdd23919b036d99560619a9939":"":112:"6611b50d6fbca83047f9f5fe1768":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4e9708e4b37e2e1b5feaf4f5ab54e2a6":"":"1c53a9fdd23919b036d99560619a9939":"":112:"6611b50d6fbca83047f9f5fe1768":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"82fede79db25f00be96eb050a22cea87":"":"e9c50b517ab26c89b83c1f0cac50162c":"":104:"d0c0ce9db60b77b0e31d05e048":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"82fede79db25f00be96eb050a22cea87":"":"e9c50b517ab26c89b83c1f0cac50162c":"":104:"d0c0ce9db60b77b0e31d05e048":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1d98566fca5201abb12914311a8bd532":"":"590aef4b46a9023405d075edab7e6849":"":104:"a1cfd1a27b341f49eda2ca8305":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1d98566fca5201abb12914311a8bd532":"":"590aef4b46a9023405d075edab7e6849":"":104:"a1cfd1a27b341f49eda2ca8305":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3038771820c2e1319f02a74b8a7a0c08":"":"e556d9f07fb69d7e9a644261c80fac92":"":104:"4d2f005d662b6a8787f231c5e1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3038771820c2e1319f02a74b8a7a0c08":"":"e556d9f07fb69d7e9a644261c80fac92":"":104:"4d2f005d662b6a8787f231c5e1":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0fb7eef50de598d7d8b508d019a30d5a":"":"a2a2617040116c2c7e4236d2d8278213":"":96:"68413c58df7bb5f067197ca0":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0fb7eef50de598d7d8b508d019a30d5a":"":"a2a2617040116c2c7e4236d2d8278213":"":96:"68413c58df7bb5f067197ca0":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8cc58b609204215c8ab4908286e56e5c":"":"fb83ea637279332677b5f68081173e99":"":96:"a2a9160d82739a55d8cd419f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8cc58b609204215c8ab4908286e56e5c":"":"fb83ea637279332677b5f68081173e99":"":96:"a2a9160d82739a55d8cd419f":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"81a5fd184742a478432963f6477e8f92":"":"da297cbb53b11d7c379e0566299b4d5a":"":96:"200bee49466fdda2f21f0062":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"81a5fd184742a478432963f6477e8f92":"":"da297cbb53b11d7c379e0566299b4d5a":"":96:"200bee49466fdda2f21f0062":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f604ac66d626959e595cbb7b4128e096":"":"269d2a49d533c6bb38008711f38e0b39":"":64:"468200fa4683e8be":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f604ac66d626959e595cbb7b4128e096":"":"269d2a49d533c6bb38008711f38e0b39":"":64:"468200fa4683e8be":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2e308ba7903e925f768c1d00ff3eb623":"":"335acd2aa48a47a37cfe21e491f1b141":"":64:"4872bfd5e2ff55f6":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2e308ba7903e925f768c1d00ff3eb623":"":"335acd2aa48a47a37cfe21e491f1b141":"":64:"4872bfd5e2ff55f6":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1304e2a5a3520454a5109df61a67da7a":"":"dbe8b452acf4fa1444c3668e9ee72d26":"":64:"83a0d3440200ca95":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1304e2a5a3520454a5109df61a67da7a":"":"dbe8b452acf4fa1444c3668e9ee72d26":"":64:"83a0d3440200ca95":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ecf1ec2c9a8f2e9cc799f9b9fddb3232":"":"ddf0b695aef5df2b594fcaae72b7e41c":"":32:"2819aedf":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ecf1ec2c9a8f2e9cc799f9b9fddb3232":"":"ddf0b695aef5df2b594fcaae72b7e41c":"":32:"2819aedf":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9ab5c8ca905b5fe50461f4a68941144b":"":"96dd3927a96e16123f2e9d6b367d303f":"":32:"6e0c53ef":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9ab5c8ca905b5fe50461f4a68941144b":"":"96dd3927a96e16123f2e9d6b367d303f":"":32:"6e0c53ef":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5fc7af605721a9cfe61c1ee6a4b3e22":"":"6b757d4055823d1035d01077666037d6":"":32:"e8c09ddd":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5fc7af605721a9cfe61c1ee6a4b3e22":"":"6b757d4055823d1035d01077666037d6":"":32:"e8c09ddd":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"03c0b4a6e508a8490db0d086a82c9db7":"":"ac52f6c1a05030321fa39f87e89fdb5e":"33316ca79d10a79f4fd038593e8eef09625089dc4e0ffe4bc1f2871554fa6666ab3e7fe7885edef694b410456f3ec0e513bb25f1b48d95e4820c5972c1aabb25c84c08566002dadc36df334c1ce86847964a122016d389ac873bca8c335a7a99bcef91e1b985ae5d488a2d7f78b4bf14e0c2dc715e814f4e24276057cf668172":128:"756292d8b4653887edef51679b161812":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"03c0b4a6e508a8490db0d086a82c9db7":"":"ac52f6c1a05030321fa39f87e89fdb5e":"33316ca79d10a79f4fd038593e8eef09625089dc4e0ffe4bc1f2871554fa6666ab3e7fe7885edef694b410456f3ec0e513bb25f1b48d95e4820c5972c1aabb25c84c08566002dadc36df334c1ce86847964a122016d389ac873bca8c335a7a99bcef91e1b985ae5d488a2d7f78b4bf14e0c2dc715e814f4e24276057cf668172":128:"756292d8b4653887edef51679b161812":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b228d3d15219ea9ad5651fce02c8374d":"":"5c7eafaead029c3fe3cf3835fe758d0e":"8c35dd805c08686b9b4d460f81b4dcb8c46c6d57842dc3e72ba90952e2bebf17fe7184445b02f801800a944486d662a127d01d3b7f42679052cdc73ce533129af8d13957415c5495142157d6ce8a68aa977e56f562fed98e468e42522767656ce50369471060381bb752dd5e77c79677a4cadffa39e518e30a789e793b07ea21":128:"a4dde1ab93c84937c3bbc3ad5237818d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b228d3d15219ea9ad5651fce02c8374d":"":"5c7eafaead029c3fe3cf3835fe758d0e":"8c35dd805c08686b9b4d460f81b4dcb8c46c6d57842dc3e72ba90952e2bebf17fe7184445b02f801800a944486d662a127d01d3b7f42679052cdc73ce533129af8d13957415c5495142157d6ce8a68aa977e56f562fed98e468e42522767656ce50369471060381bb752dd5e77c79677a4cadffa39e518e30a789e793b07ea21":128:"a4dde1ab93c84937c3bbc3ad5237818d":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"776afcbabedd5577fe660a60f920b536":"":"5bbb7f1b14084e520408dd87b97705e9":"44631fc9d4a07416b0dfb4e2b42071e3e2be45502c9ddf72b3e61810eeda31a7d685ebb2ee43a2c06af374569f439ee1668c550067de2dece9ec46ee72b260858d6033f814e85275c5ae669b60803a8c516de32804fa34d3a213ccfaf6689046e25eeb30b9e1608e689f4d31cc664b83a468a51165f5625f12f098a6bf7ddab2":128:"a5347d41d93b587240651bcd5230264f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"776afcbabedd5577fe660a60f920b536":"":"5bbb7f1b14084e520408dd87b97705e9":"44631fc9d4a07416b0dfb4e2b42071e3e2be45502c9ddf72b3e61810eeda31a7d685ebb2ee43a2c06af374569f439ee1668c550067de2dece9ec46ee72b260858d6033f814e85275c5ae669b60803a8c516de32804fa34d3a213ccfaf6689046e25eeb30b9e1608e689f4d31cc664b83a468a51165f5625f12f098a6bf7ddab2":128:"a5347d41d93b587240651bcd5230264f":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"20abeafa25fc4ea7d0592cb3e9b4d5fe":"":"3aba79a58c5aa664856b41d552c7a8d3":"98cfecaae9eb9a7c3b17e6bc5f80d8a4bf7a9f4fa5e01b74cae15ee6af14633205aafe3b28fb7b7918e12322ea27352056a603746d728a61361134a561619400ff2bf679045bac2e0fbc2c1d41f8faba4b27c7827bceda4e9bf505df4185515dd3a5e26f7639c8ad5a38bc5906a44be062f02cc53862678ae36fa3de3c02c982":120:"2a67ad1471a520fe09a304f0975f31":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"20abeafa25fc4ea7d0592cb3e9b4d5fe":"":"3aba79a58c5aa664856b41d552c7a8d3":"98cfecaae9eb9a7c3b17e6bc5f80d8a4bf7a9f4fa5e01b74cae15ee6af14633205aafe3b28fb7b7918e12322ea27352056a603746d728a61361134a561619400ff2bf679045bac2e0fbc2c1d41f8faba4b27c7827bceda4e9bf505df4185515dd3a5e26f7639c8ad5a38bc5906a44be062f02cc53862678ae36fa3de3c02c982":120:"2a67ad1471a520fe09a304f0975f31":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2bc73fba942ff105823b5dccf6befb1c":"":"902c3e3b69b1ef8395d7281ff74cce38":"4adec0b4ac00325a860044d9f9519daa4f7c163229a75819b0fd7d8e23319f030e61dfa8eadabff42ea27bc36bdb6cad249e801ca631b656836448b7172c11126bad2781e6a1aa4f62c4eda53409408b008c057e0b81215cc13ddabbb8f1915f4bbab854f8b00763a530ad5055d265778cd3080d0bd35b76a329bdd5b5a2d268":120:"ebdd7c8e87fe733138a433543542d1":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2bc73fba942ff105823b5dccf6befb1c":"":"902c3e3b69b1ef8395d7281ff74cce38":"4adec0b4ac00325a860044d9f9519daa4f7c163229a75819b0fd7d8e23319f030e61dfa8eadabff42ea27bc36bdb6cad249e801ca631b656836448b7172c11126bad2781e6a1aa4f62c4eda53409408b008c057e0b81215cc13ddabbb8f1915f4bbab854f8b00763a530ad5055d265778cd3080d0bd35b76a329bdd5b5a2d268":120:"ebdd7c8e87fe733138a433543542d1":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"356a4c245868243d61756cabe86da887":"":"b442f2ec6d45a17144c258fd59fe5b3b":"12cccc3c60474b0a1579c5006c2134850724fa6c9da3a7022d4f65fd238b052bdf34ea34aa7dbadad64996065acee588ab6bd29726d07ed24ffae2d33aadf3e66ebb87f57e689fd85128be1c9e3d8362fad1f8096ee391f75b576fb213d394cef6f091fc5488d9aa152be69475b9167abd6dd4fd93bbbc7b8ca316c952eb19c6":120:"ed26080dcb670590613d97d7c47cf4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"356a4c245868243d61756cabe86da887":"":"b442f2ec6d45a17144c258fd59fe5b3b":"12cccc3c60474b0a1579c5006c2134850724fa6c9da3a7022d4f65fd238b052bdf34ea34aa7dbadad64996065acee588ab6bd29726d07ed24ffae2d33aadf3e66ebb87f57e689fd85128be1c9e3d8362fad1f8096ee391f75b576fb213d394cef6f091fc5488d9aa152be69475b9167abd6dd4fd93bbbc7b8ca316c952eb19c6":120:"ed26080dcb670590613d97d7c47cf4":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dfa7e93aff73600fc552324253066e2c":"":"c20001e93f1cd05253c277a9445d61e4":"a64d1e20058a1f7e698622a02f7ff8dc11886717ede17bbdc3c4645a66a71d8b04346fb389a251ffb0a7f445a25faf642bb7e4697d2cacf925e78c4be98457996afb25b0516b50f179441d1923312364947f8f1e0f5715b43bd537727bf943d7b4679b0b0b28b94e56e7bbf554d9cf79fcee4387f32bb6f91efdd23620035be6":112:"6ba5e4dace9a54b50b901d9b73ad":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dfa7e93aff73600fc552324253066e2c":"":"c20001e93f1cd05253c277a9445d61e4":"a64d1e20058a1f7e698622a02f7ff8dc11886717ede17bbdc3c4645a66a71d8b04346fb389a251ffb0a7f445a25faf642bb7e4697d2cacf925e78c4be98457996afb25b0516b50f179441d1923312364947f8f1e0f5715b43bd537727bf943d7b4679b0b0b28b94e56e7bbf554d9cf79fcee4387f32bb6f91efdd23620035be6":112:"6ba5e4dace9a54b50b901d9b73ad":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2ecea80b48d2ecd194a7699aa7d8ccfc":"":"8b4db08bafc23b65ae50a2d20661d270":"efc2ca1a3b41b90f8ddf74291d68f072a6e025d0c91c3ce2b133525943c73ebadc71f150be20afeb097442fa51be31a641df65d90ebd81dcbaf32711ed31f5e0271421377ffe14ddafea3ca60a600588d484856a98de73f56a766ae60bae384a4ae01a1a06821cf0c7a6b4ee4c8f413748457b3777283d3310218fb55c107293":112:"246a9d37553088b6411ebb62aa16":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2ecea80b48d2ecd194a7699aa7d8ccfc":"":"8b4db08bafc23b65ae50a2d20661d270":"efc2ca1a3b41b90f8ddf74291d68f072a6e025d0c91c3ce2b133525943c73ebadc71f150be20afeb097442fa51be31a641df65d90ebd81dcbaf32711ed31f5e0271421377ffe14ddafea3ca60a600588d484856a98de73f56a766ae60bae384a4ae01a1a06821cf0c7a6b4ee4c8f413748457b3777283d3310218fb55c107293":112:"246a9d37553088b6411ebb62aa16":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d38fee3fd3d6d08224c3c83529a25d08":"":"a942ccb11cf9468186fabfc18c899801":"1c92a4ce0a1dae27e720d6f9b1e460276538de437f3812ab1177cf0273b05908f296f33ba0f4c790abe2ce958b1d92b930a0d81243e6ad09ef86ee8e3270243095096537cb1054fcfcf537d828b65af9b6cf7c50f5b8470f7908f314d0859107eed772ee1732c78e8a2e35b2493f3e8c1e601b08aeab8d9729e0294dca168c62":112:"803a08700ec86fdeb88f7a388921":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d38fee3fd3d6d08224c3c83529a25d08":"":"a942ccb11cf9468186fabfc18c899801":"1c92a4ce0a1dae27e720d6f9b1e460276538de437f3812ab1177cf0273b05908f296f33ba0f4c790abe2ce958b1d92b930a0d81243e6ad09ef86ee8e3270243095096537cb1054fcfcf537d828b65af9b6cf7c50f5b8470f7908f314d0859107eed772ee1732c78e8a2e35b2493f3e8c1e601b08aeab8d9729e0294dca168c62":112:"803a08700ec86fdeb88f7a388921":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1899b0cbae41d705c6eed3226afb5bc0":"":"82d0910aa53e300a487d880d018d0dea":"6bf5583cc1007d74f3529db63b8d4e085400ccf3725eab8e19cb145f3910c61465a21486740a26f74691866a9f632af9fae81f5f0bffedf0c28a6ce0fd520bb4db04a3cd1a7d29d8801e05e4b9c9374fd89bcb539489c2f7f1f801c253a1cc737408669bcd133b62da357f7399a52179125aa59fae6707d340846886d730a835":104:"c5d58870fee9ce157f5ec1fa8f":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1899b0cbae41d705c6eed3226afb5bc0":"":"82d0910aa53e300a487d880d018d0dea":"6bf5583cc1007d74f3529db63b8d4e085400ccf3725eab8e19cb145f3910c61465a21486740a26f74691866a9f632af9fae81f5f0bffedf0c28a6ce0fd520bb4db04a3cd1a7d29d8801e05e4b9c9374fd89bcb539489c2f7f1f801c253a1cc737408669bcd133b62da357f7399a52179125aa59fae6707d340846886d730a835":104:"c5d58870fee9ce157f5ec1fa8f":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8b95323d86d02754f4c2874b42ec6eb0":"":"4f76084acbdef9999c71dcc794238d7c":"ebc75788377c0b264818a6f97c19cf92c29f1c7cdeb6b5f0a92d238fa4614bc35d0cfe4ec9d045cd628ff6262c460679ac15b0c6366d9289bbd217e5012279e0af0fb2cfcbdf51fe16935968cbb727f725fe5bcd4428905849746c8493600ce8b2cfc1b61b04c8b752b915fed611d6b54ef73ec4e3950d6db1807b1ce7ed1dcc":104:"c4724ff1d2c57295eb733e9cad":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8b95323d86d02754f4c2874b42ec6eb0":"":"4f76084acbdef9999c71dcc794238d7c":"ebc75788377c0b264818a6f97c19cf92c29f1c7cdeb6b5f0a92d238fa4614bc35d0cfe4ec9d045cd628ff6262c460679ac15b0c6366d9289bbd217e5012279e0af0fb2cfcbdf51fe16935968cbb727f725fe5bcd4428905849746c8493600ce8b2cfc1b61b04c8b752b915fed611d6b54ef73ec4e3950d6db1807b1ce7ed1dcc":104:"c4724ff1d2c57295eb733e9cad":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30da555559eb11cf7e0eff9d99e9607d":"":"7799275bf12335f281ec94a870f90a0b":"e735d556e15aec78d9736016c8c99db753ed14d4e4adaaa1dd7eaad702ea5dc337433f8c2b45afdf2f385fdf6c55574425571e079ca759b6235f877ed11618ff212bafd865a22b80b76b3b5cf1acfd24d92fd41607bbb7382f26cd703757088d497b16b32de80e1256c734a9b83356b6fced207177de75458481eaef59a431d7":104:"3c82272130e17c4a0a007a908e":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30da555559eb11cf7e0eff9d99e9607d":"":"7799275bf12335f281ec94a870f90a0b":"e735d556e15aec78d9736016c8c99db753ed14d4e4adaaa1dd7eaad702ea5dc337433f8c2b45afdf2f385fdf6c55574425571e079ca759b6235f877ed11618ff212bafd865a22b80b76b3b5cf1acfd24d92fd41607bbb7382f26cd703757088d497b16b32de80e1256c734a9b83356b6fced207177de75458481eaef59a431d7":104:"3c82272130e17c4a0a007a908e":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ed2ac74af896c5190c271cfa6af02fd2":"":"e0226e2d8da47badad1fb78b9a797f27":"8f11353ae476ff923013e6e736ffc9d23101a1c471ccc07ad372a8430d6559c376075efce2e318cdf4c9443dbf132e7e6da5524045028c97e904633b44c4d189a4b64237ac7692dd03c0e751ce9f04d0fdbd8a96074cd7dfa2fd441a52328b4ac3974b4902db45663f7b6f24947dba618f8b9769e927faf84c9f49ad8239b9fb":96:"db8af7a0d548fc54d9457c73":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ed2ac74af896c5190c271cfa6af02fd2":"":"e0226e2d8da47badad1fb78b9a797f27":"8f11353ae476ff923013e6e736ffc9d23101a1c471ccc07ad372a8430d6559c376075efce2e318cdf4c9443dbf132e7e6da5524045028c97e904633b44c4d189a4b64237ac7692dd03c0e751ce9f04d0fdbd8a96074cd7dfa2fd441a52328b4ac3974b4902db45663f7b6f24947dba618f8b9769e927faf84c9f49ad8239b9fb":96:"db8af7a0d548fc54d9457c73":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0225b73fe5fbbe52f838d873173959d8":"":"02a048764f48d9aed1147ee922395bbf":"9b46a57b06e156c877e94c089814493ead879397dab3dfcab2db349ef387efcd0cc339a7e79131a2c580188fc7429044a465b8329d74cd8f47272a4ed32582b1c5c7e3d32341ae902ea4923dc33df8062bc24bb51a11d2ecc82f464f615041387f9c82bd2135d4e240fe56fa8a68e6a9a417e6702430a434b14d70cf02db3181":96:"e2c2ce4022c49a95c9ac9026":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0225b73fe5fbbe52f838d873173959d8":"":"02a048764f48d9aed1147ee922395bbf":"9b46a57b06e156c877e94c089814493ead879397dab3dfcab2db349ef387efcd0cc339a7e79131a2c580188fc7429044a465b8329d74cd8f47272a4ed32582b1c5c7e3d32341ae902ea4923dc33df8062bc24bb51a11d2ecc82f464f615041387f9c82bd2135d4e240fe56fa8a68e6a9a417e6702430a434b14d70cf02db3181":96:"e2c2ce4022c49a95c9ac9026":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"89ca3771a0ef3287568b4ac036120198":"":"7e83d2ffa8af8c554cfd71a0db56ef5b":"1bd7a9d6262882bd12c62bd50942965b3cdcadf5e0fab2dc4d0daf0ee4b16e92c6e2464c0caa423cdce88e4d843490609716ec5e44c41672c656ac0e444d3622557ea8420c94deae3ad190ddaf859f6f8c23e4e2e32a46d28df23de4f99bd6c34f69e06eddfdfa5f263dbe8baf9d4296b2c543e4c4847271e7590374edf46234":96:"06b2bf62591dc7ec1b814705":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"89ca3771a0ef3287568b4ac036120198":"":"7e83d2ffa8af8c554cfd71a0db56ef5b":"1bd7a9d6262882bd12c62bd50942965b3cdcadf5e0fab2dc4d0daf0ee4b16e92c6e2464c0caa423cdce88e4d843490609716ec5e44c41672c656ac0e444d3622557ea8420c94deae3ad190ddaf859f6f8c23e4e2e32a46d28df23de4f99bd6c34f69e06eddfdfa5f263dbe8baf9d4296b2c543e4c4847271e7590374edf46234":96:"06b2bf62591dc7ec1b814705":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a41a297bd96e224942998fe2192934a1":"":"6827f2c5a0b7ecd6bbc696abb0adf556":"f32041abd8543415cbac423d945dda5378a16a7e94d9ab5dbd2d32eb1c5048cc7c8e4df3ca84ec725f18c34cfdeaa7595392aabfd66d9e2f37c1165369cd806cd9d2110def6f5fad4345e5a6e2326c9300199438fcc078cd9fcf4d76872cac77fc9a0a8ac7e4d63995078a9addecf798460ff5910861b76c71bccfb6b629d722":64:"49a4917eef61f78e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a41a297bd96e224942998fe2192934a1":"":"6827f2c5a0b7ecd6bbc696abb0adf556":"f32041abd8543415cbac423d945dda5378a16a7e94d9ab5dbd2d32eb1c5048cc7c8e4df3ca84ec725f18c34cfdeaa7595392aabfd66d9e2f37c1165369cd806cd9d2110def6f5fad4345e5a6e2326c9300199438fcc078cd9fcf4d76872cac77fc9a0a8ac7e4d63995078a9addecf798460ff5910861b76c71bccfb6b629d722":64:"49a4917eef61f78e":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a9372c058f42e0a1d019bdb528313919":"":"8d03f423230c8f00a5b6b712d426a2af":"cfef4e70fcc1821eeccf7c7b5eb3c0c3b5f72dc762426e0bd26242f8aa68c5b716ab97eded5e5720caccc1965da603d556d8214d5828f2cf276d95bf552d47313876796221f62ccb818a6d801088755d58cfb751bfed0d5a19718d4e0f94b850e0279b3a69295d1837cba958a6cc56e7594080b9e5b954a199fdc9e54ddc8583":64:"b82cd11cd3575c8d":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a9372c058f42e0a1d019bdb528313919":"":"8d03f423230c8f00a5b6b712d426a2af":"cfef4e70fcc1821eeccf7c7b5eb3c0c3b5f72dc762426e0bd26242f8aa68c5b716ab97eded5e5720caccc1965da603d556d8214d5828f2cf276d95bf552d47313876796221f62ccb818a6d801088755d58cfb751bfed0d5a19718d4e0f94b850e0279b3a69295d1837cba958a6cc56e7594080b9e5b954a199fdc9e54ddc8583":64:"b82cd11cd3575c8d":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6302b7338f8fa84195ad9abbacd89b4e":"":"e1bed5c53547cbc85f3411fbb43bb08b":"bcd329c076e8da2797d50dcdcf271cecf3ce12f3c136ed746edc722f907be6133276ee099038fdc5d73eec812739c7489d4bcc275f95451b44890416e3ffe5a1b6fa3986b84eee3adad774c6feaecb1f785053eeda2cfc18953b8547866d98918dbe0a6abc168ac7d77467a367f11c284924d9d186ef64ef0fd54eacd75156d2":64:"5222d092e9e8bd6c":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6302b7338f8fa84195ad9abbacd89b4e":"":"e1bed5c53547cbc85f3411fbb43bb08b":"bcd329c076e8da2797d50dcdcf271cecf3ce12f3c136ed746edc722f907be6133276ee099038fdc5d73eec812739c7489d4bcc275f95451b44890416e3ffe5a1b6fa3986b84eee3adad774c6feaecb1f785053eeda2cfc18953b8547866d98918dbe0a6abc168ac7d77467a367f11c284924d9d186ef64ef0fd54eacd75156d2":64:"5222d092e9e8bd6c":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"78b5c28d62e4b2097873a1180bd5a3a5":"":"c93902c2819ee494f0fc4b259ee65dd8":"e6b1192674a02083a6cf36d4ba93ba40a5331fadf63fd1eb2efa2ee9c0d8818472aaaf2b4705746011753f30f447c8f58dd34d29606daf57eadc172529837058cb78a378b19da8d63c321f550dfa256b5fd9f30e93d8f377443bfcd125f86a079a1765d2010be73d060f24eebae8d05e644688b2149bc39e18bd527bc066f2ba":32:"eae48137":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"78b5c28d62e4b2097873a1180bd5a3a5":"":"c93902c2819ee494f0fc4b259ee65dd8":"e6b1192674a02083a6cf36d4ba93ba40a5331fadf63fd1eb2efa2ee9c0d8818472aaaf2b4705746011753f30f447c8f58dd34d29606daf57eadc172529837058cb78a378b19da8d63c321f550dfa256b5fd9f30e93d8f377443bfcd125f86a079a1765d2010be73d060f24eebae8d05e644688b2149bc39e18bd527bc066f2ba":32:"eae48137":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d84130578070e036c9e3df5b5509473":"":"3b9b4950523a19c6866fd2b0cde541fd":"a764931e1b21a140c54a8619aacdb4358834987fb6e263cec525f888f9e9764c165aaa7db74f2c42273f912daeae6d72b232a872ac2c652d7cd3af3a5753f58331c11b6c866475697876dbc4c6ca0e52a00ba015ee3c3b7fb444c6e50a4b4b9bbe135fc0632d32a3f79f333d8f487771ed12522e664b9cf90e66da267f47a74d":32:"79987692":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d84130578070e036c9e3df5b5509473":"":"3b9b4950523a19c6866fd2b0cde541fd":"a764931e1b21a140c54a8619aacdb4358834987fb6e263cec525f888f9e9764c165aaa7db74f2c42273f912daeae6d72b232a872ac2c652d7cd3af3a5753f58331c11b6c866475697876dbc4c6ca0e52a00ba015ee3c3b7fb444c6e50a4b4b9bbe135fc0632d32a3f79f333d8f487771ed12522e664b9cf90e66da267f47a74d":32:"79987692":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"08428605ab4742a3e8a55354d4764620":"":"128f5f4a817e4af04113847a223adeb0":"464b484ed79d93a48e0f804e04df69d7ca10ad04ba7188d69e6549ab50503baaec67e0acba5537d1163c868fd3e350e9d0ae9123046bc76815c201a947aa4a7e4ed239ce889d4ff9c8d043877de06df5fc27cf67442b729b02e9c30287c0821ef9fa15d4cccbc53a95fa9ec3ed432ca960ebbf5a169ccada95a5bf4c7c968830":32:"3eb3e3a2":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"08428605ab4742a3e8a55354d4764620":"":"128f5f4a817e4af04113847a223adeb0":"464b484ed79d93a48e0f804e04df69d7ca10ad04ba7188d69e6549ab50503baaec67e0acba5537d1163c868fd3e350e9d0ae9123046bc76815c201a947aa4a7e4ed239ce889d4ff9c8d043877de06df5fc27cf67442b729b02e9c30287c0821ef9fa15d4cccbc53a95fa9ec3ed432ca960ebbf5a169ccada95a5bf4c7c968830":32:"3eb3e3a2":"":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0dd358bc3f992f26e81e3a2f3aa2d517":"87cc4fd75788c9d5cc83bae5d764dd249d178ab23224049795d4288b5ed9ea3f317068a39a7574b300c8544226e87b08e008fbe241d094545c211d56ac44437d41491a438272738968c8d371aa7787b5f606c8549a9d868d8a71380e9657d3c0337979feb01de5991fc1470dfc59eb02511efbbff3fcb479a862ba3844a25aaa":"d8c750bb443ee1a169dfe97cfe4d855b":"":128:"a81d13973baa22a751833d7d3f94b3b1":"77949b29f085bb3abb71a5386003811233056d3296eb093370f7777dadd306d93d59dcb9754d3857cf2758091ba661f845ef0582f6ae0e134328106f0d5d16b541cd74fdc756dc7b53f4f8a194daeea9369ebb1630c01ccb307b848e9527da20a39898d748fd59206f0b79d0ed946a8958033a45bd9ae673518b32606748eb65":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0dd358bc3f992f26e81e3a2f3aa2d517":"87cc4fd75788c9d5cc83bae5d764dd249d178ab23224049795d4288b5ed9ea3f317068a39a7574b300c8544226e87b08e008fbe241d094545c211d56ac44437d41491a438272738968c8d371aa7787b5f606c8549a9d868d8a71380e9657d3c0337979feb01de5991fc1470dfc59eb02511efbbff3fcb479a862ba3844a25aaa":"d8c750bb443ee1a169dfe97cfe4d855b":"":128:"a81d13973baa22a751833d7d3f94b3b1":"":"77949b29f085bb3abb71a5386003811233056d3296eb093370f7777dadd306d93d59dcb9754d3857cf2758091ba661f845ef0582f6ae0e134328106f0d5d16b541cd74fdc756dc7b53f4f8a194daeea9369ebb1630c01ccb307b848e9527da20a39898d748fd59206f0b79d0ed946a8958033a45bd9ae673518b32606748eb65":0 AES-GCM NIST Validation (AES-128,128,1024,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"43b5f18227e5c74288dbeff03801acd6":"f58d630f10cfca61d4644d4f6505bab629e8e8faf1673e64417f9b79e622966a7011cfb3ff74db5cebf09ad3f41643d4437d213204a6c8397e7d59b8a5b1970aed2b6bb5ea1933c72c351f6ba96c0b0b98188f6e373f5db6c5ebece911ec7a1848abd3ae335515c774e0027dab7d1c07d047d3b8825ff94222dbaf6f9ab597ee":"08ee12246cf7edb81da3d610f3ebd167":"":128:"82d83b2f7da218d1d1441a5b37bcb065":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"43b5f18227e5c74288dbeff03801acd6":"f58d630f10cfca61d4644d4f6505bab629e8e8faf1673e64417f9b79e622966a7011cfb3ff74db5cebf09ad3f41643d4437d213204a6c8397e7d59b8a5b1970aed2b6bb5ea1933c72c351f6ba96c0b0b98188f6e373f5db6c5ebece911ec7a1848abd3ae335515c774e0027dab7d1c07d047d3b8825ff94222dbaf6f9ab597ee":"08ee12246cf7edb81da3d610f3ebd167":"":128:"82d83b2f7da218d1d1441a5b37bcb065":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a433c612d7e1bdff881e4d63ba8b141":"ce10758332f423228b5e4ae31efda7677586934a1d8f05d9b7a0dc4e2010ec3eaacb71a527a5fff8e787d75ebd24ad163394c891b33477ed9e2a2d853c364cb1c5d0bc317fcaf4010817dbe5f1fd1037c701b291b3a66b164bc818bf5c00a4c210a1671faa574d74c7f3543f6c09aaf117e12e2eb3dae55edb1cc5b4086b617d":"8b670cf31f470f79a6c0b79e73863ca1":"":128:"8526fd25daf890e79946a205b698f287":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a433c612d7e1bdff881e4d63ba8b141":"ce10758332f423228b5e4ae31efda7677586934a1d8f05d9b7a0dc4e2010ec3eaacb71a527a5fff8e787d75ebd24ad163394c891b33477ed9e2a2d853c364cb1c5d0bc317fcaf4010817dbe5f1fd1037c701b291b3a66b164bc818bf5c00a4c210a1671faa574d74c7f3543f6c09aaf117e12e2eb3dae55edb1cc5b4086b617d":"8b670cf31f470f79a6c0b79e73863ca1":"":128:"8526fd25daf890e79946a205b698f287":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8e9d75c781d63b29f1816859f7a0e0a0":"a9f1883f58e4ef78377992101ab86da0dafcefa827904dd94dff6f6704b1e45517165a34c5555a55b04c6992fb6d0840a71bd262fe59815e5c7b80fe803b47d5ba44982a3f72cb42f591d8b62df38c9f56a5868af8f68242e3a15f97be8ef2399dbace1273f509623b6f9e4d27a97436aebf2d044e75f1c62694db77ceac05de":"748a3b486b62a164cedcf1bab9325add":"":120:"131e0e4ce46d768674a7bcacdcef9c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8e9d75c781d63b29f1816859f7a0e0a0":"a9f1883f58e4ef78377992101ab86da0dafcefa827904dd94dff6f6704b1e45517165a34c5555a55b04c6992fb6d0840a71bd262fe59815e5c7b80fe803b47d5ba44982a3f72cb42f591d8b62df38c9f56a5868af8f68242e3a15f97be8ef2399dbace1273f509623b6f9e4d27a97436aebf2d044e75f1c62694db77ceac05de":"748a3b486b62a164cedcf1bab9325add":"":120:"131e0e4ce46d768674a7bcacdcef9c":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe6b8553002c69396d9976bb48d30779":"786f4801b16de7a4931ab143b269c7acc68f1ed9b17a95e8929ccec7d53413059fd4267bedbf079d9d69e90314c1345bc9cb9132f1af69323157ddf7533ced42b4b7bd39004f14d326f5b03bc19084d231d93bcab328312d99b426c1e86e8e049d380bb492e2e32ad690af4cf86838d89a0dfdcbc30e8c9e9039e423a234e113":"595b17d0d76b83780235f5e0c92bd21f":"":120:"8879de07815a88877b0623de9be411":"b15dc7cd44adcb0783f30f592e5e03ccd47851725af9fe45bfc5b01ae35779b9a8b3f26fec468b188ec3cad40785c608d6bfd867b0ccf07a836ec20d2d9b8451636df153a32b637e7dcdbd606603d9e53f6e4c4cc8396286ce64b0ea638c10e5a567c0bc8e808080b71be51381e051336e60bf1663f6d2d7640a575e0752553b":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe6b8553002c69396d9976bb48d30779":"786f4801b16de7a4931ab143b269c7acc68f1ed9b17a95e8929ccec7d53413059fd4267bedbf079d9d69e90314c1345bc9cb9132f1af69323157ddf7533ced42b4b7bd39004f14d326f5b03bc19084d231d93bcab328312d99b426c1e86e8e049d380bb492e2e32ad690af4cf86838d89a0dfdcbc30e8c9e9039e423a234e113":"595b17d0d76b83780235f5e0c92bd21f":"":120:"8879de07815a88877b0623de9be411":"":"b15dc7cd44adcb0783f30f592e5e03ccd47851725af9fe45bfc5b01ae35779b9a8b3f26fec468b188ec3cad40785c608d6bfd867b0ccf07a836ec20d2d9b8451636df153a32b637e7dcdbd606603d9e53f6e4c4cc8396286ce64b0ea638c10e5a567c0bc8e808080b71be51381e051336e60bf1663f6d2d7640a575e0752553b":0 AES-GCM NIST Validation (AES-128,128,1024,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"14898c56009b459172fef9c17993b54f":"e7ba6ef722273238b975d551f95d3e77e9b75b24c547b86eafb457d409803bdf6e1443839d8604ee497020e1a3dbd687a819b17fdde0fcf240ce2129792792a58bfcd825773001ee959bf9ec8d228e27ce1cd93d7fb86769a3793361b6f82bf7daf284afc1ece657a1ee6346ea9294880755b9b623563ad2657ba2286488a2ef":"0862f8f87289988711a877d3231d44eb":"":120:"36938974301ae733760f83439437c4":"3fd56897a62743e0ab4a465bcc9777d5fd21ad2c9a59d7e4e1a60feccdc722b9820ec65cb47e1d1160d12ff2ea93abe11bc101b82514ead7d542007fee7b4e2dd6822849cd3e82d761ff7cf5ce4f40ad9fec54050a632a401451b426812cf03c2b16a8667a88bb3f7497e3308a91de6fd646d6a3562c92c24272411229a90802":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"14898c56009b459172fef9c17993b54f":"e7ba6ef722273238b975d551f95d3e77e9b75b24c547b86eafb457d409803bdf6e1443839d8604ee497020e1a3dbd687a819b17fdde0fcf240ce2129792792a58bfcd825773001ee959bf9ec8d228e27ce1cd93d7fb86769a3793361b6f82bf7daf284afc1ece657a1ee6346ea9294880755b9b623563ad2657ba2286488a2ef":"0862f8f87289988711a877d3231d44eb":"":120:"36938974301ae733760f83439437c4":"":"3fd56897a62743e0ab4a465bcc9777d5fd21ad2c9a59d7e4e1a60feccdc722b9820ec65cb47e1d1160d12ff2ea93abe11bc101b82514ead7d542007fee7b4e2dd6822849cd3e82d761ff7cf5ce4f40ad9fec54050a632a401451b426812cf03c2b16a8667a88bb3f7497e3308a91de6fd646d6a3562c92c24272411229a90802":0 AES-GCM NIST Validation (AES-128,128,1024,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe5253d4b071793b081ebc122cc2a5f8":"b57a0bd7714ae95e77fa9452e11a7ed4a2bec60f81ad6ddb956d4b1cb5dfc277dcb4034d501801b26733b5e08c710c3cfdccc1b208dc7a92cd7ebe166320582bcaff64cc943c36fbe7008f004e5db70c40de05fa68b0c9d4c16c8f976130f20702b99674cd2f4c93aeaeb3abca4b1114dbc3a4b33e1226ad801aa0e21f7cc49b":"49e82d86804e196421ec19ddc8541066":"":112:"e8b8ae34f842277fe92729e891e3":"c4a31c7ec820469f895d57579f987733337ec6547d78d17c44a18fab91f0322cfe05f23f9afaf019cf9531dec2d420f3591d334f40d78643fd957b91ab588a7e392447bd702652017ede7fb0d61d444a3b3cc4136e1d4df13d9532eb71bcf3ff0ae65e847e1c572a2f90632362bc424da2249b36a84be2c2bb216ae7708f745c":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe5253d4b071793b081ebc122cc2a5f8":"b57a0bd7714ae95e77fa9452e11a7ed4a2bec60f81ad6ddb956d4b1cb5dfc277dcb4034d501801b26733b5e08c710c3cfdccc1b208dc7a92cd7ebe166320582bcaff64cc943c36fbe7008f004e5db70c40de05fa68b0c9d4c16c8f976130f20702b99674cd2f4c93aeaeb3abca4b1114dbc3a4b33e1226ad801aa0e21f7cc49b":"49e82d86804e196421ec19ddc8541066":"":112:"e8b8ae34f842277fe92729e891e3":"":"c4a31c7ec820469f895d57579f987733337ec6547d78d17c44a18fab91f0322cfe05f23f9afaf019cf9531dec2d420f3591d334f40d78643fd957b91ab588a7e392447bd702652017ede7fb0d61d444a3b3cc4136e1d4df13d9532eb71bcf3ff0ae65e847e1c572a2f90632362bc424da2249b36a84be2c2bb216ae7708f745c":0 AES-GCM NIST Validation (AES-128,128,1024,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b3502d6f0d172246e16503cdf5793296":"09268b8046f1558794e35cdc4945b94227a176dd8cb77f92f883542b1c4be698c379541fd1d557c2a07c7206afdd49506d6a1559123de1783c7a60006df06d87f9119fb105e9b278eb93f81fd316b6fdc38ef702a2b9feaa878a0d1ea999db4c593438f32e0f849f3adabf277a161afb5c1c3460039156eec78944d5666c2563":"6ce994689ff72f9df62f386a187c1a13":"":112:"21cdf44ff4993eb54b55d58e5a8f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b3502d6f0d172246e16503cdf5793296":"09268b8046f1558794e35cdc4945b94227a176dd8cb77f92f883542b1c4be698c379541fd1d557c2a07c7206afdd49506d6a1559123de1783c7a60006df06d87f9119fb105e9b278eb93f81fd316b6fdc38ef702a2b9feaa878a0d1ea999db4c593438f32e0f849f3adabf277a161afb5c1c3460039156eec78944d5666c2563":"6ce994689ff72f9df62f386a187c1a13":"":112:"21cdf44ff4993eb54b55d58e5a8f":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5fb33dd73db309b9dfd3aee605cd94bf":"f4e011f8c99038c46854b427475f23488077ebf051c4b705a1adfdd493a0a10af7a7e9453965b94f52f61ae62ce9243a82a2dbf9c5a285db3fe34ed34ed08b5926f34c48171195f7062d02a6e6e795322a0475017371cb8f645cdcac94afc66dc43e7583bdf1c25790f4235076a53de6c64f3bc5004e5a9ce4783fbf639fad97":"3f6486f9e9e645292e0e425bac232268":"":112:"7ee5e0e2082b18d09abf141f902e":"0503cb531f1c967dae24f16dd651d544988a732020134896a0f109222e8639bf29ff69877c6ef4ac3df1b260842f909384e3d4409b99a47112681c4b17430041ca447a903a6c1b138f0efbb3b850d8290fceac9723a32edbf8e2d6e8143b1cbc7bf2d28d1b6c7f341a69918758cc82bbab5d898fa0f572d4ceaa11234cb511ec":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5fb33dd73db309b9dfd3aee605cd94bf":"f4e011f8c99038c46854b427475f23488077ebf051c4b705a1adfdd493a0a10af7a7e9453965b94f52f61ae62ce9243a82a2dbf9c5a285db3fe34ed34ed08b5926f34c48171195f7062d02a6e6e795322a0475017371cb8f645cdcac94afc66dc43e7583bdf1c25790f4235076a53de6c64f3bc5004e5a9ce4783fbf639fad97":"3f6486f9e9e645292e0e425bac232268":"":112:"7ee5e0e2082b18d09abf141f902e":"":"0503cb531f1c967dae24f16dd651d544988a732020134896a0f109222e8639bf29ff69877c6ef4ac3df1b260842f909384e3d4409b99a47112681c4b17430041ca447a903a6c1b138f0efbb3b850d8290fceac9723a32edbf8e2d6e8143b1cbc7bf2d28d1b6c7f341a69918758cc82bbab5d898fa0f572d4ceaa11234cb511ec":0 AES-GCM NIST Validation (AES-128,128,1024,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a958fe3b520081b638d9e4c7d5da7ac7":"dfa9487378c7d8af9c8dbd9e533cd81503d9e4e7dab43133bad11fd3050a53a833df9cc3208af1a86110567d311d5fc54b0d627de433c381b10e113898203ac5225140f951cdb64c6494592b6453f9b6f952ec5ece732fb46c09a324f26b27cdad63588006bb5c6c00b9aa10d5d3b2f9eaab69beeddd6f93966654f964260018":"c396109e96afde6f685d3c38aa3c2fae":"":104:"06ca91004be43cf46ed4599e23":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a958fe3b520081b638d9e4c7d5da7ac7":"dfa9487378c7d8af9c8dbd9e533cd81503d9e4e7dab43133bad11fd3050a53a833df9cc3208af1a86110567d311d5fc54b0d627de433c381b10e113898203ac5225140f951cdb64c6494592b6453f9b6f952ec5ece732fb46c09a324f26b27cdad63588006bb5c6c00b9aa10d5d3b2f9eaab69beeddd6f93966654f964260018":"c396109e96afde6f685d3c38aa3c2fae":"":104:"06ca91004be43cf46ed4599e23":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ec319fb143eac8215b51541daec268f2":"d298d988e74927736237eb8ab09d7a86b854fa2fd1f7f3be83b417ac10aa9291f4af5b3fbaf75a296ac32369ad57ded3984b84711953e477de3035ba430a30ffb84c941936e6c8d2cae8d80159876f87dd682747f2dccc36d7c32ab227032b8ac70b313fa4202ea236e3ec4d9e4d8b48cf3b90b378edc5b1dbeec929549344f8":"8a4684f42a1775b03806574f401cff78":"":104:"e91acb1bfda191630b560debc9":"27ce4a622959930f4059f247d29d1438257093cc973bf1bae4e0515da88b9a7e21ec59c7e4d062035cdf88b91254d856b11c8c1944865fa12922227ded3eecccaa36341ecf5405c708e9ea173f1e6cdf090499d3bb079910771080814607a1efe62ec6835dc0333d19dd39dd9ea9f31cd3632128536149a122050bb9365b521d":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ec319fb143eac8215b51541daec268f2":"d298d988e74927736237eb8ab09d7a86b854fa2fd1f7f3be83b417ac10aa9291f4af5b3fbaf75a296ac32369ad57ded3984b84711953e477de3035ba430a30ffb84c941936e6c8d2cae8d80159876f87dd682747f2dccc36d7c32ab227032b8ac70b313fa4202ea236e3ec4d9e4d8b48cf3b90b378edc5b1dbeec929549344f8":"8a4684f42a1775b03806574f401cff78":"":104:"e91acb1bfda191630b560debc9":"":"27ce4a622959930f4059f247d29d1438257093cc973bf1bae4e0515da88b9a7e21ec59c7e4d062035cdf88b91254d856b11c8c1944865fa12922227ded3eecccaa36341ecf5405c708e9ea173f1e6cdf090499d3bb079910771080814607a1efe62ec6835dc0333d19dd39dd9ea9f31cd3632128536149a122050bb9365b521d":0 AES-GCM NIST Validation (AES-128,128,1024,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"14a3e69f351ac39b4297749a90c1365c":"051224f7b208549dcfda5f9d56ce5f0a072ef1f23f3810c693516c92622be6ed4d7a9e0f9450980ba490b2e9e3468ea7eef10bc9ebd673d91f32b748c1bf2c50cc4ebb59fc409c6d780bba00700d563ce1dc9927a6c860095a42ed053f3d640debfbfa7a4e6d5de234af19755000d95e7f414f1f78285ee165410c020038286b":"eb1c6c04437aa5a32bcc208bb3c01724":"":104:"e418815960559aefee8e0c3831":"797310a6ed9ce47cdc25f7f88f5dbbf6f8f4837701704d7afced250585922744598d6f95ba2eecf86e030cc5ee71b328fc1c4f2d4df945d1b91a2803d6ae8eba6881be5fe0f298dd0c0279e12720ede60b9e857ccca5abe9b4d7ee7f25108beebbfe33f05c0d9903bf613c2e7ed6a87b71b5e386d81b3ae53efd01055bbcccc2":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"14a3e69f351ac39b4297749a90c1365c":"051224f7b208549dcfda5f9d56ce5f0a072ef1f23f3810c693516c92622be6ed4d7a9e0f9450980ba490b2e9e3468ea7eef10bc9ebd673d91f32b748c1bf2c50cc4ebb59fc409c6d780bba00700d563ce1dc9927a6c860095a42ed053f3d640debfbfa7a4e6d5de234af19755000d95e7f414f1f78285ee165410c020038286b":"eb1c6c04437aa5a32bcc208bb3c01724":"":104:"e418815960559aefee8e0c3831":"":"797310a6ed9ce47cdc25f7f88f5dbbf6f8f4837701704d7afced250585922744598d6f95ba2eecf86e030cc5ee71b328fc1c4f2d4df945d1b91a2803d6ae8eba6881be5fe0f298dd0c0279e12720ede60b9e857ccca5abe9b4d7ee7f25108beebbfe33f05c0d9903bf613c2e7ed6a87b71b5e386d81b3ae53efd01055bbcccc2":0 AES-GCM NIST Validation (AES-128,128,1024,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c34827771fc3918d1cee09ba9401b832":"ce79701b661066e53191c9acdaf677ad41622314898d7216e3f113e2e6e215d26d8bd139827f06ab3ea5c4105694e87db1dd6cec10e1f86a8744d4c541f08e40319e22ab42fc1a6c89edfd486b6f142c6bbbf84a73912e0b2e55b79db306ccabf839855afdd889e52ae981520c89e7dc29bb2adb1906cca8c93fcb21290a095b":"2379bbd39a1c22bc93b9b9cc45f3840b":"":96:"26e1f6cf0d9e0f36dfd669eb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c34827771fc3918d1cee09ba9401b832":"ce79701b661066e53191c9acdaf677ad41622314898d7216e3f113e2e6e215d26d8bd139827f06ab3ea5c4105694e87db1dd6cec10e1f86a8744d4c541f08e40319e22ab42fc1a6c89edfd486b6f142c6bbbf84a73912e0b2e55b79db306ccabf839855afdd889e52ae981520c89e7dc29bb2adb1906cca8c93fcb21290a095b":"2379bbd39a1c22bc93b9b9cc45f3840b":"":96:"26e1f6cf0d9e0f36dfd669eb":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b1f9bd2006ec550b7b9913d383200b5d":"6d9fc8f586d50d6e0128172ae147844e80136905d3a297497a9566ca7c7445029028f14c9950acee92a5c12a9150f5e024e01c7505dd83937542b0b1288de9c292ae8ad918a09b2edf8493540b74c73d2794f2eb6eed18eba520ddea9567462c83330f33d7892fcde0b10c73a4e26ab1bef037cec7e0190b95188e9a752fee6f":"ca28fa6b64bb3b32ef7d211f1c8be759":"":96:"c87aac7ad0e85dbb103c0733":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b1f9bd2006ec550b7b9913d383200b5d":"6d9fc8f586d50d6e0128172ae147844e80136905d3a297497a9566ca7c7445029028f14c9950acee92a5c12a9150f5e024e01c7505dd83937542b0b1288de9c292ae8ad918a09b2edf8493540b74c73d2794f2eb6eed18eba520ddea9567462c83330f33d7892fcde0b10c73a4e26ab1bef037cec7e0190b95188e9a752fee6f":"ca28fa6b64bb3b32ef7d211f1c8be759":"":96:"c87aac7ad0e85dbb103c0733":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8b2cef1a92aa0af2b00fb2a99855d5bc":"fd09525ef3c65ab5823e1b6c36b4a9449a3975c5d3a9e7e33c61fb32edcbb8e8c915b6202e3fbce87d73cc3b66d83d9ea7e1e353cc7468f08626932cf0235563e2a28953ee5a0afadb1c3cb513b1f1fc9a8a6cf326174b877448672f7731dd6430a51619da1a169ab302da5af5b38802f8bbf5890b5d9b45deda799679501dc4":"08d87b7acee87d884667f6b1e32e34d0":"":96:"3bd7685318010b0c5fe3308b":"583e64631c218549923e8ad33b728d07f23b0f19d2aff1ad7e20d564c591db0e117caa8f21e3f3345e3d84f0ccbb27274cddf9274410fc342cb2a5d4aea4e925d0dd5350389ee0dea23a842ff3f5c1198374a96f41e055f999cfbc2f47ceaa883da8eb6ff729f583eff1f91bd3f3254d4e81e60d9993b3455e67f405708e4422":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8b2cef1a92aa0af2b00fb2a99855d5bc":"fd09525ef3c65ab5823e1b6c36b4a9449a3975c5d3a9e7e33c61fb32edcbb8e8c915b6202e3fbce87d73cc3b66d83d9ea7e1e353cc7468f08626932cf0235563e2a28953ee5a0afadb1c3cb513b1f1fc9a8a6cf326174b877448672f7731dd6430a51619da1a169ab302da5af5b38802f8bbf5890b5d9b45deda799679501dc4":"08d87b7acee87d884667f6b1e32e34d0":"":96:"3bd7685318010b0c5fe3308b":"":"583e64631c218549923e8ad33b728d07f23b0f19d2aff1ad7e20d564c591db0e117caa8f21e3f3345e3d84f0ccbb27274cddf9274410fc342cb2a5d4aea4e925d0dd5350389ee0dea23a842ff3f5c1198374a96f41e055f999cfbc2f47ceaa883da8eb6ff729f583eff1f91bd3f3254d4e81e60d9993b3455e67f405708e4422":0 AES-GCM NIST Validation (AES-128,128,1024,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"175c306f8644b0c4b894ae3d0971505e":"fbe7ced7048f83e3a075661c4924eb77da1b4d6019d504afb942d728b31fd3b17557bd101c08453540a5e28d3505aeb8801a448afac2d9f68d20c0a31c7ef22bd95438851789eef1bebe8d96ac29607025b7e1366fecd3690ba90c315528dc435d9a786d36a16808d4b3e2c7c5175a1279792f1daccf51b2f91ac839465bb89a":"9860268ca2e10974f3726a0e5b9b310f":"":64:"f809105e5fc5b13c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"175c306f8644b0c4b894ae3d0971505e":"fbe7ced7048f83e3a075661c4924eb77da1b4d6019d504afb942d728b31fd3b17557bd101c08453540a5e28d3505aeb8801a448afac2d9f68d20c0a31c7ef22bd95438851789eef1bebe8d96ac29607025b7e1366fecd3690ba90c315528dc435d9a786d36a16808d4b3e2c7c5175a1279792f1daccf51b2f91ac839465bb89a":"9860268ca2e10974f3726a0e5b9b310f":"":64:"f809105e5fc5b13c":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"08c0edcfe342a676ccdc04bdf854b4b0":"1fc8ef8480c32d908b4bcbfa7074a38e915c20ed7a1c608422087e89442d7c5af6fe9c9a716c55793248062d8e6c6e8e904e2804da3a43701e4c78ecdb67e0b25308afc6d9b463356439cd095cff1bdf0fd91ab301c79fd257046cba79a5d5cd99f2502ad968420e4d499110106072dc687f434db0955c756a174a9024373c48":"4a7b70753930fe659f8cc38e5833f0c7":"":64:"9ab1e2f3c4606376":"983458c3f198bc685d98cea2b23cf71f0eb126e90937cab3492a46d9dc85d76bbb8035c6e209c34b2a7187df007faabe9f3064dc63f1cb15bf5a10655e39b94732e0c6583d56327e9701344e048887a81b256181cdfa9ec42ebc990875e4852240ddcb3cbc4ea4e6307075fd314f7190f3553267bd68b19e954e310ec3f8dbab":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"08c0edcfe342a676ccdc04bdf854b4b0":"1fc8ef8480c32d908b4bcbfa7074a38e915c20ed7a1c608422087e89442d7c5af6fe9c9a716c55793248062d8e6c6e8e904e2804da3a43701e4c78ecdb67e0b25308afc6d9b463356439cd095cff1bdf0fd91ab301c79fd257046cba79a5d5cd99f2502ad968420e4d499110106072dc687f434db0955c756a174a9024373c48":"4a7b70753930fe659f8cc38e5833f0c7":"":64:"9ab1e2f3c4606376":"":"983458c3f198bc685d98cea2b23cf71f0eb126e90937cab3492a46d9dc85d76bbb8035c6e209c34b2a7187df007faabe9f3064dc63f1cb15bf5a10655e39b94732e0c6583d56327e9701344e048887a81b256181cdfa9ec42ebc990875e4852240ddcb3cbc4ea4e6307075fd314f7190f3553267bd68b19e954e310ec3f8dbab":0 AES-GCM NIST Validation (AES-128,128,1024,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"241067a0301edf0f825d793e03383ea1":"6984bb9830843529fad7f5e7760db89c778d62c764fcd2136ffb35d7d869f62f61d7fef64f65b7136398c1b5a792844528a18a13fba40b186ae08d1153b538007fc460684e2add8a9ed8dd82acbb8d357240daaa0c4deb979e54715545db03fe22e6d3906e89bdc81d535dae53075a58f65099434bfeed943dbc6024a92aa06a":"a30994261f48a66bb6c1fc3d69659228":"":64:"36c3b4a732ba75ae":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"241067a0301edf0f825d793e03383ea1":"6984bb9830843529fad7f5e7760db89c778d62c764fcd2136ffb35d7d869f62f61d7fef64f65b7136398c1b5a792844528a18a13fba40b186ae08d1153b538007fc460684e2add8a9ed8dd82acbb8d357240daaa0c4deb979e54715545db03fe22e6d3906e89bdc81d535dae53075a58f65099434bfeed943dbc6024a92aa06a":"a30994261f48a66bb6c1fc3d69659228":"":64:"36c3b4a732ba75ae":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"03cccb5357bd2848332d1696f2ff90cb":"5e2f18cbc1e773df9f28be08abb3d0b64d545c870c5778ac8bb396bef857d2ac1342ae1afb3bf5d64e667bf837458415d48396204fe560e3b635eb10e560e437f2d0396952998fd36e116cd047c1d7f6fc9901094454d24165c557a8816e0d0a8e0ce41e040ba6f26ca567c74fc47d9738b8cd8dae5dfc831c65bc1ba9603a07":"e0754022dfb1f813ccaf321558790806":"":32:"c75f0246":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"03cccb5357bd2848332d1696f2ff90cb":"5e2f18cbc1e773df9f28be08abb3d0b64d545c870c5778ac8bb396bef857d2ac1342ae1afb3bf5d64e667bf837458415d48396204fe560e3b635eb10e560e437f2d0396952998fd36e116cd047c1d7f6fc9901094454d24165c557a8816e0d0a8e0ce41e040ba6f26ca567c74fc47d9738b8cd8dae5dfc831c65bc1ba9603a07":"e0754022dfb1f813ccaf321558790806":"":32:"c75f0246":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4e5e53c84a05d5a5348bac7b2611cf62":"489c00c05dec06f282924c680f621ab99ac87f7d33ebbb4ca0eee187ec177d30d2b4afb4ee9f0dc019cf1a4da16d84b7f5f5c7fce72a32461db115b5a5a433024fd5ed3d47161836bb057a0189ed768f95e45fa967d0cc512fc91b555808c4033c945e8f2f7d36428dcb61f697e791b74e5c79b2bcb9cb81bec70d8119cd8d76":"47e40543b7d16bc9122c40b106d31d43":"":32:"81eec75d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4e5e53c84a05d5a5348bac7b2611cf62":"489c00c05dec06f282924c680f621ab99ac87f7d33ebbb4ca0eee187ec177d30d2b4afb4ee9f0dc019cf1a4da16d84b7f5f5c7fce72a32461db115b5a5a433024fd5ed3d47161836bb057a0189ed768f95e45fa967d0cc512fc91b555808c4033c945e8f2f7d36428dcb61f697e791b74e5c79b2bcb9cb81bec70d8119cd8d76":"47e40543b7d16bc9122c40b106d31d43":"":32:"81eec75d":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c94008bf377f90b7a1c0d2ea38f730c":"7b3d619d115de9970b2df4e1f25194940b3f3da04c653231e8e6946de9dc08ae5ba37e2a93c232e1f9445f31c01333045f22bd832e3b5f9833f37070fafb0ef1c44cc5637058ab64d9e07bb81b32852d4cf749a3ddbfdb494f8de8bb4e31f46033f8a16bc22e2595d023845505ea5db74dd69ab4ca940078b09efb4ff19bdb66":"abfe92931a8411a39986b74560a38211":"":32:"47d42e78":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c94008bf377f90b7a1c0d2ea38f730c":"7b3d619d115de9970b2df4e1f25194940b3f3da04c653231e8e6946de9dc08ae5ba37e2a93c232e1f9445f31c01333045f22bd832e3b5f9833f37070fafb0ef1c44cc5637058ab64d9e07bb81b32852d4cf749a3ddbfdb494f8de8bb4e31f46033f8a16bc22e2595d023845505ea5db74dd69ab4ca940078b09efb4ff19bdb66":"abfe92931a8411a39986b74560a38211":"":32:"47d42e78":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"69eedf3777e594c30e94e9c5e2bce467":"5114e9983c96fecec3f7304ca42f52aa16cb7c6aadfb62ad537c93a3188835ca0703dad34c73cf96435b668b68a7a1d056931959316e8d3ab956bf64c4e07479c7767f9d488b0c0c351333ccf400b7e0be19a0fd173e3f2a1ae313f27e516952260fd2da9ab9daca478ebb93cd07d0b7503b32364d8e308d904d966c58f226bb":"a3330638a809ba358d6c098e4342b81e":"df4e3f2b47cf0e8590228fcf9913fb8a5eb9751bba318fd2d57be68c7e788e04fabf303699b99f26313d1c4956105cd2817aad21b91c28f3b9251e9c0b354490fa5abfcea0065aa3cc9b96772eb8af06a1a9054bf12d3ae698dfb01a13f989f8b8a4bb61686cf3adf58f05873a24d403a62a092290c2481e4159588fea6b9a09":128:"5de3068e1e20eed469265000077b1db9":"208e6321238bf5c6e2ef55a4b8f531cbbfb0d77374fe32df6dd663486cf79beeed39bb6910c3c78dd0cc30707a0a12b226b2d06024db25dcd8a4e620f009cafa5242121e864c7f3f4360aaf1e9d4e548d99615156f156008418c1c41ff2bbc007cecf8f209c73203e6df89b32871de637b3d6af2e277d146ae03f3404d387b77":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"69eedf3777e594c30e94e9c5e2bce467":"5114e9983c96fecec3f7304ca42f52aa16cb7c6aadfb62ad537c93a3188835ca0703dad34c73cf96435b668b68a7a1d056931959316e8d3ab956bf64c4e07479c7767f9d488b0c0c351333ccf400b7e0be19a0fd173e3f2a1ae313f27e516952260fd2da9ab9daca478ebb93cd07d0b7503b32364d8e308d904d966c58f226bb":"a3330638a809ba358d6c098e4342b81e":"df4e3f2b47cf0e8590228fcf9913fb8a5eb9751bba318fd2d57be68c7e788e04fabf303699b99f26313d1c4956105cd2817aad21b91c28f3b9251e9c0b354490fa5abfcea0065aa3cc9b96772eb8af06a1a9054bf12d3ae698dfb01a13f989f8b8a4bb61686cf3adf58f05873a24d403a62a092290c2481e4159588fea6b9a09":128:"5de3068e1e20eed469265000077b1db9":"":"208e6321238bf5c6e2ef55a4b8f531cbbfb0d77374fe32df6dd663486cf79beeed39bb6910c3c78dd0cc30707a0a12b226b2d06024db25dcd8a4e620f009cafa5242121e864c7f3f4360aaf1e9d4e548d99615156f156008418c1c41ff2bbc007cecf8f209c73203e6df89b32871de637b3d6af2e277d146ae03f3404d387b77":0 AES-GCM NIST Validation (AES-128,128,1024,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"45cc35311eedf0ba093bf901931a7036":"5dc8d7525eaad035c19714ae1b1e538cb66a4089027245351e0ad9297410fb3a0c1155407c10a8bb95a9ca624a9c9925dac003ee78926c6e90ff4ccdba10e8a78bda1c4478162a0e302de5ff05fb0f94c89c3c7429fb94828bdcd97d21333c2ee72963ee6f056ce272b8bab007e653a42b01d1d2041ba627f169c8c0d32e6dae":"fed5084de3c348f5a0adf4c2fd4e848a":"6e210914e4aed188d576f5ad7fc7e4cf7dd8d82f34ea3bcbdb7267cfd9045f806978dbff3460c4e8ff8c4edb6ad2edba405a8d915729d89aab2116b36a70b54f5920a97f5a571977e0329eda6c696749be940eabfc6d8b0bbd6fbdb87657b3a7695da9f5d3a7384257f20e0becd8512d3705cc246ee6ca1e610921cf92603d79":128:"266a895fc21da5176b44b446d7d1921d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"45cc35311eedf0ba093bf901931a7036":"5dc8d7525eaad035c19714ae1b1e538cb66a4089027245351e0ad9297410fb3a0c1155407c10a8bb95a9ca624a9c9925dac003ee78926c6e90ff4ccdba10e8a78bda1c4478162a0e302de5ff05fb0f94c89c3c7429fb94828bdcd97d21333c2ee72963ee6f056ce272b8bab007e653a42b01d1d2041ba627f169c8c0d32e6dae":"fed5084de3c348f5a0adf4c2fd4e848a":"6e210914e4aed188d576f5ad7fc7e4cf7dd8d82f34ea3bcbdb7267cfd9045f806978dbff3460c4e8ff8c4edb6ad2edba405a8d915729d89aab2116b36a70b54f5920a97f5a571977e0329eda6c696749be940eabfc6d8b0bbd6fbdb87657b3a7695da9f5d3a7384257f20e0becd8512d3705cc246ee6ca1e610921cf92603d79":128:"266a895fc21da5176b44b446d7d1921d":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9edb5231ca4a136b4df4ae22b8588f9f":"493df801c57f8bb591955712d92d3fc34518f0599fec8533b2b4473364e1df4f560c12444cf50eeb584676b7e955c742189de6b50b8e012dfa6642f3679fb02bc6d8e08d1db88c8ae955a7946263e06494e17f8df246b672942661e5563302252208f2e00a0d77068a020e26082c291a75a06f63c41e2830292a418b2b5fd9dd":"c342e9bdabe7be922b2695f5894e032c":"a45c7f8032ac5144deef8d5380f033aea2786b0592720a867f4831eaccc6b85d3fd568aedc6e472e017455b0b5b30cf7a08ea43ca587f35e1646ecd9b4dc774d11e350c82c65692be1e9541cbd72a283bdcf93dc7115545f373747b4f8d5915ed0c42fbeefd3e9bd86003d65efc2361fde5b874ddabcf8265e6b884615102eff":128:"5ed3ea75c8172fa0e8755fef7b4c90f1":"56696e501fac1e8d5b83ef911ed11337d5d51ff5342a82993dd5340bb9632e6606eef68ec5fe8cec6b34ebbc596c279e6cbc9221c4cde933f6d93ae014e3c4ca49593f35eaa638606d059519bac3a3373519e6184e7227d2aa62170c36479fe239cb698bfca863925a4c9fb1338685a55a6dfd3bd9c52d8ae12be8551fce6e1a":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9edb5231ca4a136b4df4ae22b8588f9f":"493df801c57f8bb591955712d92d3fc34518f0599fec8533b2b4473364e1df4f560c12444cf50eeb584676b7e955c742189de6b50b8e012dfa6642f3679fb02bc6d8e08d1db88c8ae955a7946263e06494e17f8df246b672942661e5563302252208f2e00a0d77068a020e26082c291a75a06f63c41e2830292a418b2b5fd9dd":"c342e9bdabe7be922b2695f5894e032c":"a45c7f8032ac5144deef8d5380f033aea2786b0592720a867f4831eaccc6b85d3fd568aedc6e472e017455b0b5b30cf7a08ea43ca587f35e1646ecd9b4dc774d11e350c82c65692be1e9541cbd72a283bdcf93dc7115545f373747b4f8d5915ed0c42fbeefd3e9bd86003d65efc2361fde5b874ddabcf8265e6b884615102eff":128:"5ed3ea75c8172fa0e8755fef7b4c90f1":"":"56696e501fac1e8d5b83ef911ed11337d5d51ff5342a82993dd5340bb9632e6606eef68ec5fe8cec6b34ebbc596c279e6cbc9221c4cde933f6d93ae014e3c4ca49593f35eaa638606d059519bac3a3373519e6184e7227d2aa62170c36479fe239cb698bfca863925a4c9fb1338685a55a6dfd3bd9c52d8ae12be8551fce6e1a":0 AES-GCM NIST Validation (AES-128,128,1024,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d5fdcb8f5225090e63fae9b68f92c7cb":"d39b9cba95e3a3aab9bc1d03ff475c04faeb5b7f0510777f39e5a05756606eb7ddd154aac035d9ddaf3535629821dd8f014dedd52cd184f52fc706e3c89a3a271398c9125d9a624dafb297a56022ca2ea331ea7359ab5e65f8e14814788e64e0a886a9b1a0144bf268fdcf9d94c3d10a0452f40111da9df108252e9039eacea3":"581c818282a0905df5ffff652e5604e9":"f1ae6cd7b07f261105f555cf812a1d5bf8dd9aac07666318acffa11abb77d0238156663acbf7543825b45c6e9cddb481a40995ecd78bb5f4cba5df7c7efb00fc19c7f45e94d37697aca8ef368b99165393b6107f900194c797cd3289cb097eb5915f2abfd6aa52dd1effffdde448e30075a1c053246db54b0ec16eadca1c0071":120:"827e66b5b70dce56215cfb86c9a642":"cec11a12e47fd443f878e8e9fe23c65f29dd2d53cec59b799bcb0928de8e2f92fe85c27cec5c842ef30967b919accafe0c0d731b57f0bb5685d90a3061cb473e50e8aeca1346d1f47f7db06941f83f21ba5976d97c28cab547d8c1f38387a04b8a0b212da55b75fbaf9562eeeabd78eadcbab66457f0cd4e0d28133a64cb063f":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d5fdcb8f5225090e63fae9b68f92c7cb":"d39b9cba95e3a3aab9bc1d03ff475c04faeb5b7f0510777f39e5a05756606eb7ddd154aac035d9ddaf3535629821dd8f014dedd52cd184f52fc706e3c89a3a271398c9125d9a624dafb297a56022ca2ea331ea7359ab5e65f8e14814788e64e0a886a9b1a0144bf268fdcf9d94c3d10a0452f40111da9df108252e9039eacea3":"581c818282a0905df5ffff652e5604e9":"f1ae6cd7b07f261105f555cf812a1d5bf8dd9aac07666318acffa11abb77d0238156663acbf7543825b45c6e9cddb481a40995ecd78bb5f4cba5df7c7efb00fc19c7f45e94d37697aca8ef368b99165393b6107f900194c797cd3289cb097eb5915f2abfd6aa52dd1effffdde448e30075a1c053246db54b0ec16eadca1c0071":120:"827e66b5b70dce56215cfb86c9a642":"":"cec11a12e47fd443f878e8e9fe23c65f29dd2d53cec59b799bcb0928de8e2f92fe85c27cec5c842ef30967b919accafe0c0d731b57f0bb5685d90a3061cb473e50e8aeca1346d1f47f7db06941f83f21ba5976d97c28cab547d8c1f38387a04b8a0b212da55b75fbaf9562eeeabd78eadcbab66457f0cd4e0d28133a64cb063f":0 AES-GCM NIST Validation (AES-128,128,1024,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"036198cd3a3ab9319684d0f811cf2992":"6b95b9e82a695fb7b466ce3adb536f525d8314f95eada39efb49baf121093ce7d5439f0d8223e03530b85accd388a70650ca9f7e63eb32afecb7b1916ed9b762128cc641caf3e08e027c3d88481d653b6b15172e977dfb9b3f88465911aee162501cbf8501ce2b66ee151bbfdc23225f638f18750c239d62471663e5ee2a5856":"47dffc6b3b80ffef4b943bde87b9cf3c":"ec4de476cd337f564a3facb544d0ff31cd89af4c3d9a28543e45156189f8eff8f804494dda83a1fb2c30ce858884a01ec63db59268452b1eea0f0d48280bb7340eaacc84509469dd94d303774d053d7ab4fb5f6c26581efeb19165f8cb09d58ec314d09ab8356731e87fd081f661e7b2d1a7c3aa4af5448a12b742e7b210b0b0":120:"6cf68a374bea08a977ec8a04b92e8b":"5c2f7c408167be3d266ff634e1993fe291aef7efae245fa0b6b5bde886a810c866ae6a078286684d1b66116e636e285f03646e09f3c4ed7b184e7c171ba84f3bfd9500c6f35964a404892b4cdcdd3f697fc5b01934a86019810987a9fea7efca016049873f1072f62df3c17f57ea1d88ccd8757f7e3c5d96e8a18d5366a39ea9":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"036198cd3a3ab9319684d0f811cf2992":"6b95b9e82a695fb7b466ce3adb536f525d8314f95eada39efb49baf121093ce7d5439f0d8223e03530b85accd388a70650ca9f7e63eb32afecb7b1916ed9b762128cc641caf3e08e027c3d88481d653b6b15172e977dfb9b3f88465911aee162501cbf8501ce2b66ee151bbfdc23225f638f18750c239d62471663e5ee2a5856":"47dffc6b3b80ffef4b943bde87b9cf3c":"ec4de476cd337f564a3facb544d0ff31cd89af4c3d9a28543e45156189f8eff8f804494dda83a1fb2c30ce858884a01ec63db59268452b1eea0f0d48280bb7340eaacc84509469dd94d303774d053d7ab4fb5f6c26581efeb19165f8cb09d58ec314d09ab8356731e87fd081f661e7b2d1a7c3aa4af5448a12b742e7b210b0b0":120:"6cf68a374bea08a977ec8a04b92e8b":"":"5c2f7c408167be3d266ff634e1993fe291aef7efae245fa0b6b5bde886a810c866ae6a078286684d1b66116e636e285f03646e09f3c4ed7b184e7c171ba84f3bfd9500c6f35964a404892b4cdcdd3f697fc5b01934a86019810987a9fea7efca016049873f1072f62df3c17f57ea1d88ccd8757f7e3c5d96e8a18d5366a39ea9":0 AES-GCM NIST Validation (AES-128,128,1024,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c9fbbff8f25f951ba874dfc5ff38584e":"ca401071396da00376add467490abc6e6a7d8a85852026979f7013a09cf689113c8d833560cd6c5b8fdaa8fdd818e773ac13954839a0a2c91efeaf4e0e14de43308419a8b86fa2ae600a88a6bd39dfaabc16a3c7c1b77a5c2aab7f7caceb2f8595324125efbb7c96ba16c47d0bd10568b24bf445d72d683268466e68e46df500":"1c1fc752673be6d4ff4cc749fc11e0fe":"abfde0b60acfe265b62ed68ebebc1f5f725f155c4b8a8aeec8d704701c51ff7817060c1b0ce6b80d6efc9836c9ea2bc022ec67db4cd34e945e3a1b153fd2e0f7ac84bb4b07e04cbb529ee24014b16067f9f082b940c9d5e54024d3e5e910310457478560721587da7b5343d89eec5a8fce389c01185db15e7faa9a3fa32e8ab9":120:"ff0b2c384e03b50e7e829c7a9f95aa":"239637fac6e180e71b2c9fa63ce8805f453d81499623ec2deba9b033350250662897867bffaf0c314244baf9e1fe3e1bb7c626d616bfbf3e0ac09a32aaf718b432337c9dc57c2d6fc4a0a09bdc05b9184d1b90c7193b7869f91e2caa8b3b35c10c6621ffae4c609bdf4e4e3f06e930541c381451ef58f4f30a559d2b79b0e6b6":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c9fbbff8f25f951ba874dfc5ff38584e":"ca401071396da00376add467490abc6e6a7d8a85852026979f7013a09cf689113c8d833560cd6c5b8fdaa8fdd818e773ac13954839a0a2c91efeaf4e0e14de43308419a8b86fa2ae600a88a6bd39dfaabc16a3c7c1b77a5c2aab7f7caceb2f8595324125efbb7c96ba16c47d0bd10568b24bf445d72d683268466e68e46df500":"1c1fc752673be6d4ff4cc749fc11e0fe":"abfde0b60acfe265b62ed68ebebc1f5f725f155c4b8a8aeec8d704701c51ff7817060c1b0ce6b80d6efc9836c9ea2bc022ec67db4cd34e945e3a1b153fd2e0f7ac84bb4b07e04cbb529ee24014b16067f9f082b940c9d5e54024d3e5e910310457478560721587da7b5343d89eec5a8fce389c01185db15e7faa9a3fa32e8ab9":120:"ff0b2c384e03b50e7e829c7a9f95aa":"":"239637fac6e180e71b2c9fa63ce8805f453d81499623ec2deba9b033350250662897867bffaf0c314244baf9e1fe3e1bb7c626d616bfbf3e0ac09a32aaf718b432337c9dc57c2d6fc4a0a09bdc05b9184d1b90c7193b7869f91e2caa8b3b35c10c6621ffae4c609bdf4e4e3f06e930541c381451ef58f4f30a559d2b79b0e6b6":0 AES-GCM NIST Validation (AES-128,128,1024,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3a314ec178da96311e42334a616fb38b":"518b3f5384ab54f80497d55be7a5d6902bc7718386212c2ec7537db331514b3838f104bf9054e03039a4cfb73f41e5d0a9648e569ed738cea8d33917430dff6afa8f07a75e324b9262fa196a4439dcd66b0535ee5bea0d292600227c2a79ed03be0671740e5cb7b306d855612bd3abcbf02cf7e7cecbb6cdbb33d57b4e3234a2":"d7ea27c819e3eb2666611bb1c7fc068d":"db8dcc31a5681f13d56abd51bd2dcb0d2b171628186e215a68bf16167b4acd00c3441973c3fa62fa2698ee5c6749fc20e542364d63c40756d8bcff780269e5201bafdced3cdc97931d8203873431882c84522c151b775285d0a3c5d7667254c74724ff0ea9d417aa6c62835865dfded34edd331c0c235a089427672c5a9211c9":112:"1e774647b1ca406e0ed7141a8e1e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3a314ec178da96311e42334a616fb38b":"518b3f5384ab54f80497d55be7a5d6902bc7718386212c2ec7537db331514b3838f104bf9054e03039a4cfb73f41e5d0a9648e569ed738cea8d33917430dff6afa8f07a75e324b9262fa196a4439dcd66b0535ee5bea0d292600227c2a79ed03be0671740e5cb7b306d855612bd3abcbf02cf7e7cecbb6cdbb33d57b4e3234a2":"d7ea27c819e3eb2666611bb1c7fc068d":"db8dcc31a5681f13d56abd51bd2dcb0d2b171628186e215a68bf16167b4acd00c3441973c3fa62fa2698ee5c6749fc20e542364d63c40756d8bcff780269e5201bafdced3cdc97931d8203873431882c84522c151b775285d0a3c5d7667254c74724ff0ea9d417aa6c62835865dfded34edd331c0c235a089427672c5a9211c9":112:"1e774647b1ca406e0ed7141a8e1e":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e818372a63b7e2c23b524e29ba752bdb":"c1bf1b702a95ceaa6b48a1cdd888ae51f58a9fc3232bd6c784529a83301c6d0cdda6e605ad9a2563f54a8d59f624ae7c589e48b85041a010dcb6fb8739d43e79a456fc0e8574af086df78680460c3cdc4e00dc3b9d4e76b0de26e9aec546705249fa7e7466c01001c2667eaf2813be1f0f116916f34843a06b201d653aa1b27e":"36e617e787cb25e154f73af1da68cb06":"71801d69796c2ce36b043c157aec9fd2e06fd1ec596126d10c26b6d44e3dc36c4fa30a030d65c382b6ddfd958e71fe9c16732e595137a3d6764c15480fc3358e9a113ba492b31274663f5842df5d1cc6bad70e83b34675a4411e2e70755aede0ff5035601be130562e27a20283d6f144ff1bdb5276dec05fad80d51b28d50688":112:"3744262bc76f283964c1c15dc069":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e818372a63b7e2c23b524e29ba752bdb":"c1bf1b702a95ceaa6b48a1cdd888ae51f58a9fc3232bd6c784529a83301c6d0cdda6e605ad9a2563f54a8d59f624ae7c589e48b85041a010dcb6fb8739d43e79a456fc0e8574af086df78680460c3cdc4e00dc3b9d4e76b0de26e9aec546705249fa7e7466c01001c2667eaf2813be1f0f116916f34843a06b201d653aa1b27e":"36e617e787cb25e154f73af1da68cb06":"71801d69796c2ce36b043c157aec9fd2e06fd1ec596126d10c26b6d44e3dc36c4fa30a030d65c382b6ddfd958e71fe9c16732e595137a3d6764c15480fc3358e9a113ba492b31274663f5842df5d1cc6bad70e83b34675a4411e2e70755aede0ff5035601be130562e27a20283d6f144ff1bdb5276dec05fad80d51b28d50688":112:"3744262bc76f283964c1c15dc069":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a04f16882ff45816739d1b6697ce8b7":"6a4f3dbb3371f64258fd1f831349e745a4e19a33aad794b1de3788729618beed619586092120e9e5dc3ac6e0d52f991f7be61afbfaa4399ac716ad79a2734827254b1627791dc92a128a6f43426b8085dee94242e83176a3d762658f18ecc1e37e3e1531648c9caed212ea2cf3b3843cb92cb07730f30fe2dca3925470fadd06":"66f504d9a9128ad7fb7f1430d37c4784":"f641c53c83c4fb1ff8044bfa97cdf63fe75d8159d65b3e5ad585b89c083a53cf4a2f7a58eaeaf45fa71f2c07bc5725a6b03307d7f32884a133a4c803700bf1e12564b98b71f63b434ddf13ad2c467dda25ffa6effcafa72452b20c34cfae71e47096f8745b487e9f1945f5bec83f7ec2709a13b504d92315b1b727a78902be84":112:"fbb37084396394fecd9581741f3c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a04f16882ff45816739d1b6697ce8b7":"6a4f3dbb3371f64258fd1f831349e745a4e19a33aad794b1de3788729618beed619586092120e9e5dc3ac6e0d52f991f7be61afbfaa4399ac716ad79a2734827254b1627791dc92a128a6f43426b8085dee94242e83176a3d762658f18ecc1e37e3e1531648c9caed212ea2cf3b3843cb92cb07730f30fe2dca3925470fadd06":"66f504d9a9128ad7fb7f1430d37c4784":"f641c53c83c4fb1ff8044bfa97cdf63fe75d8159d65b3e5ad585b89c083a53cf4a2f7a58eaeaf45fa71f2c07bc5725a6b03307d7f32884a133a4c803700bf1e12564b98b71f63b434ddf13ad2c467dda25ffa6effcafa72452b20c34cfae71e47096f8745b487e9f1945f5bec83f7ec2709a13b504d92315b1b727a78902be84":112:"fbb37084396394fecd9581741f3c":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"38cf029a4b20607030586cd2d82146e6":"f4c9f4476561c9ebdac71b282ae6e2f9f03547da98e66d4d857720db2fcc9ed1f363858db34c9dcaca0109d7c81db24150493115f2bb6985efa8686e3d2ab719d33b230aa4c5c70696bf42f225fb3c6704711c054a882d89b320884a78cb59cd2100496edf4010487597fb9135d8ca79693a43843e9626fd6c64a8722b3a27dc":"6330084319e2bf32cd5240f4826944bc":"80746cfb0127c592f8164d751b0e14a5b379056a884cece7ee4e9b80538d7ff6be56a3b19c135786722aaf315123b47672b0251e87ea45f0fd3601cf93f9efa6cbd9ad537f54d57f1e187f821faac24096ecec19d137c9f4cf145c278af4cd8de01c7758784fda06f1cc62d92ae1977786f3d0645714ab4ab6f48c8794b12f73":104:"7b021de5cda915ba58f90ceef4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"38cf029a4b20607030586cd2d82146e6":"f4c9f4476561c9ebdac71b282ae6e2f9f03547da98e66d4d857720db2fcc9ed1f363858db34c9dcaca0109d7c81db24150493115f2bb6985efa8686e3d2ab719d33b230aa4c5c70696bf42f225fb3c6704711c054a882d89b320884a78cb59cd2100496edf4010487597fb9135d8ca79693a43843e9626fd6c64a8722b3a27dc":"6330084319e2bf32cd5240f4826944bc":"80746cfb0127c592f8164d751b0e14a5b379056a884cece7ee4e9b80538d7ff6be56a3b19c135786722aaf315123b47672b0251e87ea45f0fd3601cf93f9efa6cbd9ad537f54d57f1e187f821faac24096ecec19d137c9f4cf145c278af4cd8de01c7758784fda06f1cc62d92ae1977786f3d0645714ab4ab6f48c8794b12f73":104:"7b021de5cda915ba58f90ceef4":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cf4d81fc5997c744a572bed71f4ae609":"f3d65d70326e641fbe7fd945fe9cf66c74f17d0d1020ae8ac488f39b7285c99d8632bc2201960f3d77daccfecc04428abe0853aa8d82b90a93127c72b2d2af53f7f1bd0afb99d50f0b3b24e934ec98eddb278b2c65866442cebf10208c7ce1b7ecf764858480b2a269b106fa6d2428d5ad17612e53e62ccc7ad1184663aeb9a7":"bc4e20c56931c967ce8e3b8f5f1c392f":"b6b8294abf7da5703f864721f7904d3821f5568bf4b269e44edef4f1c95ddc172d83a06c0ad9f7f1fd2e292c17a876392bc5bb705d370b2f16ff721bef7648f423346fd3a4d762676e6fcf2d690553a47224af29afed0f452d263be90eb8150a13d720f1db6f1abc1c2ec18cfbf93b8ed3c5aa7cfc1dcb514d69f90409687a4d":104:"0a86142a0af81c8df64ba689f4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cf4d81fc5997c744a572bed71f4ae609":"f3d65d70326e641fbe7fd945fe9cf66c74f17d0d1020ae8ac488f39b7285c99d8632bc2201960f3d77daccfecc04428abe0853aa8d82b90a93127c72b2d2af53f7f1bd0afb99d50f0b3b24e934ec98eddb278b2c65866442cebf10208c7ce1b7ecf764858480b2a269b106fa6d2428d5ad17612e53e62ccc7ad1184663aeb9a7":"bc4e20c56931c967ce8e3b8f5f1c392f":"b6b8294abf7da5703f864721f7904d3821f5568bf4b269e44edef4f1c95ddc172d83a06c0ad9f7f1fd2e292c17a876392bc5bb705d370b2f16ff721bef7648f423346fd3a4d762676e6fcf2d690553a47224af29afed0f452d263be90eb8150a13d720f1db6f1abc1c2ec18cfbf93b8ed3c5aa7cfc1dcb514d69f90409687a4d":104:"0a86142a0af81c8df64ba689f4":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d88ad40b42ead744f1b7a36685658be1":"e99d2566fe6bcb2a04d167605db7c0f1e5567ff2d8d3292c15bbccc5d1e872bcb15a30b3bb8b1eb45e02fba15946e6bca310583a6740845a0f74f4ebfd5c59ced46875823e369e0447cc3e5d03dae530adf3c9846362c94e7f9d17207bf92d4d59981d8fd904eb8b96a0a23eb0f8d7e7a87e8e8892a2451524da6841ce575c27":"52c3158f5bd65a0a7ce1c5b57b9b295e":"dde2663335c40e5550ae192b843fa9fb4ef357b5c09d9f39dafda3296a4d14031817ee4dc1a201d677597d81e37050cd3dc86c25adbd551e947a080b6c47ec7be8a927ef7920bd1bb81f2c59801a2b9d745d33344cbe4838bcf2eb8dce53ab82c75c9bbab8e406597f6908aaa81fbbdef25aa69116c8f7a8cdc9958435aa32ac":104:"7643b3534eb5cb38331ed2e572":"6f87f6be2f4e7421aa26fe321045d1e23066a02158634bef35890581c92367d0bc232940de30974c70a66c60137a9f3924d12db1e5bc1b0e7131ea3620a25eb805b7d670263b82c8bbfcd6839305025390fc17d42d82daebe1b24f73ff9aa4617e3866785dded88f8b55ef89b2798ea2641a592a46428d9020f9bf853c194576":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d88ad40b42ead744f1b7a36685658be1":"e99d2566fe6bcb2a04d167605db7c0f1e5567ff2d8d3292c15bbccc5d1e872bcb15a30b3bb8b1eb45e02fba15946e6bca310583a6740845a0f74f4ebfd5c59ced46875823e369e0447cc3e5d03dae530adf3c9846362c94e7f9d17207bf92d4d59981d8fd904eb8b96a0a23eb0f8d7e7a87e8e8892a2451524da6841ce575c27":"52c3158f5bd65a0a7ce1c5b57b9b295e":"dde2663335c40e5550ae192b843fa9fb4ef357b5c09d9f39dafda3296a4d14031817ee4dc1a201d677597d81e37050cd3dc86c25adbd551e947a080b6c47ec7be8a927ef7920bd1bb81f2c59801a2b9d745d33344cbe4838bcf2eb8dce53ab82c75c9bbab8e406597f6908aaa81fbbdef25aa69116c8f7a8cdc9958435aa32ac":104:"7643b3534eb5cb38331ed2e572":"":"6f87f6be2f4e7421aa26fe321045d1e23066a02158634bef35890581c92367d0bc232940de30974c70a66c60137a9f3924d12db1e5bc1b0e7131ea3620a25eb805b7d670263b82c8bbfcd6839305025390fc17d42d82daebe1b24f73ff9aa4617e3866785dded88f8b55ef89b2798ea2641a592a46428d9020f9bf853c194576":0 AES-GCM NIST Validation (AES-128,128,1024,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c3ce86a212a30e724b4c624057db4e79":"3582ef7a9565c9a8e4496750ee5ca3e3a80df6238f7b7608e3394ec56d1360777921da039ede34abcedd01081babd496ba4de74a7de501181d6bb2022a6cc7f79d89a4c6a97676fb0f2b42f70e2d0bc1eaac364c3646df4f611c1d6b09737451b81b5a4da73c05fb58391c74e44498b80b26f1c29562d23c39b5d3f086b280cb":"9e03f0dd4cb2b3d830a6925e4400ed89":"92c48a39d93ea3308f55f6650d33fdf17a902076d582a94a82ac99496de9f62312292b844bbca5a683ef0f0710bbc1c7f89cbcca8f9c0299f154590d32059bd99fca5d78c450ede0d11d55075947caf2151218ce7a06c1e81985a7781a3444054170b457fd7ba816026310112abb47c8eddfd3ab7f679a0f60efc6c6dd3b759e":96:"3230fe94b6ccd63e605f87d0":"052347a4273cddba65b2a0b961477f07edee440a9117ab204359d2dd45ad2a6dad3b60ead891e7da6d79f3017ac90f95725a0089f04d25ce537bf53b7ea8e1ea58692d34c221db141e2a9fd7211adcee03ef8b5bf3c5d36311d20bb3d81f70f7e7272d0e2b6d12293b1a2c31b70f140a8f08d98c6231a3c429c3d0a10b2e1c1c":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c3ce86a212a30e724b4c624057db4e79":"3582ef7a9565c9a8e4496750ee5ca3e3a80df6238f7b7608e3394ec56d1360777921da039ede34abcedd01081babd496ba4de74a7de501181d6bb2022a6cc7f79d89a4c6a97676fb0f2b42f70e2d0bc1eaac364c3646df4f611c1d6b09737451b81b5a4da73c05fb58391c74e44498b80b26f1c29562d23c39b5d3f086b280cb":"9e03f0dd4cb2b3d830a6925e4400ed89":"92c48a39d93ea3308f55f6650d33fdf17a902076d582a94a82ac99496de9f62312292b844bbca5a683ef0f0710bbc1c7f89cbcca8f9c0299f154590d32059bd99fca5d78c450ede0d11d55075947caf2151218ce7a06c1e81985a7781a3444054170b457fd7ba816026310112abb47c8eddfd3ab7f679a0f60efc6c6dd3b759e":96:"3230fe94b6ccd63e605f87d0":"":"052347a4273cddba65b2a0b961477f07edee440a9117ab204359d2dd45ad2a6dad3b60ead891e7da6d79f3017ac90f95725a0089f04d25ce537bf53b7ea8e1ea58692d34c221db141e2a9fd7211adcee03ef8b5bf3c5d36311d20bb3d81f70f7e7272d0e2b6d12293b1a2c31b70f140a8f08d98c6231a3c429c3d0a10b2e1c1c":0 AES-GCM NIST Validation (AES-128,128,1024,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a0155360b84420b5bf4fb410ea02f31e":"ecdb51522fc440f7471ea6a31f7c1ef1ec2153e5bcf6303297dbf8ddb3830b45ed9866157375ce4bdeb5e32fcbc6607984fccd7e6552628736608ab13072856d432ceccd3e90d1bb52ca9ada9cee90eb89ac10e887a1978fd0fb3d7bb20caaf35539e150be8044b725b8427c4c4a910f79980865d36344a8784bcc3d58460acb":"46f0386be7363887e7e357376305eab5":"611bc290f91798ad84f0a5ecb5a7cb8fa35e9ab6a5a51c9869a68a076e96f92c9c117595f92cbac5d33343fa2accd2541473907cbc54792c5e215ae857424c921b04ca4b81376bbedbfcc0e565c118f2aced08f247698eed5e2d202c48245161cabeac9fa195219f9799fa253e339561e13012167f1d02b4012b7791b7c863ba":96:"ac5addcc10cae6c1345520f1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a0155360b84420b5bf4fb410ea02f31e":"ecdb51522fc440f7471ea6a31f7c1ef1ec2153e5bcf6303297dbf8ddb3830b45ed9866157375ce4bdeb5e32fcbc6607984fccd7e6552628736608ab13072856d432ceccd3e90d1bb52ca9ada9cee90eb89ac10e887a1978fd0fb3d7bb20caaf35539e150be8044b725b8427c4c4a910f79980865d36344a8784bcc3d58460acb":"46f0386be7363887e7e357376305eab5":"611bc290f91798ad84f0a5ecb5a7cb8fa35e9ab6a5a51c9869a68a076e96f92c9c117595f92cbac5d33343fa2accd2541473907cbc54792c5e215ae857424c921b04ca4b81376bbedbfcc0e565c118f2aced08f247698eed5e2d202c48245161cabeac9fa195219f9799fa253e339561e13012167f1d02b4012b7791b7c863ba":96:"ac5addcc10cae6c1345520f1":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"694f621f594d96b16c32254ff06f3f9c":"e61476b8b7f101ca6005f25af2b9bee795d62720bbbf59357057ca7cd473e00f0d465255fce8d6164657603323549fb4e3d33fa51054b1a70cc7e492916dea85453e9107fe781bfeb4a622c5b2306a8dddef99386dc50745003aa7220cd7f32fb0a060fa7682576769a48f9169c7d11fe0a8a61b95f5d6dfcf216f7d0c652a84":"542db4e107485a3cd24c7ad337a4f1b5":"27b7bfa5eb34ba376e515e58ab8b6556c396820d0074a1fe3b984945dcf5251ca450456ccb4bb66ec739b03fdc5f72d24553e843255adc012d1f1c95aa3cdac5d12926465354217203052cbd4869a8b5be2e01d0fe66b5a6a8da0a2ce351557e2991ce77baa812b9c67b8e1c5a1fc348710e1a73a0fd49acfd538b7db6bef8b3":96:"0bdef4d771a1740381e7db97":"8b27a338fd2153d304f04655e09bd9bdf4468890ecce1e3b51de2c9a25a8d9336a9acd753ce270b1fe8d50196feac68145e0fd59c9cb3aa7c1e8af03494bc4279c6e287c849f3c775ada584ae173100946ae6921ef7c96bbc6f216093548702cf1867bb1bf1f4c9e90a34230a2b2aeb584622dd615023a43a406e64428bd9170":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"694f621f594d96b16c32254ff06f3f9c":"e61476b8b7f101ca6005f25af2b9bee795d62720bbbf59357057ca7cd473e00f0d465255fce8d6164657603323549fb4e3d33fa51054b1a70cc7e492916dea85453e9107fe781bfeb4a622c5b2306a8dddef99386dc50745003aa7220cd7f32fb0a060fa7682576769a48f9169c7d11fe0a8a61b95f5d6dfcf216f7d0c652a84":"542db4e107485a3cd24c7ad337a4f1b5":"27b7bfa5eb34ba376e515e58ab8b6556c396820d0074a1fe3b984945dcf5251ca450456ccb4bb66ec739b03fdc5f72d24553e843255adc012d1f1c95aa3cdac5d12926465354217203052cbd4869a8b5be2e01d0fe66b5a6a8da0a2ce351557e2991ce77baa812b9c67b8e1c5a1fc348710e1a73a0fd49acfd538b7db6bef8b3":96:"0bdef4d771a1740381e7db97":"":"8b27a338fd2153d304f04655e09bd9bdf4468890ecce1e3b51de2c9a25a8d9336a9acd753ce270b1fe8d50196feac68145e0fd59c9cb3aa7c1e8af03494bc4279c6e287c849f3c775ada584ae173100946ae6921ef7c96bbc6f216093548702cf1867bb1bf1f4c9e90a34230a2b2aeb584622dd615023a43a406e64428bd9170":0 AES-GCM NIST Validation (AES-128,128,1024,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"78826a5215a1d5e1b39cad5a06861f8f":"0fe2c798d7015d3e2f8725648d95729c45d357dc0c89fc63b9df5a68d3e65419540f663e9190793a29c58c495d5c6a731782acf119e2df8a96fb180ad772c301d098dbc5e3560ac45b6631a01cef7eed6db51f223775d601d2e11b9baa55e2f0651344777e5a03f6738a2013626a891b5f134f07b16598b8cbe3aeaefa1c2a26":"feb9d740fd1e221e328b5ef5ed19eff5":"ca9411b368d8295210d7a04da05a351d287f2f67d978ef1bb936de9f8065473f6fa11495da2eab13a1002231c86411d5409bbc718e2042ee99e013b1df1ef786e9fc1f2d43293c854128184efb9317c4ef82a002eac8b28fcd91d8a714a3aa25fc3c0ae4af9f4bcf5ad19a30cd8ec4b1785df70aa92074da419abe433dd4c435":64:"a724bbb295a02883":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"78826a5215a1d5e1b39cad5a06861f8f":"0fe2c798d7015d3e2f8725648d95729c45d357dc0c89fc63b9df5a68d3e65419540f663e9190793a29c58c495d5c6a731782acf119e2df8a96fb180ad772c301d098dbc5e3560ac45b6631a01cef7eed6db51f223775d601d2e11b9baa55e2f0651344777e5a03f6738a2013626a891b5f134f07b16598b8cbe3aeaefa1c2a26":"feb9d740fd1e221e328b5ef5ed19eff5":"ca9411b368d8295210d7a04da05a351d287f2f67d978ef1bb936de9f8065473f6fa11495da2eab13a1002231c86411d5409bbc718e2042ee99e013b1df1ef786e9fc1f2d43293c854128184efb9317c4ef82a002eac8b28fcd91d8a714a3aa25fc3c0ae4af9f4bcf5ad19a30cd8ec4b1785df70aa92074da419abe433dd4c435":64:"a724bbb295a02883":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d450f5253251121606e56687952bf2f1":"479b4f421bd8ac7f615c4a507da187cb5d4b1f1e2c6113d1f9678c1ba92dc5e17c5b525d7f3208733223eb82af0820b8476e9b08ca714ce044417b24d2238720cb8ffdc69db558cbaff52e3651b400e16c9d5ac8ed8949a19c35516f80394a04bd1cfdced7b204f779d792086e00b2ebca2f55a1140e85f5ee9ac7cfc5a31747":"fe7ff90b020fc77d7fcd90bc583850ac":"a3bca9ff25a60006eb18f993dcdc99681e414e27605264dfd25652195d7fe1489550afd07fc7346b88d93b59eb6642913646e93bf50ee1db5dd30106cf181124d8ad01c72ed99038c9798620abdf5c78c419b08c97f982b34d9e9105d9aa4538afcd37f62e2412f14f7a248fcd60abaf2b66cd4554767f99030f1a495d56a5ae":64:"6446398aff73ed23":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d450f5253251121606e56687952bf2f1":"479b4f421bd8ac7f615c4a507da187cb5d4b1f1e2c6113d1f9678c1ba92dc5e17c5b525d7f3208733223eb82af0820b8476e9b08ca714ce044417b24d2238720cb8ffdc69db558cbaff52e3651b400e16c9d5ac8ed8949a19c35516f80394a04bd1cfdced7b204f779d792086e00b2ebca2f55a1140e85f5ee9ac7cfc5a31747":"fe7ff90b020fc77d7fcd90bc583850ac":"a3bca9ff25a60006eb18f993dcdc99681e414e27605264dfd25652195d7fe1489550afd07fc7346b88d93b59eb6642913646e93bf50ee1db5dd30106cf181124d8ad01c72ed99038c9798620abdf5c78c419b08c97f982b34d9e9105d9aa4538afcd37f62e2412f14f7a248fcd60abaf2b66cd4554767f99030f1a495d56a5ae":64:"6446398aff73ed23":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90a59f6b0abf932311f0b65623c17740":"be5a948a771a8df12adaf74d702f064a75f6483c03203365fbde7d184844fe6dee0b84cf344be05b1d163817ba1516fcb87b9167ed81f884ada73b0058e2b38cba515bbbe462f4c21f8de1d41bca2cf4340aa659f9f07886c2bb620d9c3295318c07fa3c17fe8242409359c08bcb337e5cf268880839b6a20f4ee4b3f04e7024":"20778bea82a6717038e7064f48a31981":"4022d04f1454a72d2efe57533bd32757595220b20f3a37d166cec0412fb1eb2588f939ecd906c805f4827338669888e9f730905001eb1b136b95e306edf70d9ba1e5cd0aa13a25a1f28ab55cff36f9cd7036c735e3b285d26002ad2ed1074b566e252ea3ec8a9ce10882375dc3f1d9676e301dcb179eaae991120b796cc35648":64:"dc77c1d7e0902d48":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90a59f6b0abf932311f0b65623c17740":"be5a948a771a8df12adaf74d702f064a75f6483c03203365fbde7d184844fe6dee0b84cf344be05b1d163817ba1516fcb87b9167ed81f884ada73b0058e2b38cba515bbbe462f4c21f8de1d41bca2cf4340aa659f9f07886c2bb620d9c3295318c07fa3c17fe8242409359c08bcb337e5cf268880839b6a20f4ee4b3f04e7024":"20778bea82a6717038e7064f48a31981":"4022d04f1454a72d2efe57533bd32757595220b20f3a37d166cec0412fb1eb2588f939ecd906c805f4827338669888e9f730905001eb1b136b95e306edf70d9ba1e5cd0aa13a25a1f28ab55cff36f9cd7036c735e3b285d26002ad2ed1074b566e252ea3ec8a9ce10882375dc3f1d9676e301dcb179eaae991120b796cc35648":64:"dc77c1d7e0902d48":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6be4ef629f0b38194c74f7b66418922d":"b67ea20a320f4ec0e4185c62a4ad79a3c97a8189a5e4d1deff9d3edff0f9a9323532853c1a2a2c1e62e4d1afebfcdf1d8461921ea601750380e63b912d8b7389198f976851d88a19f1aa32c97143668ad00838d98da1c4f2be0e6e2dc964d170d7f7ad2e2997982e5ca110e744b6e10c24ca18eadff6b129b1f290c8a7e0a593":"fb77a4b9b246271abfc656433f87628c":"e5d5227725a19a3050fbf2a97a6e854bc1218b94a4a3403b721ace3447daff68fff5553a26edd41219e68fb61fb9e964d0a3c29796251ae4eb942187cdc55d13a09dfb487e93d9e2072d7271456a77c6ccb81154443eea176314d6e3a08619b52cd880f1c28ae5214ac0090a3855dbd74f87389fe8afebd464330fb683dff81a":32:"3d8fc6fb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6be4ef629f0b38194c74f7b66418922d":"b67ea20a320f4ec0e4185c62a4ad79a3c97a8189a5e4d1deff9d3edff0f9a9323532853c1a2a2c1e62e4d1afebfcdf1d8461921ea601750380e63b912d8b7389198f976851d88a19f1aa32c97143668ad00838d98da1c4f2be0e6e2dc964d170d7f7ad2e2997982e5ca110e744b6e10c24ca18eadff6b129b1f290c8a7e0a593":"fb77a4b9b246271abfc656433f87628c":"e5d5227725a19a3050fbf2a97a6e854bc1218b94a4a3403b721ace3447daff68fff5553a26edd41219e68fb61fb9e964d0a3c29796251ae4eb942187cdc55d13a09dfb487e93d9e2072d7271456a77c6ccb81154443eea176314d6e3a08619b52cd880f1c28ae5214ac0090a3855dbd74f87389fe8afebd464330fb683dff81a":32:"3d8fc6fb":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c50e37244931e8debc12b3d561c83ba2":"b9abf0796f2d2f774735546cf809030f65ed0c7f6bd469ef2fe0ef32aa0225b57fbce07c36017bbc1806a81ff1a429278160a07643f864485b4e0e35d57553dc1a131e32aa10f1f91d663b10f0a418f472ed7b4bca54fd7ffdbb22c4d7764d94a7ffd04730614459431eb64335b9b65363de292c04275d40a7b968c0f5c486e9":"6c0b1fd7ab424a6883c36457d1b5521f":"516dc25f6452ae169ce293c5cee440de47353ca5ba770dca0f04175950e87a2d4c3f84fbc6eeacaac436853492929680066f959e74de4b736ab924d8367b90aaa6e9492561ad4b5aa78b6737d562e960edc3b983e2e01a186e9f22896f48d8dfcfb6a42cfe2c6006c687a27772820a1e8875bdf09e8104248ce4db883376bc04":32:"7d4393f0":"962509e494f10269b70ebad02b0cd799d1d41191a734863ef502aff3d3ba48dc2acf9da9a3fc3f40be4d210dc5e128bc00499aec57aa0a4669863165428687b88d46fad41e36af8ea6605586eaa5c0736d0d53b9d523e0cb5a0b285048e060a73cbf4b587d2cd787debdb2b4c8cda731a61a15b19fe8b561fbdd3a7373853ae1":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c50e37244931e8debc12b3d561c83ba2":"b9abf0796f2d2f774735546cf809030f65ed0c7f6bd469ef2fe0ef32aa0225b57fbce07c36017bbc1806a81ff1a429278160a07643f864485b4e0e35d57553dc1a131e32aa10f1f91d663b10f0a418f472ed7b4bca54fd7ffdbb22c4d7764d94a7ffd04730614459431eb64335b9b65363de292c04275d40a7b968c0f5c486e9":"6c0b1fd7ab424a6883c36457d1b5521f":"516dc25f6452ae169ce293c5cee440de47353ca5ba770dca0f04175950e87a2d4c3f84fbc6eeacaac436853492929680066f959e74de4b736ab924d8367b90aaa6e9492561ad4b5aa78b6737d562e960edc3b983e2e01a186e9f22896f48d8dfcfb6a42cfe2c6006c687a27772820a1e8875bdf09e8104248ce4db883376bc04":32:"7d4393f0":"":"962509e494f10269b70ebad02b0cd799d1d41191a734863ef502aff3d3ba48dc2acf9da9a3fc3f40be4d210dc5e128bc00499aec57aa0a4669863165428687b88d46fad41e36af8ea6605586eaa5c0736d0d53b9d523e0cb5a0b285048e060a73cbf4b587d2cd787debdb2b4c8cda731a61a15b19fe8b561fbdd3a7373853ae1":0 AES-GCM NIST Validation (AES-128,128,1024,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8531ddb03977383405baf2ee9ca7d64b":"d90c9e26509bdba9b1dea8d2b94f2b1881d22c2bd756ad23cd61944710a1c1f2807170ed47a6870ae654e44757fcb3822ef28b37946cafc07284f8a0c22ae3552954f0d87b8d8c825bd546935b494cacb4262d9e2a88f254f200ad31367d8b3715afbabea5f34214ffedb14d7c84806022aba2dc8f88a314ffbb24017d1a9b9f":"baf623867d6a25fd85d1f08e599c0566":"18f92cdd37dcd7f99b06838f3f68748aba367baabaebd0da9ee787d70e752fa07dea553a43b643b8d8f460175c0746675205e20a7a98acfcac864d7c4cf5ab4c41c031738c76882acda003c5af47b1c4df8894a827a317935d970d4afaee17715c9cfd1883e8c345f19d1f89e229b8edba6b4f53b86d8da1c0f159afb83b6b33":32:"2fc9de46":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8531ddb03977383405baf2ee9ca7d64b":"d90c9e26509bdba9b1dea8d2b94f2b1881d22c2bd756ad23cd61944710a1c1f2807170ed47a6870ae654e44757fcb3822ef28b37946cafc07284f8a0c22ae3552954f0d87b8d8c825bd546935b494cacb4262d9e2a88f254f200ad31367d8b3715afbabea5f34214ffedb14d7c84806022aba2dc8f88a314ffbb24017d1a9b9f":"baf623867d6a25fd85d1f08e599c0566":"18f92cdd37dcd7f99b06838f3f68748aba367baabaebd0da9ee787d70e752fa07dea553a43b643b8d8f460175c0746675205e20a7a98acfcac864d7c4cf5ab4c41c031738c76882acda003c5af47b1c4df8894a827a317935d970d4afaee17715c9cfd1883e8c345f19d1f89e229b8edba6b4f53b86d8da1c0f159afb83b6b33":32:"2fc9de46":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"862dd5b362cfa556ca37e73cff7f4a0e":"":"81530a243655a60d22d9ab40d2520447":"":128:"3b9b2af54e610ed0b3dda96961dd8783":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"862dd5b362cfa556ca37e73cff7f4a0e":"":"81530a243655a60d22d9ab40d2520447":"":128:"3b9b2af54e610ed0b3dda96961dd8783":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3452b7bc100c334292e08343f139b9d0":"":"8f92739a30fe4ba24079f5d42753d6ac":"":128:"0eeca69f8b95e1a902cc3ab1aaa8e2af":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3452b7bc100c334292e08343f139b9d0":"":"8f92739a30fe4ba24079f5d42753d6ac":"":128:"0eeca69f8b95e1a902cc3ab1aaa8e2af":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"31a0cbaf21b943f8badc939e94eac7eb":"":"d5bb2c4eaec47088230972ae34fcda9c":"":128:"580e728512c8e44fbb3fe2c498e05323":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"31a0cbaf21b943f8badc939e94eac7eb":"":"d5bb2c4eaec47088230972ae34fcda9c":"":128:"580e728512c8e44fbb3fe2c498e05323":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9e8fca537746e7cbff97f1dcd40a3392":"":"43e9f2bf186b2af8cc022e7c7412d641":"":120:"4465a3f9d9751789bcef5c7c58cbc5":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9e8fca537746e7cbff97f1dcd40a3392":"":"43e9f2bf186b2af8cc022e7c7412d641":"":120:"4465a3f9d9751789bcef5c7c58cbc5":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"35b5854ca83792ad691dbda1a66790fb":"":"cff61cf9b32ea30cf7e3692aa6e74bed":"":120:"726793199df533dd9055b0ac7c939d":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"35b5854ca83792ad691dbda1a66790fb":"":"cff61cf9b32ea30cf7e3692aa6e74bed":"":120:"726793199df533dd9055b0ac7c939d":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"07259267c1c6a015437a5d8cfa92f9e6":"":"18b9cf2ad7ace6ec1c8366b72878cf20":"":120:"4340f6263f0ba2d82c2eb79cb0cc7e":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"07259267c1c6a015437a5d8cfa92f9e6":"":"18b9cf2ad7ace6ec1c8366b72878cf20":"":120:"4340f6263f0ba2d82c2eb79cb0cc7e":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fa1df8955aa3ef191900b06e7c1b7d46":"":"6928c138c98a4350c318fbdccd3f44ba":"":112:"7c89d9e77515d271b6ed54c9c4e3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fa1df8955aa3ef191900b06e7c1b7d46":"":"6928c138c98a4350c318fbdccd3f44ba":"":112:"7c89d9e77515d271b6ed54c9c4e3":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c04200ce41ce77d772babb206315ec7d":"":"a885d58f0f38f9ff26d906fa1bfb12f4":"":112:"9ee0d025421f2bf18caf563953fb":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c04200ce41ce77d772babb206315ec7d":"":"a885d58f0f38f9ff26d906fa1bfb12f4":"":112:"9ee0d025421f2bf18caf563953fb":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"650df049461be341c3099bd1613dcead":"":"8a4ff6327b49d297248ce2d5bd38afa8":"":112:"13f067ef0d7b448d56e70d282fed":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"650df049461be341c3099bd1613dcead":"":"8a4ff6327b49d297248ce2d5bd38afa8":"":112:"13f067ef0d7b448d56e70d282fed":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ee61b5bf5060fcc637dc833926898508":"":"b2dcf21f9ffa4a883044d29f087f9b85":"":104:"9ab1d66666d4dea3cbb5982238":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ee61b5bf5060fcc637dc833926898508":"":"b2dcf21f9ffa4a883044d29f087f9b85":"":104:"9ab1d66666d4dea3cbb5982238":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"01cc56ca7e64db7fbef66236a5c49493":"":"8ea5b63004189792cc040ef18b37e550":"":104:"d685aeb54aa129a21bed17766e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"01cc56ca7e64db7fbef66236a5c49493":"":"8ea5b63004189792cc040ef18b37e550":"":104:"d685aeb54aa129a21bed17766e":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"134dd72ac8e28ab46720c2f42284a303":"":"c6368e4c0ba0ec90fa7488af9997a4c7":"":104:"4ad9cdf19ff7d7fd7e273efced":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"134dd72ac8e28ab46720c2f42284a303":"":"c6368e4c0ba0ec90fa7488af9997a4c7":"":104:"4ad9cdf19ff7d7fd7e273efced":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"180c04b2bde6901edcda66085f73ecd9":"":"9193b206beade4cb036f01a9db187cb8":"":96:"530f5e9ed0879ccef3a7b360":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"180c04b2bde6901edcda66085f73ecd9":"":"9193b206beade4cb036f01a9db187cb8":"":96:"530f5e9ed0879ccef3a7b360":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aaac85742a55ffa07e98106d6d6b1004":"":"630cd8ab849253c4da95ac80324ecc28":"":96:"37911820c810e3700c3a9321":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aaac85742a55ffa07e98106d6d6b1004":"":"630cd8ab849253c4da95ac80324ecc28":"":96:"37911820c810e3700c3a9321":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ab663c4f8f2fdc7d5eabf6ef26169b4e":"":"86e6100669929e329a1d258cd3552dc9":"":96:"958d6141f7fb2b2dc7d851a6":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ab663c4f8f2fdc7d5eabf6ef26169b4e":"":"86e6100669929e329a1d258cd3552dc9":"":96:"958d6141f7fb2b2dc7d851a6":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0dd756d49fd25380c4026ea03cafc2da":"":"6a6f7e39b0d730ea1670e13d16c12c28":"":64:"872ef05a28da5ea1":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0dd756d49fd25380c4026ea03cafc2da":"":"6a6f7e39b0d730ea1670e13d16c12c28":"":64:"872ef05a28da5ea1":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"bd8a834b288bdc7578b6c6ab36f5d068":"":"aa77de0af5fa4dd1ed2ada5cb94813a0":"":64:"c5c094e83755f2b6":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"bd8a834b288bdc7578b6c6ab36f5d068":"":"aa77de0af5fa4dd1ed2ada5cb94813a0":"":64:"c5c094e83755f2b6":"":"":0 AES-GCM NIST Validation (AES-128,128,0,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"020d280dbd06939bbb5e6edc6f6d39c6":"":"09aea6f0e57598452719d6f63b6fe5a0":"":64:"05d6c56ba601e85b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"020d280dbd06939bbb5e6edc6f6d39c6":"":"09aea6f0e57598452719d6f63b6fe5a0":"":64:"05d6c56ba601e85b":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e47f41a27a2722df293c1431badc0f90":"":"227c036fca03171a890806b9fa0c250d":"":32:"86c22189":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e47f41a27a2722df293c1431badc0f90":"":"227c036fca03171a890806b9fa0c250d":"":32:"86c22189":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9d3e112114b94e26e93d3855d4be26bd":"":"99b98525160c4bb2029da5553ff82b59":"":32:"33bee715":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9d3e112114b94e26e93d3855d4be26bd":"":"99b98525160c4bb2029da5553ff82b59":"":32:"33bee715":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5b4b7688588125349fbb66004a30d5d4":"":"b4ae363edb529d8b927c051cf21a2d9d":"":32:"6a920617":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5b4b7688588125349fbb66004a30d5d4":"":"b4ae363edb529d8b927c051cf21a2d9d":"":32:"6a920617":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c4b6c5b8e21c32f36b0ae4ef3b75d5cd":"":"3d1036bf0000e6f1b77a799f2ef32dec":"1cf2b6cbe86a87b4b5bb3cc50024aeb27c48143658d47b41f2f20b87ed67bd6fc3b85a3a803f66d3576608f5d6ce6cad11e02fe12de5390722dccb8242e1dd140051bef51aa9716c860d45d45bca6effbb1a4797e6e7406a04db5d823766c0f011ebc28e9a8cd4446ec8a75ea8bdc1b2fdbb5cc364fa9877886e30404593df34":128:"a49725014c214ef7cc2d28b9b2b53da7":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c4b6c5b8e21c32f36b0ae4ef3b75d5cd":"":"3d1036bf0000e6f1b77a799f2ef32dec":"1cf2b6cbe86a87b4b5bb3cc50024aeb27c48143658d47b41f2f20b87ed67bd6fc3b85a3a803f66d3576608f5d6ce6cad11e02fe12de5390722dccb8242e1dd140051bef51aa9716c860d45d45bca6effbb1a4797e6e7406a04db5d823766c0f011ebc28e9a8cd4446ec8a75ea8bdc1b2fdbb5cc364fa9877886e30404593df34":128:"a49725014c214ef7cc2d28b9b2b53da7":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"63c3f81500746eaf383fe3975d84f849":"":"0799d4152fd73c1604b4610cf7171fe1":"cb8248e5f904cc9ccccf6f273fe621eee1b4d7ed98480f9e806a48b84e2d6a733772ecf8fb7fe91805715cddab2b462b89f6e6c7cf873f65031f13c357d5f57b00b7c391c39e78ad1ed94be236ca0ae316bce11bc33c5d701fdfc58abbe918b9c42f7b3d6e89d46f9784b388a6e6daf47730b9fa665d755a17e89932fa669c44":128:"c53d01e53ee4a6ea106ea4a66538265e":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"63c3f81500746eaf383fe3975d84f849":"":"0799d4152fd73c1604b4610cf7171fe1":"cb8248e5f904cc9ccccf6f273fe621eee1b4d7ed98480f9e806a48b84e2d6a733772ecf8fb7fe91805715cddab2b462b89f6e6c7cf873f65031f13c357d5f57b00b7c391c39e78ad1ed94be236ca0ae316bce11bc33c5d701fdfc58abbe918b9c42f7b3d6e89d46f9784b388a6e6daf47730b9fa665d755a17e89932fa669c44":128:"c53d01e53ee4a6ea106ea4a66538265e":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0c88b191ce6e8e4a3941f7960b7eae5":"":"e2a899961c332c815685c553351fa519":"308bf10570af48d632911f3641dea60d78046211c01a63bb8e4e5cbddfff8841d2f2b11e18ccb2170805ef4cacf7804d64e0feef40731a1704907f33b77788c18ccf35b224ec3046a67664ac9a3481d2385b6ddeec6da4f32423f94ea9663a5c51cc388cef33744a8159b4fb654dfdb5092718bf926c824be31197f07f276b5f":128:"92604d37407aff33f8b677326cbb94fc":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0c88b191ce6e8e4a3941f7960b7eae5":"":"e2a899961c332c815685c553351fa519":"308bf10570af48d632911f3641dea60d78046211c01a63bb8e4e5cbddfff8841d2f2b11e18ccb2170805ef4cacf7804d64e0feef40731a1704907f33b77788c18ccf35b224ec3046a67664ac9a3481d2385b6ddeec6da4f32423f94ea9663a5c51cc388cef33744a8159b4fb654dfdb5092718bf926c824be31197f07f276b5f":128:"92604d37407aff33f8b677326cbb94fc":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c818dfa0885a09f65ef78712f5ce6609":"":"ca279284723530fdd68ae880e0ce775c":"2a562abdbb483ca5f355f9cc1c5e607bdd624a078a76b717ce0f8f35d0d4c54b629f372f15d20c848d01420c6af5a7040d42063704a17b46259dcc53723caf2d4bf556143ff9117c752fa4f22c9c155c99b7bf5949d089cdafd562165b9cbf53ff51cec21f49128c8a599718bbcdb4a5d705d20509c44c8945e2a133164b9942":120:"20e9a3a98d71d460743e1efaab13c6":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c818dfa0885a09f65ef78712f5ce6609":"":"ca279284723530fdd68ae880e0ce775c":"2a562abdbb483ca5f355f9cc1c5e607bdd624a078a76b717ce0f8f35d0d4c54b629f372f15d20c848d01420c6af5a7040d42063704a17b46259dcc53723caf2d4bf556143ff9117c752fa4f22c9c155c99b7bf5949d089cdafd562165b9cbf53ff51cec21f49128c8a599718bbcdb4a5d705d20509c44c8945e2a133164b9942":120:"20e9a3a98d71d460743e1efaab13c6":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2354c6b6afaa883e7ce91faca4981f8b":"":"604f2730c756c8c39a0527093bc2feb5":"959b4b0b9ce2e9120b327d2d090117553999ee10bdd384a546fc6de0957ef4b447daf07b3d07ef7dbc811f36b0fc09a175d26e4d1263cb5e21eda5ecab85d763807bb20b3cb6ac3f31d548dff00aae058d434ebcf6f7e3a37f11324134f453dd0ea7f51094863486426ff1706129a5a93c53d8c5ccb56cafa5881981fe233cb0":120:"3588c9aa769897dfa328549fbbd10a":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2354c6b6afaa883e7ce91faca4981f8b":"":"604f2730c756c8c39a0527093bc2feb5":"959b4b0b9ce2e9120b327d2d090117553999ee10bdd384a546fc6de0957ef4b447daf07b3d07ef7dbc811f36b0fc09a175d26e4d1263cb5e21eda5ecab85d763807bb20b3cb6ac3f31d548dff00aae058d434ebcf6f7e3a37f11324134f453dd0ea7f51094863486426ff1706129a5a93c53d8c5ccb56cafa5881981fe233cb0":120:"3588c9aa769897dfa328549fbbd10a":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0af48e6aebbb6ff5b7c92bd140b085f":"":"d210d6502a5221ac1274a9c7f5a81725":"d725311ca10eb4b4aa24e6dd19c5e72dc34fc1ff53feb25d924a9b7d8d72205790ca4b1275bd93ad60c27a5587a45659bca07c111e9748fb683a03465153ffd735b7d134b479674ab8596f0596496fe2090f623fd1e4dd730c5283d8b172db8a25df42d9b34f388ed32676a56b8ba03347e47379702654508ccd0a21ff03516e":120:"e6222f068a1e18f09ba6c771eabd86":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0af48e6aebbb6ff5b7c92bd140b085f":"":"d210d6502a5221ac1274a9c7f5a81725":"d725311ca10eb4b4aa24e6dd19c5e72dc34fc1ff53feb25d924a9b7d8d72205790ca4b1275bd93ad60c27a5587a45659bca07c111e9748fb683a03465153ffd735b7d134b479674ab8596f0596496fe2090f623fd1e4dd730c5283d8b172db8a25df42d9b34f388ed32676a56b8ba03347e47379702654508ccd0a21ff03516e":120:"e6222f068a1e18f09ba6c771eabd86":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a05fe482fe164b2eca7f6c3e377b39d8":"":"145327bcc10335fccb93afbf4b17e6e7":"ea6f2e93b5e1bf127d40440b8d6397405246b1b48eebe16964f18928f6b4b8ee2c36322d7126905c1a5b816996e340404b586edc2d77afac11a6c1266511f9eff1a320b035442d4078f8e42ca63cf26d12a971a7adf4645d1bd9a8e4d0a20722f7c2d529beaecc4033f7738075e1cdc6d8a929da5582540678935b82e7b7ba68":112:"3900bde9fa9ae2cbeee54d04f224":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a05fe482fe164b2eca7f6c3e377b39d8":"":"145327bcc10335fccb93afbf4b17e6e7":"ea6f2e93b5e1bf127d40440b8d6397405246b1b48eebe16964f18928f6b4b8ee2c36322d7126905c1a5b816996e340404b586edc2d77afac11a6c1266511f9eff1a320b035442d4078f8e42ca63cf26d12a971a7adf4645d1bd9a8e4d0a20722f7c2d529beaecc4033f7738075e1cdc6d8a929da5582540678935b82e7b7ba68":112:"3900bde9fa9ae2cbeee54d04f224":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dacbadf819eb16a63f6f091d13ed04d4":"":"b9ebce724b0dcb0989ac2d8e7ff8aaec":"7dc6e2189d8a96f3507e352e05e8fd1b4bab988c2f1c706115887119f63b78084f015d85f6b460901a02880103e4d36e8f6527dfd74e4a3acd3f578c0cc726b528875f701ff8b66e5c11b4689c346a098e123bebfa253362cb86829be73c2b85a6881fa976aa730fabb76775027feec7fd920a6c8965a4a509ea812d7c413a95":112:"8988fca83c8cfb1f8feefac46f04":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dacbadf819eb16a63f6f091d13ed04d4":"":"b9ebce724b0dcb0989ac2d8e7ff8aaec":"7dc6e2189d8a96f3507e352e05e8fd1b4bab988c2f1c706115887119f63b78084f015d85f6b460901a02880103e4d36e8f6527dfd74e4a3acd3f578c0cc726b528875f701ff8b66e5c11b4689c346a098e123bebfa253362cb86829be73c2b85a6881fa976aa730fabb76775027feec7fd920a6c8965a4a509ea812d7c413a95":112:"8988fca83c8cfb1f8feefac46f04":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"969244c7444f3f3bf193b28f8e8e96dc":"":"49b2845a1a1c87fa66eb8f78c05ac029":"1414a07e86d8b61d1eff43e1ff4ab42c1c95e159058b74c731e3007d21a5eb78bc17b7e920363a3974aeb8608813dc9a4655199b6703ed337450702d8ab16a89776831b2c7c811fec3acc23598a0aa01680a7bf42a4e258145beb08c9f0eacf2bb5f56d26bea3ad11e1a956a630b80f3d22bf35592b4704f7c464b08b06dd7f8":112:"a291c7527385f037f62e60fd8a96":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"969244c7444f3f3bf193b28f8e8e96dc":"":"49b2845a1a1c87fa66eb8f78c05ac029":"1414a07e86d8b61d1eff43e1ff4ab42c1c95e159058b74c731e3007d21a5eb78bc17b7e920363a3974aeb8608813dc9a4655199b6703ed337450702d8ab16a89776831b2c7c811fec3acc23598a0aa01680a7bf42a4e258145beb08c9f0eacf2bb5f56d26bea3ad11e1a956a630b80f3d22bf35592b4704f7c464b08b06dd7f8":112:"a291c7527385f037f62e60fd8a96":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"525abe490c8434802b69439c590a5290":"":"141f79f0501316e66451c41c7af0f0cd":"be440db66d3f81be467605a7b2805ec1df5e71e1b1b04bd7a4d05e912f5aa1912ba08de72df18613b32b7edf78963c48c80c25178b3b19262b85bb829f5377e0b368b500d6d3b442f54172d4ca4500eb5b4d478b602e5dc11d090539455087ce1e5b9ea74355fc06e9b60cbf25a9804d3f8c623fff130abc48bc2d8d116b8366":104:"038c7e95f790e6ca5ce73f9551":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"525abe490c8434802b69439c590a5290":"":"141f79f0501316e66451c41c7af0f0cd":"be440db66d3f81be467605a7b2805ec1df5e71e1b1b04bd7a4d05e912f5aa1912ba08de72df18613b32b7edf78963c48c80c25178b3b19262b85bb829f5377e0b368b500d6d3b442f54172d4ca4500eb5b4d478b602e5dc11d090539455087ce1e5b9ea74355fc06e9b60cbf25a9804d3f8c623fff130abc48bc2d8d116b8366":104:"038c7e95f790e6ca5ce73f9551":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"51644e025659de983f5c8156516b812e":"":"614837c743d0974e9cca497f13038c02":"60c5d062ade2c5c2dec68b734dd3e58ec474a586d1c4797fdfa2337800510134cb27a10d501927632af3c1febc275010c0d2e5abee630cd2bc792963fa82a42286ab047b934a261927311b40f5f953bfd661427921147cac7613d95ee86e16326ef67c1ed097e8fb87a78753d785de34e03a182232786079cb6be00182e41c9e":104:"77e3deba2c7f9386f85bc4a801":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"51644e025659de983f5c8156516b812e":"":"614837c743d0974e9cca497f13038c02":"60c5d062ade2c5c2dec68b734dd3e58ec474a586d1c4797fdfa2337800510134cb27a10d501927632af3c1febc275010c0d2e5abee630cd2bc792963fa82a42286ab047b934a261927311b40f5f953bfd661427921147cac7613d95ee86e16326ef67c1ed097e8fb87a78753d785de34e03a182232786079cb6be00182e41c9e":104:"77e3deba2c7f9386f85bc4a801":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"08566ca7310302dfb84d76ea0525ba20":"":"5f20ec9c35c08aa7f1c0e8a20fdbd2b3":"5d84e32768b8d1e7e3c426b3118d48e35491bf1bb454b359c8429220216efd8826be94fe1919409a128ccd8125a594f1691c9421fc3dbbb3f757bf2355bb0d074ceec165eb70e26eb53fa2cb5d84dfae06babb557805ef7b8c61c1bc76137571bcc5e84bf5987dc49013831d78bd497ccc49cde7dca2cb75e7ab967da8c6ce81":104:"873f037fc05252a44dc76f8155":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"08566ca7310302dfb84d76ea0525ba20":"":"5f20ec9c35c08aa7f1c0e8a20fdbd2b3":"5d84e32768b8d1e7e3c426b3118d48e35491bf1bb454b359c8429220216efd8826be94fe1919409a128ccd8125a594f1691c9421fc3dbbb3f757bf2355bb0d074ceec165eb70e26eb53fa2cb5d84dfae06babb557805ef7b8c61c1bc76137571bcc5e84bf5987dc49013831d78bd497ccc49cde7dca2cb75e7ab967da8c6ce81":104:"873f037fc05252a44dc76f8155":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dfb54db96383fa911bf5b4fa1218ef9a":"":"7e849e24983f63f1194b396bbd2d55e0":"d3fb689c5818810dd104693f3306a10b27178444af26798a194f7c2ab31ff3a172904b951942b1a26c8ae5b5b1ee2d86dc78bb72a335fde350766d7d9aef6f549871dd46b04b2cc319fcdd47be437d431ad18cab82d51ca9fa57f4108a8de622a92f87d28c0349fab27757fd773413f559a8c00d30e258c1f6cd96f9759bd957":96:"dada7fc7fed58db462854ef6":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dfb54db96383fa911bf5b4fa1218ef9a":"":"7e849e24983f63f1194b396bbd2d55e0":"d3fb689c5818810dd104693f3306a10b27178444af26798a194f7c2ab31ff3a172904b951942b1a26c8ae5b5b1ee2d86dc78bb72a335fde350766d7d9aef6f549871dd46b04b2cc319fcdd47be437d431ad18cab82d51ca9fa57f4108a8de622a92f87d28c0349fab27757fd773413f559a8c00d30e258c1f6cd96f9759bd957":96:"dada7fc7fed58db462854ef6":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"389cf888474e9403e5f4d0e22ffec439":"":"ef57794cf6fac9f9cea3e8499b53b1d6":"7ea7f7f4763ad208eb6199285b6b2819756c4e3caf2d0ac6f5076ae6785fecdcc4b138a51860ff8b87aaac3a18c2df778a4818308d458dba28f5017513e1454f60be20dae68736ea6d48b1f9deadb517df63140acbd329fbfbc9b82f3ca1862c9e998f0faff1d3ae60b005bf66829f5cf0c5fa03efbdd92d39351e3954be0257":96:"92726d90ad26130e65f2beb4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"389cf888474e9403e5f4d0e22ffec439":"":"ef57794cf6fac9f9cea3e8499b53b1d6":"7ea7f7f4763ad208eb6199285b6b2819756c4e3caf2d0ac6f5076ae6785fecdcc4b138a51860ff8b87aaac3a18c2df778a4818308d458dba28f5017513e1454f60be20dae68736ea6d48b1f9deadb517df63140acbd329fbfbc9b82f3ca1862c9e998f0faff1d3ae60b005bf66829f5cf0c5fa03efbdd92d39351e3954be0257":96:"92726d90ad26130e65f2beb4":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e55abb2ca36c822bf2a030ac703cb8b4":"":"d86f7177e8ec90f9e9edf10175d5012d":"777a9d93091de56324c10712243f5541722e0b27e1f303fef6faa387a8666161ab354dbea6c43c82a24e8623bfec39aab13164add6be0dfd55d23204c0975b4ba6fbda51363befde482a9ccc1eb9f151e6ad59c77a1e24dd268389e4686f198a936dd603044a3fb653d63cff80597f5a2913c8a2ec1b7d9dce5728dd56c78c2c":96:"65025250343ed8c09b3fceed":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e55abb2ca36c822bf2a030ac703cb8b4":"":"d86f7177e8ec90f9e9edf10175d5012d":"777a9d93091de56324c10712243f5541722e0b27e1f303fef6faa387a8666161ab354dbea6c43c82a24e8623bfec39aab13164add6be0dfd55d23204c0975b4ba6fbda51363befde482a9ccc1eb9f151e6ad59c77a1e24dd268389e4686f198a936dd603044a3fb653d63cff80597f5a2913c8a2ec1b7d9dce5728dd56c78c2c":96:"65025250343ed8c09b3fceed":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"586114f3b1dc087e1b2739b28c592dfe":"":"ae5a38ddd455505284434a4bcfe81ef2":"531ff8c285e532d961f49bd210a5523cd9b19a697a3a3fb26db940a496f253862405b1e825daeda7eb0445c98022b8342c8f8ea20301618483f8ab04b6ebccd7e7fc57878fb544a5bf78fa896f50ac30126ff8afca8a86388666b64c643d16812729bfd7e5c03ba52f7e6ea4c6a685404f7bcbd956964417fa0ea9a6d7290c41":64:"467a815610faeb82":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"586114f3b1dc087e1b2739b28c592dfe":"":"ae5a38ddd455505284434a4bcfe81ef2":"531ff8c285e532d961f49bd210a5523cd9b19a697a3a3fb26db940a496f253862405b1e825daeda7eb0445c98022b8342c8f8ea20301618483f8ab04b6ebccd7e7fc57878fb544a5bf78fa896f50ac30126ff8afca8a86388666b64c643d16812729bfd7e5c03ba52f7e6ea4c6a685404f7bcbd956964417fa0ea9a6d7290c41":64:"467a815610faeb82":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cbfe806bddb7f06b3826b097550c68f5":"":"04c1b6c9fd2ab76fc2adfe15d3421bbb":"cfa86d02599652cb4ffff027b9c6ef2336dc9fe946f64fa5ce83f624e144563d4738381bc5371c3cb55cf41ceda07e62cb635ff37246bfa428785229c6e869d5df69d7949a8577889a29e3d05b788ddd43608d9c14e3f1b51ce2085b9a976fe843e3396a74922babe6797d5f01c37ead623b5b582505bcd29edf8a6ea36b0fc7":64:"0697ac372a9acafd":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cbfe806bddb7f06b3826b097550c68f5":"":"04c1b6c9fd2ab76fc2adfe15d3421bbb":"cfa86d02599652cb4ffff027b9c6ef2336dc9fe946f64fa5ce83f624e144563d4738381bc5371c3cb55cf41ceda07e62cb635ff37246bfa428785229c6e869d5df69d7949a8577889a29e3d05b788ddd43608d9c14e3f1b51ce2085b9a976fe843e3396a74922babe6797d5f01c37ead623b5b582505bcd29edf8a6ea36b0fc7":64:"0697ac372a9acafd":"":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"96ce3a095a91effdd91d616f1f02ddcd":"":"579d6633ec6687afa24ef874899b58e0":"3ff3c0038148ed391b6a10aad623a82fe9209c5ba74482f11506d597b5fc7af977235d8ee9e28cf2160346ddd0e33a5bd1fb67b87dad7167fdd4b2b4000d8460ef7b3e1b59b9d61d06cfbe7945379ed6b650de86f396a38cc70d47b8a349f067d00144c903c276b323be6a929a7d7dd8ae7d254d640cdc1176f98e01a1d8c82f":64:"55a0f61032e048f3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"96ce3a095a91effdd91d616f1f02ddcd":"":"579d6633ec6687afa24ef874899b58e0":"3ff3c0038148ed391b6a10aad623a82fe9209c5ba74482f11506d597b5fc7af977235d8ee9e28cf2160346ddd0e33a5bd1fb67b87dad7167fdd4b2b4000d8460ef7b3e1b59b9d61d06cfbe7945379ed6b650de86f396a38cc70d47b8a349f067d00144c903c276b323be6a929a7d7dd8ae7d254d640cdc1176f98e01a1d8c82f":64:"55a0f61032e048f3":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"24ece168c2971cf2b404ea206dc9e29d":"":"e9db62a42491664a6c46cbb0b2bafc92":"3579f6c0cb3d2a5d0c4548855c7c052d36b6a8dfc60f4ca1b4bbe28ed87306119e71982dd84c4205ceba918d675472753df1b5192d3693dbf6a061c6056e312135ffc5ff426895a7e30f7f675d2cb21de06eea5e3761b94deef7537b985d324864c9ff6ab6e230a1006720f98c958912b604a6d03e3979887c07be3ceaafc78f":32:"d2b15a23":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"24ece168c2971cf2b404ea206dc9e29d":"":"e9db62a42491664a6c46cbb0b2bafc92":"3579f6c0cb3d2a5d0c4548855c7c052d36b6a8dfc60f4ca1b4bbe28ed87306119e71982dd84c4205ceba918d675472753df1b5192d3693dbf6a061c6056e312135ffc5ff426895a7e30f7f675d2cb21de06eea5e3761b94deef7537b985d324864c9ff6ab6e230a1006720f98c958912b604a6d03e3979887c07be3ceaafc78f":32:"d2b15a23":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d3c3cf993f6740a019e61ce13c29955c":"":"af900ac348082ff32d2e0ab886079516":"2ddd0e8c99661f0757f04aa79a1ffa24ad48fbe5da68b9e71f7a0cf1b4f2ca9b757695900b7549d48847ae49950dc9b270b1569d29dcbef412216737bd83509c17ae41c34ccda318939cb37a0a380762993a7568c0b07794e78746173dd5c0d921cd50de4b548c1589e142c3dadbad42161aaeda2310f3c6d5c722d9ac69e96d":32:"f2d3a6ff":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d3c3cf993f6740a019e61ce13c29955c":"":"af900ac348082ff32d2e0ab886079516":"2ddd0e8c99661f0757f04aa79a1ffa24ad48fbe5da68b9e71f7a0cf1b4f2ca9b757695900b7549d48847ae49950dc9b270b1569d29dcbef412216737bd83509c17ae41c34ccda318939cb37a0a380762993a7568c0b07794e78746173dd5c0d921cd50de4b548c1589e142c3dadbad42161aaeda2310f3c6d5c722d9ac69e96d":32:"f2d3a6ff":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,0,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5f1e5bd45ee8bb207ebbd730510ff218":"":"8846424a194f5de858556e6be5b65d7f":"e968947fc0e49136e730b97f6b16e393d5e4fdf3e4803a23af79211ef59f29167c60ead72fd489da32d2ffa43b2bca2074f9d1b4f5396ca65004b0806cb7c6dfa751fb6afbee3e443f3c9b0e3df6722e0d1320441400c5ca508afb657c2b7f1669b0de21761dccab9a40fc513768bd1f552692626ce35078a2e0e12f5d930647":32:"0d6c15da":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5f1e5bd45ee8bb207ebbd730510ff218":"":"8846424a194f5de858556e6be5b65d7f":"e968947fc0e49136e730b97f6b16e393d5e4fdf3e4803a23af79211ef59f29167c60ead72fd489da32d2ffa43b2bca2074f9d1b4f5396ca65004b0806cb7c6dfa751fb6afbee3e443f3c9b0e3df6722e0d1320441400c5ca508afb657c2b7f1669b0de21761dccab9a40fc513768bd1f552692626ce35078a2e0e12f5d930647":32:"0d6c15da":"":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3997050377cfbb802cc438d973661688":"b02f0dd373e42c65e8e1db2dd76a432e0b2bf6e630c8aaf0d48af51b3709b175de9a19b3245ae75818274c771c06fae225c4f8b002236712336e805ab006449eb29cc5e29abd82b06c32d4c36ee99acb9a6d7d9eae6ec6ec263c002a22c4a898c74f6abd6d92112367ca7ffe82787c5b39e7012ba22825d3612af3d41e8008a8":"c95c84c263bdfd5f1de66e7e616cf3fb":"":128:"b35b3cf6ed59ccb69dbc9b47a3f284ae":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3997050377cfbb802cc438d973661688":"b02f0dd373e42c65e8e1db2dd76a432e0b2bf6e630c8aaf0d48af51b3709b175de9a19b3245ae75818274c771c06fae225c4f8b002236712336e805ab006449eb29cc5e29abd82b06c32d4c36ee99acb9a6d7d9eae6ec6ec263c002a22c4a898c74f6abd6d92112367ca7ffe82787c5b39e7012ba22825d3612af3d41e8008a8":"c95c84c263bdfd5f1de66e7e616cf3fb":"":128:"b35b3cf6ed59ccb69dbc9b47a3f284ae":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c58583f6479d9bc9f1bffddefee66e59":"564a9f700cbc1f895e4f4fa6426f73b4956896a15e6127e7560d74e3fd0b980d2ee45b7a6a3884fa613d91d13921e3f90967d7132bdafcd146dd8ff7147ed1964c2bdb3e12f4133d3dbbc3bf030ff37b1d2147c493ce885068d9ba5bebae24903aaac004aa0ab73fe789e4150e75ddc2bde2700db02e6398d53e88ac652964ac":"cee448b48d3506ff3ecc227a87987846":"":128:"361fc2896d7ee986ecef7cbe665bc60c":"9cce7db3fc087d8cb384f6b1a81f03b3fafa2e3281e9f0fcf08a8283929f32439bb0d302516f0ab65b79181fc223a42345bad6e46ff8bcb55add90207f74481227f71a6230a3e13739ef2d015f5003638234b01e58537b7cfab5a8edac19721f41d46948987d1bb1b1d9485a672647bb3b5cb246a1d753a0d107bff036ac7d95":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c58583f6479d9bc9f1bffddefee66e59":"564a9f700cbc1f895e4f4fa6426f73b4956896a15e6127e7560d74e3fd0b980d2ee45b7a6a3884fa613d91d13921e3f90967d7132bdafcd146dd8ff7147ed1964c2bdb3e12f4133d3dbbc3bf030ff37b1d2147c493ce885068d9ba5bebae24903aaac004aa0ab73fe789e4150e75ddc2bde2700db02e6398d53e88ac652964ac":"cee448b48d3506ff3ecc227a87987846":"":128:"361fc2896d7ee986ecef7cbe665bc60c":"":"9cce7db3fc087d8cb384f6b1a81f03b3fafa2e3281e9f0fcf08a8283929f32439bb0d302516f0ab65b79181fc223a42345bad6e46ff8bcb55add90207f74481227f71a6230a3e13739ef2d015f5003638234b01e58537b7cfab5a8edac19721f41d46948987d1bb1b1d9485a672647bb3b5cb246a1d753a0d107bff036ac7d95":0 AES-GCM NIST Validation (AES-128,128,1024,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0bc2bde877e881aea512068105694968":"1a6369a45e8ef2846c42d54f92d0d140a94f9633432782dcbf094f1444a1d006acd07ef6076cd0faee226f9ff14adc1fb23e3c63ed818c9a743efbe16624981663e5a64f03f411dcd326e0c259bcadca3b3dd7660ed985c1b77f13a3b232a5934f8b54e46f8368c6e6eb75f933196fa973e7413e4b1442b9dee5e265b44255ed":"05f0c34ab2e8e8026b0a23719344b71f":"":128:"46bab9fc2dbe87b8f6ca0ed4d73e5368":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0bc2bde877e881aea512068105694968":"1a6369a45e8ef2846c42d54f92d0d140a94f9633432782dcbf094f1444a1d006acd07ef6076cd0faee226f9ff14adc1fb23e3c63ed818c9a743efbe16624981663e5a64f03f411dcd326e0c259bcadca3b3dd7660ed985c1b77f13a3b232a5934f8b54e46f8368c6e6eb75f933196fa973e7413e4b1442b9dee5e265b44255ed":"05f0c34ab2e8e8026b0a23719344b71f":"":128:"46bab9fc2dbe87b8f6ca0ed4d73e5368":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e14f45ba5d1eb52e0412240da5d7b5f9":"9a85fda19ce923f093a0c25b0c52f5d9534828af7c7687d22307004ae2d10c4592242c0f2704070307ab55b137780d1e2013a19396ab43ff6a295b63fdcf323456d149758f9a2bb37f1418d62ea6368b24d5067b9c63d2968e06d6586c7e3275faffa005f7c7bfef51303e4c2b2ed4564acd17d50efac9f5e3e7f16ce589c39b":"d7f8ef12f66f8b7c60aea02ef6ff688f":"":120:"beede05e4928c808bc660f3de95634":"4ad5b9ace0c0c7c07df2900faf37a902899471e7aa4a0a1ad5387f8f56d73f78f619be79a4e253f95b15d52895a05bae9ecffa916d35efacd8baf1c704d2aa4a38c234efc4dcfb191ec0fa0b522328fa5b5dff55e8c443fee660ebe3d8ad85de157a889aefc823720030a4cd6ba94a6309dd61806f0abb27772432018bc61701":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e14f45ba5d1eb52e0412240da5d7b5f9":"9a85fda19ce923f093a0c25b0c52f5d9534828af7c7687d22307004ae2d10c4592242c0f2704070307ab55b137780d1e2013a19396ab43ff6a295b63fdcf323456d149758f9a2bb37f1418d62ea6368b24d5067b9c63d2968e06d6586c7e3275faffa005f7c7bfef51303e4c2b2ed4564acd17d50efac9f5e3e7f16ce589c39b":"d7f8ef12f66f8b7c60aea02ef6ff688f":"":120:"beede05e4928c808bc660f3de95634":"":"4ad5b9ace0c0c7c07df2900faf37a902899471e7aa4a0a1ad5387f8f56d73f78f619be79a4e253f95b15d52895a05bae9ecffa916d35efacd8baf1c704d2aa4a38c234efc4dcfb191ec0fa0b522328fa5b5dff55e8c443fee660ebe3d8ad85de157a889aefc823720030a4cd6ba94a6309dd61806f0abb27772432018bc61701":0 AES-GCM NIST Validation (AES-128,128,1024,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a64579f3601b0022d357b601cd876ab":"88be1f4bc8c81b8a9d7abc073cb2751e209ab6b912c15dc094002f95a57a660b9f08b1b34f5947223205b579e704d70a9ecb54520ce3491e52965be643f729516f5cb018beeedc68a7d66c0d40a3f392ec7729c566ce1e9f964c4c0bd61b291ccb96e3d1fac18a401a302f3775697c71edb8ff5a8275a815eba9dd3b912e3759":"515efc6d036f95db7df56b1bbec0aff2":"":120:"13ea92ba35fced366d1e47c97ca5c9":"7fc8565760c168d640f24896c69758355b17310dbc359f38b73fc7b57fe3f4b6ecad3f298be931c96a639df3c5744f7e932b32d222f5534efb8eb5d5b98d218dce3efef5c8c7ce65738bf63412d0a8ed209071218a6fa2f7be79b38d0b2f5b571ec73f1a91721bd409b1722b313683e97d53df19ded95fd471124fa5f294a4bb":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a64579f3601b0022d357b601cd876ab":"88be1f4bc8c81b8a9d7abc073cb2751e209ab6b912c15dc094002f95a57a660b9f08b1b34f5947223205b579e704d70a9ecb54520ce3491e52965be643f729516f5cb018beeedc68a7d66c0d40a3f392ec7729c566ce1e9f964c4c0bd61b291ccb96e3d1fac18a401a302f3775697c71edb8ff5a8275a815eba9dd3b912e3759":"515efc6d036f95db7df56b1bbec0aff2":"":120:"13ea92ba35fced366d1e47c97ca5c9":"":"7fc8565760c168d640f24896c69758355b17310dbc359f38b73fc7b57fe3f4b6ecad3f298be931c96a639df3c5744f7e932b32d222f5534efb8eb5d5b98d218dce3efef5c8c7ce65738bf63412d0a8ed209071218a6fa2f7be79b38d0b2f5b571ec73f1a91721bd409b1722b313683e97d53df19ded95fd471124fa5f294a4bb":0 AES-GCM NIST Validation (AES-128,128,1024,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1bda4acfd10ab635f357935bb0ab7020":"c9ac8d4ef7d83848fdc03664957c28b9b76710797d5db1c21e713e85eb0898892223e52be1644fc7362c95026ebb9c9ca74d7d3739eff10cab1eda00c36628dae0b98d119a14635800e37cd340faa6fbba9c3d41d52722cc3969612b1a8c5ca9a68773f5ee654506cb88ea65fb1eddf5ab6312d0170dc03324e483342448b854":"48b77c587616ffaa449533a91230b449":"":120:"8325e4394c91719691145e68e56439":"1287ad3719508a9be70c19e3b134a2eaa4415d736c55922e9abcfd7f621ea07ffb9b78d8a9668c74bbd548b5e6519ea12609d2d6197c8bd3da9c13c46628f218e7ff81884ff7eb34664ab00f86e09cd623bec248d8898ef054fce8f718a0e0978e8b5d037709c524114ec37809ac3fd1604e223e08f594e7aa12097f7dc1850b":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1bda4acfd10ab635f357935bb0ab7020":"c9ac8d4ef7d83848fdc03664957c28b9b76710797d5db1c21e713e85eb0898892223e52be1644fc7362c95026ebb9c9ca74d7d3739eff10cab1eda00c36628dae0b98d119a14635800e37cd340faa6fbba9c3d41d52722cc3969612b1a8c5ca9a68773f5ee654506cb88ea65fb1eddf5ab6312d0170dc03324e483342448b854":"48b77c587616ffaa449533a91230b449":"":120:"8325e4394c91719691145e68e56439":"":"1287ad3719508a9be70c19e3b134a2eaa4415d736c55922e9abcfd7f621ea07ffb9b78d8a9668c74bbd548b5e6519ea12609d2d6197c8bd3da9c13c46628f218e7ff81884ff7eb34664ab00f86e09cd623bec248d8898ef054fce8f718a0e0978e8b5d037709c524114ec37809ac3fd1604e223e08f594e7aa12097f7dc1850b":0 AES-GCM NIST Validation (AES-128,128,1024,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d21cf24bc5bd176b4b0fd4c8477bb70d":"2e7108fd25c88b799263791940594ec80b26ccd53455c837b2e6cf4e27fcf9707af3f0fe311355e1b03ac3b5ee0af09fb6fb9f0311f8545d40a658119e6a87ba8ba72cc5fdb1386bc455c8fec51a7c0fec957bed4d6441180741197962d51b17c393b57553e53602f2a343a0871ea2dc4b1506663b2768ce271b89c4ed99eec6":"208cb9dced20b18edddb91596e902124":"":112:"7edfb9daf8ca2babcc02537463e9":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d21cf24bc5bd176b4b0fd4c8477bb70d":"2e7108fd25c88b799263791940594ec80b26ccd53455c837b2e6cf4e27fcf9707af3f0fe311355e1b03ac3b5ee0af09fb6fb9f0311f8545d40a658119e6a87ba8ba72cc5fdb1386bc455c8fec51a7c0fec957bed4d6441180741197962d51b17c393b57553e53602f2a343a0871ea2dc4b1506663b2768ce271b89c4ed99eec6":"208cb9dced20b18edddb91596e902124":"":112:"7edfb9daf8ca2babcc02537463e9":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d02e2b02170986944487cba8448f998":"bc1d7553f4a28754cf59ed6f7a901901f04ce62a449db2b45ad60329d0341bb9ba421c783c28a9200b41da8ab6328d826293134a7d0c9a5775dd2735e7767efda4ad183566e0847d6d978abd1a8ab13b16b8323acef05ced3b571631e1e24ad44d65e6ffa64e03c9970e94bacb9f721aba06cda6a08806a3be63dddd8029301d":"6336077bb83eff1c9ea715de99b372cd":"":112:"0466bb2957281f64b59eafed3509":"5f395958f2f7acafb1bca6d3a6ec48b717f2ceeac1b77e1b0edc09a09e4a299d2ec722cc7daf34c8f4121a93c80b2adb20a2fc95afd09320f91085c93c8b082dd703814c9777501d23bf9b328f07f04652592dc5a3f4321626a695b8db8e65c8617c809eb2978d8c9a882ffa82a4bb707c1a8f9a965bdacce5c041bafc94a1c6":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d02e2b02170986944487cba8448f998":"bc1d7553f4a28754cf59ed6f7a901901f04ce62a449db2b45ad60329d0341bb9ba421c783c28a9200b41da8ab6328d826293134a7d0c9a5775dd2735e7767efda4ad183566e0847d6d978abd1a8ab13b16b8323acef05ced3b571631e1e24ad44d65e6ffa64e03c9970e94bacb9f721aba06cda6a08806a3be63dddd8029301d":"6336077bb83eff1c9ea715de99b372cd":"":112:"0466bb2957281f64b59eafed3509":"":"5f395958f2f7acafb1bca6d3a6ec48b717f2ceeac1b77e1b0edc09a09e4a299d2ec722cc7daf34c8f4121a93c80b2adb20a2fc95afd09320f91085c93c8b082dd703814c9777501d23bf9b328f07f04652592dc5a3f4321626a695b8db8e65c8617c809eb2978d8c9a882ffa82a4bb707c1a8f9a965bdacce5c041bafc94a1c6":0 AES-GCM NIST Validation (AES-128,128,1024,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cd1ad1de0521d41645d13c97a18f4a20":"588c2617517329f3e1e7ba6206a183dc9232e6a4fa8c8b89532d46235af1e542acaa7eae4d034f139b00449076ba2ef9a692cae422998878dabdac60993dce9880d280bec1419803ba937366e5285c4a7f31a5f232f8d3ef73efe7267b3ef82a02f97d320ebc9db6219fbdf1c7f611e8e5164e9ecf25b32f9c07dfa12aa705af":"413873a0b063ad039da5513896233286":"":112:"d4dbe9cae116553b0cbe1984d176":"bd519b7e6921e6026784cd7b836c89bc1fa98e4013b41d2bf091ef0d602e44a70df89816c068d37f0c6377af46c8bfa73ec0d5bc0b61966f23e55a15a83cea49f37cc02213b4996f9353ee2b73a798b626e524b9c15937ecf98a4eded83fb62e6deea1de31e0a7f1d210f6d964bc3e69b269da834720fd33487874489b8932a8":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cd1ad1de0521d41645d13c97a18f4a20":"588c2617517329f3e1e7ba6206a183dc9232e6a4fa8c8b89532d46235af1e542acaa7eae4d034f139b00449076ba2ef9a692cae422998878dabdac60993dce9880d280bec1419803ba937366e5285c4a7f31a5f232f8d3ef73efe7267b3ef82a02f97d320ebc9db6219fbdf1c7f611e8e5164e9ecf25b32f9c07dfa12aa705af":"413873a0b063ad039da5513896233286":"":112:"d4dbe9cae116553b0cbe1984d176":"":"bd519b7e6921e6026784cd7b836c89bc1fa98e4013b41d2bf091ef0d602e44a70df89816c068d37f0c6377af46c8bfa73ec0d5bc0b61966f23e55a15a83cea49f37cc02213b4996f9353ee2b73a798b626e524b9c15937ecf98a4eded83fb62e6deea1de31e0a7f1d210f6d964bc3e69b269da834720fd33487874489b8932a8":0 AES-GCM NIST Validation (AES-128,128,1024,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cb120e9cd718b5119b4a58af0644eff":"4c8e8fb8c87ff6b994ae71bfbf0fa4529f03bad86edf9d27cf899ea93a32972640697e00546136c1dbc7e63662200951b6479c58ae26b1bd8c3b4f507c0d945d615183196868ec4f4865d1d00bb919a00184e9663f6cb9a7a0ddfc73ee2901f7a56ef2074d554f48cef254be558fca35651be405f91c39e0367762b4715d05fa":"5a7087989bfe2f6eddcb56fde4d72529":"":104:"95d8bd12af8a5ab677309df0fb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cb120e9cd718b5119b4a58af0644eff":"4c8e8fb8c87ff6b994ae71bfbf0fa4529f03bad86edf9d27cf899ea93a32972640697e00546136c1dbc7e63662200951b6479c58ae26b1bd8c3b4f507c0d945d615183196868ec4f4865d1d00bb919a00184e9663f6cb9a7a0ddfc73ee2901f7a56ef2074d554f48cef254be558fca35651be405f91c39e0367762b4715d05fa":"5a7087989bfe2f6eddcb56fde4d72529":"":104:"95d8bd12af8a5ab677309df0fb":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"315b206778c28ed0bfdd6e66088a5c39":"6186f57a85b65f54efbf9974a193012b1396fc0ca887227e1865f1c915ac2af9bbd55969f7de57ce9fb87604cf11c7bc822b542f745be8a101877a810ed72bf4544d0acb91f0f9d3c30b6a18c48b82557433d0db930e03bcecc6fb53530bfd99ee89f9e154aa1a3e2a2c2a7a9e08c9aed1deab7fae8ea5a31158b50bca2f5e79":"7ec6f47ec56dda5b52bbdaa6ad2eb6da":"":104:"930750c53effc7b84aa10b2276":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"315b206778c28ed0bfdd6e66088a5c39":"6186f57a85b65f54efbf9974a193012b1396fc0ca887227e1865f1c915ac2af9bbd55969f7de57ce9fb87604cf11c7bc822b542f745be8a101877a810ed72bf4544d0acb91f0f9d3c30b6a18c48b82557433d0db930e03bcecc6fb53530bfd99ee89f9e154aa1a3e2a2c2a7a9e08c9aed1deab7fae8ea5a31158b50bca2f5e79":"7ec6f47ec56dda5b52bbdaa6ad2eb6da":"":104:"930750c53effc7b84aa10b2276":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e886de1c907c97e7db8ec80a79df90f8":"c64cc9596d7c738746ab800f688eec190a4c802c55b2528931d74d294496892b81f53d3073d48f9bef1d58ce3be26547474cdda2868abeab71aff566fff613b4e5bfed1be1d2fff35d8ffa33302d3da1c82e421aa3a23848f31e26d90c0cb2ac2ae136ada73404ed3e0e1d3e7cb355a11cd2a4f9393b4d5eac988104fe1cf959":"612cacbf33266353d0a29a24532f3c0c":"":104:"76634e58d8f3a48f15875ac1d6":"7001d7395efb432e2804cc65c0ba5d4719ce84177ce46292c4fd62a5596bd2bab1d5c44217ac43235bd94489c43d01618a11f047d2e247062c3b88d6e59adaa1f46514fb33b7843483920bee60a41f3cb312322c305d25251b4704fb66da58637c95a9d539731434f60ef44fe3cd6d37e2c8e7089880a563938dcc98b43f08fd":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e886de1c907c97e7db8ec80a79df90f8":"c64cc9596d7c738746ab800f688eec190a4c802c55b2528931d74d294496892b81f53d3073d48f9bef1d58ce3be26547474cdda2868abeab71aff566fff613b4e5bfed1be1d2fff35d8ffa33302d3da1c82e421aa3a23848f31e26d90c0cb2ac2ae136ada73404ed3e0e1d3e7cb355a11cd2a4f9393b4d5eac988104fe1cf959":"612cacbf33266353d0a29a24532f3c0c":"":104:"76634e58d8f3a48f15875ac1d6":"":"7001d7395efb432e2804cc65c0ba5d4719ce84177ce46292c4fd62a5596bd2bab1d5c44217ac43235bd94489c43d01618a11f047d2e247062c3b88d6e59adaa1f46514fb33b7843483920bee60a41f3cb312322c305d25251b4704fb66da58637c95a9d539731434f60ef44fe3cd6d37e2c8e7089880a563938dcc98b43f08fd":0 AES-GCM NIST Validation (AES-128,128,1024,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3b936e09a6477f3bd52030a29df5001d":"65cf11d1afad19b34f282f98f140315992392f5d4eed4265085b29e1e5553f4783fec681ba2d368486ba6a54c00e71c82c08ca3d097904f021ce4b0acba2d2a7005e28e5f8750ea3d18a4f78363c37583e85104234498942c639a0564b0d80055c21cb7735dd44348298291ab602f345b1d74d624750c0177fbd5cca6f99223b":"f93105be83fa5e315d73acfdcf578de7":"":96:"91b55bb5e3f3f1abcf335db5":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3b936e09a6477f3bd52030a29df5001d":"65cf11d1afad19b34f282f98f140315992392f5d4eed4265085b29e1e5553f4783fec681ba2d368486ba6a54c00e71c82c08ca3d097904f021ce4b0acba2d2a7005e28e5f8750ea3d18a4f78363c37583e85104234498942c639a0564b0d80055c21cb7735dd44348298291ab602f345b1d74d624750c0177fbd5cca6f99223b":"f93105be83fa5e315d73acfdcf578de7":"":96:"91b55bb5e3f3f1abcf335db5":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dc9e2095de7b1b48481b56bf6a3604cd":"ed61ff94a3f84c72147faefa615e2df00324fb01790cf9764c72c1b8ba47f17866a1fd64ee5c2f53865d1bc24ec93165a6774466a59603199ee476c1f2da7d932c8943d126aa172d532d8475a484d42bb45fcf92766feafd7f3e2e3d42d22f6f84a90e7e688232f799d80cd2cc152ddd21ecfb137701ecafcb2b65abe2e4e6f4":"9e5268db19a1b51c0496a160ca76f8f7":"":96:"0fa9588536fca71bb44260f7":"ef562e301fcf923ff1a1acd3aff9b1c963058228655fe8a66cab01396547dbd2aa1f79a22eefc62944b86d1a31ebe2d17130175b8c003d6755b0eb8b79895b0f7f8046c5ae888a067ba17bc8e11a8f6e5023a9cd42f6461966c28e505b371c0f72a2606bff430a58016e99713d25ce11f10391fb4a922e27989422c6a64f9107":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dc9e2095de7b1b48481b56bf6a3604cd":"ed61ff94a3f84c72147faefa615e2df00324fb01790cf9764c72c1b8ba47f17866a1fd64ee5c2f53865d1bc24ec93165a6774466a59603199ee476c1f2da7d932c8943d126aa172d532d8475a484d42bb45fcf92766feafd7f3e2e3d42d22f6f84a90e7e688232f799d80cd2cc152ddd21ecfb137701ecafcb2b65abe2e4e6f4":"9e5268db19a1b51c0496a160ca76f8f7":"":96:"0fa9588536fca71bb44260f7":"":"ef562e301fcf923ff1a1acd3aff9b1c963058228655fe8a66cab01396547dbd2aa1f79a22eefc62944b86d1a31ebe2d17130175b8c003d6755b0eb8b79895b0f7f8046c5ae888a067ba17bc8e11a8f6e5023a9cd42f6461966c28e505b371c0f72a2606bff430a58016e99713d25ce11f10391fb4a922e27989422c6a64f9107":0 AES-GCM NIST Validation (AES-128,128,1024,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3f93901fd7cc88db3ba76a158d658c7b":"16402fded879fcbfe9405902aa63ca2a520889e0045f687455469b7bb867829a01208b8dc5dcc852d8ee478993c30e6d9ec6408773b367821310a0ae171d38d71e06981ff6e845acffbc794142b87c748e12484c0636419d79be3d798cde59e9dae0a4a4a4346596427e6b235ad52e6a1b02d6f4df0c7de35fc390cae36aef14":"7e98de461e6d96c0ce6c8d8b3854cf49":"":96:"86c9a70e4bab304ae46e6542":"1b4c09569b42c469b3ab6b39312c214502ec09f5fe2fed1d1933d13cdc6a7b77a5d135123fa69d9207d6844b0357b26b7a2f53b33a5cd218dacda87b78b09cf259e48e74076812c432e2d0833fb269721f9347c96e158500f9b2283342a35c8de0a022edce711118d72d8fbaa354bfb0ffee465844ef2d37e24ec2cea8556648":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3f93901fd7cc88db3ba76a158d658c7b":"16402fded879fcbfe9405902aa63ca2a520889e0045f687455469b7bb867829a01208b8dc5dcc852d8ee478993c30e6d9ec6408773b367821310a0ae171d38d71e06981ff6e845acffbc794142b87c748e12484c0636419d79be3d798cde59e9dae0a4a4a4346596427e6b235ad52e6a1b02d6f4df0c7de35fc390cae36aef14":"7e98de461e6d96c0ce6c8d8b3854cf49":"":96:"86c9a70e4bab304ae46e6542":"":"1b4c09569b42c469b3ab6b39312c214502ec09f5fe2fed1d1933d13cdc6a7b77a5d135123fa69d9207d6844b0357b26b7a2f53b33a5cd218dacda87b78b09cf259e48e74076812c432e2d0833fb269721f9347c96e158500f9b2283342a35c8de0a022edce711118d72d8fbaa354bfb0ffee465844ef2d37e24ec2cea8556648":0 AES-GCM NIST Validation (AES-128,128,1024,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"42289f3d3cd5838e250ef54b128e60d1":"3edae1d554b67d2036f5fdbdb2945cc112f100adc1b47009c2e23f6a2eaee78d1f39ce8a98f715853cc29fc793fb6981ec3036834188dea7d668185ccc8642071b15de1332f6a59c8a9b4399733eb4b3d8f224af57ba6b4a8e64494bb6630b9d28e7ec3349064350febcef6a3ad1d6cca1b1da74f3d2921c2b28a2dd399c3416":"e557389a216ad724aafdab0180e1892e":"":64:"6f78bc809f31393e":"25c476659cc7b343a69088baf868a811ba37daca85c4093105bf98235a90aeca015ab034da008af0982f9b2e80df804c186a9b2e97f74cffd70ebb7771d874fcaf12f6d01c44a8b0ec2898cf4493cf09a16a88a65cd77909bbf0430c9603869bd5f20d56cb51d8a3f0a032fc30d925c96599d296b1ec41c2912bda426adea4fb":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"42289f3d3cd5838e250ef54b128e60d1":"3edae1d554b67d2036f5fdbdb2945cc112f100adc1b47009c2e23f6a2eaee78d1f39ce8a98f715853cc29fc793fb6981ec3036834188dea7d668185ccc8642071b15de1332f6a59c8a9b4399733eb4b3d8f224af57ba6b4a8e64494bb6630b9d28e7ec3349064350febcef6a3ad1d6cca1b1da74f3d2921c2b28a2dd399c3416":"e557389a216ad724aafdab0180e1892e":"":64:"6f78bc809f31393e":"":"25c476659cc7b343a69088baf868a811ba37daca85c4093105bf98235a90aeca015ab034da008af0982f9b2e80df804c186a9b2e97f74cffd70ebb7771d874fcaf12f6d01c44a8b0ec2898cf4493cf09a16a88a65cd77909bbf0430c9603869bd5f20d56cb51d8a3f0a032fc30d925c96599d296b1ec41c2912bda426adea4fb":0 AES-GCM NIST Validation (AES-128,128,1024,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d772eabb7f19475665ca2a7e693bcfc":"e9fc4d86f5b857fa6057b73f967351e06f87288c40a95b9e378c84f1a4c0f4b80ed0a0b44ff90a8973be4199c0c4006fc4f5ea19d5f1fe8b9c8c01f4675ab85afab0592bb3daba36bb4fc7ed9eea867e9d8cc50c19fb62a5a57956e9efacebac5e9f849649d35a329bd68de97bb6e5ff7bef477a86765c2c9ec15e24cbba5c6e":"0747cbb486a013453fde1ca6abb11dbe":"":64:"8e761ffaea68f967":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d772eabb7f19475665ca2a7e693bcfc":"e9fc4d86f5b857fa6057b73f967351e06f87288c40a95b9e378c84f1a4c0f4b80ed0a0b44ff90a8973be4199c0c4006fc4f5ea19d5f1fe8b9c8c01f4675ab85afab0592bb3daba36bb4fc7ed9eea867e9d8cc50c19fb62a5a57956e9efacebac5e9f849649d35a329bd68de97bb6e5ff7bef477a86765c2c9ec15e24cbba5c6e":"0747cbb486a013453fde1ca6abb11dbe":"":64:"8e761ffaea68f967":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fb7fd753ee6eaaf283a42a121dab4e43":"fd5cecb2c0287cb8229e97d9cc4b9885f428710528884ce663ed1728cd44cb2df93e56ef17ace0678d1e341366c652f4ba7ee45797d39be4a05c1151e5cde499e13e5d45549b5d95a174d03616d06ef96e9d7b2b6bb0d79a726b253dd64223a5f09611671b234ccf9b383952f8888814b2c167e774cfbf54e9c6b99a753f4fa9":"8164929fb54485377ecccc9b9621af5e":"":64:"40a2fa7f4370afb2":"6208d068be60f7b04b80fc611062e6caaef9a5cf59f850d174b7446c78c039ea9aefe4885e19c2b33911d32ce1fe3c48ddffa4b03e450fd35da03f40c4e7c5bb3b1c3f3049dbfad3ac81ca1b79cafbaa172f4900e3829d38edea3b64000f93924a801259bc4b2523445c64bc23bfee190b952468507fa4baf6dc2bec66fcf0d8":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fb7fd753ee6eaaf283a42a121dab4e43":"fd5cecb2c0287cb8229e97d9cc4b9885f428710528884ce663ed1728cd44cb2df93e56ef17ace0678d1e341366c652f4ba7ee45797d39be4a05c1151e5cde499e13e5d45549b5d95a174d03616d06ef96e9d7b2b6bb0d79a726b253dd64223a5f09611671b234ccf9b383952f8888814b2c167e774cfbf54e9c6b99a753f4fa9":"8164929fb54485377ecccc9b9621af5e":"":64:"40a2fa7f4370afb2":"":"6208d068be60f7b04b80fc611062e6caaef9a5cf59f850d174b7446c78c039ea9aefe4885e19c2b33911d32ce1fe3c48ddffa4b03e450fd35da03f40c4e7c5bb3b1c3f3049dbfad3ac81ca1b79cafbaa172f4900e3829d38edea3b64000f93924a801259bc4b2523445c64bc23bfee190b952468507fa4baf6dc2bec66fcf0d8":0 AES-GCM NIST Validation (AES-128,128,1024,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30d757fd73a0fd5fa49159ad0653296d":"17d485b258f80d8924e35291118cfdcffd86c47851b65f0b06a7c1f5202de82f3f460fc61b1aa38fdba7c8ded375c92cf005afe63e59d362c0960044af39241b81ca24e85c5faa43903229355b7313fee21b992ef3931d9d2407b32b3cf72dd7acbc7948395eb513cb2fd428b215ba2bd1e29c62f45d0ce231884f62480c6d8f":"b35b8df0aebd0608517f2830e0e70cd0":"":32:"954c0e99":"022618d2598f79104e918a09c937a82b3db59243b5e13de731fcb912e4366105797ce47f6dce7f08073f2f41e5c15fd6b1ec4b5861469a4880c3b0bd769b78c696ff29c28c9349d5a46a6e5ad9211bd4b708a8c0b6928ebbb0dac1c0a5f5ce6b05de6a50073128566a23f09cc1b826aa5803f9f750aa4debf59f24ae9f98c9b5":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30d757fd73a0fd5fa49159ad0653296d":"17d485b258f80d8924e35291118cfdcffd86c47851b65f0b06a7c1f5202de82f3f460fc61b1aa38fdba7c8ded375c92cf005afe63e59d362c0960044af39241b81ca24e85c5faa43903229355b7313fee21b992ef3931d9d2407b32b3cf72dd7acbc7948395eb513cb2fd428b215ba2bd1e29c62f45d0ce231884f62480c6d8f":"b35b8df0aebd0608517f2830e0e70cd0":"":32:"954c0e99":"":"022618d2598f79104e918a09c937a82b3db59243b5e13de731fcb912e4366105797ce47f6dce7f08073f2f41e5c15fd6b1ec4b5861469a4880c3b0bd769b78c696ff29c28c9349d5a46a6e5ad9211bd4b708a8c0b6928ebbb0dac1c0a5f5ce6b05de6a50073128566a23f09cc1b826aa5803f9f750aa4debf59f24ae9f98c9b5":0 AES-GCM NIST Validation (AES-128,128,1024,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d9d3cfd5900de5d5e2109e7721cfeef6":"e4243cc37cc32dfcedf9bb76890e706af6ab1e06b290b8ccfe2a55e5dabe68cb390f7636dc9676b431d4dc8ad3f6d989e510194294ab7ab0556789046743cf374d8b6462f5f95a17f3f44337d6c69ee47b0e1ad7e5ce6f9b224c54099a104e70d2d06af869b921ea47febe08f90c591ed49c1f12003afceabd2c7bba458a0111":"b4b9dfb013de6f7c44779e5a9daaf5e5":"":32:"2b81e8ce":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d9d3cfd5900de5d5e2109e7721cfeef6":"e4243cc37cc32dfcedf9bb76890e706af6ab1e06b290b8ccfe2a55e5dabe68cb390f7636dc9676b431d4dc8ad3f6d989e510194294ab7ab0556789046743cf374d8b6462f5f95a17f3f44337d6c69ee47b0e1ad7e5ce6f9b224c54099a104e70d2d06af869b921ea47febe08f90c591ed49c1f12003afceabd2c7bba458a0111":"b4b9dfb013de6f7c44779e5a9daaf5e5":"":32:"2b81e8ce":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"68dc138f19354d73eaa1cf0e79231d74":"ce345567a76bc30d8b4fd2239788221cfa75e1a310aeeeb8c355f8eea57d80967f3047fbd4e6173fac5caeb22151fa607065953c4c35e0537b9e3788cc80de9eedf2a340698bde99a6a1bdc81265319da3e52f7a53883b7f21749237fcfd3cd4f149bb2be7a4ddd9ef0544cfe0789040d1dc951b6447304942f03ab0beae8866":"e7147749560f491420a2d893c075bb76":"":32:"70a83f6f":"64b021612c78b3e192e8349d48b77d02927e7fd70c7160d37cb8ef472f6bcd9df9d93431627c1c80875e208724ae05f94fdd2e005e9707b78a1bf3bbca7beec4b03ddd4d9de6235ffd6d84a8b9a1842e104c1e22df4566f6c4d3d4e3d96a56b9b8a5cdce9da70aa236109b289266036f285564060b204dfd7ac915eea0dd0b1e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"68dc138f19354d73eaa1cf0e79231d74":"ce345567a76bc30d8b4fd2239788221cfa75e1a310aeeeb8c355f8eea57d80967f3047fbd4e6173fac5caeb22151fa607065953c4c35e0537b9e3788cc80de9eedf2a340698bde99a6a1bdc81265319da3e52f7a53883b7f21749237fcfd3cd4f149bb2be7a4ddd9ef0544cfe0789040d1dc951b6447304942f03ab0beae8866":"e7147749560f491420a2d893c075bb76":"":32:"70a83f6f":"":"64b021612c78b3e192e8349d48b77d02927e7fd70c7160d37cb8ef472f6bcd9df9d93431627c1c80875e208724ae05f94fdd2e005e9707b78a1bf3bbca7beec4b03ddd4d9de6235ffd6d84a8b9a1842e104c1e22df4566f6c4d3d4e3d96a56b9b8a5cdce9da70aa236109b289266036f285564060b204dfd7ac915eea0dd0b1e":0 AES-GCM NIST Validation (AES-128,128,1024,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7362c86344e0aefb0cf0d04768f9c05d":"8baffc7836004deb87c0111d47c182512bf861874021ddfcd559acf2c4a51cf5bc4bfdee2d039b9c005b6af95a2607643dcf4d9cd9d62412f709334556db22fc91d7b40438505d6806ccb2f2c21ae731bc1f1c825d28a71ab27095a39985e96ccd07cfb2e75243ccafd474494a2338c324ef533ca5f17d2ac1b1883140342ced":"7e8d12c2f0dcf4f792247134234ac94b":"86d2b5debc3b10495da353d6821f6cad380776d805bd8660b08dcdb1acd87026e4f344b547a4db47b5f44cded314bec4ce9a417ce40a2acd5a21460c42dfcd27483abf3f38dd8cc5fa523b6768a26513df5896435baa97781cff1966e2e3d6ec6d0a9cdc013de5a50e4d46831667055bad04f784024a82f9cd087ae4cd37dd64":128:"9594da428fd8c1b13ecb23afa2c1af2e":"e2c424f42aedd56f0e17a39d43ad19c8e2731efc7a25f077aef51d55280b10e667e338bd981b82a975ef62bf53bc52496b6995d33c90c7ae14767c126826e3f32bd23f444ddcfd7a0dd323b0ae2c22defad04ce63892b45c176bd0b86f5fa057a3dc371359744cb80bbfb4a195755136a0ea90b4044a45bc1b069f3cb3695c04":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7362c86344e0aefb0cf0d04768f9c05d":"8baffc7836004deb87c0111d47c182512bf861874021ddfcd559acf2c4a51cf5bc4bfdee2d039b9c005b6af95a2607643dcf4d9cd9d62412f709334556db22fc91d7b40438505d6806ccb2f2c21ae731bc1f1c825d28a71ab27095a39985e96ccd07cfb2e75243ccafd474494a2338c324ef533ca5f17d2ac1b1883140342ced":"7e8d12c2f0dcf4f792247134234ac94b":"86d2b5debc3b10495da353d6821f6cad380776d805bd8660b08dcdb1acd87026e4f344b547a4db47b5f44cded314bec4ce9a417ce40a2acd5a21460c42dfcd27483abf3f38dd8cc5fa523b6768a26513df5896435baa97781cff1966e2e3d6ec6d0a9cdc013de5a50e4d46831667055bad04f784024a82f9cd087ae4cd37dd64":128:"9594da428fd8c1b13ecb23afa2c1af2e":"":"e2c424f42aedd56f0e17a39d43ad19c8e2731efc7a25f077aef51d55280b10e667e338bd981b82a975ef62bf53bc52496b6995d33c90c7ae14767c126826e3f32bd23f444ddcfd7a0dd323b0ae2c22defad04ce63892b45c176bd0b86f5fa057a3dc371359744cb80bbfb4a195755136a0ea90b4044a45bc1b069f3cb3695c04":0 AES-GCM NIST Validation (AES-128,128,1024,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"58748bb204ccb7bdafdbf739b6c19a3e":"b72902c9ebb72a86be539b19a52fd9af00aa4de081d90c0d8ad580ebb5900177a036f40a1e9b43e3a07d715466526d6d7544e5a5551805b62463f956cd519fc99182c2d54bd62fc7ffc6e5ebf1503859b706da11a1b6c707a67a70789dbfc10ef726bd360f9f2347326e068e757c8443ddc9308a171e682359ae1bfe87194ab5":"93ac298c73c88e127a4d9dd81bf24e3d":"8f168fc4d1da13bdbefae3f9d6ac1d8cb19fcec1f43f727951af0a466d8826649a46c3cb50c045ea83849fce0eedbc042a1a435e6d9d59017997a2d5459b940078b8a7f3b6b0ff279ff8c560248296a17240ff1b0643d1f436b6e3f2079363fc49fb45f410debbdde083b92057916368cb807d603cb82e2c0dc01658bff7f1ab":128:"efba4589d4a03555766bbc3b421dd60f":"d5c97a659f016904ff76286f810e8e92da6f8db2c63d8a42e617760780637e32105503440cdf04d1fe67813312f1479fda8d746c8b0b080591eba83850382f600e9d8680516c6579669f0b3d0a30323510f9de1c92512790b8347751994d022156cae64da0808a649d163a0e99e869fdf224b7c1a6a8fbc613d5917eca8ee08c":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"58748bb204ccb7bdafdbf739b6c19a3e":"b72902c9ebb72a86be539b19a52fd9af00aa4de081d90c0d8ad580ebb5900177a036f40a1e9b43e3a07d715466526d6d7544e5a5551805b62463f956cd519fc99182c2d54bd62fc7ffc6e5ebf1503859b706da11a1b6c707a67a70789dbfc10ef726bd360f9f2347326e068e757c8443ddc9308a171e682359ae1bfe87194ab5":"93ac298c73c88e127a4d9dd81bf24e3d":"8f168fc4d1da13bdbefae3f9d6ac1d8cb19fcec1f43f727951af0a466d8826649a46c3cb50c045ea83849fce0eedbc042a1a435e6d9d59017997a2d5459b940078b8a7f3b6b0ff279ff8c560248296a17240ff1b0643d1f436b6e3f2079363fc49fb45f410debbdde083b92057916368cb807d603cb82e2c0dc01658bff7f1ab":128:"efba4589d4a03555766bbc3b421dd60f":"":"d5c97a659f016904ff76286f810e8e92da6f8db2c63d8a42e617760780637e32105503440cdf04d1fe67813312f1479fda8d746c8b0b080591eba83850382f600e9d8680516c6579669f0b3d0a30323510f9de1c92512790b8347751994d022156cae64da0808a649d163a0e99e869fdf224b7c1a6a8fbc613d5917eca8ee08c":0 AES-GCM NIST Validation (AES-128,128,1024,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6cc13cbd62428bb8658dd3954fe9181f":"2c9ec982d1cfb644ddbc53c0759b10493206d5186affc6882fbb2ba3aa430f9bae1209db2d78dcc125f3c909a54dd84fdff96c71e678216a58390ef4308bdd90f94f7109c4edefa76a74fda64b201b7a435bbabc27298f3eaa4c2d1393bd584f811fff52638f6ad2f6d86a8c3c9c030d9d4264c8c079592a36178d25991cff09":"86740da7ce4efbed70af55e1d6c10fdf":"be561ac15e3cfda624b422af97c26719c140bb50e4a993d636efe9c7f1963fb9047a0762169b571a698ff310bc417e34d4039b7562a95af710ccc1b197964a376c986fd2ed8ac4b0c7b4e843c37a41366f2f483c821a1823f317416c7e4f32eed9b9dc2ae1a2f3ed32c4b3187358a2329aa42191b7c2fe87b6e27ff20303cb29":128:"76b990a1e010e5f088f6ae90bec40b32":"0b9a5f5d2e6852b75b9cf26c1b310b2200e56dafcf3c941478862cdf9737ac8e2cb9b38d41bd4a1872ea1b4cfd51a1a0b9b743aca439eefa10de8459a0a7a221c5429b3dee393f17031ca6c399df8e05657c3db55be9c9dd29e690042a4ed8db732efce7c58d6b20a2a0f7c79e42e5ada43b87ab00f481c20cac1b35514dcdc9":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6cc13cbd62428bb8658dd3954fe9181f":"2c9ec982d1cfb644ddbc53c0759b10493206d5186affc6882fbb2ba3aa430f9bae1209db2d78dcc125f3c909a54dd84fdff96c71e678216a58390ef4308bdd90f94f7109c4edefa76a74fda64b201b7a435bbabc27298f3eaa4c2d1393bd584f811fff52638f6ad2f6d86a8c3c9c030d9d4264c8c079592a36178d25991cff09":"86740da7ce4efbed70af55e1d6c10fdf":"be561ac15e3cfda624b422af97c26719c140bb50e4a993d636efe9c7f1963fb9047a0762169b571a698ff310bc417e34d4039b7562a95af710ccc1b197964a376c986fd2ed8ac4b0c7b4e843c37a41366f2f483c821a1823f317416c7e4f32eed9b9dc2ae1a2f3ed32c4b3187358a2329aa42191b7c2fe87b6e27ff20303cb29":128:"76b990a1e010e5f088f6ae90bec40b32":"":"0b9a5f5d2e6852b75b9cf26c1b310b2200e56dafcf3c941478862cdf9737ac8e2cb9b38d41bd4a1872ea1b4cfd51a1a0b9b743aca439eefa10de8459a0a7a221c5429b3dee393f17031ca6c399df8e05657c3db55be9c9dd29e690042a4ed8db732efce7c58d6b20a2a0f7c79e42e5ada43b87ab00f481c20cac1b35514dcdc9":0 AES-GCM NIST Validation (AES-128,128,1024,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"286d3f5080cfe88538571188fbeb2dd5":"55135928997711360622eda1820c815aa22115204b1e9bb567e231ac6ea2594b4d652627b6816bdc6c40a4411fd6b12fab9a1f169d81c476dbf77151bff13f98ca0d1dc0a68ea681652be089fadbc66c604284eebfc8ce4cf10f4ca6bda0e0f6634023db6e3f0f1de626c3249a28a642ecc9ec5ff401e941fa8a3c691566c0ae":"da6140bd4dc6456ddab19069e86efb35":"5d350a04562a605e9082ebd8faec6c27e561425849e7f0f05f5049859c2c1bd2c4682ebf9773fab6177d2601fd5a086cefc3adef5a2f8f6b5dc9e649e98dd0a3d1a2524419f01305bd0fcfff52d84a20d1b14dea2138dcc54eea2bf263c6fe27c3e7255f1f359d0d00fb1b350d7a04965af30027632520197e85eb41de6bb286":120:"d90d34094d740214dd3de685010ce3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"286d3f5080cfe88538571188fbeb2dd5":"55135928997711360622eda1820c815aa22115204b1e9bb567e231ac6ea2594b4d652627b6816bdc6c40a4411fd6b12fab9a1f169d81c476dbf77151bff13f98ca0d1dc0a68ea681652be089fadbc66c604284eebfc8ce4cf10f4ca6bda0e0f6634023db6e3f0f1de626c3249a28a642ecc9ec5ff401e941fa8a3c691566c0ae":"da6140bd4dc6456ddab19069e86efb35":"5d350a04562a605e9082ebd8faec6c27e561425849e7f0f05f5049859c2c1bd2c4682ebf9773fab6177d2601fd5a086cefc3adef5a2f8f6b5dc9e649e98dd0a3d1a2524419f01305bd0fcfff52d84a20d1b14dea2138dcc54eea2bf263c6fe27c3e7255f1f359d0d00fb1b350d7a04965af30027632520197e85eb41de6bb286":120:"d90d34094d740214dd3de685010ce3":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"726ae113a096769b657f973ea6d2d5dd":"90636012ba8c51d16f8f6df3d3bcabc3f09aeffbe2a762f62e677913188045b861b2e7d9a7bd93dcee46e9e4832e497a6f79db52b4e45c8dab20fa568ff9c4ace55be3216f514a3284768a25d86b1c7da5377622f3e90ed4c7bd4571715af4d0a2ab5181d0475f699202e4406bb9cfdbd4fa7f22d0dd744d36b3223134658496":"2f9900226c97585d200dd20a279c154a":"761663c3fcbf1db12bc25546b2425b8229b3153e75f79fa63958819caee3febff74603d99264b5a82ef5980439bef89301ae3206a1d01a3bbd7a6c99d27d1e934cc725daeb483f826c2c9d788fd1f67a627864cf8b5f94df777bb59ef90cb6781a2000e6f0baa4f1ea4754b47bb7cbd2699f83634e4d8ab16b325b2c49f13499":120:"d095bfb8990d4fd64752ee24f3de1e":"9f7759c6d24fd9aa0df02a7c0cc5f17e61622c63195f85dfafa5d820d3ad218c7288ec017821100f1fade10f9bb447a4a01e3698b045548c7619a08f2304e2818a9bf55e70b40f8b994b7dcf0cb243848cf3f6fdfec3ebbb147d01df84a3ec62cd8fa5d78ad9f2f28cd288a35eb49a5172339e9872e8e7e3350b0d69f59acd07":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"726ae113a096769b657f973ea6d2d5dd":"90636012ba8c51d16f8f6df3d3bcabc3f09aeffbe2a762f62e677913188045b861b2e7d9a7bd93dcee46e9e4832e497a6f79db52b4e45c8dab20fa568ff9c4ace55be3216f514a3284768a25d86b1c7da5377622f3e90ed4c7bd4571715af4d0a2ab5181d0475f699202e4406bb9cfdbd4fa7f22d0dd744d36b3223134658496":"2f9900226c97585d200dd20a279c154a":"761663c3fcbf1db12bc25546b2425b8229b3153e75f79fa63958819caee3febff74603d99264b5a82ef5980439bef89301ae3206a1d01a3bbd7a6c99d27d1e934cc725daeb483f826c2c9d788fd1f67a627864cf8b5f94df777bb59ef90cb6781a2000e6f0baa4f1ea4754b47bb7cbd2699f83634e4d8ab16b325b2c49f13499":120:"d095bfb8990d4fd64752ee24f3de1e":"":"9f7759c6d24fd9aa0df02a7c0cc5f17e61622c63195f85dfafa5d820d3ad218c7288ec017821100f1fade10f9bb447a4a01e3698b045548c7619a08f2304e2818a9bf55e70b40f8b994b7dcf0cb243848cf3f6fdfec3ebbb147d01df84a3ec62cd8fa5d78ad9f2f28cd288a35eb49a5172339e9872e8e7e3350b0d69f59acd07":0 AES-GCM NIST Validation (AES-128,128,1024,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"73a9eeda721c6f292e6b399e2647f8a6":"215fc7e52abe4c751ca2f7f9a5cbde9ab8b44b8d4054bb62dcea6df5b936145ca6ec83a2b78b070638fd6e5ea3bad5d0caf1b8f755f391c3e0962a92337e3eba575585eb83680075fc818860388c587746af78d5fc75ccd0a63f1612abb1ba0f04a2228ca27fbddba4878f9b2683683f516b6d6fe4f6622e603bd3c5ad45e332":"c1e80eb723960049cc4448b66433f1cf":"fb2a0b1f817404e74aee0a6ec8f2cd86f0c9114ed367b2690c44ad80f9d3377d7fd5066beaf1daa739d27ed3fba98379188016b1fe901204a174f9ffca370c181aece5e5d40939a0d460913b40b895e78a3b80ddf3d613c05e4e27bfd161ea2ef42271a2679f2cdca5b728ffb2319781c946a4f3ecacf486b754b30bb04ea60b":120:"e08161262234d0d5be22f09e5646bf":"b5e286183f16dd9403bec6786bd4836cc6add47947ef111fb1d5503c18c333c8fe60959502f58390d0e0f69fbe5fee13c72aed65fe6e32f6ea45877fe44f8a556aa5157b112e572197c1c350b7943c6cf2e9146018599524d27599f09c86027f2c5927e4a20c63833870e8369baa36ecc07cdb3ced520b5ae46869ff357ca089":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"73a9eeda721c6f292e6b399e2647f8a6":"215fc7e52abe4c751ca2f7f9a5cbde9ab8b44b8d4054bb62dcea6df5b936145ca6ec83a2b78b070638fd6e5ea3bad5d0caf1b8f755f391c3e0962a92337e3eba575585eb83680075fc818860388c587746af78d5fc75ccd0a63f1612abb1ba0f04a2228ca27fbddba4878f9b2683683f516b6d6fe4f6622e603bd3c5ad45e332":"c1e80eb723960049cc4448b66433f1cf":"fb2a0b1f817404e74aee0a6ec8f2cd86f0c9114ed367b2690c44ad80f9d3377d7fd5066beaf1daa739d27ed3fba98379188016b1fe901204a174f9ffca370c181aece5e5d40939a0d460913b40b895e78a3b80ddf3d613c05e4e27bfd161ea2ef42271a2679f2cdca5b728ffb2319781c946a4f3ecacf486b754b30bb04ea60b":120:"e08161262234d0d5be22f09e5646bf":"":"b5e286183f16dd9403bec6786bd4836cc6add47947ef111fb1d5503c18c333c8fe60959502f58390d0e0f69fbe5fee13c72aed65fe6e32f6ea45877fe44f8a556aa5157b112e572197c1c350b7943c6cf2e9146018599524d27599f09c86027f2c5927e4a20c63833870e8369baa36ecc07cdb3ced520b5ae46869ff357ca089":0 AES-GCM NIST Validation (AES-128,128,1024,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90dbda7397d8fc46215a1218a6ffd0d8":"4f82a1eca6c9184240f50f7e0cfec07ec772cad5276d93043c462d8364addd9a652eed385ccc6b0faa6ca679ab3a4c3d0be6a759425fd38316ee6a1b1b0c52c1bb3b57a9bd7c8a3be95c82f37800c2e3b42dde031851937398811f8f8dc2a15bfd2d6be99a572d56f536e62bc5b041d3944da666081cd755ec347f464214bf33":"7be477d14df5dc15877ae537b62e1a56":"7358ddf1310a58871a2f76705f1cf64223c015c4d1574104d2e38783bb866205042f05c86e76c47a2516ce284911f1d2cbee079982dd77167e328b8324eec47c9244cc5668cf908c679bb586d4dd32c6c99ed99a6b571cf18b00689463e7a88cea6ea32d288301a10a9139ed6092ffe298e25b8cfb6b4be8217f16076dcd0a90":112:"776d871944159c51b2f5ec1980a6":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90dbda7397d8fc46215a1218a6ffd0d8":"4f82a1eca6c9184240f50f7e0cfec07ec772cad5276d93043c462d8364addd9a652eed385ccc6b0faa6ca679ab3a4c3d0be6a759425fd38316ee6a1b1b0c52c1bb3b57a9bd7c8a3be95c82f37800c2e3b42dde031851937398811f8f8dc2a15bfd2d6be99a572d56f536e62bc5b041d3944da666081cd755ec347f464214bf33":"7be477d14df5dc15877ae537b62e1a56":"7358ddf1310a58871a2f76705f1cf64223c015c4d1574104d2e38783bb866205042f05c86e76c47a2516ce284911f1d2cbee079982dd77167e328b8324eec47c9244cc5668cf908c679bb586d4dd32c6c99ed99a6b571cf18b00689463e7a88cea6ea32d288301a10a9139ed6092ffe298e25b8cfb6b4be8217f16076dcd0a90":112:"776d871944159c51b2f5ec1980a6":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0c85174d428fc1c7c89ca5d1b8aaba25":"3735cbfb8000260021d1938d2a18e7737f378ecddb11a46ce387bf04e20bbfcc902457637fd152ab87017185601f32a7f906057123b6c2da31a1069c93e3cacc59a359aebd3e31b302e1a1f7d5d8f1b2917a8fe79181fa633b925ce03a1198dac48f4c959076b55bc6b3d50188af2c6aa33d83698aa8db22649f39825ba54775":"b3c9dfa4c55388a128fbf62aa5927361":"3f552d45b61cf05ae2aa92668e89f3338a15ec7c5b7113b6571cfcd9e4c4a962043ccd9323f828dd645e8a91b007ce2112b7f978ad22ee9821698a4f2559d987ae4421452ad2e8d180953297156426d4540aff2104d8637b56b034a3a1823cf962bffbc465fe6148097975a8821ca7487e6e6c7ff4ee4de899fe67345676bb1c":112:"1e7dec83830183d56f443a16471d":"3d98cabca4afb7c1f6b8eeed521f4666ae252ac12d17ebf4a710b9a22d839b69458387ba4bbec2f6400e0cff80fbe4682c24efcd3b8c594d9b515ca7842c9d5988c42b59b6526c29a99256451e2927f5b956ef262f97c733dfa8bff73644473b9a8562bdfca748f4733ddce94a60024dfbfcde62fb3cbd7c3d955012d5338b91":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0c85174d428fc1c7c89ca5d1b8aaba25":"3735cbfb8000260021d1938d2a18e7737f378ecddb11a46ce387bf04e20bbfcc902457637fd152ab87017185601f32a7f906057123b6c2da31a1069c93e3cacc59a359aebd3e31b302e1a1f7d5d8f1b2917a8fe79181fa633b925ce03a1198dac48f4c959076b55bc6b3d50188af2c6aa33d83698aa8db22649f39825ba54775":"b3c9dfa4c55388a128fbf62aa5927361":"3f552d45b61cf05ae2aa92668e89f3338a15ec7c5b7113b6571cfcd9e4c4a962043ccd9323f828dd645e8a91b007ce2112b7f978ad22ee9821698a4f2559d987ae4421452ad2e8d180953297156426d4540aff2104d8637b56b034a3a1823cf962bffbc465fe6148097975a8821ca7487e6e6c7ff4ee4de899fe67345676bb1c":112:"1e7dec83830183d56f443a16471d":"":"3d98cabca4afb7c1f6b8eeed521f4666ae252ac12d17ebf4a710b9a22d839b69458387ba4bbec2f6400e0cff80fbe4682c24efcd3b8c594d9b515ca7842c9d5988c42b59b6526c29a99256451e2927f5b956ef262f97c733dfa8bff73644473b9a8562bdfca748f4733ddce94a60024dfbfcde62fb3cbd7c3d955012d5338b91":0 AES-GCM NIST Validation (AES-128,128,1024,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d89f06eb07744d43d44734faf9751d07":"36cc3b2f563305208a03378f7dc036119f7de3fee77cefac06515853d36609a622382ed026c59783fbc0d9910767874c516e10c7bf3e3d104f73b3463c8d93a63418c76cb0d05e62e9c8642cb4f32caced2620912cb6c79e5110a27d5fba1ef3b4d0578077858526c5e4254365f2b2ab47a45df4af08980b3b7a9b66dff5b38c":"185f8d033713ee629e93561cf8d5acb8":"743bcb671d0aa1c547b5448d64d7c6b290777625ba28f25ca0fbf1fc66495a2fde0648a8db51039b0e7340d993aef8afb48269e660cb599837d1e46f72727762d887ee84c073d6136d1b0bc7d4c78f5673a4a6b73375937e8d54a47304845f38ca6b4f51cf14136a0826016535dc5ed003e38c3ac362b9d58ba8b555a05a1412":112:"fcad48076eb03ebe85c6d64f6357":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d89f06eb07744d43d44734faf9751d07":"36cc3b2f563305208a03378f7dc036119f7de3fee77cefac06515853d36609a622382ed026c59783fbc0d9910767874c516e10c7bf3e3d104f73b3463c8d93a63418c76cb0d05e62e9c8642cb4f32caced2620912cb6c79e5110a27d5fba1ef3b4d0578077858526c5e4254365f2b2ab47a45df4af08980b3b7a9b66dff5b38c":"185f8d033713ee629e93561cf8d5acb8":"743bcb671d0aa1c547b5448d64d7c6b290777625ba28f25ca0fbf1fc66495a2fde0648a8db51039b0e7340d993aef8afb48269e660cb599837d1e46f72727762d887ee84c073d6136d1b0bc7d4c78f5673a4a6b73375937e8d54a47304845f38ca6b4f51cf14136a0826016535dc5ed003e38c3ac362b9d58ba8b555a05a1412":112:"fcad48076eb03ebe85c6d64f6357":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6150f14dc53f391e815acfabed9f9e20":"fd8f337017e1b60d6618e6e4ad37c1f230cdeb78891579c2c63d4e6a4f7d2cb7252e99de333c73db45958808c08e91359c885a7385ab6f9ed98a27927a5b83c3a456ce2e01869712675e527155ba1e339ac14a3ccd7a4b87360902f2b8381308fe5a4eac5c90d0b84da4bf5b907de6ff3139cffd23b49a78750006100183032a":"7e92dd558bd2662c3a539dfe21a352cf":"9b4624e9118e6aa5dc65b69856638f77fd3f9f562046f50ba92a64e988258637932af7979f000505b84a71ff5dd7b60bad62586b1a8837a61c15a1a1ba7f06668272c28169915d7f06297b6c2a96c8c44203a422bfd25500c82e11274ffe07706365bfd3da34af4c4dd8ad7b620de7284a5af729bea9c4ed2631bdcba2ebdb7d":104:"922a7b48ad5bf61e6d70751cfe":"f272a3ee9b981f97785cc6fad350e516d72d402dae0d8a531c064ec64598b2a5760f9b279c10aa1ff71bec07300ab0373187138e7a103fc4130105afa6b6346f3d368b40d6f542375de97878ad4d976d64c5c4968a17be2b1757a17c03100231c34721250cd37cc596678764083ade89ae3b1a2151ff9151edcd7ba0eb8a4649":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6150f14dc53f391e815acfabed9f9e20":"fd8f337017e1b60d6618e6e4ad37c1f230cdeb78891579c2c63d4e6a4f7d2cb7252e99de333c73db45958808c08e91359c885a7385ab6f9ed98a27927a5b83c3a456ce2e01869712675e527155ba1e339ac14a3ccd7a4b87360902f2b8381308fe5a4eac5c90d0b84da4bf5b907de6ff3139cffd23b49a78750006100183032a":"7e92dd558bd2662c3a539dfe21a352cf":"9b4624e9118e6aa5dc65b69856638f77fd3f9f562046f50ba92a64e988258637932af7979f000505b84a71ff5dd7b60bad62586b1a8837a61c15a1a1ba7f06668272c28169915d7f06297b6c2a96c8c44203a422bfd25500c82e11274ffe07706365bfd3da34af4c4dd8ad7b620de7284a5af729bea9c4ed2631bdcba2ebdb7d":104:"922a7b48ad5bf61e6d70751cfe":"":"f272a3ee9b981f97785cc6fad350e516d72d402dae0d8a531c064ec64598b2a5760f9b279c10aa1ff71bec07300ab0373187138e7a103fc4130105afa6b6346f3d368b40d6f542375de97878ad4d976d64c5c4968a17be2b1757a17c03100231c34721250cd37cc596678764083ade89ae3b1a2151ff9151edcd7ba0eb8a4649":0 AES-GCM NIST Validation (AES-128,128,1024,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3e8216072ed6fcde0fe0f636b27ed718":"3b50f2a8dca9f70178503d861d9e37f5edfafc80ee023bfed390a477372986e4794175ec22ac038c3461aba50c9b2379cab48512946efdfe2cb9c12a858b373a5309324f410e6a05e88ba892759dbee6e486dc9665f66cb5950ea7e71317fa94abbebd67a3948746a998173fbbb4f14f9effbdf66d3b6e346053496a4b1934ce":"23a122cf363c3117b8c663388c760ee4":"28ce0b4a44fa83323e060f3ff6436b8829d4f842090296bdc952b6d4a6b1b1a66be06168c63c4643e6ac186f7ffd8d144f603b2d4bc0d65be48121676f9fa1f359029c512bebfd75075ff357bc55f20fc76d9f2477c9930f16408f9f09c5ae86efa2529d2f1449ceeb635b83ca13662860ef9ac04a3d8ab4605eccd2d9ae5a71":104:"531a65cc5dfeca671cc64078d1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3e8216072ed6fcde0fe0f636b27ed718":"3b50f2a8dca9f70178503d861d9e37f5edfafc80ee023bfed390a477372986e4794175ec22ac038c3461aba50c9b2379cab48512946efdfe2cb9c12a858b373a5309324f410e6a05e88ba892759dbee6e486dc9665f66cb5950ea7e71317fa94abbebd67a3948746a998173fbbb4f14f9effbdf66d3b6e346053496a4b1934ce":"23a122cf363c3117b8c663388c760ee4":"28ce0b4a44fa83323e060f3ff6436b8829d4f842090296bdc952b6d4a6b1b1a66be06168c63c4643e6ac186f7ffd8d144f603b2d4bc0d65be48121676f9fa1f359029c512bebfd75075ff357bc55f20fc76d9f2477c9930f16408f9f09c5ae86efa2529d2f1449ceeb635b83ca13662860ef9ac04a3d8ab4605eccd2d9ae5a71":104:"531a65cc5dfeca671cc64078d1":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1af434b73a1210b08595ffa686079832":"13f6c1c2d4edcf1438a7b4e85bcd1c84a989831a64d205e7854fce8817ddfceab67d10506ccf6ed9ce50080ef809e28e46cba7b0c96be6a811f59cd09cb3b7b3fe5073ee6763f40aee61e3e65356093f97deef5a8721d995e71db27a51f60a50e34ac3348852c445188cfc64337455f317f87535d465c6f96006f4079396eba3":"ae318f3cb881d1680f6afbf6713a9a2f":"3763c9241be0d9d9a9e46e64b12e107d16cca267ff87844c2325af910cc9a485c7015d95bbe62398864d079fb2b577ba0cfad923c24fa30691ad7d767d651eed4a33d0be8f06fed43f58b2e0bb04959f10b9e8e73bd80d3a6a8c8ce637bfbdb9d02c2b0a3dd8317c4997822031a35d34b3b61819b425c10c64e839b29874ddfb":104:"2ae7350dd3d1909a73f8d64255":"3cd2a770300ce4c85740666640936a0fe48888788702fc37e7a8296adb40b862ec799f257a16821adaa7315bd31e8dec60e4a8faeb8ba2ee606340f0219a6440e9c1d3168425e58fac02e8a88865f30649913d988353ab81f42a5ad43f960055f0877acda20f493208c2c40754fbf4ccee040975aa358ea3fe62cbd028c1611a":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1af434b73a1210b08595ffa686079832":"13f6c1c2d4edcf1438a7b4e85bcd1c84a989831a64d205e7854fce8817ddfceab67d10506ccf6ed9ce50080ef809e28e46cba7b0c96be6a811f59cd09cb3b7b3fe5073ee6763f40aee61e3e65356093f97deef5a8721d995e71db27a51f60a50e34ac3348852c445188cfc64337455f317f87535d465c6f96006f4079396eba3":"ae318f3cb881d1680f6afbf6713a9a2f":"3763c9241be0d9d9a9e46e64b12e107d16cca267ff87844c2325af910cc9a485c7015d95bbe62398864d079fb2b577ba0cfad923c24fa30691ad7d767d651eed4a33d0be8f06fed43f58b2e0bb04959f10b9e8e73bd80d3a6a8c8ce637bfbdb9d02c2b0a3dd8317c4997822031a35d34b3b61819b425c10c64e839b29874ddfb":104:"2ae7350dd3d1909a73f8d64255":"":"3cd2a770300ce4c85740666640936a0fe48888788702fc37e7a8296adb40b862ec799f257a16821adaa7315bd31e8dec60e4a8faeb8ba2ee606340f0219a6440e9c1d3168425e58fac02e8a88865f30649913d988353ab81f42a5ad43f960055f0877acda20f493208c2c40754fbf4ccee040975aa358ea3fe62cbd028c1611a":0 AES-GCM NIST Validation (AES-128,128,1024,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"04036d2f5273c6ff5b8364aa595359c9":"acf79b6099490af938fb5fd8913255b3daa22786b03356cdf3e0ffaf570f9f866047b8e15c9953f893d97e7098265297396868ebc383be8547e8ec9d974b6a65b5dc5147cdadef2e2ad96696e84e44f364c2ba18c8aabe21f99489957b2b5484bf3fb4fecaf5ddaa1d373e910059c978918a3d01b955de2adb475914bf2c2067":"edc433c381140dff929d9df9f62f4cb6":"404acfeeea342aeea8c8b7449af9e20ddf5b85dc7770d2144a4dd05959613d04d0cfece5a21cbb1a9175ddc9443ffacd2085332eb4c337a12a7bb294c95960e7c0bde4b8ab30a91e50267bbd0b8d2a4ed381409ea2e4c84f9a2070a793ce3c90ea8a4b140651b452674f85d5b76d0055df115608bf3a3c60996108023ebabe65":96:"71f818f1a2b789fabbda8ec1":"4729cb642304de928b9dca32bb3d7b7836dd3973bbccf3f013c8ff4b59eca56f5d34d1b8f030a7b581b2f8fdc1e22b76a4cbc10095559876736d318d6c96c5c64cbd9fbd1d8eb4df38a2d56640d67d490d03acc1cd32d3f377eb1907bbd600f21d740b578080ba9c6ddc7dc6c50cdcee41fec51499cb944713c0961fc64f5a70":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"04036d2f5273c6ff5b8364aa595359c9":"acf79b6099490af938fb5fd8913255b3daa22786b03356cdf3e0ffaf570f9f866047b8e15c9953f893d97e7098265297396868ebc383be8547e8ec9d974b6a65b5dc5147cdadef2e2ad96696e84e44f364c2ba18c8aabe21f99489957b2b5484bf3fb4fecaf5ddaa1d373e910059c978918a3d01b955de2adb475914bf2c2067":"edc433c381140dff929d9df9f62f4cb6":"404acfeeea342aeea8c8b7449af9e20ddf5b85dc7770d2144a4dd05959613d04d0cfece5a21cbb1a9175ddc9443ffacd2085332eb4c337a12a7bb294c95960e7c0bde4b8ab30a91e50267bbd0b8d2a4ed381409ea2e4c84f9a2070a793ce3c90ea8a4b140651b452674f85d5b76d0055df115608bf3a3c60996108023ebabe65":96:"71f818f1a2b789fabbda8ec1":"":"4729cb642304de928b9dca32bb3d7b7836dd3973bbccf3f013c8ff4b59eca56f5d34d1b8f030a7b581b2f8fdc1e22b76a4cbc10095559876736d318d6c96c5c64cbd9fbd1d8eb4df38a2d56640d67d490d03acc1cd32d3f377eb1907bbd600f21d740b578080ba9c6ddc7dc6c50cdcee41fec51499cb944713c0961fc64f5a70":0 AES-GCM NIST Validation (AES-128,128,1024,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"59fe44c6e28d025b2ad05e6e867051ab":"20e66bae1215de9a87a0b878d39015d17e0d4542a1aaba2000cefbd5f892c26a410f55f0d7dc2f6b66690f2997032985e5516e068bfc6ec8a3669f566e280b0cefded519023b735ee3bcbfc5b6ce8203b727933a750f9bd515ec448c1f3a030aa0f40e607727a3239ebbe655d46b38a3d867e481ccf0fadbf0d59b665d2ed6b5":"eb0c30320029433f66d29b3fd5c6563b":"49b7418b87374b462d25309b1c06e3132a3c8f4a4fcf29fed58e0902509426be712639db21c076df7b83dcfcc2c2c8fcc88576f4622a4366eb42f84ebf760e3eb22b14f8b5ff83f06a6f04a924eaab05b912e126e80da22461abf7f1925fd72ebdf2aea335a044726e7c2ebbb2b8aeebab4f7de5e186b50f275b700794d895d8":96:"296c4cdaeb94beb2847dc53d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"59fe44c6e28d025b2ad05e6e867051ab":"20e66bae1215de9a87a0b878d39015d17e0d4542a1aaba2000cefbd5f892c26a410f55f0d7dc2f6b66690f2997032985e5516e068bfc6ec8a3669f566e280b0cefded519023b735ee3bcbfc5b6ce8203b727933a750f9bd515ec448c1f3a030aa0f40e607727a3239ebbe655d46b38a3d867e481ccf0fadbf0d59b665d2ed6b5":"eb0c30320029433f66d29b3fd5c6563b":"49b7418b87374b462d25309b1c06e3132a3c8f4a4fcf29fed58e0902509426be712639db21c076df7b83dcfcc2c2c8fcc88576f4622a4366eb42f84ebf760e3eb22b14f8b5ff83f06a6f04a924eaab05b912e126e80da22461abf7f1925fd72ebdf2aea335a044726e7c2ebbb2b8aeebab4f7de5e186b50f275b700794d895d8":96:"296c4cdaeb94beb2847dc53d":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c314264cee0e6db30ebe9b2f6d4991b2":"d436ff9abfb044a332c4e009b591719a67b12a5366da0a66edf19605c34daa37588e15dd3da0d1a097215e469439de79cca74e04cd4904e5b4a6cb4e0ea54e6ba4e624ed6bd48be32d1ef68ffea1639a14e91a5914c2346ea526df95cbd4ad1b8ee842da210b35b6315c3075ecc267d51643c4b39202d0ad793cbb0045ebdc19":"4cd4431bb6dea8eb18ae74e4c35a6698":"0eeafbfd04f9a0ea18e5bdc688c7df27183f346187e9574b61222006f2b3e12e8d9d9bf1f0f15949ee1a7ee8e5c80ee903b8ba2860e15ccb999929f280200b159c2adca481748d0632a7b40601c45055f8cb5126148e6cbab2c76f543537ab54eb276188343cea3c4ab0d7b65b8754e55cfe3f6a5c41b6ea3c08b81fcecc968a":96:"fda18d2f795d900f057fe872":"cb9e0fb0ac13ca730b79e34745584b362d0716c344e4de90d8352b21117471ba12c97f193150b33774baee5e4a0f11b10428eaf0106c958e16aa46c5f6f3d99eed93d1b9ba3957bed05a8b9cc8c5511cf813a66dc7d773cb735b0523d8d6b0b80639b031ddc375f714c6dd50055320cd7ed44a471c8d5645c938a9005d0b5050":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c314264cee0e6db30ebe9b2f6d4991b2":"d436ff9abfb044a332c4e009b591719a67b12a5366da0a66edf19605c34daa37588e15dd3da0d1a097215e469439de79cca74e04cd4904e5b4a6cb4e0ea54e6ba4e624ed6bd48be32d1ef68ffea1639a14e91a5914c2346ea526df95cbd4ad1b8ee842da210b35b6315c3075ecc267d51643c4b39202d0ad793cbb0045ebdc19":"4cd4431bb6dea8eb18ae74e4c35a6698":"0eeafbfd04f9a0ea18e5bdc688c7df27183f346187e9574b61222006f2b3e12e8d9d9bf1f0f15949ee1a7ee8e5c80ee903b8ba2860e15ccb999929f280200b159c2adca481748d0632a7b40601c45055f8cb5126148e6cbab2c76f543537ab54eb276188343cea3c4ab0d7b65b8754e55cfe3f6a5c41b6ea3c08b81fcecc968a":96:"fda18d2f795d900f057fe872":"":"cb9e0fb0ac13ca730b79e34745584b362d0716c344e4de90d8352b21117471ba12c97f193150b33774baee5e4a0f11b10428eaf0106c958e16aa46c5f6f3d99eed93d1b9ba3957bed05a8b9cc8c5511cf813a66dc7d773cb735b0523d8d6b0b80639b031ddc375f714c6dd50055320cd7ed44a471c8d5645c938a9005d0b5050":0 AES-GCM NIST Validation (AES-128,128,1024,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"26072018bd0bda524b5beb66a622c63e":"91c524b359dae3bc49117eebfa610672af1e7754054607317d4c417e7b1a68453f72d355468f825aeb7fde044b20049aed196ec6646cce1eeeccf06cb394286272b573220cdb846613ebc4683442dccc7a19ec86ef1ec971c115726584ae1f4008f94e47d1290d8b6b7a932cfe07165fd2b94e8f96d15f73bf72939c73f4bd11":"c783d6d3b8392160e3b68038b43cf1f4":"8ae7c809a9dc40a6732a7384e3c64abb359c1b09dcb752e5a6b584873e3890230c6fc572b9ad24d849766f849c73f060fc48f664c1af9e6707e223691b77e170966ed164e0cc25ede3fbc3541c480f75b71e7be88fe730d8b361ea2733c6f37e6a59621de6004e020894b51dfb525973d641efe8d5fd9077a0bbc9dc7933a5de":64:"edffe55c60235556":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"26072018bd0bda524b5beb66a622c63e":"91c524b359dae3bc49117eebfa610672af1e7754054607317d4c417e7b1a68453f72d355468f825aeb7fde044b20049aed196ec6646cce1eeeccf06cb394286272b573220cdb846613ebc4683442dccc7a19ec86ef1ec971c115726584ae1f4008f94e47d1290d8b6b7a932cfe07165fd2b94e8f96d15f73bf72939c73f4bd11":"c783d6d3b8392160e3b68038b43cf1f4":"8ae7c809a9dc40a6732a7384e3c64abb359c1b09dcb752e5a6b584873e3890230c6fc572b9ad24d849766f849c73f060fc48f664c1af9e6707e223691b77e170966ed164e0cc25ede3fbc3541c480f75b71e7be88fe730d8b361ea2733c6f37e6a59621de6004e020894b51dfb525973d641efe8d5fd9077a0bbc9dc7933a5de":64:"edffe55c60235556":"FAIL":"":0 AES-GCM NIST Validation (AES-128,128,1024,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"201751d3da98bd39ff4e5990a56cfea7":"2965af0bde3565a00e61cebbfe0b51b5b5ee98dbbfff7b1b5bf61da5ba537e6f4cf5fa07d2b20e518232c4961e6bc3ae247b797429da5d7eee2fc675b07066ac2e670261c6e9a91d920c7076101d86d5ef422b58e74bdc1e0b1d58298d3ee0f510ee3a3f63a3bbc24a55be556e465c20525dd100e33815c2a128ac89574884c1":"6172468634bf4e5dda96f67d433062d7":"ae2d770f40706e1eaa36e087b0093ec11ed58afbde4695794745e7523be0a1e4e54daade393f68ba770956d1cfb267b083431851d713249ffe4b61227f1784769ce8c9127f54271526d54181513aca69dc013b2dfb4a5277f4798b1ff674bca79b3dec4a7a27fcf2905ae0ce03f727c315662cd906e57aa557d1023cce2acd84":64:"66c247e5ad4e1d6a":"efd064d4b4ef4c37b48ddf2fa6f5facc5e9cc4c3255b23a1e3765fabb5a339fa0eda754a5381b72989fc1323ff9a6bbaecd904eb4835e5a511b922927574673061ed8de23299ea1456054e7ebb62869878c34fb95e48c8385b5ebceecb962654cf1586b3f54e7887ce31850363e9a22be9e6fbc22e694db81aa055490495dbf2":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"201751d3da98bd39ff4e5990a56cfea7":"2965af0bde3565a00e61cebbfe0b51b5b5ee98dbbfff7b1b5bf61da5ba537e6f4cf5fa07d2b20e518232c4961e6bc3ae247b797429da5d7eee2fc675b07066ac2e670261c6e9a91d920c7076101d86d5ef422b58e74bdc1e0b1d58298d3ee0f510ee3a3f63a3bbc24a55be556e465c20525dd100e33815c2a128ac89574884c1":"6172468634bf4e5dda96f67d433062d7":"ae2d770f40706e1eaa36e087b0093ec11ed58afbde4695794745e7523be0a1e4e54daade393f68ba770956d1cfb267b083431851d713249ffe4b61227f1784769ce8c9127f54271526d54181513aca69dc013b2dfb4a5277f4798b1ff674bca79b3dec4a7a27fcf2905ae0ce03f727c315662cd906e57aa557d1023cce2acd84":64:"66c247e5ad4e1d6a":"":"efd064d4b4ef4c37b48ddf2fa6f5facc5e9cc4c3255b23a1e3765fabb5a339fa0eda754a5381b72989fc1323ff9a6bbaecd904eb4835e5a511b922927574673061ed8de23299ea1456054e7ebb62869878c34fb95e48c8385b5ebceecb962654cf1586b3f54e7887ce31850363e9a22be9e6fbc22e694db81aa055490495dbf2":0 AES-GCM NIST Validation (AES-128,128,1024,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3bc0dcb5261a641a08e6cb00d23e4deb":"d533ad89a1a578db330c01b4e04d08238b020e36aebe87cf2b0bf0b01f1ce4197be8b0596e475a95946918152e8b334ba89f60486c31f0bd8773ca4ff1319fe92197088b131e728d64405441c4fb5466641f0b8682e6cb371f8a8936140b16677f6def8b3dd9cbf47a73f553f1dca4320ad76f387e92f910f9434543f0df0626":"16fa19f69fceed9e97173207158755a5":"92ddd3b98f08fc8538f6106f6434a1efa0a7441cc7f6fd0841103c2e4dd181ea0c9a4811b3cb1bad1986a44d8addabc02dd6980daf7d60405b38dadc836bb1d0620ceab84e0134aca7c30f9f9490436b27acfd7052f9d7f0379b8e7116571017add46b9976f4b41431d47bae6f5f34dc42410793bc26c84bfe84fb53ae138c85":64:"f5289e1204ace3b2":"be0c30deeffbe51706247928132002b24d29272eee6b9d618483868e67280236632fa1ae06f3ef793f67bd01b1b01f70a827367c1cd28f778910457c7cbd977dfefff1f84a522247e19b2fd01fa22ce67cef9503d45c80a5084741f04108f2462b7cdd06a8f1f044fea2b05e920bcc061fbc6910175d732f45102a63c76ae48c":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3bc0dcb5261a641a08e6cb00d23e4deb":"d533ad89a1a578db330c01b4e04d08238b020e36aebe87cf2b0bf0b01f1ce4197be8b0596e475a95946918152e8b334ba89f60486c31f0bd8773ca4ff1319fe92197088b131e728d64405441c4fb5466641f0b8682e6cb371f8a8936140b16677f6def8b3dd9cbf47a73f553f1dca4320ad76f387e92f910f9434543f0df0626":"16fa19f69fceed9e97173207158755a5":"92ddd3b98f08fc8538f6106f6434a1efa0a7441cc7f6fd0841103c2e4dd181ea0c9a4811b3cb1bad1986a44d8addabc02dd6980daf7d60405b38dadc836bb1d0620ceab84e0134aca7c30f9f9490436b27acfd7052f9d7f0379b8e7116571017add46b9976f4b41431d47bae6f5f34dc42410793bc26c84bfe84fb53ae138c85":64:"f5289e1204ace3b2":"":"be0c30deeffbe51706247928132002b24d29272eee6b9d618483868e67280236632fa1ae06f3ef793f67bd01b1b01f70a827367c1cd28f778910457c7cbd977dfefff1f84a522247e19b2fd01fa22ce67cef9503d45c80a5084741f04108f2462b7cdd06a8f1f044fea2b05e920bcc061fbc6910175d732f45102a63c76ae48c":0 AES-GCM NIST Validation (AES-128,128,1024,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"239c15492d6deec979e79236baca4635":"d64886ce5f5b4adb7fe8f95904bc1461749c931655b02819ffdd0ae31bad4175125aa68962f8e36ec834a7d53a191a74c937e81ec93ad9ce0d3b286d3c11ff1733c0b7780130768c120b1833933561cf07399ca49b912370ae34f0e49b9c8cb9920eddc6816ab2ae261c6d7f70058a9b83a494026f249e58c4c613eefafe6974":"916b8b5417578fa83d2e9e9b8e2e7f6b":"b39eb732bc296c555cc9f00cf4caaf37d012329f344a6b74a873baf0d8dde9631f5e57b45b957d6aec0f7978e573dd78b43d459b77756037cd64d10d49966eb3a2a08d0f4d5e4f5dcb8713f4e4756acdf9925c5fc6120c477f6dffc59b0b47a3d5efd32b8c9052b321bb9b5129e5c6a095d8de563601b34608456f58d7221f2d":32:"fc08cbbe":"95c169721ea007c3f292e4ec7562a426d9baa7d374fd82e1e48d1eaca93d891d5ffa9acf5e3bd82e713ac627141e26a8b654920baffab948401cc3c390d6eea9d7b78c4fcb080b0aa9222e4d51bf201ccfd9328995831435e065d92ad37ee41c7c4366cc1efe15c07fc0470608866aeea96997772ecf926934c5d02efe05f250":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"239c15492d6deec979e79236baca4635":"d64886ce5f5b4adb7fe8f95904bc1461749c931655b02819ffdd0ae31bad4175125aa68962f8e36ec834a7d53a191a74c937e81ec93ad9ce0d3b286d3c11ff1733c0b7780130768c120b1833933561cf07399ca49b912370ae34f0e49b9c8cb9920eddc6816ab2ae261c6d7f70058a9b83a494026f249e58c4c613eefafe6974":"916b8b5417578fa83d2e9e9b8e2e7f6b":"b39eb732bc296c555cc9f00cf4caaf37d012329f344a6b74a873baf0d8dde9631f5e57b45b957d6aec0f7978e573dd78b43d459b77756037cd64d10d49966eb3a2a08d0f4d5e4f5dcb8713f4e4756acdf9925c5fc6120c477f6dffc59b0b47a3d5efd32b8c9052b321bb9b5129e5c6a095d8de563601b34608456f58d7221f2d":32:"fc08cbbe":"":"95c169721ea007c3f292e4ec7562a426d9baa7d374fd82e1e48d1eaca93d891d5ffa9acf5e3bd82e713ac627141e26a8b654920baffab948401cc3c390d6eea9d7b78c4fcb080b0aa9222e4d51bf201ccfd9328995831435e065d92ad37ee41c7c4366cc1efe15c07fc0470608866aeea96997772ecf926934c5d02efe05f250":0 AES-GCM NIST Validation (AES-128,128,1024,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"db68a96e216b0dd9945f14b878487e03":"5634196a32d4cbfa7a2f874a1e0f86287d2942090e0cc6a82bd5caf40136a27ddf524a17713ce4af04ca6cb640a7205cce4ac9cb2d0ab380d533e1e968089ea5740c0fcbfa51f2424008e0b89dc7b3396b224cfaed53b3ac0604879983d3e6e6d36053de4866f52976890f72b8f4b9505e4ebdd04c0497048c3ce19336133ea4":"8a1a72e7bb740ec37ea4619c3007f8ae":"1b4f37190a59a4fff41d348798d1829031204fd7ac2a1be7b5ea385567e95e2ace25bf9e324488dd3ab8ce7f29d4c9a4f4b1a8a97f774871ee825e2c17700128d3c55908d3b684a1f550fdb8b38149ff759c21debdd54e49d64d3e8aac803dfd81600464ed484749bb993f89d4224b3d7d55c756b454466ff9fd609019ed5e83":32:"9251d3e3":"0c6bb3ee5de5cbb4b39d85d509bcacb3dda63fa50897936531339882962e8dc54c285c8944768d12096d4a3c2b42ffa92603cee2da9b435ec52908fca6d38ed74f898fe0ffa761f96038ff7dfeccc65bb841c3457b8de1e97d9bee82e2911602ee2dc555b33a227424dea86d610d37c447776295b412b412903ad2cede5170b6":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"db68a96e216b0dd9945f14b878487e03":"5634196a32d4cbfa7a2f874a1e0f86287d2942090e0cc6a82bd5caf40136a27ddf524a17713ce4af04ca6cb640a7205cce4ac9cb2d0ab380d533e1e968089ea5740c0fcbfa51f2424008e0b89dc7b3396b224cfaed53b3ac0604879983d3e6e6d36053de4866f52976890f72b8f4b9505e4ebdd04c0497048c3ce19336133ea4":"8a1a72e7bb740ec37ea4619c3007f8ae":"1b4f37190a59a4fff41d348798d1829031204fd7ac2a1be7b5ea385567e95e2ace25bf9e324488dd3ab8ce7f29d4c9a4f4b1a8a97f774871ee825e2c17700128d3c55908d3b684a1f550fdb8b38149ff759c21debdd54e49d64d3e8aac803dfd81600464ed484749bb993f89d4224b3d7d55c756b454466ff9fd609019ed5e83":32:"9251d3e3":"":"0c6bb3ee5de5cbb4b39d85d509bcacb3dda63fa50897936531339882962e8dc54c285c8944768d12096d4a3c2b42ffa92603cee2da9b435ec52908fca6d38ed74f898fe0ffa761f96038ff7dfeccc65bb841c3457b8de1e97d9bee82e2911602ee2dc555b33a227424dea86d610d37c447776295b412b412903ad2cede5170b6":0 AES-GCM NIST Validation (AES-128,128,1024,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"659b9e729d12f68b73fdc2f7260ab114":"fd0732a38224c3f16f58de3a7f333da2ecdb6eec92b469544a891966dd4f8fb64a711a793f1ef6a90e49765eacaccdd8cc438c2b57c51902d27a82ee4f24925a864a9513a74e734ddbf77204a99a3c0060fcfbaccae48fe509bc95c3d6e1b1592889c489801265715e6e4355a45357ce467c1caa2f1c3071bd3a9168a7d223e3":"459df18e2dfbd66d6ad04978432a6d97":"ee0b0b52a729c45b899cc924f46eb1908e55aaaeeaa0c4cdaacf57948a7993a6debd7b6cd7aa426dc3b3b6f56522ba3d5700a820b1697b8170bad9ca7caf1050f13d54fb1ddeb111086cb650e1c5f4a14b6a927205a83bf49f357576fd0f884a83b068154352076a6e36a5369436d2c8351f3e6bfec65b4816e3eb3f144ed7f9":32:"8e5a6a79":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"659b9e729d12f68b73fdc2f7260ab114":"fd0732a38224c3f16f58de3a7f333da2ecdb6eec92b469544a891966dd4f8fb64a711a793f1ef6a90e49765eacaccdd8cc438c2b57c51902d27a82ee4f24925a864a9513a74e734ddbf77204a99a3c0060fcfbaccae48fe509bc95c3d6e1b1592889c489801265715e6e4355a45357ce467c1caa2f1c3071bd3a9168a7d223e3":"459df18e2dfbd66d6ad04978432a6d97":"ee0b0b52a729c45b899cc924f46eb1908e55aaaeeaa0c4cdaacf57948a7993a6debd7b6cd7aa426dc3b3b6f56522ba3d5700a820b1697b8170bad9ca7caf1050f13d54fb1ddeb111086cb650e1c5f4a14b6a927205a83bf49f357576fd0f884a83b068154352076a6e36a5369436d2c8351f3e6bfec65b4816e3eb3f144ed7f9":32:"8e5a6a79":"FAIL":"":0 AES-GCM Bad IV (AES-128,128,0,0,32) #0 depends_on:MBEDTLS_AES_C diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes192_de.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes192_de.data index 9e7bad00f7..34f74ac061 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes192_de.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes192_de.data @@ -1,674 +1,674 @@ AES-GCM NIST Validation (AES-192,128,0,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"806766a4d2b6507cc4113bc0e46eebe120eacd948c24dc7f":"":"4f801c772395c4519ec830980c8ca5a4":"":128:"8fa16452b132bebc6aa521e92cb3b0ea":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"806766a4d2b6507cc4113bc0e46eebe120eacd948c24dc7f":"":"4f801c772395c4519ec830980c8ca5a4":"":128:"8fa16452b132bebc6aa521e92cb3b0ea":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0c2abdcd2e4ae4137509761a38e6ca436b99c21b141f28f5":"":"335ca01a07081fea4e605eb5f23a778e":"":128:"d7f475dfcb92a75bc8521c12bb2e8b86":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0c2abdcd2e4ae4137509761a38e6ca436b99c21b141f28f5":"":"335ca01a07081fea4e605eb5f23a778e":"":128:"d7f475dfcb92a75bc8521c12bb2e8b86":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"eef490a0c2ecb32472e1654184340cc7433c34da981c062d":"":"d9172c3344d37ff93d2dcb2170ea5d01":"":128:"017fef05260a496654896d4703db3888":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"eef490a0c2ecb32472e1654184340cc7433c34da981c062d":"":"d9172c3344d37ff93d2dcb2170ea5d01":"":128:"017fef05260a496654896d4703db3888":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe0c3490f1f0dba23cf5c64e6e1740d06f85e0afec6772f3":"":"f47e915163fa3df7f6c15b9d69f53907":"":120:"14e1a057a2e7ffbd2208e9c25dbba1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe0c3490f1f0dba23cf5c64e6e1740d06f85e0afec6772f3":"":"f47e915163fa3df7f6c15b9d69f53907":"":120:"14e1a057a2e7ffbd2208e9c25dbba1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4356b3b1f308df3573509945afe5268984f9d953f01096de":"":"a35b397b34a14a8e24d05a37be4d1822":"":120:"e045ecba220d22c80826b77a21b013":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4356b3b1f308df3573509945afe5268984f9d953f01096de":"":"a35b397b34a14a8e24d05a37be4d1822":"":120:"e045ecba220d22c80826b77a21b013":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e2898937cc575c8bb7444413884deafe8eaf326be8849e42":"":"169a449ccb3eb29805b15304d603b132":"":120:"3a807251f3d6242849a69972b14f6d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e2898937cc575c8bb7444413884deafe8eaf326be8849e42":"":"169a449ccb3eb29805b15304d603b132":"":120:"3a807251f3d6242849a69972b14f6d":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"75683c7df0442e10b5368fcd6bb481f0bff8d95aae90487e":"":"538641f7d1cc5c68715971cee607da73":"":112:"07d68fffe417adc3397706d73b95":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"75683c7df0442e10b5368fcd6bb481f0bff8d95aae90487e":"":"538641f7d1cc5c68715971cee607da73":"":112:"07d68fffe417adc3397706d73b95":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0724ee1f317997ce77bb659446fcb5a557490f40597341c7":"":"0d8eb78032d83c676820b2ef5ccc2cc8":"":112:"7da181563b26c7aefeb29e71cc69":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0724ee1f317997ce77bb659446fcb5a557490f40597341c7":"":"0d8eb78032d83c676820b2ef5ccc2cc8":"":112:"7da181563b26c7aefeb29e71cc69":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"be2f0f4ae4ab851b258ec5602628df261b6a69e309ff9043":"":"646a91d83ae72b9b9e9fce64135cbf73":"":112:"169e717e2bae42e3eb61d0a1a29b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"be2f0f4ae4ab851b258ec5602628df261b6a69e309ff9043":"":"646a91d83ae72b9b9e9fce64135cbf73":"":112:"169e717e2bae42e3eb61d0a1a29b":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"583c328daecd18c2ac5c83a0c263de194a4c73aa4700fe76":"":"55e10d5e9b438b02505d30f211b16fea":"":104:"95c0a4ea9e80f91a4acce500f7":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"583c328daecd18c2ac5c83a0c263de194a4c73aa4700fe76":"":"55e10d5e9b438b02505d30f211b16fea":"":104:"95c0a4ea9e80f91a4acce500f7":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b40857e7e6f26050f1e9a6cbe05e15a0ba07c2055634ad47":"":"e25ef162a4295d7d24de75a673172346":"":104:"89ea4d1f34edb716b322ea7f6f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b40857e7e6f26050f1e9a6cbe05e15a0ba07c2055634ad47":"":"e25ef162a4295d7d24de75a673172346":"":104:"89ea4d1f34edb716b322ea7f6f":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"627008956e31fea497fb120b438a2a043c23b1b38dc6bc10":"":"08ea464baac54469b0498419d83820e6":"":104:"ab064a8d380fe2cda38e61f9e1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"627008956e31fea497fb120b438a2a043c23b1b38dc6bc10":"":"08ea464baac54469b0498419d83820e6":"":104:"ab064a8d380fe2cda38e61f9e1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8c386d67d7c2bfd46b8571d8685b35741e87a3ed4a46c9db":"":"766996fb67ace9e6a22d7f802455d4ef":"":96:"9a641be173dc3557ea015372":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8c386d67d7c2bfd46b8571d8685b35741e87a3ed4a46c9db":"":"766996fb67ace9e6a22d7f802455d4ef":"":96:"9a641be173dc3557ea015372":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"711bc5aa6b94fa3287fad0167ac1a9ef5e8e01c16a79e95a":"":"75cdb8b83017f3dc5ac8733016ab47c7":"":96:"81e3a5580234d8e0b2204bc3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"711bc5aa6b94fa3287fad0167ac1a9ef5e8e01c16a79e95a":"":"75cdb8b83017f3dc5ac8733016ab47c7":"":96:"81e3a5580234d8e0b2204bc3":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c74620828402e0bdf3f7a5353668505dc1550a31debce59a":"":"cfbefe265583ab3a2285e8080141ba48":"":96:"355a43bcebbe7f72b6cd27ea":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c74620828402e0bdf3f7a5353668505dc1550a31debce59a":"":"cfbefe265583ab3a2285e8080141ba48":"":96:"355a43bcebbe7f72b6cd27ea":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1eb53aa548b41bfdc85c657ebdebdae0c7e525a6432bc012":"":"37ffc64d4b2d9c82dd17d1ad3076d82b":"":64:"34b8e037084b3f2d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1eb53aa548b41bfdc85c657ebdebdae0c7e525a6432bc012":"":"37ffc64d4b2d9c82dd17d1ad3076d82b":"":64:"34b8e037084b3f2d":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"50d077575f6db91024a8e564db83324539e9b7add7bb98e4":"":"118d0283294d4084127cce4b0cd5b5fa":"":64:"507a361d8ac59882":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"50d077575f6db91024a8e564db83324539e9b7add7bb98e4":"":"118d0283294d4084127cce4b0cd5b5fa":"":64:"507a361d8ac59882":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d9ddca0807305025d61919ed7893d7d5c5a3c9f012f4842f":"":"b78d518b6c41a9e031a00b10fb178327":"":64:"f401d546c8b739ff":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d9ddca0807305025d61919ed7893d7d5c5a3c9f012f4842f":"":"b78d518b6c41a9e031a00b10fb178327":"":64:"f401d546c8b739ff":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6ed8d8afde4dc3872cbc274d7c47b719205518496dd7951d":"":"14eb280288740d464e3b8f296c642daa":"":32:"39e64d7a":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6ed8d8afde4dc3872cbc274d7c47b719205518496dd7951d":"":"14eb280288740d464e3b8f296c642daa":"":32:"39e64d7a":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"80aace5ab74f261bc09ac6f66898f69e7f348f805d52404d":"":"f54bf4aac8fb631c8b6ff5e96465fae6":"":32:"1ec1c1a1":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"80aace5ab74f261bc09ac6f66898f69e7f348f805d52404d":"":"f54bf4aac8fb631c8b6ff5e96465fae6":"":32:"1ec1c1a1":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"23b76efd0dbc8d501885ab7d43a7dacde91edd9cde1e1048":"":"75532d15e582e6c477b411e727d4171e":"":32:"76a0e017":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"23b76efd0dbc8d501885ab7d43a7dacde91edd9cde1e1048":"":"75532d15e582e6c477b411e727d4171e":"":32:"76a0e017":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"94c50453dd3ef7f7ea763ae13fa34debb9c1198abbf32326":"":"1afe962bc46e36099165552ddb329ac6":"b2920dd9b0325a87e8edda8db560bfe287e44df79cf61edba3b2c95e34629638ecb86584f05a303603065e63323523f6ccc5b605679d1722cde5561f89d268d5f8db8e6bdffda4839c4a04982e8314da78e89f8f8ad9c0fee86332906bf78d2f20afcaabdc282008c6d09df2bfe9be2c9027bb49268b8be8936be39fa8b1ae03":128:"51e1f19a7dea5cfe9b9ca9d09096c3e7":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"94c50453dd3ef7f7ea763ae13fa34debb9c1198abbf32326":"":"1afe962bc46e36099165552ddb329ac6":"b2920dd9b0325a87e8edda8db560bfe287e44df79cf61edba3b2c95e34629638ecb86584f05a303603065e63323523f6ccc5b605679d1722cde5561f89d268d5f8db8e6bdffda4839c4a04982e8314da78e89f8f8ad9c0fee86332906bf78d2f20afcaabdc282008c6d09df2bfe9be2c9027bb49268b8be8936be39fa8b1ae03":128:"51e1f19a7dea5cfe9b9ca9d09096c3e7":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c6a98102af3d875bcdebe594661d3a6b376970c02b11d019":"":"bea8cd85a28a2c05bf7406b8eef1efcc":"f2f80e2c042092cc7240b598ab30fad055bce85408aa0f8cefaf8a7204f0e2acb87c78f46a5867b1f1c19461cbf5ed5d2ca21c96a63fb1f42f10f394952e63520795c56df77d6a04cb5ad006ee865a47dc2349a814a630b3d4c4e0fd149f51e8fa846656ea569fd29a1ebafc061446eb80ec182f833f1f6d9083545abf52fa4c":128:"04b80f25ae9d07f5fd8220263ac3f2f7":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c6a98102af3d875bcdebe594661d3a6b376970c02b11d019":"":"bea8cd85a28a2c05bf7406b8eef1efcc":"f2f80e2c042092cc7240b598ab30fad055bce85408aa0f8cefaf8a7204f0e2acb87c78f46a5867b1f1c19461cbf5ed5d2ca21c96a63fb1f42f10f394952e63520795c56df77d6a04cb5ad006ee865a47dc2349a814a630b3d4c4e0fd149f51e8fa846656ea569fd29a1ebafc061446eb80ec182f833f1f6d9083545abf52fa4c":128:"04b80f25ae9d07f5fd8220263ac3f2f7":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ec3cc45a22fdc7cc79ed658d9e9dbc138dcc7d6e795cba1a":"":"b10d9c70205e142704f9d1f74caee0f6":"714994017c169c574aaff2f8bad15f8fa6a385117f5405f74846eca873ca4a8f4876adf704f2fcaff2dfa75c17afefd08a4707292debc6d9fafda6244ca509bc52b0c6b70f09b14c0d7c667583c091d4064e241ba1f82dd43dc3ea4b8922be65faf5583f6b21ff5b22d3632eb4a426675648250e4b3e37c688d6129b954ef6a8":128:"d22407fd3ae1921d1b380461d2e60210":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ec3cc45a22fdc7cc79ed658d9e9dbc138dcc7d6e795cba1a":"":"b10d9c70205e142704f9d1f74caee0f6":"714994017c169c574aaff2f8bad15f8fa6a385117f5405f74846eca873ca4a8f4876adf704f2fcaff2dfa75c17afefd08a4707292debc6d9fafda6244ca509bc52b0c6b70f09b14c0d7c667583c091d4064e241ba1f82dd43dc3ea4b8922be65faf5583f6b21ff5b22d3632eb4a426675648250e4b3e37c688d6129b954ef6a8":128:"d22407fd3ae1921d1b380461d2e60210":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a32ebc7a2338038ced36d2b85cbc6c45cca9845a7c5aa99":"":"9afe0882e418c9af205eeb90e131d212":"61ff8a8bc22803f17e8e9f01aff865bc7d3083ff413ce392a989e46ebed5114894de906f7d36439024d8f2e69cc815ac043fff2f75169f6c9aa9761ff32d10a1353213ac756cb84bd3613f8261ef390e1d00c3a8fb82764b0cda4e0049219e87d2e92c38f78ffac242391f838a248f608bb2b56b31bbb453d1098e99d079ea1b":120:"fcbb932ddb0128df78a71971c52838":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a32ebc7a2338038ced36d2b85cbc6c45cca9845a7c5aa99":"":"9afe0882e418c9af205eeb90e131d212":"61ff8a8bc22803f17e8e9f01aff865bc7d3083ff413ce392a989e46ebed5114894de906f7d36439024d8f2e69cc815ac043fff2f75169f6c9aa9761ff32d10a1353213ac756cb84bd3613f8261ef390e1d00c3a8fb82764b0cda4e0049219e87d2e92c38f78ffac242391f838a248f608bb2b56b31bbb453d1098e99d079ea1b":120:"fcbb932ddb0128df78a71971c52838":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bf22885e7f13bcc63bb0a2ca90c20e5c86001f05edf85d8":"":"99dec21f4781284722b5074ea567c171":"9f4176dacf26e27aa0e669cd4d44bca41f83468c70b54c745a601408a214bf876941ae2ae4d26929113f5de2e7d15a7bb656541292137bf2129fdc31f06f070e3cfaf0a7b30d93d8d3c76a981d75cd0ffa0bcacb34597d5be1a055c35eefeddc07ee098603e48ad88eb7a2ec19c1aefc5c7be9a237797397aa27590d5261f67a":120:"18fd1feec5e3bbf0985312dd6100d1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bf22885e7f13bcc63bb0a2ca90c20e5c86001f05edf85d8":"":"99dec21f4781284722b5074ea567c171":"9f4176dacf26e27aa0e669cd4d44bca41f83468c70b54c745a601408a214bf876941ae2ae4d26929113f5de2e7d15a7bb656541292137bf2129fdc31f06f070e3cfaf0a7b30d93d8d3c76a981d75cd0ffa0bcacb34597d5be1a055c35eefeddc07ee098603e48ad88eb7a2ec19c1aefc5c7be9a237797397aa27590d5261f67a":120:"18fd1feec5e3bbf0985312dd6100d1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cfd75a9d3788d965895553ab5fb7a8ff0aa383b7594850a6":"":"a6df69e5f77f4d99d5318c45c87451b2":"041aeb2fa0f7df027cd7709a992e041179d499f5dbccd389035bf7e514a38b5f8368379d2d7b5015d4fa6fadfd7c75abd2d855f5ea4220315fad2c2d435d910253bf76f252a21c57fe74f7247dac32f4276d793d30d48dd61d0e14a4b7f07a56c94d3799d04324dfb2b27a22a5077e280422d4f014f253d138e74c9ac3428a7b":120:"fd78b9956e4e4522605db410f97e84":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cfd75a9d3788d965895553ab5fb7a8ff0aa383b7594850a6":"":"a6df69e5f77f4d99d5318c45c87451b2":"041aeb2fa0f7df027cd7709a992e041179d499f5dbccd389035bf7e514a38b5f8368379d2d7b5015d4fa6fadfd7c75abd2d855f5ea4220315fad2c2d435d910253bf76f252a21c57fe74f7247dac32f4276d793d30d48dd61d0e14a4b7f07a56c94d3799d04324dfb2b27a22a5077e280422d4f014f253d138e74c9ac3428a7b":120:"fd78b9956e4e4522605db410f97e84":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0b21ae138485591c6bef7b3d5a0aa0e9762c30a50e4bba2":"":"56dc980e1cba1bc2e3b4a0733d7897ca":"a38458e5cc71f22f6f5880dc018c5777c0e6c8a1301e7d0300c02c976423c2b65f522db4a90401035346d855c892cbf27092c81b969e99cb2b6198e450a95c547bb0145652c9720aaf72a975e4cb5124b483a42f84b5cd022367802c5f167a7dfc885c1f983bb4525a88c8257df3067b6d36d2dbf6323df80c3eaeffc2d176a5":112:"b11f5c0e8cb6fea1a170c9342437":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0b21ae138485591c6bef7b3d5a0aa0e9762c30a50e4bba2":"":"56dc980e1cba1bc2e3b4a0733d7897ca":"a38458e5cc71f22f6f5880dc018c5777c0e6c8a1301e7d0300c02c976423c2b65f522db4a90401035346d855c892cbf27092c81b969e99cb2b6198e450a95c547bb0145652c9720aaf72a975e4cb5124b483a42f84b5cd022367802c5f167a7dfc885c1f983bb4525a88c8257df3067b6d36d2dbf6323df80c3eaeffc2d176a5":112:"b11f5c0e8cb6fea1a170c9342437":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8775665aba345b1c3e626128b5afa3d0da8f4d36b8cf1ca6":"":"cd17f761670e1f104f8ea4fb0cec7166":"2ee08a51ceaca1dbbb3ee09b72f57427fd34bd95da5b4c0933cbb0fc2f7270cffd3476aa05deeb892a7e6a8a3407e61f8631d1a00e47d46efb918393ee5099df7d65c12ab8c9640bfcb3a6cce00c3243d0b3f316f0822cfeae05ee67b419393cc81846b60c42aeb5c53f0ede1280dc36aa8ef59addd10668dd61557ce760c544":112:"6cdf60e62c91a6a944fa80da1854":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8775665aba345b1c3e626128b5afa3d0da8f4d36b8cf1ca6":"":"cd17f761670e1f104f8ea4fb0cec7166":"2ee08a51ceaca1dbbb3ee09b72f57427fd34bd95da5b4c0933cbb0fc2f7270cffd3476aa05deeb892a7e6a8a3407e61f8631d1a00e47d46efb918393ee5099df7d65c12ab8c9640bfcb3a6cce00c3243d0b3f316f0822cfeae05ee67b419393cc81846b60c42aeb5c53f0ede1280dc36aa8ef59addd10668dd61557ce760c544":112:"6cdf60e62c91a6a944fa80da1854":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cc9922299b47725952f06272168b728218d2443028d81597":"":"9b2f1a40717afcdbb6a95d6e335c9e4d":"bcfca8420bc7b9df0290d8c1bcf4e3e66d3a4be1c947af82dd541336e44e2c4fa7c6b456980b174948de30b694232b03f8eb990f849b5f57762886b449671e4f0b5e7a173f12910393bdf5c162163584c774ad3bba39794767a4cc45f4a582d307503960454631cdf551e528a863f2e014b1fca4955a78bd545dec831e4d71c7":112:"dd515e5a8b41ecc441443a749b31":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cc9922299b47725952f06272168b728218d2443028d81597":"":"9b2f1a40717afcdbb6a95d6e335c9e4d":"bcfca8420bc7b9df0290d8c1bcf4e3e66d3a4be1c947af82dd541336e44e2c4fa7c6b456980b174948de30b694232b03f8eb990f849b5f57762886b449671e4f0b5e7a173f12910393bdf5c162163584c774ad3bba39794767a4cc45f4a582d307503960454631cdf551e528a863f2e014b1fca4955a78bd545dec831e4d71c7":112:"dd515e5a8b41ecc441443a749b31":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a27d718f21c5cbdc52a745b931bc77bd1afa8b1231f8815":"":"59661051912fba45023aef4e6f9380a5":"2b7ce5cea81300ed23501493310f1316581ef8a50e37eaadd4bb5f527add6deb09e7dcc67652e44ac889b48726d8c0ae80e2b3a89dd34232eb1da32f7f4fcd5bf8e920d286db8604f23ab06eab3e6f99beb55fe3725107e9d67a491cdada1580717bbf64c28799c9ab67922da9194747f32fd84197070a86838d1c9ebae379b7":104:"f33e8f42b58f45a0456f83a13e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a27d718f21c5cbdc52a745b931bc77bd1afa8b1231f8815":"":"59661051912fba45023aef4e6f9380a5":"2b7ce5cea81300ed23501493310f1316581ef8a50e37eaadd4bb5f527add6deb09e7dcc67652e44ac889b48726d8c0ae80e2b3a89dd34232eb1da32f7f4fcd5bf8e920d286db8604f23ab06eab3e6f99beb55fe3725107e9d67a491cdada1580717bbf64c28799c9ab67922da9194747f32fd84197070a86838d1c9ebae379b7":104:"f33e8f42b58f45a0456f83a13e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b83e933cf54ac58f8c7e5ed18e4ed2213059158ed9cb2c30":"":"8710af55dd79da45a4b24f6e972bc60a":"b7a428bc68696cee06f2f8b43f63b47914e29f04a4a40c0eec6193a9a24bbe012d68bea5573382dd579beeb0565b0e0334cce6724997138b198fce8325f07069d6890ac4c052e127aa6e70a6248e6536d1d3c6ac60d8cd14d9a45200f6540305f882df5fca2cac48278f94fe502b5abe2992fa2719b0ce98b7ef1b5582e0151c":104:"380128ad7f35be87a17c9590fa":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b83e933cf54ac58f8c7e5ed18e4ed2213059158ed9cb2c30":"":"8710af55dd79da45a4b24f6e972bc60a":"b7a428bc68696cee06f2f8b43f63b47914e29f04a4a40c0eec6193a9a24bbe012d68bea5573382dd579beeb0565b0e0334cce6724997138b198fce8325f07069d6890ac4c052e127aa6e70a6248e6536d1d3c6ac60d8cd14d9a45200f6540305f882df5fca2cac48278f94fe502b5abe2992fa2719b0ce98b7ef1b5582e0151c":104:"380128ad7f35be87a17c9590fa":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d2f85f92092385f15da43a086cff64c7448b4ee5a83ed72e":"":"9026dfd09e4553cd51c4c13ce70830de":"3c8de64c14df73c1b470a9d8aa693af96e487d548d03a92ce59c0baec8576129945c722586a66f03deb5029cbda029fb22d355952c3dadfdede20b63f4221f27c8e5d710e2b335c2d9a9b7ca899597a03c41ee6508e40a6d74814441ac3acb64a20f48a61e8a18f4bbcbd3e7e59bb3cd2be405afd6ac80d47ce6496c4b9b294c":104:"e9e5beea7d39c9250347a2a33d":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d2f85f92092385f15da43a086cff64c7448b4ee5a83ed72e":"":"9026dfd09e4553cd51c4c13ce70830de":"3c8de64c14df73c1b470a9d8aa693af96e487d548d03a92ce59c0baec8576129945c722586a66f03deb5029cbda029fb22d355952c3dadfdede20b63f4221f27c8e5d710e2b335c2d9a9b7ca899597a03c41ee6508e40a6d74814441ac3acb64a20f48a61e8a18f4bbcbd3e7e59bb3cd2be405afd6ac80d47ce6496c4b9b294c":104:"e9e5beea7d39c9250347a2a33d":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"de7df44ce007c99f7baad6a6955195f14e60999ed9818707":"":"4d209e414965fe99636c1c6493bba3a3":"da3bc6bdd414a1e07e00981cf9199371192a1fb2eaae20f7091e5fe5368e26d61b981f7f1d29f1a9085ad2789d101155a980de98d961c093941502268adb70537ad9783e6c7d5157c939f59b8ad474c3d7fc1fcc91165cdf8dd9d6ec70d6400086d564b68ebead0d03ebd3aa66ded555692b8de0baf43bc0ddef42e3a9eb34ab":96:"24483a57c20826a709b7d10a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"de7df44ce007c99f7baad6a6955195f14e60999ed9818707":"":"4d209e414965fe99636c1c6493bba3a3":"da3bc6bdd414a1e07e00981cf9199371192a1fb2eaae20f7091e5fe5368e26d61b981f7f1d29f1a9085ad2789d101155a980de98d961c093941502268adb70537ad9783e6c7d5157c939f59b8ad474c3d7fc1fcc91165cdf8dd9d6ec70d6400086d564b68ebead0d03ebd3aa66ded555692b8de0baf43bc0ddef42e3a9eb34ab":96:"24483a57c20826a709b7d10a":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1dfa5ff20046c775b5e768c2bd9775066ae766345b7befc3":"":"2d49409b869b8b9fc5b67767979ca8cd":"e35d34478b228bc903ea2423697e603cc077967d7cfb062e95bc11d89fbe0a1f1d4569f89b2a7047300c1f5131d91564ec9bce014d18ba605a1c1e4e15e3e5c18413b8b59cbb25ab8f088885225de1235c16c7d9a8d06a23cb0b38fd1d5c6c19617fe08fd6bf01c965ed593149a1c6295435e98463e4f03a511d1a7e82c11f01":96:"23012503febbf26dc2d872dc":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1dfa5ff20046c775b5e768c2bd9775066ae766345b7befc3":"":"2d49409b869b8b9fc5b67767979ca8cd":"e35d34478b228bc903ea2423697e603cc077967d7cfb062e95bc11d89fbe0a1f1d4569f89b2a7047300c1f5131d91564ec9bce014d18ba605a1c1e4e15e3e5c18413b8b59cbb25ab8f088885225de1235c16c7d9a8d06a23cb0b38fd1d5c6c19617fe08fd6bf01c965ed593149a1c6295435e98463e4f03a511d1a7e82c11f01":96:"23012503febbf26dc2d872dc":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2df3ee3a6484c48fdd0d37bab443228c7d873c984529dfb4":"":"dc6aeb41415c115d66443fbd7acdfc8f":"eafc6007fafb461d3b151bdff459e56dd09b7b48b93ea730c85e5424f762b4a9080de44497a7c56dd7855628ffc61c7b4faeb7d6f413d464fe5ec6401f3028427ae3e62db3ff39cd0f5333a664d3505ff42caa8899b96a92ec01934d4b59556feb9055e8dfb81f55e60135345bfce3e4199bfcdb3ce42523e7d24be2a04cdb67":96:"e8e80bf6e5c4a55e7964f455":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2df3ee3a6484c48fdd0d37bab443228c7d873c984529dfb4":"":"dc6aeb41415c115d66443fbd7acdfc8f":"eafc6007fafb461d3b151bdff459e56dd09b7b48b93ea730c85e5424f762b4a9080de44497a7c56dd7855628ffc61c7b4faeb7d6f413d464fe5ec6401f3028427ae3e62db3ff39cd0f5333a664d3505ff42caa8899b96a92ec01934d4b59556feb9055e8dfb81f55e60135345bfce3e4199bfcdb3ce42523e7d24be2a04cdb67":96:"e8e80bf6e5c4a55e7964f455":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ce0787f65e6c24a1c444c35dcd38195197530aa20f1f6f3b":"":"55300431b1eaac0375681d7821e1eb7a":"84a699a34a1e597061ef95e8ec3c21b592e9236ddb98c68d7e05f1e709937b48ec34a4b88d99708d133a2cc33f5cf6819d5e7b82888e49faa5d54147d36c9e486630aa68fef88d55537119db1d57df0402f56e219f7ece7b4bb5f996dbe1c664a75174c880a00b0f2a56e35d17b69c550921961505afabf4bfd66cf04dc596d1":64:"74264163131d16ac":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ce0787f65e6c24a1c444c35dcd38195197530aa20f1f6f3b":"":"55300431b1eaac0375681d7821e1eb7a":"84a699a34a1e597061ef95e8ec3c21b592e9236ddb98c68d7e05f1e709937b48ec34a4b88d99708d133a2cc33f5cf6819d5e7b82888e49faa5d54147d36c9e486630aa68fef88d55537119db1d57df0402f56e219f7ece7b4bb5f996dbe1c664a75174c880a00b0f2a56e35d17b69c550921961505afabf4bfd66cf04dc596d1":64:"74264163131d16ac":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3a15541b5857a668dc9899b2e198d2416e83bac13282ca46":"":"89bf8ab0cea6f59616eeb9b314d7c333":"4d2843f34f9ea13a1ac521479457005178bcf8b2ebeaeb09097ea4471da9f6cc60a532bcda1c18cab822af541de3b87de606999e994ace3951f58a02de0d6620c9ae04549326da449a3e90364a17b90b6b17debc0f454bb0e7e98aef56a1caccf8c91614d1616db30fc8223dbcd8e77bf55d8253efe034fd66f7191e0303c52f":64:"8f4877806daff10e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3a15541b5857a668dc9899b2e198d2416e83bac13282ca46":"":"89bf8ab0cea6f59616eeb9b314d7c333":"4d2843f34f9ea13a1ac521479457005178bcf8b2ebeaeb09097ea4471da9f6cc60a532bcda1c18cab822af541de3b87de606999e994ace3951f58a02de0d6620c9ae04549326da449a3e90364a17b90b6b17debc0f454bb0e7e98aef56a1caccf8c91614d1616db30fc8223dbcd8e77bf55d8253efe034fd66f7191e0303c52f":64:"8f4877806daff10e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b61cdfd19c136ee2acbe09b7993a4683a713427518f8e559":"":"4066118061c904ed1e866d4f31d11234":"153c075ecdd184fd8a0fca25cae8f720201361ef84f3c638b148ca32c51d091a0e394236d0b51c1d2ee601914120c56dfea1289af470dbc9ef462ec5f974e455e6a83e215a2c8e27c0c5b5b45b662b7f58635a29866e8f76ab41ee628c12a24ab4d5f7954665c3e4a3a346739f20393fc5700ec79d2e3c2722c3fb3c77305337":64:"4eff7227b42f9a7d":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b61cdfd19c136ee2acbe09b7993a4683a713427518f8e559":"":"4066118061c904ed1e866d4f31d11234":"153c075ecdd184fd8a0fca25cae8f720201361ef84f3c638b148ca32c51d091a0e394236d0b51c1d2ee601914120c56dfea1289af470dbc9ef462ec5f974e455e6a83e215a2c8e27c0c5b5b45b662b7f58635a29866e8f76ab41ee628c12a24ab4d5f7954665c3e4a3a346739f20393fc5700ec79d2e3c2722c3fb3c77305337":64:"4eff7227b42f9a7d":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ce175a7df7e429fcc233540e6b8524323e91f40f592ba144":"":"c34484b4857b93e309df8e1a0e1ec9a3":"ce8d8775f047b543a6cc0d9ef9bc0db5ac5d610dc3ff6e12e0ad7cd3a399ebb762331e3c1101a189b3433a7ff4cd880a0639d2581b71e398dd982f55a11bf0f4e6ee95bacd897e8ec34649e1c256ee6ccecb33e36c76927cc5124bc2962713ad44cbd435ae3c1143796d3037fa1d659e5dad7ebf3c8cbdb5b619113d7ce8c483":32:"ff355f10":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ce175a7df7e429fcc233540e6b8524323e91f40f592ba144":"":"c34484b4857b93e309df8e1a0e1ec9a3":"ce8d8775f047b543a6cc0d9ef9bc0db5ac5d610dc3ff6e12e0ad7cd3a399ebb762331e3c1101a189b3433a7ff4cd880a0639d2581b71e398dd982f55a11bf0f4e6ee95bacd897e8ec34649e1c256ee6ccecb33e36c76927cc5124bc2962713ad44cbd435ae3c1143796d3037fa1d659e5dad7ebf3c8cbdb5b619113d7ce8c483":32:"ff355f10":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5f659ed236ba60494e9bf1ee2cb40edcf3f25a2bac2e5bc5":"":"ad49f12f202320255406c2f40e55b034":"6da62892f436dfe9790e72d26f4858ca156d1d655c9cc4336fcf282b0f3f0b201e47f799c3019109af89ef5fd48a4811980930e82cd95f86b1995d977c847bbb06ecdcc98b1aae100b23c9c2f0dcf317a1fb36f14e90e396e6c0c594bcc0dc5f3ebf86ce7ecd4b06d1c43202734d53f55751a6e6bbda982104102af240def4eb":32:"cb4d8c1d":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5f659ed236ba60494e9bf1ee2cb40edcf3f25a2bac2e5bc5":"":"ad49f12f202320255406c2f40e55b034":"6da62892f436dfe9790e72d26f4858ca156d1d655c9cc4336fcf282b0f3f0b201e47f799c3019109af89ef5fd48a4811980930e82cd95f86b1995d977c847bbb06ecdcc98b1aae100b23c9c2f0dcf317a1fb36f14e90e396e6c0c594bcc0dc5f3ebf86ce7ecd4b06d1c43202734d53f55751a6e6bbda982104102af240def4eb":32:"cb4d8c1d":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a73f318b1e298ba4ac0ab2aed74f73543b1017cccbd1b240":"":"abe33b7e8d88bd30deb96d1e90c4e951":"6de616b000047b14b6759015183dd753c61499c0e665d06a89e4fb0cd0dd3064ff8651582e901ef5d0cdf3344c29c70c3aabc2aaf83cb3f284c6fe4104906d389b027e7d9ca60d010f06ef8cd9e55db2483d06552ddbe3fc43b24c55085cd998eae3edec36673445bf626e933c15b6af08ea21cbace4720b0b68fe1a374877d5":32:"4a28ec97":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a73f318b1e298ba4ac0ab2aed74f73543b1017cccbd1b240":"":"abe33b7e8d88bd30deb96d1e90c4e951":"6de616b000047b14b6759015183dd753c61499c0e665d06a89e4fb0cd0dd3064ff8651582e901ef5d0cdf3344c29c70c3aabc2aaf83cb3f284c6fe4104906d389b027e7d9ca60d010f06ef8cd9e55db2483d06552ddbe3fc43b24c55085cd998eae3edec36673445bf626e933c15b6af08ea21cbace4720b0b68fe1a374877d5":32:"4a28ec97":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"73d5be74615bc5b627eedfb95746fb5f17cbf25b500a597f":"fc40993eb8559e6b127315c03103ce31b70fc0e07a766d9eecf2e4e8d973faa4afd3053c9ebef0282c9e3d2289d21b6c339748273fa1edf6d6ef5c8f1e1e9301b250297092d9ac4f4843125ea7299d5370f7f49c258eac2a58cc9df14c162604ba0801728994dc82cb625981130c3ca8cdb3391658d4e034691e62ece0a6e407":"eb16ed8de81efde2915a901f557fba95":"":128:"804056dca9f102c4a13a930c81d77eca":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"73d5be74615bc5b627eedfb95746fb5f17cbf25b500a597f":"fc40993eb8559e6b127315c03103ce31b70fc0e07a766d9eecf2e4e8d973faa4afd3053c9ebef0282c9e3d2289d21b6c339748273fa1edf6d6ef5c8f1e1e9301b250297092d9ac4f4843125ea7299d5370f7f49c258eac2a58cc9df14c162604ba0801728994dc82cb625981130c3ca8cdb3391658d4e034691e62ece0a6e407":"eb16ed8de81efde2915a901f557fba95":"":128:"804056dca9f102c4a13a930c81d77eca":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a249135c9f2f5a8b1af66442a4d4e101771a918ef8acee05":"c62b39b937edbdc9b644321d5d284e62eaa4154010c7a3208c1ef4706fba90223da04b2f686a28b975eff17386598ba77e212855692f384782c1f3c00be011e466e145f6f8b65c458e41409e01a019b290773992e19334ffaca544e28fc9044a5e86bcd2fa5ad2e76f2be3f014d8c387456a8fcfded3ae4d1194d0e3e53a2031":"80b6e48fe4a3b08d40c1636b25dfd2c4":"":128:"951c1c89b6d95661630d739dd9120a73":"b865f8dd64a6f51a500bcfc8cadbc9e9f5d54d2d27d815ecfe3d5731e1b230c587b46958c6187e41b52ff187a14d26aa41c5f9909a3b77859429232e5bd6c6dc22cf5590402476d033a32682e8ab8dc7ed0b089c5ab20ab9a8c5d6a3be9ea7aa56c9d3ab08de4a4a019abb447db448062f16a533d416951a8ff6f13ed5608f77":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a249135c9f2f5a8b1af66442a4d4e101771a918ef8acee05":"c62b39b937edbdc9b644321d5d284e62eaa4154010c7a3208c1ef4706fba90223da04b2f686a28b975eff17386598ba77e212855692f384782c1f3c00be011e466e145f6f8b65c458e41409e01a019b290773992e19334ffaca544e28fc9044a5e86bcd2fa5ad2e76f2be3f014d8c387456a8fcfded3ae4d1194d0e3e53a2031":"80b6e48fe4a3b08d40c1636b25dfd2c4":"":128:"951c1c89b6d95661630d739dd9120a73":"":"b865f8dd64a6f51a500bcfc8cadbc9e9f5d54d2d27d815ecfe3d5731e1b230c587b46958c6187e41b52ff187a14d26aa41c5f9909a3b77859429232e5bd6c6dc22cf5590402476d033a32682e8ab8dc7ed0b089c5ab20ab9a8c5d6a3be9ea7aa56c9d3ab08de4a4a019abb447db448062f16a533d416951a8ff6f13ed5608f77":0 AES-GCM NIST Validation (AES-192,128,1024,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fa832a4b37dcb3c0879a771bb8ae734f0d88b9be497797a8":"0f1105f9ec24121232b60b6ef3c3e8ca9eec1a3d7625004b857d1d77f292b6ec065d92f5bb97e0dc2fdfdf823a5db275109a9472690caea04730e4bd732c33548718e9f7658bbf3e30b8d07790cd540c5754486ed8e4d6920cefaeb1c182c4d67ebed0d205ba0bd9441a599d55e45094b380f3478bcfca9646a0d7aa18d08e52":"70835abab9f945c84ef4e97cdcf2a694":"":128:"a459be0b349f6e8392c2a86edd8a9da5":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fa832a4b37dcb3c0879a771bb8ae734f0d88b9be497797a8":"0f1105f9ec24121232b60b6ef3c3e8ca9eec1a3d7625004b857d1d77f292b6ec065d92f5bb97e0dc2fdfdf823a5db275109a9472690caea04730e4bd732c33548718e9f7658bbf3e30b8d07790cd540c5754486ed8e4d6920cefaeb1c182c4d67ebed0d205ba0bd9441a599d55e45094b380f3478bcfca9646a0d7aa18d08e52":"70835abab9f945c84ef4e97cdcf2a694":"":128:"a459be0b349f6e8392c2a86edd8a9da5":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dda216287910d1f5c0a312f63c243612388bc510cb76c5ba":"d6617d583344d4fe472099d2a688297857215a3e31b47d1bf355ccfe9cf2398a3eba362c670c88f8c7162903275dfd4761d095900bd97eba72200d4045d72bd239bda156829c36b38b1ff5e4230125e5695f623e129829721e889da235bb7d4b9da07cce8c3ceb96964fd2f9dd1ff0997e1a3e253a688ceb1bfec76a7c567266":"7f770140df5b8678bc9c4b962b8c9034":"":120:"9823e3242b3f890c6a456f1837e039":"b4910277224025f58a5d0f37385b03fcd488dfef7580eb5c270c10bd7a6f6d9c7ddc2d1368d68d4e04f90e3df029ed028432a09f710be1610b2a75bd05f31bae83920573929573affd0eb03c63e0cec7a027deab792f43ee6307fd3c5078d43d5b1407ac023824d41c9437d66eeec172488f28d700aa4b54931aad7cd458456f":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dda216287910d1f5c0a312f63c243612388bc510cb76c5ba":"d6617d583344d4fe472099d2a688297857215a3e31b47d1bf355ccfe9cf2398a3eba362c670c88f8c7162903275dfd4761d095900bd97eba72200d4045d72bd239bda156829c36b38b1ff5e4230125e5695f623e129829721e889da235bb7d4b9da07cce8c3ceb96964fd2f9dd1ff0997e1a3e253a688ceb1bfec76a7c567266":"7f770140df5b8678bc9c4b962b8c9034":"":120:"9823e3242b3f890c6a456f1837e039":"":"b4910277224025f58a5d0f37385b03fcd488dfef7580eb5c270c10bd7a6f6d9c7ddc2d1368d68d4e04f90e3df029ed028432a09f710be1610b2a75bd05f31bae83920573929573affd0eb03c63e0cec7a027deab792f43ee6307fd3c5078d43d5b1407ac023824d41c9437d66eeec172488f28d700aa4b54931aad7cd458456f":0 AES-GCM NIST Validation (AES-192,128,1024,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c5afa1e61d4594b1c2fa637f64f18dd557e4df3255b47f24":"5c772cdf19571cd51d71fc166d33a0b892fbca4eae36ab0ac94e6164d51acb2d4e60d4f3a19c3757a93960e7fd90b9a6cdf98bdf259b370ed6c7ef8cb96dba7e3a875e6e7fe6abc76aabad30c8743b3e47c8de5d604c748eeb16806c2e75180a96af7741904eca61769d39e943eb4c4c25f2afd68e9472043de2bb03e9edae20":"151fd3ba32f5bde72adce6291bcf63ea":"":120:"f0626cc07f2ed1a7570386a4110fc1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c5afa1e61d4594b1c2fa637f64f18dd557e4df3255b47f24":"5c772cdf19571cd51d71fc166d33a0b892fbca4eae36ab0ac94e6164d51acb2d4e60d4f3a19c3757a93960e7fd90b9a6cdf98bdf259b370ed6c7ef8cb96dba7e3a875e6e7fe6abc76aabad30c8743b3e47c8de5d604c748eeb16806c2e75180a96af7741904eca61769d39e943eb4c4c25f2afd68e9472043de2bb03e9edae20":"151fd3ba32f5bde72adce6291bcf63ea":"":120:"f0626cc07f2ed1a7570386a4110fc1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"febd4ff0fedd9f16bccb62380d59cd41b8eff1834347d8fa":"dc971c8f65ece2ea4130afd4db38fc657c085ea19c76fef50f5bd0f8dd364cc22471c2fa36be8cde78529f58a78888e9de10961760a01af005e42fc5b03e6f64962e6b18eaedea979d33d1b06e2038b1aad8993e5b20cae6cc93f3f7cf2ad658fbba633d74f21a2003dded5f5dda3b46ed7424845c11bab439fbb987f0be09f8":"743699d3759781e82a3d21c7cd7991c8":"":120:"1da347f9b6341049e63140395ad445":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"febd4ff0fedd9f16bccb62380d59cd41b8eff1834347d8fa":"dc971c8f65ece2ea4130afd4db38fc657c085ea19c76fef50f5bd0f8dd364cc22471c2fa36be8cde78529f58a78888e9de10961760a01af005e42fc5b03e6f64962e6b18eaedea979d33d1b06e2038b1aad8993e5b20cae6cc93f3f7cf2ad658fbba633d74f21a2003dded5f5dda3b46ed7424845c11bab439fbb987f0be09f8":"743699d3759781e82a3d21c7cd7991c8":"":120:"1da347f9b6341049e63140395ad445":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d280d079110c1c826cc77f490d807dd8d508eb579a160c49":"a286d19610a990d64f3accd329fc005d468465a98cfa2f3606c6d0fbeb9732879bad3ca8094322a334a43155baed02d8e13a2fbf259d80066c6f418a1a74b23e0f6238f505b2b3dc906ffcb4910ce6c878b595bb4e5f8f3e2ede912b38dbafdf4659a93b056a1a67cb0ec1dbf00d93223f3b20b3f64a157105c5445b61628abf":"85b241d516b94759c9ef975f557bccea":"":112:"bbf289df539f78c3a912b141da3a":"b9286ab91645c20de040a805020fed53c612d493a8ce9c71649ae16bd50eab6fb7f3a9180e1651d5413aa542608d7ecbf9fc7378c0bef4d439bc35434b6cf803976b8783aecc83a91e95cea72c2a26a883b710252e0c2a6baa115739a0692c85f6d34ff06234fbdc79b8c4a8ea0a7056fb48c18f73aaf5084868abb0dfaa287d":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d280d079110c1c826cc77f490d807dd8d508eb579a160c49":"a286d19610a990d64f3accd329fc005d468465a98cfa2f3606c6d0fbeb9732879bad3ca8094322a334a43155baed02d8e13a2fbf259d80066c6f418a1a74b23e0f6238f505b2b3dc906ffcb4910ce6c878b595bb4e5f8f3e2ede912b38dbafdf4659a93b056a1a67cb0ec1dbf00d93223f3b20b3f64a157105c5445b61628abf":"85b241d516b94759c9ef975f557bccea":"":112:"bbf289df539f78c3a912b141da3a":"":"b9286ab91645c20de040a805020fed53c612d493a8ce9c71649ae16bd50eab6fb7f3a9180e1651d5413aa542608d7ecbf9fc7378c0bef4d439bc35434b6cf803976b8783aecc83a91e95cea72c2a26a883b710252e0c2a6baa115739a0692c85f6d34ff06234fbdc79b8c4a8ea0a7056fb48c18f73aaf5084868abb0dfaa287d":0 AES-GCM NIST Validation (AES-192,128,1024,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5e80f87fa2156c62df7be2ad16c4890de5ee5868a684fcf9":"c829073efd5c5150d2b7e2cdaeff979830d1aa983c747724ade6472c647a6e8e5033046e0359ea62fc26b4c95bccb3ac416fdf54e95815c35bf86d3fdd7856abbb618fe8fcd35a9295114926a0c9df92317d44ba1885a0c67c10b9ba24b8b2f3a464308c5578932247bf9c79d939aa3576376d2d6b4f14a378ab775531fe8abf":"9769f71c76b5b6c60462a845d2c123ad":"":112:"394b6c631a69be3ed8c90770f3d4":"f886bd92ca9d73a52e626b0c63a3daa138faaacf7809086d04f5c0c899362aa22e25d8659653b59c3103668461d9785bb425c6c1026ad9c924271cec9f27a9b341f708ca86f1d82a77aae88b25da9061b78b97276f3216720352629bd1a27ebf890da6f42d8c63d68342a93c382442d49dd4b62219504785cee89dffdc36f868":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5e80f87fa2156c62df7be2ad16c4890de5ee5868a684fcf9":"c829073efd5c5150d2b7e2cdaeff979830d1aa983c747724ade6472c647a6e8e5033046e0359ea62fc26b4c95bccb3ac416fdf54e95815c35bf86d3fdd7856abbb618fe8fcd35a9295114926a0c9df92317d44ba1885a0c67c10b9ba24b8b2f3a464308c5578932247bf9c79d939aa3576376d2d6b4f14a378ab775531fe8abf":"9769f71c76b5b6c60462a845d2c123ad":"":112:"394b6c631a69be3ed8c90770f3d4":"":"f886bd92ca9d73a52e626b0c63a3daa138faaacf7809086d04f5c0c899362aa22e25d8659653b59c3103668461d9785bb425c6c1026ad9c924271cec9f27a9b341f708ca86f1d82a77aae88b25da9061b78b97276f3216720352629bd1a27ebf890da6f42d8c63d68342a93c382442d49dd4b62219504785cee89dffdc36f868":0 AES-GCM NIST Validation (AES-192,128,1024,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d8a7b99e53f5e5b197364d4516cace4b928de50e571315e3":"d0db0ac5e14bf03729125f3137d4854b4d8ce2d264f8646da17402bdad7034c0d84d7a80f107eb202aeadbfdf063904ae9793c6ae91ee8bcc0fc0674d8111f6aea6607633f92e4be3cfbb64418101db8b0a9225c83e60ffcf7a7f71f77149a13f8c5227cd92855241e11ee363062a893a76ac282fb47b523b306cd8235cd81c2":"4b12c6701534098e23e1b4659f684d6f":"":112:"729b31c65d8699c93d741caac8e3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d8a7b99e53f5e5b197364d4516cace4b928de50e571315e3":"d0db0ac5e14bf03729125f3137d4854b4d8ce2d264f8646da17402bdad7034c0d84d7a80f107eb202aeadbfdf063904ae9793c6ae91ee8bcc0fc0674d8111f6aea6607633f92e4be3cfbb64418101db8b0a9225c83e60ffcf7a7f71f77149a13f8c5227cd92855241e11ee363062a893a76ac282fb47b523b306cd8235cd81c2":"4b12c6701534098e23e1b4659f684d6f":"":112:"729b31c65d8699c93d741caac8e3":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c874b427b7181b0c90b887147c36f242827149324fd5c945":"bdd90190d587a564af022f06c8bd1a68735b6f18f04113fdcec24c6027aaf0271b183336fb713d247a173d9e095dae6e9badb0ab069712302875406f14320151fd43b90a3d6f35cc856636b1a6f98afc797cb5259567e2e9b7ce62d7b3370b5ee852722faf740edf815b3af460cdd7de90ca6ab6cd173844216c064b16ea3696":"4b8dda046a5b7c46abeeca2f2f9bcaf8":"":104:"fe1e427bcb15ce026413a0da87":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c874b427b7181b0c90b887147c36f242827149324fd5c945":"bdd90190d587a564af022f06c8bd1a68735b6f18f04113fdcec24c6027aaf0271b183336fb713d247a173d9e095dae6e9badb0ab069712302875406f14320151fd43b90a3d6f35cc856636b1a6f98afc797cb5259567e2e9b7ce62d7b3370b5ee852722faf740edf815b3af460cdd7de90ca6ab6cd173844216c064b16ea3696":"4b8dda046a5b7c46abeeca2f2f9bcaf8":"":104:"fe1e427bcb15ce026413a0da87":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"56543cd6e2ebb1e3dc136a826bfc37eddb12f7a26430a1b4":"d541dd3acec2da042e6ea26fb90ff9a3861191926423b6dc99c5110b3bf150b362017159d0b85ffea397106a0d8299ec22791cb06103cd44036eed0d6d9f953724fb003068b3c3d97da129c28d97f09e6300cbea06ba66f410ca61c3311ce334c55f077c37acb3b7129c481748f79c958bc3bbeb2d3ff445ad361ed4bbc79f0a":"927ce8a596ed28c85d9cb8e688a829e6":"":104:"3a98f471112a8a646460e8efd0":"a602d61e7a35cbe0e463119bb66fd4bb6c75d1fe0b211b9d6a0a6e9e84b0794282318f0d33ec053f2cfba1623e865681affeaf29f3da3113995e87d51a5ab4872bb05b5be8ef2b14dfc3df5a48cbc9b10853a708ee4886a7390e8e4d286740a0dd41c025c8d72eda3f73f3cec5c33d5e50b643afd7691213cccccc2c41b9bd7a":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"56543cd6e2ebb1e3dc136a826bfc37eddb12f7a26430a1b4":"d541dd3acec2da042e6ea26fb90ff9a3861191926423b6dc99c5110b3bf150b362017159d0b85ffea397106a0d8299ec22791cb06103cd44036eed0d6d9f953724fb003068b3c3d97da129c28d97f09e6300cbea06ba66f410ca61c3311ce334c55f077c37acb3b7129c481748f79c958bc3bbeb2d3ff445ad361ed4bbc79f0a":"927ce8a596ed28c85d9cb8e688a829e6":"":104:"3a98f471112a8a646460e8efd0":"":"a602d61e7a35cbe0e463119bb66fd4bb6c75d1fe0b211b9d6a0a6e9e84b0794282318f0d33ec053f2cfba1623e865681affeaf29f3da3113995e87d51a5ab4872bb05b5be8ef2b14dfc3df5a48cbc9b10853a708ee4886a7390e8e4d286740a0dd41c025c8d72eda3f73f3cec5c33d5e50b643afd7691213cccccc2c41b9bd7a":0 AES-GCM NIST Validation (AES-192,128,1024,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"caaf81cd380f3af7885ef0d6196a1688c9372c5850dc5b0b":"6f269929b92c6281e00672eaec183f187b2ddecc11c9045319521d245b595ab154dd50f045a660c4d53ae07d1b7a7fd6b21da10976eb5ffcddda08c1e9075a3b4d785faa003b4dd243f379e0654740b466704d9173bc43292ae0e279a903a955ce33b299bf2842b3461f7c9a2bd311f3e87254b5413d372ec543d6efa237b95a":"508c55f1726896f5b9f0a7024fe2fad0":"":104:"3b8026268caf599ee677ecfd70":"c4a96fb08d7c2eebd17046172b98569bc2441929fc0d6876aa1f389b80c05e2ede74dc6f8c3896a2ccf518e1b375ee75e4967f7cca21fa81ee176f8fb8753381ce03b2df873897131adc62a0cbebf718c8e0bb8eeed3104535f17a9c706d178d95a1b232e9dac31f2d1bdb3a1b098f3056f0e3d18be36bd746675779c0f80a10":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"caaf81cd380f3af7885ef0d6196a1688c9372c5850dc5b0b":"6f269929b92c6281e00672eaec183f187b2ddecc11c9045319521d245b595ab154dd50f045a660c4d53ae07d1b7a7fd6b21da10976eb5ffcddda08c1e9075a3b4d785faa003b4dd243f379e0654740b466704d9173bc43292ae0e279a903a955ce33b299bf2842b3461f7c9a2bd311f3e87254b5413d372ec543d6efa237b95a":"508c55f1726896f5b9f0a7024fe2fad0":"":104:"3b8026268caf599ee677ecfd70":"":"c4a96fb08d7c2eebd17046172b98569bc2441929fc0d6876aa1f389b80c05e2ede74dc6f8c3896a2ccf518e1b375ee75e4967f7cca21fa81ee176f8fb8753381ce03b2df873897131adc62a0cbebf718c8e0bb8eeed3104535f17a9c706d178d95a1b232e9dac31f2d1bdb3a1b098f3056f0e3d18be36bd746675779c0f80a10":0 AES-GCM NIST Validation (AES-192,128,1024,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2fc9d9ac8469cfc718add2b03a4d8c8dcc2eeca08e5ff7bc":"bc84d8a962a9cfd179d242788473d980d177abd0af9edccb14c6dc41535439a1768978158eeed99466574ea820dbedea68c819ffd9f9915ca8392c2e03049d7198baeca1d3491fe2345e64c1012aff03985b86c831ad516d4f5eb538109fff25383c7b0fa6b940ae19b0987d8c3e4a37ccbbd2034633c1eb0df1e9ddf3a8239e":"b2a7c0d52fc60bacc3d1a94f33087095":"":96:"0a7a36ec128d0deb60869893":"fc3cd6486dfe944f7cb035787573a554f4fe010c15bd08d6b09f73066f6f272ff84474f3845337b6e429c947d419c511c2945ffb181492c5465940cef85077e8a6a272a07e310a2f3808f11be03d96162913c613d9c3f25c3893c2bd2a58a619a9757fd16cc20c1308f2140557330379f07dbfd8979b26b075977805f1885acc":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2fc9d9ac8469cfc718add2b03a4d8c8dcc2eeca08e5ff7bc":"bc84d8a962a9cfd179d242788473d980d177abd0af9edccb14c6dc41535439a1768978158eeed99466574ea820dbedea68c819ffd9f9915ca8392c2e03049d7198baeca1d3491fe2345e64c1012aff03985b86c831ad516d4f5eb538109fff25383c7b0fa6b940ae19b0987d8c3e4a37ccbbd2034633c1eb0df1e9ddf3a8239e":"b2a7c0d52fc60bacc3d1a94f33087095":"":96:"0a7a36ec128d0deb60869893":"":"fc3cd6486dfe944f7cb035787573a554f4fe010c15bd08d6b09f73066f6f272ff84474f3845337b6e429c947d419c511c2945ffb181492c5465940cef85077e8a6a272a07e310a2f3808f11be03d96162913c613d9c3f25c3893c2bd2a58a619a9757fd16cc20c1308f2140557330379f07dbfd8979b26b075977805f1885acc":0 AES-GCM NIST Validation (AES-192,128,1024,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"81ff729efa4a9aa2eccc37c5f846235b53d3b93c79c709c8":"3992ad29eeb97d17bd5c0f04d8589903ee23ccb2b1adc2992a48a2eb62c2644c0df53b4afe4ace60dc5ec249c0c083473ebac3323539a575c14fa74c8381d1ac90cb501240f96d1779b287f7d8ba8775281d453aae37c803185f2711d21f5c00eb45cad37587ed196d1633f1eb0b33abef337447d03ec09c0e3f7fd32e8c69f0":"1bd17f04d1dc2e447b41665952ad9031":"":96:"01b0a815dc6da3e32851e1fb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"81ff729efa4a9aa2eccc37c5f846235b53d3b93c79c709c8":"3992ad29eeb97d17bd5c0f04d8589903ee23ccb2b1adc2992a48a2eb62c2644c0df53b4afe4ace60dc5ec249c0c083473ebac3323539a575c14fa74c8381d1ac90cb501240f96d1779b287f7d8ba8775281d453aae37c803185f2711d21f5c00eb45cad37587ed196d1633f1eb0b33abef337447d03ec09c0e3f7fd32e8c69f0":"1bd17f04d1dc2e447b41665952ad9031":"":96:"01b0a815dc6da3e32851e1fb":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"068500e8d4f8d4af9035cdaa8e005a648352e8f28bdafc8a":"98e32428d9d21c4b60e690a2ce1cf70bee90df31302d1819b7d27fd577dd990f7ffe6ba5ef117caac718cc1880b4ca98f72db281c9609e189307302dc2866f20be3a545a565521368a6881e2642cba63b3cf4c8b5e5a8eabeb3e8b004618b8f77667c111e5402c5d7c66afd297c575ce5092e898d5831031d225cee668c186a1":"5ea9198b860679759357befdbb106b62":"":96:"d58752f66b2cb9bb2bc388eb":"2ef3a17fcdb154f60d5e80263b7301a8526d2de451ea49adb441aa2541986b868dab24027178f48759dbe874ae7aa7b27fb19461c6678a0ba84bbcd8567ba2412a55179e15e7c1a1392730ac392b59c51d48f8366d45b933880095800e1f36ff1ac00753f6363b0e854f494552f1f2efe028d969e6b1a8080149dd853aa6751e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"068500e8d4f8d4af9035cdaa8e005a648352e8f28bdafc8a":"98e32428d9d21c4b60e690a2ce1cf70bee90df31302d1819b7d27fd577dd990f7ffe6ba5ef117caac718cc1880b4ca98f72db281c9609e189307302dc2866f20be3a545a565521368a6881e2642cba63b3cf4c8b5e5a8eabeb3e8b004618b8f77667c111e5402c5d7c66afd297c575ce5092e898d5831031d225cee668c186a1":"5ea9198b860679759357befdbb106b62":"":96:"d58752f66b2cb9bb2bc388eb":"":"2ef3a17fcdb154f60d5e80263b7301a8526d2de451ea49adb441aa2541986b868dab24027178f48759dbe874ae7aa7b27fb19461c6678a0ba84bbcd8567ba2412a55179e15e7c1a1392730ac392b59c51d48f8366d45b933880095800e1f36ff1ac00753f6363b0e854f494552f1f2efe028d969e6b1a8080149dd853aa6751e":0 AES-GCM NIST Validation (AES-192,128,1024,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7474d9b07739001b25baf6867254994e06e54c578508232f":"1cbab2b6e4274caa80987072914f667b887198f7aaf4574608b91b5274f5afc3eb05a457554ff5d346d460f92c068bc626fd301d0bb15cb3726504b3d88ecd46a15077728ddc2b698a2e8c5ea5885fc534ac227b8f103d193f1977badf4f853a0931398da01f8019a9b1ff271b3a783ff0fae6f54db425af6e3a345ba7512cbf":"3ade6c92fe2dc575c136e3fbbba5c484":"":64:"67c25240b8e39b63":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7474d9b07739001b25baf6867254994e06e54c578508232f":"1cbab2b6e4274caa80987072914f667b887198f7aaf4574608b91b5274f5afc3eb05a457554ff5d346d460f92c068bc626fd301d0bb15cb3726504b3d88ecd46a15077728ddc2b698a2e8c5ea5885fc534ac227b8f103d193f1977badf4f853a0931398da01f8019a9b1ff271b3a783ff0fae6f54db425af6e3a345ba7512cbf":"3ade6c92fe2dc575c136e3fbbba5c484":"":64:"67c25240b8e39b63":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d50d4c7d442d8a92d0489a96e897d50dda6fbe47ca7713ee":"b36b4caf1d47b0d10652824bd57b603ec1c16f4720ce7d43edde8af1b9737f61b68b882566e04da50136f27d9af4c4c57fff4c8465c8a85f0aeadc17e02709cc9ba818d9a272709e5fb65dd5612a5c5d700da399b3668a00041a51c23de616ea3f72093d85ecbfd9dd0b5d02b541fb605dcffe81e9f45a5c0c191cc0b92ac56d":"41b37c04ab8a80f5a8d9d82a3a444772":"":64:"4ee54d280829e6ef":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d50d4c7d442d8a92d0489a96e897d50dda6fbe47ca7713ee":"b36b4caf1d47b0d10652824bd57b603ec1c16f4720ce7d43edde8af1b9737f61b68b882566e04da50136f27d9af4c4c57fff4c8465c8a85f0aeadc17e02709cc9ba818d9a272709e5fb65dd5612a5c5d700da399b3668a00041a51c23de616ea3f72093d85ecbfd9dd0b5d02b541fb605dcffe81e9f45a5c0c191cc0b92ac56d":"41b37c04ab8a80f5a8d9d82a3a444772":"":64:"4ee54d280829e6ef":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"38f3ec3ec775dac76ae484d5b6ca61c695c7beafba4606ca":"49726b8cefc842a02f2d7bef099871f38257cc8ea096c9ac50baced6d940acb4e8baf932bec379a973a2c3a3bc49f60f7e9eef45eafdd15bda1dd1557f068e81226af503934eb96564d14c03f0f351974c8a54fb104fb07417fe79272e4b0c0072b9f89b770326562e4e1b14cad784a2cd1b4ae1dc43623ec451a1cae55f6f84":"9af53cf6891a749ab286f5c34238088a":"":64:"6f6f344dd43b0d20":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"38f3ec3ec775dac76ae484d5b6ca61c695c7beafba4606ca":"49726b8cefc842a02f2d7bef099871f38257cc8ea096c9ac50baced6d940acb4e8baf932bec379a973a2c3a3bc49f60f7e9eef45eafdd15bda1dd1557f068e81226af503934eb96564d14c03f0f351974c8a54fb104fb07417fe79272e4b0c0072b9f89b770326562e4e1b14cad784a2cd1b4ae1dc43623ec451a1cae55f6f84":"9af53cf6891a749ab286f5c34238088a":"":64:"6f6f344dd43b0d20":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6db4ef061513ef6690d57aef50d8011e0dd7eb4432d82374":"b7f9206995bc97311855ee832e2b40c41ab2d1a40d9263683c95b14dcc51c74d2de7b6198f9d4766c659e7619fe2693a5b188fac464ccbd5e632c5fd248cedba4028a92de12ed91415077e94cfe7a60f117052dea8916dfe0a51d92c1c03927e93012dbacd29bbbc50ce537a8173348ca904ac86df55940e9394c2895a9fe563":"623df5a0922d1e8c883debb2e0e5e0b1":"":32:"14f690d7":"a6414daa9be693e7ebb32480a783c54292e57feef4abbb3636bebbc3074bfc608ad55896fe9bd5ab875e52a43f715b98f52c07fc9fa6194ea0cd8ed78404f251639069c5a313ccfc6b94fb1657153ff48f16f6e22b3c4a0b7f88e188c90176447fe27fa7ddc2bac3d2b7edecad5f7605093ac4280b38ae6a4c040d2d4d491b42":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6db4ef061513ef6690d57aef50d8011e0dd7eb4432d82374":"b7f9206995bc97311855ee832e2b40c41ab2d1a40d9263683c95b14dcc51c74d2de7b6198f9d4766c659e7619fe2693a5b188fac464ccbd5e632c5fd248cedba4028a92de12ed91415077e94cfe7a60f117052dea8916dfe0a51d92c1c03927e93012dbacd29bbbc50ce537a8173348ca904ac86df55940e9394c2895a9fe563":"623df5a0922d1e8c883debb2e0e5e0b1":"":32:"14f690d7":"":"a6414daa9be693e7ebb32480a783c54292e57feef4abbb3636bebbc3074bfc608ad55896fe9bd5ab875e52a43f715b98f52c07fc9fa6194ea0cd8ed78404f251639069c5a313ccfc6b94fb1657153ff48f16f6e22b3c4a0b7f88e188c90176447fe27fa7ddc2bac3d2b7edecad5f7605093ac4280b38ae6a4c040d2d4d491b42":0 AES-GCM NIST Validation (AES-192,128,1024,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8901bec4d3c64071d8c30c720c093221e05efed71da280bf":"7c447e700db7367260dffa42050e612eff062eb0c8a6b4fe34858800bcb8ec2f622cb5213767b5771433783e9b0fa617c9ffb7fde09845dafc16dfc0df61215c0ca1191eabf43293db6603d5285859de7ef3329f5e71201586fb0188f0840ed5b877043ca06039768c77ff8687c5cfc2fd013a0b8da48344c568fce6b39e2b19":"9265abe966cb83838d7fd9302938f49d":"":32:"6f6c38bc":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8901bec4d3c64071d8c30c720c093221e05efed71da280bf":"7c447e700db7367260dffa42050e612eff062eb0c8a6b4fe34858800bcb8ec2f622cb5213767b5771433783e9b0fa617c9ffb7fde09845dafc16dfc0df61215c0ca1191eabf43293db6603d5285859de7ef3329f5e71201586fb0188f0840ed5b877043ca06039768c77ff8687c5cfc2fd013a0b8da48344c568fce6b39e2b19":"9265abe966cb83838d7fd9302938f49d":"":32:"6f6c38bc":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c57eb763f886154d3846cc333fc8ae8b3c7c9c3705f9872":"9fe7d210221773ba4a163850bab290ba9b7bf5e825760ac940c290a1b40cd6dd5b9fb6385ae1a79d35ee7b355b34275857d5b847bef4ac7a58f6f0e9de68687807009f5dc26244935d7bcafc7aed18316ce6c375192d2a7bf0bee8a632fe4f412440292e39339b94b28281622842f88048be4640486f2b21a119658c294ce32e":"9b3781165e7ff113ecd1d83d1df2366d":"":32:"62f32d4e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c57eb763f886154d3846cc333fc8ae8b3c7c9c3705f9872":"9fe7d210221773ba4a163850bab290ba9b7bf5e825760ac940c290a1b40cd6dd5b9fb6385ae1a79d35ee7b355b34275857d5b847bef4ac7a58f6f0e9de68687807009f5dc26244935d7bcafc7aed18316ce6c375192d2a7bf0bee8a632fe4f412440292e39339b94b28281622842f88048be4640486f2b21a119658c294ce32e":"9b3781165e7ff113ecd1d83d1df2366d":"":32:"62f32d4e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"307d31a594e54f673bea2f977835670aca4f3d45c9c376cc":"d7385a7bd0cb76e1e242fa547c474370bcc7cc7cf3e3fa37b00fe08a56383ca31d023d8c493f6d42e482b0f32e4f244dd100ea08eee6535e5bb8d27f76dbb7eead6ba8e031ccd0eaeb649edee92aeaf0f027d59efd4e39b1f34b15ceb8b592ee0f171b1773b308c0e747790b0e6ace90fc661caa5f942bdc197067f28fbe87d1":"0bdaa353c4904d32432926f27534c73c":"aa39f04559ccc2cae3d563dda831fb238b2582cb2c2bb28cff20cc20200724c8771b9805ef7464b8fc06c7b8060c6920fd2779fbc807c2292c8c1f88f8088755609a1732ff8c0b06606452b970c79997b985889404fd907c4668a0bcc11ba617175f4525523494a244da60b238468c863055f04db20ea489adf545d56c0a71d8":128:"2ddda790aae2ca427f5fb032c29673e6":"0b92262759897f4bd5624a891187eba6040d79322a2a5a60fb75c6c6a5badd117abe40c6d963931bbc72dca1a1bf1f5388030fe323b3b24bd408334b95908177fb59af57c5cc6b31825bc7097eec7fec19f9cdb41c0264fd22f71893bcf881c1510feb8057e64880f1ea2df8dc60bb300fd06b0a582f7be534e522caadc4a2c7":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"307d31a594e54f673bea2f977835670aca4f3d45c9c376cc":"d7385a7bd0cb76e1e242fa547c474370bcc7cc7cf3e3fa37b00fe08a56383ca31d023d8c493f6d42e482b0f32e4f244dd100ea08eee6535e5bb8d27f76dbb7eead6ba8e031ccd0eaeb649edee92aeaf0f027d59efd4e39b1f34b15ceb8b592ee0f171b1773b308c0e747790b0e6ace90fc661caa5f942bdc197067f28fbe87d1":"0bdaa353c4904d32432926f27534c73c":"aa39f04559ccc2cae3d563dda831fb238b2582cb2c2bb28cff20cc20200724c8771b9805ef7464b8fc06c7b8060c6920fd2779fbc807c2292c8c1f88f8088755609a1732ff8c0b06606452b970c79997b985889404fd907c4668a0bcc11ba617175f4525523494a244da60b238468c863055f04db20ea489adf545d56c0a71d8":128:"2ddda790aae2ca427f5fb032c29673e6":"":"0b92262759897f4bd5624a891187eba6040d79322a2a5a60fb75c6c6a5badd117abe40c6d963931bbc72dca1a1bf1f5388030fe323b3b24bd408334b95908177fb59af57c5cc6b31825bc7097eec7fec19f9cdb41c0264fd22f71893bcf881c1510feb8057e64880f1ea2df8dc60bb300fd06b0a582f7be534e522caadc4a2c7":0 AES-GCM NIST Validation (AES-192,128,1024,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"23c201968def551817f20e49b09dbb5aae0033305bef68a0":"77bc8af42d1b64ee39012df5fc33c554af32bfef6d9182804dcfe370dfc4b9d059bdbc55f6ba4eacb8e3a491d96a65360d790864ba60acf1a605f6b28a6591513ea3cfd768ff47aee242a8e9bdfac399b452231bfd59d81c9b91f8dc589ad751d8f9fdad01dd00631f0cb51cb0248332f24194b577e5571ceb5c037a6d0bcfe8":"bd2952d215aed5e915d863e7f7696b3e":"23f35fac583897519b94998084ad6d77666e13595109e874625bc6ccc6d0c7816a62d64b02e670fa664e3bb52c276b1bafbeb44e5f9cc3ae028daf1d787344482f31fce5d2800020732b381a8b11c6837f428204b7ed2f4c4810067f2d4da99987b66e6525fc6b9217a8f6933f1681b7cfa857e102f616a7c84adc2f676e3a8f":128:"bb9ba3a9ac7d63e67bd78d71dc3133b3":"17d93c921009c6b0b3ecf243d08b701422983f2dcaec9c8d7604a2d5565ed96ce5cddcb183cd5882f8d61d3202c9015d207fed16a4c1195ba712428c727601135315fc504e80c253c3a2e4a5593fc6c4a206edce1fd7104e8a888385bbb396d3cdf1eb2b2aa4d0c9e45451e99550d9cfa05aafe6e7b5319c73c33fd6f98db3c5":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"23c201968def551817f20e49b09dbb5aae0033305bef68a0":"77bc8af42d1b64ee39012df5fc33c554af32bfef6d9182804dcfe370dfc4b9d059bdbc55f6ba4eacb8e3a491d96a65360d790864ba60acf1a605f6b28a6591513ea3cfd768ff47aee242a8e9bdfac399b452231bfd59d81c9b91f8dc589ad751d8f9fdad01dd00631f0cb51cb0248332f24194b577e5571ceb5c037a6d0bcfe8":"bd2952d215aed5e915d863e7f7696b3e":"23f35fac583897519b94998084ad6d77666e13595109e874625bc6ccc6d0c7816a62d64b02e670fa664e3bb52c276b1bafbeb44e5f9cc3ae028daf1d787344482f31fce5d2800020732b381a8b11c6837f428204b7ed2f4c4810067f2d4da99987b66e6525fc6b9217a8f6933f1681b7cfa857e102f616a7c84adc2f676e3a8f":128:"bb9ba3a9ac7d63e67bd78d71dc3133b3":"":"17d93c921009c6b0b3ecf243d08b701422983f2dcaec9c8d7604a2d5565ed96ce5cddcb183cd5882f8d61d3202c9015d207fed16a4c1195ba712428c727601135315fc504e80c253c3a2e4a5593fc6c4a206edce1fd7104e8a888385bbb396d3cdf1eb2b2aa4d0c9e45451e99550d9cfa05aafe6e7b5319c73c33fd6f98db3c5":0 AES-GCM NIST Validation (AES-192,128,1024,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6baec0669add30acb8f678ce477a2b171f89d1f41935c491":"5712b84c4c97d75f84edd50561bc1d3f1ba451cc3b358b2403b5e528290954348cf7a235b4dc11a72ddbc503191204e98a9744d85419508c8ca76438c13305f716f1e239a6d9f6423c27217a0057aa75f6d7e2fb356e7194f271459ab5482589ea311b33e3d3845952ff4067dd2b9bcc2e8f83630b0a219e904040abd643d839":"b1472f92f552ca0d62496b8fa622c569":"5ae64edf11b4dbc7294d3d01bc9faf310dc08a92b28e664e0a7525f938d32ef033033f1de8931f39a58df0eabc8784423f0a6355efcff008cae62c1d8e5b7baefd360a5a2aa1b7068522faf8e437e6419be305ada05715bf21d73bd227531fea4bc31a6ce1662aec49f1961ee28e33ae00eb20013fd84b51cfe0d5adbdaff592":128:"29a2d607b2d2d9c96d093000b401a94f":"beb687f062ae7f5159d07609dd58d7b81c478d180bc0b4c07ae799626ff1da2be2e0d78b2a2a1f563257f161491a5ac500cd719da6379e30d0f6d0a7a33203381e058f487fc60989923afbee76e703c03abc73bb01bd262ff6f0ac931f771e9b4f2980e7d8c0a9e939fa6e1094796894f2c78f453e4abe64cb285016435ef0e8":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6baec0669add30acb8f678ce477a2b171f89d1f41935c491":"5712b84c4c97d75f84edd50561bc1d3f1ba451cc3b358b2403b5e528290954348cf7a235b4dc11a72ddbc503191204e98a9744d85419508c8ca76438c13305f716f1e239a6d9f6423c27217a0057aa75f6d7e2fb356e7194f271459ab5482589ea311b33e3d3845952ff4067dd2b9bcc2e8f83630b0a219e904040abd643d839":"b1472f92f552ca0d62496b8fa622c569":"5ae64edf11b4dbc7294d3d01bc9faf310dc08a92b28e664e0a7525f938d32ef033033f1de8931f39a58df0eabc8784423f0a6355efcff008cae62c1d8e5b7baefd360a5a2aa1b7068522faf8e437e6419be305ada05715bf21d73bd227531fea4bc31a6ce1662aec49f1961ee28e33ae00eb20013fd84b51cfe0d5adbdaff592":128:"29a2d607b2d2d9c96d093000b401a94f":"":"beb687f062ae7f5159d07609dd58d7b81c478d180bc0b4c07ae799626ff1da2be2e0d78b2a2a1f563257f161491a5ac500cd719da6379e30d0f6d0a7a33203381e058f487fc60989923afbee76e703c03abc73bb01bd262ff6f0ac931f771e9b4f2980e7d8c0a9e939fa6e1094796894f2c78f453e4abe64cb285016435ef0e8":0 AES-GCM NIST Validation (AES-192,128,1024,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b882a2df81fdb9275fb05d120f32417e8ffedd07457e938":"0aae7213da279b34d6dcf2a691b2d0333112ea22de0c3c68d47cf9f9f4ed8ad4e03d4a60ec18c3a04ac9c2abb73e1023051029b5e8705bb69c4c50afc84deb0379db5077be1f663652f8bd8958271af2c1ac4a87e08cb526bab8a030652f2a29af8055d0f31e35475caee27f84c156ef8642e5bfef89192f5bde3c54279ffe06":"5c064d3418b89388fb21c61d8c74d2c5":"5bfa7113d34e00f34713cf07c386d055e889bb42d7f6c8631ffce5668e98cb19bed8820b90ecb2b35df7134f975700347e5514287cfef7ffa2b0ff48b1de0769b03dca6610995d67cb80052cb2e5914eb4ed43ef5861f4b9364314fde6ad2b82fbba7fd849dfa6e46ecc12edc8cabfff28d9bd23c2bcc8ab3661c9ba4d5fee06":120:"0943abb85adee47741540900cc833f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b882a2df81fdb9275fb05d120f32417e8ffedd07457e938":"0aae7213da279b34d6dcf2a691b2d0333112ea22de0c3c68d47cf9f9f4ed8ad4e03d4a60ec18c3a04ac9c2abb73e1023051029b5e8705bb69c4c50afc84deb0379db5077be1f663652f8bd8958271af2c1ac4a87e08cb526bab8a030652f2a29af8055d0f31e35475caee27f84c156ef8642e5bfef89192f5bde3c54279ffe06":"5c064d3418b89388fb21c61d8c74d2c5":"5bfa7113d34e00f34713cf07c386d055e889bb42d7f6c8631ffce5668e98cb19bed8820b90ecb2b35df7134f975700347e5514287cfef7ffa2b0ff48b1de0769b03dca6610995d67cb80052cb2e5914eb4ed43ef5861f4b9364314fde6ad2b82fbba7fd849dfa6e46ecc12edc8cabfff28d9bd23c2bcc8ab3661c9ba4d5fee06":120:"0943abb85adee47741540900cc833f":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"51d94d21482c00bb5bc7e7e03aa017ba58f5a23494b72c2a":"3a9c69c1ed2340bfde1495658dbf4f54731a19b3922a1d535df8d0b2582f5e803b5891e8ad1aa256c923956dcda2430d0c0696bce63295fb61183e040566e459338f908d23ae51f64020c1ef3d192428f23312b285fc4111d50d1add58f4a49008a22c90d3365230e9158cd56f9d84f079bdd673555d4dc76c74b02fa9920e7d":"fb21cd763e6f25540f8ad455deaccdf0":"019d1db5569eeff83306f65d653b01064854c1be8446cd2516336667c6557e7844fc349adea64a12dc19ac7e8e40b0520a48fac64571a93d669045607085ac9fa78fed99bbf644908d7763fe5f7f503947a9fe8661b7c6aef8da101acca0aed758ca1580eeb2f26ae3bf2de06ce8827a91a694179991a993cdf814efbcc61ca5":120:"a93bd682b57e1d1bf4af97e93b8927":"7093f44703f2cbb3d12d9872b07a8cd44deb62dae48bc573b11a1ee1c9f3105223423fac3181c312a8a61757a432d92719f486c21e311b840aa63cf530710c873df27fecda0956075923f1ecc39bffb862706f48bde2de15612930fc8630d2036e9e4cfc1c69779171bd23d9e1d5de50a9e0a0de4bd82ed3efc45299980bb4cc":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"51d94d21482c00bb5bc7e7e03aa017ba58f5a23494b72c2a":"3a9c69c1ed2340bfde1495658dbf4f54731a19b3922a1d535df8d0b2582f5e803b5891e8ad1aa256c923956dcda2430d0c0696bce63295fb61183e040566e459338f908d23ae51f64020c1ef3d192428f23312b285fc4111d50d1add58f4a49008a22c90d3365230e9158cd56f9d84f079bdd673555d4dc76c74b02fa9920e7d":"fb21cd763e6f25540f8ad455deaccdf0":"019d1db5569eeff83306f65d653b01064854c1be8446cd2516336667c6557e7844fc349adea64a12dc19ac7e8e40b0520a48fac64571a93d669045607085ac9fa78fed99bbf644908d7763fe5f7f503947a9fe8661b7c6aef8da101acca0aed758ca1580eeb2f26ae3bf2de06ce8827a91a694179991a993cdf814efbcc61ca5":120:"a93bd682b57e1d1bf4af97e93b8927":"":"7093f44703f2cbb3d12d9872b07a8cd44deb62dae48bc573b11a1ee1c9f3105223423fac3181c312a8a61757a432d92719f486c21e311b840aa63cf530710c873df27fecda0956075923f1ecc39bffb862706f48bde2de15612930fc8630d2036e9e4cfc1c69779171bd23d9e1d5de50a9e0a0de4bd82ed3efc45299980bb4cc":0 AES-GCM NIST Validation (AES-192,128,1024,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e6756470937f5d9af76f2abe6df2d0bc15ff8e39b5154071":"afae92bd56c426c095d76633701aa9bea5ce05490482c6c64ac24468c3e1af6e6030a6bb6649745b011c6729bde985b9242e22105322fbb8853dcabbd00165d0b07d7b499e0238b6513bf6351eb40635a798f7e6e2d31125dda45ffe8964596fdbff55df22d4e9025bd4f39e7c9b90e74b3ee58d6901f113900ee47a4df5afd7":"4500193711a5d817a9f48deafda39772":"92fa22dba0eee6b1de1ddd24713b1be44c7105df90e6e7a54dcbf19025e560eb4986ee080cf613898a1a69d5ab460a3b8aa2723a95ac4a4af48224b011b55fb7582ae18f6746591eab2bd33d82a8dbbae3f7877e28afef9857a623530b31d8198b2df43f903d6e48ddae0848741f9eaae7b5504c67ad13791818f3c55c9b3d1e":120:"7d9f97c97c3424c79966f5b45af090":"62258d60f0138c0405df4b2ec1e308b374603a9eace45932fdc2999e9e2261de8b1099473d1fc741c46c334023aa5d9359f7ef966240aaf7e310d874b5956fd180fb1124cbeb91cf86020c78a1a0335f5f029bd34677dd2d5076482f3b3e85808f54998f4bac8b8fa968febceec3458fb882fc0530271f144fb3e2ab8c1a6289":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e6756470937f5d9af76f2abe6df2d0bc15ff8e39b5154071":"afae92bd56c426c095d76633701aa9bea5ce05490482c6c64ac24468c3e1af6e6030a6bb6649745b011c6729bde985b9242e22105322fbb8853dcabbd00165d0b07d7b499e0238b6513bf6351eb40635a798f7e6e2d31125dda45ffe8964596fdbff55df22d4e9025bd4f39e7c9b90e74b3ee58d6901f113900ee47a4df5afd7":"4500193711a5d817a9f48deafda39772":"92fa22dba0eee6b1de1ddd24713b1be44c7105df90e6e7a54dcbf19025e560eb4986ee080cf613898a1a69d5ab460a3b8aa2723a95ac4a4af48224b011b55fb7582ae18f6746591eab2bd33d82a8dbbae3f7877e28afef9857a623530b31d8198b2df43f903d6e48ddae0848741f9eaae7b5504c67ad13791818f3c55c9b3d1e":120:"7d9f97c97c3424c79966f5b45af090":"":"62258d60f0138c0405df4b2ec1e308b374603a9eace45932fdc2999e9e2261de8b1099473d1fc741c46c334023aa5d9359f7ef966240aaf7e310d874b5956fd180fb1124cbeb91cf86020c78a1a0335f5f029bd34677dd2d5076482f3b3e85808f54998f4bac8b8fa968febceec3458fb882fc0530271f144fb3e2ab8c1a6289":0 AES-GCM NIST Validation (AES-192,128,1024,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30db73d46b518669c45b81bc67b93bed3d0864f7e9e8e789":"750bc1d2f91d786bb1e621192a376f552538ba8c07d50d9e10b9345f31b3e5f9d8ad7c719c03d8548a3b184b741cd06c49d7fb6fe80258d60c01c2987c337c823211cee7c1cf82077266889bc7767475e0eeabb2ef6b5a1de2089aaef77565d40a1c2c470a880c911e77a186eacca173b25970574f05c0bdcd5428b39b52af7f":"5069e2d2f82b36de8c2eb171f301135d":"ef781dce556b84188adee2b6e1d64dac2751dd8592abc6c72af7b998dfae40cbe692a4cae0b4aa2c95910e270600550fca1e83640c64efb1eb0e0a90a6fc475ae1db863a64ce9cc272f00abac8a63d48dd9f1c0a5f4586224befed05be4afae5bd92249833d565cc6b65fd8955cb8a7d7bd9f4b6a229e3881212871a52c15d1c":112:"a5100c5e9a16aedf0e1bd8604335":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30db73d46b518669c45b81bc67b93bed3d0864f7e9e8e789":"750bc1d2f91d786bb1e621192a376f552538ba8c07d50d9e10b9345f31b3e5f9d8ad7c719c03d8548a3b184b741cd06c49d7fb6fe80258d60c01c2987c337c823211cee7c1cf82077266889bc7767475e0eeabb2ef6b5a1de2089aaef77565d40a1c2c470a880c911e77a186eacca173b25970574f05c0bdcd5428b39b52af7f":"5069e2d2f82b36de8c2eb171f301135d":"ef781dce556b84188adee2b6e1d64dac2751dd8592abc6c72af7b998dfae40cbe692a4cae0b4aa2c95910e270600550fca1e83640c64efb1eb0e0a90a6fc475ae1db863a64ce9cc272f00abac8a63d48dd9f1c0a5f4586224befed05be4afae5bd92249833d565cc6b65fd8955cb8a7d7bd9f4b6a229e3881212871a52c15d1c":112:"a5100c5e9a16aedf0e1bd8604335":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"209f0478f1a62cb54c551181cbd4d24b796e95f3a06b6cb9":"66db7cc97b4a8266c0a2228e8028e38d8986e79fcbcc3caff3050fdd2de87b7ff7a6895b988b0bdb7fcc4d6e2d538dcfaad43ce2f98b6d32500f5a6e6183d84cb19157a699cdde1266d6d75a251ee1a2eb97bfe6405d50be2b17a58ba6eafaee0a023a28d568fd1c914f06041a49c79b9df9efe63d56883cbbbeaba809273d2e":"7be1768f6ffb31599eb6def7d1daa41c":"9cb49357536ebe087e1475a5387907a9e51ad1550697f13c6cc04384ec8a67dea13376bdd5e26b815c84a78f921b506b9e2086de50f849185f05ba7c3041e49e42c0673df856da109a78b8e0ce918c25836f7e781e6b16168e4e5976d27ebc83f20b7bf4beadecb9b4f17a7a0d3a3db27fc65288a754b5031a2f5a1394801e6e":112:"4d2ac05bfd4b59b15a6f70ea7cd0":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"209f0478f1a62cb54c551181cbd4d24b796e95f3a06b6cb9":"66db7cc97b4a8266c0a2228e8028e38d8986e79fcbcc3caff3050fdd2de87b7ff7a6895b988b0bdb7fcc4d6e2d538dcfaad43ce2f98b6d32500f5a6e6183d84cb19157a699cdde1266d6d75a251ee1a2eb97bfe6405d50be2b17a58ba6eafaee0a023a28d568fd1c914f06041a49c79b9df9efe63d56883cbbbeaba809273d2e":"7be1768f6ffb31599eb6def7d1daa41c":"9cb49357536ebe087e1475a5387907a9e51ad1550697f13c6cc04384ec8a67dea13376bdd5e26b815c84a78f921b506b9e2086de50f849185f05ba7c3041e49e42c0673df856da109a78b8e0ce918c25836f7e781e6b16168e4e5976d27ebc83f20b7bf4beadecb9b4f17a7a0d3a3db27fc65288a754b5031a2f5a1394801e6e":112:"4d2ac05bfd4b59b15a6f70ea7cd0":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1bfa30b315e7b908263330140fa2d66ed57104784a43cc70":"8eeee9865e23fa51dbbf197fa41776b7edbdb9381a22c935299cd959a46190788ae82f4e645b0362df89bfc00241964784bc7ef70f6f97e81687d52e552a33af20ae34a3005e0a7b85d094368d707c3c4cd3ef31c0daf3ccaa1676609ed199327f4139d0c120977e6babceed28896d2cb3129630f3ee135572dc39433057e26a":"b7081a3010b524218390ba6dd460a1ec":"8c1f42b5931d69ae351fcde7d2b4136d4898a4fa8ba62d55cef721dadf19beaabf9d1900bdf2e58ee568b808684eecbf7aa3c890f65c54b967b94484be082193b2d8393007389abaa9debbb49d727a2ac16b4dab2c8f276840e9c65a47974d9b04f2e63adf38b6aad763f0d7cdb2c3d58691adde6e51e0a85093a4c4944f5bf2":112:"4da85b8ec861dd8be54787bb83f1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1bfa30b315e7b908263330140fa2d66ed57104784a43cc70":"8eeee9865e23fa51dbbf197fa41776b7edbdb9381a22c935299cd959a46190788ae82f4e645b0362df89bfc00241964784bc7ef70f6f97e81687d52e552a33af20ae34a3005e0a7b85d094368d707c3c4cd3ef31c0daf3ccaa1676609ed199327f4139d0c120977e6babceed28896d2cb3129630f3ee135572dc39433057e26a":"b7081a3010b524218390ba6dd460a1ec":"8c1f42b5931d69ae351fcde7d2b4136d4898a4fa8ba62d55cef721dadf19beaabf9d1900bdf2e58ee568b808684eecbf7aa3c890f65c54b967b94484be082193b2d8393007389abaa9debbb49d727a2ac16b4dab2c8f276840e9c65a47974d9b04f2e63adf38b6aad763f0d7cdb2c3d58691adde6e51e0a85093a4c4944f5bf2":112:"4da85b8ec861dd8be54787bb83f1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fc47156a693e59a1dea0618c41441fe669fc65dcfb7d0726":"3e4f0a586bad532a08c8863ebba01fd25014baa907e6032ee43d4a7dfc7c3171916dcdf9faee0531f27527872ae4e127b6b9aaee93f5e74d0ab23f3874aa0e291564bc97f17085dd7d5eb9a85d9f44574e5952929eda08863b64c85dd395c91b01fe5bef66e3fa8f9ee5bf62c25d80dc84fbe002ecfd218430b26f3549f734a1":"ea1935ed014883cc427983d7962d9992":"0d85b8513becfe8c91d0f6ffb65ec31f2cf406c51c0da88893c43d1327fd8ad1f4bab2d7b5e27438d643397034a72f8666bf641b6781bc90f764db387eae6720b5723d510194570ccd773e1b3bebfc333cc099d078583e8dac60d174d332925a24a45110c8d2abe8924ea677ac74db66ea789e2838efc96c78bceaa6236c0a67":104:"8781b045a509c4239b9f44624e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fc47156a693e59a1dea0618c41441fe669fc65dcfb7d0726":"3e4f0a586bad532a08c8863ebba01fd25014baa907e6032ee43d4a7dfc7c3171916dcdf9faee0531f27527872ae4e127b6b9aaee93f5e74d0ab23f3874aa0e291564bc97f17085dd7d5eb9a85d9f44574e5952929eda08863b64c85dd395c91b01fe5bef66e3fa8f9ee5bf62c25d80dc84fbe002ecfd218430b26f3549f734a1":"ea1935ed014883cc427983d7962d9992":"0d85b8513becfe8c91d0f6ffb65ec31f2cf406c51c0da88893c43d1327fd8ad1f4bab2d7b5e27438d643397034a72f8666bf641b6781bc90f764db387eae6720b5723d510194570ccd773e1b3bebfc333cc099d078583e8dac60d174d332925a24a45110c8d2abe8924ea677ac74db66ea789e2838efc96c78bceaa6236c0a67":104:"8781b045a509c4239b9f44624e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5fcd780a03ba80341081ef96b440c0e4348afde4d60c1d5":"6316f3beb32f6f3bf8f2ff6a2c160b432bafd3036d3eefa1e4ec204f24892e37dc4d75c7ce9a24b5c49fb4df901f35ef9d5955f7dc289c56cb74753f4d6b2982267d5269d12237e21202a65061849c65e90e6702dda03a35ace3a3a098d16b4bfbb85b7232404baee37776a9b51af6b3059a5f170f4ebe4ecf11061ca3c1f1f3":"ad20cce056e74ec5d0a76d6280998f15":"28f8fcf23b9c1ba40c19ffc1092632e35f234c1e8b82bcd5309d37bf849a2ce401413d1f242cf255ed597f9a93a1d6e50676997f95aa612e580d88234a86ddc404292746f0b2f5cf15abebcea6659f998ec6a1cb5a9914fee5aa1aa5d04b3c20914e45095e4141ce9c173653dd91c3ebe4ed4a9a28f3915d7b2edba34c2a58d8":104:"2ad4520ddc3b907414d934cc1d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5fcd780a03ba80341081ef96b440c0e4348afde4d60c1d5":"6316f3beb32f6f3bf8f2ff6a2c160b432bafd3036d3eefa1e4ec204f24892e37dc4d75c7ce9a24b5c49fb4df901f35ef9d5955f7dc289c56cb74753f4d6b2982267d5269d12237e21202a65061849c65e90e6702dda03a35ace3a3a098d16b4bfbb85b7232404baee37776a9b51af6b3059a5f170f4ebe4ecf11061ca3c1f1f3":"ad20cce056e74ec5d0a76d6280998f15":"28f8fcf23b9c1ba40c19ffc1092632e35f234c1e8b82bcd5309d37bf849a2ce401413d1f242cf255ed597f9a93a1d6e50676997f95aa612e580d88234a86ddc404292746f0b2f5cf15abebcea6659f998ec6a1cb5a9914fee5aa1aa5d04b3c20914e45095e4141ce9c173653dd91c3ebe4ed4a9a28f3915d7b2edba34c2a58d8":104:"2ad4520ddc3b907414d934cc1d":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4382507dddccf1385fc831da8924147563416d0656e168ec":"e5c5430b960aa35dc8540215c2772d66811270859e33dd4477904759e7e5eb2986a52a4ccc9f592e614147b5ea2ead6636a15c6426336b2995d9a31ab36d76578c3540bc6693842a4bc0491c7963ee9cda2317951cf93244bd30bcdfec69a4767004636fe7d1be7300c35e80627bab9236a075a803e9e1080b9159060c643a78":"a37687c9cd4bdc1ead4e6b8f78bee7f5":"fa9ae30509cbb6fe104c21480ae7b8ec9f12f1afb17320d77b77cdf32ce8c5a3f7f927e501118c7ccd6975b79225059cef530a4fcb0a9719f5e2d3bebe7bb6ec0855e495a31e5075eb50aa6c1227e48b03e3fdf780084ac4912eb3a5674cca9dd6ac037366b230ae631a8580d2d117942dee5d5ddbbb2233afeca53289cc4f68":104:"4221818d4be45306e205813789":"b5b36719bc4d13a5fbf37188ea814cdf3c97a430784330540325c899570e15482300bc82c5b8163074e0544c5132e3ce93bba68bd7a8d2db81d1431b424b697c1158c4d70625666d5ff99145ca34856815c905b5a0fd95806df56b9cd5b384bda3e394b409048eb1037144cc071539c02397e931da28a43cc354d584643afd4f":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4382507dddccf1385fc831da8924147563416d0656e168ec":"e5c5430b960aa35dc8540215c2772d66811270859e33dd4477904759e7e5eb2986a52a4ccc9f592e614147b5ea2ead6636a15c6426336b2995d9a31ab36d76578c3540bc6693842a4bc0491c7963ee9cda2317951cf93244bd30bcdfec69a4767004636fe7d1be7300c35e80627bab9236a075a803e9e1080b9159060c643a78":"a37687c9cd4bdc1ead4e6b8f78bee7f5":"fa9ae30509cbb6fe104c21480ae7b8ec9f12f1afb17320d77b77cdf32ce8c5a3f7f927e501118c7ccd6975b79225059cef530a4fcb0a9719f5e2d3bebe7bb6ec0855e495a31e5075eb50aa6c1227e48b03e3fdf780084ac4912eb3a5674cca9dd6ac037366b230ae631a8580d2d117942dee5d5ddbbb2233afeca53289cc4f68":104:"4221818d4be45306e205813789":"":"b5b36719bc4d13a5fbf37188ea814cdf3c97a430784330540325c899570e15482300bc82c5b8163074e0544c5132e3ce93bba68bd7a8d2db81d1431b424b697c1158c4d70625666d5ff99145ca34856815c905b5a0fd95806df56b9cd5b384bda3e394b409048eb1037144cc071539c02397e931da28a43cc354d584643afd4f":0 AES-GCM NIST Validation (AES-192,128,1024,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7a66db3450dac9a1e63d2639f34c5c6a3fbfb3c8e8230199":"6463a7eb2496379bc8a5635541525926a6f9fa718e338221952118ae4cf03a85f2074b4ebaf108b9c725809be1e6309c3a444b66f12286f6ea9d80c3413706b234b26372e8f00783819314a994c9e3ecf6abdd255cbfe01b3865e1390a35dcd2853a3d99ed992e82ec67ba245f088cb090adade74bdbc8a1bad0f06cbea766a6":"21f8341529b210ade7f2c6055e13007a":"1699bc8c198ab03e22d9bc4f3682aad335c6e35f3f616bb69769a9d5a202511797e770ae0d8d8528ef7b2bb25b4294d47427b43f0580fa71d93fdef667f4f4196f84e41c0b1978796d0de74a94420fb8571bff39137fa231c572b31be9ae72338288bef5f8c992121dc918538551f346e279a9047df14ec9fc0fd399cd3bd8d8":96:"4af02b81b26104d1d31e295a":"53fe6a34d280f2c96d1ae2b2e8baf6abd67cedf7d214312f75dd4a1bec28a641dda3e71aa398726b2b0b1f515e1f4259ee97acaf17f122db9ec7814c2de6a88d36c3ac106396ad03d337c2cd2d2b9b4b7170e23a5848ca7ea129838f967dfdfe83b45ff2a9be699bfb2346115465d59f074f09e24d8fcbd9ece0018c92776c43":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7a66db3450dac9a1e63d2639f34c5c6a3fbfb3c8e8230199":"6463a7eb2496379bc8a5635541525926a6f9fa718e338221952118ae4cf03a85f2074b4ebaf108b9c725809be1e6309c3a444b66f12286f6ea9d80c3413706b234b26372e8f00783819314a994c9e3ecf6abdd255cbfe01b3865e1390a35dcd2853a3d99ed992e82ec67ba245f088cb090adade74bdbc8a1bad0f06cbea766a6":"21f8341529b210ade7f2c6055e13007a":"1699bc8c198ab03e22d9bc4f3682aad335c6e35f3f616bb69769a9d5a202511797e770ae0d8d8528ef7b2bb25b4294d47427b43f0580fa71d93fdef667f4f4196f84e41c0b1978796d0de74a94420fb8571bff39137fa231c572b31be9ae72338288bef5f8c992121dc918538551f346e279a9047df14ec9fc0fd399cd3bd8d8":96:"4af02b81b26104d1d31e295a":"":"53fe6a34d280f2c96d1ae2b2e8baf6abd67cedf7d214312f75dd4a1bec28a641dda3e71aa398726b2b0b1f515e1f4259ee97acaf17f122db9ec7814c2de6a88d36c3ac106396ad03d337c2cd2d2b9b4b7170e23a5848ca7ea129838f967dfdfe83b45ff2a9be699bfb2346115465d59f074f09e24d8fcbd9ece0018c92776c43":0 AES-GCM NIST Validation (AES-192,128,1024,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1f5c818f24d201f9fb23fcca211b0545eee5c5c9b440810d":"9a7566817a06f792e96a6a2ba8e0a01f8837e2de06796e68b0782cc54ed0b04fc5e24a1ad37d5ffb035548b882d88150e89915b89f57cde2bf3c43ab9dae356927daef6bd61cc9edd5e1b7a4abea2f71313677f1b2fdf3d8d4a7e9814ea820fbc3e5c83947db961839a985a57ced7f5e4a1efffcfd17a2c806d4cdc1e79162da":"3a163067bdd90fce0406d1c198a88771":"a5e94e233d04fe0c4b6c4684b386902fe05096702237dfbe76f73befa69b6f30394cf9fe3358997942df65842748fb4f075a3dc06e147bd8d67fc4371113a4d75c70219257c650a6f38a136659e20a1cf3a119397835c304e0fb2a33aa3c3019175c86463043d5edc6992874f61e81cd0d26af8b62cf8c8626901d4f16d84236":96:"b124eea927e2a62a875494a1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1f5c818f24d201f9fb23fcca211b0545eee5c5c9b440810d":"9a7566817a06f792e96a6a2ba8e0a01f8837e2de06796e68b0782cc54ed0b04fc5e24a1ad37d5ffb035548b882d88150e89915b89f57cde2bf3c43ab9dae356927daef6bd61cc9edd5e1b7a4abea2f71313677f1b2fdf3d8d4a7e9814ea820fbc3e5c83947db961839a985a57ced7f5e4a1efffcfd17a2c806d4cdc1e79162da":"3a163067bdd90fce0406d1c198a88771":"a5e94e233d04fe0c4b6c4684b386902fe05096702237dfbe76f73befa69b6f30394cf9fe3358997942df65842748fb4f075a3dc06e147bd8d67fc4371113a4d75c70219257c650a6f38a136659e20a1cf3a119397835c304e0fb2a33aa3c3019175c86463043d5edc6992874f61e81cd0d26af8b62cf8c8626901d4f16d84236":96:"b124eea927e2a62a875494a1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a301f7edf83da63bcf37216a3a33d7613331c3210281dd7":"e09cc8543db7804870004706a26e94b457c125bd648b581a196f962f2ae8fa55d9bc66530ba5020e22d282080b4720dc9a2096a11c0fcc3d9a67cd1cf95cd7cd2417ba308c761e64be24347a14c9423447094a5c72a0043c288b35e753ba0aa748f208381249fb1c8d195a472192404b6c8172663ee4b4d4ecfa426e1fb003f2":"d73a546b0fa307633ac89506fa86138b":"f57fe548cf4a551a216ffb24a1dcf1b79c95f9abf06443fd58af042d287c2165db373c82a94172db517840f22e45e966e3ead91ce1ddad132bcb844e406e84b76a0b5b0ee23064b66a229f32a2d3b9c71103f020c4ba57fc0f0608b7114914cf2ada0c5a9bc4afbfa9ce5da320f34beb2211d569a142f53bfd262f6d149c4350":96:"f536a3b8c333b1aa520d6440":"124a327a8c22b7652886dac2c84b8997ca8a6f61c9ba9c094b5aea41eaa050a6df6cbf280259e5466071bcfa53b4ebc76c3cc4afc8c0385189a5382933aa57c89aab78dca84331e0fe8f0aab3a7857d3e13f08dcd90ec5f0684f82088ef8eb7fd67e75de43b67afc3a0beb458f5ebd61b2c779e6c539d795c667bb7dcc2b762e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a301f7edf83da63bcf37216a3a33d7613331c3210281dd7":"e09cc8543db7804870004706a26e94b457c125bd648b581a196f962f2ae8fa55d9bc66530ba5020e22d282080b4720dc9a2096a11c0fcc3d9a67cd1cf95cd7cd2417ba308c761e64be24347a14c9423447094a5c72a0043c288b35e753ba0aa748f208381249fb1c8d195a472192404b6c8172663ee4b4d4ecfa426e1fb003f2":"d73a546b0fa307633ac89506fa86138b":"f57fe548cf4a551a216ffb24a1dcf1b79c95f9abf06443fd58af042d287c2165db373c82a94172db517840f22e45e966e3ead91ce1ddad132bcb844e406e84b76a0b5b0ee23064b66a229f32a2d3b9c71103f020c4ba57fc0f0608b7114914cf2ada0c5a9bc4afbfa9ce5da320f34beb2211d569a142f53bfd262f6d149c4350":96:"f536a3b8c333b1aa520d6440":"":"124a327a8c22b7652886dac2c84b8997ca8a6f61c9ba9c094b5aea41eaa050a6df6cbf280259e5466071bcfa53b4ebc76c3cc4afc8c0385189a5382933aa57c89aab78dca84331e0fe8f0aab3a7857d3e13f08dcd90ec5f0684f82088ef8eb7fd67e75de43b67afc3a0beb458f5ebd61b2c779e6c539d795c667bb7dcc2b762e":0 AES-GCM NIST Validation (AES-192,128,1024,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fd40e8226fd13cb95ba50b7cdf0f07f7ab7037cf8705ca50":"75aa7df5c3c443d48ee998064b6fd112c20d2d90c98e00d025ef08d1ad3595385be99de47fa627549b827c48bc79eb1dcaf2f1be95a45f7e55755b952aee5ae0748e68bee1b014a628f3f7dc88e0ebac1d1d00e268355f5101838ce125c57003aebc02a1c9d6ae2cd6e2592f52c0be38cef21a680ae35c909cab99dce9837aef":"3406e70cbe16b047fedaa537eb892279":"390b18d22d5ecc0b5a524ae9afac6fd948ac72d1360775a88b385aa862cce8a27f3e4b420e539bec6e8958f8c1b5416c313fa0a16f921149a2bfeae29ad2348949b29a73970e5be925ec0c35218b82a020cf21bb68c6931f86b29e01b85500a73f3ee7eb78da60078f42550da83b2e301d151d69b273a050f89e57dfc4787cbf":64:"69e06c72ead69501":"6e8d661cd320b1b39f8494836fcf738b0ab82873d3903c9ee34d74f618aea36099926b54c1589225ec9a9d48ca53657f10d9289c31f199c37c48fb9cbe1cda1e790aaeedf73871f66a3761625cca3c4f642bc4f254868f6b903e80ceeeb015569ace23376567d3712ad16d1289dc504f15d9b2751b23e7722b9e6d8e0827859f":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fd40e8226fd13cb95ba50b7cdf0f07f7ab7037cf8705ca50":"75aa7df5c3c443d48ee998064b6fd112c20d2d90c98e00d025ef08d1ad3595385be99de47fa627549b827c48bc79eb1dcaf2f1be95a45f7e55755b952aee5ae0748e68bee1b014a628f3f7dc88e0ebac1d1d00e268355f5101838ce125c57003aebc02a1c9d6ae2cd6e2592f52c0be38cef21a680ae35c909cab99dce9837aef":"3406e70cbe16b047fedaa537eb892279":"390b18d22d5ecc0b5a524ae9afac6fd948ac72d1360775a88b385aa862cce8a27f3e4b420e539bec6e8958f8c1b5416c313fa0a16f921149a2bfeae29ad2348949b29a73970e5be925ec0c35218b82a020cf21bb68c6931f86b29e01b85500a73f3ee7eb78da60078f42550da83b2e301d151d69b273a050f89e57dfc4787cbf":64:"69e06c72ead69501":"":"6e8d661cd320b1b39f8494836fcf738b0ab82873d3903c9ee34d74f618aea36099926b54c1589225ec9a9d48ca53657f10d9289c31f199c37c48fb9cbe1cda1e790aaeedf73871f66a3761625cca3c4f642bc4f254868f6b903e80ceeeb015569ace23376567d3712ad16d1289dc504f15d9b2751b23e7722b9e6d8e0827859f":0 AES-GCM NIST Validation (AES-192,128,1024,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a85ab87563b809b01725764d64ba4cc6a143e2e0362f0c52":"ef43629721b50bd3656b7ae31b6e4b4ba1cf2c72ed0460ee7d9fb416631ddc597e5f9aebbcf4442b95cc46e28476a464dd87caf9c1c1d6c99d3e3e059dc23f8d2fe155ff5e59c50d640bc052c62adee3aa1295b38732e3458f379e98a8dbdfed04c22a5761792e87fa67ecbcbf3b90eb1bcd1d3f49e60132452f28afece83e90":"9f991ff16a3e3eb164a4f819c9f1821a":"df289511f78d8fa2505afc4c71ab1d7c31a8d15d1e5fcbb29d70f0e56f89c4d7b30f1b3b4745b5d2cc7af34fb4c95461372bf516ec192b400dc8fdb0ca9fe1f30f5320d0fadf20155cfcddcf09233c6f591c1c89917e38a003f56b94a1e2429d1f2b6297db790d7dce84d9fa13d2d86a0e4d100e154050b07178bee4cdf18126":64:"dc4c97fe8cc53350":"ff0e531c7344f0425d62d5fbedf4bc8d3d5cc80647e67b852c1a58ad1516d376d954cb8dda739f6a4df3cf1507e59696610bcb6b34340d6313028e00d7197845d392e73331aaf168b474a67364d8f9dab740509fabf92af75045f0afabc1b5829264d138820952bbc484d1100d058a4de32b4ece82746b2b4a85fb2993d4add8":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a85ab87563b809b01725764d64ba4cc6a143e2e0362f0c52":"ef43629721b50bd3656b7ae31b6e4b4ba1cf2c72ed0460ee7d9fb416631ddc597e5f9aebbcf4442b95cc46e28476a464dd87caf9c1c1d6c99d3e3e059dc23f8d2fe155ff5e59c50d640bc052c62adee3aa1295b38732e3458f379e98a8dbdfed04c22a5761792e87fa67ecbcbf3b90eb1bcd1d3f49e60132452f28afece83e90":"9f991ff16a3e3eb164a4f819c9f1821a":"df289511f78d8fa2505afc4c71ab1d7c31a8d15d1e5fcbb29d70f0e56f89c4d7b30f1b3b4745b5d2cc7af34fb4c95461372bf516ec192b400dc8fdb0ca9fe1f30f5320d0fadf20155cfcddcf09233c6f591c1c89917e38a003f56b94a1e2429d1f2b6297db790d7dce84d9fa13d2d86a0e4d100e154050b07178bee4cdf18126":64:"dc4c97fe8cc53350":"":"ff0e531c7344f0425d62d5fbedf4bc8d3d5cc80647e67b852c1a58ad1516d376d954cb8dda739f6a4df3cf1507e59696610bcb6b34340d6313028e00d7197845d392e73331aaf168b474a67364d8f9dab740509fabf92af75045f0afabc1b5829264d138820952bbc484d1100d058a4de32b4ece82746b2b4a85fb2993d4add8":0 AES-GCM NIST Validation (AES-192,128,1024,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f4f1e03abb927ffd0b081b9dce83a56a6dd419a6313ac34f":"0e70421499bc4bcb3851afa34cdf5be374722815abdd9bcee5f332dbe890bdc1c0210ab10667e5bb924bf3c1120e25a0c074da620076f143940989e222086d1b34a1200d09aea1f810ef6de7d8520c65eef9539fde5a6422606c588fce6264e5f91f934ede6397c4b307d2d7e07a518fce577a427fa92923cbba637ae495afad":"d1e29bb51a3c4e871d15bb0cd86257e2":"ae2911cdaaad1194c5d7868b6d8f30287105df132eb0cecca14b6e23ec7ac39cc01da1c567a0219cca7b902cc2e825e30f9524a473eb6e1d4d1beff5ab4f29103b2c7522a33dd33182fa955c4f09a75196b1072a6f0340fc55a802d29c7067f05219c21857ebff89ada11f648c1f28dfbfdaab56028f05509de17e2381457ebc":64:"44f760787f7bc3c0":"2199fa5051461b67581429ab19de2ccb50b8b02e12c0e1d81a8a14929f84e09d9715b7d198e77e632de4af1c08c5041276204a7ed76646385e288e96e1a4b0b0f2b1a9df7f0892beaea3cb58d9632720158f6daa4cbbfc0ebdc56ff6a5175768ff2abd24cb7669bc3fe40f8aba7869d2dd7dac86b6ebc4e4ce261edbec88db17":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f4f1e03abb927ffd0b081b9dce83a56a6dd419a6313ac34f":"0e70421499bc4bcb3851afa34cdf5be374722815abdd9bcee5f332dbe890bdc1c0210ab10667e5bb924bf3c1120e25a0c074da620076f143940989e222086d1b34a1200d09aea1f810ef6de7d8520c65eef9539fde5a6422606c588fce6264e5f91f934ede6397c4b307d2d7e07a518fce577a427fa92923cbba637ae495afad":"d1e29bb51a3c4e871d15bb0cd86257e2":"ae2911cdaaad1194c5d7868b6d8f30287105df132eb0cecca14b6e23ec7ac39cc01da1c567a0219cca7b902cc2e825e30f9524a473eb6e1d4d1beff5ab4f29103b2c7522a33dd33182fa955c4f09a75196b1072a6f0340fc55a802d29c7067f05219c21857ebff89ada11f648c1f28dfbfdaab56028f05509de17e2381457ebc":64:"44f760787f7bc3c0":"":"2199fa5051461b67581429ab19de2ccb50b8b02e12c0e1d81a8a14929f84e09d9715b7d198e77e632de4af1c08c5041276204a7ed76646385e288e96e1a4b0b0f2b1a9df7f0892beaea3cb58d9632720158f6daa4cbbfc0ebdc56ff6a5175768ff2abd24cb7669bc3fe40f8aba7869d2dd7dac86b6ebc4e4ce261edbec88db17":0 AES-GCM NIST Validation (AES-192,128,1024,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"33efe20433c6a1ad261a1fed494961749e5bf9d35809b59d":"cfbeb61be50def25f513346498f75984bfe797a8ad56be34f2461e2d673f6ce14e7479a59777267b75dadc6b9522599ebe5d7b079495a58ca187ec47796f6ee8c322278ad7451b038c938928adcff6105a8ea3780aedc45b6a3323d3ae6fbce5da4fb59ca5ec0a16a70494c3c4859672348532505e44f915e0b9b8a296ef5225":"dc94673b0c49c6d3b4611e278212c748":"919f7397a6d03836423b7cac53177fcfbe457d4aa4348646f646aae1bc5a15568cdb8c96fabef278ace248aca531110a4f4f9e8ab0c32525ad816ae3facf03175232dc84addcd6065f9cc1f513966b63fd27e91a09f1921b95d6bd8f08f1dbce073bcf827847f774514b478b9d7fb5426847dd4dee6f39b5768c1fb729b32d03":32:"c5098340":"c5e47d8c60b04df1974b68a14095d9bc8429a413d21960b15bae4fd7356bf7872e0da0a1a385ca2982d3aa3182e63ea4bb8ca01410cd4e71ddad34aa1f12c1387902b3d56634f89c619a2e6756648ab3bf90e9bc945afc9140eb935b633bae96bb067e9ee421697bcf80b14b1b88dbf13e010b472a7ca5411db36848b9c7a37f":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"33efe20433c6a1ad261a1fed494961749e5bf9d35809b59d":"cfbeb61be50def25f513346498f75984bfe797a8ad56be34f2461e2d673f6ce14e7479a59777267b75dadc6b9522599ebe5d7b079495a58ca187ec47796f6ee8c322278ad7451b038c938928adcff6105a8ea3780aedc45b6a3323d3ae6fbce5da4fb59ca5ec0a16a70494c3c4859672348532505e44f915e0b9b8a296ef5225":"dc94673b0c49c6d3b4611e278212c748":"919f7397a6d03836423b7cac53177fcfbe457d4aa4348646f646aae1bc5a15568cdb8c96fabef278ace248aca531110a4f4f9e8ab0c32525ad816ae3facf03175232dc84addcd6065f9cc1f513966b63fd27e91a09f1921b95d6bd8f08f1dbce073bcf827847f774514b478b9d7fb5426847dd4dee6f39b5768c1fb729b32d03":32:"c5098340":"":"c5e47d8c60b04df1974b68a14095d9bc8429a413d21960b15bae4fd7356bf7872e0da0a1a385ca2982d3aa3182e63ea4bb8ca01410cd4e71ddad34aa1f12c1387902b3d56634f89c619a2e6756648ab3bf90e9bc945afc9140eb935b633bae96bb067e9ee421697bcf80b14b1b88dbf13e010b472a7ca5411db36848b9c7a37f":0 AES-GCM NIST Validation (AES-192,128,1024,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3ed5dadefa0f6d14fedd1a3cdbab109f6660896a952ac5ab":"aef617f69724e020309ec39d9587520efda68a8e303686c3a41ef700cba05b7c6e43e95aadb1a566f61650c87845835e789eb2366941e3bfef6d9846af0e0dbc43249117ad6f299bbc40669ac383cdf79289ada6ccd8ccfe329a0dc6a38eea1a99550457102d10f641cda50c21f533b1f981663f74a0a7c657c04d9fc6696ff4":"553a14f1e1619f9d7bd07cd823961f25":"eb8ea81d3e328a1113942cd5efd0f2b5e7f088791c8fc05690a34584101c4d493628ee7d0099a2865ac194b9124c3fb924de0c4428d0a1c26ea3ad9a0bc89187a16673e3b6f7e370dfb2dc26e8a56a9cf91f9c2088c020a766efe0d0c91689743a603f2cd1e300a6a84828b3b515a4b9a06e6bb20457bf124cd6ce4ac8b83d51":32:"dc413c4c":"bc1f34991a48aabb0fea513f790f0d223e9feac4c99fa1e8427f01ab8b4b2827cfaf239342de36051a846af0306a3f82e7aed98dd0416fb078bc7f3b617b00ceb2cea4ddafc22dd022efa8303e9804510e0e888065d8427345156d823f796f74130c06db9f9934435552b4fefd051953e20ecba3a4514ac121d7d2097d597439":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3ed5dadefa0f6d14fedd1a3cdbab109f6660896a952ac5ab":"aef617f69724e020309ec39d9587520efda68a8e303686c3a41ef700cba05b7c6e43e95aadb1a566f61650c87845835e789eb2366941e3bfef6d9846af0e0dbc43249117ad6f299bbc40669ac383cdf79289ada6ccd8ccfe329a0dc6a38eea1a99550457102d10f641cda50c21f533b1f981663f74a0a7c657c04d9fc6696ff4":"553a14f1e1619f9d7bd07cd823961f25":"eb8ea81d3e328a1113942cd5efd0f2b5e7f088791c8fc05690a34584101c4d493628ee7d0099a2865ac194b9124c3fb924de0c4428d0a1c26ea3ad9a0bc89187a16673e3b6f7e370dfb2dc26e8a56a9cf91f9c2088c020a766efe0d0c91689743a603f2cd1e300a6a84828b3b515a4b9a06e6bb20457bf124cd6ce4ac8b83d51":32:"dc413c4c":"":"bc1f34991a48aabb0fea513f790f0d223e9feac4c99fa1e8427f01ab8b4b2827cfaf239342de36051a846af0306a3f82e7aed98dd0416fb078bc7f3b617b00ceb2cea4ddafc22dd022efa8303e9804510e0e888065d8427345156d823f796f74130c06db9f9934435552b4fefd051953e20ecba3a4514ac121d7d2097d597439":0 AES-GCM NIST Validation (AES-192,128,1024,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6d97e8bff3923a778504fb917dbc1428a1328587047697d9":"dc1a81efd51e967767f5bdd7e2e425732c1d28451f2bf5bdf3f5a6492279330594d360dd8a193e5dbde1be49bf143a35c38bcd059f762ada65c5119e097f0976891347f4d829b087bd72daa3494b344cbd3370c4459ca243bd57aeda4cb86cdd0bf274f07830cdbf5e5be4eb9b742ddffef8aa35626d2b9ea0a29d3c3d058b28":"0c28dc4cd53725091c2fb68a476c2e40":"f3932f5e82d75a1e3eba1591c17769e1a45819ccf057c31e76fa810b93678766d25905e859775c244e96bcafbc75c4a2d95e7d02868ccb2f65e49276f0b645ac8cf6e3758402304a3c25ce2de0a49f401b1acadaff8b57589b45cc79130ddc8387f41cc383e33ef38eec019152051c756198d6f782ccf56297b9fe944269a65a":32:"e6d6df7a":"39327836e9d8cfb59397adcf045a85644c52c3563290795811f26350c8bce8f55ca779cbcd15479efd8144b8a39ef611153955c70bf3a7da9d4d944c2407a0d735784fcb68de1083eebf6940ebc9cf92f9f139c01404b503ff64e61126a94e881351473507884357040fd32714b872c254349071069644e2bd642905521b944e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6d97e8bff3923a778504fb917dbc1428a1328587047697d9":"dc1a81efd51e967767f5bdd7e2e425732c1d28451f2bf5bdf3f5a6492279330594d360dd8a193e5dbde1be49bf143a35c38bcd059f762ada65c5119e097f0976891347f4d829b087bd72daa3494b344cbd3370c4459ca243bd57aeda4cb86cdd0bf274f07830cdbf5e5be4eb9b742ddffef8aa35626d2b9ea0a29d3c3d058b28":"0c28dc4cd53725091c2fb68a476c2e40":"f3932f5e82d75a1e3eba1591c17769e1a45819ccf057c31e76fa810b93678766d25905e859775c244e96bcafbc75c4a2d95e7d02868ccb2f65e49276f0b645ac8cf6e3758402304a3c25ce2de0a49f401b1acadaff8b57589b45cc79130ddc8387f41cc383e33ef38eec019152051c756198d6f782ccf56297b9fe944269a65a":32:"e6d6df7a":"":"39327836e9d8cfb59397adcf045a85644c52c3563290795811f26350c8bce8f55ca779cbcd15479efd8144b8a39ef611153955c70bf3a7da9d4d944c2407a0d735784fcb68de1083eebf6940ebc9cf92f9f139c01404b503ff64e61126a94e881351473507884357040fd32714b872c254349071069644e2bd642905521b944e":0 AES-GCM NIST Validation (AES-192,128,0,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c78e29971e90a01bb65973f81260b9344fa835751f5f142":"":"f1a23ce6e2bc9088a62c887abecd30ae":"":128:"d4d5c22f993c8c610145fcbe4e021687":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c78e29971e90a01bb65973f81260b9344fa835751f5f142":"":"f1a23ce6e2bc9088a62c887abecd30ae":"":128:"d4d5c22f993c8c610145fcbe4e021687":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8c582d5b6a40ef0e4048ec20f0263572d7cc82704e380851":"":"ef221a1c66fda17906190b7c99ab60b8":"":128:"6327dcb46ffb3d0fd8fbf3d2848a8f01":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8c582d5b6a40ef0e4048ec20f0263572d7cc82704e380851":"":"ef221a1c66fda17906190b7c99ab60b8":"":128:"6327dcb46ffb3d0fd8fbf3d2848a8f01":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3a58abadd29e946e23ca9eb09af059913d5394971bda6a4f":"":"7c29b3196d44df78fa514a1967fcd3a6":"":128:"fc123944bbea6c5075a5f987aed9cf99":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3a58abadd29e946e23ca9eb09af059913d5394971bda6a4f":"":"7c29b3196d44df78fa514a1967fcd3a6":"":128:"fc123944bbea6c5075a5f987aed9cf99":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"04bdde4c35c385783715d8a883640851b860ce0e8436ec19":"":"783f9a3c36b6d0c9fd57c15105316535":"":120:"23e21a803cac5237777014686564f2":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"04bdde4c35c385783715d8a883640851b860ce0e8436ec19":"":"783f9a3c36b6d0c9fd57c15105316535":"":120:"23e21a803cac5237777014686564f2":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4ba5fba0c22fbe10c2d1690c5d99938522de9c5186721bac":"":"2acc2073089a34d4651eee39a262e8ae":"":120:"7ac742c859a02a543b50464c66dcf5":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4ba5fba0c22fbe10c2d1690c5d99938522de9c5186721bac":"":"2acc2073089a34d4651eee39a262e8ae":"":120:"7ac742c859a02a543b50464c66dcf5":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f12890b0a8819faa5a8e0e487f7f064af42fa6d5519d009f":"":"c937615675738f4b3227c799833d1e61":"":120:"88300bd65b12dcb341f1f6d8a15584":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f12890b0a8819faa5a8e0e487f7f064af42fa6d5519d009f":"":"c937615675738f4b3227c799833d1e61":"":120:"88300bd65b12dcb341f1f6d8a15584":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"51878f3630298a81297f4a21514fea637faa3815d4f26fae":"":"1f939226feab012dabfc2193637d15b1":"":112:"eed5fcb7607c038b354746d91c5b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"51878f3630298a81297f4a21514fea637faa3815d4f26fae":"":"1f939226feab012dabfc2193637d15b1":"":112:"eed5fcb7607c038b354746d91c5b":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ae596e74840a600556a06f97b13b89e38f67c152f1a1b930":"":"e2076e1050070d468659885ea77e88d0":"":112:"b4586bdbd4b6b899648f2333eee0":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ae596e74840a600556a06f97b13b89e38f67c152f1a1b930":"":"e2076e1050070d468659885ea77e88d0":"":112:"b4586bdbd4b6b899648f2333eee0":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fd33b7a0efae34339ca987b5eb8075385fd1276e63cc8530":"":"2d07bb8616fc0bbb71755a1bd256e7fb":"":112:"6b60d645220cfde42d88296ac193":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fd33b7a0efae34339ca987b5eb8075385fd1276e63cc8530":"":"2d07bb8616fc0bbb71755a1bd256e7fb":"":112:"6b60d645220cfde42d88296ac193":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5685b12a6617d554c36b62af5b8ff2239cb3ffb1d2c40e14":"":"6c31194df99d08881fa5b1dd33b45a92":"":104:"69431593c376c9f8052bf10747":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5685b12a6617d554c36b62af5b8ff2239cb3ffb1d2c40e14":"":"6c31194df99d08881fa5b1dd33b45a92":"":104:"69431593c376c9f8052bf10747":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"036ae037410dae9f0741608516d03b855c9c1851df8c54a4":"":"73599275f8237f14c4a52b283c07275d":"":104:"6f7249d25c9f273434c4720275":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"036ae037410dae9f0741608516d03b855c9c1851df8c54a4":"":"73599275f8237f14c4a52b283c07275d":"":104:"6f7249d25c9f273434c4720275":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ac144f39ebd6124bad85c9c7fb4f75bff389ece2e8085d83":"":"d0871bfc3693245be478e6a257c79efb":"":104:"5a99d59631d0e12f58b7b95ccd":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ac144f39ebd6124bad85c9c7fb4f75bff389ece2e8085d83":"":"d0871bfc3693245be478e6a257c79efb":"":104:"5a99d59631d0e12f58b7b95ccd":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a8a541ff11a1b8548e832d9e015edeccc94b87dadc156065":"":"c72bb300b624c27cded863eba56e7587":"":96:"ea2528e7439be2ed0a0d6b2a":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a8a541ff11a1b8548e832d9e015edeccc94b87dadc156065":"":"c72bb300b624c27cded863eba56e7587":"":96:"ea2528e7439be2ed0a0d6b2a":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30dd8f400335e9c688e13cc0b1007bd21736a6d395d152e2":"":"28899601fa95f532b030f11bbeb87011":"":96:"35625638589bb7f6ccdb0222":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30dd8f400335e9c688e13cc0b1007bd21736a6d395d152e2":"":"28899601fa95f532b030f11bbeb87011":"":96:"35625638589bb7f6ccdb0222":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cb8f672b04d706d7d4125d6830fff5d2ec069569bea050ce":"":"375d4134e8649367f4db9bdb07aa8594":"":96:"70610bf329683e15ecf8c79f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cb8f672b04d706d7d4125d6830fff5d2ec069569bea050ce":"":"375d4134e8649367f4db9bdb07aa8594":"":96:"70610bf329683e15ecf8c79f":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"bf71e5b1cd6eb363ecd89a4958675a1166c10749e1ff1f44":"":"9f502fb5ac90ff5f5616dd1fa837387d":"":64:"a4b5138122e1209d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"bf71e5b1cd6eb363ecd89a4958675a1166c10749e1ff1f44":"":"9f502fb5ac90ff5f5616dd1fa837387d":"":64:"a4b5138122e1209d":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5b9d1dfb2303b66848e363793bdca0e5ada8599cb2c09e24":"":"2ee96384dd29f8a4c4a6102549a026ab":"":64:"3b33a10189338c3b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5b9d1dfb2303b66848e363793bdca0e5ada8599cb2c09e24":"":"2ee96384dd29f8a4c4a6102549a026ab":"":64:"3b33a10189338c3b":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a35ae271f70ebacb28173b37b921f5abcad1712a1cf5d5db":"":"8d97f354564d8185b57f7727626850a0":"":64:"813d2f98a760130c":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a35ae271f70ebacb28173b37b921f5abcad1712a1cf5d5db":"":"8d97f354564d8185b57f7727626850a0":"":64:"813d2f98a760130c":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bdd0cb826d5d28c2ab9777d5a0c1558e7c8227c53ed4c4f":"":"daf13501a47ee73c0197d8b774eec399":"":32:"a6d108c0":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bdd0cb826d5d28c2ab9777d5a0c1558e7c8227c53ed4c4f":"":"daf13501a47ee73c0197d8b774eec399":"":32:"a6d108c0":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"81b4d5ee4e1cbee1d8966fb3946409e6e64319a4b83231f5":"":"bc2f9320d6b62eea29ebc9cf7fc9f04a":"":32:"a47cdadd":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"81b4d5ee4e1cbee1d8966fb3946409e6e64319a4b83231f5":"":"bc2f9320d6b62eea29ebc9cf7fc9f04a":"":32:"a47cdadd":"":"":0 AES-GCM NIST Validation (AES-192,128,0,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5813627d26d568dfe5a0f8184cf561fe455eb98b98841fe0":"":"817199254a912880405c9729d75ed391":"":32:"d81d9b41":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5813627d26d568dfe5a0f8184cf561fe455eb98b98841fe0":"":"817199254a912880405c9729d75ed391":"":32:"d81d9b41":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"94f160e2325da2330fbe4e15910d33c2014f01ace58e5b24":"":"80a1b99750980bf2be84a17032fc2721":"066fdd980cf043a732403ee5f65c82ca81e3fc858ad3cfa343014a8426fd3806770f127e2041efb42e31506ce83390ac5d76de2fe1806df24ce6e4bb894972a107ef99e51e4acfb0e325ab053f9824514b5941ab1ec598fbb57a5d18ed34d72992a19215d914e34ad1a22326e493d1ff2da7bc271c96ad3ab66d0c32bd711293":128:"dd153cfd7aa946280660c445f586fa28":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"94f160e2325da2330fbe4e15910d33c2014f01ace58e5b24":"":"80a1b99750980bf2be84a17032fc2721":"066fdd980cf043a732403ee5f65c82ca81e3fc858ad3cfa343014a8426fd3806770f127e2041efb42e31506ce83390ac5d76de2fe1806df24ce6e4bb894972a107ef99e51e4acfb0e325ab053f9824514b5941ab1ec598fbb57a5d18ed34d72992a19215d914e34ad1a22326e493d1ff2da7bc271c96ad3ab66d0c32bd711293":128:"dd153cfd7aa946280660c445f586fa28":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4785846f7c0524e78f3eb137fd433e1808af64549af69183":"":"5334476a5fa3fa50dcc4b12f8ac00b51":"e70f82d1e3361ac5a5c9a087e47984d5533ba296f9b7e4a192a4ab28a833cdbbd5cece3415cf6fbb2f8055560b5c31c98d83d139954e1c03a464739f1eb5ad982c4371cf20b8984bbd97d5f40b336f5e96df3d272b95f7547be15c3bc05b3caac7d08c5eb5de8bdd246e74f6caa6bff76ea0417730ce72b911867f88fdcf73a0":128:"c59231ddaae98e0e8db6b3fe8f4d3427":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4785846f7c0524e78f3eb137fd433e1808af64549af69183":"":"5334476a5fa3fa50dcc4b12f8ac00b51":"e70f82d1e3361ac5a5c9a087e47984d5533ba296f9b7e4a192a4ab28a833cdbbd5cece3415cf6fbb2f8055560b5c31c98d83d139954e1c03a464739f1eb5ad982c4371cf20b8984bbd97d5f40b336f5e96df3d272b95f7547be15c3bc05b3caac7d08c5eb5de8bdd246e74f6caa6bff76ea0417730ce72b911867f88fdcf73a0":128:"c59231ddaae98e0e8db6b3fe8f4d3427":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"49b085fe1a8e1ae769ed09fc585d29eb24d589689992e6c5":"":"899878b0684fb865d30190821817b88c":"f789eafe3d02826b619ca4fbca7bb1919e5c6f7c33824a2f7f815dc50e329979705f7ef61e9adf7899d34f1b8840384ff62ef6d29eea38c45d12be9249aca69a02222cd744d81958c6816304ff0d81d6714a2023b3dd9d940db5c50afd89c52774d28d6afde2b6c68425b6acbe34682531a2e57e2b9a7729b3e8d96a729b15cc":128:"2c84bf7a8947ab93b10ae408243b4993":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"49b085fe1a8e1ae769ed09fc585d29eb24d589689992e6c5":"":"899878b0684fb865d30190821817b88c":"f789eafe3d02826b619ca4fbca7bb1919e5c6f7c33824a2f7f815dc50e329979705f7ef61e9adf7899d34f1b8840384ff62ef6d29eea38c45d12be9249aca69a02222cd744d81958c6816304ff0d81d6714a2023b3dd9d940db5c50afd89c52774d28d6afde2b6c68425b6acbe34682531a2e57e2b9a7729b3e8d96a729b15cc":128:"2c84bf7a8947ab93b10ae408243b4993":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"75847588760ecb6ca548747b743914c89fea367a5ccb81b6":"":"7d8a9fd254e2061c01e39eb574951924":"b03c57dfd49152401a225357f1d6e533f3a423e5cfce07b8ae7ca9daf68645e5bd67b3ca2421eac447530b27c6dc6bd9c7f1b22441b8cc8c4ac26cec2c9c0d665a35b66d779a3772d714f802d6b6272984808d0740344b6abdb63e626ef4e1ab0469da521c7908b2c95a0fd07437c0e9d4d2451ae189ad61ff19f4efb405127c":120:"e8aac14b53cdbc2028d330fc8d92a7":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"75847588760ecb6ca548747b743914c89fea367a5ccb81b6":"":"7d8a9fd254e2061c01e39eb574951924":"b03c57dfd49152401a225357f1d6e533f3a423e5cfce07b8ae7ca9daf68645e5bd67b3ca2421eac447530b27c6dc6bd9c7f1b22441b8cc8c4ac26cec2c9c0d665a35b66d779a3772d714f802d6b6272984808d0740344b6abdb63e626ef4e1ab0469da521c7908b2c95a0fd07437c0e9d4d2451ae189ad61ff19f4efb405127c":120:"e8aac14b53cdbc2028d330fc8d92a7":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e3a18a96d2e45d2f60780dc39cee7160e28cb810bf09858c":"":"26a4d659665ded39b7a1583de756d0ad":"83f8d9c58169b4c68032321197077ff5c8ee4ebb732b040748e1b55dcf53375ae86fb9646a672b5c5bc805a92c475cbb6d0ed689a58abdf2230250a7d3fbd8cfab07835fa85e738a7f74bc3e93616d844b1ec61b79f23dfea62e1815f295d43f61d7b5956103b31ca88afb0b3d37eb42cf77232dbf2258065232971c397dcbcb":120:"dc034564d4be7de243ff059b5f9160":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e3a18a96d2e45d2f60780dc39cee7160e28cb810bf09858c":"":"26a4d659665ded39b7a1583de756d0ad":"83f8d9c58169b4c68032321197077ff5c8ee4ebb732b040748e1b55dcf53375ae86fb9646a672b5c5bc805a92c475cbb6d0ed689a58abdf2230250a7d3fbd8cfab07835fa85e738a7f74bc3e93616d844b1ec61b79f23dfea62e1815f295d43f61d7b5956103b31ca88afb0b3d37eb42cf77232dbf2258065232971c397dcbcb":120:"dc034564d4be7de243ff059b5f9160":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7be3909170ea7a2ff76f9f28241d8cc48ddeafa8517c6f8c":"":"8dee7e29350c60c5bcfec89da6617d2e":"f6e9e7a7f9716760eb43060d5c80236a0f118b0f750ebd5df01fd2dba95c556ecd2e54a3f337767321abf569c8137a8e48c5b44037ba62951e9f9f709e6e4540a36d769f3945d01a20a2ed1891c415a16d95cab7ddf9bcebf18842c830067509a2a5d49a9684324c433d53824d2f8fd326b149af17f40e5bf5e49185738fba60":120:"942b52277e9dc0a30d737d00f5e597":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7be3909170ea7a2ff76f9f28241d8cc48ddeafa8517c6f8c":"":"8dee7e29350c60c5bcfec89da6617d2e":"f6e9e7a7f9716760eb43060d5c80236a0f118b0f750ebd5df01fd2dba95c556ecd2e54a3f337767321abf569c8137a8e48c5b44037ba62951e9f9f709e6e4540a36d769f3945d01a20a2ed1891c415a16d95cab7ddf9bcebf18842c830067509a2a5d49a9684324c433d53824d2f8fd326b149af17f40e5bf5e49185738fba60":120:"942b52277e9dc0a30d737d00f5e597":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1fe413bafc4753e1511b580c830449bee56e0e5b9acb852c":"":"e30829f64f3eda13bfb2ac572aceb3de":"6c772d08b4d7507e35804572fa697c646c77301954cc5c160941e49e230697ed8c23338b9f30c3ead69b1c1a2329ff025dcd3c0d0a9cc83fee4979448aa71ddb9d569bedc8c497a2a4ac3b60d087d7872f0a110bf90493ae7da03b0953734223156cd2d6c562e4a978a6dd5cdb229dd58dd4d0f50ac015f2f5e89dac4aa29a19":112:"87737873b82586bb29b406946cae":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1fe413bafc4753e1511b580c830449bee56e0e5b9acb852c":"":"e30829f64f3eda13bfb2ac572aceb3de":"6c772d08b4d7507e35804572fa697c646c77301954cc5c160941e49e230697ed8c23338b9f30c3ead69b1c1a2329ff025dcd3c0d0a9cc83fee4979448aa71ddb9d569bedc8c497a2a4ac3b60d087d7872f0a110bf90493ae7da03b0953734223156cd2d6c562e4a978a6dd5cdb229dd58dd4d0f50ac015f2f5e89dac4aa29a19":112:"87737873b82586bb29b406946cae":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b4bc4378d423931f9b320bb57df584c641406c1daa7448ad":"":"eca70e10c0358838a3f4a45c4b016ccd":"68d1c045c1604e3c3dd4f7c7543240aca8dbc5266dc18c5a8071e8b09e3700b7cf819044b2722d8db92021f42a0afb295d7b16ecf4e4704a50a527a2e72d7f53617c358e3b7be3d7fecda612ce6842fcfaa68f2d1b8a59d8b8391779f2fab99f820862c94029f444abe62367c5de0a4becc359660e4a5366f7d482bdc362b866":112:"06f95ca69c222a8985887925b15e":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b4bc4378d423931f9b320bb57df584c641406c1daa7448ad":"":"eca70e10c0358838a3f4a45c4b016ccd":"68d1c045c1604e3c3dd4f7c7543240aca8dbc5266dc18c5a8071e8b09e3700b7cf819044b2722d8db92021f42a0afb295d7b16ecf4e4704a50a527a2e72d7f53617c358e3b7be3d7fecda612ce6842fcfaa68f2d1b8a59d8b8391779f2fab99f820862c94029f444abe62367c5de0a4becc359660e4a5366f7d482bdc362b866":112:"06f95ca69c222a8985887925b15e":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cd4414ffd24e830e2dc49727efa592e430a6a75391cf111":"":"a08e32ad7d63f975de314ad2c0fa13fc":"20a271f1f4c6bea8f1584ab39a7179ec448650e2ff67a7338d1bc9fab7f73b2ce5222cd07ded947d135d9d0670dc368f0a4b50ece85cbf641877f9fe0ac6a7e6afb32fdb1b3cd35360bb80cfffc34cfb94dbcbee9ca5be98a0ca846394a135860fba57c6f0125dcb9fb8b61be681ada31a997638ee172525c03dd13171534a91":112:"c68842cafc50070799f7c8acd62a":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cd4414ffd24e830e2dc49727efa592e430a6a75391cf111":"":"a08e32ad7d63f975de314ad2c0fa13fc":"20a271f1f4c6bea8f1584ab39a7179ec448650e2ff67a7338d1bc9fab7f73b2ce5222cd07ded947d135d9d0670dc368f0a4b50ece85cbf641877f9fe0ac6a7e6afb32fdb1b3cd35360bb80cfffc34cfb94dbcbee9ca5be98a0ca846394a135860fba57c6f0125dcb9fb8b61be681ada31a997638ee172525c03dd13171534a91":112:"c68842cafc50070799f7c8acd62a":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9e0ef9ed5e6f00a721a9893e1f0d9079c5aa667a4cdd2a52":"":"5f015fd556e87ff0d0df586fb452306d":"b82986135e49e03f6f8f3ce4048ded2e63ee0c31ddc84929e022ee8561159179b3bb4403ebdafdf6beae51ac5bf4abed4dbc251433417ece3228b260eca5134e5390cba49a0b6fcbbbabb085378374e4e671d9ba265298e9864bfce256884247c36f9bddceb79b6a3e700cb3dd40088ba7bb6ab6aa11b6be261a7e5348f4a7d1":104:"ec9a79a88a164e1a6253d8312e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9e0ef9ed5e6f00a721a9893e1f0d9079c5aa667a4cdd2a52":"":"5f015fd556e87ff0d0df586fb452306d":"b82986135e49e03f6f8f3ce4048ded2e63ee0c31ddc84929e022ee8561159179b3bb4403ebdafdf6beae51ac5bf4abed4dbc251433417ece3228b260eca5134e5390cba49a0b6fcbbbabb085378374e4e671d9ba265298e9864bfce256884247c36f9bddceb79b6a3e700cb3dd40088ba7bb6ab6aa11b6be261a7e5348f4a7d1":104:"ec9a79a88a164e1a6253d8312e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bc8f15d98e089d60d4db00808700053f78b33c31652c3e4":"":"5cc0ff9bb7d5b9b2aa06f6ecf669d5bb":"24ac95a6ed2f78853f9ab20f53de47e7f662f72aea454141e2131aace7ed2daeb395bbccdbf004e23ce04ad85909f30151b6526c1ce7934726f99997bbab27055b379e5e43b80ad546e2d1655d1adad4cbe51282643bb4df086deb1b48c1bd3ac3b53c4a406be2687174028ecf7e7976e5c7a11c9a3827813ade32baef9f15ec":104:"9779b7c3ece6c23d5813e243ec":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bc8f15d98e089d60d4db00808700053f78b33c31652c3e4":"":"5cc0ff9bb7d5b9b2aa06f6ecf669d5bb":"24ac95a6ed2f78853f9ab20f53de47e7f662f72aea454141e2131aace7ed2daeb395bbccdbf004e23ce04ad85909f30151b6526c1ce7934726f99997bbab27055b379e5e43b80ad546e2d1655d1adad4cbe51282643bb4df086deb1b48c1bd3ac3b53c4a406be2687174028ecf7e7976e5c7a11c9a3827813ade32baef9f15ec":104:"9779b7c3ece6c23d5813e243ec":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"19afc43a4481f796d77561f80b5b2e1514c96c5d1d86e64c":"":"d4c06595fefd4a81bbbd4b40c2e1989d":"98fcca51352998d0126b5539e3fb9a238ac31c05954fc206d381909aee70983b6ab99d3f3efe8530a1c3cfe3b62756321b1d0771a5940055eba1e71fa64f29291aa5e5b0af0fcc8e6f5a02688d9e93417225eded791a35217822ffb346d3fa2809b65abe729448316be30cf661137d3c0e49846cb0df598d90eda545afb64a5e":104:"ca82448429106009094c21d70b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"19afc43a4481f796d77561f80b5b2e1514c96c5d1d86e64c":"":"d4c06595fefd4a81bbbd4b40c2e1989d":"98fcca51352998d0126b5539e3fb9a238ac31c05954fc206d381909aee70983b6ab99d3f3efe8530a1c3cfe3b62756321b1d0771a5940055eba1e71fa64f29291aa5e5b0af0fcc8e6f5a02688d9e93417225eded791a35217822ffb346d3fa2809b65abe729448316be30cf661137d3c0e49846cb0df598d90eda545afb64a5e":104:"ca82448429106009094c21d70b":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b4fc31dcfef6203fdb296cc928c13b7df56bfe6f32583057":"":"6308a78dc8f3c90442dc52196649c38e":"2567d80c253b080c0158102558551445d8ce4d5ddee2014a2be5cbad62e1717a0fd4d2059447c3151192951eb11a4a7b19a952f6ba261c87f10f4c9032028de3cc5a2a573a4e993a690fc8954daa3ec92743e7343e75b646c4fa9cbc3fceb4f5d59bb439c23754c4d9666fbc16c90c0cac91679b6ad1bfe5dcf6bd1a8a67c6b5":96:"9d1603799e2485a03e7b05a0":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b4fc31dcfef6203fdb296cc928c13b7df56bfe6f32583057":"":"6308a78dc8f3c90442dc52196649c38e":"2567d80c253b080c0158102558551445d8ce4d5ddee2014a2be5cbad62e1717a0fd4d2059447c3151192951eb11a4a7b19a952f6ba261c87f10f4c9032028de3cc5a2a573a4e993a690fc8954daa3ec92743e7343e75b646c4fa9cbc3fceb4f5d59bb439c23754c4d9666fbc16c90c0cac91679b6ad1bfe5dcf6bd1a8a67c6b5":96:"9d1603799e2485a03e7b05a0":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1c2d9412486c381440213e1588b6bb58b0da53300b9d3089":"":"727ed8846daab874d5a9918b47d016f4":"656430f0c1423018b5e2efbb1e32a5385c1a9a1779c4dbd585dea91edc39ea8752ebfc2d8064251a8a5ae71e1845f24a7e42c6371c2ecb31e2229d5f4923bffc21d4804575a84836f3cf90ec6047bb360b558a41a975ece111b5284dfa2441705a6df54fc66ca6cc1af9163ecc46902fac337d5f67f563fde8e8e7e64b8588b7":96:"05ee6ce13711535864674a5b":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1c2d9412486c381440213e1588b6bb58b0da53300b9d3089":"":"727ed8846daab874d5a9918b47d016f4":"656430f0c1423018b5e2efbb1e32a5385c1a9a1779c4dbd585dea91edc39ea8752ebfc2d8064251a8a5ae71e1845f24a7e42c6371c2ecb31e2229d5f4923bffc21d4804575a84836f3cf90ec6047bb360b558a41a975ece111b5284dfa2441705a6df54fc66ca6cc1af9163ecc46902fac337d5f67f563fde8e8e7e64b8588b7":96:"05ee6ce13711535864674a5b":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"abf7a97569427225a4bd5143c716a22e62f84c145bb51511":"":"e255088cdfe8ae5c9fea86d74d2f1b7d":"b850993300f54d078f83ceb9aef7345bbf758f92365b6625c210f61dad4f2a2319f51d883a383a706392d3dfca1706eba585a6fac8bd4294c0bb2cb3f6b454d5c97819e8e5c926754840261b07ec4ef1f87cf281d75c187839689944230306e1903047915e086043990745864819ad713d34a244aa4e9d755fdb137105d7eed8":96:"0c9c17388d0610f99d0a093f":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"abf7a97569427225a4bd5143c716a22e62f84c145bb51511":"":"e255088cdfe8ae5c9fea86d74d2f1b7d":"b850993300f54d078f83ceb9aef7345bbf758f92365b6625c210f61dad4f2a2319f51d883a383a706392d3dfca1706eba585a6fac8bd4294c0bb2cb3f6b454d5c97819e8e5c926754840261b07ec4ef1f87cf281d75c187839689944230306e1903047915e086043990745864819ad713d34a244aa4e9d755fdb137105d7eed8":96:"0c9c17388d0610f99d0a093f":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"45a6df655e88bc880acff41520aafd0cc8aa8aeb8952fd06":"":"1125e1de94970c9e7be70e58e7626ef4":"fe9838a445b8edef19b3e9f33c8c0c265b3a12c97b8ec57ceb94f65ae5227177de38f1e338dccb2b24e5bd0f0eb8127f83eba0f1ddfa55198789df0cdd1d977fcb985ad9c7d51b96e749d2cf3cc7a1ec4dfcbc641a1a022d55def328e081af890a7e699f2dbafdf506389e045aa1219239d5868ba675a3925602b6fb6f6e6d37":64:"1c3bd1e0d4918e36":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"45a6df655e88bc880acff41520aafd0cc8aa8aeb8952fd06":"":"1125e1de94970c9e7be70e58e7626ef4":"fe9838a445b8edef19b3e9f33c8c0c265b3a12c97b8ec57ceb94f65ae5227177de38f1e338dccb2b24e5bd0f0eb8127f83eba0f1ddfa55198789df0cdd1d977fcb985ad9c7d51b96e749d2cf3cc7a1ec4dfcbc641a1a022d55def328e081af890a7e699f2dbafdf506389e045aa1219239d5868ba675a3925602b6fb6f6e6d37":64:"1c3bd1e0d4918e36":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"279f4f2ab4b70778fdb9ca7800cd20e323601d7aa2c75366":"":"0f7b402560735cf03d5da58de5b6c685":"7dd9a8c848bbcf5127161c8a419a436a0dad559f7c1613cdf41594e177016acb1ccf44be852185c42e7120902a42efe83855995ab52cf5c190d499fcfd698c671fd72949dc3ea7ddb874e586a3aa455a021cec7b5f8608462ca66f926aba76e60a5846d4eb204155cd3c1328da51ba35c3007b8bb394f34e3a8b81ddd2ea1115":64:"dab612351f75e2cb":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"279f4f2ab4b70778fdb9ca7800cd20e323601d7aa2c75366":"":"0f7b402560735cf03d5da58de5b6c685":"7dd9a8c848bbcf5127161c8a419a436a0dad559f7c1613cdf41594e177016acb1ccf44be852185c42e7120902a42efe83855995ab52cf5c190d499fcfd698c671fd72949dc3ea7ddb874e586a3aa455a021cec7b5f8608462ca66f926aba76e60a5846d4eb204155cd3c1328da51ba35c3007b8bb394f34e3a8b81ddd2ea1115":64:"dab612351f75e2cb":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6716ab937755684af7403e6fba5452c1b11568a9047bb50f":"":"2fd5a446dd564619ef75b6e00905ffe0":"20d261d3192996c21da69e979c26f5f937e6ea4cb7b05c6ef556ce4d86ca0fe85ec2425d274c43b5212fe9d27bb48b04e887461a9f45f524059b87eaea2e287a8d4537f338b0212012a9d4b6610e8c97dd554e0b3c3133e05c14d0ddab3524c93fd527e223b1996b4cff0a4a7438f1d54890bf573cd803941b69e5fc6212c5d2":64:"f1d743b7e1b73af5":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6716ab937755684af7403e6fba5452c1b11568a9047bb50f":"":"2fd5a446dd564619ef75b6e00905ffe0":"20d261d3192996c21da69e979c26f5f937e6ea4cb7b05c6ef556ce4d86ca0fe85ec2425d274c43b5212fe9d27bb48b04e887461a9f45f524059b87eaea2e287a8d4537f338b0212012a9d4b6610e8c97dd554e0b3c3133e05c14d0ddab3524c93fd527e223b1996b4cff0a4a7438f1d54890bf573cd803941b69e5fc6212c5d2":64:"f1d743b7e1b73af5":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7dc94b5bbd6315ad8d2b67f0c683d10cf456f822a3ebb024":"":"6f3eedeb57dcf12bfb3cd80849893c90":"ee1ff367f4b23c156e3dccff84ae4bf2b8ecec1fb5ffd25ccaa93b6c6834389bd79655bd4bac75238eb0f65d3603ecc57c8774798309e85b6677e78ed2077b712cf28795d0dc8fee994f97373a82338ef67c62378136a79a990ecbcd6367445e805efa98f9168826e57cb8dd7e7b1d5c89ad98358646fa56dd2a71c40e0275a1":32:"4dc74971":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7dc94b5bbd6315ad8d2b67f0c683d10cf456f822a3ebb024":"":"6f3eedeb57dcf12bfb3cd80849893c90":"ee1ff367f4b23c156e3dccff84ae4bf2b8ecec1fb5ffd25ccaa93b6c6834389bd79655bd4bac75238eb0f65d3603ecc57c8774798309e85b6677e78ed2077b712cf28795d0dc8fee994f97373a82338ef67c62378136a79a990ecbcd6367445e805efa98f9168826e57cb8dd7e7b1d5c89ad98358646fa56dd2a71c40e0275a1":32:"4dc74971":"":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3bbe223e253bf272599e28af6861013ecd0c88710947ed41":"":"4fbf09ffaffb600f0de38fb12315cab5":"5388146f6479f7b3b280f45655a95b847ee27c734fb2fd91f6c009b1ab1810c772c7435d3221069f9490d251b76e740147906ac1db1c209c175b21aa10881c44fb307d4d2900aa3b1d56fb0edb9f2a58505653a17fee350e12755b9656bc65c78c1593d5cb7178e29f82209caf53e60fddf725f6957cc9718bf410c4a0229ed4":32:"fb845ab7":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3bbe223e253bf272599e28af6861013ecd0c88710947ed41":"":"4fbf09ffaffb600f0de38fb12315cab5":"5388146f6479f7b3b280f45655a95b847ee27c734fb2fd91f6c009b1ab1810c772c7435d3221069f9490d251b76e740147906ac1db1c209c175b21aa10881c44fb307d4d2900aa3b1d56fb0edb9f2a58505653a17fee350e12755b9656bc65c78c1593d5cb7178e29f82209caf53e60fddf725f6957cc9718bf410c4a0229ed4":32:"fb845ab7":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,0,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"461877813acfe6e9979eab729b52e3d192b3236758bb6563":"":"6985cf77b75a47a3978dd6412d59200b":"385551854a89ab37063ba0ed911501b3d632153c5c2992e154c0a334bc36620476f11495437b842409e0954f7352cbf288d158bdbbaf72621ea2ce75b708bc276f796c5aa7fd0071e522c5f175a9e7787deef79f6362101aa3607b4588f2e1df7127f617c6073593a1c792b959e201e4a7a43ea8b1c3af026376439ef629266c":32:"c840d994":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"461877813acfe6e9979eab729b52e3d192b3236758bb6563":"":"6985cf77b75a47a3978dd6412d59200b":"385551854a89ab37063ba0ed911501b3d632153c5c2992e154c0a334bc36620476f11495437b842409e0954f7352cbf288d158bdbbaf72621ea2ce75b708bc276f796c5aa7fd0071e522c5f175a9e7787deef79f6362101aa3607b4588f2e1df7127f617c6073593a1c792b959e201e4a7a43ea8b1c3af026376439ef629266c":32:"c840d994":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"09770f9114120a2c1c3cc416fe0eb8699e07141158a5bdff":"875e2e5b5c02e0a33e71b678aa29c15ce18ec259cf4b41874893ed3112daa56ff2a7475681b8b3d9028ef184d30658e881c908f3588f69899962074db4ddfc0597f8debb66c8388a1bccf0ffe2cf9f078dc1c93f8191f920754442ad4a325985c62de1a57a25de4e9ed5c2fd0f2c8af33f3b140bac12bf60fdb33e0ec557955b":"cff291d2364fc06a3a89e867b0e67e56":"":128:"81f1eb568d0af29680518df7378ba3e8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"09770f9114120a2c1c3cc416fe0eb8699e07141158a5bdff":"875e2e5b5c02e0a33e71b678aa29c15ce18ec259cf4b41874893ed3112daa56ff2a7475681b8b3d9028ef184d30658e881c908f3588f69899962074db4ddfc0597f8debb66c8388a1bccf0ffe2cf9f078dc1c93f8191f920754442ad4a325985c62de1a57a25de4e9ed5c2fd0f2c8af33f3b140bac12bf60fdb33e0ec557955b":"cff291d2364fc06a3a89e867b0e67e56":"":128:"81f1eb568d0af29680518df7378ba3e8":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4fbf1c785c087ad06b43d4163cf9b9396deffd3712856379":"96a690e5319c94d94923988025307e543f16fd970aec24524cf9808dc62b093359287251503f4231bf52cd1a16a80bfa82d8f585d96855dc1932f4919a92da2618d6448fc18a234f9acb386ab4ab4a9e38ea341e7c54faceff38c162d74e7fabbca13aadb71e9c8ae6072e7bef4073cf08aa7faaa6d639f98d15bad4ed183ced":"1c8f41424acaf009996ceaa815b24ad4":"":128:"9f3c0349c5a4a740a82d6d63bf00fb17":"6100b091e52366fb422251d9b68974b6c666a62a8bb77a1ffd7c7d1ae586a6ee763b84dc11aace02a25af91d194b70b3265ec46872fded54275b7ddb26ee1f20c857328f46a694fb1dce68bcaecbd587ece5b505d658d57d50333e30b639eea1f6537b37c175f62497c6c84e3cfddae214285d2d68d90dd5cd8ce2273d25c8ca":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4fbf1c785c087ad06b43d4163cf9b9396deffd3712856379":"96a690e5319c94d94923988025307e543f16fd970aec24524cf9808dc62b093359287251503f4231bf52cd1a16a80bfa82d8f585d96855dc1932f4919a92da2618d6448fc18a234f9acb386ab4ab4a9e38ea341e7c54faceff38c162d74e7fabbca13aadb71e9c8ae6072e7bef4073cf08aa7faaa6d639f98d15bad4ed183ced":"1c8f41424acaf009996ceaa815b24ad4":"":128:"9f3c0349c5a4a740a82d6d63bf00fb17":"":"6100b091e52366fb422251d9b68974b6c666a62a8bb77a1ffd7c7d1ae586a6ee763b84dc11aace02a25af91d194b70b3265ec46872fded54275b7ddb26ee1f20c857328f46a694fb1dce68bcaecbd587ece5b505d658d57d50333e30b639eea1f6537b37c175f62497c6c84e3cfddae214285d2d68d90dd5cd8ce2273d25c8ca":0 AES-GCM NIST Validation (AES-192,128,1024,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3e0ce4fb4fe4bb2fdf97b23084ff5671b9b899624184acef":"df89974b1534f0ba262bbea5efe39d8b72820cc8a720cc99520fedbf667515c3f6d8c3e25c72c48c1cff042171df58421741aacb2a49f23167257be7d7004d56b14901b2075eaca85946e9fbf1bbf4ae98227efc62bf255a25dd0402d37c67ba553531c699dd89ff797e7a5b5b9a9aa51e73ca2dacfda0f814152aa8ed8c79f9":"a950ab0dd84115e3829ab0ad3bbb1193":"":128:"25cfde73e7a29115828dfe1617f8b53e":"847b54e176ccc83081cb966efc4b4a3bf7809ce0b4885009f620f61fafcaa78feee91a835ae6c1a942571811108b1e81b4c4ddac46aaff599c14988c9a1fb9f387ab7f1357b581568b7b34e167ac2c8c2b2b8a4df3fd7ad8947a363c1c0cb782ec54b1901e928821cf319669dd77eb37b15c67f13ad787ff74312812731ca3e6":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3e0ce4fb4fe4bb2fdf97b23084ff5671b9b899624184acef":"df89974b1534f0ba262bbea5efe39d8b72820cc8a720cc99520fedbf667515c3f6d8c3e25c72c48c1cff042171df58421741aacb2a49f23167257be7d7004d56b14901b2075eaca85946e9fbf1bbf4ae98227efc62bf255a25dd0402d37c67ba553531c699dd89ff797e7a5b5b9a9aa51e73ca2dacfda0f814152aa8ed8c79f9":"a950ab0dd84115e3829ab0ad3bbb1193":"":128:"25cfde73e7a29115828dfe1617f8b53e":"":"847b54e176ccc83081cb966efc4b4a3bf7809ce0b4885009f620f61fafcaa78feee91a835ae6c1a942571811108b1e81b4c4ddac46aaff599c14988c9a1fb9f387ab7f1357b581568b7b34e167ac2c8c2b2b8a4df3fd7ad8947a363c1c0cb782ec54b1901e928821cf319669dd77eb37b15c67f13ad787ff74312812731ca3e6":0 AES-GCM NIST Validation (AES-192,128,1024,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6be3c66b20e5e66ababbfba1b38e5a716eafce23a1767b69":"de1cd978354a499415176f260021abe0a8c5bc34d166f53d20e02e413e1377ce4ef5d7f58337c62251a3b4ddea0dea23c40e5de037fd5dd8a558eb53bffa4e8ce94899afa8284afab503c1a485999a154d23777f9d8a031b7ad5c6d23d6abbe3b775c77876ad50f6bed14ac0b2b88fb19c438e4b7eb03f7d4d3fcca90dd01260":"3a2acf69bba19f5d1d1947af2cfda781":"":120:"f826d212f7c1212fb8a8bf23996826":"fd1f7b56e5664cf4c91e58f7c50f6c5e98e42ca2e4adcc00348cee6f662b382ad4022da54a47d8faeb9b76a24dfc4f493c27fc0bc421a4648fad7b14b0df95d8752013feb033b1fd971daa2c9a5df898bece6a3b8fa078dd130071df20a68cd0f394be25dcbb3e85bdfa0df4797fa6f01f5f0da7a6e86320207ddb5b3be53ae0":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6be3c66b20e5e66ababbfba1b38e5a716eafce23a1767b69":"de1cd978354a499415176f260021abe0a8c5bc34d166f53d20e02e413e1377ce4ef5d7f58337c62251a3b4ddea0dea23c40e5de037fd5dd8a558eb53bffa4e8ce94899afa8284afab503c1a485999a154d23777f9d8a031b7ad5c6d23d6abbe3b775c77876ad50f6bed14ac0b2b88fb19c438e4b7eb03f7d4d3fcca90dd01260":"3a2acf69bba19f5d1d1947af2cfda781":"":120:"f826d212f7c1212fb8a8bf23996826":"":"fd1f7b56e5664cf4c91e58f7c50f6c5e98e42ca2e4adcc00348cee6f662b382ad4022da54a47d8faeb9b76a24dfc4f493c27fc0bc421a4648fad7b14b0df95d8752013feb033b1fd971daa2c9a5df898bece6a3b8fa078dd130071df20a68cd0f394be25dcbb3e85bdfa0df4797fa6f01f5f0da7a6e86320207ddb5b3be53ae0":0 AES-GCM NIST Validation (AES-192,128,1024,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d16abb9f5b38d7f5abba9dc36995ce6ce928ed822a07b7c4":"e72f29b1fc1dbfc2d93a0f3b79ea4b9806ce9b2c4d490ac5c0c3c793df9dc7df5471e834b84d18afa5a7516f9a6a813a9b65ae2f083a854730547e28a1f60fe97d8dba1d2d433e11847b9bffd8873ec634e64365530c905dd6f274e45c9795ac127a6f356f63cc6c116c5dd8c628e7e17e1fadc58f8452bf21f53c4133198118":"3cd95429c6de1d327b9eb3c45424a87c":"":120:"13521236f190f78e75c0897c5fb237":"cd8bb97c28df092b6783ef653fd26f2bdc27c442bab0a4c7bee2789f389dcd1b280c0231672721bfbbc939a0449557678ec61ba0afb2e5817e6f7d94387f84ecafbfa1216d65e7f5025f47b0d2905cff7c99adf8306a3d9850c5908be05f87cb1d36a4837dba428aac97d7fbc18e3778f8d81a319259504c87fc94bd0766ed93":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d16abb9f5b38d7f5abba9dc36995ce6ce928ed822a07b7c4":"e72f29b1fc1dbfc2d93a0f3b79ea4b9806ce9b2c4d490ac5c0c3c793df9dc7df5471e834b84d18afa5a7516f9a6a813a9b65ae2f083a854730547e28a1f60fe97d8dba1d2d433e11847b9bffd8873ec634e64365530c905dd6f274e45c9795ac127a6f356f63cc6c116c5dd8c628e7e17e1fadc58f8452bf21f53c4133198118":"3cd95429c6de1d327b9eb3c45424a87c":"":120:"13521236f190f78e75c0897c5fb237":"":"cd8bb97c28df092b6783ef653fd26f2bdc27c442bab0a4c7bee2789f389dcd1b280c0231672721bfbbc939a0449557678ec61ba0afb2e5817e6f7d94387f84ecafbfa1216d65e7f5025f47b0d2905cff7c99adf8306a3d9850c5908be05f87cb1d36a4837dba428aac97d7fbc18e3778f8d81a319259504c87fc94bd0766ed93":0 AES-GCM NIST Validation (AES-192,128,1024,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0bc344b1a4078807e5f53a6e7e1e36fa83108473ae2fb4c2":"8bd73f94c71e3765bc7d17fdc90a9ba6aff9648b46300e4048985fbbd7c60c39c3766f7c524780bfc2296dc11e1132134921760a373104edc376eab6e91e9a60a5c4a5972935df12eadae074722bdc0147c3caf6a62fd449ef37d76b65f6d210283c94ac524cf13186e444d80a70b01e4373cc0462546f1caee6b49e738a742c":"bd505fcba464e6e2c58fdf29f5695fb9":"":120:"8510fff71bb879f56ea2fe43f6ff50":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0bc344b1a4078807e5f53a6e7e1e36fa83108473ae2fb4c2":"8bd73f94c71e3765bc7d17fdc90a9ba6aff9648b46300e4048985fbbd7c60c39c3766f7c524780bfc2296dc11e1132134921760a373104edc376eab6e91e9a60a5c4a5972935df12eadae074722bdc0147c3caf6a62fd449ef37d76b65f6d210283c94ac524cf13186e444d80a70b01e4373cc0462546f1caee6b49e738a742c":"bd505fcba464e6e2c58fdf29f5695fb9":"":120:"8510fff71bb879f56ea2fe43f6ff50":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c8097398fc21f93eea6a95aa93a3231096817b65520bc549":"80b0abbaebbd537a0810ed75cd172d29d50f5982e4d01f8664ddb2dfda8f57fa0ed87e64a779a1d7f5e568b6acfdc739572a7176752307b430fb1fa1c3c2c346477cebe7d01b16745ca6c8929a7f446c03ad9a9e8a5a935de78ca6c701e8c1c5e6d2550c42949cf5342fb5ef4c6ab9bb02ace8388b16edf72a1237e5d1d0e820":"776248381941e16908f52d19207881f5":"":112:"7fc4388b2f8eab0f0c2d6a08527e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c8097398fc21f93eea6a95aa93a3231096817b65520bc549":"80b0abbaebbd537a0810ed75cd172d29d50f5982e4d01f8664ddb2dfda8f57fa0ed87e64a779a1d7f5e568b6acfdc739572a7176752307b430fb1fa1c3c2c346477cebe7d01b16745ca6c8929a7f446c03ad9a9e8a5a935de78ca6c701e8c1c5e6d2550c42949cf5342fb5ef4c6ab9bb02ace8388b16edf72a1237e5d1d0e820":"776248381941e16908f52d19207881f5":"":112:"7fc4388b2f8eab0f0c2d6a08527e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"76d4bb5694faaf344db83bc6d6c47d56bb6ab52700826f2d":"9e31fda6a171f0d4a5f2af2c4f827b1312d9dda5d78fa329b8f1b6373b9b29be358601e5bb0d0c615aef4b9e441c811219f1f2ff2d0ab23e0cd829a88b5b615ee72e5e3ea604fa26cc6438ec4c30e90f7348e9116adf8e8efb7498320d2da16679fa546b1aa9afc7720b074c4e48e06862d41428c9e71a4772c2e195a6f36978":"603977845d82faccb401817ecce6e2fe":"":112:"c955a3bc316841be07e406d289c8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"76d4bb5694faaf344db83bc6d6c47d56bb6ab52700826f2d":"9e31fda6a171f0d4a5f2af2c4f827b1312d9dda5d78fa329b8f1b6373b9b29be358601e5bb0d0c615aef4b9e441c811219f1f2ff2d0ab23e0cd829a88b5b615ee72e5e3ea604fa26cc6438ec4c30e90f7348e9116adf8e8efb7498320d2da16679fa546b1aa9afc7720b074c4e48e06862d41428c9e71a4772c2e195a6f36978":"603977845d82faccb401817ecce6e2fe":"":112:"c955a3bc316841be07e406d289c8":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a3e5020695587984074d78d9c98b8e1a5719e5f88372740e":"c0bfe3b2dc4dad17ec5a7662d86847fb67e582cc0baf469bc9baa7a075d48a8b97521a1072c2798bfbdae5ca3752eda1cb96fe5cf24af989eb77a2948aae3d8b70d83d93f84c49347f788480f34051621c358c03cf8159a70fc72cb8bc02876234ffe76b181da8b22b8796c87b0904da1af46de519c20d8d1b1dc7cc24e39ba5":"4cd56de54e5140a587be7dfd02d3a39e":"":112:"1a29527a41330259f918d99d7509":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a3e5020695587984074d78d9c98b8e1a5719e5f88372740e":"c0bfe3b2dc4dad17ec5a7662d86847fb67e582cc0baf469bc9baa7a075d48a8b97521a1072c2798bfbdae5ca3752eda1cb96fe5cf24af989eb77a2948aae3d8b70d83d93f84c49347f788480f34051621c358c03cf8159a70fc72cb8bc02876234ffe76b181da8b22b8796c87b0904da1af46de519c20d8d1b1dc7cc24e39ba5":"4cd56de54e5140a587be7dfd02d3a39e":"":112:"1a29527a41330259f918d99d7509":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"afe986ead799727063958e2ce13ca846f76c51605439f839":"7c1b354a5bb214bd95147e32d81e658705089c38035d0ea423eb1a5c82f97443c6903d2cf1ba7a007eec7c8ff98b8f82b073d9636a79bd47c7f2f639a8eb4e92076f9ed615766f43ac3a4f1687301ed7d507766605e0e332880ae740ab72e861a2cb6dce1df1ff8be1873d25845ee7c665e712c5bbe029a1788634bce122836c":"f85a95ed10b69623162ab68d1098de94":"":104:"3cf1cdb4a4fdc48da78a8b4e81":"a7f252ad7983e7083260598051bffd83f40f4d4a8b580cc2388d720a0979dde71549ddcb86b0a62c4964fca591d0982f3a203f2f8884ff4991f17e20f759ea7125ba2bb4d993722f23938994eb2709c850f33ed9889e5a3966f9d7b76add46aedf230e8f417425f9db79ccd46b5660361de7c5d87f71a9d82c491c0c3daaf56c":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"afe986ead799727063958e2ce13ca846f76c51605439f839":"7c1b354a5bb214bd95147e32d81e658705089c38035d0ea423eb1a5c82f97443c6903d2cf1ba7a007eec7c8ff98b8f82b073d9636a79bd47c7f2f639a8eb4e92076f9ed615766f43ac3a4f1687301ed7d507766605e0e332880ae740ab72e861a2cb6dce1df1ff8be1873d25845ee7c665e712c5bbe029a1788634bce122836c":"f85a95ed10b69623162ab68d1098de94":"":104:"3cf1cdb4a4fdc48da78a8b4e81":"":"a7f252ad7983e7083260598051bffd83f40f4d4a8b580cc2388d720a0979dde71549ddcb86b0a62c4964fca591d0982f3a203f2f8884ff4991f17e20f759ea7125ba2bb4d993722f23938994eb2709c850f33ed9889e5a3966f9d7b76add46aedf230e8f417425f9db79ccd46b5660361de7c5d87f71a9d82c491c0c3daaf56c":0 AES-GCM NIST Validation (AES-192,128,1024,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2cfaa215841826a977ae6adfdd993346210c49dd04d5d493":"e8eb3b6edd0ca4201b49a6a83036445aba1a1db040f3e74511363bce769760a9914e05a067f555ca15a57c6e02e66fbe4e04dd8c8db8d6d14ebc01cc7d84a20ff0aacb69bb3679d6b7d9d2e07deda7c2d4fe4c584fe1166e78d21dc56b9cdad93709c03b9145b887f87b4f605f24f989d5e0534fc71a58e8a8619ee99f69e5f5":"537a4ee307af3072e745570aaaadce34":"":104:"df01cffbd3978850e07328e6b8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2cfaa215841826a977ae6adfdd993346210c49dd04d5d493":"e8eb3b6edd0ca4201b49a6a83036445aba1a1db040f3e74511363bce769760a9914e05a067f555ca15a57c6e02e66fbe4e04dd8c8db8d6d14ebc01cc7d84a20ff0aacb69bb3679d6b7d9d2e07deda7c2d4fe4c584fe1166e78d21dc56b9cdad93709c03b9145b887f87b4f605f24f989d5e0534fc71a58e8a8619ee99f69e5f5":"537a4ee307af3072e745570aaaadce34":"":104:"df01cffbd3978850e07328e6b8":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"128ddc83d2170c403a517615056dceec0d19d6fd7632e738":"cfe9f7797ee37bfc4f564419bf2268c964479efa7435970874154432930f3b2736438da4dc9c76200009651340e23044bc9d200a32acfd4df2e1b98b0bae3e9ff9d6e8181d926d2d03f89768edc35b963d341931ac57d2739b270ce254f042b64ceac4b75223b233602c9a4bdc925967b051440c28805d816abe76fc9d593f5a":"5124b410c43d875eca6ce298c45994a7":"":104:"56ad9c1653f11a41fd649cccd8":"cf91f087fd7faf362caacf4a68cff51ec57b3075563e4ad0955df20b366e92bd75c3762cf4a6f0eb859872667a5c55aa5d94f5ac9479b1b9c9345b50f82379d551506a2ab02b0441b14b28b78a12b38500d703a8c19888fe612d4710eec7cd18c16d6a4b55d3c69760e2bed99efc8b551dbe2ac9b9b64715f87180b8e14d1795":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"128ddc83d2170c403a517615056dceec0d19d6fd7632e738":"cfe9f7797ee37bfc4f564419bf2268c964479efa7435970874154432930f3b2736438da4dc9c76200009651340e23044bc9d200a32acfd4df2e1b98b0bae3e9ff9d6e8181d926d2d03f89768edc35b963d341931ac57d2739b270ce254f042b64ceac4b75223b233602c9a4bdc925967b051440c28805d816abe76fc9d593f5a":"5124b410c43d875eca6ce298c45994a7":"":104:"56ad9c1653f11a41fd649cccd8":"":"cf91f087fd7faf362caacf4a68cff51ec57b3075563e4ad0955df20b366e92bd75c3762cf4a6f0eb859872667a5c55aa5d94f5ac9479b1b9c9345b50f82379d551506a2ab02b0441b14b28b78a12b38500d703a8c19888fe612d4710eec7cd18c16d6a4b55d3c69760e2bed99efc8b551dbe2ac9b9b64715f87180b8e14d1795":0 AES-GCM NIST Validation (AES-192,128,1024,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"98581c28983c4da321ce0c419cc0d476d539e77da513c894":"bdef5b65b5111b29e781a6b71a0160179c52b5bccb1ac5c0377b26cf3f61432f3ccd67633a836357c24b5099db0510a7f8110f59e8227cacd11f17ea1798b5d4d68902ca6c6eccd319fef14545edd135078b38d43b61c9af269fc72f7a209ba7897e4c6dbd21bb71d7e93d2d2426ffa1557cae28e74059d3baf06ba419a47b39":"ff10234524433b871202c2cca6acb194":"":96:"984943355a7aef15c4fb8033":"808e28bfd441cb8890416a757d252c986daa8d607ac9cadd2f4fd29eddbcf3b859ba298e14a4ccefe2c2752b123f87b98d6708fde48faca4bc7dd818a7ea76cfa4357932e59cb6be0e9283bdfb49454b86b9fd04aa8cdef503c65d13fcff42e9cd8f142f8c06cf7daa6d8ef8b9c9d69c39e8afd980048fecf731fd674b2a814b":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"98581c28983c4da321ce0c419cc0d476d539e77da513c894":"bdef5b65b5111b29e781a6b71a0160179c52b5bccb1ac5c0377b26cf3f61432f3ccd67633a836357c24b5099db0510a7f8110f59e8227cacd11f17ea1798b5d4d68902ca6c6eccd319fef14545edd135078b38d43b61c9af269fc72f7a209ba7897e4c6dbd21bb71d7e93d2d2426ffa1557cae28e74059d3baf06ba419a47b39":"ff10234524433b871202c2cca6acb194":"":96:"984943355a7aef15c4fb8033":"":"808e28bfd441cb8890416a757d252c986daa8d607ac9cadd2f4fd29eddbcf3b859ba298e14a4ccefe2c2752b123f87b98d6708fde48faca4bc7dd818a7ea76cfa4357932e59cb6be0e9283bdfb49454b86b9fd04aa8cdef503c65d13fcff42e9cd8f142f8c06cf7daa6d8ef8b9c9d69c39e8afd980048fecf731fd674b2a814b":0 AES-GCM NIST Validation (AES-192,128,1024,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"167b8b6df8014c8f3de912b77f5a0c113580aa42d785298f":"4f787de12ba907a589edf74c8e7a6cdaaabebddd465a86e170e1efc289240298b516fddc43c7fd9bb1c51720a4455db4dd630b59aebaa82bd578eb3cb19f8b23ee6897c1fefaef820430efa6eb7d6ff04de4d8b079605fb520b0d33e96c28f0cd71983c4ce76c0ea62fd7209d21ec7b416881d545824a73d1f9f8d3323fdb90c":"49da91e926091a448d57d521cc90f3c0":"":96:"99198f55f9fa763651bba58e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"167b8b6df8014c8f3de912b77f5a0c113580aa42d785298f":"4f787de12ba907a589edf74c8e7a6cdaaabebddd465a86e170e1efc289240298b516fddc43c7fd9bb1c51720a4455db4dd630b59aebaa82bd578eb3cb19f8b23ee6897c1fefaef820430efa6eb7d6ff04de4d8b079605fb520b0d33e96c28f0cd71983c4ce76c0ea62fd7209d21ec7b416881d545824a73d1f9f8d3323fdb90c":"49da91e926091a448d57d521cc90f3c0":"":96:"99198f55f9fa763651bba58e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"71f5f8505fba62f08fa0557dd5407fc83a852c6007ccecc8":"3e19ec02365e450e946123a3362f9859352eb52902a6bcb8a782285dfac9d2b282f56302b60d6e9f53fddd16bbf04976cf4eb84ef3b6583e9dc2f805276a7b7340dec7abde4916fb94b0ed9c9af6d4917b27e44d25f3952d0444cd32a4a574e165a23fa8c93229ceb48345171a4f20d610b5be7d9e40dcf7209128f029fed6bf":"b5efb9feae3de41b5ce9aa75583b8d21":"":96:"9604d031fa43dcd0853e641c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"71f5f8505fba62f08fa0557dd5407fc83a852c6007ccecc8":"3e19ec02365e450e946123a3362f9859352eb52902a6bcb8a782285dfac9d2b282f56302b60d6e9f53fddd16bbf04976cf4eb84ef3b6583e9dc2f805276a7b7340dec7abde4916fb94b0ed9c9af6d4917b27e44d25f3952d0444cd32a4a574e165a23fa8c93229ceb48345171a4f20d610b5be7d9e40dcf7209128f029fed6bf":"b5efb9feae3de41b5ce9aa75583b8d21":"":96:"9604d031fa43dcd0853e641c":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4cdb38f8185a4186fc983e58a776a6454b92ecf0bffefe98":"1ca72c50a093076e9a9dfa09888b9c89eb36a942072fc536a81713f05a2669b39fdb2871b82ca47dcaf18393ca81dcb499aafcc4ed57ea79f8d4f9bd63540610215b2c65481b294638cec41264a7fdca4230df5fe1e7e3d8d26dcd0c435fec8e9bf778f9e6f13482157a9722761601e08425f6160d3bb626ae39ee1117b0353c":"aef257dd44d14d0bc75f9311ef24e85a":"":64:"d951becb0d55f9fb":"2eaa7e922dbd8963e2078aae216636276f3f7cb5d7f35fa759e91bddb6e247a93c388241ba1d0d37040c0b9e447c67d35b4991c1acce97914f3bc22ee50171bc5922299983ee70af79303265bc1ae1e7334202460618b4a8891d1a7eaaac5cac1e4dce024ce662d14849993f89e771fb873644b552120fd346250df39aaaa403":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4cdb38f8185a4186fc983e58a776a6454b92ecf0bffefe98":"1ca72c50a093076e9a9dfa09888b9c89eb36a942072fc536a81713f05a2669b39fdb2871b82ca47dcaf18393ca81dcb499aafcc4ed57ea79f8d4f9bd63540610215b2c65481b294638cec41264a7fdca4230df5fe1e7e3d8d26dcd0c435fec8e9bf778f9e6f13482157a9722761601e08425f6160d3bb626ae39ee1117b0353c":"aef257dd44d14d0bc75f9311ef24e85a":"":64:"d951becb0d55f9fb":"":"2eaa7e922dbd8963e2078aae216636276f3f7cb5d7f35fa759e91bddb6e247a93c388241ba1d0d37040c0b9e447c67d35b4991c1acce97914f3bc22ee50171bc5922299983ee70af79303265bc1ae1e7334202460618b4a8891d1a7eaaac5cac1e4dce024ce662d14849993f89e771fb873644b552120fd346250df39aaaa403":0 AES-GCM NIST Validation (AES-192,128,1024,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ee8d3aced3aa3cb2166aa66c4a252c12dc0978830d0bc75b":"ee69b2421d43a9f383d99f9802ba4d6cf1c537b42041c86cce681049bb475e5098d4181f1902b0a49c202bf34ef70ea7b787fa685ab8f824fcc27282146d8158925bfef47ccba89aa81c0565eacb087b46b8706c9f886b7edf863701003051d6fb57e45e61d33412591ec818d016eec7dee4254636615a43dacb4f1e6ec35702":"c15c9c0b0b70c7321df044bfde2b15fb":"":64:"c5c9851a6bf686d0":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ee8d3aced3aa3cb2166aa66c4a252c12dc0978830d0bc75b":"ee69b2421d43a9f383d99f9802ba4d6cf1c537b42041c86cce681049bb475e5098d4181f1902b0a49c202bf34ef70ea7b787fa685ab8f824fcc27282146d8158925bfef47ccba89aa81c0565eacb087b46b8706c9f886b7edf863701003051d6fb57e45e61d33412591ec818d016eec7dee4254636615a43dacb4f1e6ec35702":"c15c9c0b0b70c7321df044bfde2b15fb":"":64:"c5c9851a6bf686d0":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4a8538d609444e3197ab740cd33b66db1cf53600096b94e0":"8c2b8fb775d1b21c41a3dcf48ad6d68ab05be3879f9b94b305a6ce4d799e3a992c1c3a65a3e4eab563edb57424927c90c76e49386e29dd5e7de2800fcc0eefbc8b4f977f71be3754c006ee93dc09b1cfa59c424b6b3987aeb56feefc21004c63e8284b6845e395bc8843cca0917267fb4a8f2db1f7daafe7a9da95083a44de70":"0bd64d222532dae8ab63dc299355bf2a":"":64:"3477cad1fd4098b2":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4a8538d609444e3197ab740cd33b66db1cf53600096b94e0":"8c2b8fb775d1b21c41a3dcf48ad6d68ab05be3879f9b94b305a6ce4d799e3a992c1c3a65a3e4eab563edb57424927c90c76e49386e29dd5e7de2800fcc0eefbc8b4f977f71be3754c006ee93dc09b1cfa59c424b6b3987aeb56feefc21004c63e8284b6845e395bc8843cca0917267fb4a8f2db1f7daafe7a9da95083a44de70":"0bd64d222532dae8ab63dc299355bf2a":"":64:"3477cad1fd4098b2":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"447f0f065771b6129952e52206a64fe0844658ed685e39cd":"fea5d227869e527882c63a68a6623f4a699df82b3dc715c7260a5554336df8376744c05ae89ec27d40da02d9f1c5e9e29405579fd4132143cb21cdbe3edfaaab62128ecc28018725c8dd309d2376223d2e2edfea9765699b2630ff5d9fe9bec416c0ca6418b938d195d31a08e4034c49d79e3a249edd65f985230b33c444dd02":"37e3a300542d9caf3975c6429cb8a2e8":"":32:"06bfca29":"e1bdd1c212b159b87e41a5f64dcba6b27aa0f5c8871fabfb588df0e06bd7730ec1beb0e3388f96c992a573ff69b34870f83c53fb65b420c1c6f92e2aa6f03917e8203d77c7f5ee08baf9fab12f9d38fc0ffb83807ba781c3dd7b62edca2121f68ef230b42b8adbd4cea072209d02713789ed559b83739a54cfde69e68bdc4128":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"447f0f065771b6129952e52206a64fe0844658ed685e39cd":"fea5d227869e527882c63a68a6623f4a699df82b3dc715c7260a5554336df8376744c05ae89ec27d40da02d9f1c5e9e29405579fd4132143cb21cdbe3edfaaab62128ecc28018725c8dd309d2376223d2e2edfea9765699b2630ff5d9fe9bec416c0ca6418b938d195d31a08e4034c49d79e3a249edd65f985230b33c444dd02":"37e3a300542d9caf3975c6429cb8a2e8":"":32:"06bfca29":"":"e1bdd1c212b159b87e41a5f64dcba6b27aa0f5c8871fabfb588df0e06bd7730ec1beb0e3388f96c992a573ff69b34870f83c53fb65b420c1c6f92e2aa6f03917e8203d77c7f5ee08baf9fab12f9d38fc0ffb83807ba781c3dd7b62edca2121f68ef230b42b8adbd4cea072209d02713789ed559b83739a54cfde69e68bdc4128":0 AES-GCM NIST Validation (AES-192,128,1024,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f465e95f6fc19fe6968b98319b547104d0c01c17105f8fc0":"2426f108368a00d2a49670a3b64b4f0569c6da9660163e7b209ec3f8d058ee11f7818a8c5030c5f4ce6e1e5a93faa3e5ae3d0bd5d712fbc891cfeb20845707edcf5e29719a5246a3b024fb12d37bd1b81df3812fd50b1dfb3e948ce546dd165cc77f903c07fe32bc7da7fbc25036679017317ce94cd8a00c1bce7379774f1714":"6cba4efc8d4840aa044a92d03d6b4d69":"":32:"92750ac9":"2e59b104c1a6f6d651000396adbfa009bf4cf8cbf714da8e4d3b4a62bd7f522d614decf090c7552a4b9e8d7ee457ba642d5100c0c81c14cbba8c8ff49b12827f6ebd41504ccb6dfc97cdf8532d1f7f7e603c609efa72d2ae0dce036ec4ab36849a0c06f8737d9710075a1daaed3867ca0a7e22111c0e7afae91f553b6fd66c6e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f465e95f6fc19fe6968b98319b547104d0c01c17105f8fc0":"2426f108368a00d2a49670a3b64b4f0569c6da9660163e7b209ec3f8d058ee11f7818a8c5030c5f4ce6e1e5a93faa3e5ae3d0bd5d712fbc891cfeb20845707edcf5e29719a5246a3b024fb12d37bd1b81df3812fd50b1dfb3e948ce546dd165cc77f903c07fe32bc7da7fbc25036679017317ce94cd8a00c1bce7379774f1714":"6cba4efc8d4840aa044a92d03d6b4d69":"":32:"92750ac9":"":"2e59b104c1a6f6d651000396adbfa009bf4cf8cbf714da8e4d3b4a62bd7f522d614decf090c7552a4b9e8d7ee457ba642d5100c0c81c14cbba8c8ff49b12827f6ebd41504ccb6dfc97cdf8532d1f7f7e603c609efa72d2ae0dce036ec4ab36849a0c06f8737d9710075a1daaed3867ca0a7e22111c0e7afae91f553b6fd66c6e":0 AES-GCM NIST Validation (AES-192,128,1024,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f08e3e9f7b3a20ccdc4d98b56f2b567399a28a6b3908deab":"a986e816f1eafb532c716a555cca1839a1b0523410134ea0426ab309520b339fc1fdeb40478ae76823cee4e03b8d3450e6be92d5ff17b2f78400f0176e6d6a3930bd076a7a3c87c3397dcc0520c6b7b4ff9059ea21e71c91912a74aac2ca70eec422b507cc5c60860bb8baca01eec2a3003970ba84011efe576804b2820e306c":"4f4636d1b283bfa72c82809eb4f12519":"":32:"16c80a62":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f08e3e9f7b3a20ccdc4d98b56f2b567399a28a6b3908deab":"a986e816f1eafb532c716a555cca1839a1b0523410134ea0426ab309520b339fc1fdeb40478ae76823cee4e03b8d3450e6be92d5ff17b2f78400f0176e6d6a3930bd076a7a3c87c3397dcc0520c6b7b4ff9059ea21e71c91912a74aac2ca70eec422b507cc5c60860bb8baca01eec2a3003970ba84011efe576804b2820e306c":"4f4636d1b283bfa72c82809eb4f12519":"":32:"16c80a62":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"87b5372571fb244648053c99405999130f87a7c178052297":"ae078d1554fc6a14447a28c3dd753e790f7ef9b53e35c3e0fe63a7b1b326bc56034847f8a31c2d6358049aae990bfe7575b439db370aa515e225e0ec730488c700a7b0a96a7b8e4e8e4c6afec20decd16fe3c0f3f8d7a6cf7a8711d170829d14c706cceb00e133b8c65c8e08cd984b884662eddd2258ce629abf6b9dd28688c9":"a1cc81b87bd36affe3af50546e361c9e":"684ce23f59632308d7db14f7f6eddaf4d83271fb0c27401b09518a775b36252540f14305f0dae13ff6c0dc565c9e570759e070c8ac73dfb97abd3285689a7cdcfc941f6271be3b418740b42ba4a114421065a785be3dfa944c86af56da8209779e8736e62529c418b507c6d8ae002cbc0431747722afd64521734f99273de455":128:"98177b3428e64bc98631375905c0100f":"8be7df33a86b1162464af738de582a357d0ce8e213bba1b7913c0d13ad759d62c3bf4366f5130b3af2b255b7ad530b4977627f9e76b07e360c079d0f763dabbd22e976b98cd5495c6182f95bc963aad4b719446f49d3a448d11cac5bfcba4b675b8e4d88a389e2580e8f383f95bf85c72e698680d2a2bc993c9ee1ce0d1f1ac3":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"87b5372571fb244648053c99405999130f87a7c178052297":"ae078d1554fc6a14447a28c3dd753e790f7ef9b53e35c3e0fe63a7b1b326bc56034847f8a31c2d6358049aae990bfe7575b439db370aa515e225e0ec730488c700a7b0a96a7b8e4e8e4c6afec20decd16fe3c0f3f8d7a6cf7a8711d170829d14c706cceb00e133b8c65c8e08cd984b884662eddd2258ce629abf6b9dd28688c9":"a1cc81b87bd36affe3af50546e361c9e":"684ce23f59632308d7db14f7f6eddaf4d83271fb0c27401b09518a775b36252540f14305f0dae13ff6c0dc565c9e570759e070c8ac73dfb97abd3285689a7cdcfc941f6271be3b418740b42ba4a114421065a785be3dfa944c86af56da8209779e8736e62529c418b507c6d8ae002cbc0431747722afd64521734f99273de455":128:"98177b3428e64bc98631375905c0100f":"":"8be7df33a86b1162464af738de582a357d0ce8e213bba1b7913c0d13ad759d62c3bf4366f5130b3af2b255b7ad530b4977627f9e76b07e360c079d0f763dabbd22e976b98cd5495c6182f95bc963aad4b719446f49d3a448d11cac5bfcba4b675b8e4d88a389e2580e8f383f95bf85c72e698680d2a2bc993c9ee1ce0d1f1ac3":0 AES-GCM NIST Validation (AES-192,128,1024,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a2d069b826455d5e79e65db4f1d2b6a29ae9f401bc623917":"acd6225dc5b9109d56ea565ab38dd4db432a7ec08f0db04f1c6b691c96d2eaaa6be62da7cc7fd75f931716c7f39705ea7cf828f1a5a325955e9b2c77e7fb2d562be6a89b3351b1b3d1355b43b73ed425049430314c16bf0836ed580e9390a3b8e2a652fddbfa939ca4c3c99765b09db7f30bf2ef88e1aa030e68958722cb0da3":"6d40a0c7813bc0410ff73f19bb5d89c9":"9960376b1898618d98c327c1761959d045488cc6198238bbe72662f276d47b41e8aebc06dbce63da5adcb302a61ade140c72b9cf9f6dfad6ecedd7401c9509fae349d3c7debe35117776227ba167f2b75921d7321d79f4ebca13d20af1638a1567043365f179f4162795fe4fd80b5d832e4ca70e7bf9830bc272b82182f70d2e":128:"010195091d4e1684029e58439039d91e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a2d069b826455d5e79e65db4f1d2b6a29ae9f401bc623917":"acd6225dc5b9109d56ea565ab38dd4db432a7ec08f0db04f1c6b691c96d2eaaa6be62da7cc7fd75f931716c7f39705ea7cf828f1a5a325955e9b2c77e7fb2d562be6a89b3351b1b3d1355b43b73ed425049430314c16bf0836ed580e9390a3b8e2a652fddbfa939ca4c3c99765b09db7f30bf2ef88e1aa030e68958722cb0da3":"6d40a0c7813bc0410ff73f19bb5d89c9":"9960376b1898618d98c327c1761959d045488cc6198238bbe72662f276d47b41e8aebc06dbce63da5adcb302a61ade140c72b9cf9f6dfad6ecedd7401c9509fae349d3c7debe35117776227ba167f2b75921d7321d79f4ebca13d20af1638a1567043365f179f4162795fe4fd80b5d832e4ca70e7bf9830bc272b82182f70d2e":128:"010195091d4e1684029e58439039d91e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f3252351fe8e7c628c418c1a49709bf1f8e20add82539948":"7e8d2816d280c91d232bad43b6610e2d0532a9f670f221a3a975fb16472c2e83b168115e87a487bcd14b37f075e1faa59c42515c353cdefc728ac617b7d273fa96778e3fb5f7a1132f8e2add4a57015b15d1984338b7862356243d1c5aa628406f4a507498eda12d2f652c55e8e58113ed828783b82505790654f036b610f89a":"eacd2b1c3cf01bf4ea7582d8ee2675d5":"141cb39a2fb8e735e0c97207f1b618a4b98f6b9bf8c44a1c8e9ea575a7759cc2a02301274553e7744408b2c577b4c8c2a00e18f8717fd8a6d2f46a44eeb05d685fbef7edeb4229e7ea9b8e419ffcb504d33583b3ae421c84caeca9f9789047dd7b1810318d3765307233567bc40e003401c9f4e1b07a2a7162889e1a092aedc1":128:"63a310b4f43b421a863fb00fafd7eac4":"699c146927ae29025e5b20088b20af27bc75449e4725ee6b7d5dc60b44ba8a06f7d265330c16060fbd6def244630d056c82676be2dc85d891c63d005804085c93ce88f3f57c2d2c0371c31027d0a4a0031e3f473cb373db63d4ff8f65be9ebe74045de813a4e6c688110d000f6b12406881c08085c9348e1f0315038907e33f7":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f3252351fe8e7c628c418c1a49709bf1f8e20add82539948":"7e8d2816d280c91d232bad43b6610e2d0532a9f670f221a3a975fb16472c2e83b168115e87a487bcd14b37f075e1faa59c42515c353cdefc728ac617b7d273fa96778e3fb5f7a1132f8e2add4a57015b15d1984338b7862356243d1c5aa628406f4a507498eda12d2f652c55e8e58113ed828783b82505790654f036b610f89a":"eacd2b1c3cf01bf4ea7582d8ee2675d5":"141cb39a2fb8e735e0c97207f1b618a4b98f6b9bf8c44a1c8e9ea575a7759cc2a02301274553e7744408b2c577b4c8c2a00e18f8717fd8a6d2f46a44eeb05d685fbef7edeb4229e7ea9b8e419ffcb504d33583b3ae421c84caeca9f9789047dd7b1810318d3765307233567bc40e003401c9f4e1b07a2a7162889e1a092aedc1":128:"63a310b4f43b421a863fb00fafd7eac4":"":"699c146927ae29025e5b20088b20af27bc75449e4725ee6b7d5dc60b44ba8a06f7d265330c16060fbd6def244630d056c82676be2dc85d891c63d005804085c93ce88f3f57c2d2c0371c31027d0a4a0031e3f473cb373db63d4ff8f65be9ebe74045de813a4e6c688110d000f6b12406881c08085c9348e1f0315038907e33f7":0 AES-GCM NIST Validation (AES-192,128,1024,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e462957f2c500bf2d6bfa9af97938fdd8930e360ea4175e7":"82a7a6dd82a5ea3d9a8e9541d854978487eda298b483df02b45c76b8b38bac98ffd969dd160a2765595b19d4ea3e64351ce95764a903f595dd673d13facf5a5594e01be1d60a0c6d28b866a1f93a63a74fecb6d73ac6fb26b20c008b93db53e9dc1d3e3902359fd47734fe22a5c6958f97e9001cc4e8b6484d9542dbbdfcfcdc":"b380584a3f4e0e59add4753c282f2cf7":"682b0af6592eef173e559407e7f56574c069251b92092570cbb7f5a2f05e88bed0af48dcda45b2930b1ee7d5da78dc43ec3598a38593df7c548058eda3c9275c1304489aff95f33a6cd79e724e8d12ca0ae92b20273eb3736efcd50dc49e803ad631dcbf64376a45a687eb4e417aef08a3f5f8230d3f0b266ea732c21ed2eed7":120:"28a43253d8b37795433140641e9ffd":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e462957f2c500bf2d6bfa9af97938fdd8930e360ea4175e7":"82a7a6dd82a5ea3d9a8e9541d854978487eda298b483df02b45c76b8b38bac98ffd969dd160a2765595b19d4ea3e64351ce95764a903f595dd673d13facf5a5594e01be1d60a0c6d28b866a1f93a63a74fecb6d73ac6fb26b20c008b93db53e9dc1d3e3902359fd47734fe22a5c6958f97e9001cc4e8b6484d9542dbbdfcfcdc":"b380584a3f4e0e59add4753c282f2cf7":"682b0af6592eef173e559407e7f56574c069251b92092570cbb7f5a2f05e88bed0af48dcda45b2930b1ee7d5da78dc43ec3598a38593df7c548058eda3c9275c1304489aff95f33a6cd79e724e8d12ca0ae92b20273eb3736efcd50dc49e803ad631dcbf64376a45a687eb4e417aef08a3f5f8230d3f0b266ea732c21ed2eed7":120:"28a43253d8b37795433140641e9ffd":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4a62ddd87f41c6df756e8da0985dcd8c91e73ba395b3d79b":"37a83ee6dbdece212446739ea353cb957b9aa409c88bee042bbc3a6e5199aeb28f2b4b00ff433c0c68d6db5a197566019db8a4c7a792e2839a19a302ee02bee046adce04c1fbbd5b0c457d7cbe277992ce2c153d132269e2d1f12b084cf3026a202b4664bc9d11832e9b99c7cc5035dcfde5991dd41aeb4fbf8bec5126a9f524":"1d1843e2118772d76a0244a2c33c60bd":"028b92727b75b14cb8dfeb7a86a7fec50cd5de46aa4a34645754918b8606819d4bf8a2e7531a05ae5505492ca6cbc8c0e6d6ab2dea23bff1fdf581bb780b4a3312aa39639383fd10bcf92489801954733f16b021c2e84809345216f8f28a99773341e40c4a64305a2098eaa39f26a93bd556c97f02090e1a6c181a4e13e17d3a":120:"ab738073228bdf1e8fd4430b5c7d79":"e702f1bb9a1f395c74fca0ce9cdf29e7332c14acaca45200cd432a5767be38929ef8de43d0e1a5e7300c1eb669ac1ab997b31cb1403af8451e77e63505920af0f8c3abf5a9450ea47371039ba1cf2d65a14fa5f013b7ce1d175859404dcf6461a36e8bc260e7abf739d8951ddf1a3754e2d65e0aa31320a5ffca822023bc0906":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4a62ddd87f41c6df756e8da0985dcd8c91e73ba395b3d79b":"37a83ee6dbdece212446739ea353cb957b9aa409c88bee042bbc3a6e5199aeb28f2b4b00ff433c0c68d6db5a197566019db8a4c7a792e2839a19a302ee02bee046adce04c1fbbd5b0c457d7cbe277992ce2c153d132269e2d1f12b084cf3026a202b4664bc9d11832e9b99c7cc5035dcfde5991dd41aeb4fbf8bec5126a9f524":"1d1843e2118772d76a0244a2c33c60bd":"028b92727b75b14cb8dfeb7a86a7fec50cd5de46aa4a34645754918b8606819d4bf8a2e7531a05ae5505492ca6cbc8c0e6d6ab2dea23bff1fdf581bb780b4a3312aa39639383fd10bcf92489801954733f16b021c2e84809345216f8f28a99773341e40c4a64305a2098eaa39f26a93bd556c97f02090e1a6c181a4e13e17d3a":120:"ab738073228bdf1e8fd4430b5c7d79":"":"e702f1bb9a1f395c74fca0ce9cdf29e7332c14acaca45200cd432a5767be38929ef8de43d0e1a5e7300c1eb669ac1ab997b31cb1403af8451e77e63505920af0f8c3abf5a9450ea47371039ba1cf2d65a14fa5f013b7ce1d175859404dcf6461a36e8bc260e7abf739d8951ddf1a3754e2d65e0aa31320a5ffca822023bc0906":0 AES-GCM NIST Validation (AES-192,128,1024,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fc46976d38a581a7042a94ea4b5bfe3587ddc65d1162d71e":"4b9e858fc8f01903e426112192d4ae4686b1ae4d683b75afb2b8c63590275943d0d6d6a23b6d35796a2f101203acba107474ca6f4ff6dd87d6b77785ad1d160ef2755d84092dc70c86db5e639b689943b15efa646aff44b3f51f5d3f4cf6c8f7fc5adfe7bf2d72f75b93b8ee94ef3fa69ea0fc0bb77b3983901fdcd30bcd36f5":"b5e92563dd0339df00b7ffa2239d21bc":"7b6f6e104acbcd7188161477d8e425ff99add22df4d22de7f28d0a0075ca4ef848f68d07ed22d3165c08e40890ce04d1bd05b1a6ccb2fec8193d5f7dffc93d97a0c036b3748f708b011b68247a0249b9e1a60b652164e5c2fd7210377de804ac010c8aa08a11f40af97e8370a59f936cd14c22ea7a236d904145adc04a241fc0":120:"d4356cb417953b01f7b1110c8aa3eb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fc46976d38a581a7042a94ea4b5bfe3587ddc65d1162d71e":"4b9e858fc8f01903e426112192d4ae4686b1ae4d683b75afb2b8c63590275943d0d6d6a23b6d35796a2f101203acba107474ca6f4ff6dd87d6b77785ad1d160ef2755d84092dc70c86db5e639b689943b15efa646aff44b3f51f5d3f4cf6c8f7fc5adfe7bf2d72f75b93b8ee94ef3fa69ea0fc0bb77b3983901fdcd30bcd36f5":"b5e92563dd0339df00b7ffa2239d21bc":"7b6f6e104acbcd7188161477d8e425ff99add22df4d22de7f28d0a0075ca4ef848f68d07ed22d3165c08e40890ce04d1bd05b1a6ccb2fec8193d5f7dffc93d97a0c036b3748f708b011b68247a0249b9e1a60b652164e5c2fd7210377de804ac010c8aa08a11f40af97e8370a59f936cd14c22ea7a236d904145adc04a241fc0":120:"d4356cb417953b01f7b1110c8aa3eb":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"403e49feadd4db763652ed5c4b1e12680cfe0abc30f4696d":"221c61d769febce3913bfead9a201a805f11005ddcac185cbae00ce749de9c4362889b1b0d9546e91598e0ddedb88b673a90acca65d7e71a85636be052f361839a646dc8b834c02f3e2261d370e6bac9636b7536225b5ea77881200c8a3450d21bfd1e11afb3a470e178ecfe944a25a7cd0254e04a42b67723aac8afffd56fee":"1a60258a56e15f92814b4d372255a80d":"a4ffa9e3c612103224c86515dad4343cbca7a7daf277f5828670834f4d9af67b9a935c71b2130dfbc929c4409bffb7974ffa87523b58890770439c33342880b33319c626bf776c1c0aeb9c2a348a7681572f4ff711d94c192f3450e8b1275f9d02c742a2c9f1da316e9918bf787f22699172986cb9b10fc56d5f6b8392ff92b8":112:"62646fc8bfe38b3ba6d62f9011e3":"5c76c90dea7d659804ad873960906259fbdda3614277ec575d9eec730e747a2e7b9df6716b4c38d3451e319eeecee74d1f4918266fc9239de87080f1ad437b47c6904ed2d5514161ad25e3e237655e00e53fe18d452576580e89b2f1f0f6aa7e40a337fd8c48d690fe013a67264a80e9b5dfd009a9152d559aa02a68f401a09b":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"403e49feadd4db763652ed5c4b1e12680cfe0abc30f4696d":"221c61d769febce3913bfead9a201a805f11005ddcac185cbae00ce749de9c4362889b1b0d9546e91598e0ddedb88b673a90acca65d7e71a85636be052f361839a646dc8b834c02f3e2261d370e6bac9636b7536225b5ea77881200c8a3450d21bfd1e11afb3a470e178ecfe944a25a7cd0254e04a42b67723aac8afffd56fee":"1a60258a56e15f92814b4d372255a80d":"a4ffa9e3c612103224c86515dad4343cbca7a7daf277f5828670834f4d9af67b9a935c71b2130dfbc929c4409bffb7974ffa87523b58890770439c33342880b33319c626bf776c1c0aeb9c2a348a7681572f4ff711d94c192f3450e8b1275f9d02c742a2c9f1da316e9918bf787f22699172986cb9b10fc56d5f6b8392ff92b8":112:"62646fc8bfe38b3ba6d62f9011e3":"":"5c76c90dea7d659804ad873960906259fbdda3614277ec575d9eec730e747a2e7b9df6716b4c38d3451e319eeecee74d1f4918266fc9239de87080f1ad437b47c6904ed2d5514161ad25e3e237655e00e53fe18d452576580e89b2f1f0f6aa7e40a337fd8c48d690fe013a67264a80e9b5dfd009a9152d559aa02a68f401a09b":0 AES-GCM NIST Validation (AES-192,128,1024,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c3471259512d1f03ce44c1ddac186e9a56c1434a6ac567c6":"dd5b98b3b3cf03fb92be579068a885afd984630692eb5f155fa6b49f2b1690b803d34b90e8de3cc39c2e61650ffffb51e7ef36d35ad17dc4d91f336363b0734996b162b509c9954cab3dd959bde7e437e9100d84c44104c61e29dbe12492a0272ce6eea2906d390de7808d337e8c650b3301af04a9ed52ab9ea208f3c7439d6c":"50164c63d466148ab371376d5c2b6b72":"11d1f523888bea1fbc680d34bc9b66957d651efa59e788db3d3f6f50e72184b9d14e9ff9bc05fb687520cf423d681812e007025eedf0e78e7e8191e6b62404e8eb400cf837d762a31aa248553367263d6de091fcf7abedc3e69fc118b7efb0594c89b96c387b7c28ed9a7b75db60b6b5133949b891ff81eca5790a265f12a58c":112:"6c5f38232e8a43871ab72a3419ad":"50438ee712720abf2089331e4c058b30c30c3d17834c507c0010ac3f974a256d01b14a45e9ce5193c5cede41330cf31e1a07a1f5e3ceca515cc971bfda0fbe0b823450efc30563e8ed941b0350f146ec75cd31a2c7e1e469c2dd860c0fd5b286219018d4fbacda164a40d2980aa3a27aa95f8b8e2cd8e2f5f20d79a22c3ff028":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c3471259512d1f03ce44c1ddac186e9a56c1434a6ac567c6":"dd5b98b3b3cf03fb92be579068a885afd984630692eb5f155fa6b49f2b1690b803d34b90e8de3cc39c2e61650ffffb51e7ef36d35ad17dc4d91f336363b0734996b162b509c9954cab3dd959bde7e437e9100d84c44104c61e29dbe12492a0272ce6eea2906d390de7808d337e8c650b3301af04a9ed52ab9ea208f3c7439d6c":"50164c63d466148ab371376d5c2b6b72":"11d1f523888bea1fbc680d34bc9b66957d651efa59e788db3d3f6f50e72184b9d14e9ff9bc05fb687520cf423d681812e007025eedf0e78e7e8191e6b62404e8eb400cf837d762a31aa248553367263d6de091fcf7abedc3e69fc118b7efb0594c89b96c387b7c28ed9a7b75db60b6b5133949b891ff81eca5790a265f12a58c":112:"6c5f38232e8a43871ab72a3419ad":"":"50438ee712720abf2089331e4c058b30c30c3d17834c507c0010ac3f974a256d01b14a45e9ce5193c5cede41330cf31e1a07a1f5e3ceca515cc971bfda0fbe0b823450efc30563e8ed941b0350f146ec75cd31a2c7e1e469c2dd860c0fd5b286219018d4fbacda164a40d2980aa3a27aa95f8b8e2cd8e2f5f20d79a22c3ff028":0 AES-GCM NIST Validation (AES-192,128,1024,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ec326a1e0fe6a99421398df4fc7d8fea67b67e5f5fcd50ad":"6d5016c434a0f4b4a5d9e0b6b8e2d848a94f132f055d2d847e54601a4c9cfc5966a654d696f8a3529a48a90b491ea0d31c08eae8ef364f71f8ec7ae7f7e39bb9c331137b2578362ff165628099944ba8deb0d99ac660d5ed2215b9a7626ff1fa6173cd8dd676c988d16c9cf750a0d793f584c3c8f5fd5d167bc278f4d77a629c":"c94aa4baa840a044dbd5942787a0c951":"f8401c578f20d9c250ea86eb945184e007a0190462c7abddf238ce1ceddcc230756aa222386d8ba66ebbba13de008ced140896ac55bc47c231cc81370ca9feadc225e017d59890e6291cc4cca27db3078c0cd6cbb51afb62210226a76837c5454728cb5ce3afe7352e7fe75421f94986e6b7b26321bbca15c75ac7c13dc15f50":112:"3269922affb9d767f5abe041cc8e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ec326a1e0fe6a99421398df4fc7d8fea67b67e5f5fcd50ad":"6d5016c434a0f4b4a5d9e0b6b8e2d848a94f132f055d2d847e54601a4c9cfc5966a654d696f8a3529a48a90b491ea0d31c08eae8ef364f71f8ec7ae7f7e39bb9c331137b2578362ff165628099944ba8deb0d99ac660d5ed2215b9a7626ff1fa6173cd8dd676c988d16c9cf750a0d793f584c3c8f5fd5d167bc278f4d77a629c":"c94aa4baa840a044dbd5942787a0c951":"f8401c578f20d9c250ea86eb945184e007a0190462c7abddf238ce1ceddcc230756aa222386d8ba66ebbba13de008ced140896ac55bc47c231cc81370ca9feadc225e017d59890e6291cc4cca27db3078c0cd6cbb51afb62210226a76837c5454728cb5ce3afe7352e7fe75421f94986e6b7b26321bbca15c75ac7c13dc15f50":112:"3269922affb9d767f5abe041cc8e":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a7ef81652f604e88a72416924c53979dc73cadd3575eda1c":"9ecd19a8eba9fba843486e1bbfb8d9053c5e04b24e30174d4aa89d8307439d653f8630edddafd51719c744bcb4bce3e444847567bd2cdde2995870d0634cc0ba2bde4b6bc2bc583062fb83874a1c25b50aeb945bd109a151772c077438c4d1caaeb5b0c56390ac23c6d117f3a00fd616306fc2ffc4c1e76f934b30fbbc52eec2":"0cc9ae54c9a85f3e9325c5f3658ab3b2":"d0195b744351aa25a57a99df9573dfa3cebe9850139149b64f7e4af37756a430dda8af98e4ed480e913aa82821c01c1f75b187e105a8f39621757d522c083a8d81d7d8bfe6cf15c439d0692b6affd655a11bcd2457046fae996a1075c66029867b88cd23c503ae04037dd41f27bafd5000d1f516002f9fcc0f2500e8c1b27de0":104:"22c2efeddfd5d9cb528861c4eb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a7ef81652f604e88a72416924c53979dc73cadd3575eda1c":"9ecd19a8eba9fba843486e1bbfb8d9053c5e04b24e30174d4aa89d8307439d653f8630edddafd51719c744bcb4bce3e444847567bd2cdde2995870d0634cc0ba2bde4b6bc2bc583062fb83874a1c25b50aeb945bd109a151772c077438c4d1caaeb5b0c56390ac23c6d117f3a00fd616306fc2ffc4c1e76f934b30fbbc52eec2":"0cc9ae54c9a85f3e9325c5f3658ab3b2":"d0195b744351aa25a57a99df9573dfa3cebe9850139149b64f7e4af37756a430dda8af98e4ed480e913aa82821c01c1f75b187e105a8f39621757d522c083a8d81d7d8bfe6cf15c439d0692b6affd655a11bcd2457046fae996a1075c66029867b88cd23c503ae04037dd41f27bafd5000d1f516002f9fcc0f2500e8c1b27de0":104:"22c2efeddfd5d9cb528861c4eb":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"605271a41e263c92dc14fe9df5203e79d58cc2d1289dc361":"2bda3448a283ecba31e0299c0a9e44628cb2b41fa7b1a41107e107cabc381083bdbe048f2804568fdd5fe016f4d607f694042a459ba03a2deda4cccc8cbe4612d8ed0d4575e48bc9f59843369dbe2af6d048e65ff4250e1eef61d7b1b378fe2f3305b133ddc7e37d95ca6de89a971730fc80da943a767ff137707a8d8a24329c":"7f128092a777fc503adc7f6b85eb2006":"aef9f984fb645e08d5f0aa07a31c114d2f8e9eca047e4a8d5471378cfc2ced1159dc093d174788e58447a854be58942ed9a3fd45f3f4a1af7351e087369a267797c525f134e79709097e733b9003b9be0c569fc70ee3462b815b6410e19954ce2efac121300c06fd9e00542a9c6a5a682fe1010c145acbbb8b82333bdb5ddfd9":104:"673afea592b2ce16bd058469f1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"605271a41e263c92dc14fe9df5203e79d58cc2d1289dc361":"2bda3448a283ecba31e0299c0a9e44628cb2b41fa7b1a41107e107cabc381083bdbe048f2804568fdd5fe016f4d607f694042a459ba03a2deda4cccc8cbe4612d8ed0d4575e48bc9f59843369dbe2af6d048e65ff4250e1eef61d7b1b378fe2f3305b133ddc7e37d95ca6de89a971730fc80da943a767ff137707a8d8a24329c":"7f128092a777fc503adc7f6b85eb2006":"aef9f984fb645e08d5f0aa07a31c114d2f8e9eca047e4a8d5471378cfc2ced1159dc093d174788e58447a854be58942ed9a3fd45f3f4a1af7351e087369a267797c525f134e79709097e733b9003b9be0c569fc70ee3462b815b6410e19954ce2efac121300c06fd9e00542a9c6a5a682fe1010c145acbbb8b82333bdb5ddfd9":104:"673afea592b2ce16bd058469f1":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fa076f36cb678e2275561e9553ebdf397360e5a5e44791c4":"513305e86c0cb046c5d3720b25a406392766bd1fb7de2758de370ff2e68281e211922890c61f3659460f22c45a57895b424441262a3ba0606df4e2701f38281fd3436a4d0e0f8efecd231808a9ea063dfb725015a91f27cadfe7909a0ee109eac391ac807afed1767ae0515b9c1b51ae9a48b38fe7fec7fe0ddee562c945e5ae":"1ecd53d94fe287047ff184e8b9b71a26":"5ff25f7bac5f76f533f9edffdfd2b2991d7fc4cd5a0452a1031da6094cd498297fb2a05ae8db71cb3451e4ac33a01172619035a9621d2d54f812ef5343e14b9dedc93838e4cf30e223d215b4d2476ea961a17ac7295069f25b2a12d6e2efe76d91f45632c6d4e61ff19a95d5ae36af960d95050ce98b5791df0b7e322411c884":104:"079e8db9c3e6eddb0335b1cf64":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fa076f36cb678e2275561e9553ebdf397360e5a5e44791c4":"513305e86c0cb046c5d3720b25a406392766bd1fb7de2758de370ff2e68281e211922890c61f3659460f22c45a57895b424441262a3ba0606df4e2701f38281fd3436a4d0e0f8efecd231808a9ea063dfb725015a91f27cadfe7909a0ee109eac391ac807afed1767ae0515b9c1b51ae9a48b38fe7fec7fe0ddee562c945e5ae":"1ecd53d94fe287047ff184e8b9b71a26":"5ff25f7bac5f76f533f9edffdfd2b2991d7fc4cd5a0452a1031da6094cd498297fb2a05ae8db71cb3451e4ac33a01172619035a9621d2d54f812ef5343e14b9dedc93838e4cf30e223d215b4d2476ea961a17ac7295069f25b2a12d6e2efe76d91f45632c6d4e61ff19a95d5ae36af960d95050ce98b5791df0b7e322411c884":104:"079e8db9c3e6eddb0335b1cf64":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ce9dafa0e7e53a8766fc0bc38fba807d04e14e5ed61bc234":"b585b8bf634757dac015f2f69f2ae674372a664f2115ad2d03bd3e0c335306b02d0947d3cda5991f5c0c25f12ead2c3cc2d65d575fd67091c70bc93ddb4b1e21f7b0fc6e6ae652dea93a6564ff13489f927942e64dd94bf8f821c7ffdef16df58bd8306a957821ac256da6f19c9d96e48eee87f88acb83bae05d693b70b9337b":"fd0751af49814ee98b2b0cdf730adaa6":"1cba488a0fc8a012f9a336cc7b01cbcc504178eeb08237dbedbc6c7ac68fdf3a6742751a207e43d43068abf6ef4e12a5e3c17e5a2f9398fc04ced67377cbb858fd6020fad675a880adb249e4aba94b96efa515d1cdf5c0c3071a27a3245968867ea94b2bfc2028a67be34c84c3f475944497aa8ca1ab009f8e4b11c8308c1996":96:"e5dc92f4ad4000e9b62fb637":"95f4324b0656bef19eca5570548fc6a7a9923f4e2a7e42066891bc132fd73bc1c9089755d996756de0072824e69c43f2db8ba2bf6f90d3c4eafc0721ceaccce1af896f9fb15fb19c4746979b6d945f593fad61d550f81d12b5945ed728c02931d7f8d917285c22a3af748d75a6bf163fddd84b941d8564c1a63192c816ad6d6d":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ce9dafa0e7e53a8766fc0bc38fba807d04e14e5ed61bc234":"b585b8bf634757dac015f2f69f2ae674372a664f2115ad2d03bd3e0c335306b02d0947d3cda5991f5c0c25f12ead2c3cc2d65d575fd67091c70bc93ddb4b1e21f7b0fc6e6ae652dea93a6564ff13489f927942e64dd94bf8f821c7ffdef16df58bd8306a957821ac256da6f19c9d96e48eee87f88acb83bae05d693b70b9337b":"fd0751af49814ee98b2b0cdf730adaa6":"1cba488a0fc8a012f9a336cc7b01cbcc504178eeb08237dbedbc6c7ac68fdf3a6742751a207e43d43068abf6ef4e12a5e3c17e5a2f9398fc04ced67377cbb858fd6020fad675a880adb249e4aba94b96efa515d1cdf5c0c3071a27a3245968867ea94b2bfc2028a67be34c84c3f475944497aa8ca1ab009f8e4b11c8308c1996":96:"e5dc92f4ad4000e9b62fb637":"":"95f4324b0656bef19eca5570548fc6a7a9923f4e2a7e42066891bc132fd73bc1c9089755d996756de0072824e69c43f2db8ba2bf6f90d3c4eafc0721ceaccce1af896f9fb15fb19c4746979b6d945f593fad61d550f81d12b5945ed728c02931d7f8d917285c22a3af748d75a6bf163fddd84b941d8564c1a63192c816ad6d6d":0 AES-GCM NIST Validation (AES-192,128,1024,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8a328554fed68dc4838fbc89fd162c99ec105b36651abbc9":"75986f56972c045c850ed68aeb229f203b228fdfc36cad6b16d9bd12037c48700d20d8062a983ffeca76b8d36a67ef51bc8853706e83a34e4e23ff4f4a4eb943f19dbe85e454043d7906be6587a85079f9ccd27962d2905117d2dbeaf725d6ffe87bef52b2138da153ef29b18065b3342b3f9d07837d57b8bc5f2597de06c54f":"e4f7c69a1d026eeebfc45e77bd7b3538":"e349dcedb0bfcc771c820f0d510b80cef32ae3326484e25aa183015941e7844bc46f617d5e61fd64fa71759e90fcb72ae220bcd507f0fb389b689dd3fa29b3b937eded85f26ada9e0f3f5109f82fef47c7eba7313049750ad17969e7550c0d4093ed18ee27843d082bcee8bf3fc7833d569b7723998595a5a1d871089fd238da":96:"8e8320912fff628f47e92430":"a1ed65cfc7e1aeccd0531bce1dc749c7aa84451ec0f29856f12f22c4105888c7d62e2e2fc8ad7a62748610b16e57490f061ad063c88800037d7244ee59e109d445205280473390336d7b6089f3a78218447b1b2398c4d0b3aac8b57a35891ad60dc1b69ad75e2e86248ceac7bb4cf3caade4a896e5ee8c76893ef990f6f65266":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8a328554fed68dc4838fbc89fd162c99ec105b36651abbc9":"75986f56972c045c850ed68aeb229f203b228fdfc36cad6b16d9bd12037c48700d20d8062a983ffeca76b8d36a67ef51bc8853706e83a34e4e23ff4f4a4eb943f19dbe85e454043d7906be6587a85079f9ccd27962d2905117d2dbeaf725d6ffe87bef52b2138da153ef29b18065b3342b3f9d07837d57b8bc5f2597de06c54f":"e4f7c69a1d026eeebfc45e77bd7b3538":"e349dcedb0bfcc771c820f0d510b80cef32ae3326484e25aa183015941e7844bc46f617d5e61fd64fa71759e90fcb72ae220bcd507f0fb389b689dd3fa29b3b937eded85f26ada9e0f3f5109f82fef47c7eba7313049750ad17969e7550c0d4093ed18ee27843d082bcee8bf3fc7833d569b7723998595a5a1d871089fd238da":96:"8e8320912fff628f47e92430":"":"a1ed65cfc7e1aeccd0531bce1dc749c7aa84451ec0f29856f12f22c4105888c7d62e2e2fc8ad7a62748610b16e57490f061ad063c88800037d7244ee59e109d445205280473390336d7b6089f3a78218447b1b2398c4d0b3aac8b57a35891ad60dc1b69ad75e2e86248ceac7bb4cf3caade4a896e5ee8c76893ef990f6f65266":0 AES-GCM NIST Validation (AES-192,128,1024,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6e7f6feb4022312de5c804ed1d7a37580d74499107f8cc8b":"4f5bbdf575ab8f778549f749f2265e17dc7225713e73ee6d7be163ff7071557dcc2240b0705c079008605f81396414ac64f06b1b637876e04c3fca8d0fa576cef4dd3dc553fd6808eaf120f837f9bb1d9dbbd5cf67ed497167fc7db89d3a84151b81aeab0e921057f121583df5ed7f976b206ece17a913f23485385f64c462a8":"6ce13485ffbc80567b02dd542344d7ef":"c6804a2bd8c34de14fe485c8b7caa2564adaf9fcbb754bd2cc1d88ba9183f13d110c762a3c5d2afc0fbc80aedcb91e45efe43d9320075420ee85ab22505f20e77fa4624b0387346c1bd944e9cd54055b5135c7fc92e85390ecf45a7091136b47e3d68d9076594cfad36c36047538e652178c375a2fe59a246a79784577860189":96:"974bd0c4a8cac1563a0e0ce0":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6e7f6feb4022312de5c804ed1d7a37580d74499107f8cc8b":"4f5bbdf575ab8f778549f749f2265e17dc7225713e73ee6d7be163ff7071557dcc2240b0705c079008605f81396414ac64f06b1b637876e04c3fca8d0fa576cef4dd3dc553fd6808eaf120f837f9bb1d9dbbd5cf67ed497167fc7db89d3a84151b81aeab0e921057f121583df5ed7f976b206ece17a913f23485385f64c462a8":"6ce13485ffbc80567b02dd542344d7ef":"c6804a2bd8c34de14fe485c8b7caa2564adaf9fcbb754bd2cc1d88ba9183f13d110c762a3c5d2afc0fbc80aedcb91e45efe43d9320075420ee85ab22505f20e77fa4624b0387346c1bd944e9cd54055b5135c7fc92e85390ecf45a7091136b47e3d68d9076594cfad36c36047538e652178c375a2fe59a246a79784577860189":96:"974bd0c4a8cac1563a0e0ce0":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"46d6e982feff0e7d04a84384c56739b69626dde500e4b7fb":"a5160fb2d397b55a7eba02df33a042404188f02f4492d46f4edc03fc67723d64f5f7fed3a60728438703c60454a30f473ac918ffc8f98be5c5e9779ee984415e415ce3c71f9acc3f808d215be58535d3144cebe7982b9b527edbe41446161094d6fc74dec2e0a1c644bbc2cf5779a22bd4117a7edb11d13e35e95feeb418d3f0":"71a6d1e022a6bdff6460c674fb0cf048":"67a8455c7d3fbfdba3c5ec5f40e0be935fbb9417e805771832ffad06ba38a61b8377997af1f586dc0fa1e3da0b39facd520db1f0ec2bdf1904a3a897f0b507c901fab30a85de51effa9f7d4703ceeb2ca72abe0bd146ba0bd3ffdee11628310db7d65ea1343b018084ea2414995f86fefb45ba91a9dc2236d92078b4305671b5":64:"84f1efd34ff84e83":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"46d6e982feff0e7d04a84384c56739b69626dde500e4b7fb":"a5160fb2d397b55a7eba02df33a042404188f02f4492d46f4edc03fc67723d64f5f7fed3a60728438703c60454a30f473ac918ffc8f98be5c5e9779ee984415e415ce3c71f9acc3f808d215be58535d3144cebe7982b9b527edbe41446161094d6fc74dec2e0a1c644bbc2cf5779a22bd4117a7edb11d13e35e95feeb418d3f0":"71a6d1e022a6bdff6460c674fb0cf048":"67a8455c7d3fbfdba3c5ec5f40e0be935fbb9417e805771832ffad06ba38a61b8377997af1f586dc0fa1e3da0b39facd520db1f0ec2bdf1904a3a897f0b507c901fab30a85de51effa9f7d4703ceeb2ca72abe0bd146ba0bd3ffdee11628310db7d65ea1343b018084ea2414995f86fefb45ba91a9dc2236d92078b4305671b5":64:"84f1efd34ff84e83":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"991dcaa2e8fdad2b4e6e462a3c06c96067ef5e9fb133496a":"9cd0c27f0c2011c1ab947400d28516c7f46d22a409a18fd35c1babf693b8030dfd7822d9ba03bb8fd56a00f9c7149c056640dde690889d2f23978eeeb28ccc26e2fc251220a3682c963f5580c654c1a6736cccb1b8ed104ec7390021d244bd9f92abde89e39a4b83eff8211c8a6259bd6ac2af1da7dfb8cf1355238056c60381":"978913d2c822ba7cc758041d5ee46759":"5a94dc81af011a8af263318b60215b9752292b194b89f6fc013b0fe8e29133de631d981862f2c131ee34905bd93caffc3b8f91aeb0264b27a509e5c6a41ae781209f8c5895d0d35b3c5e1ae34a1a92a2b979e0e62132051394940ea4d9bfffb8d89ba1e8331b15bdf05c41db83a57745a4a651a757cc8648acdcf850a2f25367":64:"15d456da7645abf2":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"991dcaa2e8fdad2b4e6e462a3c06c96067ef5e9fb133496a":"9cd0c27f0c2011c1ab947400d28516c7f46d22a409a18fd35c1babf693b8030dfd7822d9ba03bb8fd56a00f9c7149c056640dde690889d2f23978eeeb28ccc26e2fc251220a3682c963f5580c654c1a6736cccb1b8ed104ec7390021d244bd9f92abde89e39a4b83eff8211c8a6259bd6ac2af1da7dfb8cf1355238056c60381":"978913d2c822ba7cc758041d5ee46759":"5a94dc81af011a8af263318b60215b9752292b194b89f6fc013b0fe8e29133de631d981862f2c131ee34905bd93caffc3b8f91aeb0264b27a509e5c6a41ae781209f8c5895d0d35b3c5e1ae34a1a92a2b979e0e62132051394940ea4d9bfffb8d89ba1e8331b15bdf05c41db83a57745a4a651a757cc8648acdcf850a2f25367":64:"15d456da7645abf2":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f29cff00781f5916930f125489c87d21f6593324d1506f65":"a3e8595747b7147d471ac4fe38014bf4a409931e3f419ff88ae249ba7a7f51bd0ede371bf153bab4b28020b7a82a8ca30b75f1e3bcfee3c13db813cbc85138ef05874dedb14a6e5b6d06d7589a83bd5e052dc64433a8e24c1188b9470ddb2536d13b4b7bff0c5afcfaa9aa0157c3aae3b1774df2df14f965d6dee4332edba67e":"50db7ee25a9f815c784236f908bfd7f2":"ec1482e18692bcd6894a364c4a6abb9c3b9818bb17e5e1fc9ec0b41702c423f3a60907e94c888fad8e78f51e1f724b39969ba7b11d31b503504b304d5c4b4cbd42634f4ec5080a9fe51c82e121ae191270dd2c307af84c82d892d982413a50ccce33698054f761a3fa93da9a1fca321296b378a50d458ba78e57a70da4676150":64:"a1e19ef2f0d4b9f1":"eea18261a4de31d8619e77005ebbb3998c5dcfac2bc120ae465e29d6b4c46de7e6c044c8b148ffe4eda7629c243df8af4e7ceb512d5751a3ee58defb0690b6f26b51086dedfde38748f6f0bbe6b495f4304373188e5d2dc93461bd51bf720149a7d3aa543623b122b9af0123b2cdc9020136b041a49498ec4aa696c2d3c46d06":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f29cff00781f5916930f125489c87d21f6593324d1506f65":"a3e8595747b7147d471ac4fe38014bf4a409931e3f419ff88ae249ba7a7f51bd0ede371bf153bab4b28020b7a82a8ca30b75f1e3bcfee3c13db813cbc85138ef05874dedb14a6e5b6d06d7589a83bd5e052dc64433a8e24c1188b9470ddb2536d13b4b7bff0c5afcfaa9aa0157c3aae3b1774df2df14f965d6dee4332edba67e":"50db7ee25a9f815c784236f908bfd7f2":"ec1482e18692bcd6894a364c4a6abb9c3b9818bb17e5e1fc9ec0b41702c423f3a60907e94c888fad8e78f51e1f724b39969ba7b11d31b503504b304d5c4b4cbd42634f4ec5080a9fe51c82e121ae191270dd2c307af84c82d892d982413a50ccce33698054f761a3fa93da9a1fca321296b378a50d458ba78e57a70da4676150":64:"a1e19ef2f0d4b9f1":"":"eea18261a4de31d8619e77005ebbb3998c5dcfac2bc120ae465e29d6b4c46de7e6c044c8b148ffe4eda7629c243df8af4e7ceb512d5751a3ee58defb0690b6f26b51086dedfde38748f6f0bbe6b495f4304373188e5d2dc93461bd51bf720149a7d3aa543623b122b9af0123b2cdc9020136b041a49498ec4aa696c2d3c46d06":0 AES-GCM NIST Validation (AES-192,128,1024,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2087e14092dad6df8996715cb1cfca90094f030328080ffd":"6d039513061980fb195bdf2f7c7079ca4b7e0fdd50d948cbfab5ba10b99e3aea27f08abd000c428851de82cacb0d64c146cd9567e9d55b89819876d6a635bd68bcaf47ffa41e02d9ee97f5a2363bfe6131ae7a21ea5130ae953a64d57d6cbfd45260c5f1946388d445ce97d23ab7ba31a5069a4896bc940a71de32bde02bc18d":"d30504afb6f8b6ac444b4a76115d79d1":"d95845d268c8d8f9135d310c39e30f55f83ef7ffee69e6ba1f80d08e92ed473b5ac12cc8f7a872bfc8b325e6b8e374609c90beaf52d975f71caeef5ee4c13de08dce80d358ee1cd091faea209a24e3392adcfe01aeb2b2e1738bc75d4a9b7cd31df7f878141cf278d150f6faa83fb3a2fd1225542a39c900606c602f15c06a4f":32:"5412f25c":"1e81a4c10a3440d0002ddc1bfa42ebb08e504fcc8f0497915c51b6f5f75fee3f0cd3e9c5a81ff6528e0fecd68a36192114f17fa1a4cfe21918dac46e3ba1383c2678c7a6889a980024ee2a21bcf737f7723b5735e1ebe78996f7c7eace2802ebb8284216867d73b53a370a57d5b587d070a96db34b5b4f5afe7f39830498c112":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2087e14092dad6df8996715cb1cfca90094f030328080ffd":"6d039513061980fb195bdf2f7c7079ca4b7e0fdd50d948cbfab5ba10b99e3aea27f08abd000c428851de82cacb0d64c146cd9567e9d55b89819876d6a635bd68bcaf47ffa41e02d9ee97f5a2363bfe6131ae7a21ea5130ae953a64d57d6cbfd45260c5f1946388d445ce97d23ab7ba31a5069a4896bc940a71de32bde02bc18d":"d30504afb6f8b6ac444b4a76115d79d1":"d95845d268c8d8f9135d310c39e30f55f83ef7ffee69e6ba1f80d08e92ed473b5ac12cc8f7a872bfc8b325e6b8e374609c90beaf52d975f71caeef5ee4c13de08dce80d358ee1cd091faea209a24e3392adcfe01aeb2b2e1738bc75d4a9b7cd31df7f878141cf278d150f6faa83fb3a2fd1225542a39c900606c602f15c06a4f":32:"5412f25c":"":"1e81a4c10a3440d0002ddc1bfa42ebb08e504fcc8f0497915c51b6f5f75fee3f0cd3e9c5a81ff6528e0fecd68a36192114f17fa1a4cfe21918dac46e3ba1383c2678c7a6889a980024ee2a21bcf737f7723b5735e1ebe78996f7c7eace2802ebb8284216867d73b53a370a57d5b587d070a96db34b5b4f5afe7f39830498c112":0 AES-GCM NIST Validation (AES-192,128,1024,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3fc76d627c775de2f789279dc7b67979a9f1cc23c8dcabc9":"92a60d38fc687b92d44635aafee416a142d11a025680e5aa42e9ba5aa010462991ad3dd7328ca4a693673410f9bba37f05a551b949ab0d43fc61ef3b8996dd3fc1b325e66eec6cc61ea667500f82a83e699756a139d14be6ca9747ed38cd9b1d9da032ece311331bdcd698666ddc970b8be2b746ec55fe60e65d7ae47c6f853c":"8f6fd53eb97e12dcd4d40f2843e25365":"e56995df73e52606a11de9df6c7bfb0ef93b86bf6766e319aea59372060294b0e1b13c6288c2310a4bef725a2dddb174f3e1228649861757903c4497a0eec9c141454fc75f101439a2150e368857c4f0f6e5161c42c77f632bf1c229a52595cbf16e9018de9a8f6a1e6b8b18bd244f93f001eb2eb315405d223c0d27ece9d4d9":32:"613ba486":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3fc76d627c775de2f789279dc7b67979a9f1cc23c8dcabc9":"92a60d38fc687b92d44635aafee416a142d11a025680e5aa42e9ba5aa010462991ad3dd7328ca4a693673410f9bba37f05a551b949ab0d43fc61ef3b8996dd3fc1b325e66eec6cc61ea667500f82a83e699756a139d14be6ca9747ed38cd9b1d9da032ece311331bdcd698666ddc970b8be2b746ec55fe60e65d7ae47c6f853c":"8f6fd53eb97e12dcd4d40f2843e25365":"e56995df73e52606a11de9df6c7bfb0ef93b86bf6766e319aea59372060294b0e1b13c6288c2310a4bef725a2dddb174f3e1228649861757903c4497a0eec9c141454fc75f101439a2150e368857c4f0f6e5161c42c77f632bf1c229a52595cbf16e9018de9a8f6a1e6b8b18bd244f93f001eb2eb315405d223c0d27ece9d4d9":32:"613ba486":"FAIL":"":0 AES-GCM NIST Validation (AES-192,128,1024,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b10979797fb8f418a126120d45106e1779b4538751a19bf6":"e3dc64e3c02731fe6e6ec0e899183018da347bf8bd476aa7746d7a7729d83a95f64bb732ba987468d0cede154e28169f7bafa36559200795037ee38279e0e4ca40f9cfa85aa0c8035df9649345c8fdffd1c31528b485dfe443c1923180cc8fae5196d16f822be4ad07e3f1234e1d218e7c8fb37a0e4480dc6717c9c09ff5c45f":"ca362e615024a1fe11286668646cc1de":"237d95d86a5ad46035870f576a1757eded636c7234d5ed0f8039f6f59f1333cc31cb893170d1baa98bd4e79576de920120ead0fdecfb343edbc2fcc556540a91607388a05d43bdb8b55f1327552feed3b620614dfcccb2b342083896cbc81dc9670b761add998913ca813163708a45974e6d7b56dfd0511a72eb879f239d6a6d":32:"28d730ea":"dafde27aa8b3076bfa16ab1d89207d339c4997f8a756cc3eb62c0b023976de808ab640ba4467f2b2ea83d238861229c73387594cd43770386512ea595a70888b4c38863472279e06b923e7cf32438199b3e054ac4bc21baa8df39ddaa207ebb17fa4cad6e83ea58c3a92ec74e6e01b0a8979af145dd31d5df29750bb91b42d45":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b10979797fb8f418a126120d45106e1779b4538751a19bf6":"e3dc64e3c02731fe6e6ec0e899183018da347bf8bd476aa7746d7a7729d83a95f64bb732ba987468d0cede154e28169f7bafa36559200795037ee38279e0e4ca40f9cfa85aa0c8035df9649345c8fdffd1c31528b485dfe443c1923180cc8fae5196d16f822be4ad07e3f1234e1d218e7c8fb37a0e4480dc6717c9c09ff5c45f":"ca362e615024a1fe11286668646cc1de":"237d95d86a5ad46035870f576a1757eded636c7234d5ed0f8039f6f59f1333cc31cb893170d1baa98bd4e79576de920120ead0fdecfb343edbc2fcc556540a91607388a05d43bdb8b55f1327552feed3b620614dfcccb2b342083896cbc81dc9670b761add998913ca813163708a45974e6d7b56dfd0511a72eb879f239d6a6d":32:"28d730ea":"":"dafde27aa8b3076bfa16ab1d89207d339c4997f8a756cc3eb62c0b023976de808ab640ba4467f2b2ea83d238861229c73387594cd43770386512ea595a70888b4c38863472279e06b923e7cf32438199b3e054ac4bc21baa8df39ddaa207ebb17fa4cad6e83ea58c3a92ec74e6e01b0a8979af145dd31d5df29750bb91b42d45":0 AES-GCM Bad IV (AES-192,128,0,0,32) #0 depends_on:MBEDTLS_AES_C diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes256_de.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes256_de.data index 9696a62be3..d207212276 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes256_de.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.aes256_de.data @@ -1,674 +1,674 @@ AES-GCM NIST Validation (AES-256,128,0,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c186654406b2b92c9639a7189d4ab5ab0b9bb87c43005027f3fa832fd3507b1":"":"3a0324d63a70400490c92e7604a3ba97":"":128:"4c61cd2e28a13d78a4e87ea7374dd01a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c186654406b2b92c9639a7189d4ab5ab0b9bb87c43005027f3fa832fd3507b1":"":"3a0324d63a70400490c92e7604a3ba97":"":128:"4c61cd2e28a13d78a4e87ea7374dd01a":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"747d01d82d7382b4263e7cbf25bd198a8a92faabf8d7367584c7e2fa506e9c5f":"":"7156358b203a44ef173706fdc81900f8":"":128:"9687fb231c4742a74d6bf78c62b8ac53":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"747d01d82d7382b4263e7cbf25bd198a8a92faabf8d7367584c7e2fa506e9c5f":"":"7156358b203a44ef173706fdc81900f8":"":128:"9687fb231c4742a74d6bf78c62b8ac53":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cbe30216136b7eaf223e6a7b46c06625176d9a08182fa806a63d8b143aa768b":"":"4fe6ace582c4e26ce71ee7f756fb7a88":"":128:"d5bdf8ec2896acafb7022708d74646c7":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cbe30216136b7eaf223e6a7b46c06625176d9a08182fa806a63d8b143aa768b":"":"4fe6ace582c4e26ce71ee7f756fb7a88":"":128:"d5bdf8ec2896acafb7022708d74646c7":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f31194c83bb8da979a1eabb3337ceb3d38a663790da74380d8f94142ab8b8797":"":"404efd26b665c97ea75437892cf676b6":"":120:"e491075851eec28c723159cc1b2c76":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f31194c83bb8da979a1eabb3337ceb3d38a663790da74380d8f94142ab8b8797":"":"404efd26b665c97ea75437892cf676b6":"":120:"e491075851eec28c723159cc1b2c76":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"daeed52ae4bf5cbe1ad58ae4ccb3da81fb9c0b6f7619ca21979313ad9d3e83c1":"":"4037eadb11249884b6b38b5525ba2df4":"":120:"360c6ef41cbd9cd4a4e649712d2930":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"daeed52ae4bf5cbe1ad58ae4ccb3da81fb9c0b6f7619ca21979313ad9d3e83c1":"":"4037eadb11249884b6b38b5525ba2df4":"":120:"360c6ef41cbd9cd4a4e649712d2930":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3ad81c34389406a965c60edb3214663ac4a6bd5cfd154ae8d9dc86dae93def64":"":"cebbce06a88852d3bb2978dbe2b5995a":"":120:"bd7ca9f6bd1099cde87c0f0d7cc887":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3ad81c34389406a965c60edb3214663ac4a6bd5cfd154ae8d9dc86dae93def64":"":"cebbce06a88852d3bb2978dbe2b5995a":"":120:"bd7ca9f6bd1099cde87c0f0d7cc887":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4c152ba30aefa5b2a08b0b4d9bf3f16fc208bb0bc4c4eca9411dc262d9276bad":"":"008d040fbd7342464209f330cf56722c":"":112:"c87107585751e666bedae2b1b7e8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4c152ba30aefa5b2a08b0b4d9bf3f16fc208bb0bc4c4eca9411dc262d9276bad":"":"008d040fbd7342464209f330cf56722c":"":112:"c87107585751e666bedae2b1b7e8":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9aed4ae6b1d857fdcbe5aec6db38440613dcc49f24aa31fba1f300b2585723f1":"":"947c5f0432723f2d7b560eca90842df1":"":112:"7d331fedcea0fd1e9e6a84385467":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9aed4ae6b1d857fdcbe5aec6db38440613dcc49f24aa31fba1f300b2585723f1":"":"947c5f0432723f2d7b560eca90842df1":"":112:"7d331fedcea0fd1e9e6a84385467":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cc80bc031676eff5f34dd076388a5130e985f9e06df4b4bf8490ff9ff20aae73":"":"51f639467083377795111d44f7d16592":"":112:"02d31f29e15f60ae3bee1ad7ea65":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cc80bc031676eff5f34dd076388a5130e985f9e06df4b4bf8490ff9ff20aae73":"":"51f639467083377795111d44f7d16592":"":112:"02d31f29e15f60ae3bee1ad7ea65":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"db7a40213b5b4b07e9900dc28f599403b0579cbce13fcd44dff090062f952686":"":"aea6f8690f865bca9f77a5ff843d2365":"":104:"7f2280776d6cd6802b3c85083c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"db7a40213b5b4b07e9900dc28f599403b0579cbce13fcd44dff090062f952686":"":"aea6f8690f865bca9f77a5ff843d2365":"":104:"7f2280776d6cd6802b3c85083c":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"299b874eaa8b7baf769f81f4988a41e2708ae928e69a5ba7b893e8e6b2db5c3b":"":"2aa04d85d2c0dc6f5294cb71c0d89ac1":"":104:"ea01723a22838ed65ceb80b1cf":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"299b874eaa8b7baf769f81f4988a41e2708ae928e69a5ba7b893e8e6b2db5c3b":"":"2aa04d85d2c0dc6f5294cb71c0d89ac1":"":104:"ea01723a22838ed65ceb80b1cf":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a6c7b4c8175db4cf23d0593ed8ea949043880fc02e2725f0ab90ae638f9dcfce":"":"ae07f8c7ac82c4f4c086e04a20db12bc":"":104:"1132e4fff06db51ff135ed9ced":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a6c7b4c8175db4cf23d0593ed8ea949043880fc02e2725f0ab90ae638f9dcfce":"":"ae07f8c7ac82c4f4c086e04a20db12bc":"":104:"1132e4fff06db51ff135ed9ced":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b98e1bf76828b65a81005449971fdc8b11be546d31de6616cd73c5813050c326":"":"929b006eb30d69b49a7f52392d7d3f11":"":96:"33940d330f7c019a57b74f2d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b98e1bf76828b65a81005449971fdc8b11be546d31de6616cd73c5813050c326":"":"929b006eb30d69b49a7f52392d7d3f11":"":96:"33940d330f7c019a57b74f2d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"09ccef64ae761a70fe16772cba462b058a69477c91595de26a5f1bd637c3816f":"":"e34b19381f05693f7606ce043626664d":"":96:"2adc2c45947bfa7faa5c464a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"09ccef64ae761a70fe16772cba462b058a69477c91595de26a5f1bd637c3816f":"":"e34b19381f05693f7606ce043626664d":"":96:"2adc2c45947bfa7faa5c464a":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"654cf46598e5ad3e243472a459bcd80f1e026a65429352dbd56e73fcc5895d1c":"":"a56f27709e670b85e5917d5c1d5b0cc2":"":96:"177b9a5e6d9731419dd33c5c":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"654cf46598e5ad3e243472a459bcd80f1e026a65429352dbd56e73fcc5895d1c":"":"a56f27709e670b85e5917d5c1d5b0cc2":"":96:"177b9a5e6d9731419dd33c5c":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"84bca1b2768b9202bf194f2d5e5a0a5f51fd8bb725f2bab8a3fccbdb64a4ea70":"":"c45b2708c5bdf65ec6cc66b6dfb3623b":"":64:"fe82300adffd8c17":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"84bca1b2768b9202bf194f2d5e5a0a5f51fd8bb725f2bab8a3fccbdb64a4ea70":"":"c45b2708c5bdf65ec6cc66b6dfb3623b":"":64:"fe82300adffd8c17":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c8ae011795c9a60ad7660a31fe354fa6f7e9c2724d7a126436291680cd95c007":"":"1bd9ea6186450f9cd253ccfed2812b1c":"":64:"35214bbc510430e3":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c8ae011795c9a60ad7660a31fe354fa6f7e9c2724d7a126436291680cd95c007":"":"1bd9ea6186450f9cd253ccfed2812b1c":"":64:"35214bbc510430e3":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"df2f0a8a3849f497d12bda44e12ce30a6957f3febcd5ec9bc134171326ca66d3":"":"728cb9608b67a489a382aa677b1f4f5b":"":64:"e2ef5d9cc5791c01":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"df2f0a8a3849f497d12bda44e12ce30a6957f3febcd5ec9bc134171326ca66d3":"":"728cb9608b67a489a382aa677b1f4f5b":"":64:"e2ef5d9cc5791c01":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"78e8a8ad1ecd17446cf9cd9c56facfd4e10faf5762da0fd0da177f6a9b9c3a71":"":"f169ce6f3ccc58f6434ae2b8ad1a63a1":"":32:"0fe57572":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"78e8a8ad1ecd17446cf9cd9c56facfd4e10faf5762da0fd0da177f6a9b9c3a71":"":"f169ce6f3ccc58f6434ae2b8ad1a63a1":"":32:"0fe57572":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"02ca6d8a862e25db9d68e4404abc107e700135df4157cfb135ce98eaa33151c9":"":"7b722fdd43cff20832812f9baf2d6791":"":32:"72dea6cc":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"02ca6d8a862e25db9d68e4404abc107e700135df4157cfb135ce98eaa33151c9":"":"7b722fdd43cff20832812f9baf2d6791":"":32:"72dea6cc":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a2b709dbcc3a4fb15b3ad541fb008c381b7e985b57df52f07ca7cd26ab1ecc4":"":"729baa4c0ef75ed8aae746376b39fe3c":"":32:"2a0d607c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9a2b709dbcc3a4fb15b3ad541fb008c381b7e985b57df52f07ca7cd26ab1ecc4":"":"729baa4c0ef75ed8aae746376b39fe3c":"":32:"2a0d607c":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"449d39f863e4909984b37f2e5c09ea4d4b3e9fac67bd57c299e4e1d1f084aaa3":"":"d8e9118f331bb5a359f0aa8882861b72":"4ddcae0bc24d622e12bdeaac73e8d1ab7957af051d27dfaafce53aeed4cdd3f989ea25989a2f41cfb3c38dbd841c5560b0b5ab1861b1fbcd236865d13da55b50219462e021f8a21848a64a85326031fcec8fe47a6ef4a435dd2b2fff637644ffcf3914ef2dfa5dd556421bfd297be150b31db039f0f2cc422b282e659e70cceb":128:"c595b9d99414891228c9fa5edb5fcce3":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"449d39f863e4909984b37f2e5c09ea4d4b3e9fac67bd57c299e4e1d1f084aaa3":"":"d8e9118f331bb5a359f0aa8882861b72":"4ddcae0bc24d622e12bdeaac73e8d1ab7957af051d27dfaafce53aeed4cdd3f989ea25989a2f41cfb3c38dbd841c5560b0b5ab1861b1fbcd236865d13da55b50219462e021f8a21848a64a85326031fcec8fe47a6ef4a435dd2b2fff637644ffcf3914ef2dfa5dd556421bfd297be150b31db039f0f2cc422b282e659e70cceb":128:"c595b9d99414891228c9fa5edb5fcce3":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3e70e66813fc48f984dcda4d1c9c24f1d5d1b71ecfc8bb9581782e7cca5a5cc6":"":"d804f1051e72c9b7117002b862eb45ff":"0b1ab2b7a87cebac668c7a532fa8fa56a22cabf0c41fc1e6744ffe07c857c6865d623f508351f98f3f0c577d1eb94300a30a445472218c8ac626b0bee7d4c122d33f8130436a89add341e8ef7e00694afb4ad80d314d87ad3f921c7105eed05431b8151df7cff2c8e3790efd4acd3f60332dc7f34fdd90beef70f9093361d65b":128:"c09c2e3fdfefa222f7345ae4efb978fc":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3e70e66813fc48f984dcda4d1c9c24f1d5d1b71ecfc8bb9581782e7cca5a5cc6":"":"d804f1051e72c9b7117002b862eb45ff":"0b1ab2b7a87cebac668c7a532fa8fa56a22cabf0c41fc1e6744ffe07c857c6865d623f508351f98f3f0c577d1eb94300a30a445472218c8ac626b0bee7d4c122d33f8130436a89add341e8ef7e00694afb4ad80d314d87ad3f921c7105eed05431b8151df7cff2c8e3790efd4acd3f60332dc7f34fdd90beef70f9093361d65b":128:"c09c2e3fdfefa222f7345ae4efb978fc":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8e534041090b45b80f287dc5fa20ebda017ad81b0530e680f62c6280fd8881af":"":"ead675b019ef5c6bbf4985f2a382d6c1":"b1db220052c4bebcef27eed6db0dc91be481179d71160c5a2ddb2fe497a05484840b04cce48980057d770fbbd0d5f3d5c633b55470617ad2cab5767188283310337825c4b0eafe13b5b11293dec230dad43b220885105767938c7ec4600fe063f98aa14bc6afb886fc874c10546749da295f571e696305bd9165486e29f43f52":128:"9aa0cdad5686ca515cd58aed94938ef4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8e534041090b45b80f287dc5fa20ebda017ad81b0530e680f62c6280fd8881af":"":"ead675b019ef5c6bbf4985f2a382d6c1":"b1db220052c4bebcef27eed6db0dc91be481179d71160c5a2ddb2fe497a05484840b04cce48980057d770fbbd0d5f3d5c633b55470617ad2cab5767188283310337825c4b0eafe13b5b11293dec230dad43b220885105767938c7ec4600fe063f98aa14bc6afb886fc874c10546749da295f571e696305bd9165486e29f43f52":128:"9aa0cdad5686ca515cd58aed94938ef4":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2de18874470c09db683cf45cd752bdfa8bf33e7967220b1a69f41f2a02da1d80":"":"af30eb2d0a0c2a50ea413f3285aa88d4":"22889b868d8ccc9f488406813caed199b23091ddd796c8632f564e7cf5a39dfb725266a931fec958659b6fc5b6b9343b8217edb0acb010afc9416601155262b57bd398d62f555953f0e15958e19ae004fbc9cb25e0269a9eaa38a4635a27bfa719fb249fa49337796bcf5f416bba87fbf3b19f0d8c11290c25ca50bbdc822f01":120:"646bbc9b14681af65b0d1c4c9f1d0d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2de18874470c09db683cf45cd752bdfa8bf33e7967220b1a69f41f2a02da1d80":"":"af30eb2d0a0c2a50ea413f3285aa88d4":"22889b868d8ccc9f488406813caed199b23091ddd796c8632f564e7cf5a39dfb725266a931fec958659b6fc5b6b9343b8217edb0acb010afc9416601155262b57bd398d62f555953f0e15958e19ae004fbc9cb25e0269a9eaa38a4635a27bfa719fb249fa49337796bcf5f416bba87fbf3b19f0d8c11290c25ca50bbdc822f01":120:"646bbc9b14681af65b0d1c4c9f1d0d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1a1bb9122e762ecd7ff861a1d65e52607d98e7ae5bd1c3a944e443710f3b0599":"":"32f99ea4cbf52c2701c2252e5e6c863d":"91b7a70c3a06c1f7f2ea584acb5dd76177ba07323c94f2e8f7cbe93fc0bb7c389c3c88e16aa53174f0fc373bc778a6ccf91bf61b6e92c2969d3441eb17a0a835d30dcf882472a6d3cb036533b04d79f05ebfaadf221ae1c14af3f02fa41867acfdfa35f81e8a9d11d42b9a63288c759063c0c3040c3e6ee69cf7c75f9c33fea1":120:"a8e29e08623a3efdbbe8b111de30a4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1a1bb9122e762ecd7ff861a1d65e52607d98e7ae5bd1c3a944e443710f3b0599":"":"32f99ea4cbf52c2701c2252e5e6c863d":"91b7a70c3a06c1f7f2ea584acb5dd76177ba07323c94f2e8f7cbe93fc0bb7c389c3c88e16aa53174f0fc373bc778a6ccf91bf61b6e92c2969d3441eb17a0a835d30dcf882472a6d3cb036533b04d79f05ebfaadf221ae1c14af3f02fa41867acfdfa35f81e8a9d11d42b9a63288c759063c0c3040c3e6ee69cf7c75f9c33fea1":120:"a8e29e08623a3efdbbe8b111de30a4":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3bfad1e8f9850577f9ba3f290e9a5e91b494c2d99534220362e171a7543177ac":"":"8410886b70c57d7ded8596443bd1b157":"ca801c83596795515ea931edba00e06e332bf84246b7036e10b317e2d09a51b2981fcb664ee3bf4180bb0b12ed1cda221abc6790b27c26914f5ef9cea9536e2453cd5b247cb054e295c2687b725a97cbc484b8eb86c6ceee03bd07a54a9301a3ac0ddb23aecb825a238252e7575329058b40e75575a7f16439edf5be163ce5f5":120:"e3645db0c600dba52044efcecfc331":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3bfad1e8f9850577f9ba3f290e9a5e91b494c2d99534220362e171a7543177ac":"":"8410886b70c57d7ded8596443bd1b157":"ca801c83596795515ea931edba00e06e332bf84246b7036e10b317e2d09a51b2981fcb664ee3bf4180bb0b12ed1cda221abc6790b27c26914f5ef9cea9536e2453cd5b247cb054e295c2687b725a97cbc484b8eb86c6ceee03bd07a54a9301a3ac0ddb23aecb825a238252e7575329058b40e75575a7f16439edf5be163ce5f5":120:"e3645db0c600dba52044efcecfc331":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"65debdf2f2191a6cd8de8ad4d5d4d0d8f731f67744e2545df6b2a7cba89c1ee0":"":"fdab2ee547dd8b6f5a4ea2dd19697b3e":"d2b0a0438ee0f145aec9a7ca452b788ecb473152b78fb75f6ace721afc7b0ae1942049b790f3a5b6221a8760295659756d35347cc04029be03459f3e23a71209b4e0bbe13a253a888c83db23376d3a6d9a539f7c9fa4a12dc64297e7c93dfa0ab53ef76b6e1d95bf6f3d5e6ee8f08662fc03ec9d40eff0a43f23ac313671bfd9":112:"c25fc157c3f2474885e2eea48aea":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"65debdf2f2191a6cd8de8ad4d5d4d0d8f731f67744e2545df6b2a7cba89c1ee0":"":"fdab2ee547dd8b6f5a4ea2dd19697b3e":"d2b0a0438ee0f145aec9a7ca452b788ecb473152b78fb75f6ace721afc7b0ae1942049b790f3a5b6221a8760295659756d35347cc04029be03459f3e23a71209b4e0bbe13a253a888c83db23376d3a6d9a539f7c9fa4a12dc64297e7c93dfa0ab53ef76b6e1d95bf6f3d5e6ee8f08662fc03ec9d40eff0a43f23ac313671bfd9":112:"c25fc157c3f2474885e2eea48aea":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"496ae810380460d40cd2fdae8c0739f16b87205cc7f57db0a71a473eb361d570":"":"77233de96f5e1744337778212b411bd5":"85f5b54b4c4af5c808120bd28d98e44e96f4126623e57684957e9fc4fd1a2d0583940b8fc8314a249325476e8d05247831b04709580ae714e8187cd38f9559419e14c9fc4f8c454ec191b8ef2a3610988fe3339d0dc6b72f5978f9eff9d596dfabf27056e3a908c6497267461386e860f6b9d65526294bcb92908b5661b06b5a":112:"4ed91af6340e70b0c2b94ab6f82e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"496ae810380460d40cd2fdae8c0739f16b87205cc7f57db0a71a473eb361d570":"":"77233de96f5e1744337778212b411bd5":"85f5b54b4c4af5c808120bd28d98e44e96f4126623e57684957e9fc4fd1a2d0583940b8fc8314a249325476e8d05247831b04709580ae714e8187cd38f9559419e14c9fc4f8c454ec191b8ef2a3610988fe3339d0dc6b72f5978f9eff9d596dfabf27056e3a908c6497267461386e860f6b9d65526294bcb92908b5661b06b5a":112:"4ed91af6340e70b0c2b94ab6f82e":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aca188183b46139cc7cffc82a6aaaeb2fd73cecad14e75c663bd62daf1ec711d":"":"7bbf7fb55eb70cce94cc6a2b67de55ba":"015cfba90f069545fed60f31992ff3d3c3592eb91e7a53df5978ded64291954cb99a57de82d5398ce782b68d14ac04a8b425395bd076ead59eb445721bdb2f45e19fa089117800cbbac7b8313fb165ccb1122acb654e1242dc7fe6885ea1cbb7281b1270cfa1549cdfe9b47caf47b4ac3807e562e48c066566f5e606b5023b47":112:"3bcb5c2a4261d75bfa106fb25ee1":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aca188183b46139cc7cffc82a6aaaeb2fd73cecad14e75c663bd62daf1ec711d":"":"7bbf7fb55eb70cce94cc6a2b67de55ba":"015cfba90f069545fed60f31992ff3d3c3592eb91e7a53df5978ded64291954cb99a57de82d5398ce782b68d14ac04a8b425395bd076ead59eb445721bdb2f45e19fa089117800cbbac7b8313fb165ccb1122acb654e1242dc7fe6885ea1cbb7281b1270cfa1549cdfe9b47caf47b4ac3807e562e48c066566f5e606b5023b47":112:"3bcb5c2a4261d75bfa106fb25ee1":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8cd6815f6ec15f03b7a53f159e877a5981e0ab7f6e6c261ddde4b47cbb2f2366":"":"c431c07d9adf5f61204a017259cddd75":"4e1a835402bde4f5227e64b46a1f8d0f23a9434e189377fcdf1b9621ba1987eb86a7f3b97ed0babfd674e74c5604a03dd016d71000a72bbbd00a7f7fe56ad0fcb36a3e24dd0fdb63bd66d4db415f35012416ed599796ca3f678df7eb5a1b17f75abb348ddd3b366369a7b362c9488aedab836b61f9a158f0b129c8ca0a53a81e":104:"0e463806ff34e206f703dd96b3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8cd6815f6ec15f03b7a53f159e877a5981e0ab7f6e6c261ddde4b47cbb2f2366":"":"c431c07d9adf5f61204a017259cddd75":"4e1a835402bde4f5227e64b46a1f8d0f23a9434e189377fcdf1b9621ba1987eb86a7f3b97ed0babfd674e74c5604a03dd016d71000a72bbbd00a7f7fe56ad0fcb36a3e24dd0fdb63bd66d4db415f35012416ed599796ca3f678df7eb5a1b17f75abb348ddd3b366369a7b362c9488aedab836b61f9a158f0b129c8ca0a53a81e":104:"0e463806ff34e206f703dd96b3":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8f0a72abcda104aa7fae501f9a3b686d00d3f6fe984731db8a2865bfec587073":"":"ab8acd063775d1b1314f14e90fddd1be":"02c6d426e7f20b725d8cde0a6382e49b029b52126889013ef45251f27b2fadb95ca4a9a3b16ad06999eeca4a473e813045db4942e9b9ff2e5a5e429d9bac298372344d1b781d5facabf6d779643f31ada6124eb50aad599044b54279ec9b25714ac8a3b9ad2487cec7f4b1ee245d7be3d496d6af1d4cbee1c8201312541f3064":104:"3f0ccc134091e0c0425887b1b9":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8f0a72abcda104aa7fae501f9a3b686d00d3f6fe984731db8a2865bfec587073":"":"ab8acd063775d1b1314f14e90fddd1be":"02c6d426e7f20b725d8cde0a6382e49b029b52126889013ef45251f27b2fadb95ca4a9a3b16ad06999eeca4a473e813045db4942e9b9ff2e5a5e429d9bac298372344d1b781d5facabf6d779643f31ada6124eb50aad599044b54279ec9b25714ac8a3b9ad2487cec7f4b1ee245d7be3d496d6af1d4cbee1c8201312541f3064":104:"3f0ccc134091e0c0425887b1b9":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"417135cad74280e6f8597dc791431c95cb8fa63bbf7197e3ab37c4b1d6d9438a":"":"0fe22d9ba1d0e32656e3a9f07a517a27":"a0b2712e81d329d5b076a4be2ad6823cee6dbd17d9a592d065bdebb92b1ff37a56bf2f5e5341f39c574246ccda19e5f35fede49c9ba958f3920cc5440fb404fab7846884ca0c2a3af5b51f4fe97a1395571319cc5b40f8aac986d77de280db82343983982638326ef003e0c013af19c34672975dc99ccc0853a1acf7c617d965":104:"888b836c9111073924a9b43069":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"417135cad74280e6f8597dc791431c95cb8fa63bbf7197e3ab37c4b1d6d9438a":"":"0fe22d9ba1d0e32656e3a9f07a517a27":"a0b2712e81d329d5b076a4be2ad6823cee6dbd17d9a592d065bdebb92b1ff37a56bf2f5e5341f39c574246ccda19e5f35fede49c9ba958f3920cc5440fb404fab7846884ca0c2a3af5b51f4fe97a1395571319cc5b40f8aac986d77de280db82343983982638326ef003e0c013af19c34672975dc99ccc0853a1acf7c617d965":104:"888b836c9111073924a9b43069":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"304824914e32ea0efd61be6972586093349bd2cc2cf0cff44be943682b2dbff5":"":"b6d927a71929029f6766be42746f7cb1":"7281c81c7514f4b17cb125c4649006ef8959a400a1e4d609d277e363e433725fa32346a10bcbd826b6afc8222158920d0a2db1e6fc915e81231c34c3941ecf3c6f94ffe2136190cae3dc39a4277acbc247f36291b5614a8433b1a0780434a6c50521b72ec25145bbd3b192647155d5dd9df9e66762d39592602ea99bf9bfff49":96:"b6044c4d7f59491f68b2c61e":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"304824914e32ea0efd61be6972586093349bd2cc2cf0cff44be943682b2dbff5":"":"b6d927a71929029f6766be42746f7cb1":"7281c81c7514f4b17cb125c4649006ef8959a400a1e4d609d277e363e433725fa32346a10bcbd826b6afc8222158920d0a2db1e6fc915e81231c34c3941ecf3c6f94ffe2136190cae3dc39a4277acbc247f36291b5614a8433b1a0780434a6c50521b72ec25145bbd3b192647155d5dd9df9e66762d39592602ea99bf9bfff49":96:"b6044c4d7f59491f68b2c61e":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8a10e9abe9389738e12a4bb6f553ae81e8bd320e0dfbc05fbae2128c1fde7a23":"":"6da44354e198e3beb54792718becbcc1":"199d754630135b669bf2ec581d3027a569412ab39a78dd9d482e87b778ec65c6473656260c27827e00e566f1e3728fd7bc1853a39d00e43752c6f62c6f9b542a302eea4fd314473674f6926a878ec1e4b475d889126ce6317115aea7660b86ab7f7595695787f6954903f72361c917523615a86d6ce724bd4a20c9257984c0c6":96:"5c5683e587baf2bd32de3df5":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"8a10e9abe9389738e12a4bb6f553ae81e8bd320e0dfbc05fbae2128c1fde7a23":"":"6da44354e198e3beb54792718becbcc1":"199d754630135b669bf2ec581d3027a569412ab39a78dd9d482e87b778ec65c6473656260c27827e00e566f1e3728fd7bc1853a39d00e43752c6f62c6f9b542a302eea4fd314473674f6926a878ec1e4b475d889126ce6317115aea7660b86ab7f7595695787f6954903f72361c917523615a86d6ce724bd4a20c9257984c0c6":96:"5c5683e587baf2bd32de3df5":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d164ffde5dd684becaf73e9667e3e6acb316682c41aea247899e104a54dd7a7f":"":"1d388e19e9d7a9750e2fc1187d4b075a":"f166a5b6f91261cda56f1a537f42ffb8aed10af5e0248f8910034b92dbc58d25953f1497f571d31fbf5ec30d92234b440161703851f0e43530418147ce6270fbcb5db33ab819ba8973051908704b6bea8aaca0718947e6aa82498a6e26a813981783ed9bf9d02eb1ea60927530c4700ff21f00179002b27903dd4103bbc5c645":96:"52e10495105799ead991547b":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d164ffde5dd684becaf73e9667e3e6acb316682c41aea247899e104a54dd7a7f":"":"1d388e19e9d7a9750e2fc1187d4b075a":"f166a5b6f91261cda56f1a537f42ffb8aed10af5e0248f8910034b92dbc58d25953f1497f571d31fbf5ec30d92234b440161703851f0e43530418147ce6270fbcb5db33ab819ba8973051908704b6bea8aaca0718947e6aa82498a6e26a813981783ed9bf9d02eb1ea60927530c4700ff21f00179002b27903dd4103bbc5c645":96:"52e10495105799ead991547b":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2854188c28b15af4b8e528ab25c0950fc1384976f242716c91bddeec06f2fdea":"":"075af9c31f5252b8920092cbd999e7a0":"e9452f71093843a025bb5f655eb6a4e8316ab5946484b11818f22b62f4df75d5891fa3397537093a261dc9a7648b7477ea1f5fc761716e302763364bcab7992595edd0fc1c7f7ac719c879e6616e2007948eb8530065a6cccf73d0fe4a0598819b471b0856e6d90ea0fc0e5d36a30ee925b6b8e5dbf40e77f01efe782c0bb4f7":64:"6ff8fd87e5a31eb6":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2854188c28b15af4b8e528ab25c0950fc1384976f242716c91bddeec06f2fdea":"":"075af9c31f5252b8920092cbd999e7a0":"e9452f71093843a025bb5f655eb6a4e8316ab5946484b11818f22b62f4df75d5891fa3397537093a261dc9a7648b7477ea1f5fc761716e302763364bcab7992595edd0fc1c7f7ac719c879e6616e2007948eb8530065a6cccf73d0fe4a0598819b471b0856e6d90ea0fc0e5d36a30ee925b6b8e5dbf40e77f01efe782c0bb4f7":64:"6ff8fd87e5a31eb6":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2bfc445ac0365ae6c3c3815fd18bbd0c60ea224f6620d9b6ac442a500221f104":"":"43c5f3367a9955aaee1a0c4d4a330059":"db0bae8ce7c66a8ba2fedec22f236212e9a7ad72b371de285c7dc6d2f6c22df0ce4920e0f03f91eb1653c4490050b9f18a2a047115796f0adc41707d1ffcbf148aed5c82013f557e6c28f49434fc4eb20112f43566f212c48cec9894ac40772fcd9b611ee9444df7b73e35b8a38428ccb064c9c50491d2535e0b539f424db83e":64:"49aaa806cb2eeadd":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2bfc445ac0365ae6c3c3815fd18bbd0c60ea224f6620d9b6ac442a500221f104":"":"43c5f3367a9955aaee1a0c4d4a330059":"db0bae8ce7c66a8ba2fedec22f236212e9a7ad72b371de285c7dc6d2f6c22df0ce4920e0f03f91eb1653c4490050b9f18a2a047115796f0adc41707d1ffcbf148aed5c82013f557e6c28f49434fc4eb20112f43566f212c48cec9894ac40772fcd9b611ee9444df7b73e35b8a38428ccb064c9c50491d2535e0b539f424db83e":64:"49aaa806cb2eeadd":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b828f99aaf751bf22d993ed682e488595617a607ed74aaacbb6b60457453080":"":"d48dac1d8d77e245420feb2598812418":"f50f785f4e7c848a55a616ecf4b6b1e1ca85e16de7100c7e4273d411bd95c1380ee157ba501ba9616980195f34e39f43e335f33253342feb8ed64443483c721b85241a0320b3cac83104de2db47188c61a373fba592ea16feeefdee1f2bb43927396f58151418672ebb74afff5c029503a0d0be81430e81ed443e08b74c03183":64:"a5b71ecf845b25d0":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b828f99aaf751bf22d993ed682e488595617a607ed74aaacbb6b60457453080":"":"d48dac1d8d77e245420feb2598812418":"f50f785f4e7c848a55a616ecf4b6b1e1ca85e16de7100c7e4273d411bd95c1380ee157ba501ba9616980195f34e39f43e335f33253342feb8ed64443483c721b85241a0320b3cac83104de2db47188c61a373fba592ea16feeefdee1f2bb43927396f58151418672ebb74afff5c029503a0d0be81430e81ed443e08b74c03183":64:"a5b71ecf845b25d0":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b6da11d69fca3e4c907628d3eb63d95c7e502fc901372fd097e064e70831432":"":"6fe2148f250ea178d4c8ca8423ead87d":"a8097bb74ded776f578eb7588f5ef8915db9bfa7262af700c8e76ee114e07557b6786dd5a60a66b2703e7c9de5d6b42aca92568aec5d1ecc298dbd0edb150b8cc13c9a78698f7674caa94da6cacd1f3ef4ca4238c59830ea725ab3a6284e28966c8c32d9bccfb0cfd6583a5ca309debe86549a6f317d15c5f928cbc7f473310c":32:"e9cdbc52":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b6da11d69fca3e4c907628d3eb63d95c7e502fc901372fd097e064e70831432":"":"6fe2148f250ea178d4c8ca8423ead87d":"a8097bb74ded776f578eb7588f5ef8915db9bfa7262af700c8e76ee114e07557b6786dd5a60a66b2703e7c9de5d6b42aca92568aec5d1ecc298dbd0edb150b8cc13c9a78698f7674caa94da6cacd1f3ef4ca4238c59830ea725ab3a6284e28966c8c32d9bccfb0cfd6583a5ca309debe86549a6f317d15c5f928cbc7f473310c":32:"e9cdbc52":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c5ae9328be49e761064080fc213e53e373fd86359a09d0355e2d438d9b8e68f1":"":"a7e3f8660ff925d5c88c5aceffbd7026":"2ddddba7a56cc808aec4602f09ae9bd78887827bf0315d8dbe16821606ef9d117746dd138bf1f23565d1ab8f4cee36d53fe3730632c5df9f12109b16edbeae285bb49dfdd155f5dc97b319a85362d53cc86817b7c1c31e5e87c9f37422f133d00dd0776bd92ab05ce6860573cd911645cfe3fbe515e85f744899a447fe443653":32:"e35dbac8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c5ae9328be49e761064080fc213e53e373fd86359a09d0355e2d438d9b8e68f1":"":"a7e3f8660ff925d5c88c5aceffbd7026":"2ddddba7a56cc808aec4602f09ae9bd78887827bf0315d8dbe16821606ef9d117746dd138bf1f23565d1ab8f4cee36d53fe3730632c5df9f12109b16edbeae285bb49dfdd155f5dc97b319a85362d53cc86817b7c1c31e5e87c9f37422f133d00dd0776bd92ab05ce6860573cd911645cfe3fbe515e85f744899a447fe443653":32:"e35dbac8":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e4f8ca13ba86c658cc7f42d4f029422209efbd101bc10a1df81a42cfb3a0f79f":"":"1a362fa0e4054ba11e4b06d59c8bc9cf":"e7ad5c75aa13659f8ce4b1650c46382645ec67418199b84ea445b8ceef619ef3fbde59ed3d313c459e36fcf87d26ef2b453409b32f1086934c3072c1ef0aac83762d28b1193b9afff2c083ce4300b768b0ae23ff9d3dcf65bc1693f1350da65180620aab205aceacfc683c8be53a332e2d0337a7518d2a5204f9c8d7325a4799":32:"e7a37f15":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e4f8ca13ba86c658cc7f42d4f029422209efbd101bc10a1df81a42cfb3a0f79f":"":"1a362fa0e4054ba11e4b06d59c8bc9cf":"e7ad5c75aa13659f8ce4b1650c46382645ec67418199b84ea445b8ceef619ef3fbde59ed3d313c459e36fcf87d26ef2b453409b32f1086934c3072c1ef0aac83762d28b1193b9afff2c083ce4300b768b0ae23ff9d3dcf65bc1693f1350da65180620aab205aceacfc683c8be53a332e2d0337a7518d2a5204f9c8d7325a4799":32:"e7a37f15":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"00050a21ca1e72cd0924be31b943c60854be6744577de3dd9d1f4fada4a19ea6":"693ffd3d92294857a99c702a0799eeca28ab066dd90917b9ea5ef8f6547f1d90b106cbec8ef2c22af9f8efa6c652f2f97c2baf33af14fe9def230d49524bd65909c3df1490f637f99e788dcc042b40e00bd524c91e2427ef991bf77e7b2f770cda6e90076c5dac4cac7ee3958b53ff8ce846c3a96281f53c2c52f5f3e523536f":"2fc1afc1395d8409919248709f468496":"":128:"e39b6a7fd5ac67a2a1cc24d5eb9d9c74":"cfcd6b9ff7641829cbadeaa2e56f1f150a099eccf3e378fa4da59794dcc4490aa4f9c5db0ab245bec36a7d4557a572008e42f03bc1baff3c946f23f54a4dc9828f106cf4264e4ab40165839d1085e7795b1ae0950f0ee4a08e46ada501b6b51dee0e518129c9426e5bd44c66674a9f99cfe676f002cfd344c5bbd22d3d91e600":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"00050a21ca1e72cd0924be31b943c60854be6744577de3dd9d1f4fada4a19ea6":"693ffd3d92294857a99c702a0799eeca28ab066dd90917b9ea5ef8f6547f1d90b106cbec8ef2c22af9f8efa6c652f2f97c2baf33af14fe9def230d49524bd65909c3df1490f637f99e788dcc042b40e00bd524c91e2427ef991bf77e7b2f770cda6e90076c5dac4cac7ee3958b53ff8ce846c3a96281f53c2c52f5f3e523536f":"2fc1afc1395d8409919248709f468496":"":128:"e39b6a7fd5ac67a2a1cc24d5eb9d9c74":"":"cfcd6b9ff7641829cbadeaa2e56f1f150a099eccf3e378fa4da59794dcc4490aa4f9c5db0ab245bec36a7d4557a572008e42f03bc1baff3c946f23f54a4dc9828f106cf4264e4ab40165839d1085e7795b1ae0950f0ee4a08e46ada501b6b51dee0e518129c9426e5bd44c66674a9f99cfe676f002cfd344c5bbd22d3d91e600":0 AES-GCM NIST Validation (AES-256,128,1024,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f10965a66255f0c3515af497ccbb257a09f22ec2d57c5edae322a3e6d2d188ef":"91598690edf2de8b27f9bc7461a84e80811cee544f0542923898328cf157590251f0342cb81d359b5dccc5391a12320d1444c26f24178977dd6705c2b365dc1ece0152c42e2f0ee3162cf886ef5529f4f16a77f3bdd2aeccd405b59addf098521d0d38cc25f1991e11be7ecf24caedb48a2a286d2e560a38fa9001c5a228c4d1":"c571ce0e911de5d883dc4a0787483235":"":128:"6d9d3a5dbc8dce385f092fff14bfffda":"2867996e389e09ec0da94d42e77b1e436b50065b09ca4adf1cd03240444ee699dbb7b3fc081a1869ca607d77d5ff9754fc3c997ff0a4ee17543a2ba77886b88a7128bcc51d3450df58ff3a26671b02c1d213df6adb6f7e853080eb46b504517cbaea162710a9bbc2da8b552eb6b0e0cb98e44fcab0a157312be67974678d143e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f10965a66255f0c3515af497ccbb257a09f22ec2d57c5edae322a3e6d2d188ef":"91598690edf2de8b27f9bc7461a84e80811cee544f0542923898328cf157590251f0342cb81d359b5dccc5391a12320d1444c26f24178977dd6705c2b365dc1ece0152c42e2f0ee3162cf886ef5529f4f16a77f3bdd2aeccd405b59addf098521d0d38cc25f1991e11be7ecf24caedb48a2a286d2e560a38fa9001c5a228c4d1":"c571ce0e911de5d883dc4a0787483235":"":128:"6d9d3a5dbc8dce385f092fff14bfffda":"":"2867996e389e09ec0da94d42e77b1e436b50065b09ca4adf1cd03240444ee699dbb7b3fc081a1869ca607d77d5ff9754fc3c997ff0a4ee17543a2ba77886b88a7128bcc51d3450df58ff3a26671b02c1d213df6adb6f7e853080eb46b504517cbaea162710a9bbc2da8b552eb6b0e0cb98e44fcab0a157312be67974678d143e":0 AES-GCM NIST Validation (AES-256,128,1024,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4437ee7d16d8c3ca1aa01e20b66749efa901614d4bb4bee786ad5a5f1bfde2e6":"ff80727a3485cdbc7fab4ee9fadfdc621c538e2055706629046078f1aa3fb687fc728d3a7ffa52ae457b7b5649613eab7bafa464bb435314c49e5900750f7ad39ca9b75df6b2eaa755439e101f67b7ae4cd80dc4a9dea0027048253f2d0a6014056ca69b8c85605b00cf75fa7634a0ddf464270a8c79ce1a1324c4a4c513b24b":"275393276745bc43bae4af1e5d43a31e":"":128:"a82ff1e87d26e4d6e417b60fb2d3ce23":"88f994d276ed20be3932d16f551c4b7e2ed80411f2e72ce098fa0b70c22157a59edab30649fec447dd63f0c87dceca7238ef0d9561b58489ba7bd86f2892743099f40af63c432f78ac0ad0b5c2be47b9e3045e7237b096ee400f430af63a6f309de785caf190f3f4aabbe79f727a741590de542bd343df68d13db55a5f8bab41":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4437ee7d16d8c3ca1aa01e20b66749efa901614d4bb4bee786ad5a5f1bfde2e6":"ff80727a3485cdbc7fab4ee9fadfdc621c538e2055706629046078f1aa3fb687fc728d3a7ffa52ae457b7b5649613eab7bafa464bb435314c49e5900750f7ad39ca9b75df6b2eaa755439e101f67b7ae4cd80dc4a9dea0027048253f2d0a6014056ca69b8c85605b00cf75fa7634a0ddf464270a8c79ce1a1324c4a4c513b24b":"275393276745bc43bae4af1e5d43a31e":"":128:"a82ff1e87d26e4d6e417b60fb2d3ce23":"":"88f994d276ed20be3932d16f551c4b7e2ed80411f2e72ce098fa0b70c22157a59edab30649fec447dd63f0c87dceca7238ef0d9561b58489ba7bd86f2892743099f40af63c432f78ac0ad0b5c2be47b9e3045e7237b096ee400f430af63a6f309de785caf190f3f4aabbe79f727a741590de542bd343df68d13db55a5f8bab41":0 AES-GCM NIST Validation (AES-256,128,1024,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe4ec037ce563dadee435cfcb2bf090f1f7ccc7d1b5b4fab2f1b738348f8ed2f":"64eb8a4bda9804c09b04cfcd89094928c21480908b81ee19d6c29c2a3631b1a5bdc8e7f8ea56f7b8b8e14a5208296026785cac3a6afa54be8af4d5faedcd12b6621bde0f8ec5a2635fe72a89468ca7704c73aa40cd2ba97aef08886b27a694d339b00e7d12a31308672f87c06a7388a1432f869eb4cc1da864140b1b33931925":"47f5264f7a5b65b671892a05fa556f63":"":120:"660462b4088f6628a630f2e4170b21":"4a310e035361f98b8c54fb4cef70b1a9c910552ece056ca8fdab54c52308ec0ad7fe9dd1dae92badab5010577de522088768fa6466fbccce22e14c51ca7986c4063d0f06bf578dab16a91856713198a7138395c49c78b6314b57ab72fd079028c8dc351952d90b04a7cd2b245df0c0522447cdb7d3329fd9425fe5cb40a8e7c9":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe4ec037ce563dadee435cfcb2bf090f1f7ccc7d1b5b4fab2f1b738348f8ed2f":"64eb8a4bda9804c09b04cfcd89094928c21480908b81ee19d6c29c2a3631b1a5bdc8e7f8ea56f7b8b8e14a5208296026785cac3a6afa54be8af4d5faedcd12b6621bde0f8ec5a2635fe72a89468ca7704c73aa40cd2ba97aef08886b27a694d339b00e7d12a31308672f87c06a7388a1432f869eb4cc1da864140b1b33931925":"47f5264f7a5b65b671892a05fa556f63":"":120:"660462b4088f6628a630f2e4170b21":"":"4a310e035361f98b8c54fb4cef70b1a9c910552ece056ca8fdab54c52308ec0ad7fe9dd1dae92badab5010577de522088768fa6466fbccce22e14c51ca7986c4063d0f06bf578dab16a91856713198a7138395c49c78b6314b57ab72fd079028c8dc351952d90b04a7cd2b245df0c0522447cdb7d3329fd9425fe5cb40a8e7c9":0 AES-GCM NIST Validation (AES-256,128,1024,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e6e1ada628ca76eb9832cc6b5efc5c9d2686bb587366a6de2d734233fa95279e":"a0ac738e0fb35246b84a6fbe319f827039515df25d0c0fc6de7c048253ae63d3c561e44a12672ffeae1cb925610b482aa422bbee0e1784fc69baac3a97d69f51e6d2a17957b44b318624ea7ec680a559f4d3f2761d09bee66efb3a312ae6b3ecb673e756b2a0f654671e82500e7ace91f2be2a74bc3bc1ec1a4b6877a53c27c8":"5a100b451e3a63a3e6d4b8a9e59c6bce":"":120:"88df9a1ea54e5bd2ef24da6880b79d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e6e1ada628ca76eb9832cc6b5efc5c9d2686bb587366a6de2d734233fa95279e":"a0ac738e0fb35246b84a6fbe319f827039515df25d0c0fc6de7c048253ae63d3c561e44a12672ffeae1cb925610b482aa422bbee0e1784fc69baac3a97d69f51e6d2a17957b44b318624ea7ec680a559f4d3f2761d09bee66efb3a312ae6b3ecb673e756b2a0f654671e82500e7ace91f2be2a74bc3bc1ec1a4b6877a53c27c8":"5a100b451e3a63a3e6d4b8a9e59c6bce":"":120:"88df9a1ea54e5bd2ef24da6880b79d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cd5c1e90d78213155c51767c52c290b3d657db8414ee0a7604a2ec7b48105667":"8e987693da0fb77b6d1282eebd3a03e05d9955ff81929b1a2c721574862a067ddee392c7ece52ca1451f3e6e321d7208882d97b4149af6d78d65c054e1bfcdfa62bd2202de32dea8363f8d7f041891ce281840f3cd906ab46ca748e5b3b11890b4014bf0271c9427c874097782d1c13dbb40e78fc8276fc134f3c29923a43a01":"4e022d8d86efbd347e8cbab7e979771f":"":120:"e7df79af0aef011299c3b882e3a45b":"3b20473d9b5018d089e7f74d3fef22ec2805948a9e07689831973c704a6d8db4d090af88d696ab8c3aae9740a2bbd7f03e0b18b2b591e59c335c1043a2578a89b1a9f20fd0dd53f12e00e9bfdb27de8caac772bbfc4de9e4a255a5d1b04e59625a87b8279babe613def58d890d5502abf2f709aab625dcc20c58772832c7bbab":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cd5c1e90d78213155c51767c52c290b3d657db8414ee0a7604a2ec7b48105667":"8e987693da0fb77b6d1282eebd3a03e05d9955ff81929b1a2c721574862a067ddee392c7ece52ca1451f3e6e321d7208882d97b4149af6d78d65c054e1bfcdfa62bd2202de32dea8363f8d7f041891ce281840f3cd906ab46ca748e5b3b11890b4014bf0271c9427c874097782d1c13dbb40e78fc8276fc134f3c29923a43a01":"4e022d8d86efbd347e8cbab7e979771f":"":120:"e7df79af0aef011299c3b882e3a45b":"":"3b20473d9b5018d089e7f74d3fef22ec2805948a9e07689831973c704a6d8db4d090af88d696ab8c3aae9740a2bbd7f03e0b18b2b591e59c335c1043a2578a89b1a9f20fd0dd53f12e00e9bfdb27de8caac772bbfc4de9e4a255a5d1b04e59625a87b8279babe613def58d890d5502abf2f709aab625dcc20c58772832c7bbab":0 AES-GCM NIST Validation (AES-256,128,1024,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6e3dfc07003bb6a2d82bd5263b2832f47db4e73279266c7a9ea21f4f18eddf83":"a960da222af9d4da5797e6957d59b00f6d3893599c70e95c0984b56eb3329b191703c2532f3288b15ebf655b9b5ee4617484e5ac9c39bb06731d03ebe4fef9495d003b0ed694cf540b4dc759d32629e55512680badd81234bd71ffd55fcb5e6a85031c1dc31ee1ed198939582d8336c905717cc87101dcfcf9d833fac815c8ea":"7c0f49fb54f5e68c84e81add009284e6":"":112:"b2ec0f3da02a9eb3132fb4ebe3b8":"a40b6f70f0572fe0bc70d83368e7c154f7dbd501f52501630a2e523d18e216e07368521f6040d806299397722b99bcf7f85d36b8bed934b49aa1fa76d38783e6a2e392d6d0786d467f7bc894a739ecf94f0fe884a9c391154f8326bf31ea5242a18aa263d04da4b63b11de23b42d3e10a2d5460cb32700cdf50a0d89165ba22a":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6e3dfc07003bb6a2d82bd5263b2832f47db4e73279266c7a9ea21f4f18eddf83":"a960da222af9d4da5797e6957d59b00f6d3893599c70e95c0984b56eb3329b191703c2532f3288b15ebf655b9b5ee4617484e5ac9c39bb06731d03ebe4fef9495d003b0ed694cf540b4dc759d32629e55512680badd81234bd71ffd55fcb5e6a85031c1dc31ee1ed198939582d8336c905717cc87101dcfcf9d833fac815c8ea":"7c0f49fb54f5e68c84e81add009284e6":"":112:"b2ec0f3da02a9eb3132fb4ebe3b8":"":"a40b6f70f0572fe0bc70d83368e7c154f7dbd501f52501630a2e523d18e216e07368521f6040d806299397722b99bcf7f85d36b8bed934b49aa1fa76d38783e6a2e392d6d0786d467f7bc894a739ecf94f0fe884a9c391154f8326bf31ea5242a18aa263d04da4b63b11de23b42d3e10a2d5460cb32700cdf50a0d89165ba22a":0 AES-GCM NIST Validation (AES-256,128,1024,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4103b1ddff87a508a219c808a04ad4750668688f4c2ee75b92d28d70b98a2c94":"a00a196193ff07006b7df524824bd0971d63f447a3a7bb1b75c1e2d11789482c115cff677b54948d36dc4de34200bce97be0101d88cee39b177857dd5da3cb0d2f9d6e1150f72a3bd655e0bace1d25a657ba9a7f8dff082b4460432075afb20173da22b49beeb6a030d72ba07869ff4389fc1c28d87018d7c1a9829c21932197":"5cea906737518c2cb901016e30206276":"":112:"3a3a771dd5f31c977e154ef5c73a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4103b1ddff87a508a219c808a04ad4750668688f4c2ee75b92d28d70b98a2c94":"a00a196193ff07006b7df524824bd0971d63f447a3a7bb1b75c1e2d11789482c115cff677b54948d36dc4de34200bce97be0101d88cee39b177857dd5da3cb0d2f9d6e1150f72a3bd655e0bace1d25a657ba9a7f8dff082b4460432075afb20173da22b49beeb6a030d72ba07869ff4389fc1c28d87018d7c1a9829c21932197":"5cea906737518c2cb901016e30206276":"":112:"3a3a771dd5f31c977e154ef5c73a":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cd8c2f0c330d5db316dae7a16b57d681ca058864f7bd60f3d0de174442283f77":"e2a5ad295d35031535bf13c2993bd0b292e8a9465b9dab738e59ba03670248a1ecc92b38a55bae34729162271cc1572c35fcccb27417b48dfcbff852a7a8845cc829a4461061b558ac8b5930a5c6491ffba04a9d0dff220b3cd5e4fc2e0f3db3b2ddd90328f2cad819573a7856299620b02f5ee0267f3b56981afbf1b7d9e3e1":"387ee8c1e7f047e94d06d0322eec02fc":"":112:"62356850d12b54e39872357cfa03":"17b7f6bdfc1993c56dd9bd674cc276a55a46fdd9fd5fe435b9e4b7ebc7052a9dc76a99e4e43aba7d486603189c90d10a21ad3722c86bf5bc856a0f930ff5bca65be708b76bb8a29105da67f31eebcec81f28aaf526d2f8f0feac393a24959dcd612e2b93b4463f61957d2b3046bcdf855e346601e4c7760c0ca618ee7bf55381":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cd8c2f0c330d5db316dae7a16b57d681ca058864f7bd60f3d0de174442283f77":"e2a5ad295d35031535bf13c2993bd0b292e8a9465b9dab738e59ba03670248a1ecc92b38a55bae34729162271cc1572c35fcccb27417b48dfcbff852a7a8845cc829a4461061b558ac8b5930a5c6491ffba04a9d0dff220b3cd5e4fc2e0f3db3b2ddd90328f2cad819573a7856299620b02f5ee0267f3b56981afbf1b7d9e3e1":"387ee8c1e7f047e94d06d0322eec02fc":"":112:"62356850d12b54e39872357cfa03":"":"17b7f6bdfc1993c56dd9bd674cc276a55a46fdd9fd5fe435b9e4b7ebc7052a9dc76a99e4e43aba7d486603189c90d10a21ad3722c86bf5bc856a0f930ff5bca65be708b76bb8a29105da67f31eebcec81f28aaf526d2f8f0feac393a24959dcd612e2b93b4463f61957d2b3046bcdf855e346601e4c7760c0ca618ee7bf55381":0 AES-GCM NIST Validation (AES-256,128,1024,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7e19e400872eed721d560202cd757d3eb99729496b6e3a6d38dd8afe1066045a":"3fb9abc7aba654dfb174e8899c17db222ffbb387b7260fc6f015b54f1cd74284c516e21aae3b72338e5e8dc643cfafca0678f5bda3a7539f1612dddb04366031b5a3eda55f3232c1b176cc9be7cc07e0ebca674a272224929c401a2530efc6d4eed0087b544b12d172a01bc8340d9c2a2ebcb5af8b07d96073a879fda140c196":"d2b277f78e98f1fa16f977ce72ee22a7":"":104:"4c81c044101f458fdfac9ca3b9":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7e19e400872eed721d560202cd757d3eb99729496b6e3a6d38dd8afe1066045a":"3fb9abc7aba654dfb174e8899c17db222ffbb387b7260fc6f015b54f1cd74284c516e21aae3b72338e5e8dc643cfafca0678f5bda3a7539f1612dddb04366031b5a3eda55f3232c1b176cc9be7cc07e0ebca674a272224929c401a2530efc6d4eed0087b544b12d172a01bc8340d9c2a2ebcb5af8b07d96073a879fda140c196":"d2b277f78e98f1fa16f977ce72ee22a7":"":104:"4c81c044101f458fdfac9ca3b9":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d0653934a16fd36c27d54488a1829302b931bed6e26ca26047242b85b50bfb61":"c02347e1add9178d830d8baaad9aeee37e958bedf2cc846e2561fe8c83481d0a8a85911e7f1f6e444b28f30bd96c13c390e80f616feb6844ee6fa486543a2e3f38c138f45b4405e3fb331b64648219aaf1d574be948ccfca6afc18d12488db19c35b05601e47c0af5d49a93a5dd4420f38585c1eb033e173376fa390d3f948df":"94886a1845aebba5ed6b86f580be47f9":"":104:"4be34ff42085ef4443c8b6042d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d0653934a16fd36c27d54488a1829302b931bed6e26ca26047242b85b50bfb61":"c02347e1add9178d830d8baaad9aeee37e958bedf2cc846e2561fe8c83481d0a8a85911e7f1f6e444b28f30bd96c13c390e80f616feb6844ee6fa486543a2e3f38c138f45b4405e3fb331b64648219aaf1d574be948ccfca6afc18d12488db19c35b05601e47c0af5d49a93a5dd4420f38585c1eb033e173376fa390d3f948df":"94886a1845aebba5ed6b86f580be47f9":"":104:"4be34ff42085ef4443c8b6042d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d0f0ccb88c7cec9496f26a59ddc67dc59ebe49ae3dd89ef3be008598727e214c":"7845e155f4f28021291e7c814a1ace8f42b239990831aa82758fc1e376cace0b6f668f7f2f224dede1ef5b1df7ae74b2c01483701044acbbb72a9216eec6b7ef0190f114b3c73c6985c4653f11601c774d10b7f9df1f1e1f3ff4fafa20d6525edb37d9e5acfafe6d3468ee068d407fdb56dc718c98425926831253978d727854":"e5ca84b907ac761a5e68a9080da0a88a":"":104:"c8f78e4139dd3eaf2baef8aafb":"0cc3ede50b0d3fb9ada11300a3239a383c98f968ad65266d57a195bb18d3e568fe6cabba258da4bee9e923c7c838e06dc887a6c49cc1453ea6a227c6a83e651a8742e0316cad5efc93739393e3603446b5c920a206db1434adbb8ebde4d1a7a8699c7f6c61b2d57c9709b564338423b4f526d6c157647a6c45da9dd521061f05":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d0f0ccb88c7cec9496f26a59ddc67dc59ebe49ae3dd89ef3be008598727e214c":"7845e155f4f28021291e7c814a1ace8f42b239990831aa82758fc1e376cace0b6f668f7f2f224dede1ef5b1df7ae74b2c01483701044acbbb72a9216eec6b7ef0190f114b3c73c6985c4653f11601c774d10b7f9df1f1e1f3ff4fafa20d6525edb37d9e5acfafe6d3468ee068d407fdb56dc718c98425926831253978d727854":"e5ca84b907ac761a5e68a9080da0a88a":"":104:"c8f78e4139dd3eaf2baef8aafb":"":"0cc3ede50b0d3fb9ada11300a3239a383c98f968ad65266d57a195bb18d3e568fe6cabba258da4bee9e923c7c838e06dc887a6c49cc1453ea6a227c6a83e651a8742e0316cad5efc93739393e3603446b5c920a206db1434adbb8ebde4d1a7a8699c7f6c61b2d57c9709b564338423b4f526d6c157647a6c45da9dd521061f05":0 AES-GCM NIST Validation (AES-256,128,1024,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e35dcea17cbf391491ae5ba6056d0dd13b348183474dd4b614742751bdebfc32":"5213542beb044910d7fdeec8bb89de93f350760e493286eaef1140485380d429f74a4279c1842a5c64f3ca3381cb5dbb0621de48821bded650cb59703e0ca88f4e9c3d15875f9dc87d85ba7e4bae9986ef8c203fce6f0ce52c28e3a93befb4cc4ba3d963d2283cd30f9bf6ab99d92f2f4f3aff0b022f1751b89d43ea10bbb28a":"fa549b33b5a43d85f012929a4816297a":"":96:"afa61e843cee615c97de42a7":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e35dcea17cbf391491ae5ba6056d0dd13b348183474dd4b614742751bdebfc32":"5213542beb044910d7fdeec8bb89de93f350760e493286eaef1140485380d429f74a4279c1842a5c64f3ca3381cb5dbb0621de48821bded650cb59703e0ca88f4e9c3d15875f9dc87d85ba7e4bae9986ef8c203fce6f0ce52c28e3a93befb4cc4ba3d963d2283cd30f9bf6ab99d92f2f4f3aff0b022f1751b89d43ea10bbb28a":"fa549b33b5a43d85f012929a4816297a":"":96:"afa61e843cee615c97de42a7":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"844c50ddc0ac1d9364b21003287d6ae6360d12bbb17a85351362420ee4ca588e":"3a3bf4ccaf05f7c02f5e158dd2c5cb08c6aed4b1ba404a6d8ef9a0737fe2f350b3e22188fc330ea63e35df82f996e3cf94d331c4246cdb25bb2c409762e05ddc21f337edee51b64f1766ad18f520b3f34735b24278d9d647c533a743e0c1e9c81e9dee975cdc47e8582113fd250ef59353605b64acb7c025a97854c1a5c03237":"2f8512bb7e214db774a217a4615139e1":"":96:"f1da1cebe00d80eb4e025feb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"844c50ddc0ac1d9364b21003287d6ae6360d12bbb17a85351362420ee4ca588e":"3a3bf4ccaf05f7c02f5e158dd2c5cb08c6aed4b1ba404a6d8ef9a0737fe2f350b3e22188fc330ea63e35df82f996e3cf94d331c4246cdb25bb2c409762e05ddc21f337edee51b64f1766ad18f520b3f34735b24278d9d647c533a743e0c1e9c81e9dee975cdc47e8582113fd250ef59353605b64acb7c025a97854c1a5c03237":"2f8512bb7e214db774a217a4615139e1":"":96:"f1da1cebe00d80eb4e025feb":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2aae1aa047a20ed2d6d8336d923864cee9404f924031ae327fbfe2d293e1d93c":"8e5b6b9e4e7d01de9a919dd33c0c1eb94dcfebf28847c754c62c1c00642d9e96f15b5d28ad103ff6969be750aadfd02fc146935562c83ec459a932a2fd5fda32eb851e6cff33335abd5c2434ae4f5524d6bc74a38094ced360f4606a1a17096ff06604952c8ca94a9a6dc4a251e13b0e0c54bd8a6dff5f397a1eb1cf186fa518":"3da9af3567d70553ca3a9636f0b26470":"":96:"e1026b3d15d261b2fb47632e":"58c52ea9f3b162511160eed1a68b6f52b3c4f5834af728de97a3d9e4ba337b29aad12636003cf5be9ffbeae0f383f7cf32f645a8f6fc5cdc1cde91c625c69a92bc434ed671e52a0044a48f3fce55cae49a7d065c2a72603a7efe58b5a7b18ac500d1a51420e820357e7a439b1c02198ebe3d4e62d5573a3aa5f40900a21e3b41":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2aae1aa047a20ed2d6d8336d923864cee9404f924031ae327fbfe2d293e1d93c":"8e5b6b9e4e7d01de9a919dd33c0c1eb94dcfebf28847c754c62c1c00642d9e96f15b5d28ad103ff6969be750aadfd02fc146935562c83ec459a932a2fd5fda32eb851e6cff33335abd5c2434ae4f5524d6bc74a38094ced360f4606a1a17096ff06604952c8ca94a9a6dc4a251e13b0e0c54bd8a6dff5f397a1eb1cf186fa518":"3da9af3567d70553ca3a9636f0b26470":"":96:"e1026b3d15d261b2fb47632e":"":"58c52ea9f3b162511160eed1a68b6f52b3c4f5834af728de97a3d9e4ba337b29aad12636003cf5be9ffbeae0f383f7cf32f645a8f6fc5cdc1cde91c625c69a92bc434ed671e52a0044a48f3fce55cae49a7d065c2a72603a7efe58b5a7b18ac500d1a51420e820357e7a439b1c02198ebe3d4e62d5573a3aa5f40900a21e3b41":0 AES-GCM NIST Validation (AES-256,128,1024,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f3d69208cb0d27474e9a231cd46eac7c1574fff950c48bbd1ba03fad16f563df":"0d1f06eef5e8f2c81d1a73bb1dca93c22cfb6e40e9948bc75b0d84830fb9216330424f580b89050c3fb3f620eca8f9fd09fb86d2e8b3a0869c6022d8a705fc280d66fd16d3aba7395d6be4bed44145d51d42d56285f3675726d62d94c081364a6d440511de83a613c598b03078e2ec7648c6302defbbea66aafd33e1a4b1686c":"b957f05921d21f2192f587768dc12b4f":"":64:"322374fbb192abbc":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f3d69208cb0d27474e9a231cd46eac7c1574fff950c48bbd1ba03fad16f563df":"0d1f06eef5e8f2c81d1a73bb1dca93c22cfb6e40e9948bc75b0d84830fb9216330424f580b89050c3fb3f620eca8f9fd09fb86d2e8b3a0869c6022d8a705fc280d66fd16d3aba7395d6be4bed44145d51d42d56285f3675726d62d94c081364a6d440511de83a613c598b03078e2ec7648c6302defbbea66aafd33e1a4b1686c":"b957f05921d21f2192f587768dc12b4f":"":64:"322374fbb192abbc":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cb2cdeb17fa6bcb006c7fc60858a12a411804464458db351957e8caf42f1ee6c":"296504131354b2c1928982f12d408ba2377f2d4bbe87e4c69f92a15bf6003910a43bda6c8929df66b3ab1d202a5258cad199f32f36cc30d2dc06199c2a52f7ccadad1fce50123c5f8434dec57cc60cc780263d7aace8f59cc8a6c54bddbaded3adb12ae2ee0bacf6a8da635ff85b51a4e8a1b3dc404863b90059de4ad0f158dd":"31bd7c971a6d330b566567ab19590545":"":64:"efc5a1acf433aaa3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cb2cdeb17fa6bcb006c7fc60858a12a411804464458db351957e8caf42f1ee6c":"296504131354b2c1928982f12d408ba2377f2d4bbe87e4c69f92a15bf6003910a43bda6c8929df66b3ab1d202a5258cad199f32f36cc30d2dc06199c2a52f7ccadad1fce50123c5f8434dec57cc60cc780263d7aace8f59cc8a6c54bddbaded3adb12ae2ee0bacf6a8da635ff85b51a4e8a1b3dc404863b90059de4ad0f158dd":"31bd7c971a6d330b566567ab19590545":"":64:"efc5a1acf433aaa3":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f94170790fadab3240df568197f9d6f6855afaed8d07eceeaa2380121872529f":"ed231b78db082f652bc6310c396993b52de804a82464fa3fac602a1286535f59c67fc2b1b420c7321eb42b971edde24cd4cb9e75c843f2ac6fb8ecdad612d2e5049cf39327aa7a8d43ec821161c385f3fdc92284a764a5d1cbae886f07f93017f83a105bb7c3cc4fc51e2781516a2471b65c940ddae6b550ad37b35f53d7cc64":"2f9c0647a4af7f61ced45f28d45c43f1":"":64:"ab74877a0b223e1c":"1cb5ed0c10cee98ff8ecfa5a1b6592391bbd9f9b1dc1ff351e0af23920d546b5e27d62b94daabd32f7f96a2632dc9fd7c19bf55f3b9b7cd492e76f4d6b0f5b437c155c14a75e65bfc4120bef186da05e06a2fd3696f210292ee422ddbce6e63d99ee766b68363139438733c5e567177f72e52ef2df6a7dd33fc0376d12ec3005":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f94170790fadab3240df568197f9d6f6855afaed8d07eceeaa2380121872529f":"ed231b78db082f652bc6310c396993b52de804a82464fa3fac602a1286535f59c67fc2b1b420c7321eb42b971edde24cd4cb9e75c843f2ac6fb8ecdad612d2e5049cf39327aa7a8d43ec821161c385f3fdc92284a764a5d1cbae886f07f93017f83a105bb7c3cc4fc51e2781516a2471b65c940ddae6b550ad37b35f53d7cc64":"2f9c0647a4af7f61ced45f28d45c43f1":"":64:"ab74877a0b223e1c":"":"1cb5ed0c10cee98ff8ecfa5a1b6592391bbd9f9b1dc1ff351e0af23920d546b5e27d62b94daabd32f7f96a2632dc9fd7c19bf55f3b9b7cd492e76f4d6b0f5b437c155c14a75e65bfc4120bef186da05e06a2fd3696f210292ee422ddbce6e63d99ee766b68363139438733c5e567177f72e52ef2df6a7dd33fc0376d12ec3005":0 AES-GCM NIST Validation (AES-256,128,1024,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"797c0091ff8787fe7cd0427c02922620e7f6fb71c52ddcc03a9f25c89ba33490":"2d3efc8900315c3691a8e3c9de3319d4deaf538fcf41aa0e295b861d0ac85baf56d149a6437747dd6976f44016e012b88de542fb8e5b9e4ad10c19deec4b7c0b69bc1b2e33d44a981ded66127dea354b072010b8dc24b85ed2ffeea3b9c0e931619dbbf22677691f0d54fc03eaa162e0ab0d760ad41021f67057c0d6ac19ca8f":"69d81c73008a6827a692fa636fbab8bb":"":32:"be2dda5c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"797c0091ff8787fe7cd0427c02922620e7f6fb71c52ddcc03a9f25c89ba33490":"2d3efc8900315c3691a8e3c9de3319d4deaf538fcf41aa0e295b861d0ac85baf56d149a6437747dd6976f44016e012b88de542fb8e5b9e4ad10c19deec4b7c0b69bc1b2e33d44a981ded66127dea354b072010b8dc24b85ed2ffeea3b9c0e931619dbbf22677691f0d54fc03eaa162e0ab0d760ad41021f67057c0d6ac19ca8f":"69d81c73008a6827a692fa636fbab8bb":"":32:"be2dda5c":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90ce1afb5500489b9edbad987f4009509c847b3e55cdf0c764ef2fb085e3d033":"98482b54edce2bac1cd64d44917dcf117ebfbfe26ad17a9b263447028304f1cf5a69559c05b5d833420f4fddb6e308277d01eb4b3235f1c4b47d33d3899325b55e7be19d43187a5b1b1354ce02a529b3df1c13b4883902ae9fc565079dee825e705f3e580371e4fd86c3b0d31bae98adb529901f346ca07127314152b4370edd":"e119e166471ecf44bc3a070639619931":"":32:"b2f54b3a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90ce1afb5500489b9edbad987f4009509c847b3e55cdf0c764ef2fb085e3d033":"98482b54edce2bac1cd64d44917dcf117ebfbfe26ad17a9b263447028304f1cf5a69559c05b5d833420f4fddb6e308277d01eb4b3235f1c4b47d33d3899325b55e7be19d43187a5b1b1354ce02a529b3df1c13b4883902ae9fc565079dee825e705f3e580371e4fd86c3b0d31bae98adb529901f346ca07127314152b4370edd":"e119e166471ecf44bc3a070639619931":"":32:"b2f54b3a":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"29264a90f114a800c0fc3247b3bda00981a12a8f85cf3a19ea4c7ffdd005f4bb":"587c8e53ab5ae8c31e16160b4a41d88798e27f4ad61c573c023c62d4dbb3952eef5026ad7b453fa9e0694347ab8fe50a6cf20da566202b81e325cee9c07ab2d4d53ed45b3ec2d2135936515f8a24f2a8116807dce9df3c44edf64c32647145152ff241d9e018e4101e400af070192dc3b498b5a213d265b4cfc8c8d4d7deccb5":"cf296aa43cb7b328e09c8975e067404e":"":32:"56015c1e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"29264a90f114a800c0fc3247b3bda00981a12a8f85cf3a19ea4c7ffdd005f4bb":"587c8e53ab5ae8c31e16160b4a41d88798e27f4ad61c573c023c62d4dbb3952eef5026ad7b453fa9e0694347ab8fe50a6cf20da566202b81e325cee9c07ab2d4d53ed45b3ec2d2135936515f8a24f2a8116807dce9df3c44edf64c32647145152ff241d9e018e4101e400af070192dc3b498b5a213d265b4cfc8c8d4d7deccb5":"cf296aa43cb7b328e09c8975e067404e":"":32:"56015c1e":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"84ff9a8772815b929d55f6052c0354cf3e02bcc8336fcfe5794952b4c45d5d96":"a87de56d49725a1625baf12fd15931fe1a6783dce5d1e744eba108f45e0c105d8141dc027d0e33ad7efb6752b43729715e2f3e2c42ebdab4d5f72f886bd821c4372244699ddded99a63dbe7763a5a3bc21cbfc253cdc2514eba2a4f54e24dca7c207cb3f6ae80153d77fe0641f357d5a073dcd425c38deb77c45f27427345516":"5c044a66e488b853baf479f7dee2aadb":"00304e3d40cbc6d2bee0778462884f4ec047a8c74bb3dd7e100f2b9d0e529fd24730063986117b56ca876b208a3691425ac63afc3d504ccb499c76622eade09717023fcb7d956b01ce24a3e53cb5da472be3fcf5b278b5d9e377de22fab75bc74afa9670f5fe9691aa0ed77e43f6abc67a61ec409ec39fd66ac0307bf195f36f":128:"72ddd9966ede9b684bc981cbb2113313":"aadb8537309940422f67ca393aa6182d67fe7c52092538a15e98a4254f0a9087c7f10903d5e78078c2e55de914dec8b6b35cb720e3e55963c0ac9901e44b83a0e7c5b2d3f002aec0a4a08354febe47b2abb955f2a21107626ef0b8e1e099650812a6fecf36908fce2d078c2735cf7c2b970a309e5c6d6ff29c26a05720c57105":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"84ff9a8772815b929d55f6052c0354cf3e02bcc8336fcfe5794952b4c45d5d96":"a87de56d49725a1625baf12fd15931fe1a6783dce5d1e744eba108f45e0c105d8141dc027d0e33ad7efb6752b43729715e2f3e2c42ebdab4d5f72f886bd821c4372244699ddded99a63dbe7763a5a3bc21cbfc253cdc2514eba2a4f54e24dca7c207cb3f6ae80153d77fe0641f357d5a073dcd425c38deb77c45f27427345516":"5c044a66e488b853baf479f7dee2aadb":"00304e3d40cbc6d2bee0778462884f4ec047a8c74bb3dd7e100f2b9d0e529fd24730063986117b56ca876b208a3691425ac63afc3d504ccb499c76622eade09717023fcb7d956b01ce24a3e53cb5da472be3fcf5b278b5d9e377de22fab75bc74afa9670f5fe9691aa0ed77e43f6abc67a61ec409ec39fd66ac0307bf195f36f":128:"72ddd9966ede9b684bc981cbb2113313":"":"aadb8537309940422f67ca393aa6182d67fe7c52092538a15e98a4254f0a9087c7f10903d5e78078c2e55de914dec8b6b35cb720e3e55963c0ac9901e44b83a0e7c5b2d3f002aec0a4a08354febe47b2abb955f2a21107626ef0b8e1e099650812a6fecf36908fce2d078c2735cf7c2b970a309e5c6d6ff29c26a05720c57105":0 AES-GCM NIST Validation (AES-256,128,1024,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5ca3991d0160b1729ae1a622dcf4b03b1f4ba86150bd66bf35cbbee9258af10":"62aad5854a238f096bdde0711ac6f5763e7fea29db068ea8c911f17ba91e6d7807883e6fc5ba7db17af33da2b00973008a3425e65cc786ce1b97360019ee2cef74563d54752be436b905705b507c3d62689df4edf0356d26b693eb43d8a2a927a9f3866b7e0e19e84a90447bd6f47e31070fa7c2a71e3f78229ee19fa47e848f":"f8402184d1cc36df07b68ecb1ab42047":"d378cfd29758bcbd21e26a324239c42c992941b3ad68d9f2b3d2def3a051fd172ee882562970ef59798ff8d9eb5f724ff17626156f4cf5d93e41ffef6e525919af6194ea9bbb58c67563d3ffd90e5a6e2a3a33bd1fa3d55eff5dba7cd439d571f7e08014c4780e3d10904ef22b660897e78258da20b2600e88d71c35ecb6329a":128:"9e8b59b4971130557aa84ec3ac7e4133":"556dd32edc0af3c64186fe8c000ddad1516cd14721c93c228e379d4f87e32c79e734539cec930322048f34a2b34931c585d44f09966caf187ec4b9244c991a8a5f263e9da1d08d6086e52535afdb36c7662307521cbceb9ecb470a76970243723fbc1613b6ebbcae261ac2f1936e66ce29ec7350b2e6b2f73a910ade645154f7":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5ca3991d0160b1729ae1a622dcf4b03b1f4ba86150bd66bf35cbbee9258af10":"62aad5854a238f096bdde0711ac6f5763e7fea29db068ea8c911f17ba91e6d7807883e6fc5ba7db17af33da2b00973008a3425e65cc786ce1b97360019ee2cef74563d54752be436b905705b507c3d62689df4edf0356d26b693eb43d8a2a927a9f3866b7e0e19e84a90447bd6f47e31070fa7c2a71e3f78229ee19fa47e848f":"f8402184d1cc36df07b68ecb1ab42047":"d378cfd29758bcbd21e26a324239c42c992941b3ad68d9f2b3d2def3a051fd172ee882562970ef59798ff8d9eb5f724ff17626156f4cf5d93e41ffef6e525919af6194ea9bbb58c67563d3ffd90e5a6e2a3a33bd1fa3d55eff5dba7cd439d571f7e08014c4780e3d10904ef22b660897e78258da20b2600e88d71c35ecb6329a":128:"9e8b59b4971130557aa84ec3ac7e4133":"":"556dd32edc0af3c64186fe8c000ddad1516cd14721c93c228e379d4f87e32c79e734539cec930322048f34a2b34931c585d44f09966caf187ec4b9244c991a8a5f263e9da1d08d6086e52535afdb36c7662307521cbceb9ecb470a76970243723fbc1613b6ebbcae261ac2f1936e66ce29ec7350b2e6b2f73a910ade645154f7":0 AES-GCM NIST Validation (AES-256,128,1024,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"df867d1dd8a287821a54479cab6f88636d2aca30e1bf01a5dffc735e17590356":"6517272cac85d7f38902bcb4b96a0c59c4bdc46bfefa6ebacd7f2fb1629b87ca91de2ffefc42ce3cfd34dcbf01b3f7cadcea3f99e6addf35d36c51f2ceb1f85c1f56a04ec9c9fff60cd7fc238674992183ea3de72ef778561b906202b7b83fe6562a0bca9c1e0a18638e8685b998b4192f5120435809ad6e93a0422d00725262":"35019826c51dd1ef07ff915d9ac4ea96":"0375ed93f287eefe414ab2968844bd10148860c528dbf571a77aa74f98cc669a7fc317adc9f7cf2d80dda29b19db635b30a044399f3665b6176ed669146d28f5ada03b3d32d53fe46575a8afcd37f20386d9e36f7e090b4fefadfab7f008e02f1b5022c0eeb81d03443a276eae48c038ed173631687d2450b913b02c97243edb":128:"e49beb083a9b008ae97a17e3825692f0":"723be39bc13adbc48c861b07753f64fac1ae28fc8933acba888b6538721df0a8b91c040a26522fe0dbb7335d8f63d209e89f7cde23afa9ca3c584b336d63a91e07fdd8808b14c3214c96a202e665bbaaa34248ff30348f3d79c9f16e66ad6c5903305acd887a89b6244eb7c2d96e18b13a686de935bf3821444ee20f48678be5":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"df867d1dd8a287821a54479cab6f88636d2aca30e1bf01a5dffc735e17590356":"6517272cac85d7f38902bcb4b96a0c59c4bdc46bfefa6ebacd7f2fb1629b87ca91de2ffefc42ce3cfd34dcbf01b3f7cadcea3f99e6addf35d36c51f2ceb1f85c1f56a04ec9c9fff60cd7fc238674992183ea3de72ef778561b906202b7b83fe6562a0bca9c1e0a18638e8685b998b4192f5120435809ad6e93a0422d00725262":"35019826c51dd1ef07ff915d9ac4ea96":"0375ed93f287eefe414ab2968844bd10148860c528dbf571a77aa74f98cc669a7fc317adc9f7cf2d80dda29b19db635b30a044399f3665b6176ed669146d28f5ada03b3d32d53fe46575a8afcd37f20386d9e36f7e090b4fefadfab7f008e02f1b5022c0eeb81d03443a276eae48c038ed173631687d2450b913b02c97243edb":128:"e49beb083a9b008ae97a17e3825692f0":"":"723be39bc13adbc48c861b07753f64fac1ae28fc8933acba888b6538721df0a8b91c040a26522fe0dbb7335d8f63d209e89f7cde23afa9ca3c584b336d63a91e07fdd8808b14c3214c96a202e665bbaaa34248ff30348f3d79c9f16e66ad6c5903305acd887a89b6244eb7c2d96e18b13a686de935bf3821444ee20f48678be5":0 AES-GCM NIST Validation (AES-256,128,1024,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0e8e9ce6294b7fbc534a96bdd060120976a6e08315d2ea73ac61d085cd462a44":"9855f186b51358f0e2111c06bfaaeaec9bf95c55e246375c614fad9883d86c82a20c86538dc5f42a0ea69677d59a20c5112d15d2a8396f12096242ad5d7b838d16ee0679fc4017af75bc15e8ad2f77b0e802c864031cbfb0bacd95c828d1db4b7bab0713619e9e5e8fe6902aac7a9e6c42eb05f5b156f7e663ee43e6fdb62480":"4edc6be20f904b4789e5bee0a80a3fc8":"db28ce076b360816cd1e04b7729f8ab080e0a07f35204350f3bd056945aab8638c0e8311ab056f3e5debdbfbb03fae700770264faf73e0f3a05a5812aee84ab613c82f4a76da276250675f6a663f85e2c26d4f4a8666a7f4cedaffc1a7218dec11ca4e72b8b5d5b620d1efbd3d3b94a5ae0d118b9860dfd543b04c78d13a94c3":120:"03cfe6c36c3f54b3188a6ef3866b84":"e10142f852a0d680c983aad2b4609ccbd35ff61bb3eb66442aee6e01d4cc1cd70f45210acbd506395d6ca0cfebc195a196c94b94fc2afb9ffa3b1714653e07e048804746955e2070e1e96bff58f9bc56f3862aaa5fe23a6a57b5e764666ddec9e3e5a6af063f2c150889268619d0128b3b5562d27070e58e41aadd471d92d07e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0e8e9ce6294b7fbc534a96bdd060120976a6e08315d2ea73ac61d085cd462a44":"9855f186b51358f0e2111c06bfaaeaec9bf95c55e246375c614fad9883d86c82a20c86538dc5f42a0ea69677d59a20c5112d15d2a8396f12096242ad5d7b838d16ee0679fc4017af75bc15e8ad2f77b0e802c864031cbfb0bacd95c828d1db4b7bab0713619e9e5e8fe6902aac7a9e6c42eb05f5b156f7e663ee43e6fdb62480":"4edc6be20f904b4789e5bee0a80a3fc8":"db28ce076b360816cd1e04b7729f8ab080e0a07f35204350f3bd056945aab8638c0e8311ab056f3e5debdbfbb03fae700770264faf73e0f3a05a5812aee84ab613c82f4a76da276250675f6a663f85e2c26d4f4a8666a7f4cedaffc1a7218dec11ca4e72b8b5d5b620d1efbd3d3b94a5ae0d118b9860dfd543b04c78d13a94c3":120:"03cfe6c36c3f54b3188a6ef3866b84":"":"e10142f852a0d680c983aad2b4609ccbd35ff61bb3eb66442aee6e01d4cc1cd70f45210acbd506395d6ca0cfebc195a196c94b94fc2afb9ffa3b1714653e07e048804746955e2070e1e96bff58f9bc56f3862aaa5fe23a6a57b5e764666ddec9e3e5a6af063f2c150889268619d0128b3b5562d27070e58e41aadd471d92d07e":0 AES-GCM NIST Validation (AES-256,128,1024,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"886c77b80f5f3a21c01932685a540b23629f6d41d5574fc527227ed0bdf2e21b":"53a17d7b69f607f08676d6f6dd4e8db08e01333a8355d8c87616e84cdf10ef5b041fc6ddc3f6a245c0f534c2b167064af82f45e4702a5e8dede59579fdecf6713353392433950c9b97c38d9ee515ac97d0970ccf03981954540088567a30941bb2cca08cbed680500f8342faa7aebbc6c143e2ea57ba6b4ac1fd975dcc5d0871":"5ec506edb1890a5a63b464490450d419":"05b8d820c9f439d7aeae5c7da0ee25fb0dad47cc3e6f3a47e8b984e856201546975f8214531fc3c2e504d2ac10fa49cb948596b9a8fab01b95c49d6f04d1589f93b77b899e803dd20e1f00a51c0b5953e85be639109b14b100e35ca26d84ea629964b0db8260dfa5a150a66261bf37e79de2ec49e9f1b082a7c58ecd3d39b6c9":120:"ffdf56e1c1a7252b88422787536484":"79ee27adfa9698a97d217c5010ec807806feda37db811e398c3b82abf698aece08561fffc6c601d2691738e279eeb57e5804e1405a9913830e3ba0d7b979213ef40d733a19497d4bb1b8b2c609a8f904e29771fa230c39a48ebb8c3376f07c8013fff6e34f10fe53988a6ec87a9296c0a7cfba769adefe599ec6671012965973":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"886c77b80f5f3a21c01932685a540b23629f6d41d5574fc527227ed0bdf2e21b":"53a17d7b69f607f08676d6f6dd4e8db08e01333a8355d8c87616e84cdf10ef5b041fc6ddc3f6a245c0f534c2b167064af82f45e4702a5e8dede59579fdecf6713353392433950c9b97c38d9ee515ac97d0970ccf03981954540088567a30941bb2cca08cbed680500f8342faa7aebbc6c143e2ea57ba6b4ac1fd975dcc5d0871":"5ec506edb1890a5a63b464490450d419":"05b8d820c9f439d7aeae5c7da0ee25fb0dad47cc3e6f3a47e8b984e856201546975f8214531fc3c2e504d2ac10fa49cb948596b9a8fab01b95c49d6f04d1589f93b77b899e803dd20e1f00a51c0b5953e85be639109b14b100e35ca26d84ea629964b0db8260dfa5a150a66261bf37e79de2ec49e9f1b082a7c58ecd3d39b6c9":120:"ffdf56e1c1a7252b88422787536484":"":"79ee27adfa9698a97d217c5010ec807806feda37db811e398c3b82abf698aece08561fffc6c601d2691738e279eeb57e5804e1405a9913830e3ba0d7b979213ef40d733a19497d4bb1b8b2c609a8f904e29771fa230c39a48ebb8c3376f07c8013fff6e34f10fe53988a6ec87a9296c0a7cfba769adefe599ec6671012965973":0 AES-GCM NIST Validation (AES-256,128,1024,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5231ca6d772edd9ea2d251e22d7d455928c22474b4b44130dad57e6511fed6ee":"2767c808410ee132291585ea74a48ad3102f883f07d060c91c5f10abd37fe0996d2210dc490260238ae15f5d74c7be2a1e15d80db09079c520047f88488a7802857a3fc3b81d85a96949997430a880177880a31d4d0c9c9045247804f057a4f2756d6e40375a4a3187c4376d6bf573ce334cda1ed88d8a50db499e7cdb89d8db":"048698a4a0feabc1f336112e2794795a":"3a81b6b0b722899ff931cb73c39222d555b83ae3f8880b982593cbc1ab8be90d1ee32fd7dfe697cf24c95b7309d82c3fed3aa6b3d5740cc86a28174ac8f17d860ebb251ac0d71751c2ff47b48bfb0b3beb4f51494464cda34feaecddb1dbbe5fa36c681ada0787d6ed728afc4008b95929a1905787917adc95f1034fedcd817a":120:"ba61edeb7b8966188854fc7926aad2":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5231ca6d772edd9ea2d251e22d7d455928c22474b4b44130dad57e6511fed6ee":"2767c808410ee132291585ea74a48ad3102f883f07d060c91c5f10abd37fe0996d2210dc490260238ae15f5d74c7be2a1e15d80db09079c520047f88488a7802857a3fc3b81d85a96949997430a880177880a31d4d0c9c9045247804f057a4f2756d6e40375a4a3187c4376d6bf573ce334cda1ed88d8a50db499e7cdb89d8db":"048698a4a0feabc1f336112e2794795a":"3a81b6b0b722899ff931cb73c39222d555b83ae3f8880b982593cbc1ab8be90d1ee32fd7dfe697cf24c95b7309d82c3fed3aa6b3d5740cc86a28174ac8f17d860ebb251ac0d71751c2ff47b48bfb0b3beb4f51494464cda34feaecddb1dbbe5fa36c681ada0787d6ed728afc4008b95929a1905787917adc95f1034fedcd817a":120:"ba61edeb7b8966188854fc7926aad2":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a3f516a7898e04e5da4efd6c7c5989b77552d195464620c2b35b9a4fda29cce":"5cc28b61ae97557774bdcd7ff653f4aa349df68d53c7e5a65263883ef1fe224ad40e86bffc2d38f28a2ed9ae1fc08563e2a1e46246106546eb8e6064c06baa0046fa137421734b7f0f94656a4f459d9d981717557d843700d116b6e5e2dd3af5f67c34edf31b40b71fd3c6f2475f9310feb70bcb973be52d41e86792c49d54c0":"9310af6974890c0a0364231f9cc8103d":"2103af8356bcb9dfc2a4f1d4ed09cbcd8e1990d23865605e19f87feb50bf8d10d0257740e5557a9297f0499c01e29a1a513ca18e6f43f7406c865cbe3951a7771128f3110c8da3bd696368901944549552842a1f6fd96cc681b45da098f3c1acb3d237d2363285f520d0b6714b698790b7660c52ac84a42c9721ac7e9d38a2ef":112:"993fc8e7176557ee9eb8dd944691":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a3f516a7898e04e5da4efd6c7c5989b77552d195464620c2b35b9a4fda29cce":"5cc28b61ae97557774bdcd7ff653f4aa349df68d53c7e5a65263883ef1fe224ad40e86bffc2d38f28a2ed9ae1fc08563e2a1e46246106546eb8e6064c06baa0046fa137421734b7f0f94656a4f459d9d981717557d843700d116b6e5e2dd3af5f67c34edf31b40b71fd3c6f2475f9310feb70bcb973be52d41e86792c49d54c0":"9310af6974890c0a0364231f9cc8103d":"2103af8356bcb9dfc2a4f1d4ed09cbcd8e1990d23865605e19f87feb50bf8d10d0257740e5557a9297f0499c01e29a1a513ca18e6f43f7406c865cbe3951a7771128f3110c8da3bd696368901944549552842a1f6fd96cc681b45da098f3c1acb3d237d2363285f520d0b6714b698790b7660c52ac84a42c9721ac7e9d38a2ef":112:"993fc8e7176557ee9eb8dd944691":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"59c9258554363d8a885fc0f5d112fee08eadfc7ce52a0e7e73e3d0d41d9a0290":"79c491411402ea7878e480519fd984dde44bce6459303bb76d4eaf97d4e345d1aafaa68ceb0590b41cfed0f411b675d9344c7e888cccfc9eb6fe6b229d198f94ba516ee850ee7f078a4f5f32a23f92f72264e3a76a31ebd042564315ac4f2ec0bb49ba6d08cfd2d3a6308688e39f28e3ecd669c588368cee8210edf5dbefb925":"77e51e89dc47bbcac79cca21e81a61de":"25a6f8800a9b914c0ebf9a45d72355c03ee72a138eb81b2980f332645ce1d7aa4659805821866aee2b276e2c032776b4eaf36f93b5f9a72b791be24e31eff105ca6d0700e3069ee327983dd7fe1c7465d6c6d77837aff69055149988e7199847fad98605c377d997dbd40f3e2ff1a4f978a493684e401249e69540fbde96323c":112:"ee6d85d3f3703b45adb4f9b2f155":"44ca68deed5478074adfddc97f06f44c08bf7bca4dee8707d621fc7396fe2efcdad0a167d1708a9ff59ce4cddb86920bf1dbdf41b2109a1815ffc4e596787319114cad8adab46cf7f080c9ef20bcf67a8441ba55eac449f979280319524c74cf247818a8c5478ea6f6770996026a43781285dd89c36212050afc88faa56135fb":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"59c9258554363d8a885fc0f5d112fee08eadfc7ce52a0e7e73e3d0d41d9a0290":"79c491411402ea7878e480519fd984dde44bce6459303bb76d4eaf97d4e345d1aafaa68ceb0590b41cfed0f411b675d9344c7e888cccfc9eb6fe6b229d198f94ba516ee850ee7f078a4f5f32a23f92f72264e3a76a31ebd042564315ac4f2ec0bb49ba6d08cfd2d3a6308688e39f28e3ecd669c588368cee8210edf5dbefb925":"77e51e89dc47bbcac79cca21e81a61de":"25a6f8800a9b914c0ebf9a45d72355c03ee72a138eb81b2980f332645ce1d7aa4659805821866aee2b276e2c032776b4eaf36f93b5f9a72b791be24e31eff105ca6d0700e3069ee327983dd7fe1c7465d6c6d77837aff69055149988e7199847fad98605c377d997dbd40f3e2ff1a4f978a493684e401249e69540fbde96323c":112:"ee6d85d3f3703b45adb4f9b2f155":"":"44ca68deed5478074adfddc97f06f44c08bf7bca4dee8707d621fc7396fe2efcdad0a167d1708a9ff59ce4cddb86920bf1dbdf41b2109a1815ffc4e596787319114cad8adab46cf7f080c9ef20bcf67a8441ba55eac449f979280319524c74cf247818a8c5478ea6f6770996026a43781285dd89c36212050afc88faa56135fb":0 AES-GCM NIST Validation (AES-256,128,1024,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5e9eae594cb54c8089330e4404ff79abb1c0841b0be5347a14633ad1e1ff44fa":"32abc1eb6077555a85a0a6fd1c78cccca6c8b375842e2eb8eee45ee6c38dc0837443d16c647252e8124639dd01c808ac5e857a25d927c2a75e2fa8955cad5beb5c206fc050cd933fc4621f5718936f01f39dd700ae1aee7537cc595df8789c5d1a6e1e87b1c7a60e3ce5d57c80dd65dee3801798e1481b1963bcc78cc69f8c50":"0917b486da754f48bb43ecc8766a7ce3":"2aa1ef2f91aeba5da10b48a882dbd4574df4e9157a18abf8cecd03e4176712ba171b6ecb0e745841ff84e35063e47b08101afc44cfd9cededb913a82f00b9d4bac922f23a22f200642270399896405d00fa5271718eefb4cd5fe7e5f32097766ebff36ff1898a1c8a1a01cc18e6121e470805c37ff298fc65ef2fb1b336d09fd":112:"92282b022e393924ab9c65b258c2":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5e9eae594cb54c8089330e4404ff79abb1c0841b0be5347a14633ad1e1ff44fa":"32abc1eb6077555a85a0a6fd1c78cccca6c8b375842e2eb8eee45ee6c38dc0837443d16c647252e8124639dd01c808ac5e857a25d927c2a75e2fa8955cad5beb5c206fc050cd933fc4621f5718936f01f39dd700ae1aee7537cc595df8789c5d1a6e1e87b1c7a60e3ce5d57c80dd65dee3801798e1481b1963bcc78cc69f8c50":"0917b486da754f48bb43ecc8766a7ce3":"2aa1ef2f91aeba5da10b48a882dbd4574df4e9157a18abf8cecd03e4176712ba171b6ecb0e745841ff84e35063e47b08101afc44cfd9cededb913a82f00b9d4bac922f23a22f200642270399896405d00fa5271718eefb4cd5fe7e5f32097766ebff36ff1898a1c8a1a01cc18e6121e470805c37ff298fc65ef2fb1b336d09fd":112:"92282b022e393924ab9c65b258c2":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aaf03c3055a35362212b9b059931e7a24fc71e32bc9a533428c9dc31077f2ebc":"c0e12cdd8233878505e025d52427536be7b6bf1887d2dd20eac7092db80b22417a3a4ca83cdf5bc5e36161be1ff9b73f7ceb297c6d07c9cb2a75035a5dc079e48283daea60596f4b356ca28c243e628cbe459f069709fe193394c9b1a31d8ccc5a3a4eba30056c415e68571a2c34bb5c32efff12e9aa483c4a68be5e76aba4cd":"7dfccd077b29e6ed5720244bb76bde9f":"21edd1c6056f51fd5f314e5c26728182edcd9df92877f30498949098dcde8089eed84e76d774ef8874d77125669a302d268b99dcd66b349d0271dde6f8cc94dc4f2df3787887b1173cad94d067e346846befb108005387102854d9387d2c0fbc9636cdf73a10d145f4b612c201b46e1ff4465f6a7654ce3da5792daf9a27fb35":104:"6154c6799ad7cdc2d89801943a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"aaf03c3055a35362212b9b059931e7a24fc71e32bc9a533428c9dc31077f2ebc":"c0e12cdd8233878505e025d52427536be7b6bf1887d2dd20eac7092db80b22417a3a4ca83cdf5bc5e36161be1ff9b73f7ceb297c6d07c9cb2a75035a5dc079e48283daea60596f4b356ca28c243e628cbe459f069709fe193394c9b1a31d8ccc5a3a4eba30056c415e68571a2c34bb5c32efff12e9aa483c4a68be5e76aba4cd":"7dfccd077b29e6ed5720244bb76bde9f":"21edd1c6056f51fd5f314e5c26728182edcd9df92877f30498949098dcde8089eed84e76d774ef8874d77125669a302d268b99dcd66b349d0271dde6f8cc94dc4f2df3787887b1173cad94d067e346846befb108005387102854d9387d2c0fbc9636cdf73a10d145f4b612c201b46e1ff4465f6a7654ce3da5792daf9a27fb35":104:"6154c6799ad7cdc2d89801943a":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"60c775971a9eac7950ed2bdd85bd60fe948ba04c419f6743fb67f37557e46c6e":"8abb2e66a4d08074916056bb8e925551372f737f0e1b597c5d08ee102989743a273b29d7281013f8b3aee2934399cb427370d70370ee86eb41584b653660c633506a53cae747826bb7d93909f069d5aacf058b7f2bbdc58ea08653db857bda83a979fc22a4f126dfef7aac45177f4cdb802fab0c812fb35d12a8176ec21336d7":"9b92ad7079b0de09c94091386577338b":"1f6a84b0df75bd99a2a64849e9686957c6a60932ebe898d033128be9b757e9890225925d856bfdc33ff514c63145f357730bb0435c65342bc5e025267b410af6fd388a5eca01b7efc87fd3b1b791df791bd47dfab736350d7b7f368b4100e04c939d5af957bab95ed502dac904e969876674602a0f0790da2d7351b686e46590":104:"1d6cd4ab3914e109f22668867f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"60c775971a9eac7950ed2bdd85bd60fe948ba04c419f6743fb67f37557e46c6e":"8abb2e66a4d08074916056bb8e925551372f737f0e1b597c5d08ee102989743a273b29d7281013f8b3aee2934399cb427370d70370ee86eb41584b653660c633506a53cae747826bb7d93909f069d5aacf058b7f2bbdc58ea08653db857bda83a979fc22a4f126dfef7aac45177f4cdb802fab0c812fb35d12a8176ec21336d7":"9b92ad7079b0de09c94091386577338b":"1f6a84b0df75bd99a2a64849e9686957c6a60932ebe898d033128be9b757e9890225925d856bfdc33ff514c63145f357730bb0435c65342bc5e025267b410af6fd388a5eca01b7efc87fd3b1b791df791bd47dfab736350d7b7f368b4100e04c939d5af957bab95ed502dac904e969876674602a0f0790da2d7351b686e46590":104:"1d6cd4ab3914e109f22668867f":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3b426e449337a14bc0663246ab61b671b523c9a3130c21ed59c93fa6a5aa5ae3":"291bd5a00d71eb7d547b7c94e7030ba4a947418eaeb378a3bacd304b08c6f92f6958eaba968ac6aa23e0512a2a8ad7c1ca2f8fcf623bfc1281f5b7b598c08d2aebcd447668b23238c5e338b4c2ac7f8fd381714c596ea3e0c17aca4317a08563e58f0f52a8af08e078dc242ae54ee0fe3869f8c9687b004a4ded0aa27d8f4c5d":"e6efc96acd105fe4a48d1ac931eea096":"0902cf7a0685444126369712ac47962bc2f7a3a5837f1b6190d9ab1adb4cd35e7f0892eee628b8e07fcf2b598cebe1ec07d8c4823172ae66a135bb51cc71590707b691a66b56af1ffe38772911d11685da355728eaddd83752d21c119d7b59f4c17c2403629fa55cd70cd331aed7b0de673c85f25c2e9e0267f53f0b7480c8ca":104:"ca4bfeedcd19d301d3f08cb729":"bcef3f2fd101b828d36cb38530cf9a0a7a285ac1c55ee1069cc78466327e85887534c98a8891d579effd832c0f7d6e7e822fb1eea85a39317a547591def4aeed6660872859fc9d1df9725d3c40e9ccaa900e0f1426a55d20ac4f2e8e07bd3bbc687f8e059ab93e7604c97e75ac94be1c8c24f4c4da0080a4d77953fb090cbb62":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3b426e449337a14bc0663246ab61b671b523c9a3130c21ed59c93fa6a5aa5ae3":"291bd5a00d71eb7d547b7c94e7030ba4a947418eaeb378a3bacd304b08c6f92f6958eaba968ac6aa23e0512a2a8ad7c1ca2f8fcf623bfc1281f5b7b598c08d2aebcd447668b23238c5e338b4c2ac7f8fd381714c596ea3e0c17aca4317a08563e58f0f52a8af08e078dc242ae54ee0fe3869f8c9687b004a4ded0aa27d8f4c5d":"e6efc96acd105fe4a48d1ac931eea096":"0902cf7a0685444126369712ac47962bc2f7a3a5837f1b6190d9ab1adb4cd35e7f0892eee628b8e07fcf2b598cebe1ec07d8c4823172ae66a135bb51cc71590707b691a66b56af1ffe38772911d11685da355728eaddd83752d21c119d7b59f4c17c2403629fa55cd70cd331aed7b0de673c85f25c2e9e0267f53f0b7480c8ca":104:"ca4bfeedcd19d301d3f08cb729":"":"bcef3f2fd101b828d36cb38530cf9a0a7a285ac1c55ee1069cc78466327e85887534c98a8891d579effd832c0f7d6e7e822fb1eea85a39317a547591def4aeed6660872859fc9d1df9725d3c40e9ccaa900e0f1426a55d20ac4f2e8e07bd3bbc687f8e059ab93e7604c97e75ac94be1c8c24f4c4da0080a4d77953fb090cbb62":0 AES-GCM NIST Validation (AES-256,128,1024,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ceaf204ff504ea8e7fade1a2097f2b527a44766860447322fa5ad346cd810217":"1c8e4cf6018211518494d46c2e0607fa42e236abc28d58f8175c530f84b1f030572f5f6a74cb5517e1fb999a637d352afcbeadea9121e695675859b66b499a3a351ecba5226e58ebbb59fe12e359e4c89cd51c8703d4643c49921ae495801c73627df404b91e828e1d0e03ae09a39defb5aa5f2c8106953772ba0713d3261329":"cfdb8183251f4b61c64e73243594fdc6":"a60f3969fd1b14793dd1425aa0b1f742a4861e0b50eaffd1525cd209ba6d1252176763bb5bee59aaa55f92341cdc0705899aba44cf0ec05cbf80274ebef65cd9507fd4224b25cac19610968d6a37e2daf9ddf046ef158ef512401f8fd0e4f95662eebdee09dd4a7894cc8c409be086d41280bd78d6bc04c35a4e8cd3a2e83be3":96:"9e45029f4f13a4767ee05cec":"5cdc66b587ed5eebb04f42b83a6ab7017093514881c598cce332d74fa3fab927493ac15bff26835296e080b5b45ef907c0529fc2f4ed2fc09db179ef598e5d193ea60c301d3f8d823404814e3e74de0e1d2417c963e9246c353201c7a42659d447376e7d05c579dd4c3ae51c2436407b8eff16ec31f592f04b8013efcfd0f367":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ceaf204ff504ea8e7fade1a2097f2b527a44766860447322fa5ad346cd810217":"1c8e4cf6018211518494d46c2e0607fa42e236abc28d58f8175c530f84b1f030572f5f6a74cb5517e1fb999a637d352afcbeadea9121e695675859b66b499a3a351ecba5226e58ebbb59fe12e359e4c89cd51c8703d4643c49921ae495801c73627df404b91e828e1d0e03ae09a39defb5aa5f2c8106953772ba0713d3261329":"cfdb8183251f4b61c64e73243594fdc6":"a60f3969fd1b14793dd1425aa0b1f742a4861e0b50eaffd1525cd209ba6d1252176763bb5bee59aaa55f92341cdc0705899aba44cf0ec05cbf80274ebef65cd9507fd4224b25cac19610968d6a37e2daf9ddf046ef158ef512401f8fd0e4f95662eebdee09dd4a7894cc8c409be086d41280bd78d6bc04c35a4e8cd3a2e83be3":96:"9e45029f4f13a4767ee05cec":"":"5cdc66b587ed5eebb04f42b83a6ab7017093514881c598cce332d74fa3fab927493ac15bff26835296e080b5b45ef907c0529fc2f4ed2fc09db179ef598e5d193ea60c301d3f8d823404814e3e74de0e1d2417c963e9246c353201c7a42659d447376e7d05c579dd4c3ae51c2436407b8eff16ec31f592f04b8013efcfd0f367":0 AES-GCM NIST Validation (AES-256,128,1024,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"15652abe38cd09777bba21d0db04637f5737d3cb3922181b9f2d07bfdafd327a":"1d6c153dec3b4738a09c9fbdfe31a093eb7ea79b8fa49f83e5e1f46893590f074fb171fb66e30ef887767014e3a10a3aa05da2bd50dd7b7936e1d7f6f31af9030e31e76bdf147f4396464db0f6a72511c4885c6c2305d339906e3c761a3249d7ebea3bf463e8b79c3706e684575550e964b8047979f7aed6ea05056c4b5840b1":"3a5e0d223ae981efb405566264e3e776":"cd755437cb61b539908e0cfaaa36c0123f8f17d1e6539783cb61d4b56cac3bc1e971c1ea558b12669b025cb6b9ad55991c6e2f8ee8b0b7901790193e226a0fbbfff7ff0bee6a554660b9f32e061b6c04bf048484ff9ebd492f7e50e744edd72d02c8fd32f87f9421bf18a5a20ebb4d9dbe39a13c34b7296232470e8be587ba09":96:"01a573d8e99c884563310954":"162430c23f7adcf98575a2d9249b4b5cec42efae33776360ebfa6a19c8eee4bd6b07cbd274deadc3292b7cdbb7803e99d9f67ccc5077f3ad5808f339a05b3213dbfd11377673d4f9b486a67a72a9ac8ea9ba699861dce0de7e2fd83d3ba2a2ec7fabf18b95a2bbe2184ff7bddd63111b560b3afe7f2c76807614ba36c1b011fb":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"15652abe38cd09777bba21d0db04637f5737d3cb3922181b9f2d07bfdafd327a":"1d6c153dec3b4738a09c9fbdfe31a093eb7ea79b8fa49f83e5e1f46893590f074fb171fb66e30ef887767014e3a10a3aa05da2bd50dd7b7936e1d7f6f31af9030e31e76bdf147f4396464db0f6a72511c4885c6c2305d339906e3c761a3249d7ebea3bf463e8b79c3706e684575550e964b8047979f7aed6ea05056c4b5840b1":"3a5e0d223ae981efb405566264e3e776":"cd755437cb61b539908e0cfaaa36c0123f8f17d1e6539783cb61d4b56cac3bc1e971c1ea558b12669b025cb6b9ad55991c6e2f8ee8b0b7901790193e226a0fbbfff7ff0bee6a554660b9f32e061b6c04bf048484ff9ebd492f7e50e744edd72d02c8fd32f87f9421bf18a5a20ebb4d9dbe39a13c34b7296232470e8be587ba09":96:"01a573d8e99c884563310954":"":"162430c23f7adcf98575a2d9249b4b5cec42efae33776360ebfa6a19c8eee4bd6b07cbd274deadc3292b7cdbb7803e99d9f67ccc5077f3ad5808f339a05b3213dbfd11377673d4f9b486a67a72a9ac8ea9ba699861dce0de7e2fd83d3ba2a2ec7fabf18b95a2bbe2184ff7bddd63111b560b3afe7f2c76807614ba36c1b011fb":0 AES-GCM NIST Validation (AES-256,128,1024,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a43f6d07042a15cd49f6f52a2a3a67c6c2ff420d95bb94b9fe03b287c3abcaf8":"b67e58c8b608724fd20aa097ee483bc4c804490cc79de635170944af75c87ae0ad8261365c1dc80d852553bcba18da9fbc3fbe61d27550a03003ef0c60202054626655509a9e1ab54677e537a4e761df011d6c6dd041c795446b384161ae9eab441afd24d19b58eb4fe5116cd7b11b751ebbd0a2adba7afc380d9d775177099a":"3b6fad21f0034bba8b1f7a344edf7a3c":"2e01c0523c8293fc51388281dccdb8d0a2d215d729289deb327b8142d716c2bb849e9476545b82f3882ba7961b70c5da2a925ba18b6b121e9215d52ac479c9129c9cd28f81584ff84509d5f9dcb7eaae66911b303cc388efa5020ac26a9cd9ea953f61992a306eb4b35bcd8447eea63cef37bb0c95c1e37811115cf26c53e8c5":96:"43470bc3d7c573cb3a5230f5":"e1720d451fa7ab9db4988567187244b15b6fe795dd4fef579fb72e41b21aaa436d2e5d8735a4abd232a3fb9188c75c247f6034cdebb07fd7f260f8e54efefa4f2981cafa510dd5c482a27753a7c015b3cae1c18c7c99a6d6daa4781b80f18bbe6620bfc1518a32531017a1a52aadb96a7794887c11ad6bdd68187ba14f72a4b5":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a43f6d07042a15cd49f6f52a2a3a67c6c2ff420d95bb94b9fe03b287c3abcaf8":"b67e58c8b608724fd20aa097ee483bc4c804490cc79de635170944af75c87ae0ad8261365c1dc80d852553bcba18da9fbc3fbe61d27550a03003ef0c60202054626655509a9e1ab54677e537a4e761df011d6c6dd041c795446b384161ae9eab441afd24d19b58eb4fe5116cd7b11b751ebbd0a2adba7afc380d9d775177099a":"3b6fad21f0034bba8b1f7a344edf7a3c":"2e01c0523c8293fc51388281dccdb8d0a2d215d729289deb327b8142d716c2bb849e9476545b82f3882ba7961b70c5da2a925ba18b6b121e9215d52ac479c9129c9cd28f81584ff84509d5f9dcb7eaae66911b303cc388efa5020ac26a9cd9ea953f61992a306eb4b35bcd8447eea63cef37bb0c95c1e37811115cf26c53e8c5":96:"43470bc3d7c573cb3a5230f5":"":"e1720d451fa7ab9db4988567187244b15b6fe795dd4fef579fb72e41b21aaa436d2e5d8735a4abd232a3fb9188c75c247f6034cdebb07fd7f260f8e54efefa4f2981cafa510dd5c482a27753a7c015b3cae1c18c7c99a6d6daa4781b80f18bbe6620bfc1518a32531017a1a52aadb96a7794887c11ad6bdd68187ba14f72a4b5":0 AES-GCM NIST Validation (AES-256,128,1024,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1f0f0191e18db07c0501dbab4ed952c5603a4cd249d2d8d17e62e10b96ae713f":"aad40e7866c26e486b6f6e8eb14a130d5f88891bf0d09aa8fe32f447ab8dea7bee5d3eda4499c0103a010483f2b64fdf1155499d31decf528c77dd7627884f9995c213cf7402143dbb7561d69c86886734260ac94ffac7eb33598d25714228ef43f744ec1af2a87e789f1e5d6fff0fbd5082dcc49328f194e8f8a14a5bfc962d":"ab8be16b4db809c81be4684b726c05ab":"a5a6e828352a44bd438ad58de80011be0408d410f6e762e3145f8b264a70c593476b41bb87875746c97de7d5fab120bd2f716b37c343608ee48d197a46c7546fafcdbe3e7688b7e9d2f5b6319c91d3881d804546b5f3dbe480996968dd046f406c11f0dc671be0421cbc8b4ea6811dd504281518bb96148dddf9f0dc4e2e2436":64:"d8bd7d8773893519":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1f0f0191e18db07c0501dbab4ed952c5603a4cd249d2d8d17e62e10b96ae713f":"aad40e7866c26e486b6f6e8eb14a130d5f88891bf0d09aa8fe32f447ab8dea7bee5d3eda4499c0103a010483f2b64fdf1155499d31decf528c77dd7627884f9995c213cf7402143dbb7561d69c86886734260ac94ffac7eb33598d25714228ef43f744ec1af2a87e789f1e5d6fff0fbd5082dcc49328f194e8f8a14a5bfc962d":"ab8be16b4db809c81be4684b726c05ab":"a5a6e828352a44bd438ad58de80011be0408d410f6e762e3145f8b264a70c593476b41bb87875746c97de7d5fab120bd2f716b37c343608ee48d197a46c7546fafcdbe3e7688b7e9d2f5b6319c91d3881d804546b5f3dbe480996968dd046f406c11f0dc671be0421cbc8b4ea6811dd504281518bb96148dddf9f0dc4e2e2436":64:"d8bd7d8773893519":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a6cf7d83137f57f2310ee6bf31e8883952bb07ccdc12f516233ed533ea967e5d":"83ab20698fd7573fd121976a72b45a7f03aad84702fc8ac73d6926eabd8a546895aeffe4ba81d117507e2cd37d58eeff71cc3afa8a4449be85f228ea52f6dc6395bb43c1c9f795343720841682d9b2f00602eafa4d4cbe297bfc62467e526b9d823cc8eeecd9e5f8dbc2f65610663c6f37b3d896651b254bd60215629ade3b2a":"f17e37e73a28c682366bfe619cc673bb":"0f4dd201b18e20230b6233e0d7add6f96537dd4e82d3d0704c047fab41af5faf6bd52bd14fa9a072f81d92a2ce04352f0b66f088c67102d2d127a9850b09ff6087f194a6e8ccaba24091feb303eebb65f1203b2d22af44e7be4de71f03e6f6cbadf28e15af58f58eb62e5bddfae06df773cc3f0942520de20078dda752e3270f":64:"74110471ccd75912":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a6cf7d83137f57f2310ee6bf31e8883952bb07ccdc12f516233ed533ea967e5d":"83ab20698fd7573fd121976a72b45a7f03aad84702fc8ac73d6926eabd8a546895aeffe4ba81d117507e2cd37d58eeff71cc3afa8a4449be85f228ea52f6dc6395bb43c1c9f795343720841682d9b2f00602eafa4d4cbe297bfc62467e526b9d823cc8eeecd9e5f8dbc2f65610663c6f37b3d896651b254bd60215629ade3b2a":"f17e37e73a28c682366bfe619cc673bb":"0f4dd201b18e20230b6233e0d7add6f96537dd4e82d3d0704c047fab41af5faf6bd52bd14fa9a072f81d92a2ce04352f0b66f088c67102d2d127a9850b09ff6087f194a6e8ccaba24091feb303eebb65f1203b2d22af44e7be4de71f03e6f6cbadf28e15af58f58eb62e5bddfae06df773cc3f0942520de20078dda752e3270f":64:"74110471ccd75912":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0c85ac6b3887639838ddca94c5c69f38115aa00122322c8114642d12ea1b8fe":"0210fce418e7e2199cb8f899c81b9be74a630d00269755f882fc4db27632e99685cc12c426a7503473646df1288d0ede28408be9add5713628700f8e2b2e27d7522520ed00ac47239084651eb99e7d03e1520aae137b768f3144232c16b72158fd5da4a26a2525b9b27791bf06d1eb2e671c54daf64fddc1420bc2a30a324ba5":"14f68e533ecf02bceb9a504d452e78c7":"796a46236fd0ff6572b1d6257c874038f870aa71cbb06b39046d0fb6489d6ae8622b5154292ae5c4e1d5ff706daedb2e812533ae3a635d339a7fbe53780e3e8204924a5deb4b6856618f4c7465d125a3edffe1ab8f88b31d49537791c0f3171f08dbb5ed1d9ed863dafbae4ecb46824a4922862fe0954ee2caa09ab0e77ed8fc":64:"6fb0b5c83b5212bf":"5e6c362f7587936bcb306673713a6f1fb080783a20e9bbb906456973e529cfa0298206184509c30e1d3793eaaa5d564edd4488f04311821eb652e0a1f4adaf6971505ca014788c8ce085ceb3523d70284ed2bb0aebeba7af83d484df69c87f55a93b3d87baa43bd301c4e55eb8c45dcf3e4612535ea1bd5fdb4c3b9056d0cae9":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b0c85ac6b3887639838ddca94c5c69f38115aa00122322c8114642d12ea1b8fe":"0210fce418e7e2199cb8f899c81b9be74a630d00269755f882fc4db27632e99685cc12c426a7503473646df1288d0ede28408be9add5713628700f8e2b2e27d7522520ed00ac47239084651eb99e7d03e1520aae137b768f3144232c16b72158fd5da4a26a2525b9b27791bf06d1eb2e671c54daf64fddc1420bc2a30a324ba5":"14f68e533ecf02bceb9a504d452e78c7":"796a46236fd0ff6572b1d6257c874038f870aa71cbb06b39046d0fb6489d6ae8622b5154292ae5c4e1d5ff706daedb2e812533ae3a635d339a7fbe53780e3e8204924a5deb4b6856618f4c7465d125a3edffe1ab8f88b31d49537791c0f3171f08dbb5ed1d9ed863dafbae4ecb46824a4922862fe0954ee2caa09ab0e77ed8fc":64:"6fb0b5c83b5212bf":"":"5e6c362f7587936bcb306673713a6f1fb080783a20e9bbb906456973e529cfa0298206184509c30e1d3793eaaa5d564edd4488f04311821eb652e0a1f4adaf6971505ca014788c8ce085ceb3523d70284ed2bb0aebeba7af83d484df69c87f55a93b3d87baa43bd301c4e55eb8c45dcf3e4612535ea1bd5fdb4c3b9056d0cae9":0 AES-GCM NIST Validation (AES-256,128,1024,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e61b1a6b40e2ab1245ff65dcfb9948318ac4fe55e9ed600cec301dae32ae0e93":"8d67fa9fcf078e421cb63abeb25dba739ab0e09a091dd06b0c616e1e888f350edb2d73a42f57f115266ea20c7f8fc143ac746649612df06a5e29b4a15934dc049be1ab49d018ab86c4f37d8c3d9c714f038029e74d8ee3dbe61d81adc63712ea413b37f7604da12107aa1695d9b0981e5a92cdfaa5fbda0e31b22c6fd6f3b499":"c356244b3034d288e4d4fe901b8e27c1":"bdcfeb09d5b97bab05a7acd9849e7de2c5beb7a4dc573c7e1c1d0c0409245a6584023114fdcc6413c800ca16847bde750b27c4d590248e2ce457c19b0f614f6aff4d78d4a19b3251531e5e852fbb05d09412cc1ff8988d1955ca6f5fe2d820f20a7642e3ae69e8122b06ba0918e806400b9b615e1abe6fdd4f56a7d02d649083":32:"86acc02f":"7c73182eca97d9617abb478a6ce62e3491a7e9951981c89c3071b161a4c80440614c3f24d0155073e28dcccee96bc8303dab4901ef77318df522d16d9da47770ef022395d6104cd623d93d67090a27507fc8ca04157e7939e639c62cd0e7d8a472314833c0eaa9ba2fd54a25b02854e3bff25cccd638885c082374ae520ed392":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e61b1a6b40e2ab1245ff65dcfb9948318ac4fe55e9ed600cec301dae32ae0e93":"8d67fa9fcf078e421cb63abeb25dba739ab0e09a091dd06b0c616e1e888f350edb2d73a42f57f115266ea20c7f8fc143ac746649612df06a5e29b4a15934dc049be1ab49d018ab86c4f37d8c3d9c714f038029e74d8ee3dbe61d81adc63712ea413b37f7604da12107aa1695d9b0981e5a92cdfaa5fbda0e31b22c6fd6f3b499":"c356244b3034d288e4d4fe901b8e27c1":"bdcfeb09d5b97bab05a7acd9849e7de2c5beb7a4dc573c7e1c1d0c0409245a6584023114fdcc6413c800ca16847bde750b27c4d590248e2ce457c19b0f614f6aff4d78d4a19b3251531e5e852fbb05d09412cc1ff8988d1955ca6f5fe2d820f20a7642e3ae69e8122b06ba0918e806400b9b615e1abe6fdd4f56a7d02d649083":32:"86acc02f":"":"7c73182eca97d9617abb478a6ce62e3491a7e9951981c89c3071b161a4c80440614c3f24d0155073e28dcccee96bc8303dab4901ef77318df522d16d9da47770ef022395d6104cd623d93d67090a27507fc8ca04157e7939e639c62cd0e7d8a472314833c0eaa9ba2fd54a25b02854e3bff25cccd638885c082374ae520ed392":0 AES-GCM NIST Validation (AES-256,128,1024,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4f5a02e9843d28c8c226ed70d44b8fced8fb757ab6ece4d4f06e3c3cec79e44f":"3ec13950d329f24074714c583bdc35686b811f775b76b0a8fcfa66fc56426c9d022f8ab0af38f8d2f71a068548330cdbe891670181ed7491bf40c739ef4dd93689fd35929b225089d2b151f83d9b3cd767300611144586767354c0491112c205409f3168092d27f9b9f433afb79820a2811984d48e70c1fb2a13bbb3ddbc53fb":"099e5d9aae89fb6391a18adf844a758e":"ad93e8662c3196e48cfdb5aa3bc923cd204151aa980cbec78f0d592b701f779c1c49f9e8686d7e2385a4146b21a643a59c18c8b82214f42560bcd686fad7c7c8e8c1944ce6b20ec9537dd14b6cf2592740ca112f4cd582250d69f240d3e957040e1f7e19c60b3c8f2bd00cb666604c38946eb9b2f17336d281b4794f71e538a2":32:"30298885":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4f5a02e9843d28c8c226ed70d44b8fced8fb757ab6ece4d4f06e3c3cec79e44f":"3ec13950d329f24074714c583bdc35686b811f775b76b0a8fcfa66fc56426c9d022f8ab0af38f8d2f71a068548330cdbe891670181ed7491bf40c739ef4dd93689fd35929b225089d2b151f83d9b3cd767300611144586767354c0491112c205409f3168092d27f9b9f433afb79820a2811984d48e70c1fb2a13bbb3ddbc53fb":"099e5d9aae89fb6391a18adf844a758e":"ad93e8662c3196e48cfdb5aa3bc923cd204151aa980cbec78f0d592b701f779c1c49f9e8686d7e2385a4146b21a643a59c18c8b82214f42560bcd686fad7c7c8e8c1944ce6b20ec9537dd14b6cf2592740ca112f4cd582250d69f240d3e957040e1f7e19c60b3c8f2bd00cb666604c38946eb9b2f17336d281b4794f71e538a2":32:"30298885":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cdb218e0bd0e02156e5b48182990f778889793ef6018a8928e61164ac047c8e":"4d039618a0eb640329f90fe97de18bc928fc3fc7a0db42c97774bec2e882e872fc1097c8319f7837a16516bf387b1bae321c565e8fc1cb8480f051158e4685f0adba310d2c6253bc1300403cbd3f7ddcb2796a69f8bf9e73d47aada9a02673c1a3d5ecdac838abf22b385906236529a1b7dd5b8af2611a04cf4f83b15ba41cfc":"d2ffbb176f86bee958e08e5c7c6357c7":"bc580c4223f34e4f867d97febf9b03629d1c00c73df94436852cafd1408c945c5474c554cb0faf2bae35d3160c823d339a64ebd607cf765fa91f416fc6db042bc2bd7445c129b4a0e04b6f92a7b7b669eb70be9f9b2569e774db7cb7ae83943e3a12d29221356e08e5bf1b09e65f193d00d9fe89f82b84b3b8b062e649163dc8":32:"1997daa9":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1cdb218e0bd0e02156e5b48182990f778889793ef6018a8928e61164ac047c8e":"4d039618a0eb640329f90fe97de18bc928fc3fc7a0db42c97774bec2e882e872fc1097c8319f7837a16516bf387b1bae321c565e8fc1cb8480f051158e4685f0adba310d2c6253bc1300403cbd3f7ddcb2796a69f8bf9e73d47aada9a02673c1a3d5ecdac838abf22b385906236529a1b7dd5b8af2611a04cf4f83b15ba41cfc":"d2ffbb176f86bee958e08e5c7c6357c7":"bc580c4223f34e4f867d97febf9b03629d1c00c73df94436852cafd1408c945c5474c554cb0faf2bae35d3160c823d339a64ebd607cf765fa91f416fc6db042bc2bd7445c129b4a0e04b6f92a7b7b669eb70be9f9b2569e774db7cb7ae83943e3a12d29221356e08e5bf1b09e65f193d00d9fe89f82b84b3b8b062e649163dc8":32:"1997daa9":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dc1a145c18bdbca760f35eea0d4a5992de04a0615964ec8b419c8288ab1470f0":"":"7f8368254955e1b6d55b5c64458f3e66":"":128:"8ddaa2c3ed09d53731834fa932d9d3af":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"dc1a145c18bdbca760f35eea0d4a5992de04a0615964ec8b419c8288ab1470f0":"":"7f8368254955e1b6d55b5c64458f3e66":"":128:"8ddaa2c3ed09d53731834fa932d9d3af":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b4766d3a6615ee58b390daa228ae7a541c46ce80a1efe227cc43cb777df3232":"":"274367f31ec16601fe87a8e35b7a22dd":"":128:"5f3a757b596e06e9b246ed9bac9397f9":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7b4766d3a6615ee58b390daa228ae7a541c46ce80a1efe227cc43cb777df3232":"":"274367f31ec16601fe87a8e35b7a22dd":"":128:"5f3a757b596e06e9b246ed9bac9397f9":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d19b04055bf6e7ff82e89daef66c9d8319ab25f9197e559444c5729b92c4f338":"":"796efaff4f172bef78453d36a237cd36":"":128:"3b445f38bf4db94f1a9ec771173a29e8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d19b04055bf6e7ff82e89daef66c9d8319ab25f9197e559444c5729b92c4f338":"":"796efaff4f172bef78453d36a237cd36":"":128:"3b445f38bf4db94f1a9ec771173a29e8":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7ca68e300534a90a7a87ca9906e4ac614a6aa51f769b6e6129753a4f83d10317":"":"45e6b23f8b3feefd4b0ea06880b2c324":"":120:"6c0a1c9c2cf5a40407bfa1d5958612":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7ca68e300534a90a7a87ca9906e4ac614a6aa51f769b6e6129753a4f83d10317":"":"45e6b23f8b3feefd4b0ea06880b2c324":"":120:"6c0a1c9c2cf5a40407bfa1d5958612":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a2b7cd693239bbc93599d3d12c9876e7303b227b8ae718e2c62e689e1fd62903":"":"548c9c8fcc16416a9d2b35c29f0dacb3":"":120:"3aa21f221266e7773eeba4440d1d01":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a2b7cd693239bbc93599d3d12c9876e7303b227b8ae718e2c62e689e1fd62903":"":"548c9c8fcc16416a9d2b35c29f0dacb3":"":120:"3aa21f221266e7773eeba4440d1d01":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"156b854beb0c276a5e724f5da72f0d1ca4ae7cbd5f93a2257d95c2e5bfd78ad4":"":"a5129e2530f47bcad42fc5774ee09fe7":"":120:"6bb09ed183527c5d5ed46f568af35f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"156b854beb0c276a5e724f5da72f0d1ca4ae7cbd5f93a2257d95c2e5bfd78ad4":"":"a5129e2530f47bcad42fc5774ee09fe7":"":120:"6bb09ed183527c5d5ed46f568af35f":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d824330c60141264e1f709d63227a9a731bcc42b4adec1d8f0161b10b4fdb2ab":"":"c5afaa45312c64ab3c3cf9d6c4e0cc47":"":112:"55952a01eee29d8a1734bbdf3f8f":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d824330c60141264e1f709d63227a9a731bcc42b4adec1d8f0161b10b4fdb2ab":"":"c5afaa45312c64ab3c3cf9d6c4e0cc47":"":112:"55952a01eee29d8a1734bbdf3f8f":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5517589948d8aea778df6fd66c17a170d327f69e504f0a4bd504c4286a9f578":"":"6404b111c6289eefa0d88ed6117bb730":"":112:"637f82e592831531a8e877adfc2c":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5517589948d8aea778df6fd66c17a170d327f69e504f0a4bd504c4286a9f578":"":"6404b111c6289eefa0d88ed6117bb730":"":112:"637f82e592831531a8e877adfc2c":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f6137b2bcbd327fbcc7f313efa10f6ffaed30e4782e222e1225c87103fcae905":"":"3b87b08337a82272b192bd067e3245ec":"":112:"1f2dda372f20ffddd9dd4810e05f":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"f6137b2bcbd327fbcc7f313efa10f6ffaed30e4782e222e1225c87103fcae905":"":"3b87b08337a82272b192bd067e3245ec":"":112:"1f2dda372f20ffddd9dd4810e05f":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5e70d1b78e931abf44bba3f937dbc344858516a8a8afe605818dc67d0c3e4c4":"":"58e70095c6f3a0cda2cdc7775e2f383d":"":104:"1763573f7dab8b46bc177e6147":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b5e70d1b78e931abf44bba3f937dbc344858516a8a8afe605818dc67d0c3e4c4":"":"58e70095c6f3a0cda2cdc7775e2f383d":"":104:"1763573f7dab8b46bc177e6147":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90de0c047d1dd01d521f2dedec7eb81bc0ace7a5a693a7869eaafbb6e725ad7b":"":"d565c9cdfb5d0a25c4083b51729626bd":"":104:"78738d3e9f5e00b49635ac9a2d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"90de0c047d1dd01d521f2dedec7eb81bc0ace7a5a693a7869eaafbb6e725ad7b":"":"d565c9cdfb5d0a25c4083b51729626bd":"":104:"78738d3e9f5e00b49635ac9a2d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c43e8dbeafb079692483a9fcbab964b76fccca6ca99e1388a1aa9bf78dfd2f02":"":"f2bd4fe0d30c0e8d429cac90c8a7b1c8":"":104:"ea7b52490943380ccc902ca5ae":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c43e8dbeafb079692483a9fcbab964b76fccca6ca99e1388a1aa9bf78dfd2f02":"":"f2bd4fe0d30c0e8d429cac90c8a7b1c8":"":104:"ea7b52490943380ccc902ca5ae":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"13540919fdb95559e37b535a427efeee334309e34c4608459e204d931b8087e7":"":"c993c1802df0f075ce92963eb9bff9bd":"":96:"edfab013213591beb53e6419":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"13540919fdb95559e37b535a427efeee334309e34c4608459e204d931b8087e7":"":"c993c1802df0f075ce92963eb9bff9bd":"":96:"edfab013213591beb53e6419":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2a7b2e07c148ff0f627ae28c241a395876bbed0c20f3fd637330e986db025714":"":"8f7e1621c2227839da4ea60548290ffa":"":96:"f9da62f59c080160ec30b43d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2a7b2e07c148ff0f627ae28c241a395876bbed0c20f3fd637330e986db025714":"":"8f7e1621c2227839da4ea60548290ffa":"":96:"f9da62f59c080160ec30b43d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b3e7837a75b38ae6d4299a1ae4af3c2460dfca558708de0874d6b1a5689b8360":"":"05d363b2452beff4b47afb052ac3c973":"":96:"6b4a16d1ea1c21b22bdcb235":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b3e7837a75b38ae6d4299a1ae4af3c2460dfca558708de0874d6b1a5689b8360":"":"05d363b2452beff4b47afb052ac3c973":"":96:"6b4a16d1ea1c21b22bdcb235":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9df3ccd95f7570f6ecf5e5329dcb79bcd46cbcf083fe03aa8f5bd0f645c6a607":"":"774f4e70a7577b5101c0c3d019655d3e":"":64:"98ff89a8e28c03fd":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9df3ccd95f7570f6ecf5e5329dcb79bcd46cbcf083fe03aa8f5bd0f645c6a607":"":"774f4e70a7577b5101c0c3d019655d3e":"":64:"98ff89a8e28c03fd":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1c7123e2e8d3774c8f1bdbb2272f19129e04f29b4351ae19c3b9d24e6ea1fe87":"":"99f25cebd6cfa7f41390b42df6a65f48":"":64:"8e14a0a4853a156a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1c7123e2e8d3774c8f1bdbb2272f19129e04f29b4351ae19c3b9d24e6ea1fe87":"":"99f25cebd6cfa7f41390b42df6a65f48":"":64:"8e14a0a4853a156a":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"490090323e9257517e2453469caa3414045cacb4d05d5cebc6b9c06fa6d19291":"":"c1beff1ff6cdd62339aa21149c4da1e6":"":64:"f998d7c08d609b3a":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"490090323e9257517e2453469caa3414045cacb4d05d5cebc6b9c06fa6d19291":"":"c1beff1ff6cdd62339aa21149c4da1e6":"":64:"f998d7c08d609b3a":"":"":0 AES-GCM NIST Validation (AES-256,128,0,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"360e48dd38d9e7f5bf29a2994ab5b3c9c70247102d94049ae791850807a4c845":"":"88126c350dfc079c569210ee44a0e31a":"":32:"f2ebe5e4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"360e48dd38d9e7f5bf29a2994ab5b3c9c70247102d94049ae791850807a4c845":"":"88126c350dfc079c569210ee44a0e31a":"":32:"f2ebe5e4":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1562b32e4dd843edaf4474b62cadd8f46d50461f5b22c9f1a8eae7367d35d71b":"":"af29fdb96f726c76f76c473c873b9e08":"":32:"13fd6dfd":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1562b32e4dd843edaf4474b62cadd8f46d50461f5b22c9f1a8eae7367d35d71b":"":"af29fdb96f726c76f76c473c873b9e08":"":32:"13fd6dfd":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d5160d0c98ffcb1c26aad755f67589000e2bb25fa940e6b1d81d780f421353d9":"":"1552604763453b48a57cea1aed8113f4":"":32:"660c5175":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d5160d0c98ffcb1c26aad755f67589000e2bb25fa940e6b1d81d780f421353d9":"":"1552604763453b48a57cea1aed8113f4":"":32:"660c5175":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c3a3ea3a097c0c2b3a4cb78462d87fd5a8f348687c4150e9d3354b388ab13d17":"":"f77945979241fb3a454d8e3da193e169":"a69bac31241a2c07d3f7e331b77f662b1e67ccb81c07f52578b01f5785de9437f02eb7627ca7b9af09c1cb428fe93d6deb31f4d6dd2f0729f87480bdeb92d985de1aaad4bcebc6fbad83bede9a5dd1ca6a15bf5d8a96d4edb5bee1f7d195e9b2e5fb2221a596d69f257c18a143eda870e22d3f2ed20c9b3b0d8c8a229c462fff":128:"6b4b1a84f49befe3897d59ce85598a9f":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c3a3ea3a097c0c2b3a4cb78462d87fd5a8f348687c4150e9d3354b388ab13d17":"":"f77945979241fb3a454d8e3da193e169":"a69bac31241a2c07d3f7e331b77f662b1e67ccb81c07f52578b01f5785de9437f02eb7627ca7b9af09c1cb428fe93d6deb31f4d6dd2f0729f87480bdeb92d985de1aaad4bcebc6fbad83bede9a5dd1ca6a15bf5d8a96d4edb5bee1f7d195e9b2e5fb2221a596d69f257c18a143eda870e22d3f2ed20c9b3b0d8c8a229c462fff":128:"6b4b1a84f49befe3897d59ce85598a9f":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e1626327d987342cba5c8c63b75b4ed65463a2b9c831f4f9f80325fa867d1d73":"":"4e25800deab7ecec2a2311f8fb44eb7d":"ebaffd558f24dae03117c69ac4b2b4aaeaffe7e0e7599eaba678bfce23a9914dc9f80b69f4a1c837a5544cba08064a8f924064cba4d783623600d8b61837a08b4e0d4eb9218c29bc3edb8dd0e78c1534ab52331f949b09b25fbf73bece7054179817bc15b4e869c5df1af569c2b19cb6d060855be9a15f2cf497c168c4e683f2":128:"8faa0ffb91311a1a2827b86fec01788d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e1626327d987342cba5c8c63b75b4ed65463a2b9c831f4f9f80325fa867d1d73":"":"4e25800deab7ecec2a2311f8fb44eb7d":"ebaffd558f24dae03117c69ac4b2b4aaeaffe7e0e7599eaba678bfce23a9914dc9f80b69f4a1c837a5544cba08064a8f924064cba4d783623600d8b61837a08b4e0d4eb9218c29bc3edb8dd0e78c1534ab52331f949b09b25fbf73bece7054179817bc15b4e869c5df1af569c2b19cb6d060855be9a15f2cf497c168c4e683f2":128:"8faa0ffb91311a1a2827b86fec01788d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"938da64b837275b0c80c442bdf2301aa75e387fe65a775d10a8ec840f62ff429":"":"dec6adeb60216cbb8a6c3afba49fa201":"4ac144bd95f405649444f01ab67ef3e4c0a54fdbd933b6ba00518c79db45c22c90030c45aadcfdb53ec8199be0cbb22dbb9ab938a871f4b3b0c98ed32590a051abb946c42726b3e9701f183b2092985e3457943a6350fbcaece2e6b111b179ea3fd10ac080a577a1481785111d5f294bc28519c470ff94392a51a2c40a42d8b5":128:"2211ca91a809adb8cf55f001745c0563":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"938da64b837275b0c80c442bdf2301aa75e387fe65a775d10a8ec840f62ff429":"":"dec6adeb60216cbb8a6c3afba49fa201":"4ac144bd95f405649444f01ab67ef3e4c0a54fdbd933b6ba00518c79db45c22c90030c45aadcfdb53ec8199be0cbb22dbb9ab938a871f4b3b0c98ed32590a051abb946c42726b3e9701f183b2092985e3457943a6350fbcaece2e6b111b179ea3fd10ac080a577a1481785111d5f294bc28519c470ff94392a51a2c40a42d8b5":128:"2211ca91a809adb8cf55f001745c0563":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e2436484ea1f454d6451ad8dbd1574b208d7a3ab4fa34869299b85c24348b43d":"":"97040d2ec094fe1c64fa35b35b7451a7":"bc198677513ce0e66697dfe52b22315fa5d8f92042f34cc9f373a01f94607df1a599132f60af010ed9b5e52162dd7b162912b68b11700e08f5fdafd84d10f760fc05ec97c05b83e55155194f399594015b90a19c04fb992e228940fe1b54ba59c4bb8318b33cc0df1cb1d71c389473dfb3eefabfe269ca95db59a7bc0201c253":120:"2e080ba16011e22a779da1922345c2":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e2436484ea1f454d6451ad8dbd1574b208d7a3ab4fa34869299b85c24348b43d":"":"97040d2ec094fe1c64fa35b35b7451a7":"bc198677513ce0e66697dfe52b22315fa5d8f92042f34cc9f373a01f94607df1a599132f60af010ed9b5e52162dd7b162912b68b11700e08f5fdafd84d10f760fc05ec97c05b83e55155194f399594015b90a19c04fb992e228940fe1b54ba59c4bb8318b33cc0df1cb1d71c389473dfb3eefabfe269ca95db59a7bc0201c253":120:"2e080ba16011e22a779da1922345c2":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7fb3fc72eb8a3aa5b102f90039f852cc3fd64f46915f5e49f1d9e02fe9cc13b1":"":"f6120fea313362524917c53d90bafb4f":"60c2be7fbd15faf895fd19a9ce775fe2b183b45cffafe4fcbf50d421bea97347e41a9418cfa129b2dda63b889a70063010215dbe38c37feae18bc31b34f31b726f22177f2b4b9d648dd4aa80edfd12dafaee10baa83224354432d1cb62ccabe38bb8448d162cd0d30e988d2e1a2458ffdafaacbdff928756390f66dc60d7ea45":120:"83de3f521fcfdaff902386f359e683":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7fb3fc72eb8a3aa5b102f90039f852cc3fd64f46915f5e49f1d9e02fe9cc13b1":"":"f6120fea313362524917c53d90bafb4f":"60c2be7fbd15faf895fd19a9ce775fe2b183b45cffafe4fcbf50d421bea97347e41a9418cfa129b2dda63b889a70063010215dbe38c37feae18bc31b34f31b726f22177f2b4b9d648dd4aa80edfd12dafaee10baa83224354432d1cb62ccabe38bb8448d162cd0d30e988d2e1a2458ffdafaacbdff928756390f66dc60d7ea45":120:"83de3f521fcfdaff902386f359e683":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"697c96d80d0a3fa9af35b86f31fb71a17aed30ce841c79896bbc8863b3b3ee04":"":"3a5163ec7e007061838d755ac219855e":"de50c12da63232768d5eb9920d49683b5b7114cb77448fa10b9d63552ec5d9c2eac94b375d11f944959f903bb20c696639b6e7f108ec1e873870098c631ddacb2c25268cfc26d2a4cacfb7dda7383374c5456bcf4daa887a887f4293f8caa14419472a8bf7ffd214dfb2743091238b6d1142b116c2b9f4360c6fe0015cd7de81":120:"cd4542b26094a1c8e058648874f06f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"697c96d80d0a3fa9af35b86f31fb71a17aed30ce841c79896bbc8863b3b3ee04":"":"3a5163ec7e007061838d755ac219855e":"de50c12da63232768d5eb9920d49683b5b7114cb77448fa10b9d63552ec5d9c2eac94b375d11f944959f903bb20c696639b6e7f108ec1e873870098c631ddacb2c25268cfc26d2a4cacfb7dda7383374c5456bcf4daa887a887f4293f8caa14419472a8bf7ffd214dfb2743091238b6d1142b116c2b9f4360c6fe0015cd7de81":120:"cd4542b26094a1c8e058648874f06f":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"66c1d9ce3feb0e966c33e3fd542ec11cc32f18c2514b953103d32abcdc72633a":"":"46fdb88fdde9b7d74e893802a0303256":"55d2f263d2e3cf0b390fce1dd1ebd5f666086f26e1ce2f08002bedbb810ada3922c6bfcf6a6adaa556e9e326c9766f02b3eb6e278da2fa3baa7dbdb6373be3c6ecfbe646b1a39e27c5a449db9b559e7ea3496366b8cdbca00ee7a3dea7fdfbea1665bbf58bd69bb961c33a0fd7d37b580b6a82804f394f9d5d4366772cee3115":112:"96ca402b16b0f2cd0cdff77935d3":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"66c1d9ce3feb0e966c33e3fd542ec11cc32f18c2514b953103d32abcdc72633a":"":"46fdb88fdde9b7d74e893802a0303256":"55d2f263d2e3cf0b390fce1dd1ebd5f666086f26e1ce2f08002bedbb810ada3922c6bfcf6a6adaa556e9e326c9766f02b3eb6e278da2fa3baa7dbdb6373be3c6ecfbe646b1a39e27c5a449db9b559e7ea3496366b8cdbca00ee7a3dea7fdfbea1665bbf58bd69bb961c33a0fd7d37b580b6a82804f394f9d5d4366772cee3115":112:"96ca402b16b0f2cd0cdff77935d3":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d7c949420dc9497232cd5810f316d11f9e85d36c430b5943ba79836d88c1eb92":"":"7ef9788ff09cbeedd9569d49083a4097":"ca1de5cc3fcde2638eb72210e551e9c0e0a3f5570d5be83a9a4406b545d854bf17e75b9cd0f4c45722fbd71319a317b72a8798485e9316a1c8102432b83bc95af42f6d50700ba68f6f2e19b6af609b73ad643dfa43da94be32cc09b024e087c120e4d2c20f96f8e9ddfe7eae186a540a22131cedfe556d1ebd9306684e345fd1":112:"8233588fca3ad1698d07b25fa3c4":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d7c949420dc9497232cd5810f316d11f9e85d36c430b5943ba79836d88c1eb92":"":"7ef9788ff09cbeedd9569d49083a4097":"ca1de5cc3fcde2638eb72210e551e9c0e0a3f5570d5be83a9a4406b545d854bf17e75b9cd0f4c45722fbd71319a317b72a8798485e9316a1c8102432b83bc95af42f6d50700ba68f6f2e19b6af609b73ad643dfa43da94be32cc09b024e087c120e4d2c20f96f8e9ddfe7eae186a540a22131cedfe556d1ebd9306684e345fd1":112:"8233588fca3ad1698d07b25fa3c4":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6fe7c70815aa12326cdcbb2d2d3e088bbaaef98b730f87fe8510b33d30e12afe":"":"e0253bd1f19e99a7f8848206fb8ac4a4":"397897eca4856f90d14c3cdfe1ad3cba47e23174ae2dab7d2a6320898584e03bffa3ffd526f416d7b3c579b0f3628744e36eebb5df519240c81d8bbbf5c5966519c5da083ab30a7aa42deae6180e517cdd764b7f77d19cc1a84141817758887a8d7265e7e62279b9d33cd2f1ba10fd54c6c96d4b8a5dbe2318fef629c8e2af0f":112:"477b0a884d788d1905646bd66084":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6fe7c70815aa12326cdcbb2d2d3e088bbaaef98b730f87fe8510b33d30e12afe":"":"e0253bd1f19e99a7f8848206fb8ac4a4":"397897eca4856f90d14c3cdfe1ad3cba47e23174ae2dab7d2a6320898584e03bffa3ffd526f416d7b3c579b0f3628744e36eebb5df519240c81d8bbbf5c5966519c5da083ab30a7aa42deae6180e517cdd764b7f77d19cc1a84141817758887a8d7265e7e62279b9d33cd2f1ba10fd54c6c96d4b8a5dbe2318fef629c8e2af0f":112:"477b0a884d788d1905646bd66084":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cbeefb3817cb02d617f385cf2371d52c8bcbc29e5e7a55cd2da131ca184c6e89":"":"f74156d6400ae46b612531848bffe18f":"1abe2ab05ceccf2391273126fe4a4426b94d2c3b97a7f1cd2ee6bb952bf4a546e972b5a1701d5ddb0e5bb7a248fcb47107a9fc77e4b9806b68a11850119aa239fa8be1370e3a2e1a8b168f7323afdfc4b8917d92570167848a56132d68876abc386c258a9233dc8a9eb73443b052e842c3d63e8b5369acdd038404e4e9a4b038":104:"0cb67cec1820339fa0552702dd":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"cbeefb3817cb02d617f385cf2371d52c8bcbc29e5e7a55cd2da131ca184c6e89":"":"f74156d6400ae46b612531848bffe18f":"1abe2ab05ceccf2391273126fe4a4426b94d2c3b97a7f1cd2ee6bb952bf4a546e972b5a1701d5ddb0e5bb7a248fcb47107a9fc77e4b9806b68a11850119aa239fa8be1370e3a2e1a8b168f7323afdfc4b8917d92570167848a56132d68876abc386c258a9233dc8a9eb73443b052e842c3d63e8b5369acdd038404e4e9a4b038":104:"0cb67cec1820339fa0552702dd":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e6f5f65ce2fc8ec3f602f5df90eb7d506dd771337913680ac16bdcd15c56583d":"":"9212a548c597677d1747e98ce6fb18a4":"55ca486c0183d0134925880d2e21dde0af51c4c77c6038a5a9c0497884e0aa4715bdb5b4bb864acc708ac00b511a24fa08496df6a0ca83259110e97a011b876e748a1d0eae2951ce7c22661a3e2ecf50633c50e3d26fa33c2319c139b288825b7aa5efbd133a5ce7483feecb11167099565e3131d5f0cb360f2174f46cb6b37c":104:"08d7cc52d1637db2a43c399310":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e6f5f65ce2fc8ec3f602f5df90eb7d506dd771337913680ac16bdcd15c56583d":"":"9212a548c597677d1747e98ce6fb18a4":"55ca486c0183d0134925880d2e21dde0af51c4c77c6038a5a9c0497884e0aa4715bdb5b4bb864acc708ac00b511a24fa08496df6a0ca83259110e97a011b876e748a1d0eae2951ce7c22661a3e2ecf50633c50e3d26fa33c2319c139b288825b7aa5efbd133a5ce7483feecb11167099565e3131d5f0cb360f2174f46cb6b37c":104:"08d7cc52d1637db2a43c399310":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0e9a0391435acb57eae2e6217e0941c79a3ff938ec6a19b8a7db2ea972e49f54":"":"27cd1d7af7e491e30c8110cc01392529":"79140d32bb32dace0779e2d37a0f744d6d973e99a279962b43a6c0af63772e8a0a21d5d9dd3c33d4b218cb2f6f24dd8d93bb4e1e6a788cb93135321ecfed455e747fa919b85b63b9e98b4980a8ccb3b19d50d735742cb5853720c2ad37fa5b0e655149583585830f8d799c0d2e67c0dc24fc9273d9730f3bb367c487a5f89a25":104:"fbb477dd4b9898a9abc5a45c63":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0e9a0391435acb57eae2e6217e0941c79a3ff938ec6a19b8a7db2ea972e49f54":"":"27cd1d7af7e491e30c8110cc01392529":"79140d32bb32dace0779e2d37a0f744d6d973e99a279962b43a6c0af63772e8a0a21d5d9dd3c33d4b218cb2f6f24dd8d93bb4e1e6a788cb93135321ecfed455e747fa919b85b63b9e98b4980a8ccb3b19d50d735742cb5853720c2ad37fa5b0e655149583585830f8d799c0d2e67c0dc24fc9273d9730f3bb367c487a5f89a25":104:"fbb477dd4b9898a9abc5a45c63":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"55a12eeca637654252e3e40b371667e3f308b00f2fd2af696223e4cd89e3fd4e":"":"8a3793b6441258360f7f4801b03d0b26":"f5810dc5f25e49bd6d94bc63c2494aa7a579a4056a25f1dd9b2734d0b8731ee52523edd54ff475651d45c213e1bf254327fb0e2c41a7d85345b02bcc9d27b08915d332e1659671991a4bb74055967bebbba6ecceb182f57977130623d5a7b2175fa5a84b334868661c1f450b95562928b4791759796a177d59ed18bbf141e2ad":96:"99230019630647aedebbb24b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"55a12eeca637654252e3e40b371667e3f308b00f2fd2af696223e4cd89e3fd4e":"":"8a3793b6441258360f7f4801b03d0b26":"f5810dc5f25e49bd6d94bc63c2494aa7a579a4056a25f1dd9b2734d0b8731ee52523edd54ff475651d45c213e1bf254327fb0e2c41a7d85345b02bcc9d27b08915d332e1659671991a4bb74055967bebbba6ecceb182f57977130623d5a7b2175fa5a84b334868661c1f450b95562928b4791759796a177d59ed18bbf141e2ad":96:"99230019630647aedebbb24b":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d353f870a9c088de5674efd97646b9c5420b2bcdfcffefcadd81682847e5331":"":"f267fa982af5c85359b6447f9b7715ea":"7cf55630867af5dff747c8dd25bcc531d94a7730a20b6c03d46059ea93fcaa00d07ee17dad0e0dff814b02dfef0cbe00b37fd2f5f95ead7c72be60016f2934d7683fc1e47185c7211c49cb03e209b088edb14e533dbcb792ab7033728904f7ff12381a236dba97894ec1fafcf853ab15fff343f9265d0283acef10168ffd1271":96:"9553b583d4f9a1a8946fe053":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3d353f870a9c088de5674efd97646b9c5420b2bcdfcffefcadd81682847e5331":"":"f267fa982af5c85359b6447f9b7715ea":"7cf55630867af5dff747c8dd25bcc531d94a7730a20b6c03d46059ea93fcaa00d07ee17dad0e0dff814b02dfef0cbe00b37fd2f5f95ead7c72be60016f2934d7683fc1e47185c7211c49cb03e209b088edb14e533dbcb792ab7033728904f7ff12381a236dba97894ec1fafcf853ab15fff343f9265d0283acef10168ffd1271":96:"9553b583d4f9a1a8946fe053":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d227c9ff5d17a984983056fb96f3991932ae8132377529c29238cf7db94a359d":"":"b8f6536f376a7efe0e684acf350bae70":"1cc25da31f90de7fa47ebce92754d3faa99f88d4e25ccab45645c1acdf850d55d7f02f61a0bfdc3125f29259d7da8abef532fe0966c63d3486753c8a2cb63a39349a0641b2f2b9526a03b97d58ca60fbb054c6c164ff2836688b0cad54df2b165bc082eeae660e768dde5130e30f8edc863446661c74da69b9e56de8ae388da0":96:"44b95a37fab232c2efb11231":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d227c9ff5d17a984983056fb96f3991932ae8132377529c29238cf7db94a359d":"":"b8f6536f376a7efe0e684acf350bae70":"1cc25da31f90de7fa47ebce92754d3faa99f88d4e25ccab45645c1acdf850d55d7f02f61a0bfdc3125f29259d7da8abef532fe0966c63d3486753c8a2cb63a39349a0641b2f2b9526a03b97d58ca60fbb054c6c164ff2836688b0cad54df2b165bc082eeae660e768dde5130e30f8edc863446661c74da69b9e56de8ae388da0":96:"44b95a37fab232c2efb11231":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b2a57ef85ffcf0548c3d087012b336c46f6574cf1d97ca087bfad042ee83eec2":"":"3d580402d2a8dc4d7466e5dcb456be7a":"c2b9e95c16e55028794a63ef82d11fb83a2a75dc34a81f238e472c33264534bdd54cd07d02a0ecf9019ad1a6d6c779f339dd479e37940486950f183bade24fca2f24f06d4037b3555b09fc80279ea311769473eb0630b694a29823324cdf780d7d1a50d89f7a23b05f7a8c3ad04b7949aa9e6a55978ba48d8078b5a2fd3c1bbb":64:"072d4118e70cd5ab":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b2a57ef85ffcf0548c3d087012b336c46f6574cf1d97ca087bfad042ee83eec2":"":"3d580402d2a8dc4d7466e5dcb456be7a":"c2b9e95c16e55028794a63ef82d11fb83a2a75dc34a81f238e472c33264534bdd54cd07d02a0ecf9019ad1a6d6c779f339dd479e37940486950f183bade24fca2f24f06d4037b3555b09fc80279ea311769473eb0630b694a29823324cdf780d7d1a50d89f7a23b05f7a8c3ad04b7949aa9e6a55978ba48d8078b5a2fd3c1bbb":64:"072d4118e70cd5ab":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"63889ed5bf2c27d518a696b71c0f85592e3337aae95b5bf07289e4c5dfdc088d":"":"1ad534280a0fac7dce31f2ae4fb73f5a":"be1b9dabea33bb9443e27f674b27931c0fba699a33dc86fab29e50b76a9441030444b465317bbf2949faf908bc1b501d11a5ea2042e4b460a85f3be5836729e523d99b56ef39231d5c6d8ae2c2ab36ef44e2aa02a1f2c559c6e333216c7f9ed5f9b880a88e920219204c99a3ae8f90afd1396563bc59a691a93e0070b0b5fd90":64:"1bcea0ac2c1a0c73":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"63889ed5bf2c27d518a696b71c0f85592e3337aae95b5bf07289e4c5dfdc088d":"":"1ad534280a0fac7dce31f2ae4fb73f5a":"be1b9dabea33bb9443e27f674b27931c0fba699a33dc86fab29e50b76a9441030444b465317bbf2949faf908bc1b501d11a5ea2042e4b460a85f3be5836729e523d99b56ef39231d5c6d8ae2c2ab36ef44e2aa02a1f2c559c6e333216c7f9ed5f9b880a88e920219204c99a3ae8f90afd1396563bc59a691a93e0070b0b5fd90":64:"1bcea0ac2c1a0c73":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"94e3e2c17cfb6f52d4fdba3ba6d18bba891b6662e85df14d7e61f04adb69e0e5":"":"8a80efb3bfe220526997543409fddb4d":"05da1b0f7ac6eef488d3f087ecae7f35abe3ef36d339709dc3fcb5b471979268ee894c3b6c7f984300d70bc5ea5fba923bfb41d88652bdaecc710964c51f3e2ae2c280b7d6c8e3b9a8a8991d19d92d46c8a158123187f19397ad1ad9080b4ffd04b82b5d68d89dacd3e76439013728c1395263e722b28e45dabf1ef46b8e70b5":64:"faa5c13d899f17ea":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"94e3e2c17cfb6f52d4fdba3ba6d18bba891b6662e85df14d7e61f04adb69e0e5":"":"8a80efb3bfe220526997543409fddb4d":"05da1b0f7ac6eef488d3f087ecae7f35abe3ef36d339709dc3fcb5b471979268ee894c3b6c7f984300d70bc5ea5fba923bfb41d88652bdaecc710964c51f3e2ae2c280b7d6c8e3b9a8a8991d19d92d46c8a158123187f19397ad1ad9080b4ffd04b82b5d68d89dacd3e76439013728c1395263e722b28e45dabf1ef46b8e70b5":64:"faa5c13d899f17ea":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe5e479ad0d79dbf717a1f51f5250d467819e444b79cb3def1e0033c80ddadd8":"":"47ce838083fd070d8544c0ad5337cdc6":"98476bf05a18c4ff1b6024dd779c1ac06d838705a0a83fe42bee5fc6ebf3b2a1a5049b67f4aabc8239cd6ff56504bcbad1e2498c159bbec2a6635933945f6ea49e5bc763dcf94f4b3643d3888f16105abb0965e24f51cb4949406124145e9ae31cc76535b4178492f38b311099df2751f674363ae7a58f6f93019653b7e6a6f0":32:"a3958500":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"fe5e479ad0d79dbf717a1f51f5250d467819e444b79cb3def1e0033c80ddadd8":"":"47ce838083fd070d8544c0ad5337cdc6":"98476bf05a18c4ff1b6024dd779c1ac06d838705a0a83fe42bee5fc6ebf3b2a1a5049b67f4aabc8239cd6ff56504bcbad1e2498c159bbec2a6635933945f6ea49e5bc763dcf94f4b3643d3888f16105abb0965e24f51cb4949406124145e9ae31cc76535b4178492f38b311099df2751f674363ae7a58f6f93019653b7e6a6f0":32:"a3958500":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"27d4dedb71a8f68ca5ce2b9e56da772bf5a09b7981d41cd29f485bd2d1adb8d4":"":"7e6f0343c54539717a97b6c8b9f7dec4":"d386db78043f719b7e137cbf79a7f53dda2fe3baccbebb57d499f6eb168e5151f10081d76b72ae0f30165efbdda469e826f9246e59dbcad5c0b27691c00d6c192c24073e99c19cf8c142087c0b83c4ce2fc7ba1e696394e5620ab2d117d5dcd2ac2298997407fd5de07d008de8f9941a4a5f8074736a59404118afac0700be6c":32:"50fd1798":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"27d4dedb71a8f68ca5ce2b9e56da772bf5a09b7981d41cd29f485bd2d1adb8d4":"":"7e6f0343c54539717a97b6c8b9f7dec4":"d386db78043f719b7e137cbf79a7f53dda2fe3baccbebb57d499f6eb168e5151f10081d76b72ae0f30165efbdda469e826f9246e59dbcad5c0b27691c00d6c192c24073e99c19cf8c142087c0b83c4ce2fc7ba1e696394e5620ab2d117d5dcd2ac2298997407fd5de07d008de8f9941a4a5f8074736a59404118afac0700be6c":32:"50fd1798":"":"":0 AES-GCM NIST Validation (AES-256,128,0,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a7aa836a469d28542d0d24d3232fad266da8fc889c6b6038b726d3da25f7b20":"":"9faf7cd805803e143ec8f3f13475efd2":"1006c707f608728b2bf64734062b12a5625062bcdcb80a3ce2058352a2922d5e6fbe19681b4f0d79ad3c837f81e72f2fbf8df669894e802a39072b26c286f4b05188c708f7c6edd5f5bb90b87ffa95b86d84d6c1c4591b11d22c772a8ad7f2fe6bd8b46be0e93672df2e8bff8ba80629e1846cfd4603e75f2d98874665c1a089":32:"07764143":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"5a7aa836a469d28542d0d24d3232fad266da8fc889c6b6038b726d3da25f7b20":"":"9faf7cd805803e143ec8f3f13475efd2":"1006c707f608728b2bf64734062b12a5625062bcdcb80a3ce2058352a2922d5e6fbe19681b4f0d79ad3c837f81e72f2fbf8df669894e802a39072b26c286f4b05188c708f7c6edd5f5bb90b87ffa95b86d84d6c1c4591b11d22c772a8ad7f2fe6bd8b46be0e93672df2e8bff8ba80629e1846cfd4603e75f2d98874665c1a089":32:"07764143":"":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a9444fd176acbe061d0221fde3ddfcc4ff74e995d981a831297c4cbda51c22a1":"c146ff5a988496cad7eced7a2ea471e0117d5d6bd2562c23ce9db4bf36d83ba3fc22e90486ec288a627d208e0b2fd3b65f8301cf7fc41d97959981a95cd1cf37effc46db99b94b21c941c3613c26a10b1a6b7793f467d58ff5134612230f1c49d7e1fcf664fe52fc6eca46273982f6fe729b009d90eb8d8e4a0b0dbe907b76da":"5714732145470da1c42452e10cd274b5":"":128:"db85b830a03357f408587410ebafd10d":"a3cad9a57fa28e6f6aaa37150a803bf8b77e765f0702e492c4e5ebb31ae6b12d791149153e469a92bb625784a699fd7ca517500ee3f2851840ba67063b28b481e24ba441314e8b7128f5aaccaf4c4e2c92258eb27310bf031422b7fc2f220f621d4c64837c9377222aced2411628018a409a744902c9e95c14b77d5bb7f5846b":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a9444fd176acbe061d0221fde3ddfcc4ff74e995d981a831297c4cbda51c22a1":"c146ff5a988496cad7eced7a2ea471e0117d5d6bd2562c23ce9db4bf36d83ba3fc22e90486ec288a627d208e0b2fd3b65f8301cf7fc41d97959981a95cd1cf37effc46db99b94b21c941c3613c26a10b1a6b7793f467d58ff5134612230f1c49d7e1fcf664fe52fc6eca46273982f6fe729b009d90eb8d8e4a0b0dbe907b76da":"5714732145470da1c42452e10cd274b5":"":128:"db85b830a03357f408587410ebafd10d":"":"a3cad9a57fa28e6f6aaa37150a803bf8b77e765f0702e492c4e5ebb31ae6b12d791149153e469a92bb625784a699fd7ca517500ee3f2851840ba67063b28b481e24ba441314e8b7128f5aaccaf4c4e2c92258eb27310bf031422b7fc2f220f621d4c64837c9377222aced2411628018a409a744902c9e95c14b77d5bb7f5846b":0 AES-GCM NIST Validation (AES-256,128,1024,0,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"686d3bd071e3f46f180611bc4ec8d7726fe72b6c617e7d42b3339f53918c9e36":"21983ad66449c557263aef299da6eef8f31d576fc17ed2dac3e836f7c2ceaff3094b2695452680e188df10c174810efd1fbaa6c832baedce0b92e4c7121447f6461ac909b4302cdf658095b1de532b536faa4fb38cfdf4192eb5c3fe090d979a343492f841b1edc6eb24b24bdcb90bbbe36d5f8409ce7d27194a7bb995ecc387":"a714e51e43aecfe2fda8f824ea1dc4b7":"":128:"cd30c3618c10d57e9a4477b4a44c5c36":"9610908a0eb2ee885981c9e512e1a55075a212d311073bbb2fb9248cce07af16ee4c58bdc8dbe806d28480f9065838146f3e1eb3ae97012cfe53863a13d487f061a49a6c78ca22a321fa25157dbe68c47d78f2359540cc9031ee42d78855ed90e6b8ea3d67725bfffcb6db3d438c982b5f88d9b660f7d82cb300c1fa1edebb6b":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"686d3bd071e3f46f180611bc4ec8d7726fe72b6c617e7d42b3339f53918c9e36":"21983ad66449c557263aef299da6eef8f31d576fc17ed2dac3e836f7c2ceaff3094b2695452680e188df10c174810efd1fbaa6c832baedce0b92e4c7121447f6461ac909b4302cdf658095b1de532b536faa4fb38cfdf4192eb5c3fe090d979a343492f841b1edc6eb24b24bdcb90bbbe36d5f8409ce7d27194a7bb995ecc387":"a714e51e43aecfe2fda8f824ea1dc4b7":"":128:"cd30c3618c10d57e9a4477b4a44c5c36":"":"9610908a0eb2ee885981c9e512e1a55075a212d311073bbb2fb9248cce07af16ee4c58bdc8dbe806d28480f9065838146f3e1eb3ae97012cfe53863a13d487f061a49a6c78ca22a321fa25157dbe68c47d78f2359540cc9031ee42d78855ed90e6b8ea3d67725bfffcb6db3d438c982b5f88d9b660f7d82cb300c1fa1edebb6b":0 AES-GCM NIST Validation (AES-256,128,1024,0,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6fe81f15a02e2ecf46e61199c057102d160e6b5d447d4a275972323fff908c3e":"0b4ee0385e6665da8fd2ae47f2d0cf1c5bd395a3bb447047ab5a3ae0b95355bf83d0381119a8d4c01acbe60cd7885da650502f73498a682fdc94f7b14f4c753226064fa15e3a90a6083e053f52f404b0d22394e243b187f913ee2c6bb16c3033f79d794852071970523a67467ce63c35390c163775de2be68b505a63f60245e8":"91d55cfdcdcd7d735d48100ff82227c3":"":128:"cd7da82e890b6d7480c7186b2ea7e6f1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6fe81f15a02e2ecf46e61199c057102d160e6b5d447d4a275972323fff908c3e":"0b4ee0385e6665da8fd2ae47f2d0cf1c5bd395a3bb447047ab5a3ae0b95355bf83d0381119a8d4c01acbe60cd7885da650502f73498a682fdc94f7b14f4c753226064fa15e3a90a6083e053f52f404b0d22394e243b187f913ee2c6bb16c3033f79d794852071970523a67467ce63c35390c163775de2be68b505a63f60245e8":"91d55cfdcdcd7d735d48100ff82227c3":"":128:"cd7da82e890b6d7480c7186b2ea7e6f1":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4c2095e1379389dc3810e8819314f5a2f87d1494213c5b1de1a402f7f4f746c4":"26ec8ebac0560538a948afbc18fb730e9a91f21392bde24b88b200f96114b229a5b57fa9d02cf10e6592d4dfb28bf0f00740c61157ce28784e9066ea3afd44ecf3a494723610cb593c0feffc6897e3435c6f448697ad3e241685c4e133eff53bdd0fe44dd8a033cfb1e1ea37a493934eb5303ae6ef47ce6478f767ef9e3301ab":"19788b2e0bd757947596676436e22df1":"":120:"f26a20bea561004267a0bfbf01674e":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"4c2095e1379389dc3810e8819314f5a2f87d1494213c5b1de1a402f7f4f746c4":"26ec8ebac0560538a948afbc18fb730e9a91f21392bde24b88b200f96114b229a5b57fa9d02cf10e6592d4dfb28bf0f00740c61157ce28784e9066ea3afd44ecf3a494723610cb593c0feffc6897e3435c6f448697ad3e241685c4e133eff53bdd0fe44dd8a033cfb1e1ea37a493934eb5303ae6ef47ce6478f767ef9e3301ab":"19788b2e0bd757947596676436e22df1":"":120:"f26a20bea561004267a0bfbf01674e":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"be5351efc0277afc9759ec2464a22cb4401f7a17efd1a205e7af023c7ed30ee1":"1eca91406f338fc09c2988b1d7dc8c409d719300c03840a497d7b680cdd5e09b144903477f7116a934e1d931cf368af1fc2a0a0e7caa95475a3cd7bf585a16fda31eb3f8201db0216b37a1635c1c030836b3dd05ca5b0194388fa198e717822131d5d4318690ef82d35ac80b27fff19aec8f020dc6c6ce28f0813bbbf8230ad9":"c6b26117d9dbd80c1c242ad41abe2acc":"":120:"61051d6c0801b4a6b6ca0124c019f3":"95447aded336d6c20d483a6f062d533efed0261ad321d37bf8b7321b98f55c0f0082ce7f3d341b18fea29a72fc909d30cd8c84a1640227227287674a9b2f16a81b191ecf3b6232d656c32d7b38bea82a1b27d5897694a2be56d7e39aa1e725f326b91bad20455f58a94a545170cb43d13d4b91e1cee82abb6a6e0d95d4de0567":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"be5351efc0277afc9759ec2464a22cb4401f7a17efd1a205e7af023c7ed30ee1":"1eca91406f338fc09c2988b1d7dc8c409d719300c03840a497d7b680cdd5e09b144903477f7116a934e1d931cf368af1fc2a0a0e7caa95475a3cd7bf585a16fda31eb3f8201db0216b37a1635c1c030836b3dd05ca5b0194388fa198e717822131d5d4318690ef82d35ac80b27fff19aec8f020dc6c6ce28f0813bbbf8230ad9":"c6b26117d9dbd80c1c242ad41abe2acc":"":120:"61051d6c0801b4a6b6ca0124c019f3":"":"95447aded336d6c20d483a6f062d533efed0261ad321d37bf8b7321b98f55c0f0082ce7f3d341b18fea29a72fc909d30cd8c84a1640227227287674a9b2f16a81b191ecf3b6232d656c32d7b38bea82a1b27d5897694a2be56d7e39aa1e725f326b91bad20455f58a94a545170cb43d13d4b91e1cee82abb6a6e0d95d4de0567":0 AES-GCM NIST Validation (AES-256,128,1024,0,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"814c2cdfdeecf39d43bb141fbfc62dac44f7552c5e5dac2d4913303fc860119b":"0d3013a1d7132f685d001420daa6c7b643bc36b887511acc4588237d3b412c79e4ebba29c08248ad46c7239e8daa232b7483c9c4e3d1c0bbebc696401efe21f7fd6fc0525a4ab81bd9a893d5f7ab23b70ed07c00f33649b8a996a006de6c94f7793f72848793f4d5b31311c68aae1e715b37409fbe506dac038a0950f05fe82b":"0db3ade15cb0dea98a47d1377e034d63":"":120:"e62f910b6046ba4e934d3cfc6e024c":"374d03cfe4dacf668df5e703902cc784f011f418b43887702972dcc3f021bcb9bdd61ed5425f2975b6da7052c4859501eb2f295eb95d10ba6b2d74e7decc1acacebf8568e93a70a7f40be41ac38db6f751518c2f44a69c01c44745c51ad9a333eda9c89d001aa644f1e4063a8eb2a3592e21c6abc515b5aacaec8c32bcf1d3c4":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"814c2cdfdeecf39d43bb141fbfc62dac44f7552c5e5dac2d4913303fc860119b":"0d3013a1d7132f685d001420daa6c7b643bc36b887511acc4588237d3b412c79e4ebba29c08248ad46c7239e8daa232b7483c9c4e3d1c0bbebc696401efe21f7fd6fc0525a4ab81bd9a893d5f7ab23b70ed07c00f33649b8a996a006de6c94f7793f72848793f4d5b31311c68aae1e715b37409fbe506dac038a0950f05fe82b":"0db3ade15cb0dea98a47d1377e034d63":"":120:"e62f910b6046ba4e934d3cfc6e024c":"":"374d03cfe4dacf668df5e703902cc784f011f418b43887702972dcc3f021bcb9bdd61ed5425f2975b6da7052c4859501eb2f295eb95d10ba6b2d74e7decc1acacebf8568e93a70a7f40be41ac38db6f751518c2f44a69c01c44745c51ad9a333eda9c89d001aa644f1e4063a8eb2a3592e21c6abc515b5aacaec8c32bcf1d3c4":0 AES-GCM NIST Validation (AES-256,128,1024,0,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1ae4541110f2bc4f83cd720b5c40c8315413d896e034b75007f172baa13d29ec":"5ea811e7fbfc0e00bf2a6abfac50cad9efd90041c5f7fb8f046a0fecbd193b70a2de8a774d01dd3cd54f848cb3e9f5152ee1b052ba698bebfba1fbbdae44a260447d6e6482640ae4d01c9cac3d37d4ffe9a0de0b6001de504a33ef7620efe3ce48ecd6f5b1b3a89185c86d4d662a843ff730e040e3668d6170be4cced8a18a1c":"83f98eec51ee4cae4cb7fe28b64d1355":"":112:"df47eef69ba2faab887aa8f48e4b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1ae4541110f2bc4f83cd720b5c40c8315413d896e034b75007f172baa13d29ec":"5ea811e7fbfc0e00bf2a6abfac50cad9efd90041c5f7fb8f046a0fecbd193b70a2de8a774d01dd3cd54f848cb3e9f5152ee1b052ba698bebfba1fbbdae44a260447d6e6482640ae4d01c9cac3d37d4ffe9a0de0b6001de504a33ef7620efe3ce48ecd6f5b1b3a89185c86d4d662a843ff730e040e3668d6170be4cced8a18a1c":"83f98eec51ee4cae4cb7fe28b64d1355":"":112:"df47eef69ba2faab887aa8f48e4b":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"20c9b662ec4bd13bf58d64cb0a7159b0e7fee4703af66292bf75c8bd6e42e8dc":"45b64f2ed5ac707890c0c1726adf338770ce6a728fe86bb372c4c49409a32705f881bc4d31a27c455c7c7df9dd2c541743523e7d32f88930d988857847f011be5f5f31a31e8812745147cbff5c1294d0fd4a7285db4833f22bf1975250da99c4d0dd2c9688d7f8001bb6ef2bc898ce4d42c5b78e74645b56ce992338f49d4183":"2bc0847d46f3d1064bbf8fe8567f54a2":"":112:"5a1bf25aa8d5c3fe5cf1be8e54a1":"9079d6275db076625e8474c2914fe483d413d5339202f98f06c3b0ef063d8f3d31029deaf7f9349bfec57e5cf11f46f02d5a6520c7992efc951adbbea6d08e53faeb10dfe8b67ee4685da9ea4fe932551a65821147d06d4c462338e6ddda52017c2bc187fd6d02b7d5193f77da809d4e59a9061efad2f9cadbc4cd9b29728d32":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"20c9b662ec4bd13bf58d64cb0a7159b0e7fee4703af66292bf75c8bd6e42e8dc":"45b64f2ed5ac707890c0c1726adf338770ce6a728fe86bb372c4c49409a32705f881bc4d31a27c455c7c7df9dd2c541743523e7d32f88930d988857847f011be5f5f31a31e8812745147cbff5c1294d0fd4a7285db4833f22bf1975250da99c4d0dd2c9688d7f8001bb6ef2bc898ce4d42c5b78e74645b56ce992338f49d4183":"2bc0847d46f3d1064bbf8fe8567f54a2":"":112:"5a1bf25aa8d5c3fe5cf1be8e54a1":"":"9079d6275db076625e8474c2914fe483d413d5339202f98f06c3b0ef063d8f3d31029deaf7f9349bfec57e5cf11f46f02d5a6520c7992efc951adbbea6d08e53faeb10dfe8b67ee4685da9ea4fe932551a65821147d06d4c462338e6ddda52017c2bc187fd6d02b7d5193f77da809d4e59a9061efad2f9cadbc4cd9b29728d32":0 AES-GCM NIST Validation (AES-256,128,1024,0,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0a1554db37f2e275732a77e521cbd8170729d8677a85db73feacf3c66a89d689":"5421d93b7e6e0091978c673df4f3a406aef5f13eb5e6f95da19b0783308cbe26d4fd6c669cc4a9f069d7e62e4c6fad14b80e918fe91556a9a941a28b3dbf776a68ac7c42df7059b5ed713e78120aec84e7b68e96226c2b5e11a994864ed61b122e7e42ef6cfdae278fadbae1b3ea3362f4e6dc68eef6a70477b8a3ffcfba0df9":"b9194a4d42b139f04c29178467955f1d":"":112:"05949d591793ca52e679bfdf64f3":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0a1554db37f2e275732a77e521cbd8170729d8677a85db73feacf3c66a89d689":"5421d93b7e6e0091978c673df4f3a406aef5f13eb5e6f95da19b0783308cbe26d4fd6c669cc4a9f069d7e62e4c6fad14b80e918fe91556a9a941a28b3dbf776a68ac7c42df7059b5ed713e78120aec84e7b68e96226c2b5e11a994864ed61b122e7e42ef6cfdae278fadbae1b3ea3362f4e6dc68eef6a70477b8a3ffcfba0df9":"b9194a4d42b139f04c29178467955f1d":"":112:"05949d591793ca52e679bfdf64f3":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3ab1d9bb571c4bdc9f3ef340914bddcfe0c8e7718d4a2530334372cec86e5fcb":"80bcea307e009745724d5f15d21f3b61a5d5a8401530346b34a2adfa13e3e8c9c9327d6fad914b081e554fbe6c1c6fe070b566620e559555c702c0ab5becf61ea1d9de64351ce43b2276ef4e20b5af7ce43db6d21286af4e740ef00c6d790705afcf0ee4850fffc12c662f2bd8212feb21db31065ab8f717a7509c213352b869":"6a5335901284dd3b64dc4a7f810bab96":"":104:"04b8e5423aee8c06539f435edd":"36b9602eee20b8f18dce0783cd1e01a799f81ae0a1ce6d293a26c62f47e7dad85c8446697cc09c81d3d9ead6f9e55c4147211660c8aea9536cc5516e9883c7d6854be580af8cd47ba38fa8451f0dad9c904e0e7f9997eff7e29bf880cd7cedd79493a0e299efe644046e4a46bf6645dfb2397b3a482a346b215deb778c9b7636":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"3ab1d9bb571c4bdc9f3ef340914bddcfe0c8e7718d4a2530334372cec86e5fcb":"80bcea307e009745724d5f15d21f3b61a5d5a8401530346b34a2adfa13e3e8c9c9327d6fad914b081e554fbe6c1c6fe070b566620e559555c702c0ab5becf61ea1d9de64351ce43b2276ef4e20b5af7ce43db6d21286af4e740ef00c6d790705afcf0ee4850fffc12c662f2bd8212feb21db31065ab8f717a7509c213352b869":"6a5335901284dd3b64dc4a7f810bab96":"":104:"04b8e5423aee8c06539f435edd":"":"36b9602eee20b8f18dce0783cd1e01a799f81ae0a1ce6d293a26c62f47e7dad85c8446697cc09c81d3d9ead6f9e55c4147211660c8aea9536cc5516e9883c7d6854be580af8cd47ba38fa8451f0dad9c904e0e7f9997eff7e29bf880cd7cedd79493a0e299efe644046e4a46bf6645dfb2397b3a482a346b215deb778c9b7636":0 AES-GCM NIST Validation (AES-256,128,1024,0,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7dddbd5657e22750bfe6baa70a1f4ac46c1ef8bee573a57cfcef50b66f85e593":"2bf5aba83a8161b9d21ff29251fb0efa697b1ea9c1b3de8481d5fd4d6b57afda0b098decdc8278cc855f25da4116ed558fc4e665a49a8fff3aef11115757a99c10b5a73b1f794f9502186c13dc79442f9226bbf4df19a6440281f76184933aeae438a25f85dbd0781e020a9f7e29fb8e517f597719e639cbd6061ea3b4b67fb0":"fcb962c39e4850efc8ffd43d9cd960a6":"":104:"1d8cdadcf1872fb2b697e82ef6":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7dddbd5657e22750bfe6baa70a1f4ac46c1ef8bee573a57cfcef50b66f85e593":"2bf5aba83a8161b9d21ff29251fb0efa697b1ea9c1b3de8481d5fd4d6b57afda0b098decdc8278cc855f25da4116ed558fc4e665a49a8fff3aef11115757a99c10b5a73b1f794f9502186c13dc79442f9226bbf4df19a6440281f76184933aeae438a25f85dbd0781e020a9f7e29fb8e517f597719e639cbd6061ea3b4b67fb0":"fcb962c39e4850efc8ffd43d9cd960a6":"":104:"1d8cdadcf1872fb2b697e82ef6":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6916b93b2712421f1f4582de7ec4237c4e42e2b32c7dced2f8bb5bd2e0598312":"3739cca20279a36ddb857ac22beae901a49529b3182463ab81a7c46e437eb0b0571e8c16f7b626ecd9f2ca0cd83debe3f83e5d58ed3738899f4b616755eb57fb965208f261736bdf7648b1f8595c6b6a779768115e3077dfee7a42d44b555a51675fb1ce9961d0e21b2b9b477c0541184350e70decf7c14a4c24b8a6cd5fed8e":"b4d9248bb500e40de99ca2a13e743f1c":"":104:"090d03446d65adcc0a42387e8e":"0255be7ac7ac6feb3a21f572f6a593cc8a97f17af7064c80e478f4a6c469cf94d604bc014b003bf284d216161a9c8a493af43c6a0d8caf813a9e6f83c7ed56dd57543876b11f76aa2be80dcd79d19ac61f00fa423ac2f52fae7a8327cd91494ca4116feb735980ad0a4b1445cb7f38cc712b8aee72179e65b97fca38694e3670":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6916b93b2712421f1f4582de7ec4237c4e42e2b32c7dced2f8bb5bd2e0598312":"3739cca20279a36ddb857ac22beae901a49529b3182463ab81a7c46e437eb0b0571e8c16f7b626ecd9f2ca0cd83debe3f83e5d58ed3738899f4b616755eb57fb965208f261736bdf7648b1f8595c6b6a779768115e3077dfee7a42d44b555a51675fb1ce9961d0e21b2b9b477c0541184350e70decf7c14a4c24b8a6cd5fed8e":"b4d9248bb500e40de99ca2a13e743f1c":"":104:"090d03446d65adcc0a42387e8e":"":"0255be7ac7ac6feb3a21f572f6a593cc8a97f17af7064c80e478f4a6c469cf94d604bc014b003bf284d216161a9c8a493af43c6a0d8caf813a9e6f83c7ed56dd57543876b11f76aa2be80dcd79d19ac61f00fa423ac2f52fae7a8327cd91494ca4116feb735980ad0a4b1445cb7f38cc712b8aee72179e65b97fca38694e3670":0 AES-GCM NIST Validation (AES-256,128,1024,0,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b751c8b724165009a8bd97a9d2a0e22cae5a95c4743c55eeeef0a6fe7d946bec":"e8546a5af1e38114822e60e75563a9399c88796f303c99c69d1f3c50379da81e1cd5b5a4a721e23c59da58ea4361b7ff58408e506a27fea24f9a235c6af7f7a5bd93fa31e90edfc322821c08d6324134830b7fe160b4a3e6d27866a10e6e60762a31618ef92f5c67ccb1deb1f1b188f0e687165e7c366c7418920df4f4fcdcae":"160c50c0621c03fd1572df6ba49f0d1e":"":96:"9fef9becf21901496772996f":"175fa6b7cd781ec057ff78ba410f2897a920739b5fc4f04bc9b998fbc7cc18e327ad44d59b167e4627256aaecd97dc3e4a7c9baaf51d177787a7f4a0a2d207a855753c4754d41348982d9418b6b24b590632d5115dc186b0ba3bec16b41fa47c0077c5d091ec705e554475024814c5167121dd224c544686398df3f33c210e82":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b751c8b724165009a8bd97a9d2a0e22cae5a95c4743c55eeeef0a6fe7d946bec":"e8546a5af1e38114822e60e75563a9399c88796f303c99c69d1f3c50379da81e1cd5b5a4a721e23c59da58ea4361b7ff58408e506a27fea24f9a235c6af7f7a5bd93fa31e90edfc322821c08d6324134830b7fe160b4a3e6d27866a10e6e60762a31618ef92f5c67ccb1deb1f1b188f0e687165e7c366c7418920df4f4fcdcae":"160c50c0621c03fd1572df6ba49f0d1e":"":96:"9fef9becf21901496772996f":"":"175fa6b7cd781ec057ff78ba410f2897a920739b5fc4f04bc9b998fbc7cc18e327ad44d59b167e4627256aaecd97dc3e4a7c9baaf51d177787a7f4a0a2d207a855753c4754d41348982d9418b6b24b590632d5115dc186b0ba3bec16b41fa47c0077c5d091ec705e554475024814c5167121dd224c544686398df3f33c210e82":0 AES-GCM NIST Validation (AES-256,128,1024,0,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0faf32c22c2a4ee38fe4b5ce08f98fdf6f83b5038dcba5ec8332b3eeb5c710c7":"8a556cc30075753c6e94c2f669bca2058ff6abcbffffc82da7cfca0a45af82dfb4cf487ceb4ede72be87ee4c8b72db1e96459de1dc96721464c544c001d785f2188b9fccaec4b1a37970d38b326f30163d2fdfdf8a2ce74aec55abcd823772b54f8081d086a2e7b17b4086d6c4a5ea67828ef0b593ea1387b2c61f5dfe8f2bb0":"04885a5846f5f75a760193de7f07853c":"":96:"0c13506ed9f082dd08434342":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0faf32c22c2a4ee38fe4b5ce08f98fdf6f83b5038dcba5ec8332b3eeb5c710c7":"8a556cc30075753c6e94c2f669bca2058ff6abcbffffc82da7cfca0a45af82dfb4cf487ceb4ede72be87ee4c8b72db1e96459de1dc96721464c544c001d785f2188b9fccaec4b1a37970d38b326f30163d2fdfdf8a2ce74aec55abcd823772b54f8081d086a2e7b17b4086d6c4a5ea67828ef0b593ea1387b2c61f5dfe8f2bb0":"04885a5846f5f75a760193de7f07853c":"":96:"0c13506ed9f082dd08434342":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0dddc3d2f82bdcdbc37648a6b9b416af28753740f8e998cd1a52a0b665369f1c":"07bf84b15b21951fd22049be6991a672503ae243b8d285fb1e515e1d2c36bfd5b0d0bcce85791f2cea8f616aed68a7d9cf4eaf76418e8b1ec27751de67cbfd9d9f7905b2667904f10d598503f04c04ea00a681ff89a9c446d5763898430bd7a9dfebfe544e3ed3e639b362683a651e087626ffa63c0c2b3e0dd088b81b07f75e":"0a93b883cbd42998ae2e39aab342cb28":"":96:"5c37918edb7aa65b246fd5a6":"ff7b7b2f88b8c6f9f9bad7152874e995eea0ff1ce1ecd9b8d563642a37a31499f14d70f0dd835b7adf80928497f845fd8c2786cd53af25f8c9fe1bba24e3c3860162635bbed58f06cf6c9966bb9b570987a48329279bb84afb9e464bb4ad19ae6600175086e28929569027c5285d2ed97615e5a7dada40ba03c440861f524475":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0dddc3d2f82bdcdbc37648a6b9b416af28753740f8e998cd1a52a0b665369f1c":"07bf84b15b21951fd22049be6991a672503ae243b8d285fb1e515e1d2c36bfd5b0d0bcce85791f2cea8f616aed68a7d9cf4eaf76418e8b1ec27751de67cbfd9d9f7905b2667904f10d598503f04c04ea00a681ff89a9c446d5763898430bd7a9dfebfe544e3ed3e639b362683a651e087626ffa63c0c2b3e0dd088b81b07f75e":"0a93b883cbd42998ae2e39aab342cb28":"":96:"5c37918edb7aa65b246fd5a6":"":"ff7b7b2f88b8c6f9f9bad7152874e995eea0ff1ce1ecd9b8d563642a37a31499f14d70f0dd835b7adf80928497f845fd8c2786cd53af25f8c9fe1bba24e3c3860162635bbed58f06cf6c9966bb9b570987a48329279bb84afb9e464bb4ad19ae6600175086e28929569027c5285d2ed97615e5a7dada40ba03c440861f524475":0 AES-GCM NIST Validation (AES-256,128,1024,0,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a0b1a62e46e7712277fc711e19d0c0c865ee77b42ac964b7202dbcaf428086c2":"7dd7c0787fdbea4aacf929341659dcf4b75cbca8f92001e8b62a4d7b40272c5755fa9c445857db05328dc11ce5221f044f4b3dafbf0e2d72a1ad0d3e4c804148db578218690ccc620d8b97b4450ff83400a6caaa959617611446a6627138a4067be9ea410d4b0581022ab621928205b4a4480560fc4c2c3b39a2805684006f35":"e20957a49a27e247d00379850f934d6c":"":64:"c99751516620bf89":"9307620479f076c39f53965c87d20c2aff11c736c040dba74cd690d275591a5defc57a02f6806de82eb7051548589484364f6c9b91f233a87258ede1ee276cb2c93b4fc76f4d7e60cbd29ba2c54cb479c178fa462c1c2fb6eeb3f1df0edfb894c9222b994c4931dedf7c6e8ddecbde385ddf4481807f52322a47bf5ff7272991":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"a0b1a62e46e7712277fc711e19d0c0c865ee77b42ac964b7202dbcaf428086c2":"7dd7c0787fdbea4aacf929341659dcf4b75cbca8f92001e8b62a4d7b40272c5755fa9c445857db05328dc11ce5221f044f4b3dafbf0e2d72a1ad0d3e4c804148db578218690ccc620d8b97b4450ff83400a6caaa959617611446a6627138a4067be9ea410d4b0581022ab621928205b4a4480560fc4c2c3b39a2805684006f35":"e20957a49a27e247d00379850f934d6c":"":64:"c99751516620bf89":"":"9307620479f076c39f53965c87d20c2aff11c736c040dba74cd690d275591a5defc57a02f6806de82eb7051548589484364f6c9b91f233a87258ede1ee276cb2c93b4fc76f4d7e60cbd29ba2c54cb479c178fa462c1c2fb6eeb3f1df0edfb894c9222b994c4931dedf7c6e8ddecbde385ddf4481807f52322a47bf5ff7272991":0 AES-GCM NIST Validation (AES-256,128,1024,0,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ffcc1c88fba1723b3ab57b458d9bffb98b878c967fb43b9db2ae0753d32a3bb1":"19b6dec86d93c466307de3a36c0791ed1010b1b9cf8d30347ae46e0f9283c9fda43da8cb491dd17cc4298b1f0b876d6a0f4bcbc9667fe34564bc08f8f7b67045057d19f4bf027bc839e590822fa09a5cef1af18e64a0116aa2a01a3f246c2b5272c18c9aa23efe674ba53d533ae8f0695cb78c1155cdc7a9d7fae2c4567dc07c":"d533c2170c5dc203512c81c34eff4077":"":64:"167ec8675e7f9e12":"0539287ac546fe5342e4c3c0ec07127dcd22899abfe8cdd6e89d08f1374d76e877bec4844d06e0a9f32d181c8d945ba16a54ce3725fae21d8245c070a4da0c646203d6b91325b665ab98c30295851c59265b4ab567b968b6e98536b7850738d92e9627b4c9c6f5d9ae2520944783d8f788a1aa11f3f5245660d41f388e26e0a1":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ffcc1c88fba1723b3ab57b458d9bffb98b878c967fb43b9db2ae0753d32a3bb1":"19b6dec86d93c466307de3a36c0791ed1010b1b9cf8d30347ae46e0f9283c9fda43da8cb491dd17cc4298b1f0b876d6a0f4bcbc9667fe34564bc08f8f7b67045057d19f4bf027bc839e590822fa09a5cef1af18e64a0116aa2a01a3f246c2b5272c18c9aa23efe674ba53d533ae8f0695cb78c1155cdc7a9d7fae2c4567dc07c":"d533c2170c5dc203512c81c34eff4077":"":64:"167ec8675e7f9e12":"":"0539287ac546fe5342e4c3c0ec07127dcd22899abfe8cdd6e89d08f1374d76e877bec4844d06e0a9f32d181c8d945ba16a54ce3725fae21d8245c070a4da0c646203d6b91325b665ab98c30295851c59265b4ab567b968b6e98536b7850738d92e9627b4c9c6f5d9ae2520944783d8f788a1aa11f3f5245660d41f388e26e0a1":0 AES-GCM NIST Validation (AES-256,128,1024,0,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"55e94b339c3bafe068ef9cc30787cc6705850114976843777c92b4b331801650":"147cc7bc4008dadf1956520b5998d961499bdf3d8b168591adbfd99411ad7b34eb4b2a5c1bb0522b810fec12dd7c775784d7ecdc741e6dec8191361e6abf473b219221801951b4d5ffe955ab50eef9cffdfee65ba29ddfa943fb52d722825338c307870a48a35f51db340aa946c71904d03174b1e4a498238b9d631a6982c68d":"2e2b31214d61276a54daf2ccb98baa36":"":64:"5266e9c67c252164":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"55e94b339c3bafe068ef9cc30787cc6705850114976843777c92b4b331801650":"147cc7bc4008dadf1956520b5998d961499bdf3d8b168591adbfd99411ad7b34eb4b2a5c1bb0522b810fec12dd7c775784d7ecdc741e6dec8191361e6abf473b219221801951b4d5ffe955ab50eef9cffdfee65ba29ddfa943fb52d722825338c307870a48a35f51db340aa946c71904d03174b1e4a498238b9d631a6982c68d":"2e2b31214d61276a54daf2ccb98baa36":"":64:"5266e9c67c252164":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,0,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"13c9572bdef62510d84f2d415cc481cd1e71b9c1132b43e63b21ba4e16de9b39":"7c78e634dec811173ff3c4a9a48ae3ae794fbd2aefd4b31701777ff6fcb670744c592a1d298d319717870dca364b2a3562a4ffa422bf7173c4f7ea9b0edf675e948f8370ffd0fd0d5703a9d33e8f9f375b8b641a1b1eecd1692ad1d461a68d97f91f9087f213aff23db1246ee16f403969c238f99eed894658277da23ced11ee":"a8339ba505a14786ad05edfe8cebb8d0":"":32:"df3cab08":"91f9780daefd2c1010c458054ac6e35baa885cdd2c95e28e13f84451064e31e0739f27bf259cb376ab951e1c7048e1252f0849ccb5453fc97b319666ebbfbc7ef3055212a61582d1b69158f3b1629950a41bc756bded20498492ebc49a1535d1bd915e59c49b87ffebea2f4ad4516ecdd63fa5afda9cce9dc730d6ab2757384a":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"13c9572bdef62510d84f2d415cc481cd1e71b9c1132b43e63b21ba4e16de9b39":"7c78e634dec811173ff3c4a9a48ae3ae794fbd2aefd4b31701777ff6fcb670744c592a1d298d319717870dca364b2a3562a4ffa422bf7173c4f7ea9b0edf675e948f8370ffd0fd0d5703a9d33e8f9f375b8b641a1b1eecd1692ad1d461a68d97f91f9087f213aff23db1246ee16f403969c238f99eed894658277da23ced11ee":"a8339ba505a14786ad05edfe8cebb8d0":"":32:"df3cab08":"":"91f9780daefd2c1010c458054ac6e35baa885cdd2c95e28e13f84451064e31e0739f27bf259cb376ab951e1c7048e1252f0849ccb5453fc97b319666ebbfbc7ef3055212a61582d1b69158f3b1629950a41bc756bded20498492ebc49a1535d1bd915e59c49b87ffebea2f4ad4516ecdd63fa5afda9cce9dc730d6ab2757384a":0 AES-GCM NIST Validation (AES-256,128,1024,0,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30a14ca53913acbb215b4e4159083106db3fff83cbedd1e5425f65af1e94f5dd":"8c5f73ee1544553b712ad7a14f31379c8d54a4e432fb6c5112436988d83c4e94954b0249b470538fb977b756fbee70b811d4dc047a869e207bb0b495f1e271d0034e912000e97594033e0dedde0591b297f8a84bafcc93a46268a5bba117b558f1c73513e971c80a7083e1718fc12d0cc0d996a8e09603d564f0b8e81eea28bc":"4f23f04904de76d6decd4bd380ff56b1":"":32:"18e92b96":"bb4b3f8061edd6fa418dd71fe22eb0528547050b3bfbaa1c74e82148470d557499ce856de3e988384c0a73671bf370e560d8fda96dabe4728b5f72a6f9efd5023b07a96a631cafdf2c878b2567104c466f82b89f429915cf3331845febcff008558f836b4c12d53e94d363eae43a50fc6cb36f4ca183be92ca5f299704e2c8cf":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"30a14ca53913acbb215b4e4159083106db3fff83cbedd1e5425f65af1e94f5dd":"8c5f73ee1544553b712ad7a14f31379c8d54a4e432fb6c5112436988d83c4e94954b0249b470538fb977b756fbee70b811d4dc047a869e207bb0b495f1e271d0034e912000e97594033e0dedde0591b297f8a84bafcc93a46268a5bba117b558f1c73513e971c80a7083e1718fc12d0cc0d996a8e09603d564f0b8e81eea28bc":"4f23f04904de76d6decd4bd380ff56b1":"":32:"18e92b96":"":"bb4b3f8061edd6fa418dd71fe22eb0528547050b3bfbaa1c74e82148470d557499ce856de3e988384c0a73671bf370e560d8fda96dabe4728b5f72a6f9efd5023b07a96a631cafdf2c878b2567104c466f82b89f429915cf3331845febcff008558f836b4c12d53e94d363eae43a50fc6cb36f4ca183be92ca5f299704e2c8cf":0 AES-GCM NIST Validation (AES-256,128,1024,0,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e69f419140289ac25fb0e2ef9cc4f7e06777ac20f7d631918d1af0c8883b7d6a":"ff8dfa4e70490ea9c84cb894dc5d7e1b935ebcdea80a39c4161d4db42cbb269cc86abd381af15ec9a4a42ed18c1eed540decec19722df46f22aa06883297cb393fb23e4bb31a817e88357aa923c7ecbcf24c28a09f622dd21fa70c0a02193024fdcefeaa96cc1b50f81a65dfa9e1bb5126f0c9766a861eed096ec15fb07b0f81":"531248afdaaf1b86cf34d2394900afd9":"":32:"c6885cdd":"f75299e0ead3834fc7ebd4b2051541b598ad57cc908fdcd4324cf4ccf7dcf7b3f0737ad6c026399a8b1b6d3d50011b3c48ea2c89833b4b44c437677f230b75d36848781d4af14546894eecd873a2b1c3d2fcdd676b10bd55112038c0fdaa7b5598fe4db273a1b6744cba47189b7e2a973651bfc2aaa9e9abea4494047b957a80":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"e69f419140289ac25fb0e2ef9cc4f7e06777ac20f7d631918d1af0c8883b7d6a":"ff8dfa4e70490ea9c84cb894dc5d7e1b935ebcdea80a39c4161d4db42cbb269cc86abd381af15ec9a4a42ed18c1eed540decec19722df46f22aa06883297cb393fb23e4bb31a817e88357aa923c7ecbcf24c28a09f622dd21fa70c0a02193024fdcefeaa96cc1b50f81a65dfa9e1bb5126f0c9766a861eed096ec15fb07b0f81":"531248afdaaf1b86cf34d2394900afd9":"":32:"c6885cdd":"":"f75299e0ead3834fc7ebd4b2051541b598ad57cc908fdcd4324cf4ccf7dcf7b3f0737ad6c026399a8b1b6d3d50011b3c48ea2c89833b4b44c437677f230b75d36848781d4af14546894eecd873a2b1c3d2fcdd676b10bd55112038c0fdaa7b5598fe4db273a1b6744cba47189b7e2a973651bfc2aaa9e9abea4494047b957a80":0 AES-GCM NIST Validation (AES-256,128,1024,1024,128) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"404a5d1ac9e32f9caabffbfa485ce9c27edc9e5cde0f2aab4f32ce3121449b88":"b63ec4d28854b7fe2d4d13973f5bcb16f78494ce25cc2820de9d0dc1d8d91db1f19bc9e01cee8418c9e88a69b2f30cdbb0dbdbb50be71e1e666c111c126f2b7197c02f69a1b2ec5e1bf4062b2d0b22fb0fa1585b4e6286b29f6ac98d1b1319dd99851fa6921607077d2947140fdeeea145b56ea7b6af276c9f65393bc43ede33":"b6e6c078e6869df156faa9ac32f057c3":"6ebc75fc9304f2b139abc7d3f68b253228009c503a08b7be77852da9e1afbe72c9ab374740b0dc391fa4d7e17de6a0aa08c69e6f5c5f05411e71e70c69dfbcf693df84c30f7a8e6c7949ea1e734297c0ea3df9b7e905faa6bbdcaf1ff2625a39363308331d74892cf531cb3f6d7db31bbe9a039fca87100367747024f68c5b77":128:"94c1b9b70f9c48e7efd40ecab320c2d3":"56a0ac94f3ec7be2608154f779c434ee96db5ed4f5a6e1acfb32361ce04e16e1337be5978df06d7c4f6012385fb9d45bb397dc00f165883714b4a5b2f72f69c018ffa6d4420ad1b772e94575f035ad203be3d34b5b789a99389f295b43f004de3daaef7fa918712d3a23ca44329595e08da190e3678bc6ad9b500b9f885abe23":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"404a5d1ac9e32f9caabffbfa485ce9c27edc9e5cde0f2aab4f32ce3121449b88":"b63ec4d28854b7fe2d4d13973f5bcb16f78494ce25cc2820de9d0dc1d8d91db1f19bc9e01cee8418c9e88a69b2f30cdbb0dbdbb50be71e1e666c111c126f2b7197c02f69a1b2ec5e1bf4062b2d0b22fb0fa1585b4e6286b29f6ac98d1b1319dd99851fa6921607077d2947140fdeeea145b56ea7b6af276c9f65393bc43ede33":"b6e6c078e6869df156faa9ac32f057c3":"6ebc75fc9304f2b139abc7d3f68b253228009c503a08b7be77852da9e1afbe72c9ab374740b0dc391fa4d7e17de6a0aa08c69e6f5c5f05411e71e70c69dfbcf693df84c30f7a8e6c7949ea1e734297c0ea3df9b7e905faa6bbdcaf1ff2625a39363308331d74892cf531cb3f6d7db31bbe9a039fca87100367747024f68c5b77":128:"94c1b9b70f9c48e7efd40ecab320c2d3":"":"56a0ac94f3ec7be2608154f779c434ee96db5ed4f5a6e1acfb32361ce04e16e1337be5978df06d7c4f6012385fb9d45bb397dc00f165883714b4a5b2f72f69c018ffa6d4420ad1b772e94575f035ad203be3d34b5b789a99389f295b43f004de3daaef7fa918712d3a23ca44329595e08da190e3678bc6ad9b500b9f885abe23":0 AES-GCM NIST Validation (AES-256,128,1024,1024,128) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b56f0c980acf7875cf7f27d53ad4a276adc126d0b93a5774ac4277eecad4309e":"2c94299e36b7c4a825ecbc5a7809061e0a6761764a5a655ffdb0c20e5c3fcb10f4e93c68aa0a38c2acc5d06f2b7c4ff4fcf814b551bfefa248dbe06a09a0f153213538a31fa7cf7d646b5b53908d8978f514c9c4d6d66f2b3738024b5f9c3fd86b6da0c818203183f4205f186ea44a54edb911b1a17c424c95852c8d271b2e93":"b004c049decfb43d6f3ec13c56f839ef":"b2045b97fbb52a5fc6ff03d74e59dd696f3f442c0b555add8e6d111f835df420f45e970c4b32a84f0c45ba3710b5cd574001862b073efa5c9c4bd50127b2ce72d2c736c5e2723956da5a0acb82041a609386d07b50551c1d1fa4678886bac54b0bd080cc5ef607dca2a0d6a1e71f0e3833678bf8560bc059dae370ec94d43af6":128:"fce7234f7f76b5d502fd2b96fc9b1ce7":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"b56f0c980acf7875cf7f27d53ad4a276adc126d0b93a5774ac4277eecad4309e":"2c94299e36b7c4a825ecbc5a7809061e0a6761764a5a655ffdb0c20e5c3fcb10f4e93c68aa0a38c2acc5d06f2b7c4ff4fcf814b551bfefa248dbe06a09a0f153213538a31fa7cf7d646b5b53908d8978f514c9c4d6d66f2b3738024b5f9c3fd86b6da0c818203183f4205f186ea44a54edb911b1a17c424c95852c8d271b2e93":"b004c049decfb43d6f3ec13c56f839ef":"b2045b97fbb52a5fc6ff03d74e59dd696f3f442c0b555add8e6d111f835df420f45e970c4b32a84f0c45ba3710b5cd574001862b073efa5c9c4bd50127b2ce72d2c736c5e2723956da5a0acb82041a609386d07b50551c1d1fa4678886bac54b0bd080cc5ef607dca2a0d6a1e71f0e3833678bf8560bc059dae370ec94d43af6":128:"fce7234f7f76b5d502fd2b96fc9b1ce7":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,128) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1c5027c36e6caa1b3e5e45fead32b5e3126ac41f106c491b0b3a7c16502f4fe6":"58f0ceaa31c0025d2e6bb58720cce4b64f5f6c657c847ae42936eb1e343fea397c8a8cf2f5ef02ffaec25f431900dcb0910cf32cea9eca3b78aed1c451c7af51066489f87b2a5f8cf28d6fdb6ce49d898b6167b590a3907be7618be11fb0922a3cfd18e73efef19e5cdc250fa33f61e3940c6482ae35f339e8c0a85a17379a4e":"3ee660f03858669e557e3effdd7df6bd":"93e803c79de6ad652def62cf3cd34f9addc9dd1774967a0f69e1d28361eb2cacc177c63c07657389ce23bbe65d73e0460946d31be495424655c7724eac044cafafe1540fcbd4218921367054e43e3d21e0fa6a0da9f8b20c5cdbd019c944a2d2ee6aa6760ee1131e58fec9da30790f5a873e792098a82ddf18c3813611d9242a":128:"ac33f5ffca9df4efc09271ff7a4f58e2":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"1c5027c36e6caa1b3e5e45fead32b5e3126ac41f106c491b0b3a7c16502f4fe6":"58f0ceaa31c0025d2e6bb58720cce4b64f5f6c657c847ae42936eb1e343fea397c8a8cf2f5ef02ffaec25f431900dcb0910cf32cea9eca3b78aed1c451c7af51066489f87b2a5f8cf28d6fdb6ce49d898b6167b590a3907be7618be11fb0922a3cfd18e73efef19e5cdc250fa33f61e3940c6482ae35f339e8c0a85a17379a4e":"3ee660f03858669e557e3effdd7df6bd":"93e803c79de6ad652def62cf3cd34f9addc9dd1774967a0f69e1d28361eb2cacc177c63c07657389ce23bbe65d73e0460946d31be495424655c7724eac044cafafe1540fcbd4218921367054e43e3d21e0fa6a0da9f8b20c5cdbd019c944a2d2ee6aa6760ee1131e58fec9da30790f5a873e792098a82ddf18c3813611d9242a":128:"ac33f5ffca9df4efc09271ff7a4f58e2":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,120) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"34c3019810d72b5e584f0758f2f5888a42729a33610aafa9824badade4136bbd":"22deef66cbb7db240c399b6c83407f090d6999ba25e560b2087fed0467904bb5c40cbaa05b8bf0ff5a77c53fa229478d8e0736414daf9c420417c391c9a523fd85954533f1304d81359bdcc2c4ac90d9f5f8a67a517d7f05ba0409b718159baf11cd9154e815d5745179beb59954a45a8676a375d5af7fae4d0da05c4ea91a13":"f315ea36c17fc57dab3a2737d687cd4f":"f33c5a3a9e546ad5b35e4febf2ae557ca767b55d93bb3c1cf62d862d112dbd26f8fe2a3f54d347c1bc30029e55118bab2662b99b984b8b8e2d76831f94e48587de2709e32f16c26695f07e654b703eba6428f30070e23ed40b61d04dd1430e33c629117d945d9c0e4d36c79a8b8ab555d85083a898e7e7fbeb64a45cc3511d99":120:"0bae9403888efb4d8ec97df604cd5d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"34c3019810d72b5e584f0758f2f5888a42729a33610aafa9824badade4136bbd":"22deef66cbb7db240c399b6c83407f090d6999ba25e560b2087fed0467904bb5c40cbaa05b8bf0ff5a77c53fa229478d8e0736414daf9c420417c391c9a523fd85954533f1304d81359bdcc2c4ac90d9f5f8a67a517d7f05ba0409b718159baf11cd9154e815d5745179beb59954a45a8676a375d5af7fae4d0da05c4ea91a13":"f315ea36c17fc57dab3a2737d687cd4f":"f33c5a3a9e546ad5b35e4febf2ae557ca767b55d93bb3c1cf62d862d112dbd26f8fe2a3f54d347c1bc30029e55118bab2662b99b984b8b8e2d76831f94e48587de2709e32f16c26695f07e654b703eba6428f30070e23ed40b61d04dd1430e33c629117d945d9c0e4d36c79a8b8ab555d85083a898e7e7fbeb64a45cc3511d99":120:"0bae9403888efb4d8ec97df604cd5d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,120) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"29397d98fc5a7f04b5c8b6aa3a1dd975b6e4678457ae7f0691eee40b5397503a":"0bbf1079cb5569c32257bc7e52371db46f3961b457402b816588243b4523543430d5ca56b52de6632724c51e6c3af310b28822c749a12bdd58dee58bbc3266631562a998ec3acdc8a2567a9f07f7f9759c3f50b1d1dcdd529256b80c0d227fc1fe8b58c62d1c643f1ac2996809fd061afcf4a9af184c14db9e63ec885c49de61":"885543a45fd1163e34ef9276145b0f8c":"d88beaa0664bcef178cbdbfab17ff526b5c0f8ad9543c6a312d93c336707fbf87c0448b07a550580953279f552f368225cc6971f1eecc718d6aad1729c8d8873081357752bd09d77075fa680cb2dc4139171e4a0aaa50b28c262c14fd10b8d799ca1c6641bb7dfdfdf3dea69aa2b9e4e4726dc18b0784afa4228e5ccb1eb2422":120:"7b334d7af54b916821f6136e977a1f":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"29397d98fc5a7f04b5c8b6aa3a1dd975b6e4678457ae7f0691eee40b5397503a":"0bbf1079cb5569c32257bc7e52371db46f3961b457402b816588243b4523543430d5ca56b52de6632724c51e6c3af310b28822c749a12bdd58dee58bbc3266631562a998ec3acdc8a2567a9f07f7f9759c3f50b1d1dcdd529256b80c0d227fc1fe8b58c62d1c643f1ac2996809fd061afcf4a9af184c14db9e63ec885c49de61":"885543a45fd1163e34ef9276145b0f8c":"d88beaa0664bcef178cbdbfab17ff526b5c0f8ad9543c6a312d93c336707fbf87c0448b07a550580953279f552f368225cc6971f1eecc718d6aad1729c8d8873081357752bd09d77075fa680cb2dc4139171e4a0aaa50b28c262c14fd10b8d799ca1c6641bb7dfdfdf3dea69aa2b9e4e4726dc18b0784afa4228e5ccb1eb2422":120:"7b334d7af54b916821f6136e977a1f":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,120) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7555dfcf354da07fd70f951d94ec1d86a635edfdb7929460207b2a39cc0cf4a3":"a1351cfffd1b0cbf80c3318cc432d3238cb647e996b7b53c527783594683f535950cd08788687c77226b2d3f095955884adc2e475ca1e1eab04e37d5e901ae8934a9d3a0cb37b80612ca25d989856dfa7607b03039b64d7dcd468204f03e0f2c55cb41c5367c56ca6c561425992b40e2d4f380b3d8419f681e88ebe2d4bdad36":"e1b30b6a47e8c21228e41a21b1a004f0":"bf986d3842378440f8924bb7f117d1a86888a666915a93ba65d486d14c580501e736d3418cebee572439318b21b6e4e504a7b075b8c2300c014e87e04fa842b6a2a3ebd9e6134b9ddd78e0a696223b1dc775f3288a6a9569c64b4d8fc5e04f2047c70115f692d2c2cefe7488de42ff862d7c0f542e58d69f0f8c9bf67ef48aea":120:"d8ef5438b7cf5dc11209a635ce1095":"95e8db7c8ecab8a60ceb49726153a7c5553cf571bc40515944d833485e19bf33cb954e2555943778040165a6cfffecef79eb7d82fef5a2f136f004bb5e7c35ae827fac3da292a185b5b8fc262012c05caeda5453ede3303cfeb0c890db1facadaa2895bdbb33265ada0bb46030607b6cf94f86961178e2e2deeb53c63900f1ec":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"7555dfcf354da07fd70f951d94ec1d86a635edfdb7929460207b2a39cc0cf4a3":"a1351cfffd1b0cbf80c3318cc432d3238cb647e996b7b53c527783594683f535950cd08788687c77226b2d3f095955884adc2e475ca1e1eab04e37d5e901ae8934a9d3a0cb37b80612ca25d989856dfa7607b03039b64d7dcd468204f03e0f2c55cb41c5367c56ca6c561425992b40e2d4f380b3d8419f681e88ebe2d4bdad36":"e1b30b6a47e8c21228e41a21b1a004f0":"bf986d3842378440f8924bb7f117d1a86888a666915a93ba65d486d14c580501e736d3418cebee572439318b21b6e4e504a7b075b8c2300c014e87e04fa842b6a2a3ebd9e6134b9ddd78e0a696223b1dc775f3288a6a9569c64b4d8fc5e04f2047c70115f692d2c2cefe7488de42ff862d7c0f542e58d69f0f8c9bf67ef48aea":120:"d8ef5438b7cf5dc11209a635ce1095":"":"95e8db7c8ecab8a60ceb49726153a7c5553cf571bc40515944d833485e19bf33cb954e2555943778040165a6cfffecef79eb7d82fef5a2f136f004bb5e7c35ae827fac3da292a185b5b8fc262012c05caeda5453ede3303cfeb0c890db1facadaa2895bdbb33265ada0bb46030607b6cf94f86961178e2e2deeb53c63900f1ec":0 AES-GCM NIST Validation (AES-256,128,1024,1024,112) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"bbeafe86c72ab0354b733b69b09e4d3462feb1658fe404004d81503f3a6e132f":"a033c2051e425d01d97d563572e42c5113860e5dedcd24c76e3e357559ba3250f1fc5d4a931a9d0900ac025400f0158621f0b1215b2907467bfc874bcabbb28e28de81fe1ee5b79985261c512afec2327c8c5957df90c9eb77950de4a4860b57a9e6e145ea15eb52da63f217f94a5c8e5fcb5d361b86e0e67637a450cdbcb06f":"ee1caba93cb549054ca29715a536393e":"e44b0e0d275ae7c38a7dc2f768e899c1c11a4c4cb5b5bd25cd2132e3ecbaa5a63654312603e1c5b393c0ce6253c55986ee45bb1daac78a26749d88928f9b9908690fc148a656b78e3595319432763efbcf6957c9b2150ccabfd4833d0dcee01758c5efb47321a948b379a2ec0abcd6b6cbf41a8883f0f5d5bf7b240cb35f0777":112:"a4809e072f93deb7b77c52427095":"e62adf9bbd92dd03cc5250251691f724c6ece1cb89d8c4daf31cc732a5420f6bedab71aab0238ba23bd7165ed1f692561ef457fd1d47413949405b6fc8e17922b17026d89d5830b383546ea516a56f3a1c45ec1251583ae880fa8985bd3dcc1d6a57b746971937bf370e76482238cc08c2c3b13258151e0a6475cc017f8a3d0e":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"bbeafe86c72ab0354b733b69b09e4d3462feb1658fe404004d81503f3a6e132f":"a033c2051e425d01d97d563572e42c5113860e5dedcd24c76e3e357559ba3250f1fc5d4a931a9d0900ac025400f0158621f0b1215b2907467bfc874bcabbb28e28de81fe1ee5b79985261c512afec2327c8c5957df90c9eb77950de4a4860b57a9e6e145ea15eb52da63f217f94a5c8e5fcb5d361b86e0e67637a450cdbcb06f":"ee1caba93cb549054ca29715a536393e":"e44b0e0d275ae7c38a7dc2f768e899c1c11a4c4cb5b5bd25cd2132e3ecbaa5a63654312603e1c5b393c0ce6253c55986ee45bb1daac78a26749d88928f9b9908690fc148a656b78e3595319432763efbcf6957c9b2150ccabfd4833d0dcee01758c5efb47321a948b379a2ec0abcd6b6cbf41a8883f0f5d5bf7b240cb35f0777":112:"a4809e072f93deb7b77c52427095":"":"e62adf9bbd92dd03cc5250251691f724c6ece1cb89d8c4daf31cc732a5420f6bedab71aab0238ba23bd7165ed1f692561ef457fd1d47413949405b6fc8e17922b17026d89d5830b383546ea516a56f3a1c45ec1251583ae880fa8985bd3dcc1d6a57b746971937bf370e76482238cc08c2c3b13258151e0a6475cc017f8a3d0e":0 AES-GCM NIST Validation (AES-256,128,1024,1024,112) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6ad06c88dd4f3becf35eed95bb859be2406a1803a66e4332a74c5f75c09b9a01":"2219c11672884b93d0290b6a7140feafe416461f1cdaf0b3aa64693d7db2eb10feae46aac7af549fa1b0abc78c11f8df7ee803ef70310fc3e67769f8b4bc64f81143a6ebf8bee9d386a8ede5d2cc0ed17985a3b7bb95191ef55e684690ccdc5ca504bc6eb28442b353861a034a43532c025f666e80be967a6b05b9dd3a91ff58":"07d8b4a6e77aef9018828b61e0fdf2a4":"cca1fd0278045dda80b847f0975b6cbf31e1910d2c99b4eb78c360d89133a1c52e66c5c3801824afc1f079d2b2b1c827199e83f680e59b9a7de9b15fa7b6848b5bf4e16a12ac1af4cf2b4d7bb45673c5e1241e9996440860a9204fc27cae46a991607bc5e7120d6c115ddcbdd02c022b262602139081e61eee4aba7193f13992":112:"e3ede170386e76321a575c095966":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"6ad06c88dd4f3becf35eed95bb859be2406a1803a66e4332a74c5f75c09b9a01":"2219c11672884b93d0290b6a7140feafe416461f1cdaf0b3aa64693d7db2eb10feae46aac7af549fa1b0abc78c11f8df7ee803ef70310fc3e67769f8b4bc64f81143a6ebf8bee9d386a8ede5d2cc0ed17985a3b7bb95191ef55e684690ccdc5ca504bc6eb28442b353861a034a43532c025f666e80be967a6b05b9dd3a91ff58":"07d8b4a6e77aef9018828b61e0fdf2a4":"cca1fd0278045dda80b847f0975b6cbf31e1910d2c99b4eb78c360d89133a1c52e66c5c3801824afc1f079d2b2b1c827199e83f680e59b9a7de9b15fa7b6848b5bf4e16a12ac1af4cf2b4d7bb45673c5e1241e9996440860a9204fc27cae46a991607bc5e7120d6c115ddcbdd02c022b262602139081e61eee4aba7193f13992":112:"e3ede170386e76321a575c095966":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,112) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"87bbf7c15689e8c99a5a32a8ba0dfebcfe1989159807428cdd1f382c3ea95178":"b77d3bf3b30b3e6e5c86cbfb7e5455f6480f423cc76834b4663d28d9f1eb5c40212634e3347668427f7848352ab789886f96682a568260bdaeb7de0aae2af36f5ae04f06c332b158d923706c1c6255c673feeadb6d30bfc901e60b92acd9ddd83ef98686c4d492f4a60e97af2541d470a6a6b21903441020ea7619cf28a06986":"2f19aa1f3a82a7398706953f01739da7":"590dbd230854aa2b5ac19fc3dc9453e5bb9637e47d97b92486a599bdafdfb27c3852e3d06a91429bb820eb12a5318ed8861ffe87d659c462ef167be22604facfa3afb601b2167989b9e3b2e5b59e7d07fda27ffccd450869d528410b0aff468f70cc10ef6723a74af6eebc1572c123a9b5a9aab748a31fa764716d3293ff5de7":112:"5c43fc4dc959fabeebb188dbf3a5":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"87bbf7c15689e8c99a5a32a8ba0dfebcfe1989159807428cdd1f382c3ea95178":"b77d3bf3b30b3e6e5c86cbfb7e5455f6480f423cc76834b4663d28d9f1eb5c40212634e3347668427f7848352ab789886f96682a568260bdaeb7de0aae2af36f5ae04f06c332b158d923706c1c6255c673feeadb6d30bfc901e60b92acd9ddd83ef98686c4d492f4a60e97af2541d470a6a6b21903441020ea7619cf28a06986":"2f19aa1f3a82a7398706953f01739da7":"590dbd230854aa2b5ac19fc3dc9453e5bb9637e47d97b92486a599bdafdfb27c3852e3d06a91429bb820eb12a5318ed8861ffe87d659c462ef167be22604facfa3afb601b2167989b9e3b2e5b59e7d07fda27ffccd450869d528410b0aff468f70cc10ef6723a74af6eebc1572c123a9b5a9aab748a31fa764716d3293ff5de7":112:"5c43fc4dc959fabeebb188dbf3a5":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,104) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"24095a66b6eb0320ca75e2ab78e8496a45f4b000fc43436904c3e386fb852ed2":"4690edc843e23d9d9b9a4dab8fa8193f8bf03897d3d29759e9dc9e0f8a970c0f5d4399b9f60461fe5cf439f9b0d54bbc075695e4d76b76298cc2b75bb3e0b516ee9ada93f77c4c002ba9fd163a1e4b377befb76c1e5ab8b3901f214c0a4c48bd2aa2f33560d46e2721a060d4671dc97633ff9bcd703bb0fbed9a4a2c259b53f3":"0955c1f0e271edca279e016074886f60":"f5160c75c449e6bb971e73b7d04ab9b9a85879f6eb2d67354af94a4f0ca339c0a03a5b9ede87a4ff6823b698113a38ae5327e6878c3ccc0e36d74fe07aa51c027c3b334812862bc660178f5d0f3e764c0b828a5e3f2e7d7a1185b7e79828304a7ad3ddcd724305484177e66f4f81e66afdc5bbee0ec174bff5eb3719482bd2d8":104:"75a31347598f09fceeea6736fe":"0dd2dca260325967267667ff3ccdc6d6b35648821a42090abba46282869bac4bdc20a8bee024bea18a07396c38dbb45d9481fedcc423a3928cfa78a2f0ae8eedb062add810bdbee77ddc26c29e4f9fda1ab336d04ef42947b05fbdb9bc4df79e37af951d19d6bf5e5cb34eef898f23642a9c4a9111ed0b7a08abeeefbbd45c23":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"24095a66b6eb0320ca75e2ab78e8496a45f4b000fc43436904c3e386fb852ed2":"4690edc843e23d9d9b9a4dab8fa8193f8bf03897d3d29759e9dc9e0f8a970c0f5d4399b9f60461fe5cf439f9b0d54bbc075695e4d76b76298cc2b75bb3e0b516ee9ada93f77c4c002ba9fd163a1e4b377befb76c1e5ab8b3901f214c0a4c48bd2aa2f33560d46e2721a060d4671dc97633ff9bcd703bb0fbed9a4a2c259b53f3":"0955c1f0e271edca279e016074886f60":"f5160c75c449e6bb971e73b7d04ab9b9a85879f6eb2d67354af94a4f0ca339c0a03a5b9ede87a4ff6823b698113a38ae5327e6878c3ccc0e36d74fe07aa51c027c3b334812862bc660178f5d0f3e764c0b828a5e3f2e7d7a1185b7e79828304a7ad3ddcd724305484177e66f4f81e66afdc5bbee0ec174bff5eb3719482bd2d8":104:"75a31347598f09fceeea6736fe":"":"0dd2dca260325967267667ff3ccdc6d6b35648821a42090abba46282869bac4bdc20a8bee024bea18a07396c38dbb45d9481fedcc423a3928cfa78a2f0ae8eedb062add810bdbee77ddc26c29e4f9fda1ab336d04ef42947b05fbdb9bc4df79e37af951d19d6bf5e5cb34eef898f23642a9c4a9111ed0b7a08abeeefbbd45c23":0 AES-GCM NIST Validation (AES-256,128,1024,1024,104) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"086b77b5731f971f0bf5b8227361b216746daf8b08c583ad38f114a64aa7877b":"629317212ff8bd8a7676e4c00b81a9577de6397c832f99ac974fa2bbbccb6e3b8aa776db6922eed0b014bf3923799da7d9d0854c8817470e1e2f7fc7a572f9d0316ee60cde7ef025d59b897d29a6fee721aeb2f7bb44f9afb471e8a7b0b43a39b5497a3b4d6beb4b511f0cefa12ce5e6d843609d3e06999acfbee50a22ca1eee":"164058e5e425f9da40d22c9098a16204":"6633eae08a1df85f2d36e162f2d7ddd92b0c56b7477f3c6cdb9919d0e4b1e54ea7635c202dcf52d1c688afbbb15552adda32b4cd30aa462b367f02ded02e0d64eeee2a6b95462b191784143c25607fd08a23a2fbc75cf6bee294daf2042587fdd8fe3d22c3a242c624cf0a51a7c14db4f0f766ec437de4c83b64f23706a24437":104:"2eb6eb6d516ed4cf1778b4e378":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"086b77b5731f971f0bf5b8227361b216746daf8b08c583ad38f114a64aa7877b":"629317212ff8bd8a7676e4c00b81a9577de6397c832f99ac974fa2bbbccb6e3b8aa776db6922eed0b014bf3923799da7d9d0854c8817470e1e2f7fc7a572f9d0316ee60cde7ef025d59b897d29a6fee721aeb2f7bb44f9afb471e8a7b0b43a39b5497a3b4d6beb4b511f0cefa12ce5e6d843609d3e06999acfbee50a22ca1eee":"164058e5e425f9da40d22c9098a16204":"6633eae08a1df85f2d36e162f2d7ddd92b0c56b7477f3c6cdb9919d0e4b1e54ea7635c202dcf52d1c688afbbb15552adda32b4cd30aa462b367f02ded02e0d64eeee2a6b95462b191784143c25607fd08a23a2fbc75cf6bee294daf2042587fdd8fe3d22c3a242c624cf0a51a7c14db4f0f766ec437de4c83b64f23706a24437":104:"2eb6eb6d516ed4cf1778b4e378":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,104) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0f9e806b0d937268561c0eafbbdd14ec715b7e9cef4118d6eb28abbb91266745":"2ae4baef22ace26f464a9b0c75802303f2d7c0f9a1ed1d0180135189765bdd347fea0cc2b73ee7fbbf95ea1fda22597b8aad826f63e744069a9c349488b2cc1cf9372f423cc650302082125724730ae5a4d878e07385ddc99034c6b6b46748f02c80b179fe6406b1d33581950cb9bcd1d1ea1ec7b5becfd6c1f5b279412c433a":"8657996634e74d4689f292645f103a2e":"2ca253355e893e58cb1a900fbb62d61595de5c4186dc8a9129da3657a92b4a631bbdc3d5f86395385a9aa8557b67f886e3bb807620e558c93aea8e65826eadeb21544418ee40f5420c2d2b8270491be6fc2dcbfd12847fa350910dd615e9a1881bc2ced3b0ac3bde445b735e43c0c84f9d120ca5edd655779fc13c6f88b484f7":104:"83155ebb1a42112dd1c474f37b":"87d69fc3cbc757b2b57b180c6ba34db4e20dde19976bfb3d274d32e7cea13f0c7d9e840d59ce857718c985763b7639e448516ddbbda559457cd8cb364fa99addd5ba44ef45c11060d9be82b4ebe1f0711ac95433074649b6c08eeab539fdfc99c77498b420427e4d70e316111845793de1f67fb0d04e3389a8862f46f4582dc8":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"0f9e806b0d937268561c0eafbbdd14ec715b7e9cef4118d6eb28abbb91266745":"2ae4baef22ace26f464a9b0c75802303f2d7c0f9a1ed1d0180135189765bdd347fea0cc2b73ee7fbbf95ea1fda22597b8aad826f63e744069a9c349488b2cc1cf9372f423cc650302082125724730ae5a4d878e07385ddc99034c6b6b46748f02c80b179fe6406b1d33581950cb9bcd1d1ea1ec7b5becfd6c1f5b279412c433a":"8657996634e74d4689f292645f103a2e":"2ca253355e893e58cb1a900fbb62d61595de5c4186dc8a9129da3657a92b4a631bbdc3d5f86395385a9aa8557b67f886e3bb807620e558c93aea8e65826eadeb21544418ee40f5420c2d2b8270491be6fc2dcbfd12847fa350910dd615e9a1881bc2ced3b0ac3bde445b735e43c0c84f9d120ca5edd655779fc13c6f88b484f7":104:"83155ebb1a42112dd1c474f37b":"":"87d69fc3cbc757b2b57b180c6ba34db4e20dde19976bfb3d274d32e7cea13f0c7d9e840d59ce857718c985763b7639e448516ddbbda559457cd8cb364fa99addd5ba44ef45c11060d9be82b4ebe1f0711ac95433074649b6c08eeab539fdfc99c77498b420427e4d70e316111845793de1f67fb0d04e3389a8862f46f4582dc8":0 AES-GCM NIST Validation (AES-256,128,1024,1024,96) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c24c17911f6db4b3e37c46bcc6fa35efc1a55f7754f0bb99f2eea93398116447":"0bd92cb106867e25ad427ff6e5f384d2d0f432fc389852187fcc7b0bf9f6d11a102a872b99ed1ad9a05dab0f79fa634745535efed804ff42b0af8dad20ba44709391fb263f245e5a2c52d9ce904179633282f57a1229b0a9c4557a5c0aeda29bbc5a7a871fa8b62d58100c3722c21e51e3b3e913185235526e7a5a91c559717d":"5098cc52a69ee044197e2c000c2d4ab8":"9ad4dee311d854925fc7f10eca4f5dd4e6990cb2d4325da2ef25a9a23690f5c5590be285d33aaeba76506c59edec64b8c3ff8e62716d1c385fbce2a42bc7bd5d8e8584de1944543ab6f340c20911f8b7b3be1a1db18a4bb94119333339de95815cae09365b016edc184e11f3c5b851f1fa92b1b63cfa3872a127109c1294b677":96:"f7930e3fab74a91cb6543e72":"6124ede608d416baa5e653a898ca76e9f47f08403c1984feec112e670ded2226e0073f8881ab2161cfda541dccae19691285f7391a729f07aba18f340bb452c1da39cbe83cf476cfc105b64187e0d2227dd283dcba8b6a350f9956b18861fa131d3f00c034443e8f60e0fdfcfaabbed93381ae374a8bf66523d33646183e1379":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c24c17911f6db4b3e37c46bcc6fa35efc1a55f7754f0bb99f2eea93398116447":"0bd92cb106867e25ad427ff6e5f384d2d0f432fc389852187fcc7b0bf9f6d11a102a872b99ed1ad9a05dab0f79fa634745535efed804ff42b0af8dad20ba44709391fb263f245e5a2c52d9ce904179633282f57a1229b0a9c4557a5c0aeda29bbc5a7a871fa8b62d58100c3722c21e51e3b3e913185235526e7a5a91c559717d":"5098cc52a69ee044197e2c000c2d4ab8":"9ad4dee311d854925fc7f10eca4f5dd4e6990cb2d4325da2ef25a9a23690f5c5590be285d33aaeba76506c59edec64b8c3ff8e62716d1c385fbce2a42bc7bd5d8e8584de1944543ab6f340c20911f8b7b3be1a1db18a4bb94119333339de95815cae09365b016edc184e11f3c5b851f1fa92b1b63cfa3872a127109c1294b677":96:"f7930e3fab74a91cb6543e72":"":"6124ede608d416baa5e653a898ca76e9f47f08403c1984feec112e670ded2226e0073f8881ab2161cfda541dccae19691285f7391a729f07aba18f340bb452c1da39cbe83cf476cfc105b64187e0d2227dd283dcba8b6a350f9956b18861fa131d3f00c034443e8f60e0fdfcfaabbed93381ae374a8bf66523d33646183e1379":0 AES-GCM NIST Validation (AES-256,128,1024,1024,96) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d267a8379260036ff3d1ec07a7b086ff75706bad12d37d9656f04776f3d8b85c":"80c68a330ef50e3e516681f1e535868b03466e7edbb86cb385d01db487da3dd3edad940fdc98d918b7db9b59f8d61369eee2928c88557306c4a13e366af0708d94cb90a15f1c3bc45544bdb05ff964da5e06c5ae965f20adb504620aed7bce2e82f4e408d00219c15ef85fae1ff13fea53deb78afa5f2a50edbd622446e4a894":"674dc34e8c74c51fa42aacd625a1bd5b":"6a9a8af732ae96d0b5a9730ad792e296150d59770a20a3fdbbc2a3a035a88ac445d64f37d684e22003c214b771c1995719da72f3ed24a96618284dd414f0cac364640b23c680dc80492a435c8ec10add53b0d9e3374f1cf5bfc663e3528fa2f6209846421ea6f481b7ecf57714f7bc2527edc4e0466b13e750dd4d4c0cc0cdfc":96:"bea660e963b08fc657741bc8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"d267a8379260036ff3d1ec07a7b086ff75706bad12d37d9656f04776f3d8b85c":"80c68a330ef50e3e516681f1e535868b03466e7edbb86cb385d01db487da3dd3edad940fdc98d918b7db9b59f8d61369eee2928c88557306c4a13e366af0708d94cb90a15f1c3bc45544bdb05ff964da5e06c5ae965f20adb504620aed7bce2e82f4e408d00219c15ef85fae1ff13fea53deb78afa5f2a50edbd622446e4a894":"674dc34e8c74c51fa42aacd625a1bd5b":"6a9a8af732ae96d0b5a9730ad792e296150d59770a20a3fdbbc2a3a035a88ac445d64f37d684e22003c214b771c1995719da72f3ed24a96618284dd414f0cac364640b23c680dc80492a435c8ec10add53b0d9e3374f1cf5bfc663e3528fa2f6209846421ea6f481b7ecf57714f7bc2527edc4e0466b13e750dd4d4c0cc0cdfc":96:"bea660e963b08fc657741bc8":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,96) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c86cb637753010f639fa3aa3bff7c28b74f012ad6090f2a31b0801d086f183ad":"6b7858557e0fd0f957842fb30e8d54dedbc127eb4bbf9de319f731fa28a606df2c046a0bce8ecda4e75d3596e4e988efd6bc279aa005bc52fad92ba07f5b1dfda4cc417029f9778c88d6fe5341a0fd48893dcb7c68d0df310a060f2a5235aee422d380f7209bc0909b2aa7e876044056f0b915dab0bc13cbea5a3b86d40ca802":"87ff6e0bb313502fedf3d2696bff99b5":"2816f1132724f42e40deabab25e325b282f8c615a79e0c98c00d488ee56237537240234966565e46bfb0c50f2b10366d1589620e6e78bd90ade24d38a272f3fff53c09466aa2d3ef793d7f814a064b713821850a6e6a058f5139a1088347a9fa0f54e38abd51ddfc7ef040bf41d188f3f86c973551ced019812c1fc668649621":96:"7859f047f32b51833333accf":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"c86cb637753010f639fa3aa3bff7c28b74f012ad6090f2a31b0801d086f183ad":"6b7858557e0fd0f957842fb30e8d54dedbc127eb4bbf9de319f731fa28a606df2c046a0bce8ecda4e75d3596e4e988efd6bc279aa005bc52fad92ba07f5b1dfda4cc417029f9778c88d6fe5341a0fd48893dcb7c68d0df310a060f2a5235aee422d380f7209bc0909b2aa7e876044056f0b915dab0bc13cbea5a3b86d40ca802":"87ff6e0bb313502fedf3d2696bff99b5":"2816f1132724f42e40deabab25e325b282f8c615a79e0c98c00d488ee56237537240234966565e46bfb0c50f2b10366d1589620e6e78bd90ade24d38a272f3fff53c09466aa2d3ef793d7f814a064b713821850a6e6a058f5139a1088347a9fa0f54e38abd51ddfc7ef040bf41d188f3f86c973551ced019812c1fc668649621":96:"7859f047f32b51833333accf":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,64) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c31ca0cac3efe467168198f06beacf39565a6f57f82e1048a5c06a231315882":"65261d6e29b2369b1828a7cef2df9873d6e6057c499301afedd6cb65b5036ddb95f9e353fbf38e54c4f46f88164325b33620ce183beb2e411fbb89a0e0002e542fc161cad32a61ee6f1e1717e0b4dcd0340b116f795bc1009dbbc65bc31c9b549bf03c40bc204cd0d02ec884be907777ebeed8b527ec3af7cbb508193c0745de":"95cae6e85f33f3043182460589be3639":"67523751a9b1b643d00de4511b55e4268cb2d18e79e01a55fc7b677d529bd6400940fb25ea6ae135c1a816e61b69e90b966981aeda685934b107066e1467db78973492ad791e20aef430db3a047447141def8be6e6a9a15089607c3af9368cdb11b7b5fbf90691505d0c33664766945d387904e7089b915a3c28886ba1763bb5":64:"21309d0351cac45e":"1d5f2cb921f54aeb552b4304142facd49497837deb1f00d26fbeddbab922fd80b00dba782961f8fce84f1f7973e81eed6ee168b1760c575c891f40a1dae0fa1a08738025d13ef6e0b30be4f054d874f1b8a2427a19ebb071d98365c32316a88a68c2b40daf1ea831a64519ac3679acb4e04986ecc614ec673c498c6fee459e40":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2c31ca0cac3efe467168198f06beacf39565a6f57f82e1048a5c06a231315882":"65261d6e29b2369b1828a7cef2df9873d6e6057c499301afedd6cb65b5036ddb95f9e353fbf38e54c4f46f88164325b33620ce183beb2e411fbb89a0e0002e542fc161cad32a61ee6f1e1717e0b4dcd0340b116f795bc1009dbbc65bc31c9b549bf03c40bc204cd0d02ec884be907777ebeed8b527ec3af7cbb508193c0745de":"95cae6e85f33f3043182460589be3639":"67523751a9b1b643d00de4511b55e4268cb2d18e79e01a55fc7b677d529bd6400940fb25ea6ae135c1a816e61b69e90b966981aeda685934b107066e1467db78973492ad791e20aef430db3a047447141def8be6e6a9a15089607c3af9368cdb11b7b5fbf90691505d0c33664766945d387904e7089b915a3c28886ba1763bb5":64:"21309d0351cac45e":"":"1d5f2cb921f54aeb552b4304142facd49497837deb1f00d26fbeddbab922fd80b00dba782961f8fce84f1f7973e81eed6ee168b1760c575c891f40a1dae0fa1a08738025d13ef6e0b30be4f054d874f1b8a2427a19ebb071d98365c32316a88a68c2b40daf1ea831a64519ac3679acb4e04986ecc614ec673c498c6fee459e40":0 AES-GCM NIST Validation (AES-256,128,1024,1024,64) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ca9fa36ca2159dff9723f6cfdb13280446eb6bc3688043c7e2e2504184791596":"ac04c4293554cd832aa400c811cb202d815d6178aa1343b4628592b7f3ae45dc5f12ea47be4b43e1865f40b06ab67b3a9fb3644248a9b3efe131a8addb7447978bb51ccf749e75574fea60e8781677200af023b2f8c415f4e6d8c575a9e374916d9ec3a612b16e37beb589444b588e0b770d9f8e818ad83f83aa4ecf386d17a7":"d13ca73365e57114fc698ee60ba0ad84":"2aa510b7f1620bfce90080e0e25f5468dbc5314b50914e793b5278369c51ac017eace9fd15127fca5a726ad9e67bdee5af298988d9a57ec4bbc43d4eb849535eb10521ac7cd7ed647479a42876af2ebc9e2108b539febdaa9127c49bda1bda800f6034050b8576e944311dfbca59d64d259571b6d2ed5b2fc07127239b03f4b7":64:"2111d55d96a4d84d":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ca9fa36ca2159dff9723f6cfdb13280446eb6bc3688043c7e2e2504184791596":"ac04c4293554cd832aa400c811cb202d815d6178aa1343b4628592b7f3ae45dc5f12ea47be4b43e1865f40b06ab67b3a9fb3644248a9b3efe131a8addb7447978bb51ccf749e75574fea60e8781677200af023b2f8c415f4e6d8c575a9e374916d9ec3a612b16e37beb589444b588e0b770d9f8e818ad83f83aa4ecf386d17a7":"d13ca73365e57114fc698ee60ba0ad84":"2aa510b7f1620bfce90080e0e25f5468dbc5314b50914e793b5278369c51ac017eace9fd15127fca5a726ad9e67bdee5af298988d9a57ec4bbc43d4eb849535eb10521ac7cd7ed647479a42876af2ebc9e2108b539febdaa9127c49bda1bda800f6034050b8576e944311dfbca59d64d259571b6d2ed5b2fc07127239b03f4b7":64:"2111d55d96a4d84d":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,64) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2f802e838250064c15fdee28d7bd4872850355870847701ad9742b2d6eb4b0c0":"e2ca8c8d172ff90232879f510d1225af91bc323bdf636363c2903fcd1790692c8bcb03a1cccb18814678852c6b3a441552e541b843ee5e4f86a152fa73d05aea659fe08aa6428bb257eaa2a7b579fdc4022c1dec359a854253c1aefc983c5ede8c97517ea69fc4606e25f13ffb0f5f49160691454fbb74e704326738353525f7":"2dd550cfd97f8e1d8d31ba5537ae4710":"72b9630dda40306e785b961934c56e20948f8eac0e981f49787eb3dbd6e4607f7d08d10ca643746bf1efa7e5066993683d527a90f2d45ec9cf73113f1f17bb67958be669acd4e2927f1dacfde902cd3048056d7f6dfdd8630ff054efce4526db7c9321d6d2be2236f4d60e27b89d8ec94f65a06dc0953c8c4533a51b6a29bd2c":64:"bd6c8823c9005c85":"f6dd0b5f3d1a393a1837112962dba175a13c2d1e525ef95734caf34949d8b2d63b4fe5603226b5f632f2d7f927361ba639dc0e3c63414f45462342695916d5792133b4a24c7c4cbe2b97c712bf27ab62d3d68b3875d58ffe4b7c30a8171bff1a9e2f3995768faacda2ea9213ff35798b9e4513f6a87bd3f5a9d93e847e768359":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"2f802e838250064c15fdee28d7bd4872850355870847701ad9742b2d6eb4b0c0":"e2ca8c8d172ff90232879f510d1225af91bc323bdf636363c2903fcd1790692c8bcb03a1cccb18814678852c6b3a441552e541b843ee5e4f86a152fa73d05aea659fe08aa6428bb257eaa2a7b579fdc4022c1dec359a854253c1aefc983c5ede8c97517ea69fc4606e25f13ffb0f5f49160691454fbb74e704326738353525f7":"2dd550cfd97f8e1d8d31ba5537ae4710":"72b9630dda40306e785b961934c56e20948f8eac0e981f49787eb3dbd6e4607f7d08d10ca643746bf1efa7e5066993683d527a90f2d45ec9cf73113f1f17bb67958be669acd4e2927f1dacfde902cd3048056d7f6dfdd8630ff054efce4526db7c9321d6d2be2236f4d60e27b89d8ec94f65a06dc0953c8c4533a51b6a29bd2c":64:"bd6c8823c9005c85":"":"f6dd0b5f3d1a393a1837112962dba175a13c2d1e525ef95734caf34949d8b2d63b4fe5603226b5f632f2d7f927361ba639dc0e3c63414f45462342695916d5792133b4a24c7c4cbe2b97c712bf27ab62d3d68b3875d58ffe4b7c30a8171bff1a9e2f3995768faacda2ea9213ff35798b9e4513f6a87bd3f5a9d93e847e768359":0 AES-GCM NIST Validation (AES-256,128,1024,1024,32) #0 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"84dd53ce0146cb71c32776033bb243098d78a22ac17f52a62a122f5653fb4e33":"68222bffa782dcfe4f328fc20eb520e75a9a5fedbe13ec7fcf0e82fba08bb87a8a8e02902638e32fe0e2294344b380797f8028426ffcc0531c739c884892394c48ff0779c5f5edf0a36a3fb8aa91213347774ec4bf0fe1049bd53746b13beef3c637169826c367056cb1aa0a3868e23f886a9c7b8015c26af9e40794662f6b21":"f0c90a1bca52f30fab3670df0d3beab0":"a3ea8032f36a5ca3d7a1088fd08ac50ae6bdc06ad3a534b773ac3e3d4a3d524499e56274a0062c58c3b0685cc850f4725e5c221af8f51c6df2bbd5fbcff4a93ba4c1054f7f9c67fd9285511a08d328d76a642f067227d378f95a1e67587b90251f9103ed3cacdb6bf69e0794e366d8b92d8de37b4e028de0778841f356ac044d":32:"b1ece9fb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"84dd53ce0146cb71c32776033bb243098d78a22ac17f52a62a122f5653fb4e33":"68222bffa782dcfe4f328fc20eb520e75a9a5fedbe13ec7fcf0e82fba08bb87a8a8e02902638e32fe0e2294344b380797f8028426ffcc0531c739c884892394c48ff0779c5f5edf0a36a3fb8aa91213347774ec4bf0fe1049bd53746b13beef3c637169826c367056cb1aa0a3868e23f886a9c7b8015c26af9e40794662f6b21":"f0c90a1bca52f30fab3670df0d3beab0":"a3ea8032f36a5ca3d7a1088fd08ac50ae6bdc06ad3a534b773ac3e3d4a3d524499e56274a0062c58c3b0685cc850f4725e5c221af8f51c6df2bbd5fbcff4a93ba4c1054f7f9c67fd9285511a08d328d76a642f067227d378f95a1e67587b90251f9103ed3cacdb6bf69e0794e366d8b92d8de37b4e028de0778841f356ac044d":32:"b1ece9fb":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,32) #1 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bb36fe25e966a075ae2c3bb43b5877679ebc379d5123c8eda3fa0e30b95cae0":"fb3a4be643c10343251c6f0745aaa54349463f622ca04a792e9b4780866844b30aeef3269fc60cac0ea031c5f3780b535e15154f7c76eb4a371b8ae368550f3fa2ce693c34511ec96b839cac567f1b0de0e7e3116d729b45d1b16e453703a43db73f5d0c3e430f16b142420b5f0d26d72ac3dba543d7d813603b0bfdca3dd63e":"59869df4ef5754b406478a2fb608ee99":"ecd125682e8a8e26757c888b0c8b95dec5e7ed7ac991768f93e8af5bcf6f21ed4d4d38699ee7984ed13635fff72f938150157c9a27fcda121ffced7b492d2b18dad299cb6495ed5f68441aefc8219d2cf717d15d5cd2dbce4606fcf90fe45f3601127cf6acee210bd7df97309f773974a35bef1d33df984101c2fc9d4b55259e":32:"cb3f5338":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"9bb36fe25e966a075ae2c3bb43b5877679ebc379d5123c8eda3fa0e30b95cae0":"fb3a4be643c10343251c6f0745aaa54349463f622ca04a792e9b4780866844b30aeef3269fc60cac0ea031c5f3780b535e15154f7c76eb4a371b8ae368550f3fa2ce693c34511ec96b839cac567f1b0de0e7e3116d729b45d1b16e453703a43db73f5d0c3e430f16b142420b5f0d26d72ac3dba543d7d813603b0bfdca3dd63e":"59869df4ef5754b406478a2fb608ee99":"ecd125682e8a8e26757c888b0c8b95dec5e7ed7ac991768f93e8af5bcf6f21ed4d4d38699ee7984ed13635fff72f938150157c9a27fcda121ffced7b492d2b18dad299cb6495ed5f68441aefc8219d2cf717d15d5cd2dbce4606fcf90fe45f3601127cf6acee210bd7df97309f773974a35bef1d33df984101c2fc9d4b55259e":32:"cb3f5338":"FAIL":"":0 AES-GCM NIST Validation (AES-256,128,1024,1024,32) #2 depends_on:MBEDTLS_AES_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ca264e7caecad56ee31c8bf8dde9592f753a6299e76c60ac1e93cff3b3de8ce9":"8d03cf6fac31182ad3e6f32e4c823e3b421aef786d5651afafbf70ef14c00524ab814bc421b1d4181b4d3d82d6ae4e8032e43a6c4e0691184425b37320798f865c88b9b306466311d79e3e42076837474c37c9f6336ed777f05f70b0c7d72bd4348a4cd754d0f0c3e4587f9a18313ea2d2bace502a24ea417d3041b709a0471f":"4763a4e37b806a5f4510f69fd8c63571":"07daeba37a66ebe15f3d6451d1176f3a7107a302da6966680c425377e621fd71610d1fc9c95122da5bf85f83b24c4b783b1dcd6b508d41e22c09b5c43693d072869601fc7e3f5a51dbd3bc6508e8d095b9130fb6a7f2a043f3a432e7ce68b7de06c1379e6bab5a1a48823b76762051b4e707ddc3201eb36456e3862425cb011a":32:"3105dddb":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_AES:"ca264e7caecad56ee31c8bf8dde9592f753a6299e76c60ac1e93cff3b3de8ce9":"8d03cf6fac31182ad3e6f32e4c823e3b421aef786d5651afafbf70ef14c00524ab814bc421b1d4181b4d3d82d6ae4e8032e43a6c4e0691184425b37320798f865c88b9b306466311d79e3e42076837474c37c9f6336ed777f05f70b0c7d72bd4348a4cd754d0f0c3e4587f9a18313ea2d2bace502a24ea417d3041b709a0471f":"4763a4e37b806a5f4510f69fd8c63571":"07daeba37a66ebe15f3d6451d1176f3a7107a302da6966680c425377e621fd71610d1fc9c95122da5bf85f83b24c4b783b1dcd6b508d41e22c09b5c43693d072869601fc7e3f5a51dbd3bc6508e8d095b9130fb6a7f2a043f3a432e7ce68b7de06c1379e6bab5a1a48823b76762051b4e707ddc3201eb36456e3862425cb011a":32:"3105dddb":"FAIL":"":0 AES-GCM Bad IV (AES-256,128,0,0,32) #0 depends_on:MBEDTLS_AES_C diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.camellia.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.camellia.data index 5f739d5464..9b71d7c0bb 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.camellia.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.camellia.data @@ -72,144 +72,144 @@ gcm_encrypt_and_tag:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #1 (128-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"":"000000000000000000000000":"":128:"f5574acc3148dfcb9015200631024df9":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"":"000000000000000000000000":"":128:"f5574acc3148dfcb9015200631024df9":"":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #2 (128-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"defe3e0b5c54c94b4f2a0f5a46f6210d":"000000000000000000000000":"":128:"f672b94d192266c7c8c8dbb427cc989a":"00000000000000000000000000000000":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"defe3e0b5c54c94b4f2a0f5a46f6210d":"000000000000000000000000":"":128:"f672b94d192266c7c8c8dbb427cc989a":"":"00000000000000000000000000000000":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #3 (128-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f8260614bab815":"cafebabefacedbaddecaf888":"":128:"86e318012dd8329dc9dae6a170f61b24":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f8260614bab815":"cafebabefacedbaddecaf888":"":128:"86e318012dd8329dc9dae6a170f61b24":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #4 (128-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f82606":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"9f458869431576ea6a095456ec6b8101":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f82606":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"9f458869431576ea6a095456ec6b8101":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #5 (128-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"28fd7434d5cd424a5353818fc21a982460d20cf632eb1e6c4fbfca17d5abcf6a52111086162fe9570e7774c7a912aca3dfa10067ddaad40688645bdd":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"e86f8f2e730c49d536f00fb5225d28b1":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"28fd7434d5cd424a5353818fc21a982460d20cf632eb1e6c4fbfca17d5abcf6a52111086162fe9570e7774c7a912aca3dfa10067ddaad40688645bdd":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"e86f8f2e730c49d536f00fb5225d28b1":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #6 (128-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"2e582b8417c93f2ff4f6f7ee3c361e4496e710ee12433baa964987d02f42953e402e6f4af407fe08cd2f35123696014c34db19128df4056faebcd647":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"ceae5569b2af8641572622731aed3e53":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"2e582b8417c93f2ff4f6f7ee3c361e4496e710ee12433baa964987d02f42953e402e6f4af407fe08cd2f35123696014c34db19128df4056faebcd647":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"ceae5569b2af8641572622731aed3e53":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #7 (192-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"":"000000000000000000000000":"":128:"ba9ae89fddce4b51131e17c4d65ce587":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"":"000000000000000000000000":"":128:"ba9ae89fddce4b51131e17c4d65ce587":"":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #8 (192-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"8f9c0aa2549714c88bb2665e8af86d41":"000000000000000000000000":"":128:"783cff5c5aca7197320658a74279ab37":"00000000000000000000000000000000":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"8f9c0aa2549714c88bb2665e8af86d41":"000000000000000000000000":"":128:"783cff5c5aca7197320658a74279ab37":"":"00000000000000000000000000000000":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #9 (192-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6a60bb2e9":"cafebabefacedbaddecaf888":"":128:"8d645a0b0e48d3c3b60a014157cb49b4":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6a60bb2e9":"cafebabefacedbaddecaf888":"":128:"8d645a0b0e48d3c3b60a014157cb49b4":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #10 (192-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"01b15bb5ab6fac0c422014e91eacbf2b":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"01b15bb5ab6fac0c422014e91eacbf2b":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #11 (192-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"678b3dcb270faa206dc5f6fbb5014996e86d6f3e35cdcdfeb03b37b9b06ff4ff2682248823bd3c84124dc76af7bde3dd440c228b5efbc795dd80dfb6":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"f876143d933214a5035ff0bb96ff650b":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"678b3dcb270faa206dc5f6fbb5014996e86d6f3e35cdcdfeb03b37b9b06ff4ff2682248823bd3c84124dc76af7bde3dd440c228b5efbc795dd80dfb6":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"f876143d933214a5035ff0bb96ff650b":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #12 (192-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"9733ea567c3bad2259ccd63ef7012f5de709e50b1fdc31f1a16db02ede1b66f11dcc4d953f2d4d4671587b65882afbf9545fdb6deab22413d091b703":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4b72e520b2521e63d240ed5c903216fa":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"9733ea567c3bad2259ccd63ef7012f5de709e50b1fdc31f1a16db02ede1b66f11dcc4d953f2d4d4671587b65882afbf9545fdb6deab22413d091b703":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4b72e520b2521e63d240ed5c903216fa":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #13 (256-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000000":"":"000000000000000000000000":"":128:"9cdb269b5d293bc5db9c55b057d9b591":"":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000000":"":"000000000000000000000000":"":128:"9cdb269b5d293bc5db9c55b057d9b591":"":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #14 (256-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000000":"3d4b2cde666761ba5dfb305178e667fb":"000000000000000000000000":"":128:"284b63bb143c40ce100fb4dea6bb617b":"00000000000000000000000000000000":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000000":"3d4b2cde666761ba5dfb305178e667fb":"000000000000000000000000":"":128:"284b63bb143c40ce100fb4dea6bb617b":"":"00000000000000000000000000000000":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #15 (256-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4948d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b776549e092":"cafebabefacedbaddecaf888":"":128:"c912686270a2b9966415fca3be75c468":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4948d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b776549e092":"cafebabefacedbaddecaf888":"":128:"c912686270a2b9966415fca3be75c468":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #16 (256-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4948d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b77":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4e4b178d8fe26fdc95e2e7246dd94bec":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4948d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b77":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4e4b178d8fe26fdc95e2e7246dd94bec":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #17 (256-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"6ca95fbb7d16577a9ef2fded94dc85b5d40c629f6bef2c649888e3cbb0ededc7810c04b12c2983bbbbc482e16e45c9215ae12c15c55f2f4809d06652":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"e6472b8ebd331bfcc7c0fa63ce094461":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"6ca95fbb7d16577a9ef2fded94dc85b5d40c629f6bef2c649888e3cbb0ededc7810c04b12c2983bbbbc482e16e45c9215ae12c15c55f2f4809d06652":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"e6472b8ebd331bfcc7c0fa63ce094461":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #18 (256-de) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"e0cddd7564d09c4dc522dd65949262bbf9dcdb07421cf67f3032becb7253c284a16e5bf0f556a308043f53fab9eebb526be7f7ad33d697ac77c67862":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"5791883f822013f8bd136fc36fb9946b":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"e0cddd7564d09c4dc522dd65949262bbf9dcdb07421cf67f3032becb7253c284a16e5bf0f556a308043f53fab9eebb526be7f7ad33d697ac77c67862":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"5791883f822013f8bd136fc36fb9946b":"":"d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #1 (128-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"":"000000000000000000000000":"":128:"f5574acc3148dfcb9015200631024df8":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"":"000000000000000000000000":"":128:"f5574acc3148dfcb9015200631024df8":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #2 (128-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"defe3e0b5c54c94b4f2a0f5a46f7210d":"000000000000000000000000":"":128:"f672b94d192266c7c8c8dbb427cc989a":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"00000000000000000000000000000000":"defe3e0b5c54c94b4f2a0f5a46f7210d":"000000000000000000000000":"":128:"f672b94d192266c7c8c8dbb427cc989a":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #3 (128-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f8260614bab815":"cafebabefacedbaddecaf889":"":128:"86e318012dd8329dc9dae6a170f61b24":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f8260614bab815":"cafebabefacedbaddecaf889":"":128:"86e318012dd8329dc9dae6a170f61b24":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #4 (128-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f82606":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"9f458869431576ea6a095456ec6b8100":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"d0d94a13b632f337a0cc9955b94fa020c815f903aab12f1efaf2fe9d90f729a6cccbfa986ef2ff2c33de418d9a2529091cf18fe652c1cfde13f82606":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"9f458869431576ea6a095456ec6b8100":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #5 (128-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"28fd7434d5cd424a5353818fc21a982460d20cf632eb1e6c4fbfca17d5abcf6a52111086162fe9570e7774c7a912aca3dfa10067ddaad40688645bdd":"cafebabefacedbad":"feedfadedeadbeeffeedfacedeadbeefabaddad2":128:"e86f8f2e730c49d536f00fb5225d28b1":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"28fd7434d5cd424a5353818fc21a982460d20cf632eb1e6c4fbfca17d5abcf6a52111086162fe9570e7774c7a912aca3dfa10067ddaad40688645bdd":"cafebabefacedbad":"feedfadedeadbeeffeedfacedeadbeefabaddad2":128:"e86f8f2e730c49d536f00fb5225d28b1":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #6 (128-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"2e582b8417c83f2ff4f6f7ee3c361e4496e710ee12433baa964987d02f42953e402e6f4af407fe08cd2f35123696014c34db19128df4056faebcd647":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"ceae5569b2af8641572622731aed3e53":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308":"2e582b8417c83f2ff4f6f7ee3c361e4496e710ee12433baa964987d02f42953e402e6f4af407fe08cd2f35123696014c34db19128df4056faebcd647":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"ceae5569b2af8641572622731aed3e53":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #7 (192-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"":"000000000000000000000000":"":128:"ba9ae89fddce4b51131e17c4d65ce586":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"":"000000000000000000000000":"":128:"ba9ae89fddce4b51131e17c4d65ce586":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #8 (192-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"8f9c0aa2549714c88bb2665e8af86d42":"000000000000000000000000":"":128:"783cff5c5aca7197320658a74279ab37":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"000000000000000000000000000000000000000000000000":"8f9c0aa2549714c88bb2665e8af86d42":"000000000000000000000000":"":128:"783cff5c5aca7197320658a74279ab37":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #9 (192-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"ffffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6a60bb2e9":"cafebabefacedbaddecaf888":"":128:"8d645a0b0e48d3c3b60a014157cb49b4":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"ffffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6a60bb2e9":"cafebabefacedbaddecaf888":"":128:"8d645a0b0e48d3c3b60a014157cb49b4":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #10 (192-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"11b15bb5ab6fac0c422014e91eacbf2b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"0f009e88410d84ad93c90d55efbe20ffa855492f4dfd0fb485c4f02f536feffbb4d967729e5c67f1de0750255cc500716ba483eb3b0a2bf607af28f6":"cafebabefacedbaddecaf888":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"11b15bb5ab6fac0c422014e91eacbf2b":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #11 (192-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"678b3dcb270faa206dc5f6fbb5014996e86d6f3e35cdcdfeb03b37b9b06ff4ff2682248823bd3c84124dc76af7bde3dd440c228b5efbc795dd80dfb6":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad3":128:"f876143d933214a5035ff0bb96ff650b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"678b3dcb270faa206dc5f6fbb5014996e86d6f3e35cdcdfeb03b37b9b06ff4ff2682248823bd3c84124dc76af7bde3dd440c228b5efbc795dd80dfb6":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad3":128:"f876143d933214a5035ff0bb96ff650b":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #12 (192-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"9733ea567c3bad2259ccd63ef7012f5de709e50b1fdc31f1a16db02ede1b66f11dcc4d953f2d4d4671587b65882afbf9545fdb6deab22413d091b703":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a328a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4b72e520b2521e63d240ed5c903216fa":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c":"9733ea567c3bad2259ccd63ef7012f5de709e50b1fdc31f1a16db02ede1b66f11dcc4d953f2d4d4671587b65882afbf9545fdb6deab22413d091b703":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a328a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4b72e520b2521e63d240ed5c903216fa":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #13 (256-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000001":"":"000000000000000000000000":"":128:"9cdb269b5d293bc5db9c55b057d9b591":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000001":"":"000000000000000000000000":"":128:"9cdb269b5d293bc5db9c55b057d9b591":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #14 (256-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000000":"3d4b2cde666761ba5dfb305178e667fb":"000000000000000000000001":"":128:"284b63bb143c40ce100fb4dea6bb617b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"0000000000000000000000000000000000000000000000000000000000000000":"3d4b2cde666761ba5dfb305178e667fb":"000000000000000000000001":"":128:"284b63bb143c40ce100fb4dea6bb617b":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #15 (256-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4949d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b776549e092":"cafebabefacedbaddecaf888":"":128:"c912686270a2b9966415fca3be75c468":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4949d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b776549e092":"cafebabefacedbaddecaf888":"":128:"c912686270a2b9966415fca3be75c468":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #16 (256-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4948d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b77":"cafebabefacedbaddecaf888":"ffedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4e4b178d8fe26fdc95e2e7246dd94bec":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"ad142c11579dd95e41f3c1f324dabc255864d920f1b65759d8f560d4948d447758dfdcf77aa9f62581c7ff572a037f810cb1a9c4b3ca6ed638179b77":"cafebabefacedbaddecaf888":"ffedfacedeadbeeffeedfacedeadbeefabaddad2":128:"4e4b178d8fe26fdc95e2e7246dd94bec":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #17 (256-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"6ca95fbb7d16577a9ef2fded94dc85b5d40c629f6bef2c649888e3cbb0ededc7810c04b12c2983bbbbc482e16e45c9215ae12c15c55f2f4809d06652":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"e6472b8ebd331bfcc7c0fa63ce094462":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a8f9467308308feffe9928665731c6d6a8f9467308308":"6ca95fbb7d16577a9ef2fded94dc85b5d40c629f6bef2c649888e3cbb0ededc7810c04b12c2983bbbbc482e16e45c9215ae12c15c55f2f4809d06652":"cafebabefacedbad":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"e6472b8ebd331bfcc7c0fa63ce094462":"FAIL":"":0 Camellia-GCM test vect draft-kato-ipsec-camellia-gcm #18 (256-bad) depends_on:MBEDTLS_CAMELLIA_C -gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a9f9467308308feffe9928665731c6d6a8f9467308308":"e0cddd7564d09c4dc522dd65949262bbf9dcdb07421cf67f3032becb7253c284a16e5bf0f556a308043f53fab9eebb526be7f7ad33d697ac77c67862":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"5791883f822013f8bd136fc36fb9946b":"FAIL":0 +gcm_decrypt_and_verify:MBEDTLS_CIPHER_ID_CAMELLIA:"feffe9928665731c6d6a9f9467308308feffe9928665731c6d6a8f9467308308":"e0cddd7564d09c4dc522dd65949262bbf9dcdb07421cf67f3032becb7253c284a16e5bf0f556a308043f53fab9eebb526be7f7ad33d697ac77c67862":"9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b":"feedfacedeadbeeffeedfacedeadbeefabaddad2":128:"5791883f822013f8bd136fc36fb9946b":"FAIL":"":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.function index 3d0830e98e..1fcb681b98 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.function @@ -9,41 +9,23 @@ /* BEGIN_CASE */ void gcm_bad_parameters( int cipher_id, int direction, - char *hex_key_string, char *hex_src_string, - char *hex_iv_string, char *hex_add_string, + data_t *key_str, data_t *src_str, + data_t *iv_str, data_t *add_str, int tag_len_bits, int gcm_result ) { - unsigned char key_str[128]; - unsigned char src_str[128]; - unsigned char dst_str[257]; - unsigned char iv_str[128]; - unsigned char add_str[128]; - unsigned char tag_str[128]; unsigned char output[128]; unsigned char tag_output[16]; mbedtls_gcm_context ctx; - unsigned int key_len; - size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8; + size_t tag_len = tag_len_bits / 8; mbedtls_gcm_init( &ctx ); - memset( key_str, 0x00, sizeof( key_str ) ); - memset( src_str, 0x00, sizeof( src_str ) ); - memset( dst_str, 0x00, sizeof( dst_str ) ); - memset( iv_str, 0x00, sizeof( iv_str ) ); - memset( add_str, 0x00, sizeof( add_str ) ); - memset( tag_str, 0x00, sizeof( tag_str ) ); memset( output, 0x00, sizeof( output ) ); memset( tag_output, 0x00, sizeof( tag_output ) ); - key_len = unhexify( key_str, hex_key_string ); - pt_len = unhexify( src_str, hex_src_string ); - iv_len = unhexify( iv_str, hex_iv_string ); - add_len = unhexify( add_str, hex_add_string ); - - TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str, key_len * 8 ) == 0 ); - TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, direction, pt_len, iv_str, iv_len, - add_str, add_len, src_str, output, tag_len, tag_output ) == gcm_result ); + TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 ); + TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, direction, src_str->len, iv_str->x, iv_str->len, + add_str->x, add_str->len, src_str->x, output, tag_len, tag_output ) == gcm_result ); exit: mbedtls_gcm_free( &ctx ); @@ -51,49 +33,30 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void gcm_encrypt_and_tag( int cipher_id, - char *hex_key_string, char *hex_src_string, - char *hex_iv_string, char *hex_add_string, - char *hex_dst_string, int tag_len_bits, - char *hex_tag_string, int init_result ) +void gcm_encrypt_and_tag( int cipher_id, data_t * key_str, + data_t * src_str, data_t * iv_str, + data_t * add_str, data_t * hex_dst_string, + int tag_len_bits, data_t * hex_tag_string, + int init_result ) { - unsigned char key_str[128]; - unsigned char src_str[128]; - unsigned char dst_str[257]; - unsigned char iv_str[128]; - unsigned char add_str[128]; - unsigned char tag_str[128]; unsigned char output[128]; unsigned char tag_output[16]; mbedtls_gcm_context ctx; - unsigned int key_len; - size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8; + size_t tag_len = tag_len_bits / 8; mbedtls_gcm_init( &ctx ); - memset(key_str, 0x00, 128); - memset(src_str, 0x00, 128); - memset(dst_str, 0x00, 257); - memset(iv_str, 0x00, 128); - memset(add_str, 0x00, 128); - memset(tag_str, 0x00, 128); memset(output, 0x00, 128); memset(tag_output, 0x00, 16); - key_len = unhexify( key_str, hex_key_string ); - pt_len = unhexify( src_str, hex_src_string ); - iv_len = unhexify( iv_str, hex_iv_string ); - add_len = unhexify( add_str, hex_add_string ); - TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str, key_len * 8 ) == init_result ); + TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == init_result ); if( init_result == 0 ) { - TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT, pt_len, iv_str, iv_len, add_str, add_len, src_str, output, tag_len, tag_output ) == 0 ); - hexify( dst_str, output, pt_len ); - hexify( tag_str, tag_output, tag_len ); + TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, MBEDTLS_GCM_ENCRYPT, src_str->len, iv_str->x, iv_str->len, add_str->x, add_str->len, src_str->x, output, tag_len, tag_output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); - TEST_ASSERT( strcmp( (char *) tag_str, hex_tag_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); + TEST_ASSERT( hexcmp( tag_output, hex_tag_string->x, tag_len, hex_tag_string->len ) == 0 ); } exit: @@ -102,55 +65,36 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void gcm_decrypt_and_verify( int cipher_id, - char *hex_key_string, char *hex_src_string, - char *hex_iv_string, char *hex_add_string, - int tag_len_bits, char *hex_tag_string, - char *pt_result, int init_result ) +void gcm_decrypt_and_verify( int cipher_id, data_t * key_str, + data_t * src_str, data_t * iv_str, + data_t * add_str, int tag_len_bits, + data_t * tag_str, char * result, + data_t * pt_result, int init_result ) { - unsigned char key_str[128]; - unsigned char src_str[128]; - unsigned char dst_str[257]; - unsigned char iv_str[128]; - unsigned char add_str[128]; - unsigned char tag_str[128]; unsigned char output[128]; mbedtls_gcm_context ctx; - unsigned int key_len; - size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8; int ret; + size_t tag_len = tag_len_bits / 8; mbedtls_gcm_init( &ctx ); - memset(key_str, 0x00, 128); - memset(src_str, 0x00, 128); - memset(dst_str, 0x00, 257); - memset(iv_str, 0x00, 128); - memset(add_str, 0x00, 128); - memset(tag_str, 0x00, 128); memset(output, 0x00, 128); - key_len = unhexify( key_str, hex_key_string ); - pt_len = unhexify( src_str, hex_src_string ); - iv_len = unhexify( iv_str, hex_iv_string ); - add_len = unhexify( add_str, hex_add_string ); - unhexify( tag_str, hex_tag_string ); - TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str, key_len * 8 ) == init_result ); + TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == init_result ); if( init_result == 0 ) { - ret = mbedtls_gcm_auth_decrypt( &ctx, pt_len, iv_str, iv_len, add_str, add_len, tag_str, tag_len, src_str, output ); + ret = mbedtls_gcm_auth_decrypt( &ctx, src_str->len, iv_str->x, iv_str->len, add_str->x, add_str->len, tag_str->x, tag_len, src_str->x, output ); - if( strcmp( "FAIL", pt_result ) == 0 ) + if( strcmp( "FAIL", result ) == 0 ) { TEST_ASSERT( ret == MBEDTLS_ERR_GCM_AUTH_FAILED ); } else { TEST_ASSERT( ret == 0 ); - hexify( dst_str, output, pt_len ); - TEST_ASSERT( strcmp( (char *) dst_str, pt_result ) == 0 ); + TEST_ASSERT( hexcmp( output, pt_result->x, src_str->len, pt_result->len ) == 0 ); } } @@ -159,8 +103,177 @@ exit: } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void gcm_invalid_param( ) +{ + mbedtls_gcm_context ctx; + unsigned char valid_buffer[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }; + mbedtls_cipher_id_t valid_cipher = MBEDTLS_CIPHER_ID_AES; + int valid_mode = MBEDTLS_GCM_ENCRYPT; + int valid_len = sizeof(valid_buffer); + int valid_bitlen = 128, invalid_bitlen = 1; + + mbedtls_gcm_init( &ctx ); + + /* mbedtls_gcm_init() */ + TEST_INVALID_PARAM( mbedtls_gcm_init( NULL ) ); + + /* mbedtls_gcm_setkey */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_setkey( NULL, valid_cipher, valid_buffer, valid_bitlen ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_setkey( &ctx, valid_cipher, NULL, valid_bitlen ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_setkey( &ctx, valid_cipher, valid_buffer, invalid_bitlen ) ); + + /* mbedtls_gcm_crypt_and_tag() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_crypt_and_tag( NULL, valid_mode, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_len, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_len, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_buffer, + valid_len, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_buffer, + valid_len, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, NULL, + valid_len, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_crypt_and_tag( &ctx, valid_mode, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer, + valid_len, NULL ) ); + + /* mbedtls_gcm_auth_decrypt() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_auth_decrypt( NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_auth_decrypt( &ctx, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_buffer) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_len, + valid_buffer, valid_buffer) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + NULL, valid_buffer) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_auth_decrypt( &ctx, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, valid_len, + valid_buffer, NULL) ); + + /* mbedtls_gcm_starts() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_starts( NULL, valid_mode, + valid_buffer, valid_len, + valid_buffer, valid_len ) ); + + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_starts( &ctx, valid_mode, + NULL, valid_len, + valid_buffer, valid_len ) ); + + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_starts( &ctx, valid_mode, + valid_buffer, valid_len, + NULL, valid_len ) ); + + /* mbedtls_gcm_update() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_update( NULL, valid_len, + valid_buffer, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_update( &ctx, valid_len, + NULL, valid_buffer ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_update( &ctx, valid_len, + valid_buffer, NULL ) ); + + /* mbedtls_gcm_finish() */ + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_finish( NULL, valid_buffer, valid_len ) ); + TEST_INVALID_PARAM_RET( + MBEDTLS_ERR_GCM_BAD_INPUT, + mbedtls_gcm_finish( &ctx, NULL, valid_len ) ); + +exit: + mbedtls_gcm_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void gcm_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_gcm_free( NULL ) ); +exit: + return; +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void gcm_selftest() +void gcm_selftest( ) { TEST_ASSERT( mbedtls_gcm_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.misc.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.misc.data new file mode 100644 index 0000000000..cf01526535 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_gcm.misc.data @@ -0,0 +1,5 @@ +GCM - Invalid parameters +gcm_invalid_param: + +GCM - Valid parameters +gcm_valid_param: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hkdf.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hkdf.data new file mode 100644 index 0000000000..15837365fe --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hkdf.data @@ -0,0 +1,98 @@ +HKDF extract fails with hash_len of 0 +test_hkdf_extract_ret:0:MBEDTLS_ERR_HKDF_BAD_INPUT_DATA + +HKDF expand fails with NULL okm +test_hkdf_expand_ret:32:32:0:MBEDTLS_ERR_HKDF_BAD_INPUT_DATA + +HKDF expand fails with hash_len of 0 +test_hkdf_expand_ret:0:32:32:MBEDTLS_ERR_HKDF_BAD_INPUT_DATA + +HKDF expand fails with prk_len < hash_len +test_hkdf_expand_ret:32:16:32:MBEDTLS_ERR_HKDF_BAD_INPUT_DATA + +HKDF expand fails with okm_len / hash_len > 255 +test_hkdf_expand_ret:32:32:8192:MBEDTLS_ERR_HKDF_BAD_INPUT_DATA + +HKDF RFC5869 Test Vector #1 +depends_on:MBEDTLS_SHA256_C +test_hkdf:6:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" + +HKDF RFC5869 Test Vector #2 +depends_on:MBEDTLS_SHA256_C +test_hkdf:6:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf":"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87" + +HKDF RFC5869 Test Vector #3 +depends_on:MBEDTLS_SHA256_C +test_hkdf:6:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"":"":"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8" + +HKDF RFC5869 Test Vector #4 +depends_on:MBEDTLS_SHA1_C +test_hkdf:4:"0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"f0f1f2f3f4f5f6f7f8f9":"085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896" + +HKDF RFC5869 Test Vector #5 +depends_on:MBEDTLS_SHA1_C +test_hkdf:4:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf":"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4" + +HKDF RFC5869 Test Vector #6 +depends_on:MBEDTLS_SHA1_C +test_hkdf:4:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"":"":"0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918" + +HKDF RFC5869 Test Vector #7 +depends_on:MBEDTLS_SHA1_C +test_hkdf:4:"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c":"":"":"2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48" + +HKDF RFC5869 Test Vector #1 Extract +depends_on:MBEDTLS_SHA256_C +test_hkdf_extract:6:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5" + +HKDF RFC5869 Test Vector #2 Extract +depends_on:MBEDTLS_SHA256_C +test_hkdf_extract:6:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf":"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244" + +HKDF RFC5869 Test Vector #3 Extract +depends_on:MBEDTLS_SHA256_C +test_hkdf_extract:6:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"":"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04" + +HKDF RFC5869 Test Vector #4 Extract +depends_on:MBEDTLS_SHA1_C +test_hkdf_extract:4:"0b0b0b0b0b0b0b0b0b0b0b":"000102030405060708090a0b0c":"9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243" + +HKDF RFC5869 Test Vector #5 Extract +depends_on:MBEDTLS_SHA1_C +test_hkdf_extract:4:"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f":"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf":"8adae09a2a307059478d309b26c4115a224cfaf6" + +HKDF RFC5869 Test Vector #6 Extract +depends_on:MBEDTLS_SHA1_C +test_hkdf_extract:4:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"":"da8c8a73c7fa77288ec6f5e7c297786aa0d32d01" + +HKDF RFC5869 Test Vector #7 Extract +depends_on:MBEDTLS_SHA1_C +test_hkdf_extract:4:"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c":"":"2adccada18779e7c2077ad2eb19d3f3e731385dd" + +HKDF RFC5869 Test Vector #1 Expand +depends_on:MBEDTLS_SHA256_C +test_hkdf_expand:6:"f0f1f2f3f4f5f6f7f8f9":"077709362c2e32df0ddc3f0dc47bba6390b6c73bb50f9c3122ec844ad7c2b3e5":"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf34007208d5b887185865" + +HKDF RFC5869 Test Vector #2 Expand +depends_on:MBEDTLS_SHA256_C +test_hkdf_expand:6:"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"06a6b88c5853361a06104c9ceb35b45cef760014904671014a193f40c15fc244":"b11e398dc80327a1c8e7f78c596a49344f012eda2d4efad8a050cc4c19afa97c59045a99cac7827271cb41c65e590e09da3275600c2f09b8367793a9aca3db71cc30c58179ec3e87c14c01d5c1f3434f1d87" + +HKDF RFC5869 Test Vector #3 Expand +depends_on:MBEDTLS_SHA256_C +test_hkdf_expand:6:"":"19ef24a32c717b167f33a91d6f648bdf96596776afdb6377ac434c1c293ccb04":"8da4e775a563c18f715f802a063c5a31b8a11f5c5ee1879ec3454e5f3c738d2d9d201395faa4b61a96c8" + +HKDF RFC5869 Test Vector #4 Expand +depends_on:MBEDTLS_SHA1_C +test_hkdf_expand:4:"f0f1f2f3f4f5f6f7f8f9":"9b6c18c432a7bf8f0e71c8eb88f4b30baa2ba243":"085a01ea1b10f36933068b56efa5ad81a4f14b822f5b091568a9cdd4f155fda2c22e422478d305f3f896" + +HKDF RFC5869 Test Vector #5 Expand +depends_on:MBEDTLS_SHA1_C +test_hkdf_expand:4:"b0b1b2b3b4b5b6b7b8b9babbbcbdbebfc0c1c2c3c4c5c6c7c8c9cacbcccdcecfd0d1d2d3d4d5d6d7d8d9dadbdcdddedfe0e1e2e3e4e5e6e7e8e9eaebecedeeeff0f1f2f3f4f5f6f7f8f9fafbfcfdfeff":"8adae09a2a307059478d309b26c4115a224cfaf6":"0bd770a74d1160f7c9f12cd5912a06ebff6adcae899d92191fe4305673ba2ffe8fa3f1a4e5ad79f3f334b3b202b2173c486ea37ce3d397ed034c7f9dfeb15c5e927336d0441f4c4300e2cff0d0900b52d3b4" + +HKDF RFC5869 Test Vector #6 Expand +depends_on:MBEDTLS_SHA1_C +test_hkdf_expand:4:"":"da8c8a73c7fa77288ec6f5e7c297786aa0d32d01":"0ac1af7002b3d761d1e55298da9d0506b9ae52057220a306e07b6b87e8df21d0ea00033de03984d34918" + +HKDF RFC5869 Test Vector #7 Expand +depends_on:MBEDTLS_SHA1_C +test_hkdf_expand:4:"":"2adccada18779e7c2077ad2eb19d3f3e731385dd":"2c91117204d745f3500d636a62f64f0ab3bae548aa53d423b0d1f27ebba6f5e5673a081d70cce7acfc48" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hkdf.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hkdf.function new file mode 100644 index 0000000000..3e8720734e --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hkdf.function @@ -0,0 +1,174 @@ +/* BEGIN_HEADER */ +#include "mbedtls/hkdf.h" +#include "mbedtls/md_internal.h" +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_HKDF_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void test_hkdf( int md_alg, char *hex_ikm_string, char *hex_salt_string, + char *hex_info_string, char *hex_okm_string ) +{ + int ret; + size_t ikm_len, salt_len, info_len, okm_len; + unsigned char ikm[128] = { '\0' }; + unsigned char salt[128] = { '\0' }; + unsigned char info[128] = { '\0' }; + unsigned char expected_okm[128] = { '\0' }; + unsigned char okm[128] = { '\0' }; + /* + * okm_hex is the string representation of okm, + * so its size is twice the size of okm, and an extra null-termination. + */ + unsigned char okm_hex[257] = { '\0' }; + + const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg ); + TEST_ASSERT( md != NULL ); + + ikm_len = unhexify( ikm, hex_ikm_string ); + salt_len = unhexify( salt, hex_salt_string ); + info_len = unhexify( info, hex_info_string ); + okm_len = unhexify( expected_okm, hex_okm_string ); + + ret = mbedtls_hkdf( md, salt, salt_len, ikm, ikm_len, info, info_len, okm, + okm_len); + TEST_ASSERT( ret == 0 ); + + // Run hexify on it so that it looks nicer if the assertion fails + hexify( okm_hex, okm, okm_len ); + TEST_ASSERT( !strcmp( (char *)okm_hex, hex_okm_string ) ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void test_hkdf_extract( int md_alg, char *hex_ikm_string, + char *hex_salt_string, char *hex_prk_string ) +{ + int ret; + unsigned char *ikm = NULL; + unsigned char *salt = NULL; + unsigned char *prk = NULL; + unsigned char *output_prk = NULL; + size_t ikm_len, salt_len, prk_len, output_prk_len; + + const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg ); + TEST_ASSERT( md != NULL ); + + output_prk_len = mbedtls_md_get_size( md ); + output_prk = mbedtls_calloc( 1, output_prk_len ); + + ikm = unhexify_alloc( hex_ikm_string, &ikm_len ); + salt = unhexify_alloc( hex_salt_string, &salt_len ); + prk = unhexify_alloc( hex_prk_string, &prk_len ); + TEST_ASSERT( prk_len == output_prk_len ); + + ret = mbedtls_hkdf_extract( md, salt, salt_len, ikm, ikm_len, output_prk ); + TEST_ASSERT( ret == 0 ); + + TEST_ASSERT( !memcmp( output_prk, prk, prk_len ) ); + +exit: + mbedtls_free(ikm); + mbedtls_free(salt); + mbedtls_free(prk); + mbedtls_free(output_prk); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void test_hkdf_expand( int md_alg, char *hex_info_string, + char *hex_prk_string, char *hex_okm_string ) +{ + enum { OKM_LEN = 1024 }; + int ret; + unsigned char *info = NULL; + unsigned char *prk = NULL; + unsigned char *okm = NULL; + unsigned char *output_okm = NULL; + size_t info_len, prk_len, okm_len; + + const mbedtls_md_info_t *md = mbedtls_md_info_from_type( md_alg ); + TEST_ASSERT( md != NULL ); + + output_okm = mbedtls_calloc( OKM_LEN, 1 ); + + prk = unhexify_alloc( hex_prk_string, &prk_len ); + info = unhexify_alloc( hex_info_string, &info_len ); + okm = unhexify_alloc( hex_okm_string, &okm_len ); + TEST_ASSERT( prk_len == mbedtls_md_get_size( md ) ); + TEST_ASSERT( okm_len < OKM_LEN ); + + ret = mbedtls_hkdf_expand( md, prk, prk_len, info, info_len, + output_okm, OKM_LEN ); + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( !memcmp( output_okm, okm, okm_len ) ); + +exit: + mbedtls_free(info); + mbedtls_free(prk); + mbedtls_free(okm); + mbedtls_free(output_okm); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void test_hkdf_extract_ret( int hash_len, int ret ) +{ + int output_ret; + unsigned char *salt = NULL; + unsigned char *ikm = NULL; + unsigned char *prk = NULL; + size_t salt_len, ikm_len; + struct mbedtls_md_info_t fake_md_info; + + memset( &fake_md_info, 0, sizeof( fake_md_info ) ); + fake_md_info.type = MBEDTLS_MD_NONE; + fake_md_info.size = hash_len; + + prk = mbedtls_calloc( MBEDTLS_MD_MAX_SIZE, 1 ); + salt_len = 0; + ikm_len = 0; + + output_ret = mbedtls_hkdf_extract( &fake_md_info, salt, salt_len, + ikm, ikm_len, prk ); + TEST_ASSERT( output_ret == ret ); + +exit: + mbedtls_free(prk); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void test_hkdf_expand_ret( int hash_len, int prk_len, int okm_len, int ret ) +{ + int output_ret; + unsigned char *info = NULL; + unsigned char *prk = NULL; + unsigned char *okm = NULL; + size_t info_len; + struct mbedtls_md_info_t fake_md_info; + + memset( &fake_md_info, 0, sizeof( fake_md_info ) ); + fake_md_info.type = MBEDTLS_MD_NONE; + fake_md_info.size = hash_len; + + info_len = 0; + + if (prk_len > 0) + prk = mbedtls_calloc( prk_len, 1 ); + + if (okm_len > 0) + okm = mbedtls_calloc( okm_len, 1 ); + + output_ret = mbedtls_hkdf_expand( &fake_md_info, prk, prk_len, + info, info_len, okm, okm_len ); + TEST_ASSERT( output_ret == ret ); + +exit: + mbedtls_free(prk); + mbedtls_free(okm); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hmac_drbg.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hmac_drbg.function index a413f5e182..13bc400623 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hmac_drbg.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_hmac_drbg.function @@ -1,5 +1,6 @@ /* BEGIN_HEADER */ #include "mbedtls/hmac_drbg.h" +#include "string.h" typedef struct { @@ -109,7 +110,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ -void hmac_drbg_seed_file( int md_alg, char *path, int ret ) +void hmac_drbg_seed_file( int md_alg, char * path, int ret ) { const mbedtls_md_info_t *md_info; mbedtls_hmac_drbg_context ctx; @@ -160,59 +161,47 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void hmac_drbg_no_reseed( int md_alg, - char *entropy_hex, char *custom_hex, - char *add1_hex, char *add2_hex, - char *output_hex ) +void hmac_drbg_no_reseed( int md_alg, data_t * entropy, + data_t * custom, data_t * add1, + data_t * add2, data_t * output ) { unsigned char data[1024]; - unsigned char entropy[512]; - unsigned char custom[512]; - unsigned char add1[512]; - unsigned char add2[512]; - unsigned char output[512]; unsigned char my_output[512]; - size_t custom_len, add1_len, add2_len, out_len; entropy_ctx p_entropy; const mbedtls_md_info_t *md_info; mbedtls_hmac_drbg_context ctx; mbedtls_hmac_drbg_init( &ctx ); - memset( my_output, 0, sizeof my_output ); - custom_len = unhexify( custom, custom_hex ); - add1_len = unhexify( add1, add1_hex ); - add2_len = unhexify( add2, add2_hex ); - out_len = unhexify( output, output_hex ); - p_entropy.len = unhexify( entropy, entropy_hex ); - p_entropy.p = entropy; + p_entropy.p = entropy->x; + p_entropy.len = entropy->len; md_info = mbedtls_md_info_from_type( md_alg ); TEST_ASSERT( md_info != NULL ); /* Test the simplified buffer-based variant */ - memcpy( data, entropy, p_entropy.len ); - memcpy( data + p_entropy.len, custom, custom_len ); + memcpy( data, entropy->x, p_entropy.len ); + memcpy( data + p_entropy.len, custom->x, custom->len ); TEST_ASSERT( mbedtls_hmac_drbg_seed_buf( &ctx, md_info, - data, p_entropy.len + custom_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add1, add1_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add2, add2_len ) == 0 ); + data, p_entropy.len + custom->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add1->x, add1->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add2->x, add2->len ) == 0 ); /* clear for second run */ mbedtls_hmac_drbg_free( &ctx ); - TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 ); + TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 ); /* And now the normal entropy-based variant */ TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy, - custom, custom_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add1, add1_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add2, add2_len ) == 0 ); - TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 ); + custom->x, custom->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add1->x, add1->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add2->x, add2->len ) == 0 ); + TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 ); exit: mbedtls_hmac_drbg_free( &ctx ); @@ -220,46 +209,32 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void hmac_drbg_nopr( int md_alg, - char *entropy_hex, char *custom_hex, - char *add1_hex, char *add2_hex, char *add3_hex, - char *output_hex ) +void hmac_drbg_nopr( int md_alg, data_t * entropy, data_t * custom, + data_t * add1, data_t * add2, data_t * add3, + data_t * output ) { - unsigned char entropy[512]; - unsigned char custom[512]; - unsigned char add1[512]; - unsigned char add2[512]; - unsigned char add3[512]; - unsigned char output[512]; unsigned char my_output[512]; - size_t custom_len, add1_len, add2_len, add3_len, out_len; entropy_ctx p_entropy; const mbedtls_md_info_t *md_info; mbedtls_hmac_drbg_context ctx; mbedtls_hmac_drbg_init( &ctx ); - memset( my_output, 0, sizeof my_output ); - custom_len = unhexify( custom, custom_hex ); - add1_len = unhexify( add1, add1_hex ); - add2_len = unhexify( add2, add2_hex ); - add3_len = unhexify( add3, add3_hex ); - out_len = unhexify( output, output_hex ); - p_entropy.len = unhexify( entropy, entropy_hex ); - p_entropy.p = entropy; + p_entropy.p = entropy->x; + p_entropy.len = entropy->len; md_info = mbedtls_md_info_from_type( md_alg ); TEST_ASSERT( md_info != NULL ); TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy, - custom, custom_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_reseed( &ctx, add1, add1_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add2, add2_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add3, add3_len ) == 0 ); + custom->x, custom->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_reseed( &ctx, add1->x, add1->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add2->x, add2->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add3->x, add3->len ) == 0 ); - TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 ); + TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 ); exit: mbedtls_hmac_drbg_free( &ctx ); @@ -267,44 +242,31 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void hmac_drbg_pr( int md_alg, - char *entropy_hex, char *custom_hex, - char *add1_hex, char *add2_hex, - char *output_hex ) +void hmac_drbg_pr( int md_alg, data_t * entropy, data_t * custom, + data_t * add1, data_t * add2, data_t * output ) { - unsigned char entropy[512]; - unsigned char custom[512]; - unsigned char add1[512]; - unsigned char add2[512]; - unsigned char output[512]; unsigned char my_output[512]; - size_t custom_len, add1_len, add2_len, out_len; entropy_ctx p_entropy; const mbedtls_md_info_t *md_info; mbedtls_hmac_drbg_context ctx; mbedtls_hmac_drbg_init( &ctx ); - memset( my_output, 0, sizeof my_output ); - custom_len = unhexify( custom, custom_hex ); - add1_len = unhexify( add1, add1_hex ); - add2_len = unhexify( add2, add2_hex ); - out_len = unhexify( output, output_hex ); - p_entropy.len = unhexify( entropy, entropy_hex ); - p_entropy.p = entropy; + p_entropy.p = entropy->x; + p_entropy.len = entropy->len; md_info = mbedtls_md_info_from_type( md_alg ); TEST_ASSERT( md_info != NULL ); TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_entropy_func, &p_entropy, - custom, custom_len ) == 0 ); + custom->x, custom->len ) == 0 ); mbedtls_hmac_drbg_set_prediction_resistance( &ctx, MBEDTLS_HMAC_DRBG_PR_ON ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add1, add1_len ) == 0 ); - TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, out_len, - add2, add2_len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add1->x, add1->len ) == 0 ); + TEST_ASSERT( mbedtls_hmac_drbg_random_with_add( &ctx, my_output, output->len, + add2->x, add2->len ) == 0 ); - TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 ); + TEST_ASSERT( memcmp( my_output, output->x, output->len ) == 0 ); exit: mbedtls_hmac_drbg_free( &ctx ); @@ -312,7 +274,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void hmac_drbg_selftest( ) +void hmac_drbg_selftest( ) { TEST_ASSERT( mbedtls_hmac_drbg_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_md.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_md.function index 6ac834e1e0..11cf88ae77 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_md.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_md.function @@ -8,7 +8,7 @@ */ /* BEGIN_CASE */ -void mbedtls_md_process( ) +void mbedtls_md_process( ) { const int *md_type_ptr; const mbedtls_md_info_t *info; @@ -40,7 +40,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void md_null_args( ) +void md_null_args( ) { mbedtls_md_context_t ctx; const mbedtls_md_info_t *info = mbedtls_md_info_from_type( *( mbedtls_md_list() ) ); @@ -103,7 +103,7 @@ void md_null_args( ) /* END_CASE */ /* BEGIN_CASE */ -void md_info( int md_type, char *md_name, int md_size ) +void md_info( int md_type, char * md_name, int md_size ) { const mbedtls_md_info_t *md_info; const int *md_type_ptr; @@ -126,17 +126,16 @@ void md_info( int md_type, char *md_name, int md_size ) /* END_CASE */ /* BEGIN_CASE */ -void md_text( char *text_md_name, char *text_src_string, char *hex_hash_string ) +void md_text( char * text_md_name, char * text_src_string, + data_t * hex_hash_string ) { char md_name[100]; unsigned char src_str[1000]; - unsigned char hash_str[1000]; unsigned char output[100]; const mbedtls_md_info_t *md_info = NULL; memset( md_name, 0x00, 100 ); memset( src_str, 0x00, 1000 ); - memset( hash_str, 0x00, 1000 ); memset( output, 0x00, 100 ); strncpy( (char *) src_str, text_src_string, sizeof( src_str ) - 1 ); @@ -145,47 +144,40 @@ void md_text( char *text_md_name, char *text_src_string, char *hex_hash_string ) TEST_ASSERT( md_info != NULL ); TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str, strlen( (char *) src_str ), output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void md_hex( char *text_md_name, char *hex_src_string, char *hex_hash_string ) +void md_hex( char * text_md_name, data_t * src_str, + data_t * hex_hash_string ) { char md_name[100]; - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[100]; - int src_len; const mbedtls_md_info_t *md_info = NULL; memset( md_name, 0x00, 100 ); - memset( src_str, 0x00, 10000 ); - memset( hash_str, 0x00, 10000 ); memset( output, 0x00, 100 ); strncpy( (char *) md_name, text_md_name, sizeof( md_name ) - 1 ); md_info = mbedtls_md_info_from_string( md_name ); TEST_ASSERT( md_info != NULL ); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str, src_len, output ) ); + TEST_ASSERT ( 0 == mbedtls_md( md_info, src_str->x, src_str->len, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, + mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void md_text_multi( char *text_md_name, char *text_src_string, - char *hex_hash_string ) +void md_text_multi( char * text_md_name, char * text_src_string, + data_t * hex_hash_string ) { char md_name[100]; unsigned char src_str[1000]; - unsigned char hash_str[1000]; unsigned char output[100]; int halfway, len; @@ -197,7 +189,6 @@ void md_text_multi( char *text_md_name, char *text_src_string, memset( md_name, 0x00, 100 ); memset( src_str, 0x00, 1000 ); - memset( hash_str, 0x00, 1000 ); memset( output, 0x00, 100 ); strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 ); @@ -217,17 +208,15 @@ void md_text_multi( char *text_md_name, char *text_src_string, TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str + halfway, len - halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, + mbedtls_md_get_size( md_info ), hex_hash_string->len) == 0 ); /* Test clone */ - memset( hash_str, 0x00, 1000 ); memset( output, 0x00, 100 ); TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str + halfway, len - halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -236,23 +225,19 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void md_hex_multi( char *text_md_name, char *hex_src_string, - char *hex_hash_string ) +void md_hex_multi( char * text_md_name, data_t * src_str, + data_t * hex_hash_string ) { char md_name[100]; - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[100]; - int src_len, halfway; const mbedtls_md_info_t *md_info = NULL; mbedtls_md_context_t ctx, ctx_copy; + int halfway; mbedtls_md_init( &ctx ); mbedtls_md_init( &ctx_copy ); memset( md_name, 0x00, 100 ); - memset( src_str, 0x00, 10000 ); - memset( hash_str, 0x00, 10000 ); memset( output, 0x00, 100 ); strncpy( (char *) md_name, text_md_name, sizeof( md_name ) - 1 ); @@ -261,27 +246,23 @@ void md_hex_multi( char *text_md_name, char *hex_src_string, TEST_ASSERT ( 0 == mbedtls_md_setup( &ctx, md_info, 0 ) ); TEST_ASSERT ( 0 == mbedtls_md_setup( &ctx_copy, md_info, 0 ) ); - src_len = unhexify( src_str, hex_src_string ); - halfway = src_len / 2; + halfway = src_str->len / 2; TEST_ASSERT ( 0 == mbedtls_md_starts( &ctx ) ); TEST_ASSERT ( ctx.md_ctx != NULL ); - TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str, halfway ) ); + TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str->x, halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_clone( &ctx_copy, &ctx ) ); - TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str + halfway, src_len - halfway) ); + TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str->x + halfway, src_str->len - halfway) ); TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 ); /* Test clone */ - memset( hash_str, 0x00, 10000 ); memset( output, 0x00, 100 ); - TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str + halfway, src_len - halfway ) ); + TEST_ASSERT ( 0 == mbedtls_md_update( &ctx_copy, src_str->x + halfway, src_str->len - halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx_copy, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -290,56 +271,41 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_md_hmac( char *text_md_name, int trunc_size, char *hex_key_string, - char *hex_src_string, char *hex_hash_string ) +void mbedtls_md_hmac( char * text_md_name, int trunc_size, + data_t * key_str, data_t * src_str, + data_t * hex_hash_string ) { char md_name[100]; - unsigned char src_str[10000]; - unsigned char key_str[10000]; - unsigned char hash_str[10000]; unsigned char output[100]; - int key_len, src_len; const mbedtls_md_info_t *md_info = NULL; memset( md_name, 0x00, 100 ); - memset( src_str, 0x00, 10000 ); - memset( key_str, 0x00, 10000 ); - memset( hash_str, 0x00, 10000 ); memset( output, 0x00, 100 ); strncpy( (char *) md_name, text_md_name, sizeof( md_name ) - 1 ); md_info = mbedtls_md_info_from_string( md_name ); TEST_ASSERT( md_info != NULL ); - key_len = unhexify( key_str, hex_key_string ); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT ( mbedtls_md_hmac( md_info, key_str, key_len, src_str, src_len, output ) == 0 ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); + TEST_ASSERT ( mbedtls_md_hmac( md_info, key_str->x, key_str->len, src_str->x, src_str->len, output ) == 0 ); - TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void md_hmac_multi( char *text_md_name, int trunc_size, char *hex_key_string, - char *hex_src_string, char *hex_hash_string ) +void md_hmac_multi( char * text_md_name, int trunc_size, data_t * key_str, + data_t * src_str, data_t * hex_hash_string ) { char md_name[100]; - unsigned char src_str[10000]; - unsigned char key_str[10000]; - unsigned char hash_str[10000]; unsigned char output[100]; - int key_len, src_len, halfway; const mbedtls_md_info_t *md_info = NULL; mbedtls_md_context_t ctx; + int halfway; mbedtls_md_init( &ctx ); memset( md_name, 0x00, 100 ); - memset( src_str, 0x00, 10000 ); - memset( key_str, 0x00, 10000 ); - memset( hash_str, 0x00, 10000 ); memset( output, 0x00, 100 ); strncpy( (char *) md_name, text_md_name, sizeof( md_name ) - 1 ); @@ -347,30 +313,25 @@ void md_hmac_multi( char *text_md_name, int trunc_size, char *hex_key_string, TEST_ASSERT( md_info != NULL ); TEST_ASSERT ( 0 == mbedtls_md_setup( &ctx, md_info, 1 ) ); - key_len = unhexify( key_str, hex_key_string ); - src_len = unhexify( src_str, hex_src_string ); - halfway = src_len / 2; + halfway = src_str->len / 2; - TEST_ASSERT ( 0 == mbedtls_md_hmac_starts( &ctx, key_str, key_len ) ); + TEST_ASSERT ( 0 == mbedtls_md_hmac_starts( &ctx, key_str->x, key_str->len ) ); TEST_ASSERT ( ctx.md_ctx != NULL ); - TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str, halfway ) ); - TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str + halfway, src_len - halfway ) ); + TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x, halfway ) ); + TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x + halfway, src_str->len - halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 ); /* Test again, for reset() */ - memset( hash_str, 0x00, 10000 ); memset( output, 0x00, 100 ); TEST_ASSERT ( 0 == mbedtls_md_hmac_reset( &ctx ) ); - TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str, halfway ) ); - TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str + halfway, src_len - halfway ) ); + TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x, halfway ) ); + TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str->x + halfway, src_str->len - halfway ) ); TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, trunc_size, hex_hash_string->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -378,15 +339,14 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ -void mbedtls_md_file( char *text_md_name, char *filename, char *hex_hash_string ) +void mbedtls_md_file( char * text_md_name, char * filename, + data_t * hex_hash_string ) { char md_name[100]; - unsigned char hash_str[1000]; unsigned char output[100]; const mbedtls_md_info_t *md_info = NULL; memset( md_name, 0x00, 100 ); - memset( hash_str, 0x00, 1000 ); memset( output, 0x00, 100 ); strncpy( (char *) md_name, text_md_name, sizeof( md_name ) - 1 ); @@ -394,8 +354,7 @@ void mbedtls_md_file( char *text_md_name, char *filename, char *hex_hash_string TEST_ASSERT( md_info != NULL ); TEST_ASSERT( mbedtls_md_file( md_info, filename, output ) == 0 ); - hexify( hash_str, output, mbedtls_md_get_size( md_info ) ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, mbedtls_md_get_size( md_info ), hex_hash_string->len ) == 0 ); } /* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mdx.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mdx.function index 648a9cc35d..02004efa84 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mdx.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mdx.function @@ -6,116 +6,104 @@ /* END_HEADER */ /* BEGIN_CASE depends_on:MBEDTLS_MD2_C */ -void md2_text( char *text_src_string, char *hex_hash_string ) +void md2_text( char * text_src_string, data_t * hex_hash_string ) { int ret; unsigned char src_str[100]; - unsigned char hash_str[33]; unsigned char output[16]; memset( src_str, 0x00, sizeof src_str ); - memset( hash_str, 0x00, sizeof hash_str ); memset( output, 0x00, sizeof output ); strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 ); ret = mbedtls_md2_ret( src_str, strlen( (char *) src_str ), output ); TEST_ASSERT( ret == 0 ) ; - hexify( hash_str, output, sizeof output ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD4_C */ -void md4_text( char *text_src_string, char *hex_hash_string ) +void md4_text( char * text_src_string, data_t * hex_hash_string ) { int ret; unsigned char src_str[100]; - unsigned char hash_str[33]; unsigned char output[16]; memset( src_str, 0x00, sizeof src_str ); - memset( hash_str, 0x00, sizeof hash_str ); memset( output, 0x00, sizeof output ); strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 ); ret = mbedtls_md4_ret( src_str, strlen( (char *) src_str ), output ); TEST_ASSERT( ret == 0 ); - hexify( hash_str, output, sizeof output ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD5_C */ -void md5_text( char *text_src_string, char *hex_hash_string ) +void md5_text( char * text_src_string, data_t * hex_hash_string ) { int ret; unsigned char src_str[100]; - unsigned char hash_str[33]; unsigned char output[16]; memset( src_str, 0x00, sizeof src_str ); - memset( hash_str, 0x00, sizeof hash_str ); memset( output, 0x00, sizeof output ); strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 ); ret = mbedtls_md5_ret( src_str, strlen( (char *) src_str ), output ); TEST_ASSERT( ret == 0 ); - hexify( hash_str, output, sizeof output ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C */ -void ripemd160_text( char *text_src_string, char *hex_hash_string ) +void ripemd160_text( char * text_src_string, data_t * hex_hash_string ) { int ret; unsigned char src_str[100]; - unsigned char hash_str[41]; unsigned char output[20]; memset(src_str, 0x00, sizeof src_str); - memset(hash_str, 0x00, sizeof hash_str); memset(output, 0x00, sizeof output); strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 ); ret = mbedtls_ripemd160_ret( src_str, strlen( (char *) src_str ), output ); TEST_ASSERT( ret == 0 ); - hexify( hash_str, output, sizeof output ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, sizeof output, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD2_C:MBEDTLS_SELF_TEST */ -void md2_selftest() +void md2_selftest( ) { TEST_ASSERT( mbedtls_md2_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD4_C:MBEDTLS_SELF_TEST */ -void md4_selftest() +void md4_selftest( ) { TEST_ASSERT( mbedtls_md4_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MD5_C:MBEDTLS_SELF_TEST */ -void md5_selftest() +void md5_selftest( ) { TEST_ASSERT( mbedtls_md5_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RIPEMD160_C:MBEDTLS_SELF_TEST */ -void ripemd160_selftest() +void ripemd160_selftest( ) { TEST_ASSERT( mbedtls_ripemd160_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_memory_buffer_alloc.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_memory_buffer_alloc.function index 09684c1d41..bc034367a6 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_memory_buffer_alloc.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_memory_buffer_alloc.function @@ -23,7 +23,7 @@ static int check_pointer( void *p ) /* END_SUITE_HELPERS */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void mbedtls_memory_buffer_alloc_self_test( ) +void mbedtls_memory_buffer_alloc_self_test( ) { TEST_ASSERT( mbedtls_memory_buffer_alloc_self_test( 1 ) == 0 ); } @@ -31,10 +31,9 @@ void mbedtls_memory_buffer_alloc_self_test( ) /* BEGIN_CASE depends_on:MBEDTLS_MEMORY_DEBUG */ void memory_buffer_alloc_free_alloc( int a_bytes, int b_bytes, int c_bytes, - int d_bytes, - int free_a, int free_b, int free_c, - int free_d, - int e_bytes, int f_bytes ) + int d_bytes, int free_a, int free_b, + int free_c, int free_d, int e_bytes, + int f_bytes ) { unsigned char buf[1024]; unsigned char *ptr_a = NULL, *ptr_b = NULL, *ptr_c = NULL, *ptr_d = NULL, @@ -190,7 +189,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_MEMORY_DEBUG */ -void memory_buffer_alloc_oom_test() +void memory_buffer_alloc_oom_test( ) { unsigned char buf[1024]; unsigned char *ptr_a = NULL, *ptr_b = NULL, *ptr_c = NULL; diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.data index 296064196c..425e93ad20 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.data @@ -1,3 +1,9 @@ +MPI - Valid parameters +mpi_valid_param: + +MPI - Invalid parameters +mpi_invalid_param: + Arguments with no value mpi_null: @@ -19,6 +25,9 @@ mpi_read_write_string:16:"-20":10:"-32":100:0:0 Base test mpi_read_write_string #3 (Negative decimal) mpi_read_write_string:16:"-23":16:"-23":100:0:0 +Base test mpi_read_write_string #4 (Buffer just fits) +mpi_read_write_string:16:"-4":4:"-10":4:0:0 + Test mpi_read_write_string #1 (Invalid character) mpi_read_write_string:10:"a28":0:"":100:MBEDTLS_ERR_MPI_INVALID_CHARACTER:0 @@ -59,7 +68,7 @@ Test mbedtls_mpi_write_binary #1 (Buffer just fits) mbedtls_mpi_write_binary:16:"123123123123123123123123123":"0123123123123123123123123123":14:0 Test mbedtls_mpi_write_binary #2 (Buffer too small) -mbedtls_mpi_write_binary:16:"123123123123123123123123123":"123123123123123123123123123":13:MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL +mbedtls_mpi_write_binary:16:"123123123123123123123123123":"23123123123123123123123123":13:MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL Base test mbedtls_mpi_read_file #1 mbedtls_mpi_read_file:10:"data_files/mpi_10":"01f55332c3a48b910f9942f6c914e58bef37a47ee45cb164a5b6b8d1006bf59a059c21449939ebebfdf517d2e1dbac88010d7b1f141e997bd6801ddaec9d05910f4f2de2b2c4d714e2c14a72fc7f17aa428d59c531627f09":0 @@ -682,11 +691,11 @@ mbedtls_mpi_is_prime:10:"49979687":0 Test mbedtls_mpi_is_prime_det (4 non-witnesses) depends_on:MBEDTLS_GENPRIME -mbedtls_mpi_is_prime_det:"043BD64BA10B11DA83FBD296B04BCA9E0552FAF6E09CAC74E2D7E735ED0DB09FC47ED76145644203EE0C826013BC602F560BCDAAED557D04683859A65D659FF828A245A2C5B1AC41E01E4669A525A45E23AF":"040EA852F7935ACCECC0E87B845281F047D10DC9AAFEF990AF9D3D66770DA30B0C5B5E03EEA8C0CB79B936FE0BB8EE5389EC1D34EB16C58AA3F2E11AF084160CDF6400BE1CC179867AB074866952D9F34EE7042D27F960E715A97FCB93F3182247D0A6AE51BD21CC2F6B0651F9E572C5FB86F3137053FA85FD7A51816D69B3A53A5A438C17754836D04E98CA240B901F828332F2D72D88C497DA45F533F99A6E53EDEA6B0424EC8951B048FA9A80134B37D0A67014597934E3CFC52C5A4DD4751ADF8D66FC79E84E2A3148C4B15C17E12CB659390FD275F39A331FFC80EC699BC3F6FAB868E30E9B14575FCDAB6FAED01E00112DD28704177E09C335AD43A696FEA761E8DF3B0663277A5C3637F9060CB5E5654F72E9A6B0F369E660AD4CF7ABF4195493545B367BD55271CD4BB7D9C15D3F508FE8F7409C2126FC8E73B43A67CD4EFB21E9F15DBF040A2A8D5F5ED75CEAC12B595C0051F3EC9D5A58ACE82A9506E64F780E9836728260FFE1BFD73E8A9869E3D46A35A856D3028F7FEAB9F4F1A04449AEDC80017EE1014080D87F0B50C8EF255324CD89F7D039":82:MBEDTLS_ERR_MPI_NOT_ACCEPTABLE +mbedtls_mpi_is_prime_det:"043BD64BA10B11DA83FBD296B04BCA9E0552FAF6E09CAC74E2D7E735ED0DB09FC47ED76145644203EE0C826013BC602F560BCDAAED557D04683859A65D659FF828A245A2C5B1AC41E01E4669A525A45E23AF":"040EA852F7935ACCECC0E87B845281F047D10DC9AAFEF990AF9D3D66770DA30B0C5B5E03EEA8C0CB79B936FE0BB8EE5389EC1D34EB16C58AA3F2E11AF084160CDF6400BE1CC179867AB074866952D9F34EE7042D27F960E715A97FCB93F3182247D0A6AE51BD21CC2F6B0651F9E572C5FB86F3137053FA85FD7A51816D69B3A53A5A438C17754836D04E98CA240B901F828332F2D72D88C497DA45F533F99A6E53EDEA6B0424EC8951B048FA9A80134B37D0A67014597934E3CFC52C5A4DD4751ADF8D66FC79E84E2A3148C4B15C17E12CB659390FD275F39A331FFC80EC699BC3F6FAB868E30E9B14575FCDAB6FAED01E00112DD28704177E09C335AD43A696FEA761E8DF3B0663277A5C3637F9060CB5E5654F72E9A6B0F369E660AD4CF7ABF4195493545B367BD55271CD4BB7D9C15D3F508FE8F7409C2126FC8E73B43A67CD4EFB21E9F15DBF040A2A8D5F5ED75CEAC12B595C0051F3EC9D5A58ACE82A9506E64F780E9836728260FFE1BFD73E8A9869E3D46A35A856D3028F7FEAB9F4F1A04449AEDC80017EE1014080D87F0B50C8EF255324CD89F7D039":82:5 Test mbedtls_mpi_is_prime_det (39 non-witnesses) depends_on:MBEDTLS_GENPRIME -mbedtls_mpi_is_prime_det:"155102B67930FBE8858DF6C0642D77D419A7B7968E622CC7500F3E3F2C5168368C50E0083187":"119B3E2C721834D83416239B04447AA18AE0163E61DCAE97054563D79E094A6FA4485BD6A0501445BF57FE9C058926CDB862E04CC1A95D79D61D9AB3466857A53E04F8D7470C9C86649B226A13DDC534E18DFD5C22FAEA317CA4D4960F18457FD6D2FFB5F3273F74C89980DC774590D8D30D1159CA81999ED94A042D67DA68C82616AD46C2C88288A8EBD0B37AC7C152D9522CA4544642AD1210F6B642FEBF43563FA872B0DEFAFC69D0B6570E8FEA9570D0AADCFA9B06CC8BFD62CEDC221541210EEEF9762448C6D49F26AA767A4D66CB168589E0201923015314E6CD4A480E5936E7CF145F73A564C5B782635B3AFC3028E2632C5D3458224A7C9E8BA1876E8F690463C878292D3DC011E9640331E7F7621F2B5E0F6713DD8C9D6767521C4BA880DA8D11C67753C8493D2C4C4F1443147550D0B25B7FAD04EAFA9F8AA60974C1365C8A794CFEECEB4279B1150909A97E5A7A10B5D91186CA5B25A612036631FE73529C8CFAE51E76FB704A772DE5320EFC1212E7A399B1FEBF57D014AF9129DFF5D2C5DFBBEEAC55F360CF6D22FA90B8E2E9AD0C71AB6495A9452A58D653B8CC26128C66B43EFBA6E39AEC5717A1A3C2AE1449FCABAFE1180B159DA55190CD81A3D9E8D798647E11B827F0A057D6DA5AAD78AB5112EE65E10E8B8B369BA24E1B8AD2CD8548C497016C07A143DE1232F8059BE303572456FA92E76A0F23D1340629228B7D27C02D3833A72745B91A3DBEB5E081117A9F19597F00E4277B414FAEA8C8CEB895C37F956A5A22F8D7A10ADA50B22BAB312504904511AA0EFDD4D3BF20ECB17E8A684564FFB5BBD5E22C429F9A75A4FB4AE468FE7612ED53C7A11212E7EF3435CC9CA6E7DB167B8CCE2BECF35F89013F8F876223C77FA81570970858663C6E32B91080AA47F9C90177F51E6FD7747B910C9489C7B6ACB070996198AD9A40A69711274159210A9A12DBAAA4FB4632446066AB70D735DC95F7C2BCE517E88C064D728DE82B1B043DF4AEE0EFF5131120A4E5B9B4180EB6F6B8A0D1491ABDA069058A9966B1A517D8E7B4997DC52A1E698FD79E271153DF1913FE6787A5D99DE69F39C3F22D26DC731CFBB33FF5C267D85D7A3DAE8E1C87E1DB2F1236212EF1942EA756967FB3D07D629E59EA4034D9A9B5E270DD4A31C8A3DFDA99C1094B5537132C196DA2AEAF5253A019B9AF25B5DCB0D4DD75C7C9C353DA9DAABFB23959A5455312E7E1C21268C1BC14E83DCFDF50C27FD3E8B4EDC04C5F3CB5FCFFF2B57151E1B1EE1A6456DC006BC43E1158674AA4CF7D146DE4A57103BE43ED130C8007294ED2418C7A2B769A7D20EBB5A8367A77B313F81BB119B9954305FF160FF83EED7F808EE6D340A5CCC000CF81AA497D315D350CCE4E86A31456B8AA85B677491FC662933DFA55EB5BFF64B8D85430D676A85D1CAFAFF383E68C4E6C22A51063739EC03FC58C36C07C44E54828BE2152B2E9AFB0F179B157D09B64C147B524BB5424BB1914419424D9100D06EDCFC718F4DF3D562E9E16C446663F35273CA7BC5426B868A80C8D415C9A12A1619CDB7CDB5BEBC70313150BDF8C3AB26B809FE62D28E798EF1EF98C410A2DA0A9071F82154AC569078B0E647E2C085D1D907E634453442803D0492D3D0C78CACB762020C0E589C8B0981321EA2771305FD0413F3B2963FCE9A232F6641DB7E12ADC009A032063C41756E5E19E5711DE12711F07AFE7545B4D83F3EFD7BFD0435297C89DF3D4AF96EBE2CE8D64B93E36EA5D7E5A0492151D0CAEE7449A7D35E1A3C83E22C3B35162C073CC3B1CF76FBDEE84270721FC042EAAEB7325110181415E2031CFB7462F15111291CDAC0560FF9F4C7341F2FA261B97CEF348D074AA2EB4DB153FE6B1410519DA4213B611999868F3B867A2B6D758D333C4989DE80782683CA26ECDE373C71524F01B76349CE8A07A5EBECBB42259CF970DDA756EC996B189FEA045FEE45F23D476960913106ECA2510B8517AA75D56FA4152B2BDDC212014E5D07FD964D6EE532F0616DF74E104659955132331FABF2D2AD265E71C93C648A956FA0A3DB21FF103D516527F2DA0E870340B61EE8A8ED913B60605EB5A67B834D0FC90564386012585609870FEF6530B3E3C037B55506F0B5694F6B0FC":38:MBEDTLS_ERR_MPI_NOT_ACCEPTABLE +mbedtls_mpi_is_prime_det:"155102B67930FBE8858DF6C0642D77D419A7B7968E622CC7500F3E3F2C5168368C50E0083187":"119B3E2C721834D83416239B04447AA18AE0163E61DCAE97054563D79E094A6FA4485BD6A0501445BF57FE9C058926CDB862E04CC1A95D79D61D9AB3466857A53E04F8D7470C9C86649B226A13DDC534E18DFD5C22FAEA317CA4D4960F18457FD6D2FFB5F3273F74C89980DC774590D8D30D1159CA81999ED94A042D67DA68C82616AD46C2C88288A8EBD0B37AC7C152D9522CA4544642AD1210F6B642FEBF43563FA872B0DEFAFC69D0B6570E8FEA9570D0AADCFA9B06CC8BFD62CEDC221541210EEEF9762448C6D49F26AA767A4D66CB168589E0201923015314E6CD4A480E5936E7CF145F73A564C5B782635B3AFC3028E2632C5D3458224A7C9E8BA1876E8F690463C878292D3DC011E9640331E7F7621F2B5E0F6713DD8C9D6767521C4BA880DA8D11C67753C8493D2C4C4F1443147550D0B25B7FAD04EAFA9F8AA60974C1365C8A794CFEECEB4279B1150909A97E5A7A10B5D91186CA5B25A612036631FE73529C8CFAE51E76FB704A772DE5320EFC1212E7A399B1FEBF57D014AF9129DFF5D2C5DFBBEEAC55F360CF6D22FA90B8E2E9AD0C71AB6495A9452A58D653B8CC26128C66B43EFBA6E39AEC5717A1A3C2AE1449FCABAFE1180B159DA55190CD81A3D9E8D798647E11B827F0A057D6DA5AAD78AB5112EE65E10E8B8B369BA24E1B8AD2CD8548C497016C07A143DE1232F8059BE303572456FA92E76A0F23D1340629228B7D27C02D3833A72745B91A3DBEB5E081117A9F19597F00E4277B414FAEA8C8CEB895C37F956A5A22F8D7A10ADA50B22BAB312504904511AA0EFDD4D3BF20ECB17E8A684564FFB5BBD5E22C429F9A75A4FB4AE468FE7612ED53C7A11212E7EF3435CC9CA6E7DB167B8CCE2BECF35F89013F8F876223C77FA81570970858663C6E32B91080AA47F9C90177F51E6FD7747B910C9489C7B6ACB070996198AD9A40A69711274159210A9A12DBAAA4FB4632446066AB70D735DC95F7C2BCE517E88C064D728DE82B1B043DF4AEE0EFF5131120A4E5B9B4180EB6F6B8A0D1491ABDA069058A9966B1A517D8E7B4997DC52A1E698FD79E271153DF1913FE6787A5D99DE69F39C3F22D26DC731CFBB33FF5C267D85D7A3DAE8E1C87E1DB2F1236212EF1942EA756967FB3D07D629E59EA4034D9A9B5E270DD4A31C8A3DFDA99C1094B5537132C196DA2AEAF5253A019B9AF25B5DCB0D4DD75C7C9C353DA9DAABFB23959A5455312E7E1C21268C1BC14E83DCFDF50C27FD3E8B4EDC04C5F3CB5FCFFF2B57151E1B1EE1A6456DC006BC43E1158674AA4CF7D146DE4A57103BE43ED130C8007294ED2418C7A2B769A7D20EBB5A8367A77B313F81BB119B9954305FF160FF83EED7F808EE6D340A5CCC000CF81AA497D315D350CCE4E86A31456B8AA85B677491FC662933DFA55EB5BFF64B8D85430D676A85D1CAFAFF383E68C4E6C22A51063739EC03FC58C36C07C44E54828BE2152B2E9AFB0F179B157D09B64C147B524BB5424BB1914419424D9100D06EDCFC718F4DF3D562E9E16C446663F35273CA7BC5426B868A80C8D415C9A12A1619CDB7CDB5BEBC70313150BDF8C3AB26B809FE62D28E798EF1EF98C410A2DA0A9071F82154AC569078B0E647E2C085D1D907E634453442803D0492D3D0C78CACB762020C0E589C8B0981321EA2771305FD0413F3B2963FCE9A232F6641DB7E12ADC009A032063C41756E5E19E5711DE12711F07AFE7545B4D83F3EFD7BFD0435297C89DF3D4AF96EBE2CE8D64B93E36EA5D7E5A0492151D0CAEE7449A7D35E1A3C83E22C3B35162C073CC3B1CF76FBDEE84270721FC042EAAEB7325110181415E2031CFB7462F15111291CDAC0560FF9F4C7341F2FA261B97CEF348D074AA2EB4DB153FE6B1410519DA4213B611999868F3B867A2B6D758D333C4989DE80782683CA26ECDE373C71524F01B76349CE8A07A5EBECBB42259CF970DDA756EC996B189FEA045FEE45F23D476960913106ECA2510B8517AA75D56FA4152B2BDDC212014E5D07FD964D6EE532F0616DF74E104659955132331FABF2D2AD265E71C93C648A956FA0A3DB21FF103D516527F2DA0E870340B61EE8A8ED913B60605EB5A67B834D0FC90564386012585609870FEF6530B3E3C037B55506F0B5694F6B0FC":38:40 Test mbedtls_mpi_gen_prime (Too small) depends_on:MBEDTLS_GENPRIME @@ -696,13 +705,37 @@ Test mbedtls_mpi_gen_prime (OK, minimum size) depends_on:MBEDTLS_GENPRIME mbedtls_mpi_gen_prime:3:0:0 +Test mbedtls_mpi_gen_prime (corner case limb size -1 bits) +depends_on:MBEDTLS_GENPRIME +mbedtls_mpi_gen_prime:63:0:0 + +Test mbedtls_mpi_gen_prime (corner case limb size) +depends_on:MBEDTLS_GENPRIME +mbedtls_mpi_gen_prime:64:0:0 + +Test mbedtls_mpi_gen_prime (corner case limb size +1 bits) +depends_on:MBEDTLS_GENPRIME +mbedtls_mpi_gen_prime:65:0:0 + Test mbedtls_mpi_gen_prime (Larger) depends_on:MBEDTLS_GENPRIME mbedtls_mpi_gen_prime:128:0:0 Test mbedtls_mpi_gen_prime (Safe) depends_on:MBEDTLS_GENPRIME -mbedtls_mpi_gen_prime:128:1:0 +mbedtls_mpi_gen_prime:128:MBEDTLS_MPI_GEN_PRIME_FLAG_DH:0 + +Test mbedtls_mpi_gen_prime (Safe with lower error rate) +depends_on:MBEDTLS_GENPRIME +mbedtls_mpi_gen_prime:128:MBEDTLS_MPI_GEN_PRIME_FLAG_DH | MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR:0 + +Test mbedtls_mpi_gen_prime standard RSA #1 (lower error rate) +depends_on:MBEDTLS_GENPRIME +mbedtls_mpi_gen_prime:1024:MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR:0 + +Test mbedtls_mpi_gen_prime standard RSA #2 (lower error rate) +depends_on:MBEDTLS_GENPRIME +mbedtls_mpi_gen_prime:1536:MBEDTLS_MPI_GEN_PRIME_FLAG_LOW_ERR:0 Test bit getting (Value bit 25) mbedtls_mpi_get_bit:10:"49979687":25:1 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.function index 04dca0fcb2..f982385e13 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_mpi.function @@ -3,10 +3,9 @@ typedef struct mbedtls_test_mpi_random { - uint8_t *data; - uint32_t data_len; - size_t pos; - size_t chunk_len; + data_t *data; + size_t pos; + size_t chunk_len; } mbedtls_test_mpi_random; /* @@ -21,10 +20,10 @@ int mbedtls_test_mpi_miller_rabin_determinizer( void* state, { mbedtls_test_mpi_random *random = (mbedtls_test_mpi_random*) state; - if( random == NULL || random->data == NULL || buf == NULL ) + if( random == NULL || random->data->x == NULL || buf == NULL ) return( -1 ); - if( random->pos + random->chunk_len > random->data_len + if( random->pos + random->chunk_len > random->data->len || random->chunk_len > len ) { return( -1 ); @@ -37,7 +36,7 @@ int mbedtls_test_mpi_miller_rabin_determinizer( void* state, * Writing the witness to the start of the buffer would result in the * buffer being 'witness 000...000', which would be treated as * witness * 2^n for some n. */ - memcpy( buf + len - random->chunk_len, &random->data[random->pos], + memcpy( buf + len - random->chunk_len, &random->data->x[random->pos], random->chunk_len ); random->pos += random->chunk_len; @@ -52,7 +51,221 @@ int mbedtls_test_mpi_miller_rabin_determinizer( void* state, */ /* BEGIN_CASE */ -void mpi_null( ) +void mpi_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_mpi_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void mpi_invalid_param( ) +{ + mbedtls_mpi X; + const char *s_in = "00101000101010"; + char s_out[16] = { 0 }; + unsigned char u_out[16] = { 0 }; + unsigned char u_in[16] = { 0 }; + size_t olen; + mbedtls_mpi_uint mpi_uint; + + TEST_INVALID_PARAM( mbedtls_mpi_init( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_grow( NULL, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_copy( NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_copy( &X, NULL ) ); + + TEST_INVALID_PARAM( mbedtls_mpi_swap( NULL, &X ) ); + TEST_INVALID_PARAM( mbedtls_mpi_swap( &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_safe_cond_assign( NULL, &X, 0 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_safe_cond_assign( &X, NULL, 0 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_safe_cond_swap( NULL, &X, 0 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_safe_cond_swap( &X, NULL, 0 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_lset( NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_get_bit( NULL, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_set_bit( NULL, 42, 0 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_read_string( NULL, 2, s_in ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_read_string( &X, 2, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_write_string( NULL, 2, + s_out, sizeof( s_out ), + &olen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_write_string( &X, 2, + NULL, sizeof( s_out ), + &olen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_write_string( &X, 2, + s_out, sizeof( s_out ), + NULL ) ); + +#if defined(MBEDTLS_FS_IO) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_read_file( NULL, 2, stdin ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_read_file( &X, 2, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_write_file( "", NULL, 2, NULL ) ); +#endif /* MBEDTLS_FS_IO */ + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_read_binary( NULL, u_in, + sizeof( u_in ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_read_binary( &X, NULL, + sizeof( u_in ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_write_binary( NULL, u_out, + sizeof( u_out ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_write_binary( &X, NULL, + sizeof( u_out ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_shift_l( NULL, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_shift_r( NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_cmp_abs( NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_cmp_abs( &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_cmp_mpi( NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_cmp_mpi( &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_cmp_int( NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_abs( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_abs( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_abs( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_abs( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_abs( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_abs( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_mpi( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_mpi( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_mpi( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_mpi( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_mpi( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_mpi( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_int( NULL, &X, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_add_int( &X, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_int( NULL, &X, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_sub_int( &X, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mul_mpi( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mul_mpi( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mul_mpi( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mul_int( NULL, &X, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mul_int( &X, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_div_mpi( &X, &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_div_mpi( &X, &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_div_int( &X, &X, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( 0, mbedtls_mpi_lsb( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mod_mpi( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mod_mpi( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mod_mpi( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mod_int( NULL, &X, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_mod_int( &mpi_uint, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_exp_mod( NULL, &X, &X, &X, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_exp_mod( &X, NULL, &X, &X, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_exp_mod( &X, &X, NULL, &X, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_exp_mod( &X, &X, &X, NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_fill_random( NULL, 42, rnd_std_rand, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_fill_random( &X, 42, NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_gcd( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_gcd( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_gcd( &X, &X, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_inv_mod( NULL, &X, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_inv_mod( &X, NULL, &X ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA, + mbedtls_mpi_inv_mod( &X, &X, NULL ) ); + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mpi_null( ) { mbedtls_mpi X, Y, Z; @@ -71,8 +284,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mpi_read_write_string( int radix_X, char *input_X, int radix_A, - char *input_A, int output_size, int result_read, +void mpi_read_write_string( int radix_X, char * input_X, int radix_A, + char * input_A, int output_size, int result_read, int result_write ) { mbedtls_mpi X; @@ -81,6 +294,8 @@ void mpi_read_write_string( int radix_X, char *input_X, int radix_A, mbedtls_mpi_init( &X ); + memset( str, '!', sizeof( str ) ); + TEST_ASSERT( mbedtls_mpi_read_string( &X, radix_X, input_X ) == result_read ); if( result_read == 0 ) { @@ -88,6 +303,7 @@ void mpi_read_write_string( int radix_X, char *input_X, int radix_A, if( result_write == 0 ) { TEST_ASSERT( strcasecmp( str, input_A ) == 0 ); + TEST_ASSERT( str[len] == '!' ); } } @@ -97,19 +313,16 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_read_binary( char *input_X, int radix_A, char *input_A ) +void mbedtls_mpi_read_binary( data_t * buf, int radix_A, char * input_A ) { mbedtls_mpi X; unsigned char str[1000]; - unsigned char buf[1000]; size_t len; - size_t input_len; mbedtls_mpi_init( &X ); - input_len = unhexify( buf, input_X ); - TEST_ASSERT( mbedtls_mpi_read_binary( &X, buf, input_len ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_binary( &X, buf->x, buf->len ) == 0 ); TEST_ASSERT( mbedtls_mpi_write_string( &X, radix_A, (char *) str, sizeof( str ), &len ) == 0 ); TEST_ASSERT( strcmp( (char *) str, input_A ) == 0 ); @@ -119,16 +332,15 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_write_binary( int radix_X, char *input_X, char *input_A, - int output_size, int result ) +void mbedtls_mpi_write_binary( int radix_X, char * input_X, + data_t * input_A, int output_size, + int result ) { mbedtls_mpi X; - unsigned char str[1000]; unsigned char buf[1000]; size_t buflen; memset( buf, 0x00, 1000 ); - memset( str, 0x00, 1000 ); mbedtls_mpi_init( &X ); @@ -141,9 +353,8 @@ void mbedtls_mpi_write_binary( int radix_X, char *input_X, char *input_A, TEST_ASSERT( mbedtls_mpi_write_binary( &X, buf, buflen ) == result ); if( result == 0) { - hexify( str, buf, buflen ); - TEST_ASSERT( strcasecmp( (char *) str, input_A ) == 0 ); + TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 ); } exit: @@ -152,18 +363,16 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ -void mbedtls_mpi_read_file( int radix_X, char *input_file, char *input_A, - int result ) +void mbedtls_mpi_read_file( int radix_X, char * input_file, + data_t * input_A, int result ) { mbedtls_mpi X; - unsigned char str[1000]; unsigned char buf[1000]; size_t buflen; FILE *file; int ret; memset( buf, 0x00, 1000 ); - memset( str, 0x00, 1000 ); mbedtls_mpi_init( &X ); @@ -178,9 +387,8 @@ void mbedtls_mpi_read_file( int radix_X, char *input_file, char *input_A, buflen = mbedtls_mpi_size( &X ); TEST_ASSERT( mbedtls_mpi_write_binary( &X, buf, buflen ) == 0 ); - hexify( str, buf, buflen ); - TEST_ASSERT( strcasecmp( (char *) str, input_A ) == 0 ); + TEST_ASSERT( hexcmp( buf, input_A->x, buflen, input_A->len ) == 0 ); } exit: @@ -189,8 +397,8 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO */ -void mbedtls_mpi_write_file( int radix_X, char *input_X, int output_radix, - char *output_file ) +void mbedtls_mpi_write_file( int radix_X, char * input_X, int output_radix, + char * output_file ) { mbedtls_mpi X, Y; FILE *file_out, *file_in; @@ -220,7 +428,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_get_bit( int radix_X, char *input_X, int pos, int val ) +void mbedtls_mpi_get_bit( int radix_X, char * input_X, int pos, int val ) { mbedtls_mpi X; mbedtls_mpi_init( &X ); @@ -233,8 +441,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_set_bit( int radix_X, char *input_X, int pos, int val, - int radix_Y, char *output_Y, int result ) +void mbedtls_mpi_set_bit( int radix_X, char * input_X, int pos, int val, + int radix_Y, char * output_Y, int result ) { mbedtls_mpi X, Y; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); @@ -254,7 +462,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_lsb( int radix_X, char *input_X, int nr_bits ) +void mbedtls_mpi_lsb( int radix_X, char * input_X, int nr_bits ) { mbedtls_mpi X; mbedtls_mpi_init( &X ); @@ -268,7 +476,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_bitlen( int radix_X, char *input_X, int nr_bits ) +void mbedtls_mpi_bitlen( int radix_X, char * input_X, int nr_bits ) { mbedtls_mpi X; mbedtls_mpi_init( &X ); @@ -282,8 +490,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_gcd( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A ) +void mbedtls_mpi_gcd( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi A, X, Y, Z; mbedtls_mpi_init( &A ); mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); @@ -314,8 +522,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_cmp_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y, - int input_A ) +void mbedtls_mpi_cmp_mpi( int radix_X, char * input_X, int radix_Y, + char * input_Y, int input_A ) { mbedtls_mpi X, Y; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); @@ -330,8 +538,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_cmp_abs( int radix_X, char *input_X, int radix_Y, char *input_Y, - int input_A ) +void mbedtls_mpi_cmp_abs( int radix_X, char * input_X, int radix_Y, + char * input_Y, int input_A ) { mbedtls_mpi X, Y; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); @@ -398,8 +606,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_safe_cond_assign( int x_sign, char *x_str, - int y_sign, char *y_str ) +void mbedtls_mpi_safe_cond_assign( int x_sign, char * x_str, int y_sign, + char * y_str ) { mbedtls_mpi X, Y, XX; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &XX ); @@ -422,8 +630,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_safe_cond_swap( int x_sign, char *x_str, - int y_sign, char *y_str ) +void mbedtls_mpi_safe_cond_swap( int x_sign, char * x_str, int y_sign, + char * y_str ) { mbedtls_mpi X, Y, XX, YY; @@ -453,7 +661,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_swap( int input_X, int input_Y ) +void mbedtls_mpi_swap( int input_X, int input_Y ) { mbedtls_mpi X, Y, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &A ); @@ -473,8 +681,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_add_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A ) +void mbedtls_mpi_add_mpi( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi X, Y, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -491,7 +699,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_add_mpi_inplace( int radix_X, char *input_X, int radix_A, char *input_A ) +void mbedtls_mpi_add_mpi_inplace( int radix_X, char * input_X, int radix_A, + char * input_A ) { mbedtls_mpi X, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A ); @@ -517,8 +726,8 @@ exit: /* BEGIN_CASE */ -void mbedtls_mpi_add_abs( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A ) +void mbedtls_mpi_add_abs( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi X, Y, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -535,8 +744,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mpi_add_abs_add_first( int radix_X, char *input_X, int radix_Y, - char *input_Y, int radix_A, char *input_A ) +void mpi_add_abs_add_first( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi X, Y, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &A ); @@ -553,8 +762,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mpi_add_abs_add_second( int radix_X, char *input_X, int radix_Y, - char *input_Y, int radix_A, char *input_A ) +void mpi_add_abs_add_second( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi X, Y, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &A ); @@ -571,8 +780,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_add_int( int radix_X, char *input_X, int input_Y, int radix_A, - char *input_A ) +void mbedtls_mpi_add_int( int radix_X, char * input_X, int input_Y, + int radix_A, char * input_A ) { mbedtls_mpi X, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -588,8 +797,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_sub_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A ) +void mbedtls_mpi_sub_mpi( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi X, Y, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -606,8 +815,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_sub_abs( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A, int sub_result ) +void mbedtls_mpi_sub_abs( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A, + int sub_result ) { mbedtls_mpi X, Y, Z, A; int res; @@ -628,8 +838,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_sub_int( int radix_X, char *input_X, int input_Y, int radix_A, - char *input_A ) +void mbedtls_mpi_sub_int( int radix_X, char * input_X, int input_Y, + int radix_A, char * input_A ) { mbedtls_mpi X, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -645,8 +855,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_mul_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A ) +void mbedtls_mpi_mul_mpi( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A ) { mbedtls_mpi X, Y, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -663,8 +873,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_mul_int( int radix_X, char *input_X, int input_Y, int radix_A, - char *input_A, char *result_comparison ) +void mbedtls_mpi_mul_int( int radix_X, char * input_X, int input_Y, + int radix_A, char * input_A, + char * result_comparison ) { mbedtls_mpi X, Z, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A ); @@ -685,9 +896,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_div_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A, int radix_B, char *input_B, - int div_result ) +void mbedtls_mpi_div_mpi( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A, + int radix_B, char * input_B, int div_result ) { mbedtls_mpi X, Y, Q, R, A, B; int res; @@ -713,8 +924,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_div_int( int radix_X, char *input_X, int input_Y, int radix_A, - char *input_A, int radix_B, char *input_B, int div_result ) +void mbedtls_mpi_div_int( int radix_X, char * input_X, int input_Y, + int radix_A, char * input_A, int radix_B, + char * input_B, int div_result ) { mbedtls_mpi X, Q, R, A, B; int res; @@ -739,8 +951,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_mod_mpi( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A, int div_result ) +void mbedtls_mpi_mod_mpi( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A, + int div_result ) { mbedtls_mpi X, Y, A; int res; @@ -762,8 +975,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_mod_int( int radix_X, char *input_X, int input_Y, int input_A, - int div_result ) +void mbedtls_mpi_mod_int( int radix_X, char * input_X, int input_Y, + int input_A, int div_result ) { mbedtls_mpi X; int res; @@ -784,9 +997,10 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_exp_mod( int radix_A, char *input_A, int radix_E, char *input_E, - int radix_N, char *input_N, int radix_RR, char *input_RR, - int radix_X, char *input_X, int div_result ) +void mbedtls_mpi_exp_mod( int radix_A, char * input_A, int radix_E, + char * input_E, int radix_N, char * input_N, + int radix_RR, char * input_RR, int radix_X, + char * input_X, int div_result ) { mbedtls_mpi A, E, N, RR, Z, X; int res; @@ -815,8 +1029,9 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_inv_mod( int radix_X, char *input_X, int radix_Y, char *input_Y, - int radix_A, char *input_A, int div_result ) +void mbedtls_mpi_inv_mod( int radix_X, char * input_X, int radix_Y, + char * input_Y, int radix_A, char * input_A, + int div_result ) { mbedtls_mpi X, Y, Z, A; int res; @@ -838,14 +1053,14 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_GENPRIME */ -void mbedtls_mpi_is_prime( int radix_X, char *input_X, int div_result ) +void mbedtls_mpi_is_prime( int radix_X, char * input_X, int div_result ) { mbedtls_mpi X; int res; mbedtls_mpi_init( &X ); TEST_ASSERT( mbedtls_mpi_read_string( &X, radix_X, input_X ) == 0 ); - res = mbedtls_mpi_is_prime( &X, rnd_std_rand, NULL ); + res = mbedtls_mpi_is_prime_ext( &X, 40, rnd_std_rand, NULL ); TEST_ASSERT( res == div_result ); exit: @@ -854,47 +1069,47 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_GENPRIME */ -void mbedtls_mpi_is_prime_det( char *input_X, char *witnesses, - int chunk_len, int div_result ) +void mbedtls_mpi_is_prime_det( data_t * input_X, data_t * witnesses, + int chunk_len, int rounds ) { mbedtls_mpi X; int res; mbedtls_test_mpi_random rand; - uint8_t *witness_buf = NULL; - uint8_t *input_buf = NULL; - size_t witness_len; - size_t input_len; - - witness_buf = unhexify_alloc( witnesses, &witness_len ); - input_buf = unhexify_alloc( input_X, &input_len ); mbedtls_mpi_init( &X ); - rand.data = witness_buf; - rand.data_len = witness_len; + rand.data = witnesses; rand.pos = 0; rand.chunk_len = chunk_len; - TEST_ASSERT( mbedtls_mpi_read_binary( &X, input_buf, input_len ) == 0 ); - res = mbedtls_mpi_is_prime( &X, mbedtls_test_mpi_miller_rabin_determinizer, + TEST_ASSERT( mbedtls_mpi_read_binary( &X, input_X->x, input_X->len ) == 0 ); + res = mbedtls_mpi_is_prime_ext( &X, rounds - 1, + mbedtls_test_mpi_miller_rabin_determinizer, &rand ); - TEST_ASSERT( res == div_result ); + TEST_ASSERT( res == 0 ); + + rand.data = witnesses; + rand.pos = 0; + rand.chunk_len = chunk_len; + + res = mbedtls_mpi_is_prime_ext( &X, rounds, + mbedtls_test_mpi_miller_rabin_determinizer, + &rand ); + TEST_ASSERT( res == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE ); exit: mbedtls_mpi_free( &X ); - mbedtls_free( witness_buf ); - mbedtls_free( input_buf ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_GENPRIME */ -void mbedtls_mpi_gen_prime( int bits, int safe, int ref_ret ) +void mbedtls_mpi_gen_prime( int bits, int flags, int ref_ret ) { mbedtls_mpi X; int my_ret; mbedtls_mpi_init( &X ); - my_ret = mbedtls_mpi_gen_prime( &X, bits, safe, rnd_std_rand, NULL ); + my_ret = mbedtls_mpi_gen_prime( &X, bits, flags, rnd_std_rand, NULL ); TEST_ASSERT( my_ret == ref_ret ); if( ref_ret == 0 ) @@ -904,12 +1119,14 @@ void mbedtls_mpi_gen_prime( int bits, int safe, int ref_ret ) TEST_ASSERT( actual_bits >= (size_t) bits ); TEST_ASSERT( actual_bits <= (size_t) bits + 1 ); - TEST_ASSERT( mbedtls_mpi_is_prime( &X, rnd_std_rand, NULL ) == 0 ); - if( safe ) + TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40, rnd_std_rand, NULL ) + == 0 ); + if( flags & MBEDTLS_MPI_GEN_PRIME_FLAG_DH ) { /* X = ( X - 1 ) / 2 */ TEST_ASSERT( mbedtls_mpi_shift_r( &X, 1 ) == 0 ); - TEST_ASSERT( mbedtls_mpi_is_prime( &X, rnd_std_rand, NULL ) == 0 ); + TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40, rnd_std_rand, NULL ) + == 0 ); } } @@ -919,8 +1136,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_shift_l( int radix_X, char *input_X, int shift_X, int radix_A, - char *input_A) +void mbedtls_mpi_shift_l( int radix_X, char * input_X, int shift_X, + int radix_A, char * input_A ) { mbedtls_mpi X, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A ); @@ -936,8 +1153,8 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_mpi_shift_r( int radix_X, char *input_X, int shift_X, int radix_A, - char *input_A ) +void mbedtls_mpi_shift_r( int radix_X, char * input_X, int shift_X, + int radix_A, char * input_A ) { mbedtls_mpi X, A; mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A ); @@ -953,7 +1170,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void mpi_selftest() +void mpi_selftest( ) { TEST_ASSERT( mbedtls_mpi_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_nist_kw.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_nist_kw.data new file mode 100644 index 0000000000..446255857b --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_nist_kw.data @@ -0,0 +1,483 @@ +NIST KW self test +mbedtls_nist_kw_self_test: + +NIST KW mix contexts and modes +mbedtls_nist_kw_mix_contexts: + +NIST KW init #1 wrapping AES-128: OK +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_setkey:MBEDTLS_CIPHER_ID_AES:128:1:0 + +NIST KW init #2 unwrapping AES-128: OK +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_setkey:MBEDTLS_CIPHER_ID_AES:128:1:0 + +NIST KW init #3 CAMELLIA-256: unsupported cipher +depends_on:MBEDTLS_CAMELLIA_C +mbedtls_nist_kw_setkey:MBEDTLS_CIPHER_ID_CAMELLIA:256:0:MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE + +NIST KW init #4 AES-224: bad key size +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_setkey:MBEDTLS_CIPHER_ID_AES:224:1:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW init #5 BLOWFISH-128: bad cipher +depends_on:MBEDTLS_BLOWFISH_C +mbedtls_nist_kw_setkey:MBEDTLS_CIPHER_ID_BLOWFISH:128:0:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #1 KW plaintext OK (2 to 2^54 - 1 semiblocks) +nist_kw_plaintext_lengths:16:24:MBEDTLS_KW_MODE_KW:0 + +NIST KW lengths #2 KWP plaintext OK (1 to 2^32 - 1 octets) +nist_kw_plaintext_lengths:5:16:MBEDTLS_KW_MODE_KWP:0 + +NIST KW lengths #3 KW ciphertext OK (3 to 2^54 semiblocks) +nist_kw_ciphertext_lengths:32:24:MBEDTLS_KW_MODE_KW:0 + +NIST KW lengths #4 KWP ciphertext OK (2 to 2^29 semiblocks) +nist_kw_ciphertext_lengths:24:16:MBEDTLS_KW_MODE_KWP:0 + +NIST KW lengths #5 KW plaintext too short (2 to 2^54 - 1 semiblocks) +nist_kw_plaintext_lengths:5:13:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #6 KWP plaintext too short (1 to 2^32 - 1 octets) +nist_kw_plaintext_lengths:0:8:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #8 KW ciphertext too short (3 to 2^54 semiblocks) +nist_kw_ciphertext_lengths:16:8:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #9 KWP ciphertext too short (2 to 2^29 semiblocks) +nist_kw_ciphertext_lengths:8:8:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #10 KW plaintext not a multiple of semiblocks. +nist_kw_plaintext_lengths:21:29:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #11 KW ciphertext not a multiple of semiblocks. +nist_kw_ciphertext_lengths:34:26:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #12 KWP ciphertext not a multiple of semiblocks. +nist_kw_ciphertext_lengths:30:22:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #13 KW wrapping output buffer too short +nist_kw_plaintext_lengths:16:16:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #14 KWP wrapping output buffer too short +nist_kw_plaintext_lengths:5:10:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #15 KW unwrapping output buffer too short +nist_kw_ciphertext_lengths:32:16:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #16 KWP unwrapping output buffer too short +nist_kw_ciphertext_lengths:24:12:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #17 KW plaintext NULL (2 to 2^54 - 1 semiblocks) +nist_kw_plaintext_lengths:0:8:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #18 KW wrapping output NULL +nist_kw_plaintext_lengths:8:0:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #19 KWP wrapping output NULL +nist_kw_plaintext_lengths:8:0:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #20 KW ciphertext NULL +nist_kw_ciphertext_lengths:0:8:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #21 KWP ciphertext NULL +nist_kw_ciphertext_lengths:0:8:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #15 KW unwrapping output NULL +nist_kw_ciphertext_lengths:32:0:MBEDTLS_KW_MODE_KW:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW lengths #16 KWP unwrapping output NULL +nist_kw_ciphertext_lengths:24:0:MBEDTLS_KW_MODE_KWP:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA + +NIST KW wrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 128 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"095e293f31e317ba6861114b95c90792":"64349d506ae85ecd84459c7a5c423f55":"97de4425572274bd7fb2d6688d5afd4454d992348d42a643" + +NIST KW wrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 256 count 11 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"ca8f6c56a9c9300549e9eae75a4604b8":"1542b8662136245162c64d45af1a982302f69f1d01a1a6bc29ef8facafbeaea0":"4d340c10bbbddf5b2014ded264bffce49901bd22adaee074b0f25a2d19c134eb3c7f38c5d0444766" + +NIST KW wrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 192 count 8 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"b4902b13ea73f17829b4e334fb359ec4":"2073399c7794c8b73dd782dc250dab31c80a8cba33477ab2":"37eda4eec3096135f5193c37bdeaf498b71e3a205c5638682fe746f236566b11" + +NIST KW wrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 320 count 14 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"579448a3d638f093742ae6b24d729849":"464d3162469899955d8bc8bfc0a22555bce609b2415bedf17a942abfe96ad4e124d4a832fbcff49f":"dadd1440a06946eabddf18e784b7719d36caa33cb626aa03aca057585584ea07a8714ecb90ceb232d6b0760845105fbb" + +NIST KW wrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"98311985c4661d7e811ee56070e6fecf":"18840c96813864ef3093b48cdde6ac5d78248b96d4a2cd1f15f0b56f98213dbf87e1ccad04e0d4f1954c233ea3e48fdad8f2b1156e54e19e3b5f4a66d2e9149032b876c51249165fe8c28e112a685b2d228a8ac308017574274af36a4ea3877bcc9850bafe8fc0e0a712faca0dea98396f9143bc5819fe4933a806e9b965133e3c695a45f0fbd6961798c400d7477287df64798b651e0d3009c13f7a2246c28f983509b9e5339919f2cdffcdfc550693cba9491c00334c4a62d878c4d0ca57b1104bc0174968ea8e3730b9e68db49678b23cd508ebe3e12e94b0ad3791023a8ef95473f0b32f906738f34e94e45a4480ad768072e1853adb63996b9ac27a1dade70804b82290a2274c6dcc3ccd40a8b38a56a5eb03f59075de015e8f9096f53549f6374e02da947fb849287a447f757cc340b6bded71d480988b6d2fcd984fba841470519830304667fef0a577b4cf84f76aef9deb84dde36abfbd76673c17113dbea7a3e24bf9b57a8fd17173a1ef91497b732b3fa8889bed58a503a0d3e20bc27ec4dbf5d13a93cbad05495e3df15e1fe34a3a6d6f648ea4aa60b2f114f30944ae593675dac2db188f90a3c483fb82cec0f0d295544d798b62cdcb51c6c036af1a341d78babf87b92609c1d866e311a46abccc8ba8c6a41420359bb061d7e752c0ed25990eef57c9f9e190572203f8c473edf8cfc8c26d34e37240f45ded97":"625aea9122b7b57b9f36446f9053acc42c6435a7f69d91b41547026f833291d488e477c7ccba698c143633a304f463d6af4a3e72c189234fcfc360013e65b07b7f7a36c529d3fdbbdbd6224bf100c14bc5354893b44790f54c739a2b1f5bda82d70fb600ed9b0606dbddea52e508b492b72d8779856274aaaaddc0a3edb6cfc788b603101bedfcc3f44baa62336bd950c2e349d5daf04f2e23ec2628893d214e277569c565e5e6aa8b72ffa14118a3b57f814b4deb179980b5eeefa4fd93f1751850466e929be537801babc2120f3ff1ffe5fea813ec7788eaf43f5ef657e5af48395c3ad11aaf741549090b58670695f7c95c68e00576ca18ef0313f2b4b757219fc8db3dc2db28721d6f912547ebfebcd96935c3100aa4e4df9955acae1b4e2c10df1166d46c4285ab631c6d2ce58ad3ae99c07c019dcd15958694055281ccd6f803af290431f188cc4c429e84a4c30fd9c63968dfd0951c417efb71921c207de172a9546bdd3e2bb35b45e140892c649f88c31a438f864e801a69f8010aa3d77a26601a7a89067c81b0f7e70d8e82f21f88c7d0bb0c8ca0db875d6c3f8c6f6d709bbb31c7da2e31f3571daa2c5ab13bfc16624cf35abd526e84269fb45bbd2fcd8c383d6fbb700bc4b5205b3ef8c4323dc0d9e0370e56a3d1e5e76aa4de082e4c2a0afd092845bd5dab52a45943181461b76e3984b95f48bea80a94944241d04b5634c86274e7" + +NIST KW wrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 128 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"13df8fa68a6e096b9b5bbaebb64ace2e6a05485b5cb7e43f":"3ee9367f631fb375ba47241966ad4ab8":"d0309b1291a06c595fcaa6dcf97817dbd7b7ad2cf48ddec2" + +NIST KW wrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 256 count 11 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"17c25023ac76a8af777a6f71c0c0f97931554b0a15a79222":"15227ef52412346e83a18c54a75374f69a24de6a07cfba9082596eeb5d758bb0":"0f8e2fe4f3a28c1fcebf20fef2bfd3489deb284e03d057337496285f4ffe62f074bafa0a0a6e44e4" + +NIST KW wrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 192 count 8 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"49d1c4ec51f2695ad7e47554efd24170ab03f628eba7d5fb":"8bf961097a6fa75694cf0ea47cfda23928fc433d5fc762e6":"dc72c58faca0dd662e5fefd05cd714987cc2470219db77baf779fca865f31529" + +NIST KW wrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 320 count 14 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e06ebf0145b178ea45687abe366fdec559877dbc9300a653":"f0104e9546628d801c4f7e875f1ca4f385e915b0c7bd52ed158b6b42d7301f1df6dd5bfc80d0318a":"5b4b1d4ef349fcf5eb7d720d84b2e79fbabf3db18277ada0752b9883c21f0e24281854420e6751af8fbcc4b98be0c1d7" + +NIST KW wrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"932ed6ee1db1c4cf7fd81efce5609641cb5f3409563089dc":"da8dd9c1dc8cbf95b0fa280747c1007ecb086b7c944b0db4dfa3bdf6ed0c9725901cb838c2e30131250188c22bd92b068aa0871ce58a0c22307671612fc4884a655329851d54afd48a9d3a7f97976850d6fd842034548aee67df1272b06f155eb21966858731c3c35d4bb94a1ea351ef5a8c4779c077d648ec1c4f27cfaa48f47541a8f36831e35a961b076307bea928e1856e448d7695a0f7fbcd8c82800d12f530c2086f3b67bc5081d384010b47d327120def5c92f815aaae31d32893cdd18a71ba4e208445ff3a2f68a0a46689458b0f2d6d9cd3726284e56b4c020b97a82d4463f74098cfd7bd7a5f12157a0bc812266b8f2c215933cb67518f900602f0825538e05765318b6d31150007e410b92d5d957e119c5d94aadba193cf6da230387b1c5e6448515f9789a8867571ea82ad34dc5b912d6cd243bd4fc2f19d132bd8f1f5cef00a141e30ec4d3f7a546a215d5b0c7e70c3b0ec4fc34b66c4170bf403ef910dd3897caef33405827a55f943904c4e1b1aee4cc3ffd0ad27e316c164e2b5bbcf73df60d8859201b6602be01ba638aff468f3136120c117ca848ae161ecafade668e2d04b227437d4b91c6fc40ebd9490f211bcd21fd7005d200ef584f37aa2c4c769174551cec0d7f2936ae78f6c389382212703d0e7c82aef1a736056ed9c45e71439731537a2edb8a63741825c678a11c42e5b2281b43e203b0523":"76b6772984932bb6314d1eab8f625e044920f9494789e9a0ac2affd9a209cabb72ee83331a30472934e02ef28697d541a071eff9eb5c7dd49862f11384d46e8f4c2ddb084e76ef382117a285993e4a9f89e1e0ba6612f63b3c8a54784f940d7e6baf12cb67d27038e91d1ad4feceb5bc44daf7444f76fd140ec7a94869b4f99b9fcf6dd68e78c6a0a4794d55a1c91756ceb9d28b43d9c72b26fafc25c71e63dc175b29282d4a70813b833c35354983f29796909a9ba515cc5c37c58e95aa6f35b850500ea933b27a5922188c2da64680362602d71d169f853af0564b53bc613c15772ed82f89c2f8625670179a83536972332509e7ae4e0726271c5381501d3d88a3cc34a56d80e3e553b9b595e358615e92f361d695837734cdaddd7068c441b310aa511407b53806f1fed984a73862ea2ded1ee67d14feb5d8661ed94a62f5768829d6feea30db392bf24f0ea103fd2a60acf1fcd4bb2465641712113375bc2c8d73650795689f9061608b65e0e608f9948f5efcc0fba62c50b8cd97f67df2b0eec4f5a0cd354e982ae6a62070f4127b6556714bb2267d558112638f10c78be201ba165e57ac9cab6f3e35a762b7fe83b3c7c050b77174a4bf14eb2cac4d6d58a94f0c02727ad020a6a05d9ed145151d4f1ed41d5a6d06c50c0e1d5c24d09100d4f06c50d06a332a95845f4192ef577dc484e7acb91f0b2a57c1f8bef97c23294c59099eea13b3" + +NIST KW wrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 128 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e823c6ef53b110eeb3f178871cf436887cca9df061d1f26409ec3b410033d967":"f90c279e9e6423804a6505e8effd924c":"0abb50b222af66058646156d106df7c85c28b708395eb9dd" + +NIST KW wrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 256 count 11 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e5cca71056548467bc9c2849aba67cfe0fd74c44d514535d2314022a3f3e6ec8":"326b6da4dce95c94226b63c2d38c4e005c566191b00028b59cc788e0af5261cc":"2a4f331f451589fd103d9a9cbbeae5d5f5be7acf15aa6e21c45e09362263cf34b0ccab7c8a28dfed" + +NIST KW wrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 192 count 8 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"6a077f95496aba1bb80831280e7563f3a187e6d014342028349f766b791108ce":"a77b3ddac0e78c9176b7445f9ec349b2d85aa2f57e6cb362":"7c065be0a2173e0f14a3418779e7f3eb6eb7fbb7a3c20fd6c08b37d408bd9423" + +NIST KW wrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 320 count 14 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"752b21422647f1006de116360e88e2f6601eeb5aafd27cba56c20193fc1b941a":"a5948c20bc611187d688cb03caa04fb17774aa4f99ae3da5d821bcccfae950d72ca74b3a870008aa":"d71109224edc4233db8819aaca4db9c61ab5aad2806d0e985f1830acd8adde23ce75046b2057e0a23dec7a053bac6c4c" + +NIST KW wrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"931bf2c55eac657ae56fc0a9505a6ea7cc9af5162d844ccf01f19debfad09cbe":"aa8074a195abd88930825b947cbf3cca9810eb829d2e7a09f9e9cb1f8271986d00c5be478150fbbe990de8c61af879495274a60d83f98cfecb2473a35d86fba6ce839d259ede318a362e7abc1f8a18168606d5e680f456f1ca19942e67e5aee382536df7c28204b7842b99023336b735a861cf28363e7773d7b0bcf32b5fab14cb524249863fd7ce49a7a7882b53728f7ecd020393852494df09d9a69189ea713e730e002252af18864b948a642d7c0fb17b0cd5671f14ae340fb0e83b4bda920445927b8de8a82ac93158edbbd57fddcc1d908688770a07c27d2bdb7151d986e85cdf1606b0c1c959542e75090d8fdce9c2a9c162e6fd988746c9bc916ff3f20f054690173d143212b74c5a8961cd46663958744ca1334f6c1dfc13fa83c0a9cc229a1030c6c84d01751ffef54d0f9edb2a4851a187d02f097a5c716f8fbae29eae76738239516ed08c14f24f9378451e9e696742a4bcdd9e0ecba49fd05eb93698afaa1b0d5558521c7b4e77b15ca2612619bbd78f670a1562a9a0a0215fe64211115e60476525444b351a4f8ff5551dd198655423f3fcfb5967c4f77e25d3911504de1d034176d3ccecaeb31bd29677c7569c858ea24d7017ce0b31f1911f4fa14b2afa429c06115bc285ea8b90bbedbcc63f5f0829dddcb17e8f9d21bd71501679e514147e1957ccf986e7e96a0e63ded70a9d017162658a901f55b1001d":"6b75fa8070291ef7c89f5cc2060c56270f5077a6df65a8095cc76b717167e67af70dcce96de4aa32293c17d0812f666e1f42e7e662cef7a3148486d2be7f314631ed6606f326e9781c3ed6be1735bef8cd5d3ac7d2b45c4419ea61462baccc0ff87b83b9b6cc85278c0b20bc15e6baa0a15eedd9e99df82c8e61476529c98aebbc9d40d417f9af26e6da5d115acdd6007d83206c616a39fbe21c6331cc45af11c578532a7cac50aaba21f3cf317534564c2ee093ef127484aea62c7a90327fe9bbe8e45627974306d8cc7452e96033f0c8c30ba2d7fb644796a49c9b502d3db7d4995f920fe21962fd2b634c15be0d82e9cf0ae3fd2b6d45524e1003ab9788ee56cff3e2e62c5784061a5ff586b5907098b8ab54bb70fbc6cb066b071fedce10e013014d82162e3cc6f9be3b4067555907a4df55012a9b1001888c55dd94b4f8528bb29e7985ecb8a7958fc8559831db05002479b1f39e5de3659f3a6e8289d9b8ff4eaa3f864b1ea101d84b4c6138aa6ffb95dea4f825d23f5d368727ca0a8cacb74f7bfd70fccbc951db99f2f4a580425c31a8552fa27397cf8b7f420f13fdcddca553a5f31d8645615b98a88795fb4472bc7cd6e8e54707d7be1f3dd7d4871725f6bc0e65762f1e42e22c411fee6dfd8139068798c7ae9781c8e5bcf4732a83f9142edce36e1ee6e20142adf46c5abaea0ca78f61e16b6875927d4141f6b215da1f48748bd33c" + +NIST KWP wrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 8 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"d060e5faa705b6c600ecfcd5252bbfba":"3d":"28ccc6da03cd79b78c7207946fcee402" + +NIST KWP wrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 64 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"663ee3d40628059fe01a9766d5c1c31f":"1c6ccd67438f20de":"c2717ed6e51bb4314388cd26464f4d18" + +NIST KWP wrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 72 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"7865e20f3c21659ab4690b629cdf3cc4":"bd6843d420378dc896":"41eca956d4aa047eb5cf4efe659661e74db6f8c564e23500" + +NIST KWP wrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 248 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"02a92285d0baa874ac94f6648988d44f":"6ac78aff505805e3145fac44eaeb6ac92945ca12d9bc0b6fee8b1e5b983f37":"18b251cf54d2a51ac903af2fd008f6aa2b1bf491fa2e0458dba272866821e98ad037eae4af654811" + +NIST KWP wrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"6b8ba9cc9b31068ba175abfcc60c1338":"8af887c58dfbc38ee0423eefcc0e032dcc79dd116638ca65ad75dca2a2459f13934dbe61a62cb26d8bbddbabf9bf52bbe137ef1d3e30eacf0fe456ec808d6798dc29fe54fa1f784aa3c11cf39405009581d3f1d596843813a6685e503fac8535e0c06ecca8561b6a1f22c578eefb691912be2e1667946101ae8c3501e6c66eb17e14f2608c9ce6fbab4a1597ed49ccb3930b1060f98c97d8dc4ce81e35279c4d30d1bf86c9b919a3ce4f0109e77929e58c4c3aeb5de1ec5e0afa38ae896df9121c72c255141f2f5c9a51be5072547cf8a3b067404e62f9615a02479cf8c202e7feb2e258314e0ebe62878a5c4ecd4e9df7dab2e1fa9a7b532c2169acedb7998d5cd8a7118848ce7ee9fb2f68e28c2b279ddc064db70ad73c6dbe10c5e1c56a709c1407f93a727cce1075103a4009ae2f7731b7d71756eee119b828ef4ed61eff164935532a94fa8fe62dc2e22cf20f168ae65f4b6785286c253f365f29453a479dc2824b8bdabd962da3b76ae9c8a720155e158fe389c8cc7fa6ad522c951b5c236bf964b5b1bfb098a39835759b95404b72b17f7dbcda936177ae059269f41ecdac81a49f5bbfd2e801392a043ef06873550a67fcbc039f0b5d30ce490baa979dbbaf9e53d45d7e2dff26b2f7e6628ded694217a39f454b288e7906b79faf4a407a7d207646f93096a157f0d1dca05a7f92e318fc1ff62ce2de7f129b187053":"aea19443d7f8ad7d4501c1ecadc6b5e3f1c23c29eca608905f9cabdd46e34a55e1f7ac8308e75c903675982bda99173a2ba57d2ccf2e01a02589f89dfd4b3c7fd229ec91c9d0c46ea5dee3c048cd4611bfeadc9bf26daa1e02cb72e222cf3dab120dd1e8c2dd9bd58bbefa5d14526abd1e8d2170a6ba8283c243ec2fd5ef07030b1ef5f69f9620e4b17a3639341005887b9ffc793533594703e5dcae67bd0ce7a3c98ca65815a4d067f27e6e66d6636cebb789732566a52ac3970e14c37310dc2fcee0e739a16291029fd2b4d534e30445474b26711a8b3e1ee3cc88b09e8b1745b6cc0f067624ecb232db750b01fe5457fdea77b251b10fe95d3eeedb083bdf109c41dba26cc9654f787bf95735ff07070b175cea8b62302e6087b91a0415474605691099f1a9e2b626c4b3bb7aeb8ead9922bc3617cb427c669b88be5f98aea7edb8b0063bec80af4c081f89778d7c7242ddae88e8d3aff1f80e575e1aab4a5d115bc27636fd14d19bc59433f697635ecd870d17e7f5b004dee4001cddc34ab6e377eeb3fb08e9476970765105d93e4558fe3d4fc6fe053aab9c6cf032f1116e70c2d65f7c8cdeb6ad63ac4291f93d467ebbb29ead265c05ac684d20a6bef09b71830f717e08bcb4f9d3773bec928f66eeb64dc451e958e357ebbfef5a342df28707ac4b8e3e8c854e8d691cb92e87c0d57558e44cd754424865c229c9e1abb28e003b6819400b" + +NIST KWP wrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 8 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"959b4595778d7b860e08fcb5e24b11f118fd5d67089f2ea4":"65":"1cf986a0fb2208977c37a4c3830eba72" + +NIST KWP wrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 64 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"02dfb6662e0c1b95d34aaba7eb6c1fdd41c52b89213d5b18":"27361c34c2601fe6":"089f835f3210734aa1a2282c6ff30ef9" + +NIST KWP wrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 72 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"9464f1af6aabad076661328bcfd15777da16a288a2660009":"431527c3a644c106bb":"d9b257b400d808a0b0386af3be9154fc7f2fb2d7edc06201" + +NIST KWP wrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 248 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"df419ca84650ef28a1c5d1cb47917e4480a3aca4bd29dd5e":"3d84df372bc0b854c058441e952738ec79474b673c94e32dc78d23745fb5e7":"497e966414475938204c3b3d606d5160461c54dfdfe903b6624208d7cfc90bb403f384bfd54d1ed2" + +NIST KWP wrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"a85b4359ebd240012ec749459bc928eaa52c84e887ababb9":"9db71e2a2d40f6fcc1b8311167ae13fb101bdf7b5c4e078373c0c3cb3f3a3ca39a91a6985d3fdd48d93f2b5a09b2a69350da2846ce6a37d018dda95ddac93a92fda7b7c3bb6518dd78f367f70e34e0bf19dbba46fd13d3f3e0a1776350f27138c64b177aa39c54dc06184b320016b6305c2dea19fa6da634cd613d5a4f71bc045f555a1ccee39b8f1ab90840b5bae555932e08719bf38f72bc1057875e8c077a70629f46be91281b977ed6f2a71171a7cbaf8e0566e55da6220a85a7655758de3b372144ef76d0337d3133004c0db096b2c41f524f95706247a331d08a6ff72b425395fee8e1ad308ccfe5b0525c40803e529db72063731fe1644891bdc0d5961397006e1f5d6521ad4e5aee3544da101fd3cf6bcf879220a612b7016e5eefe7369f136086e8f5109ae83e8687519f2008406d20992b64ba1d27b436ea5db1fd734340f3b2279e026a96e3f9c5c7b99553e35ada9e1d7d708a73774718f9b7073c0889a298f212d47ff5960e04743070338f99b11687396da2120b8f132535c0911b04505c0e6c32590c82bf59486fadfbdc0f16a224b2f52082eb66201f041d64b34809e5e91cda89d80d78fe1e15862bcf84f65a301ae68d097c9be09f3411c11cf83225733dbc9306ad2630eb7994a0d112ba83dc542966414137fd008fbb7995f649edf844fe5ee86b94acade1a04f42dae21928b9b0cdde8cc66095772d":"72880f9f173f0ef4d99e3ae71f6f3b94f66a08aaa22be1d206faf431718c1a29bd0a574b1a28b69f0e64d56d3e43617dc73506a939b7de9005ef0ee3f02b9265e91a32aaec58b7ab990f39774f6769c9be9ced3339f6bf0159055abe237c4c755613a6c03271abea3bc89527f284a3e1557ae26b3910b779a77a128e773d11d7d641479d02f4888c989cbb8d928da0136b965531730a3c0c32404351f4c2390d996dff58985ed1d4f4021a5d6ccedf4555066a826a04055cdf8c9c44bdae26619390b3e22b064f86b28382094a3e299d55ab335ade601699e85f19d6f6f12407caf84ad47f03d75198691f1a9b2aa9ed95e508d8551b19601418922f3289fc1efc3abb1ebc2f4886dfe325cddfe25dd908e5aef8ad197ce2703e692b9c46a12201fa71ebc2e323ff8926ecc059ffeeacc0446d3f28496f17f1b4ad6504e4e24188862e25f3dfc36adc7f79920d88e6c53269cc4e5dbbebbba1a2347154683c840d178476ae11d6ce574c26b8b895957b8623807e8831b87b5639aeb415adf1bbef394046deb3bbe91a5c17f2f67131ae5f696352a488e3bed40df025e0a0846e0037847350fe8ae3cf73141d0ec550d82b89c05bbff7337bfe846411d3f0bd012e4de2fe5b83c7210214c0404b40e08abdd3f4bc441f9b6e1efdaa4ac13b85d139f670a6060a1ba8d2528bcd19f241d9ee5077d20c120f2b484c67c9c598b1b209824c3b8aec2b7b" + +NIST KWP wrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 8 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"0070492ff3aaa190496c72bb0affdb6fac7fa9cb32e6e91a46ea34863422f807":"39":"643a9706af6bd06410b70ee38f546bc2" + +NIST KWP wrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 64 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"c6e882f5b8e361e43bb3e54d5a7b8c690f485bcbec2dd2183c7e623f6b02c5fc":"99ae80eec64630ed":"de0680b34f7374539ad9b75f08f4d8e6" + +NIST KWP wrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 72 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"70da43aac823c6dd37d1109f5b18feb4503c973288989745e2cc1cc21d9570c6":"edf17d966ed896aee3":"d67b5b2ad15c645450e23b5e7b6d682f8ae20e716d470db7" + +NIST KWP wrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 248 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"e941febe4b683c02dce56194a86b72d4c569e1fc84bc7a6f24c3ae2b39bf5440":"c168cf12acb6679c24d424baa62ed56559caee163a4efa946478ad43d7dbd6":"4ad9979caa72fddff0876c0295a57fcf74e5980fec2cf622191ec6b5aebb75e0adebb12d0862ffae" + +NIST KWP wrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"20f31cded60b8ed8d9d3fd1e1fa6244e76c7cb7628bfd28a5d63ce8aa2c9494d":"f07225202842c8dede42215301e44b9bb7e625d3812f74f9b6ddbcd024ebd1f33e2cbf280b9004941f3cbf86c880a2357f88f92a6dcf8dad9da7dddcd00f3635efdff0af4382024e93c2af66b991e565eacca6b886f07178c9b4adad6f0d6ada5ff6aa7cd0712519a947a8089cea5e1e3e40ffe1806010b0149f9ffc7c4dd3c31b3d08d5ae1997c52369393d58611dff9bec501c1ab35e6ed3e7f9445a34e211010a8236686f154e0a5ae3433d6a844eb3884961aa6592216d93952b46bb58a4195aa80966ad0ccd4a7e23823912556a90d5ee9c3bb952ecbb9d895dabd3b11ab4f2e3a6c2582de50403289230ef4dc46e7c0d870a3f0cba9d643a0349503c1b162ddb6350e699589eb47bd563999f55a1adb6b78b52f006901b0427ea7d3394bb0adae4637b4f1ad5d5425e2c8ff3083506d7ad7ba4c7405a778b0a3a11760c96900a5256956cc9710091d073a19f46a985d004651fe2b6448ed761bf9bc81619cf273a6783d868d090753bf01318be21afd88d9f3a961a69f93e9d9fb822c80acc7b48cf14a08b5b7ef15c66975721b7cde9761a145b679155472a44dea8fedc0f86ae7ebf6283ecfde5f2444b51569e6723a7a19e28cdf8dec6791ccc14af95abad018f741575b343cb1a20a2a9adf4248f99728069a1e2e78ad8966c41c9918fb7019ef56c153a183a6247d22d9956564bb03075cbfd1b43d96818b28484":"a5b63618fc0c4512960f00a1f226d9837a90480baea75265453b9553b12a58c72153080842d7f8710f317f88fbbbf97caf879ab4bf416ba767ee9aeb34357f4a2d0e8b9571054d98e28804a70bc4d74807f2bfd95ee955bfdbb6f4d6969a0c3c3b541a514647d5cd8c9740ac3496095c3f145c50c97ec98b935158fbdf89705d5330015e48ece89188b8c1bcb2ad6825d865b375a9b9056b743dac720feeac033c9f757f6fe73dd7c4a747661b64cf490a0dd43b547cd791a5d78dac97efcd355f7ebac248fa2a33e4fad640dc34e0d40b0d36588aa32f0864c9446739a6b44ff84666d723bd7d646c5172cda932fec34ddaaba342b02a9604087ef042a2be4774194b5d32cb3fb112438fbf2801050b5424635fa2d3d3fb10332965c73e6669e65195310a3a30602640e9809179cdfc50de585aa1c0072423c626815d281a06eac3b6ffa137716318e288e3f9970e415ef0451bdc557968febf9eb6772c1f77cb8e95701246d9c567048142bb25e340351b87d7391822d9ee7fe51378bc0d08135f9f39cf44b348b87937939dc61f430dfe308cada632722e23aed5a0699e039cf0563ab8025163744b136a13ce3c62c748c89f5e17540f105e7c6ec9ba13515b504342f9e6dc7d65b9a633d8c0b5c9fa858dbb9b3a594406d478a81bb9abfa289730408c1e303c663a61d5caca00f615065312580042862397b9aa8c80ca812887664c439c8c68" + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 128 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e63c2cb1a2c1282d473b66753494a591":"084532f86949dfb7be2cdf09d2b7505418e7bca5185661e1":"a26e8ee007ab90f599a1bc31cdabd5fe":0 + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 256 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"83da6e02404d5abfd47d15da591840e2":"3f4cbf3a98029243da87a756b3c52553f91366f4ff4b103b2c73e68aa8ca81f01ebda35d718741ac":"67dfd627346ebd217849a5ba5bca6e9ce07a7747bed1ba119ec01503202a075a":0 + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 192 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e5c2fc20f9263da4f15b817874dd987d":"0538fdca42f1fd72afadbe689fa8a396996d734e4f082c8c4ef41ef11dc6246e":"35a261169f240dffe4701ce41f6dff986764afa6e84f63c9":0 + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 320 count 8 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"3f5501341f617cae30dd0afbfa247c09":"72fcc9e5942344d11c3b23503b170e39cd635da3a83aa9ffb196cfb1d6eeae6dc5f5683238da6e9b49edbf95819bbbdf":"e2a34da9ea2ad66e130251f8a7798b87d7bd7601abc5ae8f7305b024ddb4b3e00351484165e16d25":0 + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"adf44a10a05e64f2df87db52f3ae18d3":"a940cfea67b90c81b4ccd793f186dd7c6a3c0ff5a6feb5bbef99eaae2b14a979f1acee92b5e4cd750f40571804d380f470e1f5201a389476f97bf29f6699053f468bf102975895f4c1a679a46cf627b22c8d956679ce53775702899afa223c87621f859dccb876d317f2a486d0a4d4ad6ab7e2d9ebf7a956c394ffcff423377e21b274f8ca3a379273dc8de738c97bfd318871330abfe2539a49d4f03d0eef65856c01ebd426f2e76fab90466acbed8c4c9dc09898929d80244eed4fd51e7eff567c2b340e928f298ec00cc8839e1ce9ccdff40a7edd04e01440f2288c384c673de8a758ba50f6f910b8002e0786d2eb633da0ef7eff025f37b45f7c9b918863a56e2da1f3fcd12b990f959051289a1113054c38c135336f19672c86a51200763678cc4ef50ed290d96fec4afaa53af165aa7ebc11d787ab1c535a0abd00b477b914855759477df2afd516a85a66f8b91fb5f5e98232e601e249b3faa856bc6b26f1945f48542601bb4ff1c0dc46f44ae023c0a33ec9faa7467b1cdf1c08df7d00b800ef28e2f77f1e6941db9ce8e71fcf82a14cc8983614e2ce3cb4b3e976a8dec76e4309492ca68486d119cd566b9692d1a513ff30675737d1777a3a1a95b6588685b5a64d890cb8f79578fae8f1d22b83747bf876da582e56e5267ee8e734e0fa9271f5455c40fd599082c0acb442927643aeefffa5bca0a88c38671db14899adbb4819dd1e2d":"a2b43c25c5f530a6a29c5314319bee95e0ad5a630aa8dd614b3751205118e35117c31de7d1ac41f9d782ae8456ef0387cff49eecfbcedf2d9c0b18182f5e043e3202c527be77e6f0404a9746ea1b18978a916cd47d40093813a3b0ba1cb22280fd7f00a7fb4f8def6a0cc1ef848a45106fc389e0ea00652151b1e61dff2cf2be83fccfbccd4fdce86f19859ac927a3dd08645cf072c3525624b3845a532e5a37d99db5cc943a0a9d42be4bc81134f314fd9e22ebd386e7a896bc2d56c933326edb18120c072579989c5bbb1991993a698f2a19387612b25a303e699d12003072fbea6e45569444107ff9a17675f5454440a6c3cc02c1ba513e26502b74a0cb6d397ff6d7d11877100fbfb5370fd882892ba09635fa3fa78d5344fa00008f488395f04a7185ec7819dbf3b165ee52b35bb4ebd10354f2d85514b2fdc1f825a4a2968ba44b3ff2812d1acc13c24ac49c22343b6080f2a7e7efafe86c6435195cb742c35d8178fe20ede0ca08278db49faeca90f95b9b17fc1ffb9d7b1d064f2266d32bbb6f3e28f3b17deeb9faa64f7c127c90241579399294eaf1dac93346943a3cadfd84d7cae1aec66877e892cfa31b5ae35eaf7c35faa6f4cd9212ef7cb2cf9df5748ed8194c380c3298734e1ccb87d0feaf49be1d275142f8421727b5a6c3415fb30ca44ab598597d136bd6d12435ae6ec3db72f6b85462878d833dfe5e6f":0 + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 128 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"5d4899ee66beff1bda1fc717a1ad4c50":"bb7fd0bce778bd775e4e88d904d26a7134364c53a6c493a0":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 256 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"84bc6ce7ee4fd9db512536669d0686da":"c383db930ffd02c0073ac2cc79ec289e6866bdcc6a135a3b776aa42f14ee04f9cca06ed6c0b22901":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 192 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"266b009e911bb55f9aa0661539a6fdd5":"db9c94e7236ec56982d7ddeb9427c24580bc1fb96db98ab19340e03670045b7a":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 320 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"51c2e3d090a74bfa10db090b63ae53aa":"598a16c226e6c848a78ca30fa514edc9467f704b529c02c5522d1890b4dc21588ed6c3b070ed952adc733d865eb9d468":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-128 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 4 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"6a7814a80acae9d03eda69cad200ffe5":"e1ebfaad7f6d46cd03c50ce4e9543ff01150e9a9a69c4bc8198fc08601ed71203e39375d600f69fd762b196bf50a7dee2be55574196005c8ad53234d789a9fa6f2f0eb7d7b53c7e39a7c70e9ef93c58bcd45c0f592fbcda19b5ea9a118bc2a0d49c8cf367d4c90823eafab86165db3aaa22eee9323de7d23b7729f7f088be9db421fc8256c20e5874bd0c8348c4a6e50436fc94136e568d0aa4c29d7b65136bb378ef010db091085c9c0802466d565eace2c0bd91648fa82f8045c57cc25c46bd8c9e4060ceb00e092f7beeaece1d4f8a2a01b5b1dc9de3c7d2ada7a44d4600085b7e76929198b9823b5ae0f74c652fb8793cae7c16cf062f39136789b213d1d500d560bda89bfc0df0e6bcb07fb4a48914e1af9058b73751aa4d98ef0363e48f9d1ed42230eca1b7b24631cbad80b2d4bfbc00ad1ab797c1c459214be8f64470b4d267ab576fc1d3c86a42610b8282437dc071336c325e606c2d36de1b24595f4888cfb2ddffb46557c964a4ac53ccc1d214d44ac84b8322c93db03bdf2a04b303de4f8482b8e7ee25030aa5ad8a8bfc5dd683726a0286486356f5a965599313a2c39034774ebf646fa7ccbda35316c54d443c6da466d9c95d716016326603c3989bd7545e3506333ab3e2ad7b45b225bc43ecb37e4c301b389e06b95f09b1a10beb5fd5320234fd6d488d5691ae2e078630f9f57dd0870cd617c30bd67ac8dbf4b3a8cf61067f7":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 128 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"26045402548ee6196fc0a60208ffde21137ddb1c6c5d2ba0":"fcd55c2c60ff6de19ec3e6b13490c2821f0c565abf10be2d":"94b8276743184d086962ce6c4e63bd53":0 + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 256 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"b3a0aa60fb14b658e1eb1c1a5a8e1f60307c9b9faa2f1587":"fdeda2a10e51da1817af2ba4c9f200414aec67545f5e71c608e85d14da8c5567bf51dec4ff2d8c05":"65986b3a6a3658a66cb5beb302540bb032b36c76d040b24fe278a1473ad4c32f":0 + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 192 count 6 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"f0ee8ab6f804a2629e163b58c1a9e9039b53ac60493df11d":"3593dda0daead2dcf850f8670b7d0692332f57068213a772a8244d058e5634d7":"401df0c06aa4c58a71b9438e11a11a239f577b6037adf350":0 + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 320 count 8 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"579e58b2bf9c34c31e8c644faef6b698131624063fb2d795":"b39acd09d9bf9daaa89304f76402065cc3d863e12df8a966f037146db9619e7be5ccbf50206773c5eca35e36492ef4b7":"9c1f66267c2083a42f3da4e754a073c1ff151681e2bc070e6e4682065fd109088a096e72024fdcb0":0 + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"366af2c7a1d7a1ee5a7c239fd526024472f674ab039bba25":"36fb77bd3890aa0a4a4d6f65d671156683c48214a327e5b2b0916c0031f9f4f2c643ca721aa22e84853096bcedd7ef57ab2ae05628099bdbb55111358a06c1e99233b94a568a3f59b06d8a64332acf888cb5bd1fe8ed344937137eff629bee3ad57c73344df80b303994889bbfcd0ec08b13b687ec909cc847f383d3ba91d108c84254af4ab4c22df19897fef44b62d88b0c1b269163de9a2db56a26c4dbd0481026d27e5003153eec761f21c02f4d04898dd3ed961ab158e572aaf3b828a30eedf62a8a7b0911eff27db48ce1b7bb79b14ba43d7ecc1f87c82664c99ea857746c99a993db5807f0fb06114c00428b85ddeb9cfb698d282b1d70eb7c17d4d12575e58103ef1ed37c558d7c312f0fb1d72cbadb84561a41e4745492c8b1eea557efb9f1e9664ee995aa82e7f2a1c86dabed0b2fecd9e938c796dbf2f9b4dc269545ece94e354ca3436e4c6936b51cea7abcd2e49fa263f79757c4b5a8d18c2c6a26435fbbaf3fc759bb323ffb962bdd445dc7e5c84f9d98812e7eae254d19a06ea378b1b262daf22b634dc30aaf9d911cfff0905e5e2cfdd7dde4dbca75729bf33ef6d27d5993f19c9a3e60fccf5fa201963cea0e7caec99d79f83435d11e3a90905103c302851c8d33cef77b39c104ad4d8f45abdb111780c46784e6fd6a78e57862350a671ecbf01dd936b8dae4ce4a91d86efad8b04724d7c17a89b1d43d8abd650f88e17f5df1":"40bc409ed0ba1966e733be4b2ff9d23691e6a9f44b0abebe971a47b4ebd51bb13bcf70bc1359f6b5e670be2e6b008ce9d219abd61ad20edd97aff7458b81e6114ea6d9c85a03400477b1a32f09ac5cd1a963731246011ef4908bacdbfae5e5921cba143b9395d17386e924db6ce40361740c6ae5acfdc979d45c8af70b443878adbb04bad439c9937a30bbecfc50b7005782bd01e3a87538220ca149286855129bd189f9bdb55ed1f7ab786f99c289032123c814e683db2f10970db79d2ef87f5a8a2cbbf7b9e2c447cb22d2a9d0f8c2b093a4d8aee57f0b05c2ac4f4ef780bad406b847d3c9d175f659105795236b072e96738043cbb8499292ad45acf7e576d8decdb635aeda6611da6c00a1badc11962dfa0643a83b865099de79416c86448280aad32f6797ef2fd879ba46abf36c9da45da4d0c936f6e25240cf30ffc79647720bf10ee18743f1ee3397dc0ed967445bb7b0df8eff0887d3f84abf20f0b2036837dd0308ed4a01f9d6447a9eccc9c471e75bd32f7d760216c326901ecd8590afcc2e697311e29f9d704dbeec409cc8c7fecc12fcf70cf9f718c12579fd17cef1e6bb44f89ad418005c2629a96275965f08c54a53e31cabcd4fb17021889bdcd4851ad33bb0d5438e55ba3b759dbf3c50fe20e6f3b8f1989f560818db1f2079b91b1e2d8bb22a7523c3137e9a30ab970f6019eca225e4b42bbe061f3b7b43":0 + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 128 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"9200a0f688d86c0b6bfd9abeff66341684a373fe3f9a3057":"5c685c8596e374710fe327bafc45cd09190215fdcc03d010":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 256 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"95c9e644559919cace6f93f545dbfe48b130808ed66d0964":"7b8d1307e992221f6ffdcc7909d972d5f02e92187139cfd77f79345cb998bbdbabedb3ac00a6cdc4":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 192 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"ffdbcbd0abc94c7f15e5b6e8a7190f1ed4f01be11f4f7ccb":"e9ad95c8e9185a001509c50ae0098d45f7032575c7b8fd90a561716d2e5804fb":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 320 count 9 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"253a5cbe79a291c0af1a3d7460e7f284bd672cd026753fc4":"f71014ba711602df5cff2b93e86253775ea308bf83fde65fbc9a9a7852f87357330450072aaa3d6ef8dffbee20d2de7c":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-192 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"ff8666e4e538a6cf0a2a002b63716b06ec5f187785c2fc1b":"f5bfda19b535cf39e240d5b42db06f385fb002be273e46d9e5ceed6be4b5f636031bd0622ea0b3abd0087a7280844ce7260594201214e601ada0f686da6e9b45fedbe36c7d13db025746fa6bba2e540a417a29cdde32f9a7ff56325233bf60929bfd49f80e21acc23f3abf572d81e96b556f6f4f20a7e00c1cacd6fad07df30d40de593c99f73dbd61bf9d9d5269a56006ae85d588324f7e140d9775403af631e695f7856b1bcaa377aa7f4f12c68096a974ef703435102d7110f4eeaca787744c942be1186d132bff2b39f160157617bcead75ae59288880fc0e7db9877d854f553e90e1c917a99b8f357082c50bf3b71cd30d016f164ccb85bff50212bab13cca8dcfff0be984daead905ab13054eb12908a73f37ed42c5638a5a410ba182a2bee2caa84e76af2a715ddd24e837988ec475e506faa130f0241e08d92567a69c9645fc2be3945d65a77387cfa307562c9b6c7055f98956c547ccc109da9277292f47cf43e3cbc0d2e91c916e4fbd70df4a980e9430f5c1c8cfbd6c83f0f756c436bc07e86d5c75aec7e4c039349f71fbb959db709427a33869c523c3486be0095c1fd61ac912cafb9065b94916afd9166d73678ffbcc396a037ebe75e44cd824b2196903950b528f537c8baa70530251bfd8a6f37b202453993534c06aada0d1dbf760879d0898026997f1baf63e343e94ae076da7d41ea325dd23ff2a9cbee74baca05a538543d":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 128 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e594f0067cedb74e883e7746d29ba725c884c25375323f367cf49d17ad0f567b":"3b51ae2b0e3ddeed94efd7bfdc22630187e1f7624d15ed78":"587e3f6c75644bb5c3db9c74714f5556":0 + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 256 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"049c7bcba03e04395c2a22e6a9215cdae0f762b077b1244b443147f5695799fa":"776b1e91e935d1f80a537902186d6b00dfc6afc12000f1bde913df5d67407061db8227fcd08953d4":"e617831c7db8038fda4c59403775c3d435136a566f3509c273e1da1ef9f50aea":0 + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 192 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"e86b9c1f74cc87ab8ca6a2fa1723fef173077e684345b90dacd3d485f587d320":"c97e8c25d498430300982cdcef592e34176e33e45cd59b19f7605f52e3c7b997":"261313cbea4b246e53affe1f84bd4c900c9b1d1842d79337":0 + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 320 count 8 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"5b7f48b8ce77007481667e9900f3077a0c9407a70082b0de29bbfbd716a07149":"3ed16c7e4fed98d76092936e94fa5696c787ab63cb764e930fd37f917be4e7e60c90f327f0865d279e6c449b96301ed7":"4e0e6c45137efbf858ce896c815268a10d9869ef5668a90739b7eff99617691fe63b911afa53feca":0 + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"9e92fc974e09541e6cdf1415575511436ac04a56db186bc0e60f0fac9bd58c6a":"201010a2a33fac1d20230bf5254204801de29e66cc44eb391b8e77284b3dbcfa3fabbdd4d9423d96af64ee0dde35786d79b7433021da27d6be753f91d2c1d63b40e9dc265b4a27cb2a61018a60ba5e29813c012b6acbf7d7d101ce227e45b5bc8a16c604c83a99ef35aaaa44fcd2033cddb6122db2dfb944d4b5c16dce911c5f4a1d8db46785534e7a090e31fd2192be64fe5b72efaa8b7965552bab4a20c8eac9a9e7b35e77df0277a90b0b1167e14a8be8d0bc37757354eff920ef93ad65c5a49b04bd553883efe9376811986002d4270d25c5749ee1454270a191084fdca53ae693f5a31b13929fbfd68b331a4fdd2259031f812ecf50d042a55fab302375057cb5b36735bcd2d75f745fd4a92580ecfd0fec44313ba9ca8cb1893f7a329638c17608c170de0ef68123c2233fea878fb1b49ec7478d9cf70591101bfd2d6b0328a27f7c497061b79289b6db4e46199c5db8121e9e1adcc8d64c85c27e329883775073d5f61b0bc470169ce8837b61fc23bbbe7e07d265b32cda5a94acea4bb2e52af17e13818a7ea424ca7fae7677caf405f04e37c2cad0c77eadfb4ead593f79ecbd8292e47b7838d775af9d9e252c6ceb147ccc2aadb01f8541871e5080109f9d94afc9103579bc9dbfcff8791d5eaa68521806590eeea74f411731b920a91c4f4542a60e6ffccb1285dd30e74292d5f37f33d4cb74742ac98c7a0475e069828dcd7d8301fc":"4b6f2257197b0692e6026d531bbe2f222a6764fe1cf277b0320a6bdf9efea0a3f304e94fd22372712f751aa377264b1600f3c1e7e0ada846082ab4885a5c9a51b1b25a593a269a7ca1b62a28f1a11b80fde57f0b9c0fc0e38e8edea8a294e18b4b1e0e24a5ae0e9d9fa0d8cf02378e592b322ff04c5a487332b5f58ad3fe9a0c20a205f6872c9e2d0c52c5b29c5c2f008444a3e8400b4822d39f646f9ed390c352615c4cca8cc0099ac1ec23ad7ef581ed33f9fd4a8a58eb240fc79bfc2df7c1606cc52fb97493fa59a0dc8dc01fdd9fc9fb51a2f1e9fd6a89cba67f001d105c456d99c3b1fd68dc9d01b1b8e0e4c2ed4eed63c0110ea6ee96b54eebcd56c5446dda210a9e143366014e72d5e4bf78bacc230641789ae7caa0e37682190d8007aad0a0983e7c970a6feb1112ee5920f628ba03493cc3b340aa9452e6698f818e6e409cd0a7f660094df05646ea0e6c6aa94e933f4fa4feae6207eb473f9d80e335d6020138f1fcd085a336bdea158823cd47079a89ac18bc8541918ccb6bbbe1aab5ba7d9c6b5fc9ba17cae707a556c2bf7d1f991f9a8ebe0f9aa6e395defecbb508cbbf68db8da443ce8fc40149c3c84314986615ca5685e5e2162ebc617929a7e402a6262a28e646d7f503253c30ff2e37ed6580676a9978aa2f5b4fe82e1c2fb83754fa855ee54a61e64a16b64a680732b14671ff55b3f2a6415233206188":0 + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 128 count 4 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"08c936b25b567a0aa679c29f201bf8b190327df0c2563e39cee061f149f4d91b":"e227eb8ae9d239ccd8928adec39c28810ca9b3dc1f366444":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 256 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"605b22935f1eee56ba884bc7a869febc159ac306b66fb9767a7cc6ab7068dffa":"6607f5a64c8f9fd96dc6f9f735b06a193762cdbacfc367e410926c1bfe6dd715490adbad5b9697a6":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 192 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"81c93da5baa5157bf700fd38d7d67662670778b690cfbca9fe11e06268b35605":"875e1ca385586f83d1e23e44ca201006df04e1854e41b933fd607a7383ae1a39":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 320 count 4 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"c42c53da9bd5393e63818ecc1336ec6dfcf1d633e51ebb51c68fb0997c979e7a":"52f7b481f72bc2d41edade5388d38c2ff75765939576e49bab400040a14ff488848bef57d1502c06a3faad471f5c3178":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KW unwrap AES-256 CAVS 17.4 PLAINTEXT LENGTH = 4096 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"7b51259246dd7252f6a7215fb11fbeabfabafb0f8856afae525af8feb81d3490":"c625853da9fdb8665264c30539a258ba61da8bbd214f3f493e292f686dce73c003aea5c4070ea94b19e486019b18a2f3f1d836b85414bab14eb99baa283cafffabc8498cf1151489a6a6a0d01e7041633c94f9cc6cc3dfcd661c9c4a0bf77d9be168eec29cb0efef33c74d2dad18ae2ac2b5efb519f4c1f12eaa7a7d7959e7a6dec681e4d1878b20054b7925d2da0b2f8730604445ff3fca3a06285a4a2d86648f10a2bc3cd422646f70224ec9025e7ce701c8b521c0392fd7d2ac883f2a37bb7e4d53a92a620e65e090b91dbcdd616a13b3948eb1b5a6b1bde80f03dad61aba3223fd91ca3df68b0749fd049813a7ab0268445793b16677bc1af00f877097cb14798777ac817d0df82507aec246f755ddf95b19bb56ef9f2e730bcf2863648d8b164656df37977d54eaf05063b0ee8ba61c2a2ba7dda8fae337d5f6ba965d9e643b4534ed9f4eea7b2b26680fff50260e245fa0d63139b40e2f152da3a976589e957be22cb0885cd582aa9468b08f08a22b486767a6b99c1778ecbd763ebfe2bd83c6191f4e8a84972e4920452b2b2dd28be5d7bda05dc3422419793ca8c26defd3b42b2cc99bbad98e7461f034abf137d7b3166c94e20bdba091653c6a17ccc4faf86a7ba6d2abc0ecada9103e73d9ee4659b6e991a1a209d2ebd96c24759c69ad13a03431ddc05abc20dc8581b1e526f4d98f6352ca4c77f5479db234125fa585ba275fbcbdbf":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 8 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"20501013aa1578ab32704a4287029098":"382179a39d75756f57763486d038b50f":"14":0 + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 64 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"a099fff482dbaeb53aad84f81b916da0":"b831c7137facaed059cbf268767e230f":"0d24299443bcc444":0 + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 72 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"4d49e260348172c38a79eb925b189b12":"54755a93ff5173aec60d1eaa8fd7d4090f00f638c2831aa9":"2bbe64479da7c45976":0 + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 248 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"6a5a5ac4ccedf055d7562ac58ee7819c":"46904a5583e8a22f4b2f5aa8d071f5cbfc938130f1b33f2e6401aee7cccdef2159a89c9b682cfaf4":"33ac6837955300e569b29958985cdbd434c18208779a949d20b110b0b719e1":0 + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"1dd51f0d3a0a784174ba81b2c9f89005":"e1bde6d2df3b8e48ca127f97b56b5dc2672b3736cc3157c7b80a0316ef1efbdbbce19fea23da831836ccd2e002b2c1dfad206b5cec358446b8434d7f4c39e65b0e0b50897642ffc34bfb3cb3e233aa9c1058ff0d4fd48e98bc8cc3d214c06d514dd97db2278093a308f91f4ae92626d85771fb1447b36a3467fff02ac7e81ddbd0fdbcd02d1acd4f053c989ef3dcc2c01e23bc2f6090f3e8c0ba5f0082341200b1c37b99daa9cb6fec78bce3429aec5badb9fd28fdbdbdc5d53570675a9e39535b4594095658ef950ecd79a162223b60d2eb91765e022dc6e1bbdd86f1bcc280ed9df350da08a801fa16a1bf2701947acfb08f19fdfcaa1d76f466a5de2458a78fb82f6af3e1be68f405a4289f25896f4c9830005c9e895c86e67eceab0ad544856071b8d9585835b5e85a07ab01515f7ab54f98dffb4ca49a15068eefc6a01f7f52fd1adbe3631c59f6f43f79d2b4f2a691e2b30bb1d43a848dc3ee39c7f2e50f0c9deb7ab51e33bf40903ac255bb1510fd61676a6c13c3c776b8aacc6cefb95e24973ebb11192e2692dd0c6a085b58f86e11cc28ee2194988c123e3666da7339c0a4ac6afbacc83f1f100fbb39efff7cc605c9213828224a17c476395aeb9bb0a3150fb8889a8c2a494c8c526203f261642bfa69a94b86de9e6d3d932fe20fffe4bd76d502c0d437a3e1d0d8727b7a8dc0e361967109e93566326b6c517663731c4c9bdd0295d8":"1a4eed4bf5b8d2e2a58f1f1277f164cc32cdadaed848f76fe634034082ff9aa1711870bf3936d01a2aa48de30de5143b9148cf56f4490f9d480dda0b672e8e17a012cd26cec3c68837bd5b2f9beb13e0110f21c6c36343e09e027f39557d1596d4ca406e3e7aa113e9bb8623106bae25f0ea23d46bc29970ba2596f83fe4f73a6f978a4d949fa7c271570a2ae5d2b50792d5ab5c43d455f359fb83c35ca3da37cd73cd66b6adce94d78ecdeabf667daa47ea70799af299e1d898ccf3fca6c42c6fff8cf2ec992f596fed4a0cdb502a00f9b5689302931d15cba691e2f8079a0411332438b714ace5234b91e4aebee8f8dda0e1968c2016fed350430a65d8d206c9436f40b79ce03083b8dc207d6960be1ce97007ed22a388ebb7b3d8f7d2b7d9f8f49731fbcb21e21db0cdd15674c795d5af2b2cd727f83e634e8c47157ed0c6873a5c9419e683f16f4a7827b444967812f9d1adb9201b89a0e66bbcf0591465f5d7036a21cdda0e10099feb819dfc37fdd3105120044dab716882d3971f312e3f4459006fd5a1eab08ff63edf6718f47ddaa37f7f40c9c372995f3aec97bc45e287b64fc8cf5559ab04a4d4d3ed482f5d61d3abd99cc87ee406da3ab9c9cd22ba3b8d191b26754aa94a2412f39e332d77fe72210adb0cbb5c96adebdbde036f1f1aaafad74a7ac2594f81efa734054e2e16dc931d49b970b81756862705fcd4":0 + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 8 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"30be7ff51227f0eef786cb7be2482510":"7f61a0a8b2fe7803f2947d233ec3a255":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 64 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"9ad15907cd05d77b844816b1dd806c92":"7aa0e5d322363afbdd71b531e50d4935":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 72 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"2005cbe9cc66a35cafdff1af119ae6ce":"60f9c736ec3619efdcc7cccc6b90ae5cdb8bb9eceea5dd96":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 248 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"2c3b49efbf60ed01a3ef27ee24ac90b0":"5fa5a87bec09a3e05864656f8966cd38e1c4af48a06b1dab4ec9cca35dd0f92b54015fe5332bdef9":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-128 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"4b4c43c9de4fb4a2a7a7adafeabe2dbd":"6e4d08b8124f7d3e23303fac1a842014f95e3d71c438f8f1990307842796dc5e404ad81802e35c183fe000390a12c81ee684c5cf26c1d90e414cfffe6931b0f352936fcf0b31429eb5c7612cc359a15371390e518cf5c6a6bff1bb0348d14e2c39b98c9f30672ed2af1d96296df8b5567db25b9510a2083461810e119735490058ed1b46b7fdfa885041d8749f90a072b43ba49f2f51fbcda0dbf3cf99fca1d8f46330e5f6fe079d6679cfa26214c8831b782aaa023a2e0ea91050d277dab876aa6865f2bb3fc1a4a77db52f6179d5e5325993280948b6b7002b572829641d35ed3d735d8423e5b24673c4570ca25064fc2c2ad4840632536bcfaf2a7a814f3eaed92b4d501bc51c1719a0d8d8f420b66db845682bb41c88038cfedf13417143a3a701b521a9bf0bb639875a728c3b5ce6ca7e7a45bc75285c193902e6b5e7a4c6e720493d3937bf485e587bff894f70fd6165a1d0129cc673a992e0a4f5489d228a066b1df60002ec0521924f8d672cd1452fec927e58e75807b2a390256f920743fa4d0fc8f59f2469a595ef65095ca0c80adfc843e9e69b6d4a3f824af47b2bfbf2a7a6c1b650378f096f6f0bfabc752c8f279d4f45d56d09dce97962c119de3a64d83b93ea55066f24d4238a229ae86e6a7857af1d8aba823370a72fe358046049a84a70213ef31d9e77a722def8e21480e79b71299438070946bd459a7251707446c911e381":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 8 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"716da5cce5877d8f305b5478d671f6c73eb1bff4de15df07":"dbd5247ad2445575cafb00ee7707c218":"bf":0 + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 64 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"b94bc10b85a8c2f74a66fa723a25ea1b398a4f627efe1ce0":"18eef64a022b2c7db27648cbb5f1d5e6":"19c0f2f78606fae7":0 + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 72 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"f61cde8e515d59a8ca95efb1a98ed4216c4a9649151babf2":"83fce85e9bfc6ed784b052472e5780fee662f17a91faf1a9":"1c6883862ede37b31b":0 + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 248 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"1c883af75147bae6f34205cd656ad30ec97e617456591ce6":"f24f6747711cf72fab0422026c6d548ccdba786d77ab900ac3fb8f39f116d38e92c82d5fd9a045dd":"bdd793f086d8733f69055bd79bbc448be857286e918fd4c54be4acf4eca5e4":0 + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"1b38d4b366f844e71a8db6be2b77a05a9e81720d2d3f31ee":"62ddc158ecb048250bde439dc7aad34dbe7667d330a349026266c24cee9742953b623d1e247e501641b45b60cfbab665e68040ce06ebce478d9d77f5f344943a1edb14f0d9f165ecfe407031707961fedcd016559228bff5761cd6542944a5d86f9acf4e0a4114682c2312b8d4e8285d3efe1a7c1526642c73c332a9e484377a1c86714e3cb687781928c8a5fe28b4aa74e79f53ecd00793e00041b39b172e5fedef3d4164dcc6b2d2e47994e73f2ab048a4adb8cd94fcd7767314ae40f8cdbef2b26d25f74277a2f88f1de56342a0ec97fde4df2d052e6ebc62622f65725d845f670a647808666c7325725a3428e26fefe725c2badb8a8b8f04e30456bd1fd39fd0f7c782b7a2bc9d8c53922a54c5f103551271af6d7243133b96cd1c108811e4beb9a56472c1f9823a1e88832c5505e07cb93b9041f4b8d69cd27403680a18bb3848c269babbc52aaf568ee8245f4f72e177257103dd4bdffeee9b48e0660d6c2f4dfdce52462d0ed5cc5114dc0aa5a35601c9a644a1fdd3c57c3153e65a108eb94eea3bc9979a67a2f569eb7398a4bd24547c15faa361bb2950a379a1cad1737f56e7c210652aaea7581f39f07ee09a101fde8c34c3cfc404f2b8f682735fc4c721eceb4bd2295d8a74ee3cb858329509eba9049e7e791e04d8452b50c6e6225b94a8cc10ec1d262588fd2f05eee08113414e770c83caa84d310559286c393799117c177089a2":"b1c88d3e5648218ee085abcfcaf7f362f33e4d6de363cb84182af9f18a31475f0e14ae8eff76ca67455726392a110ca262b90d040abf49beb036db096be053d493787a67e983b63945277044acf648172c75b38d7f81dcd58e3bbcecb963dc95863877784ac04eba83481152c30b1ca9e9b78fe537deee6c95933e1b5fb414cfaf7ca1dbbae8b114f0538f4cbf433ef214b776faec9ce1d29f680f4c88ff7b9ba0e964898dd253f5f82ec9f25663ece9dbff5e284f63b0e0fd07fb13b41aa8359f1ba1666bcb26e65d28b1f899952beb28b8f902f048e31efb6ab4817cafc6d84c7f4676b50936715667a67df7ca965b3ab2a5fc472375b1446c810242eb1cb78b9ac496ed4715e0f89a4e1ae0e2724edd59c954f54196ab55ac1947528fa14e716b7707aeb023bd0a2242da7ac97f3feb7795d9be05cd5b1cc33095599ab4c4d8d583c9e2a4d4ed12b836722370569737fae2d6fa60c8a5b8a80fd71129fe29395746eb746528a8845c5a9d50e7bc4372e7f3f9c6333feec791529a6ae1bc0f620feb604f56969e4ea3445810c72dd0772856feb58f09796f461f7ab1b454c303c810eec7526aeb397520b6114f57a4d906e974e8d4a910afafbb0f030b18887b951052d18578022cb7e33408578cdca34f32012f62d3dd35cb74e9d0fecac52231c5cf5a34d470d3b5413644c4e2af1f1613093a3b0550f8df26d033a35b9b":0 + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 8 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"df8f5124b1e03228f2b96f0df31924bac1d3b5d094da22e6":"230bb26c1ea9d5c8fcf7c122ea994f41":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 64 count 7 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"94c8dae772a43b5e00468e0947699b239dfe30ab5f90e2f6":"239c6bceee3583fe7825011e02f01cc0":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 72 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"d81b7162dc6e9e18bea6e258bddb53a1c9f22a4a7177d9dd":"4f3a2b7b229a665776f9cfa42e0c2a615a81f69cc0f0f465":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 248 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"688833d56cf1a0f492bf1f7e35c2fa6299a2b1b5ca2a2823":"4b7c17d7a7189e7955c03abb0ca95fc0c780953787972097ae596d46fe2a8cd75995e6309780ae5f":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-192 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"4b0faa630930b0ff8e624aeb4ddfa018a858cfa653132675":"1640db081e87ef7797a9f17509f5bc67d40beaef096131748f413cac3d2500462b61140b31bc3965958af51351903549e4a71db589a6bc67d72ec33b8605a25a539a2043704389e3e0781152dffa9b64d6ec186ed144847434345e6dccefbe26626eebc4c22e3957b2145c46fa11d7819d4195cb43a9db8d2de507c023607548b56a07628ce4c706939fde1bdef8364b2b8fb7db30fc5c8e99f29876130d9f71a8486d99f2c7fc09f646918d4c60e53c7b9f9a8a1e9a023d70448f6b79c3f35cc6b9ace0535147f7f27be66d918895b9106cc83eda1aacdc2bfb7daa75b2867ae63109ecbf9423526511c64c4261e395d9b5a68dd2503ada57cf1b8a18336b8d63d248ec4dedb6e30662336546c86ef83b53504bc3bedd85a027b6b9f0323bd9380d9ba696b77072d98f96b77f9b3ad9e219715122b2dd033529eaf7ecced8be6d1e6467b8e4a61105be9b7a7ce208b6dd6bd34481f80b3bf534fb87904d45986931a088480a8040047c681dc4e8ec1c625a5449d9ab28709d04989c4b1a4ef0f1e379d37fe6f0641b9e705207e9a0652463cd5da71cd50321116d4ff1cbae08063df336482eadc0d117bf119e01f2577afe182e7fa477ec53b754e347a2c742960b9bd355f969e6ae1df2210e75bb44c598b683dd4c8692f4cd1b92125ac9ed10ec4cef6289d3f815cb894e74dff0bb72d51c43cb420d74a31c681c10ad7f9258d77f1f186c926a":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 8 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"da862b25a629d328cf9fac7be0d6ead1cb2404e9bab87a2381a46eb1a81187c5":"5e01a2b9b8413f303a3578d2cc255fda":"d4":0 + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 64 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"362586d516d38e4d58b50a441443e75064cf6d6cdb6420862932ba7b0480b0fd":"ea7ee0f5af3a271a9777838ed13c61af":"f1b92d0db744bfee":0 + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 72 count 1 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"0e6d542f960c7e61ca190d7fd719fda157030a0a013164613a8c522b52ae685d":"b5cae8a82095abb3478ab167dbc0201d2f4dfc5f81bbe44e":"a957eb4ea02e68ba8b":0 + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 248 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"0445b86d13b7b76c0089a63dec70c32fded9607af63714b7c3cc724f49c1c6e2":"7f63167976e71e43b7b135c8cd12148f826f56e73f6fb6e7f6cefa23c34302ff374d44dd66b6bb01":"7af8c3b32e61f8b5c027383a273927b8fd09b75692bd0b713ec8ecec0bdd2c":0 + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"08f5c088acec18e6cf1f03a8f85d772e327e7fb07f8c2939eb554e84c42ab93d":"dff30fd43647d4be54cf2dfd6187e2ddffb55267313f980fb09c833a9c2bfa558a95861711f0acb2a5c7e731ba22f24a9c4dfdd9e9b0216e9088f817a175b9835b0e17615687a20f68c067205626494cd04fbabc0b3eea7c0a4cd6236bc8b3e52e721dfc357fb8a3722bfcc4c690d8f63dbb864bb6e3a15805aea7270f8eb748deebaa2d066fcda11c2e67221f9a91d2c29a6c79ffae76aa80a2590b4f9e35f623fbf2f8ceb2a205493077556a186e25e5bd52dcff7bcc6909b37a66c1d1431be1b363bb40da25386eaaf5fcabc7be6422a04434a21d1d3105328e7c56770b9f59b03395e4138f5f06fc7e6b80dab87b08caa7bfffc45a095c15263efd3f06c651ded6f58074efc20620d704997fc84721a0a8e9e5b9f5cd330bbb156b31d9d1b1c260e4a24535f30404dc5b2dd6b35d916a1391b25a7d8790be09d85483ed1522074a2785812005bda10dd55acb245b3bd3d9bb777dd23f9b02538ba1a114ba53386d7ca4d9524b2f8a18e0ffb21580b560540bb2146f08f04974b90eb324547d56222df95f44bc6e5f183bef283e4816fb1b2933f9c7c6726a245a495e304d8318d0008c51b0be8090f8f668fbc3f31e073be4b9e97468f4dd8c798e9d682868df493db8a85738b58cfd005190f365849072577772672c6f82555c65046eb34e86fe61103327a063bacbbe33cea7eaa3d1de45471b7269e1b6b38608626e323447a3d5fe0599a6":"8b68f66a3d2f59d419851b94d9a6f2f0e667f8125e11d463a6bc2cea46b12dcc40ce8018b204972c735fdd6d2d05b628f4905c6690f5ac5b1b51e12f3af2dc3ae9b9dab616f0a2a66a1ac197592fd5b15900547f32f54110b58d51a0340aa80e9eeb7b2e0eb97e80aa22ba918f2fe1c678c730ed5c3d8d24774f17d8ab6e01a06243d36e764df1dbb8af1faadbc55281f0242abd7a162c984fd0b05ab8b0bcaedffb2962024f009a8d7c9e71281c09f52ec0707ee3bbeb1ecb918be6ae3e9c1fabbcd3512af928db3ba6c109ff9e9839a616b2a53f092160a48222b84d53cd52490515ef93e1ebb33897263492ab8ec6fad2e633276ae367f76d7f926309478c0205d4f22506a451795dc98f5410d8f5d3e049cbedf381620861e7b4ae08f2d8a71abc1f230248cb636a2d7b4e7717ab2b7b5f2dc6e5b5a18e8043254208b50fd6f8929eaf974c48551233661ad67321b64d69245d536d9a8ca2a6a10966dddb9d2ce36641c9281c460ae524b077867258f638e6ac872cb5f5c6fb216b1ae60a9d0c5ea0dbcd060f255da26111175af4e9935df59ddade6a2a70cddff8cae6a98e4f3843c2dd59d09053b07b648a46f5de0eb21ebb192828279a386ea3eedf2cdc355d73d51111e8c1d522e059752bc56226a4225bcab713bfaaaec78167d7cfd33e913b26fda93ca7524aa8a8b17977c88ff9bc23ea810b4de59eac18d1523b":0 + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 8 count 5 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"5fc3ef43eef256993fb00e6ccc90f60319f10a3bc9fe5ca4ec876c165e2a7720":"f3d922a948969acca293bc3daa027e48":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 64 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"398444df32841be9e699c64faa92630c834564b8384876dceb471c4056fc8299":"30032c9a3ed00d29512d8c725fa86a4b":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 72 count 0 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"64b69233fe392c0bcda28a931cc3527b1a8f29235c1adf6256556c685cb89b9f":"6b5fd75ad16eda04a8b29f1bc0411ae28befbad9e474f2d8":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 248 count 2 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"8c35fb77766d04f48d5b52275c5c5f31f568078419e5c2335918965fbe53cedd":"bacccb1714dbaa4908c2654aa8dbb1ddbddd8ab819429b026619fb1c0fa75a8247372b2feeab1e1d":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +NIST KWP unwrap AES-256 CAVS 21.4 PLAINTEXT LENGTH = 4096 count 3 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"1726706350c11e6883955f24ea11ab247ce3b2ab54d05e67ad9770b5564483dd":"b006f26a67d0e1e2cbeb5c23b6b300adc1526d1f17bbe964fe8237ae244878158e6b04cb488786b5258ac973c3a2eafd7fcf3a7ca6c825155659fbc53d112bc78b3a770cf059fdd5e68f2b4bfa36de3721231102e5041c947fba3d906bff39592ec3901a398da23035f1190e99b58659330cc2e856ee87ad4197dcc7d16e1f062275bced1ed5cd82163ae3e58da7368dc2aadac855385bd4fa0b8baadef608d0a5c27172d12b88c70b136eeccf37f36364361a990dc50815743cab1636e661bff04ca8345520c30b935a060b450526b1d6ac09170e5b0a327b88f42327b85c9a621d2ca745963c2815a2bfcf509d50b6058ed6e67f369b5608d2aa885238b67d1b8e0d83f9464aa473bf109350fcc02e360c2619236cbfbf895b607895530d8d3d2e41450750dad05b1c37ef15db7fb4707597ac252e8e58d4c1ab2713b427643d198164c908b5d8ff36e9700157284009c7b283633d8b27b378bb65eff8aa59b5fe5e6437a1d53a99c106c2c4d033d3d23950e313a10eb31d68524ae9f8e4f56437acf66db3e8f77407a15bbff4b393e5559908993146d93c673d2aeb7d4cb8fc8d0169de7ed6e2bbe6ce9958a0f5d201419e7acb17e47da827ba380d6b3ad3b5a8c2101c5fb501110c727169065f23297947f538ab3ec165d61edc1f6a9e1735e9b7fc06d4d3406cf8f9c6a68b196cf262324a986705fbc802cdd2e6b4ebcf68e6bb9e793ae644":"":MBEDTLS_ERR_CIPHER_AUTH_FAILED + +KW AES-128 wrap rfc 3394 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"000102030405060708090A0B0C0D0E0F":"00112233445566778899AABBCCDDEEFF":"1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5" + +KW AES-192 wrap rfc 3394 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"000102030405060708090A0B0C0D0E0F1011121314151617":"00112233445566778899AABBCCDDEEFF":"96778B25AE6CA435F92B5B97C050AED2468AB8A17AD84E5D" + +KW AES-256 wrap rfc 3394 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F":"00112233445566778899AABBCCDDEEFF":"64E8C3F9CE0F5BA263E9777905818A2A93C8191E7D6E8AE7" + +KW AES-128 unwrap rfc 3394 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"000102030405060708090A0B0C0D0E0F":"1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5":"00112233445566778899AABBCCDDEEFF":0 + +KW AES-192 unwrap rfc 3394 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"000102030405060708090A0B0C0D0E0F1011121314151617":"031D33264E15D33268F24EC260743EDCE1C6C7DDEE725A936BA814915C6762D2":"00112233445566778899AABBCCDDEEFF0001020304050607":0 + +KW AES-256 unwrap rfc 3394 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_unwrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KW:"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F":"A8F9BC1612C68B3FF6E6F4FBE30E71E4769C8B80A32CB8958CD5D17D6B254DA1":"00112233445566778899AABBCCDDEEFF0001020304050607":0 + +KWP AES-192 wrap rfc 5649 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8":"c37b7e6492584340bed12207808941155068f738":"138bdeaa9b8fa7fc61f97742e72248ee5ae6ae5360d1ae6a5f54f373fa543b6a" + +KWP AES-192 wrap rfc 5649 +depends_on:MBEDTLS_AES_C +mbedtls_nist_kw_wrap:MBEDTLS_CIPHER_ID_AES:MBEDTLS_KW_MODE_KWP:"5840df6e29b02af1ab493b705bf16ea1ae8338f4dcc176a8":"466f7250617369":"afbeb0f07dfbf5419200f2ccb50bb24f" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_nist_kw.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_nist_kw.function new file mode 100644 index 0000000000..ae3ef80623 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_nist_kw.function @@ -0,0 +1,347 @@ +/* BEGIN_HEADER */ +#include "mbedtls/nist_kw.h" +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_NIST_KW_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST:MBEDTLS_AES_C */ +void mbedtls_nist_kw_self_test( ) +{ + TEST_ASSERT( mbedtls_nist_kw_self_test( 1 ) == 0 ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_AES_C */ +void mbedtls_nist_kw_mix_contexts( ) +{ + mbedtls_nist_kw_context ctx1, ctx2; + unsigned char key[16]; + unsigned char plaintext[32]; + unsigned char ciphertext1[40]; + unsigned char ciphertext2[40]; + size_t output_len, i; + + memset( plaintext, 0, sizeof( plaintext ) ); + memset( ciphertext1, 0, sizeof( ciphertext1 ) ); + memset( ciphertext2, 0, sizeof( ciphertext2 ) ); + memset( key, 0, sizeof( key ) ); + + /* + * 1. Check wrap and unwrap with two seperate contexts + */ + mbedtls_nist_kw_init( &ctx1 ); + mbedtls_nist_kw_init( &ctx2 ); + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx1, + MBEDTLS_CIPHER_ID_AES, + key, sizeof( key ) * 8, + 1 ) == 0 ); + + TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx1, MBEDTLS_KW_MODE_KW, + plaintext, sizeof( plaintext ), + ciphertext1, &output_len, + sizeof( ciphertext1 ) ) == 0 ); + TEST_ASSERT( output_len == sizeof( ciphertext1 ) ); + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx2, + MBEDTLS_CIPHER_ID_AES, + key, sizeof( key ) * 8, + 0 ) == 0 ); + + TEST_ASSERT( mbedtls_nist_kw_unwrap( &ctx2, MBEDTLS_KW_MODE_KW, + ciphertext1, output_len, + plaintext, &output_len, + sizeof( plaintext ) ) == 0 ); + + TEST_ASSERT( output_len == sizeof( plaintext ) ); + for( i = 0; i < sizeof( plaintext ); i++ ) + { + TEST_ASSERT( plaintext[i] == 0 ); + } + mbedtls_nist_kw_free( &ctx1 ); + mbedtls_nist_kw_free( &ctx2 ); + + /* + * 2. Check wrapping with two modes, on same context + */ + mbedtls_nist_kw_init( &ctx1 ); + mbedtls_nist_kw_init( &ctx2 ); + output_len = sizeof( ciphertext1 ); + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx1, + MBEDTLS_CIPHER_ID_AES, + key, sizeof( key ) * 8, + 1 ) == 0 ); + + TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx1, MBEDTLS_KW_MODE_KW, + plaintext, sizeof( plaintext ), + ciphertext1, &output_len, + sizeof( ciphertext1 ) ) == 0 ); + TEST_ASSERT( output_len == sizeof( ciphertext1 ) ); + + TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx1, MBEDTLS_KW_MODE_KWP, + plaintext, sizeof( plaintext ), + ciphertext2, &output_len, + sizeof( ciphertext2 ) ) == 0 ); + + TEST_ASSERT( output_len == sizeof( ciphertext2 ) ); + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx2, + MBEDTLS_CIPHER_ID_AES, + key, sizeof( key ) * 8, + 0 ) == 0 ); + + TEST_ASSERT( mbedtls_nist_kw_unwrap( &ctx2, MBEDTLS_KW_MODE_KW, + ciphertext1, sizeof( ciphertext1 ), + plaintext, &output_len, + sizeof( plaintext ) ) == 0 ); + + TEST_ASSERT( output_len == sizeof( plaintext ) ); + + for( i = 0; i < sizeof( plaintext ); i++ ) + { + TEST_ASSERT( plaintext[i] == 0 ); + } + + TEST_ASSERT( mbedtls_nist_kw_unwrap( &ctx2, MBEDTLS_KW_MODE_KWP, + ciphertext2, sizeof( ciphertext2 ), + plaintext, &output_len, + sizeof( plaintext ) ) == 0 ); + + TEST_ASSERT( output_len == sizeof( plaintext ) ); + + for( i = 0; i < sizeof( plaintext ); i++ ) + { + TEST_ASSERT( plaintext[i] == 0 ); + } + +exit: + mbedtls_nist_kw_free( &ctx1 ); + mbedtls_nist_kw_free( &ctx2 ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_nist_kw_setkey( int cipher_id, int key_size, + int is_wrap, int result ) +{ + mbedtls_nist_kw_context ctx; + unsigned char key[32]; + int ret; + + mbedtls_nist_kw_init( &ctx ); + + memset( key, 0x2A, sizeof( key ) ); + TEST_ASSERT( (unsigned) key_size <= 8 * sizeof( key ) ); + + ret = mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_size, is_wrap ); + TEST_ASSERT( ret == result ); + +exit: + mbedtls_nist_kw_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_AES_C */ +void nist_kw_plaintext_lengths( int in_len, int out_len, int mode, int res ) +{ + mbedtls_nist_kw_context ctx; + unsigned char key[16]; + unsigned char *plaintext = NULL; + unsigned char *ciphertext = NULL; + size_t output_len = out_len; + + mbedtls_nist_kw_init( &ctx ); + + memset( key, 0, sizeof( key ) ); + + if( in_len != 0 ) + { + plaintext = mbedtls_calloc( 1, in_len ); + TEST_ASSERT( plaintext != NULL ); + } + + if( out_len != 0 ) + { + ciphertext = mbedtls_calloc( 1, output_len ); + TEST_ASSERT( ciphertext != NULL ); + } + + memset( plaintext, 0, in_len ); + memset( ciphertext, 0, output_len ); + + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, + key, 8 * sizeof( key ), 1 ) == 0 ); + + TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx, mode, plaintext, in_len, + ciphertext, &output_len, + output_len ) == res ); + if( res == 0 ) + { + if( mode == MBEDTLS_KW_MODE_KWP ) + TEST_ASSERT( output_len == (size_t) in_len + 8 - + ( in_len % 8 ) + 8 ); + else + TEST_ASSERT( output_len == (size_t) in_len + 8 ); + } + else + { + TEST_ASSERT( output_len == 0 ); + } + +exit: + mbedtls_free( ciphertext ); + mbedtls_free( plaintext ); + mbedtls_nist_kw_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_AES_C */ +void nist_kw_ciphertext_lengths( int in_len, int out_len, int mode, int res ) +{ + mbedtls_nist_kw_context ctx; + unsigned char key[16]; + unsigned char *plaintext = NULL; + unsigned char *ciphertext = NULL; + int unwrap_ret; + size_t output_len = out_len; + + mbedtls_nist_kw_init( &ctx ); + + memset( key, 0, sizeof( key ) ); + + if( out_len != 0 ) + { + plaintext = mbedtls_calloc( 1, output_len ); + TEST_ASSERT( plaintext != NULL ); + } + if( in_len != 0 ) + { + ciphertext = mbedtls_calloc( 1, in_len ); + TEST_ASSERT( ciphertext != NULL ); + } + + memset( plaintext, 0, output_len ); + memset( ciphertext, 0, in_len ); + + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, MBEDTLS_CIPHER_ID_AES, + key, 8 * sizeof( key ), 0 ) == 0 ); + unwrap_ret = mbedtls_nist_kw_unwrap( &ctx, mode, ciphertext, in_len, + plaintext, &output_len, + output_len ); + + if( res == 0 ) + TEST_ASSERT( unwrap_ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED ); + else + TEST_ASSERT( unwrap_ret == res ); + + TEST_ASSERT( output_len == 0 ); + +exit: + mbedtls_free( ciphertext ); + mbedtls_free( plaintext ); + mbedtls_nist_kw_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_nist_kw_wrap( int cipher_id, int mode, + char *key_hex, char *msg_hex, + char *result_hex ) +{ + unsigned char key[32]; + unsigned char msg[512]; + unsigned char result[528]; + unsigned char expected_result[528]; + mbedtls_nist_kw_context ctx; + size_t key_len, msg_len, output_len, result_len, i, padlen; + + mbedtls_nist_kw_init( &ctx ); + + memset( key, 0x00, sizeof( key ) ); + memset( msg, 0x00, sizeof( msg ) ); + memset( result, '+', sizeof( result ) ); + + key_len = unhexify( key, key_hex ); + msg_len = unhexify( msg, msg_hex ); + result_len = unhexify( expected_result, result_hex ); + output_len = sizeof( result ); + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_len * 8, 1 ) + == 0 ); + + /* Test with input == output */ + TEST_ASSERT( mbedtls_nist_kw_wrap( &ctx, mode, msg, msg_len, + result, &output_len, sizeof( result ) ) == 0 ); + + TEST_ASSERT( output_len == result_len ); + + TEST_ASSERT( memcmp( expected_result, result, result_len ) == 0 ); + + padlen = ( msg_len % 8 != 0 ) ? 8 - (msg_len % 8 ) : 0; + /* Check that the function didn't write beyond the end of the buffer. */ + for( i = msg_len + 8 + padlen; i < sizeof( result ); i++ ) + { + TEST_ASSERT( result[i] == '+' ); + } + +exit: + mbedtls_nist_kw_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE */ +void mbedtls_nist_kw_unwrap( int cipher_id, int mode, + char *key_hex, char *msg_hex, + char *result_hex, int expected_ret ) +{ + unsigned char key[32]; + unsigned char msg[528]; + unsigned char result[528]; + unsigned char expected_result[528]; + mbedtls_nist_kw_context ctx; + size_t key_len, msg_len, output_len, result_len, i; + + mbedtls_nist_kw_init( &ctx ); + + memset( key, 0x00, sizeof( key ) ); + memset( msg, 0x00, sizeof( msg ) ); + memset( result, '+', sizeof( result ) ); + memset( expected_result, 0x00, sizeof( expected_result ) ); + + key_len = unhexify( key, key_hex ); + msg_len = unhexify( msg, msg_hex ); + result_len = unhexify( expected_result, result_hex ); + output_len = sizeof( result ); + + TEST_ASSERT( mbedtls_nist_kw_setkey( &ctx, cipher_id, key, key_len * 8, 0 ) + == 0 ); + + /* Test with input == output */ + TEST_ASSERT( mbedtls_nist_kw_unwrap( &ctx, mode, msg, msg_len, + result, &output_len, sizeof( result ) ) == expected_ret ); + if( expected_ret == 0 ) + { + TEST_ASSERT( output_len == result_len ); + TEST_ASSERT( memcmp( expected_result, result, result_len ) == 0 ); + } + else + { + TEST_ASSERT( output_len == 0 ); + } + + /* Check that the function didn't write beyond the end of the buffer. */ + for( i = msg_len - 8; i < sizeof( result ); i++ ) + { + TEST_ASSERT( result[i] == '+' ); + } + +exit: + mbedtls_nist_kw_free( &ctx ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pem.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pem.function index c24595d47c..947f1fb25d 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pem.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pem.function @@ -6,25 +6,21 @@ /* END_HEADER */ /* BEGIN_CASE depends_on:MBEDTLS_PEM_WRITE_C */ -void mbedtls_pem_write_buffer( char *start, char *end, char *buf_str, char *result_str ) +void mbedtls_pem_write_buffer( char * start, char * end, data_t * buf, + char * result_str ) { - unsigned char buf[5000]; unsigned char *check_buf = NULL; int ret; - size_t buf_len, olen = 0, olen2 = 0; + size_t olen = 0, olen2 = 0; - memset( buf, 0, sizeof( buf ) ); - buf_len = unhexify( buf, buf_str ); - - ret = mbedtls_pem_write_buffer( start, end, buf, buf_len, NULL, 0, &olen ); + ret = mbedtls_pem_write_buffer( start, end, buf->x, buf->len, NULL, 0, &olen ); TEST_ASSERT( ret == MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); check_buf = (unsigned char *) mbedtls_calloc( 1, olen ); TEST_ASSERT( check_buf != NULL ); - memset( check_buf, 0, olen ); - ret = mbedtls_pem_write_buffer( start, end, buf, buf_len, check_buf, olen, &olen2 ); + ret = mbedtls_pem_write_buffer( start, end, buf->x, buf->len, check_buf, olen, &olen2 ); TEST_ASSERT( olen2 <= olen ); TEST_ASSERT( olen > strlen( (char*) result_str ) ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.data index a066bd93e8..e41dfa7103 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.data @@ -1,3 +1,13 @@ +PK invalid parameters +invalid_parameters: + +PK valid parameters +valid_parameters: + +PK write valid parameters +depends_on:MBEDTLS_RSA_C +valid_parameters_pkwrite:"308204a20201000282010100a9021f3d406ad555538bfd36ee82652e15615e89bfb8e84590dbee881652d3f143504796125964876bfd2be046f973beddcf92e1915bed66a06f8929794580d0836ad54143775f397c09044782b0573970eda3ec15191ea8330847c10542a9fd4cc3b4dfdd061f4d1051406773130f40f86d81255f0ab153c6307e1539acf95aee7f929ea6055be7139785b52392d9d42406d50925897507dda61a8f3f0919bead652c64eb959bdcfe415e17a6da6c5b69cc02ba142c16249c4adccdd0f7526773f12da023fd7ef431ca2d70ca890b04db2ea64f706e9ecebd5889e253599e6e5a9265e2883f0c9419a3dde5e89d9513ed29dbab7012dc5aca6b17ab528254b10203010001028201001689f5e89142ae18a6ffb0513715a4b0b4a13b9e5b3729a2bd62d738c6e15cea7bf3a4d85ab2193a0628c9452bb1f0c1af8b132789df1c95e72778bf5330f5b0d915d242d5e0818e85001ed5fa93d1ce13455deb0a15438562e8e3c8d60ec1e4c9ebff9f2b36b9cde9332cc79f0d17a7ae79cc1353cd75409ad9b4b6d7ee3d82af6f3207656cf2ac98947c15c398db0cebf8dc3eef5398269480cdd09411b960273ae3f364da09af849f24aa87346c58618ea91d9d6cd1d3932c80dbfc1f0a4166a9036911999ca27761079f0ce02db02c1c909ff9b4278578d7bb1b54b2b7082fc9e864b6b394e331c0d11a9a68255565b6dd477f4119c5809839520700711102818100d7db987ad86de6a9b0749fb5da80bacde3bebd72dcc83f60a27db74f927ac3661386577bfce5b4a00ad024682401d6aad29713c8e223b53415305ca07559821099b187fdd1bad3dc4dec9da96f5fa6128331e8f7d89f1e1a788698d1a27256dc7cd392f04e531a9e38e7265bf4fd7eec01e7835e9b1a0dd8923e440381be1c2702818100c87025fff7a493c623404966fbc8b32ed164ca620ad1a0ad11ef42fd12118456017856a8b42e5d4ad36104e9dc9f8a2f3003c3957ffddb20e2f4e3fc3cf2cdddae01f57a56de4fd24b91ab6d3e5cc0e8af0473659594a6bbfdaacf958f19c8d508eac12d8977616af6877106288093d37904a139220c1bc278ea56edc086976702818043e708685c7cf5fa9b4f948e1856366d5e1f3a694f9a8e954f884c89f3823ac5798ee12657bfcaba2dac9c47464c6dc2fecc17a531be19da706fee336bb6e47b645dbc71d3eff9856bddeb1ac9b644ffbdd58d7ba9e1240f1faaf797ba8a4d58becbaf85789e1bd979fcfccc209d3db7f0416bc9eef09b3a6d86b8ce8199d4310281804f4b86ccffe49d0d8ace98fb63ea9f708b284ba483d130b6a75cb76cb4e4372d6b41774f20912319420ca4cbfc1b25a8cb5f01d6381f6ebc50ed3ef08010327f5ba2acc1ac7220b3fa6f7399314db2879b0db0b5647abd87abb01295815a5b086491b2c0d81c616ed67ef8a8ce0727f446711d7323d4147b5828a52143c43b4b028180540756beba83c20a0bda11d6dec706a71744ff28090cec079dffb507d82828038fe657f61496a20317f779cb683ce8196c29a6fe28839a282eef4de57773be56808b0c3e2ac7747e2b200b2fbf20b55258cd24622a1ce0099de098ab0855106ae087f08b0c8c346d81619400c1b4838e33ed9ff90f05db8fccf8fb7ab881ca12" + PK utils: RSA depends_on:MBEDTLS_RSA_C:MBEDTLS_GENPRIME pk_utils:MBEDTLS_PK_RSA:512:64:"RSA" @@ -153,3 +163,35 @@ mbedtls_pk_check_pair:"data_files/ec_256_pub.pem":"data_files/server1.key":MBEDT RSA hash_len overflow (size_t vs unsigned int) depends_on:MBEDTLS_RSA_C:MBEDTLS_HAVE_INT64 pk_rsa_overflow: + +ECDSA restartable sign/verify: ECDSA, max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECDSA:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":0:0:0 + +ECDSA restartable sign/verify: ECKEY, max_ops=0 (disabled) +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECKEY:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":0:0:0 + +ECDSA restartable sign/verify: ECDSA, max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECDSA:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":1:1:10000 + +ECDSA restartable sign/verify: ECKEY, max_ops=1 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECKEY:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":1:1:10000 + +ECDSA restartable sign/verify: ECDSA, max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECDSA:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":10000:0:0 + +ECDSA restartable sign/verify: ECKEY, max_ops=10000 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECKEY:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":10000:0:0 + +ECDSA restartable sign/verify: ECDSA, max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECDSA:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":250:2:64 + +ECDSA restartable sign/verify: ECKEY, max_ops=250 +depends_on:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C +pk_sign_verify_restart:MBEDTLS_PK_ECKEY:MBEDTLS_ECP_DP_SECP256R1:"C9AFA9D845BA75166B5C215767B1D6934E50C3DB36E89B127B8A622B120F6721":"60FED4BA255A9D31C961EB74C6356D68C049B8923B61FA6CE669622E60F29FB6":"7903FE1008B8BC99A41AE9E95628BC64F2F1B20C2D7E9F5177A3C294D4462299":MBEDTLS_MD_SHA256:"test":"3045022100f1abb023518351cd71d881567b1ea663ed3efcf6c5132b354f28d3b0b7d383670220019f4113742a2b14bd25926b49c649155f267e60d3814b4c0cc84250e46f0083":250:2:64 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.function index c0c987d5c3..4e6ab172c8 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pk.function @@ -2,6 +2,8 @@ #include "mbedtls/pk.h" /* For error codes */ +#include "mbedtls/asn1.h" +#include "mbedtls/base64.h" #include "mbedtls/ecp.h" #include "mbedtls/rsa.h" @@ -70,7 +72,427 @@ size_t mbedtls_rsa_key_len_func( void *ctx ) */ /* BEGIN_CASE */ -void pk_utils( int type, int size, int len, char *name ) +void valid_parameters( ) +{ + mbedtls_pk_context pk; + unsigned char buf[1]; + size_t len; + void *options = NULL; + + mbedtls_pk_init( &pk ); + + TEST_VALID_PARAM( mbedtls_pk_free( NULL ) ); + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + TEST_VALID_PARAM( mbedtls_pk_restart_free( NULL ) ); +#endif + + TEST_ASSERT( mbedtls_pk_setup( &pk, NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + /* In informational functions, we accept NULL where a context pointer + * is expected because that's what the library has done forever. + * We do not document that NULL is accepted, so we may wish to change + * the behavior in a future version. */ + TEST_ASSERT( mbedtls_pk_get_bitlen( NULL ) == 0 ); + TEST_ASSERT( mbedtls_pk_get_len( NULL ) == 0 ); + TEST_ASSERT( mbedtls_pk_can_do( NULL, MBEDTLS_PK_NONE ) == 0 ); + + TEST_ASSERT( mbedtls_pk_sign_restartable( &pk, + MBEDTLS_MD_NONE, + NULL, 0, + buf, &len, + rnd_std_rand, NULL, + NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_sign_restartable( &pk, + MBEDTLS_MD_NONE, + NULL, 0, + buf, &len, + rnd_std_rand, NULL, + NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_sign( &pk, + MBEDTLS_MD_NONE, + NULL, 0, + buf, &len, + rnd_std_rand, NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_verify_restartable( &pk, + MBEDTLS_MD_NONE, + NULL, 0, + buf, sizeof( buf ), + NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_verify( &pk, + MBEDTLS_MD_NONE, + NULL, 0, + buf, sizeof( buf ) ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options, + &pk, + MBEDTLS_MD_NONE, + NULL, 0, + buf, sizeof( buf ) ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_encrypt( &pk, + NULL, 0, + NULL, &len, 0, + rnd_std_rand, NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + + TEST_ASSERT( mbedtls_pk_decrypt( &pk, + NULL, 0, + NULL, &len, 0, + rnd_std_rand, NULL ) == + MBEDTLS_ERR_PK_BAD_INPUT_DATA ); + +#if defined(MBEDTLS_PK_PARSE_C) + TEST_ASSERT( mbedtls_pk_parse_key( &pk, NULL, 0, NULL, 1 ) == + MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); + + TEST_ASSERT( mbedtls_pk_parse_public_key( &pk, NULL, 0 ) == + MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); +#endif /* MBEDTLS_PK_PARSE_C */ +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_PK_WRITE_C */ +void valid_parameters_pkwrite( data_t *key_data ) +{ + mbedtls_pk_context pk; + + /* For the write tests to be effective, we need a valid key pair. */ + mbedtls_pk_init( &pk ); + TEST_ASSERT( mbedtls_pk_parse_key( &pk, + key_data->x, key_data->len, + NULL, 0 ) == 0 ); + + TEST_ASSERT( mbedtls_pk_write_key_der( &pk, NULL, 0 ) == + MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + + TEST_ASSERT( mbedtls_pk_write_pubkey_der( &pk, NULL, 0 ) == + MBEDTLS_ERR_ASN1_BUF_TOO_SMALL ); + +#if defined(MBEDTLS_PEM_WRITE_C) + TEST_ASSERT( mbedtls_pk_write_key_pem( &pk, NULL, 0 ) == + MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); + + TEST_ASSERT( mbedtls_pk_write_pubkey_pem( &pk, NULL, 0 ) == + MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL ); +#endif /* MBEDTLS_PEM_WRITE_C */ + +exit: + mbedtls_pk_free( &pk ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void invalid_parameters( ) +{ + size_t len; + unsigned char *null_buf = NULL; + unsigned char buf[1]; + unsigned char *p = buf; + char str[1] = {0}; + mbedtls_pk_context pk; + mbedtls_md_type_t valid_md = MBEDTLS_MD_SHA256; + void *options = buf; + + (void) null_buf; + (void) p; + (void) str; + + mbedtls_pk_init( &pk ); + + TEST_INVALID_PARAM( mbedtls_pk_init( NULL ) ); + +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + TEST_INVALID_PARAM( mbedtls_pk_restart_init( NULL ) ); +#endif + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_setup( NULL, NULL ) ); + +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_setup_rsa_alt( NULL, buf, + NULL, NULL, NULL ) ); +#endif + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_restartable( NULL, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + buf, sizeof( buf ), + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_restartable( &pk, + MBEDTLS_MD_NONE, + NULL, sizeof( buf ), + buf, sizeof( buf ), + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_restartable( &pk, + valid_md, + NULL, 0, + buf, sizeof( buf ), + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_restartable( &pk, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + NULL, sizeof( buf ), + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify( NULL, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify( &pk, + MBEDTLS_MD_NONE, + NULL, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify( &pk, + valid_md, + NULL, 0, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify( &pk, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options, + NULL, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options, + &pk, + MBEDTLS_MD_NONE, + NULL, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options, + &pk, + valid_md, + NULL, 0, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_verify_ext( MBEDTLS_PK_NONE, options, + &pk, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign_restartable( NULL, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + buf, &len, + rnd_std_rand, NULL, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign_restartable( &pk, + MBEDTLS_MD_NONE, + NULL, sizeof( buf ), + buf, &len, + rnd_std_rand, NULL, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign_restartable( &pk, + valid_md, + NULL, 0, + buf, &len, + rnd_std_rand, NULL, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign_restartable( &pk, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + NULL, &len, + rnd_std_rand, NULL, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign( NULL, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + buf, &len, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign( &pk, + MBEDTLS_MD_NONE, + NULL, sizeof( buf ), + buf, &len, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign( &pk, + valid_md, + NULL, 0, + buf, &len, + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_sign( &pk, + MBEDTLS_MD_NONE, + buf, sizeof( buf ), + NULL, &len, + rnd_std_rand, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_decrypt( NULL, + buf, sizeof( buf ), + buf, &len, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_decrypt( &pk, + NULL, sizeof( buf ), + buf, &len, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_decrypt( &pk, + buf, sizeof( buf ), + NULL, &len, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_decrypt( &pk, + buf, sizeof( buf ), + buf, NULL, sizeof( buf ), + rnd_std_rand, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_encrypt( NULL, + buf, sizeof( buf ), + buf, &len, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_encrypt( &pk, + NULL, sizeof( buf ), + buf, &len, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_encrypt( &pk, + buf, sizeof( buf ), + NULL, &len, sizeof( buf ), + rnd_std_rand, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_encrypt( &pk, + buf, sizeof( buf ), + buf, NULL, sizeof( buf ), + rnd_std_rand, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_check_pair( NULL, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_check_pair( &pk, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_debug( NULL, NULL ) ); + +#if defined(MBEDTLS_PK_PARSE_C) +#if defined(MBEDTLS_FS_IO) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_load_file( NULL, &p, &len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_load_file( str, NULL, &len ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_load_file( str, &p, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_keyfile( NULL, str, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_keyfile( &pk, NULL, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_public_keyfile( NULL, str ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_public_keyfile( &pk, NULL ) ); +#endif + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_subpubkey( NULL, buf, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_subpubkey( &null_buf, buf, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_subpubkey( &p, NULL, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_subpubkey( &p, buf, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_key( NULL, + buf, sizeof( buf ), + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_key( &pk, + NULL, sizeof( buf ), + buf, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_public_key( NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_parse_public_key( &pk, + NULL, sizeof( buf ) ) ); +#endif /* MBEDTLS_PK_PARSE_C */ + +#if defined(MBEDTLS_PK_WRITE_C) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey( NULL, p, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey( &null_buf, p, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey( &p, NULL, &pk ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey( &p, p, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey_der( NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey_der( &pk, + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_key_der( NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_key_der( &pk, + NULL, sizeof( buf ) ) ); + +#if defined(MBEDTLS_PEM_WRITE_C) + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey_pem( NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_pubkey_pem( &pk, + NULL, sizeof( buf ) ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_key_pem( NULL, + buf, sizeof( buf ) ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA, + mbedtls_pk_write_key_pem( &pk, + NULL, sizeof( buf ) ) ); +#endif /* MBEDTLS_PEM_WRITE_C */ + +#endif /* MBEDTLS_PK_WRITE_C */ +} +/* END_CASE */ + +/* BEGIN_CASE */ +void pk_utils( int type, int size, int len, char * name ) { mbedtls_pk_context pk; @@ -91,7 +513,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_PK_PARSE_C:MBEDTLS_FS_IO */ -void mbedtls_pk_check_pair( char *pub_file, char *prv_file, int ret ) +void mbedtls_pk_check_pair( char * pub_file, char * prv_file, int ret ) { mbedtls_pk_context pub, prv, alt; @@ -121,22 +543,27 @@ void mbedtls_pk_check_pair( char *pub_file, char *prv_file, int ret ) /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ -void pk_rsa_verify_test_vec( char *message_hex_string, int digest, - int mod, int radix_N, char *input_N, int radix_E, - char *input_E, char *result_hex_str, int result ) +void pk_rsa_verify_test_vec( data_t * message_str, int digest, int mod, + int radix_N, char * input_N, int radix_E, + char * input_E, data_t * result_str, + int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; - unsigned char result_str[1000]; mbedtls_rsa_context *rsa; mbedtls_pk_context pk; - int msg_len; + mbedtls_pk_restart_ctx *rs_ctx = NULL; +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_pk_restart_ctx ctx; + + rs_ctx = &ctx; + mbedtls_pk_restart_init( rs_ctx ); + // this setting would ensure restart would happen if ECC was used + mbedtls_ecp_set_max_ops( 1 ); +#endif mbedtls_pk_init( &pk ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 ); rsa = mbedtls_pk_rsa( pk ); @@ -145,42 +572,41 @@ void pk_rsa_verify_test_vec( char *message_hex_string, int digest, TEST_ASSERT( mbedtls_mpi_read_string( &rsa->N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - unhexify( result_str, result_hex_str ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); TEST_ASSERT( mbedtls_pk_verify( &pk, digest, hash_result, 0, - result_str, mbedtls_pk_get_len( &pk ) ) == result ); + result_str->x, mbedtls_pk_get_len( &pk ) ) == result ); + + TEST_ASSERT( mbedtls_pk_verify_restartable( &pk, digest, hash_result, 0, + result_str->x, mbedtls_pk_get_len( &pk ), rs_ctx ) == result ); exit: +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_pk_restart_free( rs_ctx ); +#endif mbedtls_pk_free( &pk ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ -void pk_rsa_verify_ext_test_vec( char *message_hex_string, int digest, - int mod, int radix_N, char *input_N, int radix_E, - char *input_E, char *result_hex_str, - int pk_type, int mgf1_hash_id, int salt_len, - int result ) +void pk_rsa_verify_ext_test_vec( data_t * message_str, int digest, + int mod, int radix_N, char * input_N, + int radix_E, char * input_E, + data_t * result_str, int pk_type, + int mgf1_hash_id, int salt_len, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; - unsigned char result_str[1000]; mbedtls_rsa_context *rsa; mbedtls_pk_context pk; mbedtls_pk_rsassa_pss_options pss_opts; void *options; - int msg_len; size_t hash_len; mbedtls_pk_init( &pk ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 ); rsa = mbedtls_pk_rsa( pk ); @@ -189,19 +615,17 @@ void pk_rsa_verify_ext_test_vec( char *message_hex_string, int digest, TEST_ASSERT( mbedtls_mpi_read_string( &rsa->N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - unhexify( result_str, result_hex_str ); if( digest != MBEDTLS_MD_NONE ) { TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), - message_str, msg_len, hash_result ) == 0 ); + message_str->x, message_str->len, hash_result ) == 0 ); hash_len = 0; } else { - memcpy( hash_result, message_str, msg_len ); - hash_len = msg_len; + memcpy( hash_result, message_str->x, message_str->len ); + hash_len = message_str->len; } if( mgf1_hash_id < 0 ) @@ -218,7 +642,7 @@ void pk_rsa_verify_ext_test_vec( char *message_hex_string, int digest, TEST_ASSERT( mbedtls_pk_verify_ext( pk_type, options, &pk, digest, hash_result, hash_len, - result_str, mbedtls_pk_get_len( &pk ) ) == result ); + result_str->x, mbedtls_pk_get_len( &pk ) ) == result ); exit: mbedtls_pk_free( &pk ); @@ -226,19 +650,14 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ECDSA_C */ -void pk_ec_test_vec( int type, int id, char *key_str, - char *hash_str, char * sig_str, int ret ) +void pk_ec_test_vec( int type, int id, data_t * key, data_t * hash, + data_t * sig, int ret ) { mbedtls_pk_context pk; mbedtls_ecp_keypair *eckey; - unsigned char hash[100], sig[500], key[500]; - size_t hash_len, sig_len, key_len; mbedtls_pk_init( &pk ); - memset( hash, 0, sizeof( hash ) ); hash_len = unhexify(hash, hash_str); - memset( sig, 0, sizeof( sig ) ); sig_len = unhexify(sig, sig_str); - memset( key, 0, sizeof( key ) ); key_len = unhexify(key, key_str); TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( type ) ) == 0 ); @@ -247,22 +666,135 @@ void pk_ec_test_vec( int type, int id, char *key_str, TEST_ASSERT( mbedtls_ecp_group_load( &eckey->grp, id ) == 0 ); TEST_ASSERT( mbedtls_ecp_point_read_binary( &eckey->grp, &eckey->Q, - key, key_len ) == 0 ); + key->x, key->len ) == 0 ); TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_NONE, - hash, hash_len, sig, sig_len ) == ret ); + hash->x, hash->len, sig->x, sig->len ) == ret ); exit: mbedtls_pk_free( &pk ); } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_ECP_RESTARTABLE:MBEDTLS_ECDSA_C:MBEDTLS_ECDSA_DETERMINISTIC */ +void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str, + char *QX_str, char *QY_str, + int md_alg, char *msg, char *sig_str, + int max_ops, int min_restart, int max_restart ) +{ + int ret, cnt_restart; + mbedtls_pk_restart_ctx rs_ctx; + mbedtls_pk_context prv, pub; + unsigned char hash[MBEDTLS_MD_MAX_SIZE]; + unsigned char sig[MBEDTLS_ECDSA_MAX_LEN]; + unsigned char sig_check[MBEDTLS_ECDSA_MAX_LEN]; + size_t hlen, slen, slen_check; + const mbedtls_md_info_t *md_info; + + mbedtls_pk_restart_init( &rs_ctx ); + mbedtls_pk_init( &prv ); + mbedtls_pk_init( &pub ); + memset( hash, 0, sizeof( hash ) ); + memset( sig, 0, sizeof( sig ) ); + memset( sig_check, 0, sizeof( sig_check ) ); + + TEST_ASSERT( mbedtls_pk_setup( &prv, mbedtls_pk_info_from_type( pk_type ) ) == 0 ); + TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( prv )->grp, grp_id ) == 0 ); + TEST_ASSERT( mbedtls_mpi_read_string( &mbedtls_pk_ec( prv )->d, 16, d_str ) == 0 ); + + TEST_ASSERT( mbedtls_pk_setup( &pub, mbedtls_pk_info_from_type( pk_type ) ) == 0 ); + TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( pub )->grp, grp_id ) == 0 ); + TEST_ASSERT( mbedtls_ecp_point_read_string( &mbedtls_pk_ec( pub )->Q, 16, QX_str, QY_str ) == 0 ); + + slen_check = unhexify( sig_check, sig_str ); + + md_info = mbedtls_md_info_from_type( md_alg ); + TEST_ASSERT( md_info != NULL ); + + hlen = mbedtls_md_get_size( md_info ); + mbedtls_md( md_info, (const unsigned char *) msg, strlen( msg ), hash ); + + mbedtls_ecp_set_max_ops( max_ops ); + + slen = sizeof( sig ); + cnt_restart = 0; + do { + ret = mbedtls_pk_sign_restartable( &prv, md_alg, hash, hlen, + sig, &slen, NULL, NULL, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( slen == slen_check ); + TEST_ASSERT( memcmp( sig, sig_check, slen ) == 0 ); + + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + cnt_restart = 0; + do { + ret = mbedtls_pk_verify_restartable( &pub, md_alg, + hash, hlen, sig, slen, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == 0 ); + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + hash[0]++; + do { + ret = mbedtls_pk_verify_restartable( &pub, md_alg, + hash, hlen, sig, slen, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + TEST_ASSERT( ret != 0 ); + hash[0]--; + + sig[0]++; + do { + ret = mbedtls_pk_verify_restartable( &pub, md_alg, + hash, hlen, sig, slen, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + TEST_ASSERT( ret != 0 ); + sig[0]--; + + /* Do we leak memory when aborting? try verify then sign + * This test only makes sense when we actually restart */ + if( min_restart > 0 ) + { + ret = mbedtls_pk_verify_restartable( &pub, md_alg, + hash, hlen, sig, slen, &rs_ctx ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + mbedtls_pk_restart_free( &rs_ctx ); + + slen = sizeof( sig ); + ret = mbedtls_pk_sign_restartable( &prv, md_alg, hash, hlen, + sig, &slen, NULL, NULL, &rs_ctx ); + TEST_ASSERT( ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + } + +exit: + mbedtls_pk_restart_free( &rs_ctx ); + mbedtls_pk_free( &prv ); + mbedtls_pk_free( &pub ); +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */ void pk_sign_verify( int type, int sign_ret, int verify_ret ) { mbedtls_pk_context pk; unsigned char hash[50], sig[5000]; size_t sig_len; + void *rs_ctx = NULL; +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_pk_restart_ctx ctx; + + rs_ctx = &ctx; + mbedtls_pk_restart_init( rs_ctx ); + /* This value is large enough that the operation will complete in one run. + * See comments at the top of ecp_test_vect_restart in + * test_suite_ecp.function for estimates of operation counts. */ + mbedtls_ecp_set_max_ops( 42000 ); +#endif mbedtls_pk_init( &pk ); @@ -272,38 +804,67 @@ void pk_sign_verify( int type, int sign_ret, int verify_ret ) TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( type ) ) == 0 ); TEST_ASSERT( pk_genkey( &pk ) == 0 ); - TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash, - sig, &sig_len, rnd_std_rand, NULL ) == sign_ret ); + TEST_ASSERT( mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_SHA256, + hash, sizeof hash, sig, &sig_len, + rnd_std_rand, NULL, rs_ctx ) == sign_ret ); TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash, sig, sig_len ) == verify_ret ); + if( verify_ret == 0 ) + { + hash[0]++; + TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256, + hash, sizeof hash, sig, sig_len ) != 0 ); + hash[0]--; + + sig[0]++; + TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_SHA256, + hash, sizeof hash, sig, sig_len ) != 0 ); + sig[0]--; + } + + TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash, + sig, &sig_len, rnd_std_rand, NULL ) == sign_ret ); + + TEST_ASSERT( mbedtls_pk_verify_restartable( &pk, MBEDTLS_MD_SHA256, + hash, sizeof hash, sig, sig_len, rs_ctx ) == verify_ret ); + + if( verify_ret == 0 ) + { + hash[0]++; + TEST_ASSERT( mbedtls_pk_verify_restartable( &pk, MBEDTLS_MD_SHA256, + hash, sizeof hash, sig, sig_len, rs_ctx ) != 0 ); + hash[0]--; + + sig[0]++; + TEST_ASSERT( mbedtls_pk_verify_restartable( &pk, MBEDTLS_MD_SHA256, + hash, sizeof hash, sig, sig_len, rs_ctx ) != 0 ); + sig[0]--; + } + exit: +#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) + mbedtls_pk_restart_free( rs_ctx ); +#endif mbedtls_pk_free( &pk ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ -void pk_rsa_encrypt_test_vec( char *message_hex, int mod, - int radix_N, char *input_N, - int radix_E, char *input_E, - char *result_hex, int ret ) +void pk_rsa_encrypt_test_vec( data_t * message, int mod, int radix_N, + char * input_N, int radix_E, char * input_E, + data_t * result, int ret ) { - unsigned char message[1000]; unsigned char output[1000]; - unsigned char result[1000]; - size_t msg_len, olen, res_len; rnd_pseudo_info rnd_info; mbedtls_rsa_context *rsa; mbedtls_pk_context pk; + size_t olen; memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); - memset( message, 0, sizeof( message ) ); memset( output, 0, sizeof( output ) ); - memset( result, 0, sizeof( result ) ); - msg_len = unhexify( message, message_hex ); - res_len = unhexify( result, result_hex ); mbedtls_pk_init( &pk ); TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 ); @@ -313,11 +874,11 @@ void pk_rsa_encrypt_test_vec( char *message_hex, int mod, TEST_ASSERT( mbedtls_mpi_read_string( &rsa->N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 ); - TEST_ASSERT( mbedtls_pk_encrypt( &pk, message, msg_len, + TEST_ASSERT( mbedtls_pk_encrypt( &pk, message->x, message->len, output, &olen, sizeof( output ), rnd_pseudo_rand, &rnd_info ) == ret ); - TEST_ASSERT( olen == res_len ); - TEST_ASSERT( memcmp( output, result, olen ) == 0 ); + TEST_ASSERT( olen == result->len ); + TEST_ASSERT( memcmp( output, result->x, olen ) == 0 ); exit: mbedtls_pk_free( &pk ); @@ -325,32 +886,24 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ -void pk_rsa_decrypt_test_vec( char *cipher_hex, int mod, - int radix_P, char *input_P, - int radix_Q, char *input_Q, - int radix_N, char *input_N, - int radix_E, char *input_E, - char *clear_hex, int ret ) +void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P, + char * input_P, int radix_Q, char * input_Q, + int radix_N, char * input_N, int radix_E, + char * input_E, data_t * clear, int ret ) { - unsigned char clear[1000]; unsigned char output[1000]; - unsigned char cipher[1000]; - size_t clear_len, olen, cipher_len; rnd_pseudo_info rnd_info; mbedtls_mpi N, P, Q, E; mbedtls_rsa_context *rsa; mbedtls_pk_context pk; + size_t olen; mbedtls_pk_init( &pk ); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); - memset( clear, 0, sizeof( clear ) ); - memset( cipher, 0, sizeof( cipher ) ); - clear_len = unhexify( clear, clear_hex ); - cipher_len = unhexify( cipher, cipher_hex ); /* init pk-rsa context */ TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == 0 ); @@ -370,13 +923,13 @@ void pk_rsa_decrypt_test_vec( char *cipher_hex, int mod, /* decryption test */ memset( output, 0, sizeof( output ) ); olen = 0; - TEST_ASSERT( mbedtls_pk_decrypt( &pk, cipher, cipher_len, + TEST_ASSERT( mbedtls_pk_decrypt( &pk, cipher->x, cipher->len, output, &olen, sizeof( output ), rnd_pseudo_rand, &rnd_info ) == ret ); if( ret == 0 ) { - TEST_ASSERT( olen == clear_len ); - TEST_ASSERT( memcmp( output, clear, olen ) == 0 ); + TEST_ASSERT( olen == clear->len ); + TEST_ASSERT( memcmp( output, clear->x, olen ) == 0 ); } exit: @@ -453,7 +1006,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_PK_RSA_ALT_SUPPORT */ -void pk_rsa_alt( ) +void pk_rsa_alt( ) { /* * An rsa_alt context can only do private operations (decrypt, sign). diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v15.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v15.function index 2b9cf297ae..0723623a5f 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v15.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v15.function @@ -9,28 +9,22 @@ */ /* BEGIN_CASE */ -void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char *input_N, int radix_E, - char *input_E, int hash, - char *message_hex_string, char *seed, - char *result_hex_str, int result ) +void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N, + int radix_E, char * input_E, int hash, + data_t * message_str, data_t * rnd_buf, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; - unsigned char rnd_buf[1000]; mbedtls_rsa_context ctx; - size_t msg_len; rnd_buf_info info; mbedtls_mpi N, E; - info.length = unhexify( rnd_buf, seed ); - info.buf = rnd_buf; + info.buf = rnd_buf->x; + info.length = rnd_buf->len; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -38,14 +32,12 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char *input_N, int radix_E, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, msg_len, message_str, output ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -55,15 +47,14 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char *input_P, - int radix_Q, char *input_Q, int radix_N, - char *input_N, int radix_E, char *input_E, - int hash, char *result_hex_str, char *seed, - char *message_hex_string, int result ) +void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P, + int radix_Q, char * input_Q, int radix_N, + char * input_N, int radix_E, char * input_E, + int hash, data_t * result_hex_str, + char * seed, data_t * message_str, + int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; size_t output_len; rnd_pseudo_info rnd_info; @@ -74,9 +65,7 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char *input_P, mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); @@ -89,14 +78,12 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char *input_P, TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); - TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str, output, 1000 ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, 1000 ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strncasecmp( (char *) output_str, result_hex_str, strlen( result_hex_str ) ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len) == 0 ); } exit: @@ -108,12 +95,11 @@ exit: /* BEGIN_CASE */ void pkcs1_v15_decode( int mode, - char *input_hex, + data_t *input, int expected_plaintext_length_arg, int output_size_arg, int expected_result ) { - size_t input_len; size_t expected_plaintext_length = expected_plaintext_length_arg; size_t output_size = output_size_arg; rnd_pseudo_info rnd_info; @@ -196,8 +182,9 @@ void pkcs1_v15_decode( int mode, NULL, &Empi ) == 0 ); TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); - input_len = unhexify( original, input_hex ); - memset( original + input_len, 'd', sizeof( original ) - input_len ); + TEST_ASSERT( input->len <= sizeof( N ) ); + memcpy( original, input->x, input->len ); + memset( original + input->len, 'd', sizeof( original ) - input->len ); if( mode == MBEDTLS_RSA_PRIVATE ) TEST_ASSERT( mbedtls_rsa_public( &ctx, original, intermediate ) == 0 ); else @@ -255,33 +242,27 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsassa_v15_sign( int mod, int radix_P, char *input_P, int radix_Q, - char *input_Q, int radix_N, char *input_N, - int radix_E, char *input_E, int digest, int hash, - char *message_hex_string, char *salt, - char *result_hex_str, int result ) +void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q, + char * input_Q, int radix_N, char * input_N, + int radix_E, char * input_E, int digest, int hash, + data_t * message_str, data_t * rnd_buf, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; - unsigned char rnd_buf[1000]; mbedtls_rsa_context ctx; mbedtls_mpi N, P, Q, E; - size_t msg_len; rnd_buf_info info; - info.length = unhexify( rnd_buf, salt ); - info.buf = rnd_buf; + info.buf = rnd_buf->x; + info.length = rnd_buf->len; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 ); @@ -293,17 +274,15 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char *input_P, int radix_Q, TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PRIVATE, digest, 0, hash_result, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -314,24 +293,19 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsassa_v15_verify( int mod, int radix_N, char *input_N, int radix_E, - char *input_E, int digest, int hash, - char *message_hex_string, char *salt, - char *result_hex_str, int result ) +void pkcs1_rsassa_v15_verify( int mod, int radix_N, char * input_N, + int radix_E, char * input_E, int digest, + int hash, data_t * message_str, char * salt, + data_t * result_str, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; - unsigned char result_str[1000]; mbedtls_rsa_context ctx; - size_t msg_len; mbedtls_mpi N, E; ((void) salt); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, hash ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -339,16 +313,11 @@ void pkcs1_rsassa_v15_verify( int mod, int radix_N, char *input_N, int radix_E, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - unhexify( result_str, result_hex_str ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), - message_str, msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); - TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, - digest, 0, hash_result, - result_str ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str->x ) == result ); exit: mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.data index 6258c62624..291c305a95 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.data @@ -376,8 +376,17 @@ pkcs1_rsassa_pss_sign:1024:16:"d17f655bf27c8b16d35462c905cc04a26f37e2a67fa9c0ce0 RSASSA-PSS Verification Test Vector Int pkcs1_rsassa_pss_verify:1024:16:"a2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5":16:"010001":MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:"859eef2fd78aca00308bdc471193bf55bf9d78db8f8a672b484634f3c9c26e6478ae10260fe0dd8c082e53a5293af2173cd50c6d5d354febf78b26021c25c02712e78cd4694c9f469777e451e7f8e9e04cd3739c6bbfedae487fb55644e9ca74ff77a53cb729802f6ed4a5ffa8ba159890fc":"e3b5d5d002c1bce50c2b65ef88a188d83bce7e61":"8daa627d3de7595d63056c7ec659e54406f10610128baae821c8b2a0f3936d54dc3bdce46689f6b7951bb18e840542769718d5715d210d85efbb596192032c42be4c29972c856275eb6d5a45f05f51876fc6743deddd28caec9bb30ea99e02c3488269604fe497f74ccd7c7fca1671897123cbd30def5d54a2b5536ad90a747e":0 -RSASSA-PSS Signing Test Vector Hash too large -pkcs1_rsassa_pss_sign:1024:16:"d17f655bf27c8b16d35462c905cc04a26f37e2a67fa9c0ce0dced472394a0df743fe7f929e378efdb368eddff453cf007af6d948e0ade757371f8a711e278f6b":16:"c6d92b6fee7414d1358ce1546fb62987530b90bd15e0f14963a5e2635adb69347ec0c01b2ab1763fd8ac1a592fb22757463a982425bb97a3a437c5bf86d03f2f":16:"a2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5":16:"010001":MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA512:"d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd00":"e3b5d5d002c1bce50c2b65ef88a188d83bce7e61":"":MBEDTLS_ERR_RSA_BAD_INPUT_DATA +RSASSA-PSS Signature RSA-1016, SHA-512: minimum salt size not met +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:1016:16:"0e3cb6845e528229e19cfb24611e6859ac1cea7d35992b6e2e796823c52affa03400e42830f90697f084499c3e3587defc19e749e72433dd7b70c28b0c8280b7":16:"0c48f9e45ae38fdb4a5143be37d79a10cd4f1f9782ef26a4848a4449c72cfd712c68350818736385cb4a9ab6db5aef8e96c551039cfcc8915821aee069ed660d":16:"00aee7874a4db2f1510044405db29f14df0f37bbcf61fcbcc994a3d31caaf858a74cc8f2a40ac9a9ce7aa9a0680f62cf9d8d4b827114533fdbf86f16fc9dfe5cbf857d86135519a4611ffc59cb7473861619a78e3ec314715e804cff82d6f32e9f57ddf390563629883bd34f40e8db413209b151cee97d817a5d65c7da54734b":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd00":"e3b5d5d002c1bce50c2b65ef88a188d83bce7e61":"":MBEDTLS_ERR_RSA_BAD_INPUT_DATA + +RSASSA-PSS Signature RSA-520, SHA-512: no possible salt size +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:520:16:"0feea5f6220fac291b9508ec2ba8ed281eb39aee4d5dc693254106816ebc700ecf":16:"0d68918785c3aafe31eaaa2d8d8156dce645940ff7734a457337a51bd00bc88811":16:"00d5a06f86e5b9d87428540165ca966fa8893a62e2a59d0bfd7617780bb039f9165a373a8e119d0766f8de556710f33f67019153bad8223775e797d451d48206f3bf":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd00":"e3b5d5d002c1bce50c2b65ef88a188d83bce7e61":"":MBEDTLS_ERR_RSA_BAD_INPUT_DATA + +RSASSA-PSS Signature RSA-528, SHA-512: zero salt size +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:528:16:"00d272aa28ed2085ac6df3c05c6719eed5deb618afa2e4ca4a6f7330b430ad48672d":16:"00c578836bab27145db9dd66f17470b62d4a6100f8ca0dedf457ee3639c3b9596325":16:"00a2554eba715bf66e5ecdf3d6d718e3e5d907e8666e7bf5a76b415106e04eb827ec4cb2199cff66491d45419082059aa5b54b0cf5eef4443402f3047c0b0e6f025081":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd32a7c8a05bbc90d32c49d436e99569fd00":"e3b5d5d002c1bce50c2b65ef88a188d83bce7e61":"":MBEDTLS_ERR_RSA_BAD_INPUT_DATA RSASSA-PSS Signature Example 1_1 pkcs1_rsassa_pss_sign:1024:16:"e7e8942720a877517273a356053ea2a1bc0c94aa72d55c6e86296b2dfc967948c0a72cbccca7eacb35706e09a1df55a1535bd9b3cc34160b3b6dcd3eda8e6443":16:"b69dca1cf7d4d7ec81e75b90fcca874abcde123fd2700180aa90479b6e48de8d67ed24f9f19d85ba275874f542cd20dc723e6963364a1f9425452b269a6799fd":16:"a56e4a0e701017589a5187dc7ea841d156f2ec0e36ad52a44dfeb1e61f7ad991d8c51056ffedb162b4c0f283a12a88a394dff526ab7291cbb307ceabfce0b1dfd5cd9508096d5b2b8b6df5d671ef6377c0921cb23c270a70e2598e6ff89d19f105acc2d3f0cb35f29280e1386b6f64c4ef22e1e1f20d0ce8cffb2249bd9a2137":16:"010001":MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:"cdc87da223d786df3b45e0bbbc721326d1ee2af806cc315475cc6f0d9c66e1b62371d45ce2392e1ac92844c310102f156a0d8d52c1f4c40ba3aa65095786cb769757a6563ba958fed0bcc984e8b517a3d5f515b23b8a41e74aa867693f90dfb061a6e86dfaaee64472c00e5f20945729cbebe77f06ce78e08f4098fba41f9d6193c0317e8b60d4b6084acb42d29e3808a3bc372d85e331170fcbf7cc72d0b71c296648b3a4d10f416295d0807aa625cab2744fd9ea8fd223c42537029828bd16be02546f130fd2e33b936d2676e08aed1b73318b750a0167d0":"dee959c7e06411361420ff80185ed57f3e6776af":"9074308fb598e9701b2294388e52f971faac2b60a5145af185df5287b5ed2887e57ce7fd44dc8634e407c8e0e4360bc226f3ec227f9d9e54638e8d31f5051215df6ebb9c2f9579aa77598a38f914b5b9c1bd83c4e2f9f382a0d0aa3542ffee65984a601bc69eb28deb27dca12c82c2d4c3f66cd500f1ff2b994d8a4e30cbb33c":0 @@ -831,3 +840,38 @@ RSASSA-PSS verify ext, all-zero padding, automatic salt length depends_on:MBEDTLS_SHA256_C pkcs1_rsassa_pss_verify_ext:512:16:"00b076d23250816f9aab02307e452b97f0cae7598369b41624e8afc7971a59a13892f64b07eaa6ec928c160b2d6ec8f9d0dd5b63c8b3ac0767b4f65c892f56c10f":16:"010001":MBEDTLS_MD_NONE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA256:MBEDTLS_RSA_SALT_LEN_ANY:"":"63a35294577c7e593170378175b7df27c293dae583ec2a971426eb2d66f2af483e897bfae5dc20300a9d61a3644e08c3aee61a463690a3498901563c46041056":MBEDTLS_ERR_RSA_INVALID_PADDING:MBEDTLS_ERR_RSA_INVALID_PADDING +RSASSA-PSS Signature RSA-1024, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:1024:16:"00e8f95a716c127d5147dcc241a7c1fe8d5487b3e8b6e95e48a83334d21d00c79ad0a90e29941c0c53065b20059de95e9e406061416f7ac12edca1983b9ee28cc3":16:"00d72348b297e7e5dc4329f6ab874b17982584e0ab43174070a9be983c0f040320d6f893c40d2717cb3044380cb3230b7133621eb1c55a3ea56d0e7cee694b5df3":16:"00c3c9873548543591c1f947e412c33da56b9d1b94a58c2f410a8a620e9b4f1d9197643ebf527f5f62b202b9d67a32654d05f326a9b61e0106efdf4829673c4f3d23655996e2424059916ab47aa67e406c129679e5979ca46708866608ffa21f619843b959b4442e422598a2faab54a8cef1f131992677d2cf5bcaf2b5564f7419":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"655d1cf86a7af5113d1791ab7b6627845ea2aa7efbae82705a3563e5ba0337a1d033cb9283b38c042056e0a1d0529891173e3df6621dd8b184930caec8b3cbe4d1068524dab0ec6854f6638d86b77434cd792ddec0d02327a9eebffcd6911ffd32ad9bcb569d3237398c8169d9c62e7eea81c1b456fd36019aad1e4b268c604d":0 + +RSASSA-PSS Verification RSA-1024, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_verify:1022:16:"00c3c9873548543591c1f947e412c33da56b9d1b94a58c2f410a8a620e9b4f1d9197643ebf527f5f62b202b9d67a32654d05f326a9b61e0106efdf4829673c4f3d23655996e2424059916ab47aa67e406c129679e5979ca46708866608ffa21f619843b959b4442e422598a2faab54a8cef1f131992677d2cf5bcaf2b5564f7419":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"655d1cf86a7af5113d1791ab7b6627845ea2aa7efbae82705a3563e5ba0337a1d033cb9283b38c042056e0a1d0529891173e3df6621dd8b184930caec8b3cbe4d1068524dab0ec6854f6638d86b77434cd792ddec0d02327a9eebffcd6911ffd32ad9bcb569d3237398c8169d9c62e7eea81c1b456fd36019aad1e4b268c604d":0 + +RSASSA-PSS Signature RSA-1032, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:1032:16:"0dfaedb709ada2105223e5e7764a5f31d07ae7a37bdc7b4a56c2499e1173147bcdcb165b8fb01a2528190cb6874656a936491898fca330db8af5a9ed5417268ed7":16:"0c339c56797a90c641292560d0ef675f71ac2c99fcaba6260c38e4f167dfd179eb7a9e255f9bdbc549e4181f9a2a19b1f30a80b292d5ef1ad75b9e658eaa6fb0bb":16:"00aa94ab91b4c26be257e469528228c4b0b6b4c99e73a84a272b3101892c07406911372b83ec4a7b8191f0ba4b4cb4cb3b732074e96c668297e1323b8ad0822a7e151182def03871a66a47b704b92845c6194142d4eeda19903e04043581f7a835dc288117863d21944c3aeded518458f1a30a41c7638aa4e098a88fdf2c2097270d":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"13ad40169494129b907f061d885fbe50ab654fc7b4be657ff8629d7ca291838159e9a7b7adc93560dda2bb9127966eb8d57377fb19d5b043dca67a07ba3c23069b391ddd921b507a8cca2d5eb7ccc84b90089092ca88530e074e629c3cb6902b2d0475000269a28c4cd89cec0dca66571fa7fbe4976373abe905cbe4c66c8d5fbb":0 + +RSASSA-PSS Verification RSA-1032, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_verify:1032:16:"00aa94ab91b4c26be257e469528228c4b0b6b4c99e73a84a272b3101892c07406911372b83ec4a7b8191f0ba4b4cb4cb3b732074e96c668297e1323b8ad0822a7e151182def03871a66a47b704b92845c6194142d4eeda19903e04043581f7a835dc288117863d21944c3aeded518458f1a30a41c7638aa4e098a88fdf2c2097270d":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"13ad40169494129b907f061d885fbe50ab654fc7b4be657ff8629d7ca291838159e9a7b7adc93560dda2bb9127966eb8d57377fb19d5b043dca67a07ba3c23069b391ddd921b507a8cca2d5eb7ccc84b90089092ca88530e074e629c3cb6902b2d0475000269a28c4cd89cec0dca66571fa7fbe4976373abe905cbe4c66c8d5fbb":0 + +RSASSA-PSS Verification of OpenSSL-generated signature RSA-1032, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_verify:1032:16:"00aa94ab91b4c26be257e469528228c4b0b6b4c99e73a84a272b3101892c07406911372b83ec4a7b8191f0ba4b4cb4cb3b732074e96c668297e1323b8ad0822a7e151182def03871a66a47b704b92845c6194142d4eeda19903e04043581f7a835dc288117863d21944c3aeded518458f1a30a41c7638aa4e098a88fdf2c2097270d":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"1de40b1c452691dfd8ceb42ecf5f0cbda944d871141b4407c1e30a6657c58c2e496b2a3ad10e025d45ca9606d25602ac1de04af8e0d24aa06e57ec3fea5c961ecf1e0a4e442fda0cdaba42469288cde5d7d0c223facceaf4c7caabe93505acd5664c9b4fae64272af4d5b74326a01724a25fabdb10b177821d2273650a84426dbd":0 + +RSASSA-PSS Signature RSA-1040, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:1040:16:"00fc7f4b490b4d3ef729db23fb5afbb5f2fc620a472342d8b8ff310cfdc124be76dc22ab6f4be35a38ddd31f24d7f64d310f67ab3a375e83f4e0559e4cb5dc43e875":16:"00d51e8680ab71dc01e1a8a68a298636bb1658cfab8d73ce528a62697722d485ab90cdafc5e27768b761839ff93420458ae55f15a69465dbc0c7b524dc9a385ff925":16:"00d2340538231dcd5a61edf83ab94b2e4b3a784394c4ed35a424c050c294157b7625f9aca8258c21e2d0a7aa9b7c9db576404e63090dba50d998f9a3ec72b1a5cf28d83251ab93341c7d2c1a90403d70f67bc1a9e413bc62facccb52441e24c3f2bc9fdeca1a783012e70b9528176260580c4e1026c58209e8dcc4de3bf3f5be5565e9":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"13e695948d59ded5a975cd9fb14bffc48e4ff9725576a96a6693da1a3c4c90d17d6811a97a633180d76dba5b957d2244e3b97e7bf3463a77d0b6c39b28a88e0b6739113726cd74937ad5f693ae5a8fd77febc270a115df05c344ddffebc2438ae67a5eea6572f434881bdf350aed4ec8f3a530d279d3fff07bb78e510807114e6ee7":0 + +RSASSA-PSS Verification RSA-1040, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_verify:1040:16:"00d2340538231dcd5a61edf83ab94b2e4b3a784394c4ed35a424c050c294157b7625f9aca8258c21e2d0a7aa9b7c9db576404e63090dba50d998f9a3ec72b1a5cf28d83251ab93341c7d2c1a90403d70f67bc1a9e413bc62facccb52441e24c3f2bc9fdeca1a783012e70b9528176260580c4e1026c58209e8dcc4de3bf3f5be5565e9":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"13e695948d59ded5a975cd9fb14bffc48e4ff9725576a96a6693da1a3c4c90d17d6811a97a633180d76dba5b957d2244e3b97e7bf3463a77d0b6c39b28a88e0b6739113726cd74937ad5f693ae5a8fd77febc270a115df05c344ddffebc2438ae67a5eea6572f434881bdf350aed4ec8f3a530d279d3fff07bb78e510807114e6ee7":0 + +RSASSA-PSS Signature RSA-1048, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_sign:1048:16:"0f39b79809516becc2e3481b6b47584aa2299bd2027ab8a303b9de5b0adcb4a5d38e38edb8c1fac3ea1dbd7e1d50b84323e362cff4df3f5a5182dafa9bb9217a73d7":16:"0d18164f8bd0d58d019998c8cb17c4c0354e62b8a9462acca30816894f982c2ae114e73993e30698930437b4eec44adec24d32ccbcbae7cc4c9f8911b1eb2100685b":16:"00c75d0f9fa17d1d24b939537a434017f390c6604444c35a13360d6b1fc986baf40159b84275d37b883278df5064dd9eb0f29b0d325acc790c4b59672737dbbf3acb88f5e2f2d54c919cafd072272c494591d52e158993315e71e2ca60b1c74feff8f3d77842b415d4e71734a498206a5cd9315c87b23e583e25eb4ca97056b45c96856d":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"9442a8ec48f87ebc81cc1273b03e528e7643c9e2fcc60ed85827d9341c5a36e5c76059baa8e9891df437e44c4047a266b46bcaaad3de1f1d4d3576defff080b791b013491636187fc45a930b70a533ed92abfd168f050df91b4c35d68d160a243ce589807a7d32661fc18b9547cdc0fd86d33acd349c98b34fb016ddd1bff23c58170e":0 + +RSASSA-PSS Verification RSA-1048, SHA-512 +depends_on:MBEDTLS_SHA512_C +pkcs1_rsassa_pss_verify:1048:16:"00c75d0f9fa17d1d24b939537a434017f390c6604444c35a13360d6b1fc986baf40159b84275d37b883278df5064dd9eb0f29b0d325acc790c4b59672737dbbf3acb88f5e2f2d54c919cafd072272c494591d52e158993315e71e2ca60b1c74feff8f3d77842b415d4e71734a498206a5cd9315c87b23e583e25eb4ca97056b45c96856d":16:"010001":MBEDTLS_MD_SHA512:MBEDTLS_MD_SHA512:"e35c6ed98f64a6d5a648fcab8adb16331db32e5d15c74a40edf94c3dc4a4de792d190889f20f1e24ed12054a6b28798fcb42d1c548769b734c96373142092aed277603f4738df4dc1446586d0ec64da4fb60536db2ae17fc7e3c04bbfbbbd907bf117c08636fa16f95f51a6216934d3e34f85030f17bbbc5ba69144058aff081e0b19cf03c17195c5e888ba58f6fe0a02e5c3bda9719a7":"653df9730e14e03f2ffb3374d6b75295aa4a52c38540b2d501adc1eb659a4d7a050769a3d11d0d5d6f3efb734200ade241fdc271c0f5eeed85b4bf00b2327bc8":"9442a8ec48f87ebc81cc1273b03e528e7643c9e2fcc60ed85827d9341c5a36e5c76059baa8e9891df437e44c4047a266b46bcaaad3de1f1d4d3576defff080b791b013491636187fc45a930b70a533ed92abfd168f050df91b4c35d68d160a243ce589807a7d32661fc18b9547cdc0fd86d33acd349c98b34fb016ddd1bff23c58170e":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.function index 50da2ff1bb..99be08ac0c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs1_v21.function @@ -9,28 +9,22 @@ */ /* BEGIN_CASE */ -void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char *input_N, int radix_E, - char *input_E, int hash, - char *message_hex_string, char *seed, - char *result_hex_str, int result ) +void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char * input_N, + int radix_E, char * input_E, int hash, + data_t * message_str, data_t * rnd_buf, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; - unsigned char rnd_buf[1000]; mbedtls_rsa_context ctx; - size_t msg_len; rnd_buf_info info; mbedtls_mpi N, E; - info.length = unhexify( rnd_buf, seed ); - info.buf = rnd_buf; + info.buf = rnd_buf->x; + info.length = rnd_buf->len; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -38,14 +32,12 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char *input_N, int radix_E, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, msg_len, message_str, output ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -55,15 +47,14 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char *input_P, - int radix_Q, char *input_Q, int radix_N, - char *input_N, int radix_E, char *input_E, - int hash, char *result_hex_str, char *seed, - char *message_hex_string, int result ) +void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P, + int radix_Q, char * input_Q, int radix_N, + char * input_N, int radix_E, char * input_E, + int hash, data_t * result_hex_str, + char * seed, data_t * message_str, + int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; size_t output_len; rnd_pseudo_info rnd_info; @@ -75,9 +66,7 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char *input_P, mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); @@ -90,14 +79,12 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char *input_P, TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); - TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str, output, 1000 ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, 1000 ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strncasecmp( (char *) output_str, result_hex_str, strlen( result_hex_str ) ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 ); } exit: @@ -108,33 +95,27 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsassa_pss_sign( int mod, int radix_P, char *input_P, int radix_Q, - char *input_Q, int radix_N, char *input_N, - int radix_E, char *input_E, int digest, int hash, - char *message_hex_string, char *salt, - char *result_hex_str, int result ) +void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q, + char * input_Q, int radix_N, char * input_N, + int radix_E, char * input_E, int digest, int hash, + data_t * message_str, data_t * rnd_buf, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; - unsigned char rnd_buf[1000]; mbedtls_rsa_context ctx; - size_t msg_len; rnd_buf_info info; mbedtls_mpi N, P, Q, E; - info.length = unhexify( rnd_buf, salt ); - info.buf = rnd_buf; + info.buf = rnd_buf->x; + info.length = rnd_buf->len; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &Q, radix_Q, input_Q ) == 0 ); @@ -146,19 +127,16 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char *input_P, int radix_Q, TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, - msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_buffer_rand, &info, MBEDTLS_RSA_PRIVATE, digest, 0, hash_result, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -169,24 +147,19 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsassa_pss_verify( int mod, int radix_N, char *input_N, int radix_E, - char *input_E, int digest, int hash, - char *message_hex_string, char *salt, - char *result_hex_str, int result ) +void pkcs1_rsassa_pss_verify( int mod, int radix_N, char * input_N, + int radix_E, char * input_E, int digest, + int hash, data_t * message_str, char * salt, + data_t * result_str, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; - unsigned char result_str[1000]; mbedtls_rsa_context ctx; - size_t msg_len; mbedtls_mpi N, E; ((void) salt); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, hash ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -195,15 +168,11 @@ void pkcs1_rsassa_pss_verify( int mod, int radix_N, char *input_N, int radix_E, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - unhexify( result_str, result_hex_str ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, - msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); - TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, - digest, 0, hash_result, result_str ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str->x ) == result ); exit: mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E ); @@ -212,28 +181,22 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void pkcs1_rsassa_pss_verify_ext( int mod, - int radix_N, char *input_N, - int radix_E, char *input_E, +void pkcs1_rsassa_pss_verify_ext( int mod, int radix_N, char * input_N, + int radix_E, char * input_E, int msg_digest_id, int ctx_hash, int mgf_hash, int salt_len, - char *message_hex_string, - char *result_hex_str, - int result_simple, + data_t * message_str, + data_t * result_str, int result_simple, int result_full ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; - unsigned char result_str[1000]; mbedtls_rsa_context ctx; - size_t msg_len, hash_len; + size_t hash_len; mbedtls_mpi N, E; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V21, ctx_hash ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -242,29 +205,27 @@ void pkcs1_rsassa_pss_verify_ext( int mod, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - unhexify( result_str, result_hex_str ); if( msg_digest_id != MBEDTLS_MD_NONE ) { TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( msg_digest_id ), - message_str, msg_len, hash_result ) == 0 ); + message_str->x, message_str->len, hash_result ) == 0 ); hash_len = 0; } else { - memcpy( hash_result, message_str, msg_len ); - hash_len = msg_len; + memcpy( hash_result, message_str->x, message_str->len ); + hash_len = message_str->len; } TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, msg_digest_id, hash_len, hash_result, - result_str ) == result_simple ); + result_str->x ) == result_simple ); TEST_ASSERT( mbedtls_rsa_rsassa_pss_verify_ext( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, msg_digest_id, hash_len, hash_result, mgf_hash, salt_len, - result_str ) == result_full ); + result_str->x ) == result_full ); exit: mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs5.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs5.function index 98546cb731..26f1d33312 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs5.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkcs5.function @@ -8,38 +8,23 @@ */ /* BEGIN_CASE */ -void pbkdf2_hmac( int hash, char *hex_password_string, - char *hex_salt_string, int it_cnt, int key_len, - char *result_key_string ) +void pbkdf2_hmac( int hash, data_t * pw_str, data_t * salt_str, + int it_cnt, int key_len, data_t * result_key_string ) { - unsigned char pw_str[100]; - unsigned char salt_str[100]; - unsigned char dst_str[200]; - mbedtls_md_context_t ctx; const mbedtls_md_info_t *info; - int pw_len, salt_len; unsigned char key[100]; mbedtls_md_init( &ctx ); - memset(pw_str, 0x00, sizeof(pw_str)); - memset(salt_str, 0x00, sizeof(salt_str)); - memset(dst_str, 0x00, sizeof(dst_str)); - - pw_len = unhexify( pw_str, hex_password_string ); - salt_len = unhexify( salt_str, hex_salt_string ); - - info = mbedtls_md_info_from_type( hash ); TEST_ASSERT( info != NULL ); TEST_ASSERT( mbedtls_md_setup( &ctx, info, 1 ) == 0 ); - TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac( &ctx, pw_str, pw_len, salt_str, salt_len, + TEST_ASSERT( mbedtls_pkcs5_pbkdf2_hmac( &ctx, pw_str->x, pw_str->len, salt_str->x, salt_str->len, it_cnt, key_len, key ) == 0 ); - hexify( dst_str, key, key_len ); - TEST_ASSERT( strcmp( (char *) dst_str, result_key_string ) == 0 ); + TEST_ASSERT( hexcmp( key, result_key_string->x, key_len, result_key_string->len ) == 0 ); exit: mbedtls_md_free( &ctx ); @@ -47,40 +32,33 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_ASN1_PARSE_C */ -void mbedtls_pkcs5_pbes2( int params_tag, char *params_hex, char *pw_hex, - char *data_hex, int ref_ret, char *ref_out_hex ) +void mbedtls_pkcs5_pbes2( int params_tag, data_t *params_hex, data_t *pw, + data_t *data, int ref_ret, data_t *ref_out ) { int my_ret; mbedtls_asn1_buf params; - unsigned char *my_out = NULL, *ref_out = NULL, *data = NULL, *pw = NULL; - size_t ref_out_len, data_len, pw_len; + unsigned char *my_out = NULL; params.tag = params_tag; - params.p = unhexify_alloc( params_hex, ¶ms.len ); + params.p = params_hex->x; + params.len = params_hex->len; - data = unhexify_alloc( data_hex, &data_len ); - pw = unhexify_alloc( pw_hex, &pw_len ); - ref_out = unhexify_alloc( ref_out_hex, &ref_out_len ); - my_out = zero_alloc( ref_out_len ); + my_out = zero_alloc( ref_out->len ); my_ret = mbedtls_pkcs5_pbes2( ¶ms, MBEDTLS_PKCS5_DECRYPT, - pw, pw_len, data, data_len, my_out ); + pw->x, pw->len, data->x, data->len, my_out ); TEST_ASSERT( my_ret == ref_ret ); if( ref_ret == 0 ) - TEST_ASSERT( memcmp( my_out, ref_out, ref_out_len ) == 0 ); + TEST_ASSERT( memcmp( my_out, ref_out->x, ref_out->len ) == 0 ); exit: - mbedtls_free( params.p ); - mbedtls_free( data ); - mbedtls_free( pw ); - mbedtls_free( ref_out ); mbedtls_free( my_out ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void pkcs5_selftest( ) +void pkcs5_selftest( ) { TEST_ASSERT( mbedtls_pkcs5_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.data index 5ffb580361..4add252df7 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.data @@ -939,8 +939,18 @@ depends_on:MBEDTLS_DES_C:MBEDTLS_SHA512_C:MBEDTLS_PKCS5_C pk_parse_keyfile_rsa:"data_files/rsa_pkcs8_pbes2_pbkdf2_4096_des_sha512.der":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT Parse Public RSA Key #1 (PKCS#8 wrapped) -depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C -pk_parse_public_keyfile_rsa:"data_files/format_gen.pub":0 +depends_on:MBEDTLS_PEM_PARSE_C +pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs8_2048_public.pem":0 + +Parse Public RSA Key #1 (PKCS#8 wrapped, DER) +pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs8_2048_public.der":0 + +Parse Public RSA Key #3 (PKCS#1 wrapped) +depends_on:MBEDTLS_PEM_PARSE_C +pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.pem":0 + +Parse Public RSA Key #4 (PKCS#1 wrapped, DER) +pk_parse_public_keyfile_rsa:"data_files/rsa_pkcs1_2048_public.der":0 Parse Public EC Key #1 (RFC 5480, DER) depends_on:MBEDTLS_ECP_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.function index 94d25e7eb0..3eb0397e6a 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkparse.function @@ -10,7 +10,7 @@ */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_FS_IO */ -void pk_parse_keyfile_rsa( char *key_file, char *password, int result ) +void pk_parse_keyfile_rsa( char * key_file, char * password, int result ) { mbedtls_pk_context ctx; int res; @@ -39,7 +39,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_RSA_C:MBEDTLS_FS_IO */ -void pk_parse_public_keyfile_rsa( char *key_file, int result ) +void pk_parse_public_keyfile_rsa( char * key_file, int result ) { mbedtls_pk_context ctx; int res; @@ -64,7 +64,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_ECP_C */ -void pk_parse_public_keyfile_ec( char *key_file, int result ) +void pk_parse_public_keyfile_ec( char * key_file, int result ) { mbedtls_pk_context ctx; int res; @@ -89,7 +89,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_ECP_C */ -void pk_parse_keyfile_ec( char *key_file, char *password, int result ) +void pk_parse_keyfile_ec( char * key_file, char * password, int result ) { mbedtls_pk_context ctx; int res; @@ -113,23 +113,19 @@ exit: } /* END_CASE */ -/* BEGIN_CASE */ -void pk_parse_key( char *key_data, char *result_str, int result ) +/* BEGIN_CASE depends_on:MBEDTLS_RSA_C */ +void pk_parse_key( data_t * buf, char * result_str, int result ) { mbedtls_pk_context pk; - unsigned char buf[2000]; unsigned char output[2000]; - int data_len; ((void) result_str); mbedtls_pk_init( &pk ); - memset( buf, 0, 2000 ); memset( output, 0, 2000 ); - data_len = unhexify( buf, key_data ); - TEST_ASSERT( mbedtls_pk_parse_key( &pk, buf, data_len, NULL, 0 ) == ( result ) ); + TEST_ASSERT( mbedtls_pk_parse_key( &pk, buf->x, buf->len, NULL, 0 ) == ( result ) ); if( ( result ) == 0 ) { TEST_ASSERT( 1 ); diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkwrite.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkwrite.function index 71aa595202..43c275ef25 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkwrite.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_pkwrite.function @@ -10,7 +10,7 @@ */ /* BEGIN_CASE depends_on:MBEDTLS_PEM_WRITE_C */ -void pk_write_pubkey_check( char *key_file ) +void pk_write_pubkey_check( char * key_file ) { mbedtls_pk_context key; unsigned char buf[5000]; @@ -42,7 +42,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_PEM_WRITE_C */ -void pk_write_key_check( char *key_file ) +void pk_write_key_check( char * key_file ) { mbedtls_pk_context key; unsigned char buf[5000]; diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_poly1305.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_poly1305.data new file mode 100644 index 0000000000..13912e997a --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_poly1305.data @@ -0,0 +1,42 @@ +Poly1305 RFC 7539 Example And Test Vector +mbedtls_poly1305:"85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b":"a8061dc1305136c6c22b8baf0c0127a9":"43727970746f6772617068696320466f72756d2052657365617263682047726f7570" + +Poly1305 RFC 7539 Test Vector #1 +mbedtls_poly1305:"0000000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + +Poly1305 RFC 7539 Test Vector #2 +mbedtls_poly1305:"0000000000000000000000000000000036e5f6b5c5e06070f0efca96227a863e":"36e5f6b5c5e06070f0efca96227a863e":"416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f" + +Poly1305 RFC 7539 Test Vector #3 +mbedtls_poly1305:"36e5f6b5c5e06070f0efca96227a863e00000000000000000000000000000000":"f3477e7cd95417af89a6b8794c310cf0":"416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f" + +Poly1305 RFC 7539 Test Vector #4 +mbedtls_poly1305:"1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0":"4541669a7eaaee61e708dc7cbcc5eb62":"2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e" + +Poly1305 RFC 7539 Test Vector #5 +mbedtls_poly1305:"0200000000000000000000000000000000000000000000000000000000000000":"03000000000000000000000000000000":"ffffffffffffffffffffffffffffffff" + +Poly1305 RFC 7539 Test Vector #6 +mbedtls_poly1305:"02000000000000000000000000000000ffffffffffffffffffffffffffffffff":"03000000000000000000000000000000":"02000000000000000000000000000000" + +Poly1305 RFC 7539 Test Vector #7 +mbedtls_poly1305:"0100000000000000000000000000000000000000000000000000000000000000":"05000000000000000000000000000000":"fffffffffffffffffffffffffffffffff0ffffffffffffffffffffffffffffff11000000000000000000000000000000" + +Poly1305 RFC 7539 Test Vector #8 +mbedtls_poly1305:"0100000000000000000000000000000000000000000000000000000000000000":"00000000000000000000000000000000":"fffffffffffffffffffffffffffffffffbfefefefefefefefefefefefefefefe01010101010101010101010101010101" + +Poly1305 RFC 7539 Test Vector #9 +mbedtls_poly1305:"0200000000000000000000000000000000000000000000000000000000000000":"faffffffffffffffffffffffffffffff":"fdffffffffffffffffffffffffffffff" + +Poly1305 RFC 7539 Test Vector #10 +mbedtls_poly1305:"0100000000000000040000000000000000000000000000000000000000000000":"14000000000000005500000000000000":"e33594d7505e43b900000000000000003394d7505e4379cd01000000000000000000000000000000000000000000000001000000000000000000000000000000" + +Poly1305 RFC 7539 Test Vector #11 +mbedtls_poly1305:"0100000000000000040000000000000000000000000000000000000000000000":"13000000000000000000000000000000":"e33594d7505e43b900000000000000003394d7505e4379cd010000000000000000000000000000000000000000000000" + +Poly1305 Parameter validation +poly1305_bad_params: + +Poly1305 Selftest +depends_on:MBEDTLS_SELF_TEST +poly1305_selftest: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_poly1305.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_poly1305.function new file mode 100644 index 0000000000..066bb39425 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_poly1305.function @@ -0,0 +1,135 @@ +/* BEGIN_HEADER */ +#include "mbedtls/poly1305.h" +#include +/* END_HEADER */ + +/* BEGIN_DEPENDENCIES + * depends_on:MBEDTLS_POLY1305_C + * END_DEPENDENCIES + */ + +/* BEGIN_CASE */ +void mbedtls_poly1305( char *hex_key_string, char *hex_mac_string, char *hex_src_string ) +{ + unsigned char src_str[375]; /* max size of binary input */ + unsigned char key[32]; /* size set by the standard */ + unsigned char mac[16]; /* size set by the standard */ + unsigned char mac_str[33]; /* hex expansion of the above */ + size_t src_len; + mbedtls_poly1305_context ctx; + + memset( src_str, 0x00, sizeof( src_str ) ); + memset( mac_str, 0x00, sizeof( mac_str ) ); + memset( key, 0x00, sizeof( key ) ); + memset( mac, 0x00, sizeof( mac ) ); + + src_len = unhexify( src_str, hex_src_string ); + unhexify( key, hex_key_string ); + + /* + * Test the integrated API + */ + TEST_ASSERT( mbedtls_poly1305_mac( key, src_str, src_len, mac ) == 0 ); + + hexify( mac_str, mac, 16 ); + TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 ); + + /* + * Test the streaming API + */ + mbedtls_poly1305_init( &ctx ); + + TEST_ASSERT( mbedtls_poly1305_starts( &ctx, key ) == 0 ); + + TEST_ASSERT( mbedtls_poly1305_update( &ctx, src_str, src_len ) == 0 ); + + TEST_ASSERT( mbedtls_poly1305_finish( &ctx, mac ) == 0 ); + + hexify( mac_str, mac, 16 ); + TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 ); + + /* + * Test the streaming API again, piecewise + */ + + /* Don't free/init the context, in order to test that starts() does the + * right thing. */ + if( src_len >= 1 ) + { + TEST_ASSERT( mbedtls_poly1305_starts( &ctx, key ) == 0 ); + + TEST_ASSERT( mbedtls_poly1305_update( &ctx, src_str, 1 ) == 0 ); + TEST_ASSERT( mbedtls_poly1305_update( &ctx, src_str + 1, src_len - 1 ) == 0 ); + + TEST_ASSERT( mbedtls_poly1305_finish( &ctx, mac ) == 0 ); + + hexify( mac_str, mac, 16 ); + TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 ); + } + + /* + * Again with more pieces + */ + if( src_len >= 2 ) + { + TEST_ASSERT( mbedtls_poly1305_starts( &ctx, key ) == 0 ); + + TEST_ASSERT( mbedtls_poly1305_update( &ctx, src_str, 1 ) == 0 ); + TEST_ASSERT( mbedtls_poly1305_update( &ctx, src_str + 1, 1 ) == 0 ); + TEST_ASSERT( mbedtls_poly1305_update( &ctx, src_str + 2, src_len - 2 ) == 0 ); + + TEST_ASSERT( mbedtls_poly1305_finish( &ctx, mac ) == 0 ); + + hexify( mac_str, mac, 16 ); + TEST_ASSERT( strcmp( (char *) mac_str, hex_mac_string ) == 0 ); + } + + mbedtls_poly1305_free( &ctx ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void poly1305_bad_params() +{ + unsigned char src[1]; + unsigned char key[32]; + unsigned char mac[16]; + size_t src_len = sizeof( src ); + mbedtls_poly1305_context ctx; + + TEST_INVALID_PARAM( mbedtls_poly1305_init( NULL ) ); + TEST_VALID_PARAM( mbedtls_poly1305_free( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_starts( NULL, key ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_starts( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_update( NULL, src, 0 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_update( &ctx, NULL, src_len ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_finish( NULL, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_finish( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_mac( NULL, src, 0, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_mac( key, NULL, src_len, mac ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA, + mbedtls_poly1305_mac( key, src, 0, NULL ) ); + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ +void poly1305_selftest() +{ + TEST_ASSERT( mbedtls_poly1305_self_test( 1 ) == 0 ); +} +/* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.data index 41149063ff..5f49ad671b 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.data @@ -1,3 +1,6 @@ +RSA parameter validation +rsa_invalid_param: + RSA PKCS1 Verify v1.5 CAVS #1 depends_on:MBEDTLS_SHA1_C:MBEDTLS_PKCS1_V15 # Good padding but wrong hash @@ -237,15 +240,15 @@ mbedtls_rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e9 RSA PKCS1 Sign #8 (RAW, 2048 bits RSA) depends_on:MBEDTLS_PKCS1_V15 -rsa_pkcs1_sign_raw:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":"1234567890deadbeef":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8" +rsa_pkcs1_sign_raw:"1234567890deadbeef":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8" RSA PKCS1 Sign #8 Verify depends_on:MBEDTLS_PKCS1_V15 -rsa_pkcs1_verify_raw:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":"1234567890deadbeef":MBEDTLS_RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8":0 +rsa_pkcs1_verify_raw:"1234567890deadbeef":MBEDTLS_RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8":0 RSA PKCS1 Sign #8 Verify (Wrong raw hash) depends_on:MBEDTLS_PKCS1_V15 -rsa_pkcs1_verify_raw:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":"1234567890deadcafe":MBEDTLS_RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8":MBEDTLS_ERR_RSA_VERIFY_FAILED +rsa_pkcs1_verify_raw:"1234567890deadcafe":MBEDTLS_RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8":MBEDTLS_ERR_RSA_VERIFY_FAILED RSA PKCS1 Sign #9 (Invalid Digest type) depends_on:MBEDTLS_PKCS1_V15 @@ -255,12 +258,6 @@ RSA PKCS1 Sign #9 Verify (Invalid Digest type) depends_on:MBEDTLS_PKCS1_V15 mbedtls_rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":MBEDTLS_RSA_PKCS_V15:255:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"3bcf673c3b27f6e2ece4bb97c7a37161e6c6ee7419ef366efc3cfee0f15f415ff6d9d4390937386c6fec1771acba73f24ec6b0469ea8b88083f0b4e1b6069d7bf286e67cf94182a548663137e82a6e09c35de2c27779da0503f1f5bedfebadf2a875f17763a0564df4a6d945a5a3e46bc90fb692af3a55106aafc6b577587456ff8d49cfd5c299d7a2b776dbe4c1ae777b0f64aa3bab27689af32d6cc76157c7dc6900a3469e18a7d9b6bfe4951d1105a08864575e4f4ec05b3e053f9b7a2d5653ae085e50a63380d6bdd6f58ab378d7e0a2be708c559849891317089ab04c82d8bc589ea088b90b11dea5cf85856ff7e609cc1adb1d403beead4c126ff29021":MBEDTLS_ERR_RSA_BAD_INPUT_DATA -RSA PKCS1 Sign #8 (Invalid padding type) -mbedtls_rsa_pkcs1_sign:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":2:MBEDTLS_MD_MD5:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"3bcf673c3b27f6e2ece4bb97c7a37161e6c6ee7419ef366efc3cfee0f15f415ff6d9d4390937386c6fec1771acba73f24ec6b0469ea8b88083f0b4e1b6069d7bf286e67cf94182a548663137e82a6e09c35de2c27779da0503f1f5bedfebadf2a875f17763a0564df4a6d945a5a3e46bc90fb692af3a55106aafc6b577587456ff8d49cfd5c299d7a2b776dbe4c1ae777b0f64aa3bab27689af32d6cc76157c7dc6900a3469e18a7d9b6bfe4951d1105a08864575e4f4ec05b3e053f9b7a2d5653ae085e50a63380d6bdd6f58ab378d7e0a2be708c559849891317089ab04c82d8bc589ea088b90b11dea5cf85856ff7e609cc1adb1d403beead4c126ff29021":MBEDTLS_ERR_RSA_INVALID_PADDING - -RSA PKCS1 Sign #8 Verify (Invalid padding type) -mbedtls_rsa_pkcs1_verify:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":1:MBEDTLS_MD_MD5:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"3bcf673c3b27f6e2ece4bb97c7a37161e6c6ee7419ef366efc3cfee0f15f415ff6d9d4390937386c6fec1771acba73f24ec6b0469ea8b88083f0b4e1b6069d7bf286e67cf94182a548663137e82a6e09c35de2c27779da0503f1f5bedfebadf2a875f17763a0564df4a6d945a5a3e46bc90fb692af3a55106aafc6b577587456ff8d49cfd5c299d7a2b776dbe4c1ae777b0f64aa3bab27689af32d6cc76157c7dc6900a3469e18a7d9b6bfe4951d1105a08864575e4f4ec05b3e053f9b7a2d5653ae085e50a63380d6bdd6f58ab378d7e0a2be708c559849891317089ab04c82d8bc589ea088b90b11dea5cf85856ff7e609cc1adb1d403beead4c126ff29021":MBEDTLS_ERR_RSA_INVALID_PADDING - RSA PKCS1 Encrypt #1 depends_on:MBEDTLS_PKCS1_V15 mbedtls_rsa_pkcs1_encrypt:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_RSA_PKCS_V15:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"b0c0b193ba4a5b4502bfacd1a9c2697da5510f3e3ab7274cf404418afd2c62c89b98d83bbc21c8c1bf1afe6d8bf40425e053e9c03e03a3be0edbe1eda073fade1cc286cc0305a493d98fe795634c3cad7feb513edb742d66d910c87d07f6b0055c3488bb262b5fd1ce8747af64801fb39d2d3a3e57086ffe55ab8d0a2ca86975629a0f85767a4990c532a7c2dab1647997ebb234d0b28a0008bfebfc905e7ba5b30b60566a5e0190417465efdbf549934b8f0c5c9f36b7c5b6373a47ae553ced0608a161b1b70dfa509375cf7a3598223a6d7b7a1d1a06ac74d345a9bb7c0e44c8388858a4f1d8115f2bd769ffa69020385fa286302c80e950f9e2751308666c":0 @@ -277,12 +274,6 @@ RSA PKCS1 Decrypt #2 (Data too small) depends_on:MBEDTLS_PKCS1_V15 mbedtls_rsa_pkcs1_decrypt:"deadbeafcafedeadbeeffedcba9876":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":1000:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_ERR_RSA_PRIVATE_FAILED + MBEDTLS_ERR_MPI_BAD_INPUT_DATA -RSA PKCS1 Encrypt #3 (Invalid padding mode) -mbedtls_rsa_pkcs1_encrypt:"4E636AF98E40F3ADCFCCB698F4E80B9F":2:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":MBEDTLS_ERR_RSA_INVALID_PADDING - -RSA PKCS1 Decrypt #3 (Invalid padding mode) -mbedtls_rsa_pkcs1_decrypt:"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":2:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":1000:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_ERR_RSA_INVALID_PADDING - RSA PKCS1 Decrypt #4 (Output buffer too small) depends_on:MBEDTLS_PKCS1_V15 mbedtls_rsa_pkcs1_decrypt:"a42eda41e56235e666e7faaa77100197f657288a1bf183e4820f0c37ce2c456b960278d6003e0bbcd4be4a969f8e8fd9231e1f492414f00ed09844994c86ec32db7cde3bec7f0c3dbf6ae55baeb2712fa609f5fc3207a824eb3dace31849cd6a6084318523912bccb84cf42e3c6d6d1685131d69bb545acec827d2b0dfdd5568b7dcc4f5a11d6916583fefa689d367f8c9e1d95dcd2240895a9470b0c1730f97cd6e8546860bd254801769f54be96e16362ddcbf34d56035028890199e0f48db38642cb66a4181e028a6443a404fea284ce02b4614b683367d40874e505611d23142d49f06feea831d52d347b13610b413c4efc43a6de9f0b08d2a951dc503b6":MBEDTLS_RSA_PKCS_V15:2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":15:"4E636AF98E40F3ADCFCCB698F4E80B9F":MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE @@ -339,6 +330,7 @@ RSA Check Public key #5 (N smaller than 128 bits) mbedtls_rsa_check_pubkey:16:"7edcba9876543210deadbeefcafe4321":16:"3":MBEDTLS_ERR_RSA_KEY_CHECK_FAILED RSA Check Public key #6 (N exactly 8192 bits) +depends_on:MBEDTLS_MPI_MAX_SIZE>=1024 mbedtls_rsa_check_pubkey:16:"88F48075BF29E95C1C6AE8716678B74E957B69CC2E49708C160C6343AAD2F076D25397ACE74220311ED18AEEB681F463611B3340C3945CAAEAD3ACC616E08A25A55683A32979BD55EA5DAB7630AF393886896F11DDC5F07E15EDF949324CF0F0B2A5C0E85DFA23167193182D1A43079DC8645F6C2C029629F475575802F7D326DE5BD891A9C5F84A433D45154181EC05685A4B368A5B6434775A00ABC6B0A04647D4598CEEE566B552230F691C98CA30B402A76C686A94B373CCD2F60EFA3878A867BB5F585D088E27C507937262D098A477B9218BE7C03B2E4C102D244CA701645F1827CD947E5E796446378B848862E689F0D1773F752056841A1F0EECE7CAB74921A42DBF2EF264ADCF4ABE05A1242E5F629A657A2D67958A2DAC9A2245074A37099B45064723ABE21241058252632C2BA6FE85AB1C75FF310891B84C9C40AB646FE1D90BC716FB3A4B56DA3EA25CA397C04B994F7C6AD1DD0CB9E994CA6B835F7830F4F4E0F976BBEA5AE8556BC7C90B3E50E21C19AD1F6BC4A8FF15F2909D9CC5F3DA533BADFF50F487869D631C3E34D69636B4C25A55127EF5B715F2FC0565734B38DF996D1970E56F7F64EBECB9D00A587AAEC608F2D3AAA51E66BF53E92C3096BF78D1DCBCE1A645FA4F0542E6F68E5A94AAA6E839F75620FABED5D2BCF40AB8EAF95F838BFA962429F281578882DF0F2721C27C8905C9E776B1D3251FC066A8BC64C0CE7FBA2B8E21F65EF6739AB6F19EC2AB07817DFF03DAB7C846AB5CC86C103642D7664A85DC2D846A8004CD6A144C72CCCAC86DB5901A047324927B80E281F5F7315FA2F9083BDE0DB7AA46DC055E36BB73FB6DBD3A14759D06CBBE8D57CBC213C4D55DE4478679E0A5902C8655BE1391C0E88D2B1FBD57E9232A2CEBC67569ECD94E4BF0FCC6C003F9AA51A2A5E6EE084A46DAE65E52400A727F9713D29E92CD6CA37FD599598B3F677624A2A484A8B36B98EFEAD662C0A23BC1D9280EF2A31F887065EB20A93B41F7A264ECFA65B3555F3E400927018186EAA2D4F00C6B7AB1BCED5F893D64478177592C7F2B945307AB474D7EC7FF2E7E55834CC763BEF81DA9BD70FB3D423AE5ADB86B336734C8A3BEC90CEB05438B5BA030D0D30DEC1442D2EB08450480FBAE090FFA1A5ADD748A415BDCDE45094E792420F0AF94BCA0A80A2096D1A478D3428A214A7E68C0F07F58C6FB232ECC3D8B821AE29AE76E13EB751193F6ECA670016D54F3D796937DDBB8900062EF116CCA3F5B3AECA618272875336C9C050FBC0FC7EDD5B88D85DA0061D21E176E1419CF573629BE7B0496E761EAD45FE32B59EB00D47CDD178AC8F8EC8D6F26DED34F7576CD938422E18E936F16A704B483A48EE3BEA59D95F688136119894930EC8E9282E5974740CF031DF8DBB07EB08F2DA0ACCADECE15A6A57502890F4A03740E60BD":16:"010001":0 RSA Check Public key #7 (N larger than 8192 bits) @@ -378,13 +370,13 @@ RSA Check Public-Private key #5 (E mismatch) rsa_check_pubpriv:2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"17":16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":16:"77B1D99300D6A54E864962DA09AE10CF19A7FB888456BC2672B72AEA52B204914493D16C184AD201EC3F762E1FBD8702BA796EF953D9EA2F26300D285264F11B0C8301D0207FEB1E2C984445C899B0ACEBAA74EF014DD1D4BDDB43202C08D2FF9692D8D788478DEC829EB52AFB5AE068FBDBAC499A27FACECC391E75C936D55F07BB45EE184DAB45808E15722502F279F89B38C1CB292557E5063597F52C75D61001EDC33F4739353E33E56AD273B067C1A2760208529EA421774A5FFFCB3423B1E0051E7702A55D80CBF2141569F18F87BFF538A1DA8EDBB2693A539F68E0D62D77743F89EACF3B1723BDB25CE2F333FA63CACF0E67DF1A431893BB9B352FCB":16:"9A66CF76572A71A17475794FA1C8C70D987E581E990D772BB27C77C53FF1ECBB31260E9EDAFAEBC79991807E48918EAB8C3A5F03A600F30C69511546AE788EDF53168E2D035D300EDCD5E4BF3AA2A6D603EA0A7BD11E1C1089657306DF8A64E7F1BC6B266B825C1A6C5F0FC85775F4CF7ACD63367E42EAFE46511D58AD6DFE0F":16:"844DBDD20925D9164F9A1E2F707076C261CCA8337D0241392B38AE3C12342F3AC14F8FD6DF4A1C36839662BD0D227344CD55A32AE5DBD2309A9A2B8A2C82BE6DDDDCE81D1B694775D9047AA765CA0C6E1BB8E61C8B7BE27ED711E8EE2FEAD87F3491F76A6D2262C14189EACDFD4CEFE0BF9D0A5B49857E0ED22CBEB98DC8D45B":16:"4951A7B174DF972C37BADCC38457B5EDD1F078BC613E75CE25E08814E12461C7A1C189A70EB8138294298D141244C7A9DE31AB4F6D38B40B04D6353CD30F77ADBF66BBDE41C7BE463C5E30AAA3F7BAD6CEE99506DEAAFA2F335C1B1C5C88B8ABB0D0387EE0D1B4E7027F7F085A025CEDB5CCE18B88C0462F1C3C910D47C0D4AB":MBEDTLS_ERR_RSA_KEY_CHECK_FAILED RSA Private (Correct) -mbedtls_rsa_private:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"48ce62658d82be10737bd5d3579aed15bc82617e6758ba862eeb12d049d7bacaf2f62fce8bf6e980763d1951f7f0eae3a493df9890d249314b39d00d6ef791de0daebf2c50f46e54aeb63a89113defe85de6dbe77642aae9f2eceb420f3a47a56355396e728917f17876bb829fabcaeef8bf7ef6de2ff9e84e6108ea2e52bbb62b7b288efa0a3835175b8b08fac56f7396eceb1c692d419ecb79d80aef5bc08a75d89de9f2b2d411d881c0e3ffad24c311a19029d210d3d3534f1b626f982ea322b4d1cfba476860ef20d4f672f38c371084b5301b429b747ea051a619e4430e0dac33c12f9ee41ca4d81a4f6da3e495aa8524574bdc60d290dd1f7a62e90a67":0 +mbedtls_rsa_private:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f8700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000":2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"48ce62658d82be10737bd5d3579aed15bc82617e6758ba862eeb12d049d7bacaf2f62fce8bf6e980763d1951f7f0eae3a493df9890d249314b39d00d6ef791de0daebf2c50f46e54aeb63a89113defe85de6dbe77642aae9f2eceb420f3a47a56355396e728917f17876bb829fabcaeef8bf7ef6de2ff9e84e6108ea2e52bbb62b7b288efa0a3835175b8b08fac56f7396eceb1c692d419ecb79d80aef5bc08a75d89de9f2b2d411d881c0e3ffad24c311a19029d210d3d3534f1b626f982ea322b4d1cfba476860ef20d4f672f38c371084b5301b429b747ea051a619e4430e0dac33c12f9ee41ca4d81a4f6da3e495aa8524574bdc60d290dd1f7a62e90a67":0 RSA Private (Data larger than N) mbedtls_rsa_private:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":2048:16:"e79a373182bfaa722eb035f772ad2a9464bd842de59432c18bbab3a7dfeae318c9b915ee487861ab665a40bd6cda560152578e8579016c929df99fea05b4d64efca1d543850bc8164b40d71ed7f3fa4105df0fb9b9ad2a18ce182c8a4f4f975bea9aa0b9a1438a27a28e97ac8330ef37383414d1bd64607d6979ac050424fd17":16:"c6749cbb0db8c5a177672d4728a8b22392b2fc4d3b8361d5c0d5055a1b4e46d821f757c24eef2a51c561941b93b3ace7340074c058c9bb48e7e7414f42c41da4cccb5c2ba91deb30c586b7fb18af12a52995592ad139d3be429add6547e044becedaf31fa3b39421e24ee034fbf367d11f6b8f88ee483d163b431e1654ad3e89":16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8":MBEDTLS_ERR_RSA_PRIVATE_FAILED + MBEDTLS_ERR_MPI_BAD_INPUT_DATA RSA Public (Correct) -mbedtls_rsa_public:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f870":2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"1f5e927c13ff231090b0f18c8c3526428ed0f4a7561457ee5afe4d22d5d9220c34ef5b9a34d0c07f7248a1f3d57f95d10f7936b3063e40660b3a7ca3e73608b013f85a6e778ac7c60d576e9d9c0c5a79ad84ceea74e4722eb3553bdb0c2d7783dac050520cb27ca73478b509873cb0dcbd1d51dd8fccb96c29ad314f36d67cc57835d92d94defa0399feb095fd41b9f0b2be10f6041079ed4290040449f8a79aba50b0a1f8cf83c9fb8772b0686ec1b29cb1814bb06f9c024857db54d395a8da9a2c6f9f53b94bec612a0cb306a3eaa9fc80992e85d9d232e37a50cabe48c9343f039601ff7d95d60025e582aec475d031888310e8ec3833b394a5cf0599101e":0 +mbedtls_rsa_public:"59779fd2a39e56640c4fc1e67b60aeffcecd78aed7ad2bdfa464e93d04198d48466b8da7445f25bfa19db2844edd5c8f539cf772cc132b483169d390db28a43bc4ee0f038f6568ffc87447746cb72fefac2d6d90ee3143a915ac4688028805905a68eb8f8a96674b093c495eddd8704461eaa2b345efbb2ad6930acd8023f8700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000":2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"1f5e927c13ff231090b0f18c8c3526428ed0f4a7561457ee5afe4d22d5d9220c34ef5b9a34d0c07f7248a1f3d57f95d10f7936b3063e40660b3a7ca3e73608b013f85a6e778ac7c60d576e9d9c0c5a79ad84ceea74e4722eb3553bdb0c2d7783dac050520cb27ca73478b509873cb0dcbd1d51dd8fccb96c29ad314f36d67cc57835d92d94defa0399feb095fd41b9f0b2be10f6041079ed4290040449f8a79aba50b0a1f8cf83c9fb8772b0686ec1b29cb1814bb06f9c024857db54d395a8da9a2c6f9f53b94bec612a0cb306a3eaa9fc80992e85d9d232e37a50cabe48c9343f039601ff7d95d60025e582aec475d031888310e8ec3833b394a5cf0599101e":0 RSA Public (Data larger than N) mbedtls_rsa_public:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":2048:16:"b38ac65c8141f7f5c96e14470e851936a67bf94cc6821a39ac12c05f7c0b06d9e6ddba2224703b02e25f31452f9c4a8417b62675fdc6df46b94813bc7b9769a892c482b830bfe0ad42e46668ace68903617faf6681f4babf1cc8e4b0420d3c7f61dc45434c6b54e2c3ee0fc07908509d79c9826e673bf8363255adb0add2401039a7bcd1b4ecf0fbe6ec8369d2da486eec59559dd1d54c9b24190965eafbdab203b35255765261cd0909acf93c3b8b8428cbb448de4715d1b813d0c94829c229543d391ce0adab5351f97a3810c1f73d7b1458b97daed4209c50e16d064d2d5bfda8c23893d755222793146d0a78c3d64f35549141486c3b0961a7b4c1a2034f":16:"3":"605baf947c0de49e4f6a0dfb94a43ae318d5df8ed20ba4ba5a37a73fb009c5c9e5cce8b70a25b1c7580f389f0d7092485cdfa02208b70d33482edf07a7eafebdc54862ca0e0396a5a7d09991b9753eb1ffb6091971bb5789c6b121abbcd0a3cbaa39969fa7c28146fce96c6d03272e3793e5be8f5abfa9afcbebb986d7b3050604a2af4d3a40fa6c003781a539a60259d1e84f13322da9e538a49c369b83e7286bf7d30b64bbb773506705da5d5d5483a563a1ffacc902fb75c9a751b1e83cdc7a6db0470056883f48b5a5446b43b1d180ea12ba11a6a8d93b3b32a30156b6084b7fb142998a2a0d28014b84098ece7d9d5e4d55cc342ca26f5a0167a679dec8":MBEDTLS_ERR_RSA_PUBLIC_FAILED + MBEDTLS_ERR_MPI_BAD_INPUT_DATA diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.function index fd632dad6a..89c84e8ca3 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_rsa.function @@ -17,29 +17,473 @@ * END_DEPENDENCIES */ +/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void rsa_invalid_param( ) +{ + mbedtls_rsa_context ctx; + const int valid_padding = MBEDTLS_RSA_PKCS_V21; + const int invalid_padding = 42; + const int valid_mode = MBEDTLS_RSA_PRIVATE; + const int invalid_mode = 42; + unsigned char buf[42] = { 0 }; + size_t olen; + + TEST_INVALID_PARAM( mbedtls_rsa_init( NULL, valid_padding, 0 ) ); + TEST_INVALID_PARAM( mbedtls_rsa_init( &ctx, invalid_padding, 0 ) ); + TEST_VALID_PARAM( mbedtls_rsa_free( NULL ) ); + + /* No more variants because only the first argument must be non-NULL. */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_import( NULL, NULL, NULL, + NULL, NULL, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_import_raw( NULL, + NULL, 0, + NULL, 0, + NULL, 0, + NULL, 0, + NULL, 0 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_complete( NULL ) ); + + /* No more variants because only the first argument must be non-NULL. */ + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_export( NULL, NULL, NULL, + NULL, NULL, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_export_raw( NULL, + NULL, 0, + NULL, 0, + NULL, 0, + NULL, 0, + NULL, 0 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_export_crt( NULL, NULL, NULL, NULL ) ); + + TEST_INVALID_PARAM( mbedtls_rsa_set_padding( NULL, + valid_padding, 0 ) ); + TEST_INVALID_PARAM( mbedtls_rsa_set_padding( &ctx, + invalid_padding, 0 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_gen_key( NULL, rnd_std_rand, + NULL, 0, 0 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_gen_key( &ctx, NULL, + NULL, 0, 0 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_check_pubkey( NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_check_privkey( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_check_pub_priv( NULL, &ctx ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_check_pub_priv( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_public( NULL, buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_public( &ctx, NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_public( &ctx, buf, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_private( NULL, NULL, NULL, + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_private( &ctx, NULL, NULL, + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_private( &ctx, NULL, NULL, + buf, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_encrypt( NULL, NULL, NULL, + valid_mode, + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL, + invalid_mode, + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL, + valid_mode, + sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_encrypt( &ctx, NULL, NULL, + valid_mode, + sizeof( buf ), buf, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_encrypt( NULL, NULL, + NULL, + valid_mode, + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx, NULL, + NULL, + invalid_mode, + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx, NULL, + NULL, + valid_mode, + sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx, NULL, + NULL, + valid_mode, + sizeof( buf ), buf, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_encrypt( NULL, NULL, NULL, + valid_mode, + buf, sizeof( buf ), + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL, + invalid_mode, + buf, sizeof( buf ), + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL, + valid_mode, + NULL, sizeof( buf ), + sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL, + valid_mode, + buf, sizeof( buf ), + sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_encrypt( &ctx, NULL, NULL, + valid_mode, + buf, sizeof( buf ), + sizeof( buf ), buf, + NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_decrypt( NULL, NULL, NULL, + valid_mode, &olen, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL, + invalid_mode, &olen, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL, + valid_mode, NULL, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL, + valid_mode, &olen, + NULL, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_decrypt( &ctx, NULL, NULL, + valid_mode, &olen, + buf, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_decrypt( NULL, NULL, + NULL, + valid_mode, &olen, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL, + NULL, + invalid_mode, &olen, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL, + NULL, + valid_mode, NULL, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL, + NULL, + valid_mode, &olen, + NULL, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL, + NULL, + valid_mode, &olen, + buf, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_decrypt( NULL, NULL, NULL, + valid_mode, + buf, sizeof( buf ), + &olen, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL, + invalid_mode, + buf, sizeof( buf ), + &olen, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL, + valid_mode, + NULL, sizeof( buf ), + NULL, + buf, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL, + valid_mode, + buf, sizeof( buf ), + &olen, + NULL, buf, 42 ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsaes_oaep_decrypt( &ctx, NULL, NULL, + valid_mode, + buf, sizeof( buf ), + &olen, + buf, NULL, 42 ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_sign( NULL, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL, + invalid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_sign( &ctx, NULL, NULL, + valid_mode, + MBEDTLS_MD_SHA1, + 0, NULL, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_sign( NULL, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL, + invalid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_sign( &ctx, NULL, NULL, + valid_mode, + MBEDTLS_MD_SHA1, + 0, NULL, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_sign( NULL, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL, + invalid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_sign( &ctx, NULL, NULL, + valid_mode, + MBEDTLS_MD_SHA1, + 0, NULL, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_verify( NULL, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, + invalid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), NULL, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), buf, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, + valid_mode, + MBEDTLS_MD_SHA1, 0, NULL, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_verify( NULL, NULL, + NULL, + valid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx, NULL, + NULL, + invalid_mode, + 0, sizeof( buf ), buf, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx, NULL, + NULL, + valid_mode, + 0, sizeof( buf ), + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx, NULL, + NULL, + valid_mode, + 0, sizeof( buf ), buf, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pkcs1_v15_verify( &ctx, NULL, + NULL, + valid_mode, + MBEDTLS_MD_SHA1, + 0, NULL, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify( NULL, NULL, NULL, + valid_mode, + 0, sizeof( buf ), + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify( &ctx, NULL, NULL, + invalid_mode, + 0, sizeof( buf ), + buf, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), + NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), + buf, NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify( &ctx, NULL, NULL, + valid_mode, + MBEDTLS_MD_SHA1, + 0, NULL, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify_ext( NULL, NULL, NULL, + valid_mode, + 0, sizeof( buf ), + buf, + 0, 0, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify_ext( &ctx, NULL, NULL, + invalid_mode, + 0, sizeof( buf ), + buf, + 0, 0, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify_ext( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), + NULL, 0, 0, + buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify_ext( &ctx, NULL, NULL, + valid_mode, + 0, sizeof( buf ), + buf, 0, 0, + NULL ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_rsassa_pss_verify_ext( &ctx, NULL, NULL, + valid_mode, + MBEDTLS_MD_SHA1, + 0, NULL, + 0, 0, + buf ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_copy( NULL, &ctx ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, + mbedtls_rsa_copy( &ctx, NULL ) ); + +exit: + return; +} +/* END_CASE */ + /* BEGIN_CASE */ -void mbedtls_rsa_pkcs1_sign( char *message_hex_string, int padding_mode, int digest, - int mod, int radix_P, char *input_P, int radix_Q, - char *input_Q, int radix_N, char *input_N, int radix_E, - char *input_E, char *result_hex_str, int result ) +void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode, + int digest, int mod, int radix_P, char * input_P, + int radix_Q, char * input_Q, int radix_N, + char * input_N, int radix_E, char * input_E, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; mbedtls_mpi N, P, Q, E; - int msg_len; rnd_pseudo_info rnd_info; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, padding_mode, 0 ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); @@ -52,20 +496,17 @@ void mbedtls_rsa_pkcs1_sign( char *message_hex_string, int padding_mode, int dig TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), - message_str, msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, digest, 0, hash_result, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -76,23 +517,19 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_pkcs1_verify( char *message_hex_string, int padding_mode, int digest, - int mod, int radix_N, char *input_N, int radix_E, - char *input_E, char *result_hex_str, int result ) +void mbedtls_rsa_pkcs1_verify( data_t * message_str, int padding_mode, + int digest, int mod, int radix_N, + char * input_N, int radix_E, char * input_E, + data_t * result_str, int result ) { - unsigned char message_str[1000]; unsigned char hash_result[1000]; - unsigned char result_str[1000]; mbedtls_rsa_context ctx; - int msg_len; mbedtls_mpi N, E; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, padding_mode, 0 ); - memset( message_str, 0x00, 1000 ); memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -100,13 +537,11 @@ void mbedtls_rsa_pkcs1_verify( char *message_hex_string, int padding_mode, int d TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); - unhexify( result_str, result_hex_str ); if( mbedtls_md_info_from_type( digest ) != NULL ) - TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str, msg_len, hash_result ) == 0 ); + TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 ); - TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, digest, 0, hash_result, result_str->x ) == result ); exit: mbedtls_mpi_free( &N ); mbedtls_mpi_free( &E ); @@ -116,29 +551,22 @@ exit: /* BEGIN_CASE */ -void rsa_pkcs1_sign_raw( char *message_hex_string, char *hash_result_string, - int padding_mode, int mod, int radix_P, char *input_P, - int radix_Q, char *input_Q, int radix_N, - char *input_N, int radix_E, char *input_E, - char *result_hex_str ) +void rsa_pkcs1_sign_raw( data_t * hash_result, + int padding_mode, int mod, int radix_P, + char * input_P, int radix_Q, char * input_Q, + int radix_N, char * input_N, int radix_E, + char * input_E, data_t * result_hex_str ) { - unsigned char message_str[1000]; - unsigned char hash_result[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; mbedtls_mpi N, P, Q, E; - int hash_len; rnd_pseudo_info rnd_info; mbedtls_rsa_init( &ctx, padding_mode, 0 ); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &E ); - memset( message_str, 0x00, 1000 ); - memset( hash_result, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); @@ -151,16 +579,14 @@ void rsa_pkcs1_sign_raw( char *message_hex_string, char *hash_result_string, TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); - hash_len = unhexify( hash_result, hash_result_string ); TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_NONE, - hash_len, hash_result, output ) == 0 ); + hash_result->len, hash_result->x, + output ) == 0 ); - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); #if defined(MBEDTLS_PKCS1_V15) /* For PKCS#1 v1.5, there is an alternative way to generate signatures */ @@ -168,11 +594,10 @@ void rsa_pkcs1_sign_raw( char *message_hex_string, char *hash_result_string, { int res; memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); res = mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx, &rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, - hash_len, hash_result, output ); + hash_result->len, hash_result->x, output ); #if !defined(MBEDTLS_RSA_ALT) TEST_ASSERT( res == 0 ); @@ -183,8 +608,7 @@ void rsa_pkcs1_sign_raw( char *message_hex_string, char *hash_result_string, if( res == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } } #endif /* MBEDTLS_PKCS1_V15 */ @@ -198,25 +622,18 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void rsa_pkcs1_verify_raw( char *message_hex_string, char *hash_result_string, +void rsa_pkcs1_verify_raw( data_t * hash_result, int padding_mode, int mod, int radix_N, - char *input_N, int radix_E, char *input_E, - char *result_hex_str, int correct ) + char * input_N, int radix_E, char * input_E, + data_t * result_str, int correct ) { - unsigned char message_str[1000]; - unsigned char hash_result[1000]; - unsigned char result_str[1000]; unsigned char output[1000]; mbedtls_rsa_context ctx; - size_t hash_len; mbedtls_mpi N, E; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, padding_mode, 0 ); - memset( message_str, 0x00, 1000 ); - memset( hash_result, 0x00, 1000 ); - memset( result_str, 0x00, 1000 ); memset( output, 0x00, sizeof( output ) ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); @@ -226,14 +643,8 @@ void rsa_pkcs1_verify_raw( char *message_hex_string, char *hash_result_string, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); - hash_len = unhexify( hash_result, hash_result_string ); - unhexify( result_str, result_hex_str ); - TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, - MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_NONE, - hash_len, hash_result, - result_str ) == correct ); + TEST_ASSERT( mbedtls_rsa_pkcs1_verify( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_NONE, hash_result->len, hash_result->x, result_str->x ) == correct ); #if defined(MBEDTLS_PKCS1_V15) /* For PKCS#1 v1.5, there is an alternative way to verify signatures */ @@ -245,7 +656,7 @@ void rsa_pkcs1_verify_raw( char *message_hex_string, char *hash_result_string, res = mbedtls_rsa_rsaes_pkcs1_v15_decrypt( &ctx, NULL, NULL, MBEDTLS_RSA_PUBLIC, - &olen, result_str, output, sizeof( output ) ); + &olen, result_str->x, output, sizeof( output ) ); #if !defined(MBEDTLS_RSA_ALT) TEST_ASSERT( res == 0 ); @@ -256,7 +667,7 @@ void rsa_pkcs1_verify_raw( char *message_hex_string, char *hash_result_string, if( res == 0 ) { - ok = olen == hash_len && memcmp( output, hash_result, olen ) == 0; + ok = olen == hash_result->len && memcmp( output, hash_result->x, olen ) == 0; if( correct == 0 ) TEST_ASSERT( ok == 1 ); else @@ -272,15 +683,13 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_pkcs1_encrypt( char *message_hex_string, int padding_mode, int mod, - int radix_N, char *input_N, int radix_E, char *input_E, - char *result_hex_str, int result ) +void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode, + int mod, int radix_N, char * input_N, + int radix_E, char * input_E, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; - size_t msg_len; rnd_pseudo_info rnd_info; mbedtls_mpi N, E; @@ -289,9 +698,7 @@ void mbedtls_rsa_pkcs1_encrypt( char *message_hex_string, int padding_mode, int memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); mbedtls_rsa_init( &ctx, padding_mode, 0 ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -300,16 +707,14 @@ void mbedtls_rsa_pkcs1_encrypt( char *message_hex_string, int padding_mode, int TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_pseudo_rand, &rnd_info, - MBEDTLS_RSA_PUBLIC, msg_len, - message_str, output ) == result ); + MBEDTLS_RSA_PUBLIC, message_str->len, + message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -319,24 +724,19 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void rsa_pkcs1_encrypt_bad_rng( char *message_hex_string, int padding_mode, - int mod, int radix_N, char *input_N, - int radix_E, char *input_E, - char *result_hex_str, int result ) +void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode, + int mod, int radix_N, char * input_N, + int radix_E, char * input_E, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; - size_t msg_len; mbedtls_mpi N, E; mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, padding_mode, 0 ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -345,16 +745,14 @@ void rsa_pkcs1_encrypt_bad_rng( char *message_hex_string, int padding_mode, TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - msg_len = unhexify( message_str, message_hex_string ); TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &rnd_zero_rand, NULL, - MBEDTLS_RSA_PUBLIC, msg_len, - message_str, output ) == result ); + MBEDTLS_RSA_PUBLIC, message_str->len, + message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -364,14 +762,14 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_pkcs1_decrypt( char *message_hex_string, int padding_mode, int mod, - int radix_P, char *input_P, int radix_Q, char *input_Q, - int radix_N, char *input_N, int radix_E, char *input_E, - int max_output, char *result_hex_str, int result ) +void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode, + int mod, int radix_P, char * input_P, + int radix_Q, char * input_Q, int radix_N, + char * input_N, int radix_E, char * input_E, + int max_output, data_t * result_hex_str, + int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx; size_t output_len; rnd_pseudo_info rnd_info; @@ -382,9 +780,7 @@ void mbedtls_rsa_pkcs1_decrypt( char *message_hex_string, int padding_mode, int mbedtls_rsa_init( &ctx, padding_mode, 0 ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); @@ -398,15 +794,13 @@ void mbedtls_rsa_pkcs1_decrypt( char *message_hex_string, int padding_mode, int TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); output_len = 0; - TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str, output, max_output ) == result ); + TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, max_output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strncasecmp( (char *) output_str, result_hex_str, strlen( result_hex_str ) ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, output_len, result_hex_str->len ) == 0 ); } exit: @@ -417,12 +811,11 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_public( char *message_hex_string, int mod, int radix_N, char *input_N, - int radix_E, char *input_E, char *result_hex_str, int result ) +void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N, + char * input_N, int radix_E, char * input_E, + data_t * result_hex_str, int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */ mbedtls_mpi N, E; @@ -430,9 +823,7 @@ void mbedtls_rsa_public( char *message_hex_string, int mod, int radix_N, char *i mbedtls_mpi_init( &N ); mbedtls_mpi_init( &E ); mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 ); mbedtls_rsa_init( &ctx2, MBEDTLS_RSA_PKCS_V15, 0 ); - memset( message_str, 0x00, 1000 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 ); TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 ); @@ -441,14 +832,12 @@ void mbedtls_rsa_public( char *message_hex_string, int mod, int radix_N, char *i TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) ); TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); - TEST_ASSERT( mbedtls_rsa_public( &ctx, message_str, output ) == result ); + TEST_ASSERT( mbedtls_rsa_public( &ctx, message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } /* And now with the copy */ @@ -459,13 +848,11 @@ void mbedtls_rsa_public( char *message_hex_string, int mod, int radix_N, char *i TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx2 ) == 0 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); - TEST_ASSERT( mbedtls_rsa_public( &ctx2, message_str, output ) == result ); + TEST_ASSERT( mbedtls_rsa_public( &ctx2, message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx2.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } exit: @@ -476,13 +863,13 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_private( char *message_hex_string, int mod, int radix_P, char *input_P, - int radix_Q, char *input_Q, int radix_N, char *input_N, - int radix_E, char *input_E, char *result_hex_str, int result ) +void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P, + char * input_P, int radix_Q, char * input_Q, + int radix_N, char * input_N, int radix_E, + char * input_E, data_t * result_hex_str, + int result ) { - unsigned char message_str[1000]; unsigned char output[1000]; - unsigned char output_str[1000]; mbedtls_rsa_context ctx, ctx2; /* Also test mbedtls_rsa_copy() while at it */ mbedtls_mpi N, P, Q, E; rnd_pseudo_info rnd_info; @@ -493,7 +880,6 @@ void mbedtls_rsa_private( char *message_hex_string, int mod, int radix_P, char * mbedtls_rsa_init( &ctx, MBEDTLS_RSA_PKCS_V15, 0 ); mbedtls_rsa_init( &ctx2, MBEDTLS_RSA_PKCS_V15, 0 ); - memset( message_str, 0x00, 1000 ); memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) ); TEST_ASSERT( mbedtls_mpi_read_string( &P, radix_P, input_P ) == 0 ); @@ -506,21 +892,17 @@ void mbedtls_rsa_private( char *message_hex_string, int mod, int radix_P, char * TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 ); - unhexify( message_str, message_hex_string ); /* repeat three times to test updating of blinding values */ for( i = 0; i < 3; i++ ) { memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_rsa_private( &ctx, rnd_pseudo_rand, &rnd_info, - message_str, output ) == result ); + message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, - result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx.len, result_hex_str->len ) == 0 ); } } @@ -532,15 +914,12 @@ void mbedtls_rsa_private( char *message_hex_string, int mod, int radix_P, char * TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx2 ) == 0 ); memset( output, 0x00, 1000 ); - memset( output_str, 0x00, 1000 ); TEST_ASSERT( mbedtls_rsa_private( &ctx2, rnd_pseudo_rand, &rnd_info, - message_str, output ) == result ); + message_str->x, output ) == result ); if( result == 0 ) { - hexify( output_str, output, ctx2.len ); - TEST_ASSERT( strcasecmp( (char *) output_str, - result_hex_str ) == 0 ); + TEST_ASSERT( hexcmp( output, result_hex_str->x, ctx2.len, result_hex_str->len ) == 0 ); } exit: @@ -552,7 +931,7 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void rsa_check_privkey_null() +void rsa_check_privkey_null( ) { mbedtls_rsa_context ctx; memset( &ctx, 0x00, sizeof( mbedtls_rsa_context ) ); @@ -562,8 +941,8 @@ void rsa_check_privkey_null() /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_check_pubkey( int radix_N, char *input_N, int radix_E, char *input_E, - int result ) +void mbedtls_rsa_check_pubkey( int radix_N, char * input_N, int radix_E, + char * input_E, int result ) { mbedtls_rsa_context ctx; mbedtls_mpi N, E; @@ -590,12 +969,13 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void mbedtls_rsa_check_privkey( int mod, int radix_P, char *input_P, int radix_Q, - char *input_Q, int radix_N, char *input_N, - int radix_E, char *input_E, int radix_D, char *input_D, - int radix_DP, char *input_DP, int radix_DQ, - char *input_DQ, int radix_QP, char *input_QP, - int result ) +void mbedtls_rsa_check_privkey( int mod, int radix_P, char * input_P, + int radix_Q, char * input_Q, int radix_N, + char * input_N, int radix_E, char * input_E, + int radix_D, char * input_D, int radix_DP, + char * input_DP, int radix_DQ, + char * input_DQ, int radix_QP, + char * input_QP, int result ) { mbedtls_rsa_context ctx; @@ -649,13 +1029,13 @@ exit: /* END_CASE */ /* BEGIN_CASE */ -void rsa_check_pubpriv( int mod, int radix_Npub, char *input_Npub, - int radix_Epub, char *input_Epub, - int radix_P, char *input_P, int radix_Q, - char *input_Q, int radix_N, char *input_N, - int radix_E, char *input_E, int radix_D, char *input_D, - int radix_DP, char *input_DP, int radix_DQ, - char *input_DQ, int radix_QP, char *input_QP, +void rsa_check_pubpriv( int mod, int radix_Npub, char * input_Npub, + int radix_Epub, char * input_Epub, int radix_P, + char * input_P, int radix_Q, char * input_Q, + int radix_N, char * input_N, int radix_E, + char * input_E, int radix_D, char * input_D, + int radix_DP, char * input_DP, int radix_DQ, + char * input_DQ, int radix_QP, char * input_QP, int result ) { mbedtls_rsa_context pub, prv; @@ -1191,64 +1571,29 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C */ -void mbedtls_rsa_export_raw( char *input_N, char *input_P, - char *input_Q, char *input_D, - char *input_E, int is_priv, +void mbedtls_rsa_export_raw( data_t *input_N, data_t *input_P, + data_t *input_Q, data_t *input_D, + data_t *input_E, int is_priv, int successive ) { - /* Original raw buffers with which we set up the RSA context */ - unsigned char bufN[1000]; - unsigned char bufP[1000]; - unsigned char bufQ[1000]; - unsigned char bufD[1000]; - unsigned char bufE[1000]; - - size_t lenN = 0; - size_t lenP = 0; - size_t lenQ = 0; - size_t lenD = 0; - size_t lenE = 0; - /* Exported buffers */ - unsigned char bufNe[ sizeof( bufN ) ]; - unsigned char bufPe[ sizeof( bufP ) ]; - unsigned char bufQe[ sizeof( bufQ ) ]; - unsigned char bufDe[ sizeof( bufD ) ]; - unsigned char bufEe[ sizeof( bufE ) ]; - - const int have_N = ( strlen( input_N ) > 0 ); - const int have_P = ( strlen( input_P ) > 0 ); - const int have_Q = ( strlen( input_Q ) > 0 ); - const int have_D = ( strlen( input_D ) > 0 ); - const int have_E = ( strlen( input_E ) > 0 ); + unsigned char bufNe[1000]; + unsigned char bufPe[1000]; + unsigned char bufQe[1000]; + unsigned char bufDe[1000]; + unsigned char bufEe[1000]; mbedtls_rsa_context ctx; mbedtls_rsa_init( &ctx, 0, 0 ); /* Setup RSA context */ - - if( have_N ) - lenN = unhexify( bufN, input_N ); - - if( have_P ) - lenP = unhexify( bufP, input_P ); - - if( have_Q ) - lenQ = unhexify( bufQ, input_Q ); - - if( have_D ) - lenD = unhexify( bufD, input_D ); - - if( have_E ) - lenE = unhexify( bufE, input_E ); - TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, - have_N ? bufN : NULL, lenN, - have_P ? bufP : NULL, lenP, - have_Q ? bufQ : NULL, lenQ, - have_D ? bufD : NULL, lenD, - have_E ? bufE : NULL, lenE ) == 0 ); + input_N->len ? input_N->x : NULL, input_N->len, + input_P->len ? input_P->x : NULL, input_P->len, + input_Q->len ? input_Q->x : NULL, input_Q->len, + input_D->len ? input_D->x : NULL, input_D->len, + input_E->len ? input_E->x : NULL, input_E->len ) == 0 ); TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == 0 ); @@ -1259,21 +1604,21 @@ void mbedtls_rsa_export_raw( char *input_N, char *input_P, /* N and E must always be present. */ if( !successive ) { - TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, bufNe, lenN, + TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, bufNe, input_N->len, NULL, 0, NULL, 0, NULL, 0, - bufEe, lenE ) == 0 ); + bufEe, input_E->len ) == 0 ); } else { - TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, bufNe, lenN, + TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, bufNe, input_N->len, NULL, 0, NULL, 0, NULL, 0, NULL, 0 ) == 0 ); TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, NULL, 0, NULL, 0, NULL, 0, - bufEe, lenE ) == 0 ); + bufEe, input_E->len ) == 0 ); } - TEST_ASSERT( memcmp( bufN, bufNe, lenN ) == 0 ); - TEST_ASSERT( memcmp( bufE, bufEe, lenE ) == 0 ); + TEST_ASSERT( memcmp( input_N->x, bufNe, input_N->len ) == 0 ); + TEST_ASSERT( memcmp( input_E->x, bufEe, input_E->len ) == 0 ); /* If we were providing enough information to setup a complete private context, * we expect to be able to export all core parameters. */ @@ -1283,35 +1628,35 @@ void mbedtls_rsa_export_raw( char *input_N, char *input_P, if( !successive ) { TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, - bufPe, lenP ? lenP : sizeof( bufPe ), - bufQe, lenQ ? lenQ : sizeof( bufQe ), - bufDe, lenD ? lenD : sizeof( bufDe ), + bufPe, input_P->len ? input_P->len : sizeof( bufPe ), + bufQe, input_Q->len ? input_Q->len : sizeof( bufQe ), + bufDe, input_D->len ? input_D->len : sizeof( bufDe ), NULL, 0 ) == 0 ); } else { TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, - bufPe, lenP ? lenP : sizeof( bufPe ), + bufPe, input_P->len ? input_P->len : sizeof( bufPe ), NULL, 0, NULL, 0, NULL, 0 ) == 0 ); TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, NULL, 0, - bufQe, lenQ ? lenQ : sizeof( bufQe ), + bufQe, input_Q->len ? input_Q->len : sizeof( bufQe ), NULL, 0, NULL, 0 ) == 0 ); - TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, NULL, 0, - NULL, 0, bufDe, lenD ? lenD : sizeof( bufDe ), + TEST_ASSERT( mbedtls_rsa_export_raw( &ctx, NULL, 0, NULL, 0, NULL, 0, + bufDe, input_D->len ? input_D->len : sizeof( bufDe ), NULL, 0 ) == 0 ); } - if( have_P ) - TEST_ASSERT( memcmp( bufP, bufPe, lenP ) == 0 ); + if( input_P->len ) + TEST_ASSERT( memcmp( input_P->x, bufPe, input_P->len ) == 0 ); - if( have_Q ) - TEST_ASSERT( memcmp( bufQ, bufQe, lenQ ) == 0 ); + if( input_Q->len ) + TEST_ASSERT( memcmp( input_Q->x, bufQe, input_Q->len ) == 0 ); - if( have_D ) - TEST_ASSERT( memcmp( bufD, bufDe, lenD ) == 0 ); + if( input_D->len ) + TEST_ASSERT( memcmp( input_D->x, bufDe, input_D->len ) == 0 ); } @@ -1321,31 +1666,19 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CTR_DRBG_C:MBEDTLS_ENTROPY_C:ENTROPY_HAVE_STRONG */ -void mbedtls_rsa_import_raw( char *input_N, - char *input_P, char *input_Q, - char *input_D, char *input_E, +void mbedtls_rsa_import_raw( data_t *input_N, + data_t *input_P, data_t *input_Q, + data_t *input_D, data_t *input_E, int successive, int is_priv, int res_check, int res_complete ) { - unsigned char bufN[1000]; - unsigned char bufP[1000]; - unsigned char bufQ[1000]; - unsigned char bufD[1000]; - unsigned char bufE[1000]; - /* Buffers used for encryption-decryption test */ unsigned char *buf_orig = NULL; unsigned char *buf_enc = NULL; unsigned char *buf_dec = NULL; - size_t lenN = 0; - size_t lenP = 0; - size_t lenQ = 0; - size_t lenD = 0; - size_t lenE = 0; - mbedtls_rsa_context ctx; mbedtls_entropy_context entropy; mbedtls_ctr_drbg_context ctr_drbg; @@ -1360,29 +1693,14 @@ void mbedtls_rsa_import_raw( char *input_N, &entropy, (const unsigned char *) pers, strlen( pers ) ) == 0 ); - if( strlen( input_N ) ) - lenN = unhexify( bufN, input_N ); - - if( strlen( input_P ) ) - lenP = unhexify( bufP, input_P ); - - if( strlen( input_Q ) ) - lenQ = unhexify( bufQ, input_Q ); - - if( strlen( input_D ) ) - lenD = unhexify( bufD, input_D ); - - if( strlen( input_E ) ) - lenE = unhexify( bufE, input_E ); - if( !successive ) { TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, - ( lenN > 0 ) ? bufN : NULL, lenN, - ( lenP > 0 ) ? bufP : NULL, lenP, - ( lenQ > 0 ) ? bufQ : NULL, lenQ, - ( lenD > 0 ) ? bufD : NULL, lenD, - ( lenE > 0 ) ? bufE : NULL, lenE ) == 0 ); + ( input_N->len > 0 ) ? input_N->x : NULL, input_N->len, + ( input_P->len > 0 ) ? input_P->x : NULL, input_P->len, + ( input_Q->len > 0 ) ? input_Q->x : NULL, input_Q->len, + ( input_D->len > 0 ) ? input_D->x : NULL, input_D->len, + ( input_E->len > 0 ) ? input_E->x : NULL, input_E->len ) == 0 ); } else { @@ -1390,27 +1708,27 @@ void mbedtls_rsa_import_raw( char *input_N, * This should make no functional difference. */ TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, - ( lenN > 0 ) ? bufN : NULL, lenN, + ( input_N->len > 0 ) ? input_N->x : NULL, input_N->len, NULL, 0, NULL, 0, NULL, 0, NULL, 0 ) == 0 ); TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, NULL, 0, - ( lenP > 0 ) ? bufP : NULL, lenP, + ( input_P->len > 0 ) ? input_P->x : NULL, input_P->len, NULL, 0, NULL, 0, NULL, 0 ) == 0 ); TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, NULL, 0, NULL, 0, - ( lenQ > 0 ) ? bufQ : NULL, lenQ, + ( input_Q->len > 0 ) ? input_Q->x : NULL, input_Q->len, NULL, 0, NULL, 0 ) == 0 ); TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, NULL, 0, NULL, 0, NULL, 0, - ( lenD > 0 ) ? bufD : NULL, lenD, + ( input_D->len > 0 ) ? input_D->x : NULL, input_D->len, NULL, 0 ) == 0 ); TEST_ASSERT( mbedtls_rsa_import_raw( &ctx, NULL, 0, NULL, 0, NULL, 0, NULL, 0, - ( lenE > 0 ) ? bufE : NULL, lenE ) == 0 ); + ( input_E->len > 0 ) ? input_E->x : NULL, input_E->len ) == 0 ); } TEST_ASSERT( mbedtls_rsa_complete( &ctx ) == res_complete ); @@ -1467,7 +1785,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void rsa_selftest() +void rsa_selftest( ) { TEST_ASSERT( mbedtls_rsa_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.data index ee8074dc08..2f65c230e4 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.data @@ -1,3 +1,9 @@ +SHA-1 - Valid parameters +sha1_valid_param: + +SHA-1 - Invalid parameters +sha1_invalid_param: + # Test the operation of SHA-1 and SHA-2 SHA-1 Test Vector NIST CAVS #1 depends_on:MBEDTLS_SHA1_C @@ -39,6 +45,12 @@ SHA-1 Test Vector NIST CAVS #10 depends_on:MBEDTLS_SHA1_C mbedtls_sha1:"8236153781bd2f1b81ffe0def1beb46f5a70191142926651503f1b3bb1016acdb9e7f7acced8dd168226f118ff664a01a8800116fd023587bfba52a2558393476f5fc69ce9c65001f23e70476d2cc81c97ea19caeb194e224339bcb23f77a83feac5096f9b3090c51a6ee6d204b735aa71d7e996d380b80822e4dfd43683af9c7442498cacbea64842dfda238cb099927c6efae07fdf7b23a4e4456e0152b24853fe0d5de4179974b2b9d4a1cdbefcbc01d8d311b5dda059136176ea698ab82acf20dd490be47130b1235cb48f8a6710473cfc923e222d94b582f9ae36d4ca2a32d141b8e8cc36638845fbc499bce17698c3fecae2572dbbd470552430d7ef30c238c2124478f1f780483839b4fb73d63a9460206824a5b6b65315b21e3c2f24c97ee7c0e78faad3df549c7ca8ef241876d9aafe9a309f6da352bec2caaa92ee8dca392899ba67dfed90aef33d41fc2494b765cb3e2422c8e595dabbfaca217757453fb322a13203f425f6073a9903e2dc5818ee1da737afc345f0057744e3a56e1681c949eb12273a3bfc20699e423b96e44bd1ff62e50a848a890809bfe1611c6787d3d741103308f849a790f9c015098286dbacfc34c1718b2c2b77e32194a75dda37954a320fa68764027852855a7e5b5274eb1e2cbcd27161d98b59ad245822015f48af82a45c0ed59be94f9af03d9736048570d6e3ef63b1770bc98dfb77de84b1bb1708d872b625d9ab9b06c18e5dbbf34399391f0f8aa26ec0dac7ff4cb8ec97b52bcb942fa6db2385dcd1b3b9d567aaeb425d567b0ebe267235651a1ed9bf78fd93d3c1dd077fe340bb04b00529c58f45124b717c168d07e9826e33376988bc5cf62845c2009980a4dfa69fbc7e5a0b1bb20a5958ca967aec68eb31dd8fccca9afcd30a26bab26279f1bf6724ff":"11863b483809ef88413ca9b0084ac4a5390640af" +SHA-256 Valid parameters +sha256_valid_param: + +SHA-256 Invalid parameters +sha256_invalid_param: + SHA-224 Test Vector NIST CAVS #1 depends_on:MBEDTLS_SHA256_C sha224:"":"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f" @@ -95,6 +107,12 @@ SHA-256 Test Vector NIST CAVS #7 depends_on:MBEDTLS_SHA256_C mbedtls_sha256:"8390cf0be07661cc7669aac54ce09a37733a629d45f5d983ef201f9b2d13800e555d9b1097fec3b783d7a50dcb5e2b644b96a1e9463f177cf34906bf388f366db5c2deee04a30e283f764a97c3b377a034fefc22c259214faa99babaff160ab0aaa7e2ccb0ce09c6b32fe08cbc474694375aba703fadbfa31cf685b30a11c57f3cf4edd321e57d3ae6ebb1133c8260e75b9224fa47a2bb205249add2e2e62f817491482ae152322be0900355cdcc8d42a98f82e961a0dc6f537b7b410eff105f59673bfb787bf042aa071f7af68d944d27371c64160fe9382772372516c230c1f45c0d6b6cca7f274b394da9402d3eafdf733994ec58ab22d71829a98399574d4b5908a447a5a681cb0dd50a31145311d92c22a16de1ead66a5499f2dceb4cae694772ce90762ef8336afec653aa9b1a1c4820b221136dfce80dce2ba920d88a530c9410d0a4e0358a3a11052e58dd73b0b179ef8f56fe3b5a2d117a73a0c38a1392b6938e9782e0d86456ee4884e3c39d4d75813f13633bc79baa07c0d2d555afbf207f52b7dca126d015aa2b9873b3eb065e90b9b065a5373fe1fb1b20d594327d19fba56cb81e7b6696605ffa56eba3c27a438697cc21b201fd7e09f18deea1b3ea2f0d1edc02df0e20396a145412cd6b13c32d2e605641c948b714aec30c0649dc44143511f35ab0fd5dd64c34d06fe86f3836dfe9edeb7f08cfc3bd40956826356242191f99f53473f32b0cc0cf9321d6c92a112e8db90b86ee9e87cc32d0343db01e32ce9eb782cb24efbbbeb440fe929e8f2bf8dfb1550a3a2e742e8b455a3e5730e9e6a7a9824d17acc0f72a7f67eae0f0970f8bde46dcdefaed3047cf807e7f00a42e5fd11d40f5e98533d7574425b7d2bc3b3845c443008b58980e768e464e17cc6f6b3939eee52f713963d07d8c4abf02448ef0b889c9671e2f8a436ddeeffcca7176e9bf9d1005ecd377f2fa67c23ed1f137e60bf46018a8bd613d038e883704fc26e798969df35ec7bbc6a4fe46d8910bd82fa3cded265d0a3b6d399e4251e4d8233daa21b5812fded6536198ff13aa5a1cd46a5b9a17a4ddc1d9f85544d1d1cc16f3df858038c8e071a11a7e157a85a6a8dc47e88d75e7009a8b26fdb73f33a2a70f1e0c259f8f9533b9b8f9af9288b7274f21baeec78d396f8bacdcc22471207d9b4efccd3fedc5c5a2214ff5e51c553f35e21ae696fe51e8df733a8e06f50f419e599e9f9e4b37ce643fc810faaa47989771509d69a110ac916261427026369a21263ac4460fb4f708f8ae28599856db7cb6a43ac8e03d64a9609807e76c5f312b9d1863bfa304e8953647648b4f4ab0ed995e":"4109cdbec3240ad74cc6c37f39300f70fede16e21efc77f7865998714aad0b5e" +SHA-512 Invalid parameters +sha512_invalid_param: + +SHA-512 Valid parameters +sha512_valid_param: + SHA-384 Test Vector NIST CAVS #1 depends_on:MBEDTLS_SHA512_C sha384:"":"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.function index d704b388b8..e621f49cdb 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_shax.function @@ -5,126 +5,250 @@ /* END_HEADER */ /* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */ -void mbedtls_sha1( char *hex_src_string, char *hex_hash_string ) +void sha1_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_sha1_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void sha1_invalid_param( ) +{ + mbedtls_sha1_context ctx; + unsigned char buf[64] = { 0 }; + size_t const buflen = sizeof( buf ); + + TEST_INVALID_PARAM( mbedtls_sha1_init( NULL ) ); + + TEST_INVALID_PARAM( mbedtls_sha1_clone( NULL, &ctx ) ); + TEST_INVALID_PARAM( mbedtls_sha1_clone( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_starts_ret( NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_update_ret( NULL, buf, buflen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_update_ret( &ctx, NULL, buflen ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_finish_ret( NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_finish_ret( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_internal_sha1_process( NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_internal_sha1_process( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_ret( NULL, buflen, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA1_BAD_INPUT_DATA, + mbedtls_sha1_ret( buf, buflen, NULL ) ); + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SHA1_C */ +void mbedtls_sha1( data_t * src_str, data_t * hex_hash_string ) { - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[41]; - int src_len; - memset(src_str, 0x00, 10000); - memset(hash_str, 0x00, 10000); memset(output, 0x00, 41); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_sha1_ret( src_str, src_len, output ) == 0 ); - hexify( hash_str, output, 20 ); + TEST_ASSERT( mbedtls_sha1_ret( src_str->x, src_str->len, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, 20, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */ -void sha224(char *hex_src_string, char *hex_hash_string ) +void sha256_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_sha256_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void sha256_invalid_param( ) +{ + mbedtls_sha256_context ctx; + unsigned char buf[64] = { 0 }; + size_t const buflen = sizeof( buf ); + int valid_type = 0; + int invalid_type = 42; + + TEST_INVALID_PARAM( mbedtls_sha256_init( NULL ) ); + + TEST_INVALID_PARAM( mbedtls_sha256_clone( NULL, &ctx ) ); + TEST_INVALID_PARAM( mbedtls_sha256_clone( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_starts_ret( NULL, valid_type ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_starts_ret( &ctx, invalid_type ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_update_ret( NULL, buf, buflen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_update_ret( &ctx, NULL, buflen ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_finish_ret( NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_finish_ret( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_internal_sha256_process( NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_internal_sha256_process( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_ret( NULL, buflen, + buf, valid_type ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_ret( buf, buflen, + NULL, valid_type ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA256_BAD_INPUT_DATA, + mbedtls_sha256_ret( buf, buflen, + buf, invalid_type ) ); + +exit: + return; +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */ +void sha224( data_t * src_str, data_t * hex_hash_string ) { - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[57]; - int src_len; - memset(src_str, 0x00, 10000); - memset(hash_str, 0x00, 10000); memset(output, 0x00, 57); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_sha256_ret( src_str, src_len, output, 1 ) == 0 ); - hexify( hash_str, output, 28 ); + TEST_ASSERT( mbedtls_sha256_ret( src_str->x, src_str->len, output, 1 ) == 0 ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, 28, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C */ -void mbedtls_sha256(char *hex_src_string, char *hex_hash_string ) +void mbedtls_sha256( data_t * src_str, data_t * hex_hash_string ) { - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[65]; - int src_len; - memset(src_str, 0x00, 10000); - memset(hash_str, 0x00, 10000); memset(output, 0x00, 65); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_sha256_ret( src_str, src_len, output, 0 ) == 0 ); - hexify( hash_str, output, 32 ); + TEST_ASSERT( mbedtls_sha256_ret( src_str->x, src_str->len, output, 0 ) == 0 ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, 32, hex_hash_string->len ) == 0 ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */ +void sha512_valid_param( ) +{ + TEST_VALID_PARAM( mbedtls_sha512_free( NULL ) ); +} +/* END_CASE */ + +/* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */ +void sha512_invalid_param( ) +{ + mbedtls_sha512_context ctx; + unsigned char buf[64] = { 0 }; + size_t const buflen = sizeof( buf ); + int valid_type = 0; + int invalid_type = 42; + + TEST_INVALID_PARAM( mbedtls_sha512_init( NULL ) ); + + TEST_INVALID_PARAM( mbedtls_sha512_clone( NULL, &ctx ) ); + TEST_INVALID_PARAM( mbedtls_sha512_clone( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_starts_ret( NULL, valid_type ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_starts_ret( &ctx, invalid_type ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_update_ret( NULL, buf, buflen ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_update_ret( &ctx, NULL, buflen ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_finish_ret( NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_finish_ret( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_internal_sha512_process( NULL, buf ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_internal_sha512_process( &ctx, NULL ) ); + + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_ret( NULL, buflen, + buf, valid_type ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_ret( buf, buflen, + NULL, valid_type ) ); + TEST_INVALID_PARAM_RET( MBEDTLS_ERR_SHA512_BAD_INPUT_DATA, + mbedtls_sha512_ret( buf, buflen, + buf, invalid_type ) ); + +exit: + return; } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */ -void sha384(char *hex_src_string, char *hex_hash_string ) +void sha384( data_t * src_str, data_t * hex_hash_string ) { - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[97]; - int src_len; - memset(src_str, 0x00, 10000); - memset(hash_str, 0x00, 10000); memset(output, 0x00, 97); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_sha512_ret( src_str, src_len, output, 1 ) == 0 ); - hexify( hash_str, output, 48 ); + TEST_ASSERT( mbedtls_sha512_ret( src_str->x, src_str->len, output, 1 ) == 0 ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, 48, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA512_C */ -void mbedtls_sha512(char *hex_src_string, char *hex_hash_string ) +void mbedtls_sha512( data_t * src_str, data_t * hex_hash_string ) { - unsigned char src_str[10000]; - unsigned char hash_str[10000]; unsigned char output[129]; - int src_len; - memset(src_str, 0x00, 10000); - memset(hash_str, 0x00, 10000); memset(output, 0x00, 129); - src_len = unhexify( src_str, hex_src_string ); - TEST_ASSERT( mbedtls_sha512_ret( src_str, src_len, output, 0 ) == 0 ); - hexify( hash_str, output, 64 ); + TEST_ASSERT( mbedtls_sha512_ret( src_str->x, src_str->len, output, 0 ) == 0 ); - TEST_ASSERT( strcmp( (char *) hash_str, hex_hash_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_hash_string->x, 64, hex_hash_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA1_C:MBEDTLS_SELF_TEST */ -void sha1_selftest() +void sha1_selftest( ) { TEST_ASSERT( mbedtls_sha1_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA256_C:MBEDTLS_SELF_TEST */ -void sha256_selftest() +void sha256_selftest( ) { TEST_ASSERT( mbedtls_sha256_self_test( 1 ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SHA512_C:MBEDTLS_SELF_TEST */ -void sha512_selftest() +void sha512_selftest( ) { TEST_ASSERT( mbedtls_sha512_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.data index b92c1fe8a2..147350744f 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.data @@ -8,52 +8,52 @@ SSL DTLS replay: 0 seen, 0 replayed ssl_dtls_replay:"000000000000":"000000000000":-1 SSL DTLS replay: 0-1 seen, 2 arriving -ssl_dtls_replay:"000000000000,000000000001":"000000000002":0 +ssl_dtls_replay:"000000000000000000000001":"000000000002":0 SSL DTLS replay: 0-1 seen, 1 replayed -ssl_dtls_replay:"000000000000,000000000001":"000000000001":-1 +ssl_dtls_replay:"000000000000000000000001":"000000000001":-1 SSL DTLS replay: 0-1 seen, 0 replayed -ssl_dtls_replay:"000000000000,000000000001":"000000000000":-1 +ssl_dtls_replay:"000000000000000000000001":"000000000000":-1 SSL DTLS replay: new -ssl_dtls_replay:"abcd12340000,abcd12340001,abcd12340003":"abcd12340004":0 +ssl_dtls_replay:"abcd12340000abcd12340001abcd12340003":"abcd12340004":0 SSL DTLS replay: way new -ssl_dtls_replay:"abcd12340000,abcd12340001,abcd12340003":"abcd12350000":0 +ssl_dtls_replay:"abcd12340000abcd12340001abcd12340003":"abcd12350000":0 SSL DTLS replay: delayed -ssl_dtls_replay:"abcd12340000,abcd12340001,abcd12340003":"abcd12340002":0 +ssl_dtls_replay:"abcd12340000abcd12340001abcd12340003":"abcd12340002":0 SSL DTLS replay: lastest replayed -ssl_dtls_replay:"abcd12340000,abcd12340001,abcd12340003":"abcd12340003":-1 +ssl_dtls_replay:"abcd12340000abcd12340001abcd12340003":"abcd12340003":-1 SSL DTLS replay: older replayed -ssl_dtls_replay:"abcd12340000,abcd12340001,abcd12340003":"abcd12340001":-1 +ssl_dtls_replay:"abcd12340000abcd12340001abcd12340003":"abcd12340001":-1 SSL DTLS replay: most recent in window, replayed -ssl_dtls_replay:"abcd12340000,abcd12340002,abcd12340003":"abcd12340002":-1 +ssl_dtls_replay:"abcd12340000abcd12340002abcd12340003":"abcd12340002":-1 SSL DTLS replay: oldest in window, replayed -ssl_dtls_replay:"abcd12340000,abcd12340001,abcd1234003f":"abcd12340000":-1 +ssl_dtls_replay:"abcd12340000abcd12340001abcd1234003f":"abcd12340000":-1 SSL DTLS replay: oldest in window, not replayed -ssl_dtls_replay:"abcd12340001,abcd12340002,abcd1234003f":"abcd12340000":0 +ssl_dtls_replay:"abcd12340001abcd12340002abcd1234003f":"abcd12340000":0 SSL DTLS replay: just out of the window -ssl_dtls_replay:"abcd12340001,abcd12340002,abcd1234003f":"abcd1233ffff":-1 +ssl_dtls_replay:"abcd12340001abcd12340002abcd1234003f":"abcd1233ffff":-1 SSL DTLS replay: way out of the window -ssl_dtls_replay:"abcd12340001,abcd12340002,abcd1234003f":"abcd12330000":-1 +ssl_dtls_replay:"abcd12340001abcd12340002abcd1234003f":"abcd12330000":-1 SSL DTLS replay: big jump then replay -ssl_dtls_replay:"abcd12340000,abcd12340100":"abcd12340100":-1 +ssl_dtls_replay:"abcd12340000abcd12340100":"abcd12340100":-1 SSL DTLS replay: big jump then new -ssl_dtls_replay:"abcd12340000,abcd12340100":"abcd12340101":0 +ssl_dtls_replay:"abcd12340000abcd12340100":"abcd12340101":0 SSL DTLS replay: big jump then just delayed -ssl_dtls_replay:"abcd12340000,abcd12340100":"abcd123400ff":0 +ssl_dtls_replay:"abcd12340000abcd12340100":"abcd123400ff":0 SSL SET_HOSTNAME memory leak: call ssl_set_hostname twice ssl_set_hostname_twice:"server0":"server1" diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.function index 1cd2ed5bb3..326f22d3b2 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_ssl.function @@ -9,11 +9,11 @@ */ /* BEGIN_CASE depends_on:MBEDTLS_SSL_DTLS_ANTI_REPLAY */ -void ssl_dtls_replay( char *prevs, char *new, int ret ) +void ssl_dtls_replay( data_t * prevs, data_t * new, int ret ) { + uint32_t len = 0; mbedtls_ssl_context ssl; mbedtls_ssl_config conf; - char *end_prevs = prevs + strlen( prevs ) + 1; mbedtls_ssl_init( &ssl ); mbedtls_ssl_config_init( &conf ); @@ -25,15 +25,14 @@ void ssl_dtls_replay( char *prevs, char *new, int ret ) TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 ); /* Read previous record numbers */ - for( ; end_prevs - prevs >= 13; prevs += 13 ) + for( len = 0; len < prevs->len; len += 6 ) { - prevs[12] = '\0'; - unhexify( ssl.in_ctr + 2, prevs ); + memcpy( ssl.in_ctr + 2, prevs->x + len, 6 ); mbedtls_ssl_dtls_replay_update( &ssl ); } /* Check new number */ - unhexify( ssl.in_ctr + 2, new ); + memcpy( ssl.in_ctr + 2, new->x, 6 ); TEST_ASSERT( mbedtls_ssl_dtls_replay_check( &ssl ) == ret ); mbedtls_ssl_free( &ssl ); @@ -53,4 +52,3 @@ void ssl_set_hostname_twice( char *hostname0, char *hostname1 ) mbedtls_ssl_free( &ssl ); } /* END_CASE */ - diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.data index 4dddcf7fc1..2522da1eaf 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.data @@ -1,41 +1,17 @@ -Timing: basic timer operation -timing_timer_simple: - -Timing: timer reset -timing_timer_reset: - -Timing: two parallel timers, delay 0 -timing_two_timers:0: - -Timing: two parallel timers, delay 100 -timing_two_timers:100: - -Timing: two parallel timers, delay 1000 -timing_two_timers:1000: - -Timing: two parallel timers, delay 10000 -timing_two_timers:10000: - -Timing: delay 0ms, 0ms -timing_delay:0:0: - -Timing: delay 0ms, 50ms -timing_delay:0:50: - -Timing: delay 50ms, 50ms -timing_delay:50:50: +Timing: hardclock +timing_hardclock: -Timing: delay 50ms, 100ms -timing_delay:50:100: +Timing: get timer +timing_get_timer: -Timing: delay 50ms, 200ms -timing_delay:50:200: +Timing: set alarm with no delay +timing_set_alarm:0: -Timing: alarm in 0 second -timing_alarm:0: +Timing: set alarm with 1s delay +timing_set_alarm:1: -Timing: alarm in 1 second -timing_alarm:1: +Timing: delay 0ms +timing_delay:0: -Timing: hardclock -timing_hardclock: +Timing: delay 100ms +timing_delay:100: diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.function index 1610155fbf..74dc823171 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_timing.function @@ -1,51 +1,14 @@ /* BEGIN_HEADER */ -/* This test module exercises the timing module. One of the expected failure - modes is for timers to never expire, which could lead to an infinite loop. - The function timing_timer_simple is protected against this failure mode and - checks that timers do expire. Other functions will terminate if their - timers do expire. Therefore it is recommended to run timing_timer_simple - first and run other test functions only if that timing_timer_simple - succeeded. */ +/* This test module exercises the timing module. Since, depending on the + * underlying operating system, the timing routines are not always reliable, + * this suite only performs very basic sanity checks of the timing API. + */ #include #include "mbedtls/timing.h" -/* Wait this many milliseconds for a short timing test. This duration - should be large enough that, in practice, if you read the timer - value twice in a row, it won't have jumped by that much. */ -#define TIMING_SHORT_TEST_MS 100 - -/* A loop that waits TIMING_SHORT_TEST_MS must not take more than this many - iterations. This value needs to be large enough to accommodate fast - platforms (e.g. at 4GHz and 10 cycles/iteration a CPU can run through 20 - million iterations in 50ms). The only motivation to keep this value low is - to avoid having an infinite loop if the timer functions are not implemented - correctly. Ideally this value should be based on the processor speed but we - don't have this information! */ -#define TIMING_SHORT_TEST_ITERATIONS_MAX 1e8 - -/* alarm(0) must fire in no longer than this amount of time. */ -#define TIMING_ALARM_0_DELAY_MS TIMING_SHORT_TEST_MS - -static int expected_delay_status( uint32_t int_ms, uint32_t fin_ms, - unsigned long actual_ms ) -{ - return( fin_ms == 0 ? -1 : - actual_ms >= fin_ms ? 2 : - actual_ms >= int_ms ? 1 : - 0 ); -} - -/* Some conditions in timing_timer_simple suggest that timers are unreliable. - Most other test cases rely on timers to terminate, and could loop - indefinitely if timers are too broken. So if timing_timer_simple detected a - timer that risks not terminating (going backwards, or not reaching the - desired count in the alloted clock cycles), set this flag to immediately - fail those other tests without running any timers. */ -static int timers_are_badly_broken = 0; - /* END_HEADER */ /* BEGIN_DEPENDENCIES @@ -54,350 +17,58 @@ static int timers_are_badly_broken = 0; */ /* BEGIN_CASE */ -void timing_timer_simple( ) +void timing_hardclock( ) { - struct mbedtls_timing_hr_time timer; - unsigned long millis = 0; - unsigned long new_millis = 0; - unsigned long iterations = 0; - /* Start the timer. */ - (void) mbedtls_timing_get_timer( &timer, 1 ); - /* Busy-wait loop for a few milliseconds. */ - do - { - new_millis = mbedtls_timing_get_timer( &timer, 0 ); - ++iterations; - /* Check that the timer didn't go backwards */ - TEST_ASSERT( new_millis >= millis ); - millis = new_millis; - } - while( millis < TIMING_SHORT_TEST_MS && - iterations <= TIMING_SHORT_TEST_ITERATIONS_MAX ); - /* The wait duration should have been large enough for at least a - few runs through the loop, even on the slowest realistic platform. */ - TEST_ASSERT( iterations >= 2 ); - /* The wait duration shouldn't have overflowed the iteration count. */ - TEST_ASSERT( iterations < TIMING_SHORT_TEST_ITERATIONS_MAX ); - return; - -exit: - if( iterations >= TIMING_SHORT_TEST_ITERATIONS_MAX || - new_millis < millis ) - { - /* The timer was very unreliable: it didn't increment and the loop ran - out, or it went backwards. Other tests that use timers might go - into an infinite loop, so we'll skip them. */ - timers_are_badly_broken = 1; - } - - /* No cleanup needed, but show some diagnostic iterations, because timing - problems can be hard to reproduce. */ - mbedtls_fprintf( stdout, " Finished with millis=%lu new_millis=%lu get(timer)<=%lu iterations=%lu\n", - millis, new_millis, mbedtls_timing_get_timer( &timer, 0 ), - iterations ); + (void) mbedtls_timing_hardclock(); + /* This goto is added to avoid warnings from the generated code. */ + goto exit; } /* END_CASE */ /* BEGIN_CASE */ -void timing_timer_reset( ) +void timing_get_timer( ) { - struct mbedtls_timing_hr_time timer; - unsigned long millis = 0; - unsigned long iterations = 0; - - /* Skip this test if it looks like timers don't work at all, to avoid an - infinite loop below. */ - TEST_ASSERT( !timers_are_badly_broken ); - - /* Start the timer. Timers are always reset to 0. */ - TEST_ASSERT( mbedtls_timing_get_timer( &timer, 1 ) == 0 ); - /* Busy-wait loop for a few milliseconds */ - do - { - ++iterations; - millis = mbedtls_timing_get_timer( &timer, 0 ); - } - while( millis < TIMING_SHORT_TEST_MS ); - - /* Reset the timer and check that it has restarted. */ - TEST_ASSERT( mbedtls_timing_get_timer( &timer, 1 ) == 0 ); - /* Read the timer immediately after reset. It should be 0 or close - to it. */ - TEST_ASSERT( mbedtls_timing_get_timer( &timer, 0 ) < TIMING_SHORT_TEST_MS ); - return; - -exit: - /* No cleanup needed, but show some diagnostic information, because timing - problems can be hard to reproduce. */ - if( !timers_are_badly_broken ) - mbedtls_fprintf( stdout, " Finished with millis=%lu get(timer)<=%lu iterations=%lu\n", - millis, mbedtls_timing_get_timer( &timer, 0 ), - iterations ); + struct mbedtls_timing_hr_time time; + (void) mbedtls_timing_get_timer( &time, 1 ); + (void) mbedtls_timing_get_timer( &time, 0 ); + /* This goto is added to avoid warnings from the generated code. */ + goto exit; } /* END_CASE */ /* BEGIN_CASE */ -void timing_two_timers( int delta ) +void timing_set_alarm( int seconds ) { - struct mbedtls_timing_hr_time timer1, timer2; - unsigned long millis1 = 0, millis2 = 0; - - /* Skip this test if it looks like timers don't work at all, to avoid an - infinite loop below. */ - TEST_ASSERT( !timers_are_badly_broken ); - - /* Start the first timer and wait for a short time. */ - (void) mbedtls_timing_get_timer( &timer1, 1 ); - do - { - millis1 = mbedtls_timing_get_timer( &timer1, 0 ); - } - while( millis1 < TIMING_SHORT_TEST_MS ); - - /* Do a short busy-wait, so that the difference between timer1 and timer2 - doesn't practically always end up being very close to a whole number of - milliseconds. */ - while( delta > 0 ) - --delta; - - /* Start the second timer and compare it with the first. */ - mbedtls_timing_get_timer( &timer2, 1 ); - do + if( seconds == 0 ) { - millis1 = mbedtls_timing_get_timer( &timer1, 0 ); - millis2 = mbedtls_timing_get_timer( &timer2, 0 ); - /* The first timer should always be ahead of the first. */ - TEST_ASSERT( millis1 > millis2 ); - /* The timers shouldn't drift apart, i.e. millis2-millis1 should stay - roughly constant, but this is hard to test reliably, especially in - a busy environment such as an overloaded continuous integration - system, so we don't test it it. */ + mbedtls_set_alarm( seconds ); + TEST_ASSERT( mbedtls_timing_alarmed == 1 ); } - while( millis2 < TIMING_SHORT_TEST_MS ); - - return; - -exit: - /* No cleanup needed, but show some diagnostic iterations, because timing - problems can be hard to reproduce. */ - if( !timers_are_badly_broken ) - mbedtls_fprintf( stdout, " Finished with millis1=%lu get(timer1)<=%lu millis2=%lu get(timer2)<=%lu\n", - millis1, mbedtls_timing_get_timer( &timer1, 0 ), - millis2, mbedtls_timing_get_timer( &timer2, 0 ) ); -} -/* END_CASE */ - -/* BEGIN_CASE */ -void timing_alarm( int seconds ) -{ - struct mbedtls_timing_hr_time timer; - unsigned long millis = 0; - /* We check that about the desired number of seconds has elapsed. Be - slightly liberal with the lower bound, so as to allow platforms where - the alarm (with second resolution) and the timer (with millisecond - resolution) are based on different clocks. Be very liberal with the - upper bound, because the platform might be busy. */ - unsigned long millis_min = ( seconds > 0 ? - seconds * 900 : - 0 ); - unsigned long millis_max = ( seconds > 0 ? - seconds * 1100 + 400 : - TIMING_ALARM_0_DELAY_MS ); - unsigned long iterations = 0; - - /* Skip this test if it looks like timers don't work at all, to avoid an - infinite loop below. */ - TEST_ASSERT( !timers_are_badly_broken ); - - /* Set an alarm and count how long it takes with a timer. */ - (void) mbedtls_timing_get_timer( &timer, 1 ); - mbedtls_set_alarm( seconds ); - - if( seconds > 0 ) - { - /* We set the alarm for at least 1 second. It should not have fired - immediately, even on a slow and busy platform. */ - TEST_ASSERT( !mbedtls_timing_alarmed ); - } - /* A 0-second alarm should fire quickly, but we don't guarantee that it - fires immediately, so mbedtls_timing_alarmed may or may not be set at - this point. */ - - /* Busy-wait until the alarm rings */ - do + else { - ++iterations; - millis = mbedtls_timing_get_timer( &timer, 0 ); + mbedtls_set_alarm( seconds ); + TEST_ASSERT( mbedtls_timing_alarmed == 0 || + mbedtls_timing_alarmed == 1 ); } - while( !mbedtls_timing_alarmed && millis <= millis_max ); - - TEST_ASSERT( mbedtls_timing_alarmed ); - TEST_ASSERT( millis >= millis_min ); - TEST_ASSERT( millis <= millis_max ); - - mbedtls_timing_alarmed = 0; - return; - -exit: - /* Show some diagnostic iterations, because timing - problems can be hard to reproduce. */ - if( !timers_are_badly_broken ) - mbedtls_fprintf( stdout, " Finished with alarmed=%d millis=%lu get(timer)<=%lu iterations=%lu\n", - mbedtls_timing_alarmed, - millis, mbedtls_timing_get_timer( &timer, 0 ), - iterations ); - /* Cleanup */ - mbedtls_timing_alarmed = 0; } /* END_CASE */ /* BEGIN_CASE */ -void timing_delay( int int_ms, int fin_ms ) +void timing_delay( int fin_ms ) { - /* This function assumes that if int_ms is nonzero then it is large - enough that we have time to read all timers at least once in an - interval of time lasting int_ms milliseconds, and likewise for (fin_ms - - int_ms). So don't call it with arguments that are too small. */ - - mbedtls_timing_delay_context delay; - struct mbedtls_timing_hr_time timer; - unsigned long delta = 0; /* delay started between timer=0 and timer=delta */ - unsigned long before = 0, after = 0; - unsigned long iterations = 0; - int status = -2; - int saw_status_1 = 0; - int warn_inconclusive = 0; - - assert( int_ms >= 0 ); - assert( fin_ms >= 0 ); - - /* Skip this test if it looks like timers don't work at all, to avoid an - infinite loop below. */ - TEST_ASSERT( !timers_are_badly_broken ); - - /* Start a reference timer. Program a delay, and verify that the status of - the delay is consistent with the time given by the reference timer. */ - (void) mbedtls_timing_get_timer( &timer, 1 ); - mbedtls_timing_set_delay( &delay, int_ms, fin_ms ); - /* Set delta to an upper bound for the interval between the start of timer - and the start of delay. Reading timer after starting delay gives us an - upper bound for the interval, rounded to a 1ms precision. Since this - might have been rounded down, but we need an upper bound, we add 1. */ - delta = mbedtls_timing_get_timer( &timer, 0 ) + 1; - - status = mbedtls_timing_get_delay( &delay ); + mbedtls_timing_delay_context ctx; + int result; if( fin_ms == 0 ) { - /* Cancelled timer. Just check the correct status for this case. */ - TEST_ASSERT( status == -1 ); - return; - } - - /* Initially, none of the delays must be passed yet if they're nonzero. - This could fail for very small values of int_ms and fin_ms, where "very - small" depends how fast and how busy the platform is. */ - if( int_ms > 0 ) - { - TEST_ASSERT( status == 0 ); + mbedtls_timing_set_delay( &ctx, 0, 0 ); + result = mbedtls_timing_get_delay( &ctx ); + TEST_ASSERT( result == -1 ); } else { - TEST_ASSERT( status == 1 ); + mbedtls_timing_set_delay( &ctx, fin_ms / 2, fin_ms ); + result = mbedtls_timing_get_delay( &ctx ); + TEST_ASSERT( result >= 0 && result <= 2 ); } - - do - { - unsigned long delay_min, delay_max; - int status_min, status_max; - ++iterations; - before = mbedtls_timing_get_timer( &timer, 0 ); - status = mbedtls_timing_get_delay( &delay ); - after = mbedtls_timing_get_timer( &timer, 0 ); - /* At a time between before and after, the delay's status was status. - Check that this is consistent given that the delay was started - between times 0 and delta. */ - delay_min = ( before > delta ? before - delta : 0 ); - status_min = expected_delay_status( int_ms, fin_ms, delay_min ); - delay_max = after; - status_max = expected_delay_status( int_ms, fin_ms, delay_max ); - TEST_ASSERT( status >= status_min ); - TEST_ASSERT( status <= status_max ); - if( status == 1 ) - saw_status_1 = 1; - } - while ( before <= fin_ms + delta && status != 2 ); - - /* Since we've waited at least fin_ms, the delay must have fully - expired. */ - TEST_ASSERT( status == 2 ); - - /* If the second delay is more than the first, then there must have been a - point in time when the first delay was passed but not the second delay. - This could fail for very small values of (fin_ms - int_ms), where "very - small" depends how fast and how busy the platform is. In practice, this - is the test that's most likely to fail on a heavily loaded machine. */ - if( fin_ms > int_ms ) - { - warn_inconclusive = 1; - TEST_ASSERT( saw_status_1 ); - } - - return; - -exit: - /* No cleanup needed, but show some diagnostic iterations, because timing - problems can be hard to reproduce. */ - if( !timers_are_badly_broken ) - mbedtls_fprintf( stdout, " Finished with delta=%lu before=%lu after=%lu status=%d iterations=%lu\n", - delta, before, after, status, iterations ); - if( warn_inconclusive ) - mbedtls_fprintf( stdout, " Inconclusive test, try running it on a less heavily loaded machine.\n" ); - } -/* END_CASE */ - -/* BEGIN_CASE */ -void timing_hardclock( ) -{ - /* We make very few guarantees about mbedtls_timing_hardclock: its rate is - platform-dependent, it can wrap around. So there isn't much we can - test. But we do at least test that it doesn't crash, stall or return - completely nonsensical values. */ - - struct mbedtls_timing_hr_time timer; - unsigned long hardclock0 = -1, hardclock1 = -1, delta1 = -1; - - /* Skip this test if it looks like timers don't work at all, to avoid an - infinite loop below. */ - TEST_ASSERT( !timers_are_badly_broken ); - - hardclock0 = mbedtls_timing_hardclock( ); - /* Wait 2ms to ensure a nonzero delay. Since the timer interface has 1ms - resolution and unspecified precision, waiting 1ms might be a very small - delay that's rounded up. */ - (void) mbedtls_timing_get_timer( &timer, 1 ); - while( mbedtls_timing_get_timer( &timer, 0 ) < 2 ) - /*busy-wait loop*/; - hardclock1 = mbedtls_timing_hardclock( ); - - /* Although the hardclock counter can wrap around, the difference - (hardclock1 - hardclock0) is taken modulo the type size, so it is - correct as long as the counter only wrapped around at most once. We - further require the difference to be nonzero (after a wait of more than - 1ms, the counter must have changed), and not to be overly large (after - a wait of less than 3ms, plus time lost because other processes were - scheduled on the CPU). If the hardclock counter runs at 4GHz, then - 1000000000 (which is 1/4 of the counter wraparound on a 32-bit machine) - allows 250ms. */ - delta1 = hardclock1 - hardclock0; - TEST_ASSERT( delta1 > 0 ); - TEST_ASSERT( delta1 < 1000000000 ); - return; - -exit: - /* No cleanup needed, but show some diagnostic iterations, because timing - problems can be hard to reproduce. */ - if( !timers_are_badly_broken ) - mbedtls_fprintf( stdout, " Finished with hardclock=%lu,%lu\n", - hardclock0, hardclock1 ); } /* END_CASE */ diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.data index eafceb3e84..cd1cee4616 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.data @@ -1,8 +1,8 @@ Check compiletime library version -check_compiletime_version:"2.7.9" +check_compiletime_version:"2.16.2" Check runtime library version -check_runtime_version:"2.7.9" +check_runtime_version:"2.16.2" Check for MBEDTLS_VERSION_C check_feature:"MBEDTLS_VERSION_C":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.function index a4847f92c5..10f9e1154e 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_version.function @@ -8,7 +8,7 @@ */ /* BEGIN_CASE */ -void check_compiletime_version( char *version_str ) +void check_compiletime_version( char * version_str ) { char build_str[100]; char build_str_full[100]; @@ -35,7 +35,7 @@ void check_compiletime_version( char *version_str ) /* END_CASE */ /* BEGIN_CASE */ -void check_runtime_version( char *version_str ) +void check_runtime_version( char * version_str ) { char build_str[100]; char get_str[100]; diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.data index 19a8af31c4..b64414a67f 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.data @@ -2,25 +2,37 @@ X509 Certificate information #1 depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C x509_cert_info:"data_files/server1.crt":"cert. version \: 3\nserial number \: 01\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nissued on \: 2011-02-12 14\:44\:06\nexpires on \: 2021-02-12 14\:44\:06\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" +X509 Certificate information #1 (DER) +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C +x509_cert_info:"data_files/server1.crt.der":"cert. version \: 3\nserial number \: 01\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nissued on \: 2011-02-12 14\:44\:06\nexpires on \: 2021-02-12 14\:44\:06\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" + X509 Certificate information #2 depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C x509_cert_info:"data_files/server2.crt":"cert. version \: 3\nserial number \: 02\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nissued on \: 2011-02-12 14\:44\:06\nexpires on \: 2021-02-12 14\:44\:06\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" +X509 Certificate information #2 (DER) +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C +x509_cert_info:"data_files/server2.crt.der":"cert. version \: 3\nserial number \: 02\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nissued on \: 2011-02-12 14\:44\:06\nexpires on \: 2021-02-12 14\:44\:06\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" + X509 Certificate information #3 depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C -x509_cert_info:"data_files/test-ca.crt":"cert. version \: 3\nserial number \: 00\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nissued on \: 2011-02-12 14\:44\:00\nexpires on \: 2021-02-12 14\:44\:00\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=true\n" +x509_cert_info:"data_files/test-ca.crt":"cert. version \: 3\nserial number \: 03\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nissued on \: 2011-02-12 14\:44\:00\nexpires on \: 2021-02-12 14\:44\:00\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=true\n" + +X509 Certificate information #3 (DER) +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C +x509_cert_info:"data_files/test-ca.crt.der":"cert. version \: 3\nserial number \: 03\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nissued on \: 2011-02-12 14\:44\:00\nexpires on \: 2021-02-12 14\:44\:00\nsigned using \: RSA with SHA1\nRSA key size \: 2048 bits\nbasic constraints \: CA=true\n" X509 Certificate information MD2 Digest depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509_cert_info:"data_files/cert_md2.crt":"cert. version \: 3\nserial number \: 09\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Cert MD2\nissued on \: 2009-07-12 10\:56\:59\nexpires on \: 2011-07-12 10\:56\:59\nsigned using \: RSA with MD2\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" +x509_cert_info:"data_files/cert_md2.crt":"cert. version \: 3\nserial number \: 09\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Cert MD2\nissued on \: 2000-01-01 12\:12\:12\nexpires on \: 2030-01-01 12\:12\:12\nsigned using \: RSA with MD2\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" X509 Certificate information MD4 Digest depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD4_C -x509_cert_info:"data_files/cert_md4.crt":"cert. version \: 3\nserial number \: 05\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Cert MD4\nissued on \: 2011-02-12 14\:44\:07\nexpires on \: 2021-02-12 14\:44\:07\nsigned using \: RSA with MD4\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" +x509_cert_info:"data_files/cert_md4.crt":"cert. version \: 3\nserial number \: 05\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Cert MD4\nissued on \: 2000-01-01 12\:12\:12\nexpires on \: 2030-01-01 12\:12\:12\nsigned using \: RSA with MD4\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" X509 Certificate information MD5 Digest depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_MD5_C -x509_cert_info:"data_files/cert_md5.crt":"cert. version \: 3\nserial number \: 06\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Cert MD5\nissued on \: 2011-02-12 14\:44\:07\nexpires on \: 2021-02-12 14\:44\:07\nsigned using \: RSA with MD5\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" +x509_cert_info:"data_files/cert_md5.crt":"cert. version \: 3\nserial number \: 06\nissuer name \: C=NL, O=PolarSSL, CN=PolarSSL Test CA\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Cert MD5\nissued on \: 2000-01-01 12\:12\:12\nexpires on \: 2030-01-01 12\:12\:12\nsigned using \: RSA with MD5\nRSA key size \: 2048 bits\nbasic constraints \: CA=false\n" X509 Certificate information SHA1 Digest depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA1_C @@ -226,7 +238,7 @@ X509 CSR Information RSA with SHA224 depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_RSA_C mbedtls_x509_csr_info:"data_files/server1.req.sha224":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-224\nRSA key size \: 2048 bits\n" -X509 CSR Information RSA with SHA256 +X509 CSR Information RSA with SHA-256 depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_RSA_C mbedtls_x509_csr_info:"data_files/server1.req.sha256":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-256\nRSA key size \: 2048 bits\n" @@ -278,6 +290,10 @@ X509 CSR Information RSA-PSS with SHA512 depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT:MBEDTLS_SHA512_C mbedtls_x509_csr_info:"data_files/server9.req.sha512":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: RSASSA-PSS (SHA512, MGF1-SHA512, 0x3E)\nRSA key size \: 1024 bits\n" +X509 CSR Information RSA with SHA-256 - Microsoft header +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_RSA_C +mbedtls_x509_csr_info:"data_files/server1-ms.req.sha256":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=PolarSSL Server 1\nsigned using \: RSA with SHA-256\nRSA key size \: 2048 bits\n" + X509 Verify Information: empty x509_verify_info:0:"":"" @@ -447,14 +463,30 @@ X509 Certificate verification #10 (Not trusted Cert, Expired CRL) depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA1_C x509_verify:"data_files/server2.crt":"data_files/server1.crt":"data_files/crl_expired.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:"compat":"NULL" -X509 Certificate verification #12 (Valid Cert MD4 Digest) +X509 Certificate verification #12 (Valid Cert MD2 Digest, MD2 forbidden) +depends_on:MBEDTLS_MD2_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md2.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"compat":"NULL" + +X509 Certificate verification #12 (Valid Cert MD4 Digest, MD4 forbidden) depends_on:MBEDTLS_MD4_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 x509_verify:"data_files/cert_md4.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"compat":"NULL" -X509 Certificate verification #13 (Valid Cert MD5 Digest) +X509 Certificate verification #13 (Valid Cert MD5 Digest, MD5 forbidden) depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_BAD_MD:"compat":"NULL" +X509 Certificate verification #12 (Valid Cert MD2 Digest, MD2 allowed) +depends_on:MBEDTLS_MD2_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md2.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"all":"NULL" + +X509 Certificate verification #12 (Valid Cert MD4 Digest, MD4 allowed) +depends_on:MBEDTLS_MD4_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md4.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"all":"NULL" + +X509 Certificate verification #13 (Valid Cert MD5 Digest, MD5 allowed) +depends_on:MBEDTLS_MD5_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_verify:"data_files/cert_md5.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"all":"NULL" + X509 Certificate verification #14 (Valid Cert SHA1 Digest explicitly allowed in profile) depends_on:MBEDTLS_SHA1_C:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 x509_verify:"data_files/cert_sha1.crt":"data_files/test-ca.crt":"data_files/crl.pem":"NULL":0:0:"compat":"NULL" @@ -825,7 +857,7 @@ x509_verify_callback:"data_files/server5-ss-expired.crt":"data_files/server5-ss- X509 Certificate verification callback: simple depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_verify_callback:"data_files/server1.crt":"data_files/test-ca.crt":"NULL":0:"depth 1 - serial 00 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" +x509_verify_callback:"data_files/server1.crt":"data_files/test-ca.crt":"NULL":0:"depth 1 - serial 03 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" X509 Certificate verification callback: simple, EE expired depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA256_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_HAVE_TIME_DATE @@ -837,15 +869,15 @@ x509_verify_callback:"data_files/server5.crt":"data_files/test-ca2-expired.crt": X509 Certificate verification callback: two trusted roots depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C -x509_verify_callback:"data_files/server1.crt":"data_files/test-ca_cat12.crt":"NULL":0:"depth 1 - serial 00 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" +x509_verify_callback:"data_files/server1.crt":"data_files/test-ca_cat12.crt":"NULL":0:"depth 1 - serial 03 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" X509 Certificate verification callback: two trusted roots, reversed order depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C -x509_verify_callback:"data_files/server1.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 1 - serial 00 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" +x509_verify_callback:"data_files/server1.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 1 - serial 03 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" X509 Certificate verification callback: root included depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_SHA256_C -x509_verify_callback:"data_files/server1_ca.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 1 - serial 00 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" +x509_verify_callback:"data_files/server1_ca.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 1 - serial 03 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 0 - serial 01 - subject C=NL, O=PolarSSL, CN=PolarSSL Server 1 - flags 0x00000000\n" X509 Certificate verification callback: intermediate ca depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C @@ -873,11 +905,11 @@ x509_verify_callback:"data_files/server7_int-ca.crt":"data_files/test-ca2-expire X509 Certificate verification callback: two intermediates depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C -x509_verify_callback:"data_files/server10_int3_int-ca2.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 3 - serial 00 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 2 - serial 0F - subject C=NL, O=PolarSSL, CN=PolarSSL Test Intermediate EC CA - flags 0x00000000\ndepth 1 - serial 4D - subject C=UK, O=mbed TLS, CN=mbed TLS Test intermediate CA 3 - flags 0x00000000\ndepth 0 - serial 4B - subject CN=localhost - flags 0x00000000\n" +x509_verify_callback:"data_files/server10_int3_int-ca2.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 3 - serial 03 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 2 - serial 0F - subject C=NL, O=PolarSSL, CN=PolarSSL Test Intermediate EC CA - flags 0x00000000\ndepth 1 - serial 4D - subject C=UK, O=mbed TLS, CN=mbed TLS Test intermediate CA 3 - flags 0x00000000\ndepth 0 - serial 4B - subject CN=localhost - flags 0x00000000\n" X509 Certificate verification callback: two intermediates, root included depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C:MBEDTLS_SHA1_C -x509_verify_callback:"data_files/server10_int3_int-ca2_ca.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 3 - serial 00 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 2 - serial 0F - subject C=NL, O=PolarSSL, CN=PolarSSL Test Intermediate EC CA - flags 0x00000000\ndepth 1 - serial 4D - subject C=UK, O=mbed TLS, CN=mbed TLS Test intermediate CA 3 - flags 0x00000000\ndepth 0 - serial 4B - subject CN=localhost - flags 0x00000000\n" +x509_verify_callback:"data_files/server10_int3_int-ca2_ca.crt":"data_files/test-ca_cat21.crt":"NULL":0:"depth 3 - serial 03 - subject C=NL, O=PolarSSL, CN=PolarSSL Test CA - flags 0x00000000\ndepth 2 - serial 0F - subject C=NL, O=PolarSSL, CN=PolarSSL Test Intermediate EC CA - flags 0x00000000\ndepth 1 - serial 4D - subject C=UK, O=mbed TLS, CN=mbed TLS Test intermediate CA 3 - flags 0x00000000\ndepth 0 - serial 4B - subject CN=localhost - flags 0x00000000\n" X509 Certificate verification callback: two intermediates, top int trusted depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_RSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_SHA256_C @@ -972,171 +1004,171 @@ X509 Certificate ASN1 (TBSCertificate, correct alg, unknown alg_id) x509parse_crt:"30173015a0030201028204deadbeef30080604cafed00d0500":"":MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + MBEDTLS_ERR_OID_NOT_FOUND X509 Certificate ASN1 (TBSCertificate, correct alg, specific alg_id) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"301c301aa0030201028204deadbeef300d06092a864886f70d0101020500":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"301c301aa0030201028204deadbeef300d06092a864886f70d01010b0500":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, correct alg, unknown specific alg_id) x509parse_crt:"301c301aa0030201028204deadbeef300d06092a864886f70d0101010500":"":MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG + MBEDTLS_ERR_OID_NOT_FOUND X509 Certificate ASN1 (TBSCertificate, correct alg, bad RSASSA-PSS params) depends_on:MBEDTLS_X509_RSASSA_PSS_SUPPORT -x509parse_crt:"30193017A003020102020118300D06092A864886F70D01010A3100":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509parse_crt:"30193017a003020102020118300d06092a864886f70d01010a3100":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate, issuer no set data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"301e301ca0030201028204deadbeef300d06092a864886f70d01010205003000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"301e301ca0030201028204deadbeef300d06092a864886f70d01010b05003000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, issuer no inner seq data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"3020301ea0030201028204deadbeef300d06092a864886f70d010102050030023100":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"3020301ea0030201028204deadbeef300d06092a864886f70d01010b050030023100":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, issuer no inner set data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30223020a0030201028204deadbeef300d06092a864886f70d0101020500300431023000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30223020a0030201028204deadbeef300d06092a864886f70d01010b0500300431023000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, issuer two inner set datas) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30243022a0030201028204deadbeef300d06092a864886f70d01010205003006310430003000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30243022a0030201028204deadbeef300d06092a864886f70d01010b05003006310430003000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, issuer no oid data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30243022a0030201028204deadbeef300d06092a864886f70d01010205003006310430020600":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30243022a0030201028204deadbeef300d06092a864886f70d01010b05003006310430020600":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, issuer invalid tag) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"302a3028a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600060454657374":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"302a3028a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600060454657374":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate, issuer, no string data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30253023a0030201028204deadbeef300d06092a864886f70d0101020500300731053003060013":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30253023a0030201028204deadbeef300d06092a864886f70d01010b0500300731053003060013":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, issuer, no full following string) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"302b3029a0030201028204deadbeef300d06092a864886f70d0101020500300d310b3009060013045465737400":"":MBEDTLS_ERR_X509_INVALID_NAME+MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"302b3029a0030201028204deadbeef300d06092a864886f70d01010b0500300d310b3009060013045465737400":"":MBEDTLS_ERR_X509_INVALID_NAME+MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 Certificate ASN1 (TBSCertificate, valid issuer, no validity) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"302a3028a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374":"":MBEDTLS_ERR_X509_INVALID_DATE + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"302a3028a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374":"":MBEDTLS_ERR_X509_INVALID_DATE + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, too much date data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30493047a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301d170c303930313031303030303030170c30393132333132333539353900":"":MBEDTLS_ERR_X509_INVALID_DATE + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30493047a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301d170c303930313031303030303030170c30393132333132333539353900":"":MBEDTLS_ERR_X509_INVALID_DATE + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 Certificate ASN1 (TBSCertificate, invalid from date) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30483046a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303000000000170c303931323331323300000000":"":MBEDTLS_ERR_X509_INVALID_DATE +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30483046a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303000000000170c303931323331323300000000":"":MBEDTLS_ERR_X509_INVALID_DATE X509 Certificate ASN1 (TBSCertificate, invalid to date) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30483046a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323300000000":"":MBEDTLS_ERR_X509_INVALID_DATE +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30483046a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323300000000":"":MBEDTLS_ERR_X509_INVALID_DATE X509 Certificate ASN1 (TBSCertificate, valid validity, no subject) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30493047a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c30393132333132333539353930":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30493047a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c30393132333132333539353930":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, valid subject, no pubkeyinfo) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30563054a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30563054a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, pubkey, no alg) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30583056a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743000":"":MBEDTLS_ERR_PK_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30583056a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743000":"":MBEDTLS_ERR_PK_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, valid subject, unknown pk alg) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30673065a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374300f300d06092A864886F70D0101000500":"":MBEDTLS_ERR_PK_UNKNOWN_PK_ALG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30673065a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374300f300d06092a864886f70d0101000500":"":MBEDTLS_ERR_PK_UNKNOWN_PK_ALG X509 Certificate ASN1 (TBSCertificate, pubkey, no bitstring) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30673065a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374300f300d06092A864886F70D0101010500":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30673065a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374300f300d06092a864886f70d0101010500":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate, pubkey, no bitstring data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30693067a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743011300d06092A864886F70D01010105000300":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_INVALID_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30693067a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743011300d06092a864886f70d01010105000300":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_INVALID_DATA X509 Certificate ASN1 (TBSCertificate, pubkey, invalid bitstring start) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"306a3068a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743012300d06092A864886F70D0101010500030101":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_INVALID_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"306a3068a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743012300d06092a864886f70d0101010500030101":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_INVALID_DATA X509 Certificate ASN1 (TBSCertificate, pubkey, invalid internal bitstring length) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"306d306ba0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743015300d06092A864886F70D0101010500030400300000":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"306d306ba0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743015300d06092a864886f70d0101010500030400300000":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 Certificate ASN1 (TBSCertificate, pubkey, invalid internal bitstring tag) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"306d306ba0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743015300d06092A864886F70D0101010500030400310000":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"306d306ba0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a300806001304546573743015300d06092a864886f70d0101010500030400310000":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate, pubkey, invalid mbedtls_mpi) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30743072a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301c300d06092A864886F70D0101010500030b0030080202ffff0302ffff":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30743072a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301c300d06092a864886f70d0101010500030b0030080202ffff0302ffff":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate, pubkey, total length mismatch) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30753073a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301d300d06092A864886F70D0101010500030b0030080202ffff0202ffff00":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30753073a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301d300d06092a864886f70d0101010500030b0030080202ffff0202ffff00":"":MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 Certificate ASN1 (TBSCertificate, pubkey, check failed) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30743072a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301c300d06092A864886F70D0101010500030b0030080202ffff0202ffff":"":MBEDTLS_ERR_PK_INVALID_PUBKEY +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30743072a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374301c300d06092a864886f70d0101010500030b0030080202ffff0202ffff":"":MBEDTLS_ERR_PK_INVALID_PUBKEY X509 Certificate ASN1 (TBSCertificate, pubkey, check failed, expanded length notation) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308183308180a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210fffffffffffffffffffffffffffffffe0202ffff":"":MBEDTLS_ERR_PK_INVALID_PUBKEY +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308183308180a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210fffffffffffffffffffffffffffffffe0202ffff":"":MBEDTLS_ERR_PK_INVALID_PUBKEY X509 Certificate ASN1 (TBSCertificate v3, Optional UIDs, Extensions not present) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308183308180a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308183308180a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, issuerID wrong tag) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308184308181a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff00":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308184308181a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff00":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate v3, UIDs, no ext) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308189308186a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bb":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308189308186a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bb":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, UIDs, invalid length) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308189308186a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa185aaa201bb":"":MBEDTLS_ERR_ASN1_INVALID_LENGTH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308189308186a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa185aaa201bb":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_INVALID_LENGTH X509 Certificate ASN1 (TBSCertificate v3, ext empty) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30818b308188a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba300":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30818b308188a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba300":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, ext length mismatch) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30818e30818ba0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba303300000":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30818e30818ba0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba303300000":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 Certificate ASN1 (TBSCertificate v3, first ext invalid) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30818f30818ca0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30330023000":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30818f30818ca0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30330023000":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, first ext invalid tag) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30819030818da0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba3043002310000":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30819030818da0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba3043002310000":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate v3, ext BasicContraint tag, bool len missing) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308198308195a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30c300a30060603551d1301010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308198308195a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30c300a30060603551d1301010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, ext BasicContraint tag, data missing) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308198308195a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30c300a30080603551d1301010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308198308195a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30c300a30080603551d1301010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, ext BasicContraint tag, no octet present) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308198308195a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30d300b30090603551d1301010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308198308195a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba30d300b30090603551d1301010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate v3, ext BasicContraint tag, octet data missing) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30819c308199a0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba311300f300d0603551d130101010403300100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30819c308199a0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba311300f300d0603551d130101010403300100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 Certificate ASN1 (TBSCertificate v3, ext BasicContraint tag, no pathlen) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30819f30819ca0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba314301230100603551d130101010406300402010102":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30819f30819ca0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba314301230100603551d130101010406300402010102":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (TBSCertificate v3, ext BasicContraint tag, octet len mismatch) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"3081a230819fa0030201028204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba317301530130603551d130101010409300702010102010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"3081a230819fa0030201028204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffffa101aaa201bba317301530130603551d130101010409300702010102010100":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 Certificate ASN1 (ExtKeyUsage, bad second tag) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C @@ -1144,101 +1176,101 @@ x509parse_crt:"3081de3081dba003020102020900ebdbcd14105e1839300906072a8648ce3d040 X509 Certificate ASN1 (SubjectAltName repeated) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C -x509parse_crt:"3081fd3081faa003020102020900a8b31ff37d09a37f300906072a8648ce3d0401300f310d300b0603550403130454657374301e170d3134313131313231333731365a170d3234313130383231333731365a300f310d300b06035504031304546573743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa321301f301d0603551d11041630148208666f6f2e7465737482086261722e74657374301d0603551d11041630148208666f6f2e7465737482086261722e74657374":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS +x509parse_crt:"3081fd3081faa003020102020900a8b31ff37d09a37f300906072a8648ce3d0401300f310d300b0603550403130454657374301e170d3134313131313231333731365a170d3234313130383231333731365a300f310d300b06035504031304546573743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa340303e301d0603551d11041630148208666f6f2e7465737482086261722e74657374301d0603551d11041630148208666f6f2e7465737482086261722e74657374":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS X509 Certificate ASN1 (ExtKeyUsage repeated) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C x509parse_crt:"3081fd3081faa003020102020900ebdbcd14105e1839300906072a8648ce3d0401300f310d300b0603550403130454657374301e170d3134313131313230353935345a170d3234313130383230353935345a300f310d300b06035504031304546573743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa340303e301d0603551d250416301406082b0601050507030106082b06010505070302301d0603551d250416301406082b0601050507030106082b06010505070302":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS X509 Certificate ASN1 (correct pubkey, no sig_alg) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308183308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308183308180a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (sig_alg mismatch) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308192308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0102020500":"":MBEDTLS_ERR_X509_SIG_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308192308180a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0102020500":"":MBEDTLS_ERR_X509_SIG_MISMATCH X509 Certificate ASN1 (sig_alg, no sig) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308192308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_OUT_OF_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308192308180a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 Certificate ASN1 (signature, invalid sig data) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308195308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030100":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_INVALID_DATA +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308195308180a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030100":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_INVALID_DATA X509 Certificate ASN1 (signature, data left) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308197308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff00":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308197308180a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff00":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH -X509 Certificate ASN1 (correct) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308196308180a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +X509 Certificate ASN1 (well-formed) +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308196308180a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (GeneralizedTime instead of UTCTime) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308198308182a0030201008204deadbeef300d06092a864886f70d0101020500300c310a30080600130454657374301e180e3230313030313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2010-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308198308182a0030201008204deadbeef300d06092a864886f70d01010b0500300c310a30080600130454657374301e180e3230313030313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2010-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with X520 CN) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550403130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: CN=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b0603550403130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: CN=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with X520 C) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550406130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: C=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b0603550406130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: C=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with X520 L) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550407130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: L=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b0603550407130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: L=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with X520 ST) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b0603550408130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ST=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b0603550408130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ST=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with X520 O) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b060355040a130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: O=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b060355040a130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: O=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with X520 OU) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b060355040b130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: OU=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b060355040b130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: OU=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with unknown X520 part) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d0101020500300f310d300b06035504de130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"308199308183a0030201008204deadbeef300d06092a864886f70d01010b0500300f310d300b06035504de130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with composite RDN) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C x509parse_crt:"3082029f30820208a00302010202044c20e3bd300d06092a864886f70d01010505003056310b3009060355040613025553310b300906035504080c0243413121301f060355040a0c18496e7465726e6574205769646769747320507479204c74643117301506035504030c0e4672616e6b656e63657274204341301e170d3133303830323135313433375a170d3135303831373035353433315a3081d1310b3009060355040613025553311330110603550408130a57617368696e67746f6e31133011060b2b0601040182373c0201031302555331193017060b2b0601040182373c020102130844656c6177617265311a3018060355040a1311417574686f72697a652e4e6574204c4c43311d301b060355040f131450726976617465204f7267616e697a6174696f6e312a300e06035504051307343336393139313018060355040313117777772e617574686f72697a652e6e6574311630140603550407130d53616e204672616e636973636f30819f300d06092a864886f70d010101050003818d0030818902818100d885c62e209b6ac005c64f0bcfdaac1f2b67a18802f75b08851ff933deed888b7b68a62fcabdb21d4a8914becfeaaa1b7e08a09ffaf9916563586dc95e2877262b0b5f5ec27eb4d754aa6facd1d39d25b38a2372891bacdd3e919f791ed25704e8920e380e5623a38e6a23935978a3aec7a8e761e211d42effa2713e44e7de0b0203010001300d06092a864886f70d010105050003818100092f7424d3f6da4b8553829d958ed1980b9270b42c0d3d5833509a28c66bb207df9f3c51d122065e00b87c08c2730d2745fe1c279d16fae4d53b4bf5bdfa3631fceeb2e772b6b08a3eca5a2e2c687aefd23b4b73bf77ac6099711342cf070b35c6f61333a7cbf613d8dd4bd73e9df34bcd4284b0b4df57c36c450613f11e5dac":"cert. version \: 3\nserial number \: 4C\:20\:E3\:BD\nissuer name \: C=US, ST=CA, O=Internet Widgits Pty Ltd, CN=Frankencert CA\nsubject name \: C=US, ST=Washington, ??=US, ??=Delaware, O=Authorize.Net LLC, ??=Private Organization, serialNumber=4369191 + CN=www.authorize.net, L=San Francisco\nissued on \: 2013-08-02 15\:14\:37\nexpires on \: 2015-08-17 05\:54\:31\nsigned using \: RSA with SHA1\nRSA key size \: 1024 bits\n":0 X509 Certificate ASN1 (Name with PKCS9 email) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30819f308189a0030201008204deadbeef300d06092a864886f70d010102050030153113301106092a864886f70d010901130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: emailAddress=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30819f308189a0030201008204deadbeef300d06092a864886f70d01010b050030153113301106092a864886f70d010901130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: emailAddress=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (Name with unknown PKCS9 part) -depends_on:MBEDTLS_RSA_C:MBEDTLS_MD2_C -x509parse_crt:"30819f308189a0030201008204deadbeef300d06092a864886f70d010102050030153113301106092a864886f70d0109ab130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092A864886F70D010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d0101020500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with MD2\nRSA key size \: 128 bits\n":0 +depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C +x509parse_crt:"30819f308189a0030201008204deadbeef300d06092a864886f70d01010b050030153113301106092a864886f70d0109ab130454657374301c170c303930313031303030303030170c303931323331323335393539300c310a30080600130454657374302a300d06092a864886f70d010101050003190030160210ffffffffffffffffffffffffffffffff0202ffff300d06092a864886f70d01010b0500030200ff":"cert. version \: 1\nserial number \: DE\:AD\:BE\:EF\nissuer name \: ?\?=Test\nsubject name \: ?\?=Test\nissued on \: 2009-01-01 00\:00\:00\nexpires on \: 2009-12-31 23\:59\:59\nsigned using \: RSA with SHA-256\nRSA key size \: 128 bits\n":0 X509 Certificate ASN1 (ECDSA signature, RSA key) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C:MBEDTLS_ECDSA_C -x509parse_crt:"3081E630819E020103300906072A8648CE3D0401300F310D300B0603550403130454657374301E170D3133303731303039343631385A170D3233303730383039343631385A300F310D300B0603550403130454657374304C300D06092A864886F70D0101010500033B003038023100E8F546061D3B49BC2F6B7524B7EA4D73A8D5293EE8C64D9407B70B5D16BAEBC32B8205591EAB4E1EB57E9241883701250203010001300906072A8648CE3D0401033800303502186E18209AFBED14A0D9A796EFCAD68891E3CCD5F75815C833021900E92B4FD460B1994693243B9FFAD54729DE865381BDA41D25":"cert. version \: 1\nserial number \: 03\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 09\:46\:18\nexpires on \: 2023-07-08 09\:46\:18\nsigned using \: ECDSA with SHA1\nRSA key size \: 384 bits\n":0 +x509parse_crt:"3081e630819e020103300906072a8648ce3d0401300f310d300b0603550403130454657374301e170d3133303731303039343631385a170d3233303730383039343631385a300f310d300b0603550403130454657374304c300d06092a864886f70d0101010500033b003038023100e8f546061d3b49bc2f6b7524b7ea4d73a8d5293ee8c64d9407b70b5d16baebc32b8205591eab4e1eb57e9241883701250203010001300906072a8648ce3d0401033800303502186e18209afbed14a0d9a796efcad68891e3ccd5f75815c833021900e92b4fd460b1994693243b9ffad54729de865381bda41d25":"cert. version \: 1\nserial number \: 03\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 09\:46\:18\nexpires on \: 2023-07-08 09\:46\:18\nsigned using \: ECDSA with SHA1\nRSA key size \: 384 bits\n":0 X509 Certificate ASN1 (ECDSA signature, EC key) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA1_C -x509parse_crt:"3081EB3081A3020900F41534662EC7E912300906072A8648CE3D0401300F310D300B0603550403130454657374301E170D3133303731303039343031395A170D3233303730383039343031395A300F310D300B06035504031304546573743049301306072A8648CE3D020106082A8648CE3D030101033200042137969FABD4E370624A0E1A33E379CAB950CCE00EF8C3C3E2ADAEB7271C8F07659D65D3D777DCF21614363AE4B6E617300906072A8648CE3D04010338003035021858CC0F957946FE6A303D92885A456AA74C743C7B708CBD37021900FE293CAC21AF352D16B82EB8EA54E9410B3ABAADD9F05DD6":"cert. version \: 1\nserial number \: F4\:15\:34\:66\:2E\:C7\:E9\:12\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 09\:40\:19\nexpires on \: 2023-07-08 09\:40\:19\nsigned using \: ECDSA with SHA1\nEC key size \: 192 bits\n":0 +x509parse_crt:"3081eb3081a3020900f41534662ec7e912300906072a8648ce3d0401300f310d300b0603550403130454657374301e170d3133303731303039343031395a170d3233303730383039343031395a300f310d300b06035504031304546573743049301306072a8648ce3d020106082a8648ce3d030101033200042137969fabd4e370624a0e1a33e379cab950cce00ef8c3c3e2adaeb7271c8f07659d65d3d777dcf21614363ae4b6e617300906072a8648ce3d04010338003035021858cc0f957946fe6a303d92885a456aa74c743c7b708cbd37021900fe293cac21af352d16b82eb8ea54e9410b3abaadd9f05dd6":"cert. version \: 1\nserial number \: F4\:15\:34\:66\:2E\:C7\:E9\:12\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 09\:40\:19\nexpires on \: 2023-07-08 09\:40\:19\nsigned using \: ECDSA with SHA1\nEC key size \: 192 bits\n":0 X509 Certificate ASN1 (RSA signature, EC key) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP192R1_ENABLED:MBEDTLS_SHA1_C:MBEDTLS_RSA_C -x509parse_crt:"3081E430819F020104300D06092A864886F70D0101050500300F310D300B0603550403130454657374301E170D3133303731303135303233375A170D3233303730383135303233375A300F310D300B06035504031304546573743049301306072A8648CE3D020106082A8648CE3D03010103320004E962551A325B21B50CF6B990E33D4318FD16677130726357A196E3EFE7107BCB6BDC6D9DB2A4DF7C964ACFE81798433D300D06092A864886F70D01010505000331001A6C18CD1E457474B2D3912743F44B571341A7859A0122774A8E19A671680878936949F904C9255BDD6FFFDB33A7E6D8":"cert. version \: 1\nserial number \: 04\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 15\:02\:37\nexpires on \: 2023-07-08 15\:02\:37\nsigned using \: RSA with SHA1\nEC key size \: 192 bits\n":0 +x509parse_crt:"3081e430819f020104300d06092a864886f70d0101050500300f310d300b0603550403130454657374301e170d3133303731303135303233375a170d3233303730383135303233375a300f310d300b06035504031304546573743049301306072a8648ce3d020106082a8648ce3d03010103320004e962551a325b21b50cf6b990e33d4318fd16677130726357a196e3efe7107bcb6bdc6d9db2a4df7c964acfe81798433d300d06092a864886f70d01010505000331001a6c18cd1e457474b2d3912743f44b571341a7859a0122774a8e19a671680878936949f904c9255bdd6fffdb33a7e6d8":"cert. version \: 1\nserial number \: 04\nissuer name \: CN=Test\nsubject name \: CN=Test\nissued on \: 2013-07-10 15\:02\:37\nexpires on \: 2023-07-08 15\:02\:37\nsigned using \: RSA with SHA1\nEC key size \: 192 bits\n":0 X509 Certificate ASN1 (invalid version 3) x509parse_crt:"30173015a0030201038204deadbeef30080604cafed00d0500":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION X509 Certificate ASN1 (invalid version overflow) -x509parse_crt:"301A3018a00602047FFFFFFF8204deadbeef30080604cafed00d0500":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION +x509parse_crt:"301a3018a00602047fffffff8204deadbeef30080604cafed00d0500":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION X509 Certificate ASN1 (invalid SubjectAltNames tag) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C -x509parse_crt:"308203723082025AA003020102020111300D06092A864886F70D0101050500303B310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C3119301706035504031310506F6C617253534C2054657374204341301E170D3132303531303133323334315A170D3232303531313133323334315A303A310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C311830160603550403130F7777772E6578616D706C652E636F6D30820122300D06092A864886F70D01010105000382010F003082010A0282010100B93C4AC5C8A38E9017A49E52AA7175266180E7C7B56D8CFFAAB64126B7BE11AD5C73160C64114804FFD6E13B05DB89BBB39709D51C14DD688739B03D71CBE276D01AD8182D801B54F6E5449AF1CBAF612EDF490D9D09B7EDB1FD3CFD3CFA24CF5DBF7CE453E725B5EA4422E926D3EA20949EE66167BA2E07670B032FA209EDF0338F0BCE10EF67A4C608DAC1EDC23FD74ADD153DF95E1C8160463EB5B33D2FA6DE471CBC92AEEBDF276B1656B7DCECD15557A56EEC7525F5B77BDFABD23A5A91987D97170B130AA76B4A8BC14730FB3AF84104D5C1DFB81DBF7B01A565A2E01E36B7A65CCC305AF8CD6FCDF1196225CA01E3357FFA20F5DCFD69B26A007D17F70203010001A38181307F30090603551D1304023000301D0603551D0E041604147DE49C6BE6F9717D46D2123DAD6B1DFDC2AA784C301F0603551D23041830168014B45AE4A5B3DED252F6B9D5A6950FEB3EBCC7FDFF30320603551D11042B3029C20B6578616D706C652E636F6D820B6578616D706C652E6E6574820D2A2E6578616D706C652E6F7267300D06092A864886F70D010105050003820101004F09CB7AD5EEF5EF620DDC7BA285D68CCA95B46BDA115B92007513B9CA0BCEEAFBC31FE23F7F217479E2E6BCDA06E52F6FF655C67339CF48BC0D2F0CD27A06C34A4CD9485DA0D07389E4D4851D969A0E5799C66F1D21271F8D0529E840AE823968C39707CF3C934C1ADF2FA6A455487F7C8C1AC922DA24CD9239C68AECB08DF5698267CB04EEDE534196C127DC2FFE33FAD30EB8D432A9842853A5F0D189D5A298E71691BB9CC0418E8C58ACFFE3DD2E7AABB0B97176AD0F2733F7A929D3C076C0BF06407C0ED5A47C8AE2326E16AEDA641FB0557CDBDDF1A4BA447CB39958D2346E00EA976C143AF2101E0AA249107601F4F2C818FDCC6346128B091BF194E6":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509parse_crt:"308203723082025aa003020102020111300d06092a864886f70d0101050500303b310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c3119301706035504031310506f6c617253534c2054657374204341301e170d3132303531303133323334315a170d3232303531313133323334315a303a310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c311830160603550403130f7777772e6578616d706c652e636f6d30820122300d06092a864886f70d01010105000382010f003082010a0282010100b93c4ac5c8a38e9017a49e52aa7175266180e7c7b56d8cffaab64126b7be11ad5c73160c64114804ffd6e13b05db89bbb39709d51c14dd688739b03d71cbe276d01ad8182d801b54f6e5449af1cbaf612edf490d9d09b7edb1fd3cfd3cfa24cf5dbf7ce453e725b5ea4422e926d3ea20949ee66167ba2e07670b032fa209edf0338f0bce10ef67a4c608dac1edc23fd74add153df95e1c8160463eb5b33d2fa6de471cbc92aeebdf276b1656b7dcecd15557a56eec7525f5b77bdfabd23a5a91987d97170b130aa76b4a8bc14730fb3af84104d5c1dfb81dbf7b01a565a2e01e36b7a65ccc305af8cd6fcdf1196225ca01e3357ffa20f5dcfd69b26a007d17f70203010001a38181307f30090603551d1304023000301d0603551d0e041604147de49c6be6f9717d46d2123dad6b1dfdc2aa784c301f0603551d23041830168014b45ae4a5b3ded252f6b9d5a6950feb3ebcc7fdff30320603551d11042b3029c20b6578616d706c652e636f6d820b6578616d706c652e6e6574820d2a2e6578616d706c652e6f7267300d06092a864886f70d010105050003820101004f09cb7ad5eef5ef620ddc7ba285d68cca95b46bda115b92007513b9ca0bceeafbc31fe23f7f217479e2e6bcda06e52f6ff655c67339cf48bc0d2f0cd27a06c34a4cd9485da0d07389e4d4851d969a0e5799c66f1d21271f8d0529e840ae823968c39707cf3c934c1adf2fa6a455487f7c8c1ac922da24cd9239c68aecb08df5698267cb04eede534196c127dc2ffe33fad30eb8d432a9842853a5f0d189d5a298e71691bb9cc0418e8c58acffe3dd2e7aabb0b97176ad0f2733f7a929d3c076c0bf06407c0ed5a47c8ae2326e16aeda641fb0557cdbddf1a4ba447cb39958d2346e00ea976c143af2101e0aa249107601f4f2c818fdcc6346128b091bf194e6":"":MBEDTLS_ERR_X509_INVALID_EXTENSIONS + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 CRL ASN1 (Incorrect first tag) x509parse_crl:"":"":MBEDTLS_ERR_X509_INVALID_FORMAT @@ -1308,7 +1340,7 @@ X509 CRL ASN1 (invalid version 2) x509parse_crl:"30463031020102300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION X509 CRL ASN1 (invalid version overflow) -x509parse_crl:"3049303102047FFFFFFF300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION +x509parse_crl:"3049303102047fffffff300d06092a864886f70d01010e0500300f310d300b0603550403130441424344170c303930313031303030303030300d06092a864886f70d01010e050003020001":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION X509 CRL ASN1 (extension seq too long, crl-idp.pem byte 121) depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_RSA_C:MBEDTLS_SHA256_C @@ -1463,28 +1495,28 @@ depends_on:MBEDTLS_SHA256_C:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBE mbedtls_x509_crt_verify_chain:"data_files/server10_int3_int-ca2_ca.crt":"data_files/test-ca2.crt":-1:-4:"":8 X509 OID description #1 -x509_oid_desc:"2B06010505070301":"TLS Web Server Authentication" +x509_oid_desc:"2b06010505070301":"TLS Web Server Authentication" X509 OID description #2 -x509_oid_desc:"2B0601050507030f":"notfound" +x509_oid_desc:"2b0601050507030f":"notfound" X509 OID description #3 -x509_oid_desc:"2B0601050507030100":"notfound" +x509_oid_desc:"2b0601050507030100":"notfound" X509 OID numstring #1 (wide buffer) -x509_oid_numstr:"2B06010505070301":"1.3.6.1.5.5.7.3.1":20:17 +x509_oid_numstr:"2b06010505070301":"1.3.6.1.5.5.7.3.1":20:17 X509 OID numstring #2 (buffer just fits) -x509_oid_numstr:"2B06010505070301":"1.3.6.1.5.5.7.3.1":18:17 +x509_oid_numstr:"2b06010505070301":"1.3.6.1.5.5.7.3.1":18:17 X509 OID numstring #3 (buffer too small) -x509_oid_numstr:"2B06010505070301":"1.3.6.1.5.5.7.3.1":17:MBEDTLS_ERR_OID_BUF_TOO_SMALL +x509_oid_numstr:"2b06010505070301":"1.3.6.1.5.5.7.3.1":17:MBEDTLS_ERR_OID_BUF_TOO_SMALL X509 OID numstring #4 (larger number) -x509_oid_numstr:"2A864886F70D":"1.2.840.113549":15:14 +x509_oid_numstr:"2a864886f70d":"1.2.840.113549":15:14 X509 OID numstring #5 (arithmetic overflow) -x509_oid_numstr:"2A8648F9F8F7F6F5F4F3F2F1F001":"":100:MBEDTLS_ERR_OID_BUF_TOO_SMALL +x509_oid_numstr:"2a8648f9f8f7f6f5f4f3f2f1f001":"":100:MBEDTLS_ERR_OID_BUF_TOO_SMALL X509 crt keyUsage #1 (no extension, expected KU) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C @@ -1532,31 +1564,31 @@ x509_check_key_usage:"data_files/keyUsage.decipherOnly.crt":MBEDTLS_X509_KU_DIGI X509 crt extendedKeyUsage #1 (no extension, serverAuth) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.crt":"2B06010505070301":0 +x509_check_extended_key_usage:"data_files/server5.crt":"2b06010505070301":0 X509 crt extendedKeyUsage #2 (single value, present) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.eku-srv.crt":"2B06010505070301":0 +x509_check_extended_key_usage:"data_files/server5.eku-srv.crt":"2b06010505070301":0 X509 crt extendedKeyUsage #3 (single value, absent) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.eku-cli.crt":"2B06010505070301":MBEDTLS_ERR_X509_BAD_INPUT_DATA +x509_check_extended_key_usage:"data_files/server5.eku-cli.crt":"2b06010505070301":MBEDTLS_ERR_X509_BAD_INPUT_DATA X509 crt extendedKeyUsage #4 (two values, first) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.eku-srv_cli.crt":"2B06010505070301":0 +x509_check_extended_key_usage:"data_files/server5.eku-srv_cli.crt":"2b06010505070301":0 X509 crt extendedKeyUsage #5 (two values, second) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.eku-srv_cli.crt":"2B06010505070302":0 +x509_check_extended_key_usage:"data_files/server5.eku-srv_cli.crt":"2b06010505070302":0 X509 crt extendedKeyUsage #6 (two values, other) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.eku-srv_cli.crt":"2B06010505070303":MBEDTLS_ERR_X509_BAD_INPUT_DATA +x509_check_extended_key_usage:"data_files/server5.eku-srv_cli.crt":"2b06010505070303":MBEDTLS_ERR_X509_BAD_INPUT_DATA X509 crt extendedKeyUsage #7 (any, random) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C -x509_check_extended_key_usage:"data_files/server5.eku-cs_any.crt":"2B060105050703FF":0 +x509_check_extended_key_usage:"data_files/server5.eku-cs_any.crt":"2b060105050703ff":0 X509 RSASSA-PSS parameters ASN1 (good, all defaults) x509_parse_rsassa_pss_params:"":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 @@ -1565,113 +1597,113 @@ X509 RSASSA-PSS parameters ASN1 (wrong initial tag) x509_parse_rsassa_pss_params:"":MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 RSASSA-PSS parameters ASN1 (unknown tag in top-level sequence) -x509_parse_rsassa_pss_params:"A400":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +x509_parse_rsassa_pss_params:"a400":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 RSASSA-PSS parameters ASN1 (good, HashAlg SHA256) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C -x509_parse_rsassa_pss_params:"A00D300B0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:20:0 +x509_parse_rsassa_pss_params:"a00d300b0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:20:0 X509 RSASSA-PSS parameters ASN1 (good, explicit HashAlg = default) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C -x509_parse_rsassa_pss_params:"A009300706052B0E03021A":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 +x509_parse_rsassa_pss_params:"a009300706052b0e03021a":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 X509 RSASSA-PSS parameters ASN1 (HashAlg wrong len #1) -x509_parse_rsassa_pss_params:"A00A300706052B0E03021A":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a00a300706052b0e03021a":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (HashAlg wrong len #2) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C -x509_parse_rsassa_pss_params:"A00A300706052B0E03021A00":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +x509_parse_rsassa_pss_params:"a00a300706052b0e03021a00":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 RSASSA-PSS parameters ASN1 (HashAlg with parameters) -x509_parse_rsassa_pss_params:"A00F300D06096086480165030402013000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_INVALID_DATA +x509_parse_rsassa_pss_params:"a00f300d06096086480165030402013000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_INVALID_DATA X509 RSASSA-PSS parameters ASN1 (HashAlg unknown OID) -x509_parse_rsassa_pss_params:"A00D300B06096086480165030402FF":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_OID_NOT_FOUND +x509_parse_rsassa_pss_params:"a00d300b06096086480165030402ff":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA256:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_OID_NOT_FOUND X509 RSASSA-PSS parameters ASN1 (good, MGAlg = MGF1-SHA256) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C -x509_parse_rsassa_pss_params:"A11A301806092A864886F70D010108300B0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:0 +x509_parse_rsassa_pss_params:"a11a301806092a864886f70d010108300b0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:0 X509 RSASSA-PSS parameters ASN1 (good, explicit MGAlg = default) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA1_C -x509_parse_rsassa_pss_params:"A116301406092A864886F70D010108300706052B0E03021A":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 +x509_parse_rsassa_pss_params:"a116301406092a864886f70d010108300706052b0e03021a":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 X509 RSASSA-PSS parameters ASN1 (MGAlg wrong len #1) -x509_parse_rsassa_pss_params:"A11B301806092A864886F70D010108300B0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a11b301806092a864886f70d010108300b0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (MGAlg wrong len #2) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C -x509_parse_rsassa_pss_params:"A11B301806092A864886F70D010108300B060960864801650304020100":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +x509_parse_rsassa_pss_params:"a11b301806092a864886f70d010108300b060960864801650304020100":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 RSASSA-PSS parameters ASN1 (MGAlg AlgId wrong len #1) -x509_parse_rsassa_pss_params:"A11A301906092A864886F70D010108300B0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a11a301906092a864886f70d010108300b0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (MGAlg OID != MGF1) -x509_parse_rsassa_pss_params:"A11A301806092A864886F70D010109300B0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE + MBEDTLS_ERR_OID_NOT_FOUND +x509_parse_rsassa_pss_params:"a11a301806092a864886f70d010109300b0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE + MBEDTLS_ERR_OID_NOT_FOUND X509 RSASSA-PSS parameters ASN1 (MGAlg.params wrong tag) -x509_parse_rsassa_pss_params:"A11A301806092A864886F70D010108310B0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509_parse_rsassa_pss_params:"a11a301806092a864886f70d010108310b0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 RSASSA-PSS parameters ASN1 (MGAlg.params wrong len #1a) -x509_parse_rsassa_pss_params:"A10F300D06092A864886F70D0101083000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a10f300d06092a864886f70d0101083000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (MGAlg.params wrong len #1b) -x509_parse_rsassa_pss_params:"A11B301906092A864886F70D010108300C0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a11b301906092a864886f70d010108300c0609608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (MGAlg.params.alg not an OID) -x509_parse_rsassa_pss_params:"A11A301806092A864886F70D010108300B0709608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509_parse_rsassa_pss_params:"a11a301806092a864886f70d010108300b0709608648016503040201":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 RSASSA-PSS parameters ASN1 (MGAlg.params.alg unknown OID) -x509_parse_rsassa_pss_params:"A11A301806092A864886F70D010108300B06096086480165030402FF":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_OID_NOT_FOUND +x509_parse_rsassa_pss_params:"a11a301806092a864886f70d010108300b06096086480165030402ff":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_OID_NOT_FOUND X509 RSASSA-PSS parameters ASN1 (MGAlg.params.params NULL) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C -x509_parse_rsassa_pss_params:"A11C301A06092A864886F70D010108300D06096086480165030402010500":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:0 +x509_parse_rsassa_pss_params:"a11c301a06092a864886f70d010108300d06096086480165030402010500":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:0 X509 RSASSA-PSS parameters ASN1 (MGAlg.params.params wrong tag) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C -x509_parse_rsassa_pss_params:"A11C301A06092A864886F70D010108300D06096086480165030402013000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509_parse_rsassa_pss_params:"a11c301a06092a864886f70d010108300d06096086480165030402013000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 RSASSA-PSS parameters ASN1 (MGAlg.params wrong len #1c) -x509_parse_rsassa_pss_params:"A11D301B06092A864886F70D010108300E06096086480165030402010500":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a11d301b06092a864886f70d010108300e06096086480165030402010500":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (MGAlg.params wrong len #2) depends_on:MBEDTLS_RSA_C:MBEDTLS_SHA256_C -x509_parse_rsassa_pss_params:"A11D301B06092A864886F70D010108300E0609608648016503040201050000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +x509_parse_rsassa_pss_params:"a11d301b06092a864886f70d010108300e0609608648016503040201050000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA256:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 RSASSA-PSS parameters ASN1 (good, saltLen = 94) -x509_parse_rsassa_pss_params:"A20302015E":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:0 +x509_parse_rsassa_pss_params:"a20302015e":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:0 X509 RSASSA-PSS parameters ASN1 (good, explicit saltLen = default) -x509_parse_rsassa_pss_params:"A203020114":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 +x509_parse_rsassa_pss_params:"a203020114":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 X509 RSASSA-PSS parameters ASN1 (saltLen wrong len #1) -x509_parse_rsassa_pss_params:"A20402015E":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a20402015e":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (saltLen wrong len #2) -x509_parse_rsassa_pss_params:"A20402015E00":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +x509_parse_rsassa_pss_params:"a20402015e00":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 RSASSA-PSS parameters ASN1 (saltLen not an int) -x509_parse_rsassa_pss_params:"A2023000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509_parse_rsassa_pss_params:"a2023000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:94:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 RSASSA-PSS parameters ASN1 (good, explicit trailerField = default) -x509_parse_rsassa_pss_params:"A303020101":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 +x509_parse_rsassa_pss_params:"a303020101":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:0 X509 RSASSA-PSS parameters ASN1 (trailerField wrong len #1) -x509_parse_rsassa_pss_params:"A304020101":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +x509_parse_rsassa_pss_params:"a304020101":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 RSASSA-PSS parameters ASN1 (trailerField wrong len #2) -x509_parse_rsassa_pss_params:"A30402010100":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +x509_parse_rsassa_pss_params:"a30402010100":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 RSASSA-PSS parameters ASN1 (trailerField not an int) -x509_parse_rsassa_pss_params:"A3023000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +x509_parse_rsassa_pss_params:"a3023000":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 RSASSA-PSS parameters ASN1 (trailerField not 1) -x509_parse_rsassa_pss_params:"A303020102":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG +x509_parse_rsassa_pss_params:"a303020102":MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE:MBEDTLS_MD_SHA1:MBEDTLS_MD_SHA1:20:MBEDTLS_ERR_X509_INVALID_ALG X509 CSR ASN.1 (OK) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C -mbedtls_x509_csr_parse:"308201183081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D04010349003046022100B49FD8C8F77ABFA871908DFBE684A08A793D0F490A43D86FCF2086E4F24BB0C2022100F829D5CCD3742369299E6294394717C4B723A0F68B44E831B6E6C3BCABF97243":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA1\nEC key size \: 256 bits\n":0 +mbedtls_x509_csr_parse:"308201183081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0300906072a8648ce3d04010349003046022100b49fd8c8f77abfa871908dfbe684a08a793d0f490a43d86fcf2086e4f24bb0c2022100f829d5ccd3742369299e6294394717c4b723a0f68b44e831b6e6c3bcabf97243":"CSR version \: 1\nsubject name \: C=NL, O=PolarSSL, CN=localhost\nsigned using \: ECDSA with SHA1\nEC key size \: 256 bits\n":0 X509 CSR ASN.1 (bad first tag) mbedtls_x509_csr_parse:"3100":"":MBEDTLS_ERR_X509_INVALID_FORMAT @@ -1704,63 +1736,63 @@ X509 CSR ASN.1 (bad CRI.Name payload: not a set) mbedtls_x509_csr_parse:"3009300702010030023000":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 CSR ASN.1 (bad CRI.Name payload: overlong) -mbedtls_x509_csr_parse:"300A30080201003002310100":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"300a30080201003002310100":"":MBEDTLS_ERR_X509_INVALID_NAME + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad SubjectPublicKeyInfo: missing) -mbedtls_x509_csr_parse:"30143012020100300D310B3009060355040613024E4C":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"30143012020100300d310b3009060355040613024e4c":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad SubjectPublicKeyInfo: not a sequence) -mbedtls_x509_csr_parse:"30163014020100300D310B3009060355040613024E4C3100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +mbedtls_x509_csr_parse:"30163014020100300d310b3009060355040613024e4c3100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 CSR ASN.1 (bad SubjectPublicKeyInfo: overlong) -mbedtls_x509_csr_parse:"30173014020100300D310B3009060355040613024E4C300100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"30173014020100300d310b3009060355040613024e4c300100":"":MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad attributes: missing) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"3081973081940201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFF":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"3081973081940201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edff":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad attributes: bad tag) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"3081993081960201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFF0500":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +mbedtls_x509_csr_parse:"3081993081960201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edff0500":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 CSR ASN.1 (bad attributes: overlong) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"30819A3081960201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA00100":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"30819a3081960201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa00100":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad sigAlg: missing) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"3081C23081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"3081c23081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad sigAlg: not a sequence) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"3081C43081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E03100":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +mbedtls_x509_csr_parse:"3081c43081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e03100":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 CSR ASN.1 (bad sigAlg: overlong) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"3081C43081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E03001":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"3081c43081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e03001":"":MBEDTLS_ERR_X509_INVALID_ALG + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad sigAlg: unknown) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED -mbedtls_x509_csr_parse:"3081CD3081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D04FF":"":MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG +mbedtls_x509_csr_parse:"3081cd3081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0300906072a8648ce3d04ff":"":MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG X509 CSR ASN.1 (bad sig: missing) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C -mbedtls_x509_csr_parse:"3081CD3081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D0401":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"3081cd3081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0300906072a8648ce3d0401":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (bad sig: not a bit string) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C -mbedtls_x509_csr_parse:"3081CF3081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D04010400":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG +mbedtls_x509_csr_parse:"3081cf3081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0300906072a8648ce3d04010400":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_UNEXPECTED_TAG X509 CSR ASN.1 (bad sig: overlong) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C -mbedtls_x509_csr_parse:"3081CF3081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D04010301":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_OUT_OF_DATA +mbedtls_x509_csr_parse:"3081cf3081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0300906072a8648ce3d04010301":"":MBEDTLS_ERR_X509_INVALID_SIGNATURE + MBEDTLS_ERR_ASN1_OUT_OF_DATA X509 CSR ASN.1 (extra data after signature) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA1_C -mbedtls_x509_csr_parse:"308201193081BF0201003034310B3009060355040613024E4C3111300F060355040A1308506F6C617253534C31123010060355040313096C6F63616C686F73743059301306072A8648CE3D020106082A8648CE3D0301070342000437CC56D976091E5A723EC7592DFF206EEE7CF9069174D0AD14B5F768225962924EE500D82311FFEA2FD2345D5D16BD8A88C26B770D55CD8A2A0EFA01C8B4EDFFA029302706092A864886F70D01090E311A301830090603551D1304023000300B0603551D0F0404030205E0300906072A8648CE3D04010349003046022100B49FD8C8F77ABFA871908DFBE684A08A793D0F490A43D86FCF2086E4F24BB0C2022100F829D5CCD3742369299E6294394717C4B723A0F68B44E831B6E6C3BCABF9724300":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH +mbedtls_x509_csr_parse:"308201193081bf0201003034310b3009060355040613024e4c3111300f060355040a1308506f6c617253534c31123010060355040313096c6f63616c686f73743059301306072a8648ce3d020106082a8648ce3d0301070342000437cc56d976091e5a723ec7592dff206eee7cf9069174d0ad14b5f768225962924ee500d82311ffea2fd2345d5d16bd8a88c26b770d55cd8a2a0efa01c8b4edffa029302706092a864886f70d01090e311a301830090603551d1304023000300b0603551d0f0404030205e0300906072a8648ce3d04010349003046022100b49fd8c8f77abfa871908dfbe684a08a793d0f490a43d86fcf2086e4f24bb0c2022100f829d5ccd3742369299e6294394717c4b723a0f68b44e831b6e6c3bcabf9724300":"":MBEDTLS_ERR_X509_INVALID_FORMAT + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH X509 CSR ASN.1 (invalid version overflow) -mbedtls_x509_csr_parse:"3008300602047FFFFFFF":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION +mbedtls_x509_csr_parse:"3008300602047fffffff":"":MBEDTLS_ERR_X509_UNKNOWN_VERSION X509 File parse (no issues) depends_on:MBEDTLS_ECDSA_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_SHA256_C:MBEDTLS_RSA_C @@ -1889,3 +1921,91 @@ x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"20000229000000Z":0:2000:2:29:0:0:0 X509 Get time (Generalized Time invalid leap year not multiple of 4, 100 or 400) depends_on:MBEDTLS_X509_USE_C x509_get_time:MBEDTLS_ASN1_GENERALIZED_TIME:"19910229000000Z":MBEDTLS_ERR_X509_INVALID_DATE:0:0:0:0:0:0 + +X509 cert verify restart: trusted EE, max_ops=0 (disabled) +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED +x509_verify_restart:"data_files/server5-selfsigned.crt":"data_files/server5-selfsigned.crt":0:0:0:0:0 + +X509 cert verify restart: trusted EE, max_ops=1 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED +x509_verify_restart:"data_files/server5-selfsigned.crt":"data_files/server5-selfsigned.crt":0:0:1:0:0 + +X509 cert verify restart: no intermediate, max_ops=0 (disabled) +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5.crt":"data_files/test-ca2.crt":0:0:0:0:0 + +X509 cert verify restart: no intermediate, max_ops=1 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5.crt":"data_files/test-ca2.crt":0:0:1:100:10000 + +X509 cert verify restart: no intermediate, max_ops=40000 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5.crt":"data_files/test-ca2.crt":0:0:40000:0:0 + +X509 cert verify restart: no intermediate, max_ops=500 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5.crt":"data_files/test-ca2.crt":0:0:500:20:80 + +X509 cert verify restart: no intermediate, badsign, max_ops=0 (disabled) +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5-badsign.crt":"data_files/test-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:0:0:0 + +X509 cert verify restart: no intermediate, badsign, max_ops=1 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5-badsign.crt":"data_files/test-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:1:100:10000 + +X509 cert verify restart: no intermediate, badsign, max_ops=40000 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5-badsign.crt":"data_files/test-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:40000:0:0 + +X509 cert verify restart: no intermediate, badsign, max_ops=500 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED +x509_verify_restart:"data_files/server5-badsign.crt":"data_files/test-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:500:20:80 + +X509 cert verify restart: one int, max_ops=0 (disabled) +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3_int-ca2.crt":"data_files/test-int-ca2.crt":0:0:0:0:0 + +X509 cert verify restart: one int, max_ops=1 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3_int-ca2.crt":"data_files/test-int-ca2.crt":0:0:1:100:10000 + +X509 cert verify restart: one int, max_ops=30000 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3_int-ca2.crt":"data_files/test-int-ca2.crt":0:0:30000:0:0 + +X509 cert verify restart: one int, max_ops=500 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3_int-ca2.crt":"data_files/test-int-ca2.crt":0:0:500:25:100 + +X509 cert verify restart: one int, EE badsign, max_ops=0 (disabled) +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10-bs_int3.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:0:0:0 + +X509 cert verify restart: one int, EE badsign, max_ops=1 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10-bs_int3.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:1:100:10000 + +X509 cert verify restart: one int, EE badsign, max_ops=30000 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10-bs_int3.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:30000:0:0 + +X509 cert verify restart: one int, EE badsign, max_ops=500 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10-bs_int3.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:500:25:100 + +X509 cert verify restart: one int, int badsign, max_ops=0 (disabled) +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3-bs.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:0:0:0 + +X509 cert verify restart: one int, int badsign, max_ops=1 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3-bs.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:1:100:10000 + +X509 cert verify restart: one int, int badsign, max_ops=30000 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3-bs.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:30000:0:0 + +X509 cert verify restart: one int, int badsign, max_ops=500 +depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_ECDSA_C:MBEDTLS_SHA256_C:MBEDTLS_ECP_DP_SECP256R1_ENABLED:MBEDTLS_ECP_DP_SECP384R1_ENABLED:MBEDTLS_RSA_C +x509_verify_restart:"data_files/server10_int3-bs.pem":"data_files/test-int-ca2.crt":MBEDTLS_ERR_X509_CERT_VERIFY_FAILED:MBEDTLS_X509_BADCERT_NOT_TRUSTED:500:25:100 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.function index 06f0108280..e6b1b4783c 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509parse.function @@ -1,4 +1,5 @@ /* BEGIN_HEADER */ +#include "mbedtls/bignum.h" #include "mbedtls/x509.h" #include "mbedtls/x509_crt.h" #include "mbedtls/x509_crl.h" @@ -6,6 +7,7 @@ #include "mbedtls/pem.h" #include "mbedtls/oid.h" #include "mbedtls/base64.h" +#include "string.h" #if MBEDTLS_X509_MAX_INTERMEDIATE_CA > 19 #error "The value of MBEDTLS_X509_MAX_INTERMEDIATE_C is larger \ @@ -13,6 +15,15 @@ than the current threshold 19. To test larger values, please \ adapt the script tests/data_files/dir-max/long.sh." #endif +/* Test-only profile allowing all digests, PK algorithms, and curves. */ +const mbedtls_x509_crt_profile profile_all = +{ + 0xFFFFFFFF, /* Any MD */ + 0xFFFFFFFF, /* Any PK alg */ + 0xFFFFFFFF, /* Any curve */ + 1024, +}; + /* Profile for backward compatibility. Allows SHA-1, unlike the default profile. */ const mbedtls_x509_crt_profile compat_profile = @@ -161,7 +172,7 @@ int verify_print( void *data, mbedtls_x509_crt *crt, int certificate_depth, uint */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ -void x509_cert_info( char *crt_file, char *result_str ) +void x509_cert_info( char * crt_file, char * result_str ) { mbedtls_x509_crt crt; char buf[2000]; @@ -184,7 +195,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRL_PARSE_C */ -void mbedtls_x509_crl_info( char *crl_file, char *result_str ) +void mbedtls_x509_crl_info( char * crl_file, char * result_str ) { mbedtls_x509_crl crl; char buf[2000]; @@ -207,7 +218,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRL_PARSE_C */ -void mbedtls_x509_crl_parse( char *crl_file, int result ) +void mbedtls_x509_crl_parse( char * crl_file, int result ) { mbedtls_x509_crl crl; char buf[2000]; @@ -223,7 +234,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CSR_PARSE_C */ -void mbedtls_x509_csr_info( char *csr_file, char *result_str ) +void mbedtls_x509_csr_info( char * csr_file, char * result_str ) { mbedtls_x509_csr csr; char buf[2000]; @@ -246,7 +257,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */ -void x509_verify_info( int flags, char *prefix, char *result_str ) +void x509_verify_info( int flags, char * prefix, char * result_str ) { char buf[2000]; int res; @@ -261,6 +272,62 @@ void x509_verify_info( int flags, char *prefix, char *result_str ) } /* END_CASE */ +/* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CRL_PARSE_C:MBEDTLS_ECP_RESTARTABLE:MBEDTLS_ECDSA_C */ +void x509_verify_restart( char *crt_file, char *ca_file, + int result, int flags_result, + int max_ops, int min_restart, int max_restart ) +{ + int ret, cnt_restart; + mbedtls_x509_crt_restart_ctx rs_ctx; + mbedtls_x509_crt crt; + mbedtls_x509_crt ca; + uint32_t flags = 0; + + /* + * See comments on ecp_test_vect_restart() for op count precision. + * + * For reference, with mbed TLS 2.6 and default settings: + * - ecdsa_verify() for P-256: ~ 6700 + * - ecdsa_verify() for P-384: ~ 18800 + * - x509_verify() for server5 -> test-ca2: ~ 18800 + * - x509_verify() for server10 -> int-ca3 -> int-ca2: ~ 25500 + */ + + mbedtls_x509_crt_restart_init( &rs_ctx ); + mbedtls_x509_crt_init( &crt ); + mbedtls_x509_crt_init( &ca ); + + TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 ); + TEST_ASSERT( mbedtls_x509_crt_parse_file( &ca, ca_file ) == 0 ); + + mbedtls_ecp_set_max_ops( max_ops ); + + cnt_restart = 0; + do { + ret = mbedtls_x509_crt_verify_restartable( &crt, &ca, NULL, + &mbedtls_x509_crt_profile_default, NULL, &flags, + NULL, NULL, &rs_ctx ); + } while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart ); + + TEST_ASSERT( ret == result ); + TEST_ASSERT( flags == (uint32_t) flags_result ); + + TEST_ASSERT( cnt_restart >= min_restart ); + TEST_ASSERT( cnt_restart <= max_restart ); + + /* Do we leak memory when aborting? */ + ret = mbedtls_x509_crt_verify_restartable( &crt, &ca, NULL, + &mbedtls_x509_crt_profile_default, NULL, &flags, + NULL, NULL, &rs_ctx ); + TEST_ASSERT( ret == result || ret == MBEDTLS_ERR_ECP_IN_PROGRESS ); + +exit: + mbedtls_x509_crt_restart_free( &rs_ctx ); + mbedtls_x509_crt_free( &crt ); + mbedtls_x509_crt_free( &ca ); +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CRL_PARSE_C */ void x509_verify( char *crt_file, char *ca_file, char *crl_file, char *cn_name_str, int result, int flags_result, @@ -291,6 +358,8 @@ void x509_verify( char *crt_file, char *ca_file, char *crl_file, profile = &mbedtls_x509_crt_profile_suiteb; else if( strcmp( profile_str, "compat" ) == 0 ) profile = &compat_profile; + else if( strcmp( profile_str, "all" ) == 0 ) + profile = &profile_all; else TEST_ASSERT( "Unknown algorithm profile" == 0 ); @@ -354,7 +423,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ -void mbedtls_x509_dn_gets( char *crt_file, char *entity, char *result_str ) +void mbedtls_x509_dn_gets( char * crt_file, char * entity, char * result_str ) { mbedtls_x509_crt crt; char buf[2000]; @@ -382,7 +451,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ -void mbedtls_x509_time_is_past( char *crt_file, char *entity, int result ) +void mbedtls_x509_time_is_past( char * crt_file, char * entity, int result ) { mbedtls_x509_crt crt; @@ -403,7 +472,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ -void mbedtls_x509_time_is_future( char *crt_file, char *entity, int result ) +void mbedtls_x509_time_is_future( char * crt_file, char * entity, int result ) { mbedtls_x509_crt crt; @@ -424,7 +493,7 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_FS_IO */ -void x509parse_crt_file( char *crt_file, int result ) +void x509parse_crt_file( char * crt_file, int result ) { mbedtls_x509_crt crt; @@ -438,20 +507,17 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */ -void x509parse_crt( char *crt_data, char *result_str, int result ) +void x509parse_crt( data_t * buf, char * result_str, int result ) { mbedtls_x509_crt crt; - unsigned char buf[2000]; unsigned char output[2000]; - int data_len, res; + int res; mbedtls_x509_crt_init( &crt ); - memset( buf, 0, 2000 ); memset( output, 0, 2000 ); - data_len = unhexify( buf, crt_data ); - TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf, data_len ) == ( result ) ); + TEST_ASSERT( mbedtls_x509_crt_parse( &crt, buf->x, buf->len ) == ( result ) ); if( ( result ) == 0 ) { res = mbedtls_x509_crt_info( (char *) output, 2000, "", &crt ); @@ -468,20 +534,17 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRL_PARSE_C */ -void x509parse_crl( char *crl_data, char *result_str, int result ) +void x509parse_crl( data_t * buf, char * result_str, int result ) { mbedtls_x509_crl crl; - unsigned char buf[2000]; unsigned char output[2000]; - int data_len, res; + int res; mbedtls_x509_crl_init( &crl ); - memset( buf, 0, 2000 ); memset( output, 0, 2000 ); - data_len = unhexify( buf, crl_data ); - TEST_ASSERT( mbedtls_x509_crl_parse( &crl, buf, data_len ) == ( result ) ); + TEST_ASSERT( mbedtls_x509_crl_parse( &crl, buf->x, buf->len ) == ( result ) ); if( ( result ) == 0 ) { res = mbedtls_x509_crl_info( (char *) output, 2000, "", &crl ); @@ -498,19 +561,16 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CSR_PARSE_C */ -void mbedtls_x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret ) +void mbedtls_x509_csr_parse( data_t * csr_der, char * ref_out, int ref_ret ) { mbedtls_x509_csr csr; - unsigned char *csr_der = NULL; char my_out[1000]; - size_t csr_der_len; int my_ret; mbedtls_x509_csr_init( &csr ); memset( my_out, 0, sizeof( my_out ) ); - csr_der = unhexify_alloc( csr_der_hex, &csr_der_len ); - my_ret = mbedtls_x509_csr_parse_der( &csr, csr_der, csr_der_len ); + my_ret = mbedtls_x509_csr_parse_der( &csr, csr_der->x, csr_der->len ); TEST_ASSERT( my_ret == ref_ret ); if( ref_ret == 0 ) @@ -522,12 +582,11 @@ void mbedtls_x509_csr_parse( char *csr_der_hex, char *ref_out, int ref_ret ) exit: mbedtls_x509_csr_free( &csr ); - mbedtls_free( csr_der ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ -void mbedtls_x509_crt_parse_path( char *crt_path, int ret, int nb_crt ) +void mbedtls_x509_crt_parse_path( char * crt_path, int ret, int nb_crt ) { mbedtls_x509_crt chain, *cur; int i; @@ -629,18 +688,16 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */ -void x509_oid_desc( char *oid_str, char *ref_desc ) +void x509_oid_desc( data_t * buf, char * ref_desc ) { mbedtls_x509_buf oid; const char *desc = NULL; - unsigned char buf[20]; int ret; - memset( buf, 0, sizeof buf ); oid.tag = MBEDTLS_ASN1_OID; - oid.len = unhexify( buf, oid_str ); - oid.p = buf; + oid.p = buf->x; + oid.len = buf->len; ret = mbedtls_oid_get_extended_key_usage( &oid, &desc ); @@ -659,18 +716,16 @@ void x509_oid_desc( char *oid_str, char *ref_desc ) /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */ -void x509_oid_numstr( char *oid_str, char *numstr, int blen, int ret ) +void x509_oid_numstr( data_t * oid_buf, char * numstr, int blen, int ret ) { mbedtls_x509_buf oid; - unsigned char oid_buf[20]; char num_buf[100]; - memset( oid_buf, 0x00, sizeof oid_buf ); memset( num_buf, 0x2a, sizeof num_buf ); oid.tag = MBEDTLS_ASN1_OID; - oid.len = unhexify( oid_buf, oid_str ); - oid.p = oid_buf; + oid.p = oid_buf->x; + oid.len = oid_buf->len; TEST_ASSERT( (size_t) blen <= sizeof num_buf ); @@ -685,7 +740,7 @@ void x509_oid_numstr( char *oid_str, char *numstr, int blen, int ret ) /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CHECK_KEY_USAGE */ -void x509_check_key_usage( char *crt_file, int usage, int ret ) +void x509_check_key_usage( char * crt_file, int usage, int ret ) { mbedtls_x509_crt crt; @@ -701,19 +756,17 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE */ -void x509_check_extended_key_usage( char *crt_file, char *usage_hex, int ret ) +void x509_check_extended_key_usage( char * crt_file, data_t * oid, int ret + ) { mbedtls_x509_crt crt; - char oid[50]; - size_t len; mbedtls_x509_crt_init( &crt ); - len = unhexify( (unsigned char *) oid, usage_hex ); TEST_ASSERT( mbedtls_x509_crt_parse_file( &crt, crt_file ) == 0 ); - TEST_ASSERT( mbedtls_x509_crt_check_extended_key_usage( &crt, oid, len ) == ret ); + TEST_ASSERT( mbedtls_x509_crt_check_extended_key_usage( &crt, (const char *)oid->x, oid->len ) == ret ); exit: mbedtls_x509_crt_free( &crt ); @@ -721,9 +774,8 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_USE_C */ -void x509_get_time( int tag, char *time_str, int ret, - int year, int mon, int day, - int hour, int min, int sec ) +void x509_get_time( int tag, char * time_str, int ret, int year, int mon, + int day, int hour, int min, int sec ) { mbedtls_x509_time time; unsigned char buf[21]; @@ -752,7 +804,7 @@ void x509_get_time( int tag, char *time_str, int ret, /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_X509_RSASSA_PSS_SUPPORT */ -void x509_parse_rsassa_pss_params( char *hex_params, int params_tag, +void x509_parse_rsassa_pss_params( data_t * hex_params, int params_tag, int ref_msg_md, int ref_mgf_md, int ref_salt_len, int ref_ret ) { @@ -761,7 +813,8 @@ void x509_parse_rsassa_pss_params( char *hex_params, int params_tag, mbedtls_md_type_t my_msg_md, my_mgf_md; int my_salt_len; - params.p = unhexify_alloc( hex_params, ¶ms.len ); + params.p = hex_params->x; + params.len = hex_params->len; params.tag = params_tag; my_ret = mbedtls_x509_get_rsassa_pss_params( ¶ms, &my_msg_md, &my_mgf_md, @@ -777,12 +830,12 @@ void x509_parse_rsassa_pss_params( char *hex_params, int params_tag, } exit: - mbedtls_free( params.p ); + ;; } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C:MBEDTLS_SELF_TEST */ -void x509_selftest() +void x509_selftest( ) { TEST_ASSERT( mbedtls_x509_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.data b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.data index 5b54d85885..c196625037 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.data +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.data @@ -1,78 +1,86 @@ Certificate Request check Server1 SHA1 depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha1":MBEDTLS_MD_SHA1:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha1":MBEDTLS_MD_SHA1:0:0:0:0 Certificate Request check Server1 SHA224 depends_on:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha224":MBEDTLS_MD_SHA224:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha224":MBEDTLS_MD_SHA224:0:0:0:0 Certificate Request check Server1 SHA256 depends_on:MBEDTLS_SHA256_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha256":MBEDTLS_MD_SHA256:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha256":MBEDTLS_MD_SHA256:0:0:0:0 Certificate Request check Server1 SHA384 depends_on:MBEDTLS_SHA512_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha384":MBEDTLS_MD_SHA384:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha384":MBEDTLS_MD_SHA384:0:0:0:0 Certificate Request check Server1 SHA512 depends_on:MBEDTLS_SHA512_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha512":MBEDTLS_MD_SHA512:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.sha512":MBEDTLS_MD_SHA512:0:0:0:0 Certificate Request check Server1 MD4 depends_on:MBEDTLS_MD4_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.md4":MBEDTLS_MD_MD4:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.md4":MBEDTLS_MD_MD4:0:0:0:0 Certificate Request check Server1 MD5 depends_on:MBEDTLS_MD5_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.md5":MBEDTLS_MD_MD5:0:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.md5":MBEDTLS_MD_MD5:0:0:0:0 Certificate Request check Server1 key_usage depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.key_usage":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:0 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.key_usage":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:1:0:0 + +Certificate Request check Server1 key_usage empty +depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.key_usage_empty":MBEDTLS_MD_SHA1:0:1:0:0 Certificate Request check Server1 ns_cert_type depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.cert_type":MBEDTLS_MD_SHA1:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER +x509_csr_check:"data_files/server1.key":"data_files/server1.req.cert_type":MBEDTLS_MD_SHA1:0:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:1 + +Certificate Request check Server1 ns_cert_type empty +depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 +x509_csr_check:"data_files/server1.key":"data_files/server1.req.cert_type_empty":MBEDTLS_MD_SHA1:0:0:0:1 Certificate Request check Server1 key_usage + ns_cert_type depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15 -x509_csr_check:"data_files/server1.key":"data_files/server1.req.ku-ct":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER +x509_csr_check:"data_files/server1.key":"data_files/server1.req.ku-ct":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:1:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:1 Certificate Request check Server5 ECDSA, key_usage depends_on:MBEDTLS_SHA1_C:MBEDTLS_ECDSA_C:MBEDTLS_ECDSA_DETERMINISTIC:MBEDTLS_ECP_DP_SECP256R1_ENABLED -x509_csr_check:"data_files/server5.key":"data_files/server5.req.ku.sha1":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION:0 +x509_csr_check:"data_files/server5.key":"data_files/server5.req.ku.sha1":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION:1:0:0 Certificate write check Server1 SHA1 depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:1:-1:"data_files/server1.crt":0 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:0:1:-1:"data_files/server1.crt":0 Certificate write check Server1 SHA1, key_usage depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:0:1:-1:"data_files/server1.key_usage.crt":0 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:1:0:0:1:-1:"data_files/server1.key_usage.crt":0 Certificate write check Server1 SHA1, ns_cert_type depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:1:-1:"data_files/server1.cert_type.crt":0 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:1:1:-1:"data_files/server1.cert_type.crt":0 Certificate write check Server1 SHA1, version 1 depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:1:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt":0 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:0:1:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt":0 Certificate write check Server1 SHA1, RSA_ALT depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:-1:"data_files/server1.noauthid.crt":1 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:0:0:-1:"data_files/server1.noauthid.crt":1 Certificate write check Server1 SHA1, RSA_ALT, key_usage depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:0:0:-1:"data_files/server1.key_usage_noauthid.crt":1 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:MBEDTLS_X509_KU_DIGITAL_SIGNATURE | MBEDTLS_X509_KU_NON_REPUDIATION | MBEDTLS_X509_KU_KEY_ENCIPHERMENT:1:0:0:0:-1:"data_files/server1.key_usage_noauthid.crt":1 Certificate write check Server1 SHA1, RSA_ALT, ns_cert_type depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:0:-1:"data_files/server1.cert_type_noauthid.crt":1 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:MBEDTLS_X509_NS_CERT_TYPE_SSL_SERVER:1:0:-1:"data_files/server1.cert_type_noauthid.crt":1 Certificate write check Server1 SHA1, RSA_ALT, version 1 depends_on:MBEDTLS_SHA1_C:MBEDTLS_RSA_C:MBEDTLS_PKCS1_V15:MBEDTLS_DES_C:MBEDTLS_CIPHER_MODE_CBC:MBEDTLS_MD5_C -x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt":1 +x509_crt_check:"data_files/server1.key":"":"C=NL,O=PolarSSL,CN=PolarSSL Server 1":"data_files/test-ca.key":"PolarSSLTest":"C=NL,O=PolarSSL,CN=PolarSSL Test CA":"1":"20110212144406":"20210212144406":MBEDTLS_MD_SHA1:0:0:0:0:0:MBEDTLS_X509_CRT_VERSION_1:"data_files/server1.v1.crt":1 X509 String to Names #1 mbedtls_x509_string_to_names:"C=NL,O=Offspark\, Inc., OU=PolarSSL":"C=NL, O=Offspark, Inc., OU=PolarSSL":0 diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.function index 62f82e8a05..535807e3a2 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_x509write.function @@ -1,4 +1,5 @@ /* BEGIN_HEADER */ +#include "mbedtls/bignum.h" #include "mbedtls/x509_crt.h" #include "mbedtls/x509_csr.h" #include "mbedtls/pem.h" @@ -35,8 +36,9 @@ size_t mbedtls_rsa_key_len_func( void *ctx ) */ /* BEGIN_CASE depends_on:MBEDTLS_PEM_WRITE_C:MBEDTLS_X509_CSR_WRITE_C */ -void x509_csr_check( char *key_file, char *cert_req_check_file, - int md_type, int key_usage, int cert_type ) +void x509_csr_check( char * key_file, char * cert_req_check_file, int md_type, + int key_usage, int set_key_usage, int cert_type, + int set_cert_type ) { mbedtls_pk_context key; mbedtls_x509write_csr req; @@ -58,9 +60,9 @@ void x509_csr_check( char *key_file, char *cert_req_check_file, mbedtls_x509write_csr_set_md_alg( &req, md_type ); mbedtls_x509write_csr_set_key( &req, &key ); TEST_ASSERT( mbedtls_x509write_csr_set_subject_name( &req, subject_name ) == 0 ); - if( key_usage != 0 ) + if( set_key_usage != 0 ) TEST_ASSERT( mbedtls_x509write_csr_set_key_usage( &req, key_usage ) == 0 ); - if( cert_type != 0 ) + if( set_cert_type != 0 ) TEST_ASSERT( mbedtls_x509write_csr_set_ns_cert_type( &req, cert_type ) == 0 ); ret = mbedtls_x509write_csr_pem( &req, buf, sizeof( buf ), @@ -99,7 +101,8 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd, char *subject_name, char *issuer_key_file, char *issuer_pwd, char *issuer_name, char *serial_str, char *not_before, char *not_after, - int md_type, int key_usage, int cert_type, int auth_ident, + int md_type, int key_usage, int set_key_usage, + int cert_type, int set_cert_type, int auth_ident, int ver, char *cert_check_file, int rsa_alt ) { mbedtls_pk_context subject_key, issuer_key, issuer_key_alt; @@ -167,9 +170,9 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd, TEST_ASSERT( mbedtls_x509write_crt_set_subject_key_identifier( &crt ) == 0 ); if( auth_ident ) TEST_ASSERT( mbedtls_x509write_crt_set_authority_key_identifier( &crt ) == 0 ); - if( key_usage != 0 ) + if( set_key_usage != 0 ) TEST_ASSERT( mbedtls_x509write_crt_set_key_usage( &crt, key_usage ) == 0 ); - if( cert_type != 0 ) + if( set_cert_type != 0 ) TEST_ASSERT( mbedtls_x509write_crt_set_ns_cert_type( &crt, cert_type ) == 0 ); } @@ -209,7 +212,8 @@ exit: /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_X509_CREATE_C:MBEDTLS_X509_USE_C */ -void mbedtls_x509_string_to_names( char *name, char *parsed_name, int result ) +void mbedtls_x509_string_to_names( char * name, char * parsed_name, int result + ) { int ret; size_t len = 0; diff --git a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_xtea.function b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_xtea.function index cbc714a12f..a24a420657 100644 --- a/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_xtea.function +++ b/3rdparty/mbedtls/mbedtls/tests/suites/test_suite_xtea.function @@ -8,121 +8,77 @@ */ /* BEGIN_CASE */ -void xtea_encrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string ) +void xtea_encrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_xtea_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); - unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - mbedtls_xtea_setup( &ctx, key_str ); - TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + mbedtls_xtea_setup( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE */ -void xtea_decrypt_ecb( char *hex_key_string, char *hex_src_string, - char *hex_dst_string ) +void xtea_decrypt_ecb( data_t * key_str, data_t * src_str, + data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; unsigned char output[100]; mbedtls_xtea_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); memset(output, 0x00, 100); - unhexify( key_str, hex_key_string ); - unhexify( src_str, hex_src_string ); - mbedtls_xtea_setup( &ctx, key_str ); - TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_DECRYPT, src_str, output ) == 0 ); - hexify( dst_str, output, 8 ); + mbedtls_xtea_setup( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_xtea_crypt_ecb( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, 8, hex_dst_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void xtea_encrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void xtea_encrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; - unsigned char iv_str[100]; unsigned char output[100]; - size_t len; mbedtls_xtea_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); - memset(iv_str, 0x00, 100); memset(output, 0x00, 100); - unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - len = unhexify( src_str, hex_src_string ); - mbedtls_xtea_setup( &ctx, key_str ); - TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_ENCRYPT, len, iv_str, - src_str, output ) == 0 ); - hexify( dst_str, output, len ); + mbedtls_xtea_setup( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_ENCRYPT, src_str->len, iv_str->x, + src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_CBC */ -void xtea_decrypt_cbc( char *hex_key_string, char *hex_iv_string, - char *hex_src_string, char *hex_dst_string ) +void xtea_decrypt_cbc( data_t * key_str, data_t * iv_str, + data_t * src_str, data_t * hex_dst_string ) { - unsigned char key_str[100]; - unsigned char src_str[100]; - unsigned char dst_str[100]; - unsigned char iv_str[100]; unsigned char output[100]; - size_t len; mbedtls_xtea_context ctx; - memset(key_str, 0x00, 100); - memset(src_str, 0x00, 100); - memset(dst_str, 0x00, 100); - memset(iv_str, 0x00, 100); memset(output, 0x00, 100); - unhexify( key_str, hex_key_string ); - unhexify( iv_str, hex_iv_string ); - len = unhexify( src_str, hex_src_string ); - mbedtls_xtea_setup( &ctx, key_str ); - TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_DECRYPT, len, iv_str, - src_str, output ) == 0 ); - hexify( dst_str, output, len ); + mbedtls_xtea_setup( &ctx, key_str->x ); + TEST_ASSERT( mbedtls_xtea_crypt_cbc( &ctx, MBEDTLS_XTEA_DECRYPT, src_str->len, iv_str->x, + src_str->x, output ) == 0 ); - TEST_ASSERT( strcmp( (char *) dst_str, hex_dst_string ) == 0 ); + TEST_ASSERT( hexcmp( output, hex_dst_string->x, src_str->len, hex_dst_string->len ) == 0 ); } /* END_CASE */ /* BEGIN_CASE depends_on:MBEDTLS_SELF_TEST */ -void xtea_selftest() +void xtea_selftest( ) { TEST_ASSERT( mbedtls_xtea_self_test( 1 ) == 0 ); } diff --git a/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.sln b/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.sln index 686091c7f7..5d2c99cd36 100644 --- a/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.sln +++ b/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.sln @@ -183,22 +183,27 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gen_random_ctr_drbg", "gen_ {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl_cert_test", "ssl_cert_test.vcxproj", "{3FE0C0E1-D9BA-6A26-380C-F293E543B914}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcxproj", "{90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}" ProjectSection(ProjectDependencies) = postProject {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcxproj", "{90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "selftest", "selftest.vcxproj", "{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}" ProjectSection(ProjectDependencies) = postProject {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "selftest", "selftest.vcxproj", "{7DBC5F77-3DA1-5F73-8421-E693D95FC66A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udp_proxy", "udp_proxy.vcxproj", "{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}" ProjectSection(ProjectDependencies) = postProject {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udp_proxy", "udp_proxy.vcxproj", "{7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zeroize", "zeroize.vcxproj", "{10C01E94-4926-063E-9F56-C84ED190D349}" + ProjectSection(ProjectDependencies) = postProject + {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "query_compile_time_config", "query_compile_time_config.vcxproj", "{D6F58AF2-9D80-562A-E2B0-F743281522B9}" ProjectSection(ProjectDependencies) = postProject {46CF2D25-6A36-4189-B59C-E4815388E554} = {46CF2D25-6A36-4189-B59C-E4815388E554} EndProjectSection @@ -542,14 +547,6 @@ Global {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|Win32.Build.0 = Release|Win32 {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|x64.ActiveCfg = Release|x64 {5FCC71F6-FF33-EBCF-FBA2-8FC783D5318E}.Release|x64.Build.0 = Release|x64 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|Win32.ActiveCfg = Debug|Win32 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|Win32.Build.0 = Debug|Win32 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|x64.ActiveCfg = Debug|x64 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Debug|x64.Build.0 = Debug|x64 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|Win32.ActiveCfg = Release|Win32 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|Win32.Build.0 = Release|Win32 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|x64.ActiveCfg = Release|x64 - {3FE0C0E1-D9BA-6A26-380C-F293E543B914}.Release|x64.Build.0 = Release|x64 {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|Win32.ActiveCfg = Debug|Win32 {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|Win32.Build.0 = Debug|Win32 {90EFD9A4-C6B0-3EE8-1F06-0A0E0D55AEDA}.Debug|x64.ActiveCfg = Debug|x64 @@ -574,6 +571,22 @@ Global {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|Win32.Build.0 = Release|Win32 {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|x64.ActiveCfg = Release|x64 {7E2C80FE-3CC3-82B4-0CAD-65DC233DE13A}.Release|x64.Build.0 = Release|x64 + {10C01E94-4926-063E-9F56-C84ED190D349}.Debug|Win32.ActiveCfg = Debug|Win32 + {10C01E94-4926-063E-9F56-C84ED190D349}.Debug|Win32.Build.0 = Debug|Win32 + {10C01E94-4926-063E-9F56-C84ED190D349}.Debug|x64.ActiveCfg = Debug|x64 + {10C01E94-4926-063E-9F56-C84ED190D349}.Debug|x64.Build.0 = Debug|x64 + {10C01E94-4926-063E-9F56-C84ED190D349}.Release|Win32.ActiveCfg = Release|Win32 + {10C01E94-4926-063E-9F56-C84ED190D349}.Release|Win32.Build.0 = Release|Win32 + {10C01E94-4926-063E-9F56-C84ED190D349}.Release|x64.ActiveCfg = Release|x64 + {10C01E94-4926-063E-9F56-C84ED190D349}.Release|x64.Build.0 = Release|x64 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Debug|Win32.ActiveCfg = Debug|Win32 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Debug|Win32.Build.0 = Debug|Win32 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Debug|x64.ActiveCfg = Debug|x64 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Debug|x64.Build.0 = Debug|x64 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Release|Win32.ActiveCfg = Release|Win32 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Release|Win32.Build.0 = Release|Win32 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Release|x64.ActiveCfg = Release|x64 + {D6F58AF2-9D80-562A-E2B0-F743281522B9}.Release|x64.Build.0 = Release|x64 {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|Win32.ActiveCfg = Debug|Win32 {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|Win32.Build.0 = Debug|Win32 {D3C6FBD6-D78E-7180-8345-5E09B492DBEC}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.vcxproj b/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.vcxproj index f13f83cc16..73c92bda55 100644 --- a/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.vcxproj +++ b/3rdparty/mbedtls/mbedtls/visualc/VS2010/mbedTLS.vcxproj @@ -149,6 +149,7 @@ + @@ -158,6 +159,8 @@ + + @@ -178,6 +181,7 @@ + @@ -187,6 +191,7 @@ + @@ -197,6 +202,8 @@ + + @@ -222,6 +229,7 @@ + @@ -230,6 +238,8 @@ + + @@ -247,6 +257,7 @@ + @@ -255,6 +266,7 @@ + @@ -266,6 +278,8 @@ + + diff --git a/3rdparty/mbedtls/mbedtls/visualc/VS2010/query_compile_time_config.vcxproj b/3rdparty/mbedtls/mbedtls/visualc/VS2010/query_compile_time_config.vcxproj new file mode 100644 index 0000000000..83a29f0679 --- /dev/null +++ b/3rdparty/mbedtls/mbedtls/visualc/VS2010/query_compile_time_config.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + {46cf2d25-6a36-4189-b59c-e4815388e554} + true + + + + {D6F58AF2-9D80-562A-E2B0-F743281522B9} + Win32Proj + query_compile_time_config + + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + Windows7.1SDK + + + + + + + + + + + + + + + + + + + true + $(Configuration)\$(TargetName)\ + + + true + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + false + $(Configuration)\$(TargetName)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + Debug + + + false + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + NotSet + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + Debug + + + false + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ../../include + + + Console + true + true + true + Release + %(AdditionalDependencies); + + + + + + diff --git a/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_client2.vcxproj b/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_client2.vcxproj index 1d44fa783c..a960facf07 100644 --- a/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_client2.vcxproj +++ b/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_client2.vcxproj @@ -20,6 +20,7 @@ + diff --git a/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_server2.vcxproj b/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_server2.vcxproj index d06e0628ef..06a91cb495 100644 --- a/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_server2.vcxproj +++ b/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_server2.vcxproj @@ -20,6 +20,7 @@ + diff --git a/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj b/3rdparty/mbedtls/mbedtls/visualc/VS2010/zeroize.vcxproj similarity index 96% rename from 3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj rename to 3rdparty/mbedtls/mbedtls/visualc/VS2010/zeroize.vcxproj index b8f014e367..9d311c7217 100644 --- a/3rdparty/mbedtls/mbedtls/visualc/VS2010/ssl_cert_test.vcxproj +++ b/3rdparty/mbedtls/mbedtls/visualc/VS2010/zeroize.vcxproj @@ -19,7 +19,7 @@ - + @@ -28,9 +28,9 @@ - {3FE0C0E1-D9BA-6A26-380C-F293E543B914} + {10C01E94-4926-063E-9F56-C84ED190D349} Win32Proj - ssl_cert_test + zeroize diff --git a/3rdparty/mbedtls/mbedtls/yotta/create-module.sh b/3rdparty/mbedtls/mbedtls/yotta/create-module.sh deleted file mode 100755 index 4c79ebe510..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/create-module.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -set -eu - -# relative to the script's directory -TREE=.. -DEST=module - -# make sure we're running in our own directory -if [ -f create-module.sh ]; then :; else - cd $( dirname $0 ) - if [ -f create-module.sh ]; then :; else - echo "Please run the script from is directory." >&2 - exit 1 - fi -fi - -# use a temporary directory to build the module, then rsync to DEST -# this allows touching only new files, for more efficient re-builds -TMP=$DEST-tmp -rm -rf $TMP - -mkdir -p $TMP/mbedtls $TMP/source -cp $TREE/include/mbedtls/*.h $TMP/mbedtls -cp $TREE/library/*.c $TMP/source - -# temporary, should depend on external module later -cp data/entropy_hardware_poll.c $TMP/source -cp data/target_config.h $TMP/mbedtls - -data/adjust-config.sh $TREE/scripts/config.pl $TMP/mbedtls/config.h - -mkdir -p $TMP/test -cp -r data/example-* $TMP/test -# later we should have the generated test suites here too - -cp data/module.json $TMP -cp data/README.md $TMP - -cp ../LICENSE $TMP -if [ -f ../apache-2.0.txt ]; then cp ../apache-2.0.txt $TMP; fi - -mkdir -p $DEST -rsync -cr --delete --exclude build --exclude yotta_\* $TMP/ $DEST/ -rm -rf $TMP - -echo "mbed TLS yotta module created in '$PWD/$DEST'." diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/README.md b/3rdparty/mbedtls/mbedtls/yotta/data/README.md deleted file mode 100644 index b748aac32b..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/README.md +++ /dev/null @@ -1,103 +0,0 @@ -# mbed TLS - -mbed TLS makes it trivially easy for developers to include cryptographic and SSL/TLS capabilities in their embedded products, with a minimal code footprint. It offers an SSL library with an intuitive API and readable source code. - -**Note:** The current release is beta, and implements no secure source of random numbers, weakening its security. - -Currently the only supported yotta targets are: -- `frdm-k64f-gcc` -- `frdm-k64f-armcc` -- `x86-linux-native` -- `x86-osx-native` - -## Sample programs - -This release includes the following examples: - -1. [**Self test:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-selftest) Tests different basic functions in the mbed TLS library. - -2. [**Benchmark:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-benchmark) Measures the time taken to perform basic cryptographic functions used in the library. - -3. [**Hashing:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-hashing) Demonstrates the various APIs for computing hashes of data (also known as message digests) with SHA-256. - -4. [**Authenticated encryption:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-authcrypt) Demonstrates usage of the Cipher API for encrypting and authenticating data with AES-CCM. - -These examples are integrated as yotta tests, so that they are built automatically when you build mbed TLS. Each of them comes with complete usage instructions as a Readme file in the repository. - -## Performing TLS and DTLS connections - -A high-level API for performing TLS and DTLS connections with mbed TLS in mbed OS is provided in a separate yotta module: [mbed-tls-sockets](https://github.com/ARMmbed/mbed-tls-sockets). We recommend this API for TLS and DTLS connections. It is very similar to the API provided by the [sockets](https://github.com/ARMmbed/sockets) module for unencrypted TCP and UDP connections. - -The `mbed-tls-sockets` module includes a complete [example TLS client](https://github.com/ARMmbed/mbed-tls-sockets/blob/master/test/tls-client/main.cpp) with [usage instructions](https://github.com/ARMmbed/mbed-tls-sockets/blob/master/test/tls-client/README.md). - -## Configuring mbed TLS features - -mbed TLS makes it easy to disable any feature during compilation, if that feature isn't required for a particular project. The default configuration enables all modern and widely-used features, which should meet the needs of new projects, and disables all features that are older or less common, to minimize the code footprint. - -The list of available compilation flags is available in the fully documented [config.h file](https://github.com/ARMmbed/mbedtls/blob/development/include/mbedtls/config.h). - -If you need to adjust those flags, you can provide your own configuration-adjustment file with suitable `#define` and `#undef` statements. These will be included between the default definitions and the sanity checks. Your configuration file should be in your application's include directory, and can be named freely; you just need to let mbed TLS know the file's name. To do that, use yotta's [configuration system](http://docs.yottabuild.org/reference/config.html). The file's name should be in your `config.json` file, under mbedtls, as the key `user-config-file`. - -For example, in an application called `myapp`, if you want to enable the EC J-PAKE key exchange and disable the CBC cipher mode, you can create a file named `mbedtls-config-changes.h` in the `myapp` directory containing the following lines: - - #define MBEDTLS_ECJPAKE_C - #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED - - #undef MBEDTLS_CIPHER_MODE_CBC - -And then create a file named `config.json` at the root of your application with the following contents: - - { - "mbedtls": { - "user-config-file": "\"myapp/mbedtls-config-changes.h\"" - } - } - -Please note: you need to provide the exact name that will be used in the `#include` directive, including the `<>` or quotes around the name. - -## Getting mbed TLS from GitHub - -Like most components of mbed OS, mbed TLS is developed in the open and its source can be found on GitHub: [ARMmbed/mbedtls](https://github.com/ARMmbed/mbedtls). Unlike most other mbed OS components, however, you cannot just clone the repository and run `yotta build` from its root. This is because mbed TLS also exists as an independent component, so its repository includes things that are not relevant for mbed OS, as well as other build systems. - -The way to use mbed TLS from a clone of the GitHub repository is to run the following commands from the root of a checkout: - - yotta/create-module.sh - cd yotta/module - -You can then run any yotta command you would normally run, such as `yotta build` or `yotta link`. - -## Differences between the standalone and mbed OS editions - -While the two editions share the same code base, there are still a number of differences, mainly in configuration and integration. You should keep in mind those differences when reading some articles in our [knowledge base](https://tls.mbed.org/kb), as currently all the articles are about the standalone edition. - -* The mbed OS edition has a smaller set of features enabled by default in `config.h`, in order to reduce footprint. While the default configuration of the standalone edition puts more emphasize on maintaining interoperability with old peers, the mbed OS edition only enables the most modern ciphers and the latest version of (D)TLS. - -* The following components of mbed TLS are disabled in the mbed OS edition: `net_sockets.c` and `timing.c`. This is because mbed OS include their equivalents. - -* The mbed OS edition comes with a fully integrated API for (D)TLS connections in a companion module: [mbed-tls-sockets](https://github.com/ARMmbed/mbed-tls-sockets). See "Performing TLS and DTLS connections" above. - -## Other resources - -The [mbed TLS website](https://tls.mbed.org) contains many other useful -resources for the developer, such as [developer -documentation](https://tls.mbed.org/dev-corner), [knowledgebase -articles](https://tls.mbed.org/kb), and a [support forum](https://tls.mbed.org/discussions). - -## Contributing - -We gratefully accept bug reports and contributions from the community. There are some requirements we need to fulfill in order to be able to integrate contributions: - -* Simple bug fixes to existing code do not contain copyright themselves and we can integrate without issue. The same is true of trivial contributions. - -* For larger contributions, such as a new feature, the code can possibly fall under copyright law. We then need your consent to share in the ownership of the copyright. We have a form for this, which we will send to you in case you submit a contribution or pull request that we deem this necessary for. - -To contribute, please: - -* [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug. - -* Fork the [mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the "development" branch as a basis. - -* Write a test that shows that the bug was fixed or that the feature works as expected. - -* Send a pull request and bug us until it gets merged and published. We will include your name in the ChangeLog. - diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/adjust-config.sh b/3rdparty/mbedtls/mbedtls/yotta/data/adjust-config.sh deleted file mode 100755 index 3fa84908f4..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/adjust-config.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -set -eu - -if [ $# -ne 2 ]; then - echo "Usage: $0 path/to/config.pl path/to/config.h" >&2 - exit 1 -fi - -SCRIPT=$1 -FILE=$2 - -conf() { - $SCRIPT -f $FILE $@ -} - - -# Set the target specific header -conf set YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE \"mbedtls/target_config.h\" - -# not supported on mbed OS, nor used by mbed Client -conf unset MBEDTLS_NET_C -conf unset MBEDTLS_TIMING_C - -# not supported on all targets with mbed OS, nor used by mbed Client -conf unset MBEDTLS_FS_IO - -conf unset MBEDTLS_CIPHER_MODE_CFB -conf unset MBEDTLS_CIPHER_MODE_CTR -conf unset MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS -conf unset MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN -conf unset MBEDTLS_CIPHER_PADDING_ZEROS -conf unset MBEDTLS_ECP_DP_SECP192R1_ENABLED -conf unset MBEDTLS_ECP_DP_SECP224R1_ENABLED -conf unset MBEDTLS_ECP_DP_SECP521R1_ENABLED -conf unset MBEDTLS_ECP_DP_SECP192K1_ENABLED -conf unset MBEDTLS_ECP_DP_SECP224K1_ENABLED -conf unset MBEDTLS_ECP_DP_SECP256K1_ENABLED -conf unset MBEDTLS_ECP_DP_BP256R1_ENABLED -conf unset MBEDTLS_ECP_DP_BP384R1_ENABLED -conf unset MBEDTLS_ECP_DP_BP512R1_ENABLED -conf unset MBEDTLS_PK_PARSE_EC_EXTENDED - -conf unset MBEDTLS_AESNI_C -conf unset MBEDTLS_ARC4_C -conf unset MBEDTLS_BLOWFISH_C -conf unset MBEDTLS_CAMELLIA_C -conf unset MBEDTLS_DES_C -conf unset MBEDTLS_DHM_C -conf unset MBEDTLS_GENPRIME -conf unset MBEDTLS_MD5_C -conf unset MBEDTLS_PADLOCK_C -conf unset MBEDTLS_PEM_WRITE_C -conf unset MBEDTLS_PKCS5_C -conf unset MBEDTLS_PKCS12_C -conf unset MBEDTLS_RIPEMD160_C -conf unset MBEDTLS_SHA1_C -conf unset MBEDTLS_XTEA_C - -conf unset MBEDTLS_X509_RSASSA_PSS_SUPPORT - -conf unset MBEDTLS_X509_CSR_PARSE_C -conf unset MBEDTLS_X509_CREATE_C -conf unset MBEDTLS_X509_CRT_WRITE_C -conf unset MBEDTLS_X509_CSR_WRITE_C - -conf unset MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED -conf unset MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED -conf unset MBEDTLS_KEY_EXCHANGE_RSA_ENABLED -conf unset MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED -conf unset MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED -conf unset MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED -conf unset MBEDTLS_SSL_FALLBACK_SCSV -conf unset MBEDTLS_SSL_CBC_RECORD_SPLITTING -conf unset MBEDTLS_SSL_PROTO_TLS1 -conf unset MBEDTLS_SSL_PROTO_TLS1_1 -conf unset MBEDTLS_SSL_TRUNCATED_HMAC diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/entropy_hardware_poll.c b/3rdparty/mbedtls/mbedtls/yotta/data/entropy_hardware_poll.c deleted file mode 100644 index 3a61e22aef..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/entropy_hardware_poll.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Hardware entropy collector for the K64F, using Freescale's RNGA - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -/* - * WARNING: this is temporary! - * This should be in a separate yotta module which would be a target - * dependency of mbedtls (see IOTSSL-313) - */ - -#if defined(TARGET_LIKE_K64F) - -/* - * Reference: "K64 Sub-Family Reference Manual, Rev. 2", chapter 34 - */ - -#include "fsl_clock_manager.h" - -/* - * Get one byte of entropy from the RNG, assuming it is up and running. - * As recommended (34.1.1), get only one bit of each output. - */ -static void rng_get_byte( unsigned char *byte ) -{ - size_t bit; - - /* 34.5 Steps 3-4-5: poll SR and read from OR when ready */ - for( bit = 0; bit < 8; bit++ ) - { - while( ( RNG->SR & RNG_SR_OREG_LVL_MASK ) == 0 ); - *byte |= ( RNG->OR & 1 ) << bit; - } -} - -/* - * Get len bytes of entropy from the hardware RNG. - */ -int mbedtls_hardware_poll( void *data, - unsigned char *output, size_t len, size_t *olen ) -{ - size_t i; - int ret; - ((void) data); - - CLOCK_SYS_EnableRngaClock( 0 ); - - /* Set "Interrupt Mask", "High Assurance" and "Go", - * unset "Clear interrupt" and "Sleep" */ - RNG->CR = RNG_CR_INTM_MASK | RNG_CR_HA_MASK | RNG_CR_GO_MASK; - - for( i = 0; i < len; i++ ) - rng_get_byte( output + i ); - - /* Just be extra sure that we didn't do it wrong */ - if( ( RNG->SR & RNG_SR_SECV_MASK ) != 0 ) - { - ret = -1; - goto cleanup; - } - - *olen = len; - ret = 0; - -cleanup: - /* Disable clock to save power - assume we're the only users of RNG */ - CLOCK_SYS_DisableRngaClock( 0 ); - - return( ret ); -} - -#endif diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-authcrypt/README.md b/3rdparty/mbedtls/mbedtls/yotta/data/example-authcrypt/README.md deleted file mode 100644 index 7ad685ff72..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-authcrypt/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Authenticated Encryption Example - -This application performs authenticated encryption and authenticated decryption of a buffer. It serves as a tutorial for the basic authenticated encryption functions of mbed TLS. - -## Pre-requisites - -To build and run this example you must have: - -* A computer with the following software installed: - * [CMake](http://www.cmake.org/download/). - * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). - * [Python](https://www.python.org/downloads/). - * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). - * A serial terminal emulator (Like screen, pySerial and cu). -* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). -* A micro-USB cable. -* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). - -## Getting started - -1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. - -2. Navigate to the mbedtls directory supplied with your release and open a terminal. - -3. Set the yotta target: - - ``` - yotta target frdm-k64f-gcc - ``` - -4. Build mbedtls and the examples. This may take a long time if this is your first compilation: - - ``` - $ yotta build - ``` - -5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-authcrypt.bin` to your mbed board and wait until the LED next to the USB port stops blinking. - -6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. - - Use the following settings: - - * 115200 baud (not 9600). - * 8N1. - * No flow control. - -7. Press the Reset button on the board. - -8. The output in the terminal window should look like: - - ``` - {{timeout;10}} - {{host_test_name;default}} - {{description;mbed TLS example authcrypt}} - {{test_id;MBEDTLS_EX_AUTHCRYPT}} - {{start}} - - - plaintext message: 536f6d65207468696e67732061726520626574746572206c65667420756e7265616400 - ciphertext: c57f7afb94f14c7977d785d08682a2596bd62ee9dcf216b8cccd997afee9b402f5de1739e8e6467aa363749ef39392e5c66622b01c7203ec0a3d14 - decrypted: 536f6d65207468696e67732061726520626574746572206c65667420756e7265616400 - - DONE - {{success}} - {{end}} - ``` - -The actual output for the ciphertext line will vary on each run because of the use of a random nonce in the encryption process. diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-authcrypt/main.cpp b/3rdparty/mbedtls/mbedtls/yotta/data/example-authcrypt/main.cpp deleted file mode 100644 index 23fad27926..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-authcrypt/main.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Hello world example of using the authenticated encryption with mbed TLS - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#include "mbedtls/cipher.h" -#include "mbedtls/entropy.h" -#include "mbedtls/ctr_drbg.h" - -#include -#include - -static void print_hex(const char *title, const unsigned char buf[], size_t len) -{ - printf("%s: ", title); - - for (size_t i = 0; i < len; i++) - printf("%02x", buf[i]); - - printf("\r\n"); -} - -/* - * The pre-shared key. Should be generated randomly and be unique to the - * device/channel/etc. Just used a fixed on here for simplicity. - */ -static const unsigned char secret_key[16] = { - 0xf4, 0x82, 0xc6, 0x70, 0x3c, 0xc7, 0x61, 0x0a, - 0xb9, 0xa0, 0xb8, 0xe9, 0x87, 0xb8, 0xc1, 0x72, -}; - -static int example(void) -{ - /* message that should be protected */ - const char message[] = "Some things are better left unread"; - /* metadata transmitted in the clear but authenticated */ - const char metadata[] = "eg sequence number, routing info"; - /* ciphertext buffer large enough to hold message + nonce + tag */ - unsigned char ciphertext[128] = { 0 }; - int ret; - - printf("\r\n\r\n"); - print_hex("plaintext message", (unsigned char *) message, sizeof message); - - /* - * Setup random number generator - * (Note: later this might be done automatically.) - */ - mbedtls_entropy_context entropy; /* entropy pool for seeding PRNG */ - mbedtls_ctr_drbg_context drbg; /* pseudo-random generator */ - - mbedtls_entropy_init(&entropy); - mbedtls_ctr_drbg_init(&drbg); - - /* Seed the PRNG using the entropy pool, and throw in our secret key as an - * additional source of randomness. */ - ret = mbedtls_ctr_drbg_seed(&drbg, mbedtls_entropy_func, &entropy, - secret_key, sizeof (secret_key)); - if (ret != 0) { - printf("mbedtls_ctr_drbg_init() returned -0x%04X\r\n", -ret); - return 1; - } - - /* - * Setup AES-CCM contex - */ - mbedtls_cipher_context_t ctx; - - mbedtls_cipher_init(&ctx); - - ret = mbedtls_cipher_setup(&ctx, mbedtls_cipher_info_from_type(MBEDTLS_CIPHER_AES_128_CCM)); - if (ret != 0) { - printf("mbedtls_cipher_setup() returned -0x%04X\r\n", -ret); - return 1; - } - - ret = mbedtls_cipher_setkey(&ctx, secret_key, 8 * sizeof secret_key, MBEDTLS_ENCRYPT); - if (ret != 0) { - printf("mbedtls_cipher_setkey() returned -0x%04X\r\n", -ret); - return 1; - } - - /* - * Encrypt-authenticate the message and authenticate additional data - * - * First generate a random 8-byte nonce. - * Put it directly in the output buffer as the recipient will need it. - * - * Warning: you must never re-use the same (key, nonce) pair. One of the - * best ways to ensure this to use a counter for the nonce. However this - * means you should save the counter accross rebots, if the key is a - * long-term one. The alternative we choose here is to generate the nonce - * randomly. However it only works if you have a good source of - * randomness. - */ - const size_t nonce_len = 8; - mbedtls_ctr_drbg_random(&drbg, ciphertext, nonce_len); - - size_t ciphertext_len = 0; - /* Go for a conservative 16-byte (128-bit) tag - * and append it to the ciphertext */ - const size_t tag_len = 16; - ret = mbedtls_cipher_auth_encrypt(&ctx, ciphertext, nonce_len, - (const unsigned char *) metadata, sizeof metadata, - (const unsigned char *) message, sizeof message, - ciphertext + nonce_len, &ciphertext_len, - ciphertext + nonce_len + sizeof message, tag_len ); - if (ret != 0) { - printf("mbedtls_cipher_auth_encrypt() returned -0x%04X\r\n", -ret); - return 1; - } - ciphertext_len += nonce_len + tag_len; - - /* - * The following information should now be transmitted: - * - first ciphertext_len bytes of ciphertext buffer - * - metadata if not already transmitted elsewhere - */ - print_hex("ciphertext", ciphertext, ciphertext_len); - - /* - * Decrypt-authenticate - */ - unsigned char decrypted[128] = { 0 }; - size_t decrypted_len = 0; - - ret = mbedtls_cipher_setkey(&ctx, secret_key, 8 * sizeof secret_key, MBEDTLS_DECRYPT); - if (ret != 0) { - printf("mbedtls_cipher_setkey() returned -0x%04X\r\n", -ret); - return 1; - } - - ret = mbedtls_cipher_auth_decrypt(&ctx, - ciphertext, nonce_len, - (const unsigned char *) metadata, sizeof metadata, - ciphertext + nonce_len, ciphertext_len - nonce_len - tag_len, - decrypted, &decrypted_len, - ciphertext + ciphertext_len - tag_len, tag_len ); - /* Checking the return code is CRITICAL for security here */ - if (ret == MBEDTLS_ERR_CIPHER_AUTH_FAILED) { - printf("Something bad is happening! Data is not authentic!\r\n"); - return 1; - } - if (ret != 0) { - printf("mbedtls_cipher_authdecrypt() returned -0x%04X\r\n", -ret); - return 1; - } - - print_hex("decrypted", decrypted, decrypted_len); - - printf("\r\nDONE\r\n"); - - return 0; -} - -#if defined(TARGET_LIKE_MBED) - -#include "mbed-drivers/test_env.h" -#include "minar/minar.h" - -static void run() { - MBED_HOSTTEST_TIMEOUT(10); - MBED_HOSTTEST_SELECT(default); - MBED_HOSTTEST_DESCRIPTION(mbed TLS example authcrypt); - MBED_HOSTTEST_START("MBEDTLS_EX_AUTHCRYPT"); - MBED_HOSTTEST_RESULT(example() == 0); -} - -void app_start(int, char*[]) { - /* Use 115200 bps for consistency with other examples */ - get_stdio_serial().baud(115200); - minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); -} - -#else - -int main() { - return example(); -} - -#endif diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-benchmark/README.md b/3rdparty/mbedtls/mbedtls/yotta/data/example-benchmark/README.md deleted file mode 100644 index 0b99d3d087..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-benchmark/README.md +++ /dev/null @@ -1,100 +0,0 @@ -# mbed TLS Benchmark Example - -This application benchmarks the various cryptographic primitives offered by mbed TLS. - -## Pre-requisites - -To build and run this example you must have: - -* A computer with the following software installed: - * [CMake](http://www.cmake.org/download/). - * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). - * [Python](https://www.python.org/downloads/). - * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). - * A serial terminal emulator (Like screen, pySerial and cu). -* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). -* A micro-USB cable. -* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). - -## Getting started - -1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. - -2. Navigate to the mbedtls directory supplied with your release and open a terminal. - -3. Set the yotta target: - - ``` - yotta target frdm-k64f-gcc - ``` - -4. Build mbedtls and the examples. This may take a long time if this is your first compilation: - - ``` - $ yotta build - ``` - -5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-benchmark.bin` to your mbed board and wait until the LED next to the USB port stops blinking. - -6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. - - Use the following settings: - - * 115200 baud (not 9600). - * 8N1. - * No flow control. - -7. Press the Reset button on the board. - -8. The output in the terminal window should look like: - - ``` - {{timeout;150}} - {{host_test_name;default}} - {{description;mbed TLS benchmark program}} - {{test_id;MBEDTLS_BENCHMARK}} - {{start}} - - - SHA-1 : 3644 KiB/s, 32 cycles/byte - SHA-256 : 1957 KiB/s, 59 cycles/byte - SHA-512 : 587 KiB/s, 200 cycles/byte - AES-CBC-128 : 1359 KiB/s, 86 cycles/byte - AES-CBC-192 : 1183 KiB/s, 99 cycles/byte - AES-CBC-256 : 1048 KiB/s, 111 cycles/byte - AES-GCM-128 : 421 KiB/s, 279 cycles/byte - AES-GCM-192 : 403 KiB/s, 292 cycles/byte - AES-GCM-256 : 385 KiB/s, 305 cycles/byte - AES-CCM-128 : 542 KiB/s, 216 cycles/byte - AES-CCM-192 : 484 KiB/s, 242 cycles/byte - AES-CCM-256 : 437 KiB/s, 268 cycles/byte - CTR_DRBG (NOPR) : 1002 KiB/s, 117 cycles/byte - CTR_DRBG (PR) : 705 KiB/s, 166 cycles/byte - HMAC_DRBG SHA-1 (NOPR) : 228 KiB/s, 517 cycles/byte - HMAC_DRBG SHA-1 (PR) : 210 KiB/s, 561 cycles/byte - HMAC_DRBG SHA-256 (NOPR) : 212 KiB/s, 557 cycles/byte - HMAC_DRBG SHA-256 (PR) : 185 KiB/s, 637 cycles/byte - RSA-2048 : 41 ms/ public - RSA-2048 : 1349 ms/private - RSA-4096 : 134 ms/ public - RSA-4096 : 7149 ms/private - ECDSA-secp384r1 : 640 ms/sign - ECDSA-secp256r1 : 387 ms/sign - ECDSA-secp384r1 : 1233 ms/verify - ECDSA-secp256r1 : 751 ms/verify - ECDHE-secp384r1 : 1191 ms/handshake - ECDHE-secp256r1 : 730 ms/handshake - ECDHE-Curve25519 : 611 ms/handshake - ECDH-secp384r1 : 584 ms/handshake - ECDH-secp256r1 : 365 ms/handshake - ECDH-Curve25519 : 303 ms/handshake - - {{success}} - {{end}} - ``` - -Any performance data generated by this example application are indicative only of the performance of the mbed TLS module on the platform it's executed on. - -Differences in the integration of mbed TLS into the platform, such as whether all available hardware accelerators have been used or not, can lead to significant differences in performance, and so results from the program are not intended to be used to meaningfully compare platforms. - -The figures may also slightly change from execution to execution due to variations in the timing functions. diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-benchmark/main.cpp b/3rdparty/mbedtls/mbedtls/yotta/data/example-benchmark/main.cpp deleted file mode 100644 index d13cde550a..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-benchmark/main.cpp +++ /dev/null @@ -1,951 +0,0 @@ -/* - * Benchmark demonstration program - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#if !defined(TARGET_LIKE_MBED) - -#include - -int main() { - printf("this version of this program only works on mbed OS\n"); - return 0; -} - -#else - -#if !defined(MBEDTLS_CONFIG_FILE) -#include "mbedtls/config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#define mbedtls_exit exit -#define mbedtls_printf printf -#define mbedtls_snprintf snprintf -#define mbedtls_free free -#endif - -#include - -#include "mbedtls/md4.h" -#include "mbedtls/md5.h" -#include "mbedtls/ripemd160.h" -#include "mbedtls/sha1.h" -#include "mbedtls/sha256.h" -#include "mbedtls/sha512.h" -#include "mbedtls/arc4.h" -#include "mbedtls/des.h" -#include "mbedtls/aes.h" -#include "mbedtls/blowfish.h" -#include "mbedtls/camellia.h" -#include "mbedtls/gcm.h" -#include "mbedtls/ccm.h" -#include "mbedtls/havege.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/hmac_drbg.h" -#include "mbedtls/rsa.h" -#include "mbedtls/pk.h" -#include "mbedtls/dhm.h" -#include "mbedtls/ecdsa.h" -#include "mbedtls/ecdh.h" -#include "mbedtls/error.h" - -#include "mbed-drivers/mbed.h" - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) -#include "mbedtls/memory_buffer_alloc.h" -#endif - -#define RSA_PRIVATE_KEY_2048 \ -"-----BEGIN RSA PRIVATE KEY-----\r\n" \ -"MIIEogIBAAKCAQEA2dwVr+IMGEtA2/MCP6fA5eb/6B18Bq6e7gw8brNPkm3E6LyR\r\n" \ -"4DnMJVxZmw3bPDKBDoKzfntkMESi/Yw5UopLtVfjGfWeQWPClqffLZBsZ60BRAsg\r\n" \ -"/g+ID5tgzxSuxzftypK59uexOVCAm7hCKZHGO3DbI7bLY27j7VAgEP7d/yuaz5Fx\r\n" \ -"Kl/vu7shqrBoz6ABJVJD3KC8nUiMRUCXRINmxbyUUjA4DnicZv6+xrGKr36r6M8h\r\n" \ -"VYLa5msKc8WzbnBWzpUsrpb4/r7ML+qp92gdSfVJ8/bLiU7h2C7faDA59uaqrFK9\r\n" \ -"xmDdx7FaWhGQs3LWW6w1UNgkPS0FDYUslpsnsQIDAQABAoIBAC7IJNwM5V3+IuJY\r\n" \ -"T35Nzo1PyloUosJokvY5KGz5Ejg2XBdCDu0gXCcVqqQyGIbXrYDpLhQV+RCoXHun\r\n" \ -"tdN0oQdC5SB47s/J1Uo2qCUHo0+sBd6PqTkFKsl3KxWssk9TQjvCwC412IefMs69\r\n" \ -"hW+ZvwCanmQP56LleApIr2oW4KLfW8Ry/QfZlua+dizctdN7+H1mWwgZQTY9T27J\r\n" \ -"6RtGRA5NVkKVPzIHVJfdpKoO7xGg1g06aEbPB/VmGvZaaFWWnaf7uRvFjLZecBLu\r\n" \ -"QSx2DA/GDjirlDYj99PJb7DtB4xRtKzsyw0o+xapC8w6OtIl/3xFt9moCu2jGrsx\r\n" \ -"vpjHdfECgYEA7fSACRseIs9gAIVX8wq6gayTpA47DHYWAD6IQfIj35SJ+AgsvbFF\r\n" \ -"4AmrwDhcJVPmDy1N4nLBfyGAMt/2CfiYkdkW6QFX/ULRMMBL/G7kWV8hYQDICB2g\r\n" \ -"xaMRN1lPCmFq6BkSWjwIYTnYDFBDWVm1GVT8TMtJoM8Erej9qC0PeFUCgYEA6mF3\r\n" \ -"bigO3t8f5sig+XepaftEUbkJMzo72TVRnIR2ycdR2ihelPQ+25g9dwV0ZA5XXhBS\r\n" \ -"DKOABWjMM739Mwmy9v26Dlmu9R01zHQktMvtEAyfz7lk2NF0aMuj8285OJUBf9bz\r\n" \ -"Cq3MjtMCD+4CZ6iaEqCdUKOuxfpx5cWVJV+qve0CgYBhD1YaYMFOGaBjFgDl1f51\r\n" \ -"Xltqk5NqZdBbkSYrIAWZ8RDF5y+4wFJsLAWuhk6vuyUgE66tK3nZzWRpXAkT0B8L\r\n" \ -"fq1lpXKqj1KcvBNCiEkEW1VWJ+dvyAYIF5eyJ++hoFLnETL3M32HivyhKSwPihPg\r\n" \ -"nVW8TT9fJJIYDe1JZ/fjcQKBgHJfv7UsrR0LSvkG3K8AOtbx+8PZhOjPuRbk0v+L\r\n" \ -"EKCkuIe5/XW4vtfQMeZb7hFJgk7vrepm+vkoy8VQKDf4urGW3W1VTHBmobM01hi4\r\n" \ -"DuYvEul+Mf0wMRtWjJolo4m+BO5KiW2jpFfqFm6JmfjVqOIAKOSKC6am8V/MDF0h\r\n" \ -"kyN9AoGAT9oOiEXMolbkDZw/QCaBiRoAGlGlNYUkJ+58U6OjIZLISw6aFv+Y2uE0\r\n" \ -"mEImItjuYZtSYKblWikp6ldPoKlt9bwEFe3c6IZ8kJ3+xyEyAGrvjXjEY7PzP6dp\r\n" \ -"Ajbjp9X9uocEBv9W/KsBLdQ7yizcL/toHwdBO4vQqmqTvAc5IIw=\r\n" \ -"-----END RSA PRIVATE KEY-----\r\n" - -#define RSA_PRIVATE_KEY_4096 \ -"-----BEGIN RSA PRIVATE KEY-----\r\n" \ -"MIIJKgIBAAKCAgEAmkdGjoIshJuOt2NO47qB3Z3yyvmLg2j351isItSNuFQU3qr+\r\n" \ -"jXHIeANf03yw/K0Zvos8RPd+CqLjoxAQL3QDH4bZAl88bIo29i+SANbNSrKQmc0k\r\n" \ -"pH+yzw3alDzO0GZaOPZjsbo6AwBrno5msi0vRuC2aY8vGLPsZWSyLai7tneS1j/o\r\n" \ -"vYW6XIo8Cj61j2Ypy9HhVUW/4Wc+zAT25D/x7jTpkqJLWWT+YzibNbOY48M5eJcB\r\n" \ -"6/sMyUIeI3/u/wXyMrooNyLiCpedkuHRA0m7u5cWPTUISTunSRlVFij/NHJjuU8e\r\n" \ -"wA3B29yfZFsUqDEnyc+OxniIueAixTomVszxAaVn8zFEbYhFMPqziiFp99u3jfeG\r\n" \ -"k1q9mmUi/uCfUC4e2IC5rqq1ZbKSduH7Ug/Vn2bGQahww0sZFRHDXFrnBcotcW+M\r\n" \ -"bnC290VBDnYgzmdYrIOxuPb2aUwJo4ZlbKh5uBB1PigMuyhLKibQ1a+V5ZJGdpP6\r\n" \ -"SE9PGIdgYWSmh2QEMuLE6v+wTO2LQ5JgqsvFfi3GIZvkn0s8jTS72Jq2uMkFkMer\r\n" \ -"UBjPDYaSPy5kpo103KerWs+cMPOJ/3FtZzI++7MoSUTkWVr1ySQFt5i1EIZ/0Thi\r\n" \ -"jut2jNe8a4AoA3TtC8Rkk/3AIIbg8MVNT4EnT+KHROTMu6gET1oJ3YfBRpUCAwEA\r\n" \ -"AQKCAgEAhuNSmT7PVZH8kfLOAuYKrY1vvm+4v0iDl048Eqfs0QESziyLK3gUYnnw\r\n" \ -"yqP2yrU+EQ8Dvvj0xq/sf6GHxTWVlXb9PcmutueRbmXhLcKg83J0Y0StiPXtjIL8\r\n" \ -"XSddW3Bh6fPi7n14Qy+W6KZwu9AtybanRlvePabyRSRpdOpWVQ7u30w5XZsSed6S\r\n" \ -"6BI0BBC68m2qqje1sInoqdCdXKtcB31TytUDNEHM+UuAyM8iGeGS2hCNqZlycHTS\r\n" \ -"jQ9KEsdMH3YLu0lQgRpWtxmg+VL6ROWwmAtKF12EwbDYZ+uoVl69OkQnCpv8pxKa\r\n" \ -"ec/4m6V+uEA1AOpaAMorHG3fH31IKWC/fTZstovgO/eG2XCtlbcCoWCQ7amFq16l\r\n" \ -"Gh1UKeBHxMXpDj4oDmIUGUvgzSNnEeSN/v76losWvWYQDjXR/LMDa/CNYsD8BmJR\r\n" \ -"PZidIjIXdVRlYOhA7ljtySQvp6RBujBfw3tsVMyZw2XzXFwM9O89b1xXC6+M5jf9\r\n" \ -"DXs/U7Fw+J9qq/YpByABcPCwWdttwdQFRbOxwxaSOKarIqS87TW1JuFcNJ59Ut6G\r\n" \ -"kMvAg6gC34U+0ktkG/AmI1hgjC+P7ErHCXBR2xARoGzcO/CMZF59S+Z2HFchpTSP\r\n" \ -"5T2o4mGy3VfHSBidQQrcZRukg8ZP8M1NF3bXjpY6QZpeLHc4oHECggEBAMjdgzzk\r\n" \ -"xp4mIYFxAEiXYt7tzuUXJk+0UpEJj5uboWLirUZqZmNUPyh6WDnzlREBH++Ms0LO\r\n" \ -"+AWSfaGPDoMb0NE2j3c4FRWAhe7Vn6lj7nLVpF2RdwRo88yGerZ4uwGMY8NUQCtn\r\n" \ -"zum3J7eCJ5DojiceRb6uMxTJ8xZmUC4W2f3J/lrR7wlYjyVnnHqH5HcemYUipWSw\r\n" \ -"sM0/cHp3lrz2VWrbAEu8HVpklvDQpdAgl7cjXt/JHYawY+p426IF/PzQSRROnzgy\r\n" \ -"4WI8FVYNV2tgu0TOFURbkkEvuj/duDKeooUIF0G0XHzha5oAX/j0iWiHbrOF6wHj\r\n" \ -"0xeajL9msKBnmD8CggEBAMSgLWmv7G31x4tndJCcXnX4AyVL7KpygAx/ZwCcyTR8\r\n" \ -"rY1rO07f/ta2noEra/xmEW/BW98qJFCHSU2nSLAQ5FpFSWyuQqrnffrMJnfWyvpr\r\n" \ -"ceQ0yQ/MiA6/JIOvGAjabcspzZijxzGp+Qk3eTT0yOXLSVOCH9B9XVHLodcy4PQM\r\n" \ -"KSCxy0vVHhVNl2SdPEwTXRmxk99Q/rw6IHVpQxBq1OhQt05nTKT+rZMD/grSK22e\r\n" \ -"my2F0DodAJwLo063Zv3RXQZhDYodMmjcp9Hqrtvj9P3HD7J3z6ACiV3SCi8cZumL\r\n" \ -"bSmnKCcd0bb45+aOWm31ieECJuIcJ9rOREEa/KDYTCsCggEBAMG5WkSVhLWsou37\r\n" \ -"dUGNuA63nq42SH3gtS0q4nU6gUkkw+dA4ST1cMByVrr1oRQ4WHup4I4TnQOKyF3T\r\n" \ -"4jQy1I+ipnVeAn+tZ/7zyzwMpEHeqNqRXA9FxbTBEoMAJ6QTqXgOvqDeSqIAQm7r\r\n" \ -"OYu5rrgtqyh/S8bGCwvUe4ooAfCSKx2ekYMbBVwW9MT8YS09tuS/iHJ3Mt2RTMLg\r\n" \ -"qeHvVmxrcXqZoFm44Ba7tN/pP0mi9HKyviZT4tmV3IYEbn3JyGGsfkUuVU9wEUfg\r\n" \ -"MCrgrVxrwfketAzooiHMjkVL2ASjzAJTmEvdAPETYXxzJD9LN0ovY3t8JfAC37IN\r\n" \ -"sVXS8/MCggEBALByOS59Y4Ktq1rLBQx8djwQyuneP0wZohUVAx7Gk7xZIfklQDyg\r\n" \ -"v/R4PrcVezstcPpDnykdjScCsGJR+uWc0v667I/ttP/e6utz5hVmmBGu965dPAzE\r\n" \ -"c1ggaSkOqFfRg/Nr2Qbf+fH0YPnHYSqHe/zSt0OMIvaaeXLcdKhEDSCUBRhE1HWB\r\n" \ -"kxR046WzgBeYzNQwycz9xwqsctJKGpeR9ute+5ANHPd3X9XtID0fqz8ctI5eZaSw\r\n" \ -"wApIW01ZQcAF8B+4WkkVuFXnpWW33yCOaRyPVOPHpnclr5WU1fS+3Q85QkW9rkej\r\n" \ -"97zlkl0QY9AHJqrXnoML1ywAK7ns+MVyNK8CggEAf62xcKZhOb1djeF72Ms+i/i/\r\n" \ -"WIAq4Q4YpsElgvJTHpNH2v9g4ngSTKe3ws3bGc502sWRlhcoTFMOW2rJNe/iqKkb\r\n" \ -"3cdeTkseDbpqozmJWz9dJWSVtXas2bZjzBEa//gQ7nHGVeQdqZJQ9rxPsoOAkfpi\r\n" \ -"qCFrmfUVUqC53e3XMt8+W+aSvKl+JZiB9ozkO9A6Q0vfQLKtjUMdQE3XaCFQT8DI\r\n" \ -"smaLBlBmeRaBpc02ENeC4ADlWosm1SwgxqMhuh2Alba/GrHOoPlVl4hDs9Fb5a6R\r\n" \ -"rmpXSt07GAxnG6j9jssA95E4rc1zO0CVKG5bvjVTxwi/sT0/VVX7VsJM4uTAQg==\r\n" \ -"-----END RSA PRIVATE KEY-----\r\n" - -#if defined _MSC_VER && !defined snprintf -#define snprintf _snprintf -#endif - -/* - * For heap usage estimates, we need an estimate of the overhead per allocated - * block. ptmalloc2/3 (used in gnu libc for instance) uses 2 size_t per block, - * so use that as our baseline. - */ -#define MEM_BLOCK_OVERHEAD ( 2 * sizeof( size_t ) ) - -/* - * Size to use for the malloc buffer if MEMORY_BUFFER_ALLOC_C is defined. - */ -#define HEAP_SIZE (1u << 16) // 64k - -#define BUFSIZE 1024 -#define HEADER_FORMAT " %-24s : " -#define TITLE_LEN 25 - -#define OPTIONS \ - "md4, md5, ripemd160, sha1, sha256, sha512,\r\n" \ - "arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish,\r\n" \ - "havege, ctr_drbg, hmac_drbg\r\n" \ - "rsa, dhm, ecdsa, ecdh.\r\n" - -#if defined(MBEDTLS_ERROR_C) -#define PRINT_ERROR \ - mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \ - mbedtls_printf( "FAILED: %s\r\n", tmp ); -#else -#define PRINT_ERROR \ - mbedtls_printf( "FAILED: -0x%04x\r\n", -ret ); -#endif - -static unsigned long mbedtls_timing_hardclock( void ) -{ - static int dwt_started = 0; - - if( dwt_started == 0 ) - { - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; - } - - return( DWT->CYCCNT ); -} - -static volatile int alarmed; -static void alarm() { alarmed = 1; } - -#define TIME_AND_TSC( TITLE, CODE ) \ -do { \ - unsigned long i, j, tsc; \ - Timeout t; \ - \ - mbedtls_printf( HEADER_FORMAT, TITLE ); \ - fflush( stdout ); \ - \ - for( i = 1, alarmed = 0, t.attach( alarm, 1.0 ); !alarmed; i++ ) \ - { \ - CODE; \ - } \ - \ - tsc = mbedtls_timing_hardclock(); \ - for( j = 0; j < 1024; j++ ) \ - { \ - CODE; \ - } \ - \ - mbedtls_printf( "%9lu KiB/s, %9lu cycles/byte\r\n", \ - i * BUFSIZE / 1024, \ - ( mbedtls_timing_hardclock() - tsc ) / ( j * BUFSIZE ) ); \ -} while( 0 ) - -#if defined(MBEDTLS_ERROR_C) -#define PRINT_ERROR \ - mbedtls_strerror( ret, ( char * )tmp, sizeof( tmp ) ); \ - mbedtls_printf( "FAILED: %s\r\n", tmp ); -#else -#define PRINT_ERROR \ - mbedtls_printf( "FAILED: -0x%04x\r\n", -ret ); -#endif - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG) - -#define MEMORY_MEASURE_INIT \ - size_t max_used, max_blocks, max_bytes; \ - size_t prv_used, prv_blocks; \ - mbedtls_memory_buffer_alloc_cur_get( &prv_used, &prv_blocks ); \ - mbedtls_memory_buffer_alloc_max_reset( ); - -#define MEMORY_MEASURE_PRINT( title_len ) \ - mbedtls_memory_buffer_alloc_max_get( &max_used, &max_blocks ); \ - for( i = 12 - title_len; i != 0; i-- ) mbedtls_printf( " " ); \ - max_used -= prv_used; \ - max_blocks -= prv_blocks; \ - max_bytes = max_used + MEM_BLOCK_OVERHEAD * max_blocks; \ - mbedtls_printf( "%6u heap bytes", (unsigned) max_bytes ); - -#else -#define MEMORY_MEASURE_INIT -#define MEMORY_MEASURE_PRINT( title_len ) -#endif - -#define TIME_PUBLIC( TITLE, TYPE, CODE ) \ -do { \ - unsigned long ms; \ - int ret = 0; \ - Timer t; \ - MEMORY_MEASURE_INIT; \ - \ - mbedtls_printf( HEADER_FORMAT, TITLE ); \ - fflush( stdout ); \ - \ - t.start(); \ - CODE; \ - t.stop(); \ - ms = t.read_ms(); \ - \ - if( ret != 0 ) \ - { \ - PRINT_ERROR; \ - } \ - else \ - { \ - mbedtls_printf( "%6lu ms/" TYPE, ms ); \ - MEMORY_MEASURE_PRINT( sizeof( TYPE ) + 1 ); \ - mbedtls_printf( "\r\n" ); \ - } \ -} while( 0 ) - -static int myrand( void *rng_state, unsigned char *output, size_t len ) -{ - size_t use_len; - int rnd; - - if( rng_state != NULL ) - rng_state = NULL; - - while( len > 0 ) - { - use_len = len; - if( use_len > sizeof(int) ) - use_len = sizeof(int); - - rnd = rand(); - memcpy( output, &rnd, use_len ); - output += use_len; - len -= use_len; - } - - return( 0 ); -} - -/* - * Clear some memory that was used to prepare the context - */ -#if defined(MBEDTLS_ECP_C) -void ecp_clear_precomputed( mbedtls_ecp_group *grp ) -{ - if( grp->T != NULL ) - { - size_t i; - for( i = 0; i < grp->T_size; i++ ) - mbedtls_ecp_point_free( &grp->T[i] ); - mbedtls_free( grp->T ); - } - grp->T = NULL; - grp->T_size = 0; -} -#else -#define ecp_clear_precomputed( g ) -#endif - -unsigned char buf[BUFSIZE]; - -typedef struct { - char md4, md5, ripemd160, sha1, sha256, sha512, - arc4, des3, des, aes_cbc, aes_gcm, aes_ccm, camellia, blowfish, - havege, ctr_drbg, hmac_drbg, - rsa, dhm, ecdsa, ecdh; -} todo_list; - -int benchmark( int argc, char *argv[] ) -{ - int i; - unsigned char tmp[200]; - char title[TITLE_LEN]; - todo_list todo; -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - unsigned char malloc_buf[HEAP_SIZE] = { 0 }; -#endif - - if( argc <= 1 ) - { - memset( &todo, 1, sizeof( todo ) ); - } - else - { - memset( &todo, 0, sizeof( todo ) ); - - for( i = 1; i < argc; i++ ) - { - if( strcmp( argv[i], "md4" ) == 0 ) - todo.md4 = 1; - else if( strcmp( argv[i], "md5" ) == 0 ) - todo.md5 = 1; - else if( strcmp( argv[i], "ripemd160" ) == 0 ) - todo.ripemd160 = 1; - else if( strcmp( argv[i], "sha1" ) == 0 ) - todo.sha1 = 1; - else if( strcmp( argv[i], "sha256" ) == 0 ) - todo.sha256 = 1; - else if( strcmp( argv[i], "sha512" ) == 0 ) - todo.sha512 = 1; - else if( strcmp( argv[i], "arc4" ) == 0 ) - todo.arc4 = 1; - else if( strcmp( argv[i], "des3" ) == 0 ) - todo.des3 = 1; - else if( strcmp( argv[i], "des" ) == 0 ) - todo.des = 1; - else if( strcmp( argv[i], "aes_cbc" ) == 0 ) - todo.aes_cbc = 1; - else if( strcmp( argv[i], "aes_gcm" ) == 0 ) - todo.aes_gcm = 1; - else if( strcmp( argv[i], "aes_ccm" ) == 0 ) - todo.aes_ccm = 1; - else if( strcmp( argv[i], "camellia" ) == 0 ) - todo.camellia = 1; - else if( strcmp( argv[i], "blowfish" ) == 0 ) - todo.blowfish = 1; - else if( strcmp( argv[i], "havege" ) == 0 ) - todo.havege = 1; - else if( strcmp( argv[i], "ctr_drbg" ) == 0 ) - todo.ctr_drbg = 1; - else if( strcmp( argv[i], "hmac_drbg" ) == 0 ) - todo.hmac_drbg = 1; - else if( strcmp( argv[i], "rsa" ) == 0 ) - todo.rsa = 1; - else if( strcmp( argv[i], "dhm" ) == 0 ) - todo.dhm = 1; - else if( strcmp( argv[i], "ecdsa" ) == 0 ) - todo.ecdsa = 1; - else if( strcmp( argv[i], "ecdh" ) == 0 ) - todo.ecdh = 1; - else - { - mbedtls_printf( "Unrecognized option: %s\r\n", argv[i] ); - mbedtls_printf( "Available options: " OPTIONS ); - } - } - } - - mbedtls_printf( "\r\n\r\n" ); - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - mbedtls_memory_buffer_alloc_init( malloc_buf, sizeof( malloc_buf ) ); -#endif - memset( buf, 0xAA, sizeof( buf ) ); - memset( tmp, 0xBB, sizeof( tmp ) ); - -#if defined(MBEDTLS_MD4_C) - if( todo.md4 ) - TIME_AND_TSC( "MD4", mbedtls_md4( buf, BUFSIZE, tmp ) ); -#endif - -#if defined(MBEDTLS_MD5_C) - if( todo.md5 ) - TIME_AND_TSC( "MD5", mbedtls_md5( buf, BUFSIZE, tmp ) ); -#endif - -#if defined(MBEDTLS_RIPEMD160_C) - if( todo.ripemd160 ) - TIME_AND_TSC( "RIPEMD160", mbedtls_ripemd160( buf, BUFSIZE, tmp ) ); -#endif - -#if defined(MBEDTLS_SHA1_C) - if( todo.sha1 ) - TIME_AND_TSC( "SHA-1", mbedtls_sha1( buf, BUFSIZE, tmp ) ); -#endif - -#if defined(MBEDTLS_SHA256_C) - if( todo.sha256 ) - TIME_AND_TSC( "SHA-256", mbedtls_sha256( buf, BUFSIZE, tmp, 0 ) ); -#endif - -#if defined(MBEDTLS_SHA512_C) - if( todo.sha512 ) - TIME_AND_TSC( "SHA-512", mbedtls_sha512( buf, BUFSIZE, tmp, 0 ) ); -#endif - -#if defined(MBEDTLS_ARC4_C) - if( todo.arc4 ) - { - mbedtls_arc4_context arc4; - mbedtls_arc4_init( &arc4 ); - mbedtls_arc4_setup( &arc4, tmp, 32 ); - TIME_AND_TSC( "ARC4", mbedtls_arc4_crypt( &arc4, BUFSIZE, buf, buf ) ); - mbedtls_arc4_free( &arc4 ); - } -#endif - -#if defined(MBEDTLS_DES_C) && defined(MBEDTLS_CIPHER_MODE_CBC) - if( todo.des3 ) - { - mbedtls_des3_context des3; - mbedtls_des3_init( &des3 ); - mbedtls_des3_set3key_enc( &des3, tmp ); - TIME_AND_TSC( "3DES", - mbedtls_des3_crypt_cbc( &des3, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); - mbedtls_des3_free( &des3 ); - } - - if( todo.des ) - { - mbedtls_des_context des; - mbedtls_des_init( &des ); - mbedtls_des_setkey_enc( &des, tmp ); - TIME_AND_TSC( "DES", - mbedtls_des_crypt_cbc( &des, MBEDTLS_DES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); - mbedtls_des_free( &des ); - } -#endif - -#if defined(MBEDTLS_AES_C) -#if defined(MBEDTLS_CIPHER_MODE_CBC) - if( todo.aes_cbc ) - { - int keysize; - mbedtls_aes_context aes; - mbedtls_aes_init( &aes ); - for( keysize = 128; keysize <= 256; keysize += 64 ) - { - mbedtls_snprintf( title, sizeof( title ), "AES-CBC-%d", keysize ); - - memset( buf, 0, sizeof( buf ) ); - memset( tmp, 0, sizeof( tmp ) ); - mbedtls_aes_setkey_enc( &aes, tmp, keysize ); - - TIME_AND_TSC( title, - mbedtls_aes_crypt_cbc( &aes, MBEDTLS_AES_ENCRYPT, BUFSIZE, tmp, buf, buf ) ); - } - mbedtls_aes_free( &aes ); - } -#endif -#if defined(MBEDTLS_GCM_C) - if( todo.aes_gcm ) - { - int keysize; - mbedtls_gcm_context gcm; - - mbedtls_gcm_init( &gcm ); - for( keysize = 128; keysize <= 256; keysize += 64 ) - { - mbedtls_snprintf( title, sizeof( title ), "AES-GCM-%d", keysize ); - - memset( buf, 0, sizeof( buf ) ); - memset( tmp, 0, sizeof( tmp ) ); - mbedtls_gcm_setkey( &gcm, MBEDTLS_CIPHER_ID_AES, tmp, keysize ); - - TIME_AND_TSC( title, - mbedtls_gcm_crypt_and_tag( &gcm, MBEDTLS_GCM_ENCRYPT, BUFSIZE, tmp, - 12, NULL, 0, buf, buf, 16, tmp ) ); - - mbedtls_gcm_free( &gcm ); - } - } -#endif -#if defined(MBEDTLS_CCM_C) - if( todo.aes_ccm ) - { - int keysize; - mbedtls_ccm_context ccm; - - mbedtls_ccm_init( &ccm ); - for( keysize = 128; keysize <= 256; keysize += 64 ) - { - mbedtls_snprintf( title, sizeof( title ), "AES-CCM-%d", keysize ); - - memset( buf, 0, sizeof( buf ) ); - memset( tmp, 0, sizeof( tmp ) ); - mbedtls_ccm_setkey( &ccm, MBEDTLS_CIPHER_ID_AES, tmp, keysize ); - - TIME_AND_TSC( title, - mbedtls_ccm_encrypt_and_tag( &ccm, BUFSIZE, tmp, - 12, NULL, 0, buf, buf, tmp, 16 ) ); - - mbedtls_ccm_free( &ccm ); - } - } -#endif -#endif - -#if defined(MBEDTLS_CAMELLIA_C) && defined(MBEDTLS_CIPHER_MODE_CBC) - if( todo.camellia ) - { - int keysize; - mbedtls_camellia_context camellia; - mbedtls_camellia_init( &camellia ); - for( keysize = 128; keysize <= 256; keysize += 64 ) - { - mbedtls_snprintf( title, sizeof( title ), "CAMELLIA-CBC-%d", keysize ); - - memset( buf, 0, sizeof( buf ) ); - memset( tmp, 0, sizeof( tmp ) ); - mbedtls_camellia_setkey_enc( &camellia, tmp, keysize ); - - TIME_AND_TSC( title, - mbedtls_camellia_crypt_cbc( &camellia, MBEDTLS_CAMELLIA_ENCRYPT, - BUFSIZE, tmp, buf, buf ) ); - } - mbedtls_camellia_free( &camellia ); - } -#endif - -#if defined(MBEDTLS_BLOWFISH_C) && defined(MBEDTLS_CIPHER_MODE_CBC) - if( todo.blowfish ) - { - int keysize; - mbedtls_blowfish_context blowfish; - mbedtls_blowfish_init( &blowfish ); - - for( keysize = 128; keysize <= 256; keysize += 64 ) - { - mbedtls_snprintf( title, sizeof( title ), "BLOWFISH-CBC-%d", keysize ); - - memset( buf, 0, sizeof( buf ) ); - memset( tmp, 0, sizeof( tmp ) ); - mbedtls_blowfish_setkey( &blowfish, tmp, keysize ); - - TIME_AND_TSC( title, - mbedtls_blowfish_crypt_cbc( &blowfish, MBEDTLS_BLOWFISH_ENCRYPT, BUFSIZE, - tmp, buf, buf ) ); - } - - mbedtls_blowfish_free( &blowfish ); - } -#endif - -#if defined(MBEDTLS_HAVEGE_C) - if( todo.havege ) - { - mbedtls_havege_state hs; - mbedtls_havege_init( &hs ); - TIME_AND_TSC( "HAVEGE", mbedtls_havege_random( &hs, buf, BUFSIZE ) ); - mbedtls_havege_free( &hs ); - } -#endif - -#if defined(MBEDTLS_CTR_DRBG_C) - if( todo.ctr_drbg ) - { - mbedtls_ctr_drbg_context ctr_drbg; - - mbedtls_ctr_drbg_init( &ctr_drbg ); - - if( mbedtls_ctr_drbg_seed( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) - mbedtls_exit(1); - TIME_AND_TSC( "CTR_DRBG (NOPR)", - if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); - - if( mbedtls_ctr_drbg_seed( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 ) - mbedtls_exit(1); - mbedtls_ctr_drbg_set_prediction_resistance( &ctr_drbg, MBEDTLS_CTR_DRBG_PR_ON ); - TIME_AND_TSC( "CTR_DRBG (PR)", - if( mbedtls_ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); - mbedtls_ctr_drbg_free( &ctr_drbg ); - } -#endif - -#if defined(MBEDTLS_HMAC_DRBG_C) - if( todo.hmac_drbg ) - { - mbedtls_hmac_drbg_context hmac_drbg; - const mbedtls_md_info_t *md_info; - - mbedtls_hmac_drbg_init( &hmac_drbg ); - -#if defined(MBEDTLS_SHA1_C) - if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 ) ) == NULL ) - mbedtls_exit(1); - - if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) - mbedtls_exit(1); - TIME_AND_TSC( "HMAC_DRBG SHA-1 (NOPR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); - mbedtls_hmac_drbg_free( &hmac_drbg ); - - if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) - mbedtls_exit(1); - mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg, - MBEDTLS_HMAC_DRBG_PR_ON ); - TIME_AND_TSC( "HMAC_DRBG SHA-1 (PR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); - mbedtls_hmac_drbg_free( &hmac_drbg ); -#endif - -#if defined(MBEDTLS_SHA256_C) - if( ( md_info = mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ) ) == NULL ) - mbedtls_exit(1); - - if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) - mbedtls_exit(1); - TIME_AND_TSC( "HMAC_DRBG SHA-256 (NOPR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); - mbedtls_hmac_drbg_free( &hmac_drbg ); - - if( mbedtls_hmac_drbg_seed( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 ) - mbedtls_exit(1); - mbedtls_hmac_drbg_set_prediction_resistance( &hmac_drbg, - MBEDTLS_HMAC_DRBG_PR_ON ); - TIME_AND_TSC( "HMAC_DRBG SHA-256 (PR)", - if( mbedtls_hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 ) - mbedtls_exit(1) ); - mbedtls_hmac_drbg_free( &hmac_drbg ); -#endif - } -#endif - -#if defined(MBEDTLS_RSA_C) && \ - defined(MBEDTLS_PEM_PARSE_C) && defined(MBEDTLS_PK_PARSE_C) - if( todo.rsa ) - { - mbedtls_pk_context pk; - mbedtls_rsa_context *rsa; - const char *rsa_keys[] = { RSA_PRIVATE_KEY_2048, RSA_PRIVATE_KEY_4096 }; - size_t i; - - for( i = 0; i < sizeof( rsa_keys ) / sizeof( rsa_keys[0] ); i++ ) - { - mbedtls_pk_init( &pk ); - mbedtls_pk_parse_key( &pk, (const unsigned char *) rsa_keys[i], - strlen( rsa_keys[i] ) + 1, NULL, 0 ); - rsa = mbedtls_pk_rsa( pk ); - - mbedtls_snprintf( title, sizeof( title ), "RSA-%d", mbedtls_pk_get_bitlen( &pk ) ); - - TIME_PUBLIC( title, " public", - buf[0] = 0; - ret = mbedtls_rsa_public( rsa, buf, buf ) ); - - TIME_PUBLIC( title, "private", - buf[0] = 0; - ret = mbedtls_rsa_private( rsa, myrand, NULL, buf, buf ) ); - - mbedtls_pk_free( &pk ); - } - } -#endif - -#if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_BIGNUM_C) - if( todo.dhm ) - { - int dhm_sizes[] = { 2048, 3072 }; - const char *dhm_P[] = { - MBEDTLS_DHM_RFC3526_MODP_2048_P, - MBEDTLS_DHM_RFC3526_MODP_3072_P, - }; - const char *dhm_G[] = { - MBEDTLS_DHM_RFC3526_MODP_2048_G, - MBEDTLS_DHM_RFC3526_MODP_3072_G, - }; - - mbedtls_dhm_context dhm; - size_t olen; - for( i = 0; (size_t) i < sizeof( dhm_sizes ) / sizeof( dhm_sizes[0] ); i++ ) - { - mbedtls_dhm_init( &dhm ); - - if( mbedtls_mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 || - mbedtls_mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 ) - { - mbedtls_exit( 1 ); - } - - dhm.len = mbedtls_mpi_size( &dhm.P ); - mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, myrand, NULL ); - if( mbedtls_mpi_copy( &dhm.GY, &dhm.GX ) != 0 ) - mbedtls_exit( 1 ); - - mbedtls_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] ); - TIME_PUBLIC( title, "handshake", - ret |= mbedtls_dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, - myrand, NULL ); - ret |= mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &olen, myrand, NULL ) ); - - mbedtls_snprintf( title, sizeof( title ), "DH-%d", dhm_sizes[i] ); - TIME_PUBLIC( title, "handshake", - ret |= mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &olen, myrand, NULL ) ); - - mbedtls_dhm_free( &dhm ); - } - } -#endif - -#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_SHA256_C) - if( todo.ecdsa ) - { - mbedtls_ecdsa_context ecdsa; - const mbedtls_ecp_curve_info *curve_info; - size_t sig_len; - - memset( buf, 0x2A, sizeof( buf ) ); - - for( curve_info = mbedtls_ecp_curve_list(); - curve_info->grp_id != MBEDTLS_ECP_DP_NONE; - curve_info++ ) - { - mbedtls_ecdsa_init( &ecdsa ); - - if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 ) - mbedtls_exit( 1 ); - ecp_clear_precomputed( &ecdsa.grp ); - - mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s", - curve_info->name ); - TIME_PUBLIC( title, "sign", - ret = mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->bit_size, - tmp, &sig_len, myrand, NULL ) ); - - mbedtls_ecdsa_free( &ecdsa ); - } - - for( curve_info = mbedtls_ecp_curve_list(); - curve_info->grp_id != MBEDTLS_ECP_DP_NONE; - curve_info++ ) - { - mbedtls_ecdsa_init( &ecdsa ); - - if( mbedtls_ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 || - mbedtls_ecdsa_write_signature( &ecdsa, MBEDTLS_MD_SHA256, buf, curve_info->bit_size, - tmp, &sig_len, myrand, NULL ) != 0 ) - { - mbedtls_exit( 1 ); - } - ecp_clear_precomputed( &ecdsa.grp ); - - mbedtls_snprintf( title, sizeof( title ), "ECDSA-%s", - curve_info->name ); - TIME_PUBLIC( title, "verify", - ret = mbedtls_ecdsa_read_signature( &ecdsa, buf, curve_info->bit_size, - tmp, sig_len ) ); - - mbedtls_ecdsa_free( &ecdsa ); - } - } -#endif - -#if defined(MBEDTLS_ECDH_C) - if( todo.ecdh ) - { - mbedtls_ecdh_context ecdh; -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - mbedtls_mpi z; -#endif - const mbedtls_ecp_curve_info *curve_info; - size_t olen; - - for( curve_info = mbedtls_ecp_curve_list(); - curve_info->grp_id != MBEDTLS_ECP_DP_NONE; - curve_info++ ) - { - mbedtls_ecdh_init( &ecdh ); - - if( mbedtls_ecp_group_load( &ecdh.grp, curve_info->grp_id ) != 0 || - mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), - myrand, NULL ) != 0 || - mbedtls_ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 ) - { - mbedtls_exit( 1 ); - } - ecp_clear_precomputed( &ecdh.grp ); - - mbedtls_snprintf( title, sizeof( title ), "ECDHE-%s", - curve_info->name ); - TIME_PUBLIC( title, "handshake", - ret |= mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), - myrand, NULL ); - ret |= mbedtls_ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ), - myrand, NULL ) ); - mbedtls_ecdh_free( &ecdh ); - } - - /* Curve25519 needs to be handled separately */ -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - mbedtls_ecdh_init( &ecdh ); - mbedtls_mpi_init( &z ); - - if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || - mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, myrand, NULL ) != 0 ) - { - mbedtls_exit( 1 ); - } - - TIME_PUBLIC( "ECDHE-Curve25519", "handshake", - ret |= mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, - myrand, NULL ); - ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, - myrand, NULL ) ); - - mbedtls_ecdh_free( &ecdh ); - mbedtls_mpi_free( &z ); -#endif - - for( curve_info = mbedtls_ecp_curve_list(); - curve_info->grp_id != MBEDTLS_ECP_DP_NONE; - curve_info++ ) - { - mbedtls_ecdh_init( &ecdh ); - - if( mbedtls_ecp_group_load( &ecdh.grp, curve_info->grp_id ) != 0 || - mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), - myrand, NULL ) != 0 || - mbedtls_ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 || - mbedtls_ecdh_make_public( &ecdh, &olen, buf, sizeof( buf), - myrand, NULL ) != 0 ) - { - mbedtls_exit( 1 ); - } - ecp_clear_precomputed( &ecdh.grp ); - - mbedtls_snprintf( title, sizeof( title ), "ECDH-%s", - curve_info->name ); - TIME_PUBLIC( title, "handshake", - ret |= mbedtls_ecdh_calc_secret( &ecdh, &olen, buf, sizeof( buf ), - myrand, NULL ) ); - mbedtls_ecdh_free( &ecdh ); - } - - /* Curve25519 needs to be handled separately */ -#if defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) - mbedtls_ecdh_init( &ecdh ); - mbedtls_mpi_init( &z ); - - if( mbedtls_ecp_group_load( &ecdh.grp, MBEDTLS_ECP_DP_CURVE25519 ) != 0 || - mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Qp, - myrand, NULL ) != 0 || - mbedtls_ecdh_gen_public( &ecdh.grp, &ecdh.d, &ecdh.Q, myrand, NULL ) != 0 ) - { - mbedtls_exit( 1 ); - } - - TIME_PUBLIC( "ECDH-Curve25519", "handshake", - ret |= mbedtls_ecdh_compute_shared( &ecdh.grp, &z, &ecdh.Qp, &ecdh.d, - myrand, NULL ) ); - - mbedtls_ecdh_free( &ecdh ); - mbedtls_mpi_free( &z ); -#endif - } -#endif - - mbedtls_printf( "\r\n" ); - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - mbedtls_memory_buffer_alloc_free(); -#endif - -#if defined(_WIN32) - mbedtls_printf( " Press Enter to exit this program.\r\n" ); - fflush( stdout ); getchar(); -#endif - - return( 0 ); -} - -#include "mbed-drivers/test_env.h" -#include "minar/minar.h" - -static void run() { - MBED_HOSTTEST_TIMEOUT(150); - MBED_HOSTTEST_SELECT(default); - MBED_HOSTTEST_DESCRIPTION(mbed TLS benchmark program); - MBED_HOSTTEST_START("MBEDTLS_BENCHMARK"); - MBED_HOSTTEST_RESULT(benchmark(0, NULL) == 0); -} - -void app_start(int, char*[]) { - /* Use 115200 bps for consistency with other examples */ - get_stdio_serial().baud(115200); - minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); -} - -#endif /* TARGET_LIKE_MBED */ diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-hashing/README.md b/3rdparty/mbedtls/mbedtls/yotta/data/example-hashing/README.md deleted file mode 100644 index 1a5491cacc..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-hashing/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# SHA-256 Hash Example - -This application performs hashing of a buffer with SHA-256 using various APIs. It serves as a tutorial for the basic hashing APIs of mbed TLS. - -## Pre-requisites - -To build and run this example you must have: - -* A computer with the following software installed: - * [CMake](http://www.cmake.org/download/). - * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). - * [Python](https://www.python.org/downloads/). - * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). - * A serial terminal emulator (Like screen, pySerial and cu). -* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). -* A micro-USB cable. -* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). - -## Getting started - -1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. - -2. Navigate to the mbedtls directory supplied with your release and open a terminal. - -3. Set the yotta target: - - ``` - yotta target frdm-k64f-gcc - ``` - -4. Build mbedtls and the examples. This may take a long time if this is your first compilation: - - ``` - $ yotta build - ``` - -5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-hashing.bin` to your mbed board and wait until the LED next to the USB port stops blinking. - -6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. - - Use the following settings: - - * 115200 baud (not 9600). - * 8N1. - * No flow control. - -7. Press the Reset button on the board. - -8. The output in the terminal window should look like: - - ``` - {{timeout;10}} - {{host_test_name;default}} - {{description;mbed TLS example on hashing}} - {{test_id;MBEDTLS_EX_HASHING}} - {{start}} - - - Method 1: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 - Method 2: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 - Method 3: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 - Method 4: 315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3 - - DONE - {{success}} - {{end}} - ``` diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-hashing/main.cpp b/3rdparty/mbedtls/mbedtls/yotta/data/example-hashing/main.cpp deleted file mode 100644 index 574152ab83..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-hashing/main.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Hello world example of using the hashing functions of mbed TLS - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -/* - * This program illustrates various ways of hashing a buffer. - * You normally need only one of these two includes. - */ -#include "mbedtls/sha256.h" /* SHA-256 only */ -#include "mbedtls/md.h" /* generic interface */ - -#if defined(TARGET_LIKE_MBED) -#include "mbed-drivers/mbed.h" -#endif -#include - -static void print_hex(const char *title, const unsigned char buf[], size_t len) -{ - printf("%s: ", title); - - for (size_t i = 0; i < len; i++) - printf("%02x", buf[i]); - - printf("\r\n"); -} - -static const char hello_str[] = "Hello, world!"; -static const unsigned char *hello_buffer = (const unsigned char *) hello_str; -static const size_t hello_len = sizeof hello_str - 1; - -int example(void) -{ - printf( "\r\n\r\n" ); - - /* - * Method 1: use all-in-one function of a specific SHA-xxx module - */ - unsigned char output1[32]; /* SHA-256 outputs 32 bytes */ - - /* 0 here means use the full SHA-256, not the SHA-224 variant */ - mbedtls_sha256(hello_buffer, hello_len, output1, 0); - - print_hex("Method 1", output1, sizeof output1); - - - /* - * Method 2: use the streaming interface of a specific SHA-xxx module - * This is useful if we get our input piecewise. - */ - unsigned char output2[32]; - mbedtls_sha256_context ctx2; - - mbedtls_sha256_init(&ctx2); - mbedtls_sha256_starts(&ctx2, 0); /* SHA-256, not 224 */ - - /* Simulating multiple fragments */ - mbedtls_sha256_update(&ctx2, hello_buffer, 1); - mbedtls_sha256_update(&ctx2, hello_buffer + 1, 1); - mbedtls_sha256_update(&ctx2, hello_buffer + 2, hello_len - 2); - - mbedtls_sha256_finish(&ctx2, output2); - print_hex("Method 2", output2, sizeof output2); - - /* Or you could re-use the context by doing mbedtls_sha256_starts() again */ - mbedtls_sha256_free(&ctx2); - - /* - * Method 3: use all-in-one function of the generice interface - */ - unsigned char output3[MBEDTLS_MD_MAX_SIZE]; /* Enough for any hash */ - - /* Can easily pick any hash you want, by identifier */ - const mbedtls_md_info_t *md_info3 = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); - - if (md_info3 == NULL) - { - printf("SHA256 not available\r\n"); - return 1; - } - - int ret3 = mbedtls_md(md_info3, hello_buffer, hello_len, output3); - - if (ret3 != 0) - { - printf("md() returned -0x%04X\r\n", -ret3); - return 1; - } - - print_hex("Method 3", output3, mbedtls_md_get_size(md_info3)); - - - /* - * Method 4: streaming & generic interface - */ - unsigned char output4[MBEDTLS_MD_MAX_SIZE]; /* Enough for any hash */ - - const mbedtls_md_info_t *md_info4 = mbedtls_md_info_from_type(MBEDTLS_MD_SHA256); - - if (md_info4 == NULL) - { - printf("SHA256 not available\r\n"); - return 1; - } - - mbedtls_md_context_t ctx4; - - mbedtls_md_init(&ctx4); - - int ret4 = mbedtls_md_init_ctx(&ctx4, md_info4); - if (ret4 != 0) - { - printf("md_init_ctx() returned -0x%04X\r\n", -ret4); - return 1; - } - - mbedtls_md_starts(&ctx4); - - /* Simulating multiple fragments */ - mbedtls_md_update(&ctx4, hello_buffer, 1); - mbedtls_md_update(&ctx4, hello_buffer + 1, 1); - mbedtls_md_update(&ctx4, hello_buffer + 2, hello_len - 2); - - mbedtls_md_finish(&ctx4, output4); - print_hex("Method 4", output4, mbedtls_md_get_size(md_info4)); - - /* Or you could re-use the context by doing mbedtls_md_starts() again */ - mbedtls_md_free(&ctx4); - - - printf("\r\nDONE\r\n"); - - return 0; -} - -#if defined(TARGET_LIKE_MBED) - -#include "mbed-drivers/test_env.h" -#include "minar/minar.h" - -static void run() { - MBED_HOSTTEST_TIMEOUT(10); - MBED_HOSTTEST_SELECT(default); - MBED_HOSTTEST_DESCRIPTION(mbed TLS example on hashing); - MBED_HOSTTEST_START("MBEDTLS_EX_HASHING"); - MBED_HOSTTEST_RESULT(example() == 0); -} - -void app_start(int, char*[]) { - /* Use 115200 bps for consistency with other examples */ - get_stdio_serial().baud(115200); - minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); -} - -#else - -int main() { - return example(); -} - -#endif diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-selftest/README.md b/3rdparty/mbedtls/mbedtls/yotta/data/example-selftest/README.md deleted file mode 100644 index 0daf8200af..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-selftest/README.md +++ /dev/null @@ -1,82 +0,0 @@ -# mbed TLS Selftest Example - -This application runs the various selftest functions of individual mbed TLS components. It serves as a basic sanity check to verify operation of mbed TLS on your platform. In the future, a wider portion of the mbed TLS test suite will become part of this example application. - -## Pre-requisites - -To build and run this example you must have: - -* A computer with the following software installed: - * [CMake](http://www.cmake.org/download/). - * [yotta](https://github.com/ARMmbed/yotta). Please note that **yotta has its own set of dependencies**, listed in the [installation instructions](http://armmbed.github.io/yotta/#installing-on-windows). - * [Python](https://www.python.org/downloads/). - * [The ARM GCC toolchain](https://launchpad.net/gcc-arm-embedded). - * A serial terminal emulator (Like screen, pySerial and cu). -* An [FRDM-K64F](http://developer.mbed.org/platforms/FRDM-K64F/) development board, or another board supported by mbed OS (in which case you'll have to substitute frdm-k64f-gcc with the appropriate target in the instructions below). -* A micro-USB cable. -* If your OS is Windows, please follow the installation instructions [for the serial port driver](https://developer.mbed.org/handbook/Windows-serial-configuration). - -## Getting started - -1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the "OpenSDA" connector on the target board. - -2. Navigate to the mbedtls directory supplied with your release and open a terminal. - -3. Set the yotta target: - - ``` - yotta target frdm-k64f-gcc - ``` - -4. Build mbedtls and the examples. This may take a long time if this is your first compilation: - - ``` - $ yotta build - ``` - -5. Copy `build/frdm-k64f-gcc/test/mbedtls-test-example-selftest.bin` to your mbed board and wait until the LED next to the USB port stops blinking. - -6. Start the serial terminal emulator and connect to the virtual serial port presented by FRDM-K64F. - - Use the following settings: - - * 115200 baud (not 9600). - * 8N1. - * No flow control. - -7. Press the Reset button on the board. - -8. The output in the terminal window should look like: - - ``` - {{timeout;40}} - {{host_test_name;default}} - {{description;mbed TLS selftest program}} - {{test_id;MBEDTLS_SELFTEST}} - {{start}} - - SHA-224 test #1: passed - SHA-224 test #2: passed - SHA-224 test #3: passed - SHA-256 test #1: passed - SHA-256 test #2: passed - SHA-256 test #3: passed - - [ ... several lines omitted ... ] - - CTR_DRBG (PR = TRUE) : passed - CTR_DRBG (PR = FALSE): passed - - HMAC_DRBG (PR = True) : passed - HMAC_DRBG (PR = False) : passed - - ECP test #1 (constant op_count, base point G): passed - ECP test #2 (constant op_count, other point): passed - - ENTROPY test: passed - - [ All tests passed ] - - {{success}} - {{end}} - ``` diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/example-selftest/main.cpp b/3rdparty/mbedtls/mbedtls/yotta/data/example-selftest/main.cpp deleted file mode 100644 index 0ff5b048ec..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/example-selftest/main.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Self-test demonstration program - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#if !defined(POLARSSL_CONFIG_FILE) -#include "mbedtls/config.h" -#else -#include MBEDTLS_CONFIG_FILE -#endif - -#include "mbedtls/entropy.h" -#include "mbedtls/hmac_drbg.h" -#include "mbedtls/ctr_drbg.h" -#include "mbedtls/dhm.h" -#include "mbedtls/gcm.h" -#include "mbedtls/ccm.h" -#include "mbedtls/md2.h" -#include "mbedtls/md4.h" -#include "mbedtls/md5.h" -#include "mbedtls/ripemd160.h" -#include "mbedtls/sha1.h" -#include "mbedtls/sha256.h" -#include "mbedtls/sha512.h" -#include "mbedtls/arc4.h" -#include "mbedtls/des.h" -#include "mbedtls/aes.h" -#include "mbedtls/camellia.h" -#include "mbedtls/base64.h" -#include "mbedtls/bignum.h" -#include "mbedtls/rsa.h" -#include "mbedtls/x509.h" -#include "mbedtls/xtea.h" -#include "mbedtls/pkcs5.h" -#include "mbedtls/ecp.h" - -#include -#include - -#if defined(MBEDTLS_PLATFORM_C) -#include "mbedtls/platform.h" -#else -#include -#define mbedtls_printf printf -#endif - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) -#include "mbedtls/memory_buffer_alloc.h" -#endif - -int selftest( int argc, char *argv[] ) -{ - int ret = 0, v; -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - unsigned char buf[1000000]; -#endif - - if( argc == 2 && strcmp( argv[1], "-quiet" ) == 0 ) - v = 0; - else - { - v = 1; - mbedtls_printf( "\n" ); - } - -#if defined(MBEDTLS_SELF_TEST) - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - mbedtls_memory_buffer_alloc_init( buf, sizeof(buf) ); -#endif - -#if defined(MBEDTLS_MD2_C) - if( ( ret = mbedtls_md2_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_MD4_C) - if( ( ret = mbedtls_md4_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_MD5_C) - if( ( ret = mbedtls_md5_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_RIPEMD160_C) - if( ( ret = mbedtls_ripemd160_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_SHA1_C) - if( ( ret = mbedtls_sha1_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_SHA256_C) - if( ( ret = mbedtls_sha256_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_SHA512_C) - if( ( ret = mbedtls_sha512_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_ARC4_C) - if( ( ret = mbedtls_arc4_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_DES_C) - if( ( ret = mbedtls_des_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_AES_C) - if( ( ret = mbedtls_aes_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_GCM_C) && defined(MBEDTLS_AES_C) - if( ( ret = mbedtls_gcm_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_CCM_C) && defined(MBEDTLS_AES_C) - if( ( ret = mbedtls_ccm_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_BASE64_C) - if( ( ret = mbedtls_base64_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_BIGNUM_C) - if( ( ret = mbedtls_mpi_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_RSA_C) - if( ( ret = mbedtls_rsa_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_X509_USE_C) - if( ( ret = mbedtls_x509_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_XTEA_C) - if( ( ret = mbedtls_xtea_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_CAMELLIA_C) - if( ( ret = mbedtls_camellia_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_CTR_DRBG_C) - if( ( ret = mbedtls_ctr_drbg_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_HMAC_DRBG_C) - if( ( ret = mbedtls_hmac_drbg_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_ECP_C) - if( ( ret = mbedtls_ecp_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_DHM_C) - if( ( ret = mbedtls_dhm_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_ENTROPY_C) - if( ( ret = mbedtls_entropy_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_PKCS5_C) - if( ( ret = mbedtls_pkcs5_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#if defined(MBEDTLS_TIMING_C) - if( ( ret = mbedtls_timing_self_test( v ) ) != 0 ) - return( ret ); -#endif - -#else - mbedtls_printf( " POLARSSL_SELF_TEST not defined.\n" ); -#endif - - if( v != 0 ) - { -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && defined(MBEDTLS_MEMORY_DEBUG) - mbedtls_memory_buffer_alloc_status(); -#endif - } - -#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) - mbedtls_memory_buffer_alloc_free(); - - if( ( ret = mbedtls_memory_buffer_alloc_self_test( v ) ) != 0 ) - return( ret ); -#endif - - if( v != 0 ) - { - mbedtls_printf( " [ All tests passed ]\n\n" ); -#if defined(_WIN32) - mbedtls_printf( " Press Enter to exit this program.\n" ); - fflush( stdout ); getchar(); -#endif - } - - return( ret ); -} - -#if defined(TARGET_LIKE_MBED) - -#include "mbed-drivers/test_env.h" -#include "minar/minar.h" - -static void run() { - MBED_HOSTTEST_TIMEOUT(40); - MBED_HOSTTEST_SELECT(default); - MBED_HOSTTEST_DESCRIPTION(mbed TLS selftest program); - MBED_HOSTTEST_START("MBEDTLS_SELFTEST"); - MBED_HOSTTEST_RESULT(selftest(0, NULL) == 0); -} - -void app_start(int, char*[]) { - /* Use 115200 bps for consistency with other examples */ - get_stdio_serial().baud(115200); - minar::Scheduler::postCallback(mbed::util::FunctionPointer0(run).bind()); -} - -#else - -int main() { - return selftest(0, NULL); -} - -#endif diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/module.json b/3rdparty/mbedtls/mbedtls/yotta/data/module.json deleted file mode 100644 index 0b8b822832..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/module.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "mbedtls", - "version": "2.3.1", - "description": "The mbed TLS crypto/SSL/TLS library", - "licenses": [ - { - "url": "https://spdx.org/licenses/Apache-2.0", - "type": "Apache-2.0" - } - ], - "dependencies": {}, - "targetDependencies": { - "mbed": { "cmsis-core": "^1.0.0" } - }, - "testTargetDependencies": { - "mbed": { "mbed-drivers": "^1.0.0" } - } -} diff --git a/3rdparty/mbedtls/mbedtls/yotta/data/target_config.h b/3rdparty/mbedtls/mbedtls/yotta/data/target_config.h deleted file mode 100644 index f350ce3ecb..0000000000 --- a/3rdparty/mbedtls/mbedtls/yotta/data/target_config.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Temporary target-specific config.h for entropy collection - * - * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This file is part of mbed TLS (https://tls.mbed.org) - */ - -#if defined(TARGET_LIKE_MBED) -#define MBEDTLS_NO_PLATFORM_ENTROPY -#undef MBEDTLS_HAVE_TIME_DATE -#undef MBEDTLS_FS_IO -#endif - -/* - * WARNING: this is temporary! - * This should be in a separate yotta module which would be a target - * dependency of mbedtls (see IOTSSL-313) - */ -#if defined(TARGET_LIKE_K64F) -#define MBEDTLS_ENTROPY_HARDWARE_ALT -#endif diff --git a/3rdparty/mbedtls/mbedtls_hardware_poll.c b/3rdparty/mbedtls/mbedtls_hardware_poll.c index d8dcb18c6b..6bd09da546 100644 --- a/3rdparty/mbedtls/mbedtls_hardware_poll.c +++ b/3rdparty/mbedtls/mbedtls_hardware_poll.c @@ -1,11 +1,92 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include +#include +#include "mbedtls/include/mbedtls/platform.h" +#include "mbedtls/include/mbedtls/sha512.h" + +/* Per https://software.intel.com/en-us/articles/intel-digital-random-number + * -generator-drng-software-implementation-guide, reading 512 x 128-bit values + * causes RDRAND to reseed */ +#define RDRAND_RESEED_SIZE_BYTES 8192 + +#define SHA512_HASH_LENGTH_BYTES 64 int mbedtls_hardware_poll(void*, unsigned char*, size_t, size_t*); +static void _fill_buffer( + uint8_t* source, + size_t source_size, + uint8_t** target, + size_t* target_size) +{ + size_t copy_size = + (*target_size > source_size) ? source_size : *target_size; + memcpy(*target, source, copy_size); + *target += copy_size; + *target_size -= copy_size; +} + +static int _get_seed_from_rdrand(uint8_t** seed, size_t* seed_size) +{ + int ret = -1; + uint8_t* rdrand_seed = NULL; + uint8_t* rdrand_bytes = NULL; + oe_entropy_kind_t kind = OE_ENTROPY_KIND_NONE; + + /* Per Intel's DRNG software implementation guide we try to obtain an + * equivalent amount of entropy by condensing several reseed windows of + * RDRAND into a single value. + * + * The DRBG that underlies RDRAND is limited to 128-bit security, so the + * seed for each consecutive RDRAND_RESEED_SIZE_BYTES of data can be + * recovered with 2^128 rounds of work. In general, to achieve N*128 bits + * of security, we need a buffer of (N+1)*RDRAND_RESEED_SIZE_BYTES bytes. + * To get to 256-bit security, similar to RDSEED for 32-bytes, we use N=3. + * + * Note that we hash this down to a 512-bit (64-byte) value via SHA-512 to + * avoid loss of entropy that would otherwise occur in hash collisions when + * mapping 256-bits of unique values into a 256-bit hash space. + */ + size_t rdrand_bytes_size = RDRAND_RESEED_SIZE_BYTES * 3; + rdrand_bytes = (uint8_t*)mbedtls_calloc(1, rdrand_bytes_size); + if (!rdrand_bytes) + goto done; + + if (oe_get_entropy(rdrand_bytes, rdrand_bytes_size, &kind) != OE_OK || + kind != OE_ENTROPY_KIND_RDRAND) + goto done; + + /* Hash the bytes down to a single 64-byte seed value */ + rdrand_seed = (uint8_t*)mbedtls_calloc(1, SHA512_HASH_LENGTH_BYTES); + if (!rdrand_seed) + goto done; + + if (mbedtls_sha512_ret(rdrand_bytes, rdrand_bytes_size, rdrand_seed, 0) != + 0) + goto done; + + *seed_size = SHA512_HASH_LENGTH_BYTES; + *seed = rdrand_seed; + rdrand_seed = NULL; + ret = 0; + +done: + if (rdrand_bytes) + { + mbedtls_free(rdrand_bytes); + rdrand_bytes = NULL; + } + if (rdrand_seed) + { + mbedtls_free(rdrand_seed); + rdrand_seed = NULL; + } + return ret; +} + /* * MBEDTLS links this function definition when MBEDTLS_ENTROPY_HARDWARE_ALT * is defined in the MBEDTLS config.h file. This is the sole source of entropy @@ -19,13 +100,48 @@ int mbedtls_hardware_poll( size_t* olen) { int ret = -1; + oe_entropy_kind_t kind = OE_ENTROPY_KIND_NONE; OE_UNUSED(data); if (olen) *olen = 0; - if (oe_get_entropy(output, len) != OE_OK) + if (oe_get_entropy(output, len, &kind) != OE_OK) + goto done; + + if (kind == OE_ENTROPY_KIND_RDSEED || kind == OE_ENTROPY_KIND_OPTEE) + { + /* According to Intel's DRNG software implementation guide, RDSEED + * produces values that are already passed through a conditioner that + * hashes pairs of 256-bit raw entropy samples via AES-CBC-MAC, so no + * further work needs to be done. + * + * For OPTEE TEE_GenerateRandom, the actual predictive resistance of + * underlying implementation may vary, so this simply takes the value + * provided as is. */ + } + else if (kind == OE_ENTROPY_KIND_RDRAND) + { + /* If RDSEED is not supported, fallback to using RDRAND to obtain a + * seed for entropy. */ + unsigned char* p = (unsigned char*)output; + size_t bytes_left = len; + while (bytes_left > 0) + { + uint8_t* seed_bytes = NULL; + size_t seed_size = 0; + + if (_get_seed_from_rdrand(&seed_bytes, &seed_size) != OE_OK) + goto done; + + _fill_buffer(seed_bytes, seed_size, &p, &bytes_left); + mbedtls_free(seed_bytes); + } + } + else + { goto done; + } if (olen) *olen = len; diff --git a/3rdparty/mbedtls/toolchain-clangw.cmake b/3rdparty/mbedtls/toolchain-clangw.cmake index fb12c66b94..dff9b99b63 100644 --- a/3rdparty/mbedtls/toolchain-clangw.cmake +++ b/3rdparty/mbedtls/toolchain-clangw.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Toolchain file used for cross-compiling using clang. diff --git a/3rdparty/mbedtls/update.make b/3rdparty/mbedtls/update.make index bdd96f6892..205c5b7892 100755 --- a/3rdparty/mbedtls/update.make +++ b/3rdparty/mbedtls/update.make @@ -1,10 +1,10 @@ #!/usr/bin/make -f -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # mbedTLS library definitions -VERSION=2.7.9 +VERSION=2.16.2 BASE=mbedtls-$(VERSION) PKG=$(BASE)-apache.tgz @@ -18,7 +18,6 @@ update-mbedtls: mv $(BASE) mbedtls rm -rf $(PKG) rm mbedtls/.gitignore - rm mbedtls/yotta/.gitignore rm mbedtls/programs/.gitignore rm mbedtls/include/.gitignore rm mbedtls/library/.gitignore diff --git a/3rdparty/musl/CMakeLists.txt b/3rdparty/musl/CMakeLists.txt index 9186035ed0..1db5e467a3 100644 --- a/3rdparty/musl/CMakeLists.txt +++ b/3rdparty/musl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Copy MUSL headers to collector dir and wrap @@ -55,9 +55,12 @@ ExternalProject_Add(musl_includes COMMAND ${CMAKE_COMMAND} -E copy ${PATCHES_DIR}/pthread_${ARCH}.h ${MUSL_DIR}/arch/${ARCH}/pthread_arch.h + COMMAND ${CMAKE_COMMAND} -E copy + ${PATCHES_DIR}/setjmp.h + ${MUSL_DIR}/include/setjmp.h CONFIGURE_COMMAND ${CMAKE_COMMAND} -E chdir ${MUSL_DIR} - ${BASH} -x ./configure + ${OE_BASH} -x ./configure --includedir=${MUSL_INCLUDES} CFLAGS=${MUSL_CFLAGS} CC=${MUSL_CC} @@ -73,12 +76,12 @@ ExternalProject_Add(musl_includes ${MUSL_DIR}/arch/${ARCH}/bits ${MUSL_INCLUDES}/bits # bash -c requires the command string to be in a single line - COMMAND ${BASH} -c "sed -f ${MUSL_DIR}/tools/mkalltypes.sed ${MUSL_DIR}/arch/${ARCH}/bits/alltypes.h.in ${MUSL_DIR}/include/alltypes.h.in > ${MUSL_INCLUDES}/bits/alltypes.h" + COMMAND ${OE_BASH} -c "sed -f ${MUSL_DIR}/tools/mkalltypes.sed ${MUSL_DIR}/arch/${ARCH}/bits/alltypes.h.in ${MUSL_DIR}/include/alltypes.h.in > ${MUSL_INCLUDES}/bits/alltypes.h" COMMAND ${CMAKE_COMMAND} -E copy ${MUSL_DIR}/arch/${ARCH}/bits/syscall.h.in ${MUSL_INCLUDES}/bits/syscall.h # bash -c requires the command string to be in a single line - COMMAND ${BASH} -c "sed -n -e s/__NR_/SYS_/p < ${MUSL_DIR}/arch/${ARCH}/bits/syscall.h.in >> ${MUSL_INCLUDES}/bits/syscall.h" + COMMAND ${OE_BASH} -c "sed -n -e s/__NR_/SYS_/p < ${MUSL_DIR}/arch/${ARCH}/bits/syscall.h.in >> ${MUSL_INCLUDES}/bits/syscall.h" COMMAND ${CMAKE_COMMAND} -E copy ${MUSL_INCLUDES}/endian.h ${MUSL_INCLUDES}/__endian.h @@ -86,7 +89,7 @@ ExternalProject_Add(musl_includes ${PATCHES_DIR}/endian.h ${MUSL_INCLUDES}/endian.h # Append deprecations.h to all C header files. - COMMAND ${BASH} -c "${MUSL_APPEND_DEPRECATIONS}" + COMMAND ${OE_BASH} -c "${MUSL_APPEND_DEPRECATIONS}" # Copy local deprecations.h to include/bits/deprecated.h. COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/deprecations.h @@ -95,6 +98,11 @@ ExternalProject_Add(musl_includes ${MUSL_INCLUDES} ${MUSL_DIR} INSTALL_COMMAND "") +set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + ${MUSL_INCLUDES} + ${MUSL_DIR} +) + add_library(oelibc_includes INTERFACE) add_dependencies(oelibc_includes musl_includes) diff --git a/3rdparty/musl/append-deprecations b/3rdparty/musl/append-deprecations index 2d25837581..f9ecf62b64 100755 --- a/3rdparty/musl/append-deprecations +++ b/3rdparty/musl/append-deprecations @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== diff --git a/3rdparty/musl/deprecations.h b/3rdparty/musl/deprecations.h index 4c471901c7..c684479654 100644 --- a/3rdparty/musl/deprecations.h +++ b/3rdparty/musl/deprecations.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_LIBC_DEPRECATIONS_H @@ -13,7 +13,9 @@ #include #if defined(__cplusplus) -#define OE_LIBC_EXTERN_C_BEGIN extern "C" { +#define OE_LIBC_EXTERN_C_BEGIN \ + extern "C" \ + { #define OE_LIBC_EXTERN_C_END } #else #define OE_LIBC_EXTERN_C_BEGIN @@ -44,10 +46,10 @@ OE_LIBC_EXTERN_C_BEGIN OE_LIBC_DEPRECATED(OE_UNSUPPORTED_ENCLAVE_FUNCTION) int pthread_create( - pthread_t *thread, - const pthread_attr_t *attr, - void *(*start_routine) (void *), - void *arg); + pthread_t* thread, + const pthread_attr_t* attr, + void* (*start_routine)(void*), + void* arg); OE_LIBC_DEPRECATED(OE_UNSUPPORTED_ENCLAVE_FUNCTION) int pthread_join(pthread_t thread, void** retval); @@ -55,34 +57,9 @@ int pthread_join(pthread_t thread, void** retval); OE_LIBC_DEPRECATED(OE_UNSUPPORTED_ENCLAVE_FUNCTION) int pthread_detach(pthread_t thread); -/* -**============================================================================== -** -** -** -**============================================================================== -*/ - -// Need this since including will create a circular dependency. -struct tm; - -OE_LIBC_DEPRECATED(OE_UNSUPPORTED_ENCLAVE_FUNCTION) -size_t strftime( - char* s, - size_t maxparam, - const char* format, - const struct tm* tm); - -OE_LIBC_DEPRECATED(OE_UNSUPPORTED_ENCLAVE_FUNCTION) -size_t strftime_l( - char* s, - size_t maxparam, - const char* format, - const struct tm* tm, - locale_t loc); - OE_LIBC_EXTERN_C_END -#endif /* !defined(OE_LIBC_SUPPRESS_DEPRECATIONS) && !defined(__ASSEMBLER__) */ +#endif /* !defined(OE_LIBC_SUPPRESS_DEPRECATIONS) && !defined(__ASSEMBLER__) \ + */ #endif /* _OE_LIBC_DEPRECATIONS_H */ diff --git a/3rdparty/musl/patches/endian.h b/3rdparty/musl/patches/endian.h index 851efac10b..e1b90382f5 100644 --- a/3rdparty/musl/patches/endian.h +++ b/3rdparty/musl/patches/endian.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_MUSL_PATCHES_ENDIAN_H diff --git a/3rdparty/musl/patches/pthread_aarch64.h b/3rdparty/musl/patches/pthread_aarch64.h index c2ae14c573..10e4031d68 100644 --- a/3rdparty/musl/patches/pthread_aarch64.h +++ b/3rdparty/musl/patches/pthread_aarch64.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_MUSL_PATCHES_PTHREAD_H diff --git a/3rdparty/musl/patches/pthread_x86_64.h b/3rdparty/musl/patches/pthread_x86_64.h index a2b6b26a66..3b9b3ad001 100644 --- a/3rdparty/musl/patches/pthread_x86_64.h +++ b/3rdparty/musl/patches/pthread_x86_64.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_MUSL_PATCHES_PTHREAD_H diff --git a/3rdparty/musl/patches/setjmp.h b/3rdparty/musl/patches/setjmp.h new file mode 100644 index 0000000000..838ce52150 --- /dev/null +++ b/3rdparty/musl/patches/setjmp.h @@ -0,0 +1,44 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _SETJMP_H +#define _SETJMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +typedef struct __jmp_buf_tag { + __jmp_buf __jb; + unsigned long __fl; + unsigned long __ss[128/sizeof(long)]; +} jmp_buf[1]; + +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +typedef jmp_buf sigjmp_buf; +int sigsetjmp (sigjmp_buf, int) __attribute__((returns_twice)); +_Noreturn void siglongjmp (sigjmp_buf, int); +#endif + +#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +int _setjmp (jmp_buf) __attribute__((returns_twice)); +_Noreturn void _longjmp (jmp_buf, int); +#endif + +int setjmp (jmp_buf) __attribute__((returns_twice)); +_Noreturn void longjmp (jmp_buf, int); + +#define setjmp setjmp + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/3rdparty/musl/patches/syscall_arch.h b/3rdparty/musl/patches/syscall_arch.h index 6744b89fc7..9fc1e28eba 100644 --- a/3rdparty/musl/patches/syscall_arch.h +++ b/3rdparty/musl/patches/syscall_arch.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_MUSL_PATCHES_SYSCALL_ARCH_H diff --git a/3rdparty/musl/update.make b/3rdparty/musl/update.make index b7f9b69040..47e9d90a74 100755 --- a/3rdparty/musl/update.make +++ b/3rdparty/musl/update.make @@ -1,6 +1,6 @@ #!/usr/bin/make -f -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # MUSL C library definitions diff --git a/3rdparty/optee/libutee/CMakeLists.txt b/3rdparty/optee/libutee/CMakeLists.txt index f244dbdfcc..7f599c1bb9 100644 --- a/3rdparty/optee/libutee/CMakeLists.txt +++ b/3rdparty/optee/libutee/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oeuteeasm @@ -94,7 +94,8 @@ add_library(oelibutee INTERFACE) target_link_libraries(oelibutee INTERFACE oeutee - oelibutee_includes) + oelibutee_includes + --undefined=TEE_GenerateRandom) install(TARGETS oelibutee oelibutee_includes EXPORT openenclave-targets) diff --git a/3rdparty/optee/libutee/compiler.h b/3rdparty/optee/libutee/compiler.h index 91e47e15ba..10cf1e70cb 100644 --- a/3rdparty/optee/libutee/compiler.h +++ b/3rdparty/optee/libutee/compiler.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef COMPILER_H diff --git a/3rdparty/optee/libutee/entry.c b/3rdparty/optee/libutee/entry.c index 380b067936..4f00fa54ee 100644 --- a/3rdparty/optee/libutee/entry.c +++ b/3rdparty/optee/libutee/entry.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/CHANGELOG.md b/CHANGELOG.md index 99abbf50e9..6cc9f8123a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Transferred repository from [microsoft/openenclave](https://github.com/microsoft/openenclave) to [openenclave/openenclave](https://github.com/openenclave/openenclave). -- Change debugging contract for oegdb. Enclaves and hosts built prior to this release cannot be debugged with this version of oegdb and vice versa. +- Open Enclave SDK is now officially an incubation project as part of the Linux + Foundation's Confidential Computing Consortium (CCC). + - All contributions are now accepted under the terms of the [Developer Certificate + of Origin](https://developercertificate.org). For details, see + [Contributing to Open Enclave](docs/Contributing.md). + - The copyright for all sources is now attributed to Open Enclave SDK contributors. +- Update Intel DCAP library dependencies to 1.3.1. +- Update Intel PSW dependencies to 2.5.101.3 on Windows. +- The stack guard for OE SDK on SGX is turned on. It is also turned on for enclaves. + +[v0.7.0] - 2019-10-26 +--------------------- + +### Added + +- Support Intel DCAP attestation on Windows. +- Support `transition_using_threads` EDL attribute in oeedger8r. + - This only applies to untrusted functions (ocalls) in this release. + - Using this attribute allows the ocall to be invoked without incurring the + performance cost of an enclave context switch. +- Ability to debug ELF enclaves on Windows using Windbg/CDB + - [Visual Studio Code CDB Extension](https://aka.ms/CDBVSCode) + - [WinDbg Preview](https://aka.ms/WinDbgPreview) + - The new oedebugrt.dll binary needs to be copied to the app folder to enable this. +- Preview support for 64-bit ARM TrustZone-capable boards with OP-TEE OS + - See the [documentation](docs/GettingStartedDocs/OP-TEE/Introduction.md) + for the list of supported platforms, features, and known issues. + +### Changed + +- Transferred repository from [microsoft/openenclave](https://github.com/microsoft/openenclave) + to [openenclave/openenclave](https://github.com/openenclave/openenclave). +- Change debugging contract for oegdb. Enclaves and hosts built prior to this + release cannot be debugged with this version of oegdb and vice versa. +- Update Intel DCAP library dependencies to 1.3. +- Update Intel PSW dependencies to 2.7 on Linux and 2.5 on Windows. +- SGX1 configurations always take build dependency on Intel SGX enclave common library. - Update LLVM libcxx to version 8.0.0. +- Update mbedTLS to version 2.16.2. + +### Deprecated + +- The mbedTLS libraries used in Open Enclave will no longer be compiled with the + following config.h options in the next (v0.8) release: + - `MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE`: Considerable advances + have been made in breaking SHA1 since our original review and we would + like to be more prescriptive in recommending the use of SHA256. + - `MBEDTLS_KEY_EXCHANGE_RSA_ENABLED`: This option provides no perfect + forward secrecy and is generally becoming less popular as this is + recognized. The ECDHE variants are also more performant. + +### Security + +- Fix enclave heap memory disclosure (CVE-2019-1369). [v0.6.0] - 2019-06-29 --------------------- @@ -35,6 +86,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 should enable it themselves after assessing its startup impact. - Removed support for the previously deprecated `OE_API_VERSION=1` APIs. - Update MUSL libc to version 1.1.21. +- Update mbedTLS to version 2.7.11. [v0.5.0] - 2019-04-09 --------------------- @@ -107,6 +159,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Check support for AVX in platform/OS before setting SECS.ATTRIBUTES.XFRM in enclave. + +### Security + - Fix CVE-2019-0876 - `_handle_sgx_get_report` will now write to the supplied argument if it lies in host memory. - Added check for missing null terminator in oeedger8r generated code. @@ -193,8 +248,10 @@ as listed below. Initial private preview release, no longer supported. -[Unreleased]: https://github.com/openenclave/openenclave/compare/v0.5.0...HEAD -[v0.5.0]: https://github.com/openenclave/openenclave/compare/v0.4.1...v0.5.0 -[v0.4.1]: https://github.com/openenclave/openenclave/compare/v0.4.0...v0.4.1 -[v0.4.0]: https://github.com/openenclave/openenclave/compare/v0.1.0...v0.4.0 -[v0.1.0]: https://github.com/openenclave/openenclave/compare/beb546f...v0.1.0 +[Unreleased](https://github.com/openenclave/openenclave/compare/v0.7.0...HEAD) +[v0.7.0](https://github.com/openenclave/openenclave/compare/v0.6.0...v0.7.0) +[v0.6.0](https://github.com/openenclave/openenclave/compare/v0.5.0...v0.6.0) +[v0.5.0](https://github.com/openenclave/openenclave/compare/v0.4.1...v0.5.0) +[v0.4.1](https://github.com/openenclave/openenclave/compare/v0.4.0...v0.4.1) +[v0.4.0](https://github.com/openenclave/openenclave/compare/v0.1.0...v0.4.0) +[v0.1.0](https://github.com/openenclave/openenclave/compare/beb546f...v0.1.0) diff --git a/CMakeGraphVizOptions.cmake b/CMakeGraphVizOptions.cmake index 733d25c113..3ce43c1b21 100644 --- a/CMakeGraphVizOptions.cmake +++ b/CMakeGraphVizOptions.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # List of regular expressions matching targets to be excluded from the diff --git a/CMakeLists.txt b/CMakeLists.txt index 7413787987..8f3a04aa37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # Top-level CMake file for the Open Enclave SDK @@ -25,8 +25,10 @@ endif () set(CMAKE_C_COMPILER_NAMES clang-7 cc) set(CMAKE_CXX_COMPILER_NAMES clang++-7 c++) -project("Open Enclave SDK" LANGUAGES C CXX ${OE_ASM}) +project("Open Enclave SDK" LANGUAGES C CXX ${OE_ASM} + HOMEPAGE_URL "https://github.com/openenclave/openenclave") set(PROJECT_VERSION ${OE_VERSION}) +set(OE_SCRIPTSDIR "${PROJECT_SOURCE_DIR}/scripts") list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -49,7 +51,7 @@ if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git") # Install Git pre-commit hook if (NOT WIN32) file( - COPY scripts/pre-commit + COPY scripts/pre-commit scripts/commit-msg DESTINATION "${PROJECT_SOURCE_DIR}/.git/hooks") endif () endif () @@ -132,16 +134,19 @@ if (WIN32) # explicitly searching only for Git Bash. See #1302 for more. find_program(GIT git) get_filename_component(GIT_DIR ${GIT} DIRECTORY) - find_program(BASH bash + find_program(OE_BASH bash PATHS "C:/Program Files/Git/bin" "${GIT_DIR}/../bin" NO_DEFAULT_PATH) # Do not find WSL bash. - if (NOT BASH) + if (NOT OE_BASH) message(FATAL_ERROR "Git Bash not found!") endif () + if (NOT NUGET_PACKAGE_PATH) + message(FATAL_ERROR "NUGET_PACKAGE_PATH not defined. Please define NUGET_PACKAGE_PATH as the path to the installed Intel and DCAP Client nuget packages.") + endif() else () - find_program(BASH bash) - if (NOT BASH) + find_program(OE_BASH bash) + if (NOT OE_BASH) message(FATAL_ERROR "Bash not found!") endif () endif () @@ -159,13 +164,8 @@ include(package_settings) # See `cmake/add_enclave.cmake` for enclave creation logic include(add_enclave) -# User configurable options -# DCAP library support on Windows is experimental and is disabled by default -if (UNIX) - option(USE_LIBSGX "Build oehost using SGX library requiring FLC" ON) -elseif (WIN32) - option(USE_LIBSGX "Build oehost using SGX library requiring FLC" OFF) -endif () +# User configurable options. +option(HAS_QUOTE_PROVIDER "Take a build dependency on SGX DCAP, which requires FLC on target device to run." ON) # TODO: See #756: Fix this because it is incompatible with # multi-configuration generators @@ -216,9 +216,26 @@ endif() if (UNIX) add_subdirectory(docs/refman) add_subdirectory(pkgconfig) - add_subdirectory(samples) endif() +if (BUILD_ENCLAVES) + add_subdirectory(samples) +endif () + +if (WIN32) + install(FILES ./scripts/clangw ./scripts/llvm-arw + DESTINATION ${CMAKE_INSTALL_BINDIR}/scripts/) + install(FILES ./scripts/install-windows-prereqs.ps1 + DESTINATION ${CMAKE_INSTALL_BINDIR}/scripts/) + install(FILES ./cmake/maybe_build_using_clangw.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/openenclave/cmake) + install(FILES ./cmake/add_dcap_client_target.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/openenclave/cmake) + install(FILES ./cmake/copy_oedebugrt_target.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/openenclave/cmake) +endif () + + install(FILES LICENSE THIRD_PARTY_NOTICES DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/licenses) diff --git a/CMakeSettings.json b/CMakeSettings.json index 3d1dbb3a4b..2b96768672 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,5 +1,5 @@ { - // Copyright (c) Microsoft Corporation. All rights reserved. + // Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // // This file illustrates CMake settings to use for building and testing @@ -31,7 +31,7 @@ "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${workspaceRoot}\\build\\x64-Debug", "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", - "cmakeCommandArgs": "-DBUILD_ENCLAVES=1 -DUSE_LIBSGX=1", + "cmakeCommandArgs": "-DBUILD_ENCLAVES=ON -DHAS_QUOTE_PROVIDER=ON -DNUGET_PACKAGE_PATH=${workspaceRoot}\\prereqs\\nuget", "buildCommandArgs": "-v", "ctestCommandArgs": "" }, @@ -42,7 +42,7 @@ "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${workspaceRoot}\\build\\x64-RelWithDebInfo", "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", - "cmakeCommandArgs": "-DBUILD_ENCLAVES=1 -DUSE_LIBSGX=1", + "cmakeCommandArgs": "-DBUILD_ENCLAVES=ON -DHAS_QUOTE_PROVIDER=ON -DNUGET_PACKAGE_PATH=${workspaceRoot}\\prereqs\\nuget", "buildCommandArgs": "-v", "ctestCommandArgs": "" }, @@ -53,7 +53,7 @@ "inheritEnvironments": [ "msvc_x64_x64" ], "buildRoot": "${workspaceRoot}\\build\\x64-Release", "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", - "cmakeCommandArgs": "-DBUILD_ENCLAVES=1 -DUSE_LIBSGX=1", + "cmakeCommandArgs": "-DBUILD_ENCLAVES=ON -DHAS_QUOTE_PROVIDER=ON -DNUGET_PACKAGE_PATH=${workspaceRoot}\\prereqs\\nuget", "buildCommandArgs": "-v", "ctestCommandArgs": "" } diff --git a/LICENSE b/LICENSE index 21071075c2..2950a9ab1e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License - Copyright (c) Microsoft Corporation. All rights reserved. + Copyright (c) Open Enclave SDK contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6b29d8172a..048ed46169 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Open Enclave SDK ================ -[![Bors enabled](https://bors.tech/images/badge_small.svg)](https://oe-bors.westus2.cloudapp.azure.com/repositories/12) [![Build Status](https://oe-jenkins.eastus.cloudapp.azure.com/buildStatus/icon?job=OpenEnclave-nightly_packages)](https://oe-jenkins.eastus.cloudapp.azure.com/job/OpenEnclave-nightly_packages/) [![Join the chat at https://gitter.im/openenclave/community](https://badges.gitter.im/openenclave/community.svg)](https://gitter.im/openenclave/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Bors enabled](https://bors.tech/images/badge_small.svg)](https://app.bors.tech/repositories/21855) [![Build Status](https://oe-jenkins.eastus.cloudapp.azure.com/buildStatus/icon?job=OpenEnclave-nightly_packages)](https://oe-jenkins.eastus.cloudapp.azure.com/job/OpenEnclave-nightly_packages/) [![Join the chat at https://gitter.im/openenclave/community](https://badges.gitter.im/openenclave/community.svg)](https://gitter.im/openenclave/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Introduction ------------ @@ -17,14 +17,17 @@ which is usually secured by hardware, for example, [Intel Software Guard Extensions (SGX)](https://software.intel.com/en-us/sgx). This SDK aims to generalize the development of enclave applications across TEEs -from different hardware vendors. While the current implementation is focused on -Intel SGX, support for ARM TrustZone is already under development. As an open -source project, this SDK also strives to provide a transparent solution that is -agnostic to specific vendors, service providers and choice of operating systems. +from different hardware vendors. The current implementation provides support for +Intel SGX as well as preview support for OP-TEE OS on ARM TrustZone. As an +open source project, this SDK also strives to provide a transparent solution +that is agnostic to specific vendors, service providers and choice of operating +systems. Getting Started --------------- +### Intel SGX + If you would like to start developing apps with the preview Open Enclave SDK release, start here for instructions to install and use the SDK package: @@ -37,28 +40,39 @@ If you would like to run Ubuntu 16.04 or Ubuntu 18.04 in a Hyper-V VM on SGX capable hardware, see [Setting up a Linux Hyper-V VM on Windows with SGX Support](docs/GettingStartedDocs/HyperVLinuxVMSetup.md). -If you would like to modify and build the Open Enclave SDK from sources, refer -to the documents for [getting started](docs/GettingStartedDocs/Contributors/building_oe_sdk.md). +### OP-TEE OS (ARM TrustZone) + +The Open Enclave SDK provides preview support for the Open Portable TEE OS +(OP-TEE OS). OP-TEE is an operating system for TEE's that implement a +traditional kernel-mode and user-mode execution environment. It runs on +A-profile ARM systems that support ARM TrustZone. As a result, the Open Enclave +SDK can be leveraged to target these systems as well. + +For an overview of the SDK's support for OP-TEE OS as well as links to getting +started guides, see +[Open Enclave SDK for OP-TEE OS](docs/GettingStartedDocs/OP-TEE/Introduction.md). Contributing ------------ -This project welcomes contributions and suggestions. Most contributions require -you to agree to a Contributor License Agreement (CLA) declaring that you have -the right to, and actually do, grant us the rights to use your contribution. For -details, see [Contributing to Open Enclave](docs/Contributing.md). - -This project has adopted the -[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). -For more information see the -[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any -additional questions or comments. - -See the [Development Guide](docs/DevelopmentGuide.md) for details about -contributing code to this project, such as coding style and development -processes. Also see our [Governance Model](docs/GovernanceModel.md) for how we -maintain the project. +This project welcomes contributions and suggestions. All contributions to the Open Enclave SDK +must adhere to the terms of the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). +For details, see [Contributing to Open Enclave](docs/Contributing.md). + +This project follows a [Code of Conduct](docs/CodeOfConduct.md) adapted from the +[Contributor Covenant v1.4](https://www.contributor-covenant.org). + +If you are interested in contributing directly to the codebase, please see the following +documentation: +- [Development Guide](docs/DevelopmentGuide.md) +- [Governance Model](docs/Governance.md) +- [Build SDK and run tests](docs/GettingStartedDocs/Contributors/building_oe_sdk.md) + +API Documentation +----------------- + +The Doxygen generated documentation corresponding to the APIs currently supported by the master branch is [here](https://openenclave.github.io/openenclave/api/index.html). +API Documentation for older releases of the SDK can be found on the Open Enclave SDK [website](https://openenclave.io/sdk). Licensing ========= diff --git a/SECURITY.md b/SECURITY.md index 661046e76f..3fadf0d133 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,9 +12,9 @@ supported versions of Open Enclave: | Version | Supported | | ------- | ------------------ | -| 0.6.x | :white_check_mark: | -| 0.6.0 | :white_check_mark: | -| < 0.6 | :x: | +| 0.7.x | :white_check_mark: | +| 0.7.0 | :white_check_mark: | +| < 0.7 | :x: | ## Reporting a Vulnerability diff --git a/THIRD_PARTY_NOTICES b/THIRD_PARTY_NOTICES index 05076e5b15..0642c71495 100644 --- a/THIRD_PARTY_NOTICES +++ b/THIRD_PARTY_NOTICES @@ -4,7 +4,7 @@ distributed under licenses different than the Open Enclave software. In the event that we accidentally failed to list a required notice, please bring it to our attention. Post an issue or email us: - openenclave@microsoft.com + oesdk@lists.confidentialcomputing.io The attached notices are provided for information only. diff --git a/VERSION b/VERSION index 4ad4b8602e..8b20e48523 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.7.x +v0.7.0 diff --git a/bors.toml b/bors.toml index 0b4e74c2b3..7c9885e99e 100644 --- a/bors.toml +++ b/bors.toml @@ -1,6 +1,6 @@ status = [ "continuous-integration/jenkins/branch" ] -pr_status = [ "license/cla" ] -required_approvals = 1 +pr_status = [ "DCO" ] +required_approvals = 2 block_labels = [ "do not merge" ] delete_merged_branches = true timeout_sec = 7200 # two hours diff --git a/cmake/add_dcap_client_target.cmake b/cmake/add_dcap_client_target.cmake index cccd1baf14..53fe8217e2 100644 --- a/cmake/add_dcap_client_target.cmake +++ b/cmake/add_dcap_client_target.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ## This function adds a CMake target for the DCAP client and its dependencies provided through nuget @@ -11,7 +11,7 @@ function(add_dcap_client_target TARGET_NAME) - if (NOT WIN32) + if (UNIX) message(WARNING "import_dcap_client is only intended for WIN32 build environments. Check if this invocation is needed.") endif () @@ -19,7 +19,7 @@ function(add_dcap_client_target TARGET_NAME) set(DEPENDENCIES "") # Define the DCAP provider path - set(AZURE_DCAP_QUOTEPROV ${CMAKE_SOURCE_DIR}/prereqs/nuget/Azure.DCAP.Windows/dll/dcap_quoteprov.dll) + set(AZURE_DCAP_QUOTEPROV ${NUGET_PACKAGE_PATH}/Azure.DCAP.Windows/dll/dcap_quoteprov.dll) # No-op if the DCAP provider is not found if (NOT EXISTS ${AZURE_DCAP_QUOTEPROV}) diff --git a/cmake/add_enclave.cmake b/cmake/add_enclave.cmake index 0328d435d1..e3eabf3b29 100644 --- a/cmake/add_enclave.cmake +++ b/cmake/add_enclave.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # Helper mecro to either sign an SGX enclave binary or to generate and sign diff --git a/cmake/add_enclave_test.cmake b/cmake/add_enclave_test.cmake index b998659e45..484791f9b8 100644 --- a/cmake/add_enclave_test.cmake +++ b/cmake/add_enclave_test.cmake @@ -1,17 +1,17 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ## This function is to add test for given host file and enclave file. -## TEST_NAME : test name for add test. -## HOST_FILE : Host application executable file name. -## ENC_FILE : Signed/Unsigned enclave file name. -## DESCRIPTION : For ADD_WINDOWS_ENCLAVE_TESTS enabled function will copy signed -## enclave file from Linux build location to windows build location -## after checking if both host and enclave file exists at specified -## location. -## NOTE : Any additional arguments after ENC_FILE argument are passed -## directly to add_test. +## TEST_NAME : test name for add test. +## HOST_FILE : Host application executable file name. +## ENC_FILE : Signed/Unsigned enclave file name. +## DESCRIPTION : For ADD_WINDOWS_ENCLAVE_TESTS enabled function will copy signed +## enclave file from Linux build location to windows build location +## after checking if both host and enclave file exists at specified +## location. +## NOTE : Any additional arguments after ENC_FILE argument are passed +## directly to add_test. function(add_enclave_test TEST_NAME HOST_FILE ENC_FILE) @@ -39,7 +39,6 @@ function(add_enclave_test TEST_NAME HOST_FILE ENC_FILE) # enclave subpath and "host" as the default host subpath. # This hack can be removed when CMake on Windows produces ELF enclaves. set(TEST_ENCSUBPATH enc) - set(TEST_HOSTSUBPATH host) # (HACK2) This is a hack to figure out the target name for the linux enclave # Ideally, the name of the enclave is found by $ @@ -50,23 +49,27 @@ function(add_enclave_test TEST_NAME HOST_FILE ENC_FILE) string(REGEX REPLACE "_signed" ".signed" TEST_ENCFILE ${ENC_FILE}) endif() - # custom rule to copy binary from linux - # take a dependency on host binary to make sure it exists in addition to - # enc binary in linux - add_custom_command(OUTPUT ${TEST_NAME}_windows_include - COMMAND ${CMAKE_COMMAND} -E copy ${LINUX_BIN_DIR}/${TEST_DIR}/${TEST_ENCSUBPATH}/${TEST_ENCFILE} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_HOSTSUBPATH}/${TEST_ENCFILE} - DEPENDS $ ${LINUX_BIN_DIR}/${TEST_DIR}/${TEST_ENCSUBPATH}/${TEST_ENCFILE} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) + # Copy the enclave subfolder from Linux + # This takes a dependency on host binary to make sure it exists, in addition to + # enclave binary in linux. It should only be executed once for the target build + # directory so that multiple tests hosted in the same enclave folder are copied + # only once. + if (NOT TARGET ${CMAKE_CURRENT_BINARY_DIR}__windows_include) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}_windows_include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${LINUX_BIN_DIR}/${TEST_DIR}/${TEST_ENCSUBPATH} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_ENCSUBPATH} + DEPENDS $ ${LINUX_BIN_DIR}/${TEST_DIR}/${TEST_ENCSUBPATH}/${TEST_ENCFILE} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + endif() - # add a custom target to ALL so that this step always needs to be run if + # Add a custom target to ALL so that this step always needs to be run if # this function is invoked get_filename_component(TEST_NAME_WITHOUT_SLASH ${TEST_NAME} NAME) add_custom_target(${TEST_NAME_WITHOUT_SLASH}.windows ALL - DEPENDS ${TEST_NAME}_windows_include + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}_windows_include ) - add_test(NAME ${TEST_NAME} COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/${TEST_HOSTSUBPATH}/${TEST_ENCFILE} ${ARGN}) + add_test(NAME ${TEST_NAME} COMMAND $ ${CMAKE_CURRENT_BINARY_DIR}/${TEST_ENCSUBPATH}/${TEST_ENCFILE} ${ARGN}) elseif (UNIX OR USE_CLANGW) add_test(NAME ${TEST_NAME} COMMAND $ $ ${ARGN}) diff --git a/cmake/arm-cross.cmake b/cmake/arm-cross.cmake index ac9edc6ea4..da18df260f 100644 --- a/cmake/arm-cross.cmake +++ b/cmake/arm-cross.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set(CMAKE_SYSTEM_NAME Linux) diff --git a/cmake/ccache.cmake b/cmake/ccache.cmake index 03ca0685c0..679429ea23 100644 --- a/cmake/ccache.cmake +++ b/cmake/ccache.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Adapted from https://crascit.com/2016/04/09/using-ccache-with-cmake/ diff --git a/cmake/compiler_settings.cmake b/cmake/compiler_settings.cmake index f8d7eb2b6b..d3ea6be4e3 100644 --- a/cmake/compiler_settings.cmake +++ b/cmake/compiler_settings.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Check Clang version. @@ -16,6 +16,8 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL CMAKE_CXX_COMPILER_ID) "${CMAKE_C_COMPILER_ID} != ${CMAKE_CXX_COMPILER_ID}") endif () +set(CMAKE_C_STANDARD 11) + # Set the default standard to C++14 for all targets. set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -72,9 +74,12 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang) # and that are easy to avoid. Treat at warnings-as-errors, which forces developers # to fix warnings as they arise, so they don't accumulate "to be fixed later". add_compile_options(-Wall -Werror -Wpointer-arith -Wconversion -Wextra -Wno-missing-field-initializers) - add_compile_options(-fno-strict-aliasing) + # Allow checks which always evaluate to true or false due to type limits. + # This is required as some macros operate on types of varying sizes. + add_compile_options(-Wno-type-limits) + # Enables XSAVE intrinsics if (OE_SGX) add_compile_options(-mxsave) @@ -84,11 +89,40 @@ elseif (MSVC) if (MSVC_VERSION VERSION_LESS 1910) message(FATAL_ERROR "Only Visual Studio 2017 and above supported!") endif () + + # Explicitly set C/CXX flags rather than using the defaults. This uses the defaults + # but removes /W3 from CMAKE_C(XX)_FLAGS. Using W3 and W1 together adds many warnings + # that W3 is being overwritten by W1. W3 as a default flag is removed in cmake 3.15, + # so this behavior can be removed if/when cmake_minimum_required is raised to 3.15. + # ======= Default compiler flags for cmake version 3.12 can be found here: ======= + # https://github.com/Kitware/CMake/blob/v3.12.0/Modules/Platform/Windows-MSVC.cmake + set (CMAKE_C_FLAGS "/DWIN32 /D_WINDOWS") + set (CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1") + set (CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG") + + set (CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /GR /EHsc") + set (CMAKE_CXX_FLAGS_DEBUG "/DWIN32 /D_WINDOWS /MDd /Zi /Ob0 /Od /RTC1") + set (CMAKE_CXX_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG") + + # Can't use add_compile_options because it adds for all file types and ml64 + # doesn't recognize /wd flags + # Turns off warnings for: + # * Unicode character cannot be represented by current code page + # * Flexible array members. These are standard in C99 so we will allow them. + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4566 /wd4200") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4566 /wd4200") + + # Add Flags we want to use for both C and CXX + add_compile_options(/WX) + add_compile_options(/W2) + + # Ignore compiler warnings: + # * unicode character not supported + if (CMAKE_MSVC_PARALLEL_ENABLE) add_compile_options(/MP) message(STATUS "Using parallel compiling (/MP)") endif() - endif () # Use ML64 as assembler on Windows diff --git a/cmake/copy_oedebugrt_target.cmake b/cmake/copy_oedebugrt_target.cmake new file mode 100644 index 0000000000..8718136396 --- /dev/null +++ b/cmake/copy_oedebugrt_target.cmake @@ -0,0 +1,29 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +## This function adds a CMake target for oedebugrt.dll. This allows the caller to :add a dependency on oedebugrt.dll so +## that it will be copied to the output folder along with the target taking the dependency. +## When the host executable is launched under windbg, if edebugrt.dll is present in the same path as the host executable, +## it gets automatically loaded into the debugger. This enables windbg to debug enclave applications. +## +## TARGET_NAME: Name of the target to add for oe_debugrt. This should be unique for each caller. +## + +function(copy_oedebugrt_target TARGET_NAME) + + if (UNIX) + message(WARNING "copy_oedebugrt_target is only intended for WIN32 build environments. Check if this invocation is needed.") + endif () + + get_property(OEDEBUGRTLOCATION TARGET openenclave::oedebugrt PROPERTY LOCATION) + # Add copy actions for the dependencies + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/oedebugrt.dll + DEPENDS ${OEDEBUGRTLOCATION} + COMMAND ${CMAKE_COMMAND} -E copy ${OEDEBUGRTLOCATION} ${CMAKE_CURRENT_BINARY_DIR}) + + + # Always create the requested target, which may have an empty dependency list + add_custom_target(${TARGET_NAME} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/oedebugrt.dll) + +endfunction( copy_oedebugrt_target ) diff --git a/cmake/cpack_settings.cmake b/cmake/cpack_settings.cmake index 64edf7c667..49252d94c2 100644 --- a/cmake/cpack_settings.cmake +++ b/cmake/cpack_settings.cmake @@ -1,15 +1,17 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # CPack variables for the regular OE SDK. include(InstallRequiredSystemLibraries) set(CPACK_PACKAGE_NAME "open-enclave") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Enclave SDK") -set(CPACK_PACKAGE_CONTACT "openenclave@microsoft.com") +set(CPACK_PACKAGE_CONTACT "oesdk@lists.confidentialcomputing.io") set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.md") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION ${OE_VERSION}) set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) + +# CPack variables for Debian packages set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsgx-enclave-common (>=2.3.100.46354-1), libsgx-enclave-common-dev (>=2.3.100.0-1), libsgx-dcap-ql (>=1.0.100.46460-1.0), libsgx-dcap-ql-dev (>=1.0.100.46460-1.0)") set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "pkg-config") set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) @@ -22,4 +24,11 @@ set(CPACK_DEBIAN_OEHOSTVERIFY_PACKAGE_DEPENDS "") set(CPACK_DEBIAN_OEHOSTVERIFY_PACKAGE_RECOMMENDS "pkg-config") set(CPACK_DEBIAN_OEHOSTVERIFY_FILE_NAME DEB-DEFAULT) set(CPACK_COMPONENT_OEHOSTVERIFY_DESCRIPTION "Open Enclave Report Verification Host Library") + +# CPack variables for Nuget packages +set(CPACK_NUGET_PACKAGE_NAME "open-enclave") +set(CPACK_NUGET_PACKAGE_AUTHORS "Open Enclave SDK Contributors") +set(CPACK_NUGET_PACKAGE_VERSION ${OE_VERSION}) +set(CPACK_NUGET_PACKAGE_LICENSEURL "https://github.com/openenclave/openenclave/blob/master/LICENSE") + include(CPack) diff --git a/cmake/get_testcase_name.cmake b/cmake/get_testcase_name.cmake index 5b8c2934ee..d7bd1495a2 100644 --- a/cmake/get_testcase_name.cmake +++ b/cmake/get_testcase_name.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # Helper function to obtain name for a test-case. Given a filename, chop diff --git a/cmake/maybe_build_using_clangw.cmake b/cmake/maybe_build_using_clangw.cmake index fab4d626fb..304b2f205b 100644 --- a/cmake/maybe_build_using_clangw.cmake +++ b/cmake/maybe_build_using_clangw.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # Helper function to create ELF enclaves and libraries on Windows by @@ -22,7 +22,7 @@ # rewrite of the build system CMakeLists.) # function(maybe_build_using_clangw OE_TARGET) - if (NOT WIN32) + if (UNIX) # Noop on Linux. return() endif() @@ -45,30 +45,30 @@ function(maybe_build_using_clangw OE_TARGET) # Setup library tool variables set(CMAKE_C_CREATE_STATIC_LIBRARY - "\"${BASH}\" \"${PROJECT_SOURCE_DIR}/scripts/llvm-arw\" \"qc \"" + "\"${OE_BASH}\" \"${OE_SCRIPTSDIR}/llvm-arw\" \"qc \"" PARENT_SCOPE) set(CMAKE_CXX_CREATE_STATIC_LIBRARY - "\"${BASH}\" \"${PROJECT_SOURCE_DIR}/scripts/llvm-arw\" \"qc \"" + "\"${OE_BASH}\" \"${OE_SCRIPTSDIR}/llvm-arw\" \"qc \"" PARENT_SCOPE) # Setup linker variables. set(CMAKE_EXECUTABLE_SUFFIX "" PARENT_SCOPE) set(CMAKE_C_STANDARD_LIBRARIES "" PARENT_SCOPE) set(CMAKE_C_LINK_EXECUTABLE - "\"${BASH}\" \"${PROJECT_SOURCE_DIR}/scripts/clangw\" \"link -o \"" + "\"${OE_BASH}\" \"${OE_SCRIPTSDIR}/clangw\" \"link -o \"" PARENT_SCOPE) set(CMAKE_CXX_STANDARD_LIBRARIES "" PARENT_SCOPE) set(CMAKE_CXX_LINK_EXECUTABLE - "\"${BASH}\" \"${PROJECT_SOURCE_DIR}/scripts/clangw\" \"link -o \"" + "\"${OE_BASH}\" \"${OE_SCRIPTSDIR}/clangw\" \"link -o \"" PARENT_SCOPE) # Setup compiler variables. set(CMAKE_C_COMPILE_OBJECT - "\"${BASH}\" \"${PROJECT_SOURCE_DIR}/scripts/clangw\" \" -o -c \"" + "\"${OE_BASH}\" \"${OE_SCRIPTSDIR}/clangw\" \" -o -c \"" PARENT_SCOPE) set(CMAKE_CXX_COMPILE_OBJECT - "\"${BASH}\" \"${PROJECT_SOURCE_DIR}/scripts/clangw\" \" -o -c \"" + "\"${OE_BASH}\" \"${OE_SCRIPTSDIR}/clangw\" \" -o -c \"" PARENT_SCOPE) # Loop through assembly files in the list of sources in the diff --git a/cmake/oeedl_file.cmake b/cmake/oeedl_file.cmake index 818a6a32ec..8cce1e2f32 100644 --- a/cmake/oeedl_file.cmake +++ b/cmake/oeedl_file.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # Helper function to handle EDL (gen) files diff --git a/cmake/openenclave-config.cmake.in b/cmake/openenclave-config.cmake.in index 9f43d138f2..e50a4f3297 100644 --- a/cmake/openenclave-config.cmake.in +++ b/cmake/openenclave-config.cmake.in @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. @PACKAGE_INIT@ @@ -12,30 +12,118 @@ set_and_check(OE_LIBDIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@") set_and_check(OE_BINDIR "@PACKAGE_CMAKE_INSTALL_BINDIR@") set_and_check(OE_DATADIR "@PACKAGE_CMAKE_INSTALL_DATADIR@") set_and_check(OE_INCLUDEDIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") +set(OE_SCRIPTSDIR "@PACKAGE_CMAKE_INSTALL_BINDIR@/scripts") +set (OE_SGX "@OE_SGX@") + +if (WIN32) + set(USE_CLANGW ON) + + # NOTE: On Windows we have found that we must use Git Bash, not the + # Bash from the Windows Subsystem for Linux. Hence this is + # explicitly searching only for Git Bash. See #1302 for more. + find_program(GIT git) + get_filename_component(GIT_DIR ${GIT} DIRECTORY) + find_program(OE_BASH bash + PATHS "C:/Program Files/Git/bin" "${GIT_DIR}/../bin" + NO_DEFAULT_PATH) # Do not find WSL bash. + + if (NOT OE_BASH) + message(FATAL_ERROR "-- Git Bash not found!") + endif () + if (NOT NUGET_PACKAGE_PATH) + message(FATAL_ERROR "NUGET_PACKAGE_PATH not defined. Please define NUGET_PACKAGE_PATH as the path to the installed Intel and DCAP Client nuget packages.") + endif() +else () + find_program(OE_BASH bash) + if (NOT OE_BASH) + message(FATAL_ERROR "-- Bash not found!") + endif () +endif () + # Dependencies. include(CMakeFindDependencyMacro) find_dependency(Threads) if (UNIX) - if (NOT TARGET crypto) + if (NOT TARGET openenclave::crypto) find_library(CRYPTO_LIB NAMES crypto) if (NOT CRYPTO_LIB) message(FATAL_ERROR "-- Looking for crypto library - not found") else () message("-- Looking for crypto library - found") - add_library(crypto SHARED IMPORTED) - set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CRYPTO_LIB}) + add_library(openenclave::crypto SHARED IMPORTED) + set_target_properties(openenclave::crypto PROPERTIES IMPORTED_LOCATION ${CRYPTO_LIB}) endif () endif () - if (NOT TARGET dl) + if (NOT TARGET openenclave::dl) find_library(DL_LIB NAMES dl) if(NOT DL_LIB) message(FATAL_ERROR "-- Looking for dl library - not found") else () message("-- Looking for dl library - found") - add_library(dl SHARED IMPORTED) - set_target_properties(dl PROPERTIES IMPORTED_LOCATION ${DL_LIB}) + add_library(openenclave::dl SHARED IMPORTED) + set_target_properties(openenclave::dl PROPERTIES IMPORTED_LOCATION ${DL_LIB}) + endif () + endif () +elseif (WIN32) + if (NOT NUGET_PACKAGE_PATH) + message(FATAL_ERROR "NUGET_PACKAGE_PATH not defined. Please define NUGET_PACKAGE_PATH as the path to the Intel and DCAP Client nuget packages.") + endif() +endif () + +# Include the automatically exported targets. +include("${CMAKE_CURRENT_LIST_DIR}/openenclave-targets.cmake") +if (WIN32) + include("${CMAKE_CURRENT_LIST_DIR}/add_dcap_client_target.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/copy_oedebugrt_target.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/maybe_build_using_clangw.cmake") +endif () + +if (OE_SGX) + if (NOT TARGET openenclave::sgx_enclave_common) + if (UNIX) + find_library(SGX_ENCLAVE_COMMON_LIB NAMES sgx_enclave_common HINTS "/usr") + elseif (WIN32) + find_library(SGX_ENCLAVE_COMMON_LIB NAMES sgx_enclave_common + HINTS ${NUGET_PACKAGE_PATH}/EnclaveCommonAPI/lib/native/x64-Release) + endif () + if (NOT SGX_ENCLAVE_COMMON_LIB) + message(FATAL_ERROR "-- Looking for sgx_enclave_common library - not found") + else () + message(VERBOSE "-- Looking for sgx_enclave_common library - found") + add_library(openenclave::sgx_enclave_common SHARED IMPORTED) + if (UNIX) + set_target_properties(openenclave::sgx_enclave_common PROPERTIES IMPORTED_LOCATION ${SGX_ENCLAVE_COMMON_LIB}) + elseif (WIN32) + set_target_properties(openenclave::sgx_enclave_common PROPERTIES + IMPORTED_LOCATION $ENV{WINDIR}/System32 + IMPORTED_IMPLIB ${SGX_ENCLAVE_COMMON_LIB}) + endif () + target_link_libraries(openenclave::oehost INTERFACE openenclave::sgx_enclave_common) + endif () + endif () + + if (NOT TARGET openenclave::sgx_dcap_ql) + if (UNIX) + find_library(SGX_DCAP_QL_LIB NAMES sgx_dcap_ql HINTS "/usr") + elseif (WIN32) + find_library(SGX_DCAP_QL_LIB NAMES sgx_dcap_ql + HINTS ${NUGET_PACKAGE_PATH}/DCAP_Components/build/lib/native/Libraries) + endif () + if (NOT SGX_DCAP_QL_LIB) + message(WARNING "-- Looking for sgx_dcap_ql library - not found. Attestations based on quotes would not function without the quote provider.") + else () + message(VERBOSE "-- Looking for sgx_dcap_ql library - found") + add_library(openenclave::sgx_dcap_ql SHARED IMPORTED) + if (UNIX) + set_target_properties(openenclave::sgx_dcap_ql PROPERTIES IMPORTED_LOCATION ${SGX_DCAP_QL_LIB}) + elseif (WIN32) + set_target_properties(openenclave::sgx_dcap_ql PROPERTIES + IMPORTED_LOCATION $ENV{WINDIR}/System32 + IMPORTED_IMPLIB ${SGX_DCAP_QL_LIB}) + endif () + target_link_libraries(openenclave::oehost INTERFACE openenclave::sgx_dcap_ql) endif () endif () endif () @@ -53,9 +141,6 @@ if(NOT TARGET openenclave::oegdb) set_target_properties(openenclave::oegdb PROPERTIES IMPORTED_LOCATION ${OE_BINDIR}/oegdb) endif () -# Include the automatically exported targets. -include("${CMAKE_CURRENT_LIST_DIR}/openenclave-targets.cmake") - # Apply Spectre mitigations if available. set(OE_SPECTRE_MITIGATION_FLAGS "@SPECTRE_MITIGATION_FLAGS@") diff --git a/cmake/openenclaverc.in b/cmake/openenclaverc.in index 8325a57537..2f74f164b9 100644 --- a/cmake/openenclaverc.in +++ b/cmake/openenclaverc.in @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Update PKG_CONFIG_PATH. diff --git a/cmake/package_settings.cmake b/cmake/package_settings.cmake index 511a8a0853..d7ece072fd 100644 --- a/cmake/package_settings.cmake +++ b/cmake/package_settings.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # # Set default paths @@ -11,8 +11,13 @@ # $ cmake -DCMAKE_INSTALL_PREFIX=/opt/myplace .. # if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX - "/opt/openenclave" CACHE PATH "default install prefix" FORCE) + if (WIN32) + set(CMAKE_INSTALL_PREFIX + "./openenclave" CACHE PATH "default install prefix" FORCE) + else () + set(CMAKE_INSTALL_PREFIX + "/opt/openenclave" CACHE PATH "default install prefix" FORCE) + endif () endif() include(GNUInstallDirs) @@ -55,15 +60,17 @@ install( RENAME README.md COMPONENT OEHOSTVERIFY) -# Generate the openenclaverc script. -configure_file( +if (UNIX) + # Generate the openenclaverc script. + configure_file( ${PROJECT_SOURCE_DIR}/cmake/openenclaverc.in ${CMAKE_BINARY_DIR}/output/share/openenclave/openenclaverc @ONLY) -# Install the openenclaverc script. -install(FILES + # Install the openenclaverc script. + install(FILES ${CMAKE_BINARY_DIR}/output/share/openenclave/openenclaverc DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/openenclave" COMPONENT OEHOSTVERIFY) +endif() diff --git a/common/argv.c b/common/argv.c index 69ce3b74d6..d2e0ddf951 100644 --- a/common/argv.c +++ b/common/argv.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/common/asn1.c b/common/asn1.c index 4e6a9c430c..504f384f4d 100644 --- a/common/asn1.c +++ b/common/asn1.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "asn1.h" diff --git a/common/asn1.h b/common/asn1.h index 4947e98ca3..2877a702d1 100644 --- a/common/asn1.h +++ b/common/asn1.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMON_ASN1_H diff --git a/common/attest_plugin.c b/common/attest_plugin.c new file mode 100644 index 0000000000..62beb33eb9 --- /dev/null +++ b/common/attest_plugin.c @@ -0,0 +1,455 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common.h" + +const char* OE_REQUIRED_CLAIMS[OE_REQUIRED_CLAIMS_COUNT] = { + OE_CLAIM_ID_VERSION, + OE_CLAIM_SECURITY_VERSION, + OE_CLAIM_ATTRIBUTES, + OE_CLAIM_UNIQUE_ID, + OE_CLAIM_SIGNER_ID, + OE_CLAIM_PRODUCT_ID, + OE_CLAIM_PLUGIN_UUID}; + +const char* OE_OPTIONAL_CLAIMS[OE_OPTIONAL_CLAIMS_COUNT] = { + OE_CLAIM_VALIDITY_FROM, + OE_CLAIM_VALIDITY_UNTIL}; + +/** + * Header that the OE runtime puts ontop of the attestation plugins. + */ +typedef struct _oe_attestation_header +{ + /* Set to OE_ATTESTATION_HEADER_VERSION. */ + uint32_t version; + + /* UUID to identify format. */ + oe_uuid_t format_id; + + /* Size of evidence/endorsements sent to the plugin. */ + uint64_t data_size; + + /* The actual data */ + uint8_t data[]; + + /* data_size bytes that follows the header will be sent to a plugin. */ +} oe_attestation_header_t; + +// Struct definition to represent the list of plugins. +struct plugin_list_node_t +{ + oe_attestation_role_t* plugin; + struct plugin_list_node_t* next; +}; + +// Variables storing the attester and verifier lists. +struct plugin_list_node_t* attesters = NULL; +struct plugin_list_node_t* verifiers = NULL; + +// Finds the plugin node with the given ID. If found, the function +// will return the node and store the pointer of the previous node +// in prev (NULL for the head pointer). If not found, the function +// will return NULL. +static struct plugin_list_node_t* _find_plugin( + struct plugin_list_node_t* head, + const oe_uuid_t* target_format_id, + struct plugin_list_node_t** prev) +{ + struct plugin_list_node_t* ret = NULL; + struct plugin_list_node_t* cur = NULL; + + if (prev) + *prev = NULL; + + // Find a plugin for attestation type. + cur = head; + while (cur) + { + if (memcmp( + &cur->plugin->format_id, target_format_id, sizeof(oe_uuid_t)) == + 0) + { + ret = cur; + break; + } + if (prev) + *prev = cur; + cur = cur->next; + } + + return ret; +} + +static oe_result_t _register_plugin( + struct plugin_list_node_t** list, + oe_attestation_role_t* plugin, + const void* config_data, + size_t config_data_size) +{ + oe_result_t result = OE_UNEXPECTED; + struct plugin_list_node_t* plugin_node = NULL; + + if (!list || !plugin) + OE_RAISE(OE_INVALID_PARAMETER); + + plugin_node = _find_plugin(*list, &plugin->format_id, NULL); + if (plugin_node) + { + plugin_node = NULL; + OE_RAISE(OE_ALREADY_EXISTS); + } + + plugin_node = (struct plugin_list_node_t*)oe_malloc(sizeof(*plugin_node)); + if (plugin_node == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + // Run the register function for the plugin. + OE_CHECK(plugin->on_register(plugin, config_data, config_data_size)); + + // Add to the plugin list. + plugin_node->plugin = plugin; + plugin_node->next = *list; + *list = plugin_node; + plugin_node = NULL; + + result = OE_OK; + +done: + if (plugin_node != NULL) + oe_free(plugin_node); + + return result; +} + +static oe_result_t _unregister_plugin( + struct plugin_list_node_t** list, + oe_attestation_role_t* plugin) +{ + oe_result_t result = OE_UNEXPECTED; + struct plugin_list_node_t* prev = NULL; + struct plugin_list_node_t* cur = NULL; + + if (!list || !plugin) + OE_RAISE(OE_INVALID_PARAMETER); + + // Find the guid and remove it. + cur = _find_plugin(*list, &plugin->format_id, &prev); + if (cur == NULL) + OE_RAISE(OE_NOT_FOUND); + + if (prev != NULL) + prev->next = cur->next; + else + *list = cur->next; + + // Run the unregister hook for the plugin. + OE_CHECK(cur->plugin->on_unregister(cur->plugin)); + + result = OE_OK; + +done: + oe_free(cur); + return result; +} + +oe_result_t oe_register_attester( + oe_attester_t* plugin, + const void* config_data, + size_t config_data_size) +{ + return _register_plugin( + &attesters, + (oe_attestation_role_t*)plugin, + config_data, + config_data_size); +} + +oe_result_t oe_register_verifier( + oe_verifier_t* plugin, + const void* config_data, + size_t config_data_size) +{ + return _register_plugin( + &verifiers, + (oe_attestation_role_t*)plugin, + config_data, + config_data_size); +} + +oe_result_t oe_unregister_attester(oe_attester_t* plugin) +{ + return _unregister_plugin(&attesters, (oe_attestation_role_t*)plugin); +} + +oe_result_t oe_unregister_verifier(oe_verifier_t* plugin) +{ + return _unregister_plugin(&verifiers, (oe_attestation_role_t*)plugin); +} + +static oe_result_t _wrap_with_header( + const oe_uuid_t* format_id, + const uint8_t* data, + size_t data_size, + uint8_t** total_data, + size_t* total_data_size) +{ + oe_result_t result = OE_UNEXPECTED; + oe_attestation_header_t* header; + + OE_CHECK(oe_safe_add_sizet(sizeof(*header), data_size, total_data_size)); + + *total_data = (uint8_t*)oe_malloc(*total_data_size); + if (*total_data == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + header = (oe_attestation_header_t*)*total_data; + header->version = OE_ATTESTATION_HEADER_VERSION; + header->format_id = *format_id; + header->data_size = data_size; + memcpy(header->data, data, data_size); + + result = OE_OK; + +done: + return result; +} + +oe_result_t oe_get_evidence( + const oe_uuid_t* format_id, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size) +{ + oe_result_t result = OE_UNEXPECTED; + struct plugin_list_node_t* plugin_node = NULL; + oe_attester_t* plugin = NULL; + uint8_t* plugin_evidence = NULL; + size_t plugin_evidence_size = 0; + uint8_t* plugin_endorsements = NULL; + size_t plugin_endorsements_size = 0; + uint8_t* total_evidence_buf = NULL; + size_t total_evidence_size = 0; + uint8_t* total_endorsements_buf = NULL; + size_t total_endorsements_size = 0; + + if (!format_id || !evidence_buffer || !evidence_buffer_size || + (endorsements_buffer && !endorsements_buffer_size) || + (!endorsements_buffer && endorsements_buffer_size)) + OE_RAISE(OE_INVALID_PARAMETER); + + // Find a plugin for attestation type and run its get_evidence. + plugin_node = _find_plugin(attesters, format_id, NULL); + if (plugin_node == NULL) + OE_RAISE(OE_NOT_FOUND); + + // Now get the evidence and endorsements (if desired). + plugin = (oe_attester_t*)plugin_node->plugin; + OE_CHECK(plugin->get_evidence( + plugin, + flags, + custom_claims, + custom_claims_length, + opt_params, + opt_params_size, + &plugin_evidence, + &plugin_evidence_size, + endorsements_buffer ? &plugin_endorsements : NULL, + endorsements_buffer ? &plugin_endorsements_size : NULL)); + + // Wrap the attestation header around the evidence. + OE_CHECK(_wrap_with_header( + format_id, + plugin_evidence, + plugin_evidence_size, + &total_evidence_buf, + &total_evidence_size)); + + if (endorsements_buffer) + { + OE_CHECK(_wrap_with_header( + format_id, + plugin_endorsements, + plugin_endorsements_size, + &total_endorsements_buf, + &total_endorsements_size)); + } + + // Finally, set the out parameters. + *evidence_buffer = total_evidence_buf; + *evidence_buffer_size = total_evidence_size; + total_evidence_buf = NULL; + + if (endorsements_buffer) + { + *endorsements_buffer = total_endorsements_buf; + *endorsements_buffer_size = total_endorsements_size; + total_endorsements_buf = NULL; + } + + result = OE_OK; + +done: + if (plugin && plugin_evidence) + { + plugin->free_evidence(plugin, plugin_evidence); + if (plugin_endorsements) + plugin->free_endorsements(plugin, plugin_endorsements); + } + if (total_evidence_buf != NULL) + oe_free(total_evidence_buf); + if (total_endorsements_buf != NULL) + oe_free(total_endorsements_buf); + return result; +} + +oe_result_t oe_free_evidence(uint8_t* evidence_buffer) +{ + oe_free(evidence_buffer); + return OE_OK; +} + +oe_result_t oe_free_endorsements(uint8_t* evidence_buffer) +{ + oe_free(evidence_buffer); + return OE_OK; +} + +static bool _check_claims(const oe_claim_t* claims, size_t claims_length) +{ + for (size_t i = 0; i < OE_REQUIRED_CLAIMS_COUNT; i++) + { + bool found = false; + + for (size_t j = 0; j < claims_length && !found; j++) + { + if (oe_strcmp(OE_REQUIRED_CLAIMS[i], claims[j].name) == 0) + { + found = true; + } + } + + if (!found) + return false; + } + return true; +} + +oe_result_t oe_verify_evidence( + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length) +{ + oe_result_t result = OE_UNEXPECTED; + struct plugin_list_node_t* plugin_node; + oe_verifier_t* verifier; + oe_attestation_header_t* evidence = + (oe_attestation_header_t*)evidence_buffer; + oe_attestation_header_t* endorsements = + (oe_attestation_header_t*)endorsements_buffer; + + if (!evidence_buffer || evidence_buffer_size < sizeof(*evidence) || + (endorsements_buffer && + endorsements_buffer_size < sizeof(*endorsements))) + OE_RAISE(OE_INVALID_PARAMETER); + + plugin_node = _find_plugin(verifiers, &evidence->format_id, NULL); + if (plugin_node == NULL) + OE_RAISE(OE_NOT_FOUND); + + if (endorsements && memcmp( + &evidence->format_id, + &endorsements->format_id, + sizeof(evidence->format_id)) != 0) + OE_RAISE(OE_CONSTRAINT_FAILED); + + verifier = (oe_verifier_t*)plugin_node->plugin; + OE_CHECK(verifier->verify_evidence( + verifier, + evidence->data, + evidence->data_size, + endorsements ? endorsements->data : NULL, + endorsements ? endorsements->data_size : 0, + policies, + policies_size, + claims, + claims_length)); + + if (!_check_claims(*claims, *claims_length)) + { + verifier->free_claims_list(verifier, *claims, *claims_length); + *claims = NULL; + *claims_length = 0; + OE_RAISE(OE_CONSTRAINT_FAILED); + } + + result = OE_OK; + +done: + return result; +} + +static oe_result_t _get_uuid( + const oe_claim_t* claims, + size_t claims_length, + oe_uuid_t* uuid) +{ + for (size_t i = 0; i < claims_length; i++) + { + if (oe_strcmp(claims[i].name, OE_CLAIM_PLUGIN_UUID) == 0) + { + if (claims[i].value_size != sizeof(oe_uuid_t)) + return OE_CONSTRAINT_FAILED; + + *uuid = *((oe_uuid_t*)claims[i].value); + return OE_OK; + } + } + return OE_NOT_FOUND; +} + +oe_result_t oe_free_claims_list(oe_claim_t* claims, size_t claims_length) +{ + oe_uuid_t uuid; + oe_result_t result = OE_UNEXPECTED; + struct plugin_list_node_t* plugin_node; + oe_verifier_t* verifier; + + if (!claims) + return OE_OK; + + OE_CHECK(_get_uuid(claims, claims_length, &uuid)); + + plugin_node = _find_plugin(verifiers, &uuid, NULL); + if (plugin_node == NULL) + OE_RAISE(OE_NOT_FOUND); + + verifier = (oe_verifier_t*)plugin_node->plugin; + OE_CHECK(verifier->free_claims_list(verifier, claims, claims_length)); + + result = OE_OK; + +done: + return result; +} diff --git a/common/cert.c b/common/cert.c index 0fa4077d7b..cc224b55d7 100644 --- a/common/cert.c +++ b/common/cert.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -97,7 +97,7 @@ static oe_result_t _append( oe_result_t oe_get_crl_distribution_points( const oe_cert_t* cert, - const char*** urls, + char*** urls, size_t* num_urls, uint8_t* buffer, size_t* buffer_size) @@ -163,7 +163,7 @@ oe_result_t oe_get_crl_distribution_points( /* Set the pointer to the urls[] array if enough space */ if (buffer && urls_bytes <= *buffer_size) - *urls = (const char**)buffer; + *urls = (char**)buffer; /* Process all the CRL distribution points */ { @@ -187,7 +187,7 @@ oe_result_t oe_get_crl_distribution_points( { // The address could point beyond end of buffer, but that is // fine since an OE_BUFFER_TOO_SMALL error is raised below. - (*urls)[i] = (const char*)(buffer + offset); + (*urls)[i] = ((char*)buffer + offset); } /* Append the URL */ @@ -270,4 +270,4 @@ oe_result_t oe_cert_write_public_key_pem( done: return result; -} \ No newline at end of file +} diff --git a/common/common.h b/common/common.h index 836de42815..ee0d1fdb76 100644 --- a/common/common.h +++ b/common/common.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMON_COMMON_H diff --git a/common/datetime.c b/common/datetime.c index 7a420f04e3..5179f3f45c 100644 --- a/common/datetime.c +++ b/common/datetime.c @@ -1,10 +1,13 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#include #include #include +#include #define UNIX_EPOCH_YEAR (1970) +#define OE_DATETIME_STR_SIZE (21) oe_result_t oe_datetime_is_valid(const oe_datetime_t* datetime) { @@ -121,10 +124,10 @@ oe_result_t oe_datetime_to_string( if (datetime == NULL || str_length == NULL) OE_RAISE(OE_INVALID_PARAMETER); - if (str == NULL || *str_length < 21) + if (str == NULL || *str_length < OE_DATETIME_STR_SIZE) { - *str_length = 21; - OE_RAISE(OE_BUFFER_TOO_SMALL); + *str_length = OE_DATETIME_STR_SIZE; + OE_RAISE_NO_TRACE(OE_BUFFER_TOO_SMALL); } OE_CHECK(oe_datetime_is_valid(datetime)); @@ -149,7 +152,7 @@ oe_result_t oe_datetime_to_string( // Null terminator. *p++ = 0; - *str_length = 21; + *str_length = OE_DATETIME_STR_SIZE; result = OE_OK; done: return result; @@ -221,3 +224,39 @@ int32_t oe_datetime_compare( return 0; } + +oe_result_t oe_datetime_now(oe_datetime_t* value) +{ + oe_result_t result = OE_UNEXPECTED; + time_t now; + struct tm* timeinfo; + + if (value == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + time(&now); + timeinfo = gmtime(&now); + + value->year = (uint32_t)timeinfo->tm_year + 1900; + value->month = (uint32_t)timeinfo->tm_mon + 1; + value->day = (uint32_t)timeinfo->tm_mday; + value->hours = (uint32_t)timeinfo->tm_hour; + value->minutes = (uint32_t)timeinfo->tm_min; + value->seconds = (uint32_t)timeinfo->tm_sec; + + result = OE_OK; +done: + + return result; +} + +void oe_datetime_log(const char* msg, const oe_datetime_t* date) +{ + if (oe_get_current_logging_level() >= OE_LOG_LEVEL_VERBOSE) + { + char str[OE_DATETIME_STR_SIZE]; + size_t size = sizeof(str); + oe_datetime_to_string(date, str, &size); + OE_TRACE_VERBOSE("%s %s\n", msg, str); + } +} diff --git a/common/kdf.c b/common/kdf.c index 1f3e785a81..298861084a 100644 --- a/common/kdf.c +++ b/common/kdf.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/common/lockless_queue.c b/common/lockless_queue.c deleted file mode 100644 index 330b906832..0000000000 --- a/common/lockless_queue.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. */ - -#include -#include - -#if _MSC_VER -#include -#endif /* _MSC_VER */ - -/* functions for oe_lockless_queue_node */ -/*---------------------------------------------------------------------------*/ -void oe_lockless_queue_node_init(oe_lockless_queue_node* p_node) -{ - p_node->p_link = NULL; -} /* init_oe_lockless_queue_node */ - -/* functions for oe_lockless_queue */ -/*---------------------------------------------------------------------------*/ -void oe_lockless_queue_init(oe_lockless_queue* p_queue) -{ -#ifdef _MSC_VER - _InterlockedExchangePointer(&(p_queue->p_tail), NULL); - _InterlockedExchangePointer(&(p_queue->p_head), NULL); -#elif defined __GNUC__ - __atomic_store_n(&(p_queue->p_tail), NULL, __ATOMIC_RELAXED); - __atomic_store_n(&(p_queue->p_head), NULL, __ATOMIC_RELAXED); -#endif /* _MSC_VER or __GNUC__ */ -} /* init_oe_lockless_queue */ - -void oe_lockless_queue_push_back( - oe_lockless_queue* p_queue, - oe_lockless_queue_node* p_node) -{ - oe_lockless_queue_node* p_expected = NULL; -#ifdef _MSC_VER - oe_lockless_queue_node* p_actual = NULL; -#endif /* _MSC_VER */ - do - { -#ifdef _MSC_VER - p_expected = p_actual; - p_node->p_link = p_expected; - p_actual = (oe_lockless_queue_node*)_InterlockedCompareExchangePointer( - &(p_queue->p_tail), p_node, p_expected); - } while (p_actual != p_expected); -#elif defined __GNUC__ - p_node->p_link = p_expected; - } while (!__atomic_compare_exchange_n( - &(p_queue->p_tail), - &p_expected, - p_node, - 1, - __ATOMIC_ACQ_REL, - __ATOMIC_ACQUIRE)); -#endif /* _MSC_VER or __GNUC__ */ -} /* oe_lockless_queue_push */ - -oe_lockless_queue_node* oe_lockless_queue_pop_front(oe_lockless_queue* p_queue) -{ - /* try to take a node from the head */ - oe_lockless_queue_node* popped_node = NULL; -#ifdef _MSC_VER - popped_node = (oe_lockless_queue_node*)_InterlockedCompareExchangePointer( - &(p_queue->p_head), NULL, NULL); -#elif defined __GNUC__ - popped_node = __atomic_load_n(&(p_queue->p_head), __ATOMIC_ACQUIRE); -#endif /* _MSC_VER or __GNUC__ */ - - if (NULL != popped_node) - { - /* there was a node at the head - * pop the node from the head and replace it with the node that it - * points to - * remove the reference from the popped node to the next node */ - oe_lockless_queue_node* next_node = popped_node->p_link; - popped_node->p_link = NULL; -#ifdef _MSC_VER - _InterlockedExchangePointer(&(p_queue->p_head), next_node); -#elif defined __GNUC__ - __atomic_store_n(&(p_queue->p_head), next_node, __ATOMIC_RELEASE); -#endif /* _MSC_VER or __GNUC__ */ - } - else - { - /* there wasn't a node at the head - * so refill the head with the nodes from the tail */ - - /* take all of the nodes off of the tail */ -#ifdef _MSC_VER - popped_node = (oe_lockless_queue_node*)_InterlockedExchangePointer( - &(p_queue->p_tail), NULL); -#elif defined __GNUC__ - popped_node = - __atomic_exchange_n(&(p_queue->p_tail), NULL, __ATOMIC_ACQ_REL); -#endif /* _MSC_VER or __GNUC__ */ - - if (NULL != popped_node) - { - /* reverse the nodes from the tail */ - oe_lockless_queue_node* prev_node = NULL; - oe_lockless_queue_node* next_node = NULL; - next_node = popped_node->p_link; - while (NULL != next_node) - { - popped_node->p_link = prev_node; - prev_node = popped_node; - popped_node = next_node; - next_node = popped_node->p_link; - } - - /* move the nodes to the head */ - popped_node->p_link = NULL; -#if _MSC_VER - _InterlockedExchangePointer(&(p_queue->p_head), prev_node); -#elif defined __GNUC__ - __atomic_store_n(&(p_queue->p_head), prev_node, __ATOMIC_RELEASE); -#endif /* _MSC_VER or __GNUC__ */ - } - } - return popped_node; -} /* oe_lockless_queue_pop */ diff --git a/common/oe_host_socket.h b/common/oe_host_socket.h new file mode 100644 index 0000000000..af46e14f0d --- /dev/null +++ b/common/oe_host_socket.h @@ -0,0 +1,154 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_HOST_SOCKET_H +#define _OE_HOST_SOCKET_H + +#include +#include +#include +#include +#include +#include + +#ifdef _WIN32 +#include +#else +#include +#endif + +OE_EXTERNC_BEGIN + +#define GETADDRINFO_HANDLE_MAGIC 0xed11d13a + +typedef struct _getaddrinfo_handle +{ + uint64_t magic; + struct addrinfo* res; + struct addrinfo* next; +} getaddrinfo_handle_t; + +OE_INLINE getaddrinfo_handle_t* _cast_getaddrinfo_handle(void* handle_); + +int _getaddrinfo_read( + uint64_t handle_, + int* ai_flags, + int* ai_family, + int* ai_socktype, + int* ai_protocol, + oe_socklen_t ai_addrlen_in, + oe_socklen_t* ai_addrlen, + struct oe_sockaddr* ai_addr, + size_t ai_canonnamelen_in, + size_t* ai_canonnamelen, + char* ai_canonname, + int* err_no); + +OE_INLINE getaddrinfo_handle_t* _cast_getaddrinfo_handle(void* handle_) +{ + getaddrinfo_handle_t* handle = (getaddrinfo_handle_t*)handle_; + + if (!handle || handle->magic != GETADDRINFO_HANDLE_MAGIC || !handle->res) + return NULL; + + return handle; +} + +int _getaddrinfo_read( + uint64_t handle_, + int* ai_flags, + int* ai_family, + int* ai_socktype, + int* ai_protocol, + oe_socklen_t ai_addrlen_in, + oe_socklen_t* ai_addrlen, + struct oe_sockaddr* ai_addr, + size_t ai_canonnamelen_in, + size_t* ai_canonnamelen, + char* ai_canonname, + int* err_no) +{ + int ret = -1; + getaddrinfo_handle_t* handle = _cast_getaddrinfo_handle((void*)handle_); + + if (!err_no) + { + goto done; + } + + if (!handle || !ai_flags || !ai_family || !ai_socktype || !ai_protocol || + !ai_addrlen || !ai_canonnamelen) + { + *err_no = OE_EINVAL; + + goto done; + } + + if (!ai_addr && ai_addrlen_in) + { + *err_no = OE_EINVAL; + goto done; + } + + if (!ai_canonname && ai_canonnamelen_in) + { + *err_no = OE_EINVAL; + goto done; + } + + if (handle->next) + { + struct addrinfo* p = handle->next; + + *ai_flags = p->ai_flags; + *ai_family = p->ai_family; + *ai_socktype = p->ai_socktype; + *ai_protocol = p->ai_protocol; + *ai_addrlen = p->ai_addrlen; + + if (p->ai_canonname) + *ai_canonnamelen = strlen(p->ai_canonname) + 1; + else + *ai_canonnamelen = 0; + + if (*ai_addrlen > ai_addrlen_in) + { + *err_no = OE_ENAMETOOLONG; + goto done; + } + + if (*ai_canonnamelen > ai_canonnamelen_in) + { + *err_no = OE_ENAMETOOLONG; + goto done; + } + + if (ai_addr) + { + memcpy(ai_addr, p->ai_addr, *ai_addrlen); + } + + if (ai_canonname && p->ai_canonname) + { + memcpy(ai_canonname, p->ai_canonname, *ai_canonnamelen); + } + + handle->next = handle->next->ai_next; + + ret = 0; + goto done; + } + else + { + /* Done */ + ret = 1; + goto done; + } + +done: + return ret; +} + +OE_EXTERNC_END + +#endif // _OE_HOST_SOCKET_H diff --git a/common/oe_host_stdio.h b/common/oe_host_stdio.h index 9f19262a6f..a532df267d 100644 --- a/common/oe_host_stdio.h +++ b/common/oe_host_stdio.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_STDIO_H diff --git a/common/oe_host_stdlib.h b/common/oe_host_stdlib.h index 060c8f6a8a..c1b88b6df3 100644 --- a/common/oe_host_stdlib.h +++ b/common/oe_host_stdlib.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_STDLIB_H diff --git a/common/oe_host_string.h b/common/oe_host_string.h index 6b0b9c9daf..6e3f63d7e1 100644 --- a/common/oe_host_string.h +++ b/common/oe_host_string.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_STRING_H diff --git a/common/result.c b/common/result.c index 1802738ced..d9c662de00 100644 --- a/common/result.c +++ b/common/result.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -100,6 +100,8 @@ const char* oe_result_str(oe_result_t result) return "OE_UNSUPPORTED_ENCLAVE_IMAGE"; case OE_VERIFY_CRL_EXPIRED: return "OE_VERIFY_CRL_EXPIRED"; + case OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD: + return "OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD"; case OE_VERIFY_CRL_MISSING: return "OE_VERIFY_CRL_MISSING"; case OE_VERIFY_REVOKED: @@ -118,6 +120,14 @@ const char* oe_result_str(oe_result_t result) return "QE_QUOTE_ENCLAVE_IDENTITY_PRODUCTID_MISMATCH"; case OE_VERIFY_FAILED_AES_CMAC_MISMATCH: return "OE_VERIFY_FAILED_AES_CMAC_MISMATCH"; + case OE_CONTEXT_SWITCHLESS_OCALL_MISSED: + return "OE_CONTEXT_SWITCHLESS_OCALL_MISSED"; + case OE_THREAD_CREATE_ERROR: + return "OE_THREAD_CREATE_ERROR"; + case OE_THREAD_JOIN_ERROR: + return "OE_THREAD_JOIN_ERROR"; + case OE_ALREADY_EXISTS: + return "OE_ALREADY_EXISTS"; case __OE_RESULT_MAX: break; } @@ -171,6 +181,7 @@ bool oe_is_valid_result(uint32_t result) case OE_INVALID_QE_IDENTITY_INFO: case OE_UNSUPPORTED_ENCLAVE_IMAGE: case OE_VERIFY_CRL_EXPIRED: + case OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD: case OE_VERIFY_CRL_MISSING: case OE_VERIFY_REVOKED: case OE_CRYPTO_ERROR: @@ -180,6 +191,10 @@ bool oe_is_valid_result(uint32_t result) case OE_QUOTE_ENCLAVE_IDENTITY_UNIQUEID_MISMATCH: case QE_QUOTE_ENCLAVE_IDENTITY_PRODUCTID_MISMATCH: case OE_VERIFY_FAILED_AES_CMAC_MISMATCH: + case OE_CONTEXT_SWITCHLESS_OCALL_MISSED: + case OE_THREAD_CREATE_ERROR: + case OE_THREAD_JOIN_ERROR: + case OE_ALREADY_EXISTS: { return true; } diff --git a/common/safecrt.c b/common/safecrt.c index 65acf833e1..f145fc5e5c 100644 --- a/common/safecrt.c +++ b/common/safecrt.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/common/sgx/eeid.c b/common/sgx/eeid.c new file mode 100644 index 0000000000..83915c9db3 --- /dev/null +++ b/common/sgx/eeid.c @@ -0,0 +1,116 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include + +#include +#include +#include + +static oe_result_t serialize_elem( + char** p, + size_t* r, + const uint8_t* e, + size_t e_sz) +{ + if (*r < 2 * e_sz + 1) + return OE_BUFFER_TOO_SMALL; + + oe_hex_string(*p, *r, e, e_sz); + *p += 2 * e_sz; + **p = '\n'; + *p += 1; + *r -= 2 * e_sz + 1; + + return OE_OK; +} + +static oe_result_t deserialize_elem( + const char** p, + size_t* r, + uint8_t* e, + size_t e_sz) +{ + if (*r < 2 * e_sz + 2) + return OE_OUT_OF_BOUNDS; + + for (size_t i = 0; i < e_sz; i++) + { + unsigned digit; + if (sscanf(*p, "%02x", &digit) != 1) + return OE_INVALID_PARAMETER; + e[i] = (uint8_t)digit; + *p += 2; + *r -= 2; + } + + if (**p != '\n') + return OE_INVALID_PARAMETER; + + *p += 1; + *r -= 1; + + return OE_OK; +} + +oe_result_t oe_serialize_eeid(const oe_eeid_t* eeid, char* buf, size_t buf_size) +{ + oe_result_t result; + size_t eeid_sz = sizeof(oe_eeid_t) + eeid->data_size; + size_t str_sz = 2 * eeid_sz + 1; + + if (str_sz >= buf_size) + return OE_BUFFER_TOO_SMALL; + + char** p = &buf; + size_t r = buf_size; + + OE_CHECK(serialize_elem( + p, &r, (uint8_t*)eeid->hash_state_H, sizeof(eeid->hash_state_H))); + OE_CHECK(serialize_elem( + p, &r, (uint8_t*)eeid->hash_state_N, sizeof(eeid->hash_state_N))); + OE_CHECK(serialize_elem( + p, &r, (uint8_t*)eeid->sigstruct, sizeof(eeid->sigstruct))); + OE_CHECK(serialize_elem( + p, &r, (uint8_t*)&eeid->size_settings, sizeof(eeid->size_settings))); + OE_CHECK(serialize_elem( + p, &r, (uint8_t*)&eeid->data_size, sizeof(eeid->data_size))); + OE_CHECK(serialize_elem( + p, &r, (uint8_t*)&eeid->data_vaddr, sizeof(eeid->data_vaddr))); + OE_CHECK(serialize_elem(p, &r, (uint8_t*)eeid->data, eeid->data_size)); + + **p = '\0'; + +done: + return OE_OK; +} + +oe_result_t oe_deserialize_eeid( + const char* buf, + size_t buf_size, + oe_eeid_t* eeid) +{ + oe_result_t result; + const char** p = &buf; + size_t r = buf_size; + + memset(eeid, 0, sizeof(oe_eeid_t)); + + OE_CHECK(deserialize_elem( + p, &r, (uint8_t*)eeid->hash_state_H, sizeof(eeid->hash_state_H))); + OE_CHECK(deserialize_elem( + p, &r, (uint8_t*)eeid->hash_state_N, sizeof(eeid->hash_state_N))); + OE_CHECK(deserialize_elem( + p, &r, (uint8_t*)eeid->sigstruct, sizeof(eeid->sigstruct))); + OE_CHECK(deserialize_elem( + p, &r, (uint8_t*)&eeid->size_settings, sizeof(eeid->size_settings))); + OE_CHECK(deserialize_elem( + p, &r, (uint8_t*)&eeid->data_size, sizeof(eeid->data_size))); + OE_CHECK(deserialize_elem( + p, &r, (uint8_t*)&eeid->data_vaddr, sizeof(eeid->data_vaddr))); + OE_CHECK(deserialize_elem(p, &r, (uint8_t*)eeid->data, eeid->data_size)); + +done: + return OE_OK; +} \ No newline at end of file diff --git a/common/sgx/endorsements.c b/common/sgx/endorsements.c new file mode 100644 index 0000000000..0334d0f7a2 --- /dev/null +++ b/common/sgx/endorsements.c @@ -0,0 +1,439 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "endorsements.h" +#include +#include +#include +#include +#include "../common.h" + +#include "qeidentity.h" +#include "quote.h" +#include "revocation.h" + +#define CREATION_DATETIME_SIZE 21 + +/** + * Create oe_endorsements_t from the given SGX endorsements. + * + * @param[in] revocation_info SGX revocation information. + * @param[in] qe_id_info SGX QE identity information. + * @param[out] endorsements OE endorsement structure. + */ +static oe_result_t oe_create_sgx_endorsements( + const oe_get_revocation_info_args_t* revocation_info, + const oe_get_qe_identity_info_args_t* qe_id_info, + oe_endorsements_t** endorsements_buffer, + size_t* endorsements_buffer_size) +{ + oe_result_t result = OE_UNEXPECTED; + oe_endorsements_t* endorsements = NULL; + char creation_datetime[CREATION_DATETIME_SIZE]; + uint32_t* buffer32 = NULL; + uint8_t* buffer = NULL; + uint32_t offset; + uint32_t offsets_size; + uint32_t size; + int i; + uint32_t remaining_size; + + OE_TRACE_INFO("Enter call %s\n", __FUNCTION__); + + if (revocation_info == NULL || qe_id_info == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + if (revocation_info->num_crl_urls != OE_SGX_ENDORSEMENTS_CRL_COUNT) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "Expected %d num CRLs, but got %d", + OE_SGX_ENDORSEMENTS_CRL_COUNT, + revocation_info->num_crl_urls); + + offsets_size = (uint32_t)sizeof(uint32_t) * OE_SGX_ENDORSEMENT_COUNT; + size = (uint32_t)sizeof(oe_endorsements_t) + // Header + offsets_size + // Array of offsets + (uint32_t)( // Data + sizeof(uint32_t) + // Version + revocation_info->tcb_info_size + + revocation_info->tcb_issuer_chain_size + + qe_id_info->qe_id_info_size + qe_id_info->issuer_chain_size); + + for (i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; i++) + { + size += (uint32_t)revocation_info->crl_size[i]; + size += (uint32_t)revocation_info->crl_issuer_chain_size[i]; + } + + size += CREATION_DATETIME_SIZE; + if (size > OE_ATTESTATION_ENDORSEMENT_MAX_SIZE) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "SGX endorsements are too large. Size is %d bytes", + size); + + // Allocate memory + endorsements = (oe_endorsements_t*)oe_calloc(1, size); + if (endorsements == NULL) + OE_RAISE_MSG( + OE_OUT_OF_MEMORY, + "Out of memory while creating endorsements.", + NULL); + + remaining_size = size; + + // Record creation datetime. + { + oe_datetime_t datetime_now = {0}; + size_t datetime_size = CREATION_DATETIME_SIZE; + + OE_CHECK(oe_datetime_now(&datetime_now)); + + OE_CHECK_MSG( + oe_datetime_to_string( + &datetime_now, creation_datetime, &datetime_size), + "Failed to update endorsement creation time. %s", + oe_result_str(result)); + } + + // Initialize header + endorsements->version = OE_ATTESTATION_ENDORSEMENT_VERSION; + endorsements->enclave_type = OE_ENCLAVE_TYPE_SGX; + endorsements->num_elements = OE_SGX_ENDORSEMENT_COUNT; + endorsements->buffer_size = size - (uint32_t)sizeof(oe_endorsements_t); + buffer32 = (uint32_t*)&endorsements->buffer[0]; + + // Set offsets + offset = 0; + buffer32[OE_SGX_ENDORSEMENT_FIELD_VERSION] = offset; + offset += (uint32_t)sizeof(uint32_t); + buffer32[OE_SGX_ENDORSEMENT_FIELD_TCB_INFO] = offset; + offset += (uint32_t)revocation_info->tcb_info_size; + buffer32[OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN] = offset; + offset += (uint32_t)revocation_info->tcb_issuer_chain_size; + for (i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; i++) + { + buffer32[OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT + i] = offset; + offset += (uint32_t)revocation_info->crl_size[i]; + } + for (i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; i++) + { + buffer32[OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT + i] = + offset; + offset += (uint32_t)revocation_info->crl_issuer_chain_size[i]; + } + buffer32[OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO] = offset; + offset += (uint32_t)qe_id_info->qe_id_info_size; + buffer32[OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN] = offset; + offset += (uint32_t)qe_id_info->issuer_chain_size; + buffer32[OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME] = offset; + offset += CREATION_DATETIME_SIZE; + + // Sanity check + if (offset != (endorsements->buffer_size - offsets_size)) + OE_RAISE_MSG( + OE_FAILURE, + "Encountered size mismatch when creating SGX endorsements. " + "data size: %d bytes, expected: %d", + offset, + (endorsements->buffer_size - offsets_size)); + + OE_TRACE_INFO( + "SGX endorsements. Header size: %d, offsets size: %d, data size: %d", + sizeof(oe_endorsements_t), + offsets_size, + offset); + + // Set version + buffer = (uint8_t*)&buffer32[OE_SGX_ENDORSEMENT_COUNT]; + *((uint32_t*)buffer) = OE_SGX_ENDORSEMENTS_VERSION; + buffer += sizeof(uint32_t); + remaining_size = + size - (uint32_t)((uint8_t*)buffer - (uint8_t*)endorsements); + + // Copy TCB Info + OE_CHECK(oe_memcpy_s( + buffer, + remaining_size, + revocation_info->tcb_info, + revocation_info->tcb_info_size)); + buffer += revocation_info->tcb_info_size; + remaining_size -= (uint32_t)revocation_info->tcb_info_size; + + // Copy TCB Issuer Chain + OE_CHECK(oe_memcpy_s( + buffer, + remaining_size, + revocation_info->tcb_issuer_chain, + revocation_info->tcb_issuer_chain_size)); + buffer += revocation_info->tcb_issuer_chain_size; + remaining_size -= (uint32_t)revocation_info->tcb_issuer_chain_size; + + // Copy CRLs + for (i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; i++) + { + OE_CHECK(oe_memcpy_s( + buffer, + remaining_size, + revocation_info->crl[i], + revocation_info->crl_size[i])); + buffer += revocation_info->crl_size[i]; + remaining_size -= (uint32_t)revocation_info->crl_size[i]; + } + + // Copy CRLs Issuer Chain + for (i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; i++) + { + OE_CHECK(oe_memcpy_s( + buffer, + remaining_size, + revocation_info->crl_issuer_chain[i], + revocation_info->crl_issuer_chain_size[i])); + buffer += revocation_info->crl_issuer_chain_size[i]; + remaining_size -= (uint32_t)revocation_info->crl_issuer_chain_size[i]; + } + + // Copy QE ID Info + OE_CHECK(oe_memcpy_s( + buffer, + remaining_size, + qe_id_info->qe_id_info, + qe_id_info->qe_id_info_size)); + buffer += qe_id_info->qe_id_info_size; + remaining_size -= (uint32_t)qe_id_info->qe_id_info_size; + + // Copy QE ID Issue Chain + OE_CHECK(oe_memcpy_s( + buffer, + remaining_size, + qe_id_info->issuer_chain, + qe_id_info->issuer_chain_size)); + buffer += qe_id_info->issuer_chain_size; + remaining_size -= (uint32_t)qe_id_info->issuer_chain_size; + + // Copy creation datetime + OE_CHECK(oe_memcpy_s( + buffer, remaining_size, creation_datetime, CREATION_DATETIME_SIZE)); + buffer += CREATION_DATETIME_SIZE; + + // Sanity check + if (buffer != (endorsements->buffer + endorsements->buffer_size)) + OE_RAISE_MSG( + OE_FAILURE, + "Encountered size mismatch when creating SGX endorsements. " + "end of data section: 0x%x bytes, expected: 0x%x", + buffer, + (endorsements->buffer + endorsements->buffer_size)); + + *endorsements_buffer = endorsements; + *endorsements_buffer_size = size; + + result = OE_OK; + +done: + if ((result != OE_OK) && endorsements) + oe_free(endorsements); + + OE_TRACE_INFO( + "Exit call %s: %d(%s)\n", __FUNCTION__, result, oe_result_str(result)); + + return result; +} + +/** + * Converts an oe_endorsement_t structure to a SGX endorsement structure + * (oe_sgx_endorsements_t). + * + * @param[in] endorsements The endorsements in raw format (oe_endorsements_t) + * @param[out] sgx_endorsements The parsed SGX endorsements. + */ +oe_result_t oe_parse_sgx_endorsements( + const oe_endorsements_t* endorsements, + const size_t endorsements_size, + oe_sgx_endorsements_t* sgx_endorsements) +{ + oe_result_t result = OE_UNEXPECTED; + uint32_t* offsets = NULL; + uint32_t offsets_size = 0; + uint8_t* data_ptr_start = NULL; + uint32_t data_size; + uint32_t version = 0; + + if (endorsements == NULL || sgx_endorsements == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + // Verify version and enclave type + if ((endorsements->version != OE_ATTESTATION_ENDORSEMENT_VERSION) || + (endorsements->enclave_type != OE_ENCLAVE_TYPE_SGX)) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "Failed to parse SGX endorsement. Invalid version or enclave " + "type.", + NULL); + + if (endorsements->num_elements != OE_SGX_ENDORSEMENT_COUNT) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "Failed to parse SGX endorsement. Exepected %d items, but got %d.", + OE_SGX_ENDORSEMENT_COUNT, + endorsements->num_elements); + + offsets_size = endorsements->num_elements * (uint32_t)sizeof(uint32_t); + if (endorsements_size > OE_ATTESTATION_ENDORSEMENT_MAX_SIZE || + endorsements->buffer_size > endorsements_size || + endorsements->buffer_size <= offsets_size) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, "Endorsement buffer size is invalid.", NULL); + + data_size = endorsements->buffer_size - offsets_size; + offsets = (uint32_t*)endorsements->buffer; + data_ptr_start = (uint8_t*)(endorsements->buffer + offsets_size); + + memset(sgx_endorsements, 0, sizeof(oe_sgx_endorsements_t)); + + version = *((uint32_t*)data_ptr_start); + if (version != OE_SGX_ENDORSEMENTS_VERSION) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "Unexpected SGX endorsement version %d, expected %d", + version, + OE_SGX_ENDORSEMENTS_VERSION); + + OE_TRACE_INFO("SGX Version: %d", version); + for (int i = 0; i < OE_SGX_ENDORSEMENT_COUNT; i++) + { + uint8_t* item_ptr = data_ptr_start + offsets[i]; + uint32_t item_size; + + if (offsets[i] >= endorsements->buffer_size) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "Offset value when creating SGX endorsement is incorrect.", + NULL); + + if (i < OE_SGX_ENDORSEMENT_COUNT - 1) + item_size = offsets[i + 1] - offsets[i]; + else + item_size = data_size - offsets[i]; + + sgx_endorsements->items[i].data = item_ptr; + sgx_endorsements->items[i].size = item_size; + + OE_TRACE_VERBOSE( + "SGX endorsement %d, size(%d): %s\n", i, item_size, item_ptr); + } + + result = OE_OK; +done: + + return result; +} + +oe_result_t oe_get_sgx_endorsements( + const uint8_t* remote_report, + size_t remote_report_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size) +{ + oe_result_t result = OE_UNEXPECTED; + oe_get_qe_identity_info_args_t qe_id_info = {0}; + oe_get_revocation_info_args_t revocation_info = {0}; + + const uint8_t* pem_pck_certificate = NULL; + size_t pem_pck_certificate_size = 0; + oe_cert_chain_t pck_cert_chain = {0}; + oe_cert_t leaf_cert = {0}; + oe_cert_t intermediate_cert = {0}; + + OE_TRACE_INFO("Enter call %s\n", __FUNCTION__); + + if ((endorsements_buffer == NULL) || (endorsements_buffer_size == NULL)) + { + OE_RAISE(OE_INVALID_PARAMETER); + } + + *endorsements_buffer = NULL; + *endorsements_buffer_size = 0; + + // + // Get the uri from the quote certificates, and then get the + // CRL (oe_get_revocation_info_from_certs) + // + + // Get PCK cert chain from the quote. + OE_CHECK_MSG( + oe_get_quote_cert_chain_internal( + remote_report, + remote_report_size, + &pem_pck_certificate, + &pem_pck_certificate_size, + &pck_cert_chain), + "Failed to get certificate chain from quote. %s", + oe_result_str(result)); + + // Fetch leaf and intermediate certificates. + OE_CHECK_MSG( + oe_cert_chain_get_leaf_cert(&pck_cert_chain, &leaf_cert), + "Failed to get leaf certificate. %s", + oe_result_str(result)); + OE_CHECK_MSG( + oe_cert_chain_get_cert(&pck_cert_chain, 1, &intermediate_cert), + "Failed to get intermediate certificate. %s", + oe_result_str(result)); + + // + // Get revocation information + // + OE_CHECK_MSG( + oe_get_revocation_info_from_certs( + &leaf_cert, &intermediate_cert, &revocation_info), + "Failed to get certificate revocation information. %s", + oe_result_str(result)); + + // + // Get QE identify info + // + OE_CHECK_MSG( + oe_get_qe_identity_info(&qe_id_info), + "Failed to get quote enclave identity information. %s", + oe_result_str(result)); + + // + // Create endorsement structure + // + OE_CHECK_MSG( + oe_create_sgx_endorsements( + &revocation_info, + &qe_id_info, + (oe_endorsements_t**)endorsements_buffer, + endorsements_buffer_size), + "Failed to create SGX endorsements.", + oe_result_str(result)); + + result = OE_OK; + +done: + oe_cert_free(&leaf_cert); + oe_cert_free(&intermediate_cert); + oe_cert_chain_free(&pck_cert_chain); + oe_free_get_revocation_info_args(&revocation_info); + oe_free_qe_identity_info_args(&qe_id_info); + + OE_TRACE_INFO( + "Exit call %s: %d(%s)\n", __FUNCTION__, result, oe_result_str(result)); + + return result; +} + +/** + * Free up any resources allocated by oe_get_sgx_endorsements() + * + * @param endorsements_buffer The buffer containing the endorsements. + */ +void oe_free_sgx_endorsements(uint8_t* endorsements_buffer) +{ + if (endorsements_buffer) + { + oe_free(endorsements_buffer); + } +} diff --git a/common/sgx/endorsements.h b/common/sgx/endorsements.h new file mode 100644 index 0000000000..aa4f7b28c1 --- /dev/null +++ b/common/sgx/endorsements.h @@ -0,0 +1,115 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_COMMON_OE_ENDORSEMENTS_H +#define _OE_COMMON_OE_ENDORSEMENTS_H + +#include +#include +#include + +OE_EXTERNC_BEGIN + +/*! \struct SGX endorsement item + */ +typedef struct _oe_sgx_endorsement_item +{ + uint8_t* data; + uint32_t size; +} oe_sgx_endorsement_item; + +/*! \struct oe_sgx_endorsements + * + * \brief SGX endorsements structure + * + * The generic oe_endorsements_t structure is parsed and converted into this + * internal structure. The order of the generic data elements should + * coincide with the order of the fields in this structure. + * + * Data format: All data comes from the Data Center Attestation Primitives(DCAP) + * Client. + * + * For Azure DCAP Client + * (https://github.com/microsoft/Azure-DCAP-Client/blob/master/src/dcap_provider.h) + * see **sgx_ql_revocation_info_t** and sgx_qe_identity_info_t. + * + * For Intel DCAP Client + * (https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/master/README.md) + * see TBD. + * + */ +typedef struct _oe_sgx_endorsements_t +{ + ///< OE_SGX_ENDORSEMENT_FIELD_VERSION + ///< Version of this SGX endorsement structure + + ///< OE_SGX_ENDORSEMENT_FIELD_TCB_INFO + ///< TCB info, null-terminated JSON string + ///< TCB Info size + ///< OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN + ///< PEM format, null-terminated string + ///< Size of the tcb_issuer_chain + + ///< OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT to + ///< OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_PROC_CA + ///< CRLs in DER format, null-terminated + ///< crl[0] = CRL for the SGX PCK Certificate + ///< crl[1] = CRL for the SGX PCK Processor CA + + ///< OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT to + ///< OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_PROC_CA + ///< CRLs issuer chains in PEM format, null-terminated string + ///< crl[0] = Issuer Chain for the SGX PCK Certificate + ///< crl[1] = CRL for the SGX PCK Processor CA + + ///< OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO + ///< QE Identity info, null-terminated JSON string + ///< QE Identity size + ///< OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN + ///< PEM format, null-terminated string + ///< Size of qe_id_issuer_chain + + ///< OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME + ///< Time the endorsements were generated, null-terminated string + ///< The size of creation_datetime. + oe_sgx_endorsement_item items[OE_SGX_ENDORSEMENT_COUNT]; + +} oe_sgx_endorsements_t; + +/** + * Convert a oe_endorsement_t structure to a SGX endorsement structure + * (oe_sgx_endorsements_t). + * + * @param[in] endorsements The endorsements in raw format (oe_endorsements_t) + * @param[in] endorsements_size The size of the **endorsements** + * @param[out] sgx_endorsements The parsed SGX endorsements. + */ +oe_result_t oe_parse_sgx_endorsements( + const oe_endorsements_t* endorsements, + const size_t endorsements_size, + oe_sgx_endorsements_t* sgx_endorsements); + +/** + * Get the endorsements for the respective SGX remote report. + * + * @param[in] remote_report The remote report. + * @param[in] remote_report_size The size of the remote report. + * @param[out] endorsements_buffer The buffer where to store the endorsements. + * @param[out] endorsements_buffer_size The size of the endorsements. + */ +oe_result_t oe_get_sgx_endorsements( + const uint8_t* remote_report, + size_t remote_report_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size); + +/** + * Free up any resources allocated by oe_get_sgx_endorsements() + * + * @param[in] endorsements_buffer The buffer containing the endorsements. + */ +void oe_free_sgx_endorsements(uint8_t* endorsements_buffer); + +OE_EXTERNC_END + +#endif /* _OE_COMMON_OE_ENDORSEMENTS_H */ diff --git a/common/sgx/qeidentity.c b/common/sgx/qeidentity.c index 8d5876b730..b514684396 100644 --- a/common/sgx/qeidentity.c +++ b/common/sgx/qeidentity.c @@ -1,29 +1,19 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "qeidentity.h" +#include #include #include #include "../common.h" #include "tcbinfo.h" -// hardcoded property values used for validating quoting enclave when qe -// identity info is not available -// The mrsigner value of Intel's Production quoting enclave. -static const uint8_t g_qe_mrsigner[32] = { - 0x8c, 0x4f, 0x57, 0x75, 0xd7, 0x96, 0x50, 0x3e, 0x96, 0x13, 0x7f, - 0x77, 0xc6, 0x8a, 0x82, 0x9a, 0x00, 0x56, 0xac, 0x8d, 0xed, 0x70, - 0x14, 0x0b, 0x08, 0x1b, 0x09, 0x44, 0x90, 0xc5, 0x7b, 0xff}; - -// The isvprodid value of Intel's Production quoting enclave. -static const uint16_t g_qe_isvprodid = 1; - -// The isvsvn value of Intel's Production quoting enclave. -static const uint32_t g_qeisvsvn = 2; - extern oe_datetime_t _sgx_minimim_crl_tcb_issue_date; -void dump_info(const char* title, const uint8_t* data, const uint8_t count) +static void dump_info( + const char* title, + const uint8_t* data, + const uint8_t count) { OE_TRACE_INFO("%s\n", title); for (uint8_t i = 0; i < count; i++) @@ -32,84 +22,55 @@ void dump_info(const char* title, const uint8_t* data, const uint8_t count) } } -oe_result_t oe_enforce_qe_identity(sgx_report_body_t* qe_report_body) +oe_result_t oe_validate_qe_identity( + const sgx_report_body_t* qe_report_body, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* validity_from, + oe_datetime_t* validity_until) { oe_result_t result = OE_FAILURE; - oe_get_qe_identity_info_args_t qe_id_args = {0}; const uint8_t* pem_pck_certificate = NULL; size_t pem_pck_certificate_size = 0; oe_cert_chain_t pck_cert_chain = {0}; + oe_cert_t leaf_cert = {0}; oe_parsed_qe_identity_info_t parsed_info = {0}; + oe_qe_identity_info_tcb_level_t platform_tcb_level = {{0}}; + oe_datetime_t from = {0}; + oe_datetime_t until = {0}; OE_TRACE_INFO("Calling %s\n", __FUNCTION__); - // fetch qe identity information - result = oe_get_qe_identity_info(&qe_id_args); - if (result == OE_QUOTE_PROVIDER_CALL_ERROR) - { - // No qe_identity info returned from the quote provider, this could be - // because either get_qe_identity_info API was not supported or - // unexpected error. In both cases, check against hardcoded quoting - // enclave properties instead Assert that the qe report's MRSIGNER - // matches Intel's quoting. We will remove these hardcoded values once - // the libdcap_quoteprov.so was updated to support qe identity feature. - - // enclave's mrsigner. - if (!oe_constant_time_mem_equal( - qe_report_body->mrsigner, g_qe_mrsigner, sizeof(g_qe_mrsigner))) - { - dump_info( - "Expected mrsigner", g_qe_mrsigner, sizeof(g_qe_mrsigner)); - dump_info( - "Actual mrsigner", - qe_report_body->mrsigner, - sizeof(qe_report_body->mrsigner)); - OE_RAISE_MSG( - OE_QUOTE_ENCLAVE_IDENTITY_UNIQUEID_MISMATCH, - "mrsigner mismatch", - NULL); - } - - if (qe_report_body->isvprodid != g_qe_isvprodid) - OE_RAISE_MSG( - QE_QUOTE_ENCLAVE_IDENTITY_PRODUCTID_MISMATCH, - "isvprodid mismatch. Expected 0x%04X, actual 0x%04X", - g_qe_isvprodid, - qe_report_body->isvprodid); - - if (qe_report_body->isvsvn < g_qeisvsvn) - OE_RAISE_MSG( - OE_QUOTE_ENCLAVE_IDENTITY_VERIFICATION_FAILED, - "isvsvn is out-of-date. Required SVN 0x%08X, actual SVN 0x%08X", - g_qeisvsvn, - qe_report_body->isvsvn); - - // Ensure that the QE is not a debug supporting enclave. - if (qe_report_body->attributes.flags & SGX_FLAGS_DEBUG) - OE_RAISE_MSG( - OE_QUOTE_ENCLAVE_IDENTITY_VERIFICATION_FAILED, - "QE has SGX_FLAGS_DEBUG set!!", - NULL); - - result = OE_OK; - goto done; - } - OE_CHECK(result); + if ((sgx_endorsements == NULL) || (validity_from == NULL) || + (validity_until == NULL)) + OE_RAISE(OE_INVALID_PARAMETER); // Use QE Identity info to validate QE // Check against fetched qe identityinfo - OE_TRACE_INFO("qe_identity.issuer_chain:[%s]\n", qe_id_args.issuer_chain); - pem_pck_certificate = qe_id_args.issuer_chain; - pem_pck_certificate_size = qe_id_args.issuer_chain_size; + OE_TRACE_INFO( + "qe_identity.issuer_chain:[%s]\n", + (const char*)sgx_endorsements + ->items[OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN] + .data); + pem_pck_certificate = + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN] + .data; + pem_pck_certificate_size = + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN] + .size; // validate the cert chain. OE_CHECK(oe_cert_chain_read_pem( &pck_cert_chain, pem_pck_certificate, pem_pck_certificate_size)); // parse identity info json blob - OE_TRACE_INFO("*qe_identity.qe_id_info:[%s]\n", qe_id_args.qe_id_info); + OE_TRACE_INFO( + "*qe_identity.qe_id_info:[%s]\n", + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO].data); OE_CHECK(oe_parse_qe_identity_info_json( - qe_id_args.qe_id_info, qe_id_args.qe_id_info_size, &parsed_info)); + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO].data, + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO].size, + &platform_tcb_level, + &parsed_info)); // verify qe identity signature OE_TRACE_INFO("Calling oe_verify_ecdsa256_signature\n"); @@ -120,15 +81,36 @@ oe_result_t oe_enforce_qe_identity(sgx_report_body_t* qe_report_body) &pck_cert_chain)); OE_TRACE_INFO("oe_verify_ecdsa256_signature succeeded\n"); + // Get leaf certificate + OE_CHECK_MSG( + oe_cert_chain_get_leaf_cert(&pck_cert_chain, &leaf_cert), + "Failed to get leaf certificate. %s", + oe_result_str(result)); + OE_CHECK_MSG( + oe_cert_get_validity_dates(&leaf_cert, &from, &until), + "Failed to get validity dates from cert. %s", + oe_result_str(result)); + + oe_datetime_log("QE identity cert issue date: ", &from); + oe_datetime_log("QE identity cert next update: ", &until); + // Check that issue_date and next_update are after the earliest date that // the enclave accepts. if (oe_datetime_compare( - &parsed_info.issue_date, &_sgx_minimim_crl_tcb_issue_date) != 1) - OE_RAISE(OE_INVALID_QE_IDENTITY_INFO); + &parsed_info.issue_date, &_sgx_minimim_crl_tcb_issue_date) < 0) + OE_RAISE_MSG( + OE_INVALID_QE_IDENTITY_INFO, + "QE identity info issue date does not meet CRL/TCB minimum issue " + "date.", + NULL); if (oe_datetime_compare( - &parsed_info.next_update, &_sgx_minimim_crl_tcb_issue_date) != 1) - OE_RAISE(OE_INVALID_QE_IDENTITY_INFO); + &parsed_info.next_update, &_sgx_minimim_crl_tcb_issue_date) < 0) + OE_RAISE_MSG( + OE_INVALID_QE_IDENTITY_INFO, + "QE identity info next update does not meet CRL/TCB minimum issue " + "date.", + NULL); // Assert that the qe report's MRSIGNER matches Intel's quoting enclave's // mrsigner. @@ -195,11 +177,36 @@ oe_result_t oe_enforce_qe_identity(sgx_report_body_t* qe_report_body) parsed_info.attributes_xfrm_mask, parsed_info.attributes.xfrm); - oe_cleanup_qe_identity_info_args(&qe_id_args); + if (qe_report_body->attributes.flags & SGX_FLAGS_DEBUG) + OE_RAISE_MSG( + OE_QUOTE_ENCLAVE_IDENTITY_VERIFICATION_FAILED, + "QE has SGX_FLAGS_DEBUG set!!", + NULL); + + if (oe_datetime_compare(&parsed_info.issue_date, &from) > 0) + from = parsed_info.issue_date; + if (oe_datetime_compare(&parsed_info.next_update, &until) < 0) + until = parsed_info.next_update; + + oe_datetime_log("QE identity issue date: ", &parsed_info.issue_date); + oe_datetime_log("QE identity next update date: ", &parsed_info.next_update); + oe_datetime_log("QE identity overall issue date: ", &from); + oe_datetime_log("QE identity overall next update: ", &until); + if (oe_datetime_compare(&from, &until) > 0) + OE_RAISE_MSG( + OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD, + "Failed to find an overall QE identity validity period.", + NULL); + + *validity_from = from; + *validity_until = until; + result = OE_OK; done: if (pck_cert_chain.impl[0] != 0) oe_cert_chain_free(&pck_cert_chain); + oe_cert_free(&leaf_cert); + return result; } diff --git a/common/sgx/qeidentity.h b/common/sgx/qeidentity.h index ef4ad7970a..4221200f52 100644 --- a/common/sgx/qeidentity.h +++ b/common/sgx/qeidentity.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMON_QE_IDENTITY_H @@ -9,18 +9,38 @@ #include #include #include +#include "endorsements.h" OE_EXTERNC_BEGIN -oe_result_t oe_enforce_qe_identity(sgx_report_body_t* qe_report_body); - -// Fetch qe identity info using the specified args structure. +/** + * Validate the QE identity information. Returns the validity time range + * for the caller to validate. + * + * @param[in] qe_report_body The QE report body from the quote. + * @param[in] qe_id_args The QE identity info. + * @param[out] validity_from The date from which the QE identity info is valid. + * @param[out] validity_until The date which the QE identity info expires. + */ +oe_result_t oe_validate_qe_identity( + const sgx_report_body_t* qe_report_body, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* validity_from, + oe_datetime_t* validity_until); + +/** + * Fetch qe identity info using the specified args structure. + * + * @param[out] args The QE identity info structure. + */ oe_result_t oe_get_qe_identity_info(oe_get_qe_identity_info_args_t* args); -// Cleanup the args structure. -void oe_cleanup_qe_identity_info_args(oe_get_qe_identity_info_args_t* args); - -void dump_info(const char* title, const uint8_t* data, const uint8_t count); +/** + * Cleanup the args structure. + * + * @param[int] args The QE identity info structure. + */ +void oe_free_qe_identity_info_args(oe_get_qe_identity_info_args_t* args); OE_EXTERNC_END diff --git a/common/sgx/quote.c b/common/sgx/quote.c index 7fd01324ec..dd881c0ba3 100644 --- a/common/sgx/quote.c +++ b/common/sgx/quote.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "quote.h" #include @@ -9,9 +9,12 @@ #include #include #include "../common.h" +#include "endorsements.h" #include "qeidentity.h" #include "revocation.h" +#include + // Public key of Intel's root certificate. static const char* g_expected_root_certificate_key = "-----BEGIN PUBLIC KEY-----\n" @@ -29,6 +32,49 @@ OE_INLINE uint32_t ReadUint32(const uint8_t* p) return (uint32_t)(p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24)); } +static oe_result_t _validate_sgx_quote(const sgx_quote_t* sgx_quote) +{ + oe_result_t result = OE_OK; + + if (sgx_quote->version != OE_SGX_QUOTE_VERSION) + { + OE_RAISE_MSG( + OE_QUOTE_VERIFICATION_ERROR, + "Unexpected quote version sgx_quote->version=%d", + sgx_quote->version); + } + +done: + return result; +} + +static oe_result_t _validate_qe_cert_data( + const sgx_qe_cert_data_t* qe_cert_data) +{ + oe_result_t result = OE_OK; + + // The certificate provided in the quote is preferred. + if (qe_cert_data->type != OE_SGX_PCK_ID_PCK_CERT_CHAIN) + OE_RAISE_MSG( + OE_MISSING_CERTIFICATE_CHAIN, + "Unexpected certificate type (qe_cert_data->type=%d)", + qe_cert_data->type); + + if (qe_cert_data->size == 0) + OE_RAISE_MSG( + OE_QUOTE_VERIFICATION_ERROR, + "Quoting enclave certificate data is empty.", + NULL); + + if (qe_cert_data->data == NULL) + OE_RAISE_MSG( + OE_MISSING_CERTIFICATE_CHAIN, + "No PCK certificate found in SGX quote.", + NULL); +done: + return result; +} + static oe_result_t _parse_quote( const uint8_t* quote, size_t quote_size, @@ -43,20 +89,27 @@ static oe_result_t _parse_quote( const uint8_t* const quote_end = quote + quote_size; if (quote_end < p) - { // Pointer wrapped around. - OE_RAISE(OE_REPORT_PARSE_ERROR); - } + OE_RAISE_MSG( + OE_REPORT_PARSE_ERROR, + "Parsing error. Pointer wrapper around.", + NULL); *sgx_quote = NULL; *sgx_quote = (sgx_quote_t*)p; p += sizeof(sgx_quote_t); if (p > quote_end) - OE_RAISE(OE_REPORT_PARSE_ERROR); + OE_RAISE_MSG( + OE_REPORT_PARSE_ERROR, + "Parse error after parsing SGX quote, before signature.", + NULL); if (p + (*sgx_quote)->signature_len != quote_end) - OE_RAISE(OE_REPORT_PARSE_ERROR); + OE_RAISE_MSG( + OE_REPORT_PARSE_ERROR, + "Parse error after parsing SGX signature.", + NULL); *quote_auth_data = (sgx_quote_auth_data_t*)(*sgx_quote)->signature; p += sizeof(sgx_quote_auth_data_t); @@ -67,7 +120,10 @@ static oe_result_t _parse_quote( p += qe_auth_data->size; if (p > quote_end) - OE_RAISE(OE_REPORT_PARSE_ERROR); + OE_RAISE_MSG( + OE_REPORT_PARSE_ERROR, + "Parse error after parsing QE authorization data.", + NULL); qe_cert_data->type = ReadUint16(p); p += 2; @@ -77,7 +133,21 @@ static oe_result_t _parse_quote( p += qe_cert_data->size; if (p != quote_end) - OE_RAISE(OE_REPORT_PARSE_ERROR); + OE_RAISE_MSG( + OE_REPORT_PARSE_ERROR, + "Unexpected quote length while parsing.", + NULL); + + // + // Validation + // + OE_CHECK_MSG( + _validate_sgx_quote(*sgx_quote), "SGX quote validation failed.", NULL); + + OE_CHECK_MSG( + _validate_qe_cert_data(qe_cert_data), + "Failed to validate QE certificate data.", + NULL); result = OE_OK; done: @@ -134,15 +204,9 @@ static oe_result_t _ecdsa_verify( return result; } -oe_result_t oe_verify_quote_internal( +static oe_result_t oe_verify_quote_internal( const uint8_t* quote, - size_t quote_size, - const uint8_t* pem_pck_certificate, - size_t pem_pck_certificate_size, - const uint8_t* pck_crl, - size_t pck_crl_size, - const uint8_t* tcb_info_json, - size_t tcb_info_json_size) + size_t quote_size) { oe_result_t result = OE_UNEXPECTED; sgx_quote_t* sgx_quote = NULL; @@ -161,84 +225,83 @@ oe_result_t oe_verify_quote_internal( oe_ec_public_key_t expected_root_public_key = {0}; bool key_equal = false; - OE_UNUSED(pck_crl); - OE_UNUSED(pck_crl_size); - OE_UNUSED(tcb_info_json); - OE_UNUSED(tcb_info_json_size); - - OE_CHECK(_parse_quote( - quote, - quote_size, - &sgx_quote, - "e_auth_data, - &qe_auth_data, - &qe_cert_data)); + uint8_t* pem_pck_certificate = NULL; + size_t pem_pck_certificate_size = 0; - if (sgx_quote->version != OE_SGX_QUOTE_VERSION) - { - OE_RAISE_MSG( - OE_QUOTE_VERIFICATION_ERROR, - "Unexpected quote version sgx_quote->version=%d", - sgx_quote->version); - } - - // The certificate provided in the quote is preferred. - if (qe_cert_data.type == OE_SGX_PCK_ID_PCK_CERT_CHAIN) - { - if (qe_cert_data.size == 0) - OE_RAISE(OE_QUOTE_VERIFICATION_ERROR); - pem_pck_certificate = qe_cert_data.data; - pem_pck_certificate_size = qe_cert_data.size; - } - else - { - OE_RAISE_MSG( - OE_MISSING_CERTIFICATE_CHAIN, - "Unexpected certificate type (qe_cert_data.type=%d)", - qe_cert_data.type); - } - - if (pem_pck_certificate == NULL) - OE_RAISE_MSG( - OE_MISSING_CERTIFICATE_CHAIN, "No certificate found", NULL); + OE_CHECK_MSG( + _parse_quote( + quote, + quote_size, + &sgx_quote, + "e_auth_data, + &qe_auth_data, + &qe_cert_data), + "Failed to parse quote. %s", + oe_result_str(result)); + + pem_pck_certificate = qe_cert_data.data; + pem_pck_certificate_size = qe_cert_data.size; // PckCertificate Chain validations. { // Read and validate the chain. - OE_CHECK(oe_cert_chain_read_pem( - &pck_cert_chain, pem_pck_certificate, pem_pck_certificate_size)); + OE_CHECK_MSG( + oe_cert_chain_read_pem( + &pck_cert_chain, pem_pck_certificate, pem_pck_certificate_size), + "Failed to parse certificate chain.", + NULL); // Fetch leaf and root certificates. - OE_CHECK(oe_cert_chain_get_leaf_cert(&pck_cert_chain, &leaf_cert)); - OE_CHECK(oe_cert_chain_get_root_cert(&pck_cert_chain, &root_cert)); - OE_CHECK( - oe_cert_chain_get_cert(&pck_cert_chain, 1, &intermediate_cert)); + OE_CHECK_MSG( + oe_cert_chain_get_leaf_cert(&pck_cert_chain, &leaf_cert), + "Failed to get leaf certificate.", + NULL); + OE_CHECK_MSG( + oe_cert_chain_get_root_cert(&pck_cert_chain, &root_cert), + "Failed to get root certificate.", + NULL); + OE_CHECK_MSG( + oe_cert_chain_get_cert(&pck_cert_chain, 1, &intermediate_cert), + "Failed to get intermediate certificate.", + NULL); - OE_CHECK(oe_cert_get_ec_public_key(&leaf_cert, &leaf_public_key)); - OE_CHECK(oe_cert_get_ec_public_key(&root_cert, &root_public_key)); + // Get public keys. + OE_CHECK_MSG( + oe_cert_get_ec_public_key(&leaf_cert, &leaf_public_key), + "Failed to get leaf cert public key.", + NULL); + OE_CHECK_MSG( + oe_cert_get_ec_public_key(&root_cert, &root_public_key), + "Failed to get root cert public key.", + NULL); // Ensure that the root certificate matches root of trust. - OE_CHECK(oe_ec_public_key_read_pem( - &expected_root_public_key, - (const uint8_t*)g_expected_root_certificate_key, - oe_strlen(g_expected_root_certificate_key) + 1)); - - OE_CHECK(oe_ec_public_key_equal( - &root_public_key, &expected_root_public_key, &key_equal)); - if (!key_equal) - OE_RAISE(OE_QUOTE_VERIFICATION_ERROR); - OE_CHECK_MSG( - oe_enforce_revocation( - &leaf_cert, &intermediate_cert, &pck_cert_chain), - "enforcing CRL", + oe_ec_public_key_read_pem( + &expected_root_public_key, + (const uint8_t*)g_expected_root_certificate_key, + oe_strlen(g_expected_root_certificate_key) + 1), + "Failed to read expected root cert key.", + NULL); + OE_CHECK_MSG( + oe_ec_public_key_equal( + &root_public_key, &expected_root_public_key, &key_equal), + "Failed to compare keys.", NULL); + if (!key_equal) + OE_RAISE_MSG( + OE_QUOTE_VERIFICATION_ERROR, + "Failed to verify root public key.", + NULL); } // Quote validations. { // Verify SHA256 ECDSA (qe_report_body_signature, qe_report_body, // PckCertificate.pub_key) + // + // Hash with PCK(QE report body) == QE report body signature + // OE_CHECK_MSG( _ecdsa_verify( &leaf_public_key, @@ -257,23 +320,26 @@ oe_result_t oe_verify_quote_internal( (const uint8_t*)"e_auth_data->attestation_key, sizeof(quote_auth_data->attestation_key))); if (qe_auth_data.size > 0) - { OE_CHECK(oe_sha256_update( &sha256_ctx, qe_auth_data.data, qe_auth_data.size)); - } OE_CHECK(oe_sha256_final(&sha256_ctx, &sha256)); if (!oe_constant_time_mem_equal( &sha256, "e_auth_data->qe_report_body.report_data, sizeof(sha256))) - OE_RAISE(OE_QUOTE_VERIFICATION_ERROR); + OE_RAISE_MSG( + OE_QUOTE_VERIFICATION_ERROR, + "QE authentication data signature verification failed.", + NULL); // Verify SHA256 ECDSA (attestation_key, SGX_QUOTE_SIGNED_DATA, // signature) + // + // Hash with attestation_key(sgx_quote) == quote_auth_data signature + // OE_CHECK(_read_public_key( "e_auth_data->attestation_key, &attestation_key)); - OE_CHECK_MSG( _ecdsa_verify( &attestation_key, @@ -284,11 +350,6 @@ oe_result_t oe_verify_quote_internal( NULL); } - // Quoting Enclave validations. - OE_CHECK_MSG( - oe_enforce_qe_identity("e_auth_data->qe_report_body), - "Quoting enclave identity checking", - NULL); result = OE_OK; done: @@ -302,3 +363,318 @@ oe_result_t oe_verify_quote_internal( oe_cert_chain_free(&pck_cert_chain); return result; } + +oe_result_t oe_get_quote_cert_chain_internal( + const uint8_t* quote, + const size_t quote_size, + const uint8_t** pem_pck_certificate, + size_t* pem_pck_certificate_size, + oe_cert_chain_t* pck_cert_chain) +{ + oe_result_t result = OE_UNEXPECTED; + sgx_quote_t* sgx_quote = NULL; + sgx_quote_auth_data_t* quote_auth_data = NULL; + sgx_qe_auth_data_t qe_auth_data = {0}; + sgx_qe_cert_data_t qe_cert_data = {0}; + + if (quote == NULL || pem_pck_certificate == NULL || pck_cert_chain == NULL) + { + OE_RAISE(OE_INVALID_PARAMETER); + } + + OE_CHECK_MSG( + _parse_quote( + quote, + quote_size, + &sgx_quote, + "e_auth_data, + &qe_auth_data, + &qe_cert_data), + "Failed to parse quote. %s", + oe_result_str(result)); + + *pem_pck_certificate = qe_cert_data.data; + *pem_pck_certificate_size = qe_cert_data.size; + + // Read and validate the chain. + OE_CHECK(oe_cert_chain_read_pem( + pck_cert_chain, *pem_pck_certificate, *pem_pck_certificate_size)); + + result = OE_OK; +done: + + return result; +} + +static void _update_validity( + oe_datetime_t* latest_from, + oe_datetime_t* earliest_until, + oe_datetime_t* from, + oe_datetime_t* until) +{ + if (oe_datetime_compare(from, latest_from) > 0) + { + *latest_from = *from; + } + + if (oe_datetime_compare(until, earliest_until) < 0) + { + *earliest_until = *until; + } +} + +oe_result_t oe_verify_sgx_quote( + const uint8_t* quote, + size_t quote_size, + const uint8_t* endorsements, + size_t endorsements_size, + oe_datetime_t* input_validation_time) +{ + oe_result_t result = OE_UNEXPECTED; + uint8_t* local_endorsements = NULL; + size_t local_endorsements_size = 0; + oe_sgx_endorsements_t sgx_endorsements; + + if (quote == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + if (endorsements == NULL && input_validation_time != NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + if (endorsements == NULL) + { + OE_CHECK_MSG( + oe_get_sgx_endorsements( + quote, + quote_size, + (uint8_t**)&local_endorsements, + &local_endorsements_size), + "Failed to get SGX endorsements. %s", + oe_result_str(result)); + + endorsements = local_endorsements; + endorsements_size = local_endorsements_size; + } + + OE_CHECK_MSG( + oe_parse_sgx_endorsements( + (oe_endorsements_t*)endorsements, + endorsements_size, + &sgx_endorsements), + "Failed to parse SGX endorsements.", + oe_result_str(result)); + + // Endorsements verification + OE_CHECK(oe_verify_quote_with_sgx_endorsements( + quote, quote_size, &sgx_endorsements, input_validation_time)); + + result = OE_OK; + +done: + if (local_endorsements) + oe_free_sgx_endorsements(local_endorsements); + + return result; +} + +oe_result_t oe_verify_quote_with_sgx_endorsements( + const uint8_t* quote, + size_t quote_size, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* input_validation_time) +{ + oe_result_t result = OE_UNEXPECTED; + oe_datetime_t validity_from = {0}; + oe_datetime_t validity_until = {0}; + oe_datetime_t validation_time = {0}; + + OE_CHECK_MSG( + oe_verify_quote_internal(quote, quote_size), + "Failed to verify remote quote.", + NULL); + + OE_CHECK_MSG( + oe_get_sgx_quote_validity( + quote, + quote_size, + sgx_endorsements, + &validity_from, + &validity_until), + "Failed to validate quote. %s", + oe_result_str(result)); + + // Verify quote/endorsements for the given time. Use endorsements + // creation time if one was not provided. + if (input_validation_time == NULL) + { + OE_CHECK_MSG( + oe_datetime_from_string( + (const char*)(sgx_endorsements + ->items + [OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME] + .data), + sgx_endorsements + ->items[OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME] + .size, + &validation_time), + "Invalid creation time in endorsements: %s", + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME] + .data); + } + else + { + validation_time = *input_validation_time; + } + + oe_datetime_log("Validation datetime: ", &validation_time); + if (oe_datetime_compare(&validation_time, &validity_from) < 0) + { + oe_datetime_log("Latests valid datetime: ", &validity_from); + OE_RAISE_MSG( + OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD, + "Time to validate quote is earlier than the " + "latest 'valid from' value.", + NULL); + } + if (oe_datetime_compare(&validation_time, &validity_until) > 0) + { + oe_datetime_log("Earliest expiration datetime: ", &validity_until); + OE_RAISE_MSG( + OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD, + "Time to validate quoteis later than the " + "earliest 'valid to' value.", + NULL); + } + + result = OE_OK; + +done: + return result; +} + +oe_result_t oe_get_sgx_quote_validity( + const uint8_t* quote, + const size_t quote_size, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* valid_from, + oe_datetime_t* valid_until) +{ + oe_result_t result = OE_UNEXPECTED; + + sgx_quote_t* sgx_quote = NULL; + sgx_quote_auth_data_t* quote_auth_data = NULL; + sgx_qe_auth_data_t qe_auth_data = {0}; + sgx_qe_cert_data_t qe_cert_data = {0}; + + const uint8_t* pem_pck_certificate = NULL; + size_t pem_pck_certificate_size = 0; + oe_cert_chain_t pck_cert_chain = {0}; + + oe_cert_t root_cert = {0}; + oe_cert_t intermediate_cert = {0}; + oe_cert_t pck_cert = {0}; + + oe_datetime_t latest_from = {0}; + oe_datetime_t earliest_until = {0}; + oe_datetime_t from; + oe_datetime_t until; + + if ((quote == NULL) || (sgx_endorsements == NULL) || (valid_from == NULL) || + (valid_until == NULL)) + OE_RAISE(OE_INVALID_PARAMETER); + + OE_TRACE_INFO("Call enter %s\n", __FUNCTION__); + + OE_CHECK_MSG( + _parse_quote( + quote, + quote_size, + &sgx_quote, + "e_auth_data, + &qe_auth_data, + &qe_cert_data), + "Failed to parse quote. %s", + oe_result_str(result)); + + pem_pck_certificate = qe_cert_data.data; + pem_pck_certificate_size = qe_cert_data.size; + + OE_CHECK_MSG( + oe_get_quote_cert_chain_internal( + quote, + quote_size, + &pem_pck_certificate, + &pem_pck_certificate_size, + &pck_cert_chain), + "Failed to retreive PCK cert chain. %s", + oe_result_str(result)); + + // Fetch certificates. + OE_CHECK_MSG( + oe_cert_chain_get_leaf_cert(&pck_cert_chain, &pck_cert), + "Failed to get leaf certificate.", + NULL); + OE_CHECK_MSG( + oe_cert_chain_get_root_cert(&pck_cert_chain, &root_cert), + "Failed to get root certificate.", + NULL); + OE_CHECK_MSG( + oe_cert_chain_get_cert(&pck_cert_chain, 1, &intermediate_cert), + "Failed to get intermediate certificate.", + NULL); + + // Process certs validity dates. + OE_CHECK_MSG( + oe_cert_get_validity_dates(&root_cert, &latest_from, &earliest_until), + "Failed to get validity info from cert. %s", + oe_result_str(result)); + OE_CHECK_MSG( + oe_cert_get_validity_dates(&intermediate_cert, &from, &until), + "Failed to get validity info from cert. %s", + oe_result_str(result)); + _update_validity(&latest_from, &earliest_until, &from, &until); + + OE_CHECK_MSG( + oe_cert_get_validity_dates(&pck_cert, &from, &until), + "Failed to get validity info from cert. %s", + oe_result_str(result)); + _update_validity(&latest_from, &earliest_until, &from, &until); + + // Fetch revocation info validity dates. + OE_CHECK_MSG( + oe_validate_revocation_list(&pck_cert, sgx_endorsements, &from, &until), + + "Failed to validate revocation info. %s", + oe_result_str(result)); + _update_validity(&latest_from, &earliest_until, &from, &until); + + // QE identity info validity dates. + OE_CHECK_MSG( + oe_validate_qe_identity( + "e_auth_data->qe_report_body, sgx_endorsements, &from, &until), + + "Failed quoting enclave identity checking. %s", + oe_result_str(result)); + _update_validity(&latest_from, &earliest_until, &from, &until); + + oe_datetime_log("Quote overall issue date: ", &latest_from); + oe_datetime_log("Quote overall next update: ", &earliest_until); + if (oe_datetime_compare(&latest_from, &earliest_until) > 0) + OE_RAISE_MSG( + OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD, + "Failed to find an overall validity period in quote.", + NULL); + + *valid_from = latest_from; + *valid_until = earliest_until; + + result = OE_OK; + +done: + oe_cert_free(&pck_cert); + oe_cert_free(&intermediate_cert); + oe_cert_free(&root_cert); + oe_cert_chain_free(&pck_cert_chain); + + return result; +} diff --git a/common/sgx/quote.h b/common/sgx/quote.h index bf279e25de..93ea059185 100644 --- a/common/sgx/quote.h +++ b/common/sgx/quote.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMON_QUOTE_H @@ -7,18 +7,102 @@ #include #include #include +#include +#include +#include "endorsements.h" OE_EXTERNC_BEGIN -oe_result_t oe_verify_quote_internal( - const uint8_t* enc_quote, +/*! + * Retrieves certifate chain from the quote. + * + * Caller is responsible for deallocating memory in pck_cert_chain. + * + * @param[in] quote Input quote. + * @param[in] quote_size The size of the quote. + * @param[out] pem_pck_certifcate Pointer to the quote where the certificate PCK + * starts. + * @param[out] pem_pck_certificate_size Size of the PCK certificate. + * @param[out] pck_cert_chain Reference to an instance of oe_cert_chain_t where + * to store the chain. Caller needs to free resources by calling + * oe_cert_chain_free() + */ +oe_result_t oe_get_quote_cert_chain_internal( + const uint8_t* quote, + const size_t quote_size, + const uint8_t** pem_pck_certificate, + size_t* pem_pck_certificate_size, + oe_cert_chain_t* pck_cert_chain); + +/*! + * Verify SGX quote and endorsements. + * + * @param[in] quote Input quote. + * @param[in] quote_size The size of the quote. + * @param[in] endorsements Optional endorsements related to a remote quote. + * @param[in] endorsements_size The size of the endorsements. + * @param[in] input_validation_time Optional time to use for validation, + * defaults to the time the endorsements were created if null. Note that + * if the input time is after than the endorsement creation time, then the + * CRLs might have updated in the period between the input time and the + * endorsement creation time. + */ +oe_result_t oe_verify_sgx_quote( + const uint8_t* quote, + size_t quote_size, + const uint8_t* endorsements, + size_t endorsements_size, + oe_datetime_t* input_validation_time); + +/*! + * Verify SGX quote and endorsements. + * + * @param[in] quote Input quote. + * @param[in] quote_size The size of the quote. + * @param[in] endorsements The endorsements in the format of + * the `oe_sgx_endorsements_t` struct. + * @param[in] input_validation_time Optional time to use for validation, + * defaults to the time the endorsements were created if null. Note that + * if the input time is after than the endorsement creation time, then the + * CRLs might have updated in the period between the input time and the + * endorsement creation time. + */ +oe_result_t oe_verify_quote_with_sgx_endorsements( + const uint8_t* quote, size_t quote_size, - const uint8_t* enc_pem_pck_certificate, - size_t pem_pck_certificate_size, - const uint8_t* enc_pck_crl, - size_t enc_pck_crl_size, - const uint8_t* enc_tcb_info_json, - size_t enc_tcb_info_json_size); + const oe_sgx_endorsements_t* endorsements, + oe_datetime_t* input_validation_time); + +/*! + * Find the valid datetime range for the given quote and sgx endorsements. + * This function accounts for the following items: + * + * 1. From the quote: + * a) Root CA. + * b) Intermediate CA. + * b) PCK CA. + * 2. From the revocation info: + * a) Root CA CRL. + * b) Intermediate CA CRL. + * c) PCK CA CRL. + * d) TCB info cert. + * e) TCB info. + * 3. From QE identity info + * a) QE identity cert. + * b) QE identity. + * + * @param[in] quote Input quote. + * @param[in] quote_size The size of the quote. + * @param[in] sgx_endorsements SGX endorsements related to the quote. + * @param[out] valid_from validity_from The date from which the quote is valid. + * @param[out] valid_until validity_until The date which the quote expires. + */ +oe_result_t oe_get_sgx_quote_validity( + const uint8_t* quote, + const size_t quote_size, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* valid_from, + oe_datetime_t* valid_until); OE_EXTERNC_END diff --git a/common/sgx/rand.S b/common/sgx/rand.S index 948a7d08db..ee300adf9a 100644 --- a/common/sgx/rand.S +++ b/common/sgx/rand.S @@ -1,17 +1,30 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. .text .globl oe_rdrand +.type oe_rdrand, @function +.globl oe_rdseed +.type oe_rdseed, @function oe_rdrand: - pushq %rbp - movq %rsp, %rbp - +.cfi_startproc _rdrand_retry: rdrand %rax - jnc _rdrand_retry - - leave + jc _rdrand_epilogue + pause + jmp _rdrand_retry +_rdrand_epilogue: ret +.cfi_endproc +oe_rdseed: +.cfi_startproc +_rdseed_retry: + rdseed %rax + jc _rdseed_epilogue + pause + jmp _rdseed_retry +_rdseed_epilogue: + ret +.cfi_endproc diff --git a/common/sgx/rand.asm b/common/sgx/rand.asm index 9045b7907a..c1d621e7ec 100644 --- a/common/sgx/rand.asm +++ b/common/sgx/rand.asm @@ -1,25 +1,33 @@ -;; Copyright (c) Microsoft Corporation. All rights reserved. +;; Copyright (c) Open Enclave SDK contributors. ;; Licensed under the MIT License. .CODE PUBLIC oe_rdrand oe_rdrand PROC -;; Subroutine Prologue - push rbp ;; Save the old base pointer value. - mov rbp, rsp ;; Set the new base pointer value. - sub rsp, 4 ;; Make room for one 4-byte local variable. -;; Subroutine Body _rdrand_retry: - rdrand rax - jnc _rdrand_retry + rdrand rax + jc _rdrand_epilogue + pause + jmp _rdrand_retry -;; Subroutine Epilogue - mov rsp, rbp ;; Deallocate local variables - pop rbp ;; Restore the caller's base pointer value - - ret +_rdrand_epilogue: + ret oe_rdrand ENDP +PUBLIC oe_rdseed +oe_rdseed PROC + +_rdseed_retry: + rdseed rax + jc _rdseed_epilogue + pause + jmp _rdseed_retry + +_rdseed_epilogue: + ret + +oe_rdseed ENDP + END diff --git a/common/sgx/report.c b/common/sgx/report.c index 49c13dc11e..de2cdfabb7 100644 --- a/common/sgx/report.c +++ b/common/sgx/report.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/common/sgx/revocation.c b/common/sgx/revocation.c index 1b0884211c..1f8fb073b7 100644 --- a/common/sgx/revocation.c +++ b/common/sgx/revocation.c @@ -1,7 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "revocation.h" +#include #include #include #include @@ -42,6 +43,103 @@ oe_result_t __oe_sgx_set_minimum_crl_tcb_issue_date( return result; } +static oe_result_t _get_tcb_info_validity( + const oe_parsed_tcb_info_t* parsed_tcb_info, + oe_datetime_t* from, + oe_datetime_t* until) +{ + *from = parsed_tcb_info->issue_date; + *until = parsed_tcb_info->next_update; + + return OE_OK; +} + +static oe_result_t _get_crl_validity( + const oe_crl_t* crls, + const uint32_t crls_count, + oe_datetime_t* from, + oe_datetime_t* until) +{ + oe_result_t result = OE_UNEXPECTED; + oe_datetime_t crl_this_update_date = {0}; + oe_datetime_t crl_next_update_date = {0}; + + if (crls_count > 0) + { + OE_CHECK_MSG( + oe_crl_get_update_dates(&crls[0], from, until), + "Failed to get CRL update dates. %s", + oe_result_str(result)); + + for (uint32_t i = 0; i < crls_count; ++i) + { + OE_CHECK_MSG( + oe_crl_get_update_dates( + &crls[0], &crl_this_update_date, &crl_next_update_date), + "Failed to get CRL update dates. %s", + oe_result_str(result)); + + if (oe_datetime_compare(&crl_this_update_date, from) > 0) + { + *from = crl_this_update_date; + } + if (oe_datetime_compare(&crl_next_update_date, until) < 0) + { + *until = crl_next_update_date; + } + } + + result = OE_OK; + } + +done: + return result; +} + +static oe_result_t _get_revocation_validity( + const oe_parsed_tcb_info_t* parsed_tcb_info, + const oe_crl_t* crls, + const uint32_t crls_count, + oe_datetime_t* from, + oe_datetime_t* until) +{ + oe_result_t result = OE_UNEXPECTED; + oe_datetime_t latest_from = {0}; + oe_datetime_t earliest_until = {0}; + oe_datetime_t current_from = {0}; + oe_datetime_t current_until = {0}; + + OE_CHECK_MSG( + _get_tcb_info_validity(parsed_tcb_info, &latest_from, &earliest_until), + "Failed to get TCB info validity datetime info. %s", + oe_result_str(result)); + oe_datetime_log("TCB info validity from date: ", &latest_from); + oe_datetime_log("TCB info validity until date: ", &earliest_until); + + OE_CHECK_MSG( + _get_crl_validity(crls, crls_count, ¤t_from, ¤t_until), + "Failed to get CRL validity datetime info. %s", + oe_result_str(result)); + oe_datetime_log("CRL validity from date: ", ¤t_from); + oe_datetime_log("CRL validity until date: ", ¤t_until); + + // Currently we are ignoring TCB Info validity dates because + // the data is expired. See Icm 148493545 + latest_from = current_from; + earliest_until = current_until; + + oe_datetime_log("Revocation overall validity from date: ", &latest_from); + oe_datetime_log( + "Revocation overall validity until date: ", &earliest_until); + + *from = latest_from; + *until = earliest_until; + result = OE_OK; + +done: + return result; +} + /** * Parse sgx extensions from given cert. */ @@ -93,7 +191,7 @@ static oe_result_t _get_crl_distribution_point(oe_cert_t* cert, char** url) oe_result_t result = OE_FAILURE; size_t buffer_size = 512; uint8_t* buffer = oe_malloc(buffer_size); - const char** urls = NULL; + char** urls = NULL; uint64_t num_urls = 0; size_t url_length = 0; @@ -141,50 +239,28 @@ static oe_result_t _get_crl_distribution_point(oe_cert_t* cert, char** url) return result; } -static void _trace_datetime(const char* msg, const oe_datetime_t* date) -{ - if (oe_get_current_logging_level() >= OE_LOG_LEVEL_INFO) - { - char str[21]; - size_t size = sizeof(str); - oe_datetime_to_string(date, str, &size); - OE_TRACE_INFO("%s%s\n", msg, str); - } -} - -oe_result_t oe_enforce_revocation( +/** + * Call into host to fetch revocation information given the CA and PCK + * certificates. + */ +oe_result_t oe_get_revocation_info_from_certs( oe_cert_t* leaf_cert, oe_cert_t* intermediate_cert, - oe_cert_chain_t* pck_cert_chain) + oe_get_revocation_info_args_t* args) { oe_result_t result = OE_FAILURE; ParsedExtensionInfo parsed_extension_info = {{0}}; - oe_get_revocation_info_args_t revocation_args = {0}; - oe_cert_chain_t tcb_issuer_chain = {0}; - oe_cert_chain_t crl_issuer_chain[3] = {{{0}}}; - oe_parsed_tcb_info_t parsed_tcb_info = {0}; - oe_tcb_level_t platform_tcb_level = {{0}}; char* intermediate_crl_url = NULL; char* leaf_crl_url = NULL; - oe_crl_t crls[2] = {{{0}}}; - const oe_crl_t* crl_ptrs[2] = {&crls[0], &crls[1]}; - oe_datetime_t crl_this_update_date = {0}; - oe_datetime_t crl_next_update_date = {0}; - - OE_UNUSED(pck_cert_chain); if (intermediate_cert == NULL || leaf_cert == NULL) OE_RAISE(OE_INVALID_PARAMETER); - OE_STATIC_ASSERT( - OE_COUNTOF(crl_issuer_chain) == - OE_COUNTOF(revocation_args.crl_issuer_chain)); - // Gather fmspc. OE_CHECK(_parse_sgx_extensions(leaf_cert, &parsed_extension_info)); OE_CHECK(oe_memcpy_s( - revocation_args.fmspc, - sizeof(revocation_args.fmspc), + args->fmspc, + sizeof(args->fmspc), parsed_extension_info.fmspc, sizeof(parsed_extension_info.fmspc))); @@ -193,32 +269,109 @@ oe_result_t oe_enforce_revocation( _get_crl_distribution_point(intermediate_cert, &intermediate_crl_url)); OE_CHECK(_get_crl_distribution_point(leaf_cert, &leaf_crl_url)); - revocation_args.crl_urls[0] = leaf_crl_url; - revocation_args.crl_urls[1] = intermediate_crl_url; - revocation_args.num_crl_urls = 2; + args->crl_urls[0] = leaf_crl_url; + args->crl_urls[1] = intermediate_crl_url; + args->num_crl_urls = 2; + + OE_CHECK(oe_get_revocation_info(args)); + + result = OE_OK; +done: + + oe_free(leaf_crl_url); + oe_free(intermediate_crl_url); - OE_CHECK(oe_get_revocation_info(&revocation_args)); + return result; +} - // Apply revocation info. - OE_CHECK(oe_cert_chain_read_pem( - &tcb_issuer_chain, - revocation_args.tcb_issuer_chain, - revocation_args.tcb_issuer_chain_size)); +oe_result_t oe_validate_revocation_list( + oe_cert_t* pck_cert, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* validity_from, + oe_datetime_t* validity_until) +{ + oe_result_t result = OE_UNEXPECTED; + + ParsedExtensionInfo parsed_extension_info = {{0}}; + oe_cert_chain_t tcb_issuer_chain = {0}; + oe_cert_chain_t crl_issuer_chain[3] = {{{0}}}; + oe_cert_t tcb_cert = {0}; + oe_parsed_tcb_info_t parsed_tcb_info = {0}; + oe_tcb_info_tcb_level_t platform_tcb_level = {{0}}; + + uint32_t version = 0; + oe_crl_t crls[2] = {{{0}}}; + const oe_crl_t* crl_ptrs[2] = {&crls[0], &crls[1]}; + oe_datetime_t from = {0}; + oe_datetime_t until = {0}; + oe_datetime_t latest_from = {0}; + oe_datetime_t earliest_until = {0}; + + if (pck_cert == NULL || sgx_endorsements == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + version = + *(uint32_t*)sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_VERSION] + .data; + if (version != OE_SGX_ENDORSEMENTS_VERSION) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "SGX endorsement version is %d, expected %d", + version, + OE_SGX_ENDORSEMENTS_VERSION); + + OE_STATIC_ASSERT( + OE_COUNTOF(crl_issuer_chain) >= OE_SGX_ENDORSEMENTS_CRL_COUNT); + + OE_CHECK_MSG( + _parse_sgx_extensions(pck_cert, &parsed_extension_info), + "Failed to parse SGX extensions from leaf cert. %s", + oe_result_str(result)); + + OE_CHECK_MSG( + oe_cert_chain_read_pem( + &tcb_issuer_chain, + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN] + .data, + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN] + .size), + "Failed to read TCB chain certificate. %s", + oe_result_str(result)); // Read CRLs for each cert other than root. If any CRL is missing, the read // will error out. - for (uint32_t i = 0; i < revocation_args.num_crl_urls; ++i) + for (uint32_t i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; ++i) { - OE_CHECK(oe_crl_read_der( - &crls[i], revocation_args.crl[i], revocation_args.crl_size[i])); - OE_CHECK(oe_cert_chain_read_pem( - &crl_issuer_chain[i], - revocation_args.crl_issuer_chain[i], - revocation_args.crl_issuer_chain_size[i])); + OE_CHECK_MSG( + oe_crl_read_der( + &crls[i], + sgx_endorsements + ->items[OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT + i] + .data, + sgx_endorsements + ->items[OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT + i] + .size), + "Failed to read CRL. %s", + oe_result_str(result)); + OE_CHECK_MSG( + oe_cert_chain_read_pem( + &crl_issuer_chain[i], + sgx_endorsements + ->items + [OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT + i] + .data, + sgx_endorsements + ->items + [OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT + i] + .size), + "Failed to read CRL cert chain. %s", + oe_result_str(result)); OE_TRACE_VERBOSE( "CRL certificate[%d]: \n[%s]\n", i, - revocation_args.crl_issuer_chain[i]); + (const char*)sgx_endorsements + ->items[OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT + i] + .data); } // Verify the leaf cert. @@ -236,8 +389,11 @@ oe_result_t oe_enforce_revocation( // constraint. If the crl_issuer_chain was different from the certificate // chain, then verification would fail because the CRLs will not be found // for certificates in the chain. - OE_CHECK(oe_cert_verify( - leaf_cert, crl_issuer_chain, crl_ptrs, OE_COUNTOF(crl_ptrs))); + OE_CHECK_MSG( + oe_cert_verify( + pck_cert, crl_issuer_chain, crl_ptrs, OE_COUNTOF(crl_ptrs)), + "Failed to verify leaf certificate. %s", + oe_result_str(result)); for (uint32_t i = 0; i < OE_COUNTOF(platform_tcb_level.sgx_tcb_comp_svn); ++i) @@ -246,64 +402,98 @@ oe_result_t oe_enforce_revocation( parsed_extension_info.comp_svn[i]; } platform_tcb_level.pce_svn = parsed_extension_info.pce_svn; - platform_tcb_level.status = OE_TCB_LEVEL_STATUS_UNKNOWN; - - OE_CHECK(oe_parse_tcb_info_json( - revocation_args.tcb_info, - revocation_args.tcb_info_size, - &platform_tcb_level, - &parsed_tcb_info)); - - OE_CHECK(oe_verify_ecdsa256_signature( - parsed_tcb_info.tcb_info_start, - parsed_tcb_info.tcb_info_size, - (sgx_ecdsa256_signature_t*)parsed_tcb_info.signature, - &tcb_issuer_chain)); - - // Check that the tcb has been issued after the earliest date that the - // enclave accepts. - if (oe_datetime_compare( - &parsed_tcb_info.issue_date, &_sgx_minimim_crl_tcb_issue_date) != 1) - OE_RAISE(OE_INVALID_REVOCATION_INFO); - - // Check that the CRLs have not expired. - // The next update of the CRL must be after the earliest date that - // the enclave accepts. - for (uint32_t i = 0; i < OE_COUNTOF(crls); ++i) + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + + OE_CHECK_MSG( + oe_parse_tcb_info_json( + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_TCB_INFO].data, + sgx_endorsements->items[OE_SGX_ENDORSEMENT_FIELD_TCB_INFO].size, + &platform_tcb_level, + &parsed_tcb_info), + "Failed to parse TCB info or Platform TCB is not up-to-date. %s", + oe_result_str(result)); + + OE_CHECK_MSG( + oe_verify_ecdsa256_signature( + parsed_tcb_info.tcb_info_start, + parsed_tcb_info.tcb_info_size, + (sgx_ecdsa256_signature_t*)parsed_tcb_info.signature, + &tcb_issuer_chain), + "Failed to verify ECDSA 256 signature in TCB. %s", + oe_result_str(result)); + + OE_CHECK_MSG( + _get_revocation_validity( + &parsed_tcb_info, + crls, + OE_COUNTOF(crls), + &latest_from, + &earliest_until), + "Failed to get revocation validity datetime info. %s", + oe_result_str(result)); + + if (oe_datetime_compare(&latest_from, &_sgx_minimim_crl_tcb_issue_date) < 0) { - OE_CHECK(oe_crl_get_update_dates( - &crls[i], &crl_this_update_date, &crl_next_update_date)); - - _trace_datetime("crl this update date ", &crl_this_update_date); - _trace_datetime("crl next update date ", &crl_next_update_date); - - // CRL must be issued after minimum date. - if (oe_datetime_compare( - &crl_this_update_date, &_sgx_minimim_crl_tcb_issue_date) != 1) - OE_RAISE(OE_INVALID_REVOCATION_INFO); + oe_datetime_log("Latest issue date : ", &latest_from); + oe_datetime_log( + " is earlier than minimum issue date: ", + &_sgx_minimim_crl_tcb_issue_date); + OE_RAISE_MSG( + OE_INVALID_REVOCATION_INFO, + "Revocation validation failed minimum issue date. %s", + oe_result_str(result)); + } - // Also check that next update date is after minimum date. - if (oe_datetime_compare( - &crl_next_update_date, &_sgx_minimim_crl_tcb_issue_date) != 1) - OE_RAISE(OE_INVALID_REVOCATION_INFO); + if (oe_datetime_compare(&earliest_until, &_sgx_minimim_crl_tcb_issue_date) < + 0) + { + oe_datetime_log("Next update date : ", &earliest_until); + oe_datetime_log( + " is earlier than minimum issue date: ", + &_sgx_minimim_crl_tcb_issue_date); + OE_RAISE_MSG( + OE_INVALID_REVOCATION_INFO, + "Revocation validation failed minimum issue date. %s", + oe_result_str(result)); } + // Get TCB cert validity period. + OE_CHECK_MSG( + oe_cert_chain_get_leaf_cert(&tcb_issuer_chain, &tcb_cert), + "Failed to get TCB certificate.", + NULL); + oe_cert_get_validity_dates(&tcb_cert, &from, &until); + oe_datetime_log("TCB cert issue date: ", &from); + oe_datetime_log("TCB cert next update: ", &until); + + if (oe_datetime_compare(&from, &latest_from) > 0) + latest_from = from; + if (oe_datetime_compare(&until, &earliest_until) < 0) + earliest_until = until; + oe_datetime_log("Revocation overall issue date: ", &latest_from); + oe_datetime_log("Revocation overall next update: ", &earliest_until); + + if (oe_datetime_compare(&latest_from, &earliest_until) > 0) + OE_RAISE_MSG( + OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD, + "Failed to find an overall revocation validity period.", + NULL); + + *validity_from = latest_from; + *validity_until = earliest_until; result = OE_OK; done: - for (int32_t i = (int32_t)revocation_args.num_crl_urls - 1; i >= 0; --i) + for (int32_t i = (int32_t)OE_SGX_ENDORSEMENTS_CRL_COUNT - 1; i >= 0; --i) { oe_crl_free(&crls[i]); } - for (uint32_t i = 0; i < revocation_args.num_crl_urls; ++i) + for (uint32_t i = 0; i < OE_SGX_ENDORSEMENTS_CRL_COUNT; ++i) { oe_cert_chain_free(&crl_issuer_chain[i]); } oe_cert_chain_free(&tcb_issuer_chain); - - oe_free(leaf_crl_url); - oe_free(intermediate_crl_url); - oe_cleanup_get_revocation_info_args(&revocation_args); + oe_cert_free(&tcb_cert); return result; } diff --git a/common/sgx/revocation.h b/common/sgx/revocation.h index e5abbe24df..f2285ac330 100644 --- a/common/sgx/revocation.h +++ b/common/sgx/revocation.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMON_REVOCATION_H @@ -9,19 +9,61 @@ #include #include #include +#include "endorsements.h" OE_EXTERNC_BEGIN -oe_result_t oe_enforce_revocation( +/** + * Validate the revocation info. Make sure the following: + * + * 1. TCB info. + * 2. CRL. + * + * Are valid and returns the validity dates for the given + * revocation info. + * + * @param[in] pck_cert The PCK certificate. + * @param[in] sgx_endorsements The SGX endorsements. + * @param[out] validity_from The date from which the revocation info is valid. + * @param[out] validity_until The date which the revocation info expires. + */ +oe_result_t oe_validate_revocation_list( + oe_cert_t* pck_cert, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_datetime_t* validity_from, + oe_datetime_t* validity_until); + +/** + * Fetch revocation info from the quote provider given the PCK certificate and + * CA certificate. + * + * Caller is responsbile for freeing the revocation info resources + * by calling oe_free_get_revocation_info_args(). + * + * @param[in] leaf_cert The PCK certificate. + * @param[in] intermediate_cert The CA certificate. + * @param[out] args The revocation info. + */ +oe_result_t oe_get_revocation_info_from_certs( oe_cert_t* leaf_cert, oe_cert_t* intermediate_cert, - oe_cert_chain_t* pck_cert_chain); + oe_get_revocation_info_args_t* args); -// Fetch revocation info using the specified args structure. +/** + * Get the revocation info from the quote provider. Caller is responsible for + * configuring the revocation info input parameters. + * + * @param[in,out] args The revocation info. + */ oe_result_t oe_get_revocation_info(oe_get_revocation_info_args_t* args); -// Cleanup the args structure. -void oe_cleanup_get_revocation_info_args(oe_get_revocation_info_args_t* args); +/** + * Free resources allocated by oe_get_revocation_info() and + * oe_get_revocation_info_from_certs(). + * + * @param[in] args The revocation info. + */ +void oe_free_get_revocation_info_args(oe_get_revocation_info_args_t* args); OE_EXTERNC_END diff --git a/common/sgx/sgx.edl b/common/sgx/sgx.edl index 2b5b5199c4..92b68e5e13 100644 --- a/common/sgx/sgx.edl +++ b/common/sgx/sgx.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* @@ -36,7 +36,7 @@ enclave size_t quote_size, [out] size_t* quote_size_out); - oe_result_t oe_get_qe_identify_info_ocall( + oe_result_t oe_get_qe_identity_info_ocall( [out, size=qe_id_info_size] void* qe_id_info, size_t qe_id_info_size, [out] size_t* qe_id_info_size_out, diff --git a/common/sgx/sgxcertextensions.c b/common/sgx/sgxcertextensions.c index d3715459b0..f4d975299d 100644 --- a/common/sgx/sgxcertextensions.c +++ b/common/sgx/sgxcertextensions.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/common/sgx/tcbinfo.c b/common/sgx/tcbinfo.c index cbeb9663ef..e7a47f30ef 100644 --- a/common/sgx/tcbinfo.c +++ b/common/sgx/tcbinfo.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "tcbinfo.h" #include @@ -220,8 +220,32 @@ static oe_result_t _trace_json_string(const uint8_t* str, size_t str_length) return result; } +static oe_tcb_level_status_t _parse_tcb_status( + const uint8_t* str, + size_t length) +{ + oe_tcb_level_status_t status; + status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + + if (_json_str_equal(str, length, "UpToDate")) + status.fields.up_to_date = 1; + else if (_json_str_equal(str, length, "OutOfDate")) + status.fields.outofdate = 1; + else if (_json_str_equal(str, length, "Revoked")) + status.fields.revoked = 1; + else if (_json_str_equal(str, length, "ConfigurationNeeded")) + status.fields.configuration_needed = 1; + else if (_json_str_equal(str, length, "OutOfDateConfigurationNeeded")) + { + status.fields.qe_identity_out_of_date = 1; + status.fields.configuration_needed = 1; + } + + return status; +} + /** - * Type: tcb + * Type: tcb in TCB Info tcbLevels * Schema: * { * "sgxtcbcomp01svn": uint8_t, @@ -231,10 +255,10 @@ static oe_result_t _trace_json_string(const uint8_t* str, size_t str_length) * "pcesvn": uint16_t * } */ -static oe_result_t _read_tcb( +static oe_result_t _read_tcb_info_tcb_level( const uint8_t** itr, const uint8_t* end, - oe_tcb_level_t* tcb_level) + oe_tcb_info_tcb_level_t* tcb_level) { oe_result_t result = OE_JSON_INFO_PARSE_ERROR; uint64_t value = 0; @@ -295,12 +319,12 @@ static oe_result_t _read_tcb( // 3. The status of the platform's tcb level is the status of the chosen tcb // level. // 4. If no tcb level was chosen, then the status of the platform is unknown. -static void _determine_platform_tcb_level( - oe_tcb_level_t* platform_tcb_level, - oe_tcb_level_t* tcb_level) +static void _determine_platform_tcb_info_tcb_level( + oe_tcb_info_tcb_level_t* platform_tcb_level, + oe_tcb_info_tcb_level_t* tcb_level) { // If the platform's status has already been determined, return. - if (platform_tcb_level->status != OE_TCB_LEVEL_STATUS_UNKNOWN) + if (platform_tcb_level->status.AsUINT32 != OE_TCB_LEVEL_STATUS_UNKNOWN) return; // Compare all of the platform's comp svn values with the corresponding @@ -318,35 +342,33 @@ static void _determine_platform_tcb_level( // If all the values of the tcb level are less than corresponding values of // the platform, then the platform's status is the status of the current tcb // level. - platform_tcb_level->status = tcb_level->status; + platform_tcb_level->status.AsUINT32 = tcb_level->status.AsUINT32; } /** - * Type: tcbLevel + * Type: tcbLevel in TCB Info (V1) * Schema: * { * "tcb" : object of type tcb - * "status": one of "UpToDate" or "OutOfDate" or "Revoked" + * "status": one of "UpToDate" or "OutOfDate" or "Revoked" or + * "ConfigurationNeeded" * } */ -static oe_result_t _read_tcb_level( +static oe_result_t _read_tcb_info_tcb_level_v1( const uint8_t** itr, const uint8_t* end, - oe_tcb_level_t* platform_tcb_level, - oe_parsed_tcb_info_t* parsed_info) + oe_tcb_info_tcb_level_t* platform_tcb_level) { oe_result_t result = OE_JSON_INFO_PARSE_ERROR; - oe_tcb_level_t tcb_level = {{0}}; + oe_tcb_info_tcb_level_t tcb_level = {{0}}; const uint8_t* status = NULL; size_t status_length = 0; - OE_UNUSED(parsed_info); - OE_CHECK(_read('{', itr, end)); OE_TRACE_VERBOSE("Reading tcb"); OE_CHECK(_read_property_name_and_colon("tcb", itr, end)); - OE_CHECK(_read_tcb(itr, end, &tcb_level)); + OE_CHECK(_read_tcb_info_tcb_level(itr, end, &tcb_level)); OE_CHECK(_read(',', itr, end)); OE_TRACE_VERBOSE("Reading status"); @@ -356,18 +378,88 @@ static oe_result_t _read_tcb_level( OE_CHECK(_read('}', itr, end)); - if (_json_str_equal(status, status_length, "UpToDate")) - tcb_level.status = OE_TCB_LEVEL_STATUS_UP_TO_DATE; - else if (_json_str_equal(status, status_length, "OutOfDate")) - tcb_level.status = OE_TCB_LEVEL_STATUS_OUT_OF_DATE; - else if (_json_str_equal(status, status_length, "Revoked")) - tcb_level.status = OE_TCB_LEVEL_STATUS_REVOKED; - else if (_json_str_equal(status, status_length, "ConfigurationNeeded")) - tcb_level.status = OE_TCB_LEVEL_STATUS_CONFIGURATION_NEEDED; + tcb_level.status = _parse_tcb_status(status, status_length); + if (tcb_level.status.AsUINT32 != OE_TCB_LEVEL_STATUS_UNKNOWN) + { + _determine_platform_tcb_info_tcb_level(platform_tcb_level, &tcb_level); + result = OE_OK; + } + +done: + return result; +} + +/** + * Type: tcbLevel in TCB Info (V2) + * Schema: + * { + * "tcb" : object of type tcb (Note: QE Identity info has the same object, + * but with different set of values). "tcbDate" : oe_datetime_t when TCB level + * was certified not to be vulnerable. ISO 8601 standard(YYYY-MM-DDThh:mm:ssZ). + * "tcbStatus" : one of "UpToDate" or "OutOfDate" or "Revoked" or + * "ConfigurationNeeded" or "OutOfDateConfigurationNeeded" + * "advisoryIDs" : array of strings describing vulnerabilities that this TCB + * level is vulnerable to. Example: ["INTEL-SA-00079", "INTEL-SA-00076"] + * } + */ +static oe_result_t _read_tcb_info_tcb_level_v2( + const uint8_t* info_json, + const uint8_t** itr, + const uint8_t* end, + oe_tcb_info_tcb_level_t* platform_tcb_level, + oe_tcb_info_tcb_level_t* tcb_level) +{ + oe_result_t result = OE_JSON_INFO_PARSE_ERROR; + const uint8_t* status = NULL; + size_t status_length = 0; + const uint8_t* date_str = NULL; + size_t date_size = 0; + + OE_CHECK(_read('{', itr, end)); + + OE_TRACE_VERBOSE("Reading tcb"); + OE_CHECK(_read_property_name_and_colon("tcb", itr, end)); + OE_CHECK(_read_tcb_info_tcb_level(itr, end, tcb_level)); + OE_CHECK(_read(',', itr, end)); - if (tcb_level.status != OE_TCB_LEVEL_STATUS_UNKNOWN) + OE_TRACE_VERBOSE("Reading tcbDate"); + OE_CHECK(_read_property_name_and_colon("tcbDate", itr, end)); + OE_CHECK(_read_string(itr, end, &date_str, &date_size)); + if (oe_datetime_from_string( + (const char*)date_str, date_size, &tcb_level->tcb_date) != OE_OK) + OE_RAISE(OE_JSON_INFO_PARSE_ERROR); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading tcbStatus"); + OE_CHECK(_read_property_name_and_colon("tcbStatus", itr, end)); + OE_CHECK(_read_string(itr, end, &status, &status_length)); + OE_CHECK(_trace_json_string(status, status_length)); + + // Optional advisoryIDs field + if (OE_JSON_INFO_PARSE_ERROR != _read(',', itr, end)) { - _determine_platform_tcb_level(platform_tcb_level, &tcb_level); + OE_TRACE_VERBOSE("Reading advisoryIDs"); + OE_CHECK(_read_property_name_and_colon("advisoryIDs", itr, end)); + OE_CHECK(_read('[', itr, end)); + + tcb_level->advisory_ids_offset = (size_t)(*itr - info_json); + size_t size = 0; + + while (*itr < end && **itr != ']') + { + (*itr)++; + size++; + } + OE_CHECK(_read(']', itr, end)); + tcb_level->advisory_ids_size = size; + } + + OE_CHECK(_read('}', itr, end)); + + tcb_level->status = _parse_tcb_status(status, status_length); + if (tcb_level->status.AsUINT32 != OE_TCB_LEVEL_STATUS_UNKNOWN) + { + _determine_platform_tcb_info_tcb_level(platform_tcb_level, tcb_level); result = OE_OK; } @@ -377,18 +469,33 @@ static oe_result_t _read_tcb_level( /** * type = tcbInfo - * Schema: + * V1 Schema: * { * "version" : integer, * "issueDate" : string, - * "fmspc" : "hex string" - * "tcbLevels" : [ objects of type tcbLevel ] + * "nextUpdate" : string, + * "fmspc" : "hex string (12 nibbles)" + * "pceId" : "hex string (4 nibbles)" + * "tcbLevels" : [ objects of type oe_tcb_info_tcb_level_t ] + * } + * + * V2 Schema: + * { + * "version" : integer, + * "issueDate" : string, + * "nextUpdate" : string, + * "fmspc" : "hex string (12 nibbles)" + * "pceId" : "hex string (4 nibbles)" + * "tcbType" : integer + * "tcbEvaluationDataNumber" : integer + * "tcbLevels" : [ objects of type oe_tcb_info_tcb_level_t ] * } */ static oe_result_t _read_tcb_info( + const uint8_t* tcb_info_json, const uint8_t** itr, const uint8_t* end, - oe_tcb_level_t* platform_tcb_level, + oe_tcb_info_tcb_level_t* platform_tcb_level, oe_parsed_tcb_info_t* parsed_info) { oe_result_t result = OE_JSON_INFO_PARSE_ERROR; @@ -451,19 +558,73 @@ static oe_result_t _read_tcb_info( } } - OE_TRACE_VERBOSE("Reading tcbLevels"); - OE_CHECK(_read_property_name_and_colon("tcbLevels", itr, end)); - OE_CHECK(_read('[', itr, end)); - while (*itr < end) + if (parsed_info->version == 2) { - OE_CHECK(_read_tcb_level(itr, end, platform_tcb_level, parsed_info)); - // Read end of array or comma separator. - if (*itr < end && **itr == ']') - break; + OE_TRACE_VERBOSE("V2: Reading tcbType"); + OE_CHECK(_read_property_name_and_colon("tcbType", itr, end)); + OE_CHECK(_read_integer(itr, end, &value)); + parsed_info->tcb_type = (uint32_t)value; + OE_CHECK(_read(',', itr, end)); + OE_TRACE_VERBOSE("V2: Reading tcbEvaluationDataNumber"); + OE_CHECK( + _read_property_name_and_colon("tcbEvaluationDataNumber", itr, end)); + OE_CHECK(_read_integer(itr, end, &value)); + parsed_info->tcb_evaluation_data_number = (uint32_t)value; OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading tcbLevels (V2)"); + OE_CHECK(_read_property_name_and_colon("tcbLevels", itr, end)); + OE_CHECK(_read('[', itr, end)); + while (*itr < end) + { + OE_CHECK(_read_tcb_info_tcb_level_v2( + tcb_info_json, + itr, + end, + platform_tcb_level, + &parsed_info->tcb_level)); + + // Optimization + if (platform_tcb_level->status.AsUINT32 != + OE_TCB_LEVEL_STATUS_UNKNOWN) + { + // Found matching TCB level, go to the end of the array. + while (*itr < end && **itr != ']') + (*itr)++; + } + + // Read end of array or comma separator. + if (*itr < end && **itr == ']') + break; + + OE_CHECK(_read(',', itr, end)); + } + OE_CHECK(_read(']', itr, end)); + } + else if (parsed_info->version == 1) + { + OE_TRACE_VERBOSE("Reading tcbLevels (V1)"); + OE_CHECK(_read_property_name_and_colon("tcbLevels", itr, end)); + OE_CHECK(_read('[', itr, end)); + while (*itr < end) + { + OE_CHECK(_read_tcb_info_tcb_level_v1(itr, end, platform_tcb_level)); + // Read end of array or comma separator. + if (*itr < end && **itr == ']') + break; + + OE_CHECK(_read(',', itr, end)); + } + OE_CHECK(_read(']', itr, end)); + } + else + { + OE_RAISE_MSG( + OE_JSON_INFO_PARSE_ERROR, + "Unsupported TCB level info version %d", + parsed_info->version); } - OE_CHECK(_read(']', itr, end)); // itr is expected to point to the '}' that denotes the end of the tcb // object. The signature is generated over the entire object including the @@ -487,7 +648,7 @@ static oe_result_t _read_tcb_info( oe_result_t oe_parse_tcb_info_json( const uint8_t* tcb_info_json, size_t tcb_info_json_size, - oe_tcb_level_t* platform_tcb_level, + oe_tcb_info_tcb_level_t* platform_tcb_level, oe_parsed_tcb_info_t* parsed_info) { oe_result_t result = OE_JSON_INFO_PARSE_ERROR; @@ -502,15 +663,16 @@ oe_result_t oe_parse_tcb_info_json( if (end <= itr) OE_RAISE(OE_INVALID_PARAMETER); - if (platform_tcb_level->status != OE_TCB_LEVEL_STATUS_UNKNOWN) - OE_RAISE(OE_INVALID_PARAMETER); + // Initialize status + platform_tcb_level->status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; itr = _skip_ws(itr, end); OE_CHECK(_read('{', &itr, end)); OE_TRACE_VERBOSE("Reading tcbInfo"); OE_CHECK(_read_property_name_and_colon("tcbInfo", &itr, end)); - OE_CHECK(_read_tcb_info(&itr, end, platform_tcb_level, parsed_info)); + OE_CHECK(_read_tcb_info( + tcb_info_json, &itr, end, platform_tcb_level, parsed_info)); OE_CHECK(_read(',', &itr, end)); OE_TRACE_VERBOSE("Reading signature"); @@ -522,7 +684,7 @@ oe_result_t oe_parse_tcb_info_json( if (itr == end) { - if (platform_tcb_level->status != OE_TCB_LEVEL_STATUS_UP_TO_DATE) + if (platform_tcb_level->status.fields.up_to_date != 1) { for (uint32_t i = 0; i < OE_COUNTOF(platform_tcb_level->sgx_tcb_comp_svn); @@ -537,6 +699,15 @@ oe_result_t oe_parse_tcb_info_json( "Platform TCB (%d) is not up-to-date", platform_tcb_level->status); } + + // Display any advisory IDs as warnings + if (platform_tcb_level->advisory_ids_size > 0) + { + OE_TRACE_WARNING( + "Found %d AdvisoryIDs for this tcb level.", + platform_tcb_level->advisory_ids_size); + } + result = OE_OK; } done: @@ -561,11 +732,11 @@ OE_INLINE uint64_t read_uint64(const uint8_t* p) } /** * type = qe_identity - * Schema: + * V1 Schema: * { - * "version" : integer, + * "version" : integer, * "issueDate" : string, - * "nextDate" : string, + * "nextUpdate" : string, * "miscselect" : hex string, * "miscselectMask" : hex string, * "attributes" : hex string, @@ -575,7 +746,7 @@ OE_INLINE uint64_t read_uint64(const uint8_t* p) * "isvsvn" : integer, * } */ -static oe_result_t _read_qe_identity_info( +static oe_result_t _read_qe_identity_info_v1( const uint8_t** itr, const uint8_t* end, oe_parsed_qe_identity_info_t* parsed_info) @@ -670,23 +841,350 @@ static oe_result_t _read_qe_identity_info( result = OE_OK; done: OE_TRACE_VERBOSE( - "Reading _read_qe_identity_info ended with [%s]\n", + "Reading _read_qe_identity_info_v1 ended with [%s]\n", oe_result_str(result)); return result; } +/** + * Type: tcb in QE Identity Info tcbLevels + * Schema: + * { + * "isvsvn": uint32_t + * } + */ +static oe_result_t _read_qe_tcb( + const uint8_t** itr, + const uint8_t* end, + oe_qe_identity_info_tcb_level_t* tcb_level) +{ + oe_result_t result = OE_JSON_INFO_PARSE_ERROR; + uint64_t value = 0; + + static const char* _names[] = {"isvsvn"}; + OE_STATIC_ASSERT(OE_COUNTOF(_names) == OE_COUNTOF(tcb_level->isvsvn)); + + OE_CHECK(_read('{', itr, end)); + + for (size_t i = 0; i < OE_COUNTOF(_names); ++i) + { + OE_TRACE_VERBOSE("Reading %s", _names[i]); + OE_CHECK(_read_property_name_and_colon(_names[i], itr, end)); + OE_CHECK(_read_integer(itr, end, &value)); + OE_TRACE_VERBOSE("value = %lu", value); + + if (i != (OE_COUNTOF(_names) - 1)) + OE_CHECK(_read(',', itr, end)); + + if (value > OE_UINT32_MAX) + OE_RAISE(OE_JSON_INFO_PARSE_ERROR); + tcb_level->isvsvn[i] = (uint32_t)value; + } + + OE_CHECK(_read('}', itr, end)); + + result = OE_OK; +done: + return result; +} + +// Algorithm specified by Intel, reworded: +// 1. Go over the sorted collection of TCB levels in the JSON. +// 2. Choose the first tcb level for which all of the platform's isv svn +// values are greater than or equal to corresponding values of +// the tcb level. +// 3. The status of the platform's tcb level is the status of the chosen tcb +// level. +// 4. If no tcb level was chosen, then the status of the platform is unknown. +static void _determine_platform_qe_tcb_level( + oe_qe_identity_info_tcb_level_t* platform_tcb_level, + oe_qe_identity_info_tcb_level_t* tcb_level) +{ + // If the platform's status has already been determined, return. + if (platform_tcb_level->tcb_status.AsUINT32 != OE_TCB_LEVEL_STATUS_UNKNOWN) + return; + + // Compare all of the platform's comp svn values with the corresponding + // values in the current tcb level. + for (uint32_t i = 0; i < OE_COUNTOF(platform_tcb_level->isvsvn); ++i) + { + if (platform_tcb_level->isvsvn[i] < tcb_level->isvsvn[i]) + return; + } + + // If all the values of the tcb level are less than corresponding values of + // the platform, then the platform's status is the status of the current tcb + // level. + platform_tcb_level->tcb_status = tcb_level->tcb_status; +} + +/** + * Type: tcbLevel in QE Identity Info (New in V2 of QE Identity Info) + * Schema: + * { + * "tcb" : object of type tcb (Note: TCB Info has the same object, but with + * different set of values). + * "tcbDate" : oe_datetime_t when TCB level was certified not to be + * vulnerable. ISO 8601 standard(YYYY-MM-DDThh:mm:ssZ). "tcbStatus" : one of + * "UpToDate" or "OutOfDate" or "Revoked" or "ConfigurationNeeded" or + * "OutOfDateConfigurationNeeded" "advisoryIDs" : array of strings describing + * vulnerabilities that this TCB level is vulnerable to. Example: + * ["INTEL-SA-00079", "INTEL-SA-00076"] + * } + */ +static oe_result_t _read_qe_tcb_level( + const uint8_t* info_json, + const uint8_t** itr, + const uint8_t* end, + oe_qe_identity_info_tcb_level_t* platform_qe_tcb_level, + oe_qe_identity_info_tcb_level_t* tcb_level) +{ + oe_result_t result = OE_JSON_INFO_PARSE_ERROR; + const uint8_t* status = NULL; + size_t status_length = 0; + const uint8_t* date_str = NULL; + size_t date_size = 0; + + memset(tcb_level, 0, sizeof(oe_qe_identity_info_tcb_level_t)); + + OE_CHECK(_read('{', itr, end)); + + OE_TRACE_VERBOSE("Reading QE Identity tcb"); + OE_CHECK(_read_property_name_and_colon("tcb", itr, end)); + OE_CHECK(_read_qe_tcb(itr, end, tcb_level)); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading tcbDate"); + OE_CHECK(_read_property_name_and_colon("tcbDate", itr, end)); + OE_CHECK(_read_string(itr, end, &date_str, &date_size)); + if (oe_datetime_from_string( + (const char*)date_str, date_size, &tcb_level->tcb_date) != OE_OK) + OE_RAISE(OE_JSON_INFO_PARSE_ERROR); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading tcbStatus"); + OE_CHECK(_read_property_name_and_colon("tcbStatus", itr, end)); + OE_CHECK(_read_string(itr, end, &status, &status_length)); + OE_CHECK(_trace_json_string(status, status_length)); + + // Optional advisoryIDs field + if (OE_JSON_INFO_PARSE_ERROR != _read(',', itr, end)) + { + OE_TRACE_VERBOSE("Reading advisoryIDs"); + OE_CHECK(_read_property_name_and_colon("advisoryIDs", itr, end)); + OE_CHECK(_read('[', itr, end)); + + tcb_level->advisory_ids_offset = (size_t)(*itr - info_json); + size_t size = 0; + + while (*itr < end && **itr != ']') + { + (*itr)++; + size++; + } + OE_CHECK(_read(']', itr, end)); + tcb_level->advisory_ids_size = size; + } + + OE_CHECK(_read('}', itr, end)); + + tcb_level->tcb_status = _parse_tcb_status(status, status_length); + if (tcb_level->tcb_status.AsUINT32 != OE_TCB_LEVEL_STATUS_UNKNOWN) + { + _determine_platform_qe_tcb_level(platform_qe_tcb_level, tcb_level); + result = OE_OK; + } + +done: + return result; +} + +/*! + * type = enclaveIdentity + * V2 Schema: + * { + * "id" : string ("QE" | "QVE") + * "version" : integer, + * "issueDate" : string, + * "nextUpdate" : string, + * "tcbEvaluationDataNumber" : integer + * "miscselect" : hex string, + * "miscselectMask" : hex string, + * "attributes" : hex string, + * "attributesMask" : hex string, + * "mrsigner" : hex string, + * "isvprodid" : integer, + * "tcbLevels" : [ objects of type oe_qe_identity_info_tcb_level_t ] + * } + */ +static oe_result_t _read_qe_identity_info_v2( + const uint8_t* info_json, + const uint8_t** itr, + const uint8_t* end, + oe_qe_identity_info_tcb_level_t* platform_tcb_level, + oe_parsed_qe_identity_info_t* parsed_info) +{ + oe_result_t result = OE_JSON_INFO_PARSE_ERROR; + uint64_t value = 0; + const uint8_t* str = NULL; + size_t size = 0; + uint8_t four_bytes_buf[4]; + uint8_t sixteen_bytes_buf[16]; + + if (platform_tcb_level == NULL) + OE_RAISE_MSG( + OE_INVALID_PARAMETER, + "QE identity info v2 requires platform tcb level.", + NULL); + + // Initialize status. + platform_tcb_level->tcb_status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + + parsed_info->info_start = *itr; + OE_CHECK(_read('{', itr, end)); + + OE_TRACE_VERBOSE("Reading id"); + OE_CHECK(_read_property_name_and_colon("id", itr, end)); + OE_CHECK(_read_string(itr, end, &str, &size)); + if (_json_str_equal(str, size, "QE")) + parsed_info->id = QE_IDENTITY_ID_QE; + else if (_json_str_equal(str, size, "QVE")) + parsed_info->id = QE_IDENTITY_ID_QVE; + else + OE_RAISE_MSG(OE_JSON_INFO_PARSE_ERROR, "Invalid id %s", str); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading version"); + OE_CHECK(_read_property_name_and_colon("version", itr, end)); + OE_CHECK(_read_integer(itr, end, &value)); + parsed_info->version = (uint32_t)value; + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading issueDate"); + OE_CHECK(_read_property_name_and_colon("issueDate", itr, end)); + OE_CHECK(_read_string(itr, end, &str, &size)); + if (oe_datetime_from_string( + (const char*)str, size, &parsed_info->issue_date) != OE_OK) + OE_RAISE(OE_JSON_INFO_PARSE_ERROR); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading nextUpdate"); + OE_CHECK(_read_property_name_and_colon("nextUpdate", itr, end)); + OE_CHECK(_read_string(itr, end, &str, &size)); + if (oe_datetime_from_string( + (const char*)str, size, &parsed_info->next_update) != OE_OK) + OE_RAISE(OE_JSON_INFO_PARSE_ERROR); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading tcbEvaluationDataNumber"); + OE_CHECK( + _read_property_name_and_colon("tcbEvaluationDataNumber", itr, end)); + OE_CHECK(_read_integer(itr, end, &value)); + parsed_info->tcb_evaluation_data_number = (uint32_t)value; + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading miscselect"); + OE_CHECK(_read_property_name_and_colon("miscselect", itr, end)); + OE_CHECK( + _read_hex_string(itr, end, four_bytes_buf, sizeof(four_bytes_buf))); + parsed_info->miscselect = read_uint32(four_bytes_buf); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading miscselectMask"); + OE_CHECK(_read_property_name_and_colon("miscselectMask", itr, end)); + OE_CHECK( + _read_hex_string(itr, end, four_bytes_buf, sizeof(four_bytes_buf))); + parsed_info->miscselect_mask = read_uint32(four_bytes_buf); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading attributes.flags"); + OE_CHECK(_read_property_name_and_colon("attributes", itr, end)); + OE_CHECK(_read_hex_string( + itr, end, sixteen_bytes_buf, sizeof(sixteen_bytes_buf))); + parsed_info->attributes.flags = read_uint64(sixteen_bytes_buf); + parsed_info->attributes.xfrm = read_uint64(sixteen_bytes_buf + 8); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading attributesMask"); + OE_CHECK(_read_property_name_and_colon("attributesMask", itr, end)); + OE_CHECK(_read_hex_string( + itr, end, sixteen_bytes_buf, sizeof(sixteen_bytes_buf))); + parsed_info->attributes_flags_mask = read_uint64(sixteen_bytes_buf); + parsed_info->attributes_xfrm_mask = read_uint64(sixteen_bytes_buf + 8); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading mrsigner"); + OE_CHECK(_read_property_name_and_colon("mrsigner", itr, end)); + OE_CHECK(_read_hex_string( + itr, end, parsed_info->mrsigner, sizeof(parsed_info->mrsigner))); + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading isvprodid"); + OE_CHECK(_read_property_name_and_colon("isvprodid", itr, end)); + OE_CHECK(_read_integer(itr, end, &value)); + parsed_info->isvprodid = (uint16_t)value; + OE_CHECK(_read(',', itr, end)); + + OE_TRACE_VERBOSE("Reading tcbLevels"); + OE_CHECK(_read_property_name_and_colon("tcbLevels", itr, end)); + OE_CHECK(_read('[', itr, end)); + while (*itr < end) + { + OE_CHECK(_read_qe_tcb_level( + info_json, itr, end, platform_tcb_level, &parsed_info->tcb_level)); + + // Optimization + if (platform_tcb_level->tcb_status.AsUINT32 != + OE_TCB_LEVEL_STATUS_UNKNOWN) + { + // Found matching TCB level, go to the end of the array. + while (*itr < end && **itr != ']') + (*itr)++; + } + + // Read end of array or comma separator. + if (*itr < end && **itr == ']') + break; + + OE_CHECK(_read(',', itr, end)); + } + OE_CHECK(_read(']', itr, end)); + + // Synchronize legacy V1 field. + parsed_info->isvsvn = (uint16_t)parsed_info->tcb_level.isvsvn[0]; + + // itr is expected to point to the '}' that denotes the end of the qe + // identity object. The signature is generated over the entire object + // including the '}'. + parsed_info->info_size = (size_t)(*itr - parsed_info->info_start + 1); + OE_CHECK(_read('}', itr, end)); + OE_TRACE_VERBOSE("Done with last read"); + result = OE_OK; +done: + OE_TRACE_VERBOSE( + "Reading %s ended with [%s]\n", __FUNCTION__, oe_result_str(result)); + return result; +} + /** * type = qe_identity_info * - * Schema: + * Schema V1: * { * "qeIdentity" : object of type qe_identity, * "signature" : "hex string" * } + * + * Schema V2: + * { + * "enclaveIdentity" : object of type enclaveIdentity, + * "signature" : "hex string" + * } */ oe_result_t oe_parse_qe_identity_info_json( const uint8_t* info_json, size_t info_json_size, + oe_qe_identity_info_tcb_level_t* platform_tcb_level, oe_parsed_qe_identity_info_t* parsed_info) { oe_result_t result = OE_JSON_INFO_PARSE_ERROR; @@ -704,18 +1202,50 @@ oe_result_t oe_parse_qe_identity_info_json( itr = _skip_ws(itr, end); OE_CHECK(_read('{', &itr, end)); - OE_TRACE_VERBOSE("Reading qeIdentity"); - OE_CHECK(_read_property_name_and_colon("qeIdentity", &itr, end)); - OE_CHECK(_read_qe_identity_info(&itr, end, parsed_info)); - OE_CHECK(_read(',', &itr, end)); + if (OE_JSON_INFO_PARSE_ERROR != + _read_property_name_and_colon("enclaveIdentity", &itr, end)) + { + OE_TRACE_VERBOSE("Reading enclaveIdentity"); + OE_CHECK(_read_qe_identity_info_v2( + info_json, &itr, end, platform_tcb_level, parsed_info)); + OE_CHECK(_read(',', &itr, end)); + } + else + { + OE_TRACE_VERBOSE("Reading qeIdentity"); + OE_CHECK(_read_property_name_and_colon("qeIdentity", &itr, end)); + OE_CHECK(_read_qe_identity_info_v1(&itr, end, parsed_info)); + OE_CHECK(_read(',', &itr, end)); + } OE_TRACE_VERBOSE("Reading signature"); OE_CHECK(_read_property_name_and_colon("signature", &itr, end)); OE_CHECK(_read_hex_string( &itr, end, parsed_info->signature, sizeof(parsed_info->signature))); OE_CHECK(_read('}', &itr, end)); + if (itr == end) { + if (parsed_info->version == 2 && + platform_tcb_level->tcb_status.fields.up_to_date != 1) + { + for (uint32_t i = 0; i < OE_COUNTOF(platform_tcb_level->isvsvn); + ++i) + OE_TRACE_VERBOSE( + "isvsvn[%d] = 0x%x", i, platform_tcb_level->isvsvn[i]); + OE_RAISE_MSG( + OE_TCB_LEVEL_INVALID, + "QE Identity Information (%d) is not up-to-date", + platform_tcb_level->tcb_status.AsUINT32); + } + + // Display any advisory IDs as warnings + if (parsed_info->tcb_level.advisory_ids_size > 0) + { + OE_TRACE_WARNING( + "Found %d AdvisoryIDs for this tcb level.", + parsed_info->tcb_level.advisory_ids_size); + } result = OE_OK; } @@ -817,3 +1347,40 @@ oe_result_t oe_verify_ecdsa256_signature( return result; } + +oe_result_t oe_parse_advisoryids_json( + const uint8_t* json, + size_t json_size, + const uint8_t** id_array, + size_t id_array_size, + size_t* id_sizes_array, + size_t id_sizes_size, + size_t* num_ids) +{ + oe_result_t result = OE_JSON_INFO_PARSE_ERROR; + const uint8_t* itr = json; + const uint8_t* end = json + json_size; + size_t count = 0; + + if (json == NULL || json_size == 0 || id_array == NULL || num_ids == NULL || + (id_array_size != id_sizes_size)) + OE_RAISE(OE_INVALID_PARAMETER); + + *num_ids = 0; + + while (itr < end && count < id_array_size) + { + OE_CHECK( + _read_string(&itr, end, &id_array[count], &id_sizes_array[count])); + count += 1; + + if (itr < end) + OE_CHECK(_read(',', &itr, end)); + } + + *num_ids = count; + result = OE_OK; +done: + + return result; +} \ No newline at end of file diff --git a/common/sgx/tcbinfo.h b/common/sgx/tcbinfo.h index 91b084788c..7b75a1d9bc 100644 --- a/common/sgx/tcbinfo.h +++ b/common/sgx/tcbinfo.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMON_TCBINFO_H @@ -13,23 +13,56 @@ OE_EXTERNC_BEGIN -typedef enum _oe_tcb_level_status -{ - OE_TCB_LEVEL_STATUS_UNKNOWN, - OE_TCB_LEVEL_STATUS_REVOKED, - OE_TCB_LEVEL_STATUS_OUT_OF_DATE, - OE_TCB_LEVEL_STATUS_CONFIGURATION_NEEDED, - OE_TCB_LEVEL_STATUS_UP_TO_DATE, - __OE_TCB_LEVEL_MAX = OE_ENUM_MAX, +#define OE_TCB_LEVEL_STATUS_UNKNOWN (0) + +/*! \struct oe_tcb_level_status_t + */ +typedef union _oe_tcb_level_status { + struct + { + uint32_t revoked : 1; //! "Revoked" + uint32_t outofdate : 1; //! "OutOfDate" + uint32_t configuration_needed : 1; //! "ConfigurationNeeded" + uint32_t up_to_date : 1; //! "UpToDate" + + /*! "OutOfDateConfigurationNeeded" + * + * This tcb status indicates that the QE Identity Info is out of date + * and the TCB Info requires configuration "ConfigurationNeeded" + */ + uint32_t qe_identity_out_of_date : 1; + } fields; + uint32_t AsUINT32; + } oe_tcb_level_status_t; -typedef struct _oe_tcb_level +/*! \struct oe_tcb_info_tcb_level_t + * \brief TCB level field in the SGX TCB Info. + * + * Version 2 of the SGX endorsements/collaterals, the QE Identiy + * Info structure also has a TCB level field (\ref See oe_qe_info_tcb_level_t). + */ +typedef struct _oe_tcb_info_tcb_level { uint8_t sgx_tcb_comp_svn[16]; uint16_t pce_svn; oe_tcb_level_status_t status; -} oe_tcb_level_t; + // V2 fields + oe_datetime_t tcb_date; + + /*! Offset into the json QE Identity info where + * the advisoryIDs fields start. + */ + size_t advisory_ids_offset; + + //! Total size of all the advisoryIDs. + size_t advisory_ids_size; +} oe_tcb_info_tcb_level_t; + +/*! \struct oe_parsed_tcb_info_t + * \brief TCB info excluding the TCB levels field. + */ typedef struct _oe_parsed_tcb_info { uint32_t version; @@ -38,8 +71,15 @@ typedef struct _oe_parsed_tcb_info uint8_t fmspc[6]; uint8_t pceid[2]; uint8_t signature[64]; + + // V2 fields + uint32_t tcb_type; + uint32_t tcb_evaluation_data_number; + oe_tcb_info_tcb_level_t tcb_level; + const uint8_t* tcb_info_start; size_t tcb_info_size; + } oe_parsed_tcb_info_t; /** @@ -63,11 +103,17 @@ typedef struct _oe_parsed_tcb_info * If the plaform's tcb level status was determined to be not uptodate, * then OE_TCB_LEVEL_INVALID is returned. * + * @param[in] tcb_info_json The json string to parse. + * @param[in] tcb_info_json_size The string length of info_json + * @param[in] platform_tcb_level The platform tcb level. + * The sgx_tcb_comp_svn and pce_svn fields are required to be + * set. + * @param[out] parsed_info The parsed results. */ oe_result_t oe_parse_tcb_info_json( const uint8_t* tcb_info_json, size_t tcb_info_json_size, - oe_tcb_level_t* platform_tcb_level, + oe_tcb_info_tcb_level_t* platform_tcb_level, oe_parsed_tcb_info_t* parsed_info); oe_result_t oe_verify_ecdsa256_signature( @@ -76,29 +122,96 @@ oe_result_t oe_verify_ecdsa256_signature( sgx_ecdsa256_signature_t* signature, oe_cert_chain_t* tcb_cert_chain); +/*! \enum oe_qe_identity_id + * \brief Quoting enclave identity id (V2 only) + */ +typedef enum _oe_qe_identity_id +{ + QE_IDENTITY_ID_QE, + QE_IDENTITY_ID_QVE +} oe_qe_identity_id_t; + +/*! \struct oe_qe_tcb_level + * \brief Quoting enclave identity TCB level. Applies to V2 only. + */ +typedef struct _oe_qe_identity_info_tcb_level +{ + uint32_t isvsvn[1]; + oe_tcb_level_status_t tcb_status; + oe_datetime_t tcb_date; + + /*! Offset into the json QE Identity info where + * the advisoryIDs fields start. + */ + size_t advisory_ids_offset; + + //! Total size of all the advisoryIDs. + size_t advisory_ids_size; +} oe_qe_identity_info_tcb_level_t; + +/*! \struct oe_parsed_qe_identity_info_t + * \brief SGX Quoting Enclave Identity Info data structure. + */ typedef struct _oe_parsed_qe_identity_info { uint32_t version; oe_datetime_t issue_date; oe_datetime_t next_update; - uint32_t miscselect; // The MISCSELECT that must be set - uint32_t miscselect_mask; // Mask of MISCSELECT to enforce - sgx_attributes_t attributes; // flags and xfrm (XSAVE-Feature Request Mask) - uint64_t attributes_flags_mask; // mask for attributes.flags - uint64_t attributes_xfrm_mask; // mask for attributes.xfrm - uint8_t mrsigner[OE_SHA256_SIZE]; // MRSIGNER of the enclave - uint16_t isvprodid; // ISV assigned Product ID - uint16_t isvsvn; // ISV assigned SVN + uint32_t miscselect; //! The MISCSELECT that must be set + uint32_t miscselect_mask; //! Mask of MISCSELECT to enforce + sgx_attributes_t attributes; //! flags and xfrm (XSAVE-Feature Request Mask) + uint64_t attributes_flags_mask; //! mask for attributes.flags + uint64_t attributes_xfrm_mask; //! mask for attributes.xfrm + uint8_t mrsigner[OE_SHA256_SIZE]; //! MRSIGNER of the enclave + uint16_t isvprodid; //! ISV assigned Product ID + uint16_t isvsvn; //! ISV assigned SVN uint8_t signature[64]; + + // V2 fields + oe_qe_identity_id_t id; + uint32_t tcb_evaluation_data_number; + oe_qe_identity_info_tcb_level_t tcb_level; + const uint8_t* info_start; size_t info_size; } oe_parsed_qe_identity_info_t; +/*! + * Parse a QE or QVE identity json string. + * + * @param[in] info_json The json string to parse. + * @param[in] info_json_size The string length of info_json + * @param[in,out] platform_tcb_level The platform tcb level. + * The platform isvsvn is required to be set as input. + * The status field is updated as output. + * @param[out] parsed_info The parsed results. + */ oe_result_t oe_parse_qe_identity_info_json( const uint8_t* info_json, size_t info_json_size, + oe_qe_identity_info_tcb_level_t* platform_tcb_level, oe_parsed_qe_identity_info_t* parsed_info); +/*! + * Parse an advisoryIDs field json string. + * + * @param[in] json Json string to parse. + * @param[in] json_size Length of the json string. + * @param[out] id_array Array of char* to store the resulting advisoryIDs. + * @param[in] json_size The number of elements in array id_array. + * @param[out] id_sizes_array Array of the length of each id in id_array. + * @param[in] id_sizes_size The number of elements in array id_sizes_array. + * @param[out] num_ids The number of advisoryIDs set in id_array. + */ +oe_result_t oe_parse_advisoryids_json( + const uint8_t* json, + size_t json_size, + const uint8_t** id_array, + size_t id_array_size, + size_t* id_sizes_array, + size_t id_sizes_size, + size_t* num_ids); + OE_EXTERNC_END #endif // _OE_COMMON_TCBINFO_H diff --git a/common/sgx/tlsverifier.c b/common/sgx/tlsverifier.c index 120a29e11d..4531510c67 100644 --- a/common/sgx/tlsverifier.c +++ b/common/sgx/tlsverifier.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -10,6 +10,7 @@ #include #include #include "../common/common.h" +#include "quote.h" #define KEY_BUFF_SIZE 2048 @@ -127,7 +128,8 @@ oe_result_t oe_verify_attestation_certificate( #ifdef OE_BUILD_ENCLAVE result = oe_verify_report(report, report_size, &parsed_report); #else - result = oe_verify_remote_report(report, report_size, &parsed_report); + result = + oe_verify_remote_report(report, report_size, NULL, 0, &parsed_report); #endif OE_CHECK(result); OE_TRACE_VERBOSE("quote validation succeeded"); diff --git a/common/sgx/verifier.c b/common/sgx/verifier.c new file mode 100644 index 0000000000..02ad6b821e --- /dev/null +++ b/common/sgx/verifier.c @@ -0,0 +1,461 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include + +#include "../common.h" +#include "endorsements.h" +#include "quote.h" +#if defined(OE_LINK_SGX_DCAP_QL) && !defined(OE_BUILD_ENCLAVE) +#include "../../host/sgx/sgxquoteprovider.h" +#endif + +static oe_result_t _on_register( + oe_attestation_role_t* context, + const void* config_data, + size_t config_data_size) +{ + OE_UNUSED(context); + OE_UNUSED(config_data); + OE_UNUSED(config_data_size); + +#if defined(OE_BUILD_ENCLAVE) || !defined(OE_LINK_SGX_DCAP_QL) + return OE_OK; +#else + return oe_initialize_quote_provider(); +#endif +} + +static oe_result_t _on_unregister(oe_attestation_role_t* context) +{ + OE_UNUSED(context); + return OE_OK; +} + +static void _free_claim(oe_claim_t* claim) +{ + oe_free(claim->name); + oe_free(claim->value); +} + +static oe_result_t _free_claims_list( + oe_verifier_t* context, + oe_claim_t* claims, + size_t claims_length) +{ + OE_UNUSED(context); + if (!claims) + return OE_OK; + + for (size_t i = 0; i < claims_length; i++) + _free_claim(&claims[i]); + oe_free(claims); + return OE_OK; +} + +static oe_result_t _get_input_time( + const oe_policy_t* policies, + size_t policies_size, + oe_datetime_t** time) +{ + if (!policies) + { + *time = NULL; + return OE_OK; + } + + for (size_t i = 0; i < policies_size; i++) + { + if (policies[i].type == OE_POLICY_ENDORSEMENTS_TIME) + { + if (policies[i].policy_size != sizeof(**time)) + return OE_INVALID_PARAMETER; + + *time = (oe_datetime_t*)policies[i].policy; + return OE_OK; + } + } + + // Time not found, which is fine since it's an optional parameter. + *time = NULL; + return OE_OK; +} + +static oe_result_t _verify_local_report( + const uint8_t* evidence_buffer, + size_t evidence_buffer_size) +{ + // Do a normal report verification on the enclave side. + // Local report verification is unsupported for host side. +#ifdef OE_BUILD_ENCLAVE + return oe_verify_report(evidence_buffer, evidence_buffer_size, NULL); +#else + OE_UNUSED(evidence_buffer); + OE_UNUSED(evidence_buffer_size); + return OE_UNSUPPORTED; +#endif +} + +static oe_result_t _add_claim( + oe_claim_t* claim, + void* name, + size_t name_size, + void* value, + size_t value_size) +{ + if (*((uint8_t*)name + name_size - 1) != '\0') + return OE_CONSTRAINT_FAILED; + + claim->name = (char*)oe_malloc(name_size); + if (claim->name == NULL) + return OE_OUT_OF_MEMORY; + memcpy(claim->name, name, name_size); + + claim->value = (uint8_t*)oe_malloc(value_size); + if (claim->value == NULL) + { + oe_free(claim->name); + return OE_OUT_OF_MEMORY; + } + memcpy(claim->value, value, value_size); + claim->value_size = value_size; + + return OE_OK; +} + +static oe_result_t _fill_with_known_claims( + const uint8_t* report, + size_t report_size, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_claim_t* claims, + size_t claims_length, + size_t* claims_added) +{ + oe_result_t result = OE_UNEXPECTED; + oe_report_t parsed_report = {0}; + oe_identity_t* id = &parsed_report.identity; + oe_uuid_t plugin_id = {OE_SGX_PLUGIN_UUID}; + size_t claims_index = 0; + oe_report_header_t* header = (oe_report_header_t*)report; + oe_datetime_t valid_from = {0}; + oe_datetime_t valid_until = {0}; + + if (claims_length < OE_REQUIRED_CLAIMS_COUNT) + OE_RAISE(OE_INVALID_PARAMETER); + + OE_CHECK(oe_parse_report(report, report_size, &parsed_report)); + + if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE && + claims_length < OE_REQUIRED_CLAIMS_COUNT + OE_OPTIONAL_CLAIMS_COUNT) + OE_RAISE(OE_INVALID_PARAMETER); + + // ID version. + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_ID_VERSION, + sizeof(OE_CLAIM_ID_VERSION), + &id->id_version, + sizeof(id->id_version))); + + // Security version. + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_SECURITY_VERSION, + sizeof(OE_CLAIM_SECURITY_VERSION), + &id->security_version, + sizeof(id->security_version))); + + // Attributes. + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_ATTRIBUTES, + sizeof(OE_CLAIM_ATTRIBUTES), + &id->attributes, + sizeof(id->attributes))); + + // Unique ID + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_UNIQUE_ID, + sizeof(OE_CLAIM_UNIQUE_ID), + &id->unique_id, + sizeof(id->unique_id))); + + // Signer ID + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_SIGNER_ID, + sizeof(OE_CLAIM_SIGNER_ID), + &id->signer_id, + sizeof(id->signer_id))); + + // Product ID + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_PRODUCT_ID, + sizeof(OE_CLAIM_PRODUCT_ID), + &id->product_id, + sizeof(id->product_id))); + + // Plugin UUID + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_PLUGIN_UUID, + sizeof(OE_CLAIM_PLUGIN_UUID), + &plugin_id, + sizeof(plugin_id))); + + if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE) + { + // Get quote validity periods to get validity from and until claims. + OE_CHECK(oe_get_sgx_quote_validity( + header->report, + header->report_size, + sgx_endorsements, + &valid_from, + &valid_until)); + + // Validity from. + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_VALIDITY_FROM, + sizeof(OE_CLAIM_VALIDITY_FROM), + &valid_from, + sizeof(valid_from))); + + // Validity to. + OE_CHECK(_add_claim( + &claims[claims_index++], + OE_CLAIM_VALIDITY_UNTIL, + sizeof(OE_CLAIM_VALIDITY_UNTIL), + &valid_until, + sizeof(valid_until))); + } + + *claims_added = claims_index; + result = OE_OK; + +done: + if (result != OE_OK) + { + for (size_t i = 0; i < claims_index; i++) + _free_claim(&claims[i]); + } + return result; +} + +static oe_result_t _fill_with_custom_claims( + const uint8_t* claims_buf, + size_t claims_buf_size, + oe_claim_t* claims, + size_t claims_length) +{ + oe_result_t result = OE_UNEXPECTED; + oe_sgx_plugin_claims_header_t* header = + (oe_sgx_plugin_claims_header_t*)claims_buf; + size_t claims_index = 0; + + if (claims_length < header->num_claims) + OE_RAISE(OE_INVALID_PARAMETER); + + claims_buf += sizeof(*header); + claims_buf_size -= sizeof(*header); + for (uint64_t i = 0; i < header->num_claims; i++) + { + oe_sgx_plugin_claims_entry_t* entry = + (oe_sgx_plugin_claims_entry_t*)claims_buf; + uint64_t size; + + // Sanity check sizes. + if (claims_buf_size < sizeof(*entry)) + OE_RAISE(OE_CONSTRAINT_FAILED); + + OE_CHECK(oe_safe_add_u64(sizeof(*entry), entry->name_size, &size)); + OE_CHECK(oe_safe_add_u64(size, entry->value_size, &size)); + + if (claims_buf_size < size) + OE_RAISE(OE_CONSTRAINT_FAILED); + + // Finally, add the claim. + OE_CHECK(_add_claim( + &claims[claims_index++], + entry->name, + entry->name_size, + entry->name + entry->name_size, + entry->value_size)); + + // Go to next entry. + claims_buf += size; + claims_buf_size -= size; + } + + result = OE_OK; + +done: + if (result != OE_OK) + { + for (size_t i = 0; i < claims_index; i++) + _free_claim(&claims[i]); + } + return result; +} + +static oe_result_t _extract_claims( + const uint8_t* evidence, + size_t evidence_size, + const oe_sgx_endorsements_t* sgx_endorsements, + oe_claim_t** claims_out, + size_t* claims_length_out) +{ + oe_result_t result = OE_UNEXPECTED; + oe_report_header_t* header = (oe_report_header_t*)evidence; + oe_sgx_plugin_claims_header_t* claims_header = NULL; + size_t report_size = sizeof(*header) + header->report_size; + oe_claim_t* claims = NULL; + uint64_t claims_length = 0; + uint64_t claims_size = 0; + size_t claims_added = 0; + + // Check if the buffer is the proper size. + if (evidence_size - report_size < sizeof(*claims_header)) + OE_RAISE(OE_INVALID_PARAMETER); + + claims_header = (oe_sgx_plugin_claims_header_t*)(evidence + report_size); + + // Get the number of claims we need and allocate the claims. + OE_CHECK(oe_safe_add_u64( + OE_REQUIRED_CLAIMS_COUNT, claims_header->num_claims, &claims_length)); + + if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE) + { + OE_CHECK(oe_safe_add_u64( + claims_length, OE_OPTIONAL_CLAIMS_COUNT, &claims_length)); + } + + OE_CHECK(oe_safe_mul_u64(claims_length, sizeof(oe_claim_t), &claims_size)); + + claims = (oe_claim_t*)oe_malloc(claims_size); + if (claims == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + // Fill the list with the known claims. + OE_CHECK(_fill_with_known_claims( + evidence, + report_size, + sgx_endorsements, + claims, + claims_length, + &claims_added)); + + // Fill with the custom claims. + OE_CHECK(_fill_with_custom_claims( + evidence + report_size, + evidence_size - report_size, + claims + claims_added, + claims_length - claims_added)); + + *claims_out = claims; + *claims_length_out = claims_length; + claims = NULL; + result = OE_OK; + +done: + if (claims) + _free_claims_list(NULL, claims, claims_length); + return result; +} + +static oe_result_t _verify_evidence( + oe_verifier_t* context, + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length) +{ + oe_result_t result = OE_UNEXPECTED; + oe_report_header_t* header = (oe_report_header_t*)evidence_buffer; + oe_datetime_t* time = NULL; + uint8_t* local_endorsements_buffer = NULL; + size_t local_endorsements_buffer_size = 0; + oe_sgx_endorsements_t sgx_endorsements; + OE_UNUSED(context); + + if (!evidence_buffer || !claims || !claims_length || + evidence_buffer_size < sizeof(*header) || + evidence_buffer_size - sizeof(*header) < header->report_size) + OE_RAISE(OE_INVALID_PARAMETER); + + // Check the datetime policy if it exists. + OE_CHECK(_get_input_time(policies, policies_size, &time)); + + // Verify the report. Send the report size to just the oe report, + // not including the custom claims section. + if (header->report_type == OE_REPORT_TYPE_SGX_LOCAL) + { + OE_CHECK(_verify_local_report( + evidence_buffer, header->report_size + sizeof(oe_report_header_t))); + } + else + { + // Get the endorsements if none were provided. + if (endorsements_buffer == NULL) + { + OE_CHECK(oe_get_sgx_endorsements( + header->report, + header->report_size, + &local_endorsements_buffer, + &local_endorsements_buffer_size)); + endorsements_buffer = local_endorsements_buffer; + endorsements_buffer_size = local_endorsements_buffer_size; + } + + // Parse into SGX endorsements. + OE_CHECK(oe_parse_sgx_endorsements( + (oe_endorsements_t*)endorsements_buffer, + endorsements_buffer_size, + &sgx_endorsements)); + + // Verify the quote now. + OE_CHECK(oe_verify_quote_with_sgx_endorsements( + header->report, header->report_size, &sgx_endorsements, time)); + } + + // Last step is to return the required and custom claims. + OE_CHECK(_extract_claims( + evidence_buffer, + evidence_buffer_size, + &sgx_endorsements, + claims, + claims_length)); + + result = OE_OK; + +done: + if (local_endorsements_buffer) + oe_free_sgx_endorsements(local_endorsements_buffer); + + return result; +} + +static oe_verifier_t _verifier = {.base = + { + .format_id = {OE_SGX_PLUGIN_UUID}, + .on_register = &_on_register, + .on_unregister = &_on_unregister, + }, + .verify_evidence = &_verify_evidence, + .free_claims_list = &_free_claims_list}; + +oe_verifier_t* oe_sgx_plugin_verifier() +{ + return &_verifier; +} diff --git a/common/sgx/verify_eeid.c b/common/sgx/verify_eeid.c new file mode 100644 index 0000000000..98ea85dd20 --- /dev/null +++ b/common/sgx/verify_eeid.c @@ -0,0 +1,225 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "../../host/sgx/sgxmeasure.h" +#include "../common/sgx/quote.h" + +#ifdef OE_BUILD_ENCLAVE +#include +#include "../../enclave/crypto/key.h" +#include "../../enclave/crypto/rsa.h" +#else +#include +#include +#include "../../host/crypto/openssl/key.h" +#include "../../host/crypto/openssl/rsa.h" +#endif + +#include "verify_eeid.h" + +static bool is_zero(const uint8_t* buf, size_t sz) +{ + while (sz != 0) + if (buf[--sz] != 0) + return false; + return true; +} + +oe_result_t verify_eeid(oe_report_t* report, const oe_eeid_t* eeid) +{ + oe_result_t result = OE_UNEXPECTED; + + if (!eeid || !report) + OE_RAISE(OE_INVALID_PARAMETER); + + if (oe_get_current_logging_level() >= OE_LOG_LEVEL_WARNING) + { + char buf[2 * (sizeof(oe_eeid_t) + eeid->data_size) + 8]; + OE_CHECK(oe_serialize_eeid(eeid, buf, sizeof(buf))); + printf("EEID:\n%s", buf); + } + + // Recompute extended mrenclave + oe_sha256_context_t hctx; + oe_sha256_restore(&hctx, eeid->hash_state_H, eeid->hash_state_N); + + size_t eeid_sz = sizeof(oe_eeid_t) + eeid->data_size; + size_t num_pages = oe_round_up_to_page_size(eeid_sz) / OE_PAGE_SIZE; + oe_page_t* pages = (oe_page_t*)eeid; + uint64_t enclave_base = 0x0ab0c0d0e0f; + uint64_t addr = enclave_base + eeid->data_vaddr; + + for (size_t i = 0; i < num_pages; i++) + { + uint8_t* page = (uint8_t*)&pages[i]; + + if (i == num_pages - 1 && eeid_sz % OE_PAGE_SIZE != 0) + { + uint8_t* npage = calloc(1, OE_PAGE_SIZE); + memcpy(npage, page, eeid_sz % OE_PAGE_SIZE); + page = npage; + } + + OE_CHECK(oe_sgx_measure_load_enclave_data( + &hctx, + (uint64_t)enclave_base, + addr, + (uint64_t)page, + SGX_SECINFO_REG | SGX_SECINFO_R, + true)); + + if (i == num_pages - 1 && eeid_sz % OE_PAGE_SIZE != 0) + free(page); + + addr += OE_PAGE_SIZE; + } + + OE_SHA256 cpt_mrenclave; + oe_sha256_final(&hctx, &cpt_mrenclave); + + // Extract reported mrenclave + OE_SHA256 reported_mrenclave; + uint8_t reported_mrsigner[OE_SIGNER_ID_SIZE]; + + memcpy(reported_mrenclave.buf, report->identity.unique_id, OE_SHA256_SIZE); + memcpy(reported_mrsigner, report->identity.signer_id, OE_SIGNER_ID_SIZE); + + // Check recomputed mrenclave against reported mrenclave + if (memcmp(cpt_mrenclave.buf, reported_mrenclave.buf, OE_SHA256_SIZE) != 0) + OE_RAISE(OE_VERIFY_FAILED); + + static const uint8_t debug_public_key[] = { + 0xca, 0x9a, 0xd7, 0x33, 0x14, 0x48, 0x98, 0x0a, 0xa2, 0x88, 0x90, + 0xce, 0x73, 0xe4, 0x33, 0x63, 0x83, 0x77, 0xf1, 0x79, 0xab, 0x44, + 0x56, 0xb2, 0xfe, 0x23, 0x71, 0x93, 0x19, 0x3a, 0x8d, 0xa}; + + if (memcmp(debug_public_key, reported_mrsigner, OE_SIGNER_ID_SIZE) != 0) + OE_RAISE(OE_VERIFY_FAILED); + + const sgx_sigstruct_t* sigstruct = (const sgx_sigstruct_t*)&eeid->sigstruct; + + uint16_t ppid = (uint16_t)(report->identity.product_id[1] << 8) + + (uint16_t)report->identity.product_id[0]; + + bool sigstruct_debug = sigstruct->attributes.flags & SGX_FLAGS_DEBUG; + bool reported_debug = + report->identity.attributes & OE_REPORT_ATTRIBUTES_DEBUG; + + if (sigstruct_debug != reported_debug || sigstruct->isvprodid != ppid || + sigstruct->isvsvn != report->identity.security_version) + OE_RAISE(OE_VERIFY_FAILED); + + // Check old signature (new signature has been checked above) + if (sigstruct_debug && is_zero(sigstruct->signature, OE_KEY_SIZE)) + return OE_OK; // Unsigned debug image is ok? + else + { + // OE_SHA256 mrsigner; + // oe_sha256_init(&hctx); + // oe_sha256_update(&hctx, sigstruct->modulus, OE_KEY_SIZE); + // oe_sha256_final(&hctx, &mrsigner); + + unsigned char buf[sizeof(sgx_sigstruct_t)]; + size_t n = 0; + + OE_CHECK(oe_memcpy_s( + buf, + sizeof(buf), + sgx_sigstruct_header(sigstruct), + sgx_sigstruct_header_size())); + n += sgx_sigstruct_header_size(); + OE_CHECK(oe_memcpy_s( + &buf[n], + sizeof(buf) - n, + sgx_sigstruct_body(sigstruct), + sgx_sigstruct_body_size())); + n += sgx_sigstruct_body_size(); + + OE_SHA256 msg_hsh; + oe_sha256_context_t context; + + oe_sha256_init(&context); + oe_sha256_update(&context, buf, n); + oe_sha256_final(&context, &msg_hsh); + + uint8_t reversed_modulus[OE_KEY_SIZE]; + for (size_t i = 0; i < OE_KEY_SIZE; i++) + reversed_modulus[i] = sigstruct->modulus[OE_KEY_SIZE - 1 - i]; + + uint8_t reversed_exponent[OE_KEY_SIZE]; + for (size_t i = 0; i < OE_EXPONENT_SIZE; i++) + reversed_exponent[i] = + sigstruct->exponent[OE_EXPONENT_SIZE - 1 - i]; + + uint8_t reversed_signature[OE_KEY_SIZE]; + for (size_t i = 0; i < OE_KEY_SIZE; i++) + reversed_signature[i] = sigstruct->signature[OE_KEY_SIZE - 1 - i]; + + oe_rsa_public_key_t pk; +#ifdef OE_BUILD_ENCLAVE + mbedtls_pk_context pkctx; + mbedtls_pk_init(&pkctx); + const mbedtls_pk_info_t* info = + mbedtls_pk_info_from_type(MBEDTLS_PK_RSA); + mbedtls_pk_setup(&pkctx, info); + + mbedtls_rsa_context* rsa_ctx = mbedtls_pk_rsa(pkctx); + mbedtls_rsa_init(rsa_ctx, 0, 0); + mbedtls_rsa_import_raw( + rsa_ctx, + reversed_modulus, + OE_KEY_SIZE, // N + NULL, + 0, + NULL, + 0, + NULL, + 0, // P Q D + reversed_exponent, + OE_EXPONENT_SIZE); + if (mbedtls_rsa_check_pubkey(rsa_ctx) != 0) + OE_RAISE(OE_INVALID_PARAMETER); + mbedtls_pk_context* ikey = &pkctx; +#else + BIGNUM* rm = BN_bin2bn(reversed_modulus, OE_KEY_SIZE, 0); + BIGNUM* re = BN_bin2bn(reversed_exponent, OE_EXPONENT_SIZE, 0); + RSA* rsa = RSA_new(); + RSA_set0_key(rsa, rm, re, NULL); + EVP_PKEY* ikey = EVP_PKEY_new(); + EVP_PKEY_assign_RSA(ikey, rsa); +#endif + oe_rsa_public_key_init(&pk, ikey); + + OE_CHECK(oe_rsa_public_key_verify( + &pk, + OE_HASH_TYPE_SHA256, + msg_hsh.buf, + sizeof(msg_hsh.buf), + reversed_signature, + OE_KEY_SIZE)); + + oe_rsa_public_key_free(&pk); + +#ifdef OE_BUILD_ENCLAVE + mbedtls_pk_free(ikey); +#else + EVP_PKEY_free(ikey); +#endif + } + +done: + + return result; +} diff --git a/common/sgx/verify_eeid.h b/common/sgx/verify_eeid.h new file mode 100644 index 0000000000..1eb8710d58 --- /dev/null +++ b/common/sgx/verify_eeid.h @@ -0,0 +1,11 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_VERIFY_EEID_H +#define _OE_VERIFY_EEID_H + +#include + +oe_result_t verify_eeid(oe_report_t* report, const oe_eeid_t* eeid); + +#endif /* _OE_VERIFY_EEID_H */ diff --git a/common/syscall.edl b/common/syscall.edl index 6f80d2bec0..7add35a379 100644 --- a/common/syscall.edl +++ b/common/syscall.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/common/tee.edl b/common/tee.edl index 394e4a5341..93a5731289 100644 --- a/common/tee.edl +++ b/common/tee.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/debugger/CMakeLists.txt b/debugger/CMakeLists.txt index 8e7dc11535..3fb8bdad75 100644 --- a/debugger/CMakeLists.txt +++ b/debugger/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (UNIX) diff --git a/debugger/debugrt/CMakeLists.txt b/debugger/debugrt/CMakeLists.txt index 576230d627..0a87cd9fb5 100644 --- a/debugger/debugrt/CMakeLists.txt +++ b/debugger/debugrt/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (OE_SGX) diff --git a/debugger/debugrt/host/CMakeLists.txt b/debugger/debugrt/host/CMakeLists.txt index 2aa7c48fd2..24c2b7852a 100644 --- a/debugger/debugrt/host/CMakeLists.txt +++ b/debugger/debugrt/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (UNIX) @@ -17,8 +17,7 @@ else() OE_BUILDING_DEBUGRT_SHARED_LIBRARY) install(TARGETS oedebugrt EXPORT openenclave-targets - # TODO:Determine DLL install location on Windows - ARCHIVE DESTINATION ${CMAKE_INSTALL_BINDIR}) + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() target_include_directories(oedebugrt PRIVATE diff --git a/debugger/debugrt/host/host.c b/debugger/debugrt/host/host.c index c9ba6b5047..5ad48ef5ef 100644 --- a/debugger/debugrt/host/host.c +++ b/debugger/debugrt/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/debugger/oe-gdb b/debugger/oe-gdb index 6be1718db6..f0771205a9 100644 --- a/debugger/oe-gdb +++ b/debugger/oe-gdb @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" diff --git a/debugger/oegdb b/debugger/oegdb index dcea8b9ad4..17e0866830 100755 --- a/debugger/oegdb +++ b/debugger/oegdb @@ -1,13 +1,15 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Get path of the oegdb script # See https://mywiki.wooledge.org/BashFAQ/028 for complexities involved # in determining location of a bash script. ${BASH_SOURCE}, though not perfect, # is an acceptable solution for oegdb. -OE_GDB_DIR=$(dirname "${BASH_SOURCE[0]}") +# readlink provides additional benefit in getting the absolute path +# to the script directory for systems where BASH_SOURCE is only relative. +OE_GDB_DIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")") # Get the path to the debugger libraries relative to the oegdb path. # Normalize the path by cd-ing and doing a pwd -P. diff --git a/debugger/ptraceLib/CMakeLists.txt b/debugger/ptraceLib/CMakeLists.txt index 49c7f8b831..1b1fe2ff3e 100644 --- a/debugger/ptraceLib/CMakeLists.txt +++ b/debugger/ptraceLib/CMakeLists.txt @@ -1,9 +1,9 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. find_library(DL_LIB NAMES dl) -add_library(dl SHARED IMPORTED) -set_target_properties(dl PROPERTIES IMPORTED_LOCATION ${DL_LIB}) +add_library(openenclave::dl SHARED IMPORTED) +set_target_properties(openenclave::dl PROPERTIES IMPORTED_LOCATION ${DL_LIB}) find_package(Threads REQUIRED) @@ -12,7 +12,7 @@ add_library(oe_ptrace SHARED inferior_status.c enclave_context.c) -target_link_libraries(oe_ptrace oe_includes dl Threads::Threads) +target_link_libraries(oe_ptrace oe_includes openenclave::dl Threads::Threads) target_compile_options(oe_ptrace PRIVATE -Wall -Werror -Wno-attributes -Wmissing-prototypes -m64) diff --git a/debugger/ptraceLib/enclave_context.c b/debugger/ptraceLib/enclave_context.c index 3523a245c2..ac9b614141 100644 --- a/debugger/ptraceLib/enclave_context.c +++ b/debugger/ptraceLib/enclave_context.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "enclave_context.h" diff --git a/debugger/ptraceLib/enclave_context.h b/debugger/ptraceLib/enclave_context.h index 4714e059b5..ed732c908a 100644 --- a/debugger/ptraceLib/enclave_context.h +++ b/debugger/ptraceLib/enclave_context.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_CONTEXT_H diff --git a/debugger/ptraceLib/inferior_status.c b/debugger/ptraceLib/inferior_status.c index 3de9174207..7002dcea5d 100644 --- a/debugger/ptraceLib/inferior_status.c +++ b/debugger/ptraceLib/inferior_status.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "inferior_status.h" diff --git a/debugger/ptraceLib/inferior_status.h b/debugger/ptraceLib/inferior_status.h index c3b44f9b65..742ef0e546 100644 --- a/debugger/ptraceLib/inferior_status.h +++ b/debugger/ptraceLib/inferior_status.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INFERIOR_STATUS_H_ diff --git a/debugger/ptraceLib/oe_ptrace.c b/debugger/ptraceLib/oe_ptrace.c index bef9e51eec..80ade61f70 100644 --- a/debugger/ptraceLib/oe_ptrace.c +++ b/debugger/ptraceLib/oe_ptrace.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/debugger/pythonExtension/CMakeLists.txt b/debugger/pythonExtension/CMakeLists.txt index 00c6757191..b0ca53396f 100644 --- a/debugger/pythonExtension/CMakeLists.txt +++ b/debugger/pythonExtension/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Copy files during build diff --git a/debugger/pythonExtension/gdb_sgx_plugin.py b/debugger/pythonExtension/gdb_sgx_plugin.py index 285111e150..fa257be403 100644 --- a/debugger/pythonExtension/gdb_sgx_plugin.py +++ b/debugger/pythonExtension/gdb_sgx_plugin.py @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. from __future__ import print_function @@ -78,7 +78,7 @@ def is_valid(self): # This constant definition must align with the OE enclave layout. -TD_OFFSET_FROM_TCS = 0X4000 +TD_OFFSET_FROM_TCS = 0X5000 # This constant definition must align with TD structure in internal\sgxtypes.h. TD_CALLSITE_OFFSET = 0XF0 diff --git a/debugger/pythonExtension/load_symbol_cmd.py b/debugger/pythonExtension/load_symbol_cmd.py index f87da4bdbd..10d52b6cfb 100644 --- a/debugger/pythonExtension/load_symbol_cmd.py +++ b/debugger/pythonExtension/load_symbol_cmd.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright (C) 2011-2017 Intel Corporation. All rights reserved. +# Copyright (C) 2011-2019 Intel Corporation. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -30,6 +30,8 @@ # # +# -*- coding: iso-8859-15 -*- + try: from cStringIO import StringIO except ImportError: @@ -54,7 +56,7 @@ def GetLoadSymbolCommand(EnclaveFile, Base): # their offsets and add the Proj base address. for line in FileList: list = line.split(); - if(len(list) > 0): + if(len(list) > 1): SegOffset = -1; # The readelf will put a space after the open bracket for single # digit section numbers. This causes the line.split to create diff --git a/docs/CODEOWNERS b/docs/CODEOWNERS new file mode 100644 index 0000000000..fbe11d3cb6 --- /dev/null +++ b/docs/CODEOWNERS @@ -0,0 +1,53 @@ +# Each line is a file pattern followed by one or more owners. +# Refer to https://help.github.com/en/articles/about-code-owners + +# Order is important; the last matching pattern takes the most +# precedence. Try to keep at least two owners per pattern. + +# These owners will be the default owners for everything in the repo. +# Unless a later match takes precedence, they will be requested for +# review when someone opens a pull request. +* @openenclave/committers + +/3rdparty/ @mikbras @CodeMonkeyLeet +/cmake/ @andschwa @BRMcLaren +/common/ @CodeMonkeyLeet @gupta-ak @mikbras +/docs/refman @andschwa @radhikaj +/debugger/ @anakrish @jxyang +/enclave/ @CodeMonkeyLeet @gupta-ak @mikbras +/host/ @CodeMonkeyLeet @gupta-ak @mikbras +# TODO: Break this folder out? +/include/ @achamayou @dthaler @mikbras @CodeMonkeyLeet +/libc/ @mikbras @CodeMonkeyLeet +/scripts/ @achamayou @andschwa @johnkord +/samples/ @andschwa @dthaler @soccerGB +/syscall/ @mikbras @yakman2020 +# TODO: Break this folder out? +/tests/ @radhikaj +/tools/ @anakrish @CodeMonkeyLeet +/tools/oeedger8r/ @andschwa @anakrish @jxyang +/pkgconfig/ @gupta-ak @mikbras +/prereqs/ @johnkord @CodeMonkeyLeet + +# Matches all folders with these names, not just in root. +optee/ @Britel @dthaler @HernanGatta +sgx/ @CodeMonkeyLeet @gupta-ak @mikbras +linux/ @mikbras @yakman2020 +windows/ @CodeMonkeyLeet @yakman2020 +crypto/ @CodeMonkeyLeet @gupta-ak + +# Match all CMake, anywhere. +CMakeLists.txt @andschwa @BRMcLaren +*.cmake @andschwa @BRMcLaren + +# Match all Markdown, anywhere. +*.md @CodeMonkeyLeet @johnkord @andschwa @radhikaj + +# Except design reviews, which should be everyone. +/docs/DesignDocs/ @openenclave/committers + +# And governance documents. +/docs/Contributing.md @openenclave/committee +/docs/Governance.md @openenclave/committee +/docs/Committers.md @openenclave/committee +/docs/Releasing.md @openenclave/committee diff --git a/docs/CodeOfConduct.md b/docs/CodeOfConduct.md new file mode 100644 index 0000000000..30915ee2f3 --- /dev/null +++ b/docs/CodeOfConduct.md @@ -0,0 +1,76 @@ +# Open Enclave SDK Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to make participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies within all project spaces, and it also applies when +an individual is representing the project or its community in public spaces. +Examples of representing a project or community include using an official +project e-mail address, posting via an official social media account, or acting +as an appointed representative at an online or offline event. Representation of +a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting any member of the [Community Governance Committee]( +Committers.md#Committee_Members). All complaints will be reviewed and investigated +and will result in a response that is deemed necessary and appropriate to the +circumstances. The project team is obligated to maintain confidentiality with +regard to the reporter of an incident. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see +https://www.contributor-covenant.org/faq diff --git a/docs/Maintainers.md b/docs/Committers.md similarity index 59% rename from docs/Maintainers.md rename to docs/Committers.md index bdbecdc0bf..10a0c3efe4 100644 --- a/docs/Maintainers.md +++ b/docs/Committers.md @@ -1,41 +1,55 @@ -Community Maintenance Committee -=============================== +Community Governance Committee +============================== -This document describes the Community Maintenance Committee of Open Enclave. By +This document describes the Open Enclave Community Governance Committee. By our liberal contribution policy outlined in our -[governance model](GovernanceModel.md), maintainers are committers that are +[governance model](Governance.md), Committee members are committers that are trusted to grant new committer rights, and grant new membership into the Committee. -When making decisions, the Community Maintenance Committee uses a "consensus +When making decisions, the Community Governance Committee uses a "consensus seeking" process. This means that most decisions should be reached by consensus, but when that fails, the Committee calls for a vote where the super majority (two-thirds) wins. This is to prevent obstructionism by removing the possibility of a one person veto. +Quorum for Community Governance Committee meetings requires at least two-thirds +all members of the Community Governance Committee to be present. The +Community Governance Committee may continue to meet if quorum is not met but will +be prevented from making any decisions at the meeting. + +All decisions by vote, whether during a meeting or otherwise, require a super majority +vote of all members of the Community Governance Committee. + +The running minutes for the Community Governance Community meetings are located +at [aka.ms/openenclave/cgc](https://aka.ms/openenclave/cgc). + Committee Members ----------------- -| Name | Company | Email | GitHub Alias | -|----------------------|-----------|-------------------------------|----------------| -| Akash Gupta | Microsoft | akagup@microsoft.com | gupta-ak | -| Amaury Chamayou | Microsoft | amaury.chamayou@microsoft.com | achamayou | -| Anand Krishnamoorthi | Microsoft | anakrish@microsoft.com | anakrish | -| Andrew Schwartzmeyer | Microsoft | andschwa@microsoft.com | andschwa | -| Dave Thaler | Microsoft | dthaler@microsoft.com | dthaler | -| John Kordich | Microsoft | johnkord@microsoft.com | johnkord | -| Mike Brasher | Microsoft | mikbras@microsoft.com | mikbras | -| Simon Leet | Microsoft | simon.leet@microsoft.com | CodeMonkeyLeet | +| Name | Company | Email | GitHub Alias | +|----------------------|-------------|-------------------------------|----------------| +| Akash Gupta | Microsoft | akagup@microsoft.com | gupta-ak | +| Amaury Chamayou | Microsoft | amaury.chamayou@microsoft.com | achamayou | +| Anand Krishnamoorthi | Microsoft | anakrish@microsoft.com | anakrish | +| Andrew Schwartzmeyer | Microsoft | andschwa@microsoft.com | andschwa | +| Dave Thaler | Microsoft | dthaler@microsoft.com | dthaler | +| John Kordich | Independent | jkordich@gmail.com | johnkord | +| Mike Brasher | Microsoft | mikbras@microsoft.com | mikbras | +| Radhika Jandhyala | Microsoft | radhikaj@microsoft.com | radhikaj | +| Simon Leet | Microsoft | simon.leet@microsoft.com | CodeMonkeyLeet | Committee Responsibilities -------------------------- The primary responsibility of the Committee is to grant new committer rights (that is, write access to the main Open Enclave SDK repository or related -repositories), and to grant new membership into the committee. Conversely, the +repositories), and to grant new membership into the Committee. Conversely, the Committee must also remove committer rights and membership from those found to be violating the project's Code of Conduct or otherwise negatively affecting the -project's community health. +project's community health. It is duty of each committee member to receive and +address reported violations of the Code of Conduct while maintaining the +confidentiality of the reporter. This Committee is not intended to make every technical decision, as those should generally be made by agreement among committers as PRs are reviewed and merged. @@ -44,9 +58,9 @@ up with the Committee as part of its responsibility to maintain the project's community health. Otherwise technical decisions are left to the active committers (by virtue of the liberal contribution policy). -The Community Maintenance Committee should meet regularly, for example, once a -month. This meeting is a private meeting among just the maintainers to nominate -new committers and maintainer members. Priority consideration should be given to +The Community Governance Committee should meet regularly, for example, once a +month. This meeting is a private meeting among just the Committee members to nominate +new committers and Committee members. Priority consideration should be given to those actively contributing to the project. The Committee uses the consensus seeking process outlined above when making decisions, including adding or removing any members. The Committee should also discuss the community's health @@ -63,18 +77,18 @@ Project Committers ================== The following people have been granted commit permissions (that is, write -access) to the Open Enclave SDK by the Community Maintenance Committee. The area +access) to the Open Enclave SDK by the Community Governance Committee. The area column describes which technical areas each committer is most interested in, and therefore should usually be consulted for changes relating to that area. However, it is up to each committer to determine who should review which PR, and when to merge it. Remember that a PR must not be merged if a committer objects; -instead, it should be brought up with the Community Maintenance Committee. +instead, it should be brought up with the Community Governance Committee. | Name | GitHub Alias | Area | |-----------------------|---------------------|--------------------------------| | Amaury Chamayou | achamayou | Build, CCF Integration | | Anand Krishnamoorthi | anakrish | Debugging, SGX, EDL, Dev Tools | -| Andrew Schwartzmeyer | andschwa | EDL, CMake, Git, Dev Tools | +| Andrew Schwartzmeyer | andschwa | EDL, CMake, Dev Tools, Website | | Brett McLaren | BRMcLaren | Build, CMake, CI | | Brian Telfer | Britel | TrustZone, Attestation | | Simon Leet | CodeMonkeyLeet | SGX, APIs | @@ -84,12 +98,13 @@ instead, it should be brought up with the Community Maintenance Committee. | Hernan Gatta | HernanGatta | TrustZone | | Sergio Wong | jazzybluesea | Attestation, SGX | | Jiri Appl | jiria | Attestation, TrustZone | -| John Kordich | johnkord | Build, CI, Dev Tools | +| John Kordich | johnkord | Build, CI, Dev Tools, Release | +| Jordan Hand | jhand2 | Windows, Build, SGX | | Xuejun Yang | jxyang | SGX | | Mike Brasher | mikbras | SGX, APIs, EDL | | Marius Oprin | oprinmarius | Build, CMake, CI, Ansible | | Paul Allen | paulcallen | TrustZone | -| Radhika Jandhyala | radhikaj | SGX, APIs | +| Radhika Jandhyala | radhikaj | SGX, APIs, Website | | Shruti Ratnam | shruti25ratnam | Attestation | | Cheng-mean Liu | soccerGB | Attestation, SGX | | Bruce Campbell | yakman2020 | Windows, SGX | diff --git a/docs/Contributing.md b/docs/Contributing.md index 653e21feac..6ec8b70ac9 100644 --- a/docs/Contributing.md +++ b/docs/Contributing.md @@ -9,7 +9,7 @@ filing an issue. General contribution guidance is included in this document. Additional guidance is defined in the documents linked below: -- [Governance Model](GovernanceModel.md) describes how we intend our +- [Governance Model](Governance.md) describes how we intend our collaboration to happen. - [Development Guide](DevelopmentGuide.md) describes the coding style and other development practices applied to this project. @@ -39,7 +39,7 @@ You are encouraged to start a discussion with us through a GitHub issue before implementing any major changes. We want your contributions, but we also want to make sure the community is in agreement before you invest your time. -You may be asked by maintainers to provide a design document before writing an +You may be asked by Committers to provide a design document before writing an implementation. The simplest way to provide this is through a Pull Request to our repository with a Markdown style document (like this one) to the [docs/DesignDocs](DesignDocs) folder, and see its [readme](DesignDocs/README.md) @@ -59,7 +59,7 @@ General Guidelines Please do: - **DO** open an issue for design discussion before making any major changes. -- **DO** read our [Governance Model](GovernanceModel.md) to understand how our +- **DO** read our [Governance Model](Governance.md) to understand how our community works. - **DO** follow our coding style described in the [Development Guide]( DevelopmentGuide.md). @@ -81,16 +81,18 @@ Please do: - **DO** submit all code changes via pull requests (PRs) rather than through a direct commit. PRs will be reviewed and potentially merged by the repo - maintainers after a peer review that includes at least one maintainer. -- **DO** give PRs short-but-descriptive names (e.g. "Improve code coverage for - System.Console by 10%", not "Fix #1234"). + Committers after a peer review that includes at least one Committer. +- **DO** give PRs short but descriptive names (e.g. "Improve code coverage for + edger8r", not "Fix #1234"). - **DO** add breaking changes, new features, deprecations, and bug - fixes to the [unreleased section of the - changelog](../CHANGELOG.md#unreleased). + fixes to the [unreleased section of the changelog](../CHANGELOG.md#unreleased). - **DO** refer to any relevant issues and include [keywords]( https://help.github.com/articles/closing-issues-via-commit-messages/) that automatically close issues when the PR is merged. -- **DO** tag any users that should know about and/or review the change. +- **DO** tag any users that should know about and/or review the change. While + [CODEOWNERS](https://help.github.com/en/articles/about-code-owners) should + automatically tag reviewers, if you know of specific people that should look + at a PR, add them too. - **DO** ensure each commit successfully builds on all platforms and passes all unit tests. - **DO** rebase and squash unnecessary commits before opening the PR, so that @@ -103,8 +105,8 @@ Please do: Please do not: - **DON'T** make PRs for style changes. For example, do not send PRs that are - focused on changing usage of ```Int32``` to ```int```. The team would prefer - to address these holistically with tooling. + focused on changing usage of `SomeVar` to `some_var`. The team would prefer + to address these with automated tooling. - **DON'T** surprise us with big pull requests. Instead, file an issue and start a discussion so we can agree on a direction before you invest a large amount of time. @@ -120,11 +122,12 @@ Please do not: discuss it. - **DON'T** submit changes to the public API without filing an issue and discussing with us first. -- **DON'T** submit "work in progress" PRs. A PR should only be submitted when - it is considered ready for review and subsequent merging by the contributor. +- **DON'T** use GitHub [_Draft_ pull + requests](https://help.github.com/en/articles/about-pull-requests#draft-pull-requests) + to share work-in-progress. This will suppress CODEOWNER notifications - **DON'T** fix merge conflicts using a merge commit. Prefer `git rebase`. - **DON'T** mix independent, unrelated changes in one PR. Separate real - product/test code changes from larger code formatting/dead code removal + project/test code changes from larger code formatting/dead code removal changes. Separate unrelated fixes into separate PRs, especially if they are in different libraries. @@ -134,7 +137,7 @@ Merging Pull Requests Instead of merging pull requests with "the big green button" on GitHub, we use an automated system called [Bors](https://bors.tech/). The Bors bot is the _only_ approved mechanism of merging code to `master`. When a PR is ready to be -merged, a maintainer will comment on it with `bors r+`. +merged, a Committer will comment on it with `bors r+`. Bors will automatically: 1. Apply the PR's commits to a `staging` branch based on `master`. @@ -214,21 +217,70 @@ commits with incorrect author information, you can fix them as follows: 1. Choose to `edit` the commits with incorrect authorship. 1. For each edit, use `git commit --amend --reset-author`. -Contributor License Agreement ------------------------------ +Developer Certificate of Origin +------------------------------ +All contributions to the Open Enclave SDK must adhere to the terms of the +[Developer Certificate of Origin (DCO)](https://developercertificate.org/): + +> Developer Certificate of Origin +> Version 1.1 +> +> Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +> 1 Letterman Drive +> Suite D4700 +> San Francisco, CA, 94129 +> +> Everyone is permitted to copy and distribute verbatim copies of this +> license document, but changing it is not allowed. +> +> Developer's Certificate of Origin 1.1 +> +> By making a contribution to this project, I certify that: +> +> (a) The contribution was created in whole or in part by me and I +> have the right to submit it under the open source license +> indicated in the file; or +> +> (b) The contribution is based upon previous work that, to the best +> of my knowledge, is covered under an appropriate open source +> license and I have the right under that license to submit that +> work with modifications, whether created in whole or in part +> by me, under the same open source license (unless I am +> permitted to submit under a different license), as indicated +> in the file; or +> +> (c) The contribution was provided directly to me by some other +> person who certified (a), (b) or (c) and I have not modified +> it. +> +> (d) I understand and agree that this project and the contribution +> are public and that a record of the contribution (including all +> personal information I submit with it, including my sign-off) is +> maintained indefinitely and may be redistributed consistent with +> this project or the open source license(s) involved. + +Contributors need to sign-off that they adhere to these requirements by adding +a `Signed-off-by:` line to each commit message: -You must sign a [Microsoft Contribution License Agreement (CLA)]( -https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf) -before your PR will be merged. This is a one-time requirement for Open Enclave. -You can read more about [Contribution License Agreements (CLA)]( -http://en.wikipedia.org/wiki/Contributor_License_Agreement) on Wikipedia. +``` +Author: John Doe +Date: Wed Nov 6 11:30 2019 +0000 + + This is my commit message. + + Signed-off-by: John Doe +``` -You don't have to do this up-front. You can simply clone, fork, and submit your -pull request as usual. When your pull request is created, it is classified by a -CLA bot. If the change is trivial (for example, you just fixed a typo), then the -PR is labelled with `cla-not-required`. Otherwise it's classified as -`cla-required`. Once you signed a CLA, the current and all future pull requests -will be labelled as `cla-signed`. +Commits without this sign-off cannot be accepted, and the name in the +`Signed-off-by` and `Author` fields should match. + +If you have configured your `user.name` and `user.email` via `git config`, +the `Signed-off-by` line can be automatically appended to your commit message +using the `-s` option: + +``` +$ git commit -s -m "This is my commit message." +``` Copying Files from Other Projects --------------------------------- @@ -262,9 +314,5 @@ an issue to discuss the idea. Code of Conduct --------------- -This project has adopted the [Microsoft Open Source Code of Conduct]( -https://opensource.microsoft.com/codeofconduct/). -For more information see the [Code of Conduct FAQ]( -https://opensource.microsoft.com/codeofconduct/faq/) or contact -[opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional -questions or comments. +This project follows a [Code of Conduct](CodeOfConduct.md) adapted from the +[Contributor Covenant v1.4](https://www.contributor-covenant.org). diff --git a/docs/DesignDocs/CustomAttestation.md b/docs/DesignDocs/CustomAttestation.md new file mode 100644 index 0000000000..b0204c99d4 --- /dev/null +++ b/docs/DesignDocs/CustomAttestation.md @@ -0,0 +1,1062 @@ +___ + +Custom Attestation Data Formats for Open Enclave +===== + +This design document proposes a new attestation framework and set of APIs that +enable developers to use custom formats for their attestation data. + +Motivation +---------- + +Currently, Open Enclave provides several APIs that developers can use for +attestation. The two key functions are `oe_get_report`, which produces an opaque +blob that is signed by the enclave, and `oe_verify_report`, which can be used to +verify the generated report. The original purpose of those two APIs were to +provide a simple, cross-platform way to produce and verify attestation data. + +However, some developers need more flexibility for their attestation +requirements. For example, one might want to extend Open Enclave's +current attestation structures with extra information, such as geolocation +or a timestamp. Another user might want their enclaves to generate attestation +data that is in a format compatible with their existing authentication +infrastructure, such as a JSON Web Token or an X.509 certificate. There are also +users who want to specify their endorsements (information from a second source +used for verification), instead of using the set of endorsements provided by Open +Enclave. + +Overall, there has been interest in enhancing Open Enclave's APIs to support +custom attestation formats to enable these scenarios. + +Terminology +----------- + +This document uses the following terminology defined below. Note that +these definitions are consistent with the terms defined in the +[Remote Attestation Procedures (RATS)](https://datatracker.ietf.org/wg/rats/about/) +working group. + +- Claims + - Claims are statements about a particular subject. They consist of + name-value pairs containing the claim name, which is a string, and + claim value, which is arbitrary data. Example of claims could be + [name="version", value=1] or [name="enclave_id", value=1111]. +- Evidence + - Evidence is claims about the enclave that are produced and signed by it. + The SGX report would be an example of evidence. +- Endorsements + - Endorsements are additional claims used in the evidence verification process, + but not produced by the enclave. An example of an endorsement would be + the quoting enclave's identity used in SGX remote attestation, because it + is retrieved from Intel's servers, rather than the enclave. +- Attester + - The attester creates the evidence and signs it. Trusted Execution Environments + (TEEs), such as the SGX enclave, often play the role of the attester. +- Verifier + - The verifier is responsible for taking in the evidence and endorsements + and deciding if the enclave is trustworthy. +- Relying party + - The relying party is the entity interested in communicating with an + enclave. The enclave must attest to the relying party before the + relying party can trust it. The relying party can also play the role + of the verifier, but it does not necessarily have to. + +Specification +------------- + +To support custom attestation formats, this document proposes adding a plugin +model for attestation. The Open Enclave SDK will define a plugin API for the +attester and another API for the verifier. Each plugin will define a UUID to +distinguish plugins. An attester and verifier plugin sharing the same UUID +indicates that that verifier is able to process the evidence format generated +by the attester. + +Futhermore, there will be additional attestation "plugin aware" APIs that are +analogous to `oe_get_report` and `oe_verify_report` called `oe_get_evidence` +and `oe_verify_evidence` respectively. There will also +be functions for registering and unregistering plugins called +`oe_register_[attester|verifier]` and `oe_unregister_[attester|verifier]`. The user +can link in their desired plugin and call the register plugin function. +The attestation data can be retrieved from `oe_get_evidence` with the desired UUID. +The generated data will have the UUID in its header. The user can `oe_verify_evidence` +to verify the data and the Open Enclave runtime can use this UUID to determine what plugin +verification routine to run. + +If the plugin is registered on the enclave side, it will only work for the enclave side. +Likewise, if the plugin is registered for the host side, it will only work for the +host side. If the user wants to use the plugin for both sides, then they must register +it once inside the enclave and once inside the host. + +### Attester Plugin API (Enclave only) + +Each plugin must implement the functions below: + +```C +/** + * Claims struct used for claims parameters for the plugin. + */ +struct oe_claim_t +{ + char* name; + uint8_t* value; + size_t value_size; +}; + +/** + * Struct that defines the structure of each plugin. Each plugin must + * define a UUID for its format and implement the functions in this + * struct. Ideally, each plugin should provide a helper function to + * create this struct on the behalf of the plugin users. + */ +struct oe_attester_plugin_t +{ + /** + * The UUID for the plugin. + */ + uuid_t format_id; + + /** + * The function that gets executed when a plugin is registered. + * + * @param[in] plugin_context A pointer to the attester plugin struct. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK on success. + */ + oe_result_t (*on_register)( + oe_attester_plugin_t* plugin_context, + const void* config_data, + size_t config_data_size); + + /** + * The function that gets executed when a plugin is unregistered. + * + * @param[in] plugin_context A pointer to the attester plugin struct. + * @retval OE_OK on success. + */ + oe_result_t (*on_unregister)( + oe_attester_plugin_t* plugin_context); + + /** + * Generates the attestation evidence, which is defined as the data + * produced by the enclave. The caller may pass in custom claims, which + * must be attached to the evidence and then cryptographically signed. + * + * @param[in] plugin_context A pointer to the attester plugin struct. + * @param[in] flags Specifying default value (0) generates evidence for local + * attestation. Specifying OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION generates + * evidence for remote attestation. + * @param[in] custom_claims The optional custom claims list. + * @param[in] custom_claims_length The number of custom claims. + * @param[in] opt_params The optional plugin-specific input parameters. + * @param[in] opt_params_size The size of opt_params in bytes. + * @param[out] evidence_buffer An output pointer that will be assigned the + * address of the evidence buffer. + * @param[out] evidence_buffer_size A pointer that points to the size of the + * evidence buffer in bytes. + * @param[out] endorsements_buffer An output pointer that will be assigned the + * address of the endorsements buffer. + * @param[out] endorsements_buffer_size A pointer that points to the size of the + * endorsements buffer in bytes. + * @retval OE_OK on success. + */ + oe_result_t (*get_evidence)( + oe_attester_plugin_t* plugin_context, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size); + + /** + * Frees the generated attestation evidence and endorsements. + * + * @param[in] plugin_context A pointer to the attester plugin struct. + * @param[in] evidence_buffer A pointer to the evidence buffer. + * @param[in] endorsements_buffer A pointer to the endorsements buffer. + * @retval OE_OK on success. + */ + oe_result_t (*free_evidence)( + oe_attester_plugin_t* plugin_context, + uint8_t* evidence_buffer, + uint8_t* endorsements_buffer); +}; +``` + +Here is the rationale for each element in the plugin struct: +- `format_id` + - Each plugin needs a unique identifier to distinguish itself. +- `on_register` and `on_unregister` + - A plugin might require some setup or teardown when it is registered or + unregistered, so these functions are required. Furthermore, a plugin + might require configuration, which is why there is a `config_data` + parameter. The configuration data can be plugin specific, so no format is + specified in this proposal. +- `get_evidence` and `free_evidence` + - Producing evidence and endorsements is necessary for attestation. + - `flags` field to determine local vs. remote attestation. + - There is a `custom_claims` parameter because many attestation protocols + require the enclave to sign some data from a relying party. For example, + many protocols follow the "challenge response" architecture, which requires + the enclave to sign a nonce from the relying party. + - There is an `opt_params` field because some plugins might require plugin + specific input. For example, the SGX local attestation needs the + other enclave's target info struct. + - There is an `endorsements` parameter to return the endorsements that are + coupled with the evidence to ensure that the evidence and endorsements are + in sync. + +### Verifier Plugin API (Supported by host and enclave side) + +The plugin API is very similar to the attester plugin. The only difference +is that it implements a `verify_evidence` function instead of `get_evidence`. + + +```C +/** + * Claims struct used for claims parameters for the plugin. + */ +struct oe_claim_t +{ + char* name; + uint8_t* value; + size_t value_size; +}; + +/** + * Supported policies for validation. Only time is supported for now. + */ +enum oe_policy_type_t +{ + /** + * Enforces that time fields in the endorsements will be checked in + * with the given time rather than the endorsement creation time. + * + * The policy will be in the form of `oe_datetime_t`. + */ + OE_POLICY_ENDORSEMENTS_TIME = 1 +}; + +struct oe_policy_t +{ + oe_policy_type_t type; + void* policy; + size_t policy_size; +}; + +/** + * Struct that defines the structure of each plugin. Each plugin must + * define a UUID for its format and implement the functions in this + * struct. Ideally, each plugin should provide a helper function to + * create this struct on the behalf of the plugin users. + */ +struct oe_verifier_plugin_t +{ + /** + * The UUID for the plugin. + */ + uuid_t format_id; + + /** + * The function that gets executed when a plugin is registered. + * + * @param[in] plugin_context A pointer to the verifier plugin struct. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK on success. + */ + oe_result_t (*on_register)( + oe_verifier_plugin_t* plugin_context, + const void* config_data, + size_t config_data_size); + + /** + * The function that gets executed when a plugin is unregistered. + * + * @param[in] plugin_context A pointer to the verifier plugin struct. + * @retval OE_OK on success. + */ + oe_result_t (*on_unregister)( + oe_verifier_plugin_t* plugin_context); + + /** + * Verifies the attestation evidence and returns the claims contained in + * the evidence. + * + * @param[in] plugin_context A pointer to the verifier plugin struct. + * @param[in] evidence_buffer The evidence buffer. + * @param[in] evidence_buffer_size The size of evidence_buffer in bytes. + * @param[in] endorsements_buffer The endorsements buffer. + * @param[in] endorsements_buffer_size The size of endorsements_buffer in bytes. + * @param[in] policies A list of policies to use. + * @param[in] policies_size The size of the policy list. + * @param[out] claims The list of returned claims. + * @param[out] claims_length The number of claims. + * @retval OE_OK on success. + */ + oe_result_t (*verify_evidence)( + oe_verifier_plugin_t* plugin_context, + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length); + + /** + * Frees the generated claims. + * + * @param[in] context A pointer to the verifier plugin struct. + * @param[out] claims The list of returned claims. + * @param[out] claims_length The number of claims. + * @retval OE_OK on success. + */ + oe_result_t (*free_claims_list)( + oe_verifier_t* context, + oe_claim_t* claims, + size_t claims_length); +}; +``` + +Here is the rationale for the parameters in the `verify_evidence` function: +- `verify_evidence` + - Verifying evidence and endorsements is essential for attestation. + - Evidence can be verified according to some policy, which is why there + is a `policies` parameter. + - The `claims` field contains key-value pairs that can be verified by the + caller. This will have the similar contents as the `oe_identity_t` field + in the `oe_report_t` struct returned by `oe_verify_report` and any custom + claims that were passed to the `get_evidence` function. + +### Known Open Enclave Claims + +- Each plugin's `verify_evidence` function must, at minimum, return the + following claims (mapped from the `oe_identity_t`): + +| Claim Name | Claim Value Type | Description | +|:-----------------|:-------------------|:---------------------------------------------------------------------| +| id_version | uint32_t | Claims version. Must be 0 | +| security_version | uint32_t | Security version of the enclave. (ISVN for SGX). | +| attributes | uint64_t | Attributes flags for the evidence:
        `OE_REPORT_ATTRIBUTES_DEBUG`: The evidence is for a debug enclave.
        `OE_REPORT_ATTRIBUTES_REMOTE`: The evidence can be used for remote attestation. | +| unique_id | uint8_t[32] | The unique ID for the enclave (MRENCLAVE for SGX). | +| signer_id | uint8_t[32] | The signer ID for the enclave (MRSIGNER for SGX). | +| product_id | uint8_t[32] | The product ID for the enclave (ISVPRODID for SGX). | +| validity_from | oe_datetime_t | Overall datetime from which the evidence and endorsements are valid. | +| validity_until | oe_datetime_t | Overall datetime at which the evidence and endorsements expire. | +| plugin_uuid | uuid_t | The UUID of the plugin that generated the evidence. + +### Built-in SGX Plugin + +The current Open Enclave attestation only works on SGX platforms, so it will +be moved to an SGX plugin. Most of the current Open Enclave APIs can be mapped +directly to the plugin APIs. For the `on_register` and `on_unregister` APIs, +they can simply be no-ops. `oe_get_report` can be mapped to the `get_evidence` API and +`oe_verify_report` can be mapped to the `verify_evidence` API. + +### SGX Plug-In Definitions + +`sgx_plugin_common.h` + +```C + +/* Define the uuid. */ +#define SGX_PLUGIN_UUID \ +{ \ + 0x2f, 0x50, 0xdc, 0xb4, \ + 0x79, 0x9c, \ + 0x45, 0x07, \ + 0xa1, 0xe9, \ + 0x86, 0x2c, 0x62, 0x9b, 0x76, 0x2a} \ +} +``` + +`sgx_plugin_attester.h` + +```C +#include + +oe_attester_t* sgx_attester(); +``` + +`sgx_plugin_verifier.h` + +```C +#include + +oe_verifier_t* sgx_verifier(); +``` + +`sgx_plugin_attester.c` + +```C +#include "sgx_plugin_attester.h" + +static +oe_result_t +sgx_attestation_plugin_on_register( + oe_attester_t* plugin_context, + const void* config_data, + size_t config_data_size) +{ + OE_UNUSED(plugin_context); + OE_UNUSED(config_data); + OE_UNUSED(config_data_size); + + // Nothing to do + return OE_OK; +} + +static +oe_result_t +sgx_attestation_plugin_on_unregister( + oe_attester_t* plugin_context) +{ + OE_UNUSED(plugin_context); + + // Nothing to do + return OE_OK; +} + +static +oe_result_t +sgx_attestation_plugin_get_evidence( + oe_attester_t* plugin_context, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size) +{ + OE_UNUSED(plugin_context); + + /* + * Pseudocode description instead of actual C code: + * + * Hash custom claims field. + * Call oe_get_report with the flags and opt_param parameters and the hash as reportdata. + * Report contains the endorsements, so extract them out. + * Evidence will be report + custom_claims blob. + * + * Note: Since the verifier can run outside the SGX enclave, it can be running on a + * machine with different endianness. Consequently, it must be possible for the verifier + * to determine the endianness of the multibyte numbers in the evidence and endorsements, + * so it can properly interpret them. + * + */ + + return OE_OK; +} + +static +oe_result_t +sgx_attestation_plugin_free_evidence( + oe_attester_t* plugin_context, + uint8_t* evidence_buffer, + uint8_t* endorsements_buffer) +{ + OE_UNUSED(plugin_context); + + oe_free_report(evidence_buffer); + oe_free_endorsements(endorsements_buffer); + return OE_OK; +} + +/* Setting up the plugin structs. */ +oe_attester_t sgx_attester_plugin = { + + /* Plugin UUID. */ + .format_id = SGX_PLUGIN_UUID, + + .on_register = sgx_attestation_plugin_on_register, + .on_unregister = sgx_attestation_plugin_on_unregister, + .get_evidence = sgx_attestation_plugin_get_evidence, + .free_evidence = sgx_attestation_plugin_free_evidence, +}; + +/* Implement helper initialization function. */ +oe_attester_t* sgx_attester() { + return &sgx_attester_plugin; +} +``` + +`sgx_verifier_plugin.c` + +```C +#include "sgx_plugin_verifier.h" + +static +oe_result_t +sgx_attestation_plugin_on_register( + oe_verifier_t* plugin_context, + const void* config_data, + size_t config_data_size) +{ + OE_UNUSED(plugin_context); + OE_UNUSED(config_data); + OE_UNUSED(config_data_size); + + // Nothing to do + return OE_OK; +} + +static +oe_result_t +sgx_attestation_plugin_on_unregister( + oe_verifier_t* plugin_context) +{ + OE_UNUSED(plugin_context); + + // Nothing to do + return OE_OK; +} + +static +oe_result_t +sgx_attestation_plugin_verify_evidence( + oe_verifier_t* plugin_context, + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* polices, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length) +{ + OE_UNUSED(plugin_context); + + /* + * Pseudocode description instead of actual C code: + * + * Call oe_verify_report with all the input parameters and get the oe_identity_t back. + * Look for the custom claims in the evidence header and extract them if found. + * Verify the hash of custom claims == report data field in evidence report. + * Convert oe_identity_t to the claims format. + * + * Note: Since the verifier can run outside the SGX enclave, it can be running on a + * machine with different endianness. Consequently, the verification code needs to + * understand the endianness of the multibyte numbers in the evidence and endorsements + * and intelligently convert them to the verifier's native architecture. + */ + + return OE_OK; +} + +static oe_result_t +sgx_attestation_plugin_free_claims_list( + oe_verifier_t* plugin_context, + oe_claim_t* claims, + size_t claims_length) +{ + OE_UNUSED(plugin_context); + for (size_t i = 0; i < claims_length; i++) + { + free(claims[i].name); + free(claims[i].value); + } + return OE_OK; +} + +oe_verifier_t sgx_verifier_plugin = { + + /* Plugin UUID. */ + .format_id = SGX_PLUGIN_UUID, + + .on_register = sgx_attestation_plugin_on_register, + .on_unregister = sgx_attestation_plugin_on_unregister, + .verify_evidence = sgx_attestation_plugin_verify_evidence, + .free_claims_list = sgx_attestation_plugin_free_claims_list +}; + +oe_verifier_t* sgx_verifier() { + return &sgx_verifier_plugin; +} +``` + +### New Open Enclave APIs + +The functions are what the plugin user calls to use a plugin. They map almost +exactly to the plugin API. The main difference is that `oe_get_evidence` +requires the UUID of the plugin as an input parameter. + +```C +/** + * oe_register_attester + * + * Registers a new attester plugin and optionally configures it with plugin + * specific configuration data. The function will fail if the plugin UUID has + * already been registered. + * + * This is available in the enclave and host. + * + * @param[in] plugin A pointer to the attestation plugin struct. Note that this will + * not copy the contents of the pointer, so the pointer must be kept valid until + * the plugin is unregistered. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK The function succeeded. + * @retval OE_ALREADY_EXISTS A plugin with the same UUID is already registered. + */ +oe_result_t oe_register_attester( + oe_attester_t* plugin, + const void* config_data, + size_t config_data_size); + +/** + * oe_register_verifier + * + * Registers a new verifier plugin and optionally configures it with plugin + * specific configuration data. The function will fail if the plugin UUID has + * already been registered. + * + * This is available in the enclave and host. + * + * @param[in] plugin A pointer to the attestation plugin struct. Note that this will + * not copy the contents of the pointer, so the pointer must be kept valid until + * the plugin is unregistered. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK The function succeeded. + * @retval OE_ALREADY_EXISTS A plugin with the same UUID is already registered. + */ +oe_result_t oe_register_verifier( + oe_verifier_t* plugin, + const void* config_data, + size_t config_data_size); + +/** + * oe_unregister_attester + * + * Unregisters an attester plugin. This is available in the enclave and host. + * + * @param[in] plugin A pointer to the attestation plugin struct. + * @retval OE_OK The function succeeded. + * @retval OE_NOT_FOUND The plugin does not exist. + */ +oe_result_t oe_unregister_attester( + oe_attester_t* plugin); + +/** + * oe_unregister_verifier + * + * Unregisters an verifier plugin. This is available in the enclave and host. + * + * @param[in] plugin A pointer to the attestation plugin struct. + * @retval OE_OK The function succeeded. + * @retval OE_NOT_FOUND The plugin does not exist. + */ +oe_result_t oe_unregister_verifier( + oe_verifier_t* plugin); + +/** + * oe_get_evidence + * + * Generates the attestation evidence for the given UUID attestation format. + * This function is only available in the enclave. + * + * @param[in] evidence_format_uuid The UUID of the plugin. + * @param[in] flags Specifying default value (0) generates evidence for local + * attestation. Specifying OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION generates + * evidence for remote attestation. + * @param[in] custom_claims The optional custom claims list. + * @param[in] custom_claims_length The number of custom claims. + * @param[in] opt_params The optional plugin-specific input parameters. + * @param[in] opt_params_size The size of opt_params in bytes. + * @param[out] evidence_buffer An output pointer that will be assigned the + * address of the evidence buffer. + * @param[out] evidence_buffer_size A pointer that points to the size of the + * evidence buffer in bytes. + * @param[out] endorsements_buffer An output pointer that will be assigned the + * address of the endorsements buffer. + * @param[out] endorsements_buffer_size A pointer that points to the size of the + * endorsements buffer in bytes. + * @retval OE_OK The function succeeded. + * @retval OE_NOT_FOUND The plugin does not exist. + */ +oe_result_t oe_get_evidence( + const uuid_t* evidence_format_uuid, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size); + +/** + * oe_free_evidence + * + * Frees the attestation evidence and endorsements. This function is only + * available in the enclave. + * + * @param[in] evidence_buffer A pointer to the evidence buffer. + * @param[in] endorsements_buffer A pointer to the endorsements buffer. + * @retval OE_OK on success. + */ +oe_result_t oe_free_evidence(uint8_t* evidence_buffer, uint8_t* endorsements_buffer); + +/** + * oe_verify_evidence + * + * Verifies the attestation evidence and returns well known and custom claims. + * This is available in the enclave and host. + * + * @param[in] evidence_buffer The evidence buffer. + * @param[in] evidence_buffer_size The size of evidence_buffer in bytes. + * @param[in] endorsements_buffer The endorsements buffer. + * @param[in] endorsements_buffer_size The size of endorsements_buffer in bytes. + * @param[in] policies A list of policies to use. + * @param[in] policies_size The size of the policy list. + * @param[out] claims The list of claims. + * @param[out] claims_length The length of the claims list. + * @retval OE_OK on success. + */ +oe_result_t oe_verify_evidence( + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length); + +/** + * oe_get_registered_attester_format_ids + * + * Get the unique identifiers of all registered attesters. + * + * @param[out] format_ids The list of the UUIDs of the registered attesters. + * @param[out] format_ids_length The length of the UUIDs list. + * @retval OE_OK on success. + */ +oe_result_t oe_get_registered_attester_format_ids( + oe_uuid_t** format_ids, + size_t* format_ids_length); + +/** + * oe_get_registered_verifier_format_ids + * + * Get the unique identifiers of all registered verifiers. + * + * @param[out] format_ids The list of the UUIDs of the registered verifiers. + * @param[out] format_ids_length The length of the UUIDs list. + * @retval OE_OK on success. + */ +oe_result_t oe_get_registered_verifier_format_ids( + oe_uuid_t** format_ids, + size_t* format_ids_length); + +/** + * oe_free_format_ids + * + * Frees the attester/verifier format ids. + * + * @param[in] format_ids The list of the attester/verifier UUIDs. + * @retval OE_OK on success. + */ +oe_result_t oe_free_format_ids(oe_uuid_t* format_ids); +``` + +The outputs returned by `oe_get_evidence` will begin with the header +specified below. This allows `oe_verify_evidence` to determine what plugin +verification routine to use. Note that since these functions return opaque +structures, these headers are internal and not visible to the SDK consumers +or the plugin writers. + +```C +/* + * Header will be sent to oe_verify_evidence but not to the + * plugin verification routines. + */ +typedef struct _oe_attestation_header +{ + /* Set to + 1 of existing header version. */ + uint32_t version; + + /* UUID to identify format. */ + uuid_t format_id; + + /* Size of evidence/endorsements sent to the plugin. */ + uint32_t data_size; + + /* The actual data */ + uint8_t data[]; + + /* data_size bytes that follows the header will be sent to a plugin. */ +} oe_attestation_header_t; +``` + +### Backwards compatibility + +The new APIs should support verifying the old Open Enclave reports +generated by `oe_get_report`. The `oe_attestation_header_t` structure +shares the same 1st field (`uint32_t version`) as the old Open Enclave +report header. Consequently, the `oe_verify_evidence` can use this +information to decide if it needs to call a plugin or run the legacy +verification routine (which is technically the same logic as the SGX plugin). + +User Experience +--------------- + +### Plug-in + +There are two types of users: the plugin writers and the plugin consumers. + +Plugin writers will implement their plugin according to the plugin API. +They should also provide a helper function that makes it easy for plugin +consumers to register the plugin as shown below: + +`my_plugin_guid.h` + +```C +/* Define the uuid. */ +#define MY_PLUGIN_UUID \ +{ \ + 0x13, 0x99, 0x9a, 0xe5, \ + 0x23, 0xbe, _ \ + 0x4f, 0xd4, \ + 0x86, 0x63, \ + 0x42, 0x1e, 0x3a, 0x57, 0xa0, 0xa4} \ +} +``` + +`my_plugin_attester.h` + +```C +#include + +/* Helper function to create the plugin. */ +oe_attester_t* my_plugin_attester(); + +/* Example struct used for config data for my_plugin->on_register. */ +struct my_plugin_attester_config_data_t { ... }; + +/* Example struct used as input parameters for my_plugin->get_evidence. */ +struct my_plugin_attester_opt_params_t { ... }; +``` + +`my_plugin_verifier.h` + +```C +#include + +/* Helper function to create the plugin. */ +oe_verifier_t* my_plugin_verifier(); + +/* Example struct used for config data for my_plugin->on_register. */ +struct my_plugin_verifier_config_data_t { ... }; +``` + +`my_plugin_attester.c` + +```C +#include + +/* Plugin implementation functions here. */ +static oe_result_t my_plugin_on_register( + oe_attester_t* context, + const void* config_data, + size_t config_data_size) +{ + struct my_plugin_config_data_t* my_data = (struct my_plugin_config_data_t*) config_data; + /* Do meaningful work with my_data here. */ + return OE_OK; +} + +static oe_result_t my_plugin_on_unregister(...) { ... } +static oe_result_t my_plugin_get_evidence(...) { ... } +static oe_result_t my_plugin_free_evidence(...) { ... } + +/* Setting up the plugin struct. */ +oe_attester_t my_plugin = { + /* Plugin UUID. */ + .format_id = MY_PLUGIN_UUID, + + /* Plugin functions. */ + .on_register = my_plugin_on_register, + .on_unregister = my_plugin_on_unregister, + .get_evidence = my_plugin_get_evidence, + .free_evidence = my_plugin_free_evidence, +}; + +/* Implement helper initialization function. */ +oe_attester_t* my_plugin_attester() { + return &my_plugin; +} +``` + +`my_plugin_verifier.c` + +```C +#include + +/* Plugin implementation functions here. */ +static oe_result_t my_plugin_on_register(...) { ... } +static oe_result_t my_plugin_on_unregister(...) { ... } +static oe_result_t my_plugin_verify_evidence(...) { ... } +static oe_result_t my_plugin_free_claims_list(...) { ... } + +/* Setting up the plugin struct. */ +oe_verifier_t my_plugin = { + /* Plugin UUID. */ + .format_id = MY_PLUGIN_UUID, + + /* Plugin functions. */ + .on_register = my_plugin_on_register, + .on_unregister = my_plugin_on_unregister, + .verify_evidence = my_plugin_verify_evidence, + .free_claims_list = my_plugin_free_claims_list +}; + +/* Implement helper initialization function. */ +oe_verifier_t* my_plugin_attester() { + return &my_plugin; +} +``` + +They can then compile their code in the standard way for building Open Enclave +enclave and host applications. + +Plugin consumers will use the new "plugin aware" APIs like +`oe_get_evidence`. The enclave can generate the evidence +using the plugin like this: + +`attester.c` + +```C +#include + +/* Register plugin. Send the config data if necessary. */ +struct my_plugin_attester_config_data_t config = { ... }; +size_t config_size = sizeof(config); +oe_register_attester(my_plugin_attester(), &config, config_size); + +/* Create input params struct if needed. */ +struct my_plugin_attester_opt_params_t params = { ... }; +size_t params_size = sizeof(params); + +/* Create claims if desired. */ +oe_claim_t claims = { ... }; +size_t claims_size = ...; + +/* Receive the evidence format ids that the verifier supports */ +recv(VERIFIER_SOCKET_FD, evidence_format_ids, evidence_format_id_length, 0); + +/* Get registered attester format ids and find a common format */ +oe_get_registered_attester_format_ids(*format_ids, &format_ids_length); +for (size_t m = 0; m < format_ids_length; m++) +{ + for (size_t n = 0; n < evidence_format_id_length; n++) + if (format_ids[m] == evidence_format_ids[n]) + { + common_format_id = format_ids[m]; + break; + } +} + +/* Get evidence. */ +oe_get_evidence( + common_format_id, + OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION, + claims, + claims_size, + ¶ms, + params_size, + &evidence, + &evidence_size, + &endorsements, + &endorsements_size); + +/* Send the evidence to the verifier. Protocol is up to enclave and verifier. */ +send(VERIFIER_SOCKET_FD, evidence, evidence_size, 0); +send(VERIFIER_SOCKET_FD, endorsements, endorsements_size, 0); + +/* Free data and unregister plugin. */ +oe_free_format_id(format_ids); +oe_free_evidence(evidence, endorsements); +oe_unregister_attester(my_plugin_attester()); +``` + +The verifier, which can either be the enclave or the host, can verify the evidence like this: + +`verifier.c` + +```C +#include + +/* Register plugin. Send the config data if necessary. */ +struct my_plugin_verifier_config_data_t config = { ... }; +size_t config_size = sizeof(config); +oe_register_verifier(my_plugin_verifier(), &config, config_size); + +/* Tell enclave the format ids the verifier supports */ +oe_get_registered_verifier_format_ids(*format_ids, &format_ids_length); +send(ENCLAVE_SOCKET_FD, *format_ids, format_ids_length, 0); + +/* Receive evidence and endorsement buffer from enclave. */ +recv(ENCLAVE_SOCKET_FD, evidence, evidence_size, 0); +recv(ENCLAVE_SOCKET_FD, endorsements, endorsements_size, 0); + +/* Set polices if desired. */ +oe_datetime_t time = { ... }; +oe_policy_t policy = { + .type = OE_POLICY_ENDORSEMENTS_TIME, + .policy = &time, + .policy_size = sizeof(time); +}; + +/* Verify evidence. Can check the claims if desired. */ +oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + &policy, + 1, + &claims, + &claims_size); + +/* Free data and unregister plugin. */ +oe_free_format_id(format_ids); +oe_free_claims_list(claims, claims_size); +oe_unregister_verifier(my_plugin_verifier()); +``` + +In either case, the plugin user can link in the plugin to build their app: + +```bash +gcc -o my_app_attester attester.o my_plugin_attester.o ... +gcc -o my_app_verifier verifier.o my_plugin_verifier.o ... +``` + +Alternate Designs Considered +---------- + +Another option is to transform the Open Enclave report from a platform-specific +opaque blob to something like a JWT/CWT token or X.509 cert, which contains +platform-specific attestation data embedded inside it. This makes it easy to add +or parse claims and extend the report format. However, users would be constrained +to the format chosen by Open Enclave and they will not be able to use their own +custom format. + +Authors +------- + +Name: Akash Gupta + +Email: akagup@microsoft.com + +Github username: gupta-ak diff --git a/docs/DesignDocs/LoggingFormat.md b/docs/DesignDocs/LoggingFormat.md new file mode 100644 index 0000000000..1dc23caa85 --- /dev/null +++ b/docs/DesignDocs/LoggingFormat.md @@ -0,0 +1,84 @@ +Logging Format +===== + +When using the openenclave SDK and in trying to make use of the logs (e.g., via uploading them to Azure Log Analytics) +it is nice to be able to parse and display all of the available logs including the ones generated by OE. + +Motivation +---------- + +Users should be able to specify and control their own logging format so that they can further parse the log files as they see fit. + +User Experience +--------------- + +- The user can set the `OE_LOG_DEVICE` environment variable to specify the log file location + +- The user can set the `OE_LOG_FORMAT` environment variable to specify the log format. Log formats should expect the below values +to be passed in the order presented below: + + - timestamp ISO 8601 UTC [string] + - microseconds of precision in the logging timestamp [long int] + - is enclave (E|H) [string] + - log level [string] + - thread id [uint64_t] + - log message [string] + - file log initiated from [string] + - function log initiated from [string] + - file line number log initiated from [string] + + so for example a log format could be set like this: + + `OE_LOG_FORMAT=$'{\"e_ts\":\"%s.%06ldZ\",\"level\":\"(%s)%s\",\"tid\":\"tid(0x%lx)\",\"msg\":\"%s\",\"file\":\"%s\",\"func\":\"%s\",\"number":\"%s\"}\n'` + + and end up looking like this: + + ` + { + "e_ts": "2019-09-24T10:09:27.832475Z", + "level": "(H)ERROR", + "tid": "tid(0x7fc2698a6d40)", + "msg": "Hello 'world'!", + "file": "switchless/host/host.c", + "func": "main", + "number": "79" + } + ` + +- The user can set the `OE_LOG_JSON_ESCAPE` environment variable and if it is set then the log message will be escaped in order to be compatible with the JSON standard. + +Specification +------------- + +Users can specify their own format when logging to a user specified file via the existing `OE_LOG_DEVICE` environment variable. + +If the var is set then we look for an extra environment variable `OE_LOG_FORMAT`. +If `OE_LOG_FORMAT` is set we call a method where we pass in the log line information to be formatted by the `OE_LOG_FORMAT` string. +`OE_LOG_FORMAT` needs to end with a newline. + +If `OE_LOG_FORMAT` is not set then we use the default format string to log in the file. + +In addition to the `OE_LOG_FORMAT` environment variable, if the `OE_LOG_JSON_ESCAPE` environment variable is set, then the log message will be processed +accordingly in order to be compatible with the JSON standard. + +When logging to a separate file the defaut logs are not sent to stdout and the custom logs are directed to the file. If the user wants to keep the default logs +directed to stdout AND the custom logs sent to the file, they can set the `OE_LOG_ALL_STREAMS` environment variable. This is useful if we want to keep the human +readable logs, but also redirect a machine-readable format (e.g., JSON) to a file. + +OE logging format +----------------- + +The OE logging format will be changed slightly to look like this: + +`2019-09-24T10:26:58.399458Z [(H)ERROR] tid(0x7fbddf4add40) | Hello 'world'! [switchless/host/host.c:main:78]` + +where timestamp is ISO 8601 UTC. + +Authors +------- + +Name: Olga Vrousgou + +email: olga.vrousgou@microsoft.com + +github username: olgavrou \ No newline at end of file diff --git a/docs/DesignDocs/RemoteAttestationCollaterals.md b/docs/DesignDocs/RemoteAttestationCollaterals.md new file mode 100644 index 0000000000..86574d0fb8 --- /dev/null +++ b/docs/DesignDocs/RemoteAttestationCollaterals.md @@ -0,0 +1,485 @@ +Remote Attestation Endorsements +===== + +Attestation is the process of proving the authenticity of a +Trusted Execution Environment (TEE) platform (HW + software). + +In the current API, OE SDK has functions to get the evidence and to verify +the evidence. This document describes additional changes to the API to +support the concept of endorsements. Endorsements are additional information +from a second source that the verifier can use for attestation verification. + +Terminology +---------- +From Remote Attestation Procedures Architecture (RATS) +(https://www.ietf.org/id/draft-birkholz-rats-architecture-02.txt). This +a draft that is Work in Progress and subject to change. + +- Evidence is provable Claims about a specific Computing Environment + made by an Attester. + +- Known-Good-Values are reference Claims used to appraise Evidence. + +- Endorsements are reference Claims about the environment protecting + the Attesters capabilities to create believable Evidence (e.g. the + type of protection for an attestation key). It answers the + question "why Evidence is believable". + +- Attestation Results are the output from the appraisal of Evidence, + Known-Good-Values and Endorsements. + + +----------------+ +-----------------+ + | | Known-Good-Values | | + | Asserter(s) |-------------------->| Verifier | + | | Endorsements /-->| | + +----------------+ | +-----------------+ + | | + | | + | | + | |Attestation + | |Results + | | + | | + | v + +----------------+ | +-----------------+ + | | Evidence | | | + | Attester |-----------------/ | Relying Party | + | | | | + +----------------+ +-----------------+ + + Figure 1: RATS Roles + +### Roles + +RATS roles are implemented by principals that possess cryptographic +keys used to protect and authenticate Claims or Results. + +#### Attester: +An Attestation Function that creates Evidence by +collecting, formatting and protecting (e.g., signing) Claims. It +presents Evidence to a Verifier using a conveyance mechanism or +protocol. + +#### Verifier: +An Attestation Function that accepts Evidence from an Attester using +a conveyance mechanism or protocol. It also accepts Known-Good-Values +and Endorsements from an Asserter using a conveyance mechanism or protocol. +It verifies the protection mechanisms, parses and appraises Evidence +according to good-known valid (or known-invalid) Claims and Endorsements. +It produces Attestation Results that are formatted and protected (e.g., +signed). It presents Attestation Results to a Relying Party using +a conveyance mechanism or protocol. + +Claims are statements about a particular subject. They consist of +name-value pairs containing the claim name, which is a string, and +claim value, which is arbitrary data. Example of claims could be +[name="version", value=1] or [name="enclave_id", value=1111]. + +#### Asserter: +An Attestation Function that generates reference Claims +about both the Attesting Computing Environment and the Attested +Computing Environment. The manufacturing and development +processes are presumed to be trustworthy processes. In other +words the Asserter is presumed, by a Verifier, to produce valid +Claims. The function collects, formats and protects (e.g. signs) +valid Claims known as Endorsements and Known-Good-Values. It +presents provable Claims to a Verifier using a conveyance +mechanism or protocol. + +#### Relying Party: +An Attestation Function that accepts Attestation +Results from a Verifier using a conveyance mechanism or protocol. +It assesses Attestation Results protections, parses and assesses +Attestation Results according to an assessment context (Note: +definition of the assessment context is out-of-scope). + + +Motivation +---------- + +Currently, the existing endorsements used for Intel SGX quote verification are not exposed to the user. +This makes it difficult for the verifier to specify his/her own set of policies. +Adding these new APIs allows the verifier to specify a validation policy of his/her choosing. +Possible policies: +1. The verifier has the option to specify its set of endorsements during verification. +2. The verifier has the option to provide a datetime to use during verification. +This datetime specifies the date and time at which the verifier wants to do the verification. +If no datetime is provided, the datetime when the endorsements were created is used during verification. +The verifier can provide a datetime in the past, enabling auditing of the evidence and endorsements. + + +User Experience +--------------- + +There are 2 scenarios. Note that to get the endorsements, +currently requires a Data Center Attestation Primitives (DCAP) +client that runs outside the enclave. + +### 1. Verifier is provided with endorsements: +In this scenario the attester/asserter provides the evidence and endorsements to the verifier. +The verifier is then free to use these to verify the TEE. + +##### Attester generates the evidence and endorsements (inside an enclave/TEE) +```C +... +result = oe_get_evidence( + OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION, + NULL, // custom_claims + 0, + NULL, // opt_params + 0, + &evidence, + &evidence_size, + &endorsements, + &endorsements_size); +... +``` + +##### Verifier verifies the evidence and endorsements (in an untrusted host or inside an enclave/TEE) +```C +... + +// Verify report with endorsements +result = oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + NULL, // opt_params + 0, + &claims, + &claims_size); +... +``` + +### 2. Verifier specifies endorsements: +In this scenario the attester only provides the evidence to the verifier. The verifier then fetches the endorsements from a second source different than the OE SDK, and uses the evidence and endorsements to verify the TEE. + +##### Attester generates the evidence (inside an enclave/TEE) +```C +... +result = oe_get_evidence( + OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION, + NULL, // custom_claims + 0, + NULL, // opt_params + 0, + &evidence, + &evidence_size, + &endorsements, + &endorsements_size); +... +``` + +##### Verifier verifies the evidence with custom endorsements (in the untrusted host or inside an enclave/TEE) +```C +... +// +// Verifier gets endorsements not using OE SDK +// + +// +// Verifier builds **endorsements** structure +// +endorsements_external = ... +endorsements_external_size = ... + +// Verify evidence with external endorsements +result = oe_verify_evidence( + report, + report_size, + endorsements_external, + endorsements_external_size, + NULL, // opt_params + 0, + &claims, + &claims_size); +... +``` + +Specification +------------- + +### Public type definitions +Generic serializable public structure that stores the endorsements in raw binary format. + +`attestation.h` +```C +/** + * Flags passed to oe_get_evidence() function. + */ +#define OE_EVIDENCE_FLAGS_LOCAL_ATTESTATION 0x00000000 +#define OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION 0x00000001 + +/*! Limit the size of the endorsements */ +#define OE_ATTESTATION_ENDORSEMENT_MAX_SIZE (20 * 1024) + +/*! Endorsement structure version */ +#define OE_ATTESTATION_ENDORSEMENT_VERSION (1) + +/*! \struct oe_endorsements_t + * + * \brief OE endorsements + * + * Raw generic serializable structure that contains the endorsements. All + * data should be in little endian format. + * + */ +typedef struct _oe_endorsements_t +{ + uint32_t version; ///< Version of this structure + uint32_t enclave_type; ///< The type of enclave (oe_enclave_type_t) + uint32_t buffer_size; ///< Size of the buffer + uint32_t num_elements; ///< Number of elements stored in the data buffer + + /*! Data buffer is made of an offset array of type uint32_t, followed by + * the actual data. + * This array has the size of **num_elements** and stores the offset + * into the data section. + * _________________________ + * | version | + * |-----------------------| + * | enclave_type | + * |-----------------------| + * | buffer_size | + * |-----------------------| + * | num_elements | + * |-----------------------| + * | offsets | + * | (array of uint32_t | + * | with length of | + * | num_elements) | + * |-----------------------| + * | buffer (data) | + * |_______________________| + */ + uint8_t buffer[]; ///< Buffer of offsets + data + +} oe_endorsements_t; +``` + +### Private SGX endorsement definitions + +`common/sgx/evidence.h` + +```C +/*! Version of the supported SGX endorsement structures */ +#define OE_SGX_ENDORSEMENTS_VERSION (1) + +/*! Number of CRLs in the SGX endorsements */ +#define OE_SGX_ENDORSEMENTS_CRL_COUNT (2) + +/*! \enum oe_sgx_endorsements_fields + * + * Specifies the order of the SGX endorsements fields stored in + * the oe_endorsements_t structure + */ +typedef enum _oe_sgx_endorsements_fields +{ + OE_SGX_ENDORSEMENT_FIELD_VERSION, + OE_SGX_ENDORSEMENT_FIELD_TCB_INFO, + OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN, + OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT, + OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_PROC_CA, + OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT, + OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_PROC_CA, + OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO, + OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN, + OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME, + OE_SGX_ENDORSEMENT_COUNT +} oe_sgx_endorsements_fields; + +/*! \struct oe_sgx_endorsements + * + * \brief SGX endorsements structure + * + * The generic oe_endorsements_t structure is parsed and converted into this + * internal structure. The order of the generic data elements should + * coincide with the order of the fields in this structure. + * + * Data format: All data comes from the Data Center Attestation Primitives(DCAP) + * Client. + * + * For Azure DCAP Client + * (https://github.com/microsoft/Azure-DCAP-Client/blob/master/src/dcap_provider.h) + * see **sgx_ql_revocation_info_t** and **sgx_qe_identity_info_t**. + * + * For Intel DCAP Client + * (https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/master/README.md) + * see **sgx_ql_qv_collateral_t**. + * + */ +typedef struct _oe_sgx_endorsements_t +{ + /*! + * OE_SGX_ENDORSEMENT_FIELD_VERSION + * Version of this SGX endorsement structure + * OE_SGX_ENDORSEMENT_FIELD_TCB_INFO + * TCB info, null-terminated JSON string + * TCB Info size + * OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN + * PEM format, null-terminated string + * Size of the tcb_issuer_chain + * + * OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT to + * OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_PROC_CA + * CRLs in DER format, null-terminated + * crl[0] = CRL for the SGX PCK Certificate + * crl[1] = CRL for the SGX PCK Processor CA + * + * OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT to + * OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_PROC_CA + * CRLs issuer chains in PEM format, null-terminated string + * crl[0] = Issuer Chain for the SGX PCK Certificate + * crl[1] = CRL for the SGX PCK Processor CA + * + * OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO + * QE Identity info, null-terminated JSON string + * QE Identity size + * OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN + * PEM format, null-terminated string + * Size of qe_id_issuer_chain + * + * OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME + * Time the endorsements were generated, null-terminated string + * The size of creation_datetime. + */ + oe_sgx_endorsement_item items[OE_SGX_ENDORSEMENT_COUNT]; +} oe_sgx_endorsements_t; +``` + +### New Public Attestation functions + +These functions supersede the existing functions: +1. `oe_get_evidence()` supersedes `oe_get_report()` +2. `oe_verify_evidence()` supersedes `oe_verify_report()` + +Users should start using these new functions. `oe_get_report()` and `oe_verify_report()` +are deprecated and will be removed in future releases. + +These functions will sit on top of the plug-in attestation framework. For more information please +see the [attestation plug-in design doc](CustomAttestation.md). In short, the actual implementation +of these functions will depend on which plug-in is registered. By default there will +be a built-in SGX plug-in. + +`common/sgx/attestation.c` +```C +/** + * Get evidence signed by the enclave platform along with the corresponding + * endorsements for use in attestation. + * + * This function returns the evidence and endorsements used in **local** or + * **remote** attestation. + * + * For remote attesattion: + * - This function can only be called from a TEE/enclave. + * + * For local attestation: + * - This function can be called from the TEE/enclave or the untrusted host. + * + * @param[in] flags Specifying default value (0) generates evidence for local + * attestation. Specifying OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION generates + * evidence for remote attestation. + * @param[in] custom_claims A buffer to the optional custom claims. + * @param[in] custom_claims_size The size in bytes of custom_claims. + * @param[in] opt_params Optional additional parameters needed for the current + * enclave type. + * For SGX: + * This can be sgx_target_info_t for local attestation. + * @param[in] opt_params_size The size of the **opt_params** buffer. + * @param[out] evidence_buffer This points to the resulting evidence upon success. + * @param[out] evidence_buffer_size This is set to the size of the evidence buffer + * on success. + * @param[out] endorsements_buffer The buffer containing the endorsements to parse. + * @param[out] endorsements_buffer_size The size of the **endorsements_buffer**. + * + * @retval OE_OK The evidence and endorsements were successfully created. + * @retval OE_INVALID_PARAMETER At least one parameter is invalid. + * @retval OE_OUT_OF_MEMORY Failed to allocate memory. + * + */ +oe_result_t oe_get_evidence( + uint32_t flags, + const uint8_t* custom_claims, + size_t custom_claims_size, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size); + +/** + * Free up any resources allocated by oe_get_evidence() + * + * @param[in] evidence_buffer THe buffer containing the evidence. + * @param[in] endorsements_buffer The buffer containing the endorsements. + */ +void oe_free_evidence( + uint8_t* endorsements_buffer, + uint8_t* evidence_buffer); + +/** + * Verify the integrity of the evidence and its signature, + * with endorsements that are associated with the evidence. + * This function works for both local and remote attestation. + * + * This function is available in the enclave as well as in the host. + * + * @param[in] evidence_buffer The buffer containing the evidence to verify. + * @param[in] evidence_buffer_size The size of the **evidence** buffer. + * @param[in] endorsements Optional The endorsement data that is associated with + * the evidence. + * @param[in] endorsements_size The size of the **endorsements** buffer. + * @param[in] input_validation_time Optional datetime to use when verifying + * evidence. If not specified, it will use the creation_datetime of the + * endorsements (if any endorsements are provided). + * @param[out] claims The list of claims. + * @param[out] claims_size The size of claims. + * + * @retval OE_OK The verification was successful. + * @retval OE_INVALID_PARAMETER At least one parameter is invalid. + * + */ +oe_result_t oe_verify_evidence( + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements, + size_t endorsements_size, + oe_datetime_t* input_validation_time, + uint8_t** claims, + size_t* claims_size); +``` + +### Claims +As part of the claims form `oe_verify_evidence()`, there will be a validity +datetime range, `validity_from` and `validity_until` claims that applies to the evidence and endorsements. + +Current set of claims definitions: + +| Claim Name | Claim Value Type | Description | +|:-----------------|:-------------------|:---------------------------------------------------------------------| +| id_version | uint32_t | Claims version. Must be 0 | +| security_version | uint32_t | Security version of the enclave. (ISVN for SGX). | +| attributes | uint64_t | Attributes flags for the evidence:
        `OE_REPORT_ATTRIBUTES_DEBUG`: The evidence is for a debug enclave.
        `OE_REPORT_ATTRIBUTES_REMOTE`: The evidence can be used for remote attestation. | +| unique_id | uint8_t[32] | The unique ID for the enclave (MRENCLAVE for SGX). | +| signer_id | uint8_t[32] | The signer ID for the enclave (MRSIGNER for SGX). | +| product_id | uint8_t[32] | The product ID for the enclave (ISVPRODID for SGX). | +| validity_from | oe_datetime_t | Overall datetime from which the evidence and endorsements are valid. | +| validity_until | oe_datetime_t | Overall datetime at which the evidence and endorsements expire. | + + +### OE Host Verify Library + +The OE Host Verify library is a standalone library used for verifying remote reports outside +the TEE/enclave. The function `oe_verify_remote_report()` will be updated to support +endorsements. + +Authors +------- + +Name: Sergio Wong + +email: sewong@microsoft.com + +github username: jazzybluesea \ No newline at end of file diff --git a/docs/DesignDocs/SGX_Endorsements_V2.md b/docs/DesignDocs/SGX_Endorsements_V2.md new file mode 100644 index 0000000000..4e631e2d21 --- /dev/null +++ b/docs/DesignDocs/SGX_Endorsements_V2.md @@ -0,0 +1,258 @@ +SGX Attestation Endorsements V2 Updates +================ + +Intel SGX released v2 of the Provision Certification Service for ECDSA Attestation. The +following APIs were affected: + +1. Get TCB Info. +2. Get Quoting Enclave Identity. + +[API Version 1](https://api.portal.trustedservices.intel.com/documentation#pcs-certificate) + +[API Version 2](https://api.portal.trustedservices.intel.com/documentation#pcs-certificate-v2) + +This document describes the changes for supporting version 2 of the API as well as keeping +the existing support for version 1 of the API. This document assumes the user is familiar with +the SGX attestation endorsements and how it is used during SGX quote verification. + +Motivation +---------- + +This change is required for customers who would like to use the v2 API web endpoints. Note that if SGX is +being used in an Azure data center context, the Azure PCK Caching Service and the Azure DCAP Client will +also need to be updated and it is outside of this specification. + +User Experience +--------------- + +The user experience does not change, it should be seamless to the user. The caller will be able to identify the version of the data by checking the existing `version` field. + +The quote verifier will specify whether to use the v1 or v2 PCK Caching Service web API endpoints. The +quote verification logic will be able to determine the version of the API by checking the `version` field in endorsement data. + +Specification +------------- + +## Differences between V1 and V2 APIs. + +The APIs to get the PCK Certificate and the revocation list are the same between the versions. The APIs to +get the TCB Info and get QE Identity are different. The differences are highlighted below. + +### Get TCB Info +1. tcbInfo:version changed from 1 to 2. +2. New field tcbInfo:tcbType. +3. New field tcbInfo:tcbEvaluationDataNumber. +4. Field tcbInfo:tcbLevels:status was renamed to tcbInfo:tcbLevels:tcbStatus. +5. New fields in tcbInfo:tcbLevels named tcbDate and advisoryIDs. + +### Get QE Identity Info +1. The 'qeIdentity' block was renamed to 'enclaveIdentity'. +2. A new field, enclaveIdentity:id was added to differentiate QE Id info from Quoting Enclave (QE) and Quoting Validation Enclave (QVE). +3. enclaveIdentity:version changed from 1 to 2. +4. New field enclaveIdentity:tcbEvaluationDataNumber. +5. qeIdentity:isvsvn moved to enclaveIdentity:tcbLevels:tcb:isvsvn. +6. New fields in enclaveIdentity:tcbLevels named tcbData, tcbStatus and advisoryIDs. + +### New field definitions + +#### tcbType: + type: integer + example: 0 + description: >- Type of TCB level composition that determines TCB level comparison logic + +##### tcbEvaluationDataNumber: + type: integer + example: 2 + description: >- A monotonically increasing sequence number changed when Intel updates the content of the TCB evaluation data set: TCB Info, QE Idenity and QVE Identity. The tcbEvaluationDataNumber update is synchronized across TCB Info for all flavors of SGX CPUs (Family-Model-Stepping-Platform-CustomSKU) and QE/QVE Identity. This sequence number allows users to easily determine when a particular TCB Info/QE Idenity/QVE Identiy superseedes another TCB Info/QE Identity/QVE Identity (value: current TCB Recovery event number stored in the database). + +##### tcbDate: + type: string + format: date-time + description: >- Representation of date and time when the TCB level was certified not to be vulnerable to any issues described in Security Advisories (SAs) that were published on or prior to this date. The time shall be in UTC and the encoding shall be compliant to ISO 8601 standard (YYYY-MM-DDThh:mm:ssZ). + +##### tcbStatus: + type: string + description: TCB level status + +##### advisoryIDs: + type: array + description: >- Array of Advisory IDs describing vulnerabilities that this TCB level is vulnerable to. Note: The value can be different for different FMSPCs. This field is optional. It will be present only if the list of Advisory IDs is not empty. + items: + type: string + +For more information on the new fields please see [API Version 2](https://api.portal.trustedservices.intel.com/documentation#pcs-certificate-v2). + + +## Changes + +### Update current structs with new additional fields and create new type definitions. + +```C +#define OE_TCB_LEVEL_STATUS_UNKNOWN (0) +#define OE_TCB_LEVEL_STATUS_REVOKED (1 << 0) +#define OE_TCB_LEVEL_STATUS_OUT_OF_DATE (1 << 1) +#define OE_TCB_LEVEL_STATUS_CONFIGURATION_NEEDED (1 << 2) +#define OE_TCB_LEVEL_STATUS_UP_TO_DATE (1 << 3) +#define OE_TCB_LEVEL_STATUS_QE_IDENTITY_OUT_OF_DATE (1 << 4) + +/*! \struct oe_tcb_level_status_t + */ +typedef union _oe_tcb_level_status +{ + struct { + uint32_t revoked : 1; //! "Revoked" + uint32_t outofdate : 1; //! "OutOfDate" + uint32_t configuration_needed : 1; //! "ConfigurationNeeded" + uint32_t up_to_date : 1; //! "UpToDate" + + /*! "OutOfDateConfigurationNeeded" + * + * This tcb status indicates that the QE Identity Info is out of date and + * the TCB Info requires configuration "ConfigurationNeeded" + */ + uint32_t qe_identity_out_of_date : 1; + } fields; + uint32_t AsUINT32; + +} oe_tcb_level_status_t; + +/*! \struct oe_tcb_info_tcb_level_t + * \brief TCB level field in the SGX TCB Info. + * + * Version 2 of the SGX endorsements/collaterals, the QE Identiy + * Info structure also has a TCB level field (\ref See oe_qe_info_tcb_level_t). + */ +typedef struct _oe_tcb_info_tcb_level +{ + uint8_t sgx_tcb_comp_svn[16]; + uint16_t pce_svn; + oe_tcb_level_status_t status; + + // V2 fields + oe_datetime_t tcb_date; + + /*! Offset into the json QE Identity info where + * the advisoryIDs fields start. + */ + size_t advisory_ids_offset; + + //! Total size of all the advisoryIDs. + size_t advisory_ids_size; +} oe_tcb_info_tcb_level_t; + +/*! \struct oe_parsed_tcb_info_t + * \brief TCB info excluding the TCB levels field. + */ +typedef struct _oe_parsed_tcb_info +{ + uint32_t version; + oe_datetime_t issue_date; + oe_datetime_t next_update; + uint8_t fmspc[6]; + uint8_t pceid[2]; + uint8_t signature[64]; + + // V2 fields + uint32_t tcb_type; + uint32_t tcb_evaluation_data_number; + oe_tcb_info_tcb_level_t tcb_level; + + const uint8_t* tcb_info_start; + size_t tcb_info_size; + +} oe_parsed_tcb_info_t; + +/*! \enum oe_qe_identity_id + * \brief Quoting enclave identity id (V2 only) + */ +typedef enum _oe_qe_identity_id +{ + QE_IDENTITY_ID_QE, + QE_IDENTITY_ID_QVE +} oe_qe_identity_id_t; + +/*! \struct oe_qe_tcb_level + * \brief Quoting enclave identity TCB level. Applies to V2 only. + */ +typedef struct _oe_qe_identity_info_tcb_level +{ + uint32_t isvsvn[1]; + oe_tcb_level_status_t tcb_status; + oe_datetime_t tcb_date; + + /*! Offset into the json QE Identity info where + * the advisoryIDs fields start. + */ + size_t advisory_ids_offset; + + //! Total size of all the advisoryIDs. + size_t advisory_ids_size; +} oe_qe_identity_info_tcb_level_t; + +/*! \struct oe_parsed_qe_identity_info_t + * \brief SGX Quoting Enclave Identity Info data structure. + */ +typedef struct _oe_parsed_qe_identity_info +{ + uint32_t version; + oe_datetime_t issue_date; + oe_datetime_t next_update; + uint32_t miscselect; //! The MISCSELECT that must be set + uint32_t miscselect_mask; //! Mask of MISCSELECT to enforce + sgx_attributes_t attributes; //! flags and xfrm (XSAVE-Feature Request Mask) + uint64_t attributes_flags_mask; //! mask for attributes.flags + uint64_t attributes_xfrm_mask; //! mask for attributes.xfrm + uint8_t mrsigner[OE_SHA256_SIZE]; //! MRSIGNER of the enclave + uint16_t isvprodid; //! ISV assigned Product ID + uint16_t isvsvn; //! ISV assigned SVN + uint8_t signature[64]; + + // V2 fields + oe_qe_identity_id_t id; + uint32_t tcb_evaluation_data_number; + oe_qe_identity_info_tcb_level_t tcb_level; + + const uint8_t* info_start; + size_t info_size; +} oe_parsed_qe_identity_info_t; +``` + +### Summary of Processing Changes + +The quote verification logic for parsing the TCB Info and the QE Identity Info will need to be updated as well as the validation logic. + +1. Update `oe_parse_tcb_info_json()` and `oe_parse_qe_identity_info_json()` to parse the new v2 fields. +2. Account for new TCB status "OutOfDateConfigurationNeeded" in v2 API. + - This new TCB status seems to indicate that: + 1. The QE Identity info is out of date, and + 2. The TCB Info requires configuration. +3. TCB info validation updates: + - version 1: + - Bug fix. Will create and address this in a separate issue: + - Verify `pceid` field matches the one in the PCK Cert. + - Verify `fmspc` field matches the one in the PCK Cert. + - version 2: + - Validate `tcbType` has a value of 0. + - Check that `tcbEvaluationDataNumber` is at least or equal to the current cached value. Update cached + value if the current value is greater than the cached value. + - TCB Level processing: + - Account for new tcbStatus "OutOfDateConfigurationNeeded" + - No additional processing on `tcbDate` and `advisoryIDs`. +4. QE identity info validation updates: + - version 1: No updates. + - version 2: + - Check that `tcbEvaluationDataNumber` is at least or equal to the current cached value. Update cached + value if the current value is greater than the cached value. + - TCB Level processing: + - Find the first TCB level which the quote's `isvsvn` value is greater than or equal to the corresponding value in the TCB level. + - Set the `tcbStatus` value from the corresponding TCB level. + - No additional processing on `tcbDate` and `advisoryIDs`. + +Authors +------- + +Name: Sergio Wong + +email: sewong@microsoft.com + +github username: jazzybluesea diff --git a/docs/DesignDocs/SwitchlessCalls.md b/docs/DesignDocs/SwitchlessCalls.md new file mode 100644 index 0000000000..7ff3538f06 --- /dev/null +++ b/docs/DesignDocs/SwitchlessCalls.md @@ -0,0 +1,108 @@ +Context-switchless Calls +================ + +## Motivation + +Context-switchless Calls are designed to reduce the cost of context switching between hosts and enclaves. +In an enclave application, the host makes **ECALL**s into functions exposed by the enclaves it created. Likewise, +the enclaves may make **OCALL**s into functions exposed by the host that created them. In either case, the +execution has to be transitioned from an untrusted environment to a trusted environment, or vice versa. Since the +transition is costly due to heavy security checks, for example, instruction `EENTER` alone could take hundreds of CPU +cycles, it might be more performance advantageous to make the calls +**context-switchless**: the caller delegates the function call to a worker thread in the other environment, which +does the real job of calling the function and posting the result to the caller. Both the calling thread and the +worker thread never leave their respective execution contexts during the perceived function call. By having two threads +working on two different security contexts, each conforming to the security constraints of its own context, we could +achieve better function call performance without sacrificing security. + +## Possible Usages + +In general, the good candidates for switchless calls are functions that are: +1) short, thus the transition takes relatively a high percentage of the overall execution time of the call; and +2) called frequently, so the savings in transition time adds up. + +If your enclave application has such functions and you are concerned with performance, consider making those +functions context-switchless. + +## User Experience + +Firstly, the user has to identify which functions are good candidates of switchless calls. The identified ones +need to be marked in the EDL file with a keyword `transition_using_threads`. For example, to mark function +`host_increment_switchless` a target of switchless calls, it has to be declared as: + +```c +void host_increment_switchless([in, out] int* m) transition_using_threads; +``` + +Secondly, while creating an enclave, the user has to explicitly configure it to enable switchless capability. +An important setting in the configuration is how many worker threads are to be created for servicing the +context-switchless calls. More worker threads typically means more competition for the CPU cores and more thread +context switches, hurting the performance. On the other hand, fewer worker threads means simultaneously issued +switchless calls are less likely to be serviced quickly, if they got serviced at all. +We will give a guideline for users to search for the "sweet spot" of this setting. + +The users are encouraged to measure the performance delta between enclave applications with +or without switchless calls, and decide on whether switchless calling should be turned on for some functions, +and/or the ideal number of worker threads. + +## Specification + +**Information exchanges between threads** + +The calling thread and the worker thread need to exchange information twice during the call. When the switchless +call is initiated, the caller needs to pass the `job` (encapsulating information regarding the function call in a + single object, for details see the next section) to the worker thread. And when the call finishes, the worker +thread needs to pass the result back to the caller. + +**The function call as a `job`** + +We use the same marshalling code for both switchless calls and regular calls. Essentially, the `job` contains +information like the function table, the function ID, the input parameters flattened in a contiguous buffer, +and reserved spaces for output parameters and return value. Since the call is represented the same way for +both switchless calls and regular calls, we have the flexibility of converting a switchless call into a +regular call, or vice versa, at any point prior to the call is fulfilled. + +**Thread synchronizations** + +Both exchanges between the calling thread and the worker thread need to be synchronized. Whenever possible, +we use atomic operations to such exchanges for performance reasons. We will also ensure the compiler doesn't +introduce out-of-order execution in the case one thread writes data which is then consumed by another thread. Obviously, +there is a M:N mapping between the calling threads and the worker threads. To simplify synchronization, instead +of having a queue that is shared by worker threads, we choose to set up a queue for each worker thread, so that +`jobs` posted to one worker thread do not interfere with `jobs` posted to another worker +thread. With a further simplification, we limit the queue length to 1. Effectively, this means there is at +most one `job` waiting to be serviced by a worker thread. This avoids interference between `jobs` posted to +the same worker thread, i.e., a time-consuming switchless call stalls the next switchless call on the same thread. + +**Sleep/wake of worker threads** + +The worker threads are idle when there are no incoming switchless calls. To save CPU cycles, we will put a +worker thread to sleep when it is idle for a prolonged period of time. Subsequently, a calling thread has to +wake it up before posting a `job` to it. + +**Fallback to regular calls** + +Since we have a limited number of worker threads, and the queue for each worker thread is just one, obviously +a switchless call could be dropped due to all worker threads are busy. In this case, we fall back to the regular +**ECALL**/**OCALL**. + +**Security considerations** + +Switchless calls depend on switchless manager, an object manages the worker threads and their queues. Since it +exists in the untrusted memory, we have to assume it could be maliciously manipulated. The switchless handling +inside the enclave must be guarded against such manipulations. In any case, deny-of-service is outside the scope +since DoS is possible even with regular ECALL/OCALLs. + + +**Switchless OCALLs first** + +Based on customer feedback, we have decided to deliver switchless OCALLs first. Please contact us if you have +strong demand for switchless ECALLs. + + +Authors +------- + +Xuejun Yang (xuejya@microsoft.com) + +Anand Krishnamoorthi (anakrish@microsoft.com) diff --git a/docs/DesignDocs/full_edl_serialization.md b/docs/DesignDocs/full_edl_serialization.md new file mode 100644 index 0000000000..93f682208a --- /dev/null +++ b/docs/DesignDocs/full_edl_serialization.md @@ -0,0 +1,182 @@ +Enforcing full serialization in EDL +=================================== + +Motivation +---------- + +Currently EDL only provides partial support for parameter serialization. For +example, the following EDL defines ECALLs whose parameters can only be +partially serialized. + +```c++ +enclave +{ + /* Include struct iovec (foreign structure) */ + #include + + trusted + { + public int send( + [in, count=iovcnt] const struct iovec* iov, + size_t iovcnt); + + public int recv( + [out, count=iovcnt] struct iovec* iov, + size_t iovcnt); + }; +}; +``` + +The generator produces code that serializes the array of **iovec** +structures, but it cannot serialize the buffer referenced by the structure +itself. Recall the definition of the **iovec** structure. + +```c++ +struct iovec +{ + void* iov_base; + size_t iov_len; +}; +``` + +Consequently, these ECALLs pass pointers to untrusted memory (**iov_base**) to +the enclave developer's **send** and **recv** implementations. + +The exposure of untrusted pointers to the enclave implementation poses two main +problems. + +- Implementations are vulnerable to coding errors that may introduce security + vulnerabilities. +- The enclave application is not portable to trusted hardware environments + that do not support or have not enabled shared memory (e.g., TrustZone). + +Some potential security vulnerabilities include: + +- Time-of-check, Time-of-use errors (TOC-TOU). +- Unwittingly writing secrets onto host memory. +- Overwrite attacks where **iov_base** points to enclave memory. + +EDL provides a *deep-copy* feature for fully serializing parameters as shown +below. + +```c++ +enclave +{ + struct local_iovec + { + [size=iov_len] + void* iov_base; + size_t iov_len; + }; + + trusted + { + public int send( + [in, count=iovcnt] const struct local_iovec* iov, + size_t iovcnt); + + public int recv( + [out, count=iovcnt] struct local_iovec* iov, + size_t iovcnt); + }; +}; +``` + +This example introduces a local structure definition (**local_iovec**) which +provides an annotation allowing **iov_base** to be serialized. + +The following EDL considers a second scenario that implicitly passes untrusted +memory into the trusted implementation. + +```c++ +enclave +{ + untrusted + { + struct widget* get_widget(); + }; +}; +``` + +The **get_widget** OCALL returns a pointer to untrusted memory. This is overcome +by redefining the OCALL as follows. + +```c++ +enclave +{ + untrusted + { + int get_widget([out] struct widget* widget); + }; +}; +``` + +Although EDL provides sufficient mechanisms for performing full serialization, +the generator does not currently enforce these mechanisms. By default, the +generator produces edge routines that implicitly copy untrusted memory +references into the enclave. This results in potential security flaws and +non-portable code. + +To overcome these problems, the generator can be modified to warn when an EDL +specification cannot be fully serialized. + +User Experience +--------------- + +When using the generator, the user will see warnings when the following are +encountered. + +- Foreign structures +- Non-serializable local structures (lacking the appropriate annotations) +- Pointer return values + +The user may wish to treat these warnings as errors using an option similar to +GCC's **-Werror** option. + +Specification +------------- + +The generator should be modified to produce the warnings mentioned above, via +these flags: + +- `-Wforeign-struct` +- `-Wptr-in-local-struct` +- `-Wptr-return-value` + +While adding these warnings, the existing warnings that are able to be ignored +(not that they ought to be) should be made togglable with the following flags: + +- `-Wnon-portable-types` +- `-Wsigned-size-or-count-types` +- `-Wcalling-convention` +- `-Wallow-list` + +Along with `-Wno-` versions of all of the above to disable them, `-Wall` to turn +them all on and `-Werror` to treat them as errors (causing `oeedger8r` to exit +with a non-zero exit code). + +The warnings should not be on by default. However, the Open Enclave build should +be modified to use `-Wall -Werror` in all places. + +The existing "warnings" which are actually errors that cannot be ignored should +be renamed as "errors" in the implementation as well as in their messages. This +includes: + +- Simultaneous size and count parameters +- The `--use_prefix` flag +- `private` function specifier +- Switchless ecalls +- "dllimport" + +Alternatives +------------ + +We considered introducing complimentary interface definition languages such +as Google protobufs and others. We are open to having such alternatives in +the future. + +Authors +------- + +- Mike Brasher (mikbras) +- Andrew Schwartzmeyer (andschwa) diff --git a/docs/DevelopmentGuide.md b/docs/DevelopmentGuide.md index df26880aaa..fbeacdc193 100644 --- a/docs/DevelopmentGuide.md +++ b/docs/DevelopmentGuide.md @@ -11,8 +11,21 @@ Coding Conventions * **DO** use `const` and `static` and visibility modifiers to scope exposure of variables and methods as much as possible. +* **DO** use doxygen comments, with \[in,out\] + [direction annotation](http://www.doxygen.nl/manual/commands.html#cmdparam) in all public API + headers. This is also encouraged, but not strictly required, for internal API + headers as well. + +* **DO** disable doxygen documentation for elements that are not in the public + API as described [here](./refman/doxygen-howto.md#disable-doxygen). + * **DON'T** use global variables where possible. +* **DON'T** use abbreviations unless they are already well-known terms known by + users (e.g., "app", "info"), or are already required for use by developers (e.g, + "min", "max", "args"). Examples of bad use would be `num_widgets` instead of + `widget_count`, and `opt_widgets` instead of `option_widgets` or `optional_widgets`. + Style Guide ----------- @@ -50,7 +63,7 @@ for details. The following license header **must** be included at the top of every file: ``` -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. ``` @@ -97,7 +110,7 @@ in that file takes precedence. Note that we _no longer_ use `CamelCase` nor double underscores (`__`), but you may find remnants and so again should prefer the local style. This is especially the case for classes, which are still using `PascalCase`. For now, follow the -existing style. The project maintainers prefer to fix style issues in bulk using +existing style. The project Committers prefer to fix style issues in bulk using automation, so avoid submitting PRs intended to fix only a few instances of the inconsistent style. @@ -113,7 +126,7 @@ For other files (`*.asm`, `*.S`, etc.) our current best guidance is consistency: Excerpt from `enclave/key.c`: ```c -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "key.h" diff --git a/docs/GettingStartedDocs/APIs_and_Libs.md b/docs/GettingStartedDocs/APIs_and_Libs.md new file mode 100644 index 0000000000..6d041fb218 --- /dev/null +++ b/docs/GettingStartedDocs/APIs_and_Libs.md @@ -0,0 +1,23 @@ +# API reference and supported libraries + +One of the security principles of writing enclave applications is to minimize the +Trusted Computing Base (TCB) of the enclave code. A consequence of this is that +while the host application has full access to the range of libraries and API +available to all normal mode applications, the enclave is restricted to a much +more constrained set as described below: + +## [Open Enclave API](https://openenclave.github.io/openenclave/api/index.html) + +The Doxygen documentation of the API exposed by Open Enclave SDK to both enclave and host. + +## [Libc support](/docs/LibcSupport.md) + +The subset of libc functionality provided by oelibc for use inside an enclave. + +## [Libcxx support](/docs/LibcxxSupport.md) + +The subset of libcxx functionality provided by oelibcxx for use inside an enclave. + +## [mbedtls library](/docs/MbedtlsSupport.md) + +The subset of [mbedtls](https://tls.mbed.org/) functionality for use inside an enclave. \ No newline at end of file diff --git a/docs/GettingStartedDocs/Contributors/AdvancedBuildInfo.md b/docs/GettingStartedDocs/Contributors/AdvancedBuildInfo.md index 2397dee015..53522f69c4 100644 --- a/docs/GettingStartedDocs/Contributors/AdvancedBuildInfo.md +++ b/docs/GettingStartedDocs/Contributors/AdvancedBuildInfo.md @@ -102,7 +102,7 @@ huge number of nodes (targets) in the resulting graph. To change the ignored targets, edit the file named `CMakeGraphVizOptions.cmake` at the root of the repo. -As of 2019-03-27, it looks like this: +As of 2019-11-12, it looks like this: ![CMake Dependency Graph](/docs/GettingStartedDocs/DependencyGraph.svg) diff --git a/docs/GettingStartedDocs/Contributors/BuildingInADockerContainer.md b/docs/GettingStartedDocs/Contributors/BuildingInADockerContainer.md index d43075a2f9..8440152e10 100644 --- a/docs/GettingStartedDocs/Contributors/BuildingInADockerContainer.md +++ b/docs/GettingStartedDocs/Contributors/BuildingInADockerContainer.md @@ -9,11 +9,11 @@ 1. Install Docker CE by following these instructions: https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce 2. Install the appropriate Intel SGX Driver for your platform. For example, if you're running on an SGX1 with FLC system, you'll probably want to install the Intel SGX DCAP Driver for your platfrom: https://01.org/intel-software-guard-extensions/downloads - - If you're running on an SGX with FLC system, you'll probably want to install the Intel SGX DCAP Driver for your platfrom: https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-dcap-linux-1.2-release - - If you're running on an SGX without FLC system, you'll want to install the Intel SGX Driver for your platform: https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-linux-2.6-release - - The driver you're looking for is a ".bin" file, for either Ubuntu 16.04 or 18.04 releases. It will be named something like: `sgx_linux_x64_driver_1.12_c110012.bin` + - If you're running on an SGX with FLC system, you'll probably want to install the Intel SGX DCAP Driver for your platfrom: https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-dcap-linux-1.3-release + - If you're running on an SGX without FLC system, you'll want to install the Intel SGX Driver for your platform: https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-linux-2.7-release + - The driver you're looking for is a ".bin" file, for either Ubuntu 16.04 or 18.04 releases. It will be named something like: `sgx_linux_x64_driver_1.20.bin` - To install this driver, simply run it as root like this: - - `sudo bash ./sgx_linux_x64_driver_1.12_c110012.bin` + - `sudo bash ./sgx_linux_x64_driver_1.20.bin` 3. Pull the latest oetools-full image for Open Enclave from *either* of these two distributions: - https://hub.docker.com/r/oeciteam/oetools-full-16.04 diff --git a/docs/GettingStartedDocs/Contributors/InstallInfo.md b/docs/GettingStartedDocs/Contributors/LinuxInstallInfo.md similarity index 96% rename from docs/GettingStartedDocs/Contributors/InstallInfo.md rename to docs/GettingStartedDocs/Contributors/LinuxInstallInfo.md index 7680158bbc..35a1f0c2f6 100644 --- a/docs/GettingStartedDocs/Contributors/InstallInfo.md +++ b/docs/GettingStartedDocs/Contributors/LinuxInstallInfo.md @@ -1,5 +1,5 @@ -Basic Install -============= +Basic Install on Linux +====================== You can locally install the SDK from the compiled Open Enclave tree by specifying the install-prefix to the cmake call before calling "make install". The SDK does @@ -16,7 +16,7 @@ cmake -G Ninja -DCMAKE_INSTALL_PREFIX=~/openenclave-install .. ninja ``` -This would install the [resulting SDK layout](/docs/GettingStartedDocs/using_oe_sdk.md#open-enclave-sdk-layout) +This would install the [resulting SDK layout](/docs/GettingStartedDocs/Linux_using_oe_sdk.md#open-enclave-sdk-layout) under `~/openenclave-install` instead of the default `/opt/openenclave`. Optional Advanced Install diff --git a/docs/GettingStartedDocs/Contributors/OPTEEGettingStarted.md b/docs/GettingStartedDocs/Contributors/OPTEEGettingStarted.md new file mode 100644 index 0000000000..459eeca8c9 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/OPTEEGettingStarted.md @@ -0,0 +1,70 @@ +# Getting Started with Open Enclave for OP-TEE OS + +The Open Enclave SDK as well as hosts and enclaves build via cross-compilation. +Therefore, an ARM system, physical or emulated, is necessary only for execution, +but not for development and building. + +## Platform Requirements + +- Ubuntu 16.04 LTS (64-bit) or 18.04 LTS (64-bit) + +## Clone the Open Enclave SDK + +```bash +git clone --recursive https://github.com/openenclave/openenclave.git +``` + +## Install Build Requirements + +Installing the build-time requirements is done via Ansible. The following +command listing shows how to install Ansible, then how to run the Ansible +Playbook that installs the requirements. + +```bash +cd openenclave + +sudo scripts/ansible/install-ansible.sh +sudo ansible-playbook scripts/ansible/oe-contributors-setup-cross-arm.yml +``` + +## Build the Open Enclave SDK + +Given that each ARM board is different, OP-TEE OS may be configured and built +accordingly. This means that a build of OP-TEE OS for one board is most likely +not compatible with a build of the exact same code for a different board. + +During OP-TEE OS' build process, a so-called "Dev Kit" is generated. This kit +contains a number of headers, libraries and configuration files that describe +the settings that were used to build OP-TEE OS for a given board. The Open +Enclave SDK's build process consumes this Dev Kit to in turn configure and link +the components that it leverages to support OP-TEE OS. As a result, it is highly +recommended that you build the SDK from source for each target board so as to +minimize the chance of a configuration mismatch, which, while minimal at the +level of abstraction that the SDK operates at, may nevertheless occur. + +Assuming that you have a Dev Kit from an OP-TEE OS build and its location is +stored in the `DEV_KIT` variable, compiling the SDK is simple: + +```bash +mkdir build +cd build + +cmake ../sdk \ + -G Ninja \ + -DHAS_QUOTE_PROVIDER=OFF \ + -DCMAKE_TOOLCHAIN_FILE=../sdk/cmake/arm-cross.cmake \ + -DOE_TA_DEV_KIT_DIR=$DEV_KIT/export-ta_arm64 \ + -DCMAKE_BUILD_TYPE=Debug +ninja +``` + +The build results in ARM64 binaries. + +Refer to the list of +[supported platforms](../OP-TEE/Introduction.md#supported-platforms) +for details on building the SDK for a specific target. + +## Remarks + +Automatically running unit tests or installing the SDK's build output is not yet +supported when compiling it for OP-TEE OS. diff --git a/docs/GettingStartedDocs/Contributors/RunningStaticAnalysis.md b/docs/GettingStartedDocs/Contributors/RunningStaticAnalysis.md new file mode 100644 index 0000000000..b779af0372 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/RunningStaticAnalysis.md @@ -0,0 +1,42 @@ +# Getting started with running static analysis tools + +## scan-build + +*Note: scan-build only works with clang and gcc and as such is only currently supported for linux builds* + +1. Install scan-build-7 (or whatever version matches your version of clang) + + ``` + $ apt install clang-tools-7 + ``` + +2. (Optional) Create symlinks for scan-build and scan-view to avoid needing to specify a version. If you skip this step, just add the clang version to each `scan-*` command e.g. `scan-build-7 ...` + + ```{bash} + $ ln -s /usr/bin/scan-build /usr/bin/scan-build-7 + $ ln -s /usr/bin/scan-view /usr/bin/scan-view-7 + ``` + +3. Run scan-build for cmake and make build commands + + For example: + + ```{bash} + $ scan-build cmake .. -G Ninja -DHAS_QUOTE_PROVIDER=OFF + $ scan-build ninja + ``` + + *Note: scan-build also works with the cmake GNU make generator* + +4. View the output + + At the end of the scan-build output, it will print a command you can use to view the results. + + The output could look like: + + ``` + scan-build: 200 bugs found. + scan-build: Run 'scan-view /tmp/scan-build-2019-12-12-102130-18694-1' to examine bug reports. + ``` + + Running `scan-view /tmp/scan-build-2019-12-12-102130-18694-1` will open results in a web browser. diff --git a/docs/GettingStartedDocs/Contributors/SGX1FLCGettingStarted.md b/docs/GettingStartedDocs/Contributors/SGX1FLCGettingStarted.md index 16cc2b870e..c2346abf79 100644 --- a/docs/GettingStartedDocs/Contributors/SGX1FLCGettingStarted.md +++ b/docs/GettingStartedDocs/Contributors/SGX1FLCGettingStarted.md @@ -59,12 +59,9 @@ or cmake -G "Ninja" .. ninja ``` - -Open Enclave will support attestation workflows outside of Azure using DCAP in an upcoming release. - Refer to the [Advanced Build Information](AdvancedBuildInfo.md) documentation for further information. -## Run unittests +## Run unit tests After building, run all unit test cases using `ctest` to confirm the SDK is built and working as expected. @@ -96,12 +93,16 @@ Test project /home/youradminusername/openenclave/build 100% tests passed, 0 tests failed out of 123 Total Test time (real) = 83.61 sec -``` +A clean pass of the above unit tests is an indication that your Open Enclave setup was successful. -A clean pass of the above unitests run is an indication that your Open Enclave setup was successful. You can start playing with the Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, +You can start playing with the Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, For more information refer to the [Advanced Test Info](AdvancedTestInfo.md) document. ## Install -Follow the instructions in the [Install Info](InstallInfo.md) document to install the Open Enclave SDK built above. +Follow the instructions in the [Install Info](LinuxInstallInfo.md) document to install the Open Enclave SDK built above. + +## Build and run samples + +To build and run the samples, please look [here](/samples/README_Linux.md). diff --git a/docs/GettingStartedDocs/Contributors/SGX1GettingStarted.md b/docs/GettingStartedDocs/Contributors/SGX1GettingStarted.md index 82a08909b4..fe7ab198cd 100644 --- a/docs/GettingStartedDocs/Contributors/SGX1GettingStarted.md +++ b/docs/GettingStartedDocs/Contributors/SGX1GettingStarted.md @@ -15,41 +15,23 @@ git clone https://github.com/openenclave/openenclave.git This creates a source tree under the directory called openenclave. -## Install project prerequisites - -Ansible is required to install the project prerequisites. If not already installed, you can install it by running: `scripts/ansible/install-ansible.sh`. To install all the OpenEnclave prerequisites you can execute the `environment-setup.yml` tasks from `linux/openenclave` Ansible role: - +## Install project requirements +First, change directory into the openenclave repository: ```bash -cd openenclave/scripts/ansible -ansible localhost -m import_role -a "name=linux/openenclave tasks_from=environment-setup.yml" --become --ask-become-pass +cd openenclave ``` -## Install Intel SGX1 support software packages - -There are two Intel packages needed for SGX1: - -- Intel® SGX Driver (/dev/isgx) -- Intel® SGX AESM Service (from the Intel® SGX SDK) - -Refer to the [Intel® SGX Driver](https://github.com/01org/linux-sgx-driver) and [Intel® SGX AESM Service](https://github.com/01org/linux-sgx) github repositories for detailed instructions on how to build and install these packages. - -As a convenience, Open Enclave provides a script for downloading, building and -installing both the driver and the AESM service. To install these dependencies -type the following commands from the root of the source distribution: - +Ansible is required to install the project requirements. If not already installed, you can install it by running: ```bash -sudo make -C prereqs -sudo make -C prereqs install +sudo scripts/ansible/install-ansible.sh ``` -After this completes verify that the AESM service is running as follows: +Run the following command from the root of the source tree: ```bash -service aesmd status +sudo ansible-playbook scripts/ansible/oe-contributors-setup-sgx1.yml ``` -Look for the string “active (running)”, usually highlighted in green. - ## Build To build first create a build directory ("build/" in the example below) and change into it. @@ -62,13 +44,13 @@ cd build/ Then run `cmake` to configure the build and generate the make files and build: ```bash -cmake -DUSE_LIBSGX=OFF .. +cmake -DHAS_QUOTE_PROVIDER=OFF .. make ``` Refer to the [Advanced Build Information](AdvancedBuildInfo.md) documentation for further information. -## Run unittests +## Run unit tests After building, run all unit test cases using `ctest` to confirm the SDK is built and working as expected. @@ -102,10 +84,16 @@ Test project /home/youradminusername/openenclave/build Total Test time (real) = 83.61 sec ``` -A clean pass of the above unitests run is an indication that your Open Enclave setup was successful. You can start playing with the Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, +A clean pass of the above unit tests is an indication that your Open Enclave setup was successful. + +You can start playing with the Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, For more information refer to the [Advanced Test Info](AdvancedTestInfo.md) document. ## Install - Follow the instructions in the [Install Info](InstallInfo.md) document to install the Open Enclave SDK built above. + Follow the instructions in the [Install Info](LinuxInstallInfo.md) document to install the Open Enclave SDK built above. + +## Build and run samples + +To build and run the samples, please look [here](/samples/README_Linux.md). diff --git a/docs/GettingStartedDocs/Contributors/SimulatorGettingStarted.md b/docs/GettingStartedDocs/Contributors/SimulatorGettingStarted.md index dedf6ec797..8874690a0d 100644 --- a/docs/GettingStartedDocs/Contributors/SimulatorGettingStarted.md +++ b/docs/GettingStartedDocs/Contributors/SimulatorGettingStarted.md @@ -1,4 +1,4 @@ -# Getting Started with Open Enclave in Simulator mode +# Getting Started with Open Enclave in Simulation mode ## Platform requirement @@ -25,7 +25,7 @@ sudo ./scripts/ansible/install-ansible.sh To install all the Open Enclave prerequisites you can execute the `environment-setup.yml` tasks from `linux/openenclave` Ansible role: ```bash -cd openenclave/scripts/ansible +cd scripts/ansible ansible localhost -m import_role -a "name=linux/openenclave tasks_from=environment-setup.yml" --become --ask-become-pass ``` @@ -41,7 +41,7 @@ cd build/ Then run `cmake` to configure the build and generate the make files and build: ```bash -cmake -DUSE_LIBSGX=OFF .. +cmake -DHAS_QUOTE_PROVIDER=OFF .. make ``` @@ -98,10 +98,16 @@ Errors while running CTest Some of the tests are skipped (Not Run) by design because the current simulator is not fully featured yet. -A clean pass of the above unitests run is an indication that your Open Enclave setup was successful. You can start playing with those Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, +A clean pass of the above unit tests is an indication that your Open Enclave setup was successful. + +You can start playing with those Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, For more information refer to the [Advanced Test Info](AdvancedTestInfo.md) document. ## Install - Follow the instructions in the [Install Info](InstallInfo.md) document to install the Open Enclave SDK built above. + Follow the instructions in the [Install Info](LinuxInstallInfo.md) document to install the Open Enclave SDK built above. + +## Build and run samples + +To build and run the samples, please look [here](/samples/README_Linux.md). diff --git a/docs/GettingStartedDocs/Contributors/WindowsInstallInfo.md b/docs/GettingStartedDocs/Contributors/WindowsInstallInfo.md new file mode 100644 index 0000000000..b90c695b88 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/WindowsInstallInfo.md @@ -0,0 +1,38 @@ +Basic Install on Windows +======================== + +You can locally install the SDK from the compiled Open Enclave tree by specifying +the install-prefix to the cmake call before calling `ninja install`. +From the build subfolder in your source tree: + +For SGX1 + FLC targets, assuming that the Intel and Azure DCAP NuGet packages are installed to `C:\oe_prereqs` and the Open Enclave SDK is installed to `C:\openenclave`: + +```cmd +cmake .. -G Ninja -DNUGET_PACKAGE_PATH=C:\oe_prereqs -DCMAKE_INSTALL_PREFIX:PATH=C:\openenclave +ninja install +``` + +For SGX1 targets: + +```cmd +cmake .. -G Ninja -DNUGET_PACKAGE_PATH=C:\oe_prereqs -DCMAKE_INSTALL_PREFIX:PATH=C:\openenclave -DHAS_QUOTE_PROVIDER=OFF +ninja install +``` + +This will install the [resulting SDK layout](/docs/GettingStartedDocs/Windows_using_oe_sdk.md#open-enclave-sdk-layout) to C:\openenclave +Please note that NUGET_PACKAGE_PATH in the above command points to the directory where where the Intel SGX & DCAP Client NuGet packages packackages are installed on your system. + +## Create a redistributable SDK package + +To create a redistributable NuGet package use the following command from your build subfolder: + +```cmd +cmake .. -G Ninja -DNUGET_PACKAGE_PATH=C:\oe_prereqs -DCPACK_GENERATOR=NuGet +ninja package +``` + +This will result in a NuGet package being created in the build folder. + +## Create the host-only report verification package + +This is work in progress and is coming soon. diff --git a/docs/GettingStartedDocs/Contributors/WindowsManualInstallPrereqs.md b/docs/GettingStartedDocs/Contributors/WindowsManualInstallPrereqs.md new file mode 100644 index 0000000000..807478dc82 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/WindowsManualInstallPrereqs.md @@ -0,0 +1,95 @@ +# Manually Installing Open Enclave Prerequisites for Windows on a System which supports SGX + +## Platform requirements +- A system with support for SGX1 or SGX1 with Flexible Launch Control (FLC). + + Note: To check if your system has support for SGX1 with or without FLC, please look [here](../SGXSupportLevel.md). + +- A version of Windows OS with native support for SGX features: + - For server: Windows Server 2016 + - For client: Windows 10 64-bit version 1709 or newer + - To check your Windows version, run `winver` on the command line. + +## Software prerequisites +- [Microsoft Visual Studio Build Tools 2019](https://aka.ms/vs/15/release/vs_buildtools.exe) +- [Git for Windows 64-bit](https://git-scm.com/download/win) +- [Node.js 10.x](https://nodejs.org/en/download/) +- [esy](https://esy.sh/) +- [Clang/LLVM for Windows 64-bit](http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe) +- [Python 3](https://www.python.org/downloads/windows/) + +## Prerequisites specific to SGX support on your system + +For systems with support for SGX1 - [Intel's PSW 2.5, Intel Enclave Common API library](WindowsManualSGX1Prereqs.md) + +For systems with support for SGX1 + FLC - [Intel's PSW 2.5, Intel's Data Center Attestation Primitives and related dependencies](WindowsManualSGX1FLCDCAPPrereqs.md) + +## Microsoft Visual Studio Build Tools 2019 +Install [Visual Studio Build Tools 2019](https://aka.ms/vs/16/release/vs_buildtools.exe). Choose the "C++ build tools" workload. Visual Studio Build Tools 2019 has support for CMake Version 3.15 (CMake ver 3.12 or above is required for building Open Enclave SDK). For more information about CMake support, look [here](https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/). + +## Git for Windows 64-bit + +Install Git and add Git Bash to the PATH environment variable. +Typically, Git Bash is located in `C:\Program Files\Git\bin`. +Currently the Open Enclave SDK build system uses bash scripts to configure +and build Linux-based 3rd-party libraries. + +Open a command prompt and ensure that Git Bash is added to PATH. + +```cmd +C:\>where bash +C:\Program Files\Git\bin\bash.exe +``` + +Tools available in the Git bash environment are also used for test and sample +builds. For example, OpenSSL is used to generate test certificates, so it is +also useful to have the `Git\mingw64\bin` folder added to PATH. This can be checked +from the command prompt as well: + +```cmd +C:\>where openssl +C:\Program Files\Git\mingw64\bin\openssl.exe +``` + +## Clang + +Install Clang 7.0.1 and add the LLVM folder (typically C:\Program Files\LLVM\bin) +to PATH. Open Enclave SDK uses clang to build the enclave binaries. + +Open up a command prompt and ensure that clang is added to PATH. + +```cmd +C:\> where clang +C:\Program Files\LLVM\bin\clang.exe +C:\> where llvm-ar +C:\Program Files\LLVM\bin\llvm-ar.exe +C:\> where ld.lld +C:\Program Files\LLVM\bin\ld.lld.exe +``` + +## OCaml via esy with Node.js + +Install [Node.js 10.x](https://nodejs.org/en/download/) from the "Previous +Releases" page. Ensure `npm` is in your `PATH` (should be done by the MSI +installer). + +Then install [esy](https://esy.sh/) via `npm`. + +```cmd +npm install -g esy@0.5.8 +``` + +OCaml (managed via `esy`) is used to build the oeedger8r tool as part of the OE SDK. + +Open up a command prompt and ensure that `esy` is added to the `PATH`. + +```cmd +C:\Users\test> where esy +C:\Users\test\AppData\Roaming\npm\esy +``` + +## Python 3 + +Install [Python 3 for Windows](https://www.python.org/downloads/windows/) and ensure that python.exe is available in your PATH. + +Python 3 is used as part of the mbedtls tests. diff --git a/docs/GettingStartedDocs/Contributors/WindowsManualSGX1FLCDCAPPrereqs.md b/docs/GettingStartedDocs/Contributors/WindowsManualSGX1FLCDCAPPrereqs.md new file mode 100644 index 0000000000..bdd902a3d2 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/WindowsManualSGX1FLCDCAPPrereqs.md @@ -0,0 +1,55 @@ +# SGX1 with Flexible Launch Control (FLC) Prerequisites on Windows + +## [Intel Platform Software for Windows (PSW) v2.5](http://registrationcenter-download.intel.com/akdlm/irc_nas/16115/Intel%20SGX%20PSW%20for%20Windows%20v2.5.101.3.exe) + +After unpacking the self-extracting ZIP executable, install the *PSW_EXE_RS2_and_before* version: +```cmd +C:\Intel SGX PSW for Windows v2.5.101.3\PSW_EXE_RS2_and_before\Intel(R)_SGX_Windows_x64_PSW_2.5.101.3.exe" +``` + +## [Azure DCAP client for Windows](https://github.com/Microsoft/Azure-DCAP-Client/tree/master/src/Windows) [optional] + +Note that this is optional since you can choose an alternate implementation of the DCAP client or create your own. +The Azure DCAP client for Windows is necessary if you would like to perform enclave attestation on a Azure Confidential Computing VM. It is available from [nuget.org](https://www.nuget.org/packages/Azure.DCAP.Windows/) and can be installed directly via command below. +This example assumes that `C:\oe_prereqs` is where you would like the prerequisites to be installed. + +```cmd +nuget.exe install Azure.DCAP.Windows -ExcludeVersion -Version 0.0.4 -OutputDirectory C:\oe_prereqs +``` +This example assumes you would like to install the package to `C:\oe_prereqs`. + +##### [Intel Data Center Attestation Primitives (DCAP) Libraries v1.3](http://registrationcenter-download.intel.com/akdlm/irc_nas/16114/Intel%20SGX%20DCAP%20for%20Windows%20v1.3.101.3.exe) +After unpacking the self-extracting ZIP executable, you can refer to the *Intel SGX DCAP Windows SW Installation Guide.pdf* +for more details on how to install the contents of the package. + +The following summary will assume that the contents were extracted to `C:\Intel SGX DCAP for Windows v1.3.101.3`: + +1. Unzip the required drivers from the extracted subfolders: + - `LC_driver\WinServer2016\Signed_*.zip` + - `DCAP_INF\WinServer2016\Signed_*.zip` + + The following instructions will assume that these have been unzipped into the `LC_driver` and `DCAP_INF` folders respectively. + +2. Allow the SGX Launch Configuration driver (LC_driver) to run: + - From an elevated command prompt: + ```cmd + reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sgx_lc_msr\Parameters /v "SGX_Launch_Config_Optin" /t REG_DWORD /d 1 + reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sgx_lc_msr\Parameters /v "SGX_Launch_Config_Optin" + ``` + - If the driver is already installed and running, the machine will need to be rebooted for the change to take effect. + +3. Install the drivers: + - `devcon.exe` from the [Windows Driver Kit for Windows 10](https://go.microsoft.com/fwlink/?linkid=2026156) + can be used to install the drivers from an elevated command prompt: + ```cmd + devcon.exe install LC_driver\drivers\b361e4d8-bc01-43fc-b8a6-8d101e659ed1\sgx_base_dev.inf root\SgxLCDevice + devcon.exe install DCAP_INF\drivers\226fdf07-49d3-46aa-a0ce-f21b6d4a05cf\sgx_dcap_dev.inf root\SgxLCDevice_DCAP + ``` + - Note that `devcon.exe` is usually installed to `C:\Program Files (x86)\Windows Kits\10\tools\x64` which is not in the PATH environment variable by default. +4. Install the DCAP nuget packages: + - The standalone `nuget.exe` [CLI tool](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) can be used to do this from the command prompt: + ```cmd + nuget.exe install DCAP_Components -ExcludeVersion -Source "C:\Intel SGX DCAP for Windows v1.3.101.3\nuget" -OutputDirectory c:\oe_prereqs + nuget.exe install EnclaveCommonAPI -ExcludeVersion -Source "C:\Intel SGX DCAP for Windows v1.3.101.3\nuget" -OutputDirectory c:\oe_prereqs + ``` + - *Note:* EnclaveCommonAPI should be installed as the *very last* nuget package as a temporary workaround for a dependency issue. Please see issue #2170, for more details. diff --git a/docs/GettingStartedDocs/Contributors/WindowsManualSGX1Prereqs.md b/docs/GettingStartedDocs/Contributors/WindowsManualSGX1Prereqs.md new file mode 100644 index 0000000000..f35f181b23 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/WindowsManualSGX1Prereqs.md @@ -0,0 +1,52 @@ +# SGX1 Prerequisites on Windows + +## Intel SGX Platform Software for Windows (PSW) v2.4 or above + +The latest PSW should be installed automatically on a Windows machine with Windows +version no lower than 1709. To check your Windows version, run `winver` on the +command line. + +Windows Server 2016 image for an Azure Confidential Compute VM has a Windows version +lower than 1709, and therefore you need to install PSW v2.4 or above manually. +You can download [PSW v2.5](http://registrationcenter-download.intel.com/akdlm/irc_nas/16115/Intel%20SGX%20PSW%20for%20Windows%20v2.5.101.3.exe), +extract the zipped files, and run the executable under folder **PSW_EXE_RS2_and_before** +to install PSW 2.5. + +You can verify that the correct version of Intel SGX PSW is installed by using +Windows Explorer to open `C:\Windows\System32`. You should be able to find +file `sgx_urts.dll` if PSW is installed. Right click on `sgx_urts.dll`, +choose `Properties` and then find `Product version` on the `Details` tab. +The version should be "2.5.xxx.xxx" or above. + +To verify that Intel SGX PSW is running, use the following command: + +```cmd +sc query aesmservice +``` + +The state of the service should be "running" (4). Follow Intel's documentation for +troubleshooting. In case the AESM service was stopped for some reasons, restart it +using the following command from Powershell. + +```powershell +Start-Service "AESMService" +``` + +## Intel Enclave Common API library + +The Intel Enclave Common API library is necessary for creating, initializing, and deleting enclaves. +It does not supporting quoting, and consequentially, attestation which is based on quoting. The lack +of quoting capability is a limitation of SGX1 machines which don't have FLC support. + +Firstly we download the Intel SGX DCAP self-extracting executable from [here](http://registrationcenter-download.intel.com/akdlm/irc_nas/16114/Intel%20SGX%20DCAP%20for%20Windows%20v1.3.101.3.exe). Run the executable to unzip files to a specified location. +The following summary will assume that the contents were extracted to `C:\Intel SGX DCAP for Windows v1.3.101.3`: + +Make sure you have [nuget cli tool](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) installed and in your path, +run the following command from a command prompt (assuming you would like the package to be installed to `C:\oe_prereqs`): +```cmd + +nuget.exe install EnclaveCommonAPI -ExcludeVersion -Source "C:\Intel SGX DCAP for Windows v1.3.101.3\nuget" -OutputDirectory C:\path\to\where\you\would\like\to\install\intel_nuget_packages + +``` + +You can verify that the library is installed properly by checking whether `sgx_enclave_common.lib` exists in the folder `C:\oe_prereqs`. diff --git a/docs/GettingStartedDocs/Contributors/WindowsSGX1FLCGettingStarted.md b/docs/GettingStartedDocs/Contributors/WindowsSGX1FLCGettingStarted.md new file mode 100644 index 0000000000..eb5c3c6394 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/WindowsSGX1FLCGettingStarted.md @@ -0,0 +1,153 @@ +# Getting Started with Open Enclave on Windows for systems with support for SGX1 with Flexible Launch Control(FLC) + +## Platform requirements + +Intel® X86-64bit architecture with SGX1 and Flexible Launch Control (FLC) support. (e.g. Intel Coffee Lake CPU) + +Note: To check if your system has support for SGX1 with FLC, please look [here](../SGXSupportLevel.md). + +A version of Windows OS with native support for SGX features: +- For server: Windows Server 2016 +- For client: Windows 10 64-bit version 1709 or newer +- To check your Windows version, run `winver` on the command line. + +## Install Git and Clone the Open Enclave SDK repo + +- Download and install Git for Windows from [here](https://git-scm.com/download/win). +- Clone the Open Enclave SDK to folder of your choice. In these instructions + we're assuming `openenclave`. + +```powershell +git clone https://github.com/openenclave/openenclave.git +``` + +This creates a source tree under the directory called `openenclave`. + +## Install project prerequisites + +First, change directory into the Open Enclave repository (from wherever you +cloned it): + +```powershell +cd openenclave +``` + +Run the following from PowerShell to deploy all the prerequisites for building Open Enclave: + +```powershell +./scripts/install-windows-prereqs.ps1 +``` + +To install the prerequisites along with the Azure DCAP Client, use the below +command. The Azure DCAP Client is necessary to perform attestation on an Azure +Confidential Computing VM. This command assumes that you would like the +prerequisites to be installed to `C:/oe_prereqs`. + +```powershell +./scripts/install-windows-prereqs.ps1 -InstallPath C:/oe_prereqs -LaunchConfiguration SGX1FLC -DCAPClientType Azure +``` + +If you would like to skip the installation of the Azure DCAP Client, use the +command below: + +```powershell +./scripts/install-windows-prereqs.ps1 -InstallPath C:/oe_prereqs -LaunchConfiguration SGX1FLC -DCAPClientType None +``` + +If you want to install the Azure DCAP Client, you would run the following +command: + +```powershell +./scripts/install-windows-prereqs.ps1 -InstallPath C:/oe_prereqs -LaunchConfiguration SGX1FLC -DCAPClientType Azure +``` + +If you prefer to manually install prerequisites, please refer to this +[document](WindowsManualInstallPrereqs.md). + +## Building on Windows using Developer Command Prompt + +Launch the [x64 Native Tools Command Prompt for VS(2017 or 2019)]( +https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs), +which is found in the `Visual Studio 2017` folder in the Start Menu. + +Run the command `powershell.exe` to open a PowerShell prompt within the native +tools environment. + +From here, use CMake and Ninja to build Open Enclave. + +To build debug enclaves: + +```powershell +cd openenclave +mkdir build/x64-Debug +cd build/x64-Debug +cmake -G Ninja -DNUGET_PACKAGE_PATH=C:/oe_prereqs -DCMAKE_INSTALL_PREFIX=install ../.. +ninja +``` + +Later, using the `ninja install` command will install the SDK in +`C:/openenclave/build/x64-Debug/install`. To choose a different location, change +the value specified for `CMAKE_INSTALL_PATH`, but note that the samples tests +will break if an absolute path is specified. + +Similarly, to build release enclaves, specify the flag +`-DCMAKE_BUILD_TYPE=Release`: + +```powershell +cd C:/openenclave +mkdir build/x64-Release +cd build/x64-Release +cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DNUGET_PACKAGE_PATH=C:/oe_prereqs -DCMAKE_INSTALL_PREFIX=install ../.. +ninja +``` + +## Run unit tests + +After building, run all unit test cases using `ctest` to confirm the SDK is built and working as expected. + +Run the following command from the build directory to run tests, (in this example, we are testing the debug build): + +```powershell +ctest +``` + +You will see test logs similar to the following: + +```powershell + Test project C:/Users/test/openenclave/build/x64-Debug + Start 1: tests/lockless_queue + 1/107 Test #1: tests/lockless_queue .................................. Passed 3.49 sec + Start 2: tests/mem + 2/107 Test #2: tests/mem ............................................. Passed 0.01 sec + ... + .... +100% tests passed, 0 tests failed out of 107 +``` + +A clean pass of the above unit tests run is an indication that your Open Enclave setup was successful. + +You can start playing with the Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, + +For more information refer to the [Advanced Test Info](AdvancedTestInfo.md) document. + +## Installing the SDK on the local machine + +To install the SDK on the local machine use the following: + +```powershell +cd openenclave/build/x64-Debug +cmake -DCMAKE_INSTALL_PREFIX=C:/openenclave ../.. +ninja install +``` + +This installs the SDK in `C:/openenclave`, the path specified for +`CMAKE_INSTALL_PREFIX`. This install path is assumed for the rest of the +instructions. + +## Build and run samples + +To build and run the samples, please look [here](/samples/README_Windows.md). + +## Known Issues + +Not all tests currently run on Windows. See `tests/CMakeLists.txt` for a list of supported tests. diff --git a/docs/GettingStartedDocs/Contributors/WindowsSGX1GettingStarted.md b/docs/GettingStartedDocs/Contributors/WindowsSGX1GettingStarted.md new file mode 100644 index 0000000000..8e533d3925 --- /dev/null +++ b/docs/GettingStartedDocs/Contributors/WindowsSGX1GettingStarted.md @@ -0,0 +1,133 @@ +# Getting Started with Open Enclave on Windows for systems with support for SGX1 + +## Platform requirements + +Intel® X86-64bit architecture with SGX1. + +Note: To check if your system has support for SGX1, please look [here](../SGXSupportLevel.md). + +A version of Windows OS with native support for SGX features: +- For server: Windows Server 2016 +- For client: Windows 10 64-bit version 1709 or newer + +## Install Git and Clone the Open Enclave SDK repo + +- Download and install Git for Windows from [here](https://git-scm.com/download/win). +- Clone the Open Enclave SDK to folder of your choice. In these instructions + we're assuming `openenclave`. + +```powershell +git clone https://github.com/openenclave/openenclave.git +``` + +This creates a source tree under the directory called `openenclave`. + +## Install project prerequisites + +First, change directory into the Open Enclave repository (from wherever you +cloned it): + +```powershell +cd openenclave +``` + +To deploy all the prerequisities for building Open Enclave, you can run the +following from PowerShell. Note that the Data Center Attestation Primitives +(DCAP) Client is not used for attestation on systems which have support for SGX1 +without support for Flexible Launch Control (FLC). The below example assumes you +would like to install the packages to `C:/oe_prereqs`. + +```powershell +./scripts/install-windows-prereqs.ps1 -InstallPath C:/oe_prereqs -LaunchConfiguration SGX1 -DCAPClientType None +``` + +If you prefer to manually install prerequisites, please refer to this +[document](WindowsManualInstallPrereqs.md). + +## Building on Windows using Developer Command Prompt + +Launch the [x64 Native Tools Command Prompt for VS(2017 or 2019)]( +https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs), +which is found in the `Visual Studio 2017` folder in the Start Menu. + +Run the command `powershell.exe` to open a PowerShell prompt within the native +tools environment. + +From here, use CMake and Ninja to build Open Enclave. + +To build debug enclaves: + +```powershell +cd openenclave +mkdir build/x64-Debug +cd build/x64-Debug +cmake -G Ninja -DHAS_QUOTE_PROVIDER=OFF -DNUGET_PACKAGE_PATH=C:/oe_prereqs -DCMAKE_INSTALL_PREFIX=install ../.. +ninja +``` + +Later, using the `ninja install` command will install the SDK in +`C:/openenclave/build/x64-Debug/install`. To choose a different location, change +the value specified for `CMAKE_INSTALL_PATH`, but note that the samples tests +will break if an absolute path is specified. + +Similarly, to build release enclaves, specify the flag +`-DCMAKE_BUILD_TYPE=Release`: + +```powershell +cd openenclave +mkdir build/x64-Release +cd build/x64-Release +cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DHAS_QUOTE_PROVIDER=OFF -DNUGET_PACKAGE_PATH=C:/oe_prereqs -DCMAKE_INSTALL_PREFIX=install ../.. +ninja +``` + +## Run unit tests + +After building, run all unit test cases using `ctest` to confirm the SDK is built and working as expected. + +Run the following command from the build directory to run tests, (in this example, we are testing the debug build): + +```powershell +ctest +``` + +You will see test logs similar to the following: + +```powershell + Test project C:/Users/test/openenclave/build/x64-Debug + Start 1: tests/lockless_queue + 1/107 Test #1: tests/lockless_queue .................................. Passed 3.49 sec + Start 2: tests/mem + 2/107 Test #2: tests/mem ............................................. Passed 0.01 sec + ... + .... +100% tests passed, 0 tests failed out of 107 +``` + +A clean pass of the above unit tests is an indication that your Open Enclave setup was successful. + +You can start playing with the Open Enclave samples after following the instructions in the "Install" section below to configure samples for building, + +For more information refer to the [Advanced Test Info](AdvancedTestInfo.md) document. + +## Installing the SDK on the local machine + +To install the debug SDK on the local machine use the following: + +```powershell +cd openenclave/build/x64-Debug +cmake -DCMAKE_INSTALL_PREFIX=C:/openenclave ../.. +ninja install +``` + +This installs the SDK in `C:/openenclave`, the path specified for +`CMAKE_INSTALL_PREFIX`. This install path is assumed for the rest of the +instructions. + +## Build and run samples + +To build and run the samples, please look [here](/samples/README_Windows.md). + +## Known Issues + +Not all tests currently run on Windows. See `tests/CMakeLists.txt` for a list of supported tests. diff --git a/docs/GettingStartedDocs/Contributors/building_oe_sdk.md b/docs/GettingStartedDocs/Contributors/building_oe_sdk.md index ecbe134884..6f5ac3ca0a 100644 --- a/docs/GettingStartedDocs/Contributors/building_oe_sdk.md +++ b/docs/GettingStartedDocs/Contributors/building_oe_sdk.md @@ -1,7 +1,5 @@ # Building the Open Enclave SDK -This document contains the Linux build instructions. For the experimental Windows build instructions, see [here](/docs/GettingStartedDocs/GettingStarted.Windows.md). - #### 1. Determine the SGX support level on your development/target system The Open Enclave SDK runs on Linux systems, whether those systems are inside virtual machines or directly on top of the bare metal machines. @@ -21,7 +19,7 @@ Please refer to the following [documentation](/docs/GettingStartedDocs/SGXSuppor - `SGX1+FLC`: In this mode, the Open Enclave SDK takes advantage of the Flexible Launch Control mode for better managing architectural enclaves. - - `Simulator`: Open Enclave comes with a SGX software simulator that simulates a subset of + - `Simulation`: Open Enclave comes with an SGX software simulation mode that simulates a subset of the SGX feature set. This simulator enables the Open Enclave SDK to run on systems without actual SGX hardware support. @@ -31,27 +29,31 @@ Please refer to the following [documentation](/docs/GettingStartedDocs/SGXSuppor |:---------------------------|:-----------------------------------:| | SGX1+FLC | SGX1+FLC | | SGX1 | SGX1 or SGX1+FLC | - | Simulator | Any level | + | Simulation | Any level | + + On Linux, if your target system does not have any SGX hardware support, you may want to choose simulation. - On Linux, if your target system does not have any SGX hardware support, you may want to choose "Simulator" mode. - On Windows, Open Enclave SDK does not support "Simulator" mode. + On Windows, Open Enclave SDK does not support simulation mode. #### 3. Build, install and run Choose an operating mode that is compatible with the SGX support level of your target system. The links below contain instructions on how to set up Open Enclave SDK environment for a given mode. -On Linux - - [Setup Open Enclave SDK for SGX1+FLC mode](SGX1FLCGettingStarted.md) - - [Setup Open Enclave SDK for SGX1 mode](SGX1GettingStarted.md) - - [Setup Open Enclave SDK for Simulator mode](SimulatorGettingStarted.md) +On Linux: + - [Setup Open Enclave SDK for SGX1+FLC](SGX1FLCGettingStarted.md) + - [Setup Open Enclave SDK for SGX1](SGX1GettingStarted.md) + - [Setup Open Enclave SDK for simulation mode](SimulatorGettingStarted.md) -On Windows - - [Set up Open Enclave SDK](/docs/GettingStartedDocs/GettingStarted.Windows.md) +On Windows: + - [Set up Open Enclave SDK for SGX1+FLC](WindowsSGX1FLCGettingStarted.md) + - [Set up Open Enclave SDK for SGX1](WindowsSGX1GettingStarted.md) + - Simulation mode is not supported on Windows ## Samples -Assuming you install the SDK as below (also described in the [basic install section](InstallInfo.md#basic-install)) +### On Linux +Assuming you install the SDK as below (also described in the [basic install section](LinuxInstallInfo.md#basic-install-on-linux)) ```bash cmake -DCMAKE_INSTALL_PREFIX=~/openenclave .. @@ -60,9 +62,20 @@ make install Open Enclave samples can be found in ~/openenclave/share/openenclave/samples -See [Open Enclave samples](/samples/README.md) for details. +See [Open Enclave samples](/samples/README_Linux.md) for details. + +### On Windows + +Assuming you install the SDK as below (also described in the [basic install section](WindowsInstallInfo.md#basic-install-on-windows)) + +```bash +cmake .. -G Ninja -DNUGET_PACKAGE_PATH=C:\oe_prereqs -DCMAKE_INSTALL_PREFIX:PATH=C:\openenclave" +ninja install +``` +Open Enclave samples can be found in c:\openenclave\share\openenclave\samples + +See [Open Enclave samples](/samples/README_Windows.md) for details. ## Using the Open Enclave SDK -Additional information such as the [API References](/docs/GettingStartedDocs/using_oe_sdk.md#api-references) -can be found in the [documentation on using the Open Enclave SDK](/docs/GettingStartedDocs/using_oe_sdk.md). +Additional information such as the API Reference and supported libs can be found [here](/docs/GettingStartedDocs/APIs_and_Libs.md). diff --git a/docs/GettingStartedDocs/Debugging.md b/docs/GettingStartedDocs/Debugging.md index 237a1257d8..6f72db9265 100644 --- a/docs/GettingStartedDocs/Debugging.md +++ b/docs/GettingStartedDocs/Debugging.md @@ -1,5 +1,9 @@ # Open Enclave Debugging +For debugging enclaves on Windows using Visual Studio Code see [Windows_vscode.md](./Windows_vscode.md). + +For debugging enclaves on Windows using WinDbg Preview see [Windows_windbg.md](./Windows_windbg.md). + While you can use GDB to debug the host of the enclave app like any other normal process, you won’t be able to debug into the enclave’s execution state or memory. To enable that, you will need to launch the debugger with the **oegdb** plug-in. diff --git a/docs/GettingStartedDocs/DependencyGraph.svg b/docs/GettingStartedDocs/DependencyGraph.svg index cd56be12c3..43944a5ff5 100644 --- a/docs/GettingStartedDocs/DependencyGraph.svg +++ b/docs/GettingStartedDocs/DependencyGraph.svg @@ -4,334 +4,430 @@ - - + + GG - - + + -node1538 - -mbedcrypto +node102 + +logging - + -node1537 - -mbedtls +node21 + +oehost - + -node1538->node1537 - - +node102->node21 + + - + -node1534 - -mbedx509 +node2166 + +crypto - + -node1537->node1534 - - +node21->node2166 + + - + -node1536 - -mbedcrypto_static +node2167 + +dl - + -node1534->node1536 - - +node21->node2167 + + - + -node26 - -oe_includes +node29 + +oe_includes - + -node1536->node26 - - +node21->node29 + + - + -node1547 - -oelibc +node2136 + +oedebugrt - + -node1536->node1547 - - +node21->node2136 + + - + -node1464 - -oecore +node2007 + +mbedcrypto - - -node1547->node1464 - - - - + -node1548 - -oelibasm +node2006 + +mbedtls - - -node1547->node1548 - - + + +node2007->node2006 + + - + -node1521 - -oelibc_includes - - - -node1547->node1521 - - +node2003 + +mbedx509 - + -node1464->node26 - - +node2006->node2003 + + - + -node1586 - -oe_ptrace +node2005 + +mbedcrypto_static - - -node1586->node26 - - + + +node2003->node2005 + + + + + +node2005->node29 + + - + -node1630 - -dl +node2016 + +oelibc - + -node1586->node1630 - - +node2005->node2016 + + - + -node1471 - -oecryptombed +node1933 + +oecore - - -node1471->node1538 - - + + +node2016->node1933 + + - + -node1452 - -oeenclave +node2017 + +oelibasm - + -node1452->node1471 - - +node2016->node2017 + + - + -node13 - -oehost +node1990 + +oelibc_includes - - -node13->node26 - - + + +node2016->node1990 + + + + + +node2035 + +oesyscall - + -node13->node1630 - - +node2016->node2035 + + - - -node1629 - -crypto + + +node1933->node29 + + - - -node13->node1629 - - + + +node2035->node1933 + + - + -node1632 - -sgx_dcap_ql +node2104 + +oe_ptrace - + -node13->node1632 - - +node2104->node2167 + + - + + +node2104->node29 + + + + -node1631 - -sgx_enclave_common +node139 + +oecert - - -node13->node1631 - - + + +node139->node21 + + - + -node1633 - -sgx_urts +node1102 + +oecpio - - -node13->node1633 - - + + +node1102->node2016 + + - + + +node1102->node1933 + + + + -node18 - -oehostapp +node1940 + +oecryptombed - - -node18->node13 - - + + +node1940->node2007 + + - + -node1557 - -oelibcxx +node1919 + +oeenclave + + + +node1919->node1940 + + - + -node1494 - -libcxx +node23 + +oehostapp - - -node1557->node1494 - - + + +node23->node21 + + - + -node1501 - -libcxxrt +node2086 + +oehostepoll - - -node1557->node1501 - - - - - -node1511 - -libunwind - - + -node1557->node1511 - - +node2086->node2035 + + - - -node1494->node1547 - - - - - -node1501->node1547 - - + + +node2056 + +oehostfs - + -node1511->node1547 - - +node2056->node2035 + + - + -node1566 - -oesyscall +node2066 + +oehostresolver - + -node1566->node1464 - - +node2066->node2035 + + - + -node1432 - -oesgx - - - -node1442 - -oesign +node2076 + +oehostsock - + -node1442->node13 - - +node2076->node2035 + + + + + +node22 + +oehostverify + + + +node22->node2166 + + + + + +node22->node2167 + + + + + +node22->node29 + + + + + +node2026 + +oelibcxx + + + +node1963 + +libcxx + + + +node2026->node1963 + + + + + +node1970 + +libcxxrt + + + +node2026->node1970 + + + + + +node1980 + +libunwind + + + +node2026->node1980 + + + + + +node1963->node2016 + + + + + +node1970->node2016 + + + + + +node1980->node2016 + + + + + +node1899 + +oesgx + + + +node1909 + +oesign + + + +node1909->node21 + + diff --git a/docs/GettingStartedDocs/GettingStarted.Windows.md b/docs/GettingStartedDocs/GettingStarted.Windows.md deleted file mode 100644 index a72198c90a..0000000000 --- a/docs/GettingStartedDocs/GettingStarted.Windows.md +++ /dev/null @@ -1,315 +0,0 @@ -Getting Started on Windows [Work in progress] -========================================= - -Introduction ------------- - -This document is a work in progress. It describes how to use experimental -support in the Open Enclave SDK to build Windows host applications that can -load ELF enclaves built using clang. - -Please refer to the following [documentation](/docs/GettingStartedDocs/SGXSupportLevel.md) to determine the SGX support level for your target system. The instructions below work for systems with SGX1+FLC support. Instructions for systems with SGX1 but no FLC support are coming soon. - -'Simulator' mode is not available in Windows. - -Prerequisites -------------- - -The following are prerequisites for building and running Open Enclave on -Windows. - -- Intel® X86-64bit architecture with SGX1 or SGX2 -- A version of Windows OS with native support for SGX features: - - For server: Windows Server 2016 (or newer) - - For client: Windows 10 64-bit with Fall Creators Update (1709) or newer -- [Intel® SGX Platform Software for Windows (PSW)]( - https://software.intel.com/sites/default/files/managed/0f/c8/Intel-SGX-PSW-Release-Notes-for-Windows-OS.pdf) -- [Microsoft Visual Studio 2017](https://visualstudio.microsoft.com/vs/older-downloads/) -- [Git for Windows 64-bit](https://git-scm.com/download/win) -- [OCaml for Windows 64-bit](https://www.ocamlpro.com/pub/ocpwin/ocpwin-builds/ocpwin64/20160113/) -- [Clang/LLVM for Windows 64-bit](http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe) - -To deploy all the prerequisities for building Open Enclave, you can run the ```scripts/install-windows-prereqs.ps1``` - -```powershell -cd scripts -.\install-windows-prereqs.ps1 -InstallPath YOUR_WORKSPACE_PATH_HERE -LaunchConfiguration SGX1FLC -DCAPClientType Azure -``` - -To deploy each prerequisite individually, refer to the sections below. - -Intel® SGX Platform Software for Windows (PSW) ---------------------------------- - -The PSW should be installed automatically on Windows 10 with the Fall Creators -Update installed, or on a Windows Server 2016 image for an Azure Confidential -Compute VM. You can verify that is the case on the command line as follows: - -```cmd -sc query aesmservice -``` - -The state of the service should be "running" (4). Follow Intel's documentation for troubleshooting. - -Note that Open Enclave is only compatible with the Intel PSW 2.2. -To use Intel PSW 2.3 and higher, please refer _Building with Intel Data Center Attestation -Primitives (DCAP) libraries_ below. - -Microsoft Visual Studio 2017 ---------------------------------- -Install [Microsoft Visual Studio 2017](https://visualstudio.microsoft.com/vs/older-downloads/). -Visual Studio 2017's CMake support (ver 3.12 or above) is required for building the Open Enclave SDK. -Note cmake in Visual Studio 2019 is not fully supported yet. -For more information about cmake support, refer to -https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/ - -Git for Windows 64-bit ---------------------------------- -Install Git and add Git's bash to the path. -Typically, Git's bash is located in C:\Program Files\Git\bin. -Currently the Open Enclave SDK build system uses bash scripts to configure -and build Linux-based 3rd-party libraries. - -Open a command prompt and ensure that bash is available in the path: -```cmd -C:\>where bash -C:\Program Files\Git\bin\bash.exe -``` - -Tools available in the Git bash environment are also used for test and sample -builds. For example, OpenSSL is used to generate test certificates, so it is -also useful to have the `Git\mingw64\bin` folder pathed. This can be checked -from the command prompt as well: - -```cmd -C:\>where openssl -C:\Program Files\Git\mingw64\bin\openssl.exe -``` - -Clang ---------------------------------- -Install Clang 7.0.1 and add the LLVM folder (typically C:\Program Files\LLVM\bin) -to the path. Open Enclave SDK uses clang to build the enclave binaries. - -Open up a command prompt and ensure that clang is available in the path: -```cmd -C:\> where clang -C:\Program Files\LLVM\bin\clang.exe -C:\> where llvm-ar -C:\Program Files\LLVM\bin\llvm-ar.exe -C:\> where ld.lld -C:\Program Files\LLVM\bin\ld.lld.exe -``` - -OCaml ---------------------------------- -Install [OCaml for Windows (64-bit)](https://www.ocamlpro.com/pub/ocpwin/ocpwin-builds/ocpwin64/20160113/). -Please download and install the mingw64 exe for OCaml, for example, https://www.ocamlpro.com/pub/ocpwin/ocpwin-builds/ocpwin64/20160113/ocpwin64-20160113-4.02.1+ocp1-mingw64.exe. - -[Alternate OCaml Web-site](https://fdopen.github.io/opam-repository-mingw/installation/) - -OCaml is used to build the oeedger8r tool as part of the OE SDK. - -Open up a command prompt and ensure that ocaml is available in the path: -```cmd -C:\> where ocaml -C:\Program Files\ocpwin64\4.02.1+ocp1-msvc64-20160113\bin\ocaml.exe -``` - -Obtaining the source distribution ---------------------------------- - -Open Enclave is available from GitHub. - -### In Visual Studio 2017: -1. Under Team > Manage Connections... > Local Git Repositories, select the Clone - dropdown -2. Set the URL to clone as: https://github.com/openenclave/openenclave. -3. Set the local path you want to clone the repo to (e.g. C:/openenclave). -4. Click the Clone button. - -### In Git shell: -``` -git clone https://github.com/openenclave/openenclave -``` - -This creates a source tree under the directory called openenclave. - -Building --------- - -### Building on Windows using Visual Studio 2017 -[Visual Studio 2017 has integrated support for loading CMake projects]( -https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/): - -1. Under the File menu, select Open > CMake... -2. Open the CMakeLists.txt at the root of your Open Enclave repo - (e.g. C:\openenclave\CMakeLists.txt) -3. The CMake menu option should appear when it detects that a valid CMake project - is loaded. VS2017 will then recursively walk the repo directory structure and - generate a cache for the project to display Intellisense. This may take several minutes the first time. -4. Open Enclave is only supported for 64-bit. By default the `x64-Debug` configuration is - selected. -5. Once cache generation is complete, you can build the project via the CMake > - Build All menu option. - -The results of the build will be displayed in the Output window and any build -errors or warnings collated in the Error List window. - -You can change the build settings with the CMake > Change CMake Settings menu -option. This opens the [CMakeSettings.json](https://blogs.msdn.microsoft.com/vcblog/2017/08/14/cmake-support-in-visual-studio-customizing-your-environment/) -file which you can edit and change settings such as the target build location. - -By default, Open Enclave SDK will be built in the following location: -``` -${workspaceRoot}\build\ -``` -For example: -``` -C:\openenclave\build\x64-Debug -``` -### Building on Windows using Developer Command Prompt - -1. Launch the [x64 Native Tools Command Prompt for VS 2017]( -https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs) -Normally this is accessible under the `Visual Studio 2017` folder in the Start Menu. - -2. At the x64 Native Tools command prompt, use cmake and ninja to build the debug version: - - ```cmd - cd C:\openenclave - mkdir build\x64-Debug - cd build\x64-Debug - cmake -G Ninja -DBUILD_ENCLAVES=1 ../.. - ninja - ``` - - Similarly, build the release version with: - ```cmd - cd C:\openenclave - mkdir build\x64-Release - cd build\x64-Release - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_ENCLAVES=1 ../.. - ninja - ``` - -### Building with Intel Data Center Attestation Primitives (DCAP) [Experimental] - -#### Installing additional dependencies for DCAP -To use the Intel DCAP libraries for upcoming support for SGX attestation on Windows Server 2016, -you will need to install the following dependencies: - -##### [Intel Platform Software for Windows (PSW) v2.4](http://registrationcenter-download.intel.com/akdlm/irc_nas/15654/Intel%20SGX%20PSW%20for%20Windows%20v2.4.100.51291.exe) - -After unpacking the self-extracting ZIP executable, install the *PSW_EXE_RS2_and_before* version for Windows Server 2016: -```cmd -C:\Intel SGX PSW for Windows v2.3.100.49777\PSW_EXE_RS2_and_before\Intel(R)_SGX_Windows_x64_PSW_2.3.100.49777.exe -``` - -##### [Azure DCAP client for Windows](https://github.com/Microsoft/Azure-DCAP-Client/tree/master/src/Windows) [optional] - -The Azure DCAP client for Windows is necessary if you would like to perform enclave attestation on a Azure Confidential Computing VM. -It is available from [nuget.org](https://www.nuget.org/packages/Azure.DCAP.Windows/) and can be installed directly via: - -```cmd -nuget.exe install Azure.DCAP.Windows -ExcludeVersion -Version 0.0.2 -OutputDirectory C:\openenclave\prereqs\nuget -``` - -##### [Intel Data Center Attestation Primitives (DCAP) Libraries v1.2](http://registrationcenter-download.intel.com/akdlm/irc_nas/15650/Intel%20SGX%20DCAP%20for%20Windows%20v1.2.100.49925.exe) -After unpacking the self-extracting ZIP executable, you can refer to the *Intel SGX DCAP Windows SW Installation Guide.pdf* -for more details on how to install the contents of the package. - -The following summary will assume that the contents were extracted to `C:\Intel SGX DCAP for Windows v1.2.100.49925`: - -1. Unzip the required drivers from the extracted subfolders: - - `LC_driver_WinServer2016\Signed_1152921504628095185.zip` - - `DCAP_INF\WinServer2016\Signed_1152921504628099289.zip` - - The following instructions will assume that these have been unzipped into the `LC_driver` and `DCAP_INF` folders respectively. - -2. Allow the SGX Launch Configuration driver (LC_driver) to run: - - From an elevated command prompt: - ```cmd - reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sgx_lc_msr\Parameters /v "SGX_Launch_Config_Optin" /t REG_DWORD /d 1 - reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sgx_lc_msr\Parameters /v "SGX_Launch_Config_Optin" - ``` - - If the driver is already installed and running, the machine will need to be rebooted for the change to take effect. - -3. Install the drivers: - - `devcon.exe` from the [Windows Driver Kit for Windows 10](https://go.microsoft.com/fwlink/?linkid=2026156) - can be used to install the drivers from an elevated command prompt: - ```cmd - devcon.exe install LC_driver\drivers\b361e4d8-bc01-43fc-b8a6-8d101e659ed1\sgx_base_dev.inf root\SgxLCDevice - devcon.exe install DCAP_INF\drivers\226fdf07-49d3-46aa-a0ce-f21b6d4a05cf\sgx_dcap_dev.inf root\SgxLCDevice_DCAP - ``` - - Note that `devcon.exe` is usually installed to `C:\Program Files (x86)\Windows Kits\10\tools\x64` and is *not* pathed by default. - -4. Install the DCAP nuget packages: - - The standalone `nuget.exe` [CLI tool](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) can be used to do this from the command prompt: - ```cmd - nuget.exe install DCAP_Components -ExcludeVersion -Source "C:\Intel SGX DCAP for Windows v1.2.100.49925\nuget" -OutputDirectory C\openenclave\prereqs\nuget - nuget.exe install EnclaveCommonAPI -ExcludeVersion -Source "C:\Intel SGX DCAP for Windows v1.2.100.49925\nuget" -OutputDirectory C:\openenclave\prereqs\nuget - ``` - - *Note:* EnclaveCommonAPI should be installed as the *very last* nuget package as a temporary workaround for a dependency issue. - -#### Building with DCAP libraries using Visual Studio 2017 -To build with the DCAP libraries in Visual Studio, you will need to add the -`-DUSE_LIBSGX=1` to `cmakeCommandArgs` in the CMakeSettings.json file for each of the -configurations you want to build with it. - -For example, to enable it for x64-Debug, do this in your json file: - -```json - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${workspaceRoot}\\build\\x64-Debug", - "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", - "cmakeCommandArgs": "-DBUILD_ENCLAVES=1 -DUSE_LIBSGX=1", - "buildCommandArgs": "-v", - "ctestCommandArgs": "" - }, -``` - -The CMake > Build All menu option will work as usual once this is configured. - -#### Building with DCAP libraries using Developer Command Prompt - -To build with the DCAP libraries in the x64 Native Tools Command Prompt for VS 2017, -just add the `-DUSE_LIBSGX=1` option to the `cmake` call before starting the `ninja` -build. For example, for the x64-Debug configuration: - -```cmd -cd C:\openenclave -mkdir build\x64-Debug -cd build\x64-Debug -cmake -G Ninja -DBUILD_ENCLAVES=1 -DUSE_LIBSGX=1 ../.. -ninja -``` - -Testing -------- - -Note that the use of Simulation Mode via the `OE_SIMULATION` flag is _not_ supported on Windows. -See [#1753](https://github.com/openenclave/openenclave/issues/1753) for details. - -### Running tests in Visual Studio 2017 - -1. Open the CMake project in Visual Studio from menu File > Open > CMake... - and select top level CMakeLists.txt file which is present in openenclave folder. -2. Select menu CMake > Tests > Run Open Enclave SDK CTests. - -### Running tests on the Developer Command Prompt -On the x64 Native Tools Command Prompt for VS 2017: - -```cmd -ctest -``` - -Known Issues ------------- -* Samples have not yet been ported to Windows -* Not all tests currently run on Windows. See tests/CMakeLists.txt for a list of supported tests. diff --git a/docs/GettingStartedDocs/using_oe_sdk.md b/docs/GettingStartedDocs/Linux_using_oe_sdk.md similarity index 66% rename from docs/GettingStartedDocs/using_oe_sdk.md rename to docs/GettingStartedDocs/Linux_using_oe_sdk.md index bdff08ee7c..e2db5c8c5b 100644 --- a/docs/GettingStartedDocs/using_oe_sdk.md +++ b/docs/GettingStartedDocs/Linux_using_oe_sdk.md @@ -1,11 +1,13 @@ -# Using the Open Enclave SDK +# Using the Open Enclave SDK on Linux This document provides a brief overview of how to start exploring the Open Enclave SDK once you have it installed. ## Open Enclave SDK Layout -By default, the Open Enclave SDK is installed to `/opt/openenclave`. It contains the following subfolders: +On Linux, by default, the Open Enclave SDK is installed to `/opt/openenclave`. + +It contains the following subfolders: | Path | Description | |------------------------------|---------------------------------| @@ -17,10 +19,11 @@ By default, the Open Enclave SDK is installed to `/opt/openenclave`. It contains | lib/openenclave/host | Library for linking into the host process of the enclave. | | lib/openenclave/debugger | Libraries used by the gdb plug-in for debugging enclaves. | | share/openenclave/samples | Sample code showing how to use the Open Enclave SDK. | -| share/pkgconfig | Pkg-config files for header and library includes when building Open Enclave apps. | -## Configure environment variables for Open Enclave SDK +On Linux, the Open Enclave SDK installation also contains the following folder: +| share/pkgconfig | Pkg-config files for header and library includes when building Open Enclave apps. | +## Configure environment variables for Open Enclave SDK for Linux For ease of development, we recommend adding: - Open Enclave SDK `bin` folder to `PATH`, for use of our tools (such as `oegdb` and `oeedger8r`). - Open Enclave SDK `install` folder to `CMAKE_PREFIX_PATH`, for use of the [CMake package](/cmake/sdk_cmake_targets_readme.md). @@ -37,32 +40,12 @@ source /opt/openenclave/share/openenclave/openenclaverc One way to determine if your machine is correctly configured to build and run Open Enclave apps is to execute the samples. A description of all the included samples, what each one illustrates, and how to build and run them can be found in -[share/openenclave/samples/README.md](/samples/README.md). +[share/openenclave/samples/README.md](/samples/README_Linux.md). Additional documentation is also available for: - [Building and signing enclaves](/docs/GettingStartedDocs/buildandsign.md) - [Debugging enclave memory](/docs/GettingStartedDocs/Debugging.md) -## API references - -One of the security principles of writing enclave applications is to minimize the -Trusted Computing Base (TCB) of the enclave code. A consequence of this is that -while the host application has full access to the range of libraries and API -available to all normal mode applications, the enclave is restricted to a much -more constrained set as described below: - -#### [Open Enclave API](https://openenclave.github.io/openenclave/api/index.html) - -The Doxygen documentation of the API exposed by Open Enclave SDK to both enclave and host. - -#### [Libc support](/docs/LibcSupport.md) - -The subset of libc functionality provided by oelibc for use inside an enclave. - -#### [Libcxx support](/docs/LibcxxSupport.md) - -The subset of libcxx functionality provided by oelibcxx for use inside an enclave. - -#### [mbedtls library](/docs/MbedtlsSupport.md) +## APIs and supported libraries -The subset of [mbedtls](https://tls.mbed.org/) functionality for use inside an enclave. +Please look [here](/docs/GettingStartedDocs/APIs_and_Libs.md). diff --git a/docs/GettingStartedDocs/Linux_vscode.md b/docs/GettingStartedDocs/Linux_vscode.md new file mode 100644 index 0000000000..b7462be434 --- /dev/null +++ b/docs/GettingStartedDocs/Linux_vscode.md @@ -0,0 +1,118 @@ +# Building And Debugging Using Visual Studio Code for Linux Development + +This document provides a brief overview of how to build and debug Open Enclave applications using VS Code on Linux. + +## Install VS Code + +The latest version of Visual Studio Code can be installed from [https://code.visualstudio.com/](https://code.visualstudio.com/) + +## Install VS Code Extensions + +Install the following VS Code extensions. Click on an image to navigate to the Visual Studio Code Marketplace page for the extension. + +[![C/C++ Extension](images/VSCodeCppExtension.png)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) + +[![CMake Extension](images/VSCodeLinuxCMakeExtension.png)](https://marketplace.visualstudio.com/items?itemName=twxs.cmake) + +[![CMake Tools Extension](images/VSCodeCMakeToolsExtension.png)](https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools) + +## Launch Visual Studio Code + +Launch VS Code either directly on your Linux system, or use the Remote SSH extension to connect your local VS Code instance to another system. + +## Configure Your Workspace + +1. Ensure all of your dependencies for building an Open Enclave SDK application are installed on your Linux system. You can achieve that by following these instructions: [https://github.com/openenclave/openenclave#getting-started](https://github.com/openenclave/openenclave#getting-started) + +2. As an example, on your Linux system, copy one of the samples to your local directory. We will choose the helloworld sample for simplicity. + +```bash +cp -R /opt/openenclave/share/openenclave/samples/helloworld ~/my_helloworld +``` + +3. In VS Code, select `File->Open Folder...` and specify the location that you copied the helloworld sample to. In this case, that would be `~/my_helloworld` + +4. Create a typical VSCode project Settings.json file in this path for your project: .vscode/Settings.json. Make sure the `-DOpenEnclave_Dir` option is set to /opt/openenclave/lib/openenclave/cmake under the "cmake.configureArgs" field, like below: + +```json +{ + "cmake.configureArgs": [ + "-DOpenEnclave_DIR=/opt/openenclave/lib/openenclave/cmake" + ] +} +``` + +5. Use the shortcut `Ctrl-Shift-P` and select `CMake: Configure` and choose the kit from the drop down to use, for example, the Clang-7 kit. + +![Successful CMake Configure](images/VSCodeLinuxSuccessfulCMakeConfigure.png) + +## Building and Running an Open Enclave Application + +Build the application by pressing F7 or typing "CMake Build a target" in the command palette, and selecting the "all META" target. + +![Successful Build](images/VSCodeLinuxSuccessfulBuild.png) + +Run the application by pressing Shift+F7 or typing "CMake Build a target" in the command palette, and selecting the "run UTILITY" target. + +![Run](images/VSCodeLinuxRunApplication.png) + +## Configuring Intellisense + +Intellisense should work out of the box for files within your workspace. However, Intellisense may not be aware of where to locate the Open Enclave SDK headers. +Open settings.json under the .vscode folder and add entries for "C_Cpp.default.includePath" and "C_Cpp.default.systemIncludePath". + +```json +{ + "C_Cpp.default.includePath": ["/opt/openenclave/include"], + "C_Cpp.default.systemIncludePath": [ + "/opt/openenclave/include/openenclave/3rdparty/libc", + "/opt/openenclave/include/openenclave/3rdparty/libcxx" + ] +} +``` + +## Debugging an Open Enclave Application + +To configure VS Code for debugging an enclave app with GDB, go to the Debug tab in the side bar and select the settings cog to open this project's launch.json. Add the `miDebuggerPath` property to indicate where the `oegdb` script is installed. By default, this should be `/opt/openenclave/bin/oegdb`. The `program` and `args` properties should also be set to the location of the sample to debug, for example: + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(oegdb) Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/host/helloworld_host", + "args": ["${workspaceFolder}/build/enclave/enclave.signed"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/opt/openenclave/bin/oegdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} +``` + +Open host.c and add a breakpoint. Start debugging. + +![Host Breakpoint](images/VSCodeLinuxHostBreakpoint.png) + +Step over the line that creates the enclave. The Console pane should show that the enclave has been loaded. + +![Stop After Enclave Creation](images/VSCodeLinuxStopAfterEnclaveCreation.png) + +Open enc.c and put a breakpoint and continue execution. + +![Enclave Breakpoint](images/VSCodeLinuxEnclaveBreakpoint.png) + +To use `oegdb` at the command line, one can select the "Debug Console" tab near the terminal pane. Then the standard gdb commands can be used, as long as they are prefixed with `-exec` first, like `-exec bt`. Please read documentation for `gdb` for further information on how to use `oegdb`: [https://sourceware.org/gdb/current/onlinedocs/gdb/](https://sourceware.org/gdb/current/onlinedocs/gdb/) diff --git a/docs/GettingStartedDocs/OP-TEE/Debugging/QEMU.md b/docs/GettingStartedDocs/OP-TEE/Debugging/QEMU.md new file mode 100644 index 0000000000..bdadc7cf19 --- /dev/null +++ b/docs/GettingStartedDocs/OP-TEE/Debugging/QEMU.md @@ -0,0 +1,420 @@ +# Debugging Enclaves on OP-TEE OS with QEMU + +[QEMU](https://www.qemu.org/) is a system emulator that can run ARM TrustZone +enclaves on an x86/64 machine as though they were running on TrustZone-capable +hardware. QEMU provides an emulated environment whose behavior matches real ARM +TrustZone-capable hardware without requiring any: secure memory access +violations, alignment errors, and the like, can be caught using QEMU. + +In this guide, you will learn how to retrieve and build a QEMU environment for +debugging enclaves on ARM TrustZone. Then, you will see how to build the Open +Enclave SDK samples and run them in the emulated environment. Lastly, you will +learn how to set up and use GDB for source-level debugging of the sample +enclaves that ship with this SDK. + +This guide is loosely based on [OP-TEE's own Build and Debug +Guide](https://optee.readthedocs.io/en/latest/building/index.html) with some +modifications to render it more pertinent to this SDK. + +## Prerequisites + +This guide presumes you have a Ubuntu 18.04 LTS environment available. You may +install Ubuntu on bare metal or in a virtual machine using your preferred +hypervisor. Some commands launch GUIs, so a graphical environment is necessary. + +**Note:** To use this guide with the Windows Subsystem for Linux (WSL), read +through [Debugging Enclaves on OP-TEE OS with QEMU on WSL](QEMUOnWSL.md) +first. + +## Required Packages + +The following command installs all the packages necessary on Ubuntu 18.04 LTS: + +```bash +sudo apt update && sudo apt install -y android-tools-adb \ + android-tools-fastboot autoconf automake bc bison build-essential ccache \ + cgdb cscope curl device-tree-compiler expect flex ftp-upload gdb-multiarch \ + gdisk iasl libattr1-dev libc6 libcap-dev libfdt-dev libftdi-dev \ + libglib2.0-dev libhidapi-dev libncurses5-dev libpixman-1-dev libssl-dev \ + libstdc++6 libtool libz1 make mtools netcat python-crypto \ + python-pyelftools python-serial python-wand python3-pyelftools repo unzip \ + uuid-dev xdg-utils xterm xz-utils zlib1g-dev +``` + +## Directory Structure + +The instructions in this guide assume that: + +* You have three terminals open; +* The current working directory on all three is your home directory to start + with. + +The terminals are referred to as `TERM 1`, `TERM 2` and `TERM 3`, respectively. +At the top of each command, the terminal to run them in is listed, unless +otherwise specified. + +All work will be done in: + +```bash +# [ TERMS 1 & 2 & 3 ] + +# Once +mkdir openenclave_qemu + +# All terms +cd openenclave_qemu +``` + +This is so that you may be able to easily run the commands listed here, +especially the ones that must be run inside the emulator. + +# Getting Started + +The runtime environment inside a QEMU virtual machine has the same software +requirements as real hardware. As such, firmware and a filesystem from which to +boot must be generated. This section shows you how to retrieve all the software +components required, how to build them, and how to run them in QEMU. + +## Sources + +The `repo` utility can manipulate multiple Git repositories as though they were +one. The following commands instruct `repo` to clone all the repositories that +are required to build a QEMU-based debugging environment: + +```bash +# [ TERM 1 ] + +mkdir emulation +cd emulation + +repo init -u https://github.com/ms-iot/optee_manifest -m oe_qemu_v8.xml -b oe-3.6.0 +repo sync +``` + +`repo sync` takes some time, seeing as it clones the Linux kernel, among other +things. To clone multiple repositories in parallel, add the `-j` switch to the +`repo sync` command in the same way you would an invocation of `make`. + +## Building + +To create and launch a debugging environment all you need is `make`. Depending +on your machine, this may take upward of an hour the first time; subsequent runs +only take a few seconds, plus compiling anything that you may have changed: + +```bash +# [ TERM 1 ] + +cd build + +make toolchains -j2 +make run -j$(nproc) +``` + +**Note**: `make toolchains` need only be called once, and since it downloads two +files, the `-j2` is already included. + +Once this command is complete, it launches QEMU inside the same terminal as +where you executed `make run` along with two XTerm windows. In the terminal, you +can control QEMU via its monitor interface. For example, typing `c ` +resumes execution and `q ` quits QEMU. + +The two XTerm windows are connected to one emulated serial port each: one shows +output from the Normal World (the REE, or untrusted side) and the other shows +output from the Secure World (the TEE, or trusted side). The Normal World XTerm +window allows you to interact with the emulated Linux environment through a +BusyBox shell. + +By default, the emulated processor is halted when QEMU starts. To ensure that +the build is sane, resume execution by issuing the `c ` command in the +QEMU monitor (`c` is short for "continue"). + +In the Secure World XTerm window you should see OP-TEE's initialization output. +In the Normal World XTerm window you should see Linux boot. Try logging into +Linux in the Normal World XTerm window once it is done booting (see the output +in XTerm on how to log in). + +## Emulator Setup + +To debug enclaves on ARM TrustZone, you must build host applications and +enclaves. Then, you must copy your enclaves into it. + +### Building Hosts & Enclaves + +```bash +# [ TERM 2 ] + +git clone --recursive https://github.com/openenclave/openenclave.git sdk + +cd sdk + +# Set up the build environment (only once). +sudo scripts/ansible/install-ansible.sh +sudo ansible-playbook scripts/ansible/oe-contributors-setup-cross-arm.yml + +cd .. + +mkdir build +cd build + +# Configure the SDK +cmake ../sdk \ + -G Ninja \ + -DHAS_QUOTE_PROVIDER=OFF \ + -DCMAKE_TOOLCHAIN_FILE=../sdk/cmake/arm-cross.cmake \ + -DOE_TA_DEV_KIT_DIR=$PWD/../emulation/optee_os/out/arm/export-ta_arm64 \ + -DCMAKE_BUILD_TYPE=Debug + +# Build the SDK +ninja + +cd .. +``` + +For more information regarding these steps, see the [Getting Started with Open +Enclave for OP-TEE OS](../../../GettingStartedDocs/Contributors/OPTEEGettingStarted.md). + +### Copying Enclaves + +To debug enclaves on OP-TEE OS, the enclave binaries must be present inside the +emulator. A simple way to achieve this is using QEMU's built-in host-guest file +sharing capabilities. + +By default, `make run` instructs QEMU to share your home directory read-only +into the emulated guest. Once the guest boots and you have logged in via the +Normal World XTerm window, type: + +```bash +mkdir /mnt/home +mount -t 9p -o trans=virtio sh0 /mnt/home -oversion=9p2000.L + +cd /mnt/home +``` + +`sh0` is the name of the share as specified in QEMU's command line by `make +run`. + +For example, if you were trying to debug the SDK's test suite, you would do the +following on the Normal World XTerm window: + +```bash +cp openenclave_qemu/build/tests/hexdump/enc/126830b9-eb9f-412a-89a7-bcc8a517c12e.ta /lib/optee_armtz +openenclave_qemu/build/tests/hexdump/host/hexdump_host 126830b9-eb9f-412a-89a7-bcc8a517c12e +``` + +Notice how it is not necessary to copy the host application into the emulator, +it can run directly from the share. The enclave, however, must be inside. + +**Note**: QEMU environments built with this tooling automatically start +`tee-supplicant` on boot, unlike on some platforms where it might be necessary +to start it manually. + +# Debugging + +QEMU exposes a GDB server on `localhost:1234` with system-wide visibility into +the emulated environment. After starting QEMU with `make run`, start the +architecture-aware version of GDB. + +```bash +# [ TERM 2 ] + +gdb-multiarch + +target remote localhost:1234 +symbol-file ./build/tests/hexdump/host/hexdump_host + +b main +c +``` + +This command sequence connects GDB to QEMU, loads the symbols from +`oetests_host`, sets a breakpoint on the `main` function and resumes execution. +If you then run `oetests_host` inside the emulator, it will break on `main`. + +**Note:** Breakpoints on the host will not be hit if the latter is built as a +position-independent executable, which hosts are by default. This is because GDB +places breakpoints at virtual address offsets from the load address of the +executable. However, a position-independent executable may be loaded anywhere +within its virtual address space. It is possible to modify the host to print its +load address on each start, then line up the symbols with GDB correctly. For +debugging purposes, consider turning position-independent code generation off +temporarily. + +## Loading Enclave Symbols + +Instructing GDB to load symbols for an enclave requires some work the first +time. + +After launching QEMU, copying the sample enclave into it and launching the +corresponding host application, OP-TEE prints lines similar to the following in +the Secure World XTerm window: + +``` +D/TC:? 0 system_open_ta_binary:286 Lookup user TA ELF 126830b9-eb9f-412a-89a7-bcc8a517c12e (Secure Storage TA) +D/TC:? 0 system_open_ta_binary:289 res=0xffff0008 +D/TC:? 0 system_open_ta_binary:286 Lookup user TA ELF 126830b9-eb9f-412a-89a7-bcc8a517c12e (REE [buffered]) +D/TC:? 0 system_open_ta_binary:289 res=0x0 +D/LD: ldelf:150 ELF (126830b9-eb9f-412a-89a7-bcc8a517c12e) at 0x40010000 +``` + +The fifth line indicates where in secure virtual memory OP-TEE has loaded the +enclave. In this case it's `0x40010000`. This value should remain the same +throughout repeated runs as well as across reboots of the emulator. Note this +value. + +Due to how OP-TEE loads enclaves, you must manually line up the symbols in the +ELF file produced for enclaves with how the code is laid out in memory: + +```bash +#[ TERM 3 ] + +cd $HOME/openenclave_qemu + +./emulation/toolchains/aarch64/bin/aarch64-linux-gnu-objdump -x \ + ./build/tests/hexdump/enc/126830b9-eb9f-412a-89a7-bcc8a517c12e.elf | less +``` + +In the `Sections` table, you will see output like this: + +``` +Sections: +Idx Name Size VMA LMA File off Algn + 0 .ta_head 00000020 0000000000000000 0000000000000000 00001000 2**12 + CONTENTS, ALLOC, LOAD, READONLY, DATA + 1 .text 0007d9a8 0000000000000020 0000000000000020 00001020 2**3 + CONTENTS, ALLOC, LOAD, READONLY, CODE + 2 .eh_frame 0000bcd0 000000000007d9c8 000000000007d9c8 0007e9c8 2**3 + CONTENTS, ALLOC, LOAD, READONLY, DATA + 3 .rodata 00009cb5 00000000000896a0 00000000000896a0 0008a6a0 2**4 + CONTENTS, ALLOC, LOAD, READONLY, DATA +``` + +Take note of the `LMA` (Load Memory Address) of the `.text` section. + +Add the value you noted before from OP-TEE's output to the value of `LMA` for +the `.text` section. In this case: + +``` +0x40010000 + 0x20 = 0x40010020 +``` + +Switch back to `TERM 2` where GDB is running and type: + +``` + +add-symbol-file ./build/tests/hexdump/enc/126830b9-eb9f-412a-89a7-bcc8a517c12e.elf 0x40010020 +``` + +From this point forward, even if you rebuild enclaves, the load address for the +symbols should remain the same, so you do not need to go through of all this +every time you want to debug. Just execute the `add-symbol-file` command in GDB. +However, should your breakpoints stop being hit, do verify that these addresses +have not changed, especially after a `git pull` and a rebuild. + +There is a [known +issue](https://github.com/openenclave/openenclave/issues/2276), either in GDB or +QEMU, where once OP-TEE and Linux have fully booted up, it is not possible to +place breakpoints inside enclaves. To work around this, switch to `TERM 1` where +QEMU is running and type: + +``` +system_reset +``` + +On `TERM 2` where GDB is running: + +``` +b test +c +``` + +When you run the `hexdump_host` host application and the ECALL is performed, +there will be two breaks (assuming the host was built with position-independent +code off): + +* One in the host application just prior to the transition into the enclave, +and; +* One in the enclave at the ECALL. + +This duplication is due to the fact that there exist functions with the same +name in the host application and in the enclave. + +**Note**: Resetting QEMU means that emulator state is cleared, hence you must +repeat the steps of mounting your home directory inside the emulator and copying +the enclave to `/lib/optee_armtz`. Any breakpoints you set in GDB, however, +persist across `system_reset`. + +## Source-Level Debugging + +GDB by default offers a command-line interface. To see source code, registers, +and more, you can use any GUI that can use GDB as a back-end. Some of these are: + +* GDB in TUI mode +* CGDB +* Visual Studio +* Eclipse +* DDD + +This guide shows you how to use the first two. Instructions on how to set up +Visual Studio are coming soon. + +### GDB TUI + +GDB's Text User Interface, or TUI, can be accessed from within the GDB +command-line interface. Once GDB is started and you are at the GDB command +prompt: + +``` +[ TERM 2 ] + + a +``` + +This splits the GDB window in two horizontal panes: the top one shows source +code and the bottom one hosts the usual GDB command-line interface. + +You can switch between different layouts using the `layout ` command, +where `` can be any of: + +* `asm` +* `regs` +* `src` +* `split` + +You can also use `layout next` to cycle through all available layouts. + +GDB is a powerful debugger with great documentation available +[here](https://sourceware.org/gdb/current/onlinedocs/gdb/). + +### CGDB + +CGDB is a terminal utility that wraps GDB and provides syntax highlighting as +well as a simpler way to browse through source code. + +When started without arguments, CGDB uses the default GDB debugger on the +system. However, to debug an ARM or AARCH64 target from an x86/64 host, CGDB +must be told to use the same version of GDB used above. To start CGDB specifying +a particular version of GDB, issue the following command from a terminal: + +```bash +cgdb -d gdb-multiarch +``` + +CGDB looks like the first layout in the GDB TUI, but with colors by default. +Unlike the GDB TUI, however, you may switch focus from the bottom pane to the +top pane with the `ESC` key. To move back, press the `i` key. When the top pane +is in focus, you can navigate through source code using Vim-style commands. The +GDB command-line pane behaves in the same way as the regular GDB command-line +interface. + +CGDB sports a wide array of commands, be sure to read through its +[documentation](https://cgdb.github.io/docs/cgdb.html). + +**Note:** CGDB does not currently support multiple layouts and issuing the +`layout` command corrupts the screen. The only split available is source + GDB +command-line. + +Finally, to exit GDB, or CGDB: + +``` +q +``` diff --git a/docs/GettingStartedDocs/OP-TEE/Debugging/QEMUOnWSL.md b/docs/GettingStartedDocs/OP-TEE/Debugging/QEMUOnWSL.md new file mode 100644 index 0000000000..215e64f23e --- /dev/null +++ b/docs/GettingStartedDocs/OP-TEE/Debugging/QEMUOnWSL.md @@ -0,0 +1,139 @@ +# Debugging Enclaves on OP-TEE OS with QEMU on WSL + +This document is a complement to +[Debugging Enclaves on OP-TEE OS with QEMU](QEMU.md). That guide assumes it is +being followed on a native Linux system. This guide shows you how to configure +the Windows Subsystem for Linux (WSL) to use the guide on WSL. + +In this guide, you will learn how to: + +1. Install and configure a native X Server; +2. Work around a UNIX feature used by `fakeroot` +[not yet implemented in WSL](https://github.com/Microsoft/WSL/issues/1443). + +# Prerequisites + +This guide presumes you have a Windows 10 installation, version 1803 or later. + +## Required Features and Apps + +WSL is not installed by default. To install it, launch PowerShell as +Administrator and run: + +```powershell +Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux +``` + +Restart your computer when prompted. + +You are now ready to install [Ubuntu +18.04](https://www.microsoft.com/en-us/p/ubuntu-1804-lts/9n9tngvndl3q) on WSL. + +For a visual guide to this process, see [Install the Windows Subsystem for +Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10#install-the-windows-subsystem-for-linux). + +After Ubuntu 18.04 is installed, launch it from the Start Menu. The first launch +takes some time while the root filesystem is decompressed. Follow the +instructions on screen to set up an account inside the Ubuntu 18.04 environment. +Once that is complete, update the environment as follows: + +```bash +sudo apt update && sudo apt upgrade -y +``` + +## X Server + +The build system for the QEMU debugging environment launches two instances of +XTerm. XTerm is a graphical application for X11, or simply X. X is a +client-server windowing system where a graphical application runs on a remote +machine and is rendered on a thin terminal. This is not too dissimilar in +practice to Windows Server with Terminal Services. In X terminology, the server +is the thin terminal where output is rendered and the client is an application +running on a remote machine. In typical Linux distributions, the client and +server both run on the same computer. + +For the purposes of this guide, you will install an X Server that runs outside +of WSL. Then, you will let the build system launch XTerm inside WSL normally. +XTerm will connect to the X server outside of WSL over a local network +connection and render as a normal window on your Windows desktop. + +WSL does not ship with an X Server so you must install one yourself. +[XMing](http://www.straightrunning.com/XmingNotes) is a cross-compiled version +of X for Windows and is known to work well. The public domain releases are free +to use. + +**Note:** The author of XMing does not provide signed binaries. You may choose a +different X Server implementation if you prefer; the configuration steps below +should be the same if the alternative implementation that you choose is +compliant with the X protocol. + +Launch the installer and follow the instructions on screen. + +Once XMing is installed, a folder of the same name is added to the Start Menu. +Be sure to use the "XMing" shortcut, not "XLaunch". If you are prompted by the +Windows Defender Firewall after launching XMing to allow it to communicate over +the network, click "Cancel". This configures the firewall to deny all incoming +connections to XMing, but local connections are not affected. + +The only indication that XMing has successfully started is an icon in the +notification area. + +# Building & Debugging in WSL + +Before you are able to follow the steps in the debugging guide, execute the +following command inside the Ubuntu 18.04 environment: + +```bash +echo "export DISPLAY=:0" >> ~/.bashrc +exit +``` + +**Note:** You need only do this once. + +X applications read the `DISPLAY` environment variable to determine what X +Server to connect to. The value `:0` is shorthand for `localhost:0`, where +`localhost` is the network address of the machine where the X Server is running +on and `0` indicates the display number. You must exit and re-enter the Ubuntu +18.04 environment for Bash to pick up the changes to `.bashrc`. Afterward, the +`DISPLAY` variable will always be set. + +You may now follow the [Debugging Enclaves on OP-TEE OS with QEMU](QEMU.md) +guide on WSL. + +After some time into the build process of the QEMU debugging environment, it +will stop suggesting that `fakeroot` failed. + +## Fakeroot + +The build environment uses its own version of `fakeroot`. This version attempts +to make use of SYS-V IPC, but this feature is not available on WSL. You will see +an error that reads: + +``` +fakeroot, while creating message channels: Function not implemented +This may be due to a lack of SYSV IPC support. +fakeroot: error while starting the `faked' daemon. +``` + +To work around this issue, replace the `fakeroot` binary that the build system +uses with the version of `fakeroot` that uses sockets for IPC instead. Ubuntu +18.04 ships with both versions. + +Run the following commands to replace `fakeroot` with its socket-based +counterpart: + +```bash +mv $HOME/openenclave_qemu/emulation/out-br/host/bin/fakeroot $HOME/openenclave_qemu/emulation/out-br/host/bin/fakeroot.bak +ln -s /usr/bin/fakeroot-tcp $HOME/openenclave_qemu/emulation/out-br/host/bin/fakeroot +``` + +Resume the build with `make run` (and `-j`, as appropriate). If you ever clean +and rebuild the Buildroot output, you will run into this issue again. However, +that is never required for the purposes of debugging enclaves. In general, +therefore, this is a one-time fix. + +The Windows Defender Firewall might prompt for permission to allow incoming +connections to various Linux programs as the build proceeds. None of these +programs require accepting remote requests, so you can safely click "Cancel" to +block all incoming connections. Just as with XMing, local connections are not +affected. diff --git a/docs/GettingStartedDocs/OP-TEE/Hardware/ScalysTrustBox.md b/docs/GettingStartedDocs/OP-TEE/Hardware/ScalysTrustBox.md new file mode 100644 index 0000000000..9f6c08ea91 --- /dev/null +++ b/docs/GettingStartedDocs/OP-TEE/Hardware/ScalysTrustBox.md @@ -0,0 +1,402 @@ +# Getting Started with Open Enclave for the Scalys TrustBox + +The [TrustBox](https://scalys.com/trustbox-industrial) is an industrial router +manufactured by Scalys and serves as Open Enclave's reference hardware +implementation for ARM TrustZone. The TrustBox incorporates a +[Grapeboard](https://www.grapeboard.com), also produced by Scalys, which is in +turn based on the NXP Layerscape LS1012A SoC. The latter provides a hardware +root of trust as well as cryptographic and network acceleration. + +In this guide, you will learn how to retrieve, build and flash the firmware for +the TrustBox. Further, you will see how to build and flash a root filesystem +containing an Ubuntu 18.04 user-mode installation onto an SD card. Lastly, you +will learn how to run OP-TEE's test suite as well as some of Open Enclave's +own tests on the TrustBox. + +## Overview + +The TrustBox internally contains a Grapeboard. The latter has a MicroSD card +reader from which the board can boot as well as a serial port offered over a +Micro-USB Type B connector (effectively, serial-over-USB). Flashing the firmware +requires connecting to the board over the serial connection while flashing the +MicroSD card requires opening the TrustBox, retrieving the Grapeboard inside and +either overwriting the MicroSD card it ships with with the root filesystem that +you will build in this guide, or replacing the MicroSD card with your own card +after you flash the latter with the required root filesystem. + +### Caution + +The Linux-based system that you will install to the TrustBox is configured to +ease testing. Additionally, the secure firmware, such as OP-TEE OS, is currently +meant for preview purposes only. + +> **The resulting setup is not suitable for use in production and/or hostile +environments!** + +### Prerequisites + +- Ubuntu 18.04 LTS (64-bit) +- 1 TrustBox +- 1 Power supply +- 1 MicroSD card + - Optional if the TrustBox you are using ships with one +- 1 T8 Torx screwdriver +- 1 Micro-USB Type B to USB Type A cable +- Wired network (Ethernet) + - Optional + +**Note:** The procedure below has not been validated on Ubuntu 16.04 LTS. + +### Required Packages + +The following command installs all the packages necessary on Ubuntu 18.04 LTS: + +```bash +sudo apt update && sudo apt install -y android-tools-adb \ + android-tools-fastboot autoconf automake bc bison build-essential ccache \ + cgdb cscope curl device-tree-compiler expect flex \ + ftp-upload gdb-multiarch gdisk iasl libattr1-dev libc6 libcap-dev \ + libfdt-dev libftdi-dev libglib2.0-dev libhidapi-dev libncurses5-dev \ + libpixman-1-dev libssl-dev libstdc++6 libtool libz1 make mtools netcat \ + python-crypto python-pyelftools python-serial python-wand \ + python3-pyelftools repo unzip uuid-dev xdg-utils xterm xz-utils zlib1g-dev \ + flex bison python-pip libssl-dev build-essential gcc-aarch64-linux-gnu \ + g++-aarch64-linux-gnu minicom u-boot-tools device-tree-compiler \ + qemu-user-static udisks2 +``` + +## Serial Communication + +Connect the TrustBox to your computer via its serial-over-USB port. On a +computer running Ubuntu 18.04 LTS the TrustBox appears as a `ttyUSB#` device +node under `/dev`. + +For example: + +```bash +$ ll /dev/ttyUSB* + +crw-rw---- 1 root dialout 188, 0 Oct 21 18:14 /dev/ttyUSB0 +``` + +To establish a duplex serial connection, replace the device node with the one on +your system in the command below to invoke `minicom`: + +```bash +sudo minicom -D /dev/ttyUSB0 +``` + +Before the connection is usable, `minicom` must be configured to disable +hardware flow control. + +Inside the `minicom` window, type: + +``` + o +``` + +From the pop-up list, select "Serial port setup". In the new dialog, press `f` +to switch off Hardware Flow Control. Press `` to confirm, then `` to +dismiss the parent dialog. `minicom` should now be able to communicate with the +board. + +Once you have finished this guide and are ready to exit `minicom`: + +``` + q +``` + +When prompted if you would like to leave without reset, select `Yes`. + +**Note:** You must turn off hardware flow control every time you connect anew. + +## Source Code + +All the code necessary to build the TrustBox's firmware and software, as well +as the requisite build scripts may be obtained from Open Enclave's fork of +NXP's Layerscape SDK (LSDK): + +```bash +git clone --recursive https://github.com/ms-iot/lsdk -b ms-iot-openenclave-3.6.0 --depth=1 +``` + +This operation will take some time as multiple submodules will be cloned, too. + +## Firmware + +In this subsection, you will build the firmware that contains the Secondary +Program Loader (SPL), U-Boot, OP-TEE OS, and the NXP Primary Protected +Application (PPA). You will then flash this firmware to your board. + +### Building Firmware + +To build the firmware, in the same folder where you cloned the LSDK repository, +type: + +```bash +make firmware +``` + +If the board has HAB enabled, do instead: + +```bash +make firmware HAB=1 +``` + +**Note:** Do not attempt to use `-j`. The steps that are parallelizable will be +parallelized automatically. + +The build will generate the following files: + +- U-Boot + - `build/u-boot-with-spl-pbl.bin` +- OP-TEE OS and NXP PPA + - `build/ppa.itb` +- HAB Signature Data (if enabled) + - build/hdr_spl.out + +### Flashing Firmware + +To flash the newly built firmware, place the files listed above in the root +directory of a FAT-formatted MicroSD card. Then, boot into recovery U-Boot as +follows: + +1. Connect the Grapeboard to your computer; +2. Establish a `minicom` connection as outlined above; +3. Press and hold the push-button labelled `S2` on the board; +4. Power up the board, or, if already powered up, reset it by pressing and +releasing the push-button labelled `S1`. +5. Release the `S2` button when U-Boot prompts you to. + +This should leave you at the recovery U-Boot prompt. + +Flash the firmware by issuing the following commands: + +``` +# Update U-Boot +mmc rescan +fatload mmc 0:1 $load_addr u-boot-with-spl-pbl.bin +sf probe 0:0 +sf erase u-boot 200000 +sf write $load_addr u-boot $filesize + +# Update OPTEE-OS + PPA +mmc rescan +fatload mmc 0:1 $load_addr ppa.itb +sf probe 0:0 +sf erase ppa 100000 +sf write $load_addr ppa $filesize + +# Update CSF Header (only if HAB is enabled) +mmc rescan +fatload mmc 0:1 $load_addr hdr_spl.out +sf probe 0:0 +sf erase u-boot_hdr 40000 +sf write $load_addr u-boot_hdr $filesize +``` + +**Note:** Do not copy-paste more than one command at a time to the serial +console. + +To reboot, type: + +``` +reset +``` + +Upon reboot, you should see messages similar to the following with HAB disabled: + +``` +U-Boot SPL 2018.09-g8947717e16 (Oct 21 2019 - 17:01:00 -0700) +PPA Firmware: Version LSDK-18.09 +SEC Firmware: 'loadables' present in config +loadables: 'trustedOS@1' +can't get CSF - HAB disabled +SSM not in secure/trusted state: 0x9 +Security state failure +Continuing with non-secret testing identity +I/TC: +I/TC: OP-TEE version: v0.4.0-1123-gd1634ce8 #1 Tue Oct 22 00:01:37 UTC 2019 aarch64 +I/TC: Successfully captured Cyres certificate chain +I/TC: Successfully captured Cyres private key +I/TC: Initialized +Trying to boot from RAM +``` + +If HAB is enabled, the messages will instead look as follows: + +``` +U-Boot SPL 2018.09-00480-gdc28a9fa63-dirty (Jan 17 2019 - 11:17:15 -0800) +PPA Firmware: Version LSDK-18.09 +SEC Firmware: 'loadables' present in config +loadables: 'trustedOS@1' +I/TC: +I/TC: OP-TEE version: v0.4.0-443-g9cdcf55b-dev #6 Sat Jan 26 05:59:52 UTC 2019 aarch64 +I/TC: Successfully captured Cyres certificate chain +I/TC: Successfully captured Cyres private key +I/TC: Initialized +Trying to boot from RAM +``` + +### Recovery + +If upon reset the board fails to boot, you can repeat the procedure to re-enter +recovery U-Boot to flash the firmware again. Flashing the firmware does not +overwrite the copy of U-Boot, which is part of the recovery ROM. + +## Root File System + +In this subsection, you will build a root filesystem comprised of Linux, Ubuntu +18.04 user-mode as well as the necessary libraries and supporting binaries to +communicate with OP-TEE OS. You will then flash the resulting filesystem onto +a MicroSD card. + +### Building the Filesystem + +In the same folder where you cloned the LSDK repository, do: + +```bash +make os +``` + +**Note:** Do not attempt to use `-j` here either. The steps that are +parallelizable will be parallelized automatically. + +### Flashing the Filesystem + +Plug in the MicroSD card into your system, determine which block device node +corresponds to the MicroSD card, then issue the following command from within +the directory where you cloned the LSDK repository: + +```bash +make sdcard DEV=/dev/sdX +``` + +When the script finishes, it is safe to remove the MicroSD card. + +**Note:** You might observe an error related to copying an `Image` file. This is +expected if the MicroSD card is empty; copying this file is part of a backup +step. `make` is configured to ignore the error and continue. + +### Booting the Filesystem + +Insert the MicroSD card you just flashed into the TrustBox and power it up. +In the `minicom` window you should see Linux booting up. + +The default login credentials are: + +``` +Username: root +Password: root +``` + +To log in over SSH, issue the `ifconfig` command to see your board's IP address, +if it is connected to a network. + +## OP-TEE OS Test Suite + +To ensure that the build of OP-TEE OS is sane, first start the TEE supplicant on +the board: + +```bash +tee-supplicant & +``` + +You need only do this once per boot. Then, issue: + +``` +xtest +``` + +**Note:** `xtest` causes failures on purpose; do not be alarmed by the numerous +stack traces scrolling by. + +Once `xtest` finishes, you should see the following output: + +``` +24078 subtests of which 1 failed +95 test cases of which 1 failed +0 test cases were skipped +TEE test application done! +``` + +The single failed test is a +[known issue](https://github.com/openenclave/openenclave/issues/2275). + +## Open Enclave SDK + +In this subsection, you will retrieve the Open Enclave SDK from source, set up +your build environment, then build the SDK to target the TrustBox. Additionally, +you will copy a test host and enclave to the TrustBox. Lastly, you will execute +these on the TrustBox. + +### Building + +To build the Open Enclave SDK for the TrustBox, issue the commands below, taking +care to replace the path indicated for `OE_TA_DEV_KIT_DIR` to point to the +output of the LSDK build as generated in the previous steps: + +```bash +git clone --recursive https://github.com/openenclave/openenclave.git sdk + +cd sdk + +# Set up the build environment (only once). +sudo scripts/ansible/install-ansible.sh +sudo ansible-playbook scripts/ansible/oe-contributors-setup-cross-arm.yml + +cd .. + +mkdir build +cd build + +# Configure the SDK +cmake ../sdk \ + -G Ninja \ + -DHAS_QUOTE_PROVIDER=OFF \ + -DCMAKE_TOOLCHAIN_FILE=../sdk/cmake/arm-cross.cmake \ + -DOE_TA_DEV_KIT_DIR=$PWD/../lsdk/build/optee/export-ta_arm64 \ + -DCMAKE_BUILD_TYPE=Debug + +# Build the SDK +ninja +``` + +### Copy Hosts & Enclaves + +All OP-TEE OS enclaves are named `UUID.ta`, where `UUID` is a random UUID. These +must be placed on the board's filesystem under the `/lib/optee_armtz` folder. +Otherwise, enclaves will not load. The hosts may be located anywhere on the +filesystem. + +For the purposes of this guide, the test host and enclave are the following two +binaries located in the SDK's `build` folder as created above: + +``` +tests/hexdump/host/hexdump_host +tests/hexdump/enc/126830b9-eb9f-412a-89a7-bcc8a517c12e.ta +``` + +To copy these, you can either: + +1. Mount the MicroSD card on your Ubuntu 18.04 LTS machine and copy the files, +or; +2. Copy the files via SCP over the network. + +An example for using SCP: + +```bash +scp tests/hexdump/host/hexdump_host root@192.168.0.10: +scp tests/hexdump/enc/126830b9-eb9f-412a-89a7-bcc8a517c12e.ta root@192.168.0.10:/lib/optee_armtz +``` + +### Execution + +To run the test, log into the TrustBox as `root`, either over serial or SSH, and +do: + +```bash +cd ~ + +./hexdump_host 126830b9-eb9f-412a-89a7-bcc8a517c12e +``` diff --git a/docs/GettingStartedDocs/OP-TEE/Introduction.md b/docs/GettingStartedDocs/OP-TEE/Introduction.md new file mode 100644 index 0000000000..c763122978 --- /dev/null +++ b/docs/GettingStartedDocs/OP-TEE/Introduction.md @@ -0,0 +1,136 @@ +# Open Enclave SDK for OP-TEE OS + +Each Trusted Execution Environment (TEE) implementation provides a different +model with respect to the interaction between hosts and enclaves, as well as +regarding the runtime behavior of the two. + +The TEE implemented by ARM TrustZone splits the system into a secure and a +non-secure mode, where each keep their user-mode/kernel-mode partition. Hence, +an enclave that leverages ARM TrustZone executes in secure user-mode whereas its +host executes in non-secure user-mode: + +``` + |=============================================| + | Non-Secure Mode | Secure Mode | + |=============================================| + | | | + | Host #1 | Enclave #1 | + | | | + User | Host #2 | Enclave #2 | + Mode | | | + |---------------------------------------------| + Kernel | | | + Mode | Linux | OP-TEE OS | + | | | + |=============================================| +``` + +While Linux operates in the usual way in non-secure kernel-mode, OP-TEE OS +fulfills the role of the kernel in secure mode. + +OP-TEE OS provides a low-level communication mechanism to Linux based on the ARM +Secure Monitor Call (`smc`) instruction. In turn, Linux incorporates an OP-TEE +driver that enables Linux to talk to OP-TEE. This driver plugs into a generic +TEE driver, which exposes its capabilities to user-mode. There, a library known +as the OP-TEE Client (`libteec`) may be leveraged by non-secure user-mode hosts +to load, communicate with, and terminate enclaves. + +Likewise, OP-TEE OS provides a number of system calls to secure user-mode. A +library is in turn provided (`libutee`) that enclaves can use to call into these +system services. + +The Open Enclave SDK for OP-TEE OS effectively implements the SDK's APIs and +behaviors atop those exposed by OP-TEE OS both to non-secure user-mode as well +as atop those exposed to secure user-mode. + +**Note:** OP-TEE OS refers to enclaves as "Trusted Applications" (TAs). This +guide, as well as those linked at the bottom, use the term "enclave" to remain +in line with the SDK's nomenclature. However, when working with OP-TEE OS, such +as reading its debug output, you will come across "TA" frequently. + +## Supported Features + +The SDK currently provides preview support for the following features on OP-TEE +OS: + +1. Building Hosts & Enclaves + 1. Linux Hosts + 2. ARM64 Enclaves +2. Loading Enclaves +3. C/C++ +4. Enclave Calls (ECALLs) +5. Out Calls (OCALLs) +6. Terminating Enclaves + +### Known Issues + +#### C++ exceptions are not fully supported + +Even though it is possible to write enclaves that use C++ exceptions and run +them on OP-TEE OS, the stack unwinder may fail to find an exception handler on +`throw`. + +[Tracking issue](https://github.com/openenclave/openenclave/issues/2274). + +#### OP-TEE test suite failure + +One of OP-TEE's test cases is known to fail on the TrustBox. + +[Tracking issue](https://github.com/openenclave/openenclave/issues/2275). + +## Note on Forks + +While the SDK's support for Intel SGX is fairly self-contained, support for +OP-TEE OS mandates interactions among several components that exist outside the +purview of Open Enclave. + +Currently, the SDK works atop forks of the following projects: + +1. Linux + 1. The TEE and OP-TEE drivers have been modified. + 2. [Fork](https://github.com/ms-iot/linux/tree/ms-iot-openenclave-3.6.0) +2. OP-TEE OS + 1. The OS was augmented to support OCALLs. + 2. [Fork](https://github.com/ms-iot/optee_os/tree/ms-iot-openenclave-3.6.0) +3. OP-TEE Client + 1. The library was provided with the ability to handle OCALL requests. + 2. [Fork](https://github.com/ms-iot/optee_client/tree/ms-iot-openenclave-3.6.0) + +The changes to these are in the process of being upstreamed. For the moment, to +leverage the SDK's support for OP-TEE OS, be it on hardware or on an emulator, +Open Enclave's forks of these projects must be used. + +See the list of supported platforms below for instructions on how to use these +forks. + +## Binary Packages + +The Open Enclave SDK for Intel SGX may be installed on Linux and Windows systems +via binary packages. For the moment, there is no support for these for OP-TEE +OS. As a result, building hosts and enclaves for OP-TEE OS with the SDK requires +building the SDK from source. + +To do so, follow the instructions +[here](../Contributors/OPTEEGettingStarted.md). + +## Debugging + +OP-TEE OS does not provide any debugging facilities. Hence, it is not possible +to debug enclaves using a software debugger once these have been deployed to +hardware. However, it is possible to debug enclaves prior to deployment using +hardware emulation; for details, see the next section. Additionally, for boards +that support it, it is possible to debug enclaves with a JTAG debugger. + +## Supported Platforms + +The Open Enclave SDK currently provides preview support for the following +platforms: + +- Hardware + 1. Scalys TrustBox + - [Website](https://scalys.com/trustbox-industrial) + - [Getting Started Guide](Hardware/ScalysTrustBox.md) +- Emulation + 1. The Quick EMUlator (QEMU) + - [Website](https://www.qemu.org) + - [Getting Started Guide](Debugging/QEMU.md) diff --git a/docs/GettingStartedDocs/Windows_using_oe_sdk.md b/docs/GettingStartedDocs/Windows_using_oe_sdk.md new file mode 100644 index 0000000000..57937032d2 --- /dev/null +++ b/docs/GettingStartedDocs/Windows_using_oe_sdk.md @@ -0,0 +1,47 @@ +# Using the Open Enclave SDK on Windows + +This document provides a brief overview of how to start exploring the Open Enclave SDK +once you have it installed. + +## Open Enclave SDK Layout + +On Windows, if you installed the SDK using the NuGet package, it is by default installed to `%userprofile%\.nuget\packages`. +If you built the SDK from source and installed it, the SDK is installed to the location specified by CMAKE_INSTALL_PREFIX as described [here](Contributors/WindowsInstallInfo.md#basic-install-on-windows) + +It contains the following subfolders: + +| Path | Description | +|------------------------------|---------------------------------| +| bin | Developer tools such as oedebugrt.dll for debugging and oesign for signing your enclaves. | +| include\openenclave | Open Enclave runtime headers for use in your enclave (enclave.h) and its host (host.h). | +| include\openenclave\3rdparty | Headers for libc, libcxx and mbedlts libraries for use inside the enclave.
        See the API Reference section for supported functions. | +| lib\openenclave\cmake | Open Enclave SDK CMake Package for integration with your CMake projects. See [README.md](\cmake\sdk_cmake_targets_readme.md) for more details. | +| lib\openenclave\enclave | Libraries for linking into the enclave, including the libc, libcxx and mbedtls libraries for Open Enclave. | +| lib\openenclave\host | Library for linking into the host process of the enclave. | +| lib\openenclave\debugger | Libraries used by the gdb plug-in for debugging enclaves. | +| share\openenclave\samples | Sample code showing how to use the Open Enclave SDK. | + +## Configure environment variables for Open Enclave SDK for Windows + +- Set `OpenEnclave_DIR` to the point to the cmake directory of the Open Enclave SDK installation + +As an example, if you installed the SDK to C:\openenclave, then you would set `OpenEnclave_DIR` as shown below. + +```cmd +set OpenEnclave_DIR=C:\openenclave\lib\openenclave\cmake +``` + +## Samples + +One way to determine if your machine is correctly configured to build and run +Open Enclave apps is to execute the samples. A description of all the included samples, +what each one illustrates, and how to build and run them can be found in +[share/openenclave/samples/README.md](/samples/README_Windows.md). + +Additional documentation is also available for: +- [Building and signing enclaves](/docs/GettingStartedDocs/buildandsign.md) +- [Debugging enclave applications](/docs/GettingStartedDocs/Debugging.md) + +## APIs and supported libraries + +Please look [here](/docs/GettingStartedDocs/APIs_and_Libs.md). diff --git a/docs/GettingStartedDocs/Windows_vscode.md b/docs/GettingStartedDocs/Windows_vscode.md new file mode 100644 index 0000000000..8e89820e5b --- /dev/null +++ b/docs/GettingStartedDocs/Windows_vscode.md @@ -0,0 +1,168 @@ +# Building And Debugging Using Visual Studio Code on Windows + +This document provides a brief overview of how to build and debug Open Enclave applications using VS Code on Windows. + +## Install VS Code + +The latest version of Visual Studio Code can be installed from [https://code.visualstudio.com/](https://code.visualstudio.com/) + +## Install VS Code Extensions + +Install the following VS Code extensions. Click on an image to navigate to the Visual Studio Code Marketplace page for the extension. + +[![C/C++ Extension](images/VSCodeCppExtension.png)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools) + +[![CMake Tools Extension](images/VSCodeCMakeToolsExtension.png)](https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools) + +[![CDB Extension](images/VSCodeCDBExtension.png)](https://marketplace.visualstudio.com/items?itemName=MicrosoftDebuggingPlatform.vscode-cdb) + +## Launch Visual Studio Code and Configure + +Launch Visual Studio Code from the Windows Start menu. + +In the Command Palette, type "CMake: Select a Kit" and select the "Visual Studio Build Tools 2019 - amd64". + +Note that this example uses the tools you get when you download and install the [Visual Studio Build Tools 2019](https://aka.ms/vs/16/release/vs_buildtools.exe) and choose the "C++ build tools" workload. Visual Studio Build Tools 2019 has support for CMake Version 3.15 (CMake ver 3.12 or above is required for building Open Enclave SDK). + +![Select a kit](images/VSCodeSelectAKit.png) + +Open Workspace Settings by pressing Ctrl+Shift+P and typing "Open Workspace Settings" in the command palette. + +![Open Workspace Settings](images/VSCodeOpenWorkspaceSettings.png) + +Search for the setting "CMake Path" and change the path to point to the CMake executable you would like to use. + +In this example we are using the CMake executable that comes when you install Visual Studio build tools 2019 and choose the C++ build tools workload(with the C++ CMake Tools for Windows). + +![Specify Path to CMake Generator Executable](images/VSCodeCMakeExe.png) + +After this is done, Settings.json created in the .vscode folder would contain the following: + +```json +{ + "cmake.cmakePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe" +} +``` + +## Configure Your Workspace + +Open Workspace Settings by pressing Ctrl+Shift+P and typing "Open Workspace Settings" in the command palette. + +![Open Workspace Settings](images/VSCodeOpenWorkspaceSettings.png) + +Search for the setting "CMake Configure Args" and add an item `-DNUGET_PACKAGE_PATH=path-to-openenclave-nuget-packages`. +Add another item `-DOpenEnclave_DIR=YourOpenEnclaveInstallFolder\lib\openenclave\cmake` + +![CMake Configure Args](images/VSCodeCMakeConfigureArgs.png) + +For example, if you ran install-windows-prereqs.ps1 with -InstallPath C:\openenclave_prereqs, and you installed the OE SDK nuget package to C:\openenclave, Settings.json would be as below: + +```json +{ + "cmake.cmakePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe", + "cmake.configureArgs": [ + "-DNUGET_PACKAGE_PATH=C:\\openenclave_prereqs", + "-DOpenEnclave_DIR=C:\\openenclave\\lib\\openenclave\\cmake" + ] +} +``` + +Configure your workspace by typing "cmake configure" in the command palette + +![CMake Configure](images/VSCodeCMakeConfigure.png) + +Configuration should successfully complete. + +![CMake Configure Output](images/VSCodeCMakeConfigureOutput.png) + +## Build And Run Your Open Enclave Application + +Build the application by pressing F7 or typing "CMake Build a target" in the command palette, and selecting the "all META" target. + +![Build](images/VSCodeBuild.png) + +Run your application by pressing Shift+F7 or typing "CMake Build a target" in the command palette, and selecting the "run UTILITY" target. + +![Run](images/VSCodeRun.png) + +## Configuring Intellisense + +Intellisense should work out of the box for files within your workspace. However, Intellisense may not be aware of where to locate the Open Enclave SDK headers. +Open settings.json under the .vscode folder and add entries for "C_Cpp.default.includePath" and "C_Cpp.default.systemIncludePath". +If you installed the Open Enclave SDK at `C:\openenclave`, the Settings.json would be as below: + +```json +{ + "cmake.cmakePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe", + "cmake.configureArgs": [ + "-DNUGET_PACKAGE_PATH=C:\\openenclave_prereqs", + "-DOpenEnclave_DIR=C:\\openenclave\\lib\\openenclave\\cmake" + ], + "C_Cpp.default.includePath": ["C:\\openenclave\\include"], + "C_Cpp.default.systemIncludePath": [ + "C:\\openenclave\\include\\openenclave\\3rdparty\\libc", + "C:\\openenclave\\include\\openenclave\\3rdparty\\libcxx" + ] +} +``` + +## Debug Your Open Enclave Application + +Add a CDB Debug Configuration as shown below. + +![CDB Debug Configuration](images/VSCodeDebugConfiguration.png) + +Fill in program path, parameters and other values in the configuration. + +![Edit CDB Debug Configuration](images/VSCodeEditDebugConfiguration.png) + +Here is an example of launch.json after editing it. + +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "cdb", + "request": "launch", + "program": "${workspaceRoot}/build/host/helloworld_host.exe", + "sourcepath": "${workspaceRoot}", + "workingdirectory": "${workspaceRoot}/build", + "debugthedebugger": false, + "initialbreak": false, + "initialcommands": ".sympath \"\"", + "args": "enclave/enclave.signed" + } + ] +} +``` + +Open host.c and add a breakpoint. Start debugging. + +![Host Breakpoint](images/VSCodeHostBreakpoint.png) + +Step over the line that creates the enclave. The Console pane should show that the enclave has been loaded. + +![Stop After Enclave Creation](images/VSCodeStopAfterEnclaveCreation.png) + +Note: [CDB commands](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/) can be executed in the Console Prompt. + +![Debug Console](images/VSCodeDebugConsole.png) + +Open enc.c and put a breakpoint and continue execution. + +![Enclave Breakpoint](images/VSCodeEnclaveBreakpoint.png) + + +## Known Issues + +The VS Code Debugger extension is currently released as an early preview. +These issues are being worked on and will be fixed in an upcoming update. + +- Breakpoints aren't yet completely persisted and restored correctly. +Therefore, it is recommended that you clear all breakpoints and set them again every time the program is launched for debugging. +- The debugging session is not terminated when the program runs to completion. +Therefore, it is recommended that you stop and start a new debugging session each time. +- The debug cursor often jumps to the start of the file while debugging within an enclave. +Stepping again should take the cursor to the correct location. diff --git a/docs/GettingStartedDocs/Windows_windbg.md b/docs/GettingStartedDocs/Windows_windbg.md new file mode 100644 index 0000000000..49ed04ba05 --- /dev/null +++ b/docs/GettingStartedDocs/Windows_windbg.md @@ -0,0 +1,71 @@ +# Debugging ELF Enclaves Using WinDbg Preview + +This document provides a brief overview of how to debug Open Enclave applications using WinDbg Preview. + +# Install WinDbg Preview + +WinDbg Preview can be installed from the Windows Store on a Win 10 machine. + +[![WinDbg Preview](images/WinDbgPreview.png)](http://aka.ms/WinDbgPreview) + +WinDbg Preview supports debugging OpenEnclave applications since [1.0.1908.30002]( https://aka.ms/WinDbgWhatsNew#10190830002) + +Currently WinDbg Preview can be installed only on a Win 10 machine from the Windows Store. +Join the github [discussion](https://github.com/microsoftfeedback/WinDbg-Feedback/issues/19) if you want WinDbg Preview to be installed anywhere. + +In order to use WinDbg Preview on any Windows machine, copy the contents of `C:\Program Files\WindowsApps\Microsoft.WinDbg_*build*` +to your target machine, and launch the `DbgX.Shell` application. + +# Building Your Open Enclave Application + +Open an instance of x64 Native Tools Command Prompt + +![x64 Native Tools Command Prompt](images/WinDbgNativeToolsPrompt.png) + +Change to the directory containing your Open Enclave Application. Make a build folder and configure your application as shown below by defining the `OpenEnclave_DIR` and `NUGET_PACKAGE_PATH` configuration arguments. + + +```cmd +cd YourApplicationFolder +mkdir build +cd build +cmake -G Ninja -DOpenEnclave_DIR=your-open-enclave-install-path\lib\openenclave\cmake -DNUGET_PACKAGE_PATH=your-openenclave-nuget-packages-path .. +``` + +![Configure](images/WinDbgConfigure.png) + + +Build your application by running `ninja` and run your application by executing `ninja run`. + +![Build And Run](images/WinDbgBuildAndRun.png) + +# Debugging Your Open Enclave Application + +Note that to debug an Open Enclave application under windbg, `oedebugrt.dll`(found in `your-open-enclave-install-path\bin`) needs to be in the same folder as the host executable. +In the samples, this is automatically achieved via a call to the `copy_oedebugrt_target` cmake module. Please see the Helloworld sample's [CMakeLists.txt](../../samples/helloworld/CMakeLists.txt) for an example of how to call `copy_oedebugrt_target`. + +Launch `DbgX.Shell` application. Click on `File-> Start debugging -> Launch executable(advanced)` and specify the program name arguments (path to the enclave) and working directory. + +![Launch Executable](images/WinDbgLaunchExecutable.png) + +Open your host application and put a breakpoing on the source line that creates the enclave and continue execution till that line is hit. + +![Host Breakpoint](images/WinDbgHostBreakpoint.png) + + +Step over the line that creates the enclave. + + +Open your enclave source code, put a breakpoint and continue executin till that breakpoint is hit. + +![Enclave Breakpoint](images/WinDbgEnclaveBreakpoint.png) + + +Explore various WinDbg commands and features. + + +## Known Issues + +These issues are being worked on and will be fixed in an upcoming update. + +- The debug cursor often jumps to the start of the file while debugging within an enclave. Stepping again should take the cursor to the correct location. diff --git a/docs/GettingStartedDocs/images/VSCodeBuild.png b/docs/GettingStartedDocs/images/VSCodeBuild.png new file mode 100644 index 0000000000..3b603b1584 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeBuild.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCDBExtension.png b/docs/GettingStartedDocs/images/VSCodeCDBExtension.png new file mode 100644 index 0000000000..613bc69b86 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCDBExtension.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCMakeConfigure.png b/docs/GettingStartedDocs/images/VSCodeCMakeConfigure.png new file mode 100644 index 0000000000..3ac3a2d7e0 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCMakeConfigure.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCMakeConfigureArgs.png b/docs/GettingStartedDocs/images/VSCodeCMakeConfigureArgs.png new file mode 100644 index 0000000000..fc1a7918f3 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCMakeConfigureArgs.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCMakeConfigureOutput.png b/docs/GettingStartedDocs/images/VSCodeCMakeConfigureOutput.png new file mode 100644 index 0000000000..5cab7e7f73 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCMakeConfigureOutput.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCMakeExe.png b/docs/GettingStartedDocs/images/VSCodeCMakeExe.png new file mode 100644 index 0000000000..86f58ab1c9 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCMakeExe.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCMakeToolsExtension.png b/docs/GettingStartedDocs/images/VSCodeCMakeToolsExtension.png new file mode 100644 index 0000000000..9d51f271eb Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCMakeToolsExtension.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeCppExtension.png b/docs/GettingStartedDocs/images/VSCodeCppExtension.png new file mode 100644 index 0000000000..99f8f3e696 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeCppExtension.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeDebugConfiguration.png b/docs/GettingStartedDocs/images/VSCodeDebugConfiguration.png new file mode 100644 index 0000000000..13f551b3cb Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeDebugConfiguration.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeDebugConsole.png b/docs/GettingStartedDocs/images/VSCodeDebugConsole.png new file mode 100644 index 0000000000..17c24b3358 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeDebugConsole.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeEditDebugConfiguration.png b/docs/GettingStartedDocs/images/VSCodeEditDebugConfiguration.png new file mode 100644 index 0000000000..2acab8f181 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeEditDebugConfiguration.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeEnclaveBreakpoint.png b/docs/GettingStartedDocs/images/VSCodeEnclaveBreakpoint.png new file mode 100644 index 0000000000..44ca0b6776 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeEnclaveBreakpoint.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeHostBreakpoint.png b/docs/GettingStartedDocs/images/VSCodeHostBreakpoint.png new file mode 100644 index 0000000000..b395e3de34 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeHostBreakpoint.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLaunch.png b/docs/GettingStartedDocs/images/VSCodeLaunch.png new file mode 100644 index 0000000000..792a1fccdb Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLaunch.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxCMakeExtension.png b/docs/GettingStartedDocs/images/VSCodeLinuxCMakeExtension.png new file mode 100644 index 0000000000..414ac858b3 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxCMakeExtension.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxEnclaveBreakpoint.png b/docs/GettingStartedDocs/images/VSCodeLinuxEnclaveBreakpoint.png new file mode 100644 index 0000000000..79474a78bb Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxEnclaveBreakpoint.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxHostBreakpoint.png b/docs/GettingStartedDocs/images/VSCodeLinuxHostBreakpoint.png new file mode 100644 index 0000000000..a916434b84 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxHostBreakpoint.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxRemoteSSHIcon.png b/docs/GettingStartedDocs/images/VSCodeLinuxRemoteSSHIcon.png new file mode 100644 index 0000000000..06f3daf189 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxRemoteSSHIcon.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxRunApplication.png b/docs/GettingStartedDocs/images/VSCodeLinuxRunApplication.png new file mode 100644 index 0000000000..145269f5ae Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxRunApplication.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxStopAfterEnclaveCreation.png b/docs/GettingStartedDocs/images/VSCodeLinuxStopAfterEnclaveCreation.png new file mode 100644 index 0000000000..db2bd2cdf0 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxStopAfterEnclaveCreation.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxSuccessfulBuild.png b/docs/GettingStartedDocs/images/VSCodeLinuxSuccessfulBuild.png new file mode 100644 index 0000000000..316ff6d126 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxSuccessfulBuild.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeLinuxSuccessfulCMakeConfigure.png b/docs/GettingStartedDocs/images/VSCodeLinuxSuccessfulCMakeConfigure.png new file mode 100644 index 0000000000..44365bdd68 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeLinuxSuccessfulCMakeConfigure.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeNativeToolsPrompt.png b/docs/GettingStartedDocs/images/VSCodeNativeToolsPrompt.png new file mode 100644 index 0000000000..ca7f444762 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeNativeToolsPrompt.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeOpenWorkspaceSettings.png b/docs/GettingStartedDocs/images/VSCodeOpenWorkspaceSettings.png new file mode 100644 index 0000000000..8b72ca420e Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeOpenWorkspaceSettings.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeRun.png b/docs/GettingStartedDocs/images/VSCodeRun.png new file mode 100644 index 0000000000..36f58f39c6 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeRun.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeSelectAKit.png b/docs/GettingStartedDocs/images/VSCodeSelectAKit.png new file mode 100644 index 0000000000..8774a99b06 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeSelectAKit.png differ diff --git a/docs/GettingStartedDocs/images/VSCodeStopAfterEnclaveCreation.png b/docs/GettingStartedDocs/images/VSCodeStopAfterEnclaveCreation.png new file mode 100644 index 0000000000..dad26afb76 Binary files /dev/null and b/docs/GettingStartedDocs/images/VSCodeStopAfterEnclaveCreation.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgBuildAndRun.png b/docs/GettingStartedDocs/images/WinDbgBuildAndRun.png new file mode 100644 index 0000000000..366f44af06 Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgBuildAndRun.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgConfigure.png b/docs/GettingStartedDocs/images/WinDbgConfigure.png new file mode 100644 index 0000000000..9f8251bdb1 Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgConfigure.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgEnclaveBreakpoint.jpg b/docs/GettingStartedDocs/images/WinDbgEnclaveBreakpoint.jpg new file mode 100644 index 0000000000..a3f69cfe01 Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgEnclaveBreakpoint.jpg differ diff --git a/docs/GettingStartedDocs/images/WinDbgEnclaveBreakpoint.png b/docs/GettingStartedDocs/images/WinDbgEnclaveBreakpoint.png new file mode 100644 index 0000000000..c9d4aa4aec Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgEnclaveBreakpoint.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgHostBreakpoint.png b/docs/GettingStartedDocs/images/WinDbgHostBreakpoint.png new file mode 100644 index 0000000000..114ee37e2b Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgHostBreakpoint.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgLaunchExecutable.png b/docs/GettingStartedDocs/images/WinDbgLaunchExecutable.png new file mode 100644 index 0000000000..a2dfe626c4 Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgLaunchExecutable.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgNativeToolsPrompt.png b/docs/GettingStartedDocs/images/WinDbgNativeToolsPrompt.png new file mode 100644 index 0000000000..ca7f444762 Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgNativeToolsPrompt.png differ diff --git a/docs/GettingStartedDocs/images/WinDbgPreview.png b/docs/GettingStartedDocs/images/WinDbgPreview.png new file mode 100644 index 0000000000..7fe8864159 Binary files /dev/null and b/docs/GettingStartedDocs/images/WinDbgPreview.png differ diff --git a/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_16.04.md b/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_16.04.md index 2c26397ac8..16f2c697ba 100644 --- a/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_16.04.md +++ b/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_16.04.md @@ -26,7 +26,7 @@ wget -qO - https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add ```bash sudo apt update sudo apt -y install dkms -wget https://download.01.org/intel-sgx/dcap-1.2/linux/dcap_installers/ubuntuServer16.04/sgx_linux_x64_driver_1.12_c110012.bin -O sgx_linux_x64_driver.bin +wget https://download.01.org/intel-sgx/sgx-dcap/1.3.1/linux/distro/ubuntuServer16.04/sgx_linux_x64_driver_1.20.bin -O sgx_linux_x64_driver.bin chmod +x sgx_linux_x64_driver.bin sudo ./sgx_linux_x64_driver.bin ``` @@ -52,4 +52,4 @@ If you wish to make use of the Open Enclave CMake package, please install CMake ### 4. Verify the Open Enclave SDK install -See [Using the Open Enclave SDK](using_oe_sdk.md) for verifying and using the installed SDK. +See [Using the Open Enclave SDK](Linux_using_oe_sdk.md) for verifying and using the installed SDK. diff --git a/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_18.04.md b/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_18.04.md index a2a1771889..c7ebf507ae 100644 --- a/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_18.04.md +++ b/docs/GettingStartedDocs/install_oe_sdk-Ubuntu_18.04.md @@ -26,7 +26,7 @@ wget -qO - https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add ```bash sudo apt update sudo apt -y install dkms -wget https://download.01.org/intel-sgx/dcap-1.2/linux/dcap_installers/ubuntuServer18.04/sgx_linux_x64_driver_1.12_c110012.bin -O sgx_linux_x64_driver.bin +wget https://download.01.org/intel-sgx/sgx-dcap/1.3.1/linux/distro/ubuntuServer18.04/sgx_linux_x64_driver_1.20.bin -O sgx_linux_x64_driver.bin chmod +x sgx_linux_x64_driver.bin sudo ./sgx_linux_x64_driver.bin ``` @@ -53,4 +53,4 @@ If you wish to make use of the Open Enclave CMake package, please install CMake ### 4. Verify the Open Enclave SDK install -See [Using the Open Enclave SDK](using_oe_sdk.md) for verifying and using the installed SDK. +See [Using the Open Enclave SDK](Linux_using_oe_sdk.md) for verifying and using the installed SDK. diff --git a/docs/GettingStartedDocs/install_oe_sdk-Windows.md b/docs/GettingStartedDocs/install_oe_sdk-Windows.md new file mode 100644 index 0000000000..10bbaf8d2f --- /dev/null +++ b/docs/GettingStartedDocs/install_oe_sdk-Windows.md @@ -0,0 +1,75 @@ +# Install the Open Enclave SDK NuGet Package + +## Platform requirements + +- A system with support for SGX1 with Flexible Launch Control (FLC). +Note: To check if your system has support for SGX1 with or without FLC, please look [here](./SGXSupportLevel.md). + +- Windows Server 2016 + +## Software Prerequisites + +### Microsoft Visual Studio Build Tools 2019 + +Install [Visual Studio Build Tools 2019](https://aka.ms/vs/16/release/vs_buildtools.exe). Choose the "C++ build tools" workload. Visual Studio Build Tools 2019 has support for CMake Version 3.15 (CMake ver 3.12 or above is required for building Open Enclave SDK). For more information about CMake support, look [here](https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/). + +### Git for Windows 64-bit + +Download [Git for Windows 64-bit](https://git-scm.com/download/win). + +Install Git and add Git Bash to the PATH environment variable. +Typically, Git Bash is located in `C:\Program Files\Git\bin`. +Currently the Open Enclave SDK build system uses bash scripts to configure +and build Linux-based 3rd-party libraries. + +Open a command prompt and ensure that Git Bash is added to PATH. + +```cmd +C:\>where bash +C:\Program Files\Git\bin\bash.exe +``` + +Tools available in the Git bash environment are also used for test and sample +builds. For example, OpenSSL is used to generate test certificates, so it is +also useful to have the `Git\mingw64\bin` folder added to PATH. This can be checked +from the command prompt as well: + +```cmd +C:\>where openssl +C:\Program Files\Git\mingw64\bin\openssl.exe +``` + +### Clang + +Download [Clang/LLVM for Windows 64-bit](http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe). +Install Clang 7.0.1 and add the LLVM folder (typically C:\Program Files\LLVM\bin) +to PATH. Open Enclave SDK uses clang to build the enclave binaries. + +Open up a command prompt and ensure that clang is added to PATH. + +```cmd +C:\> where clang +C:\Program Files\LLVM\bin\clang.exe +C:\> where llvm-ar +C:\Program Files\LLVM\bin\llvm-ar.exe +C:\> where ld.lld +C:\Program Files\LLVM\bin\ld.lld.exe +``` + +### SGX1 with Flexible Launch Control (FLC) Prerequisites + +Instructions to install Intel's PSW 2.4, Intel's Data Center Attestation Primitives and related dependencies can be found [here](Contributors/WindowsManualSGX1FLCDCAPPrereqs.md). + +## Download and install the Open Enclave SDK NuGet Package + +Download the required Windows NuGet Package from [here](https://github.com/openenclave/openenclave/releases) and place it in a directory of your choice. Use the command below to install the NuGet package. In this example, we are placing the NuGet Package in `C:\openenclave_nuget` and installing it to `C:\oe`. + +```cmd + nuget.exe install open-enclave -Source C:\openenclave_nuget -OutputDirectory C:\oe -ExcludeVersion +``` + +Note: If it is an RC package, append `-pre` to the command above. + +## Verify the Open Enclave SDK installation + +See [Using the Open Enclave SDK](Windows_using_oe_sdk.md) for verifying and using the installed SDK. diff --git a/docs/GovernanceModel.md b/docs/Governance.md similarity index 65% rename from docs/GovernanceModel.md rename to docs/Governance.md index 8f187d335c..d9d218a4eb 100644 --- a/docs/GovernanceModel.md +++ b/docs/Governance.md @@ -10,16 +10,31 @@ Our model is based on the [liberal contribution policy](https://opensource.guide/leadership-and-governance/). See [below](#accepting-contributions) for more info. -Code of Conduct ---------------- - -In order to maintain a pleasant and welcoming environment, we want to reiterate -that it is imperative that all community members adhere to our -[Code of Conduct](Contributing.md#code-of-conduct). -Anyone failing to follow the Code of Conduct will be removed from the community -by the [Community Maintenance Committee](Maintainers.md). If you are made to -feel uncomfortable, or have any concerns about behavior within the community, we -encourage you to reach out to members of the Community Maintenance Committee. +Conflict Resolution +------------------- +We do not believe that all conflict is bad; healthy debate and disagreement often +yield positive results. However, it is never okay to be disrespectful or to engage +in behavior that violates the project’s [Code of Conduct](CodeOfConduct.md). + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly and +easily, and this gives people more control over the outcome of their dispute. If +you are unable to resolve the matter for any reason, or if the behavior is +threatening or harassing, report it. We are dedicated to providing an environment +where participants feel welcome and safe. + +Reports can be made to any member of the [Community Governance Committee]( +Committers.md#Committee_Members). It is the duty of the committee members to receive +and address reports while maintaining the confidentiality of the reporter. + +We will investigate every complaint, but you may not receive a direct response. We +will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from the +project and project-sponsored spaces. We will notify the accused of the report and +provide them an opportunity to discuss it before any action is taken. The identity +of the reporter will be omitted from the details of the report supplied to the accused. +In potentially harmful situations, such as ongoing harassment or threats to anyone’s +safety, we may take action without notice. Design and Development Discussions ---------------------------------- @@ -41,26 +56,24 @@ Remember that security issues should be reported through a separate channel, and will receive a response within 24 hours. See [Reporting Security Issues](Contributing.md#reporting-security-issues). -Maintainers, Committers, and Contributors ------------------------------------------ +Community Governance Committee Members, Committers, and Contributors +-------------------------------------------------------------------- -We define "maintainer" as members of the Open Enclave "Community Maintenance -Committee", as listed in the [maintainers document](Maintainers.md). A -"committer" is anyone with direct write access to the Open Enclave repository on -GitHub, as granted by the Committee. All maintainers are committers, but not all -committers are maintainers. Finally, "contributor" is anyone else making +A "committer" is anyone with direct write access to the Open Enclave repository on +GitHub, as granted by the Committee. All Committee members are committers, but not all +committers are Committee members. Finally, "contributor" is anyone else making contributions to the project, including: creating or commenting on issues, opening or reviewing pull requests, or other useful contributions such as providing support in forums or chats. -See the [maintainers document](Maintainers.md) for the Community Maintenance -Committee, our process for adding new committers and maintainers, as well the -areas of expertise for each of the committers. +See the [Community Governance Committee document](Committers.md) for more information +on the Community Governance Committee, our process for adding new committers and +Committee members, as well the areas of expertise for each of the committers. Accepting Contributions ----------------------- -Project committers will merge changes that improve the product significantly and +Project committers will merge changes that improve the project significantly and broadly and that align with the [Open Enclave roadmap](https://github.com/openenclave/openenclave/projects). Contributions must also satisfy the other [published guidelines](Contributing.md). @@ -69,11 +82,11 @@ Committers may revert changes if they are found to be breaking. We make most decisions through a consensus seeking process, rather than a formal voting process. For example, committers can merge contributions that were reviewed without objections. If there are objections that cannot be resolved, an -issue can be escalated to the Community Maintenance Committee to make a +issue can be escalated to the Community Governance Committee to make a decision, which handles issues as discussed in the -[maintainers document](Maintainers.md). +[Community Governance Committee document](Committers.md). -See the [maintainers document](Maintainers.md) for the list of project +See the [Community Governance Committee document](Committers.md) for the list of project committers, and how to become one. Community Approval of Releases diff --git a/docs/LibcSupport.md b/docs/LibcSupport.md index ab818e5d02..bf65e25815 100644 --- a/docs/LibcSupport.md +++ b/docs/LibcSupport.md @@ -12,7 +12,7 @@ inttypes.h | Partial | **Unsupported functions:** imaxabs(), imaxdiv() | iso646.h | Yes | - | limits.h | Yes | - | locale.h | Partial | Only basic support for C/POSIX locale | -malloc.h | Partial | **Unsupported functions:** malloc_usable_size() | +malloc.h | Partial | - | math.h | Partial | **Unsupported functions:** acosh(), asinh(), fmal(), lgamma(), lgammaf(), sinh(), sinhl(), tgamma() | setjmp.h | Yes | - | signal.h | No | - | diff --git a/docs/MbedtlsSupport.md b/docs/MbedtlsSupport.md index 47a9c64032..b94599a4b8 100644 --- a/docs/MbedtlsSupport.md +++ b/docs/MbedtlsSupport.md @@ -15,7 +15,7 @@ ccm.h | Yes | - | cipher.h | Yes | - | cmac.h | Yes | - | ctr_drbg.h | Partial | Unsupported functions: mbedtls_ctr_drbg_write_seed_file(), mbedtls_ctr_drbg_update_seed_file() | -debug.h | Yes | - | +debug.h | No | - | des.h | Yes | - | dhm.h | No | - | ecdh.h | Yes | - | diff --git a/docs/Releasing.md b/docs/Releasing.md index 45ca22a533..94c663649e 100644 --- a/docs/Releasing.md +++ b/docs/Releasing.md @@ -4,6 +4,13 @@ Open Enclave SDK Release Procedures This document covers how we handle creating a release. Let's look at it from an example: +Selecting a Release Manager +--------------------------- + +The Community Governance Committee will select a release manager from one of the +Committers by submitting a Pull Request that adds a "Release" tag to that +Committer's "Area" in [Committers.md](Committers.md). + Version Bump ------------ @@ -11,9 +18,6 @@ Version Bump > and branches are `v0.7.x`. We follow [Semantic > Versioning](https://semver.org/spec/v2.0.0.html). -We want to release `v0.7.0` in about a week, so we choose a release manager from -the committers. - The initial announcement of the upcoming release will be a PR by the release manager to the `master` branch with the commit to bump the [VERSION file](../VERSION) to _next_ pre-release, e.g. `v0.7.x`, and the commit to update @@ -97,7 +101,7 @@ release. These notes should be suitable for a blog post. Community Approval ------------------ -See the [Governance Model](GovernanceModel.md#community-approval-of-releases) +See the [Governance Model](Governance.md#community-approval-of-releases) documentation for the necessary steps to approve the release with the community. GitHub Release and Git Tag Creation @@ -146,5 +150,5 @@ notes, and any social media we currently use). Servicing --------- -See the [Governance Model](GovernanceModel.md#servicing-of-releases) +See the [Governance Model](Governance.md#servicing-of-releases) documentation for our intended servicing model. diff --git a/docs/refman/CMakeLists.txt b/docs/refman/CMakeLists.txt index 22e822bf28..973d91ec66 100644 --- a/docs/refman/CMakeLists.txt +++ b/docs/refman/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. option(ENABLE_REFMAN "Enable Doxygen reference manual generation" ON) @@ -17,6 +17,12 @@ if (ENABLE_REFMAN) # have to specify it because we have another directory to strip. set(DOXYGEN_STRIP_FROM_PATH "${PROJECT_SOURCE_DIR}/include/openenclave/;${PROJECT_SOURCE_DIR}/docs/refman") + # Allow @experimental to be used in headers to mark an API as experimental and add it to a list of + # experimental APIs. + set(DOXYGEN_ALIASES + "experimental = \\xrefitem experimental \\\"This feature is marked as experimental\\\" \\\"Experimental List\\\"" + "experimental{1} = \\xrefitem experimental \\\"Experimental\\\" \\\"Experimental List\\\" \\1") + # NOTE: These were set to their non-default values in the existing # configuration file, so that configuration has been copied here. # However, they may or may not be desired. diff --git a/docs/refman/doxygen-howto.md b/docs/refman/doxygen-howto.md index 8394d5ba99..24e0e773e7 100644 --- a/docs/refman/doxygen-howto.md +++ b/docs/refman/doxygen-howto.md @@ -182,6 +182,7 @@ For example. */ ``` + ### Disabling Doxygen documentation from blocks of code To disable Doxygen documentation from blocks of code with `#defines` or diff --git a/enclave/CMakeLists.txt b/enclave/CMakeLists.txt index 84891f5a51..ba2f275f9e 100644 --- a/enclave/CMakeLists.txt +++ b/enclave/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(core) @@ -6,6 +6,8 @@ add_subdirectory(crypto) if (OE_SGX) set(PLATFORM_SRC + ../common/sgx/eeid.c + ../common/sgx/endorsements.c ../common/sgx/qeidentity.c ../common/sgx/quote.c ../common/sgx/report.c @@ -13,6 +15,9 @@ if (OE_SGX) ../common/sgx/sgxcertextensions.c ../common/sgx/tcbinfo.c ../common/sgx/tlsverifier.c + ../common/sgx/verifier.c + ../common/sgx/verify_eeid.c + sgx/attester.c sgx/qeidinfo.c sgx/report.c sgx/revocationinfo.c @@ -25,8 +30,8 @@ elseif(OE_TRUSTZONE) endif() add_library(oeenclave STATIC + ../common/attest_plugin.c ../common/datetime.c - ../common/lockless_queue.c asym_keys.c link.c random.c diff --git a/enclave/asym_keys.c b/enclave/asym_keys.c index 2217dc7c84..bc17e1adde 100644 --- a/enclave/asym_keys.c +++ b/enclave/asym_keys.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/CMakeLists.txt b/enclave/core/CMakeLists.txt index 9b63d123bb..de279c6ead 100644 --- a/enclave/core/CMakeLists.txt +++ b/enclave/core/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== @@ -50,6 +50,8 @@ set(MUSL_SRC_DIR ${PROJECT_SOURCE_DIR}/3rdparty/musl/musl/src) if (OE_SGX) list(APPEND PLATFORM_SRC + ../../common/sgx/endorsements.c + ../../host/sgx/sgxmeasure.c sgx/backtrace.c sgx/calls.c sgx/cpuid.c @@ -59,7 +61,6 @@ if (OE_SGX) sgx/hostcalls.c sgx/init.c sgx/sgx_t_wrapper.c - sgx/jump.c sgx/keys.c sgx/memory.c sgx/properties.c @@ -67,6 +68,7 @@ if (OE_SGX) sgx/sched_yield.c sgx/spinlock.c sgx/td.c + sgx/td_basic.c sgx/thread.c sgx/tracee.c sgx/enter.S @@ -75,6 +77,11 @@ if (OE_SGX) sgx/longjmp.S sgx/setjmp.S) + # Functions in td_basic.c will change the status of td and may trigger + # stack check fail, thus it is necessary to turn off stack check. + set_source_files_properties(sgx/td_basic.c PROPERTIES + COMPILE_FLAGS -fno-stack-protector) + # OS specific sources for SGX. if (UNIX OR USE_CLANGW) list(APPEND PLATFORM_SRC @@ -136,12 +143,13 @@ add_library(oecore STATIC pthread.c result.c sbrk.c - shm.c + arena.c stdio.c strerror.c string.c strtok_r.c strtoul.c + switchlesscalls.c tee_t_wrapper.c time.c tracee.c @@ -184,9 +192,6 @@ set_source_files_properties(malloc.c PROPERTIES COMPILE_FLAGS "-Wno-conversion -Wno-null-pointer-arithmetic") if (OE_SGX) - # jump.s must be optimized for the correct call-frame. - set_source_files_properties(sgx/jump.c PROPERTIES COMPILE_FLAGS -O2) - set_source_files_properties(sgx/keys.c PROPERTIES COMPILE_FLAGS -Wno-type-limits) # -m64 is an x86_64 specific flag @@ -206,8 +211,11 @@ if (OE_SGX) target_compile_options(oecore PUBLIC -fPIE -nostdinc - -fno-stack-protector + -fstack-protector-strong -fvisibility=hidden + # Put each function or data in its own section. + # This allows aggressively eliminating unused code. + -ffunction-sections -fdata-sections # "The default without -fpic is 'initial-exec'; with -fpic the # default is 'global-dynamic'." # https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options @@ -241,8 +249,8 @@ target_compile_definitions(oecore # package. $) -if(USE_LIBSGX) - target_compile_definitions(oecore PUBLIC OE_USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(oecore PUBLIC OE_LINK_SGX_DCAP_QL) endif() if(USE_DEBUG_MALLOC) @@ -256,7 +264,8 @@ if(OE_SGX) -nostdlib -nodefaultlibs -nostartfiles -Wl,--no-undefined,-Bstatic,-Bsymbolic,--export-dynamic,-pie,--build-id -Wl,-z,noexecstack - -Wl,-z,now) + -Wl,-z,now + -Wl,-gc-sections) elseif(OE_TRUSTZONE) target_link_libraries(oecore INTERFACE -nostdlib -nodefaultlibs -nostartfiles diff --git a/enclave/core/__secs_to_tm.c b/enclave/core/__secs_to_tm.c index eded8be92d..165f29164e 100644 --- a/enclave/core/__secs_to_tm.c +++ b/enclave/core/__secs_to_tm.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* Use OE STDC time.h & limits.h defs for MUSL __secs_to_tm.c */ diff --git a/enclave/core/__stack_chk_fail.c b/enclave/core/__stack_chk_fail.c index 43c4c4f0d1..825e5d10f7 100644 --- a/enclave/core/__stack_chk_fail.c +++ b/enclave/core/__stack_chk_fail.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/arena.c b/enclave/core/arena.c new file mode 100644 index 0000000000..780e187644 --- /dev/null +++ b/enclave/core/arena.c @@ -0,0 +1,101 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "arena.h" +#include +#include +#include +#include +#include +#include + +// The per-thread shared memory arena +static __thread shared_memory_arena_t _arena = {0}; + +// Default shared memory arena capacity is 1 mb +static size_t _capacity = 1024 * 1024; + +static const size_t _max_capacity = 1 << 30; + +void* oe_allocate_arena(size_t capacity); +void oe_deallocate_arena(void* buffer); + +bool oe_configure_arena_capacity(size_t cap) +{ + if (cap > _max_capacity) + { + return false; + } + __atomic_store_n(&_capacity, cap, __ATOMIC_SEQ_CST); + return true; +} + +void* oe_arena_malloc(size_t size) +{ + oe_result_t result = OE_UNEXPECTED; + size_t total_size = 0; + const size_t align = OE_EDGER8R_BUFFER_ALIGNMENT; + + // Create the anera if it hasn't been created. + if (_arena.buffer == NULL) + { + _arena.capacity = __atomic_load_n(&_capacity, __ATOMIC_SEQ_CST); + void* buffer = oe_allocate_arena(_arena.capacity); + if (buffer == NULL) + { + _arena.capacity = 0; + return NULL; + } + _arena.buffer = (uint8_t*)buffer; + _arena.used = 0; + } + + // Round up to the nearest alignment size. + total_size = oe_round_up_to_multiple(size, align); + + // check for overflow + if (total_size < size) + return NULL; + + // check for capacity + size_t used_after; + OE_CHECK(oe_safe_add_sizet(_arena.used, total_size, &used_after)); + + // Ok if the incoming malloc puts us below the capacity. + if (used_after <= _arena.capacity) + { + uint8_t* addr = _arena.buffer + _arena.used; + _arena.used = used_after; + return addr; + } + +done: + return NULL; +} + +void* oe_arena_calloc(size_t num, size_t size) +{ + size_t total = 0; + if (oe_safe_mul_sizet(num, size, &total) != OE_OK) + return NULL; + + void* ptr = oe_arena_malloc(total); + if (ptr != NULL) + { + memset(ptr, 0, total); + } + return ptr; +} + +void oe_arena_free_all() +{ + _arena.used = 0; +} + +// Free the arena in the current thread. +void oe_teardown_arena() +{ + if (_arena.buffer != NULL) + oe_deallocate_arena(_arena.buffer); + memset(&_arena, 0, sizeof(_arena)); +} diff --git a/enclave/core/arena.h b/enclave/core/arena.h new file mode 100644 index 0000000000..b8f3cf351d --- /dev/null +++ b/enclave/core/arena.h @@ -0,0 +1,27 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_ARENA_H +#define _OE_ARENA_H + +#include + +typedef struct _shared_memory_arena_t +{ + /* Buffer holding the shared memory pool */ + uint8_t* buffer; + size_t capacity; + size_t used; +} shared_memory_arena_t; + +bool oe_configure_arena_capacity(size_t cap); + +void* oe_arena_malloc(size_t size); + +void* oe_arena_calloc(size_t num, size_t size); + +void oe_arena_free_all(); + +void oe_teardown_arena(); + +#endif /* _OE_ARENA_H */ diff --git a/enclave/core/assert.c b/enclave/core/assert.c index ff6662a66b..b7bed66d1a 100644 --- a/enclave/core/assert.c +++ b/enclave/core/assert.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/atexit.c b/enclave/core/atexit.c index 4c1d823a52..9515f88bb5 100644 --- a/enclave/core/atexit.c +++ b/enclave/core/atexit.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "atexit.h" diff --git a/enclave/core/atexit.h b/enclave/core/atexit.h index b607a03050..87619bcb3e 100644 --- a/enclave/core/atexit.h +++ b/enclave/core/atexit.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ATEXIT_H diff --git a/enclave/core/backtrace.c b/enclave/core/backtrace.c index 0cd31ed863..23ee12bc54 100644 --- a/enclave/core/backtrace.c +++ b/enclave/core/backtrace.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/calls.c b/enclave/core/calls.c index 2846c0fc7c..a04a5b0637 100644 --- a/enclave/core/calls.c +++ b/enclave/core/calls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/calls.h b/enclave/core/calls.h index c3732107c9..ef8c5f089e 100644 --- a/enclave/core/calls.h +++ b/enclave/core/calls.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/ctype.c b/enclave/core/ctype.c index 7cb94c2c60..c1de61d40d 100644 --- a/enclave/core/ctype.c +++ b/enclave/core/ctype.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/debugmalloc.c b/enclave/core/debugmalloc.c index 766f503eac..f13eb2da9e 100644 --- a/enclave/core/debugmalloc.c +++ b/enclave/core/debugmalloc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define USE_DL_PREFIX @@ -430,6 +430,13 @@ int oe_debug_posix_memalign(void** memptr, size_t alignment, size_t size) return 0; } +size_t oe_debug_malloc_usable_size(void* ptr) +{ + if (!ptr) + return 0; + return _get_header(ptr)->size; +} + void oe_debug_malloc_dump(void) { _dump(true); diff --git a/enclave/core/debugmalloc.h b/enclave/core/debugmalloc.h index a9cd07603d..999bddc4c0 100644 --- a/enclave/core/debugmalloc.h +++ b/enclave/core/debugmalloc.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_DEBUG_MALLOC_H @@ -18,4 +18,6 @@ void* oe_debug_memalign(size_t alignment, size_t size); int oe_debug_posix_memalign(void** memptr, size_t alignment, size_t size); +size_t oe_debug_malloc_usable_size(void* ptr); + #endif /* _OE_DEBUG_MALLOC_H */ diff --git a/enclave/core/errno.c b/enclave/core/errno.c index 71582aa96c..3cef71149c 100644 --- a/enclave/core/errno.c +++ b/enclave/core/errno.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/gmtime.c b/enclave/core/gmtime.c index acaf75083e..1536d98f47 100644 --- a/enclave/core/gmtime.c +++ b/enclave/core/gmtime.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/hexdump.c b/enclave/core/hexdump.c index 4baa8a89da..3c4da1e3d8 100644 --- a/enclave/core/hexdump.c +++ b/enclave/core/hexdump.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/hostcalls.c b/enclave/core/hostcalls.c index 584ee5fc1c..3526d68885 100644 --- a/enclave/core/hostcalls.c +++ b/enclave/core/hostcalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -11,7 +11,7 @@ #include #include -#include "shm.h" +#include "arena.h" #include "tee_t.h" void* oe_host_malloc(size_t size) @@ -160,14 +160,14 @@ int oe_host_fprintf(int device, const char* fmt, ...) // A stack-based allocation scheme is the most efficient in this case. void* oe_allocate_switchless_ocall_buffer(size_t size) { - return oe_shm_malloc(size); + return oe_arena_malloc(size); } // Function used by oeedger8r for freeing ocall buffers. void oe_free_switchless_ocall_buffer(void* buffer) { OE_UNUSED(buffer); - /* Do nothing. Buffer will be freed on ECALL RETURN */ + oe_arena_free_all(); } int oe_host_write(int device, const char* str, size_t len) diff --git a/enclave/core/init_fini.c b/enclave/core/init_fini.c index 3a886b7f41..053811c819 100644 --- a/enclave/core/init_fini.c +++ b/enclave/core/init_fini.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "init_fini.h" diff --git a/enclave/core/init_fini.h b/enclave/core/init_fini.h index 13111e2116..b4cf1cc354 100644 --- a/enclave/core/init_fini.h +++ b/enclave/core/init_fini.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_INIT_FINI_H diff --git a/enclave/core/intstr.c b/enclave/core/intstr.c index adbc9ea198..7948df1707 100644 --- a/enclave/core/intstr.c +++ b/enclave/core/intstr.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "intstr.h" diff --git a/enclave/core/intstr.h b/enclave/core/intstr.h index 9e6a5e4f1a..f3f5c129e8 100644 --- a/enclave/core/intstr.h +++ b/enclave/core/intstr.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTSTR_H diff --git a/enclave/core/malloc.c b/enclave/core/malloc.c index c58d69f3ab..7210ad3c31 100644 --- a/enclave/core/malloc.c +++ b/enclave/core/malloc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -51,6 +51,7 @@ static int _dlmalloc_stats_fprintf(FILE* stream, const char* format, ...); #define MEMALIGN oe_debug_memalign #define POSIX_MEMALIGN oe_debug_posix_memalign #define FREE oe_debug_free +#define MALLOC_USABLE_SIZE oe_debug_malloc_usable_size #else #define MALLOC dlmalloc #define CALLOC dlcalloc @@ -58,6 +59,7 @@ static int _dlmalloc_stats_fprintf(FILE* stream, const char* format, ...); #define MEMALIGN dlmemalign #define POSIX_MEMALIGN dlposix_memalign #define FREE dlfree +#define MALLOC_USABLE_SIZE dlmalloc_usable_size #endif static oe_allocation_failure_callback_t _failure_callback; @@ -153,6 +155,11 @@ void* oe_memalign(size_t alignment, size_t size) return p; } +size_t oe_malloc_usable_size(void* ptr) +{ + return MALLOC_USABLE_SIZE(ptr); +} + /* **============================================================================== ** diff --git a/enclave/core/once.c b/enclave/core/once.c index 407d57c47e..901d5150cf 100644 --- a/enclave/core/once.c +++ b/enclave/core/once.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/backtrace.c b/enclave/core/optee/backtrace.c index 520eadcda0..214dd80378 100644 --- a/enclave/core/optee/backtrace.c +++ b/enclave/core/optee/backtrace.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/bounds.c b/enclave/core/optee/bounds.c index 9254341720..3fdbd0be9d 100644 --- a/enclave/core/optee/bounds.c +++ b/enclave/core/optee/bounds.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES diff --git a/enclave/core/optee/calls.c b/enclave/core/optee/calls.c index 72daf2f50b..62364d4220 100644 --- a/enclave/core/optee/calls.c +++ b/enclave/core/optee/calls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/entropy.c b/enclave/core/optee/entropy.c index 174d625fd0..cd233d5d5e 100644 --- a/enclave/core/optee/entropy.c +++ b/enclave/core/optee/entropy.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES @@ -7,12 +7,12 @@ #include -oe_result_t oe_get_entropy(void* output, size_t len) +oe_result_t oe_get_entropy(void* output, size_t len, oe_entropy_kind_t* kind) { if (len > OE_UINT32_MAX) return OE_OUT_OF_BOUNDS; TEE_GenerateRandom(output, (uint32_t)len); - + *kind = OE_ENTROPY_KIND_OPTEE; return OE_OK; } diff --git a/enclave/core/optee/globals.c b/enclave/core/optee/globals.c index 335420d711..14e762750d 100644 --- a/enclave/core/optee/globals.c +++ b/enclave/core/optee/globals.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/gp.c b/enclave/core/optee/gp.c index dbd6f41d6b..1b5e543af8 100644 --- a/enclave/core/optee/gp.c +++ b/enclave/core/optee/gp.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES @@ -469,6 +469,12 @@ TEE_Result TA_InvokeCommandEntryPoint( result = TEE_ERROR_BAD_STATE; break; } + case OE_ECALL_INIT_CONTEXT_SWITCHLESS: + { + /* TODO: initialize switchless calls */ + result = TEE_ERROR_NOT_IMPLEMENTED; + break; + } default: { /* No function found with the number */ diff --git a/enclave/core/optee/header.c b/enclave/core/optee/header.c index b92c410806..b2b18e4959 100644 --- a/enclave/core/optee/header.c +++ b/enclave/core/optee/header.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES diff --git a/enclave/core/optee/hostcalls.c b/enclave/core/optee/hostcalls.c index 9ea093e243..67bc42e0bd 100644 --- a/enclave/core/optee/hostcalls.c +++ b/enclave/core/optee/hostcalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -24,14 +24,14 @@ void oe_free_ocall_buffer(void* buffer) } // TODO -void* oe_reserve_shm(size_t capacity) +void* oe_allocate_arena(size_t capacity) { OE_UNUSED(capacity); return NULL; } // TODO -void oe_unreserve_shm(void* buffer) +void oe_deallocate_arena(void* buffer) { OE_UNUSED(buffer); -} \ No newline at end of file +} diff --git a/enclave/core/optee/keys.c b/enclave/core/optee/keys.c index 93905022c3..ba8d29495b 100644 --- a/enclave/core/optee/keys.c +++ b/enclave/core/optee/keys.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/printf.c b/enclave/core/optee/printf.c index c505f87e37..34471cda02 100644 --- a/enclave/core/optee/printf.c +++ b/enclave/core/optee/printf.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/sched_yield.c b/enclave/core/optee/sched_yield.c index 052bec4326..5591a2bd5a 100644 --- a/enclave/core/optee/sched_yield.c +++ b/enclave/core/optee/sched_yield.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. int oe_sched_yield(void) diff --git a/enclave/core/optee/spinlock.c b/enclave/core/optee/spinlock.c index c4fa8ce484..17559c6d3d 100644 --- a/enclave/core/optee/spinlock.c +++ b/enclave/core/optee/spinlock.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // TODO: This file is a stub! diff --git a/enclave/core/optee/stubs.c b/enclave/core/optee/stubs.c index 99e2f0fd46..264fbcfa56 100644 --- a/enclave/core/optee/stubs.c +++ b/enclave/core/optee/stubs.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/optee/thread.c b/enclave/core/optee/thread.c index 6e057c61ed..e203becf5f 100644 --- a/enclave/core/optee/thread.c +++ b/enclave/core/optee/thread.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // TODO: This file is a stub! diff --git a/enclave/core/optee/tracee.c b/enclave/core/optee/tracee.c index 87fccb2634..d8517297fd 100644 --- a/enclave/core/optee/tracee.c +++ b/enclave/core/optee/tracee.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/printf.c b/enclave/core/printf.c index cd5bbf7984..de2b5be854 100644 --- a/enclave/core/printf.c +++ b/enclave/core/printf.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/pthread.c b/enclave/core/pthread.c index f4f1475f44..19ede7c017 100644 --- a/enclave/core/pthread.c +++ b/enclave/core/pthread.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/result.c b/enclave/core/result.c index ce2d83d42c..90f8b7b785 100644 --- a/enclave/core/result.c +++ b/enclave/core/result.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../common/result.c" diff --git a/enclave/core/sbrk.c b/enclave/core/sbrk.c index dbd4315b26..13b789b95a 100644 --- a/enclave/core/sbrk.c +++ b/enclave/core/sbrk.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/asmcommon.inc b/enclave/core/sgx/asmcommon.inc index 424021c885..c480db63b8 100644 --- a/enclave/core/sgx/asmcommon.inc +++ b/enclave/core/sgx/asmcommon.inc @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _ASM_COMMON_INC diff --git a/enclave/core/sgx/asmdefs.h b/enclave/core/sgx/asmdefs.h index 1f45ba03a6..74c8120ad6 100644 --- a/enclave/core/sgx/asmdefs.h +++ b/enclave/core/sgx/asmdefs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _ASMDEFS_H diff --git a/enclave/core/sgx/backtrace.c b/enclave/core/sgx/backtrace.c index 61aa9e3f4c..7ad417fdc4 100644 --- a/enclave/core/sgx/backtrace.c +++ b/enclave/core/sgx/backtrace.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -141,8 +141,11 @@ char** oe_backtrace_symbols(void* const* buffer, int size) goto done; } - if ((oe_result_t)retval != OE_OK) + if ((oe_result_t)retval != OE_OK || + symbols_buffer_size_out != symbols_buffer_size) + { goto done; + } } else if ((oe_result_t)retval != OE_OK) { diff --git a/enclave/core/sgx/calls.c b/enclave/core/sgx/calls.c index 08eb0e804e..e2f84f3555 100644 --- a/enclave/core/sgx/calls.c +++ b/enclave/core/sgx/calls.c @@ -1,13 +1,15 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../calls.h" +#include #include #include #include #include #include #include +#include #include #include #include @@ -18,10 +20,13 @@ #include #include #include +#include #include +#include "../../../host/sgx/sgxmeasure.h" #include "../../sgx/report.h" +#include "../arena.h" #include "../atexit.h" -#include "../shm.h" +#include "../switchlesscalls.h" #include "asmdefs.h" #include "cpuid.h" #include "init.h" @@ -123,6 +128,57 @@ extern bool oe_disable_debug_malloc_check; **============================================================================== */ +static oe_result_t _oe_check_eeid() +{ + oe_result_t result = OE_OK; + + const oe_eeid_t* eeid = (const oe_eeid_t*)__oe_get_eeid_base(); + const void* enclave_base = __oe_get_enclave_base(); + + if (eeid != enclave_base) + { + oe_sha256_context_t hctx; + oe_sha256_restore(&hctx, eeid->hash_state_H, eeid->hash_state_N); + + size_t eeid_sz = __oe_get_eeid_size(); + size_t num_pages = oe_round_up_to_page_size(eeid_sz) / OE_PAGE_SIZE; + oe_page_t* pages = (oe_page_t*)eeid; + uint64_t addr = (uint64_t)eeid; + for (size_t i = 0; i < num_pages; i++) + { + OE_CHECK(oe_sgx_measure_load_enclave_data( + &hctx, + (uint64_t)enclave_base, + addr, + (uint64_t)&pages[i], + SGX_SECINFO_REG | SGX_SECINFO_R, + true)); + + addr += sizeof(oe_page_t); + } + + OE_SHA256 ext_mrenclave; + oe_sha256_final(&hctx, &ext_mrenclave); + + // char str_old[OE_SHA256_SIZE * 2 + 1], str_new[OE_SHA256_SIZE * 2 + + // 1]; oe_hex_string(str_old, OE_SHA256_SIZE * 2 + 1, + // eeid->sigstruct.enclavehash, OE_SHA256_SIZE); oe_host_printf(" | *** + // OLD: %s\n", str_old); oe_hex_string(str_new, OE_SHA256_SIZE * 2 + 1, + // th.buf, OE_SHA256_SIZE); oe_host_printf(" | *** NEW: %s\n", str_new); + + sgx_report_t sgx_report; + OE_CHECK(sgx_create_report(NULL, 0, NULL, 0, &sgx_report)); + + if (memcmp( + ext_mrenclave.buf, sgx_report.body.mrenclave, OE_SHA256_SIZE) != + 0) + OE_RAISE(OE_VERIFY_FAILED); + } + +done: + return result; +} + /* **============================================================================== ** @@ -169,6 +225,9 @@ static oe_result_t _handle_init_enclave(uint64_t arg_in) * instructions like CPUID. */ oe_call_init_functions(); + /* Check that the EEI data has not been tampered with */ + OE_CHECK(_oe_check_eeid()); + /* DCLP Release barrier. */ OE_ATOMIC_MEMORY_BARRIER_RELEASE(); _once = true; @@ -338,6 +397,19 @@ static void _handle_ecall( uint64_t* output_arg1, uint64_t* output_arg2) { + /* To keep status of td consistent before and after _handle_ecall, td_init + is moved into _handle_ecall. In this way _handle_ecall will not trigger + stack check fail by accident. Of couse not all function have the + opportunity to keep such consistency. Such basic functions are moved to a + separate source file and the stack protector is disabled by force + through fno-stack-protector option. */ + + /* Initialize thread data structure (if not already initialized) */ + if (!td_initialized(td)) + { + td_init(td); + } + oe_result_t result = OE_OK; /* Insert ECALL context onto front of td_t.ecalls list */ @@ -386,8 +458,6 @@ static void _handle_ecall( case OE_ECALL_CALL_ENCLAVE_FUNCTION: { arg_out = _handle_call_enclave_function(arg_in); - /* clear up shared memory upon ERET */ - oe_shm_clear(); break; } case OE_ECALL_DESTRUCTOR: @@ -398,9 +468,6 @@ static void _handle_ecall( /* Call all finalization functions */ oe_call_fini_functions(); - /* Free shared memory upon destroying enclave */ - oe_shm_destroy(); - #if defined(OE_USE_DEBUG_MALLOC) /* If memory still allocated, print a trace and return an error */ @@ -421,6 +488,11 @@ static void _handle_ecall( arg_out = _handle_init_enclave(arg_in); break; } + case OE_ECALL_INIT_CONTEXT_SWITCHLESS: + { + arg_out = oe_handle_init_switchless(arg_in); + break; + } default: { /* No function found with the number */ @@ -431,6 +503,12 @@ static void _handle_ecall( done: + /* Free shared memory arena before we clear TLS */ + if (td->depth == 1) + { + oe_teardown_arena(); + } + /* Remove ECALL context from front of td_t.ecalls list */ td_pop_callsite(td); @@ -566,7 +644,7 @@ oe_result_t oe_call_host_function_by_table_id( OE_RAISE(OE_INVALID_PARAMETER); /* Initialize the arguments */ - args = switchless ? oe_shm_calloc(sizeof(*args)) + args = switchless ? oe_arena_calloc(1, sizeof(*args)) : oe_host_calloc(1, sizeof(*args)); if (args == NULL) @@ -585,9 +663,31 @@ oe_result_t oe_call_host_function_by_table_id( args->result = OE_UNEXPECTED; /* Call the host function with this address */ - // TODO: for switchessless calls, push the job (wrapped in args) to an - // available worker thread, and wait for result - // if (!switchless) + if (switchless && oe_is_switchless_initialized()) + { + oe_result_t post_result = oe_post_switchless_ocall(args); + + // Fall back to regular OCALL if host worker threads are unavailable + if (post_result == OE_CONTEXT_SWITCHLESS_OCALL_MISSED) + OE_CHECK( + oe_ocall(OE_OCALL_CALL_HOST_FUNCTION, (uint64_t)args, NULL)); + else + { + OE_CHECK(post_result); + // Wait until args.result is set by the host worker. + while (true) + { + OE_ATOMIC_MEMORY_BARRIER_ACQUIRE(); + if (__atomic_load_n(&args->result, __ATOMIC_SEQ_CST) != + __OE_RESULT_MAX) + break; + + /* Yield to CPU */ + asm volatile("pause"); + } + } + } + else { OE_CHECK(oe_ocall(OE_OCALL_CALL_HOST_FUNCTION, (uint64_t)args, NULL)); } @@ -635,34 +735,6 @@ oe_result_t oe_call_host_function( false /* non-switchless */); } -/* -**============================================================================== -** -** oe_switchless_call_host_function() -** This is the preferred way to call host functions switchlessly. -** -**============================================================================== -*/ - -oe_result_t oe_switchless_call_host_function( - size_t function_id, - const void* input_buffer, - size_t input_buffer_size, - void* output_buffer, - size_t output_buffer_size, - size_t* output_bytes_written) -{ - return oe_call_host_function_by_table_id( - OE_UINT64_MAX, - function_id, - input_buffer, - input_buffer_size, - output_buffer, - output_buffer_size, - output_bytes_written, - true /* switchless */); -} - /* **============================================================================== ** @@ -696,25 +768,27 @@ oe_result_t oe_switchless_call_host_function( ** used by a thread entering the enclave). Each thread section has the ** following layout: ** -** +--------------------------------+ -** | Guard Page | -** +--------------------------------+ -** | Stack pages | -** +--------------------------------+ -** | Guard Page | -** +--------------------------------+ -** | TCS Page | -** +--------------------------------+ -** | SSA (State Save Area) 0 | -** +--------------------------------+ -** | SSA (State Save Area) 1 | -** +--------------------------------+ -** | Guard Page | -** +--------------------------------+ -** | GS page (contains thread data) | -** +--------------------------------+ -** -** EENTER sets the GS segment register to refer to the GS page before +** +----------------------------+ +** | Guard Page | +** +----------------------------+ +** | Stack pages | +** +----------------------------+ +** | Guard Page | +** +----------------------------+ +** | TCS Page | +** +----------------------------+ +** | SSA (State Save Area) 0 | +** +----------------------------+ +** | SSA (State Save Area) 1 | +** +----------------------------+ +** | Guard Page | +** +----------------------------+ +** | Thread local storage | +** +----------------------------+ +** | FS/GS Page (td_t + tsp) | +** +----------------------------+ +** +** EENTER sets the FS segment register to refer to the FS page before ** calling this function. ** ** If the enclave should fault, SGX saves the registers in the SSA slot @@ -813,10 +887,6 @@ void __oe_handle_main( /* Get pointer to the thread data structure */ td_t* td = td_from_tcs(tcs); - /* Initialize thread data structure (if not already initialized) */ - if (!td_initialized(td)) - td_init(td); - /* If this is a normal (non-exception) entry */ if (cssa == 0) { @@ -900,7 +970,7 @@ void oe_abort(void) } // Free the shared memory pools - oe_shm_destroy(); + oe_teardown_arena(); // Return to the latest ECALL. _handle_exit(OE_CODE_ERET, 0, __oe_enclave_status); diff --git a/enclave/core/sgx/cpuid.c b/enclave/core/sgx/cpuid.c index a0d0a46288..b045759674 100644 --- a/enclave/core/sgx/cpuid.c +++ b/enclave/core/sgx/cpuid.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "cpuid.h" diff --git a/enclave/core/sgx/cpuid.h b/enclave/core/sgx/cpuid.h index 50f9987244..32e0f825ae 100644 --- a/enclave/core/sgx/cpuid.h +++ b/enclave/core/sgx/cpuid.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CPUID_ENCLAVE_H diff --git a/enclave/core/sgx/enter.S b/enclave/core/sgx/enter.S index e071227db7..ca16c5e0dd 100644 --- a/enclave/core/sgx/enter.S +++ b/enclave/core/sgx/enter.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "asmdefs.h" @@ -40,15 +40,15 @@ oe_enter: .save_host_registers: // Backup the current host rbp and rsp to previous. - mov %gs:td_host_rbp, %r8 - mov %r8, %gs:td_host_previous_rbp - mov %gs:td_host_rsp, %r8 - mov %r8, %gs:td_host_previous_rsp + mov %fs:td_host_rbp, %r8 + mov %r8, %fs:td_host_previous_rbp + mov %fs:td_host_rsp, %r8 + mov %r8, %fs:td_host_previous_rsp // Save host registers (restored on EEXIT) - mov %rcx, %gs:td_host_rcx // host return address here - mov %rsp, %gs:td_host_rsp - mov %rbp, %gs:td_host_rbp + mov %rcx, %fs:td_host_rcx // host return address here + mov %rsp, %fs:td_host_rsp + mov %rbp, %fs:td_host_rbp .determine_entry_type: // Check if this is exception dispatching request. @@ -62,7 +62,7 @@ oe_enter: // Check whether this is a clean entry or a nested entry // clean-entry-check. - mov %gs:td_depth, %r8 + mov %fs:td_depth, %r8 cmp $0, %r8 je .clean_entry jmp .nested_entry @@ -99,7 +99,7 @@ oe_enter: lfence // Restore stack pointer and enclave registers: - mov %gs:td_last_sp, %rsp + mov %fs:td_last_sp, %rsp // align the stack and $-16, %rsp @@ -119,10 +119,27 @@ oe_enter: mov %rsp, %rbp .call_function: + // Set the MXCSR according to the Linux x86_64 ABI + mov $ABI_MXCSR_INIT, %r10 + push %r10 + ldmxcsr (%rsp) + pop %r10 + + // Set the FPU Control Word according to the Linux x86_64 ABI + mov $ABI_FPUCW_INIT, %r10 + push %r10 + fldcw (%rsp) + pop %r10 + + // Initialize the RFLAGS prior to calling enclave functions + // This only clears the DF and state flag bits since + // the system flags and reserved bits are not writable here + push $0 + popfq // Get the host stack pointer. - mov %gs:td_host_rsp, %r8 - mov %gs:td_host_rbp, %r9 + mov %fs:td_host_rsp, %r8 + mov %fs:td_host_rbp, %r9 // Construct the frame and align the stack. pushq $0 @@ -145,13 +162,13 @@ oe_enter: sub $OM_STACK_LENGTH, %rsp // Save the host stack pointers to enclave stack. - mov %gs:td_host_rsp, %r8 - mov %gs:td_host_rbp, %r9 + mov %fs:td_host_rsp, %r8 + mov %fs:td_host_rbp, %r9 mov %r8, OM_HOST_RSP mov %r9, OM_HOST_RBP // Save the host return address to enclave stack. - mov %gs:td_host_rcx, %r8 + mov %fs:td_host_rcx, %r8 mov %r8, OM_HOST_RETURN_ADDR // Call __oe_handle_main(ARG1=RDI, ARG2=RSI, CSSA=RDX, TCS=RCX, OUTPUTARG1=R8, OUTPUTARG2=R9) @@ -169,7 +186,7 @@ oe_enter: // Check the depth of the ECALL stack (zero for clean exit) // exit-type-check. - mov %gs:td_depth, %r8 + mov %fs:td_depth, %r8 cmp $0, %r8 je .clean_exit @@ -201,7 +218,7 @@ oe_enter: pop %r12 pop %r12 - mov %rsp, %gs:td_last_sp + mov %rsp, %fs:td_last_sp jmp .clear_enclave_registers @@ -211,7 +228,7 @@ oe_enter: lfence // Clear the td_t.last_sp field (force oe_enter to calculate stack pointer) - movq $0, %gs:td_last_sp + movq $0, %fs:td_last_sp .clear_enclave_registers: @@ -229,7 +246,7 @@ oe_enter: // Check td_t.simulate flag // simulation-flag-check. - mov %gs:td_simulate, %rax + mov %fs:td_simulate, %rax cmp $0, %rax jz .execute_eexit_instruction diff --git a/enclave/core/sgx/entropy.c b/enclave/core/sgx/entropy.c index b526bf872d..0500efde04 100644 --- a/enclave/core/sgx/entropy.c +++ b/enclave/core/sgx/entropy.c @@ -1,48 +1,86 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. -#include +#include #include #include +#include #include +#include +#include "cpuid.h" -/* TODO: This should use RDSEED instead. See issue #242. */ -oe_result_t oe_get_entropy(void* output, size_t len) +typedef uint64_t (*_entropy_function_t)(void); + +OE_INLINE bool _has_cpuid_feature( + uint32_t leaf, + uint32_t feature, + uint32_t feature_register) { - oe_result_t ret = OE_UNEXPECTED; - unsigned char* p = (unsigned char*)output; + oe_assert(feature_register < OE_CPUID_REG_COUNT); + uint64_t r[OE_CPUID_REG_COUNT] = {0}; + r[OE_CPUID_RAX] = leaf; + return ( + (oe_emulate_cpuid( + &r[OE_CPUID_RAX], + &r[OE_CPUID_RBX], + &r[OE_CPUID_RCX], + &r[OE_CPUID_RDX]) == 0) && + (r[feature_register] & feature)); +} - if (!output) - goto done; +static oe_entropy_kind_t _get_entropy_kind() +{ + oe_entropy_kind_t result = OE_ENTROPY_KIND_NONE; - /* Copy 64-bit random integers to output */ - { - size_t n = len / sizeof(uint64_t); + /* The ordering of checks is important: we want the presence of + * stronger entropy sources to supersede the weaker ones, so + * go from least to most preferred sources. + */ + if (_has_cpuid_feature(1, OE_CPUID_RDRAND_FEATURE, OE_CPUID_RCX)) + result = OE_ENTROPY_KIND_RDRAND; - while (n--) - { - uint64_t x = oe_rdrand(); + if (_has_cpuid_feature(7, OE_CPUID_RDSEED_FEATURE, OE_CPUID_RBX)) + result = OE_ENTROPY_KIND_RDSEED; - if (oe_memcpy_s(p, len, &x, sizeof(uint64_t)) != OE_OK) - goto done; + return result; +} - p += sizeof(uint64_t); - len -= sizeof(uint64_t); - } - } +oe_result_t oe_get_entropy(void* output, size_t len, oe_entropy_kind_t* kind) +{ + oe_result_t result = OE_UNEXPECTED; + _entropy_function_t get_entropy = NULL; + unsigned char* p = (unsigned char*)output; + size_t bytes_left = len; - /* Copy remaining random bytes to output */ - { - size_t r = len % sizeof(uint64_t); - uint64_t x = oe_rdrand(); - const unsigned char* q = (const unsigned char*)&x; + if (kind) + *kind = OE_ENTROPY_KIND_NONE; + + if (output) + memset(output, 0, len); - if (oe_memcpy_s(p, len, q, r) != OE_OK) - goto done; + if (!output || !kind) + OE_RAISE(OE_INVALID_PARAMETER); + + *kind = _get_entropy_kind(); + if (*kind == OE_ENTROPY_KIND_RDSEED) + get_entropy = oe_rdseed; + else if (*kind == OE_ENTROPY_KIND_RDRAND) + get_entropy = oe_rdrand; + else + OE_RAISE(OE_UNSUPPORTED); + + while (bytes_left > 0) + { + uint64_t random = get_entropy(); + size_t copy_size = + (sizeof(random) > bytes_left) ? bytes_left : sizeof(random); + memcpy(p, &random, copy_size); + p += copy_size; + bytes_left -= copy_size; } - ret = OE_OK; + result = OE_OK; done: - return ret; + return result; } diff --git a/enclave/core/sgx/exception.c b/enclave/core/sgx/exception.c index 052175139a..9ad5c09dcf 100644 --- a/enclave/core/sgx/exception.c +++ b/enclave/core/sgx/exception.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/exit.S b/enclave/core/sgx/exit.S index 1564f2c133..9aed5372bf 100644 --- a/enclave/core/sgx/exit.S +++ b/enclave/core/sgx/exit.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "asmdefs.h" @@ -55,7 +55,7 @@ oe_asm_exit: // Check the depth of the ECALL stack (zero for clean exit) // exit-type-check. - mov %gs:td_depth, %r8 + mov %fs:td_depth, %r8 cmp $0, %r8 je .clean_exit @@ -89,7 +89,7 @@ oe_asm_exit: pop %rsi pop %rdi - mov %rsp, %gs:td_last_sp + mov %rsp, %fs:td_last_sp jmp .clear_enclave_registers @@ -99,7 +99,7 @@ oe_asm_exit: lfence // Clear the td_t.last_sp field (force oe_enter to calculate stack pointer) - movq $0, %gs:td_last_sp + movq $0, %fs:td_last_sp .clear_enclave_registers: @@ -108,15 +108,15 @@ oe_asm_exit: .restore_host_registers: - mov %gs:td_host_rcx, %rcx - mov %gs:td_host_rsp, %rsp - mov %gs:td_host_rbp, %rbp + mov %fs:td_host_rcx, %rcx + mov %fs:td_host_rsp, %rsp + mov %fs:td_host_rbp, %rbp .execute_eexit: // Check td_t.simulate flag // simulate-flag-check. - mov %gs:td_simulate, %rax + mov %fs:td_simulate, %rax cmp $0, %rax jz .execute_eexit_instruction diff --git a/enclave/core/sgx/getkey.S b/enclave/core/sgx/getkey.S index 478e8a31ee..c70be6fe3f 100644 --- a/enclave/core/sgx/getkey.S +++ b/enclave/core/sgx/getkey.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "asmdefs.h" diff --git a/enclave/core/sgx/globals.c b/enclave/core/sgx/globals.c index a286398c67..e70c3dfbc6 100644 --- a/enclave/core/sgx/globals.c +++ b/enclave/core/sgx/globals.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -127,6 +127,8 @@ extern volatile const oe_sgx_enclave_properties_t oe_enclave_properties_sgx; static volatile uint64_t _enclave_rva; static volatile uint64_t _reloc_rva; static volatile uint64_t _reloc_size; +static volatile uint64_t _eeid_rva; +static volatile uint64_t _eeid_size; #endif @@ -196,6 +198,39 @@ size_t __oe_get_reloc_size() #endif } +/* +**============================================================================== +** +** Extended enclave initialization data boundaries: +** +**============================================================================== +*/ + +const void* __oe_get_eeid_base() +{ + const unsigned char* base = __oe_get_enclave_base(); + +#if defined(__linux__) + return base + _eeid_rva; +#else +#error "unsupported" +#endif +} + +uint64_t __oe_get_eeid_size() +{ +#if defined(__linux__) + return _eeid_size; +#else +#error "unsupported" +#endif +} + +const void* __oe_get_eeid_end() +{ + return (const uint8_t*)__oe_get_eeid_base() + __oe_get_eeid_size(); +} + /* **============================================================================== ** diff --git a/enclave/core/sgx/hostcalls.c b/enclave/core/sgx/hostcalls.c index 260fdfc2fc..3581d4eb75 100644 --- a/enclave/core/sgx/hostcalls.c +++ b/enclave/core/sgx/hostcalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -18,12 +18,12 @@ void oe_free_ocall_buffer(void* buffer) oe_host_free(buffer); } -void* oe_reserve_shm(size_t capacity) +void* oe_allocate_arena(size_t capacity) { return oe_host_malloc(capacity); } -void oe_unreserve_shm(void* buffer) +void oe_deallocate_arena(void* buffer) { oe_host_free(buffer); -} \ No newline at end of file +} diff --git a/enclave/core/sgx/init.c b/enclave/core/sgx/init.c index c6f539b1ec..831acce8a8 100644 --- a/enclave/core/sgx/init.c +++ b/enclave/core/sgx/init.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "init.h" diff --git a/enclave/core/sgx/init.h b/enclave/core/sgx/init.h index b7359c5870..5b05a9ba1a 100644 --- a/enclave/core/sgx/init.h +++ b/enclave/core/sgx/init.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_INIT_H diff --git a/enclave/core/sgx/jump.c b/enclave/core/sgx/jump.c deleted file mode 100644 index 1e5c203a91..0000000000 --- a/enclave/core/sgx/jump.c +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include -#include - -OE_CHECK_SIZE(sizeof(oe_jmpbuf_t), 64); - -/* - * This file must be compiled with optimization enabled because the code - * relies on the precise layout of the stack (and thereby preamble) to obtain - * the correct rsp and rip. - * - * Really, this should go into a separate .s-file to ensure correct register - * access. - */ - -int oe_setjmp(oe_jmpbuf_t* env) -{ - asm volatile( - /* Save RBX */ - "mov %%rbx, %0;" - /* Save RBP */ - "mov %%rbp, %1;" - /* Save R12 */ - "mov %%r12, %2;" - /* Save R13 */ - "mov %%r13, %3;" - /* Save R14 */ - "mov %%r14, %4;" - /* Save R15 */ - "mov %%r15, %5;" - /* Save stack pointer */ - "lea 8(%%rsp), %6;" - /* Save instruction pointer */ - "mov (%%rsp), %7;" - : "=m"(env->rbx), - "=m"(env->rbp), - "=m"(env->r12), - "=m"(env->r13), - "=m"(env->r14), - "=m"(env->r15), - "=r"(env->rsp), - "=r"(env->rip)); - - return 0; -} - -void oe_longjmp(oe_jmpbuf_t* env, int val) -{ - if (val == 0) - val = 1; - - asm volatile( - /* Restore RBX */ - "mov %1, %%rbx;" - /* Restore RBP*/ - "mov %2, %%rbp;" - /* Restore R12 */ - "mov %3, %%r12;" - /* Restore R13 */ - "mov %4, %%r13;" - /* Restore R14 */ - "mov %5, %%r14;" - /* Restore R15 */ - "mov %6, %%r15;" - /* Restore stack pointer */ - "mov %7, %%rsp;" - /* Fetch and jump to instruction pointer */ - "jmp *%8;" - : - : "a"(val), - "m"(env->rbx), - "m"(env->rbp), - "m"(env->r12), - "m"(env->r13), - "m"(env->r14), - "m"(env->r15), - "m"(env->rsp), - "d"(env->rip)); -} diff --git a/enclave/core/sgx/keys.c b/enclave/core/sgx/keys.c index dded12bb19..8fa6e5868f 100644 --- a/enclave/core/sgx/keys.c +++ b/enclave/core/sgx/keys.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/linux/reloc.c b/enclave/core/sgx/linux/reloc.c index 67c8690198..f4c92be386 100644 --- a/enclave/core/sgx/linux/reloc.c +++ b/enclave/core/sgx/linux/reloc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/linux/threadlocal.c b/enclave/core/sgx/linux/threadlocal.c index 26ff377835..e8db3cbb6e 100644 --- a/enclave/core/sgx/linux/threadlocal.c +++ b/enclave/core/sgx/linux/threadlocal.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "threadlocal.h" @@ -204,16 +204,15 @@ static volatile bool _thread_locals_relocated = false; static __thread oe_tls_atexit_t* _tls_atexit_functions; static __thread uint64_t _num_tls_atexit_functions; -/** - * Get the address of the FS segment given a thread data object. - * Currently FS is assumed to exist one page after the thread data. - * This needs to be made more flexible, taking into account the - * actual size of the tls data. - */ +// TODO: Make this flexible in case more than one page of thread local storage +// need to allocate. + +/* The thread data (td) object is always populated at the start of the + FS segment, so this method just returns the address of the td. +*/ static uint8_t* _get_fs_from_td(td_t* td) { - // TODO: Make this flexible - uint8_t* fs = (uint8_t*)td + 1 * OE_PAGE_SIZE; + uint8_t* fs = (uint8_t*)td; return fs; } diff --git a/enclave/core/sgx/linux/threadlocal.h b/enclave/core/sgx/linux/threadlocal.h index 64db7a4753..9da66382cd 100644 --- a/enclave/core/sgx/linux/threadlocal.h +++ b/enclave/core/sgx/linux/threadlocal.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CORE_THREADLOCAL_H diff --git a/enclave/core/sgx/longjmp.S b/enclave/core/sgx/longjmp.S index 7a36bb445d..bdd35c2217 100644 --- a/enclave/core/sgx/longjmp.S +++ b/enclave/core/sgx/longjmp.S @@ -1,9 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. //============================================================================== // -// void oe_longjmp(oe_jmp_buf env, int val) +// void oe_longjmp(oe_jmp_buf* env, int val) // // Implementation of standard longjmp() function. // @@ -12,7 +12,7 @@ // //============================================================================== -/* ATTN: WINPORT */ +// Modified from musl-libc root/src/setjmp/x86_64/longjmp.s .globl oe_longjmp .type oe_longjmp, @function @@ -22,16 +22,15 @@ oe_longjmp: // if (val == 0) then set val to 1. cmp $0, %rax jne val_is_nonzero - mov $1, %rax + mov $1, %rax # Return value (int) + val_is_nonzero: - mov (%rdi), %rbx - mov 8(%rdi), %rbp - mov 16(%rdi), %r12 - mov 24(%rdi), %r13 - mov 32(%rdi), %r14 - mov 40(%rdi), %r15 - mov 48(%rdi), %rdx - mov %rdx, %rsp - mov 56(%rdi), %rdx - jmp *%rdx + mov (%rdi),%rsp + mov 8(%rdi),%rbp + mov 24(%rdi),%rbx + mov 32(%rdi),%r12 + mov 40(%rdi),%r13 + mov 48(%rdi),%r14 + mov 56(%rdi),%r15 + jmp *16(%rdi) .cfi_endproc diff --git a/enclave/core/sgx/memory.c b/enclave/core/sgx/memory.c index 812af23119..f941d02ab4 100644 --- a/enclave/core/sgx/memory.c +++ b/enclave/core/sgx/memory.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/properties.c b/enclave/core/sgx/properties.c index af545e01fe..af42878651 100644 --- a/enclave/core/sgx/properties.c +++ b/enclave/core/sgx/properties.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/report.c b/enclave/core/sgx/report.c index b9c7c10467..82723cabb1 100644 --- a/enclave/core/sgx/report.c +++ b/enclave/core/sgx/report.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "report.h" @@ -302,9 +302,10 @@ oe_result_t oe_get_report_v2( uint8_t** report_buffer, size_t* report_buffer_size) { - oe_result_t result; + oe_result_t result = OE_UNEXPECTED; uint8_t* tmp_buffer = NULL; size_t tmp_buffer_size = 0; + size_t out_buffer_size = 0; if ((report_buffer == NULL) || (report_buffer_size == NULL)) { @@ -324,7 +325,8 @@ oe_result_t oe_get_report_v2( &tmp_buffer_size); if (result != OE_BUFFER_TOO_SMALL) { - return result; + result = (result == OE_OK) ? OE_UNEXPECTED : result; + OE_RAISE(result); } tmp_buffer = oe_calloc(1, tmp_buffer_size); @@ -333,24 +335,30 @@ oe_result_t oe_get_report_v2( return OE_OUT_OF_MEMORY; } - result = _oe_get_report_internal( + out_buffer_size = tmp_buffer_size; + OE_CHECK(_oe_get_report_internal( flags, report_data, report_data_size, opt_params, opt_params_size, tmp_buffer, - &tmp_buffer_size); - if (result != OE_OK) - { - oe_free(tmp_buffer); - return result; - } + &out_buffer_size)); + + if (out_buffer_size != tmp_buffer_size) + OE_RAISE(OE_UNEXPECTED); - *report_buffer = tmp_buffer; *report_buffer_size = tmp_buffer_size; + *report_buffer = tmp_buffer; + tmp_buffer = NULL; + + result = OE_OK; - return OE_OK; +done: + if (tmp_buffer) + oe_free(tmp_buffer); + + return result; } void oe_free_report(uint8_t* report_buffer) diff --git a/enclave/core/sgx/report.h b/enclave/core/sgx/report.h index 0a2b297de7..e9886449ea 100644 --- a/enclave/core/sgx/report.h +++ b/enclave/core/sgx/report.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_CORE_REPORT_H diff --git a/enclave/core/sgx/sched_yield.c b/enclave/core/sgx/sched_yield.c index 8e279cd456..c9e5845425 100644 --- a/enclave/core/sgx/sched_yield.c +++ b/enclave/core/sgx/sched_yield.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. int oe_sched_yield(void) diff --git a/enclave/core/sgx/setjmp.S b/enclave/core/sgx/setjmp.S index fb430017b9..24574a673c 100644 --- a/enclave/core/sgx/setjmp.S +++ b/enclave/core/sgx/setjmp.S @@ -1,9 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. //============================================================================== // -// void oe_setjmp(oe_jmp_buf env) +// void oe_setjmp(oe_jmp_buf* env) // // Implementation of standard setjmp() function. // @@ -11,22 +11,22 @@ // //============================================================================== -/* ATTN: WINPORT */ +// Modified from musl-libc root/src/setjmp/x86_64/setjmp.s .globl oe_setjmp .type oe_setjmp,@function oe_setjmp: .cfi_startproc - mov %rbx, (%rdi) - mov %rbp, 8(%rdi) - mov %r12, 16(%rdi) - mov %r13, 24(%rdi) - mov %r14, 32(%rdi) - mov %r15, 40(%rdi) - lea 8(%rsp), %rdx - mov %rdx, 48(%rdi) - mov (%rsp), %rdx - mov %rdx, 56(%rdi) - xor %rax, %rax + lea 8(%rsp), %rdx # this is our rsp WITHOUT current ret addr + mov %rdx, (%rdi) + mov %rbp, 8(%rdi) + mov (%rsp), %rdx # save return addr ptr for new rip + mov %rdx, 16(%rdi) + mov %rbx, 24(%rdi) + mov %r12, 32(%rdi) + mov %r13, 40(%rdi) + mov %r14, 48(%rdi) + mov %r15, 56(%rdi) + xorl %eax, %eax # Set return value ret .cfi_endproc diff --git a/enclave/core/sgx/sgx_t_wrapper.c b/enclave/core/sgx/sgx_t_wrapper.c index c75c42a1dc..e2fa8701ab 100644 --- a/enclave/core/sgx/sgx_t_wrapper.c +++ b/enclave/core/sgx/sgx_t_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES diff --git a/enclave/core/sgx/spinlock.c b/enclave/core/sgx/spinlock.c index 591b97fd9e..3bb7a652ed 100644 --- a/enclave/core/sgx/spinlock.c +++ b/enclave/core/sgx/spinlock.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef OE_BUILD_ENCLAVE diff --git a/enclave/core/sgx/td.c b/enclave/core/sgx/td.c index 318e1192b0..2230ffaf7f 100644 --- a/enclave/core/sgx/td.c +++ b/enclave/core/sgx/td.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "td.h" @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include "asmdefs.h" @@ -17,7 +18,7 @@ #include "linux/threadlocal.h" #endif -#define TD_FROM_TCS (4 * OE_PAGE_SIZE) +#define TD_FROM_TCS (5 * OE_PAGE_SIZE) OE_STATIC_ASSERT(OE_OFFSETOF(td_t, magic) == td_magic); OE_STATIC_ASSERT(OE_OFFSETOF(td_t, depth) == td_depth); @@ -36,7 +37,7 @@ OE_STATIC_ASSERT(OE_OFFSETOF(td_t, simulate) == td_simulate); #if defined(__linux__) OE_STATIC_ASSERT(td_callsites == 0xf0); OE_STATIC_ASSERT(OE_OFFSETOF(Callsite, ocall_context) == 0x40); -OE_STATIC_ASSERT(TD_FROM_TCS == 0x4000); +OE_STATIC_ASSERT(TD_FROM_TCS == 0x5000); OE_STATIC_ASSERT(sizeof(oe_ocall_context_t) == (2 * sizeof(uintptr_t))); #endif @@ -80,41 +81,19 @@ void td_push_callsite(td_t* td, Callsite* callsite) /* **============================================================================== ** -** td_pop_callsite() -** -** Remove the Callsite structure that is at the head of the -** td_t.callsites list. -** -**============================================================================== -*/ - -void td_pop_callsite(td_t* td) -{ - if (!td->callsites) - oe_abort(); - - if (td->depth == 1) - { - // The outermost ecall is about to return. - // Clear the thread-local storage. - td_clear(td); - } - else - { - // Nested ecall returning. - td->callsites = td->callsites->next; - --td->depth; - } -} - -/* -**============================================================================== +** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +** According to the implementation of Windows debugger and the previous +** design of this structure, the debugger need the GS segment register +** to find td_t. Since td_t is moved to current FS page, now GS segment +** register needs to point to this page. Do not change the GS segment +** resigter until it is solved on Windows debugger. +** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ** ** td_from_tcs() ** ** This function calculates the address of the td_t (thread data structure) ** relative to the TCS (Thread Control Structure) page. The td_t resides in -** a page pointed to by the GS (segment register). This page occurs 4 pages +** a page pointed to by the FS (segment register). This page occurs 5 pages ** after the TCS page. The layout is as follows: ** ** +----------------------------+ @@ -126,14 +105,16 @@ void td_pop_callsite(td_t* td) ** +----------------------------+ ** | Guard Page | ** +----------------------------+ -** | GS Segment (contains td_t) | +** | Thread local storage | +** +----------------------------+ +** | FS/GS Page (td_t + tsp) | ** +----------------------------+ ** ** This layout is determined by the enclave builder. See: ** -** ../host/build.c (_add_control_pages) +** ../host/sgx/create.c (_add_control_pages) ** -** The GS segment register is set by the EENTER instruction and the td_t +** The FS segment register is set by the EENTER instruction and the td_t ** page is zero filled upon initial enclave entry. Software sets the ** contents of the td_t when it first determines that td_t.self_addr is ** zero. @@ -158,7 +139,7 @@ td_t* td_from_tcs(void* tcs) void* td_to_tcs(const td_t* td) { - return (uint8_t*)td - (4 * OE_PAGE_SIZE); + return (uint8_t*)td - TD_FROM_TCS; } /* @@ -179,7 +160,7 @@ td_t* oe_get_td() { td_t* td; - asm("mov %%gs:0, %0" : "=r"(td)); + asm("mov %%fs:0, %0" : "=r"(td)); return td; } @@ -206,107 +187,3 @@ bool td_initialized(td_t* td) return false; } - -/* -**============================================================================== -** -** td_init() -** -** Initialize the thread data structure (td_t) if not already initialized. -** The td_t resides in the GS segment and is located relative to the TCS. -** Refer to the following layout. -** -** +-------------------------+ -** | Guard Page | -** +-------------------------+ -** | Stack pages | -** +-------------------------+ -** | Guard Page | -** +-------------------------+ -** | TCS Page | -** +-------------------------+ -** | SSA (State Save Area) 0 | -** +-------------------------+ -** | SSA (State Save Area) 1 | -** +-------------------------+ -** | Guard Page | -** +-------------------------+ -** | GS page (contains td_t) | -** +-------------------------+ -** -** Note: the host register fields are pre-initialized by oe_enter: -** -**============================================================================== -*/ - -void td_init(td_t* td) -{ - /* If not already initialized */ - if (!td_initialized(td)) - { - // td_t.hostsp, td_t.hostbp, and td_t.retaddr already set by - // oe_enter(). - - /* Clear base structure */ - memset(&td->base, 0, sizeof(td->base)); - - /* Set pointer to self */ - td->base.self_addr = (uint64_t)td; - - /* Set the magic number */ - td->magic = TD_MAGIC; - - /* Set the ECALL depth to zero */ - td->depth = 0; - - /* List of callsites is initially empty */ - td->callsites = NULL; - -#if __linux__ - oe_thread_local_init(td); -#endif - } -} - -/* -**============================================================================== -** -** td_clear() -** -** Clear the td_t. This is called when the ECALL depth falls to zero -** in td_pop_callsite(). -** -**============================================================================== -*/ - -void td_clear(td_t* td) -{ - if (td->depth != 1) - oe_abort(); - - // Release any pthread thread-local storage created using - // pthread_create_key. - oe_thread_destruct_specific(); - -#if __linux__ - oe_thread_local_cleanup(td); -#endif - - // The call sites and depth are cleaned up after the thread-local storage is - // cleaned up since thread-local dynamic destructors could make ocalls. - // For such ocalls to work depth and callsites must be cleaned up here. - td->callsites = td->callsites->next; - --td->depth; - - /* Sanity checks */ - if (td->depth != 0 || td->callsites != NULL) - oe_abort(); - - /* Clear base structure */ - memset(&td->base, 0, sizeof(td->base)); - - /* Clear the magic number */ - td->magic = 0; - - /* Never clear td_t.initialized nor host registers */ -} diff --git a/enclave/core/sgx/td.h b/enclave/core/sgx/td.h index ec266c6ba9..0e57a1d289 100644 --- a/enclave/core/sgx/td.h +++ b/enclave/core/sgx/td.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _TD_H @@ -54,26 +54,40 @@ struct _callsite Callsite* next; }; +/* Some basic td function do not have the opportunity to keep consistency of + td then may trigger stack check fail. Such functions are moved to a separate + source file td_basic.c and the stack guard protector is disabled by force + through fno-stack-protector option. +*/ + /* **============================================================================== ** -** td_t methods: +** td_t methods defined in td.c ** **============================================================================== */ void td_push_callsite(td_t* td, Callsite* ec); -void td_pop_callsite(td_t* td); - td_t* td_from_tcs(void* tcs); void* td_to_tcs(const td_t* td); +bool td_initialized(td_t* td); + +/* +**============================================================================== +** +** td_t methods defined in td_basic.c +** +**============================================================================== +*/ + +void td_pop_callsite(td_t* td); + void td_init(td_t* td); void td_clear(td_t* td); -bool td_initialized(td_t* td); - #endif /* _TD_H */ diff --git a/enclave/core/sgx/td_basic.c b/enclave/core/sgx/td_basic.c new file mode 100644 index 0000000000..eae5e593c5 --- /dev/null +++ b/enclave/core/sgx/td_basic.c @@ -0,0 +1,161 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "asmdefs.h" +#include "td.h" +#include "thread.h" + +#if __linux__ +#include "linux/threadlocal.h" +#endif + +/* +**============================================================================== +** +** td_pop_callsite() +** +** Remove the Callsite structure that is at the head of the +** td_t.callsites list. +** +**============================================================================== +*/ + +void td_pop_callsite(td_t* td) +{ + if (!td->callsites) + oe_abort(); + + if (td->depth == 1) + { + // The outermost ecall is about to return. + // Clear the thread-local storage. + td_clear(td); + } + else + { + // Nested ecall returning. + td->callsites = td->callsites->next; + --td->depth; + } +} + +/* +**============================================================================== +** +** td_init() +** +** Initialize the thread data structure (td_t) if not already initialized. +** The td_t resides in the FS segment and is located relative to the TCS. +** Refer to the following layout. +** +** +----------------------------+ +** | Guard Page | +** +----------------------------+ +** | Stack pages | +** +----------------------------+ +** | Guard Page | +** +----------------------------+ +** | TCS Page | +** +----------------------------+ +** | SSA (State Save Area) 0 | +** +----------------------------+ +** | SSA (State Save Area) 1 | +** +----------------------------+ +** | Guard Page | +** +----------------------------+ +** | Thread local storage | +** +----------------------------+ +** | FS/GS Page (td_t + tsp) | +** +----------------------------+ +** +** Note: the host register fields are pre-initialized by oe_enter: +** +**============================================================================== +*/ + +void td_init(td_t* td) +{ + /* If not already initialized */ + if (!td_initialized(td)) + { + // td_t.hostsp, td_t.hostbp, and td_t.retaddr already set by + // oe_enter(). + + /* Clear base structure */ + memset(&td->base, 0, sizeof(td->base)); + + /* Set pointer to self */ + td->base.self_addr = (uint64_t)td; + + /* initialize the stack_guard at %%fs:0x28 with a random number. + oe_rdrand is a warpper of rdrand. rdrand is a hardware-implemented + Pseudo Random Generator, and it is repeatedly seeeded by a high entropy + source. */ + td->base.stack_guard = oe_rdrand(); + + /* Set the magic number */ + td->magic = TD_MAGIC; + + /* Set the ECALL depth to zero */ + td->depth = 0; + + /* List of callsites is initially empty */ + td->callsites = NULL; + +#if __linux__ + oe_thread_local_init(td); +#endif + } +} + +/* +**============================================================================== +** +** td_clear() +** +** Clear the td_t. This is called when the ECALL depth falls to zero +** in td_pop_callsite(). +** +**============================================================================== +*/ + +void td_clear(td_t* td) +{ + if (td->depth != 1) + oe_abort(); + + // Release any pthread thread-local storage created using + // pthread_create_key. + oe_thread_destruct_specific(); + +#if __linux__ + oe_thread_local_cleanup(td); +#endif + + // The call sites and depth are cleaned up after the thread-local storage is + // cleaned up since thread-local dynamic destructors could make ocalls. + // For such ocalls to work depth and callsites must be cleaned up here. + td->callsites = td->callsites->next; + --td->depth; + + /* Sanity checks */ + if (td->depth != 0 || td->callsites != NULL) + oe_abort(); + + /* Clear base structure */ + memset(&td->base, 0, sizeof(td->base)); + + /* Clear the magic number */ + td->magic = 0; + + /* Never clear td_t.initialized nor host registers */ +} diff --git a/enclave/core/sgx/thread.c b/enclave/core/sgx/thread.c index bf28f545d6..4593b33aad 100644 --- a/enclave/core/sgx/thread.c +++ b/enclave/core/sgx/thread.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "thread.h" @@ -793,7 +793,13 @@ oe_result_t oe_rwlock_unlock(oe_rwlock_t* read_write_lock) **============================================================================== */ -#define MAX_KEYS (OE_PAGE_SIZE / sizeof(void*)) +// We use the FS segment as both the start of the enclave thread data and the +// user thread-specific data (TSD) space. To prevent TSD from overwriting the +// enclave thread data, we reserve the first pthread_key indices up to +// MIN_THREAD_KEY_INDEX so that they are not used by oe_thread_key_create. +#define MIN_THREAD_KEY_INDEX \ + ((sizeof(td_t) - OE_THREAD_SPECIFIC_DATA_SIZE) / sizeof(void*)) +#define MAX_THREAD_KEY_INDEX (OE_PAGE_SIZE / sizeof(void*)) typedef struct _key_slot { @@ -801,7 +807,7 @@ typedef struct _key_slot void (*destructor)(void* value); } KeySlot; -static KeySlot _slots[MAX_KEYS]; +static KeySlot _slots[MAX_THREAD_KEY_INDEX]; static oe_spinlock_t _lock = OE_SPINLOCK_INITIALIZER; static void** _get_tsd_page(void) @@ -811,7 +817,7 @@ static void** _get_tsd_page(void) if (!td) return NULL; - return (void**)((unsigned char*)td + OE_PAGE_SIZE); + return (void**)td; } oe_result_t oe_thread_key_create( @@ -827,7 +833,8 @@ oe_result_t oe_thread_key_create( { oe_spin_lock(&_lock); - for (unsigned int i = 1; i < MAX_KEYS; i++) + for (unsigned int i = MIN_THREAD_KEY_INDEX; i < MAX_THREAD_KEY_INDEX; + i++) { /* If this key is available */ if (!_slots[i].used) @@ -853,7 +860,7 @@ oe_result_t oe_thread_key_create( oe_result_t oe_thread_key_delete(oe_thread_key_t key) { /* If key parameter is invalid */ - if (key == 0 || key >= MAX_KEYS) + if (key < MIN_THREAD_KEY_INDEX || key >= MAX_THREAD_KEY_INDEX) return OE_INVALID_PARAMETER; /* Mark this key as unused */ @@ -875,7 +882,7 @@ oe_result_t oe_thread_setspecific(oe_thread_key_t key, const void* value) void** tsd_page; /* If key parameter is invalid */ - if (key == 0 || key >= MAX_KEYS) + if (key < MIN_THREAD_KEY_INDEX || key >= MAX_THREAD_KEY_INDEX) return OE_INVALID_PARAMETER; if (!(tsd_page = _get_tsd_page())) @@ -890,7 +897,7 @@ void* oe_thread_getspecific(oe_thread_key_t key) { void** tsd_page; - if (key == 0 || key >= MAX_KEYS) + if (key < MIN_THREAD_KEY_INDEX || key >= MAX_THREAD_KEY_INDEX) return NULL; if (!(tsd_page = _get_tsd_page())) @@ -909,7 +916,9 @@ void oe_thread_destruct_specific(void) oe_spin_lock(&_lock); { /* For each thread-specific-data key */ - for (oe_thread_key_t key = 1; key < MAX_KEYS; key++) + for (oe_thread_key_t key = MIN_THREAD_KEY_INDEX; + key < MAX_THREAD_KEY_INDEX; + key++) { /* If this key is in use: */ if (_slots[key].used) diff --git a/enclave/core/sgx/thread.h b/enclave/core/sgx/thread.h index bd21be06b1..3d99e6c012 100644 --- a/enclave/core/sgx/thread.h +++ b/enclave/core/sgx/thread.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CORE_THREAD_H_H diff --git a/enclave/core/sgx/tracee.c b/enclave/core/sgx/tracee.c index 82127943fe..12011c60ca 100644 --- a/enclave/core/sgx/tracee.c +++ b/enclave/core/sgx/tracee.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/sgx/windows/reloc.c b/enclave/core/sgx/windows/reloc.c index 43513500af..bd770f71eb 100644 --- a/enclave/core/sgx/windows/reloc.c +++ b/enclave/core/sgx/windows/reloc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/shm.c b/enclave/core/shm.c deleted file mode 100644 index 024c76454e..0000000000 --- a/enclave/core/shm.c +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "shm.h" -#include -#include -#include -#include -#include - -#define ALIGNMENT sizeof(uint64_t) - -// the per-thread shared memory pool -__thread Shared_memory_pool shm = {0}; - -// the global list of shared memory pools -Shared_memory_pool* _shm_list = NULL; - -static oe_spinlock_t _shm_list_lock = OE_SPINLOCK_INITIALIZER; - -// default shared memory pool capacity is 1 mb -size_t capacity = 1024 * 1024; - -size_t max_capacity = 1 << 30; - -void* oe_reserve_shm(size_t capacity); -void oe_unreserve_shm(void* buffer); - -bool oe_configure_shm_capacity(size_t cap) -{ - if (cap > max_capacity) - { - return false; - } - capacity = cap; - return true; -} - -void* oe_shm_malloc(size_t size) -{ - oe_result_t result = OE_UNEXPECTED; - size_t total_size = 0; - - if (shm.buffer == NULL) - { - void* buffer = oe_reserve_shm(capacity); - if (buffer == NULL) - OE_RAISE(OE_OUT_OF_MEMORY); - shm.buffer = (uint8_t*)buffer; - shm.capacity = capacity; - shm.used = 0; - - // add the newly created pool to the global list - oe_spin_lock(&_shm_list_lock); - shm.next = _shm_list; - _shm_list = &shm; - oe_spin_unlock(&_shm_list_lock); - } - - // Round up to the nearest alignment size. - total_size = oe_round_up_to_multiple(size, ALIGNMENT); - - // check for overflow - OE_CHECK(total_size < size); - - // check for capacity - size_t used_after; - OE_CHECK(oe_safe_add_sizet(shm.used, total_size, &used_after)); - - // Ok if the incoming malloc puts us below the capacity. - if (used_after <= shm.capacity) - { - uint8_t* addr = shm.buffer + shm.used; - shm.used = used_after; - return addr; - } - else - OE_RAISE(OE_OUT_OF_MEMORY); - -done: - return NULL; -} - -void* oe_shm_calloc(size_t size) -{ - void* ptr = oe_shm_malloc(size); - if (ptr != NULL) - { - memset(ptr, 0, size); - } - return ptr; -} - -void oe_shm_clear() -{ - shm.used = 0; -} - -// Free all shared memory pools in the global list -void oe_shm_destroy() -{ - Shared_memory_pool* next = _shm_list; - while (next != NULL) - { - oe_unreserve_shm(next->buffer); - Shared_memory_pool* current = next; - next = next->next; - memset(current, 0, sizeof(shm)); - } - _shm_list = NULL; -} \ No newline at end of file diff --git a/enclave/core/shm.h b/enclave/core/shm.h deleted file mode 100644 index c873409dc8..0000000000 --- a/enclave/core/shm.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _OE_SHM_H -#define _OE_SHM_H - -#include - -typedef struct _shared_memory_pool -{ - /* Buffer holding the shared memory pool */ - uint8_t* buffer; - size_t capacity; - size_t used; - struct _shared_memory_pool* next; -} Shared_memory_pool; - -bool oe_configure_shm_capacity(size_t cap); - -void* oe_shm_malloc(size_t size); - -void* oe_shm_calloc(size_t size); - -void oe_shm_clear(); - -void oe_shm_destroy(); - -#endif /* _OE_SHM_H */ \ No newline at end of file diff --git a/enclave/core/stdio.c b/enclave/core/stdio.c index 5f5cf69315..e3713f9aaf 100644 --- a/enclave/core/stdio.c +++ b/enclave/core/stdio.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/strerror.c b/enclave/core/strerror.c index bad34ba389..36ead6d214 100644 --- a/enclave/core/strerror.c +++ b/enclave/core/strerror.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES diff --git a/enclave/core/string.c b/enclave/core/string.c index 2d78ff8324..de42a43297 100644 --- a/enclave/core/string.c +++ b/enclave/core/string.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/strtok_r.c b/enclave/core/strtok_r.c index ea6fdb772a..3979ed042c 100644 --- a/enclave/core/strtok_r.c +++ b/enclave/core/strtok_r.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/strtoul.c b/enclave/core/strtoul.c index 22aafe2d06..3e71785762 100644 --- a/enclave/core/strtoul.c +++ b/enclave/core/strtoul.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/switchlesscalls.c b/enclave/core/switchlesscalls.c new file mode 100644 index 0000000000..6fb968ca10 --- /dev/null +++ b/enclave/core/switchlesscalls.c @@ -0,0 +1,186 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "switchlesscalls.h" +#include +#include +#include +#include +#include + +// The number of host thread workers. Initialized by host through ECALL +static size_t _host_worker_count = 0; + +// The array of host worker contexts. Initialized by host through ECALL +static oe_host_worker_context_t* _host_worker_contexts = NULL; + +/* +**============================================================================== +** +** oe_is_switchless_initialized +** +** Return whether oe_handle_init_switchless has been called or not. +** +**============================================================================== +*/ +bool oe_is_switchless_initialized() +{ + return _host_worker_count != 0; +} + +/* +**============================================================================== +** +** oe_handle_init_switchless() +** +** Handle the OE_ECALL_INIT_CONTEXT_SWITCHLESS from host. +** +**============================================================================== +*/ +oe_result_t oe_handle_init_switchless(uint64_t arg_in) +{ + oe_result_t result = OE_UNEXPECTED; + oe_switchless_call_manager_t* manager = NULL; + oe_switchless_call_manager_t safe_manager; + size_t contexts_size, threads_size; + + if (arg_in == 0) + OE_RAISE(OE_INVALID_PARAMETER); + + manager = (oe_switchless_call_manager_t*)arg_in; + safe_manager = *manager; + + contexts_size = + sizeof(oe_host_worker_context_t) * safe_manager.num_host_workers; + threads_size = sizeof(oe_thread_t) * safe_manager.num_host_workers; + + // Ensure the switchless manager and its arrays are outside of enclave + if (!oe_is_outside_enclave(manager, sizeof(oe_switchless_call_manager_t)) || + !oe_is_outside_enclave( + safe_manager.host_worker_contexts, contexts_size) || + !oe_is_outside_enclave( + safe_manager.host_worker_threads, threads_size) || + safe_manager.num_host_workers == 0) + { + OE_RAISE(OE_INVALID_PARAMETER); + } + + /* lfence after checks. */ + oe_lfence(); + + // Copy the worker context array pointer and its size to avoid TOCTOU + _host_worker_count = safe_manager.num_host_workers; + _host_worker_contexts = safe_manager.host_worker_contexts; + result = OE_OK; + +done: + return result; +} + +/* +**============================================================================== +** +** oe_post_switchless_ocall() +** +** Post the function call (wrapped in args) to a free host worker thread +** by writing to its context. +** +**============================================================================== +*/ +oe_result_t oe_post_switchless_ocall(oe_call_host_function_args_t* args) +{ + oe_result_t result = OE_UNEXPECTED; + + OE_ATOMIC_MEMORY_BARRIER_RELEASE(); + args->result = __OE_RESULT_MAX; // Means the call hasn't been processed. + + // Cycle through the worker contexts until we find a free worker. + size_t tries = _host_worker_count; + while (tries--) + { + // Check if the worker's slot is free. + if (_host_worker_contexts[tries].call_arg == NULL) + { + // Try to atomically grab the slot by placing args in the slot. + // If the atomic operation was successful, then the worker thread + // will execute this switchless ocall. If the atomic operation + // failed, this means that the slot was grabbed by another + // switchless ocall and therefore, we must scan for another worker + // thread with a free slot. + if (oe_atomic_compare_and_swap_ptr( + (void* volatile*)&_host_worker_contexts[tries].call_arg, + NULL, + args)) + { + // The worker thread has been marked to execute this switchless + // call. Determine if it needs to be woken up or not. + // + // If event is 0, it means that it has gone to sleep. Wake it by + // making an ocall (OE_OCALL_WAKE_HOST_WORKER). + // Note: it is important to use an atomic cas operation to set + // the value to 1 before making the ocall. Setting the value to + // 1 prevents the host worker from simulataneously going to + // sleep. If instead, just a compare operation is used to + // determine if the host thread is sleeping or not, the host + // thread could go to sleep after the enclave has determined + // that the host is not sleeping, causing a deadlock. + // + // If event is 1, that indicates a pending wake notification. + int32_t oldval = 0; + int32_t newval = 1; + // Weak operation could sporadically fail. + // We need a strong operation. + bool weak = false; + if (__atomic_compare_exchange_n( + &_host_worker_contexts[tries].event, + &oldval, + newval, + weak, + __ATOMIC_ACQ_REL, + __ATOMIC_ACQUIRE)) + { + // The pevious value of the event was 0 which means that the + // worker was previously sleeping. + // Wake it via an ocall. + oe_ocall( + OE_OCALL_WAKE_HOST_WORKER, + (uint64_t)&_host_worker_contexts[tries], + NULL); + } + + return OE_OK; + } + } + } + + result = OE_CONTEXT_SWITCHLESS_OCALL_MISSED; + + return result; +} + +/* +**============================================================================== +** +** oe_switchless_call_host_function() +** +**============================================================================== +*/ + +oe_result_t oe_switchless_call_host_function( + size_t function_id, + const void* input_buffer, + size_t input_buffer_size, + void* output_buffer, + size_t output_buffer_size, + size_t* output_bytes_written) +{ + return oe_call_host_function_by_table_id( + OE_UINT64_MAX, + function_id, + input_buffer, + input_buffer_size, + output_buffer, + output_buffer_size, + output_bytes_written, + true /* switchless */); +} diff --git a/enclave/core/switchlesscalls.h b/enclave/core/switchlesscalls.h new file mode 100644 index 0000000000..3e4afe0ac7 --- /dev/null +++ b/enclave/core/switchlesscalls.h @@ -0,0 +1,15 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_SWITCHLESSCALLS_H +#define _OE_SWITCHLESSCALLS_H + +#include + +bool oe_is_switchless_initialized(); + +oe_result_t oe_handle_init_switchless(uint64_t arg_in); + +oe_result_t oe_post_switchless_ocall(oe_call_host_function_args_t* args); + +#endif // _OE_SWITCHLESSCALLS_H diff --git a/enclave/core/tee_t_wrapper.c b/enclave/core/tee_t_wrapper.c index 47003b3ed9..ead5a880ec 100644 --- a/enclave/core/tee_t_wrapper.c +++ b/enclave/core/tee_t_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES diff --git a/enclave/core/time.c b/enclave/core/time.c index 5a786e8f08..3f4eb1e106 100644 --- a/enclave/core/time.c +++ b/enclave/core/time.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/core/tracee.c b/enclave/core/tracee.c index 82e5c6258d..6c81591cb1 100644 --- a/enclave/core/tracee.c +++ b/enclave/core/tracee.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "tracee.h" diff --git a/enclave/core/tracee.h b/enclave/core/tracee.h index a9297a2277..56200c919a 100644 --- a/enclave/core/tracee.h +++ b/enclave/core/tracee.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/crypto/CMakeLists.txt b/enclave/crypto/CMakeLists.txt index 45de407745..fdd767710c 100644 --- a/enclave/crypto/CMakeLists.txt +++ b/enclave/crypto/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oecryptombed STATIC diff --git a/enclave/crypto/asn1.c b/enclave/crypto/asn1.c index fac2c8bf34..6febee4361 100644 --- a/enclave/crypto/asn1.c +++ b/enclave/crypto/asn1.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../common/asn1.h" diff --git a/enclave/crypto/cert.c b/enclave/crypto/cert.c index 9b562eb890..2e9052cd46 100644 --- a/enclave/crypto/cert.c +++ b/enclave/crypto/cert.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -1181,3 +1181,44 @@ oe_result_t oe_gen_custom_x509_cert( return result; } + +oe_result_t oe_cert_get_validity_dates( + const oe_cert_t* cert, + oe_datetime_t* not_before, + oe_datetime_t* not_after) +{ + oe_result_t result = OE_UNEXPECTED; + const Cert* impl = (const Cert*)cert; + + /* Reject invalid parameters */ + if (!_cert_is_valid(impl)) + OE_RAISE(OE_INVALID_PARAMETER); + + if (not_before) + { + memset(not_before, 0, sizeof(oe_datetime_t)); + + not_before->year = (uint32_t)impl->cert->valid_from.year; + not_before->month = (uint32_t)impl->cert->valid_from.mon; + not_before->day = (uint32_t)impl->cert->valid_from.day; + not_before->hours = (uint32_t)impl->cert->valid_from.hour; + not_before->minutes = (uint32_t)impl->cert->valid_from.min; + not_before->seconds = (uint32_t)impl->cert->valid_from.sec; + } + + if (not_after) + { + memset(not_after, 0, sizeof(oe_datetime_t)); + + not_after->year = (uint32_t)impl->cert->valid_to.year; + not_after->month = (uint32_t)impl->cert->valid_to.mon; + not_after->day = (uint32_t)impl->cert->valid_to.day; + not_after->hours = (uint32_t)impl->cert->valid_to.hour; + not_after->minutes = (uint32_t)impl->cert->valid_to.min; + not_after->seconds = (uint32_t)impl->cert->valid_to.sec; + } + result = OE_OK; + +done: + return result; +} diff --git a/enclave/crypto/cmac.c b/enclave/crypto/cmac.c index 4825c25a22..981a8262b9 100644 --- a/enclave/crypto/cmac.c +++ b/enclave/crypto/cmac.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/crypto/crl.c b/enclave/crypto/crl.c index cceb2842c5..1fce7a61e5 100644 --- a/enclave/crypto/crl.c +++ b/enclave/crypto/crl.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "crl.h" diff --git a/enclave/crypto/crl.h b/enclave/crypto/crl.h index c0bb92cf11..7c6ba80303 100644 --- a/enclave/crypto/crl.h +++ b/enclave/crypto/crl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_CRL_H diff --git a/enclave/crypto/ec.c b/enclave/crypto/ec.c index d6bca84bd3..81c3e2088d 100644 --- a/enclave/crypto/ec.c +++ b/enclave/crypto/ec.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "ec.h" diff --git a/enclave/crypto/ec.h b/enclave/crypto/ec.h index 8f36d0e41a..faf9f591a2 100644 --- a/enclave/crypto/ec.h +++ b/enclave/crypto/ec.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_EC_H diff --git a/enclave/crypto/hmac.c b/enclave/crypto/hmac.c index 5f431e7240..e1180de720 100644 --- a/enclave/crypto/hmac.c +++ b/enclave/crypto/hmac.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/crypto/key.c b/enclave/crypto/key.c index 965a0f07b0..bc0b710ee4 100644 --- a/enclave/crypto/key.c +++ b/enclave/crypto/key.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "key.h" diff --git a/enclave/crypto/key.h b/enclave/crypto/key.h index 4ce75dd66f..6096656be6 100644 --- a/enclave/crypto/key.h +++ b/enclave/crypto/key.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _ENCLAVE_KEY_H diff --git a/enclave/crypto/pem.h b/enclave/crypto/pem.h index cb10ea6a00..300b8566bb 100644 --- a/enclave/crypto/pem.h +++ b/enclave/crypto/pem.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_PEM_H diff --git a/enclave/crypto/random_internal.c b/enclave/crypto/random_internal.c index 196826665f..af8aad3990 100644 --- a/enclave/crypto/random_internal.c +++ b/enclave/crypto/random_internal.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "random_internal.h" @@ -70,9 +70,16 @@ oe_result_t oe_random_internal(void* data, size_t size) } /* Generate random data (synchronize access to _drbg instance) */ - rc = mbedtls_ctr_drbg_random(&_drbg, data, size); - if (rc != 0) - OE_RAISE_MSG(OE_CRYPTO_ERROR, "rc = 0x%x\n", rc); + for (size_t i = 0; i < size; i += MBEDTLS_CTR_DRBG_MAX_REQUEST) + { + size_t request_size = size - i; + if (request_size > MBEDTLS_CTR_DRBG_MAX_REQUEST) + request_size = MBEDTLS_CTR_DRBG_MAX_REQUEST; + + rc = mbedtls_ctr_drbg_random(&_drbg, (uint8_t*)data + i, request_size); + if (rc != 0) + OE_RAISE_MSG(OE_CRYPTO_ERROR, "rc = 0x%x\n", rc); + } result = OE_OK; done: diff --git a/enclave/crypto/random_internal.h b/enclave/crypto/random_internal.h index e85163ac03..d7765e07ea 100644 --- a/enclave/crypto/random_internal.h +++ b/enclave/crypto/random_internal.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _CRYPTO_ENCLAVE_RANDOM_H diff --git a/enclave/crypto/rsa.c b/enclave/crypto/rsa.c index 6c279325bc..5f119d72dc 100644 --- a/enclave/crypto/rsa.c +++ b/enclave/crypto/rsa.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "rsa.h" diff --git a/enclave/crypto/rsa.h b/enclave/crypto/rsa.h index a7803b0aa7..f3ca69007d 100644 --- a/enclave/crypto/rsa.h +++ b/enclave/crypto/rsa.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_RSA_H diff --git a/enclave/crypto/sha.c b/enclave/crypto/sha.c index 193989c0e5..b70ef97de4 100644 --- a/enclave/crypto/sha.c +++ b/enclave/crypto/sha.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -77,3 +77,49 @@ oe_result_t oe_sha256_final(oe_sha256_context_t* context, OE_SHA256* sha256) done: return result; } + +oe_result_t oe_sha256_save( + const oe_sha256_context_t* context, + uint32_t* H, + uint32_t* N) +{ + oe_result_t result = OE_INVALID_PARAMETER; + + if (!context || !H || !N) + OE_RAISE(OE_INVALID_PARAMETER); + + oe_sha256_context_impl_t* impl = (oe_sha256_context_impl_t*)context; + + for (size_t i = 0; i < 8; i++) + H[i] = impl->ctx.state[i]; + + N[0] = impl->ctx.total[0] * 8; + N[1] = (impl->ctx.total[1] * 8) + (impl->ctx.total[0] >> 29); + +done: + return result; +} + +oe_result_t oe_sha256_restore( + oe_sha256_context_t* context, + const uint32_t* H, + const uint32_t* N) +{ + oe_result_t result = OE_INVALID_PARAMETER; + + if (!context || !H || !N) + OE_RAISE(OE_INVALID_PARAMETER); + + oe_sha256_context_impl_t* impl = (oe_sha256_context_impl_t*)context; + oe_sha256_init(context); + + for (size_t i = 0; i < 8; i++) + impl->ctx.state[i] = H[i]; + + uint64_t NB = ((((uint64_t)N[1]) << 32) + N[0]) / 8; + impl->ctx.total[0] = NB & 0xFFFFFFFF; + impl->ctx.total[1] = (NB >> 32) & 0xFFFFFFFF; + +done: + return result; +} \ No newline at end of file diff --git a/enclave/link.c b/enclave/link.c index 02e597e505..8410f68f9e 100644 --- a/enclave/link.c +++ b/enclave/link.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/optee/report.c b/enclave/optee/report.c index 23ae1720a8..029adf057e 100644 --- a/enclave/optee/report.c +++ b/enclave/optee/report.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/optee/start.S b/enclave/optee/start.S index 270a777f4c..854a5d9100 100644 --- a/enclave/optee/start.S +++ b/enclave/optee/start.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. //============================================================================== diff --git a/enclave/random.c b/enclave/random.c index a7a59ec275..0ef124f13f 100644 --- a/enclave/random.c +++ b/enclave/random.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/enclave/sgx/attester.c b/enclave/sgx/attester.c new file mode 100644 index 0000000000..154e1a3c98 --- /dev/null +++ b/enclave/sgx/attester.c @@ -0,0 +1,248 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "../common/sgx/endorsements.h" + +static oe_result_t _on_register( + oe_attestation_role_t* context, + const void* config_data, + size_t config_data_size) +{ + OE_UNUSED(context); + OE_UNUSED(config_data); + OE_UNUSED(config_data_size); + return OE_OK; +} + +static oe_result_t _on_unregister(oe_attestation_role_t* context) +{ + OE_UNUSED(context); + return OE_OK; +} + +static size_t _get_claims_size( + const oe_claim_t* custom_claims, + size_t custom_claims_length) +{ + size_t size = sizeof(oe_sgx_plugin_claims_header_t); + + if (!custom_claims) + return size; + + for (size_t i = 0; i < custom_claims_length; i++) + { + size += sizeof(oe_sgx_plugin_claims_entry_t); + size += oe_strlen(custom_claims[i].name) + 1; + size += custom_claims[i].value_size; + } + return size; +} + +static void _set_claims( + const oe_claim_t* custom_claims, + size_t custom_claims_length, + uint8_t* claims) +{ + // Custom claims structure would be: + // - oe_sgx_plugin_claims_header_t + // - N claim entries of oe_sgx_plugin_claims_entry_t + oe_sgx_plugin_claims_header_t* header = + (oe_sgx_plugin_claims_header_t*)claims; + header->version = OE_SGX_PLUGIN_CLAIMS_VERSION; + header->num_claims = custom_claims ? custom_claims_length : 0; + claims += sizeof(oe_sgx_plugin_claims_header_t); + + if (!custom_claims) + return; + + for (size_t i = 0; i < custom_claims_length; i++) + { + oe_sgx_plugin_claims_entry_t* entry = + (oe_sgx_plugin_claims_entry_t*)claims; + entry->name_size = oe_strlen(custom_claims[i].name) + 1; + entry->value_size = custom_claims[i].value_size; + memcpy(entry->name, custom_claims[i].name, entry->name_size); + memcpy( + entry->name + entry->name_size, + custom_claims[i].value, + entry->value_size); + claims += sizeof(*entry) + entry->name_size + entry->value_size; + } +} + +static oe_result_t _serialize_claims( + const oe_claim_t* custom_claims, + size_t custom_claims_length, + uint8_t** claims_out, + size_t* claims_size_out, + OE_SHA256* hash_out) +{ + uint8_t* claims = NULL; + size_t claims_size = 0; + oe_sha256_context_t hash_ctx = {0}; + oe_result_t result = OE_UNEXPECTED; + + // Get claims size. + claims_size = _get_claims_size(custom_claims, custom_claims_length); + + // Allocate memory and set the claims. + claims = (uint8_t*)oe_malloc(claims_size); + if (claims == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + _set_claims(custom_claims, custom_claims_length, claims); + + // Produce a hash of the claims. + OE_CHECK(oe_sha256_init(&hash_ctx)); + OE_CHECK(oe_sha256_update(&hash_ctx, claims, claims_size)); + OE_CHECK(oe_sha256_final(&hash_ctx, hash_out)); + + *claims_out = claims; + *claims_size_out = claims_size; + claims = NULL; + result = OE_OK; + +done: + if (claims != NULL) + oe_free(claims); + return result; +} + +// Timing note: +// Roughly 0.002 seconds without endorsements. +// Roughtly 0.5 seconds with endorsements. +static oe_result_t _get_evidence( + oe_attester_t* context, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size) +{ + oe_result_t result = OE_UNEXPECTED; + uint8_t* claims = NULL; + size_t claims_size = 0; + OE_SHA256 hash; + uint8_t* report = NULL; + size_t report_size = 0; + uint8_t* evidence = NULL; + uint8_t* endorsements = NULL; + size_t endorsements_size = 0; + OE_UNUSED(context); + + if (!evidence_buffer || !evidence_buffer_size || + (endorsements_buffer && !endorsements_buffer_size)) + OE_RAISE(OE_INVALID_PARAMETER); + + // Serialize the claims. + OE_CHECK_MSG( + _serialize_claims( + custom_claims, custom_claims_length, &claims, &claims_size, &hash), + "SGX Plugin: Failed to serialize claims. %s", + oe_result_str(result)); + + // Get the report with the hash of the claims as the report data. + OE_CHECK_MSG( + oe_get_report( + flags, + hash.buf, + sizeof(hash.buf), + opt_params, + opt_params_size, + &report, + &report_size), + "SGX Plugin: Failed to get OE report. %s", + oe_result_str(result)); + + // Combine the two to get the evidence. + // Format is report first then claims. + evidence = (uint8_t*)oe_malloc(report_size + claims_size); + if (evidence == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + memcpy(evidence, report, report_size); + memcpy(evidence + report_size, claims, claims_size); + + // Get the endorsements from the report if needed. + if (endorsements_buffer && flags == OE_REPORT_FLAGS_REMOTE_ATTESTATION) + { + oe_report_header_t* header = (oe_report_header_t*)report; + + OE_CHECK_MSG( + oe_get_sgx_endorsements( + header->report, + header->report_size, + &endorsements, + &endorsements_size), + "SGX Plugin: Failed to get endorsements: %s", + oe_result_str(result)); + } + + *evidence_buffer = evidence; + *evidence_buffer_size = report_size + claims_size; + evidence = NULL; + if (endorsements_buffer) + { + *endorsements_buffer = endorsements; + *endorsements_buffer_size = endorsements_size; + endorsements = NULL; + } + result = OE_OK; + +done: + oe_free(claims); + oe_free_report(report); + if (evidence != NULL) + oe_free(evidence); + if (endorsements != NULL) + oe_free_sgx_endorsements(endorsements); + return result; +} + +static oe_result_t _free_evidence( + oe_attester_t* context, + uint8_t* evidence_buffer) +{ + OE_UNUSED(context); + oe_free(evidence_buffer); + return OE_OK; +} + +static oe_result_t _free_endorsements( + oe_attester_t* context, + uint8_t* endorsements_buffer) +{ + OE_UNUSED(context); + oe_free_sgx_endorsements(endorsements_buffer); + return OE_OK; +} + +static oe_attester_t _attester = {.base = + { + .format_id = {OE_SGX_PLUGIN_UUID}, + .on_register = &_on_register, + .on_unregister = &_on_unregister, + }, + .get_evidence = &_get_evidence, + .free_evidence = &_free_evidence, + .free_endorsements = &_free_endorsements}; + +oe_attester_t* oe_sgx_plugin_attester() +{ + return &_attester; +} diff --git a/enclave/sgx/qeidinfo.c b/enclave/sgx/qeidinfo.c index 78d6c37899..3fb5d86a14 100644 --- a/enclave/sgx/qeidinfo.c +++ b/enclave/sgx/qeidinfo.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -40,7 +40,7 @@ oe_result_t oe_get_qe_identity_info(oe_get_qe_identity_info_args_t* args_out) args.issuer_chain_size = ISSUER_CHAIN_SIZE; /* First call (one or more buffers might be too small). */ - if (oe_get_qe_identify_info_ocall( + if (oe_get_qe_identity_info_ocall( &retval, args.qe_id_info, args.qe_id_info_size, @@ -76,7 +76,7 @@ oe_result_t oe_get_qe_identity_info(oe_get_qe_identity_info_args_t* args_out) OE_RAISE(OE_OUT_OF_MEMORY); } - if (oe_get_qe_identify_info_ocall( + if (oe_get_qe_identity_info_ocall( &retval, args.qe_id_info, args.qe_id_info_size, @@ -117,7 +117,7 @@ oe_result_t oe_get_qe_identity_info(oe_get_qe_identity_info_args_t* args_out) } // Cleanup the args structure. -void oe_cleanup_qe_identity_info_args(oe_get_qe_identity_info_args_t* args) +void oe_free_qe_identity_info_args(oe_get_qe_identity_info_args_t* args) { if (!args) return; diff --git a/enclave/sgx/report.c b/enclave/sgx/report.c index d86a685849..3fbaaeb253 100644 --- a/enclave/sgx/report.c +++ b/enclave/sgx/report.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "report.h" @@ -14,6 +14,7 @@ #include #include #include "../common/sgx/quote.h" +#include "../common/sgx/verify_eeid.h" #include "sgx_t.h" OE_STATIC_ASSERT(OE_REPORT_DATA_SIZE == sizeof(sgx_report_data_t)); @@ -49,6 +50,15 @@ oe_result_t oe_verify_report( const uint8_t* report, size_t report_size, oe_report_t* parsed_report) +{ + return oe_verify_report_eeid(report, report_size, parsed_report, NULL); +} + +oe_result_t oe_verify_report_eeid( + const uint8_t* report, + size_t report_size, + oe_report_t* parsed_report, + oe_eeid_t* eeid) { oe_result_t result = OE_UNEXPECTED; oe_report_t oe_report = {0}; @@ -66,8 +76,8 @@ oe_result_t oe_verify_report( if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE) { - OE_CHECK(oe_verify_quote_internal( - header->report, header->report_size, NULL, 0, NULL, 0, NULL, 0)); + OE_CHECK(oe_verify_sgx_quote( + header->report, header->report_size, NULL, 0, NULL)); } else if (header->report_type == OE_REPORT_TYPE_SGX_LOCAL) { @@ -98,6 +108,9 @@ oe_result_t oe_verify_report( if (parsed_report != NULL) *parsed_report = oe_report; + if (eeid) + verify_eeid(&oe_report, eeid); + result = OE_OK; done: diff --git a/enclave/sgx/report.h b/enclave/sgx/report.h index bdbf4499d1..a3cd973059 100644 --- a/enclave/sgx/report.h +++ b/enclave/sgx/report.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENCLAVE_REPORT_H diff --git a/enclave/sgx/revocationinfo.c b/enclave/sgx/revocationinfo.c index 0b1d1689dd..2caa962dc1 100644 --- a/enclave/sgx/revocationinfo.c +++ b/enclave/sgx/revocationinfo.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -152,7 +152,7 @@ oe_result_t oe_get_revocation_info(oe_get_revocation_info_args_t* args) return result; } -void oe_cleanup_get_revocation_info_args(oe_get_revocation_info_args_t* args) +void oe_free_get_revocation_info_args(oe_get_revocation_info_args_t* args) { if (args) { diff --git a/enclave/sgx/start.S b/enclave/sgx/start.S index 4cda7c1797..2cdc094fad 100644 --- a/enclave/sgx/start.S +++ b/enclave/sgx/start.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. //============================================================================== diff --git a/enclave/tls_cert.c b/enclave/tls_cert.c index 2a463f46a0..9b32f61244 100644 --- a/enclave/tls_cert.c +++ b/enclave/tls_cert.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index bd10b4e6d8..1ca5e6dce5 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== @@ -93,10 +93,12 @@ elseif (WIN32) crypto/bcrypt/rsa.c crypto/bcrypt/sha.c crypto/bcrypt/pem.c + crypto/bcrypt/util.c windows/hostthread.c) set(PLATFORM_SDK_ONLY_SRC ../3rdparty/mbedtls/mbedtls/library/bignum.c + ../3rdparty/mbedtls/mbedtls/library/platform_util.c #Used by bignum.c ../common/asn1.c ../common/cert.c crypto/bcrypt/cert.c @@ -115,9 +117,27 @@ else() message(FATAL_ERROR "Unknown OS. Only supported OSes are Linux and Windows") endif() +if (OE_SGX AND WIN32) + # Use clang to compile the oe_enter function that calls ENCLU. + # Windows debuggers (WinDbg and Visual Studio Debugger) require that the rbp + # is set up like a Linux x64 ABI style frame pointer by the oe_enter function. + # Since oe_enter function is setting up the frame-pointer, enter.c must be + # compiled with the -fomit-frame-pointer flag so that the compiler does not + # set up the frame pointer. + add_custom_command( + OUTPUT enter.obj + DEPENDS sgx/enter.c + COMMAND clang -c -O2 -fomit-frame-pointer -m64 + -I${PROJECT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/sgx/enter.c + -o enter.obj) +endif() + # SGX specific files. if (OE_SGX) list(APPEND PLATFORM_HOST_ONLY_SRC + ../common/sgx/eeid.c + ../common/sgx/endorsements.c ../common/sgx/qeidentity.c ../common/sgx/quote.c ../common/sgx/report.c @@ -125,6 +145,8 @@ if (OE_SGX) ../common/sgx/sgxcertextensions.c ../common/sgx/tcbinfo.c ../common/sgx/tlsverifier.c + ../common/sgx/verifier.c + ../common/sgx/verify_eeid.c sgx/hostverify_report.c sgx/sgxquoteprovider.c) @@ -147,7 +169,8 @@ if (OE_SGX) sgx/sgxmeasure.c sgx/sgxquote.c sgx/sgxsign.c - sgx/sgxtypes.c) + sgx/sgxtypes.c + sgx/switchless.c) # OS specific as well. if (UNIX) @@ -156,11 +179,11 @@ if (OE_SGX) list(APPEND PLATFORM_SDK_ONLY_SRC sgx/linux/aep.S - sgx/linux/aesm.c - sgx/linux/enter.S - sgx/linux/entersim.S + sgx/enter.c sgx/linux/exception.c + sgx/linux/hoststackbridge.c sgx/linux/sgxioctl.c + sgx/linux/switchless.c sgx/linux/xstate.c) else() list(APPEND PLATFORM_HOST_ONLY_SRC @@ -168,10 +191,9 @@ if (OE_SGX) list(APPEND PLATFORM_SDK_ONLY_SRC sgx/windows/aep.asm - sgx/windows/aesm.c - sgx/windows/enter.asm - sgx/windows/entersim.asm + ${CMAKE_CURRENT_BINARY_DIR}/enter.obj sgx/windows/exception.c + sgx/windows/switchless.c sgx/windows/xstate.c) endif() @@ -179,7 +201,7 @@ if (OE_SGX) elseif(OE_TRUSTZONE) list(APPEND PLATFORM_SDK_ONLY_SRC optee/log.c) - + if (UNIX) list(APPEND PLATFORM_SDK_ONLY_SRC optee/linux/enclave.c) @@ -191,17 +213,19 @@ elseif(OE_TRUSTZONE) endif() if (OE_SGX AND WIN32) - # oedebugrt is accessed via a bridge on Win32 and need not be linked. + # oedebugrt is accessed via a bridge on Win32 and need not be linked. list(APPEND PLATFORM_SDK_ONLY_SRC sgx/windows/debugrtbridge.c) endif() # Common host verification files that work on any OS/architecture. list(APPEND PLATFORM_HOST_ONLY_SRC + ../common/attest_plugin.c ../common/datetime.c ../common/safecrt.c hexdump.c dupenv.c + fopen.c tests.c result.c traceh.c) @@ -209,7 +233,6 @@ list(APPEND PLATFORM_HOST_ONLY_SRC # Common files that are used in the OE SDK only. list(APPEND PLATFORM_SDK_ONLY_SRC ../common/kdf.c - ../common/lockless_queue.c ../common/argv.c asym_keys.c calls.c @@ -242,6 +265,16 @@ endif() if (OE_SGX AND UNIX) # Link oedebugrt static library. target_link_libraries(oehost PRIVATE oedebugrt) + + # hoststackbridge and enter.c must be forced to retain the frame-pointer + # for ocall stack-stitching by using the -fno-omit-frame-pointer flag. + # Both are compiled with -O2 flag to retain the same generated assembly + # code in both debug and release builds. + set_source_files_properties(oehost + sgx/enter.c + sgx/linux/hoststackbridge.c + PROPERTIES + COMPILE_FLAGS "-O2 -fno-omit-frame-pointer") endif() add_dependencies(oehost syscall_untrusted_edl) @@ -253,25 +286,25 @@ endif() # TODO: Replace these with `find_package` and add as dependencies to # the CMake package. if (UNIX) - if (NOT TARGET crypto) + if (NOT TARGET openenclave::crypto) find_library(CRYPTO_LIB NAMES crypto) if (NOT CRYPTO_LIB) message(FATAL_ERROR "-- Looking for crypto library - not found") else () message("-- Looking for crypto library - found") - add_library(crypto SHARED IMPORTED) - set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CRYPTO_LIB}) + add_library(openenclave::crypto SHARED IMPORTED) + set_target_properties(openenclave::crypto PROPERTIES IMPORTED_LOCATION ${CRYPTO_LIB}) endif () endif () - if (NOT TARGET dlib) + if (NOT TARGET openenclave::dl) find_library(DL_LIB NAMES dl) if (NOT DL_LIB) message(FATAL_ERROR "-- Looking for dl library - not found") else () message("-- Looking for dl library - found") - add_library(dl SHARED IMPORTED) - set_target_properties(dl PROPERTIES IMPORTED_LOCATION ${DL_LIB}) + add_library(openenclave::dl SHARED IMPORTED) + set_target_properties(openenclave::dl PROPERTIES IMPORTED_LOCATION ${DL_LIB}) endif () endif () endif () @@ -279,8 +312,14 @@ endif () find_package(Threads REQUIRED) if (UNIX) - target_link_libraries(oehost PRIVATE crypto dl Threads::Threads) - target_link_libraries(oehostverify PRIVATE crypto dl Threads::Threads) + target_link_libraries(oehost PRIVATE + openenclave::crypto + openenclave::dl + Threads::Threads) + target_link_libraries(oehostverify PRIVATE + openenclave::crypto + openenclave::dl + Threads::Threads) if (OE_TRUSTZONE) target_include_directories(oehost PRIVATE @@ -290,7 +329,9 @@ if (UNIX) elseif (WIN32) target_include_directories(oehost PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/mbedtls/mbedtls/include) - target_link_libraries(oehost PRIVATE bcrypt Crypt32) + # Synchronization library is needed for WaitOnAddress/WakeByAddress functions + # used by switchless ocalls worker threads. + target_link_libraries(oehost PRIVATE bcrypt Crypt32 Synchronization) target_include_directories(oehostverify PRIVATE ${CMAKE_SOURCE_DIR}/3rdparty/mbedtls/mbedtls/include) target_link_libraries(oehostverify PRIVATE bcrypt Crypt32) @@ -301,42 +342,55 @@ endif () # For including edge routines. target_include_directories(oehost PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -if (USE_LIBSGX) +if (OE_SGX) + # Always link with the EnclaveCommonAPI if (WIN32) - set(LIBPATHS - ${CMAKE_SOURCE_DIR}/prereqs/nuget/EnclaveCommonAPI/lib/native/x64-Release - ${CMAKE_SOURCE_DIR}/prereqs/nuget/DCAP_Components/build/lib/native/Libraries) - set(INCPATHS - "${CMAKE_SOURCE_DIR}/prereqs/nuget/EnclaveCommonAPI/Header Files" - "${CMAKE_SOURCE_DIR}/prereqs/nuget/DCAP_Components/build/Header Files") - set(WINSYSLOCATION - $ENV{WINDIR}/System32) + set(LIBPATHS ${NUGET_PACKAGE_PATH}/EnclaveCommonAPI/lib/native/x64-Release) + set(INCPATHS "${NUGET_PACKAGE_PATH}/EnclaveCommonAPI/Header Files") endif () - - find_library(LIBSGX_COMMON NAMES sgx_enclave_common PATHS ${LIBPATHS}) - find_library(LIBSGX_QE NAMES sgx_dcap_ql PATHS ${LIBPATHS}) - if (NOT LIBSGX_COMMON OR NOT LIBSGX_QE) - message(FATAL_ERROR "No SGX libraries found, aborting! Set -DUSE_LIBSGX=OFF to ignore.") + if (NOT LIBPATHS) + set(LIBPATHS "/usr") + endif () + find_library(LIBSGX_COMMON NAMES sgx_enclave_common HINTS ${LIBPATHS}) + if (NOT LIBSGX_COMMON) + message(FATAL_ERROR "Intel SGX EnclaveCommonAPI library not found, aborting!") endif () add_library(sgx_enclave_common SHARED IMPORTED) - add_library(sgx_dcap_ql SHARED IMPORTED) - - if (UNIX) + if (WIN32) + set_target_properties(sgx_enclave_common PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${INCPATHS}" + IMPORTED_LOCATION $ENV{WINDIR}/System32 + IMPORTED_IMPLIB ${LIBSGX_COMMON}) + elseif (UNIX) set_target_properties(sgx_enclave_common PROPERTIES IMPORTED_LOCATION ${LIBSGX_COMMON}) - set_target_properties(sgx_dcap_ql PROPERTIES IMPORTED_LOCATION ${LIBSGX_QE}) - elseif (WIN32) - set_target_properties(sgx_enclave_common PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${INCPATHS}" - IMPORTED_LOCATION ${WINSYSLOCATION} - IMPORTED_IMPLIB ${LIBSGX_COMMON}) - set_target_properties(sgx_dcap_ql PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${INCPATHS}" - IMPORTED_LOCATION ${WINSYSLOCATION} - IMPORTED_IMPLIB ${LIBSGX_QE}) endif () - - target_link_libraries(oehost PUBLIC sgx_enclave_common sgx_dcap_ql) - target_compile_definitions(oehost PUBLIC OE_USE_LIBSGX) + target_link_libraries(oehost PUBLIC $) + + # Optionally link in DCAP library + if (HAS_QUOTE_PROVIDER) + if (WIN32) + list(APPEND LIBPATHS + ${NUGET_PACKAGE_PATH}/DCAP_Components/build/lib/native/Libraries) + list(APPEND INCPATHS + "${NUGET_PACKAGE_PATH}/DCAP_Components/build/Header Files") + endif () + find_library(LIBSGX_QE NAMES sgx_dcap_ql HINTS ${LIBPATHS}) + if (NOT LIBSGX_QE) + message(FATAL_ERROR "No quote provider library found, aborting! Set -DHAS_QUOTE_PROVIDER=OFF to ignore.") + endif () + add_library(sgx_dcap_ql SHARED IMPORTED) + if (WIN32) + set_target_properties(sgx_dcap_ql PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${INCPATHS}" + IMPORTED_LOCATION $ENV{WINDIR}/System32 + IMPORTED_IMPLIB ${LIBSGX_QE}) + elseif (UNIX) + set_target_properties(sgx_dcap_ql PROPERTIES IMPORTED_LOCATION ${LIBSGX_QE}) + endif () + target_link_libraries(oehost PUBLIC $) + # turn on 'OE_LINK_SGX_DCAP_QL' for the preprocessor + target_compile_definitions(oehost PUBLIC OE_LINK_SGX_DCAP_QL) + endif () endif () # Compile definitions and options diff --git a/host/README.md b/host/README.md index 6919ac320d..2aeee6fc30 100644 --- a/host/README.md +++ b/host/README.md @@ -48,11 +48,20 @@ see [create.c](create.c)). +----------------------------------------+ | | Guard page | | +----------------------------------------+ | - | Segment Page: (FS or GS) | | - | (contains thread data structure) | | + | Thread local storage | | +----------------------------------------+ | - | Thread specific data (TSD) Page | | + | Segment Page: (FS) | | + | (contains thread data structure | | + | and Thread specific data (TSD)) | | +----------------------------------------+ <--+ | Padding Pages (must be a power of two) | +----------------------------------------+ +The thread data (td) object is always populated at the start of the +FS segment, thus FS segment regiter points to td. +The existing Windows SGX enclave debugger finds the start of the thread data +by assuming that it is located at the start of the GS segment. i.e. it adds the +enclave base address and the offset to the GS segment stored in TCS.OGSBASGX. +OE SDK uses the FS segment for this purpose and has no separate use for the +GS register, so we point it at the FS segment to preserve the Windows debugger +behavior. diff --git a/host/asym_keys.c b/host/asym_keys.c index fc87ea577a..1f743e6ead 100644 --- a/host/asym_keys.c +++ b/host/asym_keys.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -27,7 +27,7 @@ oe_result_t oe_get_public_key_by_policy( size_t* key_info_size) { oe_result_t result = OE_UNEXPECTED; - uint32_t retval; + oe_result_t retval; const size_t KEY_BUFFER_SIZE = DEFAULT_KEY_BUFFER_SIZE; const size_t KEY_INFO_SIZE = 1024; struct @@ -85,7 +85,7 @@ oe_result_t oe_get_public_key_by_policy( } /* If the buffers were too small, try again with corrected sizes. */ - if ((oe_result_t)retval == OE_BUFFER_TOO_SMALL) + if (retval == OE_BUFFER_TOO_SMALL) { if (!(arg.key_buffer = realloc(arg.key_buffer, arg.key_buffer_size))) OE_RAISE(OE_OUT_OF_MEMORY); @@ -109,7 +109,7 @@ oe_result_t oe_get_public_key_by_policy( } } - OE_CHECK((oe_result_t)retval); + OE_CHECK(retval); *key_buffer = arg.key_buffer; *key_buffer_size = arg.key_buffer_size; @@ -132,7 +132,7 @@ oe_result_t oe_get_public_key_by_policy( if (arg.key_info) { oe_secure_zero_fill(arg.key_info, arg.key_info_size); - free(arg.key_buffer); + free(arg.key_info); } return result; @@ -147,7 +147,7 @@ oe_result_t oe_get_public_key( size_t* key_buffer_size) { oe_result_t result = OE_UNEXPECTED; - uint32_t retval; + oe_result_t retval; const size_t KEY_BUFFER_SIZE = DEFAULT_KEY_BUFFER_SIZE; struct { @@ -190,7 +190,7 @@ oe_result_t oe_get_public_key( } /* If the buffers were too small, try again with corrected sizes. */ - if ((oe_result_t)retval == OE_BUFFER_TOO_SMALL) + if (retval == OE_BUFFER_TOO_SMALL) { if (!(arg.key_buffer = realloc(arg.key_buffer, arg.key_buffer_size))) OE_RAISE(OE_OUT_OF_MEMORY); @@ -209,7 +209,7 @@ oe_result_t oe_get_public_key( } } - OE_CHECK((oe_result_t)retval); + OE_CHECK(retval); *key_buffer = arg.key_buffer; *key_buffer_size = arg.key_buffer_size; diff --git a/host/calls.c b/host/calls.c index d2c62baa13..92501ab410 100644 --- a/host/calls.c +++ b/host/calls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/calls.h b/host/calls.h index c152354ef8..d4a276a8f1 100644 --- a/host/calls.h +++ b/host/calls.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -17,4 +17,6 @@ typedef struct _ocall_table extern ocall_table_t _ocall_tables[]; +oe_result_t oe_handle_call_host_function(uint64_t arg, oe_enclave_t* enclave); + #endif /* OE_HOST_CALLS_H */ diff --git a/host/crypto/bcrypt/bcrypt.h b/host/crypto/bcrypt/bcrypt.h index d57ab24ad3..2c559f5257 100644 --- a/host/crypto/bcrypt/bcrypt.h +++ b/host/crypto/bcrypt/bcrypt.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/host/crypto/bcrypt/cert.c b/host/crypto/bcrypt/cert.c index fef8edcf78..daa502417f 100644 --- a/host/crypto/bcrypt/cert.c +++ b/host/crypto/bcrypt/cert.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -17,6 +17,7 @@ #include "key.h" #include "pem.h" #include "rsa.h" +#include "util.h" /* **============================================================================== @@ -28,9 +29,8 @@ #define _OE_CERT_CHAIN_LENGTH_ANY 0 -static const DWORD _OE_DEFAULT_GET_CRL_FLAGS = CERT_STORE_SIGNATURE_FLAG | - CERT_STORE_TIME_VALIDITY_FLAG | - CERT_STORE_BASE_CRL_FLAG; +static const DWORD _OE_DEFAULT_GET_CRL_FLAGS = + CERT_STORE_SIGNATURE_FLAG | CERT_STORE_BASE_CRL_FLAG; static const CERT_CHAIN_POLICY_PARA _OE_DEFAULT_CERT_CHAIN_POLICY = { .cbSize = sizeof(CERT_CHAIN_POLICY_PARA), @@ -43,8 +43,8 @@ static const CERT_STRONG_SIGN_PARA _OE_DEFAULT_SIGN_PARAMS = { static const CERT_CHAIN_PARA _OE_DEFAULT_CERT_CHAIN_PARAMS = { .cbSize = sizeof(CERT_CHAIN_PARA), - .RequestedUsage = {{0}}, - .RequestedIssuancePolicy = {{0}}, + .RequestedUsage = {0}, + .RequestedIssuancePolicy = {0}, .dwUrlRetrievalTimeout = 0, .fCheckRevocationFreshnessTime = FALSE, .dwRevocationFreshnessTime = 0, @@ -204,7 +204,10 @@ static oe_result_t _bcrypt_load_cert_store_pem( OE_RAISE(find_result); OE_CHECK(oe_bcrypt_pem_to_der( - pem_cert, pem_cert_size, &der_blob.pbData, &der_blob.cbData)); + (const uint8_t*)pem_cert, + pem_cert_size, + &der_blob.pbData, + &der_blob.cbData)); free(pem_cert); pem_cert = NULL; @@ -361,7 +364,7 @@ static oe_result_t _bcrypt_check_revocation( /* For parity with OpenSSL implementation, we require that a CRL * is provided for each issuer in the chain. */ DWORD error = GetLastError(); - if (error == CRYPT_E_NOT_FOUND) + if (error == (DWORD)CRYPT_E_NOT_FOUND) OE_RAISE(OE_VERIFY_CRL_MISSING); else OE_RAISE_MSG( @@ -784,7 +787,8 @@ oe_result_t oe_cert_chain_read_pem( OE_CHECK(_bcrypt_load_cert_store_pem(pem_data, pem_data_size, &cert_store)); /* Count the number of unique certs in the resulting cert store */ - while (cert_context = CertEnumCertificatesInStore(cert_store, cert_context)) + while ( + (cert_context = CertEnumCertificatesInStore(cert_store, cert_context))) cert_count++; if (cert_count == 0) @@ -796,7 +800,8 @@ oe_result_t oe_cert_chain_read_pem( * cert until a cert chain is found that uses all certs in the store and * terminates in a self-signed (root) certificate. */ - while (cert_context = CertEnumCertificatesInStore(cert_store, cert_context)) + while ( + (cert_context = CertEnumCertificatesInStore(cert_store, cert_context))) { oe_result_t find_result = _bcrypt_get_cert_chain( cert_context, cert_store, cert_count, &cert_chain); @@ -922,7 +927,7 @@ oe_result_t oe_cert_verify( } /* Add CRLs to cert store */ - for (int j = 0; j < num_crls; j++) + for (size_t j = 0; j < num_crls; j++) { PCCRL_CONTEXT crl_context; OE_CHECK(oe_crl_get_context(crls[j], &crl_context)); @@ -960,7 +965,7 @@ oe_result_t oe_cert_verify( oe_result_t oe_get_crl_distribution_points( const oe_cert_t* cert, - const char*** urls, + char*** urls, size_t* num_urls, uint8_t* buffer, size_t* buffer_size) @@ -1044,7 +1049,7 @@ oe_result_t oe_get_crl_distribution_points( /* Copy the URLs array and pack the URL strings into buffer */ if (buffer) { - uint8_t* offset = buffer + found_urls_size; + char* offset = (char*)buffer + found_urls_size; size_t remaining_bytes = found_urls_total_length; char** urls_array = (char**)buffer; for (DWORD k = 0; k < found_urls_count; k++) @@ -1084,7 +1089,6 @@ oe_result_t oe_cert_get_rsa_public_key( oe_rsa_public_key_t* public_key) { oe_result_t result = OE_UNEXPECTED; - NTSTATUS status = STATUS_UNSUCCESSFUL; BCRYPT_KEY_HANDLE key_handle = NULL; PWSTR key_alg_name = NULL; ULONG key_alg_name_size; @@ -1134,7 +1138,6 @@ oe_result_t oe_cert_get_ec_public_key( oe_ec_public_key_t* public_key) { oe_result_t result = OE_UNEXPECTED; - NTSTATUS status = STATUS_UNSUCCESSFUL; BCRYPT_KEY_HANDLE key_handle = NULL; PWSTR key_alg_name = NULL; ULONG key_alg_name_size; @@ -1296,3 +1299,37 @@ oe_result_t oe_cert_find_extension( done: return result; } + +oe_result_t oe_cert_get_validity_dates( + const oe_cert_t* cert, + oe_datetime_t* not_before, + oe_datetime_t* not_after) +{ + oe_result_t result = OE_UNEXPECTED; + const cert_t* impl = (const cert_t*)cert; + + if (!_cert_is_valid(impl)) + OE_RAISE(OE_INVALID_PARAMETER); + + if (not_before) + { + memset(not_before, 0, sizeof(oe_datetime_t)); + + OE_CHECK(oe_util_filetime_to_oe_datetime( + &impl->cert->pCertInfo->NotBefore, not_before)); + } + + if (not_after) + { + memset(not_after, 0, sizeof(oe_datetime_t)); + + OE_CHECK(oe_util_filetime_to_oe_datetime( + &impl->cert->pCertInfo->NotAfter, not_after)); + } + + result = OE_OK; + +done: + + return result; +} diff --git a/host/crypto/bcrypt/crl.c b/host/crypto/bcrypt/crl.c index 658806e80c..033b8a32da 100644 --- a/host/crypto/bcrypt/crl.c +++ b/host/crypto/bcrypt/crl.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -9,6 +9,7 @@ #include "../magic.h" #include "bcrypt.h" #include "crl.h" +#include "util.h" typedef struct _crl { @@ -38,31 +39,6 @@ OE_INLINE void _crl_destroy(crl_t* impl) } } -static oe_result_t _filetime_to_oe_datetime( - const FILETIME* filetime, - oe_datetime_t* datetime) -{ - oe_result_t result = OE_UNEXPECTED; - SYSTEMTIME systime = {0}; - if (!FileTimeToSystemTime(filetime, &systime)) - OE_RAISE_MSG( - OE_INVALID_UTC_DATE_TIME, - "FileTimeToSystemTime failed, err=%#x\n", - GetLastError()); - - datetime->year = systime.wYear; - datetime->month = systime.wMonth; - datetime->day = systime.wDay; - datetime->hours = systime.wHour; - datetime->minutes = systime.wMinute; - datetime->seconds = systime.wSecond; - - result = OE_OK; - -done: - return result; -} - oe_result_t oe_crl_get_context(const oe_crl_t* crl, PCCRL_CONTEXT* crl_context) { oe_result_t result = OE_UNEXPECTED; @@ -106,8 +82,7 @@ oe_result_t oe_crl_read_der( "CertCreateCRLContext failed, err=%#x\n", GetLastError()); - impl->magic = OE_CRL_MAGIC; - impl->crl = crl_context; + _crl_init(impl, crl_context); result = OE_OK; done: @@ -151,10 +126,10 @@ oe_result_t oe_crl_get_update_dates( PCRL_INFO crl_info = impl->crl->pCrlInfo; if (last) - OE_CHECK(_filetime_to_oe_datetime(&crl_info->ThisUpdate, last)); + OE_CHECK(oe_util_filetime_to_oe_datetime(&crl_info->ThisUpdate, last)); if (next) - OE_CHECK(_filetime_to_oe_datetime(&crl_info->NextUpdate, next)); + OE_CHECK(oe_util_filetime_to_oe_datetime(&crl_info->NextUpdate, next)); result = OE_OK; diff --git a/host/crypto/bcrypt/crl.h b/host/crypto/bcrypt/crl.h index 30f7137f87..097ff6a274 100644 --- a/host/crypto/bcrypt/crl.h +++ b/host/crypto/bcrypt/crl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_CRL_H diff --git a/host/crypto/bcrypt/ec.c b/host/crypto/bcrypt/ec.c index 7fb07e45a5..3582c456c6 100644 --- a/host/crypto/bcrypt/ec.c +++ b/host/crypto/bcrypt/ec.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -96,8 +96,8 @@ static oe_result_t _fixup_public_key_info_for_import( * offsets from the original */ new_key_info = (PCERT_PUBLIC_KEY_INFO)new_key_info_buffer; new_key_info->Algorithm.pszObjId = - new_key_info_buffer + - (key_info->Algorithm.pszObjId - key_info_base); + (PSTR)new_key_info_buffer + + (key_info->Algorithm.pszObjId - (PSTR)key_info_base); new_key_info->Algorithm.Parameters.pbData = new_key_info_buffer + (key_info->Algorithm.Parameters.pbData - key_info_base); @@ -157,6 +157,8 @@ static oe_result_t _bcrypt_import_ec_private_key( DWORD d_data_size, BCRYPT_KEY_HANDLE* private_key) { + OE_UNUSED(ec_key_magic); + oe_result_t result = OE_UNEXPECTED; DWORD key_blob_size = 0; BYTE* key_blob = NULL; @@ -544,6 +546,8 @@ oe_result_t oe_ec_private_key_sign( uint8_t* signature, size_t* signature_size) { + OE_UNUSED(hash_type); + oe_result_t result = OE_UNEXPECTED; uint8_t* raw_signature = NULL; size_t raw_signature_size = 0; @@ -638,6 +642,8 @@ oe_result_t oe_ec_public_key_verify( const uint8_t* signature, size_t signature_size) { + OE_UNUSED(hash_type); + oe_result_t result = OE_UNEXPECTED; BYTE* x509_signature = NULL; DWORD x509_signature_size = 0; @@ -1013,8 +1019,8 @@ oe_result_t oe_ecdsa_signature_write_der( /* Encode the ECDSA siganture */ { - CERT_ECC_SIGNATURE ecc_sig = { - (DWORD)max_rs_size, r, (DWORD)max_rs_size, s}; + CERT_ECC_SIGNATURE ecc_sig = {{(DWORD)max_rs_size, r}, + {(DWORD)max_rs_size, s}}; BOOL success = CryptEncodeObjectEx( X509_ASN_ENCODING, X509_ECC_SIGNATURE, diff --git a/host/crypto/bcrypt/ec.h b/host/crypto/bcrypt/ec.h index d106e8d0cd..dee63b4e82 100644 --- a/host/crypto/bcrypt/ec.h +++ b/host/crypto/bcrypt/ec.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_BCRYPT_EC_H diff --git a/host/crypto/bcrypt/hmac.c b/host/crypto/bcrypt/hmac.c index 9537858609..e9671fe53e 100644 --- a/host/crypto/bcrypt/hmac.c +++ b/host/crypto/bcrypt/hmac.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "bcrypt.h" diff --git a/host/crypto/bcrypt/key.c b/host/crypto/bcrypt/key.c index 8ce0426db9..7a67654579 100644 --- a/host/crypto/bcrypt/key.c +++ b/host/crypto/bcrypt/key.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/bcrypt/key.h b/host/crypto/bcrypt/key.h index 1bc09adb5a..1321cf0ba2 100644 --- a/host/crypto/bcrypt/key.h +++ b/host/crypto/bcrypt/key.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _HOST_KEY_H diff --git a/host/crypto/bcrypt/pem.c b/host/crypto/bcrypt/pem.c index a74ed80573..0725bbb527 100644 --- a/host/crypto/bcrypt/pem.c +++ b/host/crypto/bcrypt/pem.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "pem.h" @@ -145,7 +145,7 @@ oe_result_t oe_bcrypt_der_to_pem( size_t* pem_size) { oe_result_t result = OE_UNEXPECTED; - uint8_t* pem_local = NULL; + char* pem_local = NULL; DWORD pem_local_size = 0; BOOL success = FALSE; pem_header_info_t* pem_info = NULL; @@ -158,7 +158,7 @@ oe_result_t oe_bcrypt_der_to_pem( /* Check parameters */ if (!der_data || der_data_size == 0 || der_data_size > MAXDWORD || - !pem_data || !pem_size || pem_type >= ARRAYSIZE(_PEM_HEADERS)) + !pem_data || !pem_size || pem_type >= OE_PEM_HEADER_MAX) OE_RAISE(OE_INVALID_PARAMETER); success = CryptBinaryToStringA( @@ -179,7 +179,7 @@ oe_result_t oe_bcrypt_der_to_pem( /* Need to allocate and write the PEM header/footer manually because * BCrypt only supports the cert/CRL/CSR headers. * The size also accounts for LF characters at the end of each line. */ - pem_info = &_PEM_HEADERS[(DWORD)pem_type]; + pem_info = (pem_header_info_t*)&_PEM_HEADERS[(DWORD)pem_type]; assert(pem_info->type == pem_type); assert(pem_info->begin_label_length < OE_PEM_MAX_LEN); assert(pem_info->end_label_length < OE_PEM_MAX_LEN); @@ -188,17 +188,17 @@ oe_result_t oe_bcrypt_der_to_pem( /* Max pem_headers_size is (2 * OE_PEM_MAX_LEN + 2) < MAXDWORD */ DWORD pem_headers_size = (DWORD)( pem_info->begin_label_length + pem_info->end_label_length + 2); - OE_CHECK( - oe_safe_add_u32(pem_local_size, pem_headers_size, &pem_local_size)); + OE_CHECK(oe_safe_add_u32( + pem_local_size, pem_headers_size, (uint32_t*)&pem_local_size)); - pem_local = (uint8_t*)malloc(pem_local_size); + pem_local = (char*)malloc(pem_local_size); if (pem_local == NULL) OE_RAISE(OE_OUT_OF_MEMORY); } { /* Write the begin public key header */ - uint8_t* pos = pem_local; + char* pos = pem_local; DWORD size_left = pem_local_size; OE_CHECK(oe_memcpy_s( @@ -288,14 +288,12 @@ oe_result_t oe_get_next_pem_cert( if (!pem_cert || !pem_cert_size) OE_RAISE(OE_INVALID_PARAMETER); - cert_begin = (unsigned char*)strstr( - (const char*)*pem_read_pos, OE_PEM_BEGIN_CERTIFICATE); + cert_begin = strstr((const char*)*pem_read_pos, OE_PEM_BEGIN_CERTIFICATE); if (!cert_begin || *cert_begin == '\0') return (OE_NOT_FOUND); - cert_end = (unsigned char*)strstr( - (const char*)*pem_read_pos, OE_PEM_END_CERTIFICATE); + cert_end = strstr((const char*)*pem_read_pos, OE_PEM_END_CERTIFICATE); if (!cert_end || *cert_begin == '\0' || cert_end <= cert_begin) return (OE_NOT_FOUND); @@ -339,4 +337,4 @@ oe_result_t oe_get_next_pem_cert( free(found_pem); return result; -} \ No newline at end of file +} diff --git a/host/crypto/bcrypt/pem.h b/host/crypto/bcrypt/pem.h index b324875f0b..2045f0b363 100644 --- a/host/crypto/bcrypt/pem.h +++ b/host/crypto/bcrypt/pem.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_PEM_H @@ -18,6 +18,8 @@ typedef enum _oe_pem_header OE_PEM_HEADER_PRIVATE_KEY = 2, OE_PEM_HEADER_RSA_PRIVATE_KEY = 3, OE_PEM_HEADER_EC_PRIVATE_KEY = 4, + /* Caution: always add new PEM header values here */ + OE_PEM_HEADER_MAX, __OE_PEM_HEADER_MAX = OE_ENUM_MAX, } oe_pem_header_t; diff --git a/host/crypto/bcrypt/random.c b/host/crypto/bcrypt/random.c index eb0e0adc6a..c0d44cc43c 100644 --- a/host/crypto/bcrypt/random.c +++ b/host/crypto/bcrypt/random.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/bcrypt/rsa.c b/host/crypto/bcrypt/rsa.c index 670d297307..38247fc1e7 100644 --- a/host/crypto/bcrypt/rsa.c +++ b/host/crypto/bcrypt/rsa.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -429,7 +429,6 @@ oe_result_t oe_rsa_public_key_equal( bool* equal) { oe_result_t result = OE_UNEXPECTED; - NTSTATUS status = STATUS_UNSUCCESSFUL; /* key1 and key2 are both BCRYPT_RSAKEY_BLOB structures * which should be comparable as raw byte buffers. diff --git a/host/crypto/bcrypt/rsa.h b/host/crypto/bcrypt/rsa.h index 58557c8b48..270e55e585 100644 --- a/host/crypto/bcrypt/rsa.h +++ b/host/crypto/bcrypt/rsa.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_BCRYPT_RSA_H diff --git a/host/crypto/bcrypt/sha.c b/host/crypto/bcrypt/sha.c index b1e5f4871f..748471630f 100644 --- a/host/crypto/bcrypt/sha.c +++ b/host/crypto/bcrypt/sha.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/bcrypt/util.c b/host/crypto/bcrypt/util.c new file mode 100644 index 0000000000..c9c55aed5a --- /dev/null +++ b/host/crypto/bcrypt/util.c @@ -0,0 +1,31 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include + +#include "util.h" + +oe_result_t oe_util_filetime_to_oe_datetime( + const FILETIME* filetime, + oe_datetime_t* datetime) +{ + oe_result_t result = OE_UNEXPECTED; + SYSTEMTIME systime = {0}; + if (!FileTimeToSystemTime(filetime, &systime)) + OE_RAISE_MSG( + OE_INVALID_UTC_DATE_TIME, + "FileTimeToSystemTime failed, err=%#x\n", + GetLastError()); + + datetime->year = systime.wYear; + datetime->month = systime.wMonth; + datetime->day = systime.wDay; + datetime->hours = systime.wHour; + datetime->minutes = systime.wMinute; + datetime->seconds = systime.wSecond; + + result = OE_OK; + +done: + return result; +} diff --git a/host/crypto/bcrypt/util.h b/host/crypto/bcrypt/util.h new file mode 100644 index 0000000000..2ec0f4e310 --- /dev/null +++ b/host/crypto/bcrypt/util.h @@ -0,0 +1,22 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_HOST_CRYPTO_UTIL_H +#define _OE_HOST_CRYPTO_UTIL_H + +#include +#include + +#include + +/** + * Convert FILETIME to oe_datetime_t. + * + * @param filetime[in] The FILETIME to convert. + * @param datetime[out] The corresponding oe_datetime_t. + */ +oe_result_t oe_util_filetime_to_oe_datetime( + const FILETIME* filetime, + oe_datetime_t* datetime); + +#endif /* _OE_HOST_CRYPTO_UTIL_H */ diff --git a/host/crypto/magic.h b/host/crypto/magic.h index 4d9a687110..54a4b1ec46 100644 --- a/host/crypto/magic.h +++ b/host/crypto/magic.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_MAGIC_H diff --git a/host/crypto/openssl/asn1.c b/host/crypto/openssl/asn1.c index babcc2d01f..ab3cf72c12 100644 --- a/host/crypto/openssl/asn1.c +++ b/host/crypto/openssl/asn1.c @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../common/asn1.h" #include #include +#include #include #include #include @@ -11,6 +12,8 @@ #include #include +#include "asn1.h" + OE_STATIC_ASSERT(V_ASN1_CONSTRUCTED == OE_ASN1_TAG_CONSTRUCTED); OE_STATIC_ASSERT(V_ASN1_SEQUENCE == OE_ASN1_TAG_SEQUENCE); OE_STATIC_ASSERT(V_ASN1_INTEGER == OE_ASN1_TAG_INTEGER); @@ -179,3 +182,92 @@ oe_result_t oe_asn1_get_octet_string( done: return result; } + +oe_result_t oe_asn1_string_to_date(const char* str, oe_datetime_t* date) +{ + oe_result_t result = OE_UNEXPECTED; + char month[4]; + + memset(date, 0, sizeof(oe_datetime_t)); + + /* Convert the string to oe_datetime_t struct */ + if (sscanf( + str, + "%3s %02u %02u:%02u:%02u %04u", + month, + &date->day, + &date->hours, + &date->minutes, + &date->seconds, + &date->year) != 6) + { + OE_RAISE(OE_FAILURE); + } + + /* Convert the month string to integer */ + { + static const char* _month[] = {"Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec"}; + + date->month = UINT_MAX; + + for (uint32_t i = 0; i < OE_COUNTOF(_month); i++) + { + if (strncmp(month, _month[i], 3) == 0) + { + date->month = i + 1; + break; + } + } + + if (date->month == UINT_MAX) + OE_RAISE(OE_FAILURE); + } + + result = OE_OK; + +done: + return result; +} + +oe_result_t oe_asn1_time_to_date(const ASN1_TIME* time, oe_datetime_t* date) +{ + oe_result_t result = OE_UNEXPECTED; + struct tm; + BIO* bio = NULL; + BUF_MEM* mem; + const char null_terminator = '\0'; + + if (!(bio = BIO_new(BIO_s_mem()))) + OE_RAISE(OE_CRYPTO_ERROR); + + if (!ASN1_TIME_print(bio, time)) + OE_RAISE(OE_CRYPTO_ERROR); + + if (!BIO_get_mem_ptr(bio, &mem)) + OE_RAISE(OE_CRYPTO_ERROR); + + if (BIO_write(bio, &null_terminator, sizeof(null_terminator)) <= 0) + OE_RAISE(OE_CRYPTO_ERROR); + + OE_CHECK(oe_asn1_string_to_date(mem->data, date)); + + result = OE_OK; + +done: + + if (bio) + BIO_free(bio); + + return result; +} diff --git a/host/crypto/openssl/asn1.h b/host/crypto/openssl/asn1.h new file mode 100644 index 0000000000..182b86b4df --- /dev/null +++ b/host/crypto/openssl/asn1.h @@ -0,0 +1,28 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_HOST_CRYPTO_ASN1_OPENSSL_H +#define _OE_HOST_CRYPTO_ASN1_OPENSSL_H + +#include +#include +#include + +/** + * Parse a string into a oe_datetime_t: example: "May 30 10:23:42 2018 GMT". + * This format is specific to OpenSSL: produced by ASN1_TIME_print(). + * + * @param str[in] string to parse into a oe_datetime_t + * @param date[out] output datetime. + */ +oe_result_t oe_asn1_string_to_date(const char* str, oe_datetime_t* date); + +/** + * Convert an ASN1_TIME in openSSL format ta a oe_datetime_t. + * + * @param time[in] The time to convert. + * @param date[out] The output datetime. + */ +oe_result_t oe_asn1_time_to_date(const ASN1_TIME* time, oe_datetime_t* date); + +#endif /* _OE_HOST_CRYPTO_ASN1_OPENSSL_H */ diff --git a/host/crypto/openssl/cert.c b/host/crypto/openssl/cert.c index 97833dca13..b914fd65f2 100644 --- a/host/crypto/openssl/cert.c +++ b/host/crypto/openssl/cert.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -17,6 +17,7 @@ #include #include #include "../magic.h" +#include "asn1.h" #include "crl.h" #include "ec.h" #include "init.h" @@ -958,3 +959,44 @@ oe_result_t oe_cert_find_extension( done: return result; } + +oe_result_t oe_cert_get_validity_dates( + const oe_cert_t* cert, + oe_datetime_t* not_before, + oe_datetime_t* not_after) +{ + oe_result_t result = OE_UNEXPECTED; + const cert_t* impl = (const cert_t*)cert; + + if (!_cert_is_valid(impl)) + OE_RAISE(OE_INVALID_PARAMETER); + + if (not_before) + { + const ASN1_TIME* time; + + memset(not_before, 0, sizeof(oe_datetime_t)); + + if (!(time = X509_get_notBefore(impl->x509))) + OE_RAISE(OE_CRYPTO_ERROR); + + OE_CHECK(oe_asn1_time_to_date(time, not_before)); + } + + if (not_after) + { + const ASN1_TIME* time; + + memset(not_after, 0, sizeof(oe_datetime_t)); + + if (!(time = X509_get_notAfter(impl->x509))) + OE_RAISE(OE_CRYPTO_ERROR); + + OE_CHECK(oe_asn1_time_to_date(time, not_after)); + } + + result = OE_OK; +done: + + return result; +} diff --git a/host/crypto/openssl/crl.c b/host/crypto/openssl/crl.c index d38ad214d7..b6af8c80c8 100644 --- a/host/crypto/openssl/crl.c +++ b/host/crypto/openssl/crl.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -14,6 +14,7 @@ #include #include "../magic.h" +#include "asn1.h" #include "crl.h" #if OPENSSL_VERSION_NUMBER < 0x10100000L @@ -118,99 +119,6 @@ oe_result_t oe_crl_free(oe_crl_t* crl) return result; } -// Parse a string into a oe_datetime_t: example: "May 30 10:23:42 2018 GMT". -// This format is specific to OpenSSL: produced by ASN1_TIME_print(). -static oe_result_t _string_to_date(const char* str, oe_datetime_t* date) -{ - oe_result_t result = OE_UNEXPECTED; - char month[4]; - - memset(date, 0, sizeof(oe_datetime_t)); - - /* Convert the string to oe_datetime_t struct */ - if (sscanf( - str, - "%3s %02u %02u:%02u:%02u %04u", - month, - &date->day, - &date->hours, - &date->minutes, - &date->seconds, - &date->year) != 6) - { - OE_RAISE(OE_FAILURE); - } - - /* Convert the month string to integer */ - { - static const char* _month[] = {"Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec"}; - - date->month = UINT_MAX; - - for (uint32_t i = 0; i < OE_COUNTOF(_month); i++) - { - if (strncmp(month, _month[i], 3) == 0) - { - date->month = i + 1; - break; - } - } - - if (date->month == UINT_MAX) - OE_RAISE(OE_FAILURE); - } - - result = OE_OK; - -done: - return result; -} - -static oe_result_t _asn1_time_to_date( - const ASN1_TIME* time, - oe_datetime_t* date) -{ - oe_result_t result = OE_UNEXPECTED; - struct tm; - BIO* bio = NULL; - BUF_MEM* mem; - const char null_terminator = '\0'; - - if (!(bio = BIO_new(BIO_s_mem()))) - OE_RAISE(OE_CRYPTO_ERROR); - - if (!ASN1_TIME_print(bio, time)) - OE_RAISE(OE_CRYPTO_ERROR); - - if (!BIO_get_mem_ptr(bio, &mem)) - OE_RAISE(OE_CRYPTO_ERROR); - - if (BIO_write(bio, &null_terminator, sizeof(null_terminator)) <= 0) - OE_RAISE(OE_CRYPTO_ERROR); - - OE_CHECK(_string_to_date(mem->data, date)); - - result = OE_OK; - -done: - - if (bio) - BIO_free(bio); - - return result; -} - oe_result_t oe_crl_get_update_dates( const oe_crl_t* crl, oe_datetime_t* last, @@ -235,7 +143,7 @@ oe_result_t oe_crl_get_update_dates( if (!(time = X509_CRL_get0_lastUpdate(impl->crl))) OE_RAISE(OE_CRYPTO_ERROR); - OE_CHECK(_asn1_time_to_date(time, last)); + OE_CHECK(oe_asn1_time_to_date(time, last)); } if (next) @@ -245,7 +153,7 @@ oe_result_t oe_crl_get_update_dates( if (!(time = X509_CRL_get0_nextUpdate(impl->crl))) OE_RAISE(OE_CRYPTO_ERROR); - OE_CHECK(_asn1_time_to_date(time, next)); + OE_CHECK(oe_asn1_time_to_date(time, next)); } result = OE_OK; diff --git a/host/crypto/openssl/crl.h b/host/crypto/openssl/crl.h index b9418dab04..7823e260db 100644 --- a/host/crypto/openssl/crl.h +++ b/host/crypto/openssl/crl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_CRL_H diff --git a/host/crypto/openssl/ec.c b/host/crypto/openssl/ec.c index b54cabb8f8..cff0a9ffce 100644 --- a/host/crypto/openssl/ec.c +++ b/host/crypto/openssl/ec.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/openssl/ec.h b/host/crypto/openssl/ec.h index df841aec8e..989d452fb9 100644 --- a/host/crypto/openssl/ec.h +++ b/host/crypto/openssl/ec.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_EC_H diff --git a/host/crypto/openssl/hmac.c b/host/crypto/openssl/hmac.c index ff43d22a41..b0bbfbd957 100644 --- a/host/crypto/openssl/hmac.c +++ b/host/crypto/openssl/hmac.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/openssl/init.c b/host/crypto/openssl/init.c index 44a8a0bb20..bd2dd08fad 100644 --- a/host/crypto/openssl/init.c +++ b/host/crypto/openssl/init.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "init.h" diff --git a/host/crypto/openssl/init.h b/host/crypto/openssl/init.h index 33ebee65a3..09891d8641 100644 --- a/host/crypto/openssl/init.h +++ b/host/crypto/openssl/init.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CRYPTO_HOST_INIT_H diff --git a/host/crypto/openssl/key.c b/host/crypto/openssl/key.c index e455298287..5eb3d4d590 100644 --- a/host/crypto/openssl/key.c +++ b/host/crypto/openssl/key.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "key.h" diff --git a/host/crypto/openssl/key.h b/host/crypto/openssl/key.h index abe7e1cf98..d3c272fe4c 100644 --- a/host/crypto/openssl/key.h +++ b/host/crypto/openssl/key.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _HOST_KEY_H diff --git a/host/crypto/openssl/random.c b/host/crypto/openssl/random.c index dee89e9430..68f22fff72 100644 --- a/host/crypto/openssl/random.c +++ b/host/crypto/openssl/random.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/openssl/rsa.c b/host/crypto/openssl/rsa.c index 6b7cc43bbe..bd9a813a77 100644 --- a/host/crypto/openssl/rsa.c +++ b/host/crypto/openssl/rsa.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/crypto/openssl/rsa.h b/host/crypto/openssl/rsa.h index 271bf9072c..f746235222 100644 --- a/host/crypto/openssl/rsa.h +++ b/host/crypto/openssl/rsa.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_OPENSSL_RSA_H diff --git a/host/crypto/openssl/sha.c b/host/crypto/openssl/sha.c index 3fc51ba0a5..53b7ac2f87 100644 --- a/host/crypto/openssl/sha.c +++ b/host/crypto/openssl/sha.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -70,3 +70,48 @@ oe_result_t oe_sha256_final(oe_sha256_context_t* context, OE_SHA256* sha256) done: return result; } + +oe_result_t oe_sha256_save( + const oe_sha256_context_t* context, + uint32_t* H, + uint32_t* N) +{ + oe_result_t result = OE_INVALID_PARAMETER; + + if (!context || !H || !N) + OE_RAISE(OE_INVALID_PARAMETER); + + oe_sha256_context_impl_t* impl = (oe_sha256_context_impl_t*)context; + + for (size_t i = 0; i < 8; i++) + H[i] = impl->ctx.h[i]; + + N[0] = impl->ctx.Nl; + N[1] = impl->ctx.Nh; + +done: + return result; +} + +oe_result_t oe_sha256_restore( + oe_sha256_context_t* context, + const uint32_t* H, + const uint32_t* N) +{ + oe_result_t result = OE_INVALID_PARAMETER; + + if (!context || !H || !N) + OE_RAISE(OE_INVALID_PARAMETER); + + oe_sha256_context_impl_t* impl = (oe_sha256_context_impl_t*)context; + oe_sha256_init(context); + + for (size_t i = 0; i < 8; i++) + impl->ctx.h[i] = H[i]; + + impl->ctx.Nl = N[0]; + impl->ctx.Nh = N[1]; + +done: + return result; +} \ No newline at end of file diff --git a/host/crypto/rsa.h b/host/crypto/rsa.h index 327a60f9cf..c97caadc63 100644 --- a/host/crypto/rsa.h +++ b/host/crypto/rsa.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_CRYPTO_RSA_H diff --git a/host/dupenv.c b/host/dupenv.c index 1b87636f28..38c336b4c4 100644 --- a/host/dupenv.c +++ b/host/dupenv.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "dupenv.h" diff --git a/host/dupenv.h b/host/dupenv.h index 1e99b84df0..f70c28270a 100644 --- a/host/dupenv.h +++ b/host/dupenv.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_DUPENV_H diff --git a/host/error.c b/host/error.c index 8f6bf25263..7f6a4e02fd 100644 --- a/host/error.c +++ b/host/error.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/files.c b/host/files.c index 114e20108e..848544d396 100644 --- a/host/files.c +++ b/host/files.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/fopen.c b/host/fopen.c index b16e87ef20..f92d2342ab 100644 --- a/host/fopen.c +++ b/host/fopen.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "fopen.h" diff --git a/host/fopen.h b/host/fopen.h index 1325aa012d..8a0c2ae4bb 100644 --- a/host/fopen.h +++ b/host/fopen.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_FOPEN_H diff --git a/host/hexdump.c b/host/hexdump.c index 0bbb4ea3d0..374ade33a1 100644 --- a/host/hexdump.c +++ b/host/hexdump.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/hostthread.h b/host/hostthread.h index 65f206a5f2..09367b3af7 100644 --- a/host/hostthread.h +++ b/host/hostthread.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -11,7 +11,9 @@ #define _HOSTTHREAD_H #include +#include #include +#include #if __GNUC__ #include @@ -28,8 +30,6 @@ OE_EXTERNC_BEGIN typedef pthread_once_t oe_once_type; #define OE_H_ONCE_INITIALIZER PTHREAD_ONCE_INIT -typedef pthread_t oe_thread; - typedef pthread_mutex_t oe_mutex; #define OE_H_MUTEX_INITIALIZER PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP @@ -40,8 +40,6 @@ typedef pthread_key_t oe_thread_key; typedef INIT_ONCE oe_once_type; #define OE_H_ONCE_INITIALIZER INIT_ONCE_STATIC_INIT -typedef DWORD oe_thread; - typedef HANDLE oe_mutex; #define OE_H_MUTEX_INITIALIZER INVALID_HANDLE_VALUE @@ -49,6 +47,25 @@ typedef DWORD oe_thread_key; #endif +/** + * Create a platform-specific thread. + * + * @param func The pointer to the start routine. + * @param arg The argument to the start routine. + * + * @returns Returns zero on success. + */ +int oe_thread_create(oe_thread_t* thread, void* (*func)(void*), void* arg); + +/** + * Join a platform-specific thread. + * + * @param thread The thread to be joined. + * + * @returns Returns zero on success. + */ +int oe_thread_join(oe_thread_t thread); + /** * Returns the identifier of the current thread. * @@ -57,7 +74,7 @@ typedef DWORD oe_thread_key; * * @returns Returns the thread identifier of the calling thread. */ -oe_thread oe_thread_self(void); +oe_thread_t oe_thread_self(void); /** * Checks two thread identifiers for equality. @@ -70,7 +87,7 @@ oe_thread oe_thread_self(void); * * @returns Returns non-zero if the thread identifiers are equal. */ -int oe_thread_equal(oe_thread thread1, oe_thread thread2); +int oe_thread_equal(oe_thread_t thread1, oe_thread_t thread2); /** * Calls the given function exactly once. diff --git a/host/linux/hostthread.c b/host/linux/hostthread.c index 644755768a..bbba03cd00 100644 --- a/host/linux/hostthread.c +++ b/host/linux/hostthread.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../hostthread.h" @@ -13,13 +13,22 @@ ** **============================================================================== */ +int oe_thread_create(oe_thread_t* thread, void* (*func)(void*), void* arg) +{ + return pthread_create(thread, NULL, func, arg); +} + +int oe_thread_join(oe_thread_t thread) +{ + return pthread_join(thread, NULL); +} -oe_thread oe_thread_self(void) +oe_thread_t oe_thread_self(void) { return pthread_self(); } -int oe_thread_equal(oe_thread thread1, oe_thread thread2) +int oe_thread_equal(oe_thread_t thread1, oe_thread_t thread2) { return pthread_equal(thread1, thread2); } diff --git a/host/linux/syscall.c b/host/linux/syscall.c index ef8f3812a4..85254882a6 100644 --- a/host/linux/syscall.c +++ b/host/linux/syscall.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -21,6 +21,7 @@ #include #include #include +#include "../../common/oe_host_socket.h" #include "../host/strings.h" #include "syscall_u.h" @@ -792,25 +793,6 @@ int oe_syscall_kill_ocall(int pid, int signum) **============================================================================== */ -#define GETADDRINFO_HANDLE_MAGIC 0xed11d13a - -typedef struct _getaddrinfo_handle -{ - uint32_t magic; - struct addrinfo* res; - struct addrinfo* next; -} getaddrinfo_handle_t; - -static getaddrinfo_handle_t* _cast_getaddrinfo_handle(void* handle_) -{ - getaddrinfo_handle_t* handle = (getaddrinfo_handle_t*)handle_; - - if (!handle || handle->magic != GETADDRINFO_HANDLE_MAGIC || !handle->res) - return NULL; - - return handle; -} - int oe_syscall_getaddrinfo_open_ocall( const char* node, const char* service, @@ -870,75 +852,22 @@ int oe_syscall_getaddrinfo_read_ocall( size_t* ai_canonnamelen, char* ai_canonname) { - int ret = -1; - getaddrinfo_handle_t* handle = _cast_getaddrinfo_handle((void*)handle_); - - errno = 0; - - if (!handle || !ai_flags || !ai_family || !ai_socktype || !ai_protocol || - !ai_addrlen || !ai_canonnamelen) - { - errno = EINVAL; - goto done; - } - - if (!ai_addr && ai_addrlen_in) - { - errno = EINVAL; - goto done; - } - - if (!ai_canonname && ai_canonnamelen_in) - { - errno = EINVAL; - goto done; - } + int err_no = 0; + int ret = _getaddrinfo_read( + handle_, + ai_flags, + ai_family, + ai_socktype, + ai_protocol, + ai_addrlen_in, + ai_addrlen, + ai_addr, + ai_canonnamelen_in, + ai_canonnamelen, + ai_canonname, + &err_no); + errno = err_no; - if (handle->next) - { - struct addrinfo* p = handle->next; - - *ai_flags = p->ai_flags; - *ai_family = p->ai_family; - *ai_socktype = p->ai_socktype; - *ai_protocol = p->ai_protocol; - *ai_addrlen = p->ai_addrlen; - - if (p->ai_canonname) - *ai_canonnamelen = strlen(p->ai_canonname) + 1; - else - *ai_canonnamelen = 0; - - if (*ai_addrlen > ai_addrlen_in) - { - errno = ENAMETOOLONG; - goto done; - } - - if (*ai_canonnamelen > ai_canonnamelen_in) - { - errno = ENAMETOOLONG; - goto done; - } - - memcpy(ai_addr, p->ai_addr, *ai_addrlen); - - if (p->ai_canonname) - memcpy(ai_canonname, p->ai_canonname, *ai_canonnamelen); - - handle->next = handle->next->ai_next; - - ret = 0; - goto done; - } - else - { - /* Done */ - ret = 1; - goto done; - } - -done: return ret; } diff --git a/host/linux/time.c b/host/linux/time.c index 1e7930049f..6bb45d219f 100644 --- a/host/linux/time.c +++ b/host/linux/time.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/linux/windows.c b/host/linux/windows.c index 3c4b461290..34457863c9 100644 --- a/host/linux/windows.c +++ b/host/linux/windows.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "windows.h" diff --git a/host/linux/windows.h b/host/linux/windows.h index 40bed4f14a..163e7c1100 100644 --- a/host/linux/windows.h +++ b/host/linux/windows.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_WINDOWS_H diff --git a/host/memalign.c b/host/memalign.c index 41253f4ee1..c87b5e7124 100644 --- a/host/memalign.c +++ b/host/memalign.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "memalign.h" diff --git a/host/memalign.h b/host/memalign.h index 72861c1407..204dd206c5 100644 --- a/host/memalign.h +++ b/host/memalign.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_MEMALIGN_H diff --git a/host/ocalls.c b/host/ocalls.c index 144eb0c1fe..c93149bd61 100644 --- a/host/ocalls.c +++ b/host/ocalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/ocalls.h b/host/ocalls.h index c23873631f..12ce6032a7 100644 --- a/host/ocalls.h +++ b/host/ocalls.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_OCALLS_H @@ -12,4 +12,6 @@ void HandleFree(uint64_t arg); void oe_handle_sleep(uint64_t arg_in); void oe_handle_get_time(uint64_t arg_in, uint64_t* arg_out); +void oe_handle_wake_host_worker(uint64_t arg_in); + #endif /* _OE_HOST_OCALLS_H */ diff --git a/host/optee/linux/enclave.c b/host/optee/linux/enclave.c index 06c8c80019..a54f19ba8b 100644 --- a/host/optee/linux/enclave.c +++ b/host/optee/linux/enclave.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -220,6 +220,9 @@ static TEEC_Result _handle_generic_rpc( *(uint64_t*)input_buffer, (uint64_t*)output_buffer); break; + case OE_OCALL_WAKE_HOST_WORKER: + return TEEC_ERROR_NOT_SUPPORTED; + default: { /* No function found with the number */ @@ -399,10 +402,10 @@ oe_result_t oe_create_enclave( const char* enclave_path, oe_enclave_type_t enclave_type, uint32_t flags, - const void* config, - uint32_t config_size, + const oe_enclave_setting_t* settings, + uint32_t setting_count, const oe_ocall_func_t* ocall_table, - uint32_t ocall_table_size, + uint32_t ocall_count, oe_enclave_t** enclave_out) { oe_result_t result = OE_UNEXPECTED; @@ -425,10 +428,11 @@ oe_result_t oe_create_enclave( if (!enclave_path || !enclave_out || ((enclave_type != OE_ENCLAVE_TYPE_OPTEE) && (enclave_type != OE_ENCLAVE_TYPE_AUTO)) || + (setting_count > 0 && settings == NULL) || + (setting_count == 0 && settings != NULL) || (flags & OE_ENCLAVE_FLAG_RESERVED) || (!(flags & OE_ENCLAVE_FLAG_SIMULATE) && - (flags & OE_ENCLAVE_FLAG_DEBUG)) || - config || config_size > 0) + (flags & OE_ENCLAVE_FLAG_DEBUG))) OE_RAISE(OE_INVALID_PARAMETER); /* Convert the path into a TEE UUID. */ @@ -482,7 +486,7 @@ oe_result_t oe_create_enclave( enclave->path = strndup( enclave_path, 38); // 37 + 1 = length of a UUID + NULL terminator enclave->ocalls = (const oe_ocall_func_t*)ocall_table; - enclave->num_ocalls = ocall_table_size; + enclave->num_ocalls = ocall_count; *enclave_out = enclave; result = OE_OK; diff --git a/host/optee/linux/enclave.h b/host/optee/linux/enclave.h index 3301ed67f7..a9f25c18ba 100644 --- a/host/optee/linux/enclave.h +++ b/host/optee/linux/enclave.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_ENCLAVE_H diff --git a/host/optee/log.c b/host/optee/log.c index 0b05012570..5f7d96da42 100644 --- a/host/optee/log.c +++ b/host/optee/log.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/result.c b/host/result.c index ce2d83d42c..90f8b7b785 100644 --- a/host/result.c +++ b/host/result.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../common/result.c" diff --git a/host/sgx/asmdefs.h b/host/sgx/asmdefs.h index 4efe93bee2..292ed0bce7 100644 --- a/host/sgx/asmdefs.h +++ b/host/sgx/asmdefs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _ASMDEFS_H @@ -62,13 +62,13 @@ int __oe_dispatch_ocall( #endif #ifndef __ASSEMBLER__ -int _oe_host_stack_bridge( +int __oe_host_stack_bridge( uint64_t arg1, uint64_t arg2, uint64_t* arg1_out, uint64_t* arg2_out, void* tcs, - void* rsp); + oe_enclave_t* enclave); #endif #ifndef __ASSEMBLER__ @@ -80,10 +80,12 @@ typedef struct _oe_host_ocall_frame #endif #ifndef __ASSEMBLER__ +OE_EXPORT void oe_notify_ocall_start(oe_host_ocall_frame_t* frame_pointer, void* tcs); #endif #ifndef __ASSEMBLER__ +OE_EXPORT void oe_notify_ocall_end(oe_host_ocall_frame_t* frame_pointer, void* tcs); #endif diff --git a/host/sgx/calls.c b/host/sgx/calls.c index 4c21d96ae3..e2ff6164b9 100644 --- a/host/sgx/calls.c +++ b/host/sgx/calls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "../calls.h" #include "../hostthread.h" @@ -114,7 +115,6 @@ static oe_result_t _enter_sim( { oe_result_t result = OE_UNEXPECTED; sgx_tcs_t* tcs = (sgx_tcs_t*)tcs_; - ThreadBinding* binding = GetThreadBinding(); td_t* td = NULL; /* Reject null parameters */ @@ -126,22 +126,8 @@ static oe_result_t _enter_sim( if (!tcs->u.entry) OE_RAISE(OE_NOT_FOUND); - /* Save old GS and FS register bases */ - binding->host_gs = oe_get_gs_register_base(); - binding->host_fs = oe_get_fs_register_base(); - - /* Change GS and FS registers to the values for the enclave thread. At this - * point thread-locals, pthread, libc etc won't work within the host thread - * since they depend on FS register. - * This means that when the enclave makes an ocall, the GS and FS registers - * must be immediately restored upon entry to host. - * See __oe_dispatch_ocall. - */ - td = (td_t*)(enclave->addr + tcs->gsbase); - oe_set_gs_register_base(td); - oe_set_fs_register_base((void*)(enclave->addr + tcs->fsbase)); - /* Set td_t.simulate flag */ + td = (td_t*)(enclave->addr + tcs->gsbase); td->simulate = true; /* Call into enclave */ @@ -152,13 +138,6 @@ static oe_result_t _enter_sim( *arg4 = 0; oe_enter_sim(tcs, aep, arg1, arg2, arg3, arg4, enclave); - - /* Restore GS and GS registers. After this, host side library calls can be - * safely called. - */ - oe_set_fs_register_base(binding->host_fs); - oe_set_gs_register_base(binding->host_gs); - result = OE_OK; done: @@ -245,16 +224,14 @@ static oe_result_t _do_eenter( /* **============================================================================== ** -** _handle_call_host_function() +** oe_handle_call_host_function() ** ** Handle calls from the enclave. ** **============================================================================== */ -static oe_result_t _handle_call_host_function( - uint64_t arg, - oe_enclave_t* enclave) +oe_result_t oe_handle_call_host_function(uint64_t arg, oe_enclave_t* enclave) { oe_call_host_function_args_t* args_ptr = NULL; oe_result_t result = OE_OK; @@ -320,6 +297,7 @@ static oe_result_t _handle_call_host_function( &args_ptr->output_bytes_written); // The ocall succeeded. + OE_ATOMIC_MEMORY_BARRIER_RELEASE(); args_ptr->result = OE_OK; result = OE_OK; done: @@ -339,13 +317,13 @@ static const char* oe_ocall_str(oe_func_t ocall) "FREE", "SLEEP", "GET_TIME", + "WAKE_HOST_WORKER", }; // clang-format on OE_STATIC_ASSERT(OE_OCALL_BASE + OE_COUNTOF(func_names) == OE_OCALL_MAX); - if (ocall >= OE_OCALL_BASE && - ocall < (OE_OCALL_BASE + OE_COUNTOF(func_names))) + if (ocall >= OE_OCALL_BASE && ocall < OE_OCALL_MAX) return func_names[ocall - OE_OCALL_BASE]; else return "UNKNOWN"; @@ -359,14 +337,14 @@ static const char* oe_ecall_str(oe_func_t ecall) "DESTRUCTOR", "INIT_ENCLAVE", "CALL_ENCLAVE_FUNCTION", - "VIRTUAL_EXCEPTION_HANDLER" + "VIRTUAL_EXCEPTION_HANDLER", + "INIT_CONTEXT_SWITCHLESS", }; // clang-format on OE_STATIC_ASSERT(OE_ECALL_BASE + OE_COUNTOF(func_names) == OE_ECALL_MAX); - if (ecall >= OE_ECALL_BASE && - ecall < (OE_ECALL_BASE + OE_COUNTOF(func_names))) + if (ecall >= OE_ECALL_BASE && ecall < OE_ECALL_MAX) return func_names[ecall - OE_ECALL_BASE]; else return "UNKNOWN"; @@ -408,7 +386,7 @@ static oe_result_t _handle_ocall( switch ((oe_func_t)func) { case OE_OCALL_CALL_HOST_FUNCTION: - _handle_call_host_function(arg_in, enclave); + OE_CHECK(oe_handle_call_host_function(arg_in, enclave)); break; case OE_OCALL_MALLOC: @@ -435,6 +413,10 @@ static oe_result_t _handle_ocall( oe_handle_get_time(arg_in, arg_out); break; + case OE_OCALL_WAKE_HOST_WORKER: + oe_handle_wake_host_worker(arg_in); + break; + default: { /* No function found with the number */ @@ -509,13 +491,6 @@ int __oe_dispatch_ocall( break; } } - - /** - * Restore FS and GS registers when making an OCALL. - * This makes sure that thread-locals, libc on host work. - */ - oe_set_fs_register_base(binding->host_fs); - oe_set_gs_register_base(binding->host_gs); } else { @@ -529,14 +504,6 @@ int __oe_dispatch_ocall( // Restore the binding. _set_thread_binding(binding); - - if (enclave->simulate) - { - // Prior to returning back to the enclave, set the GS and FS - // registers to their values for the enclave thread. - oe_set_fs_register_base((void*)(enclave->addr + tcs->fsbase)); - oe_set_gs_register_base((void*)(enclave->addr + tcs->gsbase)); - } return 0; } @@ -567,7 +534,7 @@ static void* _assign_tcs(oe_enclave_t* enclave) { void* tcs = NULL; size_t i; - oe_thread thread = oe_thread_self(); + oe_thread_t thread = oe_thread_self(); oe_mutex_lock(&enclave->lock); { @@ -828,10 +795,13 @@ oe_result_t oe_switchless_call_enclave_function( /* ** These two functions are needed to notify the debugger. They should not be ** optimized out even though they don't do anything in here. +** OE_EXPORT is used to retain these function irrespective of linker +** optimizations. */ OE_NO_OPTIMIZE_BEGIN +OE_EXPORT OE_NEVER_INLINE void oe_notify_ocall_start( oe_host_ocall_frame_t* frame_pointer, void* tcs) @@ -842,6 +812,7 @@ OE_NEVER_INLINE void oe_notify_ocall_start( return; } +OE_EXPORT OE_NEVER_INLINE void oe_notify_ocall_end( oe_host_ocall_frame_t* frame_pointer, void* tcs) diff --git a/host/sgx/cpuid.h b/host/sgx/cpuid.h index 4179e4662a..0b18b25388 100644 --- a/host/sgx/cpuid.h +++ b/host/sgx/cpuid.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CPUIDCOUNT_H @@ -29,12 +29,12 @@ static inline void oe_get_cpuid( #elif defined(_MSC_VER) int registers[4] = {0}; - __cpuidex(registers, __leaf, __subleaf); + __cpuidex(registers, (int)__leaf, (int)__subleaf); - *__eax = registers[0]; - *__ebx = registers[1]; - *__ecx = registers[2]; - *__edx = registers[3]; + *__eax = (unsigned int)registers[0]; + *__ebx = (unsigned int)registers[1]; + *__ecx = (unsigned int)registers[2]; + *__edx = (unsigned int)registers[3]; #endif } #endif /* _OE_CPUIDCOUNT_H */ diff --git a/host/sgx/create.c b/host/sgx/create.c index 71d3977893..f99e3597bd 100644 --- a/host/sgx/create.c +++ b/host/sgx/create.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../strings.h" @@ -44,11 +44,14 @@ static char* get_fullpath(const char* path) #include #include #include +#include #include +#include #include #include #include #include "../memalign.h" +#include "../signkey.h" #include "cpuid.h" #include "enclave.h" #include "exception.h" @@ -165,7 +168,7 @@ static oe_result_t _add_control_pages( * page2 - state-save-area (SSA) slot (zero-filled) * page3 - state-save-area (SSA) slot (zero-filled) * page4 - guard page - * page5 - segment space for fs or gs register (holds thread data). + * page5 - thread local storage page. * page6 - extra segment space for thread-specific data. */ @@ -204,9 +207,6 @@ static oe_result_t _add_control_pages( /* The entry point for the program (from ELF) */ tcs->oentry = entry; - /* GS segment: points to page following SSA slots (page[3]) */ - tcs->gsbase = *vaddr + (4 * OE_PAGE_SIZE); - /* FS segment: Used for thread-local variables. * The reserved (unused) space in td_t is used for thread-local * variables. @@ -215,6 +215,16 @@ static oe_result_t _add_control_pages( */ tcs->fsbase = *vaddr + (5 * OE_PAGE_SIZE); + /* The existing Windows SGX enclave debugger finds the start of the + * thread data by assuming that it is located at the start of the GS + * segment. i.e. it adds the enclave base address and the offset to the + * GS segment stored in TCS.OGSBASGX. OE SDK uses the FS segment for + * this purpose and has no separate use for the GS register, so we + * point it at the FS segment to preserve the Windows debugger + * behavior. + */ + tcs->gsbase = tcs->fsbase; + /* Set to maximum value */ tcs->fslimit = 0xFFFFFFFF; @@ -401,6 +411,51 @@ static oe_result_t _initialize_enclave(oe_enclave_t* enclave) return result; } +/* +** _config_enclave() +** +** Config the enclave with an array of settings. +*/ + +static oe_result_t _configure_enclave( + oe_enclave_t* enclave, + const oe_enclave_setting_t* settings, + uint32_t setting_count) +{ + oe_result_t result = OE_UNEXPECTED; + + for (uint32_t i = 0; i < setting_count; i++) + { + switch (settings[i].setting_type) + { + // Configure the switchless ocalls, such as the number of workers. + case OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS: + { + size_t max_host_workers = + settings[i].u.context_switchless_setting->max_host_workers; + size_t max_enclave_workers = + settings[i] + .u.context_switchless_setting->max_enclave_workers; + + // Switchless ecalls are not enabled yet. Make sure the max + // number of enclave workers is always 0. + if (max_enclave_workers != 0) + OE_RAISE(OE_INVALID_PARAMETER); + + OE_CHECK( + oe_start_switchless_manager(enclave, max_host_workers)); + break; + } + default: + OE_RAISE(OE_INVALID_PARAMETER); + } + } + result = OE_OK; + +done: + return result; +} + oe_result_t oe_sgx_validate_enclave_properties( const oe_sgx_enclave_properties_t* properties, const char** field_name) @@ -492,10 +547,141 @@ oe_result_t oe_sgx_validate_enclave_properties( return result; } +static oe_result_t _add_extra_data_pages( + oe_sgx_load_context_t* context, + uint64_t enclave_addr, + const oe_page_t* pages, + const size_t num_pages, + uint64_t* vaddr) +{ + oe_result_t result = OE_UNEXPECTED; + + if (!context || !vaddr) + OE_RAISE(OE_INVALID_PARAMETER); + + /* Add any data pages as regular-read-only pages. */ + if (pages && num_pages) + { + uint64_t size = num_pages * OE_PAGE_SIZE; + assert((size & (OE_PAGE_SIZE - 1)) == 0); + + for (size_t i = 0; i < num_pages; i++) + { + uint64_t addr = enclave_addr + *vaddr; + uint64_t src = (uint64_t)&pages[i]; + uint64_t flags = SGX_SECINFO_REG | SGX_SECINFO_R; + bool extend = true; + + OE_CHECK(oe_sgx_load_enclave_data( + context, enclave_addr, addr, src, flags, extend)); + (*vaddr) += sizeof(oe_page_t); + } + } + + result = OE_OK; + +done: + return result; +} + +static uint64_t eeid_pages_size(const oe_eeid_t* eeid) +{ + if (!eeid || eeid->data_size == 0) + return 0; + else + return oe_round_up_to_page_size(sizeof(oe_eeid_t) + eeid->data_size); +} + +static oe_result_t _patch_eeid_symbols( + oe_enclave_image_t* oeimage, + uint64_t enclave_end, + const oe_eeid_t* eeid) +{ + elf64_sym_t sym_rva = {0}, sym_sz = {0}; + + if (eeid && eeid->data_size > 0) + { + const elf64_t* eimg = &oeimage->u.elf.elf; + if (elf64_find_symbol_by_name(eimg, "_eeid_rva", &sym_rva) == 0) + { + uint64_t pgsz = eeid_pages_size(eeid); + uint64_t* sym_rva_addr = NULL; + sym_rva_addr = (uint64_t*)(oeimage->image_base + sym_rva.st_value); + *sym_rva_addr = eeid->data_size == 0 ? 0 : enclave_end - pgsz; + } + if (elf64_find_symbol_by_name(eimg, "_eeid_size", &sym_sz) == 0) + { + uint64_t* sym_sz_addr = NULL; + sym_sz_addr = (uint64_t*)(oeimage->image_base + sym_sz.st_value); + *sym_sz_addr = + eeid->data_size == 0 ? 0 : sizeof(oe_eeid_t) + eeid->data_size; + } + } + + return OE_OK; +} + +static oe_result_t _add_eeid_pages( + oe_sgx_load_context_t* context, + oe_enclave_t* enclave, + uint64_t enclave_end, + const oe_sgx_enclave_properties_t* properties, + uint64_t* vaddr, + oe_eeid_t* eeid) +{ + oe_result_t result = OE_OK; + + if (eeid && eeid->data_size > 0) + { + oe_sha256_context_t* hctx = &context->hash_context; + sgx_sigstruct_t* sigstruct = (sgx_sigstruct_t*)properties->sigstruct; + memcpy(eeid->sigstruct, (uint8_t*)sigstruct, sizeof(sgx_sigstruct_t)); + oe_sha256_save(hctx, eeid->hash_state_H, eeid->hash_state_N); + eeid->data_vaddr = *vaddr; + + uint64_t ee_sz = sizeof(oe_eeid_t) + eeid->data_size; + uint64_t epg_sz = eeid_pages_size(eeid); + uint64_t num_pages = epg_sz / OE_PAGE_SIZE; + assert(*vaddr == enclave_end - epg_sz); + + oe_page_t* pages = (oe_page_t*)eeid; + if (ee_sz < epg_sz) + { + oe_page_t* tmp = (oe_page_t*)calloc(1, epg_sz); + memcpy(tmp, eeid, ee_sz); + pages = tmp; + } + + OE_CHECK(_add_extra_data_pages( + context, enclave->addr, pages, num_pages, vaddr)); + + if (ee_sz < epg_sz) + free(pages); + + OE_SHA256 ext_mrenclave; + oe_sha256_final(hctx, &ext_mrenclave); + + OE_CHECK(oe_sgx_sign_enclave( + &ext_mrenclave, + properties->config.attributes, + properties->config.product_id, + properties->config.security_version, + OE_DEBUG_SIGN_KEY, /* Use different key? */ + OE_DEBUG_SIGN_KEY_SIZE, + sigstruct)); + + assert(*vaddr == enclave_end); + } + +done: + return result; +} + oe_result_t oe_sgx_build_enclave( oe_sgx_load_context_t* context, const char* path, const oe_sgx_enclave_properties_t* properties, + oe_eeid_t* eeid, oe_enclave_t* enclave) { oe_result_t result = OE_UNEXPECTED; @@ -508,6 +694,9 @@ oe_result_t oe_sgx_build_enclave( uint64_t vaddr = 0; oe_sgx_enclave_properties_t props; + if (!enclave) + OE_RAISE(OE_INVALID_PARAMETER); + memset(&oeimage, 0, sizeof(oeimage)); /* Clear and initialize enclave structure */ @@ -546,6 +735,34 @@ oe_result_t oe_sgx_build_enclave( memcpy(&props, oeimage.image_base + oeimage.oeinfo_rva, sizeof(props)); } + if (eeid) + { + if (props.header.size_settings.num_heap_pages != 0 || + props.header.size_settings.num_stack_pages != 0 || + props.header.size_settings.num_tcs != 0) + OE_RAISE(OE_INVALID_PARAMETER); + + props.header.size_settings.num_heap_pages = + eeid->size_settings.num_heap_pages; + props.header.size_settings.num_stack_pages = + eeid->size_settings.num_stack_pages; + props.header.size_settings.num_tcs = eeid->size_settings.num_tcs; + + // patch + elf64_sym_t sym_props = {0}; + const elf64_t* eimg = &oeimage.u.elf.elf; + if (elf64_find_symbol_by_name( + eimg, "oe_enclave_properties_sgx", &sym_props) == 0) + { + uint64_t* sym_props_addr = NULL; + sym_props_addr = + (uint64_t*)(oeimage.image_base + sym_props.st_value); + oe_sgx_enclave_properties_t* p = + (oe_sgx_enclave_properties_t*)sym_props_addr; + p->header.size_settings = props.header.size_settings; + } + } + /* Validate the enclave prop_override structure */ OE_CHECK(oe_sgx_validate_enclave_properties(&props, NULL)); @@ -577,6 +794,9 @@ oe_result_t oe_sgx_build_enclave( /* Calculate the size of image */ OE_CHECK(oeimage.calculate_size(&oeimage, &image_size)); + /* Add (optional) user data pages size */ + image_size += eeid_pages_size(eeid); + /* Calculate the size of this enclave in memory */ OE_CHECK(_calculate_enclave_size( image_size, &props, &enclave_end, &enclave_size)); @@ -592,6 +812,9 @@ oe_result_t oe_sgx_build_enclave( /* Patch image */ OE_CHECK(oeimage.patch(&oeimage, enclave_end)); + /* Patch EEID symbols */ + OE_CHECK(_patch_eeid_symbols(&oeimage, enclave_end, eeid)); + /* Add image to enclave */ OE_CHECK(oeimage.add_pages(&oeimage, context, enclave, &vaddr)); @@ -599,6 +822,17 @@ oe_result_t oe_sgx_build_enclave( OE_CHECK( _add_data_pages(context, enclave, &props, oeimage.entry_rva, &vaddr)); + /* Add EEID */ + OE_CHECK( + _add_eeid_pages(context, enclave, enclave_end, &props, &vaddr, eeid)); + + if (eeid && oe_get_current_logging_level() >= OE_LOG_LEVEL_WARNING) + { + char buf[2 * (sizeof(oe_eeid_t) + eeid->data_size) + 8]; + OE_CHECK(oe_serialize_eeid(eeid, buf, sizeof(buf))); + printf("EEID:\n%s", buf); + } + /* Ask the platform to initialize the enclave and finalize the hash */ OE_CHECK(oe_sgx_initialize_enclave( context, enclave_addr, &props, &enclave->hash)); @@ -644,10 +878,33 @@ oe_result_t oe_create_enclave( const char* enclave_path, oe_enclave_type_t enclave_type, uint32_t flags, - const void* config, - uint32_t config_size, + const oe_enclave_setting_t* settings, + uint32_t setting_count, const oe_ocall_func_t* ocall_table, - uint32_t ocall_table_size, + uint32_t ocall_count, + oe_enclave_t** enclave_out) +{ + return oe_create_enclave_eeid( + enclave_path, + enclave_type, + flags, + settings, + setting_count, + ocall_table, + ocall_count, + NULL, + enclave_out); +} + +oe_result_t oe_create_enclave_eeid( + const char* enclave_path, + oe_enclave_type_t enclave_type, + uint32_t flags, + const oe_enclave_setting_t* settings, + uint32_t setting_count, + const oe_ocall_func_t* ocall_table, + uint32_t ocall_count, + oe_eeid_t* eeid, oe_enclave_t** enclave_out) { oe_result_t result = OE_UNEXPECTED; @@ -663,7 +920,9 @@ oe_result_t oe_create_enclave( if (!enclave_path || !enclave_out || ((enclave_type != OE_ENCLAVE_TYPE_SGX) && (enclave_type != OE_ENCLAVE_TYPE_AUTO)) || - (flags & OE_ENCLAVE_FLAG_RESERVED) || config || config_size > 0) + (setting_count > 0 && settings == NULL) || + (setting_count == 0 && settings != NULL) || + (flags & OE_ENCLAVE_FLAG_RESERVED)) OE_RAISE(OE_INVALID_PARAMETER); /* Allocate and zero-fill the enclave structure */ @@ -702,7 +961,7 @@ oe_result_t oe_create_enclave( &context, OE_SGX_LOAD_TYPE_CREATE, flags)); /* Build the enclave */ - OE_CHECK(oe_sgx_build_enclave(&context, enclave_path, NULL, enclave)); + OE_CHECK(oe_sgx_build_enclave(&context, enclave_path, NULL, eeid, enclave)); /* Push the new created enclave to the global list. */ if (oe_push_enclave_instance(enclave) != 0) @@ -747,11 +1006,14 @@ oe_result_t oe_create_enclave( /* Enclave initialization invokes global constructors which could make * ocalls. Therefore setup ocall table prior to initialization. */ enclave->ocalls = (const oe_ocall_func_t*)ocall_table; - enclave->num_ocalls = ocall_table_size; + enclave->num_ocalls = ocall_count; /* Invoke enclave initialization. */ OE_CHECK(_initialize_enclave(enclave)); + /* Apply the list of settings to the enclave */ + OE_CHECK(_configure_enclave(enclave, settings, setting_count)); + /* Setup logging configuration */ oe_log_enclave_init(enclave); @@ -794,6 +1056,9 @@ oe_result_t oe_terminate_enclave(oe_enclave_t* enclave) /* Remove this enclave from the global list. */ oe_remove_enclave_instance(enclave); + /* Shut down the switchless manager */ + OE_CHECK(oe_stop_switchless_manager(enclave)); + /* Clear the magic number */ enclave->magic = 0; diff --git a/host/sgx/elf.c b/host/sgx/elf.c index c2e03e72b1..cd7a2f600d 100644 --- a/host/sgx/elf.c +++ b/host/sgx/elf.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -80,15 +80,13 @@ static bool _is_valid_elf64(const elf64_t* elf) return false; /* Ensure that multiplying header size and num entries won't overflow. */ - static_assert( + OE_STATIC_ASSERT( sizeof(uint64_t) >= - sizeof(header->e_phentsize) + sizeof(header->e_phnum), - "e_phentsize or e_phnum is too large"); + sizeof(header->e_phentsize) + sizeof(header->e_phnum)); - static_assert( + OE_STATIC_ASSERT( sizeof(uint64_t) >= - sizeof(header->e_shentsize) + sizeof(header->e_shnum), - "e_shentsize or e_shnum is too large"); + sizeof(header->e_shentsize) + sizeof(header->e_shnum)); uint64_t size = (uint64_t)header->e_phentsize * header->e_phnum; uint64_t end; @@ -284,7 +282,7 @@ int elf64_load(const char* path, elf64_t* elf) if (fd == -1 || _fstat64(fd, &statbuf) != 0) goto done; - if (!(statbuf.st_mode & _S_IFREG) != 0) + if ((statbuf.st_mode & _S_IFREG) == 0) goto done; #else fd = fileno(is); @@ -321,7 +319,7 @@ int elf64_load(const char* path, elf64_t* elf) if (is) fclose(is); - if (rc != 0) + if (rc != 0 && elf) { free(elf->data); memset(elf, 0, sizeof(elf64_t)); @@ -1652,9 +1650,7 @@ int elf64_add_section( } /* Update the size of the .shstrtab section */ - static_assert( - sizeof(namesize) == sizeof(uint64_t), - "sizeof(namesize) != sizeof(uint64_t)"); + OE_STATIC_ASSERT(sizeof(namesize) == sizeof(uint64_t)); if (oe_safe_add_u64( shdr->sh_size, (uint64_t)namesize, &shdr->sh_size) != OE_OK) diff --git a/host/sgx/enclave.c b/host/sgx/enclave.c index f7e7902044..968017668e 100644 --- a/host/sgx/enclave.c +++ b/host/sgx/enclave.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "enclave.h" diff --git a/host/sgx/enclave.h b/host/sgx/enclave.h index e684a3d4a6..de585bc788 100644 --- a/host/sgx/enclave.h +++ b/host/sgx/enclave.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_ENCLAVE_H @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "../hostthread.h" #include "asmdefs.h" @@ -56,7 +57,7 @@ typedef struct _thread_binding uint64_t tcs; /* The thread this slot is assigned to */ - oe_thread thread; + oe_thread_t thread; /* Flags */ uint64_t flags; @@ -66,10 +67,6 @@ typedef struct _thread_binding /* Event signaling object for enclave threading implementation */ EnclaveEvent event; - - /* The host GS and FS values saved before making an ecall */ - void* host_gs; - void* host_fs; } ThreadBinding; OE_STATIC_ASSERT(OE_OFFSETOF(ThreadBinding, tcs) == ThreadBinding_tcs); @@ -124,24 +121,10 @@ struct _oe_enclave /* Meta-data needed by debugrt */ oe_debug_enclave_t* debug_enclave; -}; - -// Static asserts for consistency with -// debugger/pythonExtension/gdb_sgx_plugin.py -#if defined(__linux__) -OE_STATIC_ASSERT(OE_OFFSETOF(oe_enclave_t, magic) == 0); -// Python plugin only needs the field number which is 2 -OE_STATIC_ASSERT(OE_OFFSETOF(oe_enclave_t, addr) == 2 * sizeof(void*)); - -// The fields up to binding correspond to 'ENCLAVE_HEADER' -OE_STATIC_ASSERT(OE_OFFSETOF(oe_enclave_t, bindings) == 0x28); - -OE_STATIC_ASSERT(OE_OFFSETOF(oe_enclave_t, debug) == 0x788); -OE_STATIC_ASSERT( - OE_OFFSETOF(oe_enclave_t, debug) + 1 == - OE_OFFSETOF(oe_enclave_t, simulate)); -#endif + /* Manager for switchless calls */ + oe_switchless_call_manager_t* switchless_manager; +}; /* Get the event for the given TCS */ EnclaveEvent* GetEnclaveEvent(oe_enclave_t* enclave, uint64_t tcs); diff --git a/host/sgx/enclavemanager.c b/host/sgx/enclavemanager.c index ec6e1fa3cf..39aea36d2f 100644 --- a/host/sgx/enclavemanager.c +++ b/host/sgx/enclavemanager.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/sgx/enter.c b/host/sgx/enter.c new file mode 100644 index 0000000000..a702466b0c --- /dev/null +++ b/host/sgx/enter.c @@ -0,0 +1,225 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include "asmdefs.h" +#include "enclave.h" + +// Define a variable with given name and bind it to the register with the +// corresponding name. This allows manipulating the register as a normal +// C variable. The variable and hence the register is also assigned the +// specified value. +#define OE_DEFINE_REGISTER(regname, value) \ + register uint64_t regname __asm__(#regname) = (uint64_t)(value) + +#if _WIN32 + +// In x64 Windows ABI, the frame pointer can be any register and the frame +// pointer points to a constant location *within* the frame. In x64, the +// frame pointer points to the top of the frame. Windows debugger extensions +// for Open Enclave SDK require a linux-style frame pointer for the oe_enter +// function on the host-side. +#define OE_DEFINE_FRAME_POINTER(r, v) OE_DEFINE_REGISTER(r, v) + +// As per Windows x64 ABI, the linux style frame pointer is -0x40 bytes +// from the address of the enclave parameter which is passed via the stack. +// Enclave parameter is the 7th parameter. Including the return-address, the +// Linux style frame-pointer is -(7+1)*8 = -64 = -0x40 bytes from the enclave +// parameter in the stack. +#define OE_FRAME_POINTER_VALUE ((uint64_t)&enclave - 0x40) +#define OE_FRAME_POINTER , "r"(rbp) + +// The SDK currently does not use a bridge for ocall stack-stitching on Windows. +// Unlike oegdb, the Windows debuggers (WinDbg, VS Debugger) rely on the +// function name being __oe_dispatch_ocall to detect host-enclave transition +// during stack-walking and don't require that the stack be actually stitched +// by the ocall-bridge. In the future, the Windows Debuggers would also require +// that the SDK stitches the ocall stack, simplifying the debugger +// implementations. +#define OE_OCALL_BRIDGE __oe_dispatch_ocall + +#elif __linux__ + +// The debugger requires a Linux x64 ABI frame pointer for stack walking. +// Therefore, this file must be compiled with -fno-omit-frame-pointer. +// Nothing else needs to be done and the macros below are noops. +#define OE_DEFINE_FRAME_POINTER(r, v) OE_UNUSED(v) +#define OE_FRAME_POINTER_VALUE 0 +#define OE_FRAME_POINTER + +// The SDK uses a bridge to stitch the ocall stack with the help +// of the debugger. +#define OE_OCALL_BRIDGE __oe_host_stack_bridge + +#endif + +// The following registers are inputs to ENCLU instruction. They are also +// clobbered. Hence marked as +r. +#define OE_ENCLU_REGISTERS "+r"(rax), "+r"(rbx), "+r"(rcx), "+r"(rdi), "+r"(rsi) + +// The following registers are clobbered by ENCLU. +// Only rbp and rsp are preserved. +#define OE_ENCLU_CLOBBERED_REGISTERS \ + "rdx", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" + +/** + * oe_enter Executes the ENCLU instruction and transfers control to the enclave. + * + * The ENCLU instruction has the following contract: + * EENTER(RBX=TCS, RCX=AEP, RDI=ARG1, RSI=ARG2) contract + * Input: + * RBX=TCS, RCX=AEP, RDI=ARG1, RSI=ARG2, + * RBP=Current host stack rbp, + * RSP=Current host stack sp. + * All other registers are NOT used/ignored. + * Output: + * RDI=ARG1OUT, RSI=ARG2OUT, + * RBP, RBP are preserved. + * All other Registers are clobbered. + * + * Callee-saved (non-volatile) registers: + * As per System V x64 ABI, the registers RBX, RBP, RSP, R12, R13, R14, and R15 + * are preserved across function calls. + * As per x64 Windows ABI, the registers RBX, RBP, RDI, RSI, RSP, R12, R13, R14, + * R15, and XMM6-15 are preserved across function calls. + * The general purpose callee-saved registers are listed in + * OE_ENCLU_CLOBBERED_REGISTERS. Since we explicitly save and restore the + * floating-point state via fxsave/fxrstor, the xmm registers are not listed + * in the clobber list. + */ +OE_NEVER_INLINE +void oe_enter( + void* tcs, + uint64_t aep, + uint64_t arg1, + uint64_t arg2, + uint64_t* arg3, + uint64_t* arg4, + oe_enclave_t* enclave) +{ + // The general purpose registers are preserved by the compiler. + // The floating point state and the flags must be explicitly preserved. + // The space for saving the floating-point state must be 16 byte aligned. + OE_ALIGNED(16) + uint64_t fx_state[64]; + + while (1) + { + // Define register bindings and initialize the registers. + // On Windows, explicitly setup rbp as a Linux ABI style frame-pointer. + // On Linux, the frame-pointer is set up by compiling the file with the + // -fno-omit-frame-pointer flag. + OE_DEFINE_REGISTER(rax, ENCLU_EENTER); + OE_DEFINE_REGISTER(rbx, tcs); + OE_DEFINE_REGISTER(rcx, aep); + OE_DEFINE_REGISTER(rdi, arg1); + OE_DEFINE_REGISTER(rsi, arg2); + OE_DEFINE_FRAME_POINTER(rbp, OE_FRAME_POINTER_VALUE); + + asm volatile("fxsave %[fx_state] \n\t" // Save floating point state. + "pushfq \n\t" // Save flags. + "enclu \n\t" + "popfq \n\t" // Restore flags. + "fxrstor %[fx_state] \n\t" // Restore floating point state. + : OE_ENCLU_REGISTERS + : [fx_state] "m"(fx_state)OE_FRAME_POINTER + : OE_ENCLU_CLOBBERED_REGISTERS); + + // Update arg1 and arg2 with outputs returned by the enclave. + arg1 = rdi; + arg2 = rsi; + + // Make an OCALL if needed. + oe_code_t code = oe_get_code_from_call_arg1(arg1); + if (code == OE_CODE_OCALL) + { + OE_OCALL_BRIDGE(arg1, arg2, &arg1, &arg2, tcs, enclave); + } + else + break; + } + + *arg3 = arg1; + *arg4 = arg2; +} + +/** + * oe_enter_sim Simulates the ENCLU instruction. + * + * See oe_enter above for ENCLU instruction's contract. + * For simulation, the contract is modified as below: + * - rax is the CSSA which is always 0 + * - rcx contains the return address instead of the AEP + * - The address of the enclave entry point is fetched from the tcs + * (offset 72) and the control is transferred to it via a jmp + */ +OE_NEVER_INLINE +void oe_enter_sim( + void* tcs, + uint64_t aep, + uint64_t arg1, + uint64_t arg2, + uint64_t* arg3, + uint64_t* arg4, + oe_enclave_t* enclave) +{ + OE_UNUSED(aep); + OE_ALIGNED(16) + uint64_t fx_state[64]; + + // Backup host GS and FS registers. + void* host_gs = oe_get_gs_register_base(); + void* host_fs = oe_get_fs_register_base(); + sgx_tcs_t* sgx_tcs = (sgx_tcs_t*)tcs; + + while (1) + { + // Set GS and FS registers to values set by the ENCLU instruction upon + // entry to the enclave. + oe_set_gs_register_base((void*)(enclave->addr + sgx_tcs->gsbase)); + oe_set_fs_register_base((void*)(enclave->addr + sgx_tcs->fsbase)); + + // Define register bindings and initialize the registers. + // See oe_enter for ENCLU contract. + OE_DEFINE_REGISTER(rax, 0 /* CSSA */); + OE_DEFINE_REGISTER(rbx, tcs); + OE_DEFINE_REGISTER(rcx, 0 /* filled in asm snippet */); + OE_DEFINE_REGISTER(rdi, arg1); + OE_DEFINE_REGISTER(rsi, arg2); + OE_DEFINE_FRAME_POINTER(rbp, OE_FRAME_POINTER_VALUE); + + asm volatile("fxsave %[fx_state] \n\t" // Save floating point state + "pushfq \n\t" // Save flags + "lea 1f(%%rip), %%rcx \n\t" // Load return address in rcx + "mov 72(%%rbx), %% rdx \n\t" // Load enclave entry point + "jmp *%%rdx \n\t" // Jump to enclave entry point + "1: \n\t" + "popfq \n\t" // Restore flags + "fxrstor %[fx_state] \n\t" // Restore floating point state + : OE_ENCLU_REGISTERS + : [fx_state] "m"(fx_state)OE_FRAME_POINTER + : OE_ENCLU_CLOBBERED_REGISTERS); + + // Update arg1 and arg2 with outputs returned by the enclave. + arg1 = rdi; + arg2 = rsi; + + // Restore GS and FS registers upon returning from the enclave. + oe_set_gs_register_base(host_gs); + oe_set_fs_register_base(host_fs); + + // Make an OCALL if needed. + oe_code_t code = oe_get_code_from_call_arg1(arg1); + if (code == OE_CODE_OCALL) + { + OE_OCALL_BRIDGE(arg1, arg2, &arg1, &arg2, tcs, enclave); + } + else + break; + } + + *arg3 = arg1; + *arg4 = arg2; +} diff --git a/host/sgx/exception.c b/host/sgx/exception.c index b86702d8a8..1729fa73a5 100644 --- a/host/sgx/exception.c +++ b/host/sgx/exception.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "exception.h" diff --git a/host/sgx/exception.h b/host/sgx/exception.h index 1d4ce5abd0..c5a41f3ec9 100644 --- a/host/sgx/exception.h +++ b/host/sgx/exception.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_EXCEPTION_H diff --git a/host/sgx/hostverify_report.c b/host/sgx/hostverify_report.c index 68b3c65b4e..1d39542878 100644 --- a/host/sgx/hostverify_report.c +++ b/host/sgx/hostverify_report.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -13,6 +13,8 @@ oe_result_t oe_verify_remote_report( const uint8_t* report, size_t report_size, + const uint8_t* endorsement, + size_t endorsement_size, oe_report_t* parsed_report) { oe_result_t result = OE_UNEXPECTED; @@ -36,8 +38,12 @@ oe_result_t oe_verify_remote_report( OE_RAISE(OE_UNSUPPORTED); // Quote attestation can be done entirely on the host side. - OE_CHECK(oe_verify_quote_internal( - header->report, header->report_size, NULL, 0, NULL, 0, NULL, 0)); + OE_CHECK(oe_verify_sgx_quote( + header->report, + header->report_size, + endorsement, + endorsement_size, + NULL)); // Optionally return parsed report. if (parsed_report != NULL) @@ -47,4 +53,4 @@ oe_result_t oe_verify_remote_report( done: return result; -} +} \ No newline at end of file diff --git a/host/sgx/linux/aep.S b/host/sgx/linux/aep.S index 5022fa4498..916ea39727 100644 --- a/host/sgx/linux/aep.S +++ b/host/sgx/linux/aep.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../asmdefs.h" diff --git a/host/sgx/linux/aesm.c b/host/sgx/linux/aesm.c deleted file mode 100644 index 9c558cc8fd..0000000000 --- a/host/sgx/linux/aesm.c +++ /dev/null @@ -1,706 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* -**============================================================================== -** -** This module implements a socket client to AESM (SGX Application Enclave -** Services Manager). On linux, this service is called 'aesmd'. See if it -** is running with this command: -** -** $ services aesmd status -** -** References: -** -** See messages.proto from the Intel SGX SDK for the interface. -** -**============================================================================== -*/ - -#define OE_ERROR_UNPACK ((size_t)-1) - -#define AESM_SOCKET "/var/run/aesmd/aesm.socket" - -typedef enum _wire_type -{ - WIRE_TYPE_VARINT = 0, - WIRE_TYPE_LENGTH_DELIMITED = 2 -} wire_type_t; - -#define AESM_MAGIC 0x4efaa2a3 - -typedef enum _message_type -{ - MESSAGE_TYPE_INIT_QUOTE = 1, - MESSAGE_TYPE_GET_QUOTE = 2, - MESSAGE_TYPE_GET_LAUNCH_TOKEN = 3 -} message_type_t; - -struct _aesm -{ - uint32_t magic; - int sock; -}; - -static int _aesm_valid(const aesm_t* aesm) -{ - return aesm != NULL && aesm->magic == AESM_MAGIC; -} - -static int _make_tag(uint8_t field_num, wire_type_t wire_type, uint8_t* tag) -{ - int ret = -1; - - /* Initialize the tag in case of failure */ - if (tag) - *tag = 0; - - /* Check parameter */ - if (!tag) - goto done; - - /* Check for overflow (field_num will occupy the upper 5 bits) */ - if (field_num & 0xE0) - goto done; - - /* Check for overflow (wire_type will occupy the lower 3 bits) */ - if ((uint8_t)wire_type & 0xF8) - goto done; - - /* Form the tag */ - *tag = (uint8_t)((field_num << 3) | (uint8_t)wire_type); - - ret = 0; - -done: - return ret; -} - -static int _pack_variant_uint32(mem_t* buf, uint32_t x) -{ - uint8_t data[8]; - uint8_t* p = data; - const uint8_t* end = data + sizeof(data); - - while (x >= 0x80) - { - if (p == end) - return -1; - - *p++ = (uint8_t)(x | 0x80); - x >>= 7; - } - - if (p == end) - return -1; - - *p++ = (uint8_t)(x); - - return mem_cat(buf, data, (size_t)(p - data)); -} - -static int _pack_tag(mem_t* buf, uint8_t field_num, wire_type_t wire_type) -{ - uint8_t tag; - - if (_make_tag(field_num, wire_type, &tag) != 0) - return -1; - - return mem_cat(buf, &tag, sizeof(uint8_t)); -} - -static ssize_t _unpack_tag(const mem_t* buf, size_t pos, uint8_t* tag) -{ - size_t size = sizeof(uint8_t); - - if (pos + size > mem_size(buf)) - return -1; - - if (oe_memcpy_s(tag, sizeof(*tag), mem_ptr_at(buf, pos), size) != OE_OK) - return -1; - - if (pos + size > OE_SSIZE_MAX) - return -1; - - return (ssize_t)(pos + size); -} - -static ssize_t _unpack_variant_uint32(mem_t* buf, size_t pos, uint32_t* value) -{ - const uint8_t* p; - uint32_t result = 0; - size_t count = 0; - uint32_t b; - - if (value) - *value = 0; - - p = (const uint8_t*)mem_ptr_at(buf, pos); - - do - { - /* Check for overflow */ - if (count == sizeof(uint32_t)) - return -1; - - /* If buffer is exhausted */ - if (p == mem_end(buf)) - return -1; - - b = *p; - result |= (uint32_t)(b & 0x7F) << (7 * count); - p++; - count++; - } while (b & 0x80); - - *value = result; - - if (pos + count > OE_SSIZE_MAX) - return -1; - - return (ssize_t)(pos + count); -} - -static oe_result_t _pack_bytes( - mem_t* buf, - uint8_t field_num, - const void* data, - uint32_t size) -{ - oe_result_t result = OE_UNEXPECTED; - uint8_t tag; - - if (_make_tag(field_num, WIRE_TYPE_LENGTH_DELIMITED, &tag) != 0) - OE_RAISE(OE_FAILURE); - - if (mem_cat(buf, &tag, sizeof(tag)) != 0) - OE_RAISE(OE_FAILURE); - - if (_pack_variant_uint32(buf, size) != 0) - OE_RAISE(OE_FAILURE); - - if (mem_cat(buf, data, size) != 0) - OE_RAISE(OE_FAILURE); - - result = OE_OK; - -done: - return result; -} - -static oe_result_t _pack_var_int(mem_t* buf, uint8_t field_num, uint64_t value) -{ - oe_result_t result = OE_UNEXPECTED; - - if (_pack_tag(buf, field_num, WIRE_TYPE_VARINT) != 0) - OE_RAISE(OE_FAILURE); - - if (value > OE_UINT_MAX) - OE_RAISE(OE_INVALID_PARAMETER); - - if (_pack_variant_uint32(buf, (uint32_t)value) != 0) - OE_RAISE(OE_FAILURE); - - result = OE_OK; - -done: - return result; -} - -static oe_result_t _unpack_var_int( - mem_t* buf, - size_t* pos, - uint8_t field_num, - uint32_t* value) -{ - oe_result_t result = OE_UNEXPECTED; - uint8_t tag; - uint8_t tmp_tag; - - if ((*pos = (size_t)_unpack_tag(buf, *pos, &tag)) == OE_ERROR_UNPACK) - OE_RAISE(OE_FAILURE); - - if (_make_tag(field_num, WIRE_TYPE_VARINT, &tmp_tag) != 0) - OE_RAISE(OE_FAILURE); - - if (tag != tmp_tag) - OE_RAISE(OE_FAILURE); - - if ((*pos = (size_t)_unpack_variant_uint32(buf, *pos, value)) == - OE_ERROR_UNPACK) - OE_RAISE(OE_FAILURE); - - result = OE_OK; - -done: - return result; -} - -static oe_result_t _unpack_length_delimited( - mem_t* buf, - size_t* pos, - uint8_t field_num, - void* data, - size_t data_size) -{ - oe_result_t result = OE_UNEXPECTED; - uint8_t tag = 0; - uint8_t tmp_tag = 0; - uint32_t size; - - if ((*pos = (size_t)_unpack_tag(buf, *pos, &tag)) == OE_ERROR_UNPACK) - OE_RAISE(OE_FAILURE); - - if (_make_tag(field_num, WIRE_TYPE_LENGTH_DELIMITED, &tmp_tag) != 0) - OE_RAISE(OE_FAILURE); - - if (tag != tmp_tag) - OE_RAISE(OE_FAILURE); - - if ((*pos = (size_t)_unpack_variant_uint32(buf, *pos, &size)) == - OE_ERROR_UNPACK) - OE_RAISE(OE_FAILURE); - - if (size > data_size) - OE_RAISE(OE_FAILURE); - - OE_CHECK(oe_memcpy_s(data, data_size, mem_ptr_at(buf, *pos), size)); - - *pos += size; - - result = OE_OK; - -done: - return result; -} - -static int _read(int sock, void* data, size_t size) -{ - ssize_t n; - - if ((n = read(sock, data, size)) != (ssize_t)size) - return -1; - - return 0; -} - -static int _write(int sock, const void* data, size_t size) -{ - ssize_t n; - - if ((n = write(sock, data, size)) != (ssize_t)size) - return -1; - - return 0; -} - -static oe_result_t _write_request( - aesm_t* aesm, - message_type_t message_type, - const mem_t* message) -{ - oe_result_t result = OE_UNEXPECTED; - mem_t envelope = MEM_DYNAMIC_INIT; - - OE_TRACE_INFO("=== _write_request:\n"); - if (oe_get_current_logging_level() >= OE_LOG_LEVEL_INFO) - { - oe_hex_dump(mem_ptr(message), mem_size(message)); - } - - /* Wrap message in envelope */ - OE_CHECK(_pack_bytes( - &envelope, - (uint8_t)message_type, - mem_ptr(message), - (uint32_t)mem_size(message))); - - /* Send the envelope to the AESM service */ - { - uint32_t size = (uint32_t)mem_size(&envelope); - - /* Send message size */ - if (_write(aesm->sock, &size, sizeof(uint32_t)) != 0) - OE_RAISE(OE_FAILURE); - - /* Send message data */ - if (_write(aesm->sock, mem_ptr(&envelope), mem_size(&envelope)) != 0) - OE_RAISE(OE_FAILURE); - } - - result = OE_OK; - -done: - - mem_free(&envelope); - - return result; -} - -static oe_result_t _read_response( - aesm_t* aesm, - message_type_t message_type, - mem_t* message) -{ - oe_result_t result = OE_UNEXPECTED; - uint32_t size; - mem_t envelope = MEM_DYNAMIC_INIT; - - mem_clear(message); - - /* Read the ENVELOPE from the AESM service */ - { - /* Read the envelope size */ - if (_read(aesm->sock, &size, sizeof(uint32_t)) != 0) - OE_RAISE(OE_FAILURE); - - /* Expand the buffer */ - if (mem_resize(&envelope, size) != 0) - OE_RAISE(OE_FAILURE); - - /* Read the message */ - if (_read(aesm->sock, mem_mutable_ptr(&envelope), size) != 0) - OE_RAISE(OE_FAILURE); - } - - /* Copy envelope contents into MESSAGE */ - { - uint8_t tag; - uint8_t tmp_tag; - size_t pos = 0; - uint32_t size; - - /* Get the tag of this payload */ - if ((pos = (size_t)_unpack_tag(&envelope, pos, &tag)) == - OE_ERROR_UNPACK) - OE_RAISE(OE_FAILURE); - - if (_make_tag( - (uint8_t)message_type, WIRE_TYPE_LENGTH_DELIMITED, &tmp_tag) != - 0) - OE_RAISE(OE_FAILURE); - - if (tag != tmp_tag) - OE_RAISE(OE_FAILURE); - - /* Get the size of this payload */ - if ((pos = (size_t)_unpack_variant_uint32(&envelope, pos, &size)) == - OE_ERROR_UNPACK) - OE_RAISE(OE_FAILURE); - - /* Check the size (must equal unread bytes in envelope) */ - if (size != mem_size(&envelope) - (size_t)pos) - OE_RAISE(OE_FAILURE); - - uint8_t* temp = (uint8_t*)mem_ptr(&envelope) + pos; - - /* Read the message from the envelope */ - mem_cat(message, (const void*)temp, (size_t)size); - } - - OE_TRACE_INFO("=== _read_response():\n"); - if (oe_get_current_logging_level() >= OE_LOG_LEVEL_INFO) - { - oe_hex_dump(mem_ptr(message), mem_size(message)); - } - - result = OE_OK; - -done: - - mem_free(&envelope); - - return result; -} - -aesm_t* aesm_connect() -{ - int sock = -1; - struct sockaddr_un addr; - aesm_t* aesm = NULL; - - /* Create a socket for connecting to the AESM service */ - if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) - goto done; - - /* Initialize the address */ - memset(&addr, 0, sizeof(struct sockaddr_un)); - addr.sun_family = AF_UNIX; - oe_strncpy_s( - addr.sun_path, sizeof(addr.sun_path), AESM_SOCKET, strlen(AESM_SOCKET)); - - /* Connect to the AESM service */ - if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) - { - close(sock); - goto done; - } - - /* Allocate and initialize the AESM struct */ - { - if (!(aesm = (aesm_t*)malloc(sizeof(aesm_t)))) - { - close(sock); - goto done; - } - - aesm->magic = AESM_MAGIC; - aesm->sock = sock; - } - -done: - - if (aesm == NULL) - OE_TRACE_ERROR("aesm_connect failed"); - - return aesm; -} - -void aesm_disconnect(aesm_t* aesm) -{ - if (_aesm_valid(aesm)) - { - close(aesm->sock); - memset(aesm, 0xDD, sizeof(aesm_t)); - free(aesm); - } -} - -oe_result_t aesm_get_launch_token( - aesm_t* aesm, - uint8_t mrenclave[OE_SHA256_SIZE], - uint8_t modulus[OE_KEY_SIZE], - const sgx_attributes_t* attributes, - sgx_launch_token_t* launch_token) -{ - oe_result_t result = OE_UNEXPECTED; - uint64_t timeout = 15000; - mem_t request = MEM_DYNAMIC_INIT; - mem_t response = MEM_DYNAMIC_INIT; - - if (launch_token) - memset(launch_token, 0, sizeof(sgx_launch_token_t)); - - /* Reject invalid parameters */ - if (!_aesm_valid(aesm) || !mrenclave || !modulus || !attributes) - OE_RAISE(OE_INVALID_PARAMETER); - - /* Build the PAYLOAD */ - { - /* Pack MRENCLAVE */ - OE_CHECK(_pack_bytes(&request, 1, mrenclave, OE_SHA256_SIZE)); - - /* Pack MODULUS */ - OE_CHECK(_pack_bytes(&request, 2, modulus, OE_KEY_SIZE)); - - /* Pack ATTRIBUTES */ - OE_CHECK( - _pack_bytes(&request, 3, attributes, sizeof(sgx_attributes_t))); - - /* Pack TIMEOUT */ - OE_CHECK(_pack_var_int(&request, 9, timeout)); - } - - /* Send the request to the AESM service */ - OE_CHECK(_write_request(aesm, MESSAGE_TYPE_GET_LAUNCH_TOKEN, &request)); - - /* Receive the response from AESM service */ - OE_CHECK(_read_response(aesm, MESSAGE_TYPE_GET_LAUNCH_TOKEN, &response)); - - /* Unpack the response */ - { - size_t pos = 0; - - /* Unpack the error code */ - { - uint32_t errcode; - OE_CHECK(_unpack_var_int(&response, &pos, 1, &errcode)); - - if (errcode != 0) - OE_RAISE_MSG(OE_FAILURE, "errcode=0x%x", errcode); - } - - /* Unpack the launch token */ - OE_CHECK(_unpack_length_delimited( - &response, &pos, 2, launch_token, sizeof(sgx_launch_token_t))); - } - - result = OE_OK; - -done: - mem_free(&request); - mem_free(&response); - - return result; -} - -oe_result_t aesm_init_quote( - aesm_t* aesm, - sgx_target_info_t* target_info, - sgx_epid_group_id_t* epid_group_id) -{ - oe_result_t result = OE_UNEXPECTED; - uint64_t timeout = 15000; - mem_t request = MEM_DYNAMIC_INIT; - mem_t response = MEM_DYNAMIC_INIT; - - if (target_info) - memset(target_info, 0, sizeof(sgx_target_info_t)); - - /* Reject invalid parameters */ - if (!_aesm_valid(aesm) || !target_info || !epid_group_id) - OE_RAISE(OE_INVALID_PARAMETER); - - /* Build the PAYLOAD */ - { - /* Pack TIMEOUT */ - OE_CHECK(_pack_var_int(&request, 9, timeout)); - } - - /* Send the request to the AESM service */ - OE_CHECK(_write_request(aesm, MESSAGE_TYPE_INIT_QUOTE, &request)); - - /* Receive the response from AESM service */ - OE_CHECK(_read_response(aesm, MESSAGE_TYPE_INIT_QUOTE, &response)); - - /* Unpack the response */ - { - size_t pos = 0; - - /* Unpack the error code */ - { - uint32_t errcode; - OE_CHECK(_unpack_var_int(&response, &pos, 1, &errcode)); - - if (errcode != 0) - OE_RAISE_MSG(OE_FAILURE, "errcode=0x%x", errcode); - } - - /* Unpack target_info */ - OE_CHECK(_unpack_length_delimited( - &response, &pos, 2, target_info, sizeof(sgx_target_info_t))); - - /* Unpack epid_group_id */ - OE_CHECK(_unpack_length_delimited( - &response, &pos, 3, epid_group_id, sizeof(sgx_epid_group_id_t))); - } - - result = OE_OK; - -done: - mem_free(&request); - mem_free(&response); - - return result; -} - -oe_result_t aesm_get_quote( - aesm_t* aesm, - const sgx_report_t* report, - sgx_quote_type_t quote_type, - const sgx_spid_t* spid, - const sgx_nonce_t* nonce, - const uint8_t* signature_revocation_list, - uint32_t signature_revocation_list_size, - sgx_report_t* report_out, /* ATTN: support this! */ - sgx_quote_t* quote, - size_t quote_size) -{ - uint64_t timeout = 15000; - mem_t request = MEM_DYNAMIC_INIT; - mem_t response = MEM_DYNAMIC_INIT; - oe_result_t result = OE_UNEXPECTED; - - /* Zero initialize the quote */ - if (quote) - memset(quote, 0, quote_size); - - /* Check for invalid parameters */ - if (!_aesm_valid(aesm) || !report || !spid || !quote || !quote_size) - OE_RAISE(OE_INVALID_PARAMETER); - - /* Build the PAYLOAD */ - { - /* Pack REPORT */ - OE_CHECK(_pack_bytes(&request, 1, report, sizeof(sgx_report_t))); - - /* Pack QUOTE-TYPE */ - OE_CHECK(_pack_var_int(&request, 2, quote_type)); - - /* Pack SPID */ - OE_CHECK(_pack_bytes(&request, 3, spid, sizeof(sgx_spid_t))); - - /* Pack NONCE */ - if (nonce) - OE_CHECK(_pack_bytes(&request, 4, nonce, sizeof(sgx_nonce_t))); - - /* Pack SIGNATURE-REVOCATION-LIST */ - if (signature_revocation_list_size) - { - OE_CHECK(_pack_bytes( - &request, - 5, - signature_revocation_list, - signature_revocation_list_size)); - } - - /* Pack QUOTE-SIZE */ - OE_CHECK(_pack_var_int(&request, 6, quote_size)); - - /* Pack boolean indicating whether REPORT-OUT is present */ - if (report_out) - OE_CHECK(_pack_var_int(&request, 7, 1)); - - /* Pack TIMEOUT */ - OE_CHECK(_pack_var_int(&request, 9, timeout)); - } - - /* Send the request to the AESM service */ - OE_CHECK(_write_request(aesm, MESSAGE_TYPE_GET_QUOTE, &request)); - - /* Receive the response from AESM service */ - OE_CHECK(_read_response(aesm, MESSAGE_TYPE_GET_QUOTE, &response)); - - /* Unpack the response */ - { - size_t pos = 0; - - /* Unpack the error code */ - { - uint32_t errcode; - OE_CHECK(_unpack_var_int(&response, &pos, 1, &errcode)); - - if (errcode != 0) - OE_RAISE_MSG(OE_FAILURE, "errcode=0x%x", errcode); - } - - /* Unpack quote */ - OE_CHECK( - _unpack_length_delimited(&response, &pos, 2, quote, quote_size)); - - /* Unpack optional report_out */ - if (report_out) - { - OE_CHECK(_unpack_length_delimited( - &response, &pos, 3, report_out, sizeof(sgx_report_t))); - } - } - - result = OE_OK; - -done: - return result; -} diff --git a/host/sgx/linux/enter.S b/host/sgx/linux/enter.S deleted file mode 100644 index 4957490f8d..0000000000 --- a/host/sgx/linux/enter.S +++ /dev/null @@ -1,296 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "../asmdefs.h" -#include - -//============================================================================== -// -// void __morestack( -// [IN] void* tcs, /* RDI */ -// [IN] uint64_t aep, /* RSI */ -// [IN] uint64_t arg1, /* RDX */ -// [IN] uint64_t arg2, /* RCX */ -// [OUT] uint64_t* arg3, /* R8 */ -// [OUT] uint64_t* arg4, /* R9 */ -// [IN] oe_enclave_t* enclave); /* on stack */ -// -// Registers: -// RDI - tcs: thread control structure -// RSI - aep: asynchronous execution procedure -// RDX - arg1 -// RCX - arg2 -// R8 - arg3 -// R9 - arg4 -// -// N.B: Don't change the function name, otherwise debugger can't work. -// GDB depends on this hardcode function name when does stack walking for split -// stack. -// -// Note that oe_enter is defined to __morestack -// -//============================================================================== - -#define TCS (-1*OE_WORDSIZE)(%rbp) -#define AEP (-2*OE_WORDSIZE)(%rbp) -#define ARG1 (-3*OE_WORDSIZE)(%rbp) -#define ARG2 (-4*OE_WORDSIZE)(%rbp) -#define ARG3 (-5*OE_WORDSIZE)(%rbp) -#define ARG4 (-6*OE_WORDSIZE)(%rbp) -#define ENCLAVE (-7*OE_WORDSIZE)(%rbp) -#define ARG1OUT (-8*OE_WORDSIZE)(%rbp) -#define ARG2OUT (-9*OE_WORDSIZE)(%rbp) -#define RSP (-10*OE_WORDSIZE)(%rbp) -#define HOST_CONTEXT (-11*OE_WORDSIZE)(%rbp) -// We need an extra OE_WORDSIZE to keep the stack aligned. -#define PARAMS_SPACE ((12*OE_WORDSIZE) + OE_CONTEXT_SIZE) - -.globl __morestack -.type __morestack, @function -__morestack: - - // Setup stack frame: - push %rbp - mov %rsp, %rbp - - // Save parameters on stack for later reference: - sub $PARAMS_SPACE, %rsp - mov %rdi, TCS - mov %rsi, AEP - mov %rdx, ARG1 - mov %rcx, ARG2 - mov %r8, ARG3 - mov %r9, ARG4 - mov 16(%rbp), %rax // enclave parameter - mov %rax, ENCLAVE - - // The host context will be saved in the host stack. - mov %rsp, HOST_CONTEXT - -.execute_eenter: - - // Save the current context. - mov HOST_CONTEXT, %rdi - call oe_snap_current_context@PLT - - // Save the stack pointer so enclave can use the stack. - mov %rsp, RSP - - // The EENTER(RBX=TCS, RCX=AEP, RDI=ARG1, RSI=ARG2) contract: - // Input: - // RBX=TCS, RCX=AEP, RDI=ARG1, RSI=ARG2, - // RBP=Current host stack rbp, - // RSP=Current host stack sp. - // All other registers are NOT used/ignored. - // Output: - // RDI=ARG1OUT, RSI=ARG2OUT, - // RBP is not changed, - // RSP might be decreased because of host stack memory allocation. - // All other Registers are clobbered. - mov TCS, %rbx - mov AEP, %rcx - mov ARG1, %rdi - mov ARG2, %rsi - mov $ENCLU_EENTER, %rax - ENCLU - - // Align the stack since enclave code change the host rsp for call out. - and $-16, %rsp - - mov %rdi, ARG1OUT - mov %rsi, ARG2OUT - - // Restore the saved host context. - mov HOST_CONTEXT, %rdi - call oe_restore_partial_context@PLT - - // Check if it is an OCALL needed to be dispatched. - // ecall-return-check. - mov ARG1OUT, %r10 - shr $48, %r10 - cmpq $OE_OCALL_CODE, %r10 - jne .return_from_ecall - -.dispatch_ocall: - // Stop speculative execution at fallthrough of conditional - // ecall-return-check. - lfence - - // Save registers that could get clobbered below or by function call. - push %rdi - push %rsi - push %rdx - push %rcx - push %rbx - push %r8 - push %r9 - push %r12 - push %r13 - - // RAX = __oe_host_stack_bridge( - // RDI=arg1 - // RSI=arg2 - // RDX=arg1_out - // RCX=arg2_out - // R8=TCS, - // R9=RSP) - mov ARG1OUT, %rdi - mov ARG2OUT, %rsi - leaq ARG1OUT, %rdx - leaq ARG2OUT, %rcx - mov TCS, %r8 - mov RSP, %r9 - push ENCLAVE // push enclave parameter - call __oe_host_stack_bridge@PLT - add $8, %rsp // pop enclave parameter - - // Restore registers (except RDI and RSI) - pop %r13 - pop %r12 - pop %r9 - pop %r8 - pop %rbx - pop %rcx - pop %rdx - pop %rsi - pop %rdi - - // Restore the stack pointer: - mov RSP, %rsp - - // If this was not an OCALL, then return from ECALL. - // ecall-return-check-1. - cmp $0, %rax - jne .return_from_ecall - - // Stop speculative execution at fallthrough of conditional - // ecall-return-check-1. - lfence - - // Execute EENTER(RBX=TCS, RCX=AEP, RDI=ARG1, RSI=ARG2) - mov ARG1OUT, %rax - mov %rax, ARG1 - mov ARG2OUT, %rax - mov %rax, ARG2 - jmp .execute_eenter - -.return_from_ecall: - // Stop speculative execution at target of conditional jump - // ecall-return-check and ecall-return-check-1. - lfence - - // Set output parameters: - mov ARG1OUT, %rax - mov %rax, (%r8) /* arg3 */ - mov ARG2OUT, %rax - mov %rax, (%r9) /* arg3 */ - - // Restore stack frame: - mov %rbp, %rsp - pop %rbp - - ret - -.size __morestack, .-__morestack - -//============================================================================== -// -// __oe_host_stack_bridge( -// [IN] uint64_t arg1, /* RDI */ -// [IN] uint64_t arg2, /* RSI */ -// [OUT] uint64_t* arg3, /* RDX */ -// [OUT] uint64_t* arg4, /* RCX */ -// [IN] void* tcs, /* R8 */ -// [IN] void* rsp, /* R9 */ -// [IN] uint64_t enclave) /* STACK */ -// -// This function is wrapper of __oe_dispatch_ocall. It is needed to stitch -// the host stack and enclave stack together. -// -//============================================================================== - -#define HB_SAVED_OCALL_RETURN (0*OE_WORDSIZE)(%rsp) -#define HB_SAVED_ARG1 (1*OE_WORDSIZE)(%rsp) -#define HB_SAVED_ARG2 (2*OE_WORDSIZE)(%rsp) -#define HB_SAVED_ARG3 (3*OE_WORDSIZE)(%rsp) -#define HB_SAVED_ARG4 (4*OE_WORDSIZE)(%rsp) -#define HB_SAVED_TCS (5*OE_WORDSIZE)(%rsp) -#define HB_SAVED_RSP (6*OE_WORDSIZE)(%rsp) -#define HB_SAVED_ENCLAVE (7*OE_WORDSIZE)(%rsp) -#define HB_SAVED_RETURN_ADDR (8*OE_WORDSIZE)(%rsp) -#define HB_SAVED_FRAME_POINTER (9*OE_WORDSIZE)(%rsp) -#define HB_STACK_LENGTH (10*OE_WORDSIZE) - -.globl __oe_host_stack_bridge -.type __oe_host_stack_bridge, @function -.type oe_notify_ocall_start,@function -.hidden oe_notify_ocall_start -.type oe_notify_ocall_end,@function -.hidden oe_notify_ocall_end -__oe_host_stack_bridge: -.cfi_startproc - push %rbp -.cfi_def_cfa_offset 16 -.cfi_offset rbp,-16 - mov %rsp, %rbp -.cfi_def_cfa_register rbp - sub $HB_STACK_LENGTH, %rsp - - // Save the current return address and frame point of __oe_host_stack_bridge - // into stack. - mov 0(%rbp), %rax - mov %rax, HB_SAVED_FRAME_POINTER - mov (1*OE_WORDSIZE)(%rbp), %rax - mov %rax, HB_SAVED_RETURN_ADDR - - // Save the function parameters needed for __oe_dispatch_ocall into stack. - mov %rdi, HB_SAVED_ARG1 // arg1 - mov %rsi, HB_SAVED_ARG2 // arg2 - mov %rdx, HB_SAVED_ARG3 // arg3 - mov %rcx, HB_SAVED_ARG4 // arg4 - mov %r8, HB_SAVED_TCS // tcs - mov %r9, HB_SAVED_RSP // rsp - mov 16(%rbp), %rax // enclave - mov %rax, HB_SAVED_ENCLAVE - - // Notify that an ocall happens in current host thread. - // oe_notify_ocall_start(rdi=host_frame_pointer, rsi=tcs) - mov %rbp, %rdi - mov %r8, %rsi - call oe_notify_ocall_start@PLT - - // Restore the parameters for __oe_dispatch_ocall. - mov HB_SAVED_ARG1, %rdi - mov HB_SAVED_ARG2, %rsi - mov HB_SAVED_ARG3, %rdx - mov HB_SAVED_ARG4, %rcx - mov HB_SAVED_TCS, %r8 - mov HB_SAVED_ENCLAVE, %r9 - - // Do actual OCALL. - call __oe_dispatch_ocall@PLT - - // Save the return value of OCALL dispatch. - mov %rax, HB_SAVED_OCALL_RETURN - - // Notify that an ocall is done in current host thread. - // oe_notify_ocall_start(rdi=host_frame_pointer, rsi=tcs) - mov %rbp, %rdi - mov HB_SAVED_TCS, %rsi - call oe_notify_ocall_end@PLT - - // Because of stack stitching, the return address might be overwritten by - // gdb. Restore the current return address and frame point of - // __oe_host_stack_bridge from stack. - mov HB_SAVED_FRAME_POINTER, %rax - mov %rax, (0*OE_WORDSIZE)(%rbp) - mov HB_SAVED_RETURN_ADDR, %rax - mov %rax, (1*OE_WORDSIZE)(%rbp) - - // Restore the return value of OCALL dispatch. - mov HB_SAVED_OCALL_RETURN, %rax - - leave - ret - -.cfi_endproc diff --git a/host/sgx/linux/entersim.S b/host/sgx/linux/entersim.S deleted file mode 100644 index de7af84c07..0000000000 --- a/host/sgx/linux/entersim.S +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "../asmdefs.h" -#include - -//============================================================================== -// -// void oe_enter_sim( -// [IN] void* tcs, -// [IN] uint64_t aep, -// [IN] uint64_t arg1, -// [IN] uint64_t arg2, -// [OUT] uint64_t* arg3, -// [OUT] uint64_t* arg4, -// [IN] oe_enclave_t* enclave); -// -// Registers: -// RDI - tcs: thread control structure (extended) -// RSI - aep: asynchronous execution procedure -// RDX - arg1 -// RCX - arg2 -// R8 - arg3 -// R9 - arg4 -// -//============================================================================== - -#define TCS (-1*OE_WORDSIZE)(%rbp) -#define AEP (-2*OE_WORDSIZE)(%rbp) -#define ARG1 (-3*OE_WORDSIZE)(%rbp) -#define ARG2 (-4*OE_WORDSIZE)(%rbp) -#define ARG3 (-5*OE_WORDSIZE)(%rbp) -#define ARG4 (-6*OE_WORDSIZE)(%rbp) -#define ENCLAVE (-7*OE_WORDSIZE)(%rbp) -#define ARG1OUT (-8*OE_WORDSIZE)(%rbp) -#define ARG2OUT (-9*OE_WORDSIZE)(%rbp) -#define CSSA (-10*OE_WORDSIZE)(%rbp) -#define RSP (-11*OE_WORDSIZE)(%rbp) -#define HOST_CONTEXT (-12*OE_WORDSIZE)(%rbp) -#define PARAMS_SPACE ((12*OE_WORDSIZE) + OE_CONTEXT_SIZE) - -.globl oe_enter_sim -.type oe_enter_sim, @function -oe_enter_sim: -.cfi_startproc - - // Setup stack frame: - push %rbp - mov %rsp, %rbp - - // Save parameters on stack for later reference: - sub $PARAMS_SPACE, %rsp - mov %rdi, TCS - mov %rsi, AEP - mov %rdx, ARG1 - mov %rcx, ARG2 - mov %r8, ARG3 - mov %r9, ARG4 - mov 16(%rbp), %rax // enclave parameter - mov %rax, ENCLAVE - movq $0, CSSA - - // The host context will be saved in the host stack. - mov %rsp, HOST_CONTEXT - - // Save registers: - push %rbx - -.call_start: - - // Save the current context. - mov HOST_CONTEXT, %rdi - call oe_snap_current_context@PLT - - // Save the stack pointer so enclave can use the stack. - mov %rsp, RSP - - // Call start(RAX=CSSA, RBX=TCS, RCX=RETADDR, RDI=ARG1, RSI=ARG2) - mov CSSA, %rax - mov TCS, %rbx - mov 72(%rbx), %rdx // RDX=TCS.u.main (72) - mov ARG1, %rdi - mov ARG2, %rsi - lea .retaddr(%rip), %rcx - jmp *%rdx -.retaddr: - mov %rdi, ARG1OUT - mov %rsi, ARG2OUT - - // Align the stack since enclave code change the host rsp for call out. - and $-16, %rsp - - // Restore the saved host context. - mov HOST_CONTEXT, %rdi - call oe_restore_partial_context@PLT - -.dispatch_ocall_sim: - - // Save registers that could get clobbered below or by function call. - push %rdi - push %rsi - push %rdx - push %rcx - push %rbx - push %r8 - push %r9 - push %r12 - push %r13 - // Push one extra register to keep the stack aligned. - push %r13 - - // RAX = __oe_dispatch_ocall( - // RDI=arg1 - // RSI=arg2 - // RDX=arg1_out - // RCX=arg2_out - // R8=TCS) - mov ARG1OUT, %rdi - mov ARG2OUT, %rsi - leaq ARG1OUT, %rdx - leaq ARG2OUT, %rcx - mov TCS, %r8 - mov ENCLAVE, %r9 - call __oe_dispatch_ocall@PLT - - // Restore registers saved above: - pop %r13 - pop %r13 - pop %r12 - pop %r9 - pop %r8 - pop %rbx - pop %rcx - pop %rdx - pop %rsi - pop %rdi - - // Restore the stack pointer: - mov RSP, %rsp - - // If this was not an OCALL, then return from ECALL. - // ecall-return-check. - cmp $0, %rax - jne .return_from_ecall_sim - - // Stop speculative execution at fallthrough of conditional - // ecall-return-check. - lfence - - // (RDI=TCS, RDX=ARG1, RCX=ARG2) - mov ARG1OUT, %rax - mov %rax, ARG1 - mov ARG2OUT, %rax - mov %rax, ARG2 - jmp .call_start - -.return_from_ecall_sim: - // Stop speculative execution at target of conditional jump - // ecall-return-check. - lfence - - // Set output parameters: - mov ARG1OUT, %rax - mov %rax, (%r8) /* arg3 */ - mov ARG2OUT, %rax - mov %rax, (%r9) /* arg4 */ - - // Restore registers: - pop %rbx - - // Return parameters space: - add $PARAMS_SPACE, %rsp - - // Restore stack frame: - pop %rbp - - ret - -.forever: - jmp .forever - -.cfi_endproc diff --git a/host/sgx/linux/exception.c b/host/sgx/linux/exception.c index 8e02498bc8..75499e5b53 100644 --- a/host/sgx/linux/exception.c +++ b/host/sgx/linux/exception.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../exception.h" diff --git a/host/sgx/linux/hoststackbridge.c b/host/sgx/linux/hoststackbridge.c new file mode 100644 index 0000000000..ec573571c2 --- /dev/null +++ b/host/sgx/linux/hoststackbridge.c @@ -0,0 +1,41 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include "../asmdefs.h" + +// The following function must not be inlined and must have a frame-pointer +// so that the frame can be manipulated to stitch the ocall stack. +// This is ensured by compiling this file with -fno-omit-frame-pointer. +OE_NEVER_INLINE +int __oe_host_stack_bridge( + uint64_t arg1, + uint64_t arg2, + uint64_t* arg1_out, + uint64_t* arg2_out, + void* tcs, + oe_enclave_t* enclave) +{ + oe_host_ocall_frame_t *current, backup; + + // Fetch pointer to current frame. + asm volatile("mov %%rbp, %0\n\t" : "=r"(current) : : "memory"); + + // Back up current frame. + backup = *current; + + // Notify the debugger to overwrite the return address of + // the current frame with the exit frame of the enclave. + // This will stitch the ocall stack. + oe_notify_ocall_start(current, tcs); + + int ret = __oe_dispatch_ocall(arg1, arg2, arg1_out, arg2_out, tcs, enclave); + + // Restore the frame so that this function can return to the caller + // correctly. Alternatively, we could use a setjmp/longjmp combination. + *current = backup; + + return ret; +} diff --git a/host/sgx/linux/sgxioctl.c b/host/sgx/linux/sgxioctl.c index 7cd73ff02e..4bc3f4f134 100644 --- a/host/sgx/linux/sgxioctl.c +++ b/host/sgx/linux/sgxioctl.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "sgxioctl.h" diff --git a/host/sgx/linux/sgxioctl.h b/host/sgx/linux/sgxioctl.h index ac707a4dd7..325963b0c2 100644 --- a/host/sgx/linux/sgxioctl.h +++ b/host/sgx/linux/sgxioctl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXIOCTL_H diff --git a/host/sgx/linux/sgxquoteproviderloader.c b/host/sgx/linux/sgxquoteproviderloader.c index 30610085f1..eb3570783a 100644 --- a/host/sgx/linux/sgxquoteproviderloader.c +++ b/host/sgx/linux/sgxquoteproviderloader.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -74,7 +74,7 @@ void oe_load_quote_provider() else { OE_TRACE_ERROR( - "sgxquoteprovider: libdcap_quoteprov.so not found \n"); + "sgxquoteprovider: libdcap_quoteprov.so %s\n", dlerror()); } } } diff --git a/host/sgx/linux/switchless.c b/host/sgx/linux/switchless.c new file mode 100644 index 0000000000..808a0d400c --- /dev/null +++ b/host/sgx/linux/switchless.c @@ -0,0 +1,63 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include + +#include +#include +#include + +void oe_host_worker_wait(oe_host_worker_context_t* context) +{ + // If event is 1, it means that there a pending wake notification from + // enclave. Consume it by setting event to 0. Don't wait. + // + // If event is 0, then wait until event is 1. + int32_t oldval = 1; + int32_t newval = 0; + + // Weak operations can fail spuriously. + // We want a strong operation. + bool weak = false; + if (!__atomic_compare_exchange_n( + &context->event, + &oldval, + newval, + weak, + __ATOMIC_ACQ_REL, + __ATOMIC_ACQUIRE)) + { + // The old value is 0. There is no pending wake notification from the + // enclave. + do + { + // Error codes from syscall are ignored since we wait until event + // is non-zero. + syscall( + __NR_futex, + &context->event, + FUTEX_WAIT_PRIVATE, + 0, + NULL, + NULL, + 0); + // If context->event is still 0, then this is a spurious-wake. + // Spurious-wakes are ignored by going back to FUTEX_WAIT. + // Since FUTEX_WAIT uses atomic instructions to load event->value, + // it is safe to use a non-atomic operation here. + } while (context->event == 0); + } +} + +void oe_host_worker_wake(oe_host_worker_context_t* context) +{ + context->event = 1; + syscall( + __NR_futex, + &context->event, + FUTEX_WAKE_PRIVATE, + 1 /* wake 1 thread */, + NULL, + NULL, + 0); +} diff --git a/host/sgx/linux/xstate.c b/host/sgx/linux/xstate.c index a06c436d1c..338f79cfaf 100644 --- a/host/sgx/linux/xstate.c +++ b/host/sgx/linux/xstate.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../xstate.h" diff --git a/host/sgx/load.c b/host/sgx/load.c index 44c02d1650..f483e466a5 100644 --- a/host/sgx/load.c +++ b/host/sgx/load.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/sgx/loadelf.c b/host/sgx/loadelf.c index 18e81b903b..8baf65b45e 100644 --- a/host/sgx/loadelf.c +++ b/host/sgx/loadelf.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/sgx/loadpe.c b/host/sgx/loadpe.c index 660fdb34dd..990aed6e10 100644 --- a/host/sgx/loadpe.c +++ b/host/sgx/loadpe.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -265,6 +265,7 @@ oe_result_t oe_load_pe_enclave_image( PIMAGE_SECTION_HEADER section_hdr; const IMAGE_DATA_DIRECTORY* idd; uint32_t i; + DWORD old_protection; memset(image, 0, sizeof(oe_enclave_image_t)); image->type = OE_IMAGE_TYPE_PE; @@ -308,7 +309,10 @@ oe_result_t oe_load_pe_enclave_image( /* change protection to r/w */ if (!VirtualProtect( - image->image_base, image->image_size, PAGE_READWRITE, &i)) + image->image_base, + image->image_size, + PAGE_READWRITE, + &old_protection)) { OE_RAISE(OE_FAILURE); } diff --git a/host/sgx/ocalls.c b/host/sgx/ocalls.c index 2f2d91fa2b..91c4541fe1 100644 --- a/host/sgx/ocalls.c +++ b/host/sgx/ocalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -119,7 +119,7 @@ oe_result_t oe_get_quote_ocall( return result; } -#if defined(OE_USE_LIBSGX) +#if defined(OE_LINK_SGX_DCAP_QL) /* Copy the source array to an output buffer. */ static oe_result_t _copy_output_buffer( @@ -260,7 +260,7 @@ oe_result_t oe_get_revocation_info_ocall( &buffer_too_small)); if (buffer_too_small) - OE_RAISE(OE_BUFFER_TOO_SMALL); + OE_RAISE_NO_TRACE(OE_BUFFER_TOO_SMALL); result = OE_OK; @@ -271,7 +271,7 @@ oe_result_t oe_get_revocation_info_ocall( return result; } -oe_result_t oe_get_qe_identify_info_ocall( +oe_result_t oe_get_qe_identity_info_ocall( void* qe_id_info, size_t qe_id_info_size, size_t* qe_id_info_size_out, @@ -308,6 +308,7 @@ oe_result_t oe_get_qe_identify_info_ocall( memcpy(issuer_chain, args.issuer_chain, args.issuer_chain_size); *issuer_chain_size_out = args.issuer_chain_size; + result = OE_OK; done: @@ -317,7 +318,7 @@ oe_result_t oe_get_qe_identify_info_ocall( return result; } -#else /* !defined(OE_USE_LIBSGX) */ +#else /* !defined(OE_LINK_SGX_DCAP_QL) */ oe_result_t oe_get_revocation_info_ocall( uint8_t fmspc[6], @@ -383,7 +384,7 @@ oe_result_t oe_get_revocation_info_ocall( return OE_UNSUPPORTED; } -oe_result_t oe_get_qe_identify_info_ocall( +oe_result_t oe_get_qe_identity_info_ocall( void* qe_id_info, size_t qe_id_info_size, size_t* qe_id_info_size_out, @@ -401,7 +402,7 @@ oe_result_t oe_get_qe_identify_info_ocall( return OE_UNSUPPORTED; } -#endif /* !defined(OE_USE_LIBSGX) */ +#endif /* !defined(OE_LINK_SGX_DCAP_QL) */ oe_result_t oe_get_qetarget_info_ocall(sgx_target_info_t* target_info) { diff --git a/host/sgx/ocalls.h b/host/sgx/ocalls.h index c4bb41ea3a..3281941259 100644 --- a/host/sgx/ocalls.h +++ b/host/sgx/ocalls.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_SGX_OCALLS_H diff --git a/host/sgx/platformquoteprovider.h b/host/sgx/platformquoteprovider.h index 1b9c869758..07e2ac09f5 100644 --- a/host/sgx/platformquoteprovider.h +++ b/host/sgx/platformquoteprovider.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/host/sgx/quote.c b/host/sgx/quote.c index 37c9b0d5fd..646d3a865f 100644 --- a/host/sgx/quote.c +++ b/host/sgx/quote.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "quote.h" @@ -10,135 +10,9 @@ #include #include -#if defined(OE_USE_LIBSGX) +#if defined(OE_LINK_SGX_DCAP_QL) #include "sgxquote.h" #include "sgxquoteprovider.h" -#else -#include -#endif - -#if !defined(OE_USE_LIBSGX) - -static oe_result_t _sgx_init_quote_with_aesm(sgx_target_info_t* target_info) -{ - oe_result_t result = OE_UNEXPECTED; - sgx_epid_group_id_t epid_group_id = {{0}}; - - aesm_t* aesm = NULL; - - if (!(aesm = aesm_connect())) - OE_RAISE(OE_FAILURE); - - OE_CHECK(aesm_init_quote(aesm, target_info, &epid_group_id)); - - result = OE_OK; - -done: - - if (aesm) - aesm_disconnect(aesm); - - return result; -} - -static oe_result_t _sgx_get_quote_size_from_aesm( - const uint8_t* signature_revocation_list, - size_t* quote_size) -{ - oe_result_t result = OE_FAILURE; - size_t signature_size = 0; - uint32_t n = 0; - const sgx_sig_rl_t* sig_rl = (const sgx_sig_rl_t*)signature_revocation_list; - - if (quote_size) - *quote_size = 0; - - if (!quote_size) - goto done; - - if (sig_rl) - { - if (sig_rl->protocol_version != SGX_SE_EPID_SIG_RL_VERSION || - sig_rl->epid_identifier != SGX_SE_EPID_SIG_RL_ID) - { - goto done; - } - - assert(sizeof(sig_rl->sig_rl.n2) == sizeof(uint32_t)); - const void* tmp = &sig_rl->sig_rl.n2; - n = oe_byte_swap32(*(uint32_t*)tmp); - } - - /* Calculate variable size of EPID_Signature with N entries */ - signature_size = - sizeof(sgx_epid_signature_t) + (n * sizeof(sgx_epid_nr_proof_t)); - - *quote_size = sizeof(sgx_quote_t) + sizeof(sgx_wrap_key_t) + - SGX_QUOTE_IV_SIZE + sizeof(uint32_t) + signature_size + - SGX_MAC_SIZE; - - result = OE_OK; - -done: - return result; -} - -static oe_result_t _sgx_get_quote_from_aesm( - const sgx_report_t* report, - sgx_quote_type_t quote_type, - sgx_quote_t* quote, - size_t quote_size) -{ - static const sgx_spid_t spid = {{ - 0x21, - 0x68, - 0x79, - 0xB4, - 0x42, - 0xA0, - 0x4A, - 0x07, - 0x60, - 0xF6, - 0x39, - 0x91, - 0x7F, - 0x4E, - 0x8B, - 0x04, - }}; - - oe_result_t result = OE_UNEXPECTED; - aesm_t* aesm = NULL; - - if (!report || !quote || !quote_size) - OE_RAISE(OE_INVALID_PARAMETER); - - if (!(aesm = aesm_connect())) - OE_RAISE(OE_SERVICE_UNAVAILABLE); - - OE_CHECK(aesm_get_quote( - aesm, - report, - quote_type, - &spid, - NULL, /* nonce */ - NULL, /* signature_revocation_list */ - 0, /* signature_revocation_list_size */ - NULL, /* report_out */ - quote, - quote_size)); - - result = OE_OK; - -done: - - if (aesm) - aesm_disconnect(aesm); - - return result; -} - #endif oe_result_t sgx_get_qetarget_info(sgx_target_info_t* target_info) @@ -146,7 +20,7 @@ oe_result_t sgx_get_qetarget_info(sgx_target_info_t* target_info) oe_result_t result = OE_UNEXPECTED; memset(target_info, 0, sizeof(sgx_target_info_t)); -#if defined(OE_USE_LIBSGX) +#if defined(OE_LINK_SGX_DCAP_QL) // Quote workflow always begins with obtaining the target info. Therefore // initializing the quote provider here ensures that that we can control its // life time rather than Intel's attestation libraries. @@ -155,13 +29,13 @@ oe_result_t sgx_get_qetarget_info(sgx_target_info_t* target_info) OE_CHECK(oe_initialize_quote_provider()); OE_CHECK(oe_sgx_qe_get_target_info((uint8_t*)target_info)); -#else - OE_CHECK(_sgx_init_quote_with_aesm(target_info)); -#endif - result = OE_OK; done: return result; +#else + result = OE_UNSUPPORTED; + return result; +#endif } oe_result_t sgx_get_quote_size(size_t* quote_size) @@ -174,10 +48,10 @@ oe_result_t sgx_get_quote_size(size_t* quote_size) if (!quote_size) OE_RAISE(OE_INVALID_PARAMETER); -#if defined(OE_USE_LIBSGX) +#if defined(OE_LINK_SGX_DCAP_QL) result = oe_sgx_qe_get_quote_size(quote_size); #else - result = _sgx_get_quote_size_from_aesm(NULL, quote_size); + result = OE_UNSUPPORTED; #endif done: @@ -217,17 +91,10 @@ oe_result_t sgx_get_quote( /* Get the quote from the AESM service */ -#if defined(OE_USE_LIBSGX) - +#if defined(OE_LINK_SGX_DCAP_QL) result = oe_sgx_qe_get_quote((uint8_t*)report, *quote_size, quote); - #else - - result = _sgx_get_quote_from_aesm( - report, - SGX_QUOTE_TYPE_UNLINKABLE_SIGNATURE, - (sgx_quote_t*)quote, - *quote_size); + result = OE_UNSUPPORTED; #endif done: diff --git a/host/sgx/quote.h b/host/sgx/quote.h index 2b5377ce94..71ae20c7b0 100644 --- a/host/sgx/quote.h +++ b/host/sgx/quote.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_QUOTE_H diff --git a/host/sgx/registers.c b/host/sgx/registers.c index d661f67ad7..466cc60f62 100644 --- a/host/sgx/registers.c +++ b/host/sgx/registers.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(__linux__) @@ -7,6 +7,7 @@ #include #elif defined(_WIN32) #include +#include #endif #include diff --git a/host/sgx/report.c b/host/sgx/report.c index 0ac6b07014..872da7d6b2 100644 --- a/host/sgx/report.c +++ b/host/sgx/report.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -15,6 +15,8 @@ #include "sgx_u.h" #include "tee_u.h" +#include "../common/sgx/verify_eeid.h" + #include "sgxquoteprovider.h" OE_STATIC_ASSERT(OE_REPORT_DATA_SIZE == sizeof(sgx_report_data_t)); @@ -27,7 +29,6 @@ static oe_result_t _get_local_report( size_t* report_buffer_size) { oe_result_t result = OE_UNEXPECTED; - uint32_t retval; // opt_params, if specified, must be a sgx_target_info_t. When opt_params is // NULL, opt_params_size must be zero. @@ -43,20 +44,18 @@ static oe_result_t _get_local_report( if (report_buffer == NULL || *report_buffer_size < sizeof(sgx_report_t)) { *report_buffer_size = sizeof(sgx_report_t); - OE_RAISE(OE_BUFFER_TOO_SMALL); + OE_RAISE_NO_TRACE(OE_BUFFER_TOO_SMALL); } OE_CHECK(oe_get_sgx_report_ecall( enclave, - &retval, + &result, opt_params, opt_params_size, (sgx_report_t*)report_buffer)); *report_buffer_size = sizeof(sgx_report_t); - result = (oe_result_t)retval; - done: return result; @@ -145,10 +144,13 @@ static oe_result_t _oe_get_report_internal( oe_result_t result = OE_FAILURE; oe_report_header_t* header = (oe_report_header_t*)report_buffer; -#if defined(OE_USE_LIBSGX) +#if defined(OE_LINK_SGX_DCAP_QL) // The two host side attestation API's are oe_get_report and // oe_verify_report. Initialize the quote provider in both these APIs. OE_CHECK(oe_initialize_quote_provider()); +#else + if (flags & OE_REPORT_FLAGS_REMOTE_ATTESTATION) + return OE_UNSUPPORTED; #endif // Reserve space in the buffer for header. @@ -271,6 +273,17 @@ oe_result_t oe_verify_report( const uint8_t* report, size_t report_size, oe_report_t* parsed_report) +{ + return oe_verify_report_eeid( + enclave, report, report_size, parsed_report, NULL); +} + +oe_result_t oe_verify_report_eeid( + oe_enclave_t* enclave, + const uint8_t* report, + size_t report_size, + oe_report_t* parsed_report, + oe_eeid_t* eeid) { oe_result_t result = OE_UNEXPECTED; oe_report_t oe_report = {0}; @@ -288,27 +301,25 @@ oe_result_t oe_verify_report( if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE) { // Intialize the quote provider if we want to verify a remote quote. - // Note that we don't have the OE_USE_LIBSGX guard here since we don't - // need the sgx libraries to verify the quote. All we need is the quote - // provider. + // Note that we don't have the OE_LINK_SGX_DCAP_QL guard here since we + // don't need the sgx libraries to verify the quote. All we need is the + // quote provider. OE_CHECK(oe_initialize_quote_provider()); // Quote attestation can be done entirely on the host side. - OE_CHECK(oe_verify_quote_internal( - header->report, header->report_size, NULL, 0, NULL, 0, NULL, 0)); + OE_CHECK(oe_verify_sgx_quote( + header->report, header->report_size, NULL, 0, NULL)); } else if (header->report_type == OE_REPORT_TYPE_SGX_LOCAL) { - uint32_t retval; + oe_result_t retval; if (enclave == NULL) OE_RAISE(OE_INVALID_PARAMETER); OE_CHECK(oe_verify_report_ecall(enclave, &retval, report, report_size)); - OE_CHECK(retval); } - else { OE_RAISE(OE_INVALID_PARAMETER); @@ -318,6 +329,18 @@ oe_result_t oe_verify_report( if (parsed_report != NULL) OE_CHECK(oe_parse_report(report, report_size, parsed_report)); + if (eeid) + { + if (!parsed_report) + { + oe_report_t treport; + OE_CHECK(oe_parse_report(report, report_size, &treport)); + verify_eeid(&treport, eeid); + } + else + verify_eeid(parsed_report, eeid); + } + result = OE_OK; done: return result; diff --git a/host/sgx/sgx_u_wrapper.c b/host/sgx/sgx_u_wrapper.c index 3eed2da9ab..503ad26c48 100644 --- a/host/sgx/sgx_u_wrapper.c +++ b/host/sgx/sgx_u_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/sgx/sgxload.c b/host/sgx/sgxload.c index 8122d4a70c..81e62425ed 100644 --- a/host/sgx/sgxload.c +++ b/host/sgx/sgxload.c @@ -1,25 +1,20 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "sgxload.h" -#if defined(OE_USE_LIBSGX) #include -#endif #if defined(__linux__) -#include #include #include -#include "linux/sgxioctl.h" #elif defined(_WIN32) #include -#define MAX_EINIT_RETRY_COUNT 50 #endif #include +#include #include #include -#include #include #include #include @@ -49,23 +44,14 @@ static int _make_memory_protect_param(uint64_t inflags, bool simulate) } else { -#if defined(OE_USE_LIBSGX) - /* libsgx is only used when not in simulation mode */ outflags = ENCLAVE_PAGE_THREAD_CONTROL | ENCLAVE_PAGE_READ | ENCLAVE_PAGE_WRITE; -#elif defined(__linux__) - outflags = PROT_NONE; -#elif defined(_WIN32) - outflags = PAGE_ENCLAVE_THREAD_CONTROL | PAGE_READWRITE; -#endif } } else if (inflags & SGX_SECINFO_REG) { -#if defined(OE_USE_LIBSGX) if (!simulate) { - /* libsgx is only used when not in simulation mode */ if (inflags & SGX_SECINFO_R) outflags |= ENCLAVE_PAGE_READ; @@ -76,9 +62,8 @@ static int _make_memory_protect_param(uint64_t inflags, bool simulate) outflags |= ENCLAVE_PAGE_EXECUTE; } else + /* simulation mode falls back to OS memory protection settings */ { -/* simulation mode falls back to OS memory protection settings */ -#endif #if defined(__linux__) if (inflags & SGX_SECINFO_R) outflags |= PROT_READ; @@ -89,25 +74,23 @@ static int _make_memory_protect_param(uint64_t inflags, bool simulate) if (inflags & SGX_SECINFO_X) outflags |= PROT_EXEC; #elif defined(_WIN32) - if ((inflags & SGX_SECINFO_X) && (inflags & SGX_SECINFO_R) && - (inflags & SGX_SECINFO_W)) - { - outflags = PAGE_EXECUTE_READWRITE; - } - else if ((inflags & SGX_SECINFO_X) && (inflags & SGX_SECINFO_R)) - outflags = PAGE_EXECUTE_READ; - else if ((inflags & SGX_SECINFO_X)) - outflags = PAGE_EXECUTE; - else if ((inflags & SGX_SECINFO_R) && (inflags & SGX_SECINFO_W)) - outflags = PAGE_READWRITE; - else if ((inflags & SGX_SECINFO_R)) - outflags = PAGE_READONLY; - else - outflags = PAGE_NOACCESS; + if ((inflags & SGX_SECINFO_X) && (inflags & SGX_SECINFO_R) && + (inflags & SGX_SECINFO_W)) + { + outflags = PAGE_EXECUTE_READWRITE; + } + else if ((inflags & SGX_SECINFO_X) && (inflags & SGX_SECINFO_R)) + outflags = PAGE_EXECUTE_READ; + else if ((inflags & SGX_SECINFO_X)) + outflags = PAGE_EXECUTE; + else if ((inflags & SGX_SECINFO_R) && (inflags & SGX_SECINFO_W)) + outflags = PAGE_READWRITE; + else if ((inflags & SGX_SECINFO_R)) + outflags = PAGE_READONLY; + else + outflags = PAGE_NOACCESS; #endif -#if defined(OE_USE_LIBSGX) } -#endif } #if defined(__linux__) @@ -272,6 +255,7 @@ static void* _allocate_enclave_memory(size_t enclave_size, int fd) return result; #elif defined(_WIN32) + OE_UNUSED(fd); /* Allocate enclave memory for simulated mode only */ void* result = NULL; @@ -299,7 +283,8 @@ static oe_result_t _sgx_free_enclave_memory( size_t size, bool is_simulation) { -#if defined(OE_USE_LIBSGX) + OE_UNUSED(size); + if (!is_simulation) { uint32_t enclave_error = 0; @@ -311,7 +296,6 @@ static oe_result_t _sgx_free_enclave_memory( } } else /* Fallthrough to simulation mode cleanup based on OS. */ -#endif { OE_UNUSED(is_simulation); #if defined(__linux__) @@ -376,45 +360,6 @@ static oe_result_t _get_sig_struct( return result; } -/* obtaining a launch token is only necessary when not using libsgx */ -#if !defined(OE_USE_LIBSGX) -static oe_result_t _get_launch_token( - const oe_sgx_enclave_properties_t* properties, - sgx_sigstruct_t* sigstruct, - sgx_launch_token_t* launch_token) -{ - oe_result_t result = OE_UNEXPECTED; - aesm_t* aesm = NULL; - - /* Initialize the SGX attributes */ - sgx_attributes_t attributes = {0}; - attributes.flags = properties->config.attributes; - attributes.xfrm = properties->config.xfrm; - - memset(launch_token, 0, sizeof(sgx_launch_token_t)); - - /* Obtain a launch token from the AESM service */ - if (!(aesm = aesm_connect())) - OE_RAISE(OE_FAILURE); - - OE_CHECK(aesm_get_launch_token( - aesm, - sigstruct->enclavehash, - sigstruct->modulus, - &attributes, - launch_token)); - - result = OE_OK; - -done: - - if (aesm) - aesm_disconnect(aesm); - - return result; -} -#endif - oe_result_t oe_sgx_initialize_load_context( oe_sgx_load_context_t* context, oe_sgx_load_type_t type, @@ -433,15 +378,6 @@ oe_result_t oe_sgx_initialize_load_context( context->attributes.xfrm = _detect_xfrm(); context->dev = OE_SGX_NO_DEVICE_HANDLE; -#if !defined(OE_USE_LIBSGX) && defined(__linux__) - if (type != OE_SGX_LOAD_TYPE_MEASURE && - !oe_sgx_is_simulation_load_context(context)) - { - context->dev = open("/dev/isgx", O_RDWR); - if (context->dev == OE_SGX_NO_DEVICE_HANDLE) - OE_RAISE_MSG(OE_FAILURE, "open /dev/isgx device file failed"); - } -#endif context->state = OE_SGX_LOAD_STATE_INITIALIZED; result = OE_OK; @@ -452,10 +388,6 @@ oe_result_t oe_sgx_initialize_load_context( void oe_sgx_cleanup_load_context(oe_sgx_load_context_t* context) { -#if !defined(OE_USE_LIBSGX) && defined(__linux__) - if (context && context->dev != OE_SGX_NO_DEVICE_HANDLE) - close(context->dev); -#endif /* Clear all fields, this also sets state to undefined */ memset(context, 0, sizeof(oe_sgx_load_context_t)); } @@ -486,9 +418,7 @@ oe_result_t oe_sgx_create_enclave( * mode or on Linux Kabylake machines. */ if (context->type == OE_SGX_LOAD_TYPE_CREATE) { -#if defined(OE_USE_LIBSGX) || defined(_WIN32) if (oe_sgx_is_simulation_load_context(context)) -#endif { /* Allocation memory-mapped region */ if (!(base = _allocate_enclave_memory(enclave_size, context->dev))) @@ -516,8 +446,6 @@ oe_result_t oe_sgx_create_enclave( } else { -#if defined(OE_USE_LIBSGX) - uint32_t enclave_error; void* base = enclave_create( NULL, /* Let OS choose the enclave base address */ @@ -535,37 +463,6 @@ oe_result_t oe_sgx_create_enclave( enclave_error); secs->base = (uint64_t)base; - -#elif defined(__linux__) - - /* Ask the Linux SGX driver to create the enclave - sgxioctl internally traces any driver returned error */ - if (sgx_ioctl_enclave_create(context->dev, secs) != 0) - OE_RAISE(OE_IOCTL_FAILED); - -#elif defined(_WIN32) - - /* Ask OS to create the enclave */ - DWORD enclave_error; - void* base = CreateEnclave( - GetCurrentProcess(), - NULL, /* Let OS choose the enclave base address */ - secs->size, - secs->size, - ENCLAVE_TYPE_SGX, - (const void*)secs, - sizeof(ENCLAVE_CREATE_INFO_SGX), - &enclave_error); - - if (!base) - OE_RAISE_MSG( - OE_PLATFORM_ERROR, - "CreateEnclave failed (err=%#x)", - enclave_error); - - secs->base = (uint64_t)base; - -#endif } *enclave_addr = base ? (uint64_t)base : secs->base; @@ -770,8 +667,6 @@ oe_result_t oe_sgx_load_enclave_data( } else { -#if defined(OE_USE_LIBSGX) - int protect = _make_memory_protect_param(flags, false /*not simulate*/); if (!extend) protect |= ENCLAVE_PAGE_UNVALIDATED; @@ -789,46 +684,6 @@ oe_result_t oe_sgx_load_enclave_data( addr, protect, enclave_error); - -#elif defined(__linux__) - - /* Ask the Linux SGX driver to add a page to the enclave - sgxioctl internally traces any driver returned error */ - if (sgx_ioctl_enclave_add_page( - context->dev, addr, src, flags, extend) != 0) - OE_RAISE(OE_IOCTL_FAILED); - -#elif defined(_WIN32) - - /* Ask the OS to add a page to the enclave */ - SIZE_T num_bytes = 0; - DWORD enclave_error; - - DWORD protect = - _make_memory_protect_param(flags, false /*not simulate*/); - if (!extend) - protect |= PAGE_ENCLAVE_UNVALIDATED; - - if (!LoadEnclaveData( - GetCurrentProcess(), - (LPVOID)addr, - (LPCVOID)src, - OE_PAGE_SIZE, - protect, - NULL, - 0, - &num_bytes, - &enclave_error)) - { - OE_RAISE_MSG( - OE_PLATFORM_ERROR, - "LoadEnclaveData failed (addr=%#x, prot=%#x, err=%#x)", - addr, - protect, - enclave_error); - } - -#endif } result = OE_OK; @@ -866,8 +721,6 @@ oe_result_t oe_sgx_initialize_enclave( sgx_sigstruct_t sigstruct; OE_CHECK(_get_sig_struct(properties, mrenclave, &sigstruct)); -#if defined(OE_USE_LIBSGX) - uint32_t enclave_error = 0; if (!enclave_initialize( (void*)addr, @@ -878,82 +731,6 @@ oe_result_t oe_sgx_initialize_enclave( OE_PLATFORM_ERROR, "enclave_initialize failed (err=%#x)", enclave_error); - -#else - /* If not using libsgx, get a launch token from the AESM service */ - sgx_launch_token_t launch_token; - OE_CHECK(_get_launch_token(properties, &sigstruct, &launch_token)); - -#if defined(__linux__) - - /* Ask the Linux SGX driver to initialize the enclave - sgxioctl internally traces any driver returned error */ - if (sgx_ioctl_enclave_init( - context->dev, - addr, - (uint64_t)&sigstruct, - (uint64_t)&launch_token) != 0) - OE_RAISE(OE_IOCTL_FAILED); - -#elif defined(_WIN32) - - OE_STATIC_ASSERT( - OE_FIELD_SIZE(ENCLAVE_INIT_INFO_SGX, SigStruct) == - sizeof(sigstruct)); - OE_STATIC_ASSERT( - OE_FIELD_SIZE(ENCLAVE_INIT_INFO_SGX, EInitToken) <= - sizeof(launch_token)); - - /* Ask the OS to initialize the enclave */ - DWORD enclave_error; - ENCLAVE_INIT_INFO_SGX info = {{0}}; - - OE_CHECK(oe_memcpy_s( - &info.SigStruct, - sizeof(info.SigStruct), - (void*)&sigstruct, - sizeof(sigstruct))); - OE_CHECK(oe_memcpy_s( - &info.EInitToken, - sizeof(info.EInitToken), - (void*)&launch_token, - sizeof(info.EInitToken))); - - BOOL success = FALSE; - /* - * Adding retry count to prevent the failures seen with Windows CI with - * EINIT SGX_UNMASKED_EVENT, presumably due to large number of external - * interrupts fired in succession. Mitigating this with retry logic at - * the OE SDK level as inhibiting the unmasked events requires Windows - * kernel support. Thus far, we have not seen the same issue on Linux, - * which has more retries and also does a 20ms sleep between each EINIT - * attempt. Did not add any delay or sleep as the context switch to - * Windows kernel mode should suffice for the delay. - * - */ - for (DWORD i = 0; i < MAX_EINIT_RETRY_COUNT; i++) - { - enclave_error = 0; - success = InitializeEnclave( - GetCurrentProcess(), - (LPVOID)addr, - &info, - sizeof(info), - &enclave_error); - - if (enclave_error != SGX_UNMASKED_EVENT) - break; - } - - if (!success) - { - OE_RAISE_MSG( - OE_PLATFORM_ERROR, - "InitializeEnclave failed (err=%#x)", - enclave_error); - } -#endif -#endif } context->state = OE_SGX_LOAD_STATE_ENCLAVE_INITIALIZED; diff --git a/host/sgx/sgxload.h b/host/sgx/sgxload.h index 753ff749cf..9c0b7258c9 100644 --- a/host/sgx/sgxload.h +++ b/host/sgx/sgxload.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXLOAD_H diff --git a/host/sgx/sgxmeasure.c b/host/sgx/sgxmeasure.c index 0b3ce7e098..07c31bfb5b 100644 --- a/host/sgx/sgxmeasure.c +++ b/host/sgx/sgxmeasure.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "sgxmeasure.h" diff --git a/host/sgx/sgxmeasure.h b/host/sgx/sgxmeasure.h index 268185eba3..a23263d2cb 100644 --- a/host/sgx/sgxmeasure.h +++ b/host/sgx/sgxmeasure.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXMEASURE_H diff --git a/host/sgx/sgxquote.c b/host/sgx/sgxquote.c index ed95852952..3a23fda2a6 100644 --- a/host/sgx/sgxquote.c +++ b/host/sgx/sgxquote.c @@ -1,6 +1,6 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. -#if defined(OE_USE_LIBSGX) +#if defined(OE_LINK_SGX_DCAP_QL) #include "sgxquote.h" #include diff --git a/host/sgx/sgxquote.h b/host/sgx/sgxquote.h index 6417653621..0bd5761b8a 100644 --- a/host/sgx/sgxquote.h +++ b/host/sgx/sgxquote.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXQUOTE_H diff --git a/host/sgx/sgxquoteprovider.c b/host/sgx/sgxquoteprovider.c index 29e7dfa504..bd7b83660d 100644 --- a/host/sgx/sgxquoteprovider.c +++ b/host/sgx/sgxquoteprovider.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -232,7 +232,7 @@ oe_result_t oe_get_revocation_info(oe_get_revocation_info_args_t* args) return result; } -void oe_cleanup_get_revocation_info_args(oe_get_revocation_info_args_t* args) +void oe_free_get_revocation_info_args(oe_get_revocation_info_args_t* args) { if (args) { @@ -329,7 +329,7 @@ oe_result_t oe_get_qe_identity_info(oe_get_qe_identity_info_args_t* args) return result; } -void oe_cleanup_qe_identity_info_args(oe_get_qe_identity_info_args_t* args) +void oe_free_qe_identity_info_args(oe_get_qe_identity_info_args_t* args) { if (args) { diff --git a/host/sgx/sgxquoteprovider.h b/host/sgx/sgxquoteprovider.h index ba3858bb9c..79462cc580 100644 --- a/host/sgx/sgxquoteprovider.h +++ b/host/sgx/sgxquoteprovider.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGX_HOST_QUOTE_PROVIDER_H @@ -28,8 +28,8 @@ typedef struct _oe_sgx_quote_provider #define SGX_QL_GET_REVOCATION_INFO_NAME "sgx_ql_get_revocation_info" #define SGX_QL_FREE_REVOCATION_INFO_NAME "sgx_ql_free_revocation_info" -#define SGX_QL_GET_QE_IDENTITY_INFO_NAME "sgx_ql_get_qe_identity_info" -#define SGX_QL_FREE_QE_IDENTITY_INFO_NAME "sgx_ql_free_qe_identity_info" +#define SGX_QL_GET_QE_IDENTITY_INFO_NAME "sgx_get_qe_identity_info" +#define SGX_QL_FREE_QE_IDENTITY_INFO_NAME "sgx_free_qe_identity_info" #define SGX_QL_SET_LOGGING_FUNCTION_NAME "sgx_ql_set_logging_function" OE_EXTERNC_END diff --git a/host/sgx/sgxsign.c b/host/sgx/sgxsign.c index 09f746bb79..dd2bf28a98 100644 --- a/host/sgx/sgxsign.c +++ b/host/sgx/sgxsign.c @@ -1,9 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include -#include #include #include #include diff --git a/host/sgx/sgxtypes.c b/host/sgx/sgxtypes.c index fd0da988c7..5663b0d46f 100644 --- a/host/sgx/sgxtypes.c +++ b/host/sgx/sgxtypes.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/sgx/switchless.c b/host/sgx/switchless.c new file mode 100644 index 0000000000..c252dadba3 --- /dev/null +++ b/host/sgx/switchless.c @@ -0,0 +1,186 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include "../calls.h" +#include "../hostthread.h" +#include "../ocalls.h" +#include "enclave.h" + +/** + * Number of iterations an ocall worker thread would spin before going to sleep + */ +#define OE_HOST_WORKER_SPIN_COUNT_THRESHOLD (4096U) + +/* +** The thread function that handles switchless ocalls +** +*/ +static void* _switchless_ocall_worker(void* arg) +{ + oe_host_worker_context_t* context = (oe_host_worker_context_t*)arg; + + while (!context->is_stopping) + { + volatile oe_call_host_function_args_t* local_call_arg = NULL; + if ((local_call_arg = context->call_arg) != NULL) + { + context->call_arg = NULL; + + oe_handle_call_host_function( + (uint64_t)local_call_arg, context->enclave); + + // Reset spin count for next message. + context->total_spin_count += context->spin_count; + context->spin_count = 0; + } + else + { + // If there is no message, increment spin count until threshold is + // reached. + if (++context->spin_count >= OE_HOST_WORKER_SPIN_COUNT_THRESHOLD) + { + // Reset spin count and go to sleep until event is fired. + context->total_spin_count += context->spin_count; + context->spin_count = 0; + oe_host_worker_wait(context); + } + } + } + return NULL; +} + +static oe_result_t oe_stop_worker_threads(oe_switchless_call_manager_t* manager) +{ + oe_result_t result = OE_UNEXPECTED; + for (size_t i = 0; i < manager->num_host_workers; i++) + { + manager->host_worker_contexts[i].is_stopping = true; + oe_host_worker_wake(&manager->host_worker_contexts[i]); + + OE_TRACE_INFO( + "Switchless host worker thread %d spun for %lu times", + (int)i, + manager->host_worker_contexts[i].total_spin_count); + } + + for (size_t i = 0; i < manager->num_host_workers; i++) + { + if (manager->host_worker_threads[i] != (oe_thread_t)NULL) + if (oe_thread_join(manager->host_worker_threads[i])) + OE_RAISE(OE_THREAD_JOIN_ERROR); + } + + result = OE_OK; +done: + return result; +} + +oe_result_t oe_start_switchless_manager( + oe_enclave_t* enclave, + size_t num_host_workers) +{ + oe_result_t result = OE_UNEXPECTED; + uint64_t result_out = 0; + oe_switchless_call_manager_t* manager = NULL; + oe_host_worker_context_t* contexts = NULL; + oe_thread_t* threads = NULL; + + if (num_host_workers < 1 || enclave == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + if (enclave->switchless_manager != NULL) + OE_RAISE(OE_UNEXPECTED); + + // Limit the number of host workers to the number of thread bindings + // because the maximum parallelism is dictated by the latter for + // synchronous ocalls. We may need to revisit this for asynchronous + // calls later. + if (num_host_workers > enclave->num_bindings) + num_host_workers = (uint32_t)enclave->num_bindings; + + // Allocate memory for the manager and its arrays + manager = calloc(1, sizeof(oe_switchless_call_manager_t)); + if (manager == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + contexts = calloc(num_host_workers, sizeof(oe_host_worker_context_t)); + if (contexts == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + threads = calloc(num_host_workers, sizeof(oe_thread_t)); + if (threads == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + + manager->num_host_workers = num_host_workers; + manager->host_worker_contexts = contexts; + manager->host_worker_threads = threads; + + // Start the worker threads, and assign each one a private context. + for (size_t i = 0; i < num_host_workers; i++) + { + OE_TRACE_INFO("Creating switchless host worker thread %d\n", (int)i); + manager->host_worker_contexts[i].enclave = enclave; + if (oe_thread_create( + &manager->host_worker_threads[i], + _switchless_ocall_worker, + &manager->host_worker_contexts[i]) != 0) + { + oe_stop_worker_threads(manager); + OE_RAISE(OE_THREAD_CREATE_ERROR); + } + } + + // Each enclave has at most one switchless manager. + enclave->switchless_manager = manager; + + // Inform the enclave about the switchless manager through an ECALL + OE_CHECK(oe_ecall( + enclave, + OE_ECALL_INIT_CONTEXT_SWITCHLESS, + (uint64_t)manager, + &result_out)); + OE_CHECK((oe_result_t)result_out); + + result = OE_OK; + +done: + if (result != OE_OK) + { + if (manager) + { + free(manager); + enclave->switchless_manager = NULL; + } + + if (contexts) + free(contexts); + + if (threads) + free(threads); + } + + return result; +} + +oe_result_t oe_stop_switchless_manager(oe_enclave_t* enclave) +{ + oe_result_t result = OE_UNEXPECTED; + if (enclave != NULL && enclave->switchless_manager != NULL) + { + OE_CHECK(oe_stop_worker_threads(enclave->switchless_manager)); + } + result = OE_OK; +done: + return result; +} + +void oe_handle_wake_host_worker(uint64_t arg) +{ + oe_host_worker_context_t* context = (oe_host_worker_context_t*)arg; + oe_host_worker_wake(context); +} diff --git a/host/sgx/windows/aep.asm b/host/sgx/windows/aep.asm index b26cf028ca..79e05d8504 100644 --- a/host/sgx/windows/aep.asm +++ b/host/sgx/windows/aep.asm @@ -1,4 +1,4 @@ -;; Copyright (c) Microsoft Corporation. All rights reserved. +;; Copyright (c) Open Enclave SDK contributors. ;; Licensed under the MIT License. include ksamd64.inc diff --git a/host/sgx/windows/aesm.c b/host/sgx/windows/aesm.c deleted file mode 100644 index 3daff07708..0000000000 --- a/host/sgx/windows/aesm.c +++ /dev/null @@ -1,414 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include -#include -#include -#include - -static const uint32_t AESM_MAGIC = 0x4efaa2a3; - -typedef UINT32 aesm_error_t; - -typedef struct _aesm_interface aesm_interface_t; - -/* Copied from MSR-SDK. This is the COM interface for calling into Intel's - * AESM interface. This will eventually be replaced by a different interface - * that Intel will be providing. - */ -typedef struct aesm_interface_vtbl -{ - BEGIN_INTERFACE - - HRESULT(STDMETHODCALLTYPE* query_interface) - (aesm_interface_t* this, - /* [in] */ REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void** object); - - ULONG(STDMETHODCALLTYPE* add_ref)(aesm_interface_t* this); - - ULONG(STDMETHODCALLTYPE* release)(aesm_interface_t* this); - - HRESULT(STDMETHODCALLTYPE* get_license_token) - (aesm_interface_t* this, - /* [size_is][ref][in] */ uint8_t* mrenclave, - uint32_t mrenclave_size, - /* [size_is][ref][in] */ uint8_t* public_key, - uint32_t public_key_size, - /* [size_is][ref][in] */ uint8_t* se_attributes, - uint32_t se_attributes_size, - /* [size_is][ref][out] */ uint8_t* lictoken, - uint32_t lictoken_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* init_quote) - (aesm_interface_t* this, - /* [size_is][out] */ uint8_t* target_info, - uint32_t target_info_size, - /* [size_is][ref][out] */ uint8_t* gid, - uint32_t gid_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_quote) - (aesm_interface_t* this, - /* [size_is][ref][in] */ uint8_t* report, - uint32_t report_size, - uint32_t type, - /* [size_is][ref][in] */ uint8_t* spid, - uint32_t spid_size, - /* [size_is][unique][in] */ uint8_t* nonce, - uint32_t nonce_size, - /* [size_is][unique][in] */ uint8_t* sig_rl, - uint32_t sig_rl_size, - /* [size_is][unique][out][in] */ uint8_t* qe_report, - uint32_t qe_report_size, - /* [size_is][ref][out][in] */ uint8_t* quote, - /* [in] */ uint32_t buf_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* create_session) - (aesm_interface_t* this, - /* [ref][out] */ uint32_t* session_id, - /* [size_is][ref][out] */ uint8_t* se_dh_msg1, - uint32_t se_dh_msg1_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* exchange_report) - (aesm_interface_t* this, - uint32_t session_id, - /* [size_is][ref][in] */ uint8_t* se_dh_msg2, - uint32_t se_dh_msg2_size, - /* [size_is][ref][out] */ uint8_t* se_dh_msg3, - uint32_t se_dh_msg3_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* close_session) - (aesm_interface_t* this, - uint32_t session_id, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* invoke_service) - (aesm_interface_t* this, - /* [size_is][ref][in] */ uint8_t* pse_message_req, - uint32_t pse_message_req_size, - /* [size_is][ref][out] */ uint8_t* pse_message_resp, - uint32_t pse_message_resp_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* report_attestation_status) - (aesm_interface_t* this, - /* [size_is][ref][in] */ uint8_t* platform_info, - uint32_t platform_info_size, - uint32_t attestation_status, - /* [size_is][ref][out] */ uint8_t* update_info, - uint32_t update_info_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_ps_cap) - (aesm_interface_t* this, - /* [out] */ uint64_t* ps_cap, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* sgx_register) - (aesm_interface_t* this, - /* [size_is][ref][in] */ uint8_t* white_list_cert, - uint32_t white_list_cert_size, - uint32_t registration_data_type, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* proxy_setting_assist) - (aesm_interface_t* this, - /* [size_is][unique][in] */ uint8_t* proxy_info, - uint32_t proxy_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* query_sgx_status) - (aesm_interface_t* this, - /* [ref][out] */ uint32_t* sgx_status, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_whitelist_size) - (aesm_interface_t* this, - /* [ref][out] */ uint32_t* white_list_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_white_list) - (aesm_interface_t* this, - /* [size_is][ref][out] */ uint8_t* white_list, - uint32_t buf_size, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_sec_domain_id) - (aesm_interface_t* this, - /* [ref][out] */ uint32_t* sec_domain_id, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* switch_sec_domain) - (aesm_interface_t* this, - uint32_t sec_domain_id, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_epid_provision_status) - (aesm_interface_t* this, - /* [ref][out] */ uint32_t* epid_pr_status, - /* [ref][out] */ aesm_error_t* result); - - HRESULT(STDMETHODCALLTYPE* get_platform_service_status) - (aesm_interface_t* this, - /* [ref][out] */ uint32_t* pse_status, - /* [ref][out] */ aesm_error_t* result); - - END_INTERFACE -} aesm_interface_vtbl; - -struct _aesm_interface -{ - CONST_VTBL struct aesm_interface_vtbl* vtbl; -}; - -static aesm_interface_t* _create_instance() -{ - aesm_interface_t* instance = NULL; - static const CLSID CLSID_AESMInterface = { - 0x82367CAB, - 0xF2B9, - 0x461A, - {0xB6, 0xC6, 0x88, 0x9D, 0x13, 0xEF, 0xC6, 0xCA}}; - static const IID IID_IAESMInterface = { - 0x50AFD900, - 0xF309, - 0x4557, - {0x8F, 0xCB, 0x10, 0xCF, 0xAB, 0x80, 0x2C, 0xDD}}; - - /* Initialize COM library */ - { - HRESULT hr = CoInitializeEx( - NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); - - /* If COM initialization failed */ - if (hr != S_OK && hr != S_FALSE) - goto done; - } - - /* Create AESM interface object */ - if (!SUCCEEDED(CoCreateInstance( - &CLSID_AESMInterface, - NULL, - CLSCTX_ALL, - &IID_IAESMInterface, - &instance))) - { - CoUninitialize(); - goto done; - } - -done: - - return instance; -} - -static void _release_instance(aesm_interface_t* instance) -{ - instance->vtbl->release(instance); - CoUninitialize(); -} - -struct _aesm -{ - uint32_t magic; -}; - -static int _aesm_valid(const aesm_t* aesm) -{ - return aesm != NULL && aesm->magic == AESM_MAGIC; -} - -aesm_t* aesm_connect() -{ - aesm_t* aesm = NULL; - aesm_interface_t* instance = NULL; - - /* Obtain AESM COM object (as a test only) */ - if (!(instance = _create_instance())) - goto done; - - /* Allocate and initialize AESM struct */ - { - if (!(aesm = (aesm_t*)calloc(1, sizeof(aesm_t)))) - goto done; - - aesm->magic = AESM_MAGIC; - } - -done: - - if (instance) - _release_instance(instance); - - return aesm; -} - -void aesm_disconnect(aesm_t* aesm) -{ - if (_aesm_valid(aesm)) - { - aesm->magic = 0xDDDDDDDD; - free(aesm); - } -} - -oe_result_t aesm_get_launch_token( - aesm_t* aesm, - uint8_t mrenclave[OE_SHA256_SIZE], - uint8_t modulus[OE_KEY_SIZE], - const sgx_attributes_t* attributes, - sgx_launch_token_t* launch_token) -{ - oe_result_t result = OE_UNEXPECTED; - aesm_error_t error; - aesm_interface_t* instance = NULL; - - if (!_aesm_valid(aesm)) - goto done; - - /* Obtain AESM COM instance */ - if (!(instance = _create_instance())) - goto done; - - /* Obtain a launch token */ - HRESULT hr = instance->vtbl->get_license_token( - instance, /* this */ - mrenclave, /* mrenclave */ - OE_SHA256_SIZE, /* mrenclave_size */ - modulus, /* public_key */ - OE_KEY_SIZE, /* public_key_size */ - (PUINT8)attributes, /* se_attributes */ - sizeof(sgx_attributes_t), /* se_attributes_size */ - (PUINT8)launch_token, /* lictoken */ - /* MSR-SDK passes sizeof(sgx_einittoken_t) */ - sizeof(sgx_einittoken_t), /* lictoken_size */ - &error); /* result */ - - if (!SUCCEEDED(hr) || error != 0) - { - result = OE_FAILURE; - goto done; - } - - result = OE_OK; - -done: - - if (instance) - _release_instance(instance); - - return result; -} - -oe_result_t aesm_init_quote( - aesm_t* aesm, - sgx_target_info_t* target_info, - sgx_epid_group_id_t* epid_group_id) -{ - oe_result_t result = OE_UNEXPECTED; - aesm_error_t error; - aesm_interface_t* instance = NULL; - - if (!_aesm_valid(aesm)) - goto done; - - /* Obtain AESM COM instance */ - if (!(instance = _create_instance())) - goto done; - - // Get quote for a given report. - HRESULT hr = instance->vtbl->init_quote( - instance, - (uint8_t*)target_info, - sizeof(sgx_target_info_t), - (uint8_t*)epid_group_id, - sizeof(sgx_epid_group_id_t), - &error); - - if (!SUCCEEDED(hr) || error != 0) - { - result = OE_FAILURE; - goto done; - } - - result = OE_OK; - -done: - - if (instance) - _release_instance(instance); - - return result; -} - -oe_result_t aesm_get_quote( - aesm_t* aesm, - const sgx_report_t* report, - sgx_quote_type_t quote_type, - const sgx_spid_t* spid, - const sgx_nonce_t* nonce, - const uint8_t* signature_revocation_list, - uint32_t signature_revocation_list_size, - sgx_report_t* report_out, /* ATTN: support this! */ - sgx_quote_t* quote, - size_t quote_size) -{ - oe_result_t result = OE_UNEXPECTED; - aesm_error_t error; - aesm_interface_t* instance = NULL; - - if (quote_size > UINT_MAX) - { - result = OE_INVALID_PARAMETER; - goto done; - } - - if (!_aesm_valid(aesm)) - { - result = OE_INVALID_PARAMETER; - goto done; - } - - /* Obtain AESM COM instance */ - if (!(instance = _create_instance())) - goto done; - - // Get quote for a given report. - HRESULT hr = instance->vtbl->get_quote( - instance, /* this */ - (uint8_t*)report, /* report */ - sizeof(sgx_report_t), /* report_size */ - (uint32_t)quote_type, /* type */ - (uint8_t*)spid, /* spid */ - sizeof(sgx_spid_t), /* spid_size */ - (uint8_t*)nonce, /* nonce */ - sizeof(sgx_nonce_t), /* nonce_size */ - (uint8_t*)signature_revocation_list, /* sig_rl */ - signature_revocation_list_size, /* sigrl_size */ - (uint8_t*)report_out, /* qe_report */ - sizeof(sgx_report_t), /* qe_report_size */ - (uint8_t*)quote, /* quote */ - (uint32_t)quote_size, /* buffer_size */ - &error); - - if (!SUCCEEDED(hr) || error != 0) - { - result = OE_FAILURE; - goto done; - } - - result = OE_OK; - -done: - - if (instance) - _release_instance(instance); - - return result; -} diff --git a/host/sgx/windows/debugrtbridge.c b/host/sgx/windows/debugrtbridge.c index 5be82e846f..33332a2d28 100644 --- a/host/sgx/windows/debugrtbridge.c +++ b/host/sgx/windows/debugrtbridge.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -36,29 +36,14 @@ static void load_oedebugrt(void) return; } -#ifndef NDEBUG - /** - * In debug mode, give preference to OE_DEBUGRT_PATH. - * This is mainly used for OE SDK development. - */ - { - char* debugrtpath = getenv("OE_DEBUGRT_PATH"); - _oedebugrt.hmodule = LoadLibraryExA( - debugrtpath, - NULL, /* reserved */ - /* Search only specified path. */ - LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); - } - -#endif - - /* Search for oedebugrt.dll only in the application folder. */ + /* Search for oedebugrt.dll first in the application folder and then the + * system32 folder.*/ if (_oedebugrt.hmodule == NULL) { _oedebugrt.hmodule = LoadLibraryExA( "oedebugrt.dll", NULL, /* reserved */ - LOAD_LIBRARY_SEARCH_APPLICATION_DIR); + LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); } if (_oedebugrt.hmodule != NULL) diff --git a/host/sgx/windows/enter.asm b/host/sgx/windows/enter.asm deleted file mode 100644 index dff0dc25e4..0000000000 --- a/host/sgx/windows/enter.asm +++ /dev/null @@ -1,182 +0,0 @@ -;; Copyright (c) Microsoft Corporation. All rights reserved. -;; Licensed under the MIT License. - -include ksamd64.inc - -extern __oe_dispatch_ocall:proc - -;;============================================================================== -;; -;; void oe_enter( -;; [IN] void* tcs, -;; [IN] uint64_t aep, -;; [IN] uint64_t arg1, -;; [IN] uint64_t arg2, -;; [OUT] uint64_t* arg3, -;; [OUT] uint64_t* arg4, -;; [OUT] oe_enclave_t* enclave); -;; -;; Registers: -;; RCX - tcs: thread control structure (extended) -;; RDX - aep: asynchronous execution procedure -;; R8 - arg1 -;; R9 - arg2 -;; [RBP+48] - arg3 -;; [RBP+56] - arg4 -;; -;; These registers may be destroyed across function calls: -;; RAX, RCX, RDX, R8, R9, R10, R11 -;; -;; These registers must be preserved across function calls: -;; RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 -;; -;;============================================================================== - -ENCLU_EENTER EQU 2 -PARAMS_SPACE EQU 128 -TCS EQU [rbp-8] -AEP EQU [rbp-16] -ARG1 EQU [rbp-24] -ARG2 EQU [rbp-32] -ARG3 EQU [rbp-40] -ARG4 EQU [rbp-48] -ENCLAVE EQU [rbp-56] -ARG1OUT EQU [rbp-64] -ARG2OUT EQU [rbp-72] -STACKPTR EQU [rbp-80] -MXCSR EQU [rbp-88] - -NESTED_ENTRY oe_enter, _TEXT$00 - END_PROLOGUE - - ;; Setup stack frame: - push rbp - mov rbp, rsp - - ;; Save parameters on stack for later reference: - ;; TCS := [RBP-8] <- RCX - ;; AEP := [RBP-16] <- RDX - ;; ARG1 := [RBP-24] <- R8 - ;; ARG2 := [RBP-32] <- R9 - ;; ARG3 := [RBP-40] <- [RBP+48] - ;; ARG4 := [RBP-48] <- [RBP+56] - ;; ENCLAVE := [RBP-56] <- [RBP+64] - ;; MXCSR := [RBP-88] - sub rsp, PARAMS_SPACE - mov TCS, rcx - mov AEP, rdx - mov ARG1, r8 - mov ARG2, r9 - mov rax, [rbp+48] - mov ARG3, rax - mov rax, [rbp+56] - mov ARG4, rax - mov rax, [rbp+64] - mov ENCLAVE, rax - - ;;Save the current context - - ;;Save the SSE status and control flags - stmxcsr MXCSR - - ;; Save registers: - push rbx - push rdi - push rsi - push r12 - push r13 - push r14 - push r15 - -execute_eenter: - - ;; Save the stack pointer so enclave can use the stack. - mov STACKPTR, rsp - - ;; EENTER(RBX=TCS, RCX=AEP, RDI=ARG1, RSI=ARG2) - mov rbx, TCS - mov rcx, AEP - mov rdi, ARG1 - mov rsi, ARG2 - mov rax, ENCLU_EENTER - ENCLU - - mov ARG1OUT, rdi - mov ARG2OUT, rsi - - ;; Restore the saved MXCSR - ldmxcsr MXCSR - -dispatch_ocall: - ;; RAX = __oe_dispatch_ocall( - ;; RCX=arg1 - ;; RDX=arg2 - ;; R8=arg1_out - ;; R9=arg2_out - ;; [RSP+32]=TCS, - ;; [RSP+40]=ENCLAVE); - sub rsp, 56 - mov rcx, ARG1OUT - mov rdx, ARG2OUT - lea r8, qword ptr ARG1OUT - lea r9, qword ptr ARG2OUT - mov rax, qword ptr TCS - mov qword ptr [rsp+32], rax - mov rax, qword ptr ENCLAVE - mov qword ptr [rsp+40], rax - call __oe_dispatch_ocall ;; RAX contains return value - add rsp, 56 - - ;; Restore the stack pointer: - mov rsp, STACKPTR - - ;; If this was not an OCALL, then return from ECALL. - cmp rax, 0 - jne return_from_ecall - - ;; Stop speculative execution at fallthrough of conditional check - lfence - - ;; Prepare to reenter the enclave, calling the entry point. - mov rax, ARG1OUT - mov ARG1, rax - mov rax, ARG2OUT - mov ARG2, rax - jmp execute_eenter - -return_from_ecall: - ;; Stop speculative execution at target of conditional jump - lfence - - ;; Set ARG3 (out) - mov rbx, ARG1OUT - mov rax, qword ptr [rbp+48] - mov qword ptr [rax], rbx - - ;; Set ARG4 (out) - mov rbx, ARG2OUT - mov rax, qword ptr [rbp+56] - mov qword ptr [rax], rbx - - ;; Restore registers: - pop r15 - pop r14 - pop r13 - pop r12 - pop rsi - pop rdi - pop rbx - - - ;; Return parameters space: - add rsp, PARAMS_SPACE - - ;; Restore stack frame: - pop rbp - - BEGIN_EPILOGUE - ret - -NESTED_END oe_enter, _TEXT$00 - -END diff --git a/host/sgx/windows/entersim.asm b/host/sgx/windows/entersim.asm deleted file mode 100644 index 4e1514be37..0000000000 --- a/host/sgx/windows/entersim.asm +++ /dev/null @@ -1,181 +0,0 @@ -;; Copyright (c) Microsoft Corporation. All rights reserved. -;; Licensed under the MIT License. - -include ksamd64.inc - -extern __oe_dispatch_ocall:proc - -;;============================================================================== -;; -;; void oe_enter_sim( -;; [IN] void* tcs, -;; [IN] uint64_t aep, -;; [IN] uint64_t arg1, -;; [IN] uint64_t arg2, -;; [OUT] uint64_t* arg3, -;; [OUT] uint64_t* arg4, -;; [OUT] oe_enclave_t* enclave); -;; -;; Registers: -;; RCX - tcs: thread control structure (extended) -;; RDX - aep: asynchronous execution procedure -;; R8 - arg1 -;; R9 - arg2 -;; [RBP+48] - arg3 -;; [RBP+56] - arg4 -;; -;; These registers may be destroyed across function calls: -;; RAX, RCX, RDX, R8, R9, R10, R11 -;; -;; These registers must be preserved across function calls: -;; RBX, RBP, RDI, RSI, RSP, R12, R13, R14, and R15 -;; -;;============================================================================== - -PARAMS_SPACE EQU 128 -TCS EQU [rbp-8] -AEP EQU [rbp-16] -ARG1 EQU [rbp-24] -ARG2 EQU [rbp-32] -ARG3 EQU [rbp-40] -ARG4 EQU [rbp-48] -ENCLAVE EQU [rbp-56] -ARG1OUT EQU [rbp-64] -ARG2OUT EQU [rbp-72] -CSSA EQU [rbp-80] -STACKPTR EQU [rbp-88] -TCS_u_main EQU 72 - -NESTED_ENTRY oe_enter_sim, _TEXT$00 - END_PROLOGUE - - ;; Setup stack frame: - push rbp - mov rbp, rsp - - ;; Save parameters on stack for later reference: - ;; TCS := [RBP-8] <- RCX - ;; AEP := [RBP-16] <- RDX - ;; ARG1 := [RBP-24] <- R8 - ;; ARG2 := [RBP-32] <- R9 - ;; ARG3 := [RBP-40] <- [RBP+48] - ;; ARG4 := [RBP-48] <- [RBP+56] - ;; ENCLAVE := [RBP-56] <- [RBP+64] - ;; - sub rsp, PARAMS_SPACE - mov TCS, rcx - mov AEP, rdx - mov ARG1, r8 - mov ARG2, r9 - mov rax, [rbp+48] - mov ARG3, rax - mov rax, [rbp+56] - mov ARG4, rax - mov rax, [rbp+64] - mov ENCLAVE, rax - - ;; Load CSSA with zero initially: - mov rax, 0 - mov CSSA, rax - - ;; Save registers: - push rbx - push rdi - push rsi - push r12 - push r13 - push r14 - push r15 - -call_start: - - ;; Save the stack pointer so enclave can use the stack. - mov STACKPTR, rsp - - ;; Call start(RAX=CSSA, RBX=TCS, RCX=RETADDR, RDI=ARG1, RSI=ARG2) in enclave - mov rax, CSSA - mov rbx, TCS - lea rcx, retaddr - mov rdi, ARG1 - mov rsi, ARG2 - jmp qword ptr [rbx+TCS_u_main] -retaddr: - mov ARG1OUT, rdi - mov ARG2OUT, rsi - -dispatch_ocall_sim: - - ;; RAX = __oe_dispatch_ocall( - ;; RCX=arg1 - ;; RDX=arg2 - ;; R8=arg1_out - ;; R9=arg2_out - ;; [RSP+32]=TCS, - ;; [RSP+40]=ENCLAVE); - sub rsp, 56 - mov rcx, ARG1OUT - mov rdx, ARG2OUT - lea r8, qword ptr ARG1OUT - lea r9, qword ptr ARG2OUT - mov rax, qword ptr TCS - mov qword ptr [rsp+32], rax - mov rax, qword ptr ENCLAVE - mov qword ptr [rsp+40], rax - call __oe_dispatch_ocall ;; RAX contains return value - add rsp, 56 - - ;; Restore the stack pointer: - mov rsp, STACKPTR - - ;; If this was not an OCALL, then return from ECALL. - cmp rax, 0 - jne return_from_ecall_sim - - ;; Stop speculative execution at fallthrough of conditional check - lfence - - ;; Prepare to reenter the enclave, calling start() - mov rax, ARG1OUT - mov ARG1, rax - mov rax, ARG2OUT - mov ARG2, rax - jmp call_start - -return_from_ecall_sim: - ;; Stop speculative execution at target of conditional jump - lfence - - ;; Set ARG3 (out) - mov rbx, ARG1OUT - mov rax, qword ptr [rbp+48] - mov qword ptr [rax], rbx - - ;; Set ARG4 (out) - mov rbx, ARG2OUT - mov rax, qword ptr [rbp+56] - mov qword ptr [rax], rbx - - ;; Restore registers: - pop r15 - pop r14 - pop r13 - pop r12 - pop rsi - pop rdi - pop rbx - - ;; Return parameters space: - add rsp, PARAMS_SPACE - - ;; Restore stack frame: - pop rbp - - BEGIN_EPILOGUE - ret - -forever: - jmp forever - -NESTED_END oe_enter_sim, _TEXT$00 - -END diff --git a/host/sgx/windows/exception.c b/host/sgx/windows/exception.c index 71e7634175..1ad77cdf4f 100644 --- a/host/sgx/windows/exception.c +++ b/host/sgx/windows/exception.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../exception.h" diff --git a/host/sgx/windows/sgxquoteproviderloader.c b/host/sgx/windows/sgxquoteproviderloader.c index 3b18a04623..4bc1077a88 100644 --- a/host/sgx/windows/sgxquoteproviderloader.c +++ b/host/sgx/windows/sgxquoteproviderloader.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -8,7 +8,7 @@ oe_sgx_quote_provider_t provider = {0}; -static void _unload_quote_provider() +static void _unload_quote_provider(void) { OE_TRACE_INFO("_unload_quote_provider dcap_quoteprov.dll\n"); if (provider.handle) diff --git a/host/sgx/windows/switchless.c b/host/sgx/windows/switchless.c new file mode 100644 index 0000000000..62ac768bb4 --- /dev/null +++ b/host/sgx/windows/switchless.c @@ -0,0 +1,30 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include + +void oe_host_worker_wait(oe_host_worker_context_t* context) +{ + // If event is 1, it means that there a pending wake notification from + // enclave. Consume it by setting event to 0. Don't wait. + // + // If event is 0, then wait until event is 1. + int32_t oldval = 1; + int32_t newval = 0; + + if (_InterlockedCompareExchange((long*)&context->event, newval, oldval) == + 0) + { + // If the previous value was zero, then wait while value is zero. + uint32_t zero = 0; + WaitOnAddress(&context->event, &zero, sizeof(context->event), INFINITE); + } +} + +void oe_host_worker_wake(oe_host_worker_context_t* context) +{ + // Set the event and wake up the worker. + context->event = 1; + WakeByAddressSingle((void*)&context->event); +} diff --git a/host/sgx/windows/xstate.c b/host/sgx/windows/xstate.c index 5eca0d3d30..14e7640dcd 100644 --- a/host/sgx/windows/xstate.c +++ b/host/sgx/windows/xstate.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../xstate.h" diff --git a/host/sgx/xstate.h b/host/sgx/xstate.h index 7585736efc..4c73f221e6 100644 --- a/host/sgx/xstate.h +++ b/host/sgx/xstate.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_XSTATE_H diff --git a/host/signkey.c b/host/signkey.c index 696a3e9f8e..172055aae9 100644 --- a/host/signkey.c +++ b/host/signkey.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "signkey.h" diff --git a/host/signkey.h b/host/signkey.h index dbaf5feba9..a022120779 100644 --- a/host/signkey.h +++ b/host/signkey.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_SIGNKEY_H diff --git a/host/strings.c b/host/strings.c index f4d2ee61a8..dde3cb1b13 100644 --- a/host/strings.c +++ b/host/strings.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "strings.h" diff --git a/host/strings.h b/host/strings.h index fb7f6609f8..ce66e47b3c 100644 --- a/host/strings.h +++ b/host/strings.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HOST_STRINGS_H diff --git a/host/syscall_u_wrapper.c b/host/syscall_u_wrapper.c index e04bc51fe1..d7e5fae6f9 100644 --- a/host/syscall_u_wrapper.c +++ b/host/syscall_u_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/tee_u_wrapper.c b/host/tee_u_wrapper.c index 6832ed0387..7691583a9f 100644 --- a/host/tee_u_wrapper.c +++ b/host/tee_u_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/tests.c b/host/tests.c index 4337df7699..8bcdacd5a2 100644 --- a/host/tests.c +++ b/host/tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -9,7 +9,13 @@ uint32_t oe_get_create_flags(void) { +#if __aarch64__ + /* OE_ENCLAVE_FLAG_DEBUG is not available on ARM TrustZone. */ + uint32_t result = 0; +#else uint32_t result = OE_ENCLAVE_FLAG_DEBUG; +#endif + char* env = NULL; if (!(env = oe_dupenv("OE_SIMULATION"))) diff --git a/host/traceh.c b/host/traceh.c index e0114eb28d..f398d4b342 100644 --- a/host/traceh.c +++ b/host/traceh.c @@ -1,6 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#include +#include #include #include #include @@ -12,13 +14,24 @@ #include #endif #include +#include "dupenv.h" +#include "fopen.h" #include "hostthread.h" -#define LOGGING_FORMAT_STRING "%02d:%02d:%02d:%06ld tid(0x%lx) (%s)[%s]%s" +#define LOGGING_FORMAT_STRING "%s.%06ldZ [(%s)%s] tid(0x%llx) | %s" + static char* _log_level_strings[OE_LOG_LEVEL_MAX] = {"NONE", "FATAL", "ERROR", "WARN", "INFO", "VERBOSE"}; static oe_mutex _log_lock = OE_H_MUTEX_INITIALIZER; -static const char* _log_file_name = NULL; +static char _log_file_name[OE_PATH_MAX]; +static char _custom_log_format[OE_PATH_MAX]; +static bool _use_log_file = false; +static bool _use_custom_log_format = false; +static bool _log_all_streams = false; +static bool _log_escape = false; +static const size_t MAX_ESCAPED_CHAR_LEN = 5; // e.g. u2605 +static const size_t MAX_ESCAPED_MSG_MULTIPLIER = + 7; // MAX_ESCAPED_CHAR_LEN + sizeof("\\\\") static bool _log_creation_failed_before = false; oe_log_level_t _log_level = OE_LOG_LEVEL_ERROR; static bool _initialized = false; @@ -26,7 +39,7 @@ static bool _initialized = false; static oe_log_level_t _env2log_level(void) { oe_log_level_t level = OE_LOG_LEVEL_ERROR; - const char* level_str = getenv("OE_LOG_LEVEL"); + char* level_str = oe_dupenv("OE_LOG_LEVEL"); if (level_str == NULL) { @@ -57,98 +70,200 @@ static oe_log_level_t _env2log_level(void) level = OE_LOG_LEVEL_NONE; } done: + if (level_str) + free(level_str); + return level; } void initialize_log_config() { + oe_result_t ret; + char* env_log_file = NULL; + char* env_log_format = NULL; + char* env_log_all_streams = NULL; + char* env_log_escape = NULL; + if (!_initialized) { // inititalize if not already _log_level = _env2log_level(); - _log_file_name = getenv("OE_LOG_DEVICE"); + env_log_file = oe_dupenv("OE_LOG_DEVICE"); + env_log_format = oe_dupenv("OE_LOG_FORMAT"); + env_log_all_streams = oe_dupenv("OE_LOG_ALL_STREAMS"); + env_log_escape = oe_dupenv("OE_LOG_JSON_ESCAPE"); + + if (env_log_format) + { + // check that custom log format string terminates with a line return + size_t len = strlen(env_log_format); + if (env_log_format[len - 1] != '\n') + { + fprintf( + stderr, + "%s\n", + "[ERROR] Custom log format does not end with a newline"); + goto done; + } + } _initialized = true; } + +done: + ret = OE_OK; + + if (env_log_file) + { + ret = oe_strncpy_s( + _log_file_name, OE_PATH_MAX, env_log_file, strlen(env_log_file)); + _use_log_file = true; + + free(env_log_file); + } + + if (env_log_format) + { + ret = oe_strncpy_s( + _custom_log_format, + OE_PATH_MAX, + env_log_format, + strlen(env_log_format)); + _use_custom_log_format = true; + free(env_log_format); + } + + if (env_log_all_streams) + { + _log_all_streams = true; + free(env_log_all_streams); + } + + if (env_log_escape) + { + _log_escape = true; + free(env_log_escape); + } + + if (!_initialized || ret != OE_OK) + { + fprintf(stderr, "%s\n", "[ERROR] Could not initialize logging."); + exit(1); + } } -static void _write_header_info_to_stream(FILE* stream) +static bool _escape_characters( + const char* log_msg, + char* log_msg_escaped, + size_t msg_size, + size_t max_msg_size) { - time_t t = time(NULL); - struct tm* lt = localtime(&t); - - fprintf( - stream, "================= New logging session =================\n"); - fprintf(stream, "%s", asctime(lt)); - fprintf( - stream, - "https://github.com/openenclave/openenclave branch:%s\n", - OE_REPO_BRANCH_NAME); - fprintf(stream, "Last commit:%s\n\n", OE_REPO_LAST_COMMIT); + size_t idx = 0; + for (size_t i = 0; i < msg_size; i++) + { + uint8_t c = (uint8_t)log_msg[i]; + if (log_msg[i] == '\"') + { + // single quotes are OK for JSON + log_msg_escaped[idx] = '\''; + } + else if (log_msg[i] == '\\') + { + log_msg_escaped[idx] = '\\'; + idx++; + log_msg_escaped[idx] = '\\'; + } + else if (c <= 31 || c > 126 /* non printable ASCII values */) + { + log_msg_escaped[idx] = '\\'; + idx++; + log_msg_escaped[idx] = '\\'; + idx++; + switch (log_msg[i]) + { + case '\b': + log_msg_escaped[idx] = 'b'; + break; + case '\f': + log_msg_escaped[idx] = 'f'; + break; + case '\n': + log_msg_escaped[idx] = 'n'; + break; + case '\r': + log_msg_escaped[idx] = 'r'; + break; + case '\t': + log_msg_escaped[idx] = 't'; + break; + default: + if (c > 126 /* max ASCII value that we can escape*/) + { + log_msg_escaped[idx] = '\0'; + return false; + } + sprintf( + (char*)&log_msg_escaped[idx], "u%04hhx", log_msg[i]); + // idx is also incremented after switch case + idx += MAX_ESCAPED_CHAR_LEN - 1; + break; + } + } + else + { + log_msg_escaped[idx] = log_msg[i]; + } + idx++; + } + if (idx < max_msg_size) + { + log_msg_escaped[idx] = '\0'; + } + return true; } static void _write_message_to_stream( FILE* stream, bool is_enclave, + const char* time, + long int usecs, oe_log_level_t level, const char* message) { -#if defined(__linux__) - struct timeval time_now; - gettimeofday(&time_now, NULL); - struct tm* t = gmtime(&time_now.tv_sec); -#else - time_t lt = time(NULL); - struct tm* t = localtime(<); -#endif - - oe_thread thread_id = oe_thread_self(); - fprintf( stream, LOGGING_FORMAT_STRING, - t->tm_hour, - t->tm_min, - t->tm_sec, -#if defined(__linux__) - time_now.tv_usec, -#else - 0, -#endif - thread_id, + time, + usecs, (is_enclave ? "E" : "H"), _log_level_strings[level], + (long long unsigned int)oe_thread_self(), message); } -static void _log_session_header() +static void _write_custom_format_message_to_stream( + FILE* stream, + bool is_enclave, + const char* time, + long int usecs, + oe_log_level_t level, + const char* message, + const char* file, + const char* function, + const char* number, + const char* log_format) { - if (!_log_file_name) - { - return; - } - - // Take the log file lock. - if (!_log_creation_failed_before) - { - if (oe_mutex_lock(&_log_lock) == OE_OK) - { - FILE* log_file = NULL; - log_file = fopen(_log_file_name, "a"); - if (log_file == NULL) - { - fprintf( - stderr, "Failed to create logfile %s\n", _log_file_name); - oe_mutex_unlock(&_log_lock); - _log_creation_failed_before = true; - return; - } - - _write_header_info_to_stream(log_file); - fflush(log_file); - fclose(log_file); - oe_mutex_unlock(&_log_lock); - } - } + fprintf( + stream, + log_format, + time, + usecs, + (is_enclave ? "E" : "H"), + _log_level_strings[level], + oe_thread_self(), + message, + file, + function, + number); } oe_result_t oe_log(oe_log_level_t level, const char* fmt, ...) @@ -194,10 +309,27 @@ oe_result_t oe_log(oe_log_level_t level, const char* fmt, ...) // and file operation. void oe_log_message(bool is_enclave, oe_log_level_t level, const char* message) { + // get timestamp for log +#if defined(__linux__) + struct timeval time_now; + gettimeofday(&time_now, NULL); + struct tm* t = gmtime(&time_now.tv_sec); +#else + time_t lt = time(NULL); + struct tm* t = gmtime(<); +#endif + + char time[20]; + strftime(time, sizeof(time), "%Y-%m-%dT%H:%M:%S", t); + +#if defined(__linux__) + long int usecs = time_now.tv_usec; +#else + long int usecs = 0; +#endif if (!_initialized) { initialize_log_config(); - _log_session_header(); } if (_initialized) { @@ -208,14 +340,23 @@ void oe_log_message(bool is_enclave, oe_log_level_t level, const char* message) // Take the log file lock. if (oe_mutex_lock(&_log_lock) == OE_OK) { - if (!_log_file_name) + if (_log_all_streams || !_use_log_file) + { + _write_message_to_stream( + stdout, is_enclave, time, usecs, level, message); + } + + if (!_use_log_file) { - _write_message_to_stream(stdout, is_enclave, level, message); + // Release the log file lock. + oe_mutex_unlock(&_log_lock); + return; } - else if (!_log_creation_failed_before) + + if (!_log_creation_failed_before) { FILE* log_file = NULL; - log_file = fopen(_log_file_name, "a"); + oe_fopen(&log_file, _log_file_name, "a"); if (log_file == NULL) { fprintf( @@ -224,7 +365,79 @@ void oe_log_message(bool is_enclave, oe_log_level_t level, const char* message) _log_creation_failed_before = true; return; } - _write_message_to_stream(log_file, is_enclave, level, message); + + if (!_use_custom_log_format) + { + _write_message_to_stream( + log_file, is_enclave, time, usecs, level, message); + } + else + { + char* message_cursor = NULL; +#if defined(__linux__) + char* log_msg = strtok_r((char*)message, "[", &message_cursor); + char* file_name = strtok_r(NULL, ":", &message_cursor); + char* function = strtok_r(NULL, ":", &message_cursor); + char* line_number = strtok_r(NULL, "]", &message_cursor); +#else + char* log_msg = strtok_s((char*)message, "[", &message_cursor); + char* file_name = strtok_s(NULL, ":", &message_cursor); + char* function = strtok_s(NULL, ":", &message_cursor); + char* line_number = strtok_s(NULL, "]", &message_cursor); +#endif + if (!log_msg || !file_name || !function || !line_number) + { + _write_message_to_stream( + log_file, + is_enclave, + time, + usecs, + level, + "Failed to apply custom formatter to message\n"); + } + else + { + if (_log_escape) + { + size_t msg_size = strlen(log_msg); + size_t max_msg_size = + MAX_ESCAPED_MSG_MULTIPLIER * msg_size + 1; + char* log_msg_escaped = malloc(max_msg_size); + bool escaped_ok = _escape_characters( + log_msg, log_msg_escaped, msg_size, max_msg_size); + + _write_custom_format_message_to_stream( + log_file, + is_enclave, + time, + usecs, + level, + (escaped_ok ? log_msg_escaped + : "failed to escape log message"), + file_name, + function, + line_number, + _custom_log_format); + + free(log_msg_escaped); + } + else + { + _write_custom_format_message_to_stream( + log_file, + is_enclave, + time, + usecs, + level, + log_msg, + file_name, + function, + line_number, + _custom_log_format); + } + } + } + fflush(log_file); fclose(log_file); } diff --git a/host/traceh_enclave.c b/host/traceh_enclave.c index 4a1a13fb9f..f105f46a32 100644 --- a/host/traceh_enclave.c +++ b/host/traceh_enclave.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/host/windows/hostthread.c b/host/windows/hostthread.c index a7aae96e36..987194a9e1 100644 --- a/host/windows/hostthread.c +++ b/host/windows/hostthread.c @@ -1,10 +1,13 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../hostthread.h" #include +#include #include +typedef DWORD (*start_routine_t)(void*); + /* **============================================================================== ** @@ -13,12 +16,30 @@ **============================================================================== */ -oe_thread oe_thread_self(void) +int oe_thread_create(oe_thread_t* thread, void* (*func)(void*), void* arg) { - return GetCurrentThreadId(); + start_routine_t start_routine = (start_routine_t)func; + *thread = (oe_thread_t)CreateThread(NULL, 0, start_routine, arg, 0, NULL); + return *thread == (oe_thread_t)NULL ? OE_EINVAL : 0; } -int oe_thread_equal(oe_thread thread1, oe_thread thread2) +int oe_thread_join(oe_thread_t thread) +{ + HANDLE handle = (HANDLE)thread; + if (WaitForSingleObject(handle, INFINITE) == WAIT_OBJECT_0) + { + CloseHandle(handle); + return 0; + } + return OE_EINVAL; +} + +oe_thread_t oe_thread_self(void) +{ + return (oe_thread_t)GetCurrentThreadId(); +} + +int oe_thread_equal(oe_thread_t thread1, oe_thread_t thread2) { return thread1 == thread2; } @@ -36,6 +57,9 @@ static BOOL CALLBACK OnceHelper( _Inout_opt_ PVOID Parameter, _Out_opt_ PVOID* Context) { + OE_UNUSED(InitOnce); + OE_UNUSED(Context); + ((void (*)(void))Parameter)(); return TRUE; } diff --git a/host/windows/syscall.c b/host/windows/syscall.c index 047036f658..792ae9565c 100644 --- a/host/windows/syscall.c +++ b/host/windows/syscall.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* @@ -11,7 +11,6 @@ ** **============================================================================== */ - #define _WINSOCK_DEPRECATED_NO_WARNINGS #include @@ -20,16 +19,284 @@ #include // clang-format off + +#include #include +#include +#include // clang-format on #include +#include #include #include #include #include "../hostthread.h" +#include "../../common/oe_host_socket.h" #include "syscall_u.h" +/* +**============================================================================== +** +** WINDOWS ERROR CONVERSION +** +**============================================================================== +*/ + +struct tab_entry +{ + int key; + int val; +}; + +static struct tab_entry winerr2errno[] = { + {ERROR_ACCESS_DENIED, OE_EACCES}, + {ERROR_ACTIVE_CONNECTIONS, OE_EAGAIN}, + {ERROR_ALREADY_EXISTS, OE_EEXIST}, + {ERROR_BAD_DEVICE, OE_ENODEV}, + {ERROR_BAD_EXE_FORMAT, OE_ENOEXEC}, + {ERROR_BAD_NETPATH, OE_ENOENT}, + {ERROR_BAD_NET_NAME, OE_ENOENT}, + {ERROR_BAD_NET_RESP, OE_ENOSYS}, + {ERROR_BAD_PATHNAME, OE_ENOENT}, + {ERROR_BAD_PIPE, OE_EINVAL}, + {ERROR_BAD_UNIT, OE_ENODEV}, + {ERROR_BAD_USERNAME, OE_EINVAL}, + {ERROR_BEGINNING_OF_MEDIA, OE_EIO}, + {ERROR_BROKEN_PIPE, OE_EPIPE}, + {ERROR_BUSY, OE_EBUSY}, + {ERROR_BUS_RESET, OE_EIO}, + {ERROR_CALL_NOT_IMPLEMENTED, OE_ENOSYS}, + {ERROR_CANCELLED, OE_EINTR}, + {ERROR_CANNOT_MAKE, OE_EPERM}, + {ERROR_CHILD_NOT_COMPLETE, OE_EBUSY}, + {ERROR_COMMITMENT_LIMIT, OE_EAGAIN}, + {ERROR_CONNECTION_REFUSED, OE_ECONNREFUSED}, + {ERROR_CRC, OE_EIO}, + {ERROR_DEVICE_DOOR_OPEN, OE_EIO}, + {ERROR_DEVICE_IN_USE, OE_EAGAIN}, + {ERROR_DEVICE_REQUIRES_CLEANING, OE_EIO}, + {ERROR_DEV_NOT_EXIST, OE_ENOENT}, + {ERROR_DIRECTORY, OE_ENOTDIR}, + {ERROR_DIR_NOT_EMPTY, OE_ENOTEMPTY}, + {ERROR_DISK_CORRUPT, OE_EIO}, + {ERROR_DISK_FULL, OE_ENOSPC}, + {ERROR_DS_GENERIC_ERROR, OE_EIO}, + {ERROR_DUP_NAME, OE_ENOTUNIQ}, + {ERROR_EAS_DIDNT_FIT, OE_ENOSPC}, + {ERROR_EAS_NOT_SUPPORTED, OE_ENOTSUP}, + {ERROR_EA_LIST_INCONSISTENT, OE_EINVAL}, + {ERROR_EA_TABLE_FULL, OE_ENOSPC}, + {ERROR_END_OF_MEDIA, OE_ENOSPC}, + {ERROR_EOM_OVERFLOW, OE_EIO}, + {ERROR_EXE_MACHINE_TYPE_MISMATCH, OE_ENOEXEC}, + {ERROR_EXE_MARKED_INVALID, OE_ENOEXEC}, + {ERROR_FILEMARK_DETECTED, OE_EIO}, + {ERROR_FILENAME_EXCED_RANGE, OE_ENAMETOOLONG}, + {ERROR_FILE_CORRUPT, OE_EEXIST}, + {ERROR_FILE_EXISTS, OE_EEXIST}, + {ERROR_FILE_INVALID, OE_ENXIO}, + {ERROR_FILE_NOT_FOUND, OE_ENOENT}, + {ERROR_HANDLE_DISK_FULL, OE_ENOSPC}, + {ERROR_HANDLE_EOF, OE_ENODATA}, + {ERROR_INVALID_ADDRESS, OE_EINVAL}, + {ERROR_INVALID_AT_INTERRUPT_TIME, OE_EINTR}, + {ERROR_INVALID_BLOCK_LENGTH, OE_EIO}, + {ERROR_INVALID_DATA, OE_EINVAL}, + {ERROR_INVALID_DRIVE, OE_ENODEV}, + {ERROR_INVALID_EA_NAME, OE_EINVAL}, + {ERROR_INVALID_EXE_SIGNATURE, OE_ENOEXEC}, + {ERROR_INVALID_FUNCTION, OE_EBADRQC}, + {ERROR_INVALID_HANDLE, OE_EBADF}, + {ERROR_INVALID_NAME, OE_ENOENT}, + {ERROR_INVALID_PARAMETER, OE_EINVAL}, + {ERROR_INVALID_SIGNAL_NUMBER, OE_EINVAL}, + {ERROR_IOPL_NOT_ENABLED, OE_ENOEXEC}, + {ERROR_IO_DEVICE, OE_EIO}, + {ERROR_IO_INCOMPLETE, OE_EAGAIN}, + {ERROR_IO_PENDING, OE_EAGAIN}, + {ERROR_LOCK_VIOLATION, OE_EBUSY}, + {ERROR_MAX_THRDS_REACHED, OE_EAGAIN}, + {ERROR_META_EXPANSION_TOO_LONG, OE_EINVAL}, + {ERROR_MOD_NOT_FOUND, OE_ENOENT}, + {ERROR_MORE_DATA, OE_EMSGSIZE}, + {ERROR_NEGATIVE_SEEK, OE_EINVAL}, + {ERROR_NETNAME_DELETED, OE_ENOENT}, + {ERROR_NOACCESS, OE_EFAULT}, + {ERROR_NONE_MAPPED, OE_EINVAL}, + {ERROR_NONPAGED_SYSTEM_RESOURCES, OE_EAGAIN}, + {ERROR_NOT_CONNECTED, OE_ENOLINK}, + {ERROR_NOT_ENOUGH_MEMORY, OE_ENOMEM}, + {ERROR_NOT_ENOUGH_QUOTA, OE_EIO}, + {ERROR_NOT_OWNER, OE_EPERM}, + {ERROR_NOT_READY, OE_ENOMEDIUM}, + {ERROR_NOT_SAME_DEVICE, OE_EXDEV}, + {ERROR_NOT_SUPPORTED, OE_ENOSYS}, + {ERROR_NO_DATA, OE_EPIPE}, + {ERROR_NO_DATA_DETECTED, OE_EIO}, + {ERROR_NO_MEDIA_IN_DRIVE, OE_ENOMEDIUM}, + {ERROR_NO_MORE_FILES, OE_ENFILE}, + {ERROR_NO_MORE_ITEMS, OE_ENFILE}, + {ERROR_NO_MORE_SEARCH_HANDLES, OE_ENFILE}, + {ERROR_NO_PROC_SLOTS, OE_EAGAIN}, + {ERROR_NO_SIGNAL_SENT, OE_EIO}, + {ERROR_NO_SYSTEM_RESOURCES, OE_EFBIG}, + {ERROR_NO_TOKEN, OE_EINVAL}, + {ERROR_OPEN_FAILED, OE_EIO}, + {ERROR_OPEN_FILES, OE_EAGAIN}, + {ERROR_OUTOFMEMORY, OE_ENOMEM}, + {ERROR_PAGED_SYSTEM_RESOURCES, OE_EAGAIN}, + {ERROR_PAGEFILE_QUOTA, OE_EAGAIN}, + {ERROR_PATH_NOT_FOUND, OE_ENOENT}, + {ERROR_PIPE_BUSY, OE_EBUSY}, + {ERROR_PIPE_CONNECTED, OE_EBUSY}, + {ERROR_PIPE_LISTENING, OE_ECOMM}, + {ERROR_PIPE_NOT_CONNECTED, OE_ECOMM}, + {ERROR_POSSIBLE_DEADLOCK, OE_EDEADLOCK}, + {ERROR_PRIVILEGE_NOT_HELD, OE_EPERM}, + {ERROR_PROCESS_ABORTED, OE_EFAULT}, + {ERROR_PROC_NOT_FOUND, OE_ESRCH}, + {ERROR_REM_NOT_LIST, OE_ENONET}, + {ERROR_SECTOR_NOT_FOUND, OE_EINVAL}, + {ERROR_SEEK, OE_EINVAL}, + {ERROR_SERVICE_REQUEST_TIMEOUT, OE_EBUSY}, + {ERROR_SETMARK_DETECTED, OE_EIO}, + {ERROR_SHARING_BUFFER_EXCEEDED, OE_ENOLCK}, + {ERROR_SHARING_VIOLATION, OE_EBUSY}, + {ERROR_SIGNAL_PENDING, OE_EBUSY}, + {ERROR_SIGNAL_REFUSED, OE_EIO}, + {ERROR_SXS_CANT_GEN_ACTCTX, OE_ELIBBAD}, + {ERROR_THREAD_1_INACTIVE, OE_EINVAL}, + {ERROR_TIMEOUT, OE_EBUSY}, + {ERROR_TOO_MANY_LINKS, OE_EMLINK}, + {ERROR_TOO_MANY_OPEN_FILES, OE_EMFILE}, + {ERROR_UNEXP_NET_ERR, OE_EIO}, + {ERROR_WAIT_NO_CHILDREN, OE_ECHILD}, + {ERROR_WORKING_SET_QUOTA, OE_EAGAIN}, + {ERROR_WRITE_PROTECT, OE_EROFS}, + {0, 0}}; + +static struct tab_entry winsock2errno[] = { + {WSAEINTR, OE_EINTR}, + {WSAEBADF, OE_EBADF}, + {WSAEACCES, OE_EACCES}, + {WSAEFAULT, OE_EFAULT}, + {WSAEINVAL, OE_EINVAL}, + {WSAEMFILE, OE_EMFILE}, + {WSAEWOULDBLOCK, OE_EWOULDBLOCK}, + {WSAEINPROGRESS, OE_EINPROGRESS}, + {WSAEALREADY, OE_EALREADY}, + {WSAENOTSOCK, OE_ENOTSOCK}, + {WSAEDESTADDRREQ, OE_EDESTADDRREQ}, + {WSAEMSGSIZE, OE_EMSGSIZE}, + {WSAEPROTOTYPE, OE_EPROTOTYPE}, + {WSAENOPROTOOPT, OE_ENOPROTOOPT}, + {WSAEPROTONOSUPPORT, OE_EPROTONOSUPPORT}, + {WSAESOCKTNOSUPPORT, OE_ESOCKTNOSUPPORT}, + {WSAEOPNOTSUPP, OE_EOPNOTSUPP}, + {WSAEPFNOSUPPORT, OE_EPFNOSUPPORT}, + {WSAEAFNOSUPPORT, OE_EAFNOSUPPORT}, + {WSAEADDRINUSE, OE_EADDRINUSE}, + {WSAEADDRNOTAVAIL, OE_EADDRNOTAVAIL}, + {WSAENETDOWN, OE_ENETDOWN}, + {WSAENETUNREACH, OE_ENETUNREACH}, + {WSAENETRESET, OE_ENETRESET}, + {WSAECONNABORTED, OE_ECONNABORTED}, + {WSAECONNRESET, OE_ECONNRESET}, + {WSAENOBUFS, OE_ENOBUFS}, + {WSAEISCONN, OE_EISCONN}, + {WSAENOTCONN, OE_ENOTCONN}, + {WSAESHUTDOWN, OE_ESHUTDOWN}, + {WSAETOOMANYREFS, OE_ETOOMANYREFS}, + {WSAETIMEDOUT, OE_ETIMEDOUT}, + {WSAECONNREFUSED, OE_ECONNREFUSED}, + {WSAELOOP, OE_ELOOP}, + {WSAENAMETOOLONG, OE_ENAMETOOLONG}, + {WSAEHOSTDOWN, OE_EHOSTDOWN}, + {WSAEHOSTUNREACH, OE_EHOSTUNREACH}, + {WSAENOTEMPTY, OE_ENOTEMPTY}, + {WSAEUSERS, OE_EUSERS}, + {WSAEDQUOT, OE_EDQUOT}, + {WSAESTALE, OE_ESTALE}, + {WSAEREMOTE, OE_EREMOTE}, + {WSAEDISCON, OE_ESHUTDOWN}, + {WSAEPROCLIM, OE_EPROCLIM}, + {WSASYSNOTREADY, OE_EBUSY}, + {WSAVERNOTSUPPORTED, OE_ENOTSUP}, + {WSANOTINITIALISED, OE_ENXIO}, + {0, 0}}; + +/** + * Musl libc has redefined pretty much every define in socket.h so that + * constants passed as parameters are different if the enclave uses musl + * and the host uses a socket implementation that uses the original BSD + * defines (winsock, glibc, BSD libc). The following tables are 1-to-1 mappings + * from musl defines to bsd defines + */ + +// Only SOL_SOCKET is different. All other socket level +// defines are the same. +static struct tab_entry musl2bsd_socket_level[] = {{1, SOL_SOCKET}, {0, 0}}; + +static struct tab_entry musl2bsd_socket_option[] = {{1, SO_DEBUG}, + {2, SO_REUSEADDR}, + {3, SO_TYPE}, + {4, SO_ERROR}, + {5, SO_DONTROUTE}, + {6, SO_BROADCAST}, + {7, SO_SNDBUF}, + {8, SO_RCVBUF}, + {9, SO_KEEPALIVE}, + {10, SO_OOBINLINE}, + {13, SO_LINGER}, + {18, SO_RCVLOWAT}, + {19, SO_SNDLOWAT}}; + +static struct tab_entry wsa2eai[] = {{WSATRY_AGAIN, OE_EAI_AGAIN}, + {WSAEINVAL, OE_EAI_BADFLAGS}, + {WSAEAFNOSUPPORT, OE_EAI_FAMILY}, + {WSA_NOT_ENOUGH_MEMORY, OE_EAI_MEMORY}, + {WSAHOST_NOT_FOUND, OE_EAI_NONAME}, + {WSATYPE_NOT_FOUND, OE_EAI_SERVICE}, + {WSAESOCKTNOSUPPORT, OE_EAI_SOCKTYPE}, + {0, 0}}; + +static int _do_lookup(int key, int fallback, struct tab_entry* table) +{ + struct tab_entry* pent = table; + do + { + if (pent->key == key) + { + return pent->val; + } + + pent++; + } while (pent->val != 0); + + return fallback; +} + +static int _winerr_to_errno(int winerr) +{ + return _do_lookup(winerr, OE_EINVAL, winerr2errno); +} + +static int _winsockerr_to_errno(DWORD winsockerr) +{ + return _do_lookup(winsockerr, OE_EINVAL, winsock2errno); +} + +static int _wsaerr_to_eai(DWORD winsockerr) +{ + return _do_lookup(winsockerr, OE_EINVAL, wsa2eai); +} + +static int _musl_to_bsd(int musl_define, struct tab_entry* table) +{ + return _do_lookup(musl_define, OE_EINVAL, table); +} + /* **============================================================================== ** @@ -65,6 +332,8 @@ oe_host_fd_t oe_syscall_open_ocall( int flags, oe_mode_t mode) { + OE_UNUSED(mode); + oe_host_fd_t ret = -1; if (strcmp(pathname, "/dev/stdin") == 0) @@ -113,12 +382,18 @@ oe_host_fd_t oe_syscall_open_ocall( ssize_t oe_syscall_read_ocall(oe_host_fd_t fd, void* buf, size_t count) { - return _read(fd, buf, count); + if ((count & UINT_MAX) != count) + _set_errno(OE_EINVAL); + + return _read((int)fd, buf, (unsigned int)count); } ssize_t oe_syscall_write_ocall(oe_host_fd_t fd, const void* buf, size_t count) { - return _write(fd, buf, count); + if ((count & UINT_MAX) != count) + _set_errno(OE_EINVAL); + + return _write((int)fd, buf, (unsigned int)count); } ssize_t oe_syscall_readv_ocall( @@ -205,19 +480,25 @@ ssize_t oe_syscall_writev_ocall( oe_off_t oe_syscall_lseek_ocall(oe_host_fd_t fd, oe_off_t offset, int whence) { + OE_UNUSED(fd); + OE_UNUSED(offset); + OE_UNUSED(whence); + PANIC; } int oe_syscall_close_ocall(oe_host_fd_t fd) { - return _close(fd); + return _close((int)fd); } +static oe_host_fd_t _dup_socket(oe_host_fd_t); + oe_host_fd_t oe_syscall_dup_ocall(oe_host_fd_t oldfd) { oe_host_fd_t ret = -1; - // Only support duping std file descriptors for now. + // Only support duping std file descriptors and sockets for now. switch (oldfd) { case 0: @@ -233,6 +514,8 @@ oe_host_fd_t oe_syscall_dup_ocall(oe_host_fd_t oldfd) break; default: + // Try dup-ing it as a socket. + ret = _dup_socket(oldfd); break; } @@ -246,61 +529,92 @@ oe_host_fd_t oe_syscall_dup_ocall(oe_host_fd_t oldfd) uint64_t oe_syscall_opendir_ocall(const char* pathname) { + OE_UNUSED(pathname); + PANIC; } int oe_syscall_readdir_ocall(uint64_t dirp, struct oe_dirent* entry) { + OE_UNUSED(dirp); + OE_UNUSED(entry); + PANIC; } void oe_syscall_rewinddir_ocall(uint64_t dirp) { + OE_UNUSED(dirp); + PANIC; } int oe_syscall_closedir_ocall(uint64_t dirp) { + OE_UNUSED(dirp); + PANIC; } int oe_syscall_stat_ocall(const char* pathname, struct oe_stat* buf) { + OE_UNUSED(pathname); + OE_UNUSED(buf); + PANIC; } int oe_syscall_access_ocall(const char* pathname, int mode) { + OE_UNUSED(pathname); + OE_UNUSED(mode); + PANIC; } int oe_syscall_link_ocall(const char* oldpath, const char* newpath) { + OE_UNUSED(oldpath); + OE_UNUSED(newpath); + PANIC; } int oe_syscall_unlink_ocall(const char* pathname) { + OE_UNUSED(pathname); + PANIC; } int oe_syscall_rename_ocall(const char* oldpath, const char* newpath) { + OE_UNUSED(oldpath); + OE_UNUSED(newpath); + PANIC; } int oe_syscall_truncate_ocall(const char* pathname, oe_off_t length) { + OE_UNUSED(pathname); + OE_UNUSED(length); + PANIC; } int oe_syscall_mkdir_ocall(const char* pathname, oe_mode_t mode) { + OE_UNUSED(pathname); + OE_UNUSED(mode); + PANIC; } int oe_syscall_rmdir_ocall(const char* pathname) { + OE_UNUSED(pathname); + PANIC; } @@ -312,9 +626,108 @@ int oe_syscall_rmdir_ocall(const char* pathname) **============================================================================== */ +#define OE_SOCKET_FD_MAGIC 0x29b4a345c7564b57 +typedef struct win_socket_fd +{ + uint64_t magic; + SOCKET socket; +} oe_socket_fd_t; + +static oe_socket_fd_t _invalid_socket = {OE_SOCKET_FD_MAGIC, INVALID_SOCKET}; + +oe_host_fd_t _make_socket_fd(SOCKET sock) +{ + oe_host_fd_t fd = (oe_host_fd_t)&_invalid_socket; + if (sock != INVALID_SOCKET) + { + oe_socket_fd_t* socket_fd = + (oe_socket_fd_t*)malloc(sizeof(oe_socket_fd_t)); + if (socket_fd) + { + socket_fd->magic = OE_SOCKET_FD_MAGIC; + socket_fd->socket = sock; + fd = (oe_host_fd_t)socket_fd; + } + } + return fd; +} + +SOCKET _get_socket(oe_host_fd_t fd) +{ + oe_socket_fd_t* socket_fd = (oe_socket_fd_t*)fd; + if (socket_fd && socket_fd->magic == OE_SOCKET_FD_MAGIC) + return socket_fd->socket; + return INVALID_SOCKET; +} + +static oe_host_fd_t _dup_socket(oe_host_fd_t oldfd) +{ + oe_socket_fd_t* old_socket_fd = (oe_socket_fd_t*)oldfd; + if (old_socket_fd && old_socket_fd->magic == OE_SOCKET_FD_MAGIC) + { + // Duplicate socket + WSAPROTOCOL_INFO protocolInfo; + int ret = WSADuplicateSocket( + old_socket_fd->socket, GetCurrentProcessId(), &protocolInfo); + if (ret == SOCKET_ERROR) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + SOCKET sock = WSASocket( + protocolInfo.iAddressFamily, + protocolInfo.iSocketType, + protocolInfo.iProtocol, + &protocolInfo, + 0, + 0); + if (sock == INVALID_SOCKET) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return _make_socket_fd(sock); + } + + return -1; +} + +static int _wsa_startup() +{ + static int64_t wsa_init_done = FALSE; + WSADATA wsaData; + int ret = 0; + + if (oe_atomic_compare_and_swap( + (volatile int64_t*)&wsa_init_done, (int64_t)0, (int64_t)1)) + { + ret = WSAStartup(2, &wsaData); + if (ret != 0) + goto done; + } + +done: + return ret; +} + oe_host_fd_t oe_syscall_socket_ocall(int domain, int type, int protocol) { - PANIC; + SOCKET sock = INVALID_SOCKET; + + if (_wsa_startup() != 0) + { + _set_errno(OE_EINVAL); + goto done; + } + + sock = socket(domain, type, protocol); + if (sock == INVALID_SOCKET) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + +done: + return _make_socket_fd(sock); } int oe_syscall_socketpair_ocall( @@ -323,6 +736,11 @@ int oe_syscall_socketpair_ocall( int protocol, oe_host_fd_t sv_out[2]) { + OE_UNUSED(domain); + OE_UNUSED(type); + OE_UNUSED(protocol); + OE_UNUSED(sv_out); + PANIC; } @@ -331,7 +749,14 @@ int oe_syscall_connect_ocall( const struct oe_sockaddr* addr, oe_socklen_t addrlen) { - PANIC; + int ret = connect( + _get_socket(sockfd), (const struct sockaddr*)addr, (int)addrlen); + if (ret != 0) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } oe_host_fd_t oe_syscall_accept_ocall( @@ -340,7 +765,22 @@ oe_host_fd_t oe_syscall_accept_ocall( oe_socklen_t addrlen_in, oe_socklen_t* addrlen_out) { - PANIC; + int addrlen = (int)addrlen_in; + SOCKET conn_socket = accept( + _get_socket(sockfd), + (struct sockaddr*)addr, + addrlen_out ? &addrlen : NULL); + if (conn_socket == INVALID_SOCKET) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + goto done; + } + + if (addrlen_out) + *addrlen_out = addrlen; + +done: + return _make_socket_fd(conn_socket); } int oe_syscall_bind_ocall( @@ -348,12 +788,24 @@ int oe_syscall_bind_ocall( const struct oe_sockaddr* addr, oe_socklen_t addrlen) { - PANIC; + int ret = bind(_get_socket(sockfd), (const struct sockaddr*)addr, addrlen); + if (ret != 0) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } int oe_syscall_listen_ocall(oe_host_fd_t sockfd, int backlog) { - PANIC; + int ret = listen(_get_socket(sockfd), backlog); + if (ret != 0) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } ssize_t oe_syscall_recvmsg_ocall( @@ -369,6 +821,18 @@ ssize_t oe_syscall_recvmsg_ocall( size_t* msg_controllen_out, int flags) { + OE_UNUSED(sockfd); + OE_UNUSED(msg_name); + OE_UNUSED(msg_namelen); + OE_UNUSED(msg_namelen_out); + OE_UNUSED(msg_iov_buf); + OE_UNUSED(msg_iovlen); + OE_UNUSED(msg_iov_buf_size); + OE_UNUSED(msg_control); + OE_UNUSED(msg_controllen); + OE_UNUSED(msg_controllen_out); + OE_UNUSED(flags); + PANIC; } @@ -383,6 +847,16 @@ ssize_t oe_syscall_sendmsg_ocall( size_t msg_controllen, int flags) { + OE_UNUSED(sockfd); + OE_UNUSED(msg_name); + OE_UNUSED(msg_namelen); + OE_UNUSED(msg_iov_buf); + OE_UNUSED(msg_iovlen); + OE_UNUSED(msg_iov_buf_size); + OE_UNUSED(msg_control); + OE_UNUSED(msg_controllen); + OE_UNUSED(flags); + PANIC; } @@ -392,7 +866,16 @@ ssize_t oe_syscall_recv_ocall( size_t len, int flags) { - PANIC; + ssize_t ret; + _set_errno(0); + + ret = recv(_get_socket(sockfd), (char*)buf, (int)len, flags); + if (ret == SOCKET_ERROR) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } ssize_t oe_syscall_recvfrom_ocall( @@ -404,7 +887,27 @@ ssize_t oe_syscall_recvfrom_ocall( oe_socklen_t addrlen_in, oe_socklen_t* addrlen_out) { - PANIC; + ssize_t ret; + _set_errno(0); + + ret = recvfrom( + _get_socket(sockfd), + (char*)buf, + (int)len, + flags, + (struct sockaddr*)src_addr, + (int*)&addrlen_in); + if (ret == SOCKET_ERROR) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + else + { + if (addrlen_out) + *addrlen_out = addrlen_in; + } + + return ret; } ssize_t oe_syscall_send_ocall( @@ -413,7 +916,16 @@ ssize_t oe_syscall_send_ocall( size_t len, int flags) { - PANIC; + ssize_t ret; + _set_errno(0); + + ret = send(_get_socket(sockfd), buf, len, flags); + if (ret == SOCKET_ERROR) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } ssize_t oe_syscall_sendto_ocall( @@ -424,7 +936,22 @@ ssize_t oe_syscall_sendto_ocall( const struct oe_sockaddr* src_addr, oe_socklen_t addrlen) { - PANIC; + ssize_t ret; + _set_errno(0); + + ret = sendto( + _get_socket(sockfd), + buf, + len, + flags, + (struct sockaddr*)src_addr, + addrlen); + if (ret == SOCKET_ERROR) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } ssize_t oe_syscall_recvv_ocall( @@ -433,6 +960,11 @@ ssize_t oe_syscall_recvv_ocall( int iovcnt, size_t iov_buf_size) { + OE_UNUSED(fd); + OE_UNUSED(iov_buf); + OE_UNUSED(iovcnt); + OE_UNUSED(iov_buf_size); + PANIC; } @@ -442,19 +974,44 @@ ssize_t oe_syscall_sendv_ocall( int iovcnt, size_t iov_buf_size) { + OE_UNUSED(fd); + OE_UNUSED(iov_buf); + OE_UNUSED(iovcnt); + OE_UNUSED(iov_buf_size); + PANIC; } int oe_syscall_shutdown_ocall(oe_host_fd_t sockfd, int how) { - PANIC; + int ret = shutdown(_get_socket(sockfd), how); + if (ret != 0) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + return ret; } int oe_syscall_close_socket_ocall(oe_host_fd_t sockfd) { - PANIC; + SOCKET sock = _get_socket(sockfd); + int r = -1; + if (sock != INVALID_SOCKET) + { + r = closesocket(sock); + if (r != 0) + { + _set_errno(_winsockerr_to_errno(WSAGetLastError())); + } + + free((oe_socket_fd_t*)sockfd); + } + return r; } +#define F_GETFL 3 + int oe_syscall_fcntl_ocall( oe_host_fd_t fd, int cmd, @@ -462,7 +1019,28 @@ int oe_syscall_fcntl_ocall( uint64_t argsize, void* argout) { - PANIC; + SOCKET sock; + + if ((sock = _get_socket(fd)) != INVALID_SOCKET) + { + switch (cmd) + { + case F_GETFL: + // TODO: There is no way to get file access modes on winsock + // sockets. Currently this only exists to because mbedtls uses + // this syscall to check if the socket is blocking. If we want + // this syscall to actually work properly for other cases, this + // should be revisited. + return 0; + default: + PANIC; + } + } + else + { + // File operations are not supported + PANIC; + } } #define TIOCGWINSZ 0x5413 @@ -475,6 +1053,11 @@ int oe_syscall_ioctl_ocall( uint64_t argsize, void* argout) { + OE_UNUSED(fd); + OE_UNUSED(arg); + OE_UNUSED(argsize); + OE_UNUSED(argout); + errno = 0; // We don't support any ioctls right now as we will have to translate the @@ -503,7 +1086,17 @@ int oe_syscall_setsockopt_ocall( const void* optval, oe_socklen_t optlen) { - PANIC; + level = _musl_to_bsd(level, musl2bsd_socket_level); + optname = _musl_to_bsd(optname, musl2bsd_socket_option); + + int ret = setsockopt(_get_socket(sockfd), level, optname, optval, optlen); + if (ret != 0) + { + int err = _winsockerr_to_errno(WSAGetLastError()); + _set_errno(err); + } + + return ret; } int oe_syscall_getsockopt_ocall( @@ -514,7 +1107,23 @@ int oe_syscall_getsockopt_ocall( oe_socklen_t optlen_in, oe_socklen_t* optlen_out) { - PANIC; + level = _musl_to_bsd(level, musl2bsd_socket_level); + optname = _musl_to_bsd(optname, musl2bsd_socket_option); + + int ret = + getsockopt(_get_socket(sockfd), level, optname, optval, &optlen_in); + if (ret != 0) + { + int err = _winsockerr_to_errno(WSAGetLastError()); + _set_errno(err); + } + else + { + if (optlen_out) + *optlen_out = optlen_in; + } + + return ret; } int oe_syscall_getsockname_ocall( @@ -523,6 +1132,11 @@ int oe_syscall_getsockname_ocall( oe_socklen_t addrlen_in, oe_socklen_t* addrlen_out) { + OE_UNUSED(sockfd); + OE_UNUSED(addr); + OE_UNUSED(addrlen_in); + OE_UNUSED(addrlen_out); + PANIC; } @@ -532,11 +1146,18 @@ int oe_syscall_getpeername_ocall( oe_socklen_t addrlen_in, oe_socklen_t* addrlen_out) { + OE_UNUSED(sockfd); + OE_UNUSED(addr); + OE_UNUSED(addrlen_in); + OE_UNUSED(addrlen_out); + PANIC; } int oe_syscall_shutdown_sockets_device_ocall(oe_host_fd_t sockfd) { + OE_UNUSED(sockfd); + PANIC; } @@ -550,6 +1171,9 @@ int oe_syscall_shutdown_sockets_device_ocall(oe_host_fd_t sockfd) int oe_syscall_kill_ocall(int pid, int signum) { + OE_UNUSED(pid); + OE_UNUSED(signum); + PANIC; } @@ -567,7 +1191,55 @@ int oe_syscall_getaddrinfo_open_ocall( const struct oe_addrinfo* hints, uint64_t* handle_out) { - PANIC; + int ret = OE_EAI_FAIL; + getaddrinfo_handle_t* handle = NULL; + + if (_wsa_startup() != 0) + { + _set_errno(OE_EINVAL); + goto done; + } + + _set_errno(0); + + if (handle_out) + { + *handle_out = 0; + } + else + { + ret = OE_EAI_SYSTEM; + _set_errno(OE_EINVAL); + goto done; + } + + if (!(handle = calloc(1, sizeof(getaddrinfo_handle_t)))) + { + ret = OE_EAI_MEMORY; + _set_errno(OE_ENOMEM); + goto done; + } + + ret = + getaddrinfo(node, service, (const struct addrinfo*)hints, &handle->res); + if (ret == 0) + { + handle->magic = GETADDRINFO_HANDLE_MAGIC; + handle->next = handle->res; + *handle_out = (uint64_t)handle; + handle = NULL; + } + else + { + ret = _wsaerr_to_eai(ret); + } + +done: + + if (handle) + free(handle); + + return ret; } int oe_syscall_getaddrinfo_read_ocall( @@ -583,12 +1255,45 @@ int oe_syscall_getaddrinfo_read_ocall( size_t* ai_canonnamelen, char* ai_canonname) { - PANIC; + int err_no = 0; + int ret = _getaddrinfo_read( + handle_, + ai_flags, + ai_family, + ai_socktype, + ai_protocol, + ai_addrlen_in, + ai_addrlen, + ai_addr, + ai_canonnamelen_in, + ai_canonnamelen, + ai_canonname, + &err_no); + _set_errno(err_no); + + return ret; } int oe_syscall_getaddrinfo_close_ocall(uint64_t handle_) { - PANIC; + int ret = -1; + getaddrinfo_handle_t* handle = _cast_getaddrinfo_handle((void*)handle_); + + _set_errno(0); + + if (!handle) + { + _set_errno(OE_EINVAL); + goto done; + } + + freeaddrinfo(handle->res); + free(handle); + + ret = 0; + +done: + return ret; } int oe_syscall_getnameinfo_ocall( @@ -600,6 +1305,14 @@ int oe_syscall_getnameinfo_ocall( oe_socklen_t servlen, int flags) { + OE_UNUSED(sa); + OE_UNUSED(salen); + OE_UNUSED(host); + OE_UNUSED(hostlen); + OE_UNUSED(serv); + OE_UNUSED(servlen); + OE_UNUSED(flags); + PANIC; } @@ -613,6 +1326,8 @@ int oe_syscall_getnameinfo_ocall( oe_host_fd_t oe_syscall_epoll_create1_ocall(int flags) { + OE_UNUSED(flags); + PANIC; } @@ -622,6 +1337,11 @@ int oe_syscall_epoll_wait_ocall( unsigned int maxevents, int timeout) { + OE_UNUSED(epfd); + OE_UNUSED(events); + OE_UNUSED(maxevents); + OE_UNUSED(timeout); + PANIC; } @@ -636,11 +1356,18 @@ int oe_syscall_epoll_ctl_ocall( int64_t fd, struct oe_epoll_event* event) { + OE_UNUSED(epfd); + OE_UNUSED(op); + OE_UNUSED(fd); + OE_UNUSED(event); + PANIC; } int oe_syscall_epoll_close_ocall(oe_host_fd_t epfd) { + OE_UNUSED(epfd); + PANIC; } @@ -657,6 +1384,10 @@ int oe_syscall_poll_ocall( oe_nfds_t nfds, int timeout) { + OE_UNUSED(host_fds); + OE_UNUSED(nfds); + OE_UNUSED(timeout); + PANIC; } @@ -705,11 +1436,16 @@ unsigned int oe_syscall_getegid_ocall(void) int oe_syscall_getpgid_ocall(int pid) { + OE_UNUSED(pid); + PANIC; } int oe_syscall_getgroups_ocall(size_t size, unsigned int* list) { + OE_UNUSED(size); + OE_UNUSED(list); + PANIC; } @@ -723,5 +1459,46 @@ int oe_syscall_getgroups_ocall(size_t size, unsigned int* list) int oe_syscall_uname_ocall(struct oe_utsname* buf) { - PANIC; + int ret = -1; + + if (!buf) + { + _set_errno(OE_EINVAL); + goto done; + } + + // Get domain name + DWORD size = sizeof(buf->domainname); + if (!GetComputerNameEx(ComputerNameDnsDomain, buf->domainname, &size)) + { + _set_errno(_winerr_to_errno(GetLastError())); + goto done; + } + + // Get hostname + size = sizeof(buf->nodename); + if (!GetComputerNameEx(ComputerNameDnsHostname, buf->nodename, &size)) + { + _set_errno(_winerr_to_errno(GetLastError())); + goto done; + } + + // Based on + // https://docs.microsoft.com/en-us/windows/win32/sysinfo/getting-the-system-version + // OE SDK is supported only on WindowsServer and Win10 + if (IsWindowsServer()) + { + sprintf(buf->sysname, "WindowsServer"); + sprintf(buf->version, "2016OrAbove"); + } + else if (IsWindows10OrGreater()) + { + sprintf(buf->sysname, "Windows10OrGreater"); + sprintf(buf->version, "10OrAbove"); + } + + ret = 0; + +done: + return ret; } diff --git a/host/windows/time.c b/host/windows/time.c index ca848ab58d..0c40096cab 100644 --- a/host/windows/time.c +++ b/host/windows/time.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 8e247028e4..585e2f851e 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OE main include files, add interface library, add install steps @@ -13,4 +13,7 @@ install(DIRECTORY openenclave/edger8r DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/op install(FILES openenclave/enclave.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openenclave/) install(FILES openenclave/host.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openenclave/) install(FILES openenclave/host_verify.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openenclave/ COMPONENT OEHOSTVERIFY) +install(FILES openenclave/attestation/plugin.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openenclave/ COMPONENT OEHOSTVERIFY) +install(FILES openenclave/attestation/sgx/attester.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openenclave/) +install(FILES openenclave/attestation/sgx/verifier.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openenclave/ COMPONENT OEHOSTVERIFY) install(TARGETS oe_includes EXPORT openenclave-targets) diff --git a/include/openenclave/attestation/plugin.h b/include/openenclave/attestation/plugin.h new file mode 100644 index 0000000000..c5edeb8a29 --- /dev/null +++ b/include/openenclave/attestation/plugin.h @@ -0,0 +1,430 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +/** + * @file attestation_plugin.h + * + * This file defines the programming interface for developing an + * attestation plugin for supporting alternative evidence formats. + * + */ + +#ifndef _OE_ATTESTATION_PLUGIN_H +#define _OE_ATTESTATION_PLUGIN_H + +#include +#include +#include + +OE_EXTERNC_BEGIN + +/** + * Struct that defines the base structure of each attestation role plugin. + * Each attestation role will have an UUID to indicate what evidence format + * is supported and have functions for registering/unregistering the plugin. + * Each attestation role will also define the require function for their + * specific role (i.e. `get_evidence` for the attester and `verifiy_evidence` + * for the verifier). + */ +typedef struct _oe_attestation_role oe_attestation_role_t; +struct _oe_attestation_role +{ + /** + * The UUID for the attestation role. + */ + oe_uuid_t format_id; + + /** + * The function that gets executed when the attestation role is registered. + * + * @param[in] context A pointer to the attestation role struct. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t (*on_register)( + oe_attestation_role_t* context, + const void* config_data, + size_t config_data_size); + + /** + * The function that gets executed when the attestation role is + * unregistered. + * + * @param[in] context A pointer to the attestation role struct. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t (*on_unregister)(oe_attestation_role_t* context); +}; + +/** + * The attester attestion role. The attester is reponsible for generating the + * attestation evidence and must implement the functions below. + */ +typedef struct _oe_attester oe_attester_t; +struct _oe_attester +{ + /** + * The base attestation role containing the common functions for each role. + */ + oe_attestation_role_t base; + + /** + * Generates the attestation evidence, which is defined as the data + * produced by the enclave. The caller may pass in custom claims, which + * must be attached to the evidence and then cryptographically signed. + * + * Note that many callers of `get_evidence` will send the results over + * the network, so the output must be in a serialized form. + * + * @param[in] context A pointer to the attester plugin struct. + * @param[in] flags Specifying default value (0) generates evidence for + * local attestation. Specifying OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION + * generates evidence for remote attestation. + * @param[in] custom_claims The optional custom claims list. + * @param[in] custom_claims_length The number of custom claims. + * @param[in] opt_params The optional plugin-specific input parameters. + * @param[in] opt_params_size The size of opt_params in bytes. + * @param[out] evidence_buffer An output pointer that will be assigned the + * address of the evidence buffer. + * @param[out] evidence_buffer_size A pointer that points to the size of the + * evidence buffer in bytes. + * @param[out] endorsements_buffer An output pointer that will be assigned + * the address of the endorsements buffer. + * @param[out] endorsements_buffer_size A pointer that points to the size of + * the endorsements buffer in bytes. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t (*get_evidence)( + oe_attester_t* context, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size); + + /** + * Frees the generated attestation evidence and endorsements. + * + * @param[in] context A pointer to the attester plugin struct. + * @param[in] evidence_buffer A pointer to the evidence buffer. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t ( + *free_evidence)(oe_attester_t* context, uint8_t* evidence_buffer); + + /** + * Frees the generated attestation endorsements. + * + * @param[in] context A pointer to the attester plugin struct. + * @param[in] endorsements_buffer A pointer to the endorsements buffer. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t (*free_endorsements)( + oe_attester_t* context, + uint8_t* endorsements_buffer); +}; + +/** + * The verifier attestion role. The verifier is reponsible for verifying the + * attestation evidence and must implement the functions below. + */ +typedef struct _oe_verifier oe_verifier_t; +struct _oe_verifier +{ + /** + * The base attestation role containing the common functions for each role. + */ + oe_attestation_role_t base; + + /** + * Verifies the attestation evidence and returns the claims contained in + * the evidence. + * + * Each plugin must return the following required claims: + * - id_version (uint32_t) + * - Version number. Must be 1. + * - security_version (uint32_t) + * - Security version of the enclave. (ISVN for SGX). + * - attributes (uint64_t) + * - Attributes flags for the evidence: + * - OE_REPORT_ATTRIBUTES_DEBUG: The evidence is for a debug + * enclave. + * - OE_REPORT_ATTRIBUTES_REMOTE: The evidence can be used for + * remote attestation. + * - unique_id (uint8_t[32]) + * - The unique ID for the enclave (MRENCLAVE for SGX). + * - signer_id (uint8_t[32]) + * - The signer ID for the enclave (MRSIGNER for SGX). + * - product_id (uint8_t[32]) + * - The product ID for the enclave (ISVPRODID for SGX). + * - validity_from (oe_datetime_t) + * - Overall datetime from which the evidence and endorsements are + * valid. + * - validity_until (oe_datetime_t) + * - Overall datetime at which the evidence and endorsements expire. + * - plugin_uuid (uint8_t[16]) + * - The UUID of the plugin used to verify the evidence. + * + * The plugin is responsible for handling endianness and ensuring that the + * data from the raw evidence converted properly for each platform. + * + * @param[in] context A pointer to the verifier plugin struct. + * @param[in] evidence_buffer The evidence buffer. + * @param[in] evidence_buffer_size The size of evidence_buffer in bytes. + * @param[in] endorsements_buffer The endorsements buffer. + * @param[in] endorsements_buffer_size The size of endorsements_buffer in + * bytes. + * @param[in] policies A list of policies to use. + * @param[in] policies_size The size of the policy list. + * @param[out] claims The list of returned claims. + * @param[out] claims_length The number of claims. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t (*verify_evidence)( + oe_verifier_t* context, + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length); + + /** + * Frees the generated claims. + * + * @param[in] context A pointer to the verifier plugin struct. + * @param[out] claims The list of returned claims. + * @param[out] claims_length The number of claims. + * @retval OE_OK on success. + * @retval An appropriate error code on failure. + */ + oe_result_t (*free_claims_list)( + oe_verifier_t* context, + oe_claim_t* claims, + size_t claims_length); +}; + +/** + * oe_register_attester + * + * Registers a new attester plugin and optionally configures it with plugin + * specific configuration data. The function will fail if the plugin UUID has + * already been registered. + * + * This is available in the enclave only. + * + * @param[in] plugin A pointer to the attestation plugin struct. Note that this + * will not copy the contents of the pointer, so the pointer must be kept valid + * until the plugin is unregistered. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK The function succeeded. + * @retval OE_INVALID_PARAMTER Atleast one of the parameters is invalid. + * @retval OE_OUT_OF_MEMORY Out of memory. + * @retval OE_ALREADY_EXISTS A plugin with the same UUID is already registered. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_register_attester( + oe_attester_t* plugin, + const void* config_data, + size_t config_data_size); + +/** + * oe_register_verifier + * + * Registers a new verifier plugin and optionally configures it with plugin + * specific configuration data. The function will fail if the plugin UUID has + * already been registered. + * + * This is available in the enclave and host. + * + * @param[in] plugin A pointer to the attestation plugin struct. Note that this + * will not copy the contents of the pointer, so the pointer must be kept valid + * until the plugin is unregistered. + * @param[in] config_data An optional pointer to the configuration data. + * @param[in] config_data_size The size in bytes of config_data. + * @retval OE_OK The function succeeded. + * @retval OE_INVALID_PARAMTER Atleast one of the parameters is invalid. + * @retval OE_OUT_OF_MEMORY Out of memory. + * @retval OE_ALREADY_EXISTS A plugin with the same UUID is already registered. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_register_verifier( + oe_verifier_t* plugin, + const void* config_data, + size_t config_data_size); + +/** + * oe_unregister_attester + * + * Unregisters an attester plugin. This is available in the enclave only. + * + * @param[in] plugin A pointer to the attestation plugin struct. + * @retval OE_OK The function succeeded. + * @retval OE_INVALID_PARAMTER Atleast one of the parameters is invalid. + * @retval OE_NOT_FOUND The plugin does not exist or has not been registered. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_unregister_attester(oe_attester_t* plugin); + +/** + * oe_unregister_verifier + * + * Unregisters an verifier plugin. This is available in the enclave and host. + * + * @param[in] plugin A pointer to the attestation plugin struct. + * @retval OE_OK The function succeeded. + * @retval OE_INVALID_PARAMTER Atleast one of the parameters is invalid. + * @retval OE_NOT_FOUND The plugin does not exist or has not been registered. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_unregister_verifier(oe_verifier_t* plugin); + +/** + * oe_get_evidence + * + * Generates the attestation evidence for the given UUID attestation format. + * This function is only available in the enclave. + * + * @param[in] evidence_format_uuid The UUID of the plugin. + * @param[in] flags Specifying default value (0) generates evidence for local + * attestation. Specifying OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION generates + * evidence for remote attestation. + * @param[in] custom_claims The optional custom claims list. + * @param[in] custom_claims_length The number of custom claims. + * @param[in] opt_params The optional plugin-specific input parameters. + * @param[in] opt_params_size The size of opt_params in bytes. + * @param[out] evidence_buffer An output pointer that will be assigned the + * address of the evidence buffer. + * @param[out] evidence_buffer_size A pointer that points to the size of the + * evidence buffer in bytes. + * @param[out] endorsements_buffer An output pointer that will be assigned the + * address of the endorsements buffer. + * @param[out] endorsements_buffer_size A pointer that points to the size of the + * endorsements buffer in bytes. + * @retval OE_OK The function succeeded. + * @retval OE_INVALID_PARAMTER Atleast one of the parameters is invalid. + * @retval OE_NOT_FOUND The plugin does not exist or has not been registered. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_get_evidence( + const oe_uuid_t* evidence_format_uuid, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size); + +/** + * oe_free_evidence + * + * Frees the attestation evidence. This function is only available in the + * enclave. + * + * @param[in] evidence_buffer A pointer to the evidence buffer. + * @retval OE_OK The function succeeded. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_free_evidence(uint8_t* evidence_buffer); + +/** + * oe_free_endorsements + * + * Frees the generated attestation endorsements. This function is only available + * in the enclave. + * + * @param[in] endorsements_buffer A pointer to the endorsements buffer. + * @retval OE_OK The function succeeded. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_free_endorsements(uint8_t* endorsements_buffer); + +/** + * oe_verify_evidence + * + * Verifies the attestation evidence and returns well known and custom claims. + * This is available in the enclave and host. + * + * The following claims will be returned at the minimum: + * + * - id_version (uint32_t) + * - Version number. Must be 1. + * - security_version (uint32_t) + * - Security version of the enclave. (ISVN for SGX). + * - attributes (uint64_t) + * - Attributes flags for the evidence: + * - OE_REPORT_ATTRIBUTES_DEBUG: The evidence is for a debug enclave. + * - OE_REPORT_ATTRIBUTES_REMOTE: The evidence can be used for remote + * attestation. + * - unique_id (uint8_t[32]) + * - The unique ID for the enclave (MRENCLAVE for SGX). + * - signer_id (uint8_t[32]) + * - The signer ID for the enclave (MRSIGNER for SGX). + * - product_id (uint8_t[32]) + * - The product ID for the enclave (ISVPRODID for SGX). + * - validity_from (oe_datetime_t, optional) + * - Overall datetime from which the evidence and endorsements are valid. + * - validity_until (oe_datetime_t, optional) + * - Overall datetime at which the evidence and endorsements expire. + * - plugin_uuid (uint8_t[16]) + * - The UUID of the plugin used to verify the evidence. + * + * @param[in] evidence_buffer The evidence buffer. + * @param[in] evidence_buffer_size The size of evidence_buffer in bytes. + * @param[in] endorsements_buffer The optional endorsements buffer. + * @param[in] endorsements_buffer_size The size of endorsements_buffer in bytes. + * @param[in] policies An optional list of policies to use. + * @param[in] policies_size The size of the policy list. + * @param[out] claims The list of claims. + * @param[out] claims_length The length of the claims list. + * @retval OE_OK The function succeeded. + * @retval OE_INVALID_PARAMTER Atleast one of the parameters is invalid. + * @retval OE_NOT_FOUND The plugin does not exist or has not been registered. + * @retval OE_CONSTRAINT_FAILED The UUIDs of the evidence and endorsements + * differ. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_verify_evidence( + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length); + +/** + * oe_free_claims_list + * + * Frees a claims list. + * + * @param[in] claims The list of claims. + * @param[in] claims_length The length of the claims list. + * @retval OE_OK The function succeeded. + * @retval OE_NOT_FOUND The plugin that generated the claims does not exist or + * has not been registered, so the claims can't be freed. + * @retval Otherwise, returns the error code the plugin's function. + */ +oe_result_t oe_free_claims_list(oe_claim_t* claims, size_t claims_length); + +OE_EXTERNC_END + +#endif /* _OE_ATTESTATION_PLUGIN_H */ diff --git a/include/openenclave/attestation/sgx/attester.h b/include/openenclave/attestation/sgx/attester.h new file mode 100644 index 0000000000..82a0b5b727 --- /dev/null +++ b/include/openenclave/attestation/sgx/attester.h @@ -0,0 +1,40 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +/** + * @file attester.h + * + * This file defines the API for getting the SGX attester. + * + */ + +#ifndef _OE_ATTESTATION_SGX_ATTESTER_H +#define _OE_ATTESTATION_SGX_ATTESTER_H + +#ifdef _OE_HOST_H +#error "The sgx attester (sgx/attester.h) is only available for the enclave." +#endif + +#include + +OE_EXTERNC_BEGIN + +/** + * The `opt_params` field for `oe_get_evidence` identical to the `opt_params` + * field `oe_get_report`. In other words, it is the output of + * `oe_get_target_info` for local attestation and is ignored for remote + * attestation. + */ +typedef void* oe_sgx_plugin_opt_params; + +/** + * Helper function that returns the SGX attester that can then be sent to + * `oe_register_attester`. + * + * @retval A pointer to the SGX attester. This function never fails. + */ +oe_attester_t* oe_sgx_plugin_attester(void); + +OE_EXTERNC_END + +#endif /* _OE_ATTESTATION_SGX_ATTESTER_H */ diff --git a/include/openenclave/attestation/sgx/verifier.h b/include/openenclave/attestation/sgx/verifier.h new file mode 100644 index 0000000000..4b767d50f8 --- /dev/null +++ b/include/openenclave/attestation/sgx/verifier.h @@ -0,0 +1,28 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +/** + * @file verifier.h + * + * This file defines the API for getting the SGX verifier. + * + */ + +#ifndef _OE_ATTESTATION_SGX_VERIFIER_H +#define _OE_ATTESTATION_SGX_VERIFIER_H + +#include + +OE_EXTERNC_BEGIN + +/** + * Helper function that returns the SGX verifier that can then be sent to + * `oe_register_verifier`. + * + * @retval A pointer to the SGX verifier. This function never fails. + */ +oe_verifier_t* oe_sgx_plugin_verifier(void); + +OE_EXTERNC_END + +#endif /* _OE_ATTESTATION_SGX_ATTESTER_H */ diff --git a/include/openenclave/bits/attestation.h b/include/openenclave/bits/attestation.h new file mode 100644 index 0000000000..86aa996131 --- /dev/null +++ b/include/openenclave/bits/attestation.h @@ -0,0 +1,96 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +/** + * @file attestation.h + * + * This file defines structures and options passed to attestation functions. + * + */ +#ifndef _OE_BITS_ATTESTATION_H +#define _OE_BITS_ATTESTATION_H + +#include +#include + +/** + * Flags passed to oe_get_evidence() function. + */ +#define OE_EVIDENCE_FLAGS_LOCAL_ATTESTATION 0x00000000 +#define OE_EVIDENCE_FLAGS_REMOTE_ATTESTATION 0x00000001 + +/*! Limit the size of the endorsements */ +#define OE_ATTESTATION_ENDORSEMENT_MAX_SIZE (20 * 1024) + +/*! Endorsement structure version */ +#define OE_ATTESTATION_ENDORSEMENT_VERSION (1) + +/*! \struct oe_endorsements_t + * + * \brief OE endorsements + * + * Raw generic serializable structure that contains the endorsements. All + * data should be in little endian format. + * + */ +typedef struct _oe_endorsements_t +{ + uint32_t version; ///< Version of this structure + uint32_t enclave_type; ///< The type of enclave (oe_enclave_type_t) + uint32_t buffer_size; ///< Size of the buffer + uint32_t num_elements; ///< Number of elements stored in the data buffer + + /*! Data buffer is made of an offset array of type uint32_t, followed by + * the actual data. + * This array has the size of **num_elements** and stores the offset + * into the data section. + * _________________________ + * | version | + * |-----------------------| + * | enclave_type | + * |-----------------------| + * | buffer_size | + * |-----------------------| + * | num_elements | + * |-----------------------| + * | offsets | + * | (array of uint32_t | + * | with length of | + * | num_elements) | + * |-----------------------| + * | buffer (data) | + * |_______________________| + */ + uint8_t buffer[]; ///< Buffer of offsets + data + +} oe_endorsements_t; +/**< typedef struct _oe_endorsements_t */ + +/*! Version of the supported SGX endorsement structures */ +#define OE_SGX_ENDORSEMENTS_VERSION (1) + +/*! Number of CRLs in the SGX endorsements */ +#define OE_SGX_ENDORSEMENTS_CRL_COUNT (2) + +/*! \enum oe_sgx_endorsements_fields + * + * Specifies the order of the SGX endorsements fields stored in + * the oe_endorsements_t structure + */ +typedef enum _oe_sgx_endorsements_fields_t +{ + OE_SGX_ENDORSEMENT_FIELD_VERSION, + OE_SGX_ENDORSEMENT_FIELD_TCB_INFO, + OE_SGX_ENDORSEMENT_FIELD_TCB_ISSUER_CHAIN, + OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_CERT, + OE_SGX_ENDORSEMENT_FIELD_CRL_PCK_PROC_CA, + OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_CERT, + OE_SGX_ENDORSEMENT_FIELD_CRL_ISSUER_CHAIN_PCK_PROC_CA, + OE_SGX_ENDORSEMENT_FIELD_QE_ID_INFO, + OE_SGX_ENDORSEMENT_FIELD_QE_ID_ISSUER_CHAIN, + OE_SGX_ENDORSEMENT_FIELD_CREATION_DATETIME, + OE_SGX_ENDORSEMENT_COUNT + +} oe_sgx_endorsements_fields_t; + +#endif /* _OE_BITS_ATTESTATION_H */ diff --git a/include/openenclave/bits/defs.h b/include/openenclave/bits/defs.h index 7e5bdcacf6..70c9633aba 100644 --- a/include/openenclave/bits/defs.h +++ b/include/openenclave/bits/defs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_DEFS_H @@ -51,6 +51,12 @@ #define OE_INLINE static __inline__ #endif +#if defined(__GNUC__) || defined(__clang__) +#define OE_RETURNS_TWICE __attribute__((returns_twice)) +#else +#define OE_RETURNS_TWICE +#endif + #ifdef _MSC_VER #define OE_NO_OPTIMIZE_BEGIN __pragma(optimize("", off)) #define OE_NO_OPTIMIZE_END __pragma(optimize("", on)) diff --git a/include/openenclave/bits/eeid.h b/include/openenclave/bits/eeid.h new file mode 100644 index 0000000000..6924ab73e9 --- /dev/null +++ b/include/openenclave/bits/eeid.h @@ -0,0 +1,48 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +/** + * @file eeid.h + * + * This file defines the EEID structure. + * + */ + +#ifndef _OE_BITS_EEID_H +#define _OE_BITS_EEID_H + +#include "properties.h" + +OE_EXTERNC_BEGIN + +/* +**============================================================================== +** +** oe_eeid_t +** +**============================================================================== +*/ +typedef struct oe_eeid_t_ +{ + uint32_t hash_state_H[8]; + uint32_t hash_state_N[2]; + uint8_t sigstruct[1808]; /* complete sigstruct before eeid */ + oe_enclave_size_settings_t size_settings; /* new size settings */ + uint64_t data_size; /* size of initialization data */ + uint64_t data_vaddr; /* location of initialization data */ + uint8_t data[]; /* actual initialization data */ +} oe_eeid_t; + +oe_result_t oe_serialize_eeid( + const oe_eeid_t* eeid, + char* buf, + size_t buf_size); + +oe_result_t oe_deserialize_eeid( + const char* buf, + size_t buf_size, + oe_eeid_t* eeid); + +OE_EXTERNC_END + +#endif /* _OE_BITS_EEID_H */ diff --git a/include/openenclave/bits/exception.h b/include/openenclave/bits/exception.h index 6e4e16f3dd..2bda489e11 100644 --- a/include/openenclave/bits/exception.h +++ b/include/openenclave/bits/exception.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/bits/fs.h b/include/openenclave/bits/fs.h index 6ed53c1c17..f7220c44f6 100644 --- a/include/openenclave/bits/fs.h +++ b/include/openenclave/bits/fs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_FS_H diff --git a/include/openenclave/bits/module.h b/include/openenclave/bits/module.h index 9cca479894..09bdef92e0 100644 --- a/include/openenclave/bits/module.h +++ b/include/openenclave/bits/module.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/bits/optee/opteeproperties.h b/include/openenclave/bits/optee/opteeproperties.h index 79531eaa3e..2d7f6d7346 100644 --- a/include/openenclave/bits/optee/opteeproperties.h +++ b/include/openenclave/bits/optee/opteeproperties.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // Additional copyrights follow: diff --git a/include/openenclave/bits/properties.h b/include/openenclave/bits/properties.h index a2cbf35eda..fb4e1841dc 100644 --- a/include/openenclave/bits/properties.h +++ b/include/openenclave/bits/properties.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/bits/report.h b/include/openenclave/bits/report.h index 1f09fc09f7..aac7722f67 100644 --- a/include/openenclave/bits/report.h +++ b/include/openenclave/bits/report.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -136,6 +136,75 @@ typedef struct _oe_report } oe_report_t; /**< typedef struct _oe_report oe_report_t*/ +/** + * The size of a UUID in bytes. + */ +#define OE_UUID_SIZE 16 + +/** + * Struct containing the definition for an UUID. + */ +typedef struct _oe_uuid_t +{ + uint8_t b[OE_UUID_SIZE]; +} oe_uuid_t; + +/** + * Claims struct used for claims parameters for the attestation plugins. + */ +typedef struct _oe_claim +{ + char* name; + uint8_t* value; + size_t value_size; +} oe_claim_t; + +/** + * Claims that are known to OE that every attestation plugin should output. + */ +#define OE_CLAIM_ID_VERSION "id_version" +#define OE_CLAIM_SECURITY_VERSION "security_version" +#define OE_CLAIM_ATTRIBUTES "attributes" +#define OE_CLAIM_UNIQUE_ID "unique_id" +#define OE_CLAIM_SIGNER_ID "signer_id" +#define OE_CLAIM_PRODUCT_ID "product_id" +#define OE_CLAIM_PLUGIN_UUID "plugin_uuid" +#define OE_REQUIRED_CLAIMS_COUNT 7 +extern const char* OE_REQUIRED_CLAIMS[OE_REQUIRED_CLAIMS_COUNT]; + +/** + * Additional optional claims that are known to OE that plugins can output. + */ +#define OE_CLAIM_VALIDITY_FROM "validity_from" +#define OE_CLAIM_VALIDITY_UNTIL "validity_until" +#define OE_OPTIONAL_CLAIMS_COUNT 2 +extern const char* OE_OPTIONAL_CLAIMS[OE_OPTIONAL_CLAIMS_COUNT]; + +/** + * Supported policies for validation by the verifier attestation plugin. + * Only time is supported for now. + */ +typedef enum _oe_policy_type +{ + /** + * Enforces that time fields in the endorsements will be checked in + * with the given time rather than the endorsement creation time. + * + * The policy will be in the form of `oe_datetime_t`. + */ + OE_POLICY_ENDORSEMENTS_TIME = 1 +} oe_policy_type_t; + +/** + * Generic struct for defining policy for the attestation plugins. + */ +typedef struct _oe_policy +{ + oe_policy_type_t type; + void* policy; + size_t policy_size; +} oe_policy_t; + OE_EXTERNC_END #endif /* _OE_BITS_REPORT_H */ diff --git a/include/openenclave/bits/result.h b/include/openenclave/bits/result.h index 77aef25bde..514228e984 100644 --- a/include/openenclave/bits/result.h +++ b/include/openenclave/bits/result.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -279,6 +279,11 @@ typedef enum _oe_result */ OE_VERIFY_REVOKED, + /** + * Could not find a valid validity period. + */ + OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD, + /** * An underlying crypto provider returned an error. */ @@ -314,6 +319,26 @@ typedef enum _oe_result */ OE_VERIFY_FAILED_AES_CMAC_MISMATCH, + /** + * Failed to post a switchless call to host workers + */ + OE_CONTEXT_SWITCHLESS_OCALL_MISSED, + + /** + * Thread creation failed. + */ + OE_THREAD_CREATE_ERROR, + + /** + * Thread join failed. + */ + OE_THREAD_JOIN_ERROR, + + /** + * The desired resource already exists. + */ + OE_ALREADY_EXISTS, + __OE_RESULT_MAX = OE_ENUM_MAX, } oe_result_t; /**< typedef enum _oe_result oe_result_t*/ diff --git a/include/openenclave/bits/safecrt.h b/include/openenclave/bits/safecrt.h index fd9a427cd1..f429c6702d 100644 --- a/include/openenclave/bits/safecrt.h +++ b/include/openenclave/bits/safecrt.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SAFECRT_H diff --git a/include/openenclave/bits/safemath.h b/include/openenclave/bits/safemath.h index 995706b533..789d216679 100644 --- a/include/openenclave/bits/safemath.h +++ b/include/openenclave/bits/safemath.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SAFEMATH_H diff --git a/include/openenclave/bits/sgx/sgxproperties.h b/include/openenclave/bits/sgx/sgxproperties.h index 826a85d21c..3dd2aa8ec5 100644 --- a/include/openenclave/bits/sgx/sgxproperties.h +++ b/include/openenclave/bits/sgx/sgxproperties.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/bits/types.h b/include/openenclave/bits/types.h index 9b06060025..c807c56841 100644 --- a/include/openenclave/bits/types.h +++ b/include/openenclave/bits/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -224,4 +224,17 @@ typedef struct _oe_asymmetric_key_params size_t user_data_size; } oe_asymmetric_key_params_t; +/** + * This struct defines a datetime up to 1 second precision. + */ +typedef struct _oe_datetime +{ + uint32_t year; /* format: 1970, 2018, 2020 */ + uint32_t month; /* range: 1-12 */ + uint32_t day; /* range: 1-31 */ + uint32_t hours; /* range: 0-23 */ + uint32_t minutes; /* range: 0-59 */ + uint32_t seconds; /* range: 0-59 */ +} oe_datetime_t; + #endif /* _OE_BITS_TYPES_H */ diff --git a/include/openenclave/corelibc/assert.h b/include/openenclave/corelibc/assert.h index 95f235b5aa..6f015d60b3 100644 --- a/include/openenclave/corelibc/assert.h +++ b/include/openenclave/corelibc/assert.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ASSERT_H diff --git a/include/openenclave/corelibc/bits/atexit.h b/include/openenclave/corelibc/bits/atexit.h index 1be51037b3..e47fc4518e 100644 --- a/include/openenclave/corelibc/bits/atexit.h +++ b/include/openenclave/corelibc/bits/atexit.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_ATEXIT_H diff --git a/include/openenclave/corelibc/bits/defs.h b/include/openenclave/corelibc/bits/defs.h index cb5c20b0b0..d0af6f8cc3 100644 --- a/include/openenclave/corelibc/bits/defs.h +++ b/include/openenclave/corelibc/bits/defs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CORELIBC_BITS_DEFS_H diff --git a/include/openenclave/corelibc/bits/jmp_buf.h b/include/openenclave/corelibc/bits/jmp_buf.h index a5a84fb3f9..9b2a7c5dc8 100644 --- a/include/openenclave/corelibc/bits/jmp_buf.h +++ b/include/openenclave/corelibc/bits/jmp_buf.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* These are the registers that are preserved across function calls diff --git a/include/openenclave/corelibc/bits/malloc.h b/include/openenclave/corelibc/bits/malloc.h index a4f459004a..3e2ee6191b 100644 --- a/include/openenclave/corelibc/bits/malloc.h +++ b/include/openenclave/corelibc/bits/malloc.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_MALLOC_H @@ -40,4 +40,10 @@ int posix_memalign(void** memptr, size_t alignment, size_t size) return oe_posix_memalign(memptr, alignment, size); } +OE_INLINE +size_t malloc_usable_size(void* ptr) +{ + return oe_malloc_usable_size(ptr); +} + #endif /* _OE_BITS_MALLOC_H */ diff --git a/include/openenclave/corelibc/bits/pthread_cond.h b/include/openenclave/corelibc/bits/pthread_cond.h index 06416eede0..696a409af1 100644 --- a/include/openenclave/corelibc/bits/pthread_cond.h +++ b/include/openenclave/corelibc/bits/pthread_cond.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_COND_H diff --git a/include/openenclave/corelibc/bits/pthread_create.h b/include/openenclave/corelibc/bits/pthread_create.h index 1d88545b42..8cc1a936fb 100644 --- a/include/openenclave/corelibc/bits/pthread_create.h +++ b/include/openenclave/corelibc/bits/pthread_create.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_CREATE_H diff --git a/include/openenclave/corelibc/bits/pthread_def.h b/include/openenclave/corelibc/bits/pthread_def.h index 7869c362d9..b3202cb356 100644 --- a/include/openenclave/corelibc/bits/pthread_def.h +++ b/include/openenclave/corelibc/bits/pthread_def.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_DEF_H diff --git a/include/openenclave/corelibc/bits/pthread_equal.h b/include/openenclave/corelibc/bits/pthread_equal.h index 5801f2621a..a695a905dc 100644 --- a/include/openenclave/corelibc/bits/pthread_equal.h +++ b/include/openenclave/corelibc/bits/pthread_equal.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_EQUAL_H diff --git a/include/openenclave/corelibc/bits/pthread_key.h b/include/openenclave/corelibc/bits/pthread_key.h index 05375e7827..936dab0f57 100644 --- a/include/openenclave/corelibc/bits/pthread_key.h +++ b/include/openenclave/corelibc/bits/pthread_key.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_KEY_H diff --git a/include/openenclave/corelibc/bits/pthread_mutex.h b/include/openenclave/corelibc/bits/pthread_mutex.h index 3a60680654..4995a618a8 100644 --- a/include/openenclave/corelibc/bits/pthread_mutex.h +++ b/include/openenclave/corelibc/bits/pthread_mutex.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_MUTEX_H diff --git a/include/openenclave/corelibc/bits/pthread_once.h b/include/openenclave/corelibc/bits/pthread_once.h index a2a10a60c6..df7f413751 100644 --- a/include/openenclave/corelibc/bits/pthread_once.h +++ b/include/openenclave/corelibc/bits/pthread_once.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_ONCE_H diff --git a/include/openenclave/corelibc/bits/pthread_rwlock.h b/include/openenclave/corelibc/bits/pthread_rwlock.h index 35140756fb..adfaffb892 100644 --- a/include/openenclave/corelibc/bits/pthread_rwlock.h +++ b/include/openenclave/corelibc/bits/pthread_rwlock.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_RWLOCK_H diff --git a/include/openenclave/corelibc/bits/pthread_spin.h b/include/openenclave/corelibc/bits/pthread_spin.h index 70d9907596..bcaa949671 100644 --- a/include/openenclave/corelibc/bits/pthread_spin.h +++ b/include/openenclave/corelibc/bits/pthread_spin.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_PTHREAD_SPIN_H diff --git a/include/openenclave/corelibc/bits/stdfile.h b/include/openenclave/corelibc/bits/stdfile.h index 94f67700c1..bee2a820ba 100644 --- a/include/openenclave/corelibc/bits/stdfile.h +++ b/include/openenclave/corelibc/bits/stdfile.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_STDFILE_H diff --git a/include/openenclave/corelibc/bits/strtoul.h b/include/openenclave/corelibc/bits/strtoul.h index 5b2ad761cc..96acd49e35 100644 --- a/include/openenclave/corelibc/bits/strtoul.h +++ b/include/openenclave/corelibc/bits/strtoul.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BITS_STRTOUL_H diff --git a/include/openenclave/corelibc/bits/types.h b/include/openenclave/corelibc/bits/types.h index 384919662f..1e86e0cbee 100644 --- a/include/openenclave/corelibc/bits/types.h +++ b/include/openenclave/corelibc/bits/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CORELIBC_BITS_TYPES_H diff --git a/include/openenclave/corelibc/ctype.h b/include/openenclave/corelibc/ctype.h index f531c2d77f..d1f2dba6fe 100644 --- a/include/openenclave/corelibc/ctype.h +++ b/include/openenclave/corelibc/ctype.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CTYPE_H diff --git a/include/openenclave/corelibc/endian.h b/include/openenclave/corelibc/endian.h index 23332f478c..6d7b91e446 100644 --- a/include/openenclave/corelibc/endian.h +++ b/include/openenclave/corelibc/endian.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* This header is a dependency for directly compiling MUSL memcpy diff --git a/include/openenclave/corelibc/errno.h b/include/openenclave/corelibc/errno.h index ac8e1198fa..eb44232351 100644 --- a/include/openenclave/corelibc/errno.h +++ b/include/openenclave/corelibc/errno.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ERRNO_H @@ -153,6 +153,7 @@ OE_EXTERNC_BEGIN #define OE_ENOTRECOVERABLE 131 #define OE_ERFKILL 132 #define OE_EHWPOISON 133 +#define OE_EPROCLIM 134 // clang-format on extern int* __oe_errno_location(void); diff --git a/include/openenclave/corelibc/inttypes.h b/include/openenclave/corelibc/inttypes.h index d194bed477..cb1923a6f4 100644 --- a/include/openenclave/corelibc/inttypes.h +++ b/include/openenclave/corelibc/inttypes.h @@ -1,2 +1,2 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. diff --git a/include/openenclave/corelibc/limits.h b/include/openenclave/corelibc/limits.h index 686335873e..2f3020534c 100644 --- a/include/openenclave/corelibc/limits.h +++ b/include/openenclave/corelibc/limits.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_LIMITS_H diff --git a/include/openenclave/corelibc/pthread.h b/include/openenclave/corelibc/pthread.h index db8748ef4c..6a65aa40d7 100644 --- a/include/openenclave/corelibc/pthread.h +++ b/include/openenclave/corelibc/pthread.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_PTHREAD_H diff --git a/include/openenclave/corelibc/sched.h b/include/openenclave/corelibc/sched.h index f89204cbb1..c23eb55320 100644 --- a/include/openenclave/corelibc/sched.h +++ b/include/openenclave/corelibc/sched.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SCHED_H diff --git a/include/openenclave/corelibc/setjmp.h b/include/openenclave/corelibc/setjmp.h index e5659359fb..a5e82303ae 100644 --- a/include/openenclave/corelibc/setjmp.h +++ b/include/openenclave/corelibc/setjmp.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SETJMP_H @@ -6,6 +6,7 @@ #include #include +#include /* **============================================================================== @@ -21,7 +22,7 @@ #undef ___OE_JMP_BUF #undef __OE_JMP_BUF -int oe_setjmp(oe_jmp_buf* env); +int oe_setjmp(oe_jmp_buf* env) OE_RETURNS_TWICE; void oe_longjmp(oe_jmp_buf* env, int val); diff --git a/include/openenclave/corelibc/stdarg.h b/include/openenclave/corelibc/stdarg.h index d1c7160db1..b671aaa2c4 100644 --- a/include/openenclave/corelibc/stdarg.h +++ b/include/openenclave/corelibc/stdarg.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STDARG_H diff --git a/include/openenclave/corelibc/stdbool.h b/include/openenclave/corelibc/stdbool.h index b4ccf603aa..315038a9fb 100644 --- a/include/openenclave/corelibc/stdbool.h +++ b/include/openenclave/corelibc/stdbool.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STDBOOL_H diff --git a/include/openenclave/corelibc/stddef.h b/include/openenclave/corelibc/stddef.h index 7f31c61d6d..c37ff05acd 100644 --- a/include/openenclave/corelibc/stddef.h +++ b/include/openenclave/corelibc/stddef.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STDDEF_H diff --git a/include/openenclave/corelibc/stdint.h b/include/openenclave/corelibc/stdint.h index 4330bbf430..320960b796 100644 --- a/include/openenclave/corelibc/stdint.h +++ b/include/openenclave/corelibc/stdint.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STDINT_H diff --git a/include/openenclave/corelibc/stdio.h b/include/openenclave/corelibc/stdio.h index 8c86ccc604..3d9ec1335e 100644 --- a/include/openenclave/corelibc/stdio.h +++ b/include/openenclave/corelibc/stdio.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STDIO_H diff --git a/include/openenclave/corelibc/stdlib.h b/include/openenclave/corelibc/stdlib.h index e57ce8bd43..aca5654ee3 100644 --- a/include/openenclave/corelibc/stdlib.h +++ b/include/openenclave/corelibc/stdlib.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STDLIB_H @@ -37,6 +37,8 @@ void* oe_memalign(size_t alignment, size_t size); int oe_posix_memalign(void** memptr, size_t alignment, size_t size); +size_t oe_malloc_usable_size(void* ptr); + unsigned long int oe_strtoul(const char* nptr, char** endptr, int base); long int oe_strtol(const char* nptr, char** endptr, int base); diff --git a/include/openenclave/corelibc/string.h b/include/openenclave/corelibc/string.h index 886b2d9e0a..13525b7b5d 100644 --- a/include/openenclave/corelibc/string.h +++ b/include/openenclave/corelibc/string.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STRING_H diff --git a/include/openenclave/corelibc/time.h b/include/openenclave/corelibc/time.h index d29636799b..20a49a4632 100644 --- a/include/openenclave/corelibc/time.h +++ b/include/openenclave/corelibc/time.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TIME_H diff --git a/include/openenclave/corelibc/wchar.h b/include/openenclave/corelibc/wchar.h index d194bed477..cb1923a6f4 100644 --- a/include/openenclave/corelibc/wchar.h +++ b/include/openenclave/corelibc/wchar.h @@ -1,2 +1,2 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. diff --git a/include/openenclave/edger8r/common.h b/include/openenclave/edger8r/common.h index 73aa6d52d4..39f5391e74 100644 --- a/include/openenclave/edger8r/common.h +++ b/include/openenclave/edger8r/common.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -66,14 +66,24 @@ OE_INLINE oe_result_t oe_add_size(size_t* total, size_t size) return result; } -#define OE_ADD_SIZE(total, size) \ - do \ - { \ - if (oe_add_size(&total, size) != OE_OK) \ - { \ - _result = OE_INTEGER_OVERFLOW; \ - goto done; \ - } \ +#define OE_ADD_SIZE(total, size) \ + do \ + { \ + if (sizeof(total) > sizeof(size_t) && total > SIZE_MAX) \ + { \ + _result = OE_INVALID_PARAMETER; \ + goto done; \ + } \ + if (sizeof(size) > sizeof(size_t) && size > SIZE_MAX) \ + { \ + _result = OE_INVALID_PARAMETER; \ + goto done; \ + } \ + if (oe_add_size((size_t*)&total, (size_t)size) != OE_OK) \ + { \ + _result = OE_INTEGER_OVERFLOW; \ + goto done; \ + } \ } while (0) /** diff --git a/include/openenclave/edger8r/enclave.h b/include/openenclave/edger8r/enclave.h index a502fba0a7..27f88699f6 100644 --- a/include/openenclave/edger8r/enclave.h +++ b/include/openenclave/edger8r/enclave.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/edger8r/host.h b/include/openenclave/edger8r/host.h index 7b9907d33f..2ac11b0ed8 100644 --- a/include/openenclave/edger8r/host.h +++ b/include/openenclave/edger8r/host.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/enclave.h b/include/openenclave/enclave.h index 5c89747324..4e6272e5e5 100644 --- a/include/openenclave/enclave.h +++ b/include/openenclave/enclave.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -385,6 +385,13 @@ oe_result_t oe_verify_report( size_t report_size, oe_report_t* parsed_report); +struct oe_eeid_t_; +oe_result_t oe_verify_report_eeid( + const uint8_t* report, + size_t report_size, + oe_report_t* parsed_report, + struct oe_eeid_t_* eeid); + #if (OE_API_VERSION < 2) #error "Only OE_API_VERSION of 2 is supported" #else diff --git a/include/openenclave/host.h b/include/openenclave/host.h index 45172e0c89..7f62c4ce49 100644 --- a/include/openenclave/host.h +++ b/include/openenclave/host.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -50,6 +50,7 @@ OE_EXTERNC_BEGIN */ #define OE_ENCLAVE_FLAG_RESERVED \ (~(OE_ENCLAVE_FLAG_DEBUG | OE_ENCLAVE_FLAG_SIMULATE)) + /** * @endcond */ @@ -64,6 +65,53 @@ typedef void (*oe_ocall_func_t)( size_t output_buffer_size, size_t* output_bytes_written); +/** + * Types of settings passed into **oe_create_enclave** + */ +typedef enum _oe_enclave_setting_type +{ + OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS = 0xdc73a628, +} oe_enclave_setting_type_t; + +/** + * The setting for context-switchless calls. + */ +typedef struct _oe_enclave_setting_context_switchless +{ + /** + * The max number of worker threads for context-switchless ocalls. + * The actual number of threads launched could be capped for performance + * reasons. + */ + size_t max_host_workers; + /** + * Context-switchless ecalls are not enabled yet. The max number of enclave + * workers should be 0. + */ + size_t max_enclave_workers; +} oe_enclave_setting_context_switchless_t; + +/** + * The uniform structure type containing a specific type of enclave + * setting. + */ +typedef struct _oe_enclave_setting +{ + /** + * The type of the setting in **u** + */ + oe_enclave_setting_type_t setting_type; + /** + * The specific setting for the enclave, such as for configuring + * context-switchless calls. + */ + union { + const oe_enclave_setting_context_switchless_t* + context_switchless_setting; + /* Add new setting types here. */ + } u; +} oe_enclave_setting_t; + /** * Create an enclave from an enclave image file. * @@ -83,15 +131,15 @@ typedef void (*oe_ocall_func_t)( * - OE_ENCLAVE_FLAG_DEBUG - runs the enclave in debug mode. * DO NOT SHIP CODE with this flag * - * @param config Additional enclave creation configuration data for the specific - * enclave type. This parameter is reserved and must be NULL. + * @param settings Array of additional enclave creation settings for the + * specific enclave type. * - * @param config_size The size of the **config** data buffer in bytes. + * @param setting_count The number of settings in the **settings**. * * @param ocall_table Pointer to table of ocall functions generated by * oeedger8r. * - * @param ocall_table_size The size of the **ocall_table**. + * @param ocall_count The number of functions in the **ocall_table**. * * @param enclave This points to the enclave instance upon success. * @@ -102,10 +150,59 @@ oe_result_t oe_create_enclave( const char* path, oe_enclave_type_t type, uint32_t flags, - const void* config, - uint32_t config_size, + const oe_enclave_setting_t* settings, + uint32_t setting_count, + const oe_ocall_func_t* ocall_table, + uint32_t ocall_count, + oe_enclave_t** enclave); + +/** + * Create an enclave from an enclave image file with extended enclave + * initialization data. + * + * This function creates an enclave from an enclave image file. On successful + * return, the enclave is fully initialized and ready to use. + * + * @param path The path of an enclave image file in ELF-64 format. This + * file must have been linked with the **oecore** library and signed by the + * **oesign** tool. + * + * @param type The type of enclave supported by the enclave image file. + * - OE_ENCLAVE_TYPE_SGX - An SGX enclave + * + * @param flags These flags control how the enclave is run. + * It is the bitwise OR of zero or more of the following flags + * - OE_ENCLAVE_FLAG_SIMULATE - runs the enclave in simulation mode + * - OE_ENCLAVE_FLAG_DEBUG - runs the enclave in debug mode. + * DO NOT SHIP CODE with this flag + * + * @param settings Array of additional enclave creation settings for the + * specific enclave type. + * + * @param setting_count The number of settings in the **settings**. + * + * @param ocall_table Pointer to table of ocall functions generated by + * oeedger8r. + * + * @param ocall_count The number of functions in the **ocall_table**. + * + * @param eeid Optional user data for attestation. + * + * @param enclave This points to the enclave instance upon success. + * + * @returns Returns OE_OK on success. + * + */ +struct oe_eeid_t_; +oe_result_t oe_create_enclave_eeid( + const char* path, + oe_enclave_type_t type, + uint32_t flags, + const oe_enclave_setting_t* settings, + uint32_t setting_count, const oe_ocall_func_t* ocall_table, - uint32_t ocall_table_size, + uint32_t ocall_count, + struct oe_eeid_t_* eeid, oe_enclave_t** enclave); /** @@ -247,6 +344,14 @@ oe_result_t oe_verify_report( size_t report_size, oe_report_t* parsed_report); +struct oe_eeid_t_; +oe_result_t oe_verify_report_eeid( + oe_enclave_t* enclave, + const uint8_t* report, + size_t report_size, + oe_report_t* parsed_report, + struct oe_eeid_t_* eeid); + /** * Returns a public key that is associated with the identity of the enclave * and the specified policy. diff --git a/include/openenclave/host_verify.h b/include/openenclave/host_verify.h index dad2758224..fca849a76a 100644 --- a/include/openenclave/host_verify.h +++ b/include/openenclave/host_verify.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** @@ -32,6 +32,10 @@ OE_EXTERNC_BEGIN * @param report_size The size of the **report** buffer. * @param parsed_report Optional **oe_report_t** structure to populate * with the report properties in a standard format. + * @param[out] endorsements An optional output pointer that will be assigned + * the address of the endorsements buffer. + * @param[out] endorsements_size A pointer that points to the size of + * the endorsements buffer in bytes. * * @retval OE_OK The report was successfully verified. * @retval OE_INVALID_PARAMETER At least one parameter is invalid. @@ -40,6 +44,8 @@ OE_EXTERNC_BEGIN oe_result_t oe_verify_remote_report( const uint8_t* report, size_t report_size, + const uint8_t* endorsement, + size_t endorsement_size, oe_report_t* parsed_report); /** diff --git a/include/openenclave/internal/aesm.h b/include/openenclave/internal/aesm.h deleted file mode 100644 index 29a9b14aa5..0000000000 --- a/include/openenclave/internal/aesm.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#ifndef _OE_AESM_H -#define _OE_AESM_H - -#include -#include -#include "sgxtypes.h" - -OE_EXTERNC_BEGIN - -typedef struct _aesm aesm_t; -typedef struct _sgx_target_info sgx_target_info_t; -typedef struct _sgx_epid_group_id sgx_epid_group_id_t; - -aesm_t* aesm_connect(void); - -void aesm_disconnect(aesm_t* aesm); - -oe_result_t aesm_get_launch_token( - aesm_t* aesm, - uint8_t mrenclave[OE_SHA256_SIZE], - uint8_t modulus[OE_KEY_SIZE], - const sgx_attributes_t* attributes, - sgx_launch_token_t* launch_token); - -oe_result_t aesm_init_quote( - aesm_t* aesm, - sgx_target_info_t* target_info, - sgx_epid_group_id_t* epid_group_id); - -oe_result_t aesm_get_quote( - aesm_t* aesm, - const sgx_report_t* report, - sgx_quote_type_t quote_type, - const sgx_spid_t* spid, - const sgx_nonce_t* nonce, - const uint8_t* signature_revocation_list, - uint32_t signature_revocation_list_size, - sgx_report_t* report_out, - sgx_quote_t* quote, - size_t quote_size); - -OE_EXTERNC_END - -#endif /* _OE_AESM_H */ diff --git a/include/openenclave/internal/argv.h b/include/openenclave/internal/argv.h index 0defdea2cf..9738dfc868 100644 --- a/include/openenclave/internal/argv.h +++ b/include/openenclave/internal/argv.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_ARGV_H diff --git a/include/openenclave/internal/asn1.h b/include/openenclave/internal/asn1.h index 107f3350ae..b9a0cd6870 100644 --- a/include/openenclave/internal/asn1.h +++ b/include/openenclave/internal/asn1.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/internal/atomic.h b/include/openenclave/internal/atomic.h index 754babeddf..8e947c808c 100644 --- a/include/openenclave/internal/atomic.h +++ b/include/openenclave/internal/atomic.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ATOMIC_H @@ -10,8 +10,18 @@ #if defined(_MSC_VER) #pragma intrinsic(_InterlockedIncrement64) #pragma intrinsic(_InterlockedDecrement64) +#pragma intrinsic(_InterlockedCompareExchange64) +#pragma intrinsic(_InterlockedCompareExchangePointer) __int64 _InterlockedIncrement64(__int64* lpAddend); __int64 _InterlockedDecrement64(__int64* lpAddend); +__int64 _InterlockedCompareExchange64( + __int64 volatile* Dest, + __int64 val, + __int64 old); +void* _InterlockedCompareExchangePointer( + void* volatile* Dest, + void* newptr, + void* old); #endif /* Atomically increment **x** and return its new value */ @@ -38,4 +48,36 @@ OE_INLINE uint64_t oe_atomic_decrement(volatile uint64_t* x) #endif } +OE_INLINE +bool oe_atomic_compare_and_swap( + int64_t volatile* dest, + int64_t old, + int64_t newval) +{ +#if defined(__GNUC__) + return __atomic_compare_exchange_n( + dest, &old, newval, 1, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); +#elif defined(_MSC_VER) + return _InterlockedCompareExchange64(dest, newval, old) == old; +#else +#error "unsupported" +#endif +} + +OE_INLINE +bool oe_atomic_compare_and_swap_ptr( + void* volatile* dest, + void* old, + void* newptr) +{ +#if defined(__GNUC__) + return __atomic_compare_exchange_n( + dest, &old, newptr, 1, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE); +#elif defined(_MSC_VER) + return _InterlockedCompareExchangePointer(dest, newptr, old) == old; +#else +#error "unsupported" +#endif +} + #endif /* _OE_ATOMIC_H */ diff --git a/include/openenclave/internal/backtrace.h b/include/openenclave/internal/backtrace.h index 8fd28676f9..ff4748213c 100644 --- a/include/openenclave/internal/backtrace.h +++ b/include/openenclave/internal/backtrace.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_BACKTRACE_H diff --git a/include/openenclave/internal/calls.h b/include/openenclave/internal/calls.h index fc9e97c70e..e09ed5d548 100644 --- a/include/openenclave/internal/calls.h +++ b/include/openenclave/internal/calls.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CALLS_H @@ -75,6 +75,7 @@ typedef enum _oe_func OE_ECALL_INIT_ENCLAVE, OE_ECALL_CALL_ENCLAVE_FUNCTION, OE_ECALL_VIRTUAL_EXCEPTION_HANDLER, + OE_ECALL_INIT_CONTEXT_SWITCHLESS, /* Caution: always add new ECALL function numbers here */ OE_ECALL_MAX, @@ -85,6 +86,7 @@ typedef enum _oe_func OE_OCALL_FREE, OE_OCALL_SLEEP, OE_OCALL_GET_TIME, + OE_OCALL_WAKE_HOST_WORKER, /* Caution: always add new OCALL function numbers here */ OE_OCALL_MAX, /* This value is never used */ diff --git a/include/openenclave/internal/cert.h b/include/openenclave/internal/cert.h index f993acf8d8..bf228b7a05 100644 --- a/include/openenclave/internal/cert.h +++ b/include/openenclave/internal/cert.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CERT_INTERNAL_H diff --git a/include/openenclave/internal/constants_x64.h b/include/openenclave/internal/constants_x64.h index 1ed966a656..c5ec1b1dff 100644 --- a/include/openenclave/internal/constants_x64.h +++ b/include/openenclave/internal/constants_x64.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_CONSTANTS_X64_H @@ -21,7 +21,7 @@ // #define OE_SSA_FROM_TCS_BYTE_OFFSET OE_PAGE_SIZE -#define OE_TD_FROM_TCS_BYTE_OFFSET (4 * OE_PAGE_SIZE) +#define OE_TD_FROM_TCS_BYTE_OFFSET (5 * OE_PAGE_SIZE) #define OE_DEFAULT_SSA_FRAME_SIZE 0x1 #define OE_SGX_GPR_BYTE_SIZE 0xb8 #define OE_SGX_TCS_HEADER_BYTE_SIZE 0x48 @@ -71,4 +71,10 @@ // AMD64 ABI needs a 128 bytes red zone. #define ABI_REDZONE_BYTE_SIZE 0x80 +// MXCSR initialization value for Linux x86_64 ABI in enclave +#define ABI_MXCSR_INIT 0x1F80 + +// x87 FPU control word initialization value for Linux x86_64 ABI in enclave +#define ABI_FPUCW_INIT 0x037F + #endif /* _OE_INTERNAL_CONSTANTS_X64_H */ diff --git a/include/openenclave/internal/context.h b/include/openenclave/internal/context.h index 07ae5dda5e..c66c2c6cf6 100644 --- a/include/openenclave/internal/context.h +++ b/include/openenclave/internal/context.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_CONTEXT_H diff --git a/include/openenclave/internal/context.inc b/include/openenclave/internal/context.inc index c293de2ebc..8fc6bf2ceb 100644 --- a/include/openenclave/internal/context.inc +++ b/include/openenclave/internal/context.inc @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/include/openenclave/internal/cpuid.h b/include/openenclave/internal/cpuid.h index e6c9c669b1..1b64b71e0f 100644 --- a/include/openenclave/internal/cpuid.h +++ b/include/openenclave/internal/cpuid.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CPUID_H @@ -16,7 +16,9 @@ #define OE_CPUID_RDX 3 #define OE_CPUID_REG_COUNT 4 -#define OE_CPUID_AESNI_FEATURE 0x02000000u +#define OE_CPUID_AESNI_FEATURE 0x02000000u /* Leaf 1, subleaf 0, ECX */ +#define OE_CPUID_RDRAND_FEATURE 0x40000000u /* Leaf 1, subleaf 0, ECX */ +#define OE_CPUID_RDSEED_FEATURE 0x00040000u /* Leaf 7, subleaf 0, EBX */ /** * The list of cpuid leafs that are emulated. diff --git a/include/openenclave/internal/crypto/asn1.h b/include/openenclave/internal/crypto/asn1.h index 1a7a3b15f2..f0cae3c65f 100644 --- a/include/openenclave/internal/crypto/asn1.h +++ b/include/openenclave/internal/crypto/asn1.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/internal/crypto/cert.h b/include/openenclave/internal/crypto/cert.h index 9a432939ca..875cf40739 100644 --- a/include/openenclave/internal/crypto/cert.h +++ b/include/openenclave/internal/crypto/cert.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CERT_H @@ -340,11 +340,25 @@ oe_result_t oe_cert_find_extension( */ oe_result_t oe_get_crl_distribution_points( const oe_cert_t* cert, - const char*** urls, + char*** urls, size_t* num_urls, uint8_t* buffer, size_t* buffer_size); +/** + * Gets the validation datetimes from the certificate. + * + * @param cert[in] the certificate. + * @param not_before the date when the certificate validate starts (may be + * null). + * @param not_after the date at which this CRL should be considered invalid + * (may be null). + */ +oe_result_t oe_cert_get_validity_dates( + const oe_cert_t* cert, + oe_datetime_t* not_before, + oe_datetime_t* not_after); + #ifdef OE_BUILD_ENCLAVE typedef struct _oe_cert_config diff --git a/include/openenclave/internal/crypto/cmac.h b/include/openenclave/internal/crypto/cmac.h index 831ede86a4..c607a885c6 100644 --- a/include/openenclave/internal/crypto/cmac.h +++ b/include/openenclave/internal/crypto/cmac.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CMAC_H diff --git a/include/openenclave/internal/crypto/crl.h b/include/openenclave/internal/crypto/crl.h index 8d0fb3f1be..ab26c01cfa 100644 --- a/include/openenclave/internal/crypto/crl.h +++ b/include/openenclave/internal/crypto/crl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CRL_H diff --git a/include/openenclave/internal/crypto/ec.h b/include/openenclave/internal/crypto/ec.h index 8bebde5b5c..feceec75e9 100644 --- a/include/openenclave/internal/crypto/ec.h +++ b/include/openenclave/internal/crypto/ec.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_EC_H diff --git a/include/openenclave/internal/crypto/hash.h b/include/openenclave/internal/crypto/hash.h index bcdb9c4cfc..8c58aac129 100644 --- a/include/openenclave/internal/crypto/hash.h +++ b/include/openenclave/internal/crypto/hash.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HASH_H diff --git a/include/openenclave/internal/crypto/hmac.h b/include/openenclave/internal/crypto/hmac.h index a712b8d6a4..91a701cc60 100644 --- a/include/openenclave/internal/crypto/hmac.h +++ b/include/openenclave/internal/crypto/hmac.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HMAC_H diff --git a/include/openenclave/internal/crypto/kdf.h b/include/openenclave/internal/crypto/kdf.h index 374ad32c60..c187ce4d29 100644 --- a/include/openenclave/internal/crypto/kdf.h +++ b/include/openenclave/internal/crypto/kdf.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_KDF_H diff --git a/include/openenclave/internal/crypto/oid.h b/include/openenclave/internal/crypto/oid.h index e5e67af981..9de30e97bc 100644 --- a/include/openenclave/internal/crypto/oid.h +++ b/include/openenclave/internal/crypto/oid.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_OID_H diff --git a/include/openenclave/internal/crypto/sha.h b/include/openenclave/internal/crypto/sha.h index 355e0c99a0..defb59639e 100644 --- a/include/openenclave/internal/crypto/sha.h +++ b/include/openenclave/internal/crypto/sha.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SHA_H @@ -66,6 +66,16 @@ oe_result_t oe_sha256_update( */ oe_result_t oe_sha256_final(oe_sha256_context_t* context, OE_SHA256* sha256); +oe_result_t oe_sha256_save( + const oe_sha256_context_t* context, + uint32_t* H, + uint32_t* N); + +oe_result_t oe_sha256_restore( + oe_sha256_context_t* context, + const uint32_t* H, + const uint32_t* N); + OE_EXTERNC_END #endif /* _OE_SHA_H */ diff --git a/include/openenclave/internal/datetime.h b/include/openenclave/internal/datetime.h index b7dfdb6301..730fa3d471 100644 --- a/include/openenclave/internal/datetime.h +++ b/include/openenclave/internal/datetime.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_DATETIME_H @@ -10,17 +10,6 @@ OE_EXTERNC_BEGIN -/* Date representation with 1 second precision */ -typedef struct _oe_datetime -{ - uint32_t year; /* format: 1970, 2018, 2020 */ - uint32_t month; /* range: 1-12 */ - uint32_t day; /* range: 1-31 */ - uint32_t hours; /* range: 0-23 */ - uint32_t minutes; /* range: 0-59 */ - uint32_t seconds; /* range: 0-59 */ -} oe_datetime_t; - // ISO 8601 format: YYYY-MM-DDThh:mm:ssZ #define OE_DATETIME_FORMAT ("YYYY-MM-DDThh:mm:ssZ") @@ -52,6 +41,16 @@ int32_t oe_datetime_compare( const oe_datetime_t* date1, const oe_datetime_t* date2); +/** + * Return the current system time in GMT time. + */ +oe_result_t oe_datetime_now(oe_datetime_t* value); + +/** + * Log the given datetime. + */ +void oe_datetime_log(const char* msg, const oe_datetime_t* date); + OE_EXTERNC_END #endif /* _OE_INTERNAL_DATETIME_H */ diff --git a/include/openenclave/internal/debugrt/host.h b/include/openenclave/internal/debugrt/host.h index e0fa85b621..bc19bb8712 100644 --- a/include/openenclave/internal/debugrt/host.h +++ b/include/openenclave/internal/debugrt/host.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/internal/defs.h b/include/openenclave/internal/defs.h index 75e8d4150d..30d97b9b40 100644 --- a/include/openenclave/internal/defs.h +++ b/include/openenclave/internal/defs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_DEFS_H diff --git a/include/openenclave/internal/ec.h b/include/openenclave/internal/ec.h index 6db40cdc65..e6fe924249 100644 --- a/include/openenclave/internal/ec.h +++ b/include/openenclave/internal/ec.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_EC_INTERNAL_H diff --git a/include/openenclave/internal/elf.h b/include/openenclave/internal/elf.h index b2572c4ce9..acac5218c3 100644 --- a/include/openenclave/internal/elf.h +++ b/include/openenclave/internal/elf.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ELF_H diff --git a/include/openenclave/internal/entropy.h b/include/openenclave/internal/entropy.h index bdd3bdf95e..e9df1e3a0b 100644 --- a/include/openenclave/internal/entropy.h +++ b/include/openenclave/internal/entropy.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ENTROPY_H @@ -9,18 +9,33 @@ OE_EXTERNC_BEGIN +/** + * The kind of entropy returned by the oe_get_entropy method, as classified + * by the Digital Random Number Generator (DRNG) implementation used. + */ +typedef enum _oe_entropy_kind +{ + OE_ENTROPY_KIND_NONE = 0, + OE_ENTROPY_KIND_RDRAND = 1, + OE_ENTROPY_KIND_RDSEED = 2, + OE_ENTROPY_KIND_OPTEE = 3, + __OE_ENTROPY_KIND_MAX = OE_ENUM_MAX +} oe_entropy_kind_t; + /** * Generates a sequence of high quality sequence of random bytes that * is suitable for a seed to a pseudorandom number generator (PRNG). * * This function will block if there is insufficient hardware entropy. * - * @param data the buffer that will be filled with random bytes - * @param size the size of the buffer + * @param data The buffer that will be filled with random bytes + * @param size The size of the buffer + * @param kind The kind of entropy returned as classified by the Digital + * Random Number Generator (DRNG) implementation used. * * @return OE_OK on success */ -oe_result_t oe_get_entropy(void* data, size_t size); +oe_result_t oe_get_entropy(void* data, size_t size, oe_entropy_kind_t* kind); OE_EXTERNC_END diff --git a/include/openenclave/internal/epid.h b/include/openenclave/internal/epid.h index fd51514193..23d6f5dc23 100644 --- a/include/openenclave/internal/epid.h +++ b/include/openenclave/internal/epid.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/include/openenclave/internal/error.h b/include/openenclave/internal/error.h index 9019a93946..d0c3e521f9 100644 --- a/include/openenclave/internal/error.h +++ b/include/openenclave/internal/error.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ERROR_H diff --git a/include/openenclave/internal/fault.h b/include/openenclave/internal/fault.h index ca294a99c3..85f21ecbd1 100644 --- a/include/openenclave/internal/fault.h +++ b/include/openenclave/internal/fault.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_FAULT_H diff --git a/include/openenclave/internal/files.h b/include/openenclave/internal/files.h index 33fbe64e60..0d4b94625f 100644 --- a/include/openenclave/internal/files.h +++ b/include/openenclave/internal/files.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_FILES_H diff --git a/include/openenclave/internal/globals.h b/include/openenclave/internal/globals.h index b4a60cfcf7..6dd9c01e36 100644 --- a/include/openenclave/internal/globals.h +++ b/include/openenclave/internal/globals.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_GLOBALS_H @@ -32,6 +32,11 @@ uint64_t oe_get_base_heap_page(void); uint64_t oe_get_num_heap_pages(void); uint64_t oe_get_num_pages(void); +/* Extended enclave initialization data */ +const void* __oe_get_eeid_base(void); +const void* __oe_get_eeid_end(void); +uint64_t __oe_get_eeid_size(void); + OE_EXTERNC_END #endif /* _OE_GLOBALS_H */ diff --git a/include/openenclave/internal/hexdump.h b/include/openenclave/internal/hexdump.h index 63cec3310f..55ee11556c 100644 --- a/include/openenclave/internal/hexdump.h +++ b/include/openenclave/internal/hexdump.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_HEXDUMP_H diff --git a/include/openenclave/internal/jump.h b/include/openenclave/internal/jump.h index 1693868b43..3bf204442a 100644 --- a/include/openenclave/internal/jump.h +++ b/include/openenclave/internal/jump.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_JUMP_H @@ -26,7 +26,7 @@ typedef struct _oe_jmpbuf uint64_t r15; } oe_jmpbuf_t; -int oe_setjmp(oe_jmpbuf_t* env); +int oe_setjmp(oe_jmpbuf_t* env) OE_RETURNS_TWICE; void oe_longjmp(oe_jmpbuf_t* env, int val); diff --git a/include/openenclave/internal/kdf.h b/include/openenclave/internal/kdf.h index 212236e5c2..4f15fec648 100644 --- a/include/openenclave/internal/kdf.h +++ b/include/openenclave/internal/kdf.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_KDF_INTERNAL_H diff --git a/include/openenclave/internal/load.h b/include/openenclave/internal/load.h index d268730a39..3a5d022912 100644 --- a/include/openenclave/internal/load.h +++ b/include/openenclave/internal/load.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_LOAD_H diff --git a/include/openenclave/internal/lockless_queue.h b/include/openenclave/internal/lockless_queue.h deleted file mode 100644 index 30bad0ffeb..0000000000 --- a/include/openenclave/internal/lockless_queue.h +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. */ - -#ifndef _LOCKLESS_QUEUE_H_ -#define _LOCKLESS_QUEUE_H_ - -#include - -OE_EXTERNC_BEGIN - -/* forward declarations */ -struct _oe_lockless_queue_node; -struct _oe_lockless_queue; - -/** - * @typedef atomic_lockless_node_ptr - * - * @brief A platform abstract pointer to a lockless_queue_node. - */ -#ifdef _MSC_VER -typedef struct _oe_lockless_queue_node* volatile atomic_lockless_node_ptr; -#elif defined __GNUC__ -typedef struct _oe_lockless_queue_node* atomic_lockless_node_ptr; -#else -#error "unsupported" -#endif - -/** - * @struct _oe_lockless_queue_node - * - * @brief The basic structure for a lockless queue node. - * - * This structure is the basic node used with struct _oe_lockless queue. - * - * @note This should be initialized with oe_lockless_queue_node_init() before - * use. - * - * @see _oe_lockless_queue - * @see oe_lockless_queue_node_init() - */ -typedef struct _oe_lockless_queue_node -{ - /** - * @internal - */ - struct _oe_lockless_queue_node* p_link; -} oe_lockless_queue_node; - -/** - * @function oe_lockless_queue_node_init - * - * @brief Initializes an _oe_lockless_queue_node. - * - * Prepares a node for use with _oe_lockless_queue. - * - * @param p_node An uninitialized _oe_lockless_queue_node. - * - * @pre p_node is non-NULL and points to an unitialized node. - * @post p_node is prepared to pass to oe_lockless_queue_push_back(). - */ -void oe_lockless_queue_node_init(oe_lockless_queue_node* p_node); - -/** - * @struct _oe_lockless_queue - * - * @brief The structure for managing a multi-producer, single-consumer, FIFO - * queue data structure that is multithread stable. - * - * This structure is the basic control data type for a thread-safe lockless FIFO - * queue. This data structure allows any number of threads to call - * oe_lockless_queue_push_back() and one thread to call - * oe_lockless_queue_pop_front() concurrently without the use of any mutex while - * maintaining a consistent and stable state. - * - * @note This should be initialized with oe_lockless_queue_init() before use. - * - * @see oe_lockless_queue_node_init() - * @see oe_lockless_queue_push_front() - * @see oe_lockless_queue_pop_back() - */ -typedef struct _oe_lockless_queue -{ - /** - * @internal - */ - atomic_lockless_node_ptr p_tail; - /** - * @internal - */ - atomic_lockless_node_ptr p_head; -} oe_lockless_queue; - -/** - * @function oe_lockless_queue_init - * - * @brief Initializes an _oe_lockless_queue_node. - * - * Prepares an _oe_lockless_queue for use. - * - * @param p_queue An uninitialized _oe_lockless_queue. - * - * @pre p_queue is non-NULL and points to an unitialized queue. - * @post p_queue is prepared to use with oe_lockless_queue_push_back() and - * oe_lockless_queue_pop_front(). - */ -void oe_lockless_queue_init(oe_lockless_queue* p_queue); - -/** - * @function oe_lockless_queue_push_back - * - * @brief Appends an _oe_lockless_queue node to the tail end of an - * _oe_lockless_queue. - * - * @param p_queue The _oe_lockless_queue to append the node. - * @param p_node The _oe_lockless_queue_node to append to the queue. - * - * @pre p_queue is non-NULL and points to an initialized queue and p_node is - * non-NULL and points to an initialized node. - * @post p_node has been appended to the end of p_queue. - * - * @note It is safe to call this method from any number of threads concurrently. - * It is also safe to call this method concurrently while also calling - * oe_lockless_queue_pop_front() from a single thread. - */ -void oe_lockless_queue_push_back( - oe_lockless_queue* p_queue, - oe_lockless_queue_node* p_node); - -/** - * @function oe_lockless_queue_pop_front - * - * @brief Attempts to remove and return an _oe_lockless_queue_node from the head - * of an _oe_lockless_queue. - * - * @param p_queue The _oe_lockless_queue to remove a node from. - * @return A pointer to an _oe_lockless_queue_node if there was at least one in - * the queue or NULL if there was not a node in the queue. - * @pre p_queue is non-NULL and points to an initialized queue and p_node is - * non-NULL and points to an initialized node. - * - * @note It is not safe to call this method concurrently from more than one - * thread. However it is safe to call this method while concurrently - * calling oe_lockless_queue_push_back() from any number of threads. - */ -oe_lockless_queue_node* oe_lockless_queue_pop_front(oe_lockless_queue* p_queue); - -OE_EXTERNC_END - -#endif /* _LOCKLESS_QUEUE_H_ */ diff --git a/include/openenclave/internal/malloc.h b/include/openenclave/internal/malloc.h index 03482ddc99..40b9c858d2 100644 --- a/include/openenclave/internal/malloc.h +++ b/include/openenclave/internal/malloc.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_MALLOC_H diff --git a/include/openenclave/internal/mem.h b/include/openenclave/internal/mem.h index d928434138..2e8787fdc0 100644 --- a/include/openenclave/internal/mem.h +++ b/include/openenclave/internal/mem.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _MEM_H diff --git a/include/openenclave/internal/pem.h b/include/openenclave/internal/pem.h index 22005e3190..37cd625503 100644 --- a/include/openenclave/internal/pem.h +++ b/include/openenclave/internal/pem.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_PEM_H diff --git a/include/openenclave/internal/print.h b/include/openenclave/internal/print.h index 3eb15e079c..ee28d6c494 100644 --- a/include/openenclave/internal/print.h +++ b/include/openenclave/internal/print.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_PRINT_H diff --git a/include/openenclave/internal/properties.h b/include/openenclave/internal/properties.h index 73ae94a9d2..1379d16e5a 100644 --- a/include/openenclave/internal/properties.h +++ b/include/openenclave/internal/properties.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_PROPERTIES_H diff --git a/include/openenclave/internal/pthreadhooks.h b/include/openenclave/internal/pthreadhooks.h index fd8b7d364a..6d5d77589f 100644 --- a/include/openenclave/internal/pthreadhooks.h +++ b/include/openenclave/internal/pthreadhooks.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_PTHREADHOOKS_H diff --git a/include/openenclave/internal/raise.h b/include/openenclave/internal/raise.h index b9297b7a45..4a4fa71f91 100644 --- a/include/openenclave/internal/raise.h +++ b/include/openenclave/internal/raise.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/internal/random.h b/include/openenclave/internal/random.h index 400c537bef..989ce4a033 100644 --- a/include/openenclave/internal/random.h +++ b/include/openenclave/internal/random.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_RANDOM_INTERNAL_H diff --git a/include/openenclave/internal/rdrand.h b/include/openenclave/internal/rdrand.h index 5814082e01..55a0caa55d 100644 --- a/include/openenclave/internal/rdrand.h +++ b/include/openenclave/internal/rdrand.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_RDRAND_H @@ -15,7 +15,7 @@ OE_EXTERNC_BEGIN * instruction. This method will block if there is insufficient hardware * entropy to provide the full 64-bits of randomness. * - * @return OE_OK on success + * @return uint64_t 8-bytes of randomness. */ uint64_t oe_rdrand(void); diff --git a/include/openenclave/internal/rdseed.h b/include/openenclave/internal/rdseed.h new file mode 100644 index 0000000000..12263e1d39 --- /dev/null +++ b/include/openenclave/internal/rdseed.h @@ -0,0 +1,24 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_RDSEED_H +#define _OE_RDSEED_H + +#include + +OE_EXTERNC_BEGIN + +/** + * Generate a sequence of random bytes using Intel RDSEED instruction + * + * This function generates 8 random bytes using direct call to Intel's RDSEED + * instruction. This method will block if there is insufficient hardware + * entropy to provide the full 64-bits of randomness. + * + * @return uint64_t 8-bytes of randomness. + */ +uint64_t oe_rdseed(void); + +OE_EXTERNC_END + +#endif /* _OE_RDSEED_H */ diff --git a/include/openenclave/internal/registers.h b/include/openenclave/internal/registers.h index dbb81242aa..1a38147b51 100644 --- a/include/openenclave/internal/registers.h +++ b/include/openenclave/internal/registers.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_ASM_H diff --git a/include/openenclave/internal/report.h b/include/openenclave/internal/report.h index 4ed83a63fb..327c38d527 100644 --- a/include/openenclave/internal/report.h +++ b/include/openenclave/internal/report.h @@ -1,11 +1,16 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INCLUDE_REPORT_H_ #define _OE_INCLUDE_REPORT_H_ +#include #include +#include + +#if __x86_64__ || _M_X64 #include +#endif /* **============================================================================== @@ -87,6 +92,10 @@ OE_STATIC_ASSERT( } #define X509_OID_FOR_QUOTE_STRING "1.2.840.113556.10.1.1" +// For old OE reports. #define OE_REPORT_HEADER_VERSION (1) +// For attestation plugin reports. +#define OE_ATTESTATION_HEADER_VERSION (2) + #endif //_OE_INCLUDE_REPORT_H_ diff --git a/include/openenclave/internal/result.h b/include/openenclave/internal/result.h index 45939d34f3..f412528cf2 100644 --- a/include/openenclave/internal/result.h +++ b/include/openenclave/internal/result.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /** diff --git a/include/openenclave/internal/rsa.h b/include/openenclave/internal/rsa.h index cc22d99341..b2b3b0ac15 100644 --- a/include/openenclave/internal/rsa.h +++ b/include/openenclave/internal/rsa.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_RSA_H diff --git a/include/openenclave/internal/sgx/plugin.h b/include/openenclave/internal/sgx/plugin.h new file mode 100644 index 0000000000..531a6ccb93 --- /dev/null +++ b/include/openenclave/internal/sgx/plugin.h @@ -0,0 +1,42 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_INTERNAL_SGX_PLUGIN +#define _OE_INTERNAL_SGX_PLUGIN + +#include + +/** + * The SGX plugin UUID. + */ +#define OE_SGX_PLUGIN_UUID \ + { \ + 0xa3, 0xa2, 0x1e, 0x87, 0x1b, 0x4d, 0x40, 0x14, 0xb7, 0x0a, 0xa1, \ + 0x25, 0xd2, 0xfb, 0xcd, 0x8c \ + } + +#define OE_SGX_PLUGIN_CLAIMS_VERSION 1 + +/** + * Serialized header for the custom claims. + */ +typedef struct _oe_sgx_plugin_claims_header +{ + uint64_t version; + uint64_t num_claims; +} oe_sgx_plugin_claims_header_t; + +/** + * Serialzied entry for custom claims. Each entry will have the name and value + * sizes and then the contents of the name and value respectively. + */ +typedef struct _oe_sgx_plugin_claims_entry +{ + uint64_t name_size; + uint64_t value_size; + uint8_t name[]; + // name_size bytes follow. + // value_size_bytes follow. +} oe_sgx_plugin_claims_entry_t; + +#endif // _OE_INTENRAL_SGX_PLUGIN diff --git a/include/openenclave/internal/sgx/sgxproperties.h b/include/openenclave/internal/sgx/sgxproperties.h index b6d02afcd5..f7b59b4903 100644 --- a/include/openenclave/internal/sgx/sgxproperties.h +++ b/include/openenclave/internal/sgx/sgxproperties.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_SGX_PROPERTIES_H diff --git a/include/openenclave/internal/sgxcertextensions.h b/include/openenclave/internal/sgxcertextensions.h index 046c648176..7ad23ffbd3 100644 --- a/include/openenclave/internal/sgxcertextensions.h +++ b/include/openenclave/internal/sgxcertextensions.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXCERTEXTENSIONS_H diff --git a/include/openenclave/internal/sgxcreate.h b/include/openenclave/internal/sgxcreate.h index 0344612934..f5a21a8415 100644 --- a/include/openenclave/internal/sgxcreate.h +++ b/include/openenclave/internal/sgxcreate.h @@ -1,13 +1,16 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXCREATE_H #define _OE_SGXCREATE_H +#include #include +#include #include "crypto/sha.h" #include "load.h" #include "sgxtypes.h" +#include "types.h" OE_EXTERNC_BEGIN @@ -75,6 +78,7 @@ oe_result_t oe_sgx_build_enclave( oe_sgx_load_context_t* context, const char* path, const oe_sgx_enclave_properties_t* properties, + oe_eeid_t* eeid, oe_enclave_t* enclave); /** diff --git a/include/openenclave/internal/sgxkeys.h b/include/openenclave/internal/sgxkeys.h index ba128085b6..68ab543e52 100644 --- a/include/openenclave/internal/sgxkeys.h +++ b/include/openenclave/internal/sgxkeys.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_KEYS_H diff --git a/include/openenclave/internal/sgxsign.h b/include/openenclave/internal/sgxsign.h index 8b83832129..83c65296d5 100644 --- a/include/openenclave/internal/sgxsign.h +++ b/include/openenclave/internal/sgxsign.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SIGNSGX_H diff --git a/include/openenclave/internal/sgxtypes.h b/include/openenclave/internal/sgxtypes.h index 22c689fe15..798bf6f7af 100644 --- a/include/openenclave/internal/sgxtypes.h +++ b/include/openenclave/internal/sgxtypes.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SGXTYPES_H @@ -505,11 +505,11 @@ OE_CHECK_SIZE(OE_OFFSETOF(sgx_tcs_t, u.entry), 72); ** ** This structure defines information about an enclave thread. Each ** instance is associated with one thread control structure (TCS). This -** structure resides in the GS segment page (referenced by the GS segment +** structure resides in the FS segment page (referenced by the FS segment ** register). A thread obtains its thread data structure by calling ** oe_get_thread_data(), which fetches the address at offset zero in -** the GS segment register (%gs:0) which contains -*oe_thread_data_t.self_addr. +** the FS segment register (%fs:0) which contains +** oe_thread_data_t.self_addr. ** **============================================================================== */ @@ -528,7 +528,12 @@ struct _oe_thread_data uint64_t __stack_base_addr; uint64_t __stack_limit_addr; uint64_t __first_ssa_gpr; - uint64_t __stack_guard; /* 0x28 for x64 */ + /* Here the name and offset of stack_guard complies to the properties of + stack_guard defined in tcbhead_t(Struct for Thread Control Block). In + this way we can make use of the compiler's support of stack smashing + protector. + */ + uint64_t stack_guard; /* The offset is 0x28 for x64 */ uint64_t __reserved_0; uint64_t __ssa_frame_size; uint64_t __last_error; @@ -565,7 +570,9 @@ oe_thread_data_t* oe_get_thread_data(void); #define TD_MAGIC 0xc90afe906c5d19a3 -#define OE_THREAD_LOCAL_SPACE (3840) +#define OE_THREAD_LOCAL_SPACE (OE_PAGE_SIZE) + +#define OE_THREAD_SPECIFIC_DATA_SIZE (3840) typedef struct _callsite Callsite; @@ -606,8 +613,8 @@ typedef struct _td /* Simulation mode is active if non-zero */ uint64_t simulate; - /* Reserved for thread-local variables. */ - uint8_t thread_local_data[OE_THREAD_LOCAL_SPACE]; + /* Reserved for thread specific data. */ + uint8_t thread_specific_data[OE_THREAD_SPECIFIC_DATA_SIZE]; } td_t; OE_PACK_END diff --git a/include/openenclave/internal/stack_alloc.h b/include/openenclave/internal/stack_alloc.h index cc83d7c5c6..dc33fcd20b 100644 --- a/include/openenclave/internal/stack_alloc.h +++ b/include/openenclave/internal/stack_alloc.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STACK_ALLOC_H diff --git a/include/openenclave/internal/str.h b/include/openenclave/internal/str.h index 0b09c5b3ef..40a1a294fe 100644 --- a/include/openenclave/internal/str.h +++ b/include/openenclave/internal/str.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STR_H diff --git a/include/openenclave/internal/switchless.h b/include/openenclave/internal/switchless.h new file mode 100644 index 0000000000..a6c3d37427 --- /dev/null +++ b/include/openenclave/internal/switchless.h @@ -0,0 +1,56 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_SWITCHLESS_H +#define _OE_SWITCHLESS_H + +#include +#include +#include +#include + +typedef struct _host_worker_thread_context +{ + volatile oe_call_host_function_args_t* call_arg; + oe_enclave_t* enclave; + bool is_stopping; + + volatile int32_t event; + + // Number of times the worker spinned without seeing a message. + uint64_t spin_count; + + // Statistics. + uint64_t total_spin_count; +} oe_host_worker_context_t; + +/** + * oe_host_worker_context_t is used both by the host (windows/linux) and the + * enclave (ELF). Lock down the layout. + */ +OE_STATIC_ASSERT(sizeof(oe_host_worker_context_t) == 40); +OE_STATIC_ASSERT(OE_OFFSETOF(oe_host_worker_context_t, call_arg) == 0); +OE_STATIC_ASSERT(OE_OFFSETOF(oe_host_worker_context_t, enclave) == 8); +OE_STATIC_ASSERT(OE_OFFSETOF(oe_host_worker_context_t, is_stopping) == 16); +OE_STATIC_ASSERT(OE_OFFSETOF(oe_host_worker_context_t, event) == 20); +OE_STATIC_ASSERT(OE_OFFSETOF(oe_host_worker_context_t, spin_count) == 24); +OE_STATIC_ASSERT(OE_OFFSETOF(oe_host_worker_context_t, total_spin_count) == 32); + +typedef struct _oe_switchless_call_manager +{ + oe_host_worker_context_t* host_worker_contexts; + oe_thread_t* host_worker_threads; + size_t num_host_workers; +} oe_switchless_call_manager_t; + +oe_result_t oe_start_switchless_manager( + oe_enclave_t* enclave, + size_t num_host_workers); + +oe_result_t oe_stop_switchless_manager(oe_enclave_t* enclave); + +void oe_host_worker_wait(oe_host_worker_context_t* context); + +void oe_host_worker_wake(oe_host_worker_context_t* context); + +#endif /* _OE_SWITCHLESS_H */ diff --git a/include/openenclave/internal/syscall.h b/include/openenclave/internal/syscall.h index 5abb407193..5e15d248e2 100644 --- a/include/openenclave/internal/syscall.h +++ b/include/openenclave/internal/syscall.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_SYSCALL_H diff --git a/include/openenclave/internal/syscall/arpa/inet.h b/include/openenclave/internal/syscall/arpa/inet.h index c2d0e24eed..69d0162e17 100644 --- a/include/openenclave/internal/syscall/arpa/inet.h +++ b/include/openenclave/internal/syscall/arpa/inet.h @@ -1,4 +1,4 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Copyright (c) Open Enclave SDK contributors. */ /* Licensed under the MIT License. */ #ifndef OE_SYSCALL_ARPA_INET_H diff --git a/include/openenclave/internal/syscall/bits/addrinfo.h b/include/openenclave/internal/syscall/bits/addrinfo.h index af9868e0c1..a3516d2945 100644 --- a/include/openenclave/internal/syscall/bits/addrinfo.h +++ b/include/openenclave/internal/syscall/bits/addrinfo.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_ADDRINFO diff --git a/include/openenclave/internal/syscall/bits/dirent.h b/include/openenclave/internal/syscall/bits/dirent.h index a6b3be28e6..c2530ab8a3 100644 --- a/include/openenclave/internal/syscall/bits/dirent.h +++ b/include/openenclave/internal/syscall/bits/dirent.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_DIRENT diff --git a/include/openenclave/internal/syscall/bits/sigaction.h b/include/openenclave/internal/syscall/bits/sigaction.h index 0a1ea4d3a4..c92d0849fe 100644 --- a/include/openenclave/internal/syscall/bits/sigaction.h +++ b/include/openenclave/internal/syscall/bits/sigaction.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_SIGACTION diff --git a/include/openenclave/internal/syscall/bits/siginfo.h b/include/openenclave/internal/syscall/bits/siginfo.h index 8c5e8e2fa3..8168055960 100644 --- a/include/openenclave/internal/syscall/bits/siginfo.h +++ b/include/openenclave/internal/syscall/bits/siginfo.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define __OE_SI_PAD_SIZE ((128 / sizeof(int)) - 4) diff --git a/include/openenclave/internal/syscall/device.h b/include/openenclave/internal/syscall/device.h index 912f94ca92..dc6f5b1eb9 100644 --- a/include/openenclave/internal/syscall/device.h +++ b/include/openenclave/internal/syscall/device.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_DEVICE_H diff --git a/include/openenclave/internal/syscall/dirent.h b/include/openenclave/internal/syscall/dirent.h index fe962bd134..e79332c73d 100644 --- a/include/openenclave/internal/syscall/dirent.h +++ b/include/openenclave/internal/syscall/dirent.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_DIRENT_H diff --git a/include/openenclave/internal/syscall/fcntl.h b/include/openenclave/internal/syscall/fcntl.h index b4e802bbaa..c514082fd2 100644 --- a/include/openenclave/internal/syscall/fcntl.h +++ b/include/openenclave/internal/syscall/fcntl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_FCNTL_H diff --git a/include/openenclave/internal/syscall/fd.h b/include/openenclave/internal/syscall/fd.h index c58a4b5c0c..2936b90e30 100644 --- a/include/openenclave/internal/syscall/fd.h +++ b/include/openenclave/internal/syscall/fd.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_FD_H diff --git a/include/openenclave/internal/syscall/fdtable.h b/include/openenclave/internal/syscall/fdtable.h index 35676eae0e..3c5df59719 100644 --- a/include/openenclave/internal/syscall/fdtable.h +++ b/include/openenclave/internal/syscall/fdtable.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_FDTABLE_H diff --git a/include/openenclave/internal/syscall/host.h b/include/openenclave/internal/syscall/host.h index 7e75ac7230..ff970e6ca9 100644 --- a/include/openenclave/internal/syscall/host.h +++ b/include/openenclave/internal/syscall/host.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_HOST_H diff --git a/include/openenclave/internal/syscall/iov.h b/include/openenclave/internal/syscall/iov.h index 5ea3e267de..aed31cb800 100644 --- a/include/openenclave/internal/syscall/iov.h +++ b/include/openenclave/internal/syscall/iov.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_IOV_H diff --git a/include/openenclave/internal/syscall/netdb.h b/include/openenclave/internal/syscall/netdb.h index b0c0099392..3975e1a5aa 100644 --- a/include/openenclave/internal/syscall/netdb.h +++ b/include/openenclave/internal/syscall/netdb.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_NETDB_H_ diff --git a/include/openenclave/internal/syscall/netinet/bits/in6_addr.h b/include/openenclave/internal/syscall/netinet/bits/in6_addr.h index 64ccd921d5..d0e1981a47 100644 --- a/include/openenclave/internal/syscall/netinet/bits/in6_addr.h +++ b/include/openenclave/internal/syscall/netinet/bits/in6_addr.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_IN6_ADDR diff --git a/include/openenclave/internal/syscall/netinet/bits/sockaddr_in.h b/include/openenclave/internal/syscall/netinet/bits/sockaddr_in.h index a1eea520fa..b670fb7b69 100644 --- a/include/openenclave/internal/syscall/netinet/bits/sockaddr_in.h +++ b/include/openenclave/internal/syscall/netinet/bits/sockaddr_in.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_SOCKADDR_IN diff --git a/include/openenclave/internal/syscall/netinet/bits/sockaddr_in6.h b/include/openenclave/internal/syscall/netinet/bits/sockaddr_in6.h index e877868076..1e6114b52d 100644 --- a/include/openenclave/internal/syscall/netinet/bits/sockaddr_in6.h +++ b/include/openenclave/internal/syscall/netinet/bits/sockaddr_in6.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_SOCKADDR_IN6 diff --git a/include/openenclave/internal/syscall/netinet/in.h b/include/openenclave/internal/syscall/netinet/in.h index abe0063961..ffbba3ff1b 100644 --- a/include/openenclave/internal/syscall/netinet/in.h +++ b/include/openenclave/internal/syscall/netinet/in.h @@ -1,4 +1,4 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Copyright (c) Open Enclave SDK contributors. */ /* Licensed under the MIT License. */ #ifndef _OE_SYSCALL_NETINET_IN_H diff --git a/include/openenclave/internal/syscall/poll.h b/include/openenclave/internal/syscall/poll.h index f8d7df9e76..730391e451 100644 --- a/include/openenclave/internal/syscall/poll.h +++ b/include/openenclave/internal/syscall/poll.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_POLL_H diff --git a/include/openenclave/internal/syscall/raise.h b/include/openenclave/internal/syscall/raise.h index b13391f247..5f328735da 100644 --- a/include/openenclave/internal/syscall/raise.h +++ b/include/openenclave/internal/syscall/raise.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_RAISE_H diff --git a/include/openenclave/internal/syscall/resolver.h b/include/openenclave/internal/syscall/resolver.h index 4acd8e0c07..9bf6e3e43e 100644 --- a/include/openenclave/internal/syscall/resolver.h +++ b/include/openenclave/internal/syscall/resolver.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_RESOLVER_H diff --git a/include/openenclave/internal/syscall/sys/bits/epoll_data.h b/include/openenclave/internal/syscall/sys/bits/epoll_data.h index 2cb817bd11..1db508409c 100644 --- a/include/openenclave/internal/syscall/sys/bits/epoll_data.h +++ b/include/openenclave/internal/syscall/sys/bits/epoll_data.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. typedef union __OE_EPOLL_DATA { diff --git a/include/openenclave/internal/syscall/sys/bits/epoll_event.h b/include/openenclave/internal/syscall/sys/bits/epoll_event.h index 953e1236e5..27ad847926 100644 --- a/include/openenclave/internal/syscall/sys/bits/epoll_event.h +++ b/include/openenclave/internal/syscall/sys/bits/epoll_event.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/include/openenclave/internal/syscall/sys/bits/fd_set.h b/include/openenclave/internal/syscall/sys/bits/fd_set.h index c7bf9aef4a..002ae411f9 100644 --- a/include/openenclave/internal/syscall/sys/bits/fd_set.h +++ b/include/openenclave/internal/syscall/sys/bits/fd_set.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. typedef struct diff --git a/include/openenclave/internal/syscall/sys/bits/msghdr.h b/include/openenclave/internal/syscall/sys/bits/msghdr.h index 705f0c0e18..93e03aaa1f 100644 --- a/include/openenclave/internal/syscall/sys/bits/msghdr.h +++ b/include/openenclave/internal/syscall/sys/bits/msghdr.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_MSGHDR diff --git a/include/openenclave/internal/syscall/sys/bits/sigset.h b/include/openenclave/internal/syscall/sys/bits/sigset.h index 397f8e6568..e29132e827 100644 --- a/include/openenclave/internal/syscall/sys/bits/sigset.h +++ b/include/openenclave/internal/syscall/sys/bits/sigset.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SIGSET_H diff --git a/include/openenclave/internal/syscall/sys/bits/sockaddr.h b/include/openenclave/internal/syscall/sys/bits/sockaddr.h index b3dc4995de..f14a60a2d2 100644 --- a/include/openenclave/internal/syscall/sys/bits/sockaddr.h +++ b/include/openenclave/internal/syscall/sys/bits/sockaddr.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_SOCKADDR diff --git a/include/openenclave/internal/syscall/sys/bits/sockaddr_storage.h b/include/openenclave/internal/syscall/sys/bits/sockaddr_storage.h index 49ed4714ae..78f834ebc1 100644 --- a/include/openenclave/internal/syscall/sys/bits/sockaddr_storage.h +++ b/include/openenclave/internal/syscall/sys/bits/sockaddr_storage.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. struct __OE_SOCKADDR_STORAGE diff --git a/include/openenclave/internal/syscall/sys/bits/stat.h b/include/openenclave/internal/syscall/sys/bits/stat.h index b29f27f776..b8396c7d11 100644 --- a/include/openenclave/internal/syscall/sys/bits/stat.h +++ b/include/openenclave/internal/syscall/sys/bits/stat.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off diff --git a/include/openenclave/internal/syscall/sys/bits/syscall_aarch64.h b/include/openenclave/internal/syscall/sys/bits/syscall_aarch64.h index bafa7c7b82..a20fe8b042 100644 --- a/include/openenclave/internal/syscall/sys/bits/syscall_aarch64.h +++ b/include/openenclave/internal/syscall/sys/bits/syscall_aarch64.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_SYS_io_setup 0 diff --git a/include/openenclave/internal/syscall/sys/bits/syscall_x86_64.h b/include/openenclave/internal/syscall/sys/bits/syscall_x86_64.h index 367df67c3a..4cac0e024d 100644 --- a/include/openenclave/internal/syscall/sys/bits/syscall_x86_64.h +++ b/include/openenclave/internal/syscall/sys/bits/syscall_x86_64.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_SYS_read 0 diff --git a/include/openenclave/internal/syscall/sys/bits/utsname.h b/include/openenclave/internal/syscall/sys/bits/utsname.h index 18734ee6bd..acc9f6574b 100644 --- a/include/openenclave/internal/syscall/sys/bits/utsname.h +++ b/include/openenclave/internal/syscall/sys/bits/utsname.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define __OE_UTSNAME_FIELD_SIZE 65 diff --git a/include/openenclave/internal/syscall/sys/epoll.h b/include/openenclave/internal/syscall/sys/epoll.h index dbc78916f3..1d315a7581 100644 --- a/include/openenclave/internal/syscall/sys/epoll.h +++ b/include/openenclave/internal/syscall/sys/epoll.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYS_EPOLL_H diff --git a/include/openenclave/internal/syscall/sys/ioctl.h b/include/openenclave/internal/syscall/sys/ioctl.h index 335a17e113..9beb41c0c1 100644 --- a/include/openenclave/internal/syscall/sys/ioctl.h +++ b/include/openenclave/internal/syscall/sys/ioctl.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_IOCTL_H diff --git a/include/openenclave/internal/syscall/sys/mount.h b/include/openenclave/internal/syscall/sys/mount.h index a445622a01..31ab7bdfdc 100644 --- a/include/openenclave/internal/syscall/sys/mount.h +++ b/include/openenclave/internal/syscall/sys/mount.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_MOUNT_H diff --git a/include/openenclave/internal/syscall/sys/poll.h b/include/openenclave/internal/syscall/sys/poll.h index 4c697664fa..754987f380 100644 --- a/include/openenclave/internal/syscall/sys/poll.h +++ b/include/openenclave/internal/syscall/sys/poll.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_POLL_H diff --git a/include/openenclave/internal/syscall/sys/select.h b/include/openenclave/internal/syscall/sys/select.h index 5f5f8c9a72..eb25658430 100644 --- a/include/openenclave/internal/syscall/sys/select.h +++ b/include/openenclave/internal/syscall/sys/select.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_SELECT_H diff --git a/include/openenclave/internal/syscall/sys/socket.h b/include/openenclave/internal/syscall/sys/socket.h index cb49c2b221..d7aaeb2a0f 100644 --- a/include/openenclave/internal/syscall/sys/socket.h +++ b/include/openenclave/internal/syscall/sys/socket.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_SOCKET_H diff --git a/include/openenclave/internal/syscall/sys/stat.h b/include/openenclave/internal/syscall/sys/stat.h index d0bcc6cda0..0c5eec423a 100644 --- a/include/openenclave/internal/syscall/sys/stat.h +++ b/include/openenclave/internal/syscall/sys/stat.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_STAT_H diff --git a/include/openenclave/internal/syscall/sys/syscall.h b/include/openenclave/internal/syscall/sys/syscall.h index 755ebb7a0c..fc3ed903ab 100644 --- a/include/openenclave/internal/syscall/sys/syscall.h +++ b/include/openenclave/internal/syscall/sys/syscall.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_SYSCALL_H diff --git a/include/openenclave/internal/syscall/sys/time.h b/include/openenclave/internal/syscall/sys/time.h index e6dcd9645f..69641d166d 100644 --- a/include/openenclave/internal/syscall/sys/time.h +++ b/include/openenclave/internal/syscall/sys/time.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_TIME_H diff --git a/include/openenclave/internal/syscall/sys/types.h b/include/openenclave/internal/syscall/sys/types.h index d8ad99238d..70f61eeaae 100644 --- a/include/openenclave/internal/syscall/sys/types.h +++ b/include/openenclave/internal/syscall/sys/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_TYPES_H diff --git a/include/openenclave/internal/syscall/sys/uio.h b/include/openenclave/internal/syscall/sys/uio.h index 74998ec2da..56375cdd78 100644 --- a/include/openenclave/internal/syscall/sys/uio.h +++ b/include/openenclave/internal/syscall/sys/uio.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_UIO_H diff --git a/include/openenclave/internal/syscall/sys/utsname.h b/include/openenclave/internal/syscall/sys/utsname.h index cb3262fb01..c74ddfa746 100644 --- a/include/openenclave/internal/syscall/sys/utsname.h +++ b/include/openenclave/internal/syscall/sys/utsname.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_SYS_UTSNAME_H diff --git a/include/openenclave/internal/syscall/types.h b/include/openenclave/internal/syscall/types.h index 1ed571cec6..9a6ba7dd16 100644 --- a/include/openenclave/internal/syscall/types.h +++ b/include/openenclave/internal/syscall/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_TYPES_H diff --git a/include/openenclave/internal/syscall/unistd.h b/include/openenclave/internal/syscall/unistd.h index 8596ba7681..15d8dd2df0 100644 --- a/include/openenclave/internal/syscall/unistd.h +++ b/include/openenclave/internal/syscall/unistd.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_SYSCALL_UNISTD_H diff --git a/include/openenclave/internal/tests.h b/include/openenclave/internal/tests.h index 9934a0f1eb..b279bbd272 100644 --- a/include/openenclave/internal/tests.h +++ b/include/openenclave/internal/tests.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TESTS_H diff --git a/include/openenclave/internal/thread.h b/include/openenclave/internal/thread.h index bd848625cc..ac799501ee 100644 --- a/include/openenclave/internal/thread.h +++ b/include/openenclave/internal/thread.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INCLUDE_THREAD_H @@ -8,11 +8,11 @@ #include #include +typedef uint64_t oe_thread_t; + #ifdef OE_BUILD_ENCLAVE OE_EXTERNC_BEGIN -typedef uint64_t oe_thread_t; - /* * Note that all the __impl[] fields in the below implementations are * all larger than what is actually needed. This is to account for diff --git a/include/openenclave/internal/time.h b/include/openenclave/internal/time.h index e09b3045bb..fe0548950e 100644 --- a/include/openenclave/internal/time.h +++ b/include/openenclave/internal/time.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INCLUDE_TIME_H diff --git a/include/openenclave/internal/trace.h b/include/openenclave/internal/trace.h index ea85c6114e..38867e0b66 100644 --- a/include/openenclave/internal/trace.h +++ b/include/openenclave/internal/trace.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TRACE_H @@ -45,7 +45,7 @@ void initialize_log_config(void); #define OE_TRACE_FATAL(fmt, ...) \ OE_TRACE( \ OE_LOG_LEVEL_FATAL, \ - fmt "[%s %s:%d]\n", \ + fmt " [%s:%s:%d]\n", \ ##__VA_ARGS__, \ __FILE__, \ __FUNCTION__, \ @@ -54,7 +54,7 @@ void initialize_log_config(void); #define OE_TRACE_ERROR(fmt, ...) \ OE_TRACE( \ OE_LOG_LEVEL_ERROR, \ - fmt "[%s %s:%d]\n", \ + fmt " [%s:%s:%d]\n", \ ##__VA_ARGS__, \ __FILE__, \ __FUNCTION__, \ @@ -63,7 +63,7 @@ void initialize_log_config(void); #define OE_TRACE_WARNING(fmt, ...) \ OE_TRACE( \ OE_LOG_LEVEL_WARNING, \ - fmt "[%s %s:%d]\n", \ + fmt " [%s:%s:%d]\n", \ ##__VA_ARGS__, \ __FILE__, \ __FUNCTION__, \ @@ -72,7 +72,7 @@ void initialize_log_config(void); #define OE_TRACE_INFO(fmt, ...) \ OE_TRACE( \ OE_LOG_LEVEL_INFO, \ - fmt "[%s %s:%d]\n", \ + fmt " [%s:%s:%d]\n", \ ##__VA_ARGS__, \ __FILE__, \ __FUNCTION__, \ @@ -81,7 +81,7 @@ void initialize_log_config(void); #define OE_TRACE_VERBOSE(fmt, ...) \ OE_TRACE( \ OE_LOG_LEVEL_VERBOSE, \ - fmt "[%s %s:%d]\n", \ + fmt " [%s:%s:%d]\n", \ ##__VA_ARGS__, \ __FILE__, \ __FUNCTION__, \ diff --git a/include/openenclave/internal/types.h b/include/openenclave/internal/types.h index 78e597eaa9..889033eb4b 100644 --- a/include/openenclave/internal/types.h +++ b/include/openenclave/internal/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_INTERNAL_TYPES_H diff --git a/include/openenclave/internal/utils.h b/include/openenclave/internal/utils.h index 46d8c4ae1e..93716b343a 100644 --- a/include/openenclave/internal/utils.h +++ b/include/openenclave/internal/utils.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_UTILS_H @@ -6,6 +6,9 @@ #include #include +#if defined(_MSC_VER) +#include +#endif OE_EXTERNC_BEGIN @@ -126,10 +129,17 @@ OE_INLINE uint64_t StrCode(const char* s, uint64_t n) * understanding see "C++ and the Perils of Double-Checked Locking" * http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf. */ +#if defined(__linux__) #define OE_ATOMIC_MEMORY_BARRIER_ACQUIRE() \ __atomic_thread_fence(__ATOMIC_ACQUIRE) #define OE_ATOMIC_MEMORY_BARRIER_RELEASE() \ __atomic_thread_fence(__ATOMIC_RELEASE) +#elif defined(_MSC_VER) +#define OE_ATOMIC_MEMORY_BARRIER_ACQUIRE() _ReadBarrier() +#define OE_ATOMIC_MEMORY_BARRIER_RELEASE() _WriteBarrier() +#else +#error "Unsupported platform" +#endif #if __x86_64__ || _M_X64 #define OE_CPU_RELAX() asm volatile("pause" ::: "memory") diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index f6f76b28df..4cf4f3375f 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Build the C library, using local sources and sources from musl. @@ -76,7 +76,6 @@ add_library(oelibc STATIC strerror.c syscalls.c sysconf.c - time.c regcomp.c regexec.c tre-mem.c @@ -747,6 +746,7 @@ add_library(oelibc STATIC ${MUSLSRC}/time/mktime.c ${MUSLSRC}/time/nanosleep.c ${MUSLSRC}/time/__secs_to_tm.c + ${MUSLSRC}/time/strftime.c ${MUSLSRC}/time/__tz.c ${MUSLSRC}/time/time.c ${MUSLSRC}/time/__tm_to_secs.c diff --git a/libc/__printf_chk.c b/libc/__printf_chk.c index 90c86f0df7..75792e28e2 100644 --- a/libc/__printf_chk.c +++ b/libc/__printf_chk.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/__vfprintf_chk.c b/libc/__vfprintf_chk.c index 695dc8e6a0..3b04b0627d 100644 --- a/libc/__vfprintf_chk.c +++ b/libc/__vfprintf_chk.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/atexit.c b/libc/atexit.c index de3a56bc69..6a9916fdb5 100644 --- a/libc/atexit.c +++ b/libc/atexit.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/dladdr.c b/libc/dladdr.c index aa9deb9969..4cc093abb2 100644 --- a/libc/dladdr.c +++ b/libc/dladdr.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define _GNU_SOURCE diff --git a/libc/epoll.c b/libc/epoll.c index 9fa1c842d4..70847f14ec 100644 --- a/libc/epoll.c +++ b/libc/epoll.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/errno.c b/libc/errno.c index c226e12ba8..9c2c084279 100644 --- a/libc/errno.c +++ b/libc/errno.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/exit.c b/libc/exit.c index 1c82080556..1362c421f1 100644 --- a/libc/exit.c +++ b/libc/exit.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/freeaddrinfo.c b/libc/freeaddrinfo.c index 7cc4e749c0..cfcbea21af 100644 --- a/libc/freeaddrinfo.c +++ b/libc/freeaddrinfo.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/getaddrinfo.c b/libc/getaddrinfo.c index aaf3e52cb2..d77a1a1ae2 100644 --- a/libc/getaddrinfo.c +++ b/libc/getaddrinfo.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/getnameinfo.c b/libc/getnameinfo.c index 76df49ddc5..3ce7cfa5c6 100644 --- a/libc/getnameinfo.c +++ b/libc/getnameinfo.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/kill.c b/libc/kill.c index db66222964..ca452550fb 100644 --- a/libc/kill.c +++ b/libc/kill.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/libunwind_stubs.c b/libc/libunwind_stubs.c index b0f766a021..7bafb41ad1 100644 --- a/libc/libunwind_stubs.c +++ b/libc/libunwind_stubs.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define _GNU_SOURCE diff --git a/libc/link.c b/libc/link.c index bfac7463bc..48bb303fb2 100644 --- a/libc/link.c +++ b/libc/link.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/locale.c b/libc/locale.c index 42fb32fa2c..406aad06a0 100644 --- a/libc/locale.c +++ b/libc/locale.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/malloc.c b/libc/malloc.c index 8e31b83fcd..9677a690f4 100644 --- a/libc/malloc.c +++ b/libc/malloc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/optee/abort.c b/libc/optee/abort.c index 81b6dfb405..84e9233fbb 100644 --- a/libc/optee/abort.c +++ b/libc/optee/abort.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/optee/arc4random.c b/libc/optee/arc4random.c index 1efa46f0b9..51e8e09e95 100644 --- a/libc/optee/arc4random.c +++ b/libc/optee/arc4random.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/optee/trace.c b/libc/optee/trace.c index b08e6913c5..8fa8d85569 100644 --- a/libc/optee/trace.c +++ b/libc/optee/trace.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/pthread.c b/libc/pthread.c index 19e69ba424..0f702ade15 100644 --- a/libc/pthread.c +++ b/libc/pthread.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/regcomp.c b/libc/regcomp.c index ad04ef62aa..2ed65af07f 100644 --- a/libc/regcomp.c +++ b/libc/regcomp.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef NDEBUG diff --git a/libc/regexec.c b/libc/regexec.c index 6f80507278..b45dbdbf19 100644 --- a/libc/regexec.c +++ b/libc/regexec.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef NDEBUG diff --git a/libc/sched_yield.c b/libc/sched_yield.c index 95ee7eedce..f8373d0ed7 100644 --- a/libc/sched_yield.c +++ b/libc/sched_yield.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/sgx/abort.S b/libc/sgx/abort.S index bad56405c4..069cb78740 100644 --- a/libc/sgx/abort.S +++ b/libc/sgx/abort.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. .globl abort diff --git a/libc/sgx/arc4random.c b/libc/sgx/arc4random.c index f811589f86..ac27f7e74e 100644 --- a/libc/sgx/arc4random.c +++ b/libc/sgx/arc4random.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* Ignore unused-variable warning in system header */ diff --git a/libc/sgx/exp2l.S b/libc/sgx/exp2l.S index e948cb1696..ca68f4c67c 100644 --- a/libc/sgx/exp2l.S +++ b/libc/sgx/exp2l.S @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // Rename the expm1l() defined in exp2l.s and use the definition in expm1l.c diff --git a/libc/sigaction.c b/libc/sigaction.c index 41f829abee..f7ff359208 100644 --- a/libc/sigaction.c +++ b/libc/sigaction.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/signal.c b/libc/signal.c index 40a5eaaf8c..eb20de3fa5 100644 --- a/libc/signal.c +++ b/libc/signal.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/stdlib.c b/libc/stdlib.c index d71af7a11e..1c30d97dbf 100644 --- a/libc/stdlib.c +++ b/libc/stdlib.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/strerror.c b/libc/strerror.c index aa14cbc8ff..fea32d054c 100644 --- a/libc/strerror.c +++ b/libc/strerror.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/syscalls.c b/libc/syscalls.c index a23f5ffb72..5261bdfe30 100644 --- a/libc/syscalls.c +++ b/libc/syscalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define __OE_NEED_TIME_CALLS diff --git a/libc/sysconf.c b/libc/sysconf.c index f520f40d01..090f1d5335 100644 --- a/libc/sysconf.c +++ b/libc/sysconf.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/libc/time.c b/libc/time.c deleted file mode 100644 index b2fd04113e..0000000000 --- a/libc/time.c +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include -#include -#include -#include -#include - -// MUSL gmtime_r.c depends on these variable definitions. -const char __gmt[] = "GMT"; - -size_t strftime(char* s, size_t max, const char* format, const struct tm* tm) -{ - OE_UNUSED(s); - OE_UNUSED(max); - OE_UNUSED(format); - OE_UNUSED(tm); - assert("strftime(): panic" == NULL); - return 0; -} - -size_t strftime_l( - char* s, - size_t max, - const char* format, - const struct tm* tm, - locale_t loc) -{ - OE_UNUSED(s); - OE_UNUSED(max); - OE_UNUSED(format); - OE_UNUSED(tm); - OE_UNUSED(loc); - assert("strftime_l(): panic" == NULL); - return 0; -} diff --git a/libc/tre-mem.c b/libc/tre-mem.c index 93d9d32766..12b42dd7bf 100644 --- a/libc/tre-mem.c +++ b/libc/tre-mem.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef NDEBUG diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index a5b109543d..3518f70eda 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oelibcxx STATIC) diff --git a/pkgconfig/CMakeLists.txt b/pkgconfig/CMakeLists.txt index a0af26df0b..8b89434748 100644 --- a/pkgconfig/CMakeLists.txt +++ b/pkgconfig/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== @@ -27,7 +27,9 @@ set(ENCLAVE_CFLAGS_LIST -fPIE -ftls-model=local-exec -fvisibility=hidden - -fno-stack-protector) + -fno-stack-protector + -ffunction-sections + -fdata-sections) set(ENCLAVE_CFLAGS_CLANG_LIST ${ENCLAVE_CFLAGS_LIST} ${SPECTRE_MITIGATION_FLAGS}) list(JOIN ENCLAVE_CFLAGS_CLANG_LIST " " ENCLAVE_CFLAGS_CLANG) @@ -52,6 +54,7 @@ set(ENCLAVE_CLIBS_1 -Wl,--build-id -Wl,-z,noexecstack -Wl,-z,now + -Wl,-gc-sections -L\${libdir}/openenclave/enclave -loeenclave -loecryptombed @@ -90,10 +93,10 @@ set(HOST_CXXFLAGS_GCC ${HOST_CFLAGS_GCC}) ## ##============================================================================== -if(USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) set(SGX_LIBS "-lsgx_enclave_common -lsgx_dcap_ql -lsgx_urts") else() - set(SGX_LIBS "") + set(SGX_LIBS "-lsgx_enclave_common -lsgx_urts") endif() set(HOSTVERIFY_CLIBS "-rdynamic -Wl,-z,noexecstack -L\${libdir}/openenclave/host -loehostverify -ldl -lpthread") diff --git a/pkgconfig/oeenclave-clang++.pc b/pkgconfig/oeenclave-clang++.pc index 7c31714d30..9ca45a5e49 100644 --- a/pkgconfig/oeenclave-clang++.pc +++ b/pkgconfig/oeenclave-clang++.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oeenclave-clang.pc b/pkgconfig/oeenclave-clang.pc index 98b8aac6e2..0e2c77d6ea 100644 --- a/pkgconfig/oeenclave-clang.pc +++ b/pkgconfig/oeenclave-clang.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oeenclave-g++.pc b/pkgconfig/oeenclave-g++.pc index dcac3f09ef..1c2f81d433 100644 --- a/pkgconfig/oeenclave-g++.pc +++ b/pkgconfig/oeenclave-g++.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oeenclave-gcc.pc b/pkgconfig/oeenclave-gcc.pc index 4e0e6a54ea..4267b8db03 100644 --- a/pkgconfig/oeenclave-gcc.pc +++ b/pkgconfig/oeenclave-gcc.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oehost-clang++.pc b/pkgconfig/oehost-clang++.pc index 37951b49fb..89b5c91e0f 100644 --- a/pkgconfig/oehost-clang++.pc +++ b/pkgconfig/oehost-clang++.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oehost-clang.pc b/pkgconfig/oehost-clang.pc index face75da56..702ac7afb2 100644 --- a/pkgconfig/oehost-clang.pc +++ b/pkgconfig/oehost-clang.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oehost-g++.pc b/pkgconfig/oehost-g++.pc index 87ae5a0a7a..944f85875b 100644 --- a/pkgconfig/oehost-g++.pc +++ b/pkgconfig/oehost-g++.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oehost-gcc.pc b/pkgconfig/oehost-gcc.pc index 02772dbf00..6c86ba0062 100644 --- a/pkgconfig/oehost-gcc.pc +++ b/pkgconfig/oehost-gcc.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=${pcfiledir}/../.. diff --git a/pkgconfig/oehostverify-clang++.pc b/pkgconfig/oehostverify-clang++.pc index 2fe6d6f7e5..33c01b43f7 100644 --- a/pkgconfig/oehostverify-clang++.pc +++ b/pkgconfig/oehostverify-clang++.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=@PREFIX@ diff --git a/pkgconfig/oehostverify-clang.pc b/pkgconfig/oehostverify-clang.pc index 38995a0c1c..ed5b67a287 100644 --- a/pkgconfig/oehostverify-clang.pc +++ b/pkgconfig/oehostverify-clang.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=@PREFIX@ diff --git a/pkgconfig/oehostverify-g++.pc b/pkgconfig/oehostverify-g++.pc index fabda9a79d..da30cf65b5 100644 --- a/pkgconfig/oehostverify-g++.pc +++ b/pkgconfig/oehostverify-g++.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=@PREFIX@ diff --git a/pkgconfig/oehostverify-gcc.pc b/pkgconfig/oehostverify-gcc.pc index f0518775ac..0559e1f588 100644 --- a/pkgconfig/oehostverify-gcc.pc +++ b/pkgconfig/oehostverify-gcc.pc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. prefix=@PREFIX@ diff --git a/prereqs/Makefile b/prereqs/Makefile deleted file mode 100644 index 48b4343aa0..0000000000 --- a/prereqs/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -DIRS = packages isgx aesm - -define NL - - -endef - -all: - $(foreach i, $(DIRS), $(MAKE) -C $(i) $(NL) ) - -install: - $(foreach i, $(DIRS), $(MAKE) -C $(i) install $(NL) ) - -uninstall: - $(foreach i, $(DIRS), $(MAKE) -C $(i) uninstall $(NL) ) - -clean: - $(foreach i, $(DIRS), $(MAKE) -C $(i) clean $(NL) ) - -distclean: - $(foreach i, $(DIRS), $(MAKE) -C $(i) distclean $(NL) ) diff --git a/prereqs/README.md b/prereqs/README.md index 6d189443b2..f9c9643f42 100644 --- a/prereqs/README.md +++ b/prereqs/README.md @@ -1,11 +1 @@ -prereqs -======= - -This directory contains a makefile to build and install Open Enclave -prerequisites, including: - -- Package dependencies - -- Intel(R) SGX driver - -- Intel(R) SGX AESM service +This is a placeholder file specifically to keep this directory's existence around until we no longer expect NuGet packages to be installed to this directory. \ No newline at end of file diff --git a/prereqs/aesm/Makefile b/prereqs/aesm/Makefile deleted file mode 100644 index 71c195f7ef..0000000000 --- a/prereqs/aesm/Makefile +++ /dev/null @@ -1,171 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -.PHONY: sgx1 - -##============================================================================== -## -## SDK_VERSION - get the version from the se_version.h file: -## -##============================================================================== - -define SDK_VERSION_SCRIPT -grep "^#define STRFILEVER[ \t]" ./linux-sgx/common/inc/internal/se_version.h 2> /dev/null | sed "s/^#define STRFILEVER[ \t][ \t]*\"\(.*\)\"/\1/g" -endef - -##============================================================================== -## -## build: -## -##============================================================================== - -#INSTALL_SDK=1 - -build: .build - -.build: - $(MAKE) linux-sgx - $(MAKE) dynamic-application-loader-host-interface - $(MAKE) .prebuilt - $(MAKE) .sdk - rm -f ./linux-sgx/linux/installer/bin/sgx_linux_x64_sdk_*.bin - $(MAKE) .sdk_installer - rm -f ./linux-sgx/linux/installer/bin/sgx_linux_x64_psw_*.bin - $(MAKE) .psw_installer - $(MAKE) build-dynamic-application-loader-host-interface - touch .build - -linux-sgx: - git clone https://github.com/01org/linux-sgx - -dynamic-application-loader-host-interface: - git clone https://github.com/01org/dynamic-application-loader-host-interface - -.prebuilt: - ( cd linux-sgx; ./download_prebuilt.sh ) - touch .prebuilt - -.sdk: - $(MAKE) -C linux-sgx - touch .sdk - -.sdk_installer: - $(MAKE) -C linux-sgx sdk_install_pkg - touch .sdk_installer - -.psw_installer: - $(MAKE) -C linux-sgx psw_install_pkg - touch .psw_installer - -build-dynamic-application-loader-host-interface: - ( cd dynamic-application-loader-host-interface; cmake . ) - $(MAKE) -C dynamic-application-loader-host-interface - -##============================================================================== -## -## clean: -## -##============================================================================== - -clean: clean-linux-sdk clean-dynamic-application-loader-host-interface - -clean-linux-sdk: - -@ $(MAKE) -C linux-sgx clean - rm -f .sdk .build .sdk_installer .psw_installer - -clean-dynamic-application-loader-host-interface: - -@ $(MAKE) -C dynamic-application-loader-host-interface clean - -##============================================================================== -## -## distclean: -## -##============================================================================== - -distclean: clean - rm -rf linux-sgx - rm -rf dynamic-application-loader-host-interface - rm -f .prebuilt - -##============================================================================== -## -## install: -## -##============================================================================== - -ICLS_CLIENT_DEB=$(wildcard ./packages/iclsclient_*_amd64.deb) -SDK_VERSION=$(shell $(SDK_VERSION_SCRIPT) ) -SDK_INSTALLER=./linux-sgx/linux/installer/bin/sgx_linux_x64_sdk_$(SDK_VERSION).bin -PSW_INSTALLER=./linux-sgx/linux/installer/bin/sgx_linux_x64_psw_$(SDK_VERSION).bin - -install: - $(MAKE) stop - $(MAKE) install-sdk - $(MAKE) install-build-dynamic-application-loader-host-interface - $(MAKE) install-psw - $(MAKE) start - -install-sdk: -ifdef INSTALL_SDK - $(MAKE) /opt/intel/sgxsdk -endif - -/opt/intel/sgxsdk: - echo "y" >> /tmp/answers - echo "/opt/intel" >> /tmp/answers - $(SDK_INSTALLER) < /tmp/answers - -install-psw: /opt/intel/sgxpsw - -/opt/intel/sgxpsw: - $(PSW_INSTALLER) - -install-build-dynamic-application-loader-host-interface: - $(MAKE) -C dynamic-application-loader-host-interface install - ( cd dynamic-application-loader-host-interface; systemctl enable jhi ) - -install-icls-client: - dpkg -i $(ICLS_CLIENT_DEB) - -##============================================================================== -## -## uninstall: -## -##============================================================================== - -uninstall: - $(MAKE) -s stop - $(MAKE) -s uninstall-sdk - $(MAKE) -s uninstall-psw - -uninstall-sdk: - - /opt/intel/sgxsdk/uninstall.sh 2> /dev/null > /dev/null - -uninstall-psw: - - /opt/intel/sgxpsw/uninstall.sh 2> /dev/null > /dev/null - -##============================================================================== -## -## start-aesmd: -## stop-aesmd: -## -##============================================================================== - -start: - service aesmd start - -stop: - -@ service aesmd stop 2> /dev/null > /dev/null - -status: - service aesmd status - -##============================================================================== -## -## sdk-version: print the SDK version: -## -##============================================================================== - -sdk-version: - @ echo $(SDK_VERSION) - diff --git a/prereqs/isgx/Makefile b/prereqs/isgx/Makefile deleted file mode 100644 index 0983cc1404..0000000000 --- a/prereqs/isgx/Makefile +++ /dev/null @@ -1,102 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -all: linux-sgx-driver build - -build: - $(MAKE) -C linux-sgx-driver - -linux-sgx-driver: - git clone https://github.com/01org/linux-sgx-driver - -clean: - $(MAKE) -C linux-sgx-driver clean - -distclean: - rm -rf linux-sgx-driver - -##============================================================================== -## -## install: -## -##============================================================================== - -MODULE=$(wildcard ./linux-sgx-driver/isgx.ko) - -UNAME_R=$(shell uname -r) - -DIR=/lib/modules/$(UNAME_R)/kernel/drivers/intel/sgx - -DEV=$(wildcard /dev/isgx) - -RUNNING=$(shell lsmod | grep isgx) - -install: - $(MAKE) -s stop-aesm - $(MAKE) -s run-rmmod - $(MAKE) mkdir - $(MAKE) check-module - $(MAKE) check-device - $(MAKE) copy-module - $(MAKE) update-modules - $(MAKE) run-depmod - $(MAKE) run-modprobe - $(MAKE) check-running - $(MAKE) -s start-aesm - -stop-aesm: - -@ service aesmd stop 2> /dev/null > /dev/null - -start-aesm: - -@ service aesmd start 2> /dev/null > /dev/null - -run-rmmod: - -@ /sbin/rmmod isgx 2> /dev/null > /dev/null - -mkdir: - mkdir -p $(DIR) - -check-module: -ifeq ($(MODULE),) - @ echo "*** Module not found: $(MODULE)" - @ exit 1 -endif - -check-device: -ifneq ($(DEV),) - @ echo "*** Device already exists: {$(DEV)}" - @ exit 1 -endif - -copy-module: - cp $(MODULE) $(DIR) - -update-modules: - ( cat /etc/modules | grep -Fxq isgx || echo isgx >> /etc/modules ) - -run-depmod: - /sbin/depmod - -run-modprobe: - /sbin/modprobe isgx - -check-running: -ifeq ($(RUNNING),) - @ echo "*** Failed to start driver: isgx not found by lsmod" - @ exit 1 -endif -ifeq ($(DEV),) - @ echo "*** Failed to start driver: /dev/isgx does not exist" - @ exit 1 -endif - -##============================================================================== -## -## uninstall: -## -##============================================================================== - -uninstall: - $(MAKE) -s stop-aesm - $(MAKE) -s run-rmmod - diff --git a/prereqs/packages/Makefile b/prereqs/packages/Makefile deleted file mode 100644 index 5210dfcc79..0000000000 --- a/prereqs/packages/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -# Packages needed for building AESM and ISGX driver -PACKAGES=build-essential \ - ocaml \ - automake \ - autoconf \ - libtool \ - wget \ - python \ - libssl-dev \ - libcurl4-openssl-dev \ - protobuf-compiler \ - libprotobuf-dev \ - build-essential \ - python \ - libssl-dev \ - libcurl4-openssl-dev \ - libprotobuf-dev \ - uuid-dev \ - libxml2-dev \ - cmake \ - pkg-config \ - subversion \ - cloc \ - libexpat1 \ - libexpat1-dev \ - ccache \ - libsystemd-dev - -all: .packages - -.packages: - apt-get -y install $(PACKAGES) - touch .packages - -clean: - -distclean: - rm -f .packages - -install: - -uninstall: diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index fdd493a7ef..208b1d508e 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -1,19 +1,42 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. -if (USE_LIBSGX) - install(DIRECTORY remote_attestation local_attestation attested_tls - DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples - PATTERN "gen_pubkey_header.sh" - PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ +if (HAS_QUOTE_PROVIDER) + install(DIRECTORY remote_attestation + DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples + PATTERN "gen_pubkey_header.sh" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) + install(DIRECTORY attested_tls + DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples + PATTERN "gen_pubkey_header.sh" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) endif () -install(DIRECTORY helloworld file-encryptor data-sealing - DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples) +install(DIRECTORY local_attestation + DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples + PATTERN "gen_pubkey_header.sh" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ) -install(FILES README.md - DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples) +install(DIRECTORY helloworld file-encryptor data-sealing switchless + DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples) -add_test(NAME samples - COMMAND ${CMAKE_COMMAND} -DUSE_LIBSGX=${USE_LIBSGX} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBUILD_DIR=${PROJECT_BINARY_DIR} -DPREFIX_DIR=${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_SOURCE_DIR}/test-samples.cmake) +if (WIN32) + install(FILES README_Windows.md + DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples + RENAME README.md) +else () + install(FILES README_Linux.md + DESTINATION ${CMAKE_INSTALL_DATADIR}/openenclave/samples + RENAME README.md) +endif () + +if (WIN32) + add_test(NAME samples + COMMAND ${CMAKE_COMMAND} -DHAS_QUOTE_PROVIDER=${HAS_QUOTE_PROVIDER} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBUILD_DIR=${PROJECT_BINARY_DIR} -DPREFIX_DIR=${CMAKE_INSTALL_PREFIX} -DNUGET_PACKAGE_PATH=${NUGET_PACKAGE_PATH} -P ${CMAKE_CURRENT_SOURCE_DIR}/test-samples.cmake) +else () + add_test(NAME samples + COMMAND ${CMAKE_COMMAND} -DHAS_QUOTE_PROVIDER=${HAS_QUOTE_PROVIDER} -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBUILD_DIR=${PROJECT_BINARY_DIR} -DPREFIX_DIR=${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_SOURCE_DIR}/test-samples.cmake) +endif () diff --git a/samples/README.md b/samples/README_Linux.md similarity index 85% rename from samples/README.md rename to samples/README_Linux.md index c90c3e129d..0850852136 100644 --- a/samples/README.md +++ b/samples/README_Linux.md @@ -1,21 +1,9 @@ -# Open Enclave SDK Samples +# Building Open Enclave SDK Samples on Linux -All the samples that come with the Open Enclave SDK installation share similar directory structure and build instructions. The section contains general information on how to setup/build/sign/run all samples. It's important that you read information on this page before jumping into any individual sample. +All the samples that come with the Open Enclave SDK installation share a similar directory structure and build instructions. This document describes how to setup, build, sign and run these samples. ## Common Sample information -### Prepare samples - -Building samples involves writing files into the working directory, which is not allowed in `/opt` unless it's running in the context of superuser (`sudo`). - -To avoid this `sudo` requirement, you may want to first copy them to a user directory of your choice then build and run on those local copy. - -For example, assuming Open Enclave SDK is installed to the default location `/opt/openenclave`: - -```bash -cp -r /opt/openenclave/share/openenclave/samples ~/mysamples -``` - ### How Sample source code directories were structured Open Enclave SDK helps developers build enclave applications. An enclave application is partitioned into an untrusted component (called a host) and a trusted component (called an enclave). An enclave is a secure container whose memory (text and data) is protected from access by outside entities, including the host, privileged users, and even the hardware. All functionality that needs to be run in a Trusted Execution Environment (TEE) should be compiled into the enclave binary. The enclave may run in an untrusted environment with the expectation that secrets will not be compromised. A host is a normal user mode application that loads an enclave into its address space before starting interacting with an enclave. @@ -26,7 +14,7 @@ All the samples that come with the Open Enclave SDK installation are all structu | Files/dir | contents | |:-----------------|---------------------------------------------| -| Makefile | Makefile for the whole samples | +| Makefile | Makefile for building all samples | | ./enclave | Files needed for building the sample enclave| | ./host | Files needed for building the host | @@ -40,6 +28,17 @@ drwxr-xr-x 2 yourusername yourusername 4096 Aug 16 13:59 host -rw-r--r-- 1 yourusername yourusername 245 Aug 16 13:57 Makefile ``` +### Prepare samples + +Building samples involves writing files into the working directory, which is not allowed in `/opt` unless it's running in the context of superuser (`sudo`). + +Before building any of the samples, please copy them out of the /opt/openenclave/share/openenclave/samples directory to a directory where your current user has write permissions. A normal user usually does not have permission to write files into a directory in /opt. + +For example, assuming Open Enclave SDK is installed to the default location `/opt/openenclave`: + +```bash +cp -r /opt/openenclave/share/openenclave/samples ~/mysamples +``` ### How to build and run samples Each sample comes with two different build systems: one using GNU Make and pkg-config, the other using CMake. They help simplify the sample building process, which involves building and signing @@ -147,3 +146,11 @@ The following samples demonstrate how to develop enclave applications using OE A - between two enclaves - between one non-enclave client and an enclave +#### [Switchless Calls](switchless/README.md) + +- Explain the concept of switchless calls +- Identify cases where switchless calls are appropriate +- Demonstrate how to mark a function as `transition_using_threads` in EDL +- Demonstrate how to configure an enclave to enable switchless calls originated within it +- Recommend the number of host worker threads required for switchless calls in practice +- Demonstrate how to enable switchless calls in an enclave application diff --git a/samples/README_Windows.md b/samples/README_Windows.md new file mode 100644 index 0000000000..4de561e20c --- /dev/null +++ b/samples/README_Windows.md @@ -0,0 +1,107 @@ +# Building Open Enclave SDK Samples on Windows + +All the samples that come with the Open Enclave SDK installation share a similar directory structure and build instructions. This document describes how to setup, build, sign and run these samples. + +## Common Sample information + +### How Sample source code directories were structured + +Open Enclave SDK helps developers build enclave applications. An enclave application is partitioned into an untrusted component (called a host) and a trusted component (called an enclave). + +An enclave is a secure container whose memory (text and data) is protected from access by outside entities, including the host, privileged users, and even the hardware. All functionality that needs to be run in a Trusted Execution Environment (TEE) should be compiled into the enclave binary. The enclave may run in an untrusted environment with the expectation that secrets will not be compromised. On Windows and Linux, enclaves are ELF binaries. + +A host is a normal user mode application that loads an enclave into its address space before starting interacting with an enclave. + +![Sample components diagram](sampledirstructure.png) + +All the samples that come with the Open Enclave SDK installation are all structured into two subdirectories (one for enclave and one for host) accordingly. + +| Files/dir | contents | +|:-----------------|---------------------------------------------| +| enclave | Files needed for building the sample enclave | +| host | Files needed for building the host | + +### Prepare samples + +Building a sample will write intermediate and output files into the sample directory. If you would like to use a separate working directory for building samples, you can copy the samples to your working directory first. For example, if the SDK was installed to C:\openenclave: + +```cmd +xcopy C:\openenclave\share\openenclave\samples C:\mysample +``` + +### How to build and run samples + +1. [x64 Native Tools Command Prompt for VS2017 or 2019]( +https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs) + +2. Set `OpenEnclave_DIR` to the cmake directory in the Open Enclave SDK installation. + +As an example, if the Open Enclave SDK is installed to `C:\openenclave`, then you would set `OpenEnclave_DIR` as shown below + +```cmd +set OpenEnclave_DIR=C:\openenclave\lib\openenclave\cmake +``` + +3. To build a sample using CMake, change directory to your target sample directory and execute the following commands: + +```cmd +mkdir build +cd build +cmake .. -G Ninja -DNUGET_PACKAGE_PATH=C:\oe_prereqs +ninja +``` + +4. To run the sample, use below: + +```cmd +ninja run +``` + +## Samples + +The following samples demonstrate how to develop enclave applications using OE APIs. It's recommended to go through the following samples in the order listed. + +#### [HelloWorld](helloworld/README.md) + +- Minimum code needed for an OE app +- Help understand the basic components an OE application +- Demonstrate how to build, sign, and run an OE image + +#### [File-Encryptor](file-encryptor/README.md) + +- Shows how to encrypt and decrypt data inside an enclave +- Uses AES mbedTLS API to perform encryption and decryption + +#### [Data-Sealing](data-sealing/README.md) + +- Introduce OE sealing and unsealing features +- Demonstrate how to use OE sealing APIs +- Explore two supported seal polices + - OE_SEAL_POLICY_UNIQUE + - OE_SEAL_POLICY_PRODUCT + +#### [Remote Attestation](remote_attestation/README.md) + +- Explain how OE attestation works +- Demonstrate an implementation of remote attestation between two enclaves running on different machines + +#### [Local Attestation](local_attestation/README.md) + +- Explain the concept of OE local attestation +- Demonstrate an implementation of local attestation between two enclaves on the same VM + +#### [Attested TLS](attested_tls/README.md) + +- Explain what an Attested TLS channel is +- Demonstrate an implementation for how to establish an Attested TLS channel + - between two enclaves + - between one non-enclave client and an enclave + +#### [Switchless Calls](switchless/README.md) + +- Explain the concept of switchless calls +- Identify cases where switchless calls are appropriate +- Demonstrate how to mark a function as `transition_using_threads` in EDL +- Demonstrate how to configure an enclave to enable switchless calls originated within it +- Recommend the number of host worker threads required for switchless calls in practice +- Demonstrate how to enable switchless calls in an enclave application diff --git a/samples/attested_tls/CMakeLists.txt b/samples/attested_tls/CMakeLists.txt index e914109b6b..8caddd7c0d 100644 --- a/samples/attested_tls/CMakeLists.txt +++ b/samples/attested_tls/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.11) @@ -16,12 +16,12 @@ if ((NOT DEFINED ENV{OE_SIMULATION}) OR (NOT $ENV{OE_SIMULATION})) add_custom_target(run DEPENDS tls_server tls_client tls_non_enc_client tls_client_enc tls_server_enc COMMENT "Launch processes to establish an Attested TLS between two enclaves" - COMMAND ${CMAKE_BINARY_DIR}/server/host/tls_server_host ${CMAKE_BINARY_DIR}/server/enc/tls_server_enc.signed -port:12341 & + COMMAND bash -c "${CMAKE_BINARY_DIR}/server/host/tls_server_host ${CMAKE_BINARY_DIR}/server/enc/tls_server_enc.signed -port:12341 &" COMMAND ${CMAKE_COMMAND} -E sleep 2 COMMAND ${CMAKE_BINARY_DIR}/client/host/tls_client_host ${CMAKE_BINARY_DIR}/client/enc/tls_client_enc.signed -server:localhost -port:12341 COMMAND ${CMAKE_COMMAND} -E sleep 2 COMMENT "Launch processes to establish an Attested TLS between an non-encalve TLS client and an TLS server running inside an enclave " - COMMAND ${CMAKE_BINARY_DIR}/server/host/tls_server_host ${CMAKE_BINARY_DIR}/server/enc/tls_server_enc.signed -port:12341 & + COMMAND bash -c "${CMAKE_BINARY_DIR}/server/host/tls_server_host ${CMAKE_BINARY_DIR}/server/enc/tls_server_enc.signed -port:12341 &" COMMAND ${CMAKE_COMMAND} -E sleep 2 COMMAND ${CMAKE_BINARY_DIR}/non_enc_client/tls_non_enc_client -server:localhost -port:12341) endif () diff --git a/samples/attested_tls/Makefile b/samples/attested_tls/Makefile index e8a3e8986b..cff2e53006 100644 --- a/samples/attested_tls/Makefile +++ b/samples/attested_tls/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run diff --git a/samples/attested_tls/client/CMakeLists.txt b/samples/attested_tls/client/CMakeLists.txt index dfec8232d2..6d0d982141 100644 --- a/samples/attested_tls/client/CMakeLists.txt +++ b/samples/attested_tls/client/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(enc) diff --git a/samples/attested_tls/client/Makefile b/samples/attested_tls/client/Makefile index 9c1b11ddf5..deb906af40 100644 --- a/samples/attested_tls/client/Makefile +++ b/samples/attested_tls/client/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. all: build diff --git a/samples/attested_tls/client/enc/CMakeLists.txt b/samples/attested_tls/client/enc/CMakeLists.txt index 28ea9aa1b3..9be4fbd866 100644 --- a/samples/attested_tls/client/enc/CMakeLists.txt +++ b/samples/attested_tls/client/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Use the edger8r to generate C bindings from the EDL file. @@ -18,7 +18,13 @@ add_executable(tls_client_enc cert_verifier.cpp identity_verifier.cpp ../../common/utility.cpp - ${CMAKE_CURRENT_BINARY_DIR}/tls_client_t.c) + ${CMAKE_CURRENT_BINARY_DIR}/tls_client_t.c) + +add_dependencies(tls_client_enc tls_server_sign_enc) + +if (WIN32) + maybe_build_using_clangw(tls_client_enc) +endif () target_compile_definitions(tls_client_enc PUBLIC OE_API_VERSION=2) diff --git a/samples/attested_tls/client/enc/Makefile b/samples/attested_tls/client/enc/Makefile index 2abb1945f7..14d50804ba 100644 --- a/samples/attested_tls/client/enc/Makefile +++ b/samples/attested_tls/client/enc/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/attested_tls/client/enc/cert_verifier.cpp b/samples/attested_tls/client/enc/cert_verifier.cpp index 2505d59529..f2345dac82 100644 --- a/samples/attested_tls/client/enc/cert_verifier.cpp +++ b/samples/attested_tls/client/enc/cert_verifier.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/attested_tls/client/enc/client.cpp b/samples/attested_tls/client/enc/client.cpp index 011b0f9554..cb6f0525ca 100644 --- a/samples/attested_tls/client/enc/client.cpp +++ b/samples/attested_tls/client/enc/client.cpp @@ -1,10 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include #include -#include #include #include #include @@ -14,8 +13,6 @@ #include #include "../../common/utility.h" -#define DEBUG_LEVEL 1 - extern "C" { int launch_tls_client(char* server_name, char* server_port); @@ -119,7 +116,7 @@ int handle_communication_until_done(mbedtls_ssl_context* ssl) // Write client payload to the server printf(TLS_CLIENT "Write to server-->:"); len = sprintf((char*)buf, CLIENT_PAYLOAD); - while ((ret = mbedtls_ssl_write(ssl, buf, len)) <= 0) + while ((ret = mbedtls_ssl_write(ssl, buf, (size_t)len)) <= 0) { if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) @@ -138,7 +135,7 @@ int handle_communication_until_done(mbedtls_ssl_context* ssl) { len = sizeof(buf) - 1; memset(buf, 0, sizeof(buf)); - ret = mbedtls_ssl_read(ssl, buf, len); + ret = mbedtls_ssl_read(ssl, buf, (size_t)len); if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) continue; @@ -159,8 +156,8 @@ int handle_communication_until_done(mbedtls_ssl_context* ssl) } len = ret; printf(TLS_CLIENT "%d bytes received from server:\n\n", len); - if ((len != SERVER_PAYLOAD_SIZE) || - (memcmp(SERVER_PAYLOAD, buf, len) != 0)) + if (((size_t)len != SERVER_PAYLOAD_SIZE) || + (memcmp(SERVER_PAYLOAD, buf, (size_t)len) != 0)) { printf( TLS_CLIENT @@ -187,7 +184,6 @@ int handle_communication_until_done(mbedtls_ssl_context* ssl) int launch_tls_client(char* server_name, char* server_port) { int ret = 1; - uint32_t flags; const char* pers = "ssl_client"; oe_result_t result = OE_FAILURE; int exit_code = MBEDTLS_EXIT_FAILURE; @@ -217,7 +213,6 @@ int launch_tls_client(char* server_name, char* server_port) } // Initialize mbedtls objects - mbedtls_debug_set_threshold(DEBUG_LEVEL); mbedtls_net_init(&server_fd); mbedtls_ssl_init(&ssl); mbedtls_ssl_config_init(&conf); diff --git a/samples/attested_tls/client/enc/crypto.cpp b/samples/attested_tls/client/enc/crypto.cpp index 0ed6053754..ebcdd00d3a 100644 --- a/samples/attested_tls/client/enc/crypto.cpp +++ b/samples/attested_tls/client/enc/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "crypto.h" diff --git a/samples/attested_tls/client/enc/crypto.h b/samples/attested_tls/client/enc/crypto.h index cf20f355f2..8cba0faa9a 100644 --- a/samples/attested_tls/client/enc/crypto.h +++ b/samples/attested_tls/client/enc/crypto.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H diff --git a/samples/attested_tls/client/enc/ecalls.cpp b/samples/attested_tls/client/enc/ecalls.cpp index e03d41123e..13bed1a3e9 100644 --- a/samples/attested_tls/client/enc/ecalls.cpp +++ b/samples/attested_tls/client/enc/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/attested_tls/client/enc/enc.conf b/samples/attested_tls/client/enc/enc.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/attested_tls/client/enc/enc.conf +++ b/samples/attested_tls/client/enc/enc.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/attested_tls/client/enc/identity_verifier.cpp b/samples/attested_tls/client/enc/identity_verifier.cpp index 8d4e825447..d4cbbe82db 100644 --- a/samples/attested_tls/client/enc/identity_verifier.cpp +++ b/samples/attested_tls/client/enc/identity_verifier.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -13,8 +13,9 @@ oe_result_t enclave_identity_verifier_callback( oe_identity_t* identity, void* arg) { + OE_UNUSED(arg); + oe_result_t result = OE_VERIFY_FAILED; - bool bret = false; printf(TLS_CLIENT "Client:enclave_identity_verifier_callback is called with enclave " diff --git a/samples/attested_tls/client/enc/log.h b/samples/attested_tls/client/enc/log.h index b064e3b905..507dcd8b81 100644 --- a/samples/attested_tls/client/enc/log.h +++ b/samples/attested_tls/client/enc/log.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_LOG_H diff --git a/samples/attested_tls/client/host/CMakeLists.txt b/samples/attested_tls/client/host/CMakeLists.txt index 0966389be3..89451f9020 100644 --- a/samples/attested_tls/client/host/CMakeLists.txt +++ b/samples/attested_tls/client/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT tls_client_u.h tls_client_u.c tls_client_args.h diff --git a/samples/attested_tls/client/host/Makefile b/samples/attested_tls/client/host/Makefile index 9bd5637d06..9885d1e1ce 100644 --- a/samples/attested_tls/client/host/Makefile +++ b/samples/attested_tls/client/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/attested_tls/client/host/host.cpp b/samples/attested_tls/client/host/host.cpp index df99b14882..8a4be171a1 100644 --- a/samples/attested_tls/client/host/host.cpp +++ b/samples/attested_tls/client/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -104,7 +104,7 @@ int main(int argc, const char* argv[]) goto exit; } - printf("Host: llaunch TLS client to initiate TLS connection\n"); + printf("Host: launch TLS client to initiate TLS connection\n"); ret = launch_tls_client(enclave, &ret, server_name, server_port); if (ret != 0) { diff --git a/samples/attested_tls/client/tls_client.edl b/samples/attested_tls/client/tls_client.edl index 0362263f86..d76fa877cd 100644 --- a/samples/attested_tls/client/tls_client.edl +++ b/samples/attested_tls/client/tls_client.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/attested_tls/common/common.h b/samples/attested_tls/common/common.h index c9c40b7551..74e1dd1ec6 100644 --- a/samples/attested_tls/common/common.h +++ b/samples/attested_tls/common/common.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // #define ADD_TEST_CHECKING diff --git a/samples/attested_tls/common/tls_client_enc_pubkey.h b/samples/attested_tls/common/tls_client_enc_pubkey.h index ebbc528edd..f10413c4f9 100644 --- a/samples/attested_tls/common/tls_client_enc_pubkey.h +++ b/samples/attested_tls/common/tls_client_enc_pubkey.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef SAMPLES_REMOTE_ATTESTATION_PUBKEY_H diff --git a/samples/attested_tls/common/tls_server_enc_pubkey.h b/samples/attested_tls/common/tls_server_enc_pubkey.h index 57603a74b7..d54d8a6756 100644 --- a/samples/attested_tls/common/tls_server_enc_pubkey.h +++ b/samples/attested_tls/common/tls_server_enc_pubkey.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef SAMPLES_REMOTE_ATTESTATION_PUBKEY_H diff --git a/samples/attested_tls/common/utility.cpp b/samples/attested_tls/common/utility.cpp index 40d6b78727..ab08faecc2 100644 --- a/samples/attested_tls/common/utility.cpp +++ b/samples/attested_tls/common/utility.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off @@ -94,7 +94,6 @@ oe_result_t generate_certificate_and_pkey( mbedtls_pk_context* private_key) { oe_result_t result = OE_FAILURE; - uint8_t* host_cert_buf = NULL; uint8_t* output_cert = NULL; size_t output_cert_size = 0; uint8_t* private_key_buf = NULL; @@ -245,7 +244,7 @@ bool verify_mrsigner( if (memcmp(signer, signer_id_buf, signer_id_buf_size) != 0) { printf("mrsigner is not equal!\n"); - for (int i = 0; i < signer_id_buf_size; i++) + for (int i = 0; i < (int)signer_id_buf_size; i++) { printf( "0x%x - 0x%x\n", (uint8_t)signer[i], (uint8_t)signer_id_buf[i]); diff --git a/samples/attested_tls/common/utility.h b/samples/attested_tls/common/utility.h index 8e94e032e0..6f8d145d7d 100644 --- a/samples/attested_tls/common/utility.h +++ b/samples/attested_tls/common/utility.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/attested_tls/non_enc_client/CMakeLists.txt b/samples/attested_tls/non_enc_client/CMakeLists.txt index bdbf6c8484..ad44206e6f 100644 --- a/samples/attested_tls/non_enc_client/CMakeLists.txt +++ b/samples/attested_tls/non_enc_client/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. find_package(OpenSSL REQUIRED) @@ -8,6 +8,8 @@ add_executable(tls_non_enc_client verify_callback.cpp verify_signer_openssl.cpp) +add_dependencies(tls_non_enc_client tls_server_sign_enc) + target_include_directories(tls_non_enc_client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} diff --git a/samples/attested_tls/non_enc_client/Makefile b/samples/attested_tls/non_enc_client/Makefile index 8a1b3dd614..6c74a6a648 100644 --- a/samples/attested_tls/non_enc_client/Makefile +++ b/samples/attested_tls/non_enc_client/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run diff --git a/samples/attested_tls/non_enc_client/client.cpp b/samples/attested_tls/non_enc_client/client.cpp index 6addd96e5d..91f4dccdd8 100644 --- a/samples/attested_tls/non_enc_client/client.cpp +++ b/samples/attested_tls/non_enc_client/client.cpp @@ -1,13 +1,19 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#ifdef _WIN32 +#include +#define close closesocket +#else #include #include #include #include -#include #include #include +#endif + +#include #include #include @@ -135,12 +141,47 @@ int create_socket(char* server_name, char* server_port) int sockfd = -1; char* addr_ptr = NULL; int port = 0; - struct hostent* host = NULL; - struct sockaddr_in dest_addr; + struct addrinfo hints, *dest_info, *curr_di; + int res; + +#ifdef _WIN32 + WSADATA wsaData; + if ((res = WSAStartup(MAKEWORD(2, 2), &wsaData)) != 0) + { + printf(TLS_CLIENT "Error: WSAStartup failed: %d\n", res); + goto done; + } +#endif + + hints = {0}; + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + + if ((res = getaddrinfo(server_name, server_port, &hints, &dest_info)) != 0) + { + printf( + TLS_CLIENT "Error: Cannot resolve hostname %s. %s\n", + server_name, + gai_strerror(res)); + goto done; + } + + curr_di = dest_info; + while (curr_di) + { + if (curr_di->ai_family == AF_INET) + { + break; + } - if ((host = gethostbyname(server_name)) == NULL) + curr_di = curr_di->ai_next; + } + + if (!curr_di) { - printf(TLS_CLIENT "Error: Cannot resolve hostname %s.\n", server_name); + printf( + TLS_CLIENT "Error: Cannot get address for hostname %s.\n", + server_name); goto done; } @@ -151,17 +192,10 @@ int create_socket(char* server_name, char* server_port) goto done; } - port = atoi(server_port); - dest_addr.sin_family = AF_INET; - dest_addr.sin_port = htons(port); - dest_addr.sin_addr.s_addr = *(long*)(host->h_addr); - - memset(&(dest_addr.sin_zero), '\0', 8); - addr_ptr = inet_ntoa(dest_addr.sin_addr); - if (connect( - sockfd, (struct sockaddr*)&dest_addr, sizeof(struct sockaddr)) == - -1) + sockfd, + (struct sockaddr*)curr_di->ai_addr, + sizeof(struct sockaddr)) == -1) { printf( TLS_CLIENT "failed to connect to %s:%s (errno=%d)\n", @@ -173,7 +207,11 @@ int create_socket(char* server_name, char* server_port) goto done; } printf(TLS_CLIENT "connected to %s:%s\n", server_name, server_port); + done: + if (dest_info) + freeaddrinfo(dest_info); + return sockfd; } diff --git a/samples/attested_tls/non_enc_client/verify_callback.cpp b/samples/attested_tls/non_enc_client/verify_callback.cpp index d87d477c31..21af6fe096 100644 --- a/samples/attested_tls/non_enc_client/verify_callback.cpp +++ b/samples/attested_tls/non_enc_client/verify_callback.cpp @@ -1,12 +1,17 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#ifdef _WIN32 +#include +#else #include #include #include #include -#include #include +#endif + +#include #include #include diff --git a/samples/attested_tls/non_enc_client/verify_signer_openssl.cpp b/samples/attested_tls/non_enc_client/verify_signer_openssl.cpp index 84a24a9559..c0d84379fa 100644 --- a/samples/attested_tls/non_enc_client/verify_signer_openssl.cpp +++ b/samples/attested_tls/non_enc_client/verify_signer_openssl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/attested_tls/scripts/gen_mrenclave_header.sh b/samples/attested_tls/scripts/gen_mrenclave_header.sh index 70562fc9b6..f013009774 100755 --- a/samples/attested_tls/scripts/gen_mrenclave_header.sh +++ b/samples/attested_tls/scripts/gen_mrenclave_header.sh @@ -1,40 +1,52 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. destfile="$1" input_file="$2" -cat > "$destfile" << EOF -// Copyright (c) Microsoft Corporation. All rights reserved. +# Store text in variables and then write file all at once at the end. This +# will keep build tools from consuming an incomplete header file. + +SECTION1="$(cat <<-EOF +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef SAMPLES_ATTESTED_TLS_SERVER_UNIQUE_ID_H #define SAMPLES_ATTESTED_TLS_SERVER_UNIQUE_ID_H +static const unsigned char SERVER_ENCLAVE_MRENCLAVE[] = +{ EOF +)" -printf 'static const unsigned char SERVER_ENCLAVE_MRENCLAVE[] =' >> "$destfile" -printf '\n{' >> "$destfile" - +SECTION2="" while read -r line; do if [[ $line == mrenclave=* ]]; then read -r mrenclave < <(echo "$line" | cut -d'=' --fields=2) + if [[ "${mrenclave: -1}" = $'\r' ]]; then + mrenclave="${mrenclave:0: -1}" + fi + for (( i=0; i<${#mrenclave}; i=i+2)); do - echo "0x${mrenclave:$i:2}" >> "$destfile" + echo -n "" >> "$destfile" + SECTION2=$SECTION2"0x${mrenclave:$i:2}" index=$((${#mrenclave} - 2)) if [ $i -lt $index ]; then - printf "," >> "$destfile" + SECTION2=$SECTION2",\n" fi done fi done < "$input_file" -printf '};\n' >> "$destfile" -cat >> "$destfile" << EOF +SECTION3="$(cat <<-EOF +}; #endif /* SAMPLES_ATTESTED_TLS_SERVER_UNIQUE_ID_H */ EOF +)" + +echo -ne "$SECTION1$SECTION2$SECTION3" > "$destfile" diff --git a/samples/attested_tls/server/CMakeLists.txt b/samples/attested_tls/server/CMakeLists.txt index d2cb62caff..86ce87c3d8 100644 --- a/samples/attested_tls/server/CMakeLists.txt +++ b/samples/attested_tls/server/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(enc) diff --git a/samples/attested_tls/server/Makefile b/samples/attested_tls/server/Makefile index 3f10fc555e..e2f7cdc6a6 100644 --- a/samples/attested_tls/server/Makefile +++ b/samples/attested_tls/server/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. all: build diff --git a/samples/attested_tls/server/enc/CMakeLists.txt b/samples/attested_tls/server/enc/CMakeLists.txt index a788a187c5..838804125f 100644 --- a/samples/attested_tls/server/enc/CMakeLists.txt +++ b/samples/attested_tls/server/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Use the edger8r to generate C bindings from the EDL file. @@ -11,8 +11,8 @@ add_custom_command(OUTPUT tls_server_enc.signed tls_server_enc_mrenclave.h DEPENDS tls_server_enc enc.conf ${CMAKE_SOURCE_DIR}/server/enc/private.pem ${CMAKE_SOURCE_DIR}/scripts/gen_mrenclave_header.sh COMMAND openenclave::oesign sign -e $ -c ${CMAKE_SOURCE_DIR}/server/enc/enc.conf -k ${CMAKE_SOURCE_DIR}/server/enc/private.pem COMMAND openenclave::oesign dump -e tls_server_enc.signed > temp.dmp - COMMAND chmod u+x ${CMAKE_SOURCE_DIR}/scripts/gen_mrenclave_header.sh - COMMAND ${CMAKE_SOURCE_DIR}/scripts/gen_mrenclave_header.sh ${CMAKE_SOURCE_DIR}/common/tls_server_enc_mrenclave.h temp.dmp + COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/gen_mrenclave_header.sh ${CMAKE_SOURCE_DIR}/common/tls_server_enc_mrenclave.h temp.dmp + COMMAND ${CMAKE_COMMAND} -E sleep 1 COMMAND ${CMAKE_COMMAND} -E remove temp.dmp) add_executable(tls_server_enc @@ -24,6 +24,10 @@ add_executable(tls_server_enc ../../common/utility.cpp ${CMAKE_CURRENT_BINARY_DIR}/tls_server_t.c) +if (WIN32) + maybe_build_using_clangw(tls_server_enc) +endif () + target_compile_definitions(tls_server_enc PUBLIC OE_API_VERSION=2) target_include_directories(tls_server_enc PRIVATE @@ -37,4 +41,4 @@ target_link_libraries(tls_server_enc openenclave::oehostsock openenclave::oehostresolver) -add_custom_target(tls_server_sign_enc ALL DEPENDS tls_server_enc.signed) +add_custom_target(tls_server_sign_enc ALL DEPENDS tls_server_enc.signed tls_server_enc_mrenclave.h) diff --git a/samples/attested_tls/server/enc/Makefile b/samples/attested_tls/server/enc/Makefile index fd7e167d30..64fc2cb63e 100644 --- a/samples/attested_tls/server/enc/Makefile +++ b/samples/attested_tls/server/enc/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/attested_tls/server/enc/cert_verifier.cpp b/samples/attested_tls/server/enc/cert_verifier.cpp index 0e1626baf9..78bb541ae6 100644 --- a/samples/attested_tls/server/enc/cert_verifier.cpp +++ b/samples/attested_tls/server/enc/cert_verifier.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/attested_tls/server/enc/crypto.cpp b/samples/attested_tls/server/enc/crypto.cpp index f35e473f9f..25c68c83cb 100644 --- a/samples/attested_tls/server/enc/crypto.cpp +++ b/samples/attested_tls/server/enc/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "crypto.h" diff --git a/samples/attested_tls/server/enc/crypto.h b/samples/attested_tls/server/enc/crypto.h index cf20f355f2..8cba0faa9a 100644 --- a/samples/attested_tls/server/enc/crypto.h +++ b/samples/attested_tls/server/enc/crypto.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H diff --git a/samples/attested_tls/server/enc/ecalls.cpp b/samples/attested_tls/server/enc/ecalls.cpp index 73c63cfc3e..75f718766e 100644 --- a/samples/attested_tls/server/enc/ecalls.cpp +++ b/samples/attested_tls/server/enc/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/attested_tls/server/enc/enc.conf b/samples/attested_tls/server/enc/enc.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/attested_tls/server/enc/enc.conf +++ b/samples/attested_tls/server/enc/enc.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/attested_tls/server/enc/identity_verifier.cpp b/samples/attested_tls/server/enc/identity_verifier.cpp index 3540aa3cb6..ba0c39f302 100644 --- a/samples/attested_tls/server/enc/identity_verifier.cpp +++ b/samples/attested_tls/server/enc/identity_verifier.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -11,8 +11,9 @@ oe_result_t enclave_identity_verifier_callback( oe_identity_t* identity, void* arg) { + OE_UNUSED(arg); + oe_result_t result = OE_VERIFY_FAILED; - bool bret = false; printf(TLS_SERVER "Server:enclave_identity_verifier_callback is called with enclave " diff --git a/samples/attested_tls/server/enc/log.h b/samples/attested_tls/server/enc/log.h index b064e3b905..507dcd8b81 100644 --- a/samples/attested_tls/server/enc/log.h +++ b/samples/attested_tls/server/enc/log.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_LOG_H diff --git a/samples/attested_tls/server/enc/server.cpp b/samples/attested_tls/server/enc/server.cpp index ef6029c245..7fc2280d21 100644 --- a/samples/attested_tls/server/enc/server.cpp +++ b/samples/attested_tls/server/enc/server.cpp @@ -1,9 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include -#include #include #include #include @@ -34,9 +33,6 @@ int cert_verify_callback( int depth, uint32_t* flags); -// mbedtls debug levels -// 0 No debug, 1 Error, 2 State change, 3 Informational, 4 Verbose -#define DEBUG_LEVEL 1 #define SERVER_IP "0.0.0.0" #define HTTP_RESPONSE \ @@ -187,7 +183,7 @@ int handle_communication_until_done( { len = sizeof(buf) - 1; memset(buf, 0, sizeof(buf)); - ret = mbedtls_ssl_read(ssl, buf, len); + ret = mbedtls_ssl_read(ssl, buf, (size_t)len); if (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE) @@ -218,8 +214,8 @@ int handle_communication_until_done( // For testing purpose, valdiate received data's content and size #ifdef ADD_TEST_CHECKING - if ((len != CLIENT_PAYLOAD_SIZE) || - (memcmp(CLIENT_PAYLOAD, buf, len) != 0)) + if (((size_t)len != CLIENT_PAYLOAD_SIZE) || + (memcmp(CLIENT_PAYLOAD, buf, (size_t)len) != 0)) { printf( TLS_SERVER @@ -232,7 +228,7 @@ int handle_communication_until_done( printf(TLS_SERVER "Verified: the contents of client payload were expected\n\n"); #endif - if (ret == CLIENT_PAYLOAD_SIZE) + if ((size_t)ret == CLIENT_PAYLOAD_SIZE) break; } while (1); @@ -240,7 +236,7 @@ int handle_communication_until_done( printf(TLS_SERVER "-----> Write to client:\n"); len = snprintf((char*)buf, sizeof(buf) - 1, SERVER_PAYLOAD); - while ((ret = mbedtls_ssl_write(ssl, buf, len)) <= 0) + while ((ret = mbedtls_ssl_write(ssl, buf, (size_t)len)) <= 0) { if (ret == MBEDTLS_ERR_NET_CONN_RESET) { @@ -321,8 +317,6 @@ int setup_tls_server(char* server_port) mbedtls_entropy_init(&entropy); mbedtls_ctr_drbg_init(&ctr_drbg); - mbedtls_debug_set_threshold(DEBUG_LEVEL); - printf( TLS_SERVER "Setup the listening TCP socket on SERVER_IP= [%s] " "server_port = [%s]\n", diff --git a/samples/attested_tls/server/host/CMakeLists.txt b/samples/attested_tls/server/host/CMakeLists.txt index 7f44397fee..a511007c00 100644 --- a/samples/attested_tls/server/host/CMakeLists.txt +++ b/samples/attested_tls/server/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT tls_server_u.h tls_server_u.c tls_server_args.h diff --git a/samples/attested_tls/server/host/Makefile b/samples/attested_tls/server/host/Makefile index bcbe4235b7..66dd25013e 100644 --- a/samples/attested_tls/server/host/Makefile +++ b/samples/attested_tls/server/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/attested_tls/server/host/host.cpp b/samples/attested_tls/server/host/host.cpp index 8139ad65c5..e559f510f6 100644 --- a/samples/attested_tls/server/host/host.cpp +++ b/samples/attested_tls/server/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -55,7 +55,7 @@ int main(int argc, const char* argv[]) // read port parameter { char* option = (char*)"-port:"; - int param_len = 0; + size_t param_len = 0; param_len = strlen(option); if (strncmp(argv[2], option, param_len) == 0) { diff --git a/samples/attested_tls/server/tls_server.edl b/samples/attested_tls/server/tls_server.edl index 071694f5a7..5f1f6b0929 100644 --- a/samples/attested_tls/server/tls_server.edl +++ b/samples/attested_tls/server/tls_server.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/data-sealing/CMakeLists.txt b/samples/data-sealing/CMakeLists.txt index 3fc647d321..a1959546e1 100644 --- a/samples/data-sealing/CMakeLists.txt +++ b/samples/data-sealing/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.11) diff --git a/samples/data-sealing/Makefile b/samples/data-sealing/Makefile index 4bb1423cd1..3e2b03e2fe 100644 --- a/samples/data-sealing/Makefile +++ b/samples/data-sealing/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run diff --git a/samples/data-sealing/common/CMakeLists.txt b/samples/data-sealing/common/CMakeLists.txt index 8af836fd0d..73556fa9ed 100644 --- a/samples/data-sealing/common/CMakeLists.txt +++ b/samples/data-sealing/common/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Use the edger8r to generate C bindings from the EDL file. @@ -9,6 +9,7 @@ add_custom_command(OUTPUT datasealing_t.h datasealing_t.c datasealing_args.h # Create a library common to each of our three enclaves. add_library(common STATIC dispatcher.cpp keys.cpp ${CMAKE_CURRENT_BINARY_DIR}/datasealing_t.c) target_compile_definitions(common PUBLIC OE_API_VERSION=2) + target_link_libraries(common PUBLIC # `liboecore`, a dependency of `liboeenclave`, requires the ecalls # function table. Because the libraries linking `libcommon` do not @@ -17,7 +18,11 @@ target_link_libraries(common PUBLIC # # Alternatively we could use a CMake OBJECT library, but that # requires a newish version of CMake. - -Wl,--require-defined=__oe_ecalls_table + $<$:-Wl,--require-defined=__oe_ecalls_table> openenclave::oeenclave openenclave::oelibcxx) +if(WIN32) + maybe_build_using_clangw(common) +endif() + target_include_directories(common PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) diff --git a/samples/data-sealing/common/common.h b/samples/data-sealing/common/common.h index f63ca440e8..6a7962c8a1 100644 --- a/samples/data-sealing/common/common.h +++ b/samples/data-sealing/common/common.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. extern const char* enclave_name; diff --git a/samples/data-sealing/common/dispatcher.cpp b/samples/data-sealing/common/dispatcher.cpp index 676554f304..b83fcae1b5 100644 --- a/samples/data-sealing/common/dispatcher.cpp +++ b/samples/data-sealing/common/dispatcher.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "dispatcher.h" @@ -86,13 +86,28 @@ int ecall_dispatcher::seal_data( } memcpy(iv, m_sealed_data->iv, IV_SIZE); + // We need to cast these variables down to unsigned int. + // Check if that will cut off any significant bits. + if (m_data_size > UINT32_MAX) + { + TRACE_ENCLAVE( + "m_data_size is too large to fit into an unsigned int", 1); + goto exit; + } + if (seal_key_size > UINT32_MAX) + { + TRACE_ENCLAVE( + "seal_key_size is too large to fit into an unsigned int", 1); + goto exit; + } + // seal data: encrypt data with the seal key ret = cipher_data( ENCRYPT_OPERATION, m_data, - m_data_size, + (unsigned int)m_data_size, seal_key, - seal_key_size, + (unsigned int)seal_key_size, iv, m_sealed_data->encrypted_data); if (ret != 0) @@ -108,7 +123,10 @@ int ecall_dispatcher::seal_data( // generate signature by signing the hash of the sealed data with the seal // key ret = sign_sealed_data( - m_sealed_data, seal_key, seal_key_size, m_sealed_data->signature); + m_sealed_data, + seal_key, + (unsigned int)seal_key_size, + m_sealed_data->signature); if (ret != 0) { TRACE_ENCLAVE("sign_sealed_data %d\n", ret); @@ -145,7 +163,7 @@ int ecall_dispatcher::seal_data( if (ret) result = OE_FAILURE; - return result; + return (int)result; } int ecall_dispatcher::unseal_data( @@ -161,6 +179,7 @@ int ecall_dispatcher::unseal_data( size_t seal_key_size = 0; uint8_t* key_info = NULL; size_t key_info_size = 0; + (void)sealed_data_size; unsigned char* data_buf = NULL; int ret = 0; @@ -185,12 +204,28 @@ int ecall_dispatcher::unseal_data( // read initialization vector values memcpy(iv, m_sealed_data->iv, IV_SIZE); + // We need to cast these variables down to unsigned int. + // Check if that will cut off any significant bits. + if (m_sealed_data->encrypted_data_len > UINT32_MAX) + { + TRACE_ENCLAVE( + "seal_key_size is too large to fit into an unsigned int", 1); + goto exit; + } + if (seal_key_size > UINT32_MAX) + { + TRACE_ENCLAVE( + "seal_key_size is too large to fit into an unsigned int", 1); + goto exit; + } + // validate signature by re-generating a signature from the input // sealed_data // structure then comparing it with sealed_data.signature // regenerate signature - ret = sign_sealed_data(m_sealed_data, seal_key, seal_key_size, signature); + ret = sign_sealed_data( + m_sealed_data, seal_key, (unsigned int)seal_key_size, signature); if (ret != 0) { ret = ERROR_SIGN_SEALED_DATA_FAIL; @@ -222,9 +257,9 @@ int ecall_dispatcher::unseal_data( ret = cipher_data( DECRYPT_OPERATION, m_sealed_data->encrypted_data, - m_sealed_data->encrypted_data_len, + (unsigned int)m_sealed_data->encrypted_data_len, seal_key, - seal_key_size, + (unsigned int)seal_key_size, iv, data_buf); if (ret != 0) @@ -291,6 +326,12 @@ oe_result_t ecall_dispatcher::get_seal_key_and_prep_sealed_data( else padded_byte_count = CIPHER_BLOCK_SIZE - bytes_left; + if (padded_byte_count > UINT32_MAX) + { + TRACE_ENCLAVE("padded_byte_count is too large to fit into an int", 1); + goto exit; + } + padded_data = (unsigned char*)malloc(m_data_size + padded_byte_count); if (padded_data == NULL) { @@ -303,7 +344,7 @@ oe_result_t ecall_dispatcher::get_seal_key_and_prep_sealed_data( // PKCS5 padding memset( (void*)(padded_data + m_data_size), - padded_byte_count, + (int)padded_byte_count, padded_byte_count); m_data_size += padded_byte_count; diff --git a/samples/data-sealing/common/dispatcher.h b/samples/data-sealing/common/dispatcher.h index 79a9989423..c991f9ae74 100644 --- a/samples/data-sealing/common/dispatcher.h +++ b/samples/data-sealing/common/dispatcher.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/samples/data-sealing/common/keys.cpp b/samples/data-sealing/common/keys.cpp index 241f9f49d1..ce5dc16b32 100644 --- a/samples/data-sealing/common/keys.cpp +++ b/samples/data-sealing/common/keys.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/data-sealing/common/shared.h b/samples/data-sealing/common/shared.h index 3885fe0800..6e731f33c9 100644 --- a/samples/data-sealing/common/shared.h +++ b/samples/data-sealing/common/shared.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _SHARED_H diff --git a/samples/data-sealing/datasealing.edl b/samples/data-sealing/datasealing.edl index 71fcf1fbcd..df5bbc4a68 100644 --- a/samples/data-sealing/datasealing.edl +++ b/samples/data-sealing/datasealing.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/data-sealing/enclave_a_v1/CMakeLists.txt b/samples/data-sealing/enclave_a_v1/CMakeLists.txt index 2da430f4ff..dd0969d9da 100644 --- a/samples/data-sealing/enclave_a_v1/CMakeLists.txt +++ b/samples/data-sealing/enclave_a_v1/CMakeLists.txt @@ -1,5 +1,10 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(enclave_a_v1 ecalls.cpp) + +if(WIN32) + maybe_build_using_clangw(enclave_a_v1) +endif() + target_link_libraries(enclave_a_v1 common) diff --git a/samples/data-sealing/enclave_a_v1/Makefile b/samples/data-sealing/enclave_a_v1/Makefile index 5332929f7b..bd9b3ff302 100644 --- a/samples/data-sealing/enclave_a_v1/Makefile +++ b/samples/data-sealing/enclave_a_v1/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/data-sealing/enclave_a_v1/data-sealing.conf b/samples/data-sealing/enclave_a_v1/data-sealing.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/data-sealing/enclave_a_v1/data-sealing.conf +++ b/samples/data-sealing/enclave_a_v1/data-sealing.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/data-sealing/enclave_a_v1/ecalls.cpp b/samples/data-sealing/enclave_a_v1/ecalls.cpp index 9c96bf0500..b1749df002 100644 --- a/samples/data-sealing/enclave_a_v1/ecalls.cpp +++ b/samples/data-sealing/enclave_a_v1/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/data-sealing/enclave_a_v2/CMakeLists.txt b/samples/data-sealing/enclave_a_v2/CMakeLists.txt index 7545d3148d..9a61838ea0 100644 --- a/samples/data-sealing/enclave_a_v2/CMakeLists.txt +++ b/samples/data-sealing/enclave_a_v2/CMakeLists.txt @@ -1,5 +1,10 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(enclave_a_v2 ecalls.cpp) + +if(WIN32) + maybe_build_using_clangw(enclave_a_v2) +endif() + target_link_libraries(enclave_a_v2 common) diff --git a/samples/data-sealing/enclave_a_v2/Makefile b/samples/data-sealing/enclave_a_v2/Makefile index 960cc2f4d7..6b7a928a39 100644 --- a/samples/data-sealing/enclave_a_v2/Makefile +++ b/samples/data-sealing/enclave_a_v2/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/data-sealing/enclave_a_v2/data-sealing.conf b/samples/data-sealing/enclave_a_v2/data-sealing.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/data-sealing/enclave_a_v2/data-sealing.conf +++ b/samples/data-sealing/enclave_a_v2/data-sealing.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/data-sealing/enclave_a_v2/ecalls.cpp b/samples/data-sealing/enclave_a_v2/ecalls.cpp index ef806ca5c2..226340e46e 100644 --- a/samples/data-sealing/enclave_a_v2/ecalls.cpp +++ b/samples/data-sealing/enclave_a_v2/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/data-sealing/enclave_b/CMakeLists.txt b/samples/data-sealing/enclave_b/CMakeLists.txt index ba547a20c6..b0db36e408 100644 --- a/samples/data-sealing/enclave_b/CMakeLists.txt +++ b/samples/data-sealing/enclave_b/CMakeLists.txt @@ -1,5 +1,10 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(enclave_b ecalls.cpp) + +if(WIN32) + maybe_build_using_clangw(enclave_b) +endif() + target_link_libraries(enclave_b common) diff --git a/samples/data-sealing/enclave_b/Makefile b/samples/data-sealing/enclave_b/Makefile index 7bd69ddc4c..708fc95967 100644 --- a/samples/data-sealing/enclave_b/Makefile +++ b/samples/data-sealing/enclave_b/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/data-sealing/enclave_b/data-sealing.conf b/samples/data-sealing/enclave_b/data-sealing.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/data-sealing/enclave_b/data-sealing.conf +++ b/samples/data-sealing/enclave_b/data-sealing.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/data-sealing/enclave_b/ecalls.cpp b/samples/data-sealing/enclave_b/ecalls.cpp index 4016a912a5..e854199ec5 100644 --- a/samples/data-sealing/enclave_b/ecalls.cpp +++ b/samples/data-sealing/enclave_b/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/data-sealing/host/CMakeLists.txt b/samples/data-sealing/host/CMakeLists.txt index 9ddeb55004..6a45d79c05 100644 --- a/samples/data-sealing/host/CMakeLists.txt +++ b/samples/data-sealing/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT datasealing_u.h datasealing_u.c datasealing_args.h @@ -7,6 +7,11 @@ add_custom_command(OUTPUT datasealing_u.h datasealing_u.c datasealing_args.h add_executable(data-sealing_host host.cpp ${CMAKE_CURRENT_BINARY_DIR}/datasealing_u.c) +if(WIN32) + copy_oedebugrt_target(data-sealing_host_oedebugrt) + add_dependencies(data-sealing_host data-sealing_host_oedebugrt) +endif() + target_include_directories(data-sealing_host PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ # For common/shared.h ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/samples/data-sealing/host/Makefile b/samples/data-sealing/host/Makefile index bfe674616b..6f7ef276da 100644 --- a/samples/data-sealing/host/Makefile +++ b/samples/data-sealing/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/data-sealing/host/host.cpp b/samples/data-sealing/host/host.cpp index ab1d3719c3..62f37df355 100644 --- a/samples/data-sealing/host/host.cpp +++ b/samples/data-sealing/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -8,7 +8,7 @@ #include #include #include -#include + #include #include #include "datasealing_u.h" diff --git a/samples/file-encryptor/CMakeLists.txt b/samples/file-encryptor/CMakeLists.txt index 2af6c85476..d22be25402 100644 --- a/samples/file-encryptor/CMakeLists.txt +++ b/samples/file-encryptor/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.11) diff --git a/samples/file-encryptor/Makefile b/samples/file-encryptor/Makefile index 11cdd0a660..65c437b836 100644 --- a/samples/file-encryptor/Makefile +++ b/samples/file-encryptor/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run simulate diff --git a/samples/file-encryptor/README.md b/samples/file-encryptor/README.md index fdf6069b68..f07d04c4dc 100644 --- a/samples/file-encryptor/README.md +++ b/samples/file-encryptor/README.md @@ -17,7 +17,6 @@ It has the following properties: - mbedtls_entropy_* - mbedtls_ctr_drbg_* - mbedtls_sha256_* - - oe_is_outside_enclave - Also runs in OE simulation mode ## Host application diff --git a/samples/file-encryptor/enclave/CMakeLists.txt b/samples/file-encryptor/enclave/CMakeLists.txt index 126bc7aab9..5dd6b28177 100644 --- a/samples/file-encryptor/enclave/CMakeLists.txt +++ b/samples/file-encryptor/enclave/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Use the edger8r to generate C bindings from the EDL file. @@ -7,6 +7,9 @@ add_custom_command(OUTPUT fileencryptor_t.h fileencryptor_t.c fileencryptor_args COMMAND openenclave::oeedger8r --trusted ${CMAKE_SOURCE_DIR}/fileencryptor.edl) add_executable(enclave ecalls.cpp encryptor.cpp keys.cpp ${CMAKE_CURRENT_BINARY_DIR}/fileencryptor_t.c) +if(WIN32) + maybe_build_using_clangw(enclave) +endif() target_compile_definitions(enclave PUBLIC OE_API_VERSION=2) diff --git a/samples/file-encryptor/enclave/Makefile b/samples/file-encryptor/enclave/Makefile index 35592ec100..cf900933e4 100644 --- a/samples/file-encryptor/enclave/Makefile +++ b/samples/file-encryptor/enclave/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/file-encryptor/enclave/common.h b/samples/file-encryptor/enclave/common.h index 7dfd765732..5d0df7e363 100644 --- a/samples/file-encryptor/enclave/common.h +++ b/samples/file-encryptor/enclave/common.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define TRACE_ENCLAVE(fmt, ...) \ diff --git a/samples/file-encryptor/enclave/ecalls.cpp b/samples/file-encryptor/enclave/ecalls.cpp index c9c9fb22ef..fd3cf1ce9a 100644 --- a/samples/file-encryptor/enclave/ecalls.cpp +++ b/samples/file-encryptor/enclave/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/file-encryptor/enclave/encryptor.cpp b/samples/file-encryptor/enclave/encryptor.cpp index 2eaa4e874d..96c7c57d2e 100644 --- a/samples/file-encryptor/enclave/encryptor.cpp +++ b/samples/file-encryptor/enclave/encryptor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "encryptor.h" @@ -38,6 +38,7 @@ int ecall_dispatcher::initialize( encrypt ? "encrypting" : "decrypting"); m_encrypt = encrypt; + memset((void*)m_encryption_key, 0, ENCRYPTION_KEY_SIZE_IN_BYTES); ret = process_encryption_header(encrypt, password, password_len, header); if (ret != 0) diff --git a/samples/file-encryptor/enclave/encryptor.h b/samples/file-encryptor/enclave/encryptor.h index 40cdd91162..689846d605 100644 --- a/samples/file-encryptor/enclave/encryptor.h +++ b/samples/file-encryptor/enclave/encryptor.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/samples/file-encryptor/enclave/file-encryptor.conf b/samples/file-encryptor/enclave/file-encryptor.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/file-encryptor/enclave/file-encryptor.conf +++ b/samples/file-encryptor/enclave/file-encryptor.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/file-encryptor/enclave/keys.cpp b/samples/file-encryptor/enclave/keys.cpp index 250e71b8fe..39fa9eab64 100644 --- a/samples/file-encryptor/enclave/keys.cpp +++ b/samples/file-encryptor/enclave/keys.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -201,6 +201,7 @@ int ecall_dispatcher::cipher_encryption_key( unsigned int output_data_size) { int ret = 0; + (void)output_data_size; mbedtls_aes_context aescontext; unsigned char iv[IV_SIZE] = {0xb2, 0x4b, @@ -226,10 +227,19 @@ int ecall_dispatcher::cipher_encryption_key( mbedtls_aes_init(&aescontext); // set aes key - ret = mbedtls_aes_setkey_enc(&aescontext, encrypt_key, ENCRYPTION_KEY_SIZE); + if (encrypt) + { + ret = mbedtls_aes_setkey_enc( + &aescontext, encrypt_key, ENCRYPTION_KEY_SIZE); + } + else + { + ret = mbedtls_aes_setkey_dec( + &aescontext, encrypt_key, ENCRYPTION_KEY_SIZE); + } if (ret != 0) { - TRACE_ENCLAVE("mbedtls_aes_setkey_enc failed with %d", ret); + TRACE_ENCLAVE("mbedtls_aes_setkey_enc/dec failed with %d", ret); goto exit; } @@ -371,8 +381,8 @@ int ecall_dispatcher::parse_encryption_header( DECRYPT_OPERATION, header->encrypted_key, ENCRYPTION_KEY_SIZE_IN_BYTES, - (unsigned char*)m_encryption_key, password_key, + (unsigned char*)m_encryption_key, ENCRYPTION_KEY_SIZE_IN_BYTES); if (ret != 0) { diff --git a/samples/file-encryptor/fileencryptor.edl b/samples/file-encryptor/fileencryptor.edl index 45a0fd558f..49e7d55334 100644 --- a/samples/file-encryptor/fileencryptor.edl +++ b/samples/file-encryptor/fileencryptor.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/file-encryptor/host/CMakeLists.txt b/samples/file-encryptor/host/CMakeLists.txt index 177ccd1921..9da81780df 100644 --- a/samples/file-encryptor/host/CMakeLists.txt +++ b/samples/file-encryptor/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT fileencryptor_u.h fileencryptor_u.c fileencryptor_args.h @@ -7,6 +7,11 @@ add_custom_command(OUTPUT fileencryptor_u.h fileencryptor_u.c fileencryptor_args add_executable(file-encryptor_host host.cpp ${CMAKE_CURRENT_BINARY_DIR}/fileencryptor_u.c) +if(WIN32) + copy_oedebugrt_target(file-encryptor_host_oedebugrt) + add_dependencies(file-encryptor_host file-encryptor_host_oedebugrt) +endif() + target_include_directories(file-encryptor_host PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} # Needed for #include "../shared.h" ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/samples/file-encryptor/host/Makefile b/samples/file-encryptor/host/Makefile index 1ba0d4a766..2e1f048e71 100644 --- a/samples/file-encryptor/host/Makefile +++ b/samples/file-encryptor/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/file-encryptor/host/host.cpp b/samples/file-encryptor/host/host.cpp index 8e4ba1ea92..f43eaf8989 100644 --- a/samples/file-encryptor/host/host.cpp +++ b/samples/file-encryptor/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -74,6 +73,7 @@ int get_file_size(FILE* file, size_t* _file_size) *_file_size = (size_t)ftell(file); fseek(file, oldpos, SEEK_SET); + exit: return ret; } @@ -144,7 +144,7 @@ int encrypt_file( } // open source and dest files - src_file = fopen(input_file, "r"); + src_file = fopen(input_file, "rb"); if (!src_file) { cout << "Host: fopen " << input_file << " failed." << endl; @@ -159,7 +159,7 @@ int encrypt_file( goto exit; } src_data_size = src_file_size; - dest_file = fopen(output_file, "w"); + dest_file = fopen(output_file, "wb"); if (!dest_file) { cerr << "Host: fopen " << output_file << " failed." << endl; diff --git a/samples/file-encryptor/shared.h b/samples/file-encryptor/shared.h index 8266c07b9e..9c8e42e7c0 100644 --- a/samples/file-encryptor/shared.h +++ b/samples/file-encryptor/shared.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _ARGS_H diff --git a/samples/file-encryptor/testfile b/samples/file-encryptor/testfile index e1ca9c4e96..ae36a39644 100644 --- a/samples/file-encryptor/testfile +++ b/samples/file-encryptor/testfile @@ -1,28 +1,15 @@ -Open Enclave SDK -Introduction -Open Enclave (OE) is an SDK for building enclave applications in C and C++. An enclave application partitions itself into two components (1) An untrusted component (called the host) and (2) A trusted component (called the enclave). An enclave is a secure container whose memory is protected from entities outside the enclave. These protections allow enclaves to perform secure computations with assurances that secrets will not be compromised. - -This SDK is a fully open-source and transparent project, which plans to generalize enclave application models across enclave implementations from different hardware vendors. It's a non-vendor specific solution that supports enclave applications both on Linux and Windows platforms. - -The current implementation of Open Enclave is built on Intel Software Guard Extensions (SGX), other enclave architectures (such as solutions from AMD or ARM) will be added in the future. This public preview focuses on the Linux platform. - -Design Overview -The Design Overview document provides a brief design overview of the Open Enclave SDK. It describes the parts of the SDK and how they work together to create, invoke, and terminate enclaves. - -Getting Started -For OE application developers, user intends to build/develop an OE application. Start here - -For OE Developer/Builder of OE Source, users who not only want to experience OE applications but also want to dig into how OE was implemented, and potentially contribute to this open source effort, start here - -Contributing -This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, see Contributing to Open Enclave. - -This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments. - -See the Development Guide for details about developing code in this repo, such as coding style and development processes. - -Licensing -Microsoft plans to release the Open Enclave SDK under the MIT license +This is dummy text file consisting of only English words and punctuation: +------------------------------------------------------------------------- +Our. Fifth have saying two they're firmament, herb. Shall, set for. Open +firmament greater creeping gently winged thing likeness abundantly fourth +hath subdue. That multiply night. I third whose there i. Give. Morning. +Over forth light us. +Herb. Replenish. Firmament lesser their of our lesser fowl were beginning +divided may give cattle don't deep sea, cattle night second had appear He +over. Were were blessed, place Multiply were given. +Were, two god you'll, to, had spirit together, won't likeness is first good +greater called together dominion. Unto without subdue creeping void you +dominion two man forth one moving abundantly multiply. diff --git a/samples/helloworld/CMakeLists.txt b/samples/helloworld/CMakeLists.txt index f99e7fb394..c1262b8360 100644 --- a/samples/helloworld/CMakeLists.txt +++ b/samples/helloworld/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.11) diff --git a/samples/helloworld/Makefile b/samples/helloworld/Makefile index 51482a91ab..0bb4a0b78d 100644 --- a/samples/helloworld/Makefile +++ b/samples/helloworld/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run simulate diff --git a/samples/helloworld/README.md b/samples/helloworld/README.md index 259cac97da..61695ceeec 100644 --- a/samples/helloworld/README.md +++ b/samples/helloworld/README.md @@ -166,7 +166,7 @@ Each line will now be described in turn. #include ``` -An enclave library will be loaded into and run inside a host application which is a user-mode process. To keep the [trusted computing base](https://en.wikipedia.org/wiki/Trusted_computing_base) small, the decision was made to make only a specific set of APIs available to an enclave library. A complete list of APIs available to an enclave library can be found [here](https://github.com/openenclave/openenclave/tree/master/docs/GettingStartedDocs/using_oe_sdk.md#api-references) +An enclave library will be loaded into and run inside a host application which is a user-mode process. To keep the [trusted computing base](https://en.wikipedia.org/wiki/Trusted_computing_base) small, the decision was made to make only a specific set of APIs available to an enclave library. A complete list of APIs available to an enclave library can be found [here](https://github.com/openenclave/openenclave/tree/master/docs/GettingStartedDocs/APIs_and_Libs.md) The `stdio.h` header file is included in this sample because we are calling the CRT function `fprintf` to print a message on the screen. However this function has a dependency on the kernel to print a message on the screen so this code cannot execute within the enclave itself. Instead this function marshals the call through to the host to carry out the call on the enclaves behalf. Only a subset of the CRT is made available through this open enclave library. diff --git a/samples/helloworld/enclave/CMakeLists.txt b/samples/helloworld/enclave/CMakeLists.txt index 4e7149465a..6f102aa25f 100644 --- a/samples/helloworld/enclave/CMakeLists.txt +++ b/samples/helloworld/enclave/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Use the edger8r to generate C bindings from the EDL file. @@ -8,6 +8,10 @@ add_custom_command(OUTPUT helloworld_t.h helloworld_t.c helloworld_args.h add_executable(enclave enc.c ${CMAKE_CURRENT_BINARY_DIR}/helloworld_t.c) +if (WIN32) + maybe_build_using_clangw(enclave) +endif () + target_compile_definitions(enclave PUBLIC OE_API_VERSION=2) # Need for the generated file helloworld_t.h diff --git a/samples/helloworld/enclave/Makefile b/samples/helloworld/enclave/Makefile index 2d3fa65b5a..ae8baa57e8 100644 --- a/samples/helloworld/enclave/Makefile +++ b/samples/helloworld/enclave/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/helloworld/enclave/enc.c b/samples/helloworld/enclave/enc.c index 512ef5f717..f6e42c73d1 100644 --- a/samples/helloworld/enclave/enc.c +++ b/samples/helloworld/enclave/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/helloworld/enclave/helloworld.conf b/samples/helloworld/enclave/helloworld.conf index 5d4ce9ef95..ca997aa136 100644 --- a/samples/helloworld/enclave/helloworld.conf +++ b/samples/helloworld/enclave/helloworld.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/helloworld/helloworld.edl b/samples/helloworld/helloworld.edl index 81e48130eb..952eb74f67 100644 --- a/samples/helloworld/helloworld.edl +++ b/samples/helloworld/helloworld.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/helloworld/host/CMakeLists.txt b/samples/helloworld/host/CMakeLists.txt index ce67b3dc04..dd95d96708 100644 --- a/samples/helloworld/host/CMakeLists.txt +++ b/samples/helloworld/host/CMakeLists.txt @@ -1,12 +1,16 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. - add_custom_command(OUTPUT helloworld_u.h helloworld_u.c helloworld_args.h DEPENDS ${CMAKE_SOURCE_DIR}/helloworld.edl COMMAND openenclave::oeedger8r --untrusted ${CMAKE_SOURCE_DIR}/helloworld.edl) add_executable(helloworld_host host.c ${CMAKE_CURRENT_BINARY_DIR}/helloworld_u.c) +if(WIN32) + copy_oedebugrt_target(helloworld_host_oedebugrt) + add_dependencies(helloworld_host helloworld_host_oedebugrt) +endif() + target_include_directories(helloworld_host PRIVATE # Needed for the generated file helloworld_u.h ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/samples/helloworld/host/Makefile b/samples/helloworld/host/Makefile index 1e692bf455..2de7207621 100644 --- a/samples/helloworld/host/Makefile +++ b/samples/helloworld/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/helloworld/host/host.c b/samples/helloworld/host/host.c index 4e7f85f12b..0085973c35 100644 --- a/samples/helloworld/host/host.c +++ b/samples/helloworld/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/local_attestation/CMakeLists.txt b/samples/local_attestation/CMakeLists.txt index 475d344eb4..c76cc7320d 100644 --- a/samples/local_attestation/CMakeLists.txt +++ b/samples/local_attestation/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.11) diff --git a/samples/local_attestation/Makefile b/samples/local_attestation/Makefile index 1bd09ee0a0..b9631c2239 100644 --- a/samples/local_attestation/Makefile +++ b/samples/local_attestation/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run diff --git a/samples/local_attestation/common/CMakeLists.txt b/samples/local_attestation/common/CMakeLists.txt index 3e47827a91..757ec6736f 100644 --- a/samples/local_attestation/common/CMakeLists.txt +++ b/samples/local_attestation/common/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Use the edger8r to generate C bindings from the EDL file. @@ -8,6 +8,11 @@ add_custom_command(OUTPUT localattestation_t.h localattestation_t.c localattesta # Create a library common to each of our two enclaves. add_library(common STATIC attestation.cpp crypto.cpp dispatcher.cpp ${CMAKE_CURRENT_BINARY_DIR}/localattestation_t.c) + +if(WIN32) + maybe_build_using_clangw(common) +endif() + target_compile_definitions(common PUBLIC OE_API_VERSION=2) target_link_libraries(common PUBLIC # `liboecore`, a dependency of `liboeenclave`, requires the ecalls @@ -17,7 +22,7 @@ target_link_libraries(common PUBLIC # # Alternatively we could use a CMake OBJECT library, but that # requires a newish version of CMake. - -Wl,--require-defined=__oe_ecalls_table + $<$:-Wl,--require-defined=__oe_ecalls_table> openenclave::oeenclave openenclave::oelibcxx) target_include_directories(common PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) diff --git a/samples/local_attestation/common/attestation.cpp b/samples/local_attestation/common/attestation.cpp index 93f42a0444..a11bc47ed6 100644 --- a/samples/local_attestation/common/attestation.cpp +++ b/samples/local_attestation/common/attestation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "attestation.h" diff --git a/samples/local_attestation/common/attestation.h b/samples/local_attestation/common/attestation.h index 494432fdc4..d245a21010 100644 --- a/samples/local_attestation/common/attestation.h +++ b/samples/local_attestation/common/attestation.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_ATTESTATION_H diff --git a/samples/local_attestation/common/crypto.cpp b/samples/local_attestation/common/crypto.cpp index 978adc1eb7..369a73c5ba 100644 --- a/samples/local_attestation/common/crypto.cpp +++ b/samples/local_attestation/common/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "crypto.h" diff --git a/samples/local_attestation/common/crypto.h b/samples/local_attestation/common/crypto.h index cf20f355f2..8cba0faa9a 100644 --- a/samples/local_attestation/common/crypto.h +++ b/samples/local_attestation/common/crypto.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H diff --git a/samples/local_attestation/common/dispatcher.cpp b/samples/local_attestation/common/dispatcher.cpp index f64d648154..15ce110aa0 100644 --- a/samples/local_attestation/common/dispatcher.cpp +++ b/samples/local_attestation/common/dispatcher.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "dispatcher.h" diff --git a/samples/local_attestation/common/dispatcher.h b/samples/local_attestation/common/dispatcher.h index 50ae2d1f76..f20364062a 100644 --- a/samples/local_attestation/common/dispatcher.h +++ b/samples/local_attestation/common/dispatcher.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/samples/local_attestation/common/log.h b/samples/local_attestation/common/log.h index 26d7b92394..50235ce974 100644 --- a/samples/local_attestation/common/log.h +++ b/samples/local_attestation/common/log.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_LOG_H diff --git a/samples/local_attestation/enclave_a/CMakeLists.txt b/samples/local_attestation/enclave_a/CMakeLists.txt index 2cc9ceac3c..665c3021a4 100644 --- a/samples/local_attestation/enclave_a/CMakeLists.txt +++ b/samples/local_attestation/enclave_a/CMakeLists.txt @@ -1,13 +1,17 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Generate header with public key of enclave B (2) add_custom_command(OUTPUT enclave_b_pubkey.h DEPENDS public_key_b ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh - COMMAND ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_b_pubkey.h ${CMAKE_BINARY_DIR}/enclave_b/public_b.pem) + COMMAND ${OE_BASH} ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_b_pubkey.h ${CMAKE_BINARY_DIR}/enclave_b/public_b.pem) add_executable(enclave_a ecalls.cpp ${CMAKE_CURRENT_BINARY_DIR}/enclave_b_pubkey.h) +if(WIN32) + maybe_build_using_clangw(enclave_a) +endif() + target_include_directories(enclave_a PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(enclave_a common) diff --git a/samples/local_attestation/enclave_a/Makefile b/samples/local_attestation/enclave_a/Makefile index 38f6b521dd..18e62c67a3 100644 --- a/samples/local_attestation/enclave_a/Makefile +++ b/samples/local_attestation/enclave_a/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/local_attestation/enclave_a/ecalls.cpp b/samples/local_attestation/enclave_a/ecalls.cpp index 283bc1fafe..fe33805ab1 100644 --- a/samples/local_attestation/enclave_a/ecalls.cpp +++ b/samples/local_attestation/enclave_a/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/samples/local_attestation/enclave_a/enc.conf b/samples/local_attestation/enclave_a/enc.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/local_attestation/enclave_a/enc.conf +++ b/samples/local_attestation/enclave_a/enc.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/local_attestation/enclave_b/CMakeLists.txt b/samples/local_attestation/enclave_b/CMakeLists.txt index 8cd30cc378..97a1ba9811 100644 --- a/samples/local_attestation/enclave_b/CMakeLists.txt +++ b/samples/local_attestation/enclave_b/CMakeLists.txt @@ -1,13 +1,21 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Generate header with public key of enclave A + +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + add_custom_command(OUTPUT enclave_a_pubkey.h DEPENDS public_key_a ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh - COMMAND ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_a_pubkey.h ${CMAKE_BINARY_DIR}/enclave_a/public_a.pem) + COMMAND ${OE_BASH} ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_a_pubkey.h ${CMAKE_BINARY_DIR}/enclave_a/public_a.pem) add_executable(enclave_b ecalls.cpp ${CMAKE_CURRENT_BINARY_DIR}/enclave_a_pubkey.h) +if(WIN32) + maybe_build_using_clangw(enclave_b) +endif() + target_include_directories(enclave_b PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(enclave_b common) diff --git a/samples/local_attestation/enclave_b/Makefile b/samples/local_attestation/enclave_b/Makefile index 135c97787a..e22bf8044e 100644 --- a/samples/local_attestation/enclave_b/Makefile +++ b/samples/local_attestation/enclave_b/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/local_attestation/enclave_b/ecalls.cpp b/samples/local_attestation/enclave_b/ecalls.cpp index 13727da78c..89a418e3a8 100644 --- a/samples/local_attestation/enclave_b/ecalls.cpp +++ b/samples/local_attestation/enclave_b/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/samples/local_attestation/enclave_b/enc.conf b/samples/local_attestation/enclave_b/enc.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/local_attestation/enclave_b/enc.conf +++ b/samples/local_attestation/enclave_b/enc.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/local_attestation/gen_pubkey_header.sh b/samples/local_attestation/gen_pubkey_header.sh index d96b2de78f..aa77857117 100755 --- a/samples/local_attestation/gen_pubkey_header.sh +++ b/samples/local_attestation/gen_pubkey_header.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. destfile="$1" pubkey_file="$2" cat > "$destfile" << EOF -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef SAMPLES_LOCAL_ATTESTATION_PUBKEY_H @@ -18,6 +18,9 @@ EOF printf 'static const char OTHER_ENCLAVE_PUBLIC_KEY[] =' >> "$destfile" while IFS="" read -r p || [ -n "$p" ] do + # Sometimes openssl can insert carriage returns into the PEM files. Let's remove those! + CR=$(printf "\r") + p=$(echo "$p" | tr -d "$CR") printf '\n \"%s\\n\"' "$p" >> "$destfile" done < "$pubkey_file" printf ';\n' >> "$destfile" diff --git a/samples/local_attestation/host/CMakeLists.txt b/samples/local_attestation/host/CMakeLists.txt index 1447a41467..f121b83862 100644 --- a/samples/local_attestation/host/CMakeLists.txt +++ b/samples/local_attestation/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT localattestation_u.h localattestation_u.c localattestation_args.h @@ -7,6 +7,11 @@ add_custom_command(OUTPUT localattestation_u.h localattestation_u.c localattesta add_executable(local_attestation_host host.cpp ${CMAKE_CURRENT_BINARY_DIR}/localattestation_u.c) +if(WIN32) + copy_oedebugrt_target(local_attestation_host_oedebugrt) + add_dependencies(local_attestation_host local_attestation_host_oedebugrt) +endif() + target_include_directories(local_attestation_host PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ # For common/shared.h ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/samples/local_attestation/host/Makefile b/samples/local_attestation/host/Makefile index 2979b7ffb2..752e4b3036 100644 --- a/samples/local_attestation/host/Makefile +++ b/samples/local_attestation/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/local_attestation/host/host.cpp b/samples/local_attestation/host/host.cpp index 0dab70f02d..93fa4a68ef 100644 --- a/samples/local_attestation/host/host.cpp +++ b/samples/local_attestation/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/local_attestation/localattestation.edl b/samples/local_attestation/localattestation.edl index fa843b6066..6c179f2ffd 100644 --- a/samples/local_attestation/localattestation.edl +++ b/samples/local_attestation/localattestation.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/remote_attestation/CMakeLists.txt b/samples/remote_attestation/CMakeLists.txt index 8d2847129e..6cac3fd9cb 100644 --- a/samples/remote_attestation/CMakeLists.txt +++ b/samples/remote_attestation/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. cmake_minimum_required(VERSION 3.11) diff --git a/samples/remote_attestation/Makefile b/samples/remote_attestation/Makefile index 1bd09ee0a0..b9631c2239 100644 --- a/samples/remote_attestation/Makefile +++ b/samples/remote_attestation/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. .PHONY: all build clean run diff --git a/samples/remote_attestation/common/CMakeLists.txt b/samples/remote_attestation/common/CMakeLists.txt index db388e09a2..629d1fc157 100644 --- a/samples/remote_attestation/common/CMakeLists.txt +++ b/samples/remote_attestation/common/CMakeLists.txt @@ -1,6 +1,9 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. +add_custom_command(OUTPUT enclave_a_pubkey.h + DEPENDS public_key_a ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh + COMMAND ${OE_BASH} ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_a_pubkey.h ${CMAKE_BINARY_DIR}/enclave_a/public_a.pem) # Use the edger8r to generate C bindings from the EDL file. add_custom_command(OUTPUT remoteattestation_t.h remoteattestation_t.c remoteattestation_args.h DEPENDS ${CMAKE_SOURCE_DIR}/remoteattestation.edl @@ -8,6 +11,11 @@ add_custom_command(OUTPUT remoteattestation_t.h remoteattestation_t.c remoteatte # Create a library common to each of our two enclaves. add_library(common STATIC attestation.cpp crypto.cpp dispatcher.cpp ${CMAKE_CURRENT_BINARY_DIR}/remoteattestation_t.c) + +if(WIN32) + maybe_build_using_clangw(common) +endif() + target_compile_definitions(common PUBLIC OE_API_VERSION=2) target_link_libraries(common PUBLIC # `liboecore`, a dependency of `liboeenclave`, requires the ecalls @@ -17,7 +25,7 @@ target_link_libraries(common PUBLIC # # Alternatively we could use a CMake OBJECT library, but that # requires a newish version of CMake. - -Wl,--require-defined=__oe_ecalls_table + $<$:-Wl,--require-defined=__oe_ecalls_table> openenclave::oeenclave openenclave::oelibcxx) target_include_directories(common PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) diff --git a/samples/remote_attestation/common/attestation.cpp b/samples/remote_attestation/common/attestation.cpp index ec23f2baec..d934b42bc3 100644 --- a/samples/remote_attestation/common/attestation.cpp +++ b/samples/remote_attestation/common/attestation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "attestation.h" diff --git a/samples/remote_attestation/common/attestation.h b/samples/remote_attestation/common/attestation.h index 7d72090fb7..a942acca86 100644 --- a/samples/remote_attestation/common/attestation.h +++ b/samples/remote_attestation/common/attestation.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_ATTESTATION_H diff --git a/samples/remote_attestation/common/crypto.cpp b/samples/remote_attestation/common/crypto.cpp index 0ed6053754..ebcdd00d3a 100644 --- a/samples/remote_attestation/common/crypto.cpp +++ b/samples/remote_attestation/common/crypto.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "crypto.h" diff --git a/samples/remote_attestation/common/crypto.h b/samples/remote_attestation/common/crypto.h index cf20f355f2..8cba0faa9a 100644 --- a/samples/remote_attestation/common/crypto.h +++ b/samples/remote_attestation/common/crypto.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H diff --git a/samples/remote_attestation/common/dispatcher.cpp b/samples/remote_attestation/common/dispatcher.cpp index 81adde71d2..e0503b0cd2 100644 --- a/samples/remote_attestation/common/dispatcher.cpp +++ b/samples/remote_attestation/common/dispatcher.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "dispatcher.h" diff --git a/samples/remote_attestation/common/dispatcher.h b/samples/remote_attestation/common/dispatcher.h index db2ddddee0..8ab7151588 100644 --- a/samples/remote_attestation/common/dispatcher.h +++ b/samples/remote_attestation/common/dispatcher.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/samples/remote_attestation/common/log.h b/samples/remote_attestation/common/log.h index b064e3b905..507dcd8b81 100644 --- a/samples/remote_attestation/common/log.h +++ b/samples/remote_attestation/common/log.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef OE_SAMPLES_ATTESTATION_ENC_LOG_H diff --git a/samples/remote_attestation/enclave_a/CMakeLists.txt b/samples/remote_attestation/enclave_a/CMakeLists.txt index 2cc9ceac3c..c63833ed70 100644 --- a/samples/remote_attestation/enclave_a/CMakeLists.txt +++ b/samples/remote_attestation/enclave_a/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Generate header with public key of enclave B (2) @@ -8,6 +8,10 @@ add_custom_command(OUTPUT enclave_b_pubkey.h add_executable(enclave_a ecalls.cpp ${CMAKE_CURRENT_BINARY_DIR}/enclave_b_pubkey.h) +if(WIN32) + maybe_build_using_clangw(enclave_a) +endif() + target_include_directories(enclave_a PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(enclave_a common) diff --git a/samples/remote_attestation/enclave_a/Makefile b/samples/remote_attestation/enclave_a/Makefile index 1c08fba7d5..bb6cf7daf3 100644 --- a/samples/remote_attestation/enclave_a/Makefile +++ b/samples/remote_attestation/enclave_a/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/remote_attestation/enclave_a/ecalls.cpp b/samples/remote_attestation/enclave_a/ecalls.cpp index b4a7f60052..e3b953a895 100644 --- a/samples/remote_attestation/enclave_a/ecalls.cpp +++ b/samples/remote_attestation/enclave_a/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/samples/remote_attestation/enclave_a/enc.conf b/samples/remote_attestation/enclave_a/enc.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/remote_attestation/enclave_a/enc.conf +++ b/samples/remote_attestation/enclave_a/enc.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/remote_attestation/enclave_b/CMakeLists.txt b/samples/remote_attestation/enclave_b/CMakeLists.txt index 8cd30cc378..182425d0c0 100644 --- a/samples/remote_attestation/enclave_b/CMakeLists.txt +++ b/samples/remote_attestation/enclave_b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Generate header with public key of enclave A @@ -8,6 +8,10 @@ add_custom_command(OUTPUT enclave_a_pubkey.h add_executable(enclave_b ecalls.cpp ${CMAKE_CURRENT_BINARY_DIR}/enclave_a_pubkey.h) +if(WIN32) + maybe_build_using_clangw(enclave_b) +endif() + target_include_directories(enclave_b PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(enclave_b common) diff --git a/samples/remote_attestation/enclave_b/Makefile b/samples/remote_attestation/enclave_b/Makefile index 5b773e6e2c..47d97a0f09 100644 --- a/samples/remote_attestation/enclave_b/Makefile +++ b/samples/remote_attestation/enclave_b/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/remote_attestation/enclave_b/ecalls.cpp b/samples/remote_attestation/enclave_b/ecalls.cpp index 2e60f060f8..216a44d2d9 100644 --- a/samples/remote_attestation/enclave_b/ecalls.cpp +++ b/samples/remote_attestation/enclave_b/ecalls.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/samples/remote_attestation/enclave_b/enc.conf b/samples/remote_attestation/enclave_b/enc.conf index 981fd5fe9b..c6af0590eb 100644 --- a/samples/remote_attestation/enclave_b/enc.conf +++ b/samples/remote_attestation/enclave_b/enc.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/samples/remote_attestation/gen_pubkey_header.sh b/samples/remote_attestation/gen_pubkey_header.sh index e6f98353f9..d6ac4ffb30 100755 --- a/samples/remote_attestation/gen_pubkey_header.sh +++ b/samples/remote_attestation/gen_pubkey_header.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. destfile="$1" pubkey_file="$2" cat > "$destfile" << EOF -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef SAMPLES_REMOTE_ATTESTATION_PUBKEY_H @@ -18,6 +18,9 @@ EOF printf 'static const char OTHER_ENCLAVE_PUBLIC_KEY[] =' >> "$destfile" while IFS="" read -r p || [ -n "$p" ] do + # Sometimes openssl can insert carriage returns into the PEM files. Let's remove those! + CR=$(printf "\r") + p=$(echo "$p" | tr -d "$CR") printf '\n \"%s\\n\"' "$p" >> "$destfile" done < "$pubkey_file" printf ';\n' >> "$destfile" diff --git a/samples/remote_attestation/host/CMakeLists.txt b/samples/remote_attestation/host/CMakeLists.txt index 37208d891c..5369024603 100644 --- a/samples/remote_attestation/host/CMakeLists.txt +++ b/samples/remote_attestation/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT remoteattestation_u.h remoteattestation_u.c remoteattestation_args.h @@ -6,9 +6,15 @@ add_custom_command(OUTPUT remoteattestation_u.h remoteattestation_u.c remoteatte COMMAND openenclave::oeedger8r --untrusted ${CMAKE_SOURCE_DIR}/remoteattestation.edl) add_executable(remote_attestation_host host.cpp ${CMAKE_CURRENT_BINARY_DIR}/remoteattestation_u.c) - target_include_directories(remote_attestation_host PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../ # For common/shared.h ${CMAKE_CURRENT_BINARY_DIR}) +if(WIN32) + add_dcap_client_target(remote_attestation_dcap_target) + add_dependencies(remote_attestation_host remote_attestation_dcap_target) + copy_oedebugrt_target(remote_attestation_oedebugrt_target) + add_dependencies(remote_attestation_host remote_attestation_oedebugrt_target) +endif() + target_link_libraries(remote_attestation_host openenclave::oehostapp) diff --git a/samples/remote_attestation/host/Makefile b/samples/remote_attestation/host/Makefile index 306034bd84..3b07aaa8c8 100644 --- a/samples/remote_attestation/host/Makefile +++ b/samples/remote_attestation/host/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Detect C and C++ compiler options diff --git a/samples/remote_attestation/host/host.cpp b/samples/remote_attestation/host/host.cpp index cd5076193a..a3e997e608 100644 --- a/samples/remote_attestation/host/host.cpp +++ b/samples/remote_attestation/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/samples/remote_attestation/remoteattestation.edl b/samples/remote_attestation/remoteattestation.edl index 790260b847..ae99dac4bb 100644 --- a/samples/remote_attestation/remoteattestation.edl +++ b/samples/remote_attestation/remoteattestation.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/samples/remote_attestation_eeid/CMakeLists.txt b/samples/remote_attestation_eeid/CMakeLists.txt new file mode 100644 index 0000000000..6cac3fd9cb --- /dev/null +++ b/samples/remote_attestation_eeid/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.11) + +project("Remote Attestation Sample" LANGUAGES C CXX) + +find_package(OpenEnclave CONFIG REQUIRED) + +set(CMAKE_CXX_STANDARD 11) + +add_subdirectory(common) +add_subdirectory(enclave_a) +add_subdirectory(enclave_b) +add_subdirectory(host) + +add_custom_target(sign ALL DEPENDS enclave_a_signed enclave_b_signed) + +if ((NOT DEFINED ENV{OE_SIMULATION}) OR (NOT $ENV{OE_SIMULATION})) + add_custom_target(run + DEPENDS remote_attestation_host sign + COMMAND remote_attestation_host ${CMAKE_BINARY_DIR}/enclave_a/enclave_a.signed ${CMAKE_BINARY_DIR}/enclave_b/enclave_b.signed) +endif () diff --git a/samples/remote_attestation_eeid/Makefile b/samples/remote_attestation_eeid/Makefile new file mode 100644 index 0000000000..b9631c2239 --- /dev/null +++ b/samples/remote_attestation_eeid/Makefile @@ -0,0 +1,19 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +.PHONY: all build clean run + +all: build + +build: + $(MAKE) -C enclave_a + $(MAKE) -C enclave_b + $(MAKE) -C host + +clean: + $(MAKE) -C enclave_a clean + $(MAKE) -C enclave_b clean + $(MAKE) -C host clean + +run: + host/attestation_host ./enclave_a/enclave_a.signed ./enclave_b/enclave_b.signed diff --git a/samples/remote_attestation_eeid/README.md b/samples/remote_attestation_eeid/README.md new file mode 100644 index 0000000000..c359e3c010 --- /dev/null +++ b/samples/remote_attestation_eeid/README.md @@ -0,0 +1,233 @@ +# The Remote Attestation Sample + +This sample demonstrates how to do remote attestation between two enclaves and establish a secure communication channel for exchanging messages between them. + +It has the following properties: + +- Written in C++ +- Demonstrates an implementation of remote attestation +- Use of mbedTLS within the enclave +- Use Asymmetric / Public-Key Encryption to establish secure communications between two attesting enclaves +- Enclave APIs used: + - oe_get_report + - oe_verify_report, + - oe_is_within_enclave + +**Note: Currently this sample only works on SGX-FLC systems.** The underlying SGX library support for end-to-end remote attestation is available only on SGX-FLC system. There is no plan to back port those libraries to either SGX1 system or software emulator. + +## Attestation primer + +### What is Attestation + +Attestation is the process of demonstrating that a software component (such as an enclave image) has been properly instantiated on an Trusted Execution Environment (TEE, such as the SGX enabled platform). + +A successfully attested enclave proves: + +- The enclave is running in a valid Trusted Execution Environment (TEE), which is Intel SGX in this case (trustworthiness). + +- The enclave has the correct identity and runtime properties that has not been tampered with (identity). + + In the context of Open Enclave, when an enclave requests confidential information from a remote entity, the remote entity will issue a challenge to the requesting enclave to prove its identity and trustworthiness before provisioning any confidential information to the enclave. This process of proving its identity and trustworthiness to a challenger is known as attestation. + +### Attestation types + +There are two types of attestation: + +- **Local Attestation** refers to two enclaves on the same TEE platform authenticating each other before exchanging information. In Open Enclave, this is done through the creation and validation of an enclave's `local report`. + + ![Local Attestation](images/localattestation.png) + +- **Remote Attestation** is the process of a [trusted computing base (TCB)](https://en.wikipedia.org/wiki/Trusted_computing_base), a combination of HW and SW, gaining the trust of a remote enclave/provider. In Open Enclave, this is done through the creation and validation of an enclave's `remote report`. + + ![Remote Attestation Sample](images/remoteattestation_service.png) + +### Secure Communication Channel + +Remote Attestation alone is not enough for the remote party to be able to securely deliver their secrets to the requesting enclave. Securely delivering services requires a secure communication channel which is often guaranteed by Transport Layer Security (TLS). + +A few alternatives for establishing a secure communication channel without TLS are: +1) Use the established ephemeral private keys to perform a signed Diffie-Hellman key exchange and use symmetric key cryptography to communicate after that point. +2) Generate an ephemeral symmetric key in one of the enclaves, say enclave_a, encrypt with the public key of enclave_b, sign with your private key and then send it to enclave_b. This will ensure that the symmetric key is only known to the two enclaves and the root of trust is in the remote attestation. + +This remote attestation sample only demonstrates the remote attestation process but does not establish a secure communication channel or communicate secrets after that. Please note that the established public keys cannot be used to encrypt the messages as they are visible to the external world, including the host. The host can fake messages on behalf of the enclaves. + +Here is a good article about [Intel SGX attestation]( +https://software.intel.com/sites/default/files/managed/57/0e/ww10-2016-sgx-provisioning-and-attestation-final.pdf), which describes how Intel's SGX attestation works. The current Open Enclave's implementation was based on it for the SGX platform. + +Note: `local report` is the same as an `Intel SGX report`, while the `remote report` is the same as an `Intel SGX quote`. + +## Remote Attestation sample + +In a typical Open Enclave application, it's common to see multiple enclaves working together to achieve common goals. Once an enclave verifies the counterpart is trustworthy, they can exchange information on a protected channel, which typically provides confidentiality, integrity and replay protection. + +This is why instead of attesting an enclave to a remote (mostly cloud) service, this sample demonstrates how to attest two enclaves to each other by using Open Enclave APIs `oe_get_report` and `oe_verify_report` which takes care of all remote attestation operations. + +To simplify this sample without losing the focus in explaining how the remote attestation works, host1 and host2 are combined into one single host to eliminate the need for additional socket code logic to deal with communication between two hosts. + +![Remote Attestation](images/remoteattestation_sample.png) + +### Authoring the Host + +The host process is what drives the enclave app. It is responsible for managing the lifetime of the enclave and invoking enclave ECALLs but should be considered an untrusted component that is never allowed to handle plaintext secrets intended for the enclave. + +![Remote Attestation](images/remoteattestation_sample_details.png) + +The host does the following in this sample: + + 1. Create two enclaves for attesting each other, let's say they are enclave_a and enclave_b + + ```c + oe_create_remoteattestation_enclave( enclaveImagePath, OE_ENCLAVE_TYPE_SGX, OE_ENCLAVE_FLAG_DEBUG, NULL, 0, &enclave); + ``` + + 2. Ask enclave_a for a remote report and a public key, which is returned in a `RemoteReportWithPKey` structure. + + This is done through a call into the enclave_a `GetRemoteReportWithPKey` `OE_ECALL` + + ```c + oe_call_enclave(enclave, "GetRemoteReportWithPKey", &args); + + struct RemoteReportWithPKey + { + uint8_t pem_key[512]; // public key information + uint8_t* remote_report; + size_t remote_report_size; + }; + ``` + + Where: + + - `pem_key` holds the public key that identifies enclave_a + + - `remote_report` contains a remote report signed by the enclave platform for use in remote attestation + + 3. Ask enclave_b to attest (validate) enclave_a's remote report (remote_report from above) + + This is done through the following call: + ```c + oe_call_enclave(enclave, "VerifyReportAndSetPKey", &args); + ``` + + In the enclave_b's implementation of `VerifyReportAndSetPKey`, it calls `oe_verify_report`, which will be described in the enclave section to handle all the platform specfic report validation operations (including PCK certificate chain checking). If successful the public key in `RemoteReportWithPKey.pem_key` will be stored inside the enclave for future use + + 4. Repeat step 2 and 3 for asking enclave_a to validate enclave_b + + 5. Free the resource used, including the host memory allocated by the enclaves and the enclaves themselves + + For example: + + ```c + oe_terminate_enclave(enclave_a); + oe_terminate_enclave(enclave_b); + ``` + +### Authoring the Enclave + +#### Attesting an Enclave + +Attesting an enclave consists of three steps: + +##### 1) Generating an Enclave Report + +The enclave being attested first needs to generate a cryptographically strong proof of its identity that the challenger can verify. In the sample this is done by asking the SGX platform to generate a `remote report` signed by Intel via the `oe_get_report` method with `OE_REPORT_FLAGS_REMOTE_ATTESTATION` flag. The `remote report` can be verified by the `oe_verify_report` method on a different machine. + +An important feature of `oe_get_report` is that you can pass in application specific data as the `reportData` parameter to be signed into the report. + +- This is limited to 64 bytes in SGX. As illustrated in the sample, you sign arbitrarily large data into the report by first hashing it and then passing it to the `oe_get_report` method. + +- This is useful to bootstrap a secure communication channel between the enclave and the challenger. + + - In this sample, the enclave signs the hash of an ephemeral public key into its report, which the challenger can then use to encrypt a response to it. + + - Other usage examples for `reportData` might be to include a nonce, or to initiate Diffie-Helman key exchange. + +##### 2) Verifying the integrity of the Enclave Report + +Once the report is generated and passed to the challenger, the challenger can call `oe_verify_report` to validate the report originated from an Trust Execution Environment (TEE, in the case it's a valid SGX platform). + +In the context of Open Enclave on Intel SGX platform, a remote report is verified using the certificate chain issued by Intel which is only valid for SGX platforms. + +At this point, the challenger knows that the report originated from an enclave running in a TEE, and that the information in the report can be trusted. + +Note that for the Public Preview, remote attestation verification is only supported in the Azure ACC VMs, but Intel will be expanding support for this with Open Enclave SDK more broadly moving forward. + +##### 3) Verifying the enclave identity + +Finally, it is up to the enclave app to check that identity and properties of the enclave reflected in the report matches its expectation. +Open Enclave exposes a generalized identity model to support this process across TEE types. In the sample, the app-specific `AttestQuote` method calls `oe_parse_report` to obtain an `oe_report_t`. This data structure contains: + +- The `reportData` signed into the report +- The generalized identity structure as defined by `oe_identity_t`: + + ```c + typedef struct _oe_identity + { + /** Version of the oe_identity_t structure */ + uint32_t idVersion; + + /** Security version of the enclave. For SGX enclaves, this is the + * ISVN value */ + uint32_t securityVersion; + + /** Values of the attributes flags for the enclave - + * OE_REPORT_ATTRIBUTES_DEBUG: The report is for a debug enclave. + * OE_REPORT_ATTRIBUTES_REMOTE: The report can be used for remote + * attestation */ + uint64_t attributes; + + /** The unique ID for the enclave. + * For SGX enclaves, this is the MRENCLAVE value */ + uint8_t uniqueID[OE_UNIQUE_ID_SIZE]; + + /** The author ID for the enclave. + * For SGX enclaves, this is the MRSIGNER value */ + uint8_t authorID[OE_AUTHOR_ID_SIZE]; + + /** The Product ID for the enclave. + * For SGX enclaves, this is the ISVPRODID value. */ + uint8_t productID[OE_PRODUCT_ID_SIZE]; + } oe_identity_t; + ``` + +As shown in the sample, the set of validations performed on these properties is up to the app. In general, we would strongly recommend: + +- Ensure that the identity of the enclave matches the expected value: + - Verify the `uniqueID` value if you want to match the exact bitwise identity of the enclave. Bear in mind that any patches to the enclave will change the uniqueID in the future. + - Verify the `authorID` and `productID` values if you want to match the identity of an enclave that might span multiple binary versions. This is what the attestation sample does. +- Ensure that the `securityVersion` of the enclave matches your minimum required security version. +- Ensure that the `reportData` matches the hash of the data provided with the report, as illustrated by the sample. + +## Using Cryptography in an Enclave + +The attestation remote_attestation/common/crypto.cpp file from the sample illustrates how to use mbedTLS inside the enclave for cryptographic operations such as: + +- RSA key generation, encryption and decryption +- SHA256 hashing + +In general, the Open Enclave SDK provides default support for mbedTLS layered on top of the Open Enclave core runtime with a small integration surface so that it can be switched out by open source developers in the future for your choice of crypto libraries. + +See [here](https://github.com/openenclave/openenclave/tree/master/docs/MbedtlsSupport.md) for supported mbedTLS functions + +## Build and run + +Note that there are two different build systems supported, one using GNU Make and +`pkg-config`, the other using CMake. + +### CMake + +This uses the CMake package provided by the Open Enclave SDK. + +```bash +cd remote_attestation +mkdir build && cd build +cmake .. +make run +``` + +### GNU Make + +```bash +cd remote_attestation +make build +make run +``` diff --git a/samples/remote_attestation_eeid/common/CMakeLists.txt b/samples/remote_attestation_eeid/common/CMakeLists.txt new file mode 100644 index 0000000000..629d1fc157 --- /dev/null +++ b/samples/remote_attestation_eeid/common/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command(OUTPUT enclave_a_pubkey.h + DEPENDS public_key_a ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh + COMMAND ${OE_BASH} ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_a_pubkey.h ${CMAKE_BINARY_DIR}/enclave_a/public_a.pem) +# Use the edger8r to generate C bindings from the EDL file. +add_custom_command(OUTPUT remoteattestation_t.h remoteattestation_t.c remoteattestation_args.h + DEPENDS ${CMAKE_SOURCE_DIR}/remoteattestation.edl + COMMAND openenclave::oeedger8r --trusted ${CMAKE_SOURCE_DIR}/remoteattestation.edl) + +# Create a library common to each of our two enclaves. +add_library(common STATIC attestation.cpp crypto.cpp dispatcher.cpp ${CMAKE_CURRENT_BINARY_DIR}/remoteattestation_t.c) + +if(WIN32) + maybe_build_using_clangw(common) +endif() + +target_compile_definitions(common PUBLIC OE_API_VERSION=2) +target_link_libraries(common PUBLIC + # `liboecore`, a dependency of `liboeenclave`, requires the ecalls + # function table. Because the libraries linking `libcommon` do not + # directly require this symbol, the linker skips the object in + # `libcommon` which defines them. So we manually require it. + # + # Alternatively we could use a CMake OBJECT library, but that + # requires a newish version of CMake. + $<$:-Wl,--require-defined=__oe_ecalls_table> + openenclave::oeenclave + openenclave::oelibcxx) +target_include_directories(common PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) diff --git a/samples/remote_attestation_eeid/common/attestation.cpp b/samples/remote_attestation_eeid/common/attestation.cpp new file mode 100644 index 0000000000..5aa11b5f97 --- /dev/null +++ b/samples/remote_attestation_eeid/common/attestation.cpp @@ -0,0 +1,167 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "attestation.h" +#include +#include "log.h" + +Attestation::Attestation(Crypto* crypto, uint8_t* enclave_mrsigner) +{ + m_crypto = crypto; + m_enclave_mrsigner = enclave_mrsigner; +} + +/** + * Generate a remote report for the given data. The SHA256 digest of the data is + * stored in the report_data field of the generated remote report. + */ +bool Attestation::generate_remote_report( + const uint8_t* data, + const size_t data_size, + uint8_t** remote_report_buf, + size_t* remote_report_buf_size) +{ + bool ret = false; + uint8_t sha256[32]; + oe_result_t result = OE_OK; + uint8_t* temp_buf = NULL; + + if (m_crypto->Sha256(data, data_size, sha256) != 0) + { + goto exit; + } + + // To generate a remote report that can be attested remotely by an enclave + // running on a different platform, pass the + // OE_REPORT_FLAGS_REMOTE_ATTESTATION option. This uses the trusted + // quoting enclave to generate the report based on this enclave's local + // report. + // To generate a remote report that just needs to be attested by another + // enclave running on the same platform, pass 0 instead. This uses the + // EREPORT instruction to generate this enclave's local report. + // Both kinds of reports can be verified using the oe_verify_report + // function. + result = oe_get_report( + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + sha256, // Store sha256 in report_data field + sizeof(sha256), + NULL, // opt_params must be null + 0, + &temp_buf, + remote_report_buf_size); + if (result != OE_OK) + { + TRACE_ENCLAVE("oe_get_report failed."); + goto exit; + } + *remote_report_buf = temp_buf; + ret = true; + TRACE_ENCLAVE("generate_remote_report succeeded."); +exit: + return ret; +} + +/** + * Attest the given remote report and accompanying data. It consists of the + * following three steps: + * + * 1) The remote report is first attested using the oe_verify_report API. This + * ensures the authenticity of the enclave that generated the remote report. + * 2) Next, to establish trust of the enclave that generated the remote report, + * the mrsigner, product_id, isvsvn values are checked to see if they are + * predefined trusted values. + * 3) Once the enclave's trust has been established, the validity of + * accompanying data is ensured by comparing its SHA256 digest against the + * report_data field. + */ +bool Attestation::attest_remote_report( + const uint8_t* remote_report, + size_t remote_report_size, + const uint8_t* data, + size_t data_size, + oe_eeid_t* eeid) +{ + bool ret = false; + uint8_t sha256[32]; + oe_report_t parsed_report = {0}; + oe_result_t result = OE_OK; + + // While attesting, the remote report being attested must not be tampered + // with. Ensure that it has been copied over to the enclave. + if (!oe_is_within_enclave(remote_report, remote_report_size)) + { + TRACE_ENCLAVE("Cannot attest remote report in host memory. Unsafe."); + goto exit; + } + + // 1) Validate the report's trustworthiness + // Verify the remote report to ensure its authenticity. + result = oe_verify_report_eeid( + remote_report, remote_report_size, &parsed_report, eeid); + if (result != OE_OK) + { + TRACE_ENCLAVE("oe_verify_report failed (%s).\n", oe_result_str(result)); + goto exit; + } + + // 2) validate the enclave identity's signed_id is the hash of the public + // signing key that was used to sign an enclave. Check that the enclave was + // signed by an trusted entity. + if (memcmp(parsed_report.identity.signer_id, m_enclave_mrsigner, 32) != 0) + { + TRACE_ENCLAVE("identity.signer_id checking failed."); + TRACE_ENCLAVE( + "identity.signer_id %s", parsed_report.identity.signer_id); + + for (int i = 0; i < 32; i++) + { + TRACE_ENCLAVE( + "m_enclave_mrsigner[%d]=0x%0x\n", + i, + (uint8_t)m_enclave_mrsigner[i]); + } + + TRACE_ENCLAVE("\n\n\n"); + + for (int i = 0; i < 32; i++) + { + TRACE_ENCLAVE( + "parsedReport.identity.signer_id)[%d]=0x%0x\n", + i, + (uint8_t)parsed_report.identity.signer_id[i]); + } + TRACE_ENCLAVE("m_enclave_mrsigner %s", m_enclave_mrsigner); + goto exit; + } + + // Check the enclave's product id and security version + // See enc.conf for values specified when signing the enclave. + if (parsed_report.identity.product_id[0] != 1) + { + TRACE_ENCLAVE("identity.product_id checking failed."); + goto exit; + } + + if (parsed_report.identity.security_version < 1) + { + TRACE_ENCLAVE("identity.security_version checking failed."); + goto exit; + } + + // 3) Validate the report data + // The report_data has the hash value of the report data + if (m_crypto->Sha256(data, data_size, sha256) != 0) + { + goto exit; + } + + if (memcmp(parsed_report.report_data, sha256, sizeof(sha256)) != 0) + { + TRACE_ENCLAVE("SHA256 mismatch."); + goto exit; + } + ret = true; + TRACE_ENCLAVE("remote attestation succeeded."); +exit: + return ret; +} diff --git a/samples/remote_attestation_eeid/common/attestation.h b/samples/remote_attestation_eeid/common/attestation.h new file mode 100644 index 0000000000..648077b2df --- /dev/null +++ b/samples/remote_attestation_eeid/common/attestation.h @@ -0,0 +1,46 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef OE_SAMPLES_ATTESTATION_ENC_ATTESTATION_H +#define OE_SAMPLES_ATTESTATION_ENC_ATTESTATION_H + +#include +#include +#include "crypto.h" + +#define ENCLAVE_SECRET_DATA_SIZE 16 +class Attestation +{ + private: + Crypto* m_crypto; + uint8_t* m_enclave_mrsigner; + + public: + Attestation(Crypto* crypto, uint8_t* enclave_mrsigner); + + // Generate a remote report for the given data. The SHA256 digest of the + // data is stored in the report_data field of the generated remote report. + bool generate_remote_report( + const uint8_t* data, + size_t data_size, + uint8_t** remote_report_buf, + size_t* remote_report_buf_size); + + /** + * Attest the given remote report and accompanying data. The remote report + * is first attested using the oe_verify_report API. This ensures the + * authenticity of the enclave that generated the remote report. Next the + * mrsigner and mrenclave values are tested to establish trust of the + * enclave that generated the remote report. Next the validity of + * accompanying data is ensured by comparing its SHA256 digest against the + * report_data field. + */ + bool attest_remote_report( + const uint8_t* remote_report, + size_t remote_report_size, + const uint8_t* data, + size_t data_size, + oe_eeid_t* eeid); +}; + +#endif // OE_SAMPLES_ATTESTATION_ENC_ATTESTATION_H diff --git a/samples/remote_attestation_eeid/common/crypto.cpp b/samples/remote_attestation_eeid/common/crypto.cpp new file mode 100644 index 0000000000..ebcdd00d3a --- /dev/null +++ b/samples/remote_attestation_eeid/common/crypto.cpp @@ -0,0 +1,312 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "crypto.h" +#include +#include +#include +#include +#include + +Crypto::Crypto() +{ + m_initialized = init_mbedtls(); +} + +Crypto::~Crypto() +{ + cleanup_mbedtls(); +} + +/** + * init_mbedtls initializes the crypto module. + * mbedtls initialization. Please refer to mbedtls documentation for detailed + * information about the functions used. + */ +bool Crypto::init_mbedtls(void) +{ + bool ret = false; + int res = -1; + + mbedtls_ctr_drbg_init(&m_ctr_drbg_contex); + mbedtls_entropy_init(&m_entropy_context); + mbedtls_pk_init(&m_pk_context); + + // Initialize entropy. + res = mbedtls_ctr_drbg_seed( + &m_ctr_drbg_contex, mbedtls_entropy_func, &m_entropy_context, NULL, 0); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_ctr_drbg_seed failed."); + goto exit; + } + + // Initialize RSA context. + res = mbedtls_pk_setup( + &m_pk_context, mbedtls_pk_info_from_type(MBEDTLS_PK_RSA)); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_pk_setup failed (%d).", res); + goto exit; + } + + // Generate an ephemeral 2048-bit RSA key pair with + // exponent 65537 for the enclave. + res = mbedtls_rsa_gen_key( + mbedtls_pk_rsa(m_pk_context), + mbedtls_ctr_drbg_random, + &m_ctr_drbg_contex, + 2048, + 65537); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_rsa_gen_key failed (%d)\n", res); + goto exit; + } + + // Write out the public key in PEM format for exchange with other enclaves. + res = mbedtls_pk_write_pubkey_pem( + &m_pk_context, m_public_key, sizeof(m_public_key)); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_pk_write_pubkey_pem failed (%d)\n", res); + goto exit; + } + ret = true; + TRACE_ENCLAVE("mbedtls initialized."); +exit: + return ret; +} + +/** + * mbedtls cleanup during shutdown. + */ +void Crypto::cleanup_mbedtls(void) +{ + mbedtls_pk_free(&m_pk_context); + mbedtls_entropy_free(&m_entropy_context); + mbedtls_ctr_drbg_free(&m_ctr_drbg_contex); + + TRACE_ENCLAVE("mbedtls cleaned up."); +} + +/** + * Get the public key for this enclave. + */ +void Crypto::retrieve_public_key(uint8_t pem_public_key[512]) +{ + memcpy(pem_public_key, m_public_key, sizeof(m_public_key)); +} + +// Compute the sha256 hash of given data. +int Crypto::Sha256(const uint8_t* data, size_t data_size, uint8_t sha256[32]) +{ + int ret = 0; + mbedtls_sha256_context ctx; + + mbedtls_sha256_init(&ctx); + + ret = mbedtls_sha256_starts_ret(&ctx, 0); + if (ret) + goto exit; + + ret = mbedtls_sha256_update_ret(&ctx, data, data_size); + if (ret) + goto exit; + + ret = mbedtls_sha256_finish_ret(&ctx, sha256); + if (ret) + goto exit; + +exit: + mbedtls_sha256_free(&ctx); + return ret; +} + +/** + * Encrypt encrypts the given data using the given public key. + * Used to encrypt data using the public key of another enclave. + */ +bool Crypto::Encrypt( + const uint8_t* pem_public_key, + const uint8_t* data, + size_t data_size, + uint8_t* encrypted_data, + size_t* encrypted_data_size) +{ + bool result = false; + mbedtls_pk_context key; + size_t key_size = 0; + int res = -1; + mbedtls_rsa_context* rsa_context; + + mbedtls_pk_init(&key); + + if (!m_initialized) + goto exit; + + // Read the given public key. + key_size = strlen((const char*)pem_public_key) + 1; // Include ending '\0'. + res = mbedtls_pk_parse_public_key(&key, pem_public_key, key_size); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_pk_parse_public_key failed."); + goto exit; + } + + rsa_context = mbedtls_pk_rsa(key); + rsa_context->padding = MBEDTLS_RSA_PKCS_V21; + rsa_context->hash_id = MBEDTLS_MD_SHA256; + + if (rsa_context->padding == MBEDTLS_RSA_PKCS_V21) + { + TRACE_ENCLAVE("Padding used: MBEDTLS_RSA_PKCS_V21 for OAEP or PSS"); + } + + if (rsa_context->padding == MBEDTLS_RSA_PKCS_V15) + { + TRACE_ENCLAVE("New MBEDTLS_RSA_PKCS_V15 for 1.5 padding"); + } + + // Encrypt the data. + res = mbedtls_rsa_pkcs1_encrypt( + rsa_context, + mbedtls_ctr_drbg_random, + &m_ctr_drbg_contex, + MBEDTLS_RSA_PUBLIC, + data_size, + data, + encrypted_data); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_rsa_pkcs1_encrypt failed with %d\n", res); + goto exit; + } + + *encrypted_data_size = mbedtls_pk_rsa(key)->len; + result = true; +exit: + mbedtls_pk_free(&key); + return result; +} + +/** + * decrypt the given data using current enclave's private key. + * Used to receive encrypted data from another enclave. + */ +bool Crypto::decrypt( + const uint8_t* encrypted_data, + size_t encrypted_data_size, + uint8_t* data, + size_t* data_size) +{ + bool ret = false; + size_t output_size = 0; + int res = 0; + mbedtls_rsa_context* rsa_context; + + if (!m_initialized) + goto exit; + + mbedtls_pk_rsa(m_pk_context)->len = encrypted_data_size; + rsa_context = mbedtls_pk_rsa(m_pk_context); + rsa_context->padding = MBEDTLS_RSA_PKCS_V21; + rsa_context->hash_id = MBEDTLS_MD_SHA256; + + output_size = *data_size; + res = mbedtls_rsa_pkcs1_decrypt( + rsa_context, + mbedtls_ctr_drbg_random, + &m_ctr_drbg_contex, + MBEDTLS_RSA_PRIVATE, + &output_size, + encrypted_data, + data, + output_size); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_rsa_pkcs1_decrypt failed with %d\n", res); + goto exit; + } + *data_size = output_size; + ret = true; + +exit: + return ret; +} + +bool Crypto::get_rsa_modulus_from_pem( + const char* pem_data, + size_t pem_size, + uint8_t** modulus, + size_t* modulus_size) +{ + mbedtls_pk_context ctx; + mbedtls_pk_type_t pk_type; + mbedtls_rsa_context* rsa_ctx = NULL; + uint8_t* modulus_local = NULL; + size_t modulus_local_size = 0; + int res = 0; + bool ret = false; + + if (!m_initialized || !modulus || !modulus_size) + goto exit_preinit; + + mbedtls_pk_init(&ctx); + res = mbedtls_pk_parse_public_key( + &ctx, (const unsigned char*)pem_data, pem_size); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_pk_parse_public_key failed with %d\n", res); + goto exit; + } + + pk_type = mbedtls_pk_get_type(&ctx); + if (pk_type != MBEDTLS_PK_RSA) + { + TRACE_ENCLAVE("mbedtls_pk_get_type had incorrect type: %d\n", res); + goto exit; + } + + rsa_ctx = mbedtls_pk_rsa(ctx); + modulus_local_size = mbedtls_rsa_get_len(rsa_ctx); + modulus_local = (uint8_t*)malloc(modulus_local_size); + if (modulus_local == NULL) + { + TRACE_ENCLAVE( + "malloc for modulus failed with size %zu:\n", modulus_local_size); + goto exit; + } + + res = mbedtls_rsa_export_raw( + rsa_ctx, + modulus_local, + modulus_local_size, + NULL, + 0, + NULL, + 0, + NULL, + 0, + NULL, + 0); + if (res != 0) + { + TRACE_ENCLAVE("mbedtls_rsa_export failed with %d\n", res); + goto exit; + } + + *modulus = modulus_local; + *modulus_size = modulus_local_size; + modulus_local = NULL; + ret = true; + +exit: + if (modulus_local != NULL) + free(modulus_local); + + mbedtls_pk_free(&ctx); + +exit_preinit: + return ret; +} diff --git a/samples/remote_attestation_eeid/common/crypto.h b/samples/remote_attestation_eeid/common/crypto.h new file mode 100644 index 0000000000..8cba0faa9a --- /dev/null +++ b/samples/remote_attestation_eeid/common/crypto.h @@ -0,0 +1,103 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H +#define OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H + +#include +// Includes for mbedtls shipped with oe. +// Also add the following libraries to your linker command line: +// -loeenclave -lmbedcrypto -lmbedtls -lmbedx509 +#include +#include +#include +#include +#include +#include +#include "log.h" + +#define PUBLIC_KEY_SIZE 512 + +class Crypto +{ + private: + mbedtls_ctr_drbg_context m_ctr_drbg_contex; + mbedtls_entropy_context m_entropy_context; + mbedtls_pk_context m_pk_context; + uint8_t m_public_key[512]; + bool m_initialized; + + // Public key of another enclave. + uint8_t m_other_enclave_pubkey[PUBLIC_KEY_SIZE]; + + public: + Crypto(); + ~Crypto(); + + /** + * Get this enclave's own public key + */ + void retrieve_public_key(uint8_t pem_public_key[512]); + + /** + * Encrypt encrypts the given data using the given public key. + * Used to encrypt data using the public key of another enclave. + */ + bool Encrypt( + const uint8_t* pem_public_key, + const uint8_t* data, + size_t size, + uint8_t* encrypted_data, + size_t* encrypted_data_size); + + /** + * decrypt decrypts the given data using current enclave's private key. + * Used to receive encrypted data from another enclave. + */ + bool decrypt( + const uint8_t* encrypted_data, + size_t encrypted_data_size, + uint8_t* data, + size_t* data_size); + + /** + * get_rsa_modulus_from_pem returns the RSA modulus in big endian format + * from the public key PEM data. This is needed to verify the MRSIGNER + * of the other enclave, which ensures that the other enclave has been + * signed by the right key. MRSIGNER is the SHA256 hash of the modulus + * in little endian. + */ + bool get_rsa_modulus_from_pem( + const char* pem_data, + size_t pem_size, + uint8_t** modulus, + size_t* modulus_size); + + // Public key of another enclave. + uint8_t* get_the_other_enclave_public_key() + { + return m_other_enclave_pubkey; + } + + /** + * Compute the sha256 hash of given data. + */ + int Sha256(const uint8_t* data, size_t data_size, uint8_t sha256[32]); + + private: + /** + * Crypto demonstrates use of mbedtls within the enclave to generate keys + * and perform encryption. In this sample, each enclave instance generates + * an ephemeral 2048-bit RSA key pair and shares the public key with the + * other instance. The other enclave instance then replies with data + * encrypted to the provided public key. + */ + + /** init_mbedtls initializes the crypto module. + */ + bool init_mbedtls(void); + + void cleanup_mbedtls(void); +}; + +#endif // OE_SAMPLES_ATTESTATION_ENC_CRYPTO_H diff --git a/samples/remote_attestation_eeid/common/dispatcher.cpp b/samples/remote_attestation_eeid/common/dispatcher.cpp new file mode 100644 index 0000000000..a57813a21b --- /dev/null +++ b/samples/remote_attestation_eeid/common/dispatcher.cpp @@ -0,0 +1,205 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "dispatcher.h" +#include + +// Public key corresponding to OE_DEBUG_SIGN_KEY +const char EXPECTED_MRSIGNER_PUBKEY[] = + "-----BEGIN PUBLIC KEY-----\n" + "MIIBoDANBgkqhkiG9w0BAQEFAAOCAY0AMIIBiAKCAYEAukAt/kn+T5FG64MM2dDv\n" + "R26WSrDjGu8XDjYisFwBbktinVUFE05mFO9X1GDBlOqS8lqZuq8fhwm4lZFSc01i\n" + "m6LlLRp4l+EOAHkhfRl+y4SDPlLbJX2yl5DMJjjTbWLH+Wiu5BzzWZ85Z2tPeS8d\n" + "aMnisrv3ZuyVGl+aJPC3x1SCtL4G4yk5+svrGwYemefSBV8sLviVaPmRcmeBV2x6\n" + "BLUc8/jgVVt3L9e0fWM3wnb9o9ZxJoIoAX1bFwXRnuP6N2xezEpfSWLgK41scmsN\n" + "AkCmsp0WvoeiaD9nsOGfRxZnBpHbZBC0IyzTEPiOI+5NhRQ3QFbdy1kFuJxOoFiZ\n" + "4leKZOwLqG264HwPmiTTWA7XXhP4+d/osb4F4BaEXZ7+4EYfbo5yxbjngcVI1oNN\n" + "drCZIy9spWXxqfrG3XMfReWteVlYr6GLcbB5fNE8qm9AiX+fAyw5/ACajPAduKqU\n" + "+7Q7ZoMNReay/Zkj9VPCAHeGZzLG/MUOC3Xtdjo3IJ/BAgED\n" + "-----END PUBLIC KEY-----\n"; + +size_t EXPECTED_MRSIGNER_PUBKEY_SIZE = OE_COUNTOF(EXPECTED_MRSIGNER_PUBKEY); + +ecall_dispatcher::ecall_dispatcher( + const char* name, + enclave_config_data_t* enclave_config) + : m_crypto(NULL), m_attestation(NULL) +{ + m_enclave_config = enclave_config; + m_initialized = initialize(name); +} + +ecall_dispatcher::~ecall_dispatcher() +{ + if (m_crypto) + delete m_crypto; + + if (m_attestation) + delete m_attestation; +} + +bool ecall_dispatcher::initialize(const char* name) +{ + bool ret = false; + uint8_t* modulus = NULL; + size_t modulus_size; + + m_name = name; + m_crypto = new Crypto(); + if (m_crypto == NULL) + { + goto exit; + } + + // Extract modulus from raw PEM. + if (!m_crypto->get_rsa_modulus_from_pem( + // m_enclave_config->other_enclave_pubkey_pem, + // m_enclave_config->other_enclave_pubkey_pem_size, + + // The expected MRSIGNER is the public key corresponding to + // the extended attestation re-signer (debug key in this example) + EXPECTED_MRSIGNER_PUBKEY, + EXPECTED_MRSIGNER_PUBKEY_SIZE, + &modulus, + &modulus_size)) + { + goto exit; + } + + // Reverse the modulus and compute sha256 on it. + for (size_t i = 0; i < modulus_size / 2; i++) + { + uint8_t tmp = modulus[i]; + modulus[i] = modulus[modulus_size - 1 - i]; + modulus[modulus_size - 1 - i] = tmp; + } + + // Calculate the MRSIGNER value which is the SHA256 hash of the + // little endian representation of the public key modulus. This value + // is populated by the signer_id sub-field of a parsed oe_report_t's + // identity field. + if (m_crypto->Sha256(modulus, modulus_size, m_other_enclave_mrsigner) != 0) + { + goto exit; + } + + m_attestation = new Attestation(m_crypto, m_other_enclave_mrsigner); + if (m_attestation == NULL) + { + goto exit; + } + ret = true; + +exit: + if (modulus != NULL) + free(modulus); + + return ret; +} + +/** + * Return the public key of this enclave along with the enclave's remote report. + * The enclave that receives the key will use the remote report to attest this + * enclave. + */ +int ecall_dispatcher::get_remote_report_with_pubkey( + uint8_t** pem_key, + size_t* key_size, + uint8_t** remote_report, + size_t* remote_report_size) +{ + uint8_t pem_public_key[512]; + uint8_t* report = NULL; + size_t report_size = 0; + uint8_t* key_buf = NULL; + int ret = 1; + + TRACE_ENCLAVE("get_remote_report_with_pubkey"); + if (m_initialized == false) + { + TRACE_ENCLAVE("ecall_dispatcher initialization failed."); + goto exit; + } + + m_crypto->retrieve_public_key(pem_public_key); + + // Generate a remote report for the public key so that the enclave that + // receives the key can attest this enclave. + if (m_attestation->generate_remote_report( + pem_public_key, sizeof(pem_public_key), &report, &report_size)) + { + // Allocate memory on the host and copy the report over. + *remote_report = (uint8_t*)oe_host_malloc(report_size); + if (*remote_report == NULL) + { + ret = OE_OUT_OF_MEMORY; + goto exit; + } + memcpy(*remote_report, report, report_size); + *remote_report_size = report_size; + oe_free_report(report); + + key_buf = (uint8_t*)oe_host_malloc(512); + if (key_buf == NULL) + { + ret = OE_OUT_OF_MEMORY; + goto exit; + } + memcpy(key_buf, pem_public_key, sizeof(pem_public_key)); + + *pem_key = key_buf; + *key_size = sizeof(pem_public_key); + + ret = 0; + TRACE_ENCLAVE("get_remote_report_with_pubkey succeeded"); + } + else + { + TRACE_ENCLAVE("get_remote_report_with_pubkey failed."); + } + +exit: + if (ret != 0) + { + if (report) + oe_free_report(report); + if (key_buf) + oe_host_free(key_buf); + if (*remote_report) + oe_host_free(*remote_report); + } + return ret; +} + +int ecall_dispatcher::verify_report_and_set_pubkey( + uint8_t* pem_key, + size_t key_size, + uint8_t* remote_report, + size_t remote_report_size, + oe_eeid_t* eeid) +{ + int ret = 1; + + if (m_initialized == false) + { + TRACE_ENCLAVE("ecall_dispatcher initialization failed."); + goto exit; + } + + // Attest the remote report and accompanying key. + if (m_attestation->attest_remote_report( + remote_report, remote_report_size, pem_key, key_size, eeid)) + { + memcpy(m_crypto->get_the_other_enclave_public_key(), pem_key, key_size); + } + else + { + TRACE_ENCLAVE("verify_report_and_set_pubkey failed."); + goto exit; + } + ret = 0; + TRACE_ENCLAVE("verify_report_and_set_pubkey succeeded."); + +exit: + return ret; +} diff --git a/samples/remote_attestation_eeid/common/dispatcher.h b/samples/remote_attestation_eeid/common/dispatcher.h new file mode 100644 index 0000000000..21e2b1e399 --- /dev/null +++ b/samples/remote_attestation_eeid/common/dispatcher.h @@ -0,0 +1,46 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#pragma once +#include +#include +#include "attestation.h" +#include "crypto.h" + +using namespace std; + +typedef struct _enclave_config_data +{ + uint8_t* enclave_secret_data; + const char* other_enclave_pubkey_pem; + size_t other_enclave_pubkey_pem_size; +} enclave_config_data_t; + +class ecall_dispatcher +{ + private: + bool m_initialized; + Crypto* m_crypto; + Attestation* m_attestation; + string m_name; + enclave_config_data_t* m_enclave_config; + unsigned char m_other_enclave_mrsigner[32]; + + public: + ecall_dispatcher(const char* name, enclave_config_data_t* enclave_config); + ~ecall_dispatcher(); + int get_remote_report_with_pubkey( + uint8_t** pem_key, + size_t* key_size, + uint8_t** remote_report, + size_t* remote_report_size); + int verify_report_and_set_pubkey( + uint8_t* pem_key, + size_t key_size, + uint8_t* remote_report, + size_t remote_report_size, + oe_eeid_t* eeid); + + private: + bool initialize(const char* name); +}; diff --git a/samples/remote_attestation_eeid/common/log.h b/samples/remote_attestation_eeid/common/log.h new file mode 100644 index 0000000000..507dcd8b81 --- /dev/null +++ b/samples/remote_attestation_eeid/common/log.h @@ -0,0 +1,13 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef OE_SAMPLES_ATTESTATION_ENC_LOG_H +#define OE_SAMPLES_ATTESTATION_ENC_LOG_H + +#include + +#define TRACE_ENCLAVE(fmt, ...) \ + \ + printf("Enclave: ***%s(%d): " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__) + +#endif // OE_SAMPLES_ATTESTATION_ENC_LOG_H diff --git a/samples/remote_attestation_eeid/enclave_a/CMakeLists.txt b/samples/remote_attestation_eeid/enclave_a/CMakeLists.txt new file mode 100644 index 0000000000..c63833ed70 --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_a/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Generate header with public key of enclave B (2) +add_custom_command(OUTPUT enclave_b_pubkey.h + DEPENDS public_key_b ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh + COMMAND ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_b_pubkey.h ${CMAKE_BINARY_DIR}/enclave_b/public_b.pem) + +add_executable(enclave_a ecalls.cpp ${CMAKE_CURRENT_BINARY_DIR}/enclave_b_pubkey.h) + +if(WIN32) + maybe_build_using_clangw(enclave_a) +endif() + +target_include_directories(enclave_a PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(enclave_a common) + +# Generate key A +add_custom_command(OUTPUT private_a.pem public_a.pem + COMMAND openssl genrsa -out private_a.pem -3 3072 + COMMAND openssl rsa -in private_a.pem -pubout -out public_a.pem) + +add_custom_target(public_key_a DEPENDS public_a.pem) + +# Sign enclave A with key A +add_custom_command(OUTPUT enclave_a.signed + DEPENDS enclave_a enc.conf private_a.pem + COMMAND openenclave::oesign sign -e $ -c ${CMAKE_CURRENT_SOURCE_DIR}/enc.conf -k private_a.pem) + +add_custom_target(enclave_a_signed ALL DEPENDS enclave_a.signed) diff --git a/samples/remote_attestation_eeid/enclave_a/Makefile b/samples/remote_attestation_eeid/enclave_a/Makefile new file mode 100644 index 0000000000..bb6cf7daf3 --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_a/Makefile @@ -0,0 +1,57 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Detect C and C++ compiler options +# if not gcc and g++, default to clang-7 +C_COMPILER=$(notdir $(CC)) +ifeq ($(C_COMPILER), gcc) + CXX_COMPILER=$(notdir $(CXX)) + USE_GCC = true +endif + +ifeq ($(USE_GCC),) + CC = clang-7 + CXX = clang++-7 + C_COMPILER=clang + CXX_COMPILER=clang++ +endif + +CFLAGS=$(shell pkg-config oeenclave-$(C_COMPILER) --cflags) +CXXFLAGS=$(shell pkg-config oeenclave-$(CXX_COMPILER) --cflags) +LDFLAGS=$(shell pkg-config oeenclave-$(CXX_COMPILER) --libs) + +all: + $(MAKE) genkey + $(MAKE) -C ../enclave_b genkey + $(MAKE) build + $(MAKE) sign + +private.pem: + openssl genrsa -out $@ -3 3072 + +public.pem: private.pem + openssl rsa -in $< -out $@ -pubout + +# The enclaves in the sample will check if the other enclave is signed +# with the expected key. Since this sample builds both enclaves, we can +# inject the expected public keys at build time. +# +# If the other public key isn't known, then we would have to load the +# public key from the host. We can't simply load the raw public key since +# a malicious host might change it. So, we would need to load a certicate +# that contains the expected public key that is signed by a trusted CA. +genkey: public.pem + ../gen_pubkey_header.sh ../enclave_b/enclave_a_pubkey.h $< + +build: + @ echo "Compilers used: $(CC), $(CXX)" + oeedger8r ../remoteattestation.edl --trusted --trusted-dir ../common + $(CXX) -g -c $(CXXFLAGS) $(INCLUDES) -I.. -std=c++11 -DOE_API_VERSION=2 ecalls.cpp ../common/attestation.cpp ../common/crypto.cpp ../common/dispatcher.cpp + $(CC) -g -c $(CFLAGS) $(CINCLUDES) -I.. -DOE_API_VERSION=2 ../common/remoteattestation_t.c + $(CXX) -o enclave_a attestation.o crypto.o ecalls.o dispatcher.o remoteattestation_t.o $(LDFLAGS) + +sign: + oesign sign -e enclave_a -c enc.conf -k private.pem + +clean: + rm -f *.o enclave_a enclave_a.signed ../common/remoteattestation_t.* ../common/remoteattestation_args.h *.pem enclave_b_pubkey.h diff --git a/samples/remote_attestation_eeid/enclave_a/ecalls.cpp b/samples/remote_attestation_eeid/enclave_a/ecalls.cpp new file mode 100644 index 0000000000..a584010c50 --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_a/ecalls.cpp @@ -0,0 +1,60 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. +#include +#include +#include +#include "enclave_b_pubkey.h" + +// For this purpose of this example: demonstrating how to do remote attestation +// g_enclave_secret_data is hardcoded as part of the enclave. In this sample, +// the secret data is hard coded as part of the enclave binary. In a real world +// enclave implementation, secrets are never hard coded in the enclave binary +// since the enclave binary itself is not encrypted. Instead, secrets are +// acquired via provisioning from a service (such as a cloud server) after +// successful attestation. +// The g_enclave_secret_data holds the secret data specific to the holding +// enclave, it's only visible inside this secured enclave. Arbitrary enclave +// specific secret data exchanged by the enclaves. In this sample, the first +// enclave sends its g_enclave_secret_data (encrypted) to the second enclave. +// The second enclave decrypts the received data and adds it to its own +// g_enclave_secret_data, and sends it back to the other enclave. +uint8_t g_enclave_secret_data[ENCLAVE_SECRET_DATA_SIZE] = + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + +enclave_config_data_t config_data = {g_enclave_secret_data, + OTHER_ENCLAVE_PUBLIC_KEY, + sizeof(OTHER_ENCLAVE_PUBLIC_KEY)}; + +// Declare a static dispatcher object for enabling +// for better organizing enclave-wise global variables +static ecall_dispatcher dispatcher("Enclave1", &config_data); +const char* enclave_name = "Enclave1"; +/** + * Return the public key of this enclave along with the enclave's remote report. + * Another enclave can use the remote report to attest the enclave and verify + * the integrity of the public key. + */ +int get_remote_report_with_pubkey( + uint8_t** pem_key, + size_t* key_size, + uint8_t** remote_report, + size_t* remote_report_size) +{ + TRACE_ENCLAVE("enter get_remote_report_with_pubkey"); + return dispatcher.get_remote_report_with_pubkey( + pem_key, key_size, remote_report, remote_report_size); +} + +// Attest and store the public key of another enclave. +int verify_report_and_set_pubkey( + uint8_t* pem_key, + size_t key_size, + uint8_t* remote_report, + size_t remote_report_size, + oe_eeid_t* eeid, + size_t eeid_byte_size) +{ + (void)eeid_byte_size; + return dispatcher.verify_report_and_set_pubkey( + pem_key, key_size, remote_report, remote_report_size, eeid); +} diff --git a/samples/remote_attestation_eeid/enclave_a/enc.conf b/samples/remote_attestation_eeid/enclave_a/enc.conf new file mode 100644 index 0000000000..31dfe3de9e --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_a/enc.conf @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Enclave settings: +Debug=1 +NumHeapPages=0 +NumStackPages=0 +NumTCS=0 +ProductID=1 +SecurityVersion=1 diff --git a/samples/remote_attestation_eeid/enclave_b/CMakeLists.txt b/samples/remote_attestation_eeid/enclave_b/CMakeLists.txt new file mode 100644 index 0000000000..182425d0c0 --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_b/CMakeLists.txt @@ -0,0 +1,31 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Generate header with public key of enclave A +add_custom_command(OUTPUT enclave_a_pubkey.h + DEPENDS public_key_a ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh + COMMAND ${CMAKE_SOURCE_DIR}/gen_pubkey_header.sh enclave_a_pubkey.h ${CMAKE_BINARY_DIR}/enclave_a/public_a.pem) + +add_executable(enclave_b ecalls.cpp ${CMAKE_CURRENT_BINARY_DIR}/enclave_a_pubkey.h) + +if(WIN32) + maybe_build_using_clangw(enclave_b) +endif() + +target_include_directories(enclave_b PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(enclave_b common) + +# Generate key B +add_custom_command(OUTPUT private_b.pem public_b.pem + COMMAND openssl genrsa -out private_b.pem -3 3072 + COMMAND openssl rsa -in private_b.pem -pubout -out public_b.pem) + +add_custom_target(public_key_b DEPENDS public_b.pem) + +# Sign enclave B with key B +add_custom_command(OUTPUT enclave_b.signed + DEPENDS enclave_b enc.conf private_b.pem + COMMAND openenclave::oesign sign -e $ -c ${CMAKE_CURRENT_SOURCE_DIR}/enc.conf -k private_b.pem) + +add_custom_target(enclave_b_signed ALL DEPENDS enclave_b.signed) diff --git a/samples/remote_attestation_eeid/enclave_b/Makefile b/samples/remote_attestation_eeid/enclave_b/Makefile new file mode 100644 index 0000000000..d4b0a566e5 --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_b/Makefile @@ -0,0 +1,56 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Detect C and C++ compiler options +# if not gcc and g++, default to clang-7 +C_COMPILER=$(notdir $(CC)) +ifeq ($(C_COMPILER), gcc) + CXX_COMPILER=$(notdir $(CXX)) + USE_GCC = true +endif + +ifeq ($(USE_GCC),) + CC = clang-7 + CXX = clang++-7 + C_COMPILER=clang + CXX_COMPILER=clang++ +endif + +CFLAGS=$(shell pkg-config oeenclave-$(C_COMPILER) --cflags) +CXXFLAGS=$(shell pkg-config oeenclave-$(CXX_COMPILER) --cflags) +LDFLAGS=$(shell pkg-config oeenclave-$(CXX_COMPILER) --libs) + +all: + $(MAKE) genkey + $(MAKE) -C ../enclave_a genkey + $(MAKE) build + $(MAKE) sign + +private.pem: + openssl genrsa -out $@ -3 3072 + +public.pem: private.pem + openssl rsa -in $< -out $@ -pubout + +# The enclaves in the sample will check if the other enclave is signed +# with the expected key. Since this sample builds both enclaves, we can +# inject the expected public keys at build time. +# +# If the other public key isn't known, then we would have to load the +# public key from the host. We can't simply load the raw public key since +# a malicious host might change it. So, we would need to load a certicate +# that contains the expected public key that is signed by a trusted CA. +genkey: public.pem + ../gen_pubkey_header.sh ../enclave_a/enclave_b_pubkey.h $< + +build: + @ echo "Compilers used: $(CC), $(CXX)" + $(CXX) -g -c $(CXXFLAGS) $(INCLUDES) -I.. -std=c++11 -DOE_API_VERSION=2 ecalls.cpp ../common/attestation.cpp ../common/crypto.cpp ../common/dispatcher.cpp + $(CC) -g -c $(CFLAGS) $(CINCLUDES) -I.. -DOE_API_VERSION=2 ../common/remoteattestation_t.c + $(CXX) -o enclave_b attestation.o crypto.o ecalls.o dispatcher.o remoteattestation_t.o $(LDFLAGS) + +sign: + oesign sign -e enclave_b -c enc.conf -k private.pem + +clean: + rm -f *.o enclave_b enclave_b.signed ../common/remoteattestation_t.* ../common/remoteattestation_args.h *.pem enclave_a_pubkey.h \ No newline at end of file diff --git a/samples/remote_attestation_eeid/enclave_b/ecalls.cpp b/samples/remote_attestation_eeid/enclave_b/ecalls.cpp new file mode 100644 index 0000000000..d95d6f223c --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_b/ecalls.cpp @@ -0,0 +1,60 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. +#include +#include +#include +#include "enclave_a_pubkey.h" + +// For this purpose of this example: demonstrating how to do remote attestation +// g_enclave_secret_data is hardcoded as part of the enclave. In this sample, +// the secret data is hard coded as part of the enclave binary. In a real world +// enclave implementation, secrets are never hard coded in the enclave binary +// since the enclave binary itself is not encrypted. Instead, secrets are +// acquired via provisioning from a service (such as a cloud server) after +// successful attestation. +// This g_enclave_secret_data holds the secret data specific to the holding +// enclave, it's only visible inside this secured enclave. Arbitrary enclave +// specific secret data exchanged by the enclaves. In this sample, the first +// enclave sends its g_enclave_secret_data (encrypted) to the second enclave. +// The second enclave decrypts the received data and adds it to its own +// g_enclave_secret_data, and sends it back to the other enclave. +uint8_t g_enclave_secret_data[ENCLAVE_SECRET_DATA_SIZE] = + {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + +enclave_config_data_t config_data = {g_enclave_secret_data, + OTHER_ENCLAVE_PUBLIC_KEY, + sizeof(OTHER_ENCLAVE_PUBLIC_KEY)}; + +// Declare a static dispatcher object for enabling +// for better organizing enclave-wise global variables +static ecall_dispatcher dispatcher("Enclave2", &config_data); +const char* enclave_name = "Enclave2"; + +/** + * Return the public key of this enclave along with the enclave's remote report. + * Another enclave can use the remote report to attest the enclave and verify + * the integrity of the public key. + */ +int get_remote_report_with_pubkey( + uint8_t** pem_key, + size_t* key_size, + uint8_t** remote_report, + size_t* remote_report_size) +{ + return dispatcher.get_remote_report_with_pubkey( + pem_key, key_size, remote_report, remote_report_size); +} + +// Attest and store the public key of another enclave. +int verify_report_and_set_pubkey( + uint8_t* pem_key, + size_t key_size, + uint8_t* remote_report, + size_t remote_report_size, + oe_eeid_t* eeid, + size_t eeid_byte_size) +{ + (void)eeid_byte_size; + return dispatcher.verify_report_and_set_pubkey( + pem_key, key_size, remote_report, remote_report_size, eeid); +} diff --git a/samples/remote_attestation_eeid/enclave_b/enc.conf b/samples/remote_attestation_eeid/enclave_b/enc.conf new file mode 100644 index 0000000000..31dfe3de9e --- /dev/null +++ b/samples/remote_attestation_eeid/enclave_b/enc.conf @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Enclave settings: +Debug=1 +NumHeapPages=0 +NumStackPages=0 +NumTCS=0 +ProductID=1 +SecurityVersion=1 diff --git a/samples/remote_attestation_eeid/gen_pubkey_header.sh b/samples/remote_attestation_eeid/gen_pubkey_header.sh new file mode 100755 index 0000000000..d6ac4ffb30 --- /dev/null +++ b/samples/remote_attestation_eeid/gen_pubkey_header.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +destfile="$1" +pubkey_file="$2" + +cat > "$destfile" << EOF +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef SAMPLES_REMOTE_ATTESTATION_PUBKEY_H +#define SAMPLES_REMOTE_ATTESTATION_PUBKEY_H + +EOF + +printf 'static const char OTHER_ENCLAVE_PUBLIC_KEY[] =' >> "$destfile" +while IFS="" read -r p || [ -n "$p" ] +do + # Sometimes openssl can insert carriage returns into the PEM files. Let's remove those! + CR=$(printf "\r") + p=$(echo "$p" | tr -d "$CR") + printf '\n \"%s\\n\"' "$p" >> "$destfile" +done < "$pubkey_file" +printf ';\n' >> "$destfile" + +cat >> "$destfile" << EOF + +#endif /* SAMPLES_REMOTE_ATTESTATION_PUBKEY_H */ +EOF diff --git a/samples/remote_attestation_eeid/host/CMakeLists.txt b/samples/remote_attestation_eeid/host/CMakeLists.txt new file mode 100644 index 0000000000..5369024603 --- /dev/null +++ b/samples/remote_attestation_eeid/host/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command(OUTPUT remoteattestation_u.h remoteattestation_u.c remoteattestation_args.h + DEPENDS ${CMAKE_SOURCE_DIR}/remoteattestation.edl + COMMAND openenclave::oeedger8r --untrusted ${CMAKE_SOURCE_DIR}/remoteattestation.edl) + +add_executable(remote_attestation_host host.cpp ${CMAKE_CURRENT_BINARY_DIR}/remoteattestation_u.c) +target_include_directories(remote_attestation_host PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../ # For common/shared.h + ${CMAKE_CURRENT_BINARY_DIR}) + +if(WIN32) + add_dcap_client_target(remote_attestation_dcap_target) + add_dependencies(remote_attestation_host remote_attestation_dcap_target) + copy_oedebugrt_target(remote_attestation_oedebugrt_target) + add_dependencies(remote_attestation_host remote_attestation_oedebugrt_target) +endif() + +target_link_libraries(remote_attestation_host openenclave::oehostapp) diff --git a/samples/remote_attestation_eeid/host/Makefile b/samples/remote_attestation_eeid/host/Makefile new file mode 100644 index 0000000000..c4d906561d --- /dev/null +++ b/samples/remote_attestation_eeid/host/Makefile @@ -0,0 +1,33 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Detect C and C++ compiler options +# if not gcc and g++, default to clang-7 +C_COMPILER=$(notdir $(CC)) +ifeq ($(C_COMPILER), gcc) + CXX_COMPILER=$(notdir $(CXX)) + USE_GCC = true +endif + +ifeq ($(USE_GCC),) + CC = clang-7 + CXX = clang++-7 + C_COMPILER=clang + CXX_COMPILER=clang++ +endif + +CFLAGS=$(shell pkg-config oehost-$(C_COMPILER) --cflags) +CXXFLAGS=$(shell pkg-config oehost-$(CXX_COMPILER) --cflags) +LDFLAGS=$(shell pkg-config oehost-$(CXX_COMPILER) --libs) + +all: build + +build: + @ echo "Compilers used: $(CC), $(CXX)" + oeedger8r ../remoteattestation.edl --untrusted + $(CC) -g -c $(CFLAGS) $(CINCLUDES) remoteattestation_u.c + $(CXX) -g -c $(CXXFLAGS) $(INCLUDES) host.cpp + $(CXX) -o attestation_host host.o remoteattestation_u.o $(LDFLAGS) + +clean: + rm -f attestation_host *.o remoteattestation_u.* remoteattestation_args.h \ No newline at end of file diff --git a/samples/remote_attestation_eeid/host/host.cpp b/samples/remote_attestation_eeid/host/host.cpp new file mode 100644 index 0000000000..4e9d7774d1 --- /dev/null +++ b/samples/remote_attestation_eeid/host/host.cpp @@ -0,0 +1,208 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include "remoteattestation_u.h" + +oe_enclave_t* create_enclave(const char* enclave_path, oe_eeid_t* eeid) +{ + oe_enclave_t* enclave = NULL; + + printf("Host: Enclave library %s\n", enclave_path); + oe_result_t result = oe_create_remoteattestation_enclave_eeid( + enclave_path, + OE_ENCLAVE_TYPE_SGX, + OE_ENCLAVE_FLAG_DEBUG, + NULL, + 0, + eeid, + &enclave); + + if (result != OE_OK) + { + printf( + "Host: oe_create_remoteattestation_enclave failed. %s", + oe_result_str(result)); + } + else + { + printf("Host: Enclave successfully created.\n"); + } + return enclave; +} + +void terminate_enclave(oe_enclave_t* enclave) +{ + oe_terminate_enclave(enclave); + printf("Host: Enclave successfully terminated.\n"); +} + +int main(int argc, const char* argv[]) +{ + oe_enclave_t* enclave_a = NULL; + oe_enclave_t* enclave_b = NULL; + uint8_t* encrypted_msg = NULL; + size_t encrypted_msg_size = 0; + oe_result_t result = OE_OK; + int ret = 1; + uint8_t* pem_key = NULL; + size_t pem_key_size = 0; + uint8_t* remote_report = NULL; + size_t remote_report_size = 0; + + uint32_t eeid_size = 512; + uint64_t eeid_byte_size = sizeof(oe_eeid_t) + eeid_size; + oe_eeid_t* eeid_a = (oe_eeid_t*)calloc(1, eeid_byte_size); + oe_eeid_t* eeid_b = (oe_eeid_t*)calloc(1, eeid_byte_size); + eeid_a->data_size = eeid_b->data_size = eeid_size; + + for (size_t i = 0; i < eeid_size; i++) + { + eeid_a->data[i] = i; + eeid_b->data[i] = eeid_size - i - 1; + + eeid_a->size_settings.num_heap_pages = + eeid_b->size_settings.num_heap_pages = 37; + eeid_a->size_settings.num_stack_pages = + eeid_b->size_settings.num_stack_pages = 6; + eeid_a->size_settings.num_tcs = eeid_b->size_settings.num_tcs = 1; + } + + /* Check argument count */ + if (argc != 3) + { + printf("Usage: %s ENCLAVE_PATH\n", argv[0]); + return 1; + } + + printf("Host: Creating two enclaves\n"); + enclave_a = create_enclave(argv[1], eeid_a); + if (enclave_a == NULL) + { + goto exit; + } + enclave_b = create_enclave(argv[2], eeid_b); + if (enclave_b == NULL) + { + goto exit; + } + + printf("Host: requesting a remote report and the encryption key from 1st " + "enclave\n"); + result = get_remote_report_with_pubkey( + enclave_a, + &ret, + &pem_key, + &pem_key_size, + &remote_report, + &remote_report_size); + if ((result != OE_OK) || (ret != 0)) + { + printf( + "Host: verify_report_and_set_pubkey failed. %s", + oe_result_str(result)); + if (ret == 0) + ret = 1; + goto exit; + } + printf("Host: 1st enclave's public key: \n%s", pem_key); + + printf("Host: requesting 2nd enclave to attest 1st enclave's the remote " + "report and the public key\n"); + result = verify_report_and_set_pubkey( + enclave_b, + &ret, + pem_key, + pem_key_size, + remote_report, + remote_report_size, + eeid_a, + eeid_byte_size); + if ((result != OE_OK) || (ret != 0)) + { + printf( + "Host: verify_report_and_set_pubkey failed. %s", + oe_result_str(result)); + if (ret == 0) + ret = 1; + goto exit; + } + free(pem_key); + pem_key = NULL; + free(remote_report); + remote_report = NULL; + + printf("Host: Requesting a remote report and the encryption key from " + "2nd enclave=====\n"); + result = get_remote_report_with_pubkey( + enclave_b, + &ret, + &pem_key, + &pem_key_size, + &remote_report, + &remote_report_size); + if ((result != OE_OK) || (ret != 0)) + { + printf( + "Host: verify_report_and_set_pubkey failed. %s", + oe_result_str(result)); + if (ret == 0) + ret = 1; + goto exit; + } + + printf("Host: 2nd enclave's public key: \n%s", pem_key); + + printf("Host: Requesting first enclave to attest 2nd enclave's " + "remote report and the public key=====\n"); + result = verify_report_and_set_pubkey( + enclave_a, + &ret, + pem_key, + pem_key_size, + remote_report, + remote_report_size, + eeid_b, + eeid_byte_size); + if ((result != OE_OK) || (ret != 0)) + { + printf( + "Host: verify_report_and_set_pubkey failed. %s", + oe_result_str(result)); + if (ret == 0) + ret = 1; + goto exit; + } + free(pem_key); + pem_key = NULL; + free(remote_report); + remote_report = NULL; + + printf("Host: Remote attestation Succeeded\n"); + + // Free host memory allocated by the enclave. + free(encrypted_msg); + encrypted_msg = NULL; + ret = 0; + +exit: + if (pem_key) + free(pem_key); + + if (remote_report) + free(remote_report); + + if (encrypted_msg != NULL) + free(encrypted_msg); + + printf("Host: Terminating enclaves\n"); + if (enclave_a) + terminate_enclave(enclave_a); + + if (enclave_b) + terminate_enclave(enclave_b); + + printf("Host: %s \n", (ret == 0) ? "succeeded" : "failed"); + return ret; +} diff --git a/samples/remote_attestation_eeid/images/attestationsample.png b/samples/remote_attestation_eeid/images/attestationsample.png new file mode 100644 index 0000000000..a6a96960ef Binary files /dev/null and b/samples/remote_attestation_eeid/images/attestationsample.png differ diff --git a/samples/remote_attestation_eeid/images/localattestation.png b/samples/remote_attestation_eeid/images/localattestation.png new file mode 100644 index 0000000000..5867a3b1df Binary files /dev/null and b/samples/remote_attestation_eeid/images/localattestation.png differ diff --git a/samples/remote_attestation_eeid/images/remoteattestation_sample.png b/samples/remote_attestation_eeid/images/remoteattestation_sample.png new file mode 100644 index 0000000000..456b9cc91c Binary files /dev/null and b/samples/remote_attestation_eeid/images/remoteattestation_sample.png differ diff --git a/samples/remote_attestation_eeid/images/remoteattestation_sample_details.png b/samples/remote_attestation_eeid/images/remoteattestation_sample_details.png new file mode 100644 index 0000000000..d38f3aead4 Binary files /dev/null and b/samples/remote_attestation_eeid/images/remoteattestation_sample_details.png differ diff --git a/samples/remote_attestation_eeid/images/remoteattestation_service.png b/samples/remote_attestation_eeid/images/remoteattestation_service.png new file mode 100644 index 0000000000..1aeb1fb1f5 Binary files /dev/null and b/samples/remote_attestation_eeid/images/remoteattestation_service.png differ diff --git a/samples/remote_attestation_eeid/remoteattestation.edl b/samples/remote_attestation_eeid/remoteattestation.edl new file mode 100644 index 0000000000..e1ca27b54b --- /dev/null +++ b/samples/remote_attestation_eeid/remoteattestation.edl @@ -0,0 +1,27 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + + // Return the public key of this enclave along with the enclave's remote report. + // Another enclave can use the remote report to attest the enclave and verify + // the integrity of the public key. + public int get_remote_report_with_pubkey( [out] uint8_t **pem_key, + [out] size_t *key_size, + [out] uint8_t **remote_report, + [out] size_t *remote_report_size); + + // Attest and store the public key of another enclave + public int verify_report_and_set_pubkey( [in, count=key_size] uint8_t *pem_key, + size_t key_size, + [in, count=remote_report_size] uint8_t *remote_report, + size_t remote_report_size, + [in, size=eeid_byte_size] oe_eeid_t* eeid, + size_t eeid_byte_size); + }; + + //untrusted { + // no untrusted functions in this sample + //}; +}; diff --git a/samples/switchless/CMakeLists.txt b/samples/switchless/CMakeLists.txt new file mode 100644 index 0000000000..736188069c --- /dev/null +++ b/samples/switchless/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.11) + +project("Switchless Call Sample" LANGUAGES C CXX) + +find_package(OpenEnclave CONFIG REQUIRED) + +set(CMAKE_CXX_STANDARD 11) + +add_subdirectory(enclave) +add_subdirectory(host) + +# Generate key +add_custom_command(OUTPUT private.pem public.pem + COMMAND openssl genrsa -out private.pem -3 3072 + COMMAND openssl rsa -in private.pem -pubout -out public.pem) + +# Sign enclave +add_custom_command(OUTPUT enclave/enclave.signed + DEPENDS enclave enclave/switchless.conf private.pem + COMMAND openenclave::oesign sign -e $ -c ${CMAKE_SOURCE_DIR}/enclave/switchless.conf -k private.pem) + +add_custom_target(sign ALL DEPENDS enclave/enclave.signed) + +if ((NOT DEFINED ENV{OE_SIMULATION}) OR (NOT $ENV{OE_SIMULATION})) + add_custom_target(run + DEPENDS switchless_host sign + COMMAND switchless_host ${CMAKE_BINARY_DIR}/enclave/enclave.signed) +endif () + +add_custom_target(simulate + DEPENDS switchless_host sign + COMMAND switchless_host ${CMAKE_BINARY_DIR}/enclave/enclave.signed --simulate) diff --git a/samples/switchless/Makefile b/samples/switchless/Makefile new file mode 100644 index 0000000000..4ef7181d3b --- /dev/null +++ b/samples/switchless/Makefile @@ -0,0 +1,20 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +.PHONY: all build clean run simulate + +all: build + +build: + $(MAKE) -C enclave + $(MAKE) -C host + +clean: + $(MAKE) -C enclave clean + $(MAKE) -C host clean + +run: + host/switchlesshost ./enclave/switchlessenc.signed + +simulate: + host/switchlesshost ./enclave/switchlessenc.signed --simulate diff --git a/samples/switchless/README.md b/samples/switchless/README.md new file mode 100644 index 0000000000..e3f11caae0 --- /dev/null +++ b/samples/switchless/README.md @@ -0,0 +1,206 @@ +# Switchless Calls Sample + +This sample demonstrates how to make switchless calls to host from inside an enclave. +It has the following properties: + +- Explain the concept of switchless calls +- Identify cases where switchless calls are appropriate +- Demonstrate how to mark a function as `transition_using_threads` in EDL, and use [`oeedger8r`](https://github.com/openenclave/openenclave/tree/master/docs/GettingStartedDocs/Edger8rGettingStarted.md) tool to compile it +- Demonstrate how to configure an enclave to enable switchless calls originated within it +- Recommend the number of host worker threads required for switchless calls in practice + +Prerequisite: you may want to read [Common Sample Information](../README.md#common-sample-information) before going further. + +## Switchless Calls + +In an enclave application, the host makes **ECALL**s into functions exposed by the enclaves it created. Likewise, +the enclaves may make **OCALL**s into functions exposed by the host that created them. In either case, the +execution has to be transitioned from an untrusted environment to a trusted environment, or vice versa. Since the +transition is costly due to heavy security checks, it might be more performance advantageous to make the calls +**context-switchless**: the caller delegates the function call to a worker thread in the other environment, which +does the real job of calling the function and post the result to the caller. Both the calling thread and the +worker thread never leave their respective execution contexts during the perceived function call. + +The calling thread and the worker thread need to exchange information twice during the call. When the switchless +call is initiated, the caller needs to pass the `job` (encapsulating information regarding the function call in a + single object, for details see the next section) to the worker thread. And when the call finishes, the worker +thread needs to pass the result back to the caller. Both exchanges need to be synchronized. + +While switchless calls save transition time, they require at least one additional thread to service the calls. +Currently, the worker threads that service the calls busy-wait for messages and therefore consume a lot of CPU. +Thus more worker threads typically means more competition for the CPU cores and more thread context switches, +hurting the performance. In order to determine whether to make a particular function switchless, one has to weigh +the associated costs and savings. In general, the good candidates for switchless calls are functions that are: +1) short, thus the transition takes relatively high percentage of the overall execution time of the call; and +2) called frequently, so the savings in transition time add up. + +## How does Open Enclave support switchless OCALLs + +Open Enclave only supports synchronous switchless OCALLs currently. When the caller within an enclave makes a +switchless OCALL, the trusted Open Enclave runtime creates a `job` out of the function call. The `job` object +includes information such as the function ID, the parameters marshaled into a buffer, and a buffer for holding the +return value(s). The job is posted to a shared memory region which both the enclave and the host can access. + +A host worker thread checks and retrieves `job` from the shared memory region. It uses the untrusted Open Enclave +runtime to process the `job` by unmarshaling the parameters, then dispatching to the callee function, and finally +relaying the result back to the trusted Open Enclave runtime, which is further forwarded back to the caller. + +If an enclave supports multiple simultaneous ECALLs, multiple simultaneous switchless OCALLs could be made from the +enclave. We use multi-threaded host workers in that scenario. Open Enclave +allows users to configure how many host worker threads are to be created for servicing switchless OCALLs. The +following example illustrates how to do that. A word of caution is that too many host worker threads might increase +competition of cores between threads and degrade the performance. Therefore, if a enclave has switchless calls +enabled, Open Enclave caps the number of host worker threads for it to the number of enclave threads specified. + +With the current implementation, we recommend that users avoid using more host worker threads than the minimum of: + +1. the number of simultaneously active enclave threads, and +2. the number of cores that are potentially available to host worker threads. + +For example, on a 4-core machine, if the number of the simultaneously active enclave threads is 2, and there are no +host threads other than the two threads making ECALLs and the switchless worker threads, both 1) and 2) would be 2. +So we recommend setting the number of host worker threads to 2. + +The exception to the above rule happens when 2) is zero or negative. For example, if the host starts two more +additional threads that are expected to be active along with the two enclave threads, the number of cores available +to the worker threads is actually 0, and the minimum of 1) and 2) would be 0. In this case, we recommend setting +the number of host worker threads to 1 nevertheless, to ensure switchless calls are serviced by at least one thread. + +The above recommendation may change when we modify the behavior of worker threads in the future. + +## About the EDL + +In this sample, we pretend the enclave doesn't know addition. It relies on a host function to +increment a number by 1, and repeats calling it `N` times to add `N` to a given number. Since the host function is +short and called frequently, it is appropriate to make it a switchless function. + +We want to compare the performance of switchless calls vs. regular calls. To that end, we define two variants of +the host function: `host_increment_regular` which is a regular OCALL, and `host_increment_switchless`, +which is called switchlessly. + +Additionally, We define two enclave functions `enclave_add_N_regular` and `enclave_add_N_switchless`, which call host function +`host_increment_regular` and `host_increment_switchless` respectively. Both enclave functions call its host function +in a loop repeatedly. The number of iterations is determined by parameter `n`. + +The host functions and enclave functions are defined in an EDL file `switchless.edl` as below: + +```edl +enclave { + trusted { + public void enclave_add_N_switchless([in, out] int* m, int n); + public void enclave_add_N_regular([in, out] int* m, int n); + };t + + untrusted { + void host_increment_switchless([in, out] int* m) transition_using_threads; + void host_increment_regular([in, out] int* m); + }; +}; +``` + +Function `host_increment_switchless`'s declaration ends with keyword `transition_using_threads`, indicating it should be +called switchlessly at run time. However, this a best-effort directive. Open Enclave runtime may still choose +to fall back to a tradition OCALL if switchless call resources are unavailable, e.g., the enclave is not configured +as switchless-capable, or the host worker threads are busy servicing other switchless OCALLs. In this example, +`host_increment_switchless` is always called switchlessly because there are no simultaneous switchless OCALLs. + +To generate the functions with the marshaling code, the `oeedger8r` tool is called in both the host and enclave +directories from their Makefiles. For example: + +```bash +cd host +oeedger8r ../switchless.edl --untrusted +``` + +## About the host + +The host first defines a structure specifically for configuring switchless calls. In this case, we specify the +first field `1` as the number of host worker threads for switchless OCALLs. In this example, 1) There is at most +1 enclave thread all the time, and 2) The number of cores available to the host worker threads is unknown, and +so we use 1 as explained above. The 2nd field specifies the number of enclave threads for switchless ECALLs. +Since switchless ECALL is not yet implemented, we require the 2nd field to be `0`. + +```c +oe_enclave_setting_context_switchless_t switchless_setting = {1, 0}; +``` + +The host then puts the structure address and the setting type in an array of settings for the enclave +to be created. Even though we only have one setting (for switchless) for the enclave, we'd like the +flexibility of adding more than one setting (with different types) for an enclave in the future. + +```c +oe_enclave_setting_t settings[] = {{ + .setting_type = OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS, + .u.context_switchless_setting = &setting, + }}; +``` + +To make the settings created above effective, we need to pass the array `settingss` into `oe_create_enclave` +in the following way: + +```c +oe_create_switchless_enclave( + argv[1], + OE_ENCLAVE_TYPE_SGX, + flags, + settings, + OE_COUNTOF(settings), + &enclave); +``` + +The host then makes an ECALL of `enclave_add_N_regular` to transition into the enclave to compute the sum of +two integers `m` and `n`. After that, the host makes an ECALL of `enclave_add_N_switchless` to perform the same +computation except for using switchless OCALLs instead of regular OCALLs. We print out the time spent on both +ECALLs to highlight the performance advantage of switchless calls in this case. + +## About the enclave + +The enclave exposes two functions `enclave_add_N_switchless` and `enclave_add_N_regular`, both taking +two parameters `m` and `n`. The formal calls host function `host_increment_switchless`, while the latter +calls `host_increment_regular`. Both host functions are called in a loop of `n` iterations. + +## Build and run + +Note that there are two different build systems supported, one using GNU Make and +`pkg-config`, the other using CMake. + +If the build and run succeed, output like the following is expected (the exact time spent on the enclave functions could vary): + +```bash +host/switchlesshost ./enclave/switchlessenc.signed +enclave_add_N_switchless(): 1000000 + 1000000 = 2000000. Time spent: 923 ms +enclave_add_N_regular(): 1000000 + 1000000 = 2000000. Time spent: 19167 ms +``` + +We expect to see a speed up of the first ECALL over the 2nd one due to switchless calls. + +### CMake + +This uses the CMake package provided by the Open Enclave SDK. + +```bash +cd switchless +mkdir build && cd build +cmake .. +make run +``` + +### GNU Make + +```bash +cd switchless +make build +make run +``` +#### Note + +switchless sample can run under Open Enclave simulation mode. + +To run the switchless sample in simulation mode from the command like, use the following: + +```bash +# if built with cmake +./host/switchless_host ./enclave/switchless_enc.signed --simulate +# or, if built with GNU Make and pkg-config +make simulate +``` diff --git a/samples/switchless/enclave/CMakeLists.txt b/samples/switchless/enclave/CMakeLists.txt new file mode 100644 index 0000000000..755e5c9919 --- /dev/null +++ b/samples/switchless/enclave/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Use the edger8r to generate C bindings from the EDL file. +add_custom_command(OUTPUT switchless_t.h switchless_t.c switchless_args.h + DEPENDS ${CMAKE_SOURCE_DIR}/switchless.edl + COMMAND openenclave::oeedger8r --trusted ${CMAKE_SOURCE_DIR}/switchless.edl) + +add_executable(enclave enc.c ${CMAKE_CURRENT_BINARY_DIR}/switchless_t.c) + +if (WIN32) + maybe_build_using_clangw(enclave) +endif () + +target_compile_definitions(enclave PUBLIC OE_API_VERSION=2) + +# Need for the generated file switchless_t.h +target_include_directories(enclave PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(enclave openenclave::oeenclave openenclave::oelibc) diff --git a/samples/switchless/enclave/Makefile b/samples/switchless/enclave/Makefile new file mode 100644 index 0000000000..224bd8f713 --- /dev/null +++ b/samples/switchless/enclave/Makefile @@ -0,0 +1,40 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Detect C and C++ compiler options +# if not gcc, default to clang-7 + +COMPILER=$(notdir $(CC)) +ifeq ($(COMPILER), gcc) + USE_GCC = true +endif + +ifeq ($(USE_GCC),) + CC = clang-7 + COMPILER=clang +endif + +CFLAGS=$(shell pkg-config oeenclave-$(COMPILER) --cflags) +LDFLAGS=$(shell pkg-config oeenclave-$(COMPILER) --libs) + +all: + $(MAKE) build + $(MAKE) keys + $(MAKE) sign + +build: + @ echo "Compilers used: $(CC), $(CXX)" + oeedger8r ../switchless.edl --trusted + $(CC) -g -c $(CFLAGS) -DOE_API_VERSION=2 enc.c -o enc.o + $(CC) -g -c $(CFLAGS) -DOE_API_VERSION=2 switchless_t.c -o switchless_t.o + $(CC) -o switchlessenc switchless_t.o enc.o $(LDFLAGS) + +sign: + oesign sign -e switchlessenc -c switchless.conf -k private.pem + +clean: + rm -f enc.o switchlessenc switchlessenc.signed private.pem public.pem switchless_t.o switchless_t.h switchless_t.c switchless_args.h + +keys: + openssl genrsa -out private.pem -3 3072 + openssl rsa -in private.pem -pubout -out public.pem diff --git a/samples/switchless/enclave/enc.c b/samples/switchless/enclave/enc.c new file mode 100644 index 0000000000..ac5eb83e3c --- /dev/null +++ b/samples/switchless/enclave/enc.c @@ -0,0 +1,39 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include "switchless_t.h" + +void enclave_add_N_switchless(int* m, int n) +{ + // Call back into the host switchlessly + for (int i = 0; i < n; i++) + { + oe_result_t result = host_increment_switchless(m); + if (result != OE_OK) + { + fprintf(stderr, "host_increment_switchless(): result=%u", result); + } + } +} + +void enclave_add_N_regular(int* m, int n) +{ + // Call back into the host + for (int i = 0; i < n; i++) + { + oe_result_t result = host_increment_regular(m); + if (result != OE_OK) + { + fprintf(stderr, "host_increment_regular(): result=%u", result); + } + } +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 1024, /* HeapPageCount */ + 1024, /* StackPageCount */ + 2); /* TCSCount */ diff --git a/samples/switchless/enclave/switchless.conf b/samples/switchless/enclave/switchless.conf new file mode 100644 index 0000000000..ca997aa136 --- /dev/null +++ b/samples/switchless/enclave/switchless.conf @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Enclave settings: +Debug=1 +NumHeapPages=1024 +NumStackPages=1024 +NumTCS=1 +ProductID=1 +SecurityVersion=1 diff --git a/samples/switchless/host/CMakeLists.txt b/samples/switchless/host/CMakeLists.txt new file mode 100644 index 0000000000..d2586c85ca --- /dev/null +++ b/samples/switchless/host/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command(OUTPUT switchless_u.h switchless_u.c switchless_args.h + DEPENDS ${CMAKE_SOURCE_DIR}/switchless.edl + COMMAND openenclave::oeedger8r --untrusted ${CMAKE_SOURCE_DIR}/switchless.edl) + +add_executable(switchless_host host.c ${CMAKE_CURRENT_BINARY_DIR}/switchless_u.c) + +if(WIN32) + copy_oedebugrt_target(switchless_host_oedebugrt_target) + add_dependencies(switchless_host switchless_host_oedebugrt_target) +endif() + +target_include_directories(switchless_host PRIVATE + # Needed for the generated file switchless_u.h + ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(switchless_host openenclave::oehostapp) diff --git a/samples/switchless/host/Makefile b/samples/switchless/host/Makefile new file mode 100644 index 0000000000..e7e342fa74 --- /dev/null +++ b/samples/switchless/host/Makefile @@ -0,0 +1,28 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +# Detect C and C++ compiler options +# if not gcc, default to clang-7 + +COMPILER=$(notdir $(CC)) +ifeq ($(COMPILER), gcc) + USE_GCC = true +endif + +ifeq ($(USE_GCC),) + CC = clang-7 + COMPILER=clang +endif + +CFLAGS=$(shell pkg-config oehost-$(COMPILER) --cflags) +LDFLAGS=$(shell pkg-config oehost-$(COMPILER) --libs) + +build: + @ echo "Compilers used: $(CC), $(CXX)" + oeedger8r ../switchless.edl --untrusted + $(CC) -g -c $(CFLAGS) host.c + $(CC) -g -c $(CFLAGS) switchless_u.c + $(CC) -o switchlesshost switchless_u.o host.o $(LDFLAGS) + +clean: + rm -f switchlesshost host.o switchless_u.o switchless_u.c switchless_u.h switchless_args.h diff --git a/samples/switchless/host/host.c b/samples/switchless/host/host.c new file mode 100644 index 0000000000..fee3bc9a6f --- /dev/null +++ b/samples/switchless/host/host.c @@ -0,0 +1,151 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include "switchless_u.h" + +#if defined(__linux__) + +double get_relative_time_in_microseconds() +{ + struct timespec current_time; + clock_gettime(CLOCK_REALTIME, ¤t_time); + return (double)current_time.tv_sec * 1000000 + + (double)current_time.tv_nsec / 1000.0; +} + +#elif defined(_WIN32) + +#include + +static double frequency; +double get_relative_time_in_microseconds() +{ + double current_time; + QueryPerformanceCounter(¤t_time); + return current_time / frequency; +} + +#endif + +void host_increment_switchless(int* n) +{ + *n = *n + 1; +} + +void host_increment_regular(int* n) +{ + *n = *n + 1; +} + +static bool check_simulate_opt(int* argc, const char* argv[]) +{ + for (int i = 0; i < *argc; i++) + { + if (strcmp(argv[i], "--simulate") == 0) + { + fprintf(stderr, "Running in simulation mode\n"); + memmove(&argv[i], &argv[i + 1], (*argc - i) * sizeof(char*)); + (*argc)--; + return true; + } + } + return false; +} + +int main(int argc, const char* argv[]) +{ + oe_enclave_t* enclave = NULL; + oe_result_t result; + int ret = 1, m = 1000000, n = 1000000; + int oldm = m; + double switchless_microseconds = 0; + double start, end; + + if (argc != 2 && argc != 3) + { + fprintf(stderr, "Usage: %s ENCLAVE_PATH [--simulate]\n", argv[0]); + return 1; + } + +#if defined(_WIN32) + QueryPerformanceFrequency(&frequency); + frequency /= 1000000; // convert to microseconds +#endif + + uint32_t flags = OE_ENCLAVE_FLAG_DEBUG; + if (check_simulate_opt(&argc, argv)) + { + flags |= OE_ENCLAVE_FLAG_SIMULATE; + } + + // Enable switchless and configure host worker number + oe_enclave_setting_context_switchless_t switchless_setting = {1, 0}; + oe_enclave_setting_t settings[] = {{ + .setting_type = OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS, + .u.context_switchless_setting = &switchless_setting, + }}; + + if ((result = oe_create_switchless_enclave( + argv[1], + OE_ENCLAVE_TYPE_SGX, + flags, + settings, + OE_COUNTOF(settings), + &enclave)) != OE_OK) + fprintf(stderr, "oe_create_enclave(): result=%u", result); + + start = get_relative_time_in_microseconds(); + + // Call into the enclave + result = enclave_add_N_switchless(enclave, &m, n); + + end = get_relative_time_in_microseconds(); + + if (result != OE_OK) + { + fprintf(stderr, "enclave_add_N_switchless(): result=%u", result); + goto done; + } + + fprintf( + stderr, + "enclave_add_N_switchless(): %d + %d = %d. Time spent: " + "%d ms\n", + oldm, + n, + m, + (int)(end - start) / 1000); + + start = get_relative_time_in_microseconds(); + + // Call into the enclave + m = oldm; + result = enclave_add_N_regular(enclave, &m, n); + + end = get_relative_time_in_microseconds(); + + if (result != OE_OK) + { + fprintf(stderr, "enclave_add_N_regular(): result=%u", result); + goto done; + } + + fprintf( + stderr, + "enclave_add_N_regular(): %d + %d = %d. Time spent: " + "%d ms\n", + oldm, + n, + m, + (int)(end - start) / 1000); + +done: + ret = result != OE_OK ? 1 : 0; + oe_terminate_enclave(enclave); + + return ret; +} diff --git a/samples/switchless/switchless.edl b/samples/switchless/switchless.edl new file mode 100644 index 0000000000..928717a814 --- /dev/null +++ b/samples/switchless/switchless.edl @@ -0,0 +1,14 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + public void enclave_add_N_switchless([in, out] int* m, int n); + public void enclave_add_N_regular([in, out] int* m, int n); + }; + + untrusted { + void host_increment_switchless([in, out] int* m) transition_using_threads; + void host_increment_regular([in, out] int* m); + }; +}; diff --git a/samples/test-samples.cmake b/samples/test-samples.cmake index 5338bc4e7b..4cf2652eaf 100644 --- a/samples/test-samples.cmake +++ b/samples/test-samples.cmake @@ -1,13 +1,13 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # This script requires the variables SOURCE_DIR, BUILD_DIR, and # PREFIX_DIR to be defined: # -# cmake -DUSE_LIBSGX=ON -DSOURCE_DIR=~/openenclave -DBUILD_DIR=~/openenclave/build -DPREFIX_DIR=/opt/openenclave -P ~/openenclave/samples/test-samples.cmake +# cmake -DHAS_QUOTE_PROVIDER=ON -DSOURCE_DIR=~/openenclave -DBUILD_DIR=~/openenclave/build -DPREFIX_DIR=/opt/openenclave -P ~/openenclave/samples/test-samples.cmake -# These two samples can run in simulation, and therefore run in every configuration. -set(SAMPLES_LIST helloworld file-encryptor) +# These three samples can run in simulation, and therefore run in every configuration. +set(SAMPLES_LIST helloworld file-encryptor switchless) if ($ENV{OE_SIMULATION}) message(WARNING "Running only sample simulation tests due to OE_SIMULATION=$ENV{OE_SIMULATION}!") @@ -19,19 +19,25 @@ else () # This sample can run on SGX, both with and without FLC, meaning # they can run even if they weren't built against SGX, because in # that cause they directly interface with the AESM service. - list(APPEND SAMPLES_LIST data-sealing) + list(APPEND SAMPLES_LIST data-sealing local_attestation) # These tests can only run with SGX-FLC, meaning they were built # against SGX. - if (USE_LIBSGX) - list(APPEND SAMPLES_LIST local_attestation remote_attestation attested_tls) + if (HAS_QUOTE_PROVIDER) + list(APPEND SAMPLES_LIST remote_attestation) + list(APPEND SAMPLES_LIST attested_tls) endif () endif () -execute_process(COMMAND ${CMAKE_COMMAND} -E env DESTDIR=${BUILD_DIR}/install ${CMAKE_COMMAND} --build ${BUILD_DIR} --target install) - -# The prefix is appended to the value given to DESTDIR, e.g. build/install/opt/openenclave/... -set(INSTALL_DIR ${BUILD_DIR}/install${PREFIX_DIR}) +if (WIN32) + # On Windows, DESTDIR is not supported by cmake for the install function. Must use a relative path for -DCMAKE_INSTALL_PREFIX:PATH + set(INSTALL_DIR ${BUILD_DIR}/${PREFIX_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target install) +else () + # The prefix is appended to the value given to DESTDIR, e.g. build/install/opt/openenclave/... + set(INSTALL_DIR ${BUILD_DIR}/install/${PREFIX_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E env DESTDIR=${BUILD_DIR}/install ${CMAKE_COMMAND} --build ${BUILD_DIR} --target install) +endif () # A variable to know if all samples ran successfully set(ALL_TEST_RESULT 0) @@ -43,9 +49,15 @@ foreach (SAMPLE ${SAMPLES_LIST}) execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${SAMPLE_BUILD_DIR}) # Configure, build, and run the installed sample with CMake. - execute_process( - COMMAND ${CMAKE_COMMAND} -DCMAKE_PREFIX_PATH=${INSTALL_DIR} ${SAMPLE_SOURCE_DIR} - WORKING_DIRECTORY ${SAMPLE_BUILD_DIR}) + if (WIN32) + execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_PREFIX_PATH=${INSTALL_DIR}/lib/openenclave/cmake -G Ninja -DNUGET_PACKAGE_PATH=${NUGET_PACKAGE_PATH} -DHAS_QUOTE_PROVIDER=${HAS_QUOTE_PROVIDER} ${SAMPLE_SOURCE_DIR} + WORKING_DIRECTORY ${SAMPLE_BUILD_DIR}) + else () + execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_PREFIX_PATH=${INSTALL_DIR} ${SAMPLE_SOURCE_DIR} + WORKING_DIRECTORY ${SAMPLE_BUILD_DIR}) + endif () execute_process( COMMAND ${CMAKE_COMMAND} --build ${SOURCE_DIR}/${SAMPLE} @@ -64,45 +76,50 @@ foreach (SAMPLE ${SAMPLES_LIST}) message(STATUS "Samples test '${SAMPLE}' with CMake passed!") endif () - # Build with pkg-config - message(STATUS "Samples test '${SAMPLE}' with pkg-config running...") - execute_process( - COMMAND ${CMAKE_COMMAND} -E env PATH=${INSTALL_DIR}/bin:$ENV{PATH} PKG_CONFIG_PATH=${INSTALL_DIR}/share/pkgconfig/ make -C ${SAMPLE_SOURCE_DIR} clean build run - RESULT_VARIABLE TEST_RESULT) - if (TEST_RESULT) - message(WARNING "Samples test '${SAMPLE}' with pkg-config failed!") + if (UNIX) + # Build with pkg-config if not running on Windows. + message(STATUS "Samples test '${SAMPLE}' with pkg-config running...") + execute_process( + COMMAND ${CMAKE_COMMAND} -E env PATH=${INSTALL_DIR}/bin:$ENV{PATH} PKG_CONFIG_PATH=${INSTALL_DIR}/share/pkgconfig/ make -C ${SAMPLE_SOURCE_DIR} clean build run + RESULT_VARIABLE TEST_RESULT) + if (TEST_RESULT) + message(WARNING "Samples test '${SAMPLE}' with pkg-config failed!") + set(ALL_TEST_RESULT 1) + else () + message(STATUS "Samples test '${SAMPLE}' with pkg-config passed!") + endif () + endif () + endif () + + # Simulation mode is not supported on Windows currently. + if (UNIX) + # The file-encryptor and helloworld are special cases which also + # work under simulation, so we test that additional scenario here. + if (${SAMPLE} MATCHES "(file-encryptor|helloworld)") + # Build with the CMake package + message(STATUS "Samples test '${SAMPLE}' in simulation with CMake running...") + execute_process( + COMMAND ${CMAKE_COMMAND} --build ${SAMPLE_BUILD_DIR} --target simulate + RESULT_VARIABLE TEST_SIMULATE_RESULT) + if (TEST_SIMULATE_RESULT) + message(WARNING "Samples test '${SAMPLE}' in simulation with CMake failed!") set(ALL_TEST_RESULT 1) else () - message(STATUS "Samples test '${SAMPLE}' with pkg-config passed!") + message(STATUS "Samples test '${SAMPLE}' in simulation with CMake passed!") endif () - endif () - # The file-encryptor and helloworld are special cases which also - # work under simulation, so we test that additional scenario here. - if (${SAMPLE} MATCHES "(file-encryptor|helloworld)") - # Build with the CMake package - message(STATUS "Samples test '${SAMPLE}' in simulation with CMake running...") - execute_process( - COMMAND ${CMAKE_COMMAND} --build ${SAMPLE_BUILD_DIR} --target simulate - RESULT_VARIABLE TEST_SIMULATE_RESULT) - if (TEST_SIMULATE_RESULT) - message(WARNING "Samples test '${SAMPLE}' in simulation with CMake failed!") - set(ALL_TEST_RESULT 1) - else () - message(STATUS "Samples test '${SAMPLE}' in simulation with CMake passed!") - endif () - - # Build with pkg-config - message(STATUS "Samples test '${SAMPLE}' in simulation with pkg-config running...") - message(WARNING "PKG_CONFIG_PATH=${INSTALL_DIR}") - execute_process( - COMMAND ${CMAKE_COMMAND} -E env PATH=${INSTALL_DIR}/bin:$ENV{PATH} PKG_CONFIG_PATH=${INSTALL_DIR}/share/pkgconfig make -C ${SAMPLE_SOURCE_DIR} clean build simulate - RESULT_VARIABLE TEST_SIMULATE_RESULT) - if (TEST_SIMULATE_RESULT) - message(WARNING "Samples test '${SAMPLE}' in simulation with pkg-config failed!") - set(TEST_SIMULATE_RESULT 1) - else () - message(STATUS "Samples test '${SAMPLE}' in simulation with pkg-config passed!") + # Build with pkg-config + message(STATUS "Samples test '${SAMPLE}' in simulation with pkg-config running...") + message(WARNING "PKG_CONFIG_PATH=${INSTALL_DIR}") + execute_process( + COMMAND ${CMAKE_COMMAND} -E env PATH=${INSTALL_DIR}/bin:$ENV{PATH} PKG_CONFIG_PATH=${INSTALL_DIR}/share/pkgconfig make -C ${SAMPLE_SOURCE_DIR} clean build simulate + RESULT_VARIABLE TEST_SIMULATE_RESULT) + if (TEST_SIMULATE_RESULT) + message(WARNING "Samples test '${SAMPLE}' in simulation with pkg-config failed!") + set(TEST_SIMULATE_RESULT 1) + else () + message(STATUS "Samples test '${SAMPLE}' in simulation with pkg-config passed!") + endif () endif () endif () diff --git a/scripts/.check-license.ignore b/scripts/.check-license.ignore index 4edcbbb6a4..d3c87d2fef 100644 --- a/scripts/.check-license.ignore +++ b/scripts/.check-license.ignore @@ -4,8 +4,10 @@ .*\.der$ .*\.docx$ .*\.html$ +.*\.jpg$ .*\.json$ .*\.md$ +.*\.patch$ .*\.pdf$ .*\.pem$ .*\.png$ @@ -31,6 +33,7 @@ tests/mbed/tests\..*$ 3rdparty/optee/patches/.* 3rdparty/optee/optee_client/.* 3rdparty/optee/optee_os/.* +tools/oeedger8r/esy\.lock/.* tools/oeedger8r/intel/.* # Files @@ -42,6 +45,7 @@ tools/oeedger8r/intel/.* 3rdparty/musl/endian\.h\.suffix 3rdparty/optee/optee_client 3rdparty/optee/optee_os +docs/CODEOWNERS LICENSE THIRD_PARTY_NOTICES VERSION @@ -60,8 +64,9 @@ tests/ocall/debugging\.txt tests/print/printhost\.stderr tests/print/printhost\.stdout tests/str/test1\.txt -tools/oeedger8r/\.merlin -tools/oeedger8r/main\.ml +tools/oeedger8r/src/\.ocamlformat +tools/oeedger8r/src/\.ocamlformat-ignore +tools/oeedger8r/src/main\.ml tools/oesign/getopt\.h tools/oesign/getopt_long\.c tests/host_verify/data/.* diff --git a/scripts/README.md b/scripts/README.md index 38f057c38e..9b72a1d639 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -7,6 +7,9 @@ This directory contains the following scripts. and code linting have been met before changes should be merged - [check-license][] - Prints a list of sources missing the license header - [check-linters][] - Runs ShellCheck across scripts to lint them +- [commit-msg][] - A [Git pre-commit hook](https://git-scm.com/docs/githooks) + to ensure that commit messages contain a [DCO](https://developercertificate.org) + sign-off - [deploy-docs][] - Deploys HTML documentation to GitHub pages - [format-code][] - Formats Open Enclave C/C++ code using `clang-format` - [pre-commit][] - A [Git pre-commit hook](https://git-scm.com/docs/githooks) diff --git a/scripts/VirtualMachineSgxSettings.psd1 b/scripts/VirtualMachineSgxSettings.psd1 index bb8e1f3886..2500c59a1c 100644 --- a/scripts/VirtualMachineSgxSettings.psd1 +++ b/scripts/VirtualMachineSgxSettings.psd1 @@ -1,15 +1,15 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. @{ GUID = "{5c36f9d9-e64f-4dbb-ae38-6ad1669954c4}" - Author = "Microsoft Corporation" - CompanyName = "Microsoft Corporation" - Copyright = "© Microsoft Corporation. All rights reserved." + Author = "Open Enclave SDK contributors" + CompanyName = "Confidential Computing Consortium" + Copyright = "© Open Enclave SDK contributors" RootModule = "VirtualMachineSgxSettings.psm1" ModuleVersion = "1.0.0.0" PowerShellVersion = "3.0" ClrVersion = "4.0" FunctionsToExport = "Get-VMSgx", "Set-VMSgx" - HelpInfoUri = "https://github.com/Microsoft/openenclave" + HelpInfoUri = "https://github.com/openenclave/openenclave" } \ No newline at end of file diff --git a/scripts/VirtualMachineSgxSettings.psm1 b/scripts/VirtualMachineSgxSettings.psm1 index 2cf7ae7c4e..353311886a 100644 --- a/scripts/VirtualMachineSgxSettings.psm1 +++ b/scripts/VirtualMachineSgxSettings.psm1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. Import-Module Hyper-V diff --git a/scripts/ansible/README.md b/scripts/ansible/README.md index bf9456d3af..64200a7dcd 100644 --- a/scripts/ansible/README.md +++ b/scripts/ansible/README.md @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. This directory contains the Ansible work used to automate all the required tasks for setting up new Open Enclave environments, and new Jenkins agents for the CI / CD system. diff --git a/scripts/ansible/ansible.cfg b/scripts/ansible/ansible.cfg index 3380d6c6a3..acb77002db 100644 --- a/scripts/ansible/ansible.cfg +++ b/scripts/ansible/ansible.cfg @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. [defaults] diff --git a/scripts/ansible/install-ansible.sh b/scripts/ansible/install-ansible.sh index d637c41100..87241a9f67 100755 --- a/scripts/ansible/install-ansible.sh +++ b/scripts/ansible/install-ansible.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/scripts/ansible/inventory/group_vars/all b/scripts/ansible/inventory/group_vars/all index 2d9ccfda1d..973cb49b19 100644 --- a/scripts/ansible/inventory/group_vars/all +++ b/scripts/ansible/inventory/group_vars/all @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Global configs for all the Ansible machines diff --git a/scripts/ansible/inventory/group_vars/linux-agents b/scripts/ansible/inventory/group_vars/linux-agents index 4aeb81f870..a56b3b12b5 100644 --- a/scripts/ansible/inventory/group_vars/linux-agents +++ b/scripts/ansible/inventory/group_vars/linux-agents @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ansible_ssh_user: azureuser diff --git a/scripts/ansible/inventory/group_vars/windows-agents b/scripts/ansible/inventory/group_vars/windows-agents index 12fe513fb8..165e01af7b 100644 --- a/scripts/ansible/inventory/group_vars/windows-agents +++ b/scripts/ansible/inventory/group_vars/windows-agents @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Username and password of the nodes (if the nodes have different passwords, please look into host_vars folder) diff --git a/scripts/ansible/inventory/hosts b/scripts/ansible/inventory/hosts index 4509d6efec..817d28d3b1 100644 --- a/scripts/ansible/inventory/hosts +++ b/scripts/ansible/inventory/hosts @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. [linux-agents] diff --git a/scripts/ansible/jenkins-agents-register.yml b/scripts/ansible/jenkins-agents-register.yml index 8d4799f056..1b221d72b1 100644 --- a/scripts/ansible/jenkins-agents-register.yml +++ b/scripts/ansible/jenkins-agents-register.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/jenkins-setup.yml b/scripts/ansible/jenkins-setup.yml index 89812c9250..6610c06006 100644 --- a/scripts/ansible/jenkins-setup.yml +++ b/scripts/ansible/jenkins-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-contributors-acc-setup-no-driver.yml b/scripts/ansible/oe-contributors-acc-setup-no-driver.yml index fe469b66ab..a8b01fe641 100644 --- a/scripts/ansible/oe-contributors-acc-setup-no-driver.yml +++ b/scripts/ansible/oe-contributors-acc-setup-no-driver.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-contributors-acc-setup.yml b/scripts/ansible/oe-contributors-acc-setup.yml index d6cedbbd0d..606c4ebd45 100644 --- a/scripts/ansible/oe-contributors-acc-setup.yml +++ b/scripts/ansible/oe-contributors-acc-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-contributors-setup-cross-arm.yml b/scripts/ansible/oe-contributors-setup-cross-arm.yml new file mode 100644 index 0000000000..c7c0bd7d75 --- /dev/null +++ b/scripts/ansible/oe-contributors-setup-cross-arm.yml @@ -0,0 +1,11 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +--- +- hosts: localhost + any_errors_fatal: true + become: yes + tasks: + - import_role: + name: linux/openenclave + tasks_from: environment-setup-cross-arm.yml diff --git a/scripts/ansible/oe-contributors-setup-sgx1.yml b/scripts/ansible/oe-contributors-setup-sgx1.yml new file mode 100644 index 0000000000..f2758b7e8d --- /dev/null +++ b/scripts/ansible/oe-contributors-setup-sgx1.yml @@ -0,0 +1,21 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +--- +- hosts: localhost + any_errors_fatal: true + become: yes + tasks: + - import_role: + name: linux/openenclave + tasks_from: environment-setup.yml + + - import_role: + name: linux/intel + tasks_from: sgx-driver.yml + + - import_role: + name: linux/intel + tasks_from: sgx-packages.yml + vars: + flc_enabled: false diff --git a/scripts/ansible/oe-contributors-setup.yml b/scripts/ansible/oe-contributors-setup.yml index 59a65e7989..f4e402851d 100644 --- a/scripts/ansible/oe-contributors-setup.yml +++ b/scripts/ansible/oe-contributors-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-linux-acc-setup-no-driver.yml b/scripts/ansible/oe-linux-acc-setup-no-driver.yml index 13a9d684a6..80ccc464a4 100644 --- a/scripts/ansible/oe-linux-acc-setup-no-driver.yml +++ b/scripts/ansible/oe-linux-acc-setup-no-driver.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-linux-acc-setup.yml b/scripts/ansible/oe-linux-acc-setup.yml index 8cef5ff7f3..f16231dd03 100644 --- a/scripts/ansible/oe-linux-acc-setup.yml +++ b/scripts/ansible/oe-linux-acc-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-linux-esy-setup.yml b/scripts/ansible/oe-linux-esy-setup.yml new file mode 100644 index 0000000000..e69e2d0cd5 --- /dev/null +++ b/scripts/ansible/oe-linux-esy-setup.yml @@ -0,0 +1,13 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +--- +- hosts: localhost + any_errors_fatal: true + gather_facts: true + become: yes + tasks: + - import_role: + name: linux/openenclave + tasks_from: esy-setup.yml + vars_from: ubuntu.yml diff --git a/scripts/ansible/oe-vanilla-prelibsgx-setup.yml b/scripts/ansible/oe-vanilla-prelibsgx-setup.yml index cd7e4caa07..54d9445379 100644 --- a/scripts/ansible/oe-vanilla-prelibsgx-setup.yml +++ b/scripts/ansible/oe-vanilla-prelibsgx-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/oe-windows-acc-setup.yml b/scripts/ansible/oe-windows-acc-setup.yml index 9a7bcae44d..6ddbff4f44 100644 --- a/scripts/ansible/oe-windows-acc-setup.yml +++ b/scripts/ansible/oe-windows-acc-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -8,20 +8,18 @@ tasks: - name: OE setup | Set installer URLs from the OE storage account set_fact: - intel_psw_2_2_url: "https://oejenkins.blob.core.windows.net/oejenkins/intel_sgx_win_2.2.100.47975_PV.zip" - intel_psw_2_2_hash: "EB479D1E029D51E48E534C284FCF5CCA3A937DA43052DCB2F4C71E5F354CA623" - intel_psw_2_4_url: "https://oejenkins.blob.core.windows.net/oejenkins/Intel%20SGX%20PSW%20for%20Windows%20v2.4.100.51291.exe" - intel_psw_2_4_hash: "79AE32E984B5511CE4BF7568403333F837FBCE7E8D5730271C5D68F55BBF251D" - intel_dcap_url: "https://oejenkins.blob.core.windows.net/oejenkins/Intel%20SGX%20DCAP%20for%20Windows%20v1.2.100.49925.exe" - intel_dcap_hash: "F31E4451CA32E19CA3DCB0AFC49AFE9F4963C47BF62AAF24A8AE436BDA14FD8B" + intel_psw_url: "https://oejenkins.blob.core.windows.net/oejenkins/Intel%20SGX%20PSW%20for%20Windows%20v2.5.101.3.exe" + intel_psw_hash: "D904964872A49426D3BFD0249752403DC746611F92F4FF6B95F64F336744323C" + intel_dcap_url: "https://oejenkins.blob.core.windows.net/oejenkins/Intel%20SGX%20DCAP%20for%20Windows%20v1.3.101.3.exe" + intel_dcap_hash: "27C1CC7F8434A704853FC3BFE15723F6F507CB09BF79B248A09A9ED0EED48A01" git_url: "https://oejenkins.blob.core.windows.net/oejenkins/Git-2.19.1-64-bit.exe" git_hash: "5E11205840937DD4DFA4A2A7943D08DA7443FAA41D92CCC5DAFBB4F82E724793" seven_zip_url: "https://oejenkins.blob.core.windows.net/oejenkins/7z1806-x64.msi" seven_zip_hash: "F00E1588ED54DDF633D8652EB89D0A8F95BD80CCCFC3EED362D81927BEC05AA5" vs_buildtools: "https://oejenkins.blob.core.windows.net/oejenkins/vs_buildtools_2017.exe" vs_buildtools_hash: "6F49872B04A0EAEDF5ED96AB25F7697062D81A419D45D9970E41784F31165BF2" - ocaml_url: "https://oejenkins.blob.core.windows.net/oejenkins/ocpwin64-20160113-4.02.1+ocp1-mingw64.zip" - ocaml_hash: "369F900F7CDA543ABF674520ED6004CC75008E10BEED0D34845E8A42866D0F3A" + node_url: "https://nodejs.org/dist/v10.16.3/node-v10.16.3-x64.msi" + node_hash: "f68b75eea46232adb8fd38126c977dc244166d29e7c6cd2df930b460c38590a9" clang7_url: "https://oejenkins.blob.core.windows.net/oejenkins/LLVM-7.0.1-win64.exe" clang7_hash: "672E4C420D6543A8A9F8EC5F1E5F283D88AC2155EF4C57232A399160A02BFF57" shellcheck_url: "https://oejenkins.blob.core.windows.net/oejenkins/shellcheck-v0.7.0.zip" @@ -35,11 +33,11 @@ - name: OE setup | Run the install-windows-prereqs.ps1 script (this may take a while) script: ../install-windows-prereqs.ps1 - -InstallPath "C:\openenclave" - -LaunchConfiguration "{{ SGX1FLC if dcap_testing_node is defined and dcap_testing_node == true else SGX1 }}" - -DCAPClientType "{{ Azure }}" - -IntelPSWURL "{{ intel_psw_2_4_url if dcap_testing_node is defined and dcap_testing_node == true else intel_psw_2_2_url }}" - -IntelPSWHash "{{ intel_psw_2_4_hash if dcap_testing_node is defined and dcap_testing_node == true else intel_psw_2_2_hash }}" + -InstallPath "C:\oe_prereqs" + -LaunchConfiguration "{{ 'SGX1FLC' if dcap_testing_node is defined and dcap_testing_node == 'true' else 'SGX1' }}" + -DCAPClientType "{{ 'Azure' }}" + -IntelPSWURL "{{ intel_psw_url }}" + -IntelPSWHash "{{ intel_psw_hash }}" -IntelDCAPURL "{{ intel_dcap_url }}" -IntelDCAPHash "{{ intel_dcap_hash }}" -GitURL "{{ git_url }}" @@ -48,8 +46,8 @@ -SevenZipHash "{{ seven_zip_hash }}" -VSBuildToolsURL "{{ vs_buildtools }}" -VSBuildToolsHash "{{ vs_buildtools_hash }}" - -OCamlURL "{{ ocaml_url }}" - -OCamlHash "{{ ocaml_hash }}" + -NodeURL "{{ node_url }}" + -NodeHash "{{ node_hash }}" -Clang7URL "{{ clang7_url }}" -Clang7Hash "{{ clang7_hash }}" -ShellCheckURL "{{ shellcheck_url }}" @@ -63,6 +61,7 @@ - name: OE setup | Reboot the node win_reboot: + when: ansible_user != "packer" - import_role: name: windows/openenclave diff --git a/scripts/ansible/remove-ansible.sh b/scripts/ansible/remove-ansible.sh index 0a8d84b663..13e941b5e7 100755 --- a/scripts/ansible/remove-ansible.sh +++ b/scripts/ansible/remove-ansible.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/scripts/ansible/requirements.txt b/scripts/ansible/requirements.txt index 71464aed68..2383c81dac 100644 --- a/scripts/ansible/requirements.txt +++ b/scripts/ansible/requirements.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. -ansible==2.8.0 +ansible==2.8.2 pywinrm==0.2.1 diff --git a/scripts/ansible/roles/common/jenkins/tasks/agent-provision.yml b/scripts/ansible/roles/common/jenkins/tasks/agent-provision.yml index 8e36c077f9..036772e6a3 100644 --- a/scripts/ansible/roles/common/jenkins/tasks/agent-provision.yml +++ b/scripts/ansible/roles/common/jenkins/tasks/agent-provision.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/az-dcap-client/tasks/stable-install.yml b/scripts/ansible/roles/linux/az-dcap-client/tasks/stable-install.yml index cc03287a44..761e928bd4 100644 --- a/scripts/ansible/roles/linux/az-dcap-client/tasks/stable-install.yml +++ b/scripts/ansible/roles/linux/az-dcap-client/tasks/stable-install.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -12,5 +12,5 @@ - name: Install the official Azure-DCAP-Client APT package apt: name: az-dcap-client - state: present + state: latest update_cache: yes diff --git a/scripts/ansible/roles/linux/az-dcap-client/tasks/validation.yml b/scripts/ansible/roles/linux/az-dcap-client/tasks/validation.yml index 2284733cba..1c4d96861c 100644 --- a/scripts/ansible/roles/linux/az-dcap-client/tasks/validation.yml +++ b/scripts/ansible/roles/linux/az-dcap-client/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/az-dcap-client/vars/ubuntu.yml b/scripts/ansible/roles/linux/az-dcap-client/vars/ubuntu.yml index acee0b1de4..6d72ed0a84 100644 --- a/scripts/ansible/roles/linux/az-dcap-client/vars/ubuntu.yml +++ b/scripts/ansible/roles/linux/az-dcap-client/vars/ubuntu.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/common/tasks/apt-repo.yml b/scripts/ansible/roles/linux/common/tasks/apt-repo.yml index 21193b529f..5a448c3f9b 100644 --- a/scripts/ansible/roles/linux/common/tasks/apt-repo.yml +++ b/scripts/ansible/roles/linux/common/tasks/apt-repo.yml @@ -1,18 +1,18 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- - name: Install apt-transport-https APT package apt: name: apt-transport-https - state: present + state: latest -- name: Add Microsoft APT repository key +- name: Add APT repository key apt_key: url: "{{ apt_key_url }}" state: present -- name: Add Microsoft APT repository +- name: Add APT repository apt_repository: repo: "{{ apt_repository }}" state: present diff --git a/scripts/ansible/roles/linux/docker/tasks/ci-setup.yml b/scripts/ansible/roles/linux/docker/tasks/ci-setup.yml index aadacc1de6..f04e9114df 100644 --- a/scripts/ansible/roles/linux/docker/tasks/ci-setup.yml +++ b/scripts/ansible/roles/linux/docker/tasks/ci-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -16,7 +16,7 @@ - name: Install Docker prerequisite packages apt: name: "{{ ci_apt_packages }}" - state: present + state: latest update_cache: yes install_recommends: no diff --git a/scripts/ansible/roles/linux/docker/tasks/stable-install.yml b/scripts/ansible/roles/linux/docker/tasks/stable-install.yml index 9e5012875a..daeb986996 100644 --- a/scripts/ansible/roles/linux/docker/tasks/stable-install.yml +++ b/scripts/ansible/roles/linux/docker/tasks/stable-install.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -32,7 +32,7 @@ - name: Docker | Install Docker-CE apt: name: "{{ apt_packages }}" - state: present + state: latest update_cache: yes retries: 10 delay: 10 diff --git a/scripts/ansible/roles/linux/docker/tasks/validation.yml b/scripts/ansible/roles/linux/docker/tasks/validation.yml index de3c816731..ca355b88d1 100644 --- a/scripts/ansible/roles/linux/docker/tasks/validation.yml +++ b/scripts/ansible/roles/linux/docker/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/docker/vars/bionic.yml b/scripts/ansible/roles/linux/docker/vars/bionic.yml index 53b8bea693..2d3f45aa0d 100644 --- a/scripts/ansible/roles/linux/docker/vars/bionic.yml +++ b/scripts/ansible/roles/linux/docker/vars/bionic.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/docker/vars/ubuntu.yml b/scripts/ansible/roles/linux/docker/vars/ubuntu.yml index 050225db24..6f6e693baa 100644 --- a/scripts/ansible/roles/linux/docker/vars/ubuntu.yml +++ b/scripts/ansible/roles/linux/docker/vars/ubuntu.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/docker/vars/xenial.yml b/scripts/ansible/roles/linux/docker/vars/xenial.yml index c2cd43a020..a9cf45fc95 100644 --- a/scripts/ansible/roles/linux/docker/vars/xenial.yml +++ b/scripts/ansible/roles/linux/docker/vars/xenial.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/intel/defaults/main.yml b/scripts/ansible/roles/linux/intel/defaults/main.yml new file mode 100644 index 0000000000..ed63f9e87d --- /dev/null +++ b/scripts/ansible/roles/linux/intel/defaults/main.yml @@ -0,0 +1,5 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +--- +flc_enabled: true diff --git a/scripts/ansible/roles/linux/intel/tasks/driver-validation.yml b/scripts/ansible/roles/linux/intel/tasks/driver-validation.yml index 120a0db72c..f34148edf5 100644 --- a/scripts/ansible/roles/linux/intel/tasks/driver-validation.yml +++ b/scripts/ansible/roles/linux/intel/tasks/driver-validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/intel/tasks/packages-validation.yml b/scripts/ansible/roles/linux/intel/tasks/packages-validation.yml index 7a2a85afb5..e91ca0d53a 100644 --- a/scripts/ansible/roles/linux/intel/tasks/packages-validation.yml +++ b/scripts/ansible/roles/linux/intel/tasks/packages-validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/intel/tasks/sgx-driver.yml b/scripts/ansible/roles/linux/intel/tasks/sgx-driver.yml index 0396b060d9..2edf77021c 100644 --- a/scripts/ansible/roles/linux/intel/tasks/sgx-driver.yml +++ b/scripts/ansible/roles/linux/intel/tasks/sgx-driver.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -14,7 +14,7 @@ apt: name: - "dkms" - state: present + state: latest update_cache: yes install_recommends: no @@ -29,18 +29,28 @@ - name: Download Intel SGX DCAP Driver get_url: - url: "{{ intel_sgx_driver_url }}" - dest: /tmp/sgx_linux_x64_driver_dcap.bin + url: "{{intel_sgx_w_flc_driver_url}}" + dest: /tmp/sgx_linux_x64_driver.bin mode: 0755 timeout: 120 retries: 3 + when: flc_enabled|bool + +- name: Download Intel SGX1 Driver + get_url: + url: "{{intel_sgx1_driver_url}}" + dest: /tmp/sgx_linux_x64_driver.bin + mode: 0755 + timeout: 120 + retries: 3 + when: not flc_enabled|bool - name: Install the Intel SGX DCAP Driver - command: /tmp/sgx_linux_x64_driver_dcap.bin + command: /tmp/sgx_linux_x64_driver.bin - name: Remove the Intel SGX DCAP Driver installer file: - path: /tmp/sgx_linux_x64_driver_dcap.bin + path: /tmp/sgx_linux_x64_driver.bin state: absent - name: Ensure aesmd service running diff --git a/scripts/ansible/roles/linux/intel/tasks/sgx-packages.yml b/scripts/ansible/roles/linux/intel/tasks/sgx-packages.yml index c4968e4586..7f59dfe163 100644 --- a/scripts/ansible/roles/linux/intel/tasks/sgx-packages.yml +++ b/scripts/ansible/roles/linux/intel/tasks/sgx-packages.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -23,13 +23,21 @@ - name: Install the Intel libsgx package dependencies apt: name: "{{ intel_sgx_package_dependencies }}" - state: present + state: latest update_cache: yes install_recommends: no - name: Install the Intel libsgx packages apt: name: "{{ intel_sgx_packages }}" - state: present + state: latest update_cache: yes install_recommends: no + +- name: Install the Intel DCAP packages + apt: + name: "{{ intel_dcap_packages }}" + state: latest + update_cache: yes + install_recommends: no + when: flc_enabled|bool diff --git a/scripts/ansible/roles/linux/intel/vars/bionic.yml b/scripts/ansible/roles/linux/intel/vars/bionic.yml index f55469e7a2..de4b425227 100644 --- a/scripts/ansible/roles/linux/intel/vars/bionic.yml +++ b/scripts/ansible/roles/linux/intel/vars/bionic.yml @@ -1,7 +1,8 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- -intel_sgx_driver_url: "https://download.01.org/intel-sgx/dcap-1.2/linux/dcap_installers/ubuntuServer18.04/sgx_linux_x64_driver_1.12_c110012.bin" +intel_sgx_w_flc_driver_url: "https://download.01.org/intel-sgx/sgx-dcap/1.3.1/linux/distro/ubuntuServer18.04/sgx_linux_x64_driver_1.20.bin" +intel_sgx1_driver_url: "https://download.01.org/intel-sgx/sgx-linux/2.7/distro/ubuntu18.04-server/sgx_linux_x64_driver_2.6.0_4f5bb63.bin" intel_sgx_package_dependencies: - "libprotobuf10" diff --git a/scripts/ansible/roles/linux/intel/vars/ubuntu.yml b/scripts/ansible/roles/linux/intel/vars/ubuntu.yml index 69e86eccf2..a5bbfb1098 100644 --- a/scripts/ansible/roles/linux/intel/vars/ubuntu.yml +++ b/scripts/ansible/roles/linux/intel/vars/ubuntu.yml @@ -1,10 +1,12 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- intel_sgx_packages: - "libsgx-enclave-common" - "libsgx-enclave-common-dev" + +intel_dcap_packages: - "libsgx-dcap-ql" - "libsgx-dcap-ql-dev" diff --git a/scripts/ansible/roles/linux/intel/vars/xenial.yml b/scripts/ansible/roles/linux/intel/vars/xenial.yml index 20f07207e2..399b79edda 100644 --- a/scripts/ansible/roles/linux/intel/vars/xenial.yml +++ b/scripts/ansible/roles/linux/intel/vars/xenial.yml @@ -1,7 +1,8 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- -intel_sgx_driver_url: "https://download.01.org/intel-sgx/dcap-1.2/linux/dcap_installers/ubuntuServer16.04/sgx_linux_x64_driver_1.12_c110012.bin" +intel_sgx_w_flc_driver_url: "https://download.01.org/intel-sgx/sgx-dcap/1.3.1/linux/distro/ubuntuServer16.04/sgx_linux_x64_driver_1.20.bin" +intel_sgx1_driver_url: "https://download.01.org/intel-sgx/sgx-linux/2.7/distro/ubuntu16.04-server/sgx_linux_x64_driver_2.6.0_4f5bb63.bin" intel_sgx_package_dependencies: - "libprotobuf9v5" diff --git a/scripts/ansible/roles/linux/jenkins/tasks/slave-setup.yml b/scripts/ansible/roles/linux/jenkins/tasks/slave-setup.yml index e3fc3387e7..4e49b732ce 100644 --- a/scripts/ansible/roles/linux/jenkins/tasks/slave-setup.yml +++ b/scripts/ansible/roles/linux/jenkins/tasks/slave-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -21,7 +21,7 @@ - name: Jenkins | Install Java JRE needed by Jenkins apt: name: openjdk-8-jre - state: present + state: latest update_cache: yes retries: 10 delay: 10 diff --git a/scripts/ansible/roles/linux/jenkins/tasks/validation.yml b/scripts/ansible/roles/linux/jenkins/tasks/validation.yml index 14507fb0f5..ee684d28ae 100644 --- a/scripts/ansible/roles/linux/jenkins/tasks/validation.yml +++ b/scripts/ansible/roles/linux/jenkins/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.default.j2 b/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.default.j2 index 89364ea8d0..4b88363cdb 100644 --- a/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.default.j2 +++ b/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.default.j2 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. JENKINS_RUN=/var/run/jenkins diff --git a/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.service.j2 b/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.service.j2 index bb649bb4b3..e08e6929f1 100644 --- a/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.service.j2 +++ b/scripts/ansible/roles/linux/jenkins/templates/jenkins-slave.service.j2 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. [Unit] diff --git a/scripts/ansible/roles/linux/jenkins/vars/ubuntu.yml b/scripts/ansible/roles/linux/jenkins/vars/ubuntu.yml index 722b10f372..8ba4c57643 100644 --- a/scripts/ansible/roles/linux/jenkins/vars/ubuntu.yml +++ b/scripts/ansible/roles/linux/jenkins/vars/ubuntu.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/linux/openenclave/tasks/environment-setup-cross-arm.yml b/scripts/ansible/roles/linux/openenclave/tasks/environment-setup-cross-arm.yml index e70771575e..a7a368af06 100644 --- a/scripts/ansible/roles/linux/openenclave/tasks/environment-setup-cross-arm.yml +++ b/scripts/ansible/roles/linux/openenclave/tasks/environment-setup-cross-arm.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -29,6 +29,6 @@ - name: Install the additional Open Enclave prerequisites APT packages for ARM development apt: name: "{{ apt_arm_packages }}" - state: present + state: latest update_cache: yes install_recommends: no diff --git a/scripts/ansible/roles/linux/openenclave/tasks/environment-setup.yml b/scripts/ansible/roles/linux/openenclave/tasks/environment-setup.yml index 26d9f75da7..a3825df30b 100644 --- a/scripts/ansible/roles/linux/openenclave/tasks/environment-setup.yml +++ b/scripts/ansible/roles/linux/openenclave/tasks/environment-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -26,39 +26,12 @@ - name: Install all the Open Enclave prerequisites APT packages for development apt: name: "{{ apt_packages }}" - state: present + state: latest update_cache: yes install_recommends: no -- name: Download the OCaml deb packages - get_url: - url: "{{ item.value.url }}" - dest: "{{ item.value.local_path }}" - timeout: 10 - retries: 5 - with_dict: "{{ ocaml_packages }}" - -- name: Install the OCaml deb packages - shell: | - set -o errexit - dpkg --install {{ ocaml_packages.ocaml_base_nox.local_path }} - dpkg --install {{ ocaml_packages.ocaml_base.local_path }} - dpkg --install --force-depends {{ ocaml_packages.ocaml_compiler_libs.local_path }} - dpkg --install {{ ocaml_packages.ocaml_interp.local_path }} - dpkg --install {{ ocaml_packages.ocaml_nox.local_path }} - dpkg --install {{ ocaml_packages.ocaml.local_path }} - args: - executable: /bin/bash - -- name: Clean OCaml downloaded deb packages - file: - state: absent - path: "{{ item.value.local_path }}" - with_dict: "{{ ocaml_packages }}" - -- import_role: - name: linux/openenclave - tasks_from: opam-setup.yml +- name: Install esy + include_tasks: esy-setup.yml - name: Install CMake 3.13.1 unarchive: diff --git a/scripts/ansible/roles/linux/openenclave/tasks/esy-setup.yml b/scripts/ansible/roles/linux/openenclave/tasks/esy-setup.yml new file mode 100644 index 0000000000..2573e81def --- /dev/null +++ b/scripts/ansible/roles/linux/openenclave/tasks/esy-setup.yml @@ -0,0 +1,98 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. +# +# See https://github.com/esy/esy/pull/957, specifically: +# https://github.com/esy/esy/blob/15f593510ea078b4b392b931c9572bc07a306119/scripts/install-esy.sh + +--- +- name: Prepare esy installation + file: + path: "{{ item }}" + state: directory + with_items: + - "/tmp/esy-release" + - "/tmp/esy-solve-cudf-release" + - "{{ esy_prefix }}/bin" + - "{{ esy_prefix }}/lib/node_modules/esy-solve-cudf/" + +- name: Download esy + get_url: + url: "https://registry.npmjs.org/esy/-/esy-{{ esy_target_version }}.tgz" + dest: "/tmp/esy-release/esy-{{ esy_target_version }}.tgz" + checksum: "sha256:f2cec5e6556172141bb399d1dcef7db4b9d881b0bed9c9749c0eebd95584b739" + timeout: 120 + retries: 3 + +- name: Download esy_solve_cudf + get_url: + url: "https://registry.npmjs.org/esy-solve-cudf/-/esy-solve-cudf-0.1.10.tgz" + dest: "/tmp/esy-solve-cudf-release/esy-solve-cudf-0.1.10.tgz" + checksum: "sha256:3cfb233e5536fe555ff1318bcff241481c8dcbe1edc30b5f97e2366134d3f234" + timeout: 120 + retries: 3 + +- name: Unarchive esy + unarchive: + src: "/tmp/esy-release/esy-{{ esy_target_version }}.tgz" + dest: "/tmp/esy-release/" + remote_src: yes + +- name: Unarchive esy_solve_cudf + unarchive: + src: "/tmp/esy-solve-cudf-release/esy-solve-cudf-0.1.10.tgz" + dest: "/tmp/esy-solve-cudf-release/" + remote_src: yes + +- name: Copy esy package.json + copy: + src: "/tmp/esy-release/package/package.json" + dest: "{{ esy_prefix }}/" + remote_src: yes + +- name: Copy esy esyInstallRelease.js + copy: + src: "/tmp/esy-release/package/platform-linux/_build/default/bin/esyInstallRelease.js" + dest: "{{ esy_prefix }}/bin/" + remote_src: yes + +- name: Copy esy default + copy: + src: "/tmp/esy-release/package/platform-linux/_build/default" + dest: "{{ esy_prefix }}/lib/" + remote_src: yes + +- name: Copy esy_solve_cudfy package.json + copy: + src: "/tmp/esy-solve-cudf-release/package/package.json" + dest: "{{ esy_prefix }}/lib/node_modules/esy-solve-cudf/" + remote_src: yes + +- name: Copy esy_solve_cudf exe + copy: + src: "/tmp/esy-solve-cudf-release/package/platform-linux/esySolveCudfCommand.exe" + dest: "{{ esy_prefix }}/lib/node_modules/esy-solve-cudf/" + remote_src: yes + +- name: Apply esy permissions + file: + mode: 0555 + path: "{{ item }}" + with_items: + - "{{ esy_prefix }}/lib/default/bin/esy.exe" + - "{{ esy_prefix }}/lib/default/esy-build-package/bin/esyBuildPackageCommand.exe" + - "{{ esy_prefix }}/lib/default/esy-build-package/bin/esyRewritePrefixCommand.exe" + +- name: Create esy symbolic links + file: + src: "{{ esy_prefix }}/lib/default/bin/esy.exe" + dest: "/usr/local/bin/esy" + force: yes + state: link + +- name: Cleanup esy installation + file: + path: "/tmp/{{ item }}" + state: absent + with_items: + - esy-release + - esy-solve-cudf-release diff --git a/scripts/ansible/roles/linux/openenclave/tasks/opam-setup.yml b/scripts/ansible/roles/linux/openenclave/tasks/opam-setup.yml deleted file mode 100644 index 33bff9bd55..0000000000 --- a/scripts/ansible/roles/linux/openenclave/tasks/opam-setup.yml +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - ---- -- name: Gather Ansible facts - setup: - -- name: Include distribution vars - include_vars: - file: "{{ ansible_distribution | lower }}.yml" - -- name: Add extra bubblewrap APT repository for Ubuntu Xenial - block: - - apt_key: - keyserver: keyserver.ubuntu.com - id: 6125E2A8C77F2818FB7BD15B93C4A3FD7BB9C367 - - - apt_repository: - repo: deb http://ppa.launchpad.net/ansible/bubblewrap/ubuntu xenial main - state: present - update_cache: yes - when: ansible_distribution_release == "xenial" - -- name: Install OPAM dependencies - apt: - name: - - "unzip" - - "bubblewrap" - state: present - update_cache: yes - -- name: Download OPAM bin - get_url: - url: "{{ opam_bin_url }}" - dest: /usr/local/bin/opam - mode: "u=rwx,g=rx,o=rx" - timeout: 10 - retries: 5 - -- name: Init OPAM - shell: | - if [[ -f /.dockerenv ]]; then - # Disable sandboxing inside Docker environment, otherwise opam will - # error out when installing ocamlformat package. - DISABLE_SANDBOXING="--disable-sandboxing" - fi - opam init --no-setup --root={{ opam_root }} $DISABLE_SANDBOXING - args: - executable: /bin/bash - retries: 10 - delay: 5 - register: result - until: result.rc == 0 - -- name: Create OPAM profile file with the environment variables - blockinfile: - dest: /etc/profile.d/opam-env.sh - create: yes - block: | - export PATH="{{ opam_root }}/default/bin:{{ ansible_env.PATH }}" - export OPAMROOT="{{ opam_root }}" - export OPAM_SWITCH_PREFIX="{{ opam_root }}/default" - export CAML_LD_LIBRARY_PATH="{{ opam_root }}/default/lib/stublibs" - export OCAML_TOPLEVEL_PATH="{{ opam_root }}/default/lib/toplevel" - export MANPATH="{{ opam_root }}/default/man" - -- name: Install ocamlformat via OPAM - shell: "source /etc/profile && opam install ocamlformat -y" - args: - executable: /bin/bash - retries: 10 - delay: 5 - register: result - until: result.rc == 0 - -- name: Create symbolic link for ocamlformat into /usr/local/bin - file: - src: "{{ opam_root }}/default/bin/ocamlformat" - dest: "/usr/local/bin/ocamlformat" - force: yes - state: link diff --git a/scripts/ansible/roles/linux/openenclave/tasks/stable-install.yml b/scripts/ansible/roles/linux/openenclave/tasks/stable-install.yml index 4034a350c2..dcbc62f154 100644 --- a/scripts/ansible/roles/linux/openenclave/tasks/stable-install.yml +++ b/scripts/ansible/roles/linux/openenclave/tasks/stable-install.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -15,5 +15,5 @@ - name: Install the official Open Enclave APT package apt: name: open-enclave - state: present + state: latest update_cache: yes diff --git a/scripts/ansible/roles/linux/openenclave/tasks/validation.yml b/scripts/ansible/roles/linux/openenclave/tasks/validation.yml index c3f425d889..3f86d3ec76 100644 --- a/scripts/ansible/roles/linux/openenclave/tasks/validation.yml +++ b/scripts/ansible/roles/linux/openenclave/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -37,9 +37,9 @@ register: clang_check_version failed_when: clang_check_version.stdout.find(clang_target_version) == -1 -- name: Ocaml version check - shell: "ocaml -version" +- name: Esy version check + shell: "esy --version" args: executable: /bin/bash - register: ocaml_check_version - failed_when: ocaml_check_version.stdout.find(ocaml_version) == -1 + register: esy_check_version + failed_when: esy_check_version.stdout.find(esy_target_version) == -1 diff --git a/scripts/ansible/roles/linux/openenclave/vars/ubuntu.yml b/scripts/ansible/roles/linux/openenclave/vars/ubuntu.yml index 9110aca36c..8eee4dd17c 100644 --- a/scripts/ansible/roles/linux/openenclave/vars/ubuntu.yml +++ b/scripts/ansible/roles/linux/openenclave/vars/ubuntu.yml @@ -1,32 +1,11 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- -opam_bin_url: "https://github.com/ocaml/opam/releases/download/2.0.4/opam-2.0.4-x86_64-linux" -opam_root: "/usr/local/opam" -ocaml_version: "4.05.0" cmake_target_version: "3.13.1" clang_target_version: "7.1.0" - -ocaml_packages: - ocaml_base_nox: - url: "https://oejenkins.blob.core.windows.net/oejenkins/ocaml/ocaml-base-nox_amd64.deb" - local_path: "/tmp/ocaml-base-nox_amd64.deb" - ocaml_base: - url: "https://oejenkins.blob.core.windows.net/oejenkins/ocaml/ocaml-base_amd64.deb" - local_path: "/tmp/ocaml-base_amd64.deb" - ocaml_compiler_libs: - url: "https://oejenkins.blob.core.windows.net/oejenkins/ocaml/ocaml-compiler-libs_amd64.deb" - local_path: "/tmp/ocaml-compiler-libs_amd64.deb" - ocaml_interp: - url: "https://oejenkins.blob.core.windows.net/oejenkins/ocaml/ocaml-interp_amd64.deb" - local_path: "/tmp/ocaml-interp_amd64.deb" - ocaml_nox: - url: "https://oejenkins.blob.core.windows.net/oejenkins/ocaml/ocaml-nox_amd64.deb" - local_path: "/tmp/ocaml-nox_amd64.deb" - ocaml: - url: "https://oejenkins.blob.core.windows.net/oejenkins/ocaml/ocaml_amd64.deb" - local_path: "/tmp/ocaml_amd64.deb" +esy_target_version: "0.5.8" +esy_prefix: "/usr/local/lib/esy" apt_packages: - "curl" @@ -65,7 +44,6 @@ apt_arm_packages: - "sshpass" validation_directories: - - "/usr/local/opam" - "/usr/share/libtool" validation_files: @@ -77,6 +55,7 @@ validation_binaries: - "/usr/local/bin/ccmake" - "/usr/local/bin/cpack" - "/usr/local/bin/ctest" + - "/usr/local/bin/esy" - "/usr/bin/dot" - "/usr/bin/gcc" - "/usr/bin/g++" @@ -84,7 +63,6 @@ validation_binaries: - "/usr/bin/autoconf" - "/usr/bin/libtoolize" - "/usr/bin/doxygen" - - "/usr/bin/ocaml" - "/usr/bin/openssl" - "/usr/bin/pkg-config" - "/usr/bin/clang-7" diff --git a/scripts/ansible/roles/windows/az-dcap-client/tasks/validation.yml b/scripts/ansible/roles/windows/az-dcap-client/tasks/validation.yml index 008451c9bf..0a96d692eb 100644 --- a/scripts/ansible/roles/windows/az-dcap-client/tasks/validation.yml +++ b/scripts/ansible/roles/windows/az-dcap-client/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -25,6 +25,7 @@ name: '{{ lc_driver.reg_key }}' register: reg_key failed_when: reg_key.value != 1 + when: dcap_testing_node is defined and dcap_testing_node == 'true' - name: Azure DCAP Client | Download devcon.exe win_get_url: @@ -40,6 +41,7 @@ with_items: - 'root\SgxLCDevice' - 'root\SgxLCDevice_DCAP' + when: dcap_testing_node is defined and dcap_testing_node == 'true' - name: Azure DCAP Client | Remove temp devcon.exe win_file: diff --git a/scripts/ansible/roles/windows/az-dcap-client/vars/windows.yml b/scripts/ansible/roles/windows/az-dcap-client/vars/windows.yml index bd3dae7cd8..6a6fd32b6f 100644 --- a/scripts/ansible/roles/windows/az-dcap-client/vars/windows.yml +++ b/scripts/ansible/roles/windows/az-dcap-client/vars/windows.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -11,20 +11,9 @@ lc_driver: reg_value: 1 validation_directories: - - "C:\\openenclave\\prereqs\\nuget\\curl" - - "C:\\openenclave\\prereqs\\nuget\\DCAP_Components" - - "C:\\openenclave\\prereqs\\nuget\\EnclaveCommonAPI" - - "C:\\openenclave\\prereqs\\nuget\\Microsoft.Azure.DCAP.Client" - - "C:\\openenclave\\prereqs\\nuget\\openssl" - - "C:\\openenclave\\prereqs\\nuget\\zlib" + - "C:\\oe_prereqs\\DCAP_Components" + - "C:\\oe_prereqs\\EnclaveCommonAPI" validation_binaries: - - "C:\\openenclave\\prereqs\\nuget\\curl\\build\\native\\lib\\v110\\x64\\Release\\static\\libcurl.lib" - - "C:\\openenclave\\prereqs\\nuget\\DCAP_Components\\build\\lib\\native\\Libraries\\sgx_dcap_ql.lib" - - "C:\\openenclave\\prereqs\\nuget\\EnclaveCommonAPI\\lib\\native\\x64-Release\\sgx_enclave_common.lib" - - "C:\\openenclave\\prereqs\\nuget\\libssh2\\build\\native\\lib\\v110\\x64\\Release\\static\\cdecl\\libssh2.lib" - - "C:\\openenclave\\prereqs\\nuget\\Microsoft.Azure.DCAP.Client\\lib\\release\\dcap_quoteprov.dll" - - "C:\\openenclave\\prereqs\\nuget\\openssl\\build\\native\\lib\\v110\\x64\\Release\\static\\cdecl\\libeay32.lib" - - "C:\\openenclave\\prereqs\\nuget\\openssl\\build\\native\\lib\\v110\\x64\\Release\\static\\cdecl\\ssleay32.lib" - - "C:\\openenclave\\prereqs\\nuget\\zlib\\build\\native\\lib\\v110\\x64\\Release\\static\\stdcall\\zlib.lib" - - "C:\\openenclave\\prereqs\\nuget\\curl\\build\\native\\lib\\v110\\x64\\Release\\static\\libcurl.lib" + - "C:\\oe_prereqs\\DCAP_Components\\build\\lib\\native\\Libraries\\sgx_dcap_ql.lib" + - "C:\\oe_prereqs\\EnclaveCommonAPI\\lib\\native\\x64-Release\\sgx_enclave_common.lib" diff --git a/scripts/ansible/roles/windows/jenkins/tasks/slave-setup.yml b/scripts/ansible/roles/windows/jenkins/tasks/slave-setup.yml index e4c5b7d9cf..cd776f2a83 100644 --- a/scripts/ansible/roles/windows/jenkins/tasks/slave-setup.yml +++ b/scripts/ansible/roles/windows/jenkins/tasks/slave-setup.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/windows/jenkins/tasks/validation.yml b/scripts/ansible/roles/windows/jenkins/tasks/validation.yml index fb867cbab2..41cffd5639 100644 --- a/scripts/ansible/roles/windows/jenkins/tasks/validation.yml +++ b/scripts/ansible/roles/windows/jenkins/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/windows/jenkins/vars/windows.yml b/scripts/ansible/roles/windows/jenkins/vars/windows.yml index f60457acbf..c640263786 100644 --- a/scripts/ansible/roles/windows/jenkins/vars/windows.yml +++ b/scripts/ansible/roles/windows/jenkins/vars/windows.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- diff --git a/scripts/ansible/roles/windows/openenclave/tasks/validation.yml b/scripts/ansible/roles/windows/openenclave/tasks/validation.yml index 15b5c572cf..2403596200 100644 --- a/scripts/ansible/roles/windows/openenclave/tasks/validation.yml +++ b/scripts/ansible/roles/windows/openenclave/tasks/validation.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- @@ -33,8 +33,3 @@ raw: "clang --version" register: clang_check_version failed_when: clang_check_version.stdout.find(clang_target_version) == -1 - -- name: Ocaml version check - raw: "ocaml -version" - register: ocaml_check_version - failed_when: ocaml_check_version.stdout.find(ocaml_target_version) == -1 diff --git a/scripts/ansible/roles/windows/openenclave/vars/windows.yml b/scripts/ansible/roles/windows/openenclave/vars/windows.yml index 86b3fc355a..95baaad66e 100644 --- a/scripts/ansible/roles/windows/openenclave/vars/windows.yml +++ b/scripts/ansible/roles/windows/openenclave/vars/windows.yml @@ -1,31 +1,32 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. --- cmake_target_version: 3.12.18081601 ninja_target_version: 1.8.2 clang_target_version: 7.0.1 -ocaml_target_version: 4.02.1 validation_directories: - "C:\\Program Files\\7-Zip" - - "C:\\Program Files\\OCaml\\bin" + - "C:\\Program Files\\nodejs" - "C:\\Program Files\\LLVM\\bin" - "C:\\Program Files\\Git\\bin" - "C:\\Program Files\\Git\\mingw64\\bin" - "C:\\Program Files\\shellcheck" - "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build" - "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools" + - "C:\\oe_prereqs\\node_modules\\esy" validation_files: - "C:\\Program Files\\LLVM\\lib\\libclang.lib" - - "C:\\Program Files\\OCaml\\lib\\arg.cmi" + - "C:\\Program Files\\nodejs\\npm.cmd" - "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\lib\\x64\\vcomp.lib" validation_binaries: - "C:\\Program Files\\LLVM\\bin\\clang.exe" - "C:\\Program Files\\LLVM\\bin\\llvm-ar.exe" - - "C:\\Program Files\\OCaml\\bin\\ocaml.exe" + - "C:\\Program Files\\nodejs\\node.exe" - "C:\\Program Files\\shellcheck\\shellcheck.exe" - "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\cl.exe" - "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\Hostx64\\x64\\link.exe" + - "C:\\oe_prereqs\\esy" diff --git a/scripts/check-ci b/scripts/check-ci index dd55b3a58d..b8388a237a 100755 --- a/scripts/check-ci +++ b/scripts/check-ci @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # This script is very similar to the pre-commit hook, except it diff --git a/scripts/check-license b/scripts/check-license index 9de9405280..18c0da200a 100755 --- a/scripts/check-license +++ b/scripts/check-license @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # This script accepts either a list of files relative to the current @@ -11,7 +11,7 @@ set -o errexit set -o pipefail -license=("Copyright (c) Microsoft Corporation. All rights reserved." "Licensed under the MIT License.") +license=("Copyright (c) Open Enclave SDK contributors." "Licensed under the MIT License.") root=$(git rev-parse --show-toplevel) diff --git a/scripts/check-linters b/scripts/check-linters index f3eef93093..371e7fb3ca 100755 --- a/scripts/check-linters +++ b/scripts/check-linters @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # This script currently runs just the ShellCheck linter on shell diff --git a/scripts/clangw b/scripts/clangw index e8f3d7a1e4..9de31dc8d5 100644 --- a/scripts/clangw +++ b/scripts/clangw @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # shellcheck disable=SC2068 disable=SC2006 disable=SC2179 @@ -42,6 +42,16 @@ function call_clang { [ "$a" == "/FS" ] && continue [ "$a" == "/showIncludes" ] && continue [ "$a" == "/JMC" ] && continue + [ "$a" == "/W1" ] && continue + [ "$a" == "/W2" ] && continue + [ "$a" == "/W3" ] && continue + [ "$a" == "/W4" ] && continue + [ "$a" == "/WX" ] && continue + + # Ignore warnings for specific error codes + if [[ "$a" =~ /[wW][dD][0-9]* ]]; then + continue + fi # Map the following arguments [ "$a" == "/DNDEBUG" ] && args+="-DNDEBUG " && continue diff --git a/scripts/commit-msg b/scripts/commit-msg new file mode 100644 index 0000000000..5490af6060 --- /dev/null +++ b/scripts/commit-msg @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +set -o errexit + +exit_() { + echo "" + echo "$1" + echo "" + echo "This hook can be skipped if needed with 'git commit --no-verify'" + echo "See '.git/hooks/commit-msg', installed from 'scripts/commit-msg'" + exit 1 +} + +sign_offs="$(grep '^Signed-off-by: ' "$1" || test $? = 1 )" + +if [[ -z $sign_offs ]]; then + exit_ "Commit failed: please sign-off on the DCO with 'git commit -s'" +fi + +if [[ -n $(echo "$sign_offs" | sort | uniq -c | sed -e '/^[ ]*1[ ]/d') ]]; then + exit_ "Commit failed: please remove duplicate Signed-off-by lines" +fi diff --git a/scripts/deploy-docs b/scripts/deploy-docs index 338c6c2ec7..e31ee9c313 100755 --- a/scripts/deploy-docs +++ b/scripts/deploy-docs @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== diff --git a/scripts/format-code b/scripts/format-code index 2ed26771e5..b1a56c2123 100755 --- a/scripts/format-code +++ b/scripts/format-code @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== @@ -140,8 +140,7 @@ check_version() # Because clang-format is not invariant across versions, this # is an explicit equivalence check. if [[ ${v1[$i]} -ne ${v2[$i]} ]]; then - echo "format-code requires clang-format version $1, installed version is $2" - exit 1 + echo "Warning: format-code prefers clang-format version $1, installed version is $2" fi done } @@ -170,7 +169,7 @@ check_clang-format() local required_cfver='7.0.1' # shellcheck disable=SC2155 - local cfver=$(${cf} --version | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+') + local cfver=$(${cf} --version | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+' | head -1) check_version "${required_cfver}" "${cfver}" } diff --git a/scripts/format-code.ps1 b/scripts/format-code.ps1 index 4c323183ba..97f5610777 100644 --- a/scripts/format-code.ps1 +++ b/scripts/format-code.ps1 @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. $usage=$false; diff --git a/scripts/generate-devkits b/scripts/generate-devkits index 899334cabe..0c4fe58fd3 100755 --- a/scripts/generate-devkits +++ b/scripts/generate-devkits @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. OPTEE_OS_PATH=$1 diff --git a/scripts/install-windows-prereqs.ps1 b/scripts/install-windows-prereqs.ps1 index 0248eec0d3..4164f8181b 100644 --- a/scripts/install-windows-prereqs.ps1 +++ b/scripts/install-windows-prereqs.ps1 @@ -1,53 +1,46 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # The Hash parameter defaults below are calculated using Get-FileHash with the default SHA256 hashing algorithm Param( [string]$GitURL = 'https://github.com/git-for-windows/git/releases/download/v2.19.1.windows.1/Git-2.19.1-64-bit.exe', [string]$GitHash = '5E11205840937DD4DFA4A2A7943D08DA7443FAA41D92CCC5DAFBB4F82E724793', + [string]$OpenSSLURL = 'https://slproweb.com/download/Win64OpenSSL-1_1_1d.exe', + [string]$OpenSSLHash = '6AFA17D0768CF91B6F69F31FBC67CAB1AC2E3F40CCAAADB7A9D6C7FC37B38492', [string]$SevenZipURL = 'https://www.7-zip.org/a/7z1806-x64.msi', [string]$SevenZipHash = 'F00E1588ED54DDF633D8652EB89D0A8F95BD80CCCFC3EED362D81927BEC05AA5', + # We skip the hash check for the vs_buildtools.exe file because it is regularly updated without a change to the URL, unfortunately. [string]$VSBuildToolsURL = 'https://aka.ms/vs/15/release/vs_buildtools.exe', - [string]$VSBuildToolsHash = '7D5B0220670BA1C174F0AE1FF2CE87D65A508E66C321431FBD4751F478037E12', - [string]$OCamlURL = 'https://www.ocamlpro.com/pub/ocpwin/ocpwin-builds/ocpwin64/20160113/ocpwin64-20160113-4.02.1+ocp1-mingw64.zip', - [string]$OCamlHash = '369F900F7CDA543ABF674520ED6004CC75008E10BEED0D34845E8A42866D0F3A', + [string]$VSBuildToolsHash = '', + [string]$NodeURL = 'https://nodejs.org/dist/v10.16.3/node-v10.16.3-x64.msi', + [string]$NodeHash = 'F68B75EEA46232ADB8FD38126C977DC244166D29E7C6CD2DF930B460C38590A9', [string]$Clang7URL = 'http://releases.llvm.org/7.0.1/LLVM-7.0.1-win64.exe', [string]$Clang7Hash = '672E4C420D6543A8A9F8EC5F1E5F283D88AC2155EF4C57232A399160A02BFF57', - [string]$IntelPSWURL = 'http://registrationcenter-download.intel.com/akdlm/irc_nas/15654/Intel%20SGX%20PSW%20for%20Windows%20v2.4.100.51291.exe', - [string]$IntelPSWHash = '79AE32E984B5511CE4BF7568403333F837FBCE7E8D5730271C5D68F55BBF251D', + [string]$IntelPSWURL = 'http://registrationcenter-download.intel.com/akdlm/irc_nas/16115/Intel%20SGX%20PSW%20for%20Windows%20v2.5.101.3.exe', + [string]$IntelPSWHash = 'D904964872A49426D3BFD0249752403DC746611F92F4FF6B95F64F336744323C', [string]$ShellCheckURL = 'https://shellcheck.storage.googleapis.com/shellcheck-v0.7.0.zip', [string]$ShellCheckHash = '02CFA14220C8154BB7C97909E80E74D3A7FE2CBB7D80AC32ADCAC7988A95E387', [string]$NugetURL = 'https://www.nuget.org/api/v2/package/NuGet.exe/3.4.3', [string]$NugetHash = '2D4D38666E5C7D27EE487C60C9637BD9DD63795A117F0E0EDC68C55EE6DFB71F', [string]$DevconURL = 'https://download.microsoft.com/download/7/D/D/7DD48DE6-8BDA-47C0-854A-539A800FAA90/wdk/Installers/787bee96dbd26371076b37b13c405890.cab', [string]$DevconHash = 'A38E409617FC89D0BA1224C31E42AF4344013FEA046D2248E4B9E03F67D5908A', - [string]$IntelDCAPURL = 'http://registrationcenter-download.intel.com/akdlm/irc_nas/15650/Intel%20SGX%20DCAP%20for%20Windows%20v1.2.100.49925.exe', - [string]$IntelDCAPHash = 'F31E4451CA32E19CA3DCB0AFC49AFE9F4963C47BF62AAF24A8AE436BDA14FD8B', + [string]$IntelDCAPURL = 'http://registrationcenter-download.intel.com/akdlm/irc_nas/16114/Intel%20SGX%20DCAP%20for%20Windows%20v1.3.101.3.exe', + [string]$IntelDCAPHash = '27C1CC7F8434A704853FC3BFE15723F6F507CB09BF79B248A09A9ED0EED48A01', [string]$VCRuntime2012URL = 'https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exe', [string]$VCRuntime2012Hash = '681BE3E5BA9FD3DA02C09D7E565ADFA078640ED66A0D58583EFAD2C1E3CC4064', - [string]$AzureDCAPNupkgURL = 'https://www.nuget.org/api/v2/package/Azure.DCAP.Windows/0.0.2', - [string]$AzureDCAPNupkgHash = 'E319A6C2D136FE5EDB8799305F6151B71F4CE4E67D96CA74538D0AD5D2D793F1', + [string]$AzureDCAPNupkgURL = 'https://www.nuget.org/api/v2/package/Azure.DCAP.Windows/0.0.3', + [string]$AzureDCAPNupkgHash = '79C698B61CADA32F56F26647B96BBB1C00B7409A6646597C7CC2908A57677256', + [string]$Python3ZipURL = 'https://www.python.org/ftp/python/3.7.4/python-3.7.4-embed-amd64.zip', + [string]$Python3ZipHash = 'FB65E5CD595AD01049F73B47BC0EE23FD03F0CBADC56CB318990CEE83B37761B', [Parameter(mandatory=$true)][string]$InstallPath, [Parameter(mandatory=$true)][ValidateSet("SGX1FLC", "SGX1", "SGX1FLC-NoDriver")][string]$LaunchConfiguration, [Parameter(mandatory=$true)][ValidateSet("None", "Azure")][string]$DCAPClientType ) -if ($LaunchConfiguration -eq "SGX1") -{ - Write-Host "**** Installing PSW 2.2 ****" - - $IntelPSWURL = "https://oejenkins.blob.core.windows.net/oejenkins/intel_sgx_win_2.2.100.47975_PV.zip" - $IntelPSWHash = 'EB479D1E029D51E48E534C284FCF5CCA3A937DA43052DCB2F4C71E5F354CA623' -} -else -{ - Write-Host "**** Installing PSW 2.4 ****" -} - $ErrorActionPreference = "Stop" $PACKAGES_DIRECTORY = Join-Path $env:TEMP "packages" -$OE_NUGET_DIR = Join-Path $InstallPath "prereqs\nuget" +$OE_NUGET_DIR = $InstallPath $PACKAGES = @{ "git" = @{ @@ -65,10 +58,10 @@ $PACKAGES = @{ "hash" = $VSBuildToolsHash "local_file" = Join-Path $PACKAGES_DIRECTORY "vs_buildtools.exe" } - "ocaml" = @{ - "url" = $OCamlURL - "hash" = $OCamlHash - "local_file" = Join-Path $PACKAGES_DIRECTORY "ocpwin64.zip" + "node" = @{ + "url" = $NodeURL + "hash" = $NodeHash + "local_file" = Join-Path $PACKAGES_DIRECTORY "node-x64.msi" } "clang7" = @{ "url" = $Clang7URL @@ -110,6 +103,16 @@ $PACKAGES = @{ "hash" = $AzureDCAPNupkgHash "local_file" = Join-Path $PACKAGES_DIRECTORY "Azure.DCAP.Windows.nupkg" } + "openssl" = @{ + "url" = $OpenSSLURL + "hash" = $OpenSSLHash + "local_file" = Join-Path $PACKAGES_DIRECTORY "Win64OpenSSL-1_1_1d.exe" + } + "python3" = @{ + "url" = $Python3ZipURL + "hash" = $Python3ZipHash + "local_file" = Join-Path $PACKAGES_DIRECTORY "Python3.zip" + } } filter Timestamp { "[$(Get-Date -Format o)] $_" } @@ -149,13 +152,16 @@ function Start-LocalPackagesDownload { -Destination $PACKAGES[$pkg]["local_file"] $downloaded_hash = Get-FileHash $PACKAGES[$pkg]["local_file"] $expected_hash = $PACKAGES[$pkg]["hash"] - if ($downloaded_hash.Hash -ne $expected_hash) - { - Throw "Error: Computed hash ($downloaded_hash) does not match expected hash ($expected_hash)" - } - else + if ($expected_hash -ne "") { - Write-Output "Computed hash ($downloaded_hash) matches expected hash ($expected_hash)" + if ($downloaded_hash.Hash -ne $expected_hash) + { + Throw "Error: Computed hash ($downloaded_hash) does not match expected hash ($expected_hash)" + } + else + { + Write-Output "Computed hash ($downloaded_hash) matches expected hash ($expected_hash)" + } } } Write-Output "Finished downloading all the packages" @@ -307,7 +313,25 @@ function Install-Nuget { Install-ZipTool -ZipPath $PACKAGES["nuget"]["local_file"] ` -InstallDirectory $tempInstallDir ` -EnvironmentPath @("$tempInstallDir") - Copy-Item -Force "$tempInstallDir\build\native\Nuget.exe" $PACKAGES_DIRECTORY + $installDir = Join-Path $env:ProgramFiles "nuget-3.4.3" + New-Directory -Path $installDir -RemoveExisting + Move-Item -Path "$tempInstallDir\build\native\Nuget.exe" -Destination $installDir + Add-ToSystemPath -Path $installDir +} + +function Install-Python3 { + $tempInstallDir = "$PACKAGES_DIRECTORY\python3" + if(Test-Path -Path $tempInstallDir) { + Remove-Item -Path $tempInstallDir -Force -Recurse + } + Install-ZipTool -ZipPath $PACKAGES["python3"]["local_file"] ` + -InstallDirectory $tempInstallDir ` + -EnvironmentPath @("$tempInstallDir") + + $installDir = Join-Path $env:ProgramFiles "python-3.7.4" + New-Directory -Path $installDir -RemoveExisting + Move-Item -Path "$tempInstallDir\*" -Destination $installDir + Add-ToSystemPath -Path $installDir } function Install-Git { @@ -318,6 +342,29 @@ function Install-Git { -EnvironmentPath @("$installDir\cmd", "$installDir\bin", "$installDir\mingw64\bin") } +function Install-OpenSSL { + $installDir = $installDir = Join-Path $env:ProgramFiles "OpenSSL-Win64" + Install-Tool -InstallerPath $PACKAGES["openssl"]["local_file"] ` + -InstallDirectory $installDir ` + -ArgumentList @("/silent", "/eula=accept") ` + -EnvironmentPath @($installDir) + + $binDir = Join-Path $installDir "bin" + $systemPath = [System.Environment]::GetEnvironmentVariable('Path', 'Machine') + $currentPath = $env:PATH + if($binDir -notin $systemPath) { + $systemPath = "$binDir;$systemPath" + } + if($binDir -notin $currentPath) { + $currentPath = "$binDir;$currentPath" + } + $env:PATH = $currentPath + setx.exe /M PATH $systemPath + if($LASTEXITCODE) { + Throw "Failed to set the new system path" + } +} + function Install-7Zip { $installDir = Join-Path $env:ProgramFiles "7-Zip" Install-Tool -InstallerPath $PACKAGES["7z"]["local_file"] ` @@ -370,17 +417,18 @@ function Install-VisualStudio { "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2017\BuildTools\Common7\Tools") } -function Install-OCaml { - $installDir = Join-Path $env:ProgramFiles "OCaml" - $tmpDir = Join-Path $PACKAGES_DIRECTORY "ocpwin64" - if(Test-Path -Path $tmpDir) { - Remove-Item -Recurse -Force -Path $tmpDir - } - Install-ZipTool -ZipPath $PACKAGES["ocaml"]["local_file"] ` - -InstallDirectory $tmpDir ` - -EnvironmentPath @("$installDir\bin") - New-Directory -Path $installDir -RemoveExisting - Move-Item -Path "$tmpDir\*\*" -Destination $installDir +function Install-Node { + $installDir = Join-Path $env:ProgramFiles "nodejs" + Install-Tool -InstallerPath $PACKAGES["node"]["local_file"] ` + -InstallDirectory $installDir ` + -ArgumentList @("/quiet", "/passive") ` + -EnvironmentPath @($installDir) + + Add-ToSystemPath -Path "${InstallPath}" + + Start-ExecuteWithRetry -ScriptBlock { + npm install --prefix "${InstallPath}" -g esy@0.5.8 + } -RetryMessage "Failed to install esy. Retrying" } function Install-LLVM { @@ -397,7 +445,9 @@ function Install-Shellcheck { Install-ZipTool -ZipPath $PACKAGES["shellcheck"]["local_file"] ` -InstallDirectory $installDir ` -EnvironmentPath @("$installDir") - Add-ToSystemPath -Path "${env:ProgramFiles}\shellcheck" + $filePath = Join-Path $installDir "shellcheck*.exe" + $scexe = Get-ChildItem $filePath + Rename-Item $scexe "shellcheck.exe" } function Get-DevconBinary { @@ -459,64 +509,68 @@ function Install-DCAP-Dependencies { Install-Tool -InstallerPath $PACKAGES["dcap"]["local_file"] ` -ArgumentList @('/auto', "$PACKAGES_DIRECTORY\Intel_SGX_DCAP") - $drivers = @{ - 'sgx_base_dev' = @{ - 'zip_path' = "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\Intel SGX DCAP for Windows *\LC_driver_WinServer2016\Signed_*.zip" - 'location' = 'root\SgxLCDevice' - 'description' = 'Intel(R) Software Guard Extensions Launch Configuration Service' - } - 'sgx_dcap_dev' = @{ - 'zip_path' = "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\Intel SGX DCAP for Windows *\DCAP_INF\WinServer2016\Signed_*.zip" - 'location' = 'root\SgxLCDevice_DCAP' - 'description' = 'Intel(R) Software Guard Extensions DCAP Components Device' - } - } - $devConBinaryPath = Get-DevconBinary - foreach($driver in $drivers.Keys) { - $zip = Get-Item $drivers[$driver]['zip_path'] - if(!$zip) { - Throw "Cannot find the zile file with $driver" - } - if($zip.Count -gt 1) { - $zip - Throw "Multiple driver zip files found" - } - New-Item -ItemType Directory -Force -Path "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver" - Expand-Archive -Path $zip -DestinationPath "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver" -Force - $inf = Get-Item "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver\drivers\*\$driver.inf" - if(!$inf) { - Throw "Cannot find $driver.inf file" - } - if($inf.Count -gt 1) { - $inf - Throw "Multiple $driver.inf files found" - } - # Check if the driver is already installed and delete it - $output = & $devConBinaryPath find "$($drivers[$driver]['location'])" - if($LASTEXITCODE) { - Throw "Failed searching for $driver driver" - } - $output | ForEach-Object { - if($_.Contains($drivers[$driver]['description'])) { - Write-Output "Removing driver $($drivers[$driver]['location'])" - Remove-DCAPDriver -Name $drivers[$driver]['location'] + if (($LaunchConfiguration -eq "SGX1FLC") -or ($LaunchConfiguration -eq "SGX1FLC-NoDriver") -or ($DCAPClientType -eq "Azure")) + { + $drivers = @{ + 'sgx_base_dev' = @{ + 'zip_path' = "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\Intel SGX DCAP for Windows *\LC_driver_WinServer2016\Signed_*.zip" + 'location' = 'root\SgxLCDevice' + 'description' = 'Intel(R) Software Guard Extensions Launch Configuration Service' + } + 'sgx_dcap_dev' = @{ + 'zip_path' = "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\Intel SGX DCAP for Windows *\DCAP_INF\WinServer2016\Signed_*.zip" + 'location' = 'root\SgxLCDevice_DCAP' + 'description' = 'Intel(R) Software Guard Extensions DCAP Components Device' } } - if ($LaunchConfiguration -eq "SGX1FLC") - { - Write-Output "Installing driver $($drivers[$driver]['location'])" - $install = & $devConBinaryPath install "$($inf.FullName)" $drivers[$driver]['location'] + $devConBinaryPath = Get-DevconBinary + foreach($driver in $drivers.Keys) { + $zip = Get-Item $drivers[$driver]['zip_path'] + if(!$zip) { + Throw "Cannot find the zile file with $driver" + } + if($zip.Count -gt 1) { + $zip + Throw "Multiple driver zip files found" + } + New-Item -ItemType Directory -Force -Path "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver" + Expand-Archive -Path $zip -DestinationPath "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver" -Force + $inf = Get-Item "$PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver\drivers\*\$driver.inf" + if(!$inf) { + Throw "Cannot find $driver.inf file" + } + if($inf.Count -gt 1) { + $inf + Throw "Multiple $driver.inf files found" + } + # Check if the driver is already installed and delete it + $output = & $devConBinaryPath find "$($drivers[$driver]['location'])" if($LASTEXITCODE) { - Throw "Failed to install $driver driver" + Throw "Failed searching for $driver driver" + } + $output | ForEach-Object { + if($_.Contains($drivers[$driver]['description'])) { + Write-Output "Removing driver $($drivers[$driver]['location'])" + Remove-DCAPDriver -Name $drivers[$driver]['location'] + } + } + if ($LaunchConfiguration -eq "SGX1FLC") + { + Write-Output "Installing driver $($drivers[$driver]['location'])" + $install = & $devConBinaryPath install "$($inf.FullName)" $drivers[$driver]['location'] + if($LASTEXITCODE) { + Throw "Failed to install $driver driver" + } + Write-Output $install + } + elseif ($LaunchConfiguration -eq "SGX1FLC-NoDriver") + { + Write-Output "Copying Intel_SGX_DCAP dll files into $($env:SystemRoot)\system32" + Copy-item -Path $PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver\drivers\*\*.dll $env:SystemRoot\system32\ } - Write-Output $install - } - elseif ($LaunchConfiguration -eq "SGX1FLC-NoDriver") - { - Write-Output "Copying Intel_SGX_DCAP dll files into $($env:SystemRoot)\system32" - Copy-item -Path $PACKAGES_DIRECTORY\Intel_SGX_DCAP\$driver\drivers\*\*.dll $env:SystemRoot\system32\ } } + $TEMP_NUGET_DIR = "$PACKAGES_DIRECTORY\Azure_DCAP_Client_nupkg" New-Directory -Path $OE_NUGET_DIR -RemoveExisting New-Directory -Path $TEMP_NUGET_DIR -RemoveExisting @@ -532,16 +586,19 @@ function Install-DCAP-Dependencies { # Note: the ordering of nuget installs below is important to preserve here until the issue with the EnclaveCommonAPI nuget package gets fixed. if ($DCAPClientType -eq "Azure") { - & "$PACKAGES_DIRECTORY\nuget.exe" install 'Azure.DCAP.Windows' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion + & nuget.exe install 'Azure.DCAP.Windows' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion if($LASTEXITCODE -ne 0) { Throw "Failed to install nuget EnclaveCommonAPI" } } - & "$PACKAGES_DIRECTORY\nuget.exe" install 'DCAP_Components' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion - if($LASTEXITCODE -ne 0) { - Throw "Failed to install nuget DCAP_Components" + if (($LaunchConfiguration -eq "SGX1FLC") -or ($LaunchConfiguration -eq "SGX1FLC-NoDriver") -or ($DCAPClientType -eq "Azure")) + { + & nuget.exe install 'DCAP_Components' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion + if($LASTEXITCODE -ne 0) { + Throw "Failed to install nuget DCAP_Components" + } } - & "$PACKAGES_DIRECTORY\nuget.exe" install 'EnclaveCommonAPI' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion + & nuget.exe install 'EnclaveCommonAPI' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion if($LASTEXITCODE -ne 0) { Throw "Failed to install nuget EnclaveCommonAPI" } @@ -567,7 +624,7 @@ function Install-AzureDCAPWindows { Copy-Item $PACKAGES['azure_dcap_client_nupkg']['local_file'] -Destination $TEMP_NUGET_DIR -Force - & "$PACKAGES_DIRECTORY\nuget.exe" install 'Azure.DCAP.Windows' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion + & nuget.exe install 'Azure.DCAP.Windows' -Source "$TEMP_NUGET_DIR;nuget.org" -OutputDirectory "$OE_NUGET_DIR" -ExcludeVersion if($LASTEXITCODE -ne 0) { Throw "Failed to install nuget Azure.DCAP.Windows" } @@ -584,28 +641,31 @@ try { Install-7Zip Install-Nuget + Install-Python3 Install-VisualStudio + Install-OpenSSL Install-LLVM Install-Git - Install-OCaml Install-Shellcheck - Install-PSW - + + if ($LaunchConfiguration -ne "SGX1FLC-NoDriver") + { + Install-PSW + } + if ($DCAPClientType -eq "Azure") { Write-Host "*** Installing Azure.DCAP.Windows ***" - Install-AzureDCAPWindows + Install-AzureDCAPWindows } else { Write-Host "*** Not installing a DCAP Client ***" } - if ( ($LaunchConfiguration -eq "SGX1FLC") -or ($LaunchConfiguration -eq "SGX1FLC-NoDriver") -or ($DCAPClientType -eq "Azure") ) - { - Install-DCAP-Dependencies - } - + Install-DCAP-Dependencies + # Install-Node has to be executed after Install-DCAP-Dependencies because it removes existing $InstallPath directory + Install-Node Install-VCRuntime Write-Output 'Please reboot your computer for the configuration to complete.' diff --git a/scripts/llvm-arw b/scripts/llvm-arw index 3a5e971289..9993658fb5 100644 --- a/scripts/llvm-arw +++ b/scripts/llvm-arw @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # shellcheck disable=SC2068 diff --git a/scripts/pre-commit b/scripts/pre-commit index ffe64a5fca..82800cdc6c 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/scripts/test-build-config b/scripts/test-build-config index ff75176fd0..00c6ec7f8b 100755 --- a/scripts/test-build-config +++ b/scripts/test-build-config @@ -1,14 +1,14 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##==================================================================================== ## ## This script fires OE build and test for specified build-type, platform and -## simulator/hardware mode. +## simulation/hardware mode. ## Default run with no parameters builds with Debug build-type and for SGX1 -## platform and will test in Simulator mode. +## platform and will test in simulation. ## Run this from the root of the source tree as sudo. ## Please note that this script does not install any packages needed for build/test. ## Please install all packages necessary for your test before invoking this script. @@ -19,7 +19,7 @@ if [[ $1 == "-h" || $1 == "--help" ]]; then echo "Script to fire OE build and test with specified platform/build-type/test mode" echo " Usage: " echo " ./scripts/test-build-config" - echo " -d or --disable_sim to Disable Simulator Test Mode" + echo " -d or --disable_sim to Disable Simulation Test Mode" echo " -p SGX1FLC or -p=SGX1FLC to build for SGX1FLC platform" echo " -b Debug|RelWithDebInfo|Release or -b=Debug|RelWithDebInfo|Release" echo " -h or --help to Display usage and exit" @@ -28,14 +28,14 @@ if [[ $1 == "-h" || $1 == "--help" ]]; then echo " --enable_full_libcxx_tests to Enable libcxx tests" echo " --enable_full_libc_tests to Enable libc tests" echo " Default is to build for SGX1 platform, Debug Build type & test in" - echo " simulator mode" + echo " simulation" echo "" exit 0 fi # Default values for the arguments -# Disable Simulator test mode to run on SGX hardware -# Default test mode is Simulator, disable Simulator test mode with -d or --disable_sim +# Disable Simulation test mode to run on SGX hardware +# Default test mode is simulation, disable simulation test mode with -d or --disable_sim DISABLE_SIM=0 # Valid PLATFORM_MODE values are SGX1 or SGX1FLC PLATFORM_MODE="SGX1" @@ -123,7 +123,7 @@ mkdir build && cd build || exit 1 CMAKE="cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE}" if [[ ${PLATFORM_MODE} == "SGX1FLC" ]]; then - CMAKE+=" -DUSE_LIBSGX=1" + CMAKE+=" -DHAS_QUOTE_PROVIDER=1" fi if [[ ${BUILD_PACKAGE} -eq 1 ]]; then CMAKE+=" -DCMAKE_INSTALL_PREFIX=${OE_INSTALL_DIR} -DCPACK_GENERATOR=DEB" @@ -156,7 +156,7 @@ if ! make; then exit 1 fi -# Finally run the tests in Simulator mode or on Hardware +# Finally run the tests in simulation or on Hardware if [[ ${DISABLE_SIM} -ne 1 ]]; then SIMULATION_MODE_TEXT="simulation" export OE_SIMULATION=1 diff --git a/syscall/CMakeLists.txt b/syscall/CMakeLists.txt index 2fe73c8626..003e74b31a 100644 --- a/syscall/CMakeLists.txt +++ b/syscall/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. ##============================================================================== diff --git a/syscall/consolefs.c b/syscall/consolefs.c index 3f4039688d..a97f322ca1 100644 --- a/syscall/consolefs.c +++ b/syscall/consolefs.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/consolefs.h b/syscall/consolefs.h index 73dec63bc6..c8c9e991eb 100644 --- a/syscall/consolefs.h +++ b/syscall/consolefs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved._ops +// Copyright (c) Open Enclave SDK contributors._ops // Licensed under the MIT License. #ifndef _OE_SYSCALL_CONSOLEFS_H diff --git a/syscall/device.c b/syscall/device.c index e8a7fa7cd4..de00c6ec4d 100644 --- a/syscall/device.c +++ b/syscall/device.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/devices/CMakeLists.txt b/syscall/devices/CMakeLists.txt index a9b5012e52..dcc928accc 100644 --- a/syscall/devices/CMakeLists.txt +++ b/syscall/devices/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(hostfs) diff --git a/syscall/devices/hostepoll/CMakeLists.txt b/syscall/devices/hostepoll/CMakeLists.txt index ffb43275a7..fca60f36b9 100644 --- a/syscall/devices/hostepoll/CMakeLists.txt +++ b/syscall/devices/hostepoll/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oehostepoll STATIC hostepoll.c) diff --git a/syscall/devices/hostepoll/hostepoll.c b/syscall/devices/hostepoll/hostepoll.c index bb048883ce..b19be44f38 100644 --- a/syscall/devices/hostepoll/hostepoll.c +++ b/syscall/devices/hostepoll/hostepoll.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define _GNU_SOURCE @@ -62,7 +62,7 @@ typedef struct _epoll size_t map_capacity; /* Synchronizes access to this structure. */ - oe_spinlock_t lock; + oe_mutex_t lock; } epoll_t; static oe_epoll_ops_t _get_epoll_ops(void); @@ -224,6 +224,10 @@ static int _epoll_ctl_add(epoll_t* epoll, int fd, struct oe_epoll_event* event) host_event.data.fd = fd; } + // The host call and the map update must be done in an atomic operation. + locked = true; + oe_mutex_lock(&epoll->lock); + if (oe_syscall_epoll_ctl_ocall( &retval, host_epfd, OE_EPOLL_CTL_ADD, host_fd, &host_event) != OE_OK) @@ -233,9 +237,6 @@ static int _epoll_ctl_add(epoll_t* epoll, int fd, struct oe_epoll_event* event) if (retval == 0) { - oe_spin_lock(&epoll->lock); - locked = true; - if (_map_reserve(epoll, epoll->map_size + 1) != 0) OE_RAISE_ERRNO(OE_ENOMEM); @@ -249,7 +250,7 @@ static int _epoll_ctl_add(epoll_t* epoll, int fd, struct oe_epoll_event* event) done: if (locked) - oe_spin_unlock(&epoll->lock); + oe_mutex_unlock(&epoll->lock); return ret; } @@ -262,6 +263,7 @@ static int _epoll_ctl_mod(epoll_t* epoll, int fd, struct oe_epoll_event* event) oe_host_fd_t host_fd; struct oe_epoll_event host_event; int retval; + bool locked = false; oe_errno = 0; @@ -290,6 +292,10 @@ static int _epoll_ctl_mod(epoll_t* epoll, int fd, struct oe_epoll_event* event) host_event.data.fd = fd; } + // The host call and the map update must be done in an atomic operation. + locked = true; + oe_mutex_lock(&epoll->lock); + if (oe_syscall_epoll_ctl_ocall( &retval, host_epfd, OE_EPOLL_CTL_MOD, host_fd, &host_event) != OE_OK) @@ -300,22 +306,19 @@ static int _epoll_ctl_mod(epoll_t* epoll, int fd, struct oe_epoll_event* event) /* Modify the mapping. */ if (retval == 0) { - mapping_t* mapping; - - oe_spin_lock(&epoll->lock); - { - if ((mapping = _map_find(epoll, fd))) - mapping->event = *event; - } - oe_spin_unlock(&epoll->lock); - + mapping_t* const mapping = _map_find(epoll, fd); if (!mapping) OE_RAISE_ERRNO(OE_ENOENT); + + mapping->event = *event; } ret = 0; done: + if (locked) + oe_mutex_unlock(&epoll->lock); + return ret; } @@ -326,6 +329,7 @@ static int _epoll_ctl_del(epoll_t* epoll, int fd) oe_host_fd_t host_epfd; oe_host_fd_t host_fd; int retval; + bool locked = false; oe_errno = 0; @@ -343,6 +347,10 @@ static int _epoll_ctl_del(epoll_t* epoll, int fd) if ((host_fd = desc->ops.fd.get_host_fd(desc)) == -1) OE_RAISE_ERRNO(oe_errno); + // The host call and the map update must be done in an atomic operation. + locked = true; + oe_mutex_lock(&epoll->lock); + if (oe_syscall_epoll_ctl_ocall( &retval, host_epfd, OE_EPOLL_CTL_DEL, host_fd, NULL) != OE_OK) { @@ -354,20 +362,16 @@ static int _epoll_ctl_del(epoll_t* epoll, int fd) { bool found = false; - oe_spin_lock(&epoll->lock); + for (size_t i = 0; epoll->map_size; i++) { - for (size_t i = 0; epoll->map_size; i++) + if (epoll->map[i].fd == fd) { - if (epoll->map[i].fd == fd) - { - /* Swap with last element of array. */ - epoll->map[i] = epoll->map[--epoll->map_size]; - found = true; - break; - } + /* Swap with last element of array. */ + epoll->map[i] = epoll->map[--epoll->map_size]; + found = true; + break; } } - oe_spin_unlock(&epoll->lock); if (!found) OE_RAISE_ERRNO(OE_ENOENT); @@ -376,6 +380,9 @@ static int _epoll_ctl_del(epoll_t* epoll, int fd) ret = 0; done: + if (locked) + oe_mutex_unlock(&epoll->lock); + return ret; } @@ -434,6 +441,7 @@ static int _epoll_wait( { int ret = -1; int retval; + bool locked = false; epoll_t* epoll = _cast_epoll(epoll_); oe_host_fd_t host_epfd = -1; @@ -457,26 +465,32 @@ static int _epoll_wait( if (retval > maxevents) OE_RAISE_ERRNO(OE_EINVAL); + locked = true; + oe_mutex_lock(&epoll->lock); + for (int i = 0; i < retval; i++) { - struct oe_epoll_event* event = &events[i]; - const mapping_t* mapping; + struct oe_epoll_event* const event = &events[i]; + const mapping_t* const mapping = _map_find(epoll, event->data.fd); - oe_spin_lock(&epoll->lock); + if (mapping) + event->data.u64 = mapping->event.data.u64; + else { - if ((mapping = _map_find(epoll, event->data.fd))) - event->data.u64 = mapping->event.data.u64; + // fd has been deleted between the return of epoll_wait and the + // acquisition of the lock. + --retval; + *event = events[retval]; + --i; } - oe_spin_unlock(&epoll->lock); - - if (!mapping) - OE_RAISE_ERRNO(OE_ENOENT); } } ret = (int)retval; done: + if (locked) + oe_mutex_unlock(&epoll->lock); return ret; } diff --git a/syscall/devices/hostfs/CMakeLists.txt b/syscall/devices/hostfs/CMakeLists.txt index 5127cda0dc..4ad635b7fd 100644 --- a/syscall/devices/hostfs/CMakeLists.txt +++ b/syscall/devices/hostfs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oehostfs STATIC hostfs.c) diff --git a/syscall/devices/hostfs/hostfs.c b/syscall/devices/hostfs/hostfs.c index 0b47e9959a..bacdb84087 100644 --- a/syscall/devices/hostfs/hostfs.c +++ b/syscall/devices/hostfs/hostfs.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* @@ -221,6 +221,15 @@ static int _hostfs_mount( if ((flags & OE_MS_RDONLY)) fs->mount.flags = flags; + /* --------------------------------------------------------------------- + * Only support absolute paths. Hostfs is treated as an external + * filesystem. As such, it does not make sense to resolve relative paths + * using the enclave's current working directory. + * --------------------------------------------------------------------- + */ + if (source && source[0] != '/') + OE_RAISE_ERRNO(OE_EINVAL); + /* Save the source parameter (will be needed to form host paths). */ oe_strlcpy(fs->mount.source, source, sizeof(fs->mount.source)); @@ -433,8 +442,10 @@ static int _hostfs_dup(oe_fd_t* desc, oe_fd_t** new_file_out) file_t* file = _cast_file(desc); file_t* new_file = NULL; - if (new_file_out) - *new_file_out = NULL; + if (!new_file_out) + OE_RAISE_ERRNO(OE_EINVAL); + + *new_file_out = NULL; /* Check parameters. */ if (!file) @@ -871,13 +882,13 @@ static oe_fd_t* _hostfs_opendir(oe_device_t* device, const char* name) if (oe_syscall_opendir_ocall(&retval, host_name) != OE_OK) OE_RAISE_ERRNO(OE_EINVAL); - if (retval != 0) - { - dir->base.type = OE_FD_TYPE_FILE; - dir->magic = DIR_MAGIC; - dir->base.ops.file = _get_file_ops(); - dir->host_dir = retval; - } + if (!retval) + OE_RAISE_ERRNO(oe_errno); + + dir->base.type = OE_FD_TYPE_FILE; + dir->magic = DIR_MAGIC; + dir->base.ops.file = _get_file_ops(); + dir->host_dir = retval; ret = &dir->base; dir = NULL; diff --git a/syscall/devices/hostresolver/CMakeLists.txt b/syscall/devices/hostresolver/CMakeLists.txt index 036e70070e..493284943d 100644 --- a/syscall/devices/hostresolver/CMakeLists.txt +++ b/syscall/devices/hostresolver/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oehostresolver STATIC hostresolver.c) diff --git a/syscall/devices/hostresolver/hostresolver.c b/syscall/devices/hostresolver/hostresolver.c index bfff8d7baf..fd6072e4b6 100644 --- a/syscall/devices/hostresolver/hostresolver.c +++ b/syscall/devices/hostresolver/hostresolver.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define _GNU_SOURCE diff --git a/syscall/devices/hostsock/CMakeLists.txt b/syscall/devices/hostsock/CMakeLists.txt index 97adabb5d9..d4873c8861 100644 --- a/syscall/devices/hostsock/CMakeLists.txt +++ b/syscall/devices/hostsock/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oehostsock STATIC hostsock.c) diff --git a/syscall/devices/hostsock/hostsock.c b/syscall/devices/hostsock/hostsock.c index 99e4e60a33..7976ca29cd 100644 --- a/syscall/devices/hostsock/hostsock.c +++ b/syscall/devices/hostsock/hostsock.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define _GNU_SOURCE @@ -261,8 +261,11 @@ static oe_fd_t* _hostsock_accept( oe_host_fd_t retval = -1; if (oe_syscall_accept_ocall( - &retval, sock->host_fd, &buf.addr, addrlen_in, addrlen) != - OE_OK) + &retval, + sock->host_fd, + addr ? &buf.addr : NULL, + addrlen_in, + addrlen) != OE_OK) { OE_RAISE_ERRNO(oe_errno); } @@ -271,6 +274,14 @@ static oe_fd_t* _hostsock_accept( OE_RAISE_ERRNO_MSG(oe_errno, "retval=%d", retval); new_sock->host_fd = retval; + + // copy peer addr to out buffer + if (addrlen) + { + oe_assert(addr); + if (oe_memcpy_s(addr, addrlen_in, &buf.addr, *addrlen) != OE_OK) + OE_RAISE_ERRNO(OE_EINVAL); + } } ret = &new_sock->base; @@ -343,7 +354,7 @@ static ssize_t _hostsock_recv( if (buf) { - if (oe_memset_s(buf, sizeof(count), 0, sizeof(count)) != OE_OK) + if (oe_memset_s(buf, count, 0, count) != OE_OK) OE_RAISE_ERRNO(OE_EINVAL); } diff --git a/syscall/dirent.c b/syscall/dirent.c index ee32ddabae..aae1fa32e7 100644 --- a/syscall/dirent.c +++ b/syscall/dirent.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/epoll.c b/syscall/epoll.c index 57613d722c..28d81b9d91 100644 --- a/syscall/epoll.c +++ b/syscall/epoll.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off diff --git a/syscall/fcntl.c b/syscall/fcntl.c index e6a4f81d5a..e84a2be693 100644 --- a/syscall/fcntl.c +++ b/syscall/fcntl.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/fdtable.c b/syscall/fdtable.c index 96743be314..db6f422185 100644 --- a/syscall/fdtable.c +++ b/syscall/fdtable.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -283,12 +283,14 @@ int oe_fdtable_reassign(int fd, oe_fd_t* new_desc, oe_fd_t** old_desc) int ret = -1; bool locked = false; + if (!new_desc || !old_desc) + OE_RAISE_ERRNO(OE_EINVAL); + #if !defined(NDEBUG) _assert_fd(new_desc); #endif - if (old_desc) - *old_desc = NULL; + *old_desc = NULL; oe_spin_lock(&_lock); locked = true; diff --git a/syscall/ioctl.c b/syscall/ioctl.c index b43bf1eee3..18f6b174ce 100644 --- a/syscall/ioctl.c +++ b/syscall/ioctl.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/iov.c b/syscall/iov.c index 03a7844671..0429ab5f37 100644 --- a/syscall/iov.c +++ b/syscall/iov.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/mount.c b/syscall/mount.c index 5d123568ff..a726e8a4ca 100644 --- a/syscall/mount.c +++ b/syscall/mount.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off @@ -137,7 +137,6 @@ int oe_mount( oe_device_t* device = NULL; oe_device_t* new_device = NULL; bool locked = false; - oe_syscall_path_t source_path; oe_syscall_path_t target_path; mount_point_t mount_point = {0}; @@ -152,14 +151,9 @@ int oe_mount( target = target_path.buf; } - /* Normalize the source path if any. */ - if (source) - { - if (!oe_realpath(source, &source_path)) - OE_RAISE_ERRNO(OE_EINVAL); - - source = source_path.buf; - } + /* Note: Normalization of source path is left to the external device + * as it may not be a path internal to the enclave. + */ /* Resolve the device for the given filesystemtype. */ device = oe_device_table_find(filesystemtype, OE_DEVICE_TYPE_FILE_SYSTEM); @@ -172,7 +166,12 @@ int oe_mount( struct oe_stat buf; int retval = -1; - if ((retval = oe_stat(target, &buf)) != 0) + /** + * oe_stat tries to do a mount resolution, but the directory is not yet + * mounted. As a result, we must call the filesystem's stat + * implementation directly. + */ + if ((retval = device->ops.fs.stat(device, target, &buf)) != 0) OE_RAISE_ERRNO(oe_errno); if (!OE_S_ISDIR(buf.st_mode)) diff --git a/syscall/mount.h b/syscall/mount.h index 53ac193327..b8c242395f 100644 --- a/syscall/mount.h +++ b/syscall/mount.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved._ops +// Copyright (c) Open Enclave SDK contributors._ops // Licensed under the MIT License. #ifndef _OE_SYSCALL_MOUNT_H diff --git a/syscall/netdb.c b/syscall/netdb.c index d8c81c6e95..26d943fdb7 100644 --- a/syscall/netdb.c +++ b/syscall/netdb.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -69,6 +69,8 @@ int oe_getaddrinfo( if (res_out) *res_out = NULL; + else + OE_RAISE_ERRNO(OE_EINVAL); oe_spin_lock(&_lock); locked = true; diff --git a/syscall/poll.c b/syscall/poll.c index fa4172cb08..d99e676391 100644 --- a/syscall/poll.c +++ b/syscall/poll.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/select.c b/syscall/select.c index 9b97f522c6..5e5c6ea7d6 100644 --- a/syscall/select.c +++ b/syscall/select.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/socket.c b/syscall/socket.c index dea108059c..33f0ff5897 100644 --- a/syscall/socket.c +++ b/syscall/socket.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/stat.c b/syscall/stat.c index c9334f02de..7581f1e564 100644 --- a/syscall/stat.c +++ b/syscall/stat.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/stdio.c b/syscall/stdio.c index 0fd2912562..a1defe0f41 100644 --- a/syscall/stdio.c +++ b/syscall/stdio.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/stdlib.c b/syscall/stdlib.c index f600a6c235..636ed957d7 100644 --- a/syscall/stdlib.c +++ b/syscall/stdlib.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/stub.c b/syscall/stub.c index 3a3cb11aa4..167cc0fd15 100644 --- a/syscall/stub.c +++ b/syscall/stub.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/syscall.c b/syscall/syscall.c index 4e228a996b..0c003631ee 100644 --- a/syscall/syscall.c +++ b/syscall/syscall.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/syscall_t_wrapper.c b/syscall/syscall_t_wrapper.c index 9d07779912..f980aca6a3 100644 --- a/syscall/syscall_t_wrapper.c +++ b/syscall/syscall_t_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_NEED_STDC_NAMES diff --git a/syscall/unistd.c b/syscall/unistd.c index cdc5202e70..7b12067281 100644 --- a/syscall/unistd.c +++ b/syscall/unistd.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/syscall/utsname.c b/syscall/utsname.c index 4bdf55ebe0..d90dbd7e4c 100644 --- a/syscall/utsname.c +++ b/syscall/utsname.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 04f5d7fbba..0e37a7930f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) @@ -16,17 +16,18 @@ if (WIN32_SIMULATION) message("WIN32_SIMULATION set, failing tests are skipped") endif () -add_subdirectory(lockless_queue) add_subdirectory(mem) add_subdirectory(safecrt) add_subdirectory(safemath) add_subdirectory(str) +add_subdirectory(logging) add_subdirectory(tools) if (OE_SGX) - add_subdirectory(aesm) add_subdirectory(debugger) add_subdirectory(host_verify) + add_subdirectory(switchless) + add_subdirectory(switchless_threads) endif() if (UNIX OR ADD_WINDOWS_ENCLAVE_TESTS OR USE_CLANGW) @@ -34,8 +35,10 @@ if (UNIX OR ADD_WINDOWS_ENCLAVE_TESTS OR USE_CLANGW) # The following tests currently fail in Windows simulation mode if (NOT WIN32_SIMULATION) add_subdirectory(abortStatus) + add_subdirectory(attestation_plugin) add_subdirectory(cppException) add_subdirectory(ecall) + add_subdirectory(ecall_ocall) add_subdirectory(file) add_subdirectory(mbed) add_subdirectory(ocall-create) @@ -46,6 +49,9 @@ if (UNIX OR ADD_WINDOWS_ENCLAVE_TESTS OR USE_CLANGW) add_subdirectory(thread_local) add_subdirectory(thread_local_no_tdata) endif() + if (BUILD_ENCLAVES) + add_subdirectory(tls_e2e) + endif() add_subdirectory(argv) add_subdirectory(attestation_cert_apis) add_subdirectory(backtrace) @@ -66,6 +72,7 @@ if (UNIX OR ADD_WINDOWS_ENCLAVE_TESTS OR USE_CLANGW) add_subdirectory(stdc) add_subdirectory(syscall) add_subdirectory(VectorException) + add_subdirectory(stack_smashing_protector) endif() add_subdirectory(create-errors) @@ -81,6 +88,7 @@ endif() # Windows test Broken Post #632 issue if ( UNIX ) if (OE_SGX) + add_subdirectory(cmake_name_conflict) add_subdirectory(libcxx) add_subdirectory(libcxxrt) add_subdirectory(memory) @@ -90,11 +98,5 @@ add_subdirectory(libc) endif() if (OE_SGX AND UNIX) - # ecall_ocall enclave size cannot be handled by Windows ninja CI - add_subdirectory(ecall_ocall) add_subdirectory(libunwind) - - # Attestation supported only on Linux - add_subdirectory(tls_e2e) - add_subdirectory(switchless) endif() diff --git a/tests/README.md b/tests/README.md index acdc8444ae..1615ae5afc 100644 --- a/tests/README.md +++ b/tests/README.md @@ -41,11 +41,6 @@ signalling a "did not run" state to ctest (rather than failing). To signal "did not run", such tests should return with an exit code of 2. ctest evaluates this specifically. -# Testing on Windows [Work in progress] - -Refer to [Getting Started on Windows](/docs/GettingStartedDocs/GettingStarted.Windows.md) for -instructions on testing Linux-built enclaves with Windows-built host apps. - # On calls to add_enclave The test enclave targets are added by calling `add_enclave`, a CMake macro diff --git a/tests/SampleApp/CMakeLists.txt b/tests/SampleApp/CMakeLists.txt index b67b0e421d..914a4c89e8 100644 --- a/tests/SampleApp/CMakeLists.txt +++ b/tests/SampleApp/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/SampleApp/SampleApp.edl b/tests/SampleApp/SampleApp.edl index 7fe72934d8..06f60610a5 100644 --- a/tests/SampleApp/SampleApp.edl +++ b/tests/SampleApp/SampleApp.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/SampleApp/enc/CMakeLists.txt b/tests/SampleApp/enc/CMakeLists.txt index e5408accf4..3106bc8761 100644 --- a/tests/SampleApp/enc/CMakeLists.txt +++ b/tests/SampleApp/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # TODO: Does this need CXX? diff --git a/tests/SampleApp/enc/SampleApp.cpp b/tests/SampleApp/enc/SampleApp.cpp index 30ef05f4ad..50456fb8d9 100644 --- a/tests/SampleApp/enc/SampleApp.cpp +++ b/tests/SampleApp/enc/SampleApp.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/SampleApp/host/CMakeLists.txt b/tests/SampleApp/host/CMakeLists.txt index f836b65b12..2e15aec4e1 100644 --- a/tests/SampleApp/host/CMakeLists.txt +++ b/tests/SampleApp/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../SampleApp.edl host gen) diff --git a/tests/SampleApp/host/SampleAppHost.cpp b/tests/SampleApp/host/SampleAppHost.cpp index 80a058fb44..35d45d2639 100644 --- a/tests/SampleApp/host/SampleAppHost.cpp +++ b/tests/SampleApp/host/SampleAppHost.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/SampleAppCRT/CMakeLists.txt b/tests/SampleAppCRT/CMakeLists.txt index 58b9984d92..5f045807d6 100644 --- a/tests/SampleAppCRT/CMakeLists.txt +++ b/tests/SampleAppCRT/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/SampleAppCRT/SampleAppCRT.edl b/tests/SampleAppCRT/SampleAppCRT.edl index b6267f3603..402d9a22f9 100644 --- a/tests/SampleAppCRT/SampleAppCRT.edl +++ b/tests/SampleAppCRT/SampleAppCRT.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/SampleAppCRT/enc/CMakeLists.txt b/tests/SampleAppCRT/enc/CMakeLists.txt index c32b82f6aa..63780d9e0f 100644 --- a/tests/SampleAppCRT/enc/CMakeLists.txt +++ b/tests/SampleAppCRT/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # TODO: Does this need CXX? diff --git a/tests/SampleAppCRT/enc/SampleAppCRT.cpp b/tests/SampleAppCRT/enc/SampleAppCRT.cpp index 08cbaebe90..fe6b87b1a7 100644 --- a/tests/SampleAppCRT/enc/SampleAppCRT.cpp +++ b/tests/SampleAppCRT/enc/SampleAppCRT.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/SampleAppCRT/host/CMakeLists.txt b/tests/SampleAppCRT/host/CMakeLists.txt index 9829a785e1..37f99bba56 100644 --- a/tests/SampleAppCRT/host/CMakeLists.txt +++ b/tests/SampleAppCRT/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../SampleAppCRT.edl host gen) diff --git a/tests/SampleAppCRT/host/SampleAppCRTHost.cpp b/tests/SampleAppCRT/host/SampleAppCRTHost.cpp index 377a39487f..8a0b7ae41b 100644 --- a/tests/SampleAppCRT/host/SampleAppCRTHost.cpp +++ b/tests/SampleAppCRT/host/SampleAppCRTHost.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/VectorException/CMakeLists.txt b/tests/VectorException/CMakeLists.txt index fd8bf39f35..cb7a660288 100644 --- a/tests/VectorException/CMakeLists.txt +++ b/tests/VectorException/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/VectorException/VectorException.edl b/tests/VectorException/VectorException.edl index b3b7af1941..d2556af185 100644 --- a/tests/VectorException/VectorException.edl +++ b/tests/VectorException/VectorException.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/VectorException/enc/CMakeLists.txt b/tests/VectorException/enc/CMakeLists.txt index 905fc54572..d07befa400 100644 --- a/tests/VectorException/enc/CMakeLists.txt +++ b/tests/VectorException/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../VectorException.edl enclave gen) diff --git a/tests/VectorException/enc/enc.c b/tests/VectorException/enc/enc.c index e463a7e9e5..99f942d3f1 100644 --- a/tests/VectorException/enc/enc.c +++ b/tests/VectorException/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/VectorException/enc/init.cpp b/tests/VectorException/enc/init.cpp index 05fe5d8391..0b993d0da8 100644 --- a/tests/VectorException/enc/init.cpp +++ b/tests/VectorException/enc/init.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/VectorException/enc/sigill_handling.c b/tests/VectorException/enc/sigill_handling.c index 47df80921e..74abd78901 100644 --- a/tests/VectorException/enc/sigill_handling.c +++ b/tests/VectorException/enc/sigill_handling.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/tests/VectorException/host/CMakeLists.txt b/tests/VectorException/host/CMakeLists.txt index 56d36c73eb..d82c9fd8ab 100644 --- a/tests/VectorException/host/CMakeLists.txt +++ b/tests/VectorException/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../VectorException.edl host gen) diff --git a/tests/VectorException/host/host.c b/tests/VectorException/host/host.c index 2e7fa011a6..54ace06c1c 100644 --- a/tests/VectorException/host/host.c +++ b/tests/VectorException/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/tests/abortStatus/CMakeLists.txt b/tests/abortStatus/CMakeLists.txt index f3fd781e0b..3e641f0bf1 100644 --- a/tests/abortStatus/CMakeLists.txt +++ b/tests/abortStatus/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/abortStatus/abortStatus.edl b/tests/abortStatus/abortStatus.edl index 3273ff9332..3fb2be1ead 100644 --- a/tests/abortStatus/abortStatus.edl +++ b/tests/abortStatus/abortStatus.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/abortStatus/enc/CMakeLists.txt b/tests/abortStatus/enc/CMakeLists.txt index 5ff7274b40..4294ab98de 100644 --- a/tests/abortStatus/enc/CMakeLists.txt +++ b/tests/abortStatus/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/abortStatus/enc/enc.cpp b/tests/abortStatus/enc/enc.cpp index b448f93496..beda29d2a2 100644 --- a/tests/abortStatus/enc/enc.cpp +++ b/tests/abortStatus/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/abortStatus/host/CMakeLists.txt b/tests/abortStatus/host/CMakeLists.txt index 63d5787076..f4a580d2c8 100644 --- a/tests/abortStatus/host/CMakeLists.txt +++ b/tests/abortStatus/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/abortStatus/host/host.cpp b/tests/abortStatus/host/host.cpp index 09eb95db90..9b6a383e10 100644 --- a/tests/abortStatus/host/host.cpp +++ b/tests/abortStatus/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/aesm/CMakeLists.txt b/tests/aesm/CMakeLists.txt deleted file mode 100644 index 87642a897a..0000000000 --- a/tests/aesm/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -add_executable(aesm main.cpp) -target_link_libraries(aesm oehost) - -# Additional compilation options when using libsgx instead of AESM -if(USE_LIBSGX) -target_compile_definitions(aesm PRIVATE OE_USE_LIBSGX) -endif() -add_test(NAME tests/aesm COMMAND aesm) -set_tests_properties(tests/aesm PROPERTIES SKIP_RETURN_CODE 2) diff --git a/tests/aesm/main.cpp b/tests/aesm/main.cpp deleted file mode 100644 index 6e0c3b684d..0000000000 --- a/tests/aesm/main.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include -#include -#include -#include - -#if defined(OE_USE_LIBSGX) -#include -#else -#include -#endif - -#define SKIP_RETURN_CODE 2 - -int main() -{ - const uint32_t flags = oe_get_create_flags(); - if ((flags & OE_ENCLAVE_FLAG_SIMULATE) != 0) - { - printf("=== Skipped unsupported test in simulation mode " - "(aesm)\n"); - return SKIP_RETURN_CODE; - } - -#if defined(OE_USE_LIBSGX) - quote3_error_t err; - sgx_target_info_t target_info = {}; - if (SGX_QL_SUCCESS != (err = sgx_qe_get_target_info(&target_info))) - { - printf("FAILED: Call returned %x\n", err); - return -1; - } -#else - aesm_t* aesm; - if (!(aesm = aesm_connect())) - { - fprintf(stderr, "aesm: failed to connect\n"); - exit(1); - } - aesm_disconnect(aesm); -#endif - - printf("=== passed all tests (aesm)\n"); - return 0; -} diff --git a/tests/argv/CMakeLists.txt b/tests/argv/CMakeLists.txt index eee6714aa5..ff670509ce 100644 --- a/tests/argv/CMakeLists.txt +++ b/tests/argv/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/argv/argv.edl b/tests/argv/argv.edl index fbd7b1a906..ed2c71b944 100644 --- a/tests/argv/argv.edl +++ b/tests/argv/argv.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave diff --git a/tests/argv/enc/CMakeLists.txt b/tests/argv/enc/CMakeLists.txt index c717c824cb..85f5ee7f11 100644 --- a/tests/argv/enc/CMakeLists.txt +++ b/tests/argv/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/argv/enc/enc.c b/tests/argv/enc/enc.c index 30c7ed1db6..0e0da2c1d8 100644 --- a/tests/argv/enc/enc.c +++ b/tests/argv/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/argv/host/CMakeLists.txt b/tests/argv/host/CMakeLists.txt index e412a011fd..b5429a406d 100644 --- a/tests/argv/host/CMakeLists.txt +++ b/tests/argv/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/argv/host/host.c b/tests/argv/host/host.c index d4961bf553..0c540168b1 100644 --- a/tests/argv/host/host.c +++ b/tests/argv/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/attestation_cert_apis/CMakeLists.txt b/tests/attestation_cert_apis/CMakeLists.txt index d6f0f80dc5..6ca545ab31 100644 --- a/tests/attestation_cert_apis/CMakeLists.txt +++ b/tests/attestation_cert_apis/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/attestation_cert_apis/enc/CMakeLists.txt b/tests/attestation_cert_apis/enc/CMakeLists.txt index 09a52d5660..a7da26510b 100644 --- a/tests/attestation_cert_apis/enc/CMakeLists.txt +++ b/tests/attestation_cert_apis/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) diff --git a/tests/attestation_cert_apis/enc/enc.cpp b/tests/attestation_cert_apis/enc/enc.cpp index 0b9c1d001b..a4182fb2d1 100644 --- a/tests/attestation_cert_apis/enc/enc.cpp +++ b/tests/attestation_cert_apis/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/attestation_cert_apis/host/CMakeLists.txt b/tests/attestation_cert_apis/host/CMakeLists.txt index e465c99eb7..1f904bae72 100644 --- a/tests/attestation_cert_apis/host/CMakeLists.txt +++ b/tests/attestation_cert_apis/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(add_dcap_client_target) diff --git a/tests/attestation_cert_apis/host/host.cpp b/tests/attestation_cert_apis/host/host.cpp index 34a227b9a8..026cd078c8 100644 --- a/tests/attestation_cert_apis/host/host.cpp +++ b/tests/attestation_cert_apis/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -123,7 +123,7 @@ void run_test(oe_enclave_t* enclave, int test_type) int main(int argc, const char* argv[]) { -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL #ifdef _WIN32 /* This is a workaround for running in Visual Studio 2017 Test Explorer @@ -189,11 +189,11 @@ int main(int argc, const char* argv[]) OE_TRACE_INFO("=== passed all tests (tls)\n"); return 0; #else - // this test should not run on any platforms where OE_USE_LIBSGX is not + // this test should not run on any platforms where HAS_QUOTE_PROVIDER is not // defined OE_UNUSED(argc); OE_UNUSED(argv); - OE_TRACE_INFO("=== tests skipped when built with OE_USE_LIBSGX=OFF\n"); + OE_TRACE_INFO("=== tests skipped when built with HAS_QUOTE_PROVIDER=OFF\n"); return SKIP_RETURN_CODE; #endif } diff --git a/tests/attestation_cert_apis/tls.edl b/tests/attestation_cert_apis/tls.edl index 8494af080d..a655645d6d 100644 --- a/tests/attestation_cert_apis/tls.edl +++ b/tests/attestation_cert_apis/tls.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/attestation_plugin/CMakeLists.txt b/tests/attestation_plugin/CMakeLists.txt new file mode 100644 index 0000000000..3f40dc93e5 --- /dev/null +++ b/tests/attestation_plugin/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_subdirectory(host) + +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() + +add_enclave_test(tests/attestation_plugin plugin_host plugin_enc) +set_tests_properties(tests/attestation_plugin PROPERTIES SKIP_RETURN_CODE 2) diff --git a/tests/attestation_plugin/enc/CMakeLists.txt b/tests/attestation_plugin/enc/CMakeLists.txt new file mode 100644 index 0000000000..fd35c4db44 --- /dev/null +++ b/tests/attestation_plugin/enc/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +include(oeedl_file) + +oeedl_file(../plugin.edl enclave gen) + +add_enclave(TARGET plugin_enc UUID 0ed4cfa8-3d98-4ef6-a8e6-b3120517ccac SOURCES enc.c ../plugin/tests.c ${gen}) + +target_include_directories(plugin_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(plugin_enc oeenclave oelibc) diff --git a/tests/attestation_plugin/enc/enc.c b/tests/attestation_plugin/enc/enc.c new file mode 100644 index 0000000000..c230c5d657 --- /dev/null +++ b/tests/attestation_plugin/enc/enc.c @@ -0,0 +1,203 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../../common/sgx/quote.h" +#include "../plugin/tests.h" +#include "plugin_t.h" + +oe_attester_t* sgx_attest = NULL; + +void run_runtime_test() +{ + test_runtime(); +} + +void register_sgx() +{ + printf("====== running register_sgx\n"); + + sgx_attest = oe_sgx_plugin_attester(); + OE_TEST(oe_register_attester(sgx_attest, NULL, 0) == OE_OK); + register_verifier(); +} + +void unregister_sgx() +{ + printf("====== running unregister_sgx\n"); + + OE_TEST(oe_unregister_attester(sgx_attest) == OE_OK); + sgx_attest = NULL; + unregister_verifier(); +} + +static void _test_sgx_remote() +{ + printf("====== running _test_sgx_remote\n"); + uint8_t* evidence = NULL; + size_t evidence_size = 0; + uint8_t* endorsements = NULL; + size_t endorsements_size = 0; + + // Get a remote attestation report. + printf("====== running _test_sgx_remote #1: Just evidence\n"); + OE_TEST( + oe_get_evidence( + &sgx_attest->base.format_id, + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + NULL, + 0, + NULL, + 0, + &evidence, + &evidence_size, + NULL, + 0) == OE_OK); + + verify_sgx_evidence(evidence, evidence_size, NULL, 0, NULL, 0, false); + + OE_TEST(oe_free_evidence(evidence) == OE_OK); + + // Get a remote report with endorsements. + printf("====== running _test_sgx_remote #2: + Endorsements\n"); + OE_TEST( + oe_get_evidence( + &sgx_attest->base.format_id, + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + NULL, + 0, + NULL, + 0, + &evidence, + &evidence_size, + &endorsements, + &endorsements_size) == OE_OK); + + verify_sgx_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + NULL, + 0, + false); + + OE_TEST(oe_free_evidence(evidence) == OE_OK); + OE_TEST(oe_free_endorsements(endorsements) == OE_OK); + + // Get a remote report with both. + printf("====== running _test_sgx_remote #3: + Claims\n"); + OE_TEST( + oe_get_evidence( + &sgx_attest->base.format_id, + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + test_claims, + NUM_TEST_CLAIMS, + NULL, + 0, + &evidence, + &evidence_size, + &endorsements, + &endorsements_size) == OE_OK); + + verify_sgx_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + test_claims, + NUM_TEST_CLAIMS, + false); + + OE_TEST( + host_verify(evidence, evidence_size, endorsements, endorsements_size) == + OE_OK); + + OE_TEST(oe_free_evidence(evidence) == OE_OK); + OE_TEST(oe_free_endorsements(endorsements) == OE_OK); +} + +static void _test_sgx_local() +{ + uint8_t* report = NULL; + size_t report_size = 0; + void* target = NULL; + size_t target_size = 0; + uint8_t* evidence = NULL; + size_t evidence_size = 0; + + printf("====== running _test_sgx_local\n"); + printf("====== running _test_sgx_local #0: Getting target info.\n"); + OE_TEST(oe_get_report(0, NULL, 0, NULL, 0, &report, &report_size) == OE_OK); + + OE_TEST( + oe_get_target_info(report, report_size, &target, &target_size) == + OE_OK); + + oe_free_report(report); + + // Only evidence. + printf("====== running _test_sgx_local #1: Just evidence\n"); + OE_TEST( + oe_get_evidence( + &sgx_attest->base.format_id, + 0, + NULL, + 0, + target, + target_size, + &evidence, + &evidence_size, + NULL, + 0) == OE_OK); + + verify_sgx_evidence(evidence, evidence_size, NULL, 0, NULL, 0, true); + + OE_TEST(oe_free_evidence(evidence) == OE_OK); + + // Evidence + claims. + printf("====== running _test_sgx_local #2: + Claims\n"); + OE_TEST( + oe_get_evidence( + &sgx_attest->base.format_id, + 0, + test_claims, + NUM_TEST_CLAIMS, + target, + target_size, + &evidence, + &evidence_size, + NULL, + 0) == OE_OK); + + verify_sgx_evidence( + evidence, evidence_size, NULL, 0, test_claims, NUM_TEST_CLAIMS, true); + + OE_TEST(oe_free_evidence(evidence) == OE_OK); + oe_free_target_info(target); +} + +void test_sgx() +{ + printf("====== running test_sgx\n"); + + _test_sgx_remote(); + _test_sgx_local(); +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 128, /* HeapPageCount */ + 128, /* StackPageCount */ + 1); /* TCSCount */ diff --git a/tests/attestation_plugin/host/CMakeLists.txt b/tests/attestation_plugin/host/CMakeLists.txt new file mode 100644 index 0000000000..e8aafd7e05 --- /dev/null +++ b/tests/attestation_plugin/host/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +include(oeedl_file) + +oeedl_file(../plugin.edl host gen) + +add_executable(plugin_host host.c ../plugin/tests.c ${gen}) + +target_include_directories(plugin_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(plugin_host oehostapp) \ No newline at end of file diff --git a/tests/attestation_plugin/host/host.c b/tests/attestation_plugin/host/host.c new file mode 100644 index 0000000000..bcce7efd6d --- /dev/null +++ b/tests/attestation_plugin/host/host.c @@ -0,0 +1,121 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include + +#if defined(_WIN32) +#include +#include +#endif + +#include "../../../host/sgx/quote.h" +#include "../plugin/tests.h" +#include "plugin_u.h" + +#define SKIP_RETURN_CODE 2 + +void host_verify( + uint8_t* evidence, + size_t evidence_size, + uint8_t* endorsements, + size_t endorsements_size) +{ + printf("====== running host_verify.\n"); + verify_sgx_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + test_claims, + NUM_TEST_CLAIMS, + false); +} + +int main(int argc, const char* argv[]) +{ +#ifdef OE_LINK_SGX_DCAP_QL + +#ifdef _WIN32 + /* This is a workaround for running in Visual Studio 2017 Test Explorer + * where the environment variables are not correctly propagated to the + * test. This is resolved in Visual Studio 2019 */ + WCHAR path[_MAX_PATH]; + + if (!GetEnvironmentVariableW(L"SystemRoot", path, _MAX_PATH)) + { + if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) + exit(1); + + UINT path_length = GetSystemWindowsDirectoryW(path, _MAX_PATH); + if (path_length == 0 || path_length > _MAX_PATH) + exit(1); + + if (SetEnvironmentVariableW(L"SystemRoot", path) == 0) + exit(1); + } + + if (!GetEnvironmentVariableW(L"LOCALAPPDATA", path, _MAX_PATH)) + { + if (GetLastError() != ERROR_ENVVAR_NOT_FOUND) + exit(1); + + WCHAR* local_path = NULL; + if (SHGetKnownFolderPath( + &FOLDERID_LocalAppData, 0, NULL, &local_path) != S_OK) + { + exit(1); + } + + BOOL success = SetEnvironmentVariableW(L"LOCALAPPDATA", local_path); + CoTaskMemFree(local_path); + + if (!success) + exit(1); + } +#endif + + oe_result_t result; + oe_enclave_t* enclave = NULL; + + if (argc != 2) + { + fprintf(stderr, "Usage: %s ENCLAVE\n", argv[0]); + exit(1); + } + + // Skip in simulation mode. + const uint32_t flags = oe_get_create_flags(); + if ((flags & OE_ENCLAVE_FLAG_SIMULATE) != 0) + return SKIP_RETURN_CODE; + + // Register the host verifier. + register_verifier(); + + // Run all enclave tests. + result = oe_create_plugin_enclave( + argv[1], OE_ENCLAVE_TYPE_AUTO, flags, NULL, 0, &enclave); + OE_TEST(result == OE_OK); + + run_runtime_test(enclave); + register_sgx(enclave); + test_sgx(enclave); + unregister_sgx(enclave); + OE_TEST(oe_terminate_enclave(enclave) == OE_OK); + + // Run runtime test on the host. + test_runtime(); + + // Unregister verifier. + unregister_verifier(); + return 0; +#else + // This test should not run on any platforms where HAS_QUOTE_PROVIDER is not + // defined. + OE_UNUSED(argc); + OE_UNUSED(argv); + printf("=== tests skipped when built with HAS_QUOTE_PROVIDER=OFF\n"); + return SKIP_RETURN_CODE; +#endif +} diff --git a/tests/attestation_plugin/plugin.edl b/tests/attestation_plugin/plugin.edl new file mode 100644 index 0000000000..d77448dd61 --- /dev/null +++ b/tests/attestation_plugin/plugin.edl @@ -0,0 +1,20 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + + trusted { + public void run_runtime_test(); + public void register_sgx(); + public void unregister_sgx(); + public void test_sgx(); + }; + + untrusted { + void host_verify( + [in, size=evidence_size] uint8_t* evidence, + size_t evidence_size, + [in, size=endorsements_size] uint8_t* endorsements, + size_t endorsements_size); + }; +}; diff --git a/tests/attestation_plugin/plugin/mock_attester.h b/tests/attestation_plugin/plugin/mock_attester.h new file mode 100644 index 0000000000..a02a3a1744 --- /dev/null +++ b/tests/attestation_plugin/plugin/mock_attester.h @@ -0,0 +1,245 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +// This file provides a dummy implementation of an attester plugin and a +// verifier plugin in order to test the OE plugin management runtime +// implementation. It essentially tests that plugins are being registered +// correctly and can get/verify evidence based of the right UUID. + +#ifndef _OE_MOCK_ATTESTER_H +#define _OE_MOCK_ATTESTER_H + +#include +#include + +#define MOCK_EVIDENCE "123" +#define MOCK_ENDORSEMENTS "456" + +#define OE_MOCK_ATTESTER_UUID1 \ + { \ + 0x17, 0x04, 0x94, 0xa6, 0xab, 0x23, 0x47, 0x98, 0x8c, 0x38, 0x35, \ + 0x1c, 0xb0, 0xb6, 0xaf, 0x09 \ + } + +#define OE_MOCK_ATTESTER_UUID2 \ + { \ + 0x15, 0x6a, 0x29, 0x71, 0x27, 0xee, 0x41, 0xf1, 0x9b, 0x90, 0xff, \ + 0xc7, 0xc6, 0x52, 0x68, 0xf1 \ + } + +static inline oe_result_t mock_attester_register( + oe_attestation_role_t* context, + const void* config_data, + size_t config_data_size) +{ + OE_UNUSED(context); + OE_UNUSED(config_data); + OE_UNUSED(config_data_size); + return OE_OK; +} + +static inline oe_result_t mock_attester_unregister( + oe_attestation_role_t* context) +{ + OE_UNUSED(context); + return OE_OK; +} + +static inline oe_result_t mock_get_evidence( + oe_attester_t* context, + uint32_t flags, + const oe_claim_t* custom_claims, + size_t custom_claims_length, + const void* opt_params, + size_t opt_params_size, + uint8_t** evidence_buffer, + size_t* evidence_buffer_size, + uint8_t** endorsements_buffer, + size_t* endorsements_buffer_size) +{ + OE_UNUSED(context); + OE_UNUSED(flags); + OE_UNUSED(custom_claims); + OE_UNUSED(custom_claims_length); + OE_UNUSED(opt_params); + OE_UNUSED(opt_params_size); + *evidence_buffer = (uint8_t*)MOCK_EVIDENCE; + *evidence_buffer_size = sizeof(MOCK_EVIDENCE); + if (endorsements_buffer) + { + *endorsements_buffer = (uint8_t*)MOCK_ENDORSEMENTS; + *endorsements_buffer_size = sizeof(MOCK_ENDORSEMENTS); + } + return OE_OK; +} + +static inline oe_result_t mock_free_evidence( + oe_attester_t* context, + uint8_t* evidence_buffer) +{ + OE_UNUSED(context); + OE_UNUSED(evidence_buffer); + return OE_OK; +} + +static inline oe_result_t mock_free_endorsements( + oe_attester_t* context, + uint8_t* endorsements_buffer) +{ + OE_UNUSED(context); + OE_UNUSED(endorsements_buffer); + return OE_OK; +} + +static inline oe_result_t mock_verify_evidence( + oe_verifier_t* context, + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length) +{ + OE_UNUSED(context); + OE_UNUSED(policies); + OE_UNUSED(policies_size); + + if (evidence_buffer_size != sizeof(MOCK_EVIDENCE)) + return OE_VERIFY_FAILED; + + if (strcmp(MOCK_EVIDENCE, (const char*)evidence_buffer) != 0) + return OE_VERIFY_FAILED; + + if (endorsements_buffer) + { + if (endorsements_buffer_size != sizeof(MOCK_ENDORSEMENTS)) + return OE_VERIFY_FAILED; + + if (strcmp(MOCK_ENDORSEMENTS, (const char*)endorsements_buffer) != 0) + return OE_VERIFY_FAILED; + } + + *claims = + (oe_claim_t*)malloc(OE_REQUIRED_CLAIMS_COUNT * sizeof(oe_claim_t)); + if (*claims == NULL) + return OE_OUT_OF_MEMORY; + + for (int i = 0; i < OE_REQUIRED_CLAIMS_COUNT; i++) + { + (*claims)[i].name = (char*)(OE_REQUIRED_CLAIMS[i]); + if (strcmp(OE_REQUIRED_CLAIMS[i], OE_CLAIM_PLUGIN_UUID) == 0) + { + (*claims)[i].value = (uint8_t*)&context->base.format_id; + (*claims)[i].value_size = sizeof(oe_uuid_t); + } + } + *claims_length = OE_REQUIRED_CLAIMS_COUNT; + + return OE_OK; +} + +static inline oe_result_t mock_verify_evidence_bad( + oe_verifier_t* context, + const uint8_t* evidence_buffer, + size_t evidence_buffer_size, + const uint8_t* endorsements_buffer, + size_t endorsements_buffer_size, + const oe_policy_t* policies, + size_t policies_size, + oe_claim_t** claims, + size_t* claims_length) +{ + OE_UNUSED(context); + OE_UNUSED(evidence_buffer); + OE_UNUSED(evidence_buffer_size); + OE_UNUSED(endorsements_buffer); + OE_UNUSED(endorsements_buffer_size); + OE_UNUSED(policies); + OE_UNUSED(policies_size); + + *claims = (oe_claim_t*)malloc( + (OE_REQUIRED_CLAIMS_COUNT - 1) * sizeof(oe_claim_t)); + if (*claims == NULL) + return OE_OUT_OF_MEMORY; + + for (int i = 0; i < OE_REQUIRED_CLAIMS_COUNT - 1; i++) + { + (*claims)[i].name = (char*)(OE_REQUIRED_CLAIMS[i]); + if (strcmp(OE_REQUIRED_CLAIMS[i], OE_CLAIM_PLUGIN_UUID) == 0) + { + (*claims)[i].value = (uint8_t*)&context->base.format_id; + (*claims)[i].value_size = sizeof(oe_uuid_t); + } + } + *claims_length = OE_REQUIRED_CLAIMS_COUNT - 1; + + return OE_OK; +} + +static inline oe_result_t mock_free_claims_list( + oe_verifier_t* context, + oe_claim_t* claims, + size_t claims_length) +{ + OE_UNUSED(context); + OE_UNUSED(claims_length); + free(claims); + return OE_OK; +} + +static oe_attester_t mock_attester1 = { + .base = + { + .format_id = {OE_MOCK_ATTESTER_UUID1}, + .on_register = &mock_attester_register, + .on_unregister = &mock_attester_unregister, + }, + .get_evidence = &mock_get_evidence, + .free_evidence = &mock_free_evidence, + .free_endorsements = &mock_free_endorsements}; + +static oe_verifier_t mock_verifier1 = { + .base = + { + .format_id = {OE_MOCK_ATTESTER_UUID1}, + .on_register = &mock_attester_register, + .on_unregister = &mock_attester_unregister, + }, + .verify_evidence = &mock_verify_evidence, + .free_claims_list = &mock_free_claims_list}; + +// Same implementation but different UUID. +static oe_attester_t mock_attester2 = { + .base = + { + .format_id = {OE_MOCK_ATTESTER_UUID2}, + .on_register = &mock_attester_register, + .on_unregister = &mock_attester_unregister, + }, + .get_evidence = &mock_get_evidence, + .free_evidence = &mock_free_evidence, + .free_endorsements = &mock_free_endorsements}; + +static oe_verifier_t mock_verifier2 = { + .base = + { + .format_id = {OE_MOCK_ATTESTER_UUID2}, + .on_register = &mock_attester_register, + .on_unregister = &mock_attester_unregister, + }, + .verify_evidence = &mock_verify_evidence, + .free_claims_list = &mock_free_claims_list}; + +static oe_verifier_t bad_verifier = { + .base = + { + .format_id = {OE_MOCK_ATTESTER_UUID1}, + .on_register = &mock_attester_register, + .on_unregister = &mock_attester_unregister, + }, + .verify_evidence = &mock_verify_evidence_bad, + .free_claims_list = &mock_free_claims_list}; + +#endif /* _OE_MOCK_ATTESTER_H */ \ No newline at end of file diff --git a/tests/attestation_plugin/plugin/tests.c b/tests/attestation_plugin/plugin/tests.c new file mode 100644 index 0000000000..6aa419d0b7 --- /dev/null +++ b/tests/attestation_plugin/plugin/tests.c @@ -0,0 +1,594 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifdef OE_BUILD_ENCLAVE +#include +#else +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../../common/sgx/quote.h" +#include "mock_attester.h" +#include "tests.h" + +oe_verifier_t* sgx_verify = NULL; + +typedef struct _header +{ + uint32_t version; + oe_uuid_t format_id; + uint64_t data_size; + uint8_t data[]; +} header_t; + +oe_claim_t test_claims[2] = {{.name = CLAIM1_NAME, + .value = (uint8_t*)CLAIM1_VALUE, + .value_size = sizeof(CLAIM1_VALUE)}, + {.name = CLAIM2_NAME, + .value = (uint8_t*)CLAIM2_VALUE, + .value_size = sizeof(CLAIM2_VALUE)}}; + +static bool _check_claims(const oe_claim_t* claims, size_t claims_length) +{ + for (size_t i = 0; i < OE_REQUIRED_CLAIMS_COUNT; i++) + { + bool found = false; + + for (size_t j = 0; j < claims_length && !found; j++) + { + if (strcmp(OE_REQUIRED_CLAIMS[i], claims[j].name) == 0) + { + found = true; + } + } + + if (!found) + return false; + } + return true; +} + +static void _test_and_register_attester() +{ + printf("====== running _test_and_register_attester\n"); + OE_TEST(oe_register_attester(&mock_attester1, NULL, 0) == OE_OK); + OE_TEST( + oe_register_attester(&mock_attester1, NULL, 0) == OE_ALREADY_EXISTS); + OE_TEST(oe_register_attester(&mock_attester2, NULL, 0) == OE_OK); + OE_TEST( + oe_register_attester(&mock_attester1, NULL, 0) == OE_ALREADY_EXISTS); + OE_TEST( + oe_register_attester(&mock_attester2, NULL, 0) == OE_ALREADY_EXISTS); +} + +static void _test_and_register_verifier() +{ + printf("====== running _test_and_register_verifier\n"); + OE_TEST(oe_register_verifier(&mock_verifier1, NULL, 0) == OE_OK); + OE_TEST( + oe_register_verifier(&mock_verifier1, NULL, 0) == OE_ALREADY_EXISTS); + OE_TEST(oe_register_verifier(&mock_verifier2, NULL, 0) == OE_OK); + OE_TEST( + oe_register_verifier(&mock_verifier1, NULL, 0) == OE_ALREADY_EXISTS); + OE_TEST( + oe_register_verifier(&mock_verifier2, NULL, 0) == OE_ALREADY_EXISTS); +} + +static void _test_and_unregister_attester() +{ + printf("====== running _test_and_unregister_attester\n"); + OE_TEST(oe_unregister_attester(&mock_attester1) == OE_OK); + OE_TEST(oe_unregister_attester(&mock_attester1) == OE_NOT_FOUND); + OE_TEST(oe_unregister_attester(&mock_attester2) == OE_OK); + OE_TEST(oe_unregister_attester(&mock_attester1) == OE_NOT_FOUND); + OE_TEST(oe_unregister_attester(&mock_attester2) == OE_NOT_FOUND); +} + +static void _test_and_unregister_verifier() +{ + printf("====== running _test_and_unregister_verifier\n"); + OE_TEST(oe_unregister_verifier(&mock_verifier1) == OE_OK); + OE_TEST(oe_unregister_verifier(&mock_verifier1) == OE_NOT_FOUND); + OE_TEST(oe_unregister_verifier(&mock_verifier2) == OE_OK); + OE_TEST(oe_unregister_verifier(&mock_verifier1) == OE_NOT_FOUND); + OE_TEST(oe_unregister_verifier(&mock_verifier2) == OE_NOT_FOUND); +} + +static void _test_evidence_success( + const oe_uuid_t* format_id, + bool use_endorsements) +{ + printf("====== running _test_evidence_success\n"); + + uint8_t* evidence = NULL; + size_t evidence_size = 0; + uint8_t* endorsements = NULL; + size_t endorsements_size = 0; + oe_claim_t* claims = NULL; + size_t claims_length = 0; + + OE_TEST( + oe_get_evidence( + format_id, + 0, + NULL, + 0, + NULL, + 0, + &evidence, + &evidence_size, + use_endorsements ? &endorsements : NULL, + use_endorsements ? &endorsements_size : NULL) == OE_OK); + + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + NULL, + 0, + &claims, + &claims_length) == OE_OK); + + OE_TEST(_check_claims(claims, claims_length)); + + OE_TEST(oe_free_evidence(evidence) == OE_OK); + OE_TEST(oe_free_endorsements(endorsements) == OE_OK); + OE_TEST(oe_free_claims_list(claims, claims_length) == OE_OK); +} + +static void _test_get_evidence_fail() +{ + printf("====== running _test_get_evidence_fail\n"); + + uint8_t* evidence; + size_t evidence_size; + + // Test get_evidence when plugin is unregistered. + OE_TEST(oe_unregister_attester(&mock_attester1) == OE_OK); + + OE_TEST( + oe_get_evidence( + &mock_attester1.base.format_id, + 0, + NULL, + 0, + NULL, + 0, + &evidence, + &evidence_size, + NULL, + NULL) == OE_NOT_FOUND); + + OE_TEST(oe_register_attester(&mock_attester1, NULL, 0) == OE_OK); +} + +static void _test_verify_evidence_fail() +{ + printf("====== running _test_verify_evidence_fail\n"); + + uint8_t* evidence; + size_t evidence_size; + uint8_t* endorsements; + size_t endorsements_size; + oe_claim_t* claims; + size_t claims_length; + + OE_TEST( + oe_get_evidence( + &mock_attester1.base.format_id, + 0, + NULL, + 0, + NULL, + 0, + &evidence, + &evidence_size, + &endorsements, + &endorsements_size) == OE_OK); + + // Test verify_evidence with wrong sizes + OE_TEST( + oe_verify_evidence( + evidence, + 0, + endorsements, + endorsements_size, + NULL, + 0, + &claims, + &claims_length) == OE_INVALID_PARAMETER); + + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + 0, + NULL, + 0, + &claims, + &claims_length) == OE_INVALID_PARAMETER); + + // Test verify evidence when plugin is unregistered + OE_TEST(oe_unregister_verifier(&mock_verifier1) == OE_OK); + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + NULL, + 0, + &claims, + &claims_length) == OE_NOT_FOUND); + OE_TEST(oe_register_verifier(&mock_verifier1, NULL, 0) == OE_OK); + + // Test verify when evidence / endorsement id don't match + uint8_t* evidence2; + size_t evidence2_size; + uint8_t* endorsements2; + size_t endorsements2_size; + oe_claim_t* claims2; + size_t claims2_length; + + OE_TEST( + oe_get_evidence( + &mock_attester2.base.format_id, + 0, + NULL, + 0, + NULL, + 0, + &evidence2, + &evidence2_size, + &endorsements2, + &endorsements2_size) == OE_OK); + + OE_TEST( + oe_verify_evidence( + evidence2, + evidence2_size, + endorsements, + endorsements_size, + NULL, + 0, + &claims2, + &claims2_length) == OE_CONSTRAINT_FAILED); + + OE_TEST(oe_free_evidence(evidence2) == OE_OK); + OE_TEST(oe_free_endorsements(endorsements2) == OE_OK); + + // Test faulty verifier when they don't have the right claims. + OE_TEST(oe_unregister_verifier(&mock_verifier1) == OE_OK); + OE_TEST(oe_register_verifier(&bad_verifier, NULL, 0) == OE_OK); + + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + NULL, + 0, + &claims, + &claims_length) == OE_CONSTRAINT_FAILED); + + OE_TEST(oe_unregister_verifier(&bad_verifier) == OE_OK); + OE_TEST(oe_register_verifier(&mock_verifier1, NULL, 0) == OE_OK); + OE_TEST(oe_free_evidence(evidence) == OE_OK); + OE_TEST(oe_free_endorsements(endorsements) == OE_OK); +} + +void test_runtime() +{ + printf("====== running test_runtime\n"); + + // Test register functions. + _test_and_register_attester(); + _test_and_register_verifier(); + + // Test get evidence + verify evidence with the proper claims. + // Should work with and without endorsements. + _test_evidence_success(&mock_attester1.base.format_id, true); + _test_evidence_success(&mock_attester2.base.format_id, true); + _test_evidence_success(&mock_attester1.base.format_id, false); + _test_evidence_success(&mock_attester2.base.format_id, false); + + // Test failures. + _test_get_evidence_fail(); + _test_verify_evidence_fail(); + + // Test unregister functions + _test_and_unregister_attester(); + _test_and_unregister_verifier(); +} + +void register_verifier() +{ + sgx_verify = oe_sgx_plugin_verifier(); + OE_TEST(oe_register_verifier(sgx_verify, NULL, 0) == OE_OK); +} + +void unregister_verifier() +{ + OE_TEST(oe_unregister_verifier(sgx_verify) == OE_OK); + sgx_verify = NULL; +} + +static void* _find_claim( + const oe_claim_t* claims, + size_t claims_size, + const char* name) +{ + for (size_t i = 0; i < claims_size; i++) + { + if (strcmp(claims[i].name, name) == 0) + return claims[i].value; + } + return NULL; +} + +static void _test_time( + const uint8_t* report, + const uint8_t* collaterals, + size_t collaterals_size, + oe_datetime_t* from, + oe_datetime_t* until) +{ + oe_datetime_t tmp; + oe_report_header_t* header = (oe_report_header_t*)report; + + OE_TEST( + oe_verify_sgx_quote( + header->report, + header->report_size, + collaterals, + collaterals_size, + from) == OE_OK); + + OE_TEST( + oe_verify_sgx_quote( + header->report, + header->report_size, + collaterals, + collaterals_size, + until) == OE_OK); + + tmp = *from; + tmp.year--; + OE_TEST( + oe_verify_sgx_quote( + header->report, + header->report_size, + collaterals, + collaterals_size, + &tmp) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); + + tmp = *until; + tmp.year++; + OE_TEST( + oe_verify_sgx_quote( + header->report, + header->report_size, + collaterals, + collaterals_size, + &tmp) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); +} + +static void _test_time_policy( + const uint8_t* evidence, + size_t evidence_size, + const uint8_t* endorsements, + size_t endorsements_size, + oe_datetime_t* from, + oe_datetime_t* until) +{ + oe_policy_t policy; + oe_datetime_t dt; + oe_claim_t* claims; + size_t claims_size; + + policy.type = OE_POLICY_ENDORSEMENTS_TIME; + policy.policy = (void*)&dt; + policy.policy_size = sizeof(dt); + + dt = *from; + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + &policy, + 1, + &claims, + &claims_size) == OE_OK); + OE_TEST(oe_free_claims_list(claims, claims_size) == OE_OK); + + dt = *until; + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + &policy, + 1, + &claims, + &claims_size) == OE_OK); + OE_TEST(oe_free_claims_list(claims, claims_size) == OE_OK); + + dt = *from; + dt.year--; + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + &policy, + 1, + &claims, + &claims_size) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); + + dt = *until; + dt.year++; + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + &policy, + 1, + &claims, + &claims_size) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); +} + +void verify_sgx_evidence( + const uint8_t* evidence, + size_t evidence_size, + const uint8_t* endorsements, + size_t endorsements_size, + const oe_claim_t* custom_claims, + size_t custom_claims_size, + bool is_local) +{ + printf("====== running verify_sgx_evidence\n"); + + header_t* header = (header_t*)evidence; + header_t* header_endorsements = (header_t*)endorsements; + oe_report_t report; + oe_claim_t* claims = NULL; + size_t claims_size = 0; + size_t extra_size = 0; + void* value; + void* from; + void* until; + + // Try with no policies. + OE_TEST( + oe_verify_evidence( + evidence, + evidence_size, + endorsements, + endorsements_size, + NULL, + 0, + &claims, + &claims_size) == OE_OK); + + // Make sure that the identity info matches with the regular oe report. + // We need to remove the attestation header and the claims first. + extra_size = sizeof(oe_sgx_plugin_claims_header_t); + for (size_t i = 0; i < custom_claims_size; i++) + { + extra_size += sizeof(oe_sgx_plugin_claims_entry_t); + extra_size += strlen(custom_claims[i].name) + 1; + extra_size += custom_claims[i].value_size; + } + + OE_TEST( + oe_parse_report( + header->data, header->data_size - extra_size, &report) == OE_OK); + + // Check id version. + value = _find_claim(claims, claims_size, OE_CLAIM_ID_VERSION); + OE_TEST(value != NULL && *((uint32_t*)value) == report.identity.id_version); + + // Check security version. + value = _find_claim(claims, claims_size, OE_CLAIM_SECURITY_VERSION); + OE_TEST( + value != NULL && + *((uint32_t*)value) == report.identity.security_version); + + // Check attributes + value = _find_claim(claims, claims_size, OE_CLAIM_ATTRIBUTES); + OE_TEST(value != NULL && *((uint64_t*)value) == report.identity.attributes); + + // Check unique ID + value = _find_claim(claims, claims_size, OE_CLAIM_UNIQUE_ID); + OE_TEST( + value != NULL && memcmp( + value, + &report.identity.unique_id, + sizeof(report.identity.unique_id)) == 0); + + // Check signer ID + value = _find_claim(claims, claims_size, OE_CLAIM_SIGNER_ID); + OE_TEST( + value != NULL && memcmp( + value, + &report.identity.signer_id, + sizeof(report.identity.signer_id)) == 0); + + // Check product ID + value = _find_claim(claims, claims_size, OE_CLAIM_PRODUCT_ID); + OE_TEST( + value != NULL && memcmp( + value, + &report.identity.product_id, + sizeof(report.identity.product_id)) == 0); + + // Check UUID. + value = _find_claim(claims, claims_size, OE_CLAIM_PLUGIN_UUID); + OE_TEST( + value != NULL && memcmp( + value, + &sgx_verify->base.format_id, + sizeof(sgx_verify->base.format_id)) == 0); + + // Check date time. + from = _find_claim(claims, claims_size, OE_CLAIM_VALIDITY_FROM); + OE_TEST(is_local || from != NULL); + + until = _find_claim(claims, claims_size, OE_CLAIM_VALIDITY_UNTIL); + OE_TEST(is_local || until != NULL); + + if (!is_local && endorsements) + { + _test_time( + header->data, + endorsements ? header_endorsements->data : NULL, + endorsements ? header_endorsements->data_size : 0, + (oe_datetime_t*)from, + (oe_datetime_t*)until); + + _test_time_policy( + evidence, + evidence_size, + endorsements, + endorsements_size, + (oe_datetime_t*)from, + (oe_datetime_t*)until); + } + + // Check custom claims. + if (custom_claims) + { + for (size_t i = 0; i < custom_claims_size; i++) + { + value = _find_claim(claims, claims_size, custom_claims[i].name); + OE_TEST( + value != NULL && memcmp( + custom_claims[i].value, + value, + custom_claims[i].value_size) == 0); + } + } + + OE_TEST(oe_free_claims_list(claims, claims_size) == OE_OK); +} \ No newline at end of file diff --git a/tests/attestation_plugin/plugin/tests.h b/tests/attestation_plugin/plugin/tests.h new file mode 100644 index 0000000000..ed2afd6b80 --- /dev/null +++ b/tests/attestation_plugin/plugin/tests.h @@ -0,0 +1,32 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _OE_ATTESTATION_PLUGIN_TESTS +#define _OE_ATTESTATION_PLUGIN_TESTS + +#include + +#define CLAIM1_NAME "Hello" +#define CLAIM1_VALUE "World!" +#define CLAIM2_NAME "123" +#define CLAIM2_VALUE "456" + +#define NUM_TEST_CLAIMS 2 +extern oe_claim_t test_claims[2]; + +void test_runtime(); + +void register_verifier(); + +void unregister_verifier(); + +void verify_sgx_evidence( + const uint8_t* evidence, + size_t evidence_size, + const uint8_t* endorsements, + size_t endorsements_size, + const oe_claim_t* custom_claims, + size_t custom_claims_size, + bool is_local); + +#endif // _OE_ATTESTATION_PLUGIN_TESTS \ No newline at end of file diff --git a/tests/backtrace/CMakeLists.txt b/tests/backtrace/CMakeLists.txt index 3ed44092ab..0159031f6d 100644 --- a/tests/backtrace/CMakeLists.txt +++ b/tests/backtrace/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/backtrace/backtrace.edl b/tests/backtrace/backtrace.edl index 82ae6db9b9..cf619b2ce9 100644 --- a/tests/backtrace/backtrace.edl +++ b/tests/backtrace/backtrace.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/backtrace/enc/CMakeLists.txt b/tests/backtrace/enc/CMakeLists.txt index 3f03a0528a..348662ae3b 100644 --- a/tests/backtrace/enc/CMakeLists.txt +++ b/tests/backtrace/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/backtrace/enc/enc.cpp b/tests/backtrace/enc/enc.cpp index dd85772400..c93d0fda33 100644 --- a/tests/backtrace/enc/enc.cpp +++ b/tests/backtrace/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/backtrace/host/CMakeLists.txt b/tests/backtrace/host/CMakeLists.txt index 765bfc1344..caa7c4b5e9 100644 --- a/tests/backtrace/host/CMakeLists.txt +++ b/tests/backtrace/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/backtrace/host/host.cpp b/tests/backtrace/host/host.cpp index 077e1aef1f..133dc30a70 100644 --- a/tests/backtrace/host/host.cpp +++ b/tests/backtrace/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/bigmalloc/CMakeLists.txt b/tests/bigmalloc/CMakeLists.txt index d7d9ee1669..e942b219f7 100644 --- a/tests/bigmalloc/CMakeLists.txt +++ b/tests/bigmalloc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/bigmalloc/bigmalloc.edl b/tests/bigmalloc/bigmalloc.edl index 84f6f1c99e..2783f4dea6 100644 --- a/tests/bigmalloc/bigmalloc.edl +++ b/tests/bigmalloc/bigmalloc.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/bigmalloc/enc/CMakeLists.txt b/tests/bigmalloc/enc/CMakeLists.txt index bf59a9f0ef..1ffe515c35 100644 --- a/tests/bigmalloc/enc/CMakeLists.txt +++ b/tests/bigmalloc/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/bigmalloc/enc/enc.c b/tests/bigmalloc/enc/enc.c index f158115d66..a417e79c62 100644 --- a/tests/bigmalloc/enc/enc.c +++ b/tests/bigmalloc/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/bigmalloc/enc/sign.conf b/tests/bigmalloc/enc/sign.conf index 4a9f5712d8..9235ad588c 100644 --- a/tests/bigmalloc/enc/sign.conf +++ b/tests/bigmalloc/enc/sign.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings (with 16GB heap): diff --git a/tests/bigmalloc/host/CMakeLists.txt b/tests/bigmalloc/host/CMakeLists.txt index 27ca2e9533..fa01c818c2 100644 --- a/tests/bigmalloc/host/CMakeLists.txt +++ b/tests/bigmalloc/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../bigmalloc.edl host gen) diff --git a/tests/bigmalloc/host/host.c b/tests/bigmalloc/host/host.c index 30d03e9ca0..07b3eebb14 100644 --- a/tests/bigmalloc/host/host.c +++ b/tests/bigmalloc/host/host.c @@ -1,6 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#include #include #include #include "bigmalloc_u.h" @@ -30,7 +31,6 @@ int main(int argc, const char* argv[]) { OE_UNUSED(argc); OE_UNUSED(argv); -#if !defined(OE_USE_LIBSGX) oe_result_t result; const oe_enclave_type_t type = OE_ENCLAVE_TYPE_SGX; @@ -53,7 +53,8 @@ int main(int argc, const char* argv[]) { fprintf( stderr, - "%s: warning: insufficient memory to load enclave: %lu\n", + "%s: warning: insufficient memory to load enclave: %" PRIu64 + "\n", argv[0], free_memory); @@ -75,7 +76,5 @@ int main(int argc, const char* argv[]) printf("=== passed all tests (%s)\n", argv[0]); -#endif /* defined(OE_USE_LIBSGX) */ - return 0; } diff --git a/tests/cmake_name_conflict/CMakeLists.txt b/tests/cmake_name_conflict/CMakeLists.txt new file mode 100644 index 0000000000..3871793d40 --- /dev/null +++ b/tests/cmake_name_conflict/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_subdirectory(host) + +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() + +add_enclave_test(tests/cmake_name_conflict name_conflict_host name_conflict_enc) diff --git a/tests/cmake_name_conflict/README.md b/tests/cmake_name_conflict/README.md new file mode 100644 index 0000000000..79bdfee4d5 --- /dev/null +++ b/tests/cmake_name_conflict/README.md @@ -0,0 +1,2 @@ +This test verifies that the linux build allows developers to include cmake +target named **dl** or **crypto**. diff --git a/tests/cmake_name_conflict/enc/CMakeLists.txt b/tests/cmake_name_conflict/enc/CMakeLists.txt new file mode 100644 index 0000000000..7e8c06fde9 --- /dev/null +++ b/tests/cmake_name_conflict/enc/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command( + OUTPUT + name_conflict_t.h + name_conflict_t.c + name_conflict_args.h + DEPENDS + edger8r + ../name_conflict.edl + COMMAND edger8r --trusted --search-path ${CMAKE_CURRENT_SOURCE_DIR}/.. name_conflict.edl) + +add_enclave(TARGET name_conflict_enc + UUID 15056a35-a9ae-4c5e-a118-3ff174d61579 + SOURCES enc.c name_conflict_t.c) + +add_subdirectory(crypto) +add_subdirectory(dl) + +target_include_directories(name_conflict_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/crypto + ${CMAKE_CURRENT_SOURCE_DIR}/dl) +target_link_libraries(name_conflict_enc oelibc crypto dl) diff --git a/tests/cmake_name_conflict/enc/crypto/CMakeLists.txt b/tests/cmake_name_conflict/enc/crypto/CMakeLists.txt new file mode 100644 index 0000000000..a1f1af3352 --- /dev/null +++ b/tests/cmake_name_conflict/enc/crypto/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_library(crypto crypto.c) diff --git a/tests/cmake_name_conflict/enc/crypto/crypto.c b/tests/cmake_name_conflict/enc/crypto/crypto.c new file mode 100644 index 0000000000..549fee602b --- /dev/null +++ b/tests/cmake_name_conflict/enc/crypto/crypto.c @@ -0,0 +1,7 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +int test_crypto() +{ + return 5; +} diff --git a/tests/cmake_name_conflict/enc/crypto/crypto.h b/tests/cmake_name_conflict/enc/crypto/crypto.h new file mode 100644 index 0000000000..c6a402f306 --- /dev/null +++ b/tests/cmake_name_conflict/enc/crypto/crypto.h @@ -0,0 +1,4 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +int test_crypto(); diff --git a/tests/cmake_name_conflict/enc/dl/CMakeLists.txt b/tests/cmake_name_conflict/enc/dl/CMakeLists.txt new file mode 100644 index 0000000000..068d8684cd --- /dev/null +++ b/tests/cmake_name_conflict/enc/dl/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_library(dl dl.c) diff --git a/tests/cmake_name_conflict/enc/dl/dl.c b/tests/cmake_name_conflict/enc/dl/dl.c new file mode 100644 index 0000000000..c38896eae1 --- /dev/null +++ b/tests/cmake_name_conflict/enc/dl/dl.c @@ -0,0 +1,7 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +int test_dl() +{ + return 6; +} diff --git a/tests/cmake_name_conflict/enc/dl/dl.h b/tests/cmake_name_conflict/enc/dl/dl.h new file mode 100644 index 0000000000..c4f1c8032b --- /dev/null +++ b/tests/cmake_name_conflict/enc/dl/dl.h @@ -0,0 +1,4 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +int test_dl(); diff --git a/tests/cmake_name_conflict/enc/enc.c b/tests/cmake_name_conflict/enc/enc.c new file mode 100644 index 0000000000..ae38f9117d --- /dev/null +++ b/tests/cmake_name_conflict/enc/enc.c @@ -0,0 +1,21 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include + +void test_name_conflict(void) +{ + OE_TEST(test_crypto() == 5); + OE_TEST(test_dl() == 6); +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 1024, /* HeapPageCount */ + 1024, /* StackPageCount */ + 2); /* TCSCount */ diff --git a/tests/cmake_name_conflict/host/CMakeLists.txt b/tests/cmake_name_conflict/host/CMakeLists.txt new file mode 100644 index 0000000000..0b512db49a --- /dev/null +++ b/tests/cmake_name_conflict/host/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command( + OUTPUT + name_conflict_u.h + name_conflict_u.c + name_conflict_args.h + DEPENDS + edger8r + ../name_conflict.edl + COMMAND edger8r --untrusted --search-path ${CMAKE_CURRENT_SOURCE_DIR}/.. name_conflict.edl) + +add_executable(name_conflict_host + host.cpp + name_conflict_u.c + name_conflict_u.h + name_conflict_args.h +) + +target_include_directories(name_conflict_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(name_conflict_host oehostapp) diff --git a/tests/cmake_name_conflict/host/host.cpp b/tests/cmake_name_conflict/host/host.cpp new file mode 100644 index 0000000000..f166843796 --- /dev/null +++ b/tests/cmake_name_conflict/host/host.cpp @@ -0,0 +1,39 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include + +#include +#include +#include +#include + +#include "name_conflict_u.h" + +int main(int argc, const char* argv[]) +{ + oe_result_t result; + oe_enclave_t* enclave = NULL; + const oe_enclave_type_t type = OE_ENCLAVE_TYPE_SGX; + const uint32_t flags = oe_get_create_flags(); + + if (argc != 2) + { + fprintf(stderr, "Usage: %s ENCLAVE_PATH\n", argv[0]); + return 1; + } + + result = oe_create_name_conflict_enclave( + argv[1], type, flags, NULL, 0, &enclave); + OE_TEST(result == OE_OK); + + result = test_name_conflict(enclave); + OE_TEST(result == OE_OK); + + result = oe_terminate_enclave(enclave); + OE_TEST(result == OE_OK); + + printf("===All tests pass (cmake_name_conflict).\n"); + + return 0; +} diff --git a/tests/cmake_name_conflict/name_conflict.edl b/tests/cmake_name_conflict/name_conflict.edl new file mode 100644 index 0000000000..88de101658 --- /dev/null +++ b/tests/cmake_name_conflict/name_conflict.edl @@ -0,0 +1,9 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + + trusted { + public void test_name_conflict(); + }; +}; diff --git a/tests/cppException/CMakeLists.txt b/tests/cppException/CMakeLists.txt index 2de7366bee..bb81d7a56a 100644 --- a/tests/cppException/CMakeLists.txt +++ b/tests/cppException/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/cppException/cppException.edl b/tests/cppException/cppException.edl index 6e6d1c9e11..a95426d4e3 100644 --- a/tests/cppException/cppException.edl +++ b/tests/cppException/cppException.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/cppException/enc/CMakeLists.txt b/tests/cppException/enc/CMakeLists.txt index fd7e6b9fa7..fc52730a59 100644 --- a/tests/cppException/enc/CMakeLists.txt +++ b/tests/cppException/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/cppException/enc/cppException.cpp b/tests/cppException/enc/cppException.cpp index f3035e21ad..932d50c358 100644 --- a/tests/cppException/enc/cppException.cpp +++ b/tests/cppException/enc/cppException.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -177,7 +177,7 @@ bool BasicVerification() { return false; } - catch (BarClass01 ex_obj) + catch (BarClass01& ex_obj) { if (ex_obj.i != 0XFFFF) { @@ -243,11 +243,11 @@ bool BasicVerification() { return false; } - catch (BarClass01) + catch (BarClass01&) { return false; } - catch (BarClass02 ex_obj) + catch (BarClass02& ex_obj) { if (ex_obj.i != 0XFFFFF) { @@ -280,7 +280,7 @@ bool BasicVerification() { return false; } - catch (BarClass01) + catch (BarClass01&) { return false; } @@ -318,11 +318,11 @@ bool BasicVerification() { return false; } - catch (BarClass01) + catch (BarClass01&) { return false; } - catch (BarClass02 ex_obj) + catch (BarClass02& ex_obj) { if (ex_obj.i != 0XFFFFFF) { @@ -409,7 +409,7 @@ void bar02() BarClass02 obj(0XFFFFF); throw obj; } - catch (BarClass03) + catch (BarClass03&) { return; } @@ -421,7 +421,7 @@ void bar01() { bar02(); } - catch (BarClass01) + catch (BarClass01&) { return; } @@ -436,7 +436,7 @@ bool NestedException() BarClass01 obj(0XF); throw obj; } - catch (BarClass01 ex_obj) + catch (BarClass01& ex_obj) { if (ex_obj.i != 0XF) { @@ -487,12 +487,12 @@ bool NestedException() return false; } } - catch (BarClass01) + catch (BarClass01&) { return false; } } - catch (BarClass02 ex_obj) + catch (BarClass02& ex_obj) { if (ex_obj.i != 0XFFFF) { diff --git a/tests/cppException/enc/enc.cpp b/tests/cppException/enc/enc.cpp index b4eb137c53..b346cd4f89 100644 --- a/tests/cppException/enc/enc.cpp +++ b/tests/cppException/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/cppException/host/CMakeLists.txt b/tests/cppException/host/CMakeLists.txt index 4de7766dfb..52a2041a4b 100644 --- a/tests/cppException/host/CMakeLists.txt +++ b/tests/cppException/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/cppException/host/host.cpp b/tests/cppException/host/host.cpp index a8b68e8116..9776ab9755 100644 --- a/tests/cppException/host/host.cpp +++ b/tests/cppException/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/create-errors/CMakeLists.txt b/tests/create-errors/CMakeLists.txt index 27a05c815a..b62f36418f 100644 --- a/tests/create-errors/CMakeLists.txt +++ b/tests/create-errors/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/create-errors/create_errors.edl b/tests/create-errors/create_errors.edl index baced94d3e..90da019518 100644 --- a/tests/create-errors/create_errors.edl +++ b/tests/create-errors/create_errors.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/create-errors/enc/CMakeLists.txt b/tests/create-errors/enc/CMakeLists.txt index 05cd8f4c13..518564220a 100644 --- a/tests/create-errors/enc/CMakeLists.txt +++ b/tests/create-errors/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/create-errors/enc/enc.c b/tests/create-errors/enc/enc.c index 6ff54aeb9d..c4663142d4 100644 --- a/tests/create-errors/enc/enc.c +++ b/tests/create-errors/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/create-errors/host/CMakeLists.txt b/tests/create-errors/host/CMakeLists.txt index cf74574558..3b7ae6e750 100644 --- a/tests/create-errors/host/CMakeLists.txt +++ b/tests/create-errors/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/create-errors/host/host.c b/tests/create-errors/host/host.c index 2867b4b9be..f7b5cb1359 100644 --- a/tests/create-errors/host/host.c +++ b/tests/create-errors/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -13,6 +13,13 @@ static void _test_invalid_param(const char* path, uint32_t flags) { oe_enclave_t* enclave = NULL; + oe_enclave_setting_t invalid_setting = {0, {NULL}}; + oe_enclave_setting_context_switchless_t switchless_setting = {2, 0}; + oe_enclave_setting_t settings[] = {{ + .setting_type = OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS, + .u.context_switchless_setting = &switchless_setting, + }}; + /* Null path. */ oe_result_t result = oe_create_create_errors_enclave( NULL, OE_ENCLAVE_TYPE_AUTO, flags, NULL, 0, &enclave); @@ -36,9 +43,21 @@ static void _test_invalid_param(const char* path, uint32_t flags) OE_TEST(result == OE_INVALID_PARAMETER); - /* Content field filled. */ + /* Invalid configuration with incorrect **config_count** */ + result = oe_create_create_errors_enclave( + path, OE_ENCLAVE_TYPE_SGX, flags, &invalid_setting, 0, &enclave); + + OE_TEST(result == OE_INVALID_PARAMETER); + + /* Invalid configuration with correct **config_count** */ + result = oe_create_create_errors_enclave( + path, OE_ENCLAVE_TYPE_SGX, flags, &invalid_setting, 1, &enclave); + + OE_TEST(result == OE_INVALID_PARAMETER); + + /* Valid configuration with incorrect **config_count** */ result = oe_create_create_errors_enclave( - path, OE_ENCLAVE_TYPE_AUTO, flags, &enclave, 0, &enclave); + path, OE_ENCLAVE_TYPE_SGX, flags, settings, 0, &enclave); OE_TEST(result == OE_INVALID_PARAMETER); diff --git a/tests/create-rapid/CMakeLists.txt b/tests/create-rapid/CMakeLists.txt index 098399266f..21cb316bd7 100644 --- a/tests/create-rapid/CMakeLists.txt +++ b/tests/create-rapid/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/create-rapid/create_rapid.edl b/tests/create-rapid/create_rapid.edl index 774a1cd025..f913e1e3a4 100644 --- a/tests/create-rapid/create_rapid.edl +++ b/tests/create-rapid/create_rapid.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/create-rapid/enc/CMakeLists.txt b/tests/create-rapid/enc/CMakeLists.txt index 094236b622..dc1a41347f 100644 --- a/tests/create-rapid/enc/CMakeLists.txt +++ b/tests/create-rapid/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/create-rapid/enc/enc.cpp b/tests/create-rapid/enc/enc.cpp index c069a20d6a..10589abaf5 100644 --- a/tests/create-rapid/enc/enc.cpp +++ b/tests/create-rapid/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/create-rapid/host/CMakeLists.txt b/tests/create-rapid/host/CMakeLists.txt index 6e0ac6791c..0780fc372d 100644 --- a/tests/create-rapid/host/CMakeLists.txt +++ b/tests/create-rapid/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/create-rapid/host/host.cpp b/tests/create-rapid/host/host.cpp index 7f2256435e..3de07332fb 100644 --- a/tests/create-rapid/host/host.cpp +++ b/tests/create-rapid/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/crypto/CMakeLists.txt b/tests/crypto/CMakeLists.txt index 502f1a9c58..53d1dfac7a 100644 --- a/tests/crypto/CMakeLists.txt +++ b/tests/crypto/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(data) diff --git a/tests/crypto/asn1_tests.c b/tests/crypto/asn1_tests.c index dc727c18f8..6b04df2f02 100644 --- a/tests/crypto/asn1_tests.c +++ b/tests/crypto/asn1_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/cpu_entropy_test.c b/tests/crypto/cpu_entropy_test.c new file mode 100644 index 0000000000..b75ac7db21 --- /dev/null +++ b/tests/crypto/cpu_entropy_test.c @@ -0,0 +1,57 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#define MAX_LOOP_SIZE 1000 + +#include +#include +#include +#include +#include +#include +#include + +// Test that RDSEED and RDRAND functions synchronously block and +// retry until the sufficient entropy exists to be returned. +void TestCpuEntropy() +{ + uint64_t rand_num = 0; + printf("=== begin %s()\n", __FUNCTION__); + + /* TODO: This test does not actually manage to exhaust the RDRAND + * entropy pool regardless of the number of iterations run since + * the operation of retrieving the RDRAND value through the bus + * architecture is slow enough that a single thread can't saturate + * the interface regardless of the number of iterations run. + */ + for (uint64_t i = 0; i < MAX_LOOP_SIZE; i++) + { + rand_num = oe_rdrand(); + + /* 0 is a legal random value that could be returned, but the + * odds of this happening twice in a row are very unlikely + * unless we've run out of hardware entropy and are returning + * without retrying until we have sufficient entropy. + */ + if (rand_num == 0) + { + rand_num = oe_rdrand(); + OE_TEST(rand_num != 0); + } + } + + /* Empirically, RDSEED will start to run out ~20 iterations, on a + * Coffeelake device, so the MAX_LOOP_SIZE should be plenty. + */ + for (uint64_t i = 0; i < MAX_LOOP_SIZE; i++) + { + rand_num = oe_rdseed(); + if (rand_num == 0) + { + rand_num = oe_rdseed(); + OE_TEST(rand_num != 0); + } + } + + printf("=== passed %s()\n", __FUNCTION__); +} diff --git a/tests/crypto/crl_tests.c b/tests/crypto/crl_tests.c index 6813b00a16..a971cd220a 100644 --- a/tests/crypto/crl_tests.c +++ b/tests/crypto/crl_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/data/CMakeLists.txt b/tests/crypto/data/CMakeLists.txt index 46bec8e163..b878bdcef1 100644 --- a/tests/crypto/data/CMakeLists.txt +++ b/tests/crypto/data/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OS-specific configuration @@ -10,33 +10,35 @@ else() message(FATAL_ERROR "Unknown OS. Only supported OSes are Linux and Windows") endif() -add_custom_target( - crypto_test_data ALL - COMMAND ${BASH} -c "${CMAKE_CURRENT_SOURCE_DIR}/make-test-certs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${BUILD_OPT}" - # These are specifically the byproducts that will be directly consumed by crypto tests - BYPRODUCTS - asn1.cert.pem - coordinates.bin - ec_cert_with_ext.pem - ec_cert_crl_distribution.pem - intermediate.crl.der - intermediate.cert.pem - intermediate.ec.cert.pem - intermediate2.cert.pem - leaf.key.pem - leaf.cert.pem - leaf.ec.cert.pem - leaf.public.key.pem - leaf_modulus.hex - leaf2.cert.pem - root.crl.der - root.cert.pem - root.ec.cert.pem - root.ec.key.pem - root.ec.public.key.pem - root2.cert.pem - self_signed.cert.der - test_ec_signature - test_rsa_signature - time.txt - ) +# These are specifically the byproducts that will be directly consumed by crypto tests +set(CRYPTO_TEST_DATA + asn1.cert.pem + coordinates.bin + ec_cert_with_ext.pem + ec_cert_crl_distribution.pem + intermediate.crl.der + intermediate.cert.pem + intermediate.ec.cert.pem + intermediate2.cert.pem + leaf.key.pem + leaf.cert.pem + leaf.ec.cert.pem + leaf.public.key.pem + leaf_modulus.hex + leaf2.cert.pem + root.crl.der + root.cert.pem + root.ec.cert.pem + root.ec.key.pem + root.ec.public.key.pem + root2.cert.pem + self_signed.cert.der + test_ec_signature + test_rsa_signature + time.txt) + +add_custom_command( + COMMAND ${OE_BASH} -c "${CMAKE_CURRENT_SOURCE_DIR}/make-test-certs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${BUILD_OPT}" + OUTPUT ${CRYPTO_TEST_DATA}) + +add_custom_target(crypto_test_data DEPENDS ${CRYPTO_TEST_DATA}) diff --git a/tests/crypto/data/ec_cert_with_ext.cnf b/tests/crypto/data/ec_cert_with_ext.cnf index c67e3add00..66374a0d1b 100644 --- a/tests/crypto/data/ec_cert_with_ext.cnf +++ b/tests/crypto/data/ec_cert_with_ext.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/data/ec_crl_distribution.cnf b/tests/crypto/data/ec_crl_distribution.cnf index c67e3add00..66374a0d1b 100644 --- a/tests/crypto/data/ec_crl_distribution.cnf +++ b/tests/crypto/data/ec_crl_distribution.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/data/intermediate.cnf b/tests/crypto/data/intermediate.cnf index 65f2f4f197..200302fab2 100644 --- a/tests/crypto/data/intermediate.cnf +++ b/tests/crypto/data/intermediate.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/data/intermediate_v3.ext b/tests/crypto/data/intermediate_v3.ext index 9694525ffb..8f36350fb9 100644 --- a/tests/crypto/data/intermediate_v3.ext +++ b/tests/crypto/data/intermediate_v3.ext @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/data/make-test-certs b/tests/crypto/data/make-test-certs index 8c77b19215..7f7660a06f 100755 --- a/tests/crypto/data/make-test-certs +++ b/tests/crypto/data/make-test-certs @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/tests/crypto/data/root.cnf b/tests/crypto/data/root.cnf index 5afdd0eec5..6e4ef1d88a 100644 --- a/tests/crypto/data/root.cnf +++ b/tests/crypto/data/root.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/data/root_v3.ext b/tests/crypto/data/root_v3.ext index 2d7f3c52ea..f000ae0fd0 100644 --- a/tests/crypto/data/root_v3.ext +++ b/tests/crypto/data/root_v3.ext @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/data/sample.cnf b/tests/crypto/data/sample.cnf index 528004d31b..203e04e1f4 100644 --- a/tests/crypto/data/sample.cnf +++ b/tests/crypto/data/sample.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto/ec_tests.c b/tests/crypto/ec_tests.c index 2c1b30aa32..eec1002a43 100644 --- a/tests/crypto/ec_tests.c +++ b/tests/crypto/ec_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) @@ -878,7 +878,7 @@ static void _test_crl_distribution_points(void) { oe_result_t r; oe_cert_t cert; - const char** urls = NULL; + char** urls = NULL; size_t num_urls; size_t buffer_size = 0; diff --git a/tests/crypto/enclave/CMakeLists.txt b/tests/crypto/enclave/CMakeLists.txt index c9533cd7c5..c88bf81ac2 100644 --- a/tests/crypto/enclave/CMakeLists.txt +++ b/tests/crypto/enclave/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (BUILD_ENCLAVES) diff --git a/tests/crypto/enclave/crypto.edl b/tests/crypto/enclave/crypto.edl index c40890c0a9..7edbeff6fb 100644 --- a/tests/crypto/enclave/crypto.edl +++ b/tests/crypto/enclave/crypto.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/crypto/enclave/enc/CMakeLists.txt b/tests/crypto/enclave/enc/CMakeLists.txt index fca04fbb39..047629bd5a 100644 --- a/tests/crypto/enclave/enc/CMakeLists.txt +++ b/tests/crypto/enclave/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../crypto.edl enclave gen) @@ -21,7 +21,7 @@ set(SRCS if (OE_SGX) list(APPEND SRCS ../../../../common/sgx/rand.S - ../../rdrand_test.c) + ../../cpu_entropy_test.c) endif () add_enclave(TARGET cryptoenc UUID f0be7db0-ce7c-4dc4-b8c8-b161f4216225 diff --git a/tests/crypto/enclave/enc/enc.c b/tests/crypto/enclave/enc/enc.c index b11576356d..f552b9aad5 100644 --- a/tests/crypto/enclave/enc/enc.c +++ b/tests/crypto/enclave/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/crypto/enclave/host/CMakeLists.txt b/tests/crypto/enclave/host/CMakeLists.txt index d7e3b36b6a..55f0e9b188 100644 --- a/tests/crypto/enclave/host/CMakeLists.txt +++ b/tests/crypto/enclave/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/crypto/enclave/host/host.c b/tests/crypto/enclave/host/host.c index 74aec2d1e4..fc3963bd0a 100644 --- a/tests/crypto/enclave/host/host.c +++ b/tests/crypto/enclave/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/crypto/hash.c b/tests/crypto/hash.c index 3062815d2a..1b79843161 100644 --- a/tests/crypto/hash.c +++ b/tests/crypto/hash.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "hash.h" diff --git a/tests/crypto/hash.h b/tests/crypto/hash.h index d35f5a5814..22560b7cb0 100644 --- a/tests/crypto/hash.h +++ b/tests/crypto/hash.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _TESTS_CRYPTO_HASH_H diff --git a/tests/crypto/hmac_tests.c b/tests/crypto/hmac_tests.c index 0866553848..b9df1eb931 100644 --- a/tests/crypto/hmac_tests.c +++ b/tests/crypto/hmac_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/host/CMakeLists.txt b/tests/crypto/host/CMakeLists.txt index bb87c5fd72..128c38d2d0 100644 --- a/tests/crypto/host/CMakeLists.txt +++ b/tests/crypto/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OS- and TEE-specific source files @@ -21,7 +21,7 @@ endif() if (OE_SGX) list(APPEND PLATFORM_SRC - ../rdrand_test.c) + ../cpu_entropy_test.c) endif () add_executable(hostcrypto diff --git a/tests/crypto/host/main.c b/tests/crypto/host/main.c index e13315b68a..427a9b2ceb 100644 --- a/tests/crypto/host/main.c +++ b/tests/crypto/host/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/crypto/kdf_tests.c b/tests/crypto/kdf_tests.c index 1607f160db..de9165d858 100644 --- a/tests/crypto/kdf_tests.c +++ b/tests/crypto/kdf_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/random_tests.c b/tests/crypto/random_tests.c index 8e0b7f5e8b..939f8f71a1 100644 --- a/tests/crypto/random_tests.c +++ b/tests/crypto/random_tests.c @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) #include #endif +#include #include #include #include @@ -13,38 +14,50 @@ #include "tests.h" #define SEQ_COUNT 64 -#define SEQ_LENGTH 19 +#define SEQ_LENGTH_MAX 2049 -void TestRandom(void) +static void _test_random(size_t seq_length) { - printf("=== begin %s()\n", __FUNCTION__); + printf("=== begin %s(%zu)\n", __FUNCTION__, seq_length); - uint8_t buf[SEQ_COUNT][SEQ_LENGTH]; + uint8_t buf[SEQ_COUNT][SEQ_LENGTH_MAX]; memset(buf, 0, sizeof(buf)); for (size_t i = 0; i < SEQ_COUNT; i++) { /* Generate a random sequence */ OE_TEST( - oe_random_internal(buf[i], SEQ_LENGTH * sizeof(uint8_t)) == OE_OK); + oe_random_internal(buf[i], seq_length * sizeof(uint8_t)) == OE_OK); /* Be sure buffer is not filled with same character */ { size_t m; uint8_t c = buf[i][0]; - for (m = 1; m < SEQ_LENGTH && buf[i][m] == c; m++) + for (m = 1; m < seq_length && buf[i][m] == c; m++) ; - OE_TEST(m != SEQ_LENGTH); + OE_TEST(m != seq_length); } /* Check whether duplicate of one of the previous calls */ for (size_t j = 0; j < i; j++) { - OE_TEST(memcmp(buf[j], buf[i], SEQ_LENGTH * sizeof(uint8_t)) != 0); + OE_TEST(memcmp(buf[j], buf[i], seq_length * sizeof(uint8_t)) != 0); } } printf("=== passed %s()\n", __FUNCTION__); } + +void TestRandom(void) +{ + _test_random(19); + _test_random(1023); + _test_random(1024); + _test_random(1025); + _test_random(2047); + _test_random(2048); + _test_random(2049); + OE_STATIC_ASSERT(SEQ_LENGTH_MAX == 2049); +} diff --git a/tests/crypto/rdrand_test.c b/tests/crypto/rdrand_test.c deleted file mode 100644 index b365a54df5..0000000000 --- a/tests/crypto/rdrand_test.c +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#define MAX_LOOP_SIZE 100000000 -#include -#include -#include -#include -#include -#include - -// TestRdrand is trying to ensure that oe_rdrand function incorporates blocking -// wait to retry if the RDRAND instruction is out of entropy -void TestRdrand() -{ - uint64_t rand_num = 0; - printf("=== begin %s()\n", __FUNCTION__); - for (uint64_t i = 0; i < MAX_LOOP_SIZE; i++) - { - rand_num = oe_rdrand(); - if (rand_num == 0) - { - rand_num = oe_rdrand(); - OE_TEST(rand_num != 0); - } - } - printf("=== passed %s()\n", __FUNCTION__); -} diff --git a/tests/crypto/read_file.c b/tests/crypto/read_file.c index 913c0a225c..8a0c8a4678 100644 --- a/tests/crypto/read_file.c +++ b/tests/crypto/read_file.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/crypto/readfile.h b/tests/crypto/readfile.h index bc2f2c7bfa..be35fa3c1f 100644 --- a/tests/crypto/readfile.h +++ b/tests/crypto/readfile.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _READFILE_H_ diff --git a/tests/crypto/rsa_tests.c b/tests/crypto/rsa_tests.c index b1c8efe677..3938d33336 100644 --- a/tests/crypto/rsa_tests.c +++ b/tests/crypto/rsa_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/sha_tests.c b/tests/crypto/sha_tests.c index 7dfe2c3be8..5d62032cae 100644 --- a/tests/crypto/sha_tests.c +++ b/tests/crypto/sha_tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/tests.c b/tests/crypto/tests.c index bb1816f7a2..5f3423cd3d 100644 --- a/tests/crypto/tests.c +++ b/tests/crypto/tests.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "tests.h" @@ -13,8 +13,8 @@ void TestAll() TestRSA(); TestRandom(); #if defined(__x86_64__) || defined(__i386__) - // This test exercises the rdrand instruction, which is x86/64-specific. - TestRdrand(); + // Test the RDRAND/RDSEED instructions, which are x86/64-specific. + TestCpuEntropy(); #endif TestHMAC(); TestKDF(); diff --git a/tests/crypto/tests.h b/tests/crypto/tests.h index 5ad9c907c9..489a2abc55 100644 --- a/tests/crypto/tests.h +++ b/tests/crypto/tests.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _TESTS_CRYPTO_TESTS_H @@ -9,7 +9,7 @@ void TestCRL(void); void TestEC(void); void TestKDF(void); void TestRandom(void); -void TestRdrand(void); +void TestCpuEntropy(void); void TestRSA(void); void TestSHA(void); void TestHMAC(void); diff --git a/tests/crypto/utils.c b/tests/crypto/utils.c index d5d273e47f..aeaaff2a2d 100644 --- a/tests/crypto/utils.c +++ b/tests/crypto/utils.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/crypto/utils.h b/tests/crypto/utils.h index 7719693654..bfde003506 100644 --- a/tests/crypto/utils.h +++ b/tests/crypto/utils.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _TESTS_CRYPTO_UTILS_H diff --git a/tests/crypto_crls_cert_chains/CMakeLists.txt b/tests/crypto_crls_cert_chains/CMakeLists.txt index 359bc3fed1..77b4501d90 100644 --- a/tests/crypto_crls_cert_chains/CMakeLists.txt +++ b/tests/crypto_crls_cert_chains/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(data) diff --git a/tests/crypto_crls_cert_chains/common/crypto_crls_cert_chains.edl b/tests/crypto_crls_cert_chains/common/crypto_crls_cert_chains.edl index 8a9500b1ee..cba6fb589b 100644 --- a/tests/crypto_crls_cert_chains/common/crypto_crls_cert_chains.edl +++ b/tests/crypto_crls_cert_chains/common/crypto_crls_cert_chains.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/crypto_crls_cert_chains/common/tests.cpp b/tests/crypto_crls_cert_chains/common/tests.cpp index b9c85e9156..337026d274 100644 --- a/tests/crypto_crls_cert_chains/common/tests.cpp +++ b/tests/crypto_crls_cert_chains/common/tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/crypto_crls_cert_chains/data/CMakeLists.txt b/tests/crypto_crls_cert_chains/data/CMakeLists.txt index a2ffdad46c..82638481df 100644 --- a/tests/crypto_crls_cert_chains/data/CMakeLists.txt +++ b/tests/crypto_crls_cert_chains/data/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OS-specific configuration @@ -10,11 +10,8 @@ else() message(FATAL_ERROR "Unknown OS. Only supported OSes are Linux and Windows") endif() -add_custom_target( - crypto_crls_cert_chains_test_data ALL - COMMAND ${BASH} -c "${CMAKE_CURRENT_SOURCE_DIR}/make-test-certs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${BUILD_OPT}" - # These are specifically the byproducts that will be directly consumed by crypto_crls_cert_chains tests - BYPRODUCTS +# These are specifically the byproducts that will be directly consumed by crypto_crls_cert_chains tests +set(CRYPTO_CRLS_DATA root.cert.pem intermediate.cert.pem leaf1.cert.pem @@ -22,5 +19,10 @@ add_custom_target( root_crl1.der root_crl2.der intermediate_crl1.der - intermediate_crl2.der - ) + intermediate_crl2.der) + +add_custom_command( + COMMAND ${OE_BASH} -c "${CMAKE_CURRENT_SOURCE_DIR}/make-test-certs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${BUILD_OPT}" + OUTPUT ${CRYPTO_CRLS_DATA}) + +add_custom_target(crypto_crls_cert_chains_test_data DEPENDS ${CRYPTO_CRLS_DATA}) diff --git a/tests/crypto_crls_cert_chains/data/intermediate.cnf b/tests/crypto_crls_cert_chains/data/intermediate.cnf index a173487473..0895bd1deb 100644 --- a/tests/crypto_crls_cert_chains/data/intermediate.cnf +++ b/tests/crypto_crls_cert_chains/data/intermediate.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto_crls_cert_chains/data/intermediate2.cnf b/tests/crypto_crls_cert_chains/data/intermediate2.cnf index e0366eaba2..fac4ddae78 100644 --- a/tests/crypto_crls_cert_chains/data/intermediate2.cnf +++ b/tests/crypto_crls_cert_chains/data/intermediate2.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto_crls_cert_chains/data/intermediate_v3.ext b/tests/crypto_crls_cert_chains/data/intermediate_v3.ext index 9694525ffb..8f36350fb9 100644 --- a/tests/crypto_crls_cert_chains/data/intermediate_v3.ext +++ b/tests/crypto_crls_cert_chains/data/intermediate_v3.ext @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto_crls_cert_chains/data/make-test-certs b/tests/crypto_crls_cert_chains/data/make-test-certs index a040f401e6..0e46cd200c 100755 --- a/tests/crypto_crls_cert_chains/data/make-test-certs +++ b/tests/crypto_crls_cert_chains/data/make-test-certs @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set -o errexit diff --git a/tests/crypto_crls_cert_chains/data/root.cnf b/tests/crypto_crls_cert_chains/data/root.cnf index 93add0f165..382716a281 100644 --- a/tests/crypto_crls_cert_chains/data/root.cnf +++ b/tests/crypto_crls_cert_chains/data/root.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto_crls_cert_chains/data/root2.cnf b/tests/crypto_crls_cert_chains/data/root2.cnf index f45b68a4f9..37e4d3f074 100644 --- a/tests/crypto_crls_cert_chains/data/root2.cnf +++ b/tests/crypto_crls_cert_chains/data/root2.cnf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto_crls_cert_chains/data/root_v3.ext b/tests/crypto_crls_cert_chains/data/root_v3.ext index 2d7f3c52ea..f000ae0fd0 100644 --- a/tests/crypto_crls_cert_chains/data/root_v3.ext +++ b/tests/crypto_crls_cert_chains/data/root_v3.ext @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # OpenSSL configuration for test CRL generation diff --git a/tests/crypto_crls_cert_chains/enc/CMakeLists.txt b/tests/crypto_crls_cert_chains/enc/CMakeLists.txt index eb19b57db4..7985fdf596 100644 --- a/tests/crypto_crls_cert_chains/enc/CMakeLists.txt +++ b/tests/crypto_crls_cert_chains/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../common/crypto_crls_cert_chains.edl enclave gen) diff --git a/tests/crypto_crls_cert_chains/enc/enc.cpp b/tests/crypto_crls_cert_chains/enc/enc.cpp index d92a6f5e1d..9d5728f0a6 100644 --- a/tests/crypto_crls_cert_chains/enc/enc.cpp +++ b/tests/crypto_crls_cert_chains/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/tests/crypto_crls_cert_chains/host/CMakeLists.txt b/tests/crypto_crls_cert_chains/host/CMakeLists.txt index 575e60e4e1..f372b92049 100644 --- a/tests/crypto_crls_cert_chains/host/CMakeLists.txt +++ b/tests/crypto_crls_cert_chains/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../common/crypto_crls_cert_chains.edl host gen) diff --git a/tests/crypto_crls_cert_chains/host/host.cpp b/tests/crypto_crls_cert_chains/host/host.cpp index 474abb254e..de1903df81 100644 --- a/tests/crypto_crls_cert_chains/host/host.cpp +++ b/tests/crypto_crls_cert_chains/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/debug-mode/CMakeLists.txt b/tests/debug-mode/CMakeLists.txt index 815ac3a479..098e5c0853 100644 --- a/tests/debug-mode/CMakeLists.txt +++ b/tests/debug-mode/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/debug-mode/debug_mode.edl b/tests/debug-mode/debug_mode.edl index baced94d3e..90da019518 100644 --- a/tests/debug-mode/debug_mode.edl +++ b/tests/debug-mode/debug_mode.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/debug-mode/enc/CMakeLists.txt b/tests/debug-mode/enc/CMakeLists.txt index bf461d80d9..cf89f8f69d 100644 --- a/tests/debug-mode/enc/CMakeLists.txt +++ b/tests/debug-mode/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/debug-mode/enc/enc.c b/tests/debug-mode/enc/enc.c index 5b260e105a..a9fea41d2c 100644 --- a/tests/debug-mode/enc/enc.c +++ b/tests/debug-mode/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/debug-mode/enc/props-debug.c b/tests/debug-mode/enc/props-debug.c index 6cdce97a28..11dd22a35b 100644 --- a/tests/debug-mode/enc/props-debug.c +++ b/tests/debug-mode/enc/props-debug.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/debug-mode/enc/props.c b/tests/debug-mode/enc/props.c index 9051f1e4ca..f5ddb693bd 100644 --- a/tests/debug-mode/enc/props.c +++ b/tests/debug-mode/enc/props.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/debug-mode/enc/sign-debug.conf b/tests/debug-mode/enc/sign-debug.conf index 981fd5fe9b..c6af0590eb 100644 --- a/tests/debug-mode/enc/sign-debug.conf +++ b/tests/debug-mode/enc/sign-debug.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/tests/debug-mode/enc/sign.conf b/tests/debug-mode/enc/sign.conf index 8e40fe2694..2216676b73 100644 --- a/tests/debug-mode/enc/sign.conf +++ b/tests/debug-mode/enc/sign.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/tests/debug-mode/host/CMakeLists.txt b/tests/debug-mode/host/CMakeLists.txt index 2bdfc0e97a..ecd2042b36 100644 --- a/tests/debug-mode/host/CMakeLists.txt +++ b/tests/debug-mode/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/debug-mode/host/host.c b/tests/debug-mode/host/host.c index 2558193098..854f1481cf 100644 --- a/tests/debug-mode/host/host.c +++ b/tests/debug-mode/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -68,8 +68,8 @@ static void _test_debug_signed(const char* path) { /* Signed debug mode should always pass. */ _launch_enclave_success(path, _create_flags(true)); -#ifdef OE_USE_LIBSGX - /* Only works with the NGSA SDK. */ +#ifdef OE_LINK_SGX_DCAP_QL + /* Only works with FLC */ _launch_enclave_success(path, _create_flags(false)); #endif } @@ -85,8 +85,8 @@ static void _test_non_debug_signed(const char* path) { /* Debug mode should fail. Non-debug mode should pass. */ _launch_enclave_fail(path, _create_flags(true), OE_DEBUG_DOWNGRADE); -#ifdef OE_USE_LIBSGX - /* Only works with the NGSA SDK. */ +#ifdef OE_LINK_SGX_DCAP_QL + /* Only works with FLC */ _launch_enclave_success(path, _create_flags(false)); #endif } diff --git a/tests/debugger/CMakeLists.txt b/tests/debugger/CMakeLists.txt index 72618f9ab1..b17e683987 100644 --- a/tests/debugger/CMakeLists.txt +++ b/tests/debugger/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_UPPER) diff --git a/tests/debugger/oegdb/CMakeLists.txt b/tests/debugger/oegdb/CMakeLists.txt index 09356128c3..72b2058e36 100644 --- a/tests/debugger/oegdb/CMakeLists.txt +++ b/tests/debugger/oegdb/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/debugger/oegdb/commands.gdb b/tests/debugger/oegdb/commands.gdb index 58c818ef16..0873ede4aa 100644 --- a/tests/debugger/oegdb/commands.gdb +++ b/tests/debugger/oegdb/commands.gdb @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enable pending breakpoints diff --git a/tests/debugger/oegdb/enc/CMakeLists.txt b/tests/debugger/oegdb/enc/CMakeLists.txt index 5d98e3c8b5..1784c0e920 100644 --- a/tests/debugger/oegdb/enc/CMakeLists.txt +++ b/tests/debugger/oegdb/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/debugger/oegdb/enc/contract.c b/tests/debugger/oegdb/enc/contract.c index 0ca34464e9..8cc5a4a516 100644 --- a/tests/debugger/oegdb/enc/contract.c +++ b/tests/debugger/oegdb/enc/contract.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -24,7 +24,7 @@ volatile uint64_t OCALLCONTEXT_RET = (uint64_t)-1; void assert_debugger_binary_contract_enclave_side() { - OE_TEST(TD_OFFSET_FROM_TCS == 4 * OE_PAGE_SIZE); + OE_TEST(TD_OFFSET_FROM_TCS == 5 * OE_PAGE_SIZE); OE_TEST(TD_CALLSITE_OFFSET == OE_OFFSETOF(td_t, callsites)); OE_TEST( CALLSITE_OCALLCONTEXT_OFFSET == OE_OFFSETOF(Callsite, ocall_context)); diff --git a/tests/debugger/oegdb/enc/enc.c b/tests/debugger/oegdb/enc/enc.c index 52deac6a01..39e9844f2d 100644 --- a/tests/debugger/oegdb/enc/enc.c +++ b/tests/debugger/oegdb/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -33,6 +33,9 @@ int enc_add(int a, int b) return c; } +// The following function is intended to be called by the debugger. +// It must be retained via OE_EXPORT. +OE_EXPORT int square(int x) { printf("square called with %d\n", x); diff --git a/tests/debugger/oegdb/host/CMakeLists.txt b/tests/debugger/oegdb/host/CMakeLists.txt index 7c3f1a1014..e5e3b3ddf2 100644 --- a/tests/debugger/oegdb/host/CMakeLists.txt +++ b/tests/debugger/oegdb/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/debugger/oegdb/host/contract.c b/tests/debugger/oegdb/host/contract.c index ae5d038263..3b181545cd 100644 --- a/tests/debugger/oegdb/host/contract.c +++ b/tests/debugger/oegdb/host/contract.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/debugger/oegdb/host/host.c b/tests/debugger/oegdb/host/host.c index 67d39c7e7a..babdc4ec65 100644 --- a/tests/debugger/oegdb/host/host.c +++ b/tests/debugger/oegdb/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/debugger/oegdb/oe_gdb_test.edl b/tests/debugger/oegdb/oe_gdb_test.edl index 005f15b989..6974313157 100644 --- a/tests/debugger/oegdb/oe_gdb_test.edl +++ b/tests/debugger/oegdb/oe_gdb_test.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/ecall/CMakeLists.txt b/tests/ecall/CMakeLists.txt index 3d5f3aacaa..a41e9af776 100644 --- a/tests/ecall/CMakeLists.txt +++ b/tests/ecall/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/ecall/ecall.edl b/tests/ecall/ecall.edl index 17327c8b97..fd7de79ee3 100644 --- a/tests/ecall/ecall.edl +++ b/tests/ecall/ecall.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/ecall/enc/CMakeLists.txt b/tests/ecall/enc/CMakeLists.txt index 0fffd4a5c6..32808cd52f 100644 --- a/tests/ecall/enc/CMakeLists.txt +++ b/tests/ecall/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # TODO: Does this need CXX? diff --git a/tests/ecall/enc/enc.cpp b/tests/ecall/enc/enc.cpp index a9a345870c..9a6c2bc2f0 100644 --- a/tests/ecall/enc/enc.cpp +++ b/tests/ecall/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ecall/host/CMakeLists.txt b/tests/ecall/host/CMakeLists.txt index cfc282246b..5af0c03c2a 100644 --- a/tests/ecall/host/CMakeLists.txt +++ b/tests/ecall/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ecall.edl host gen) diff --git a/tests/ecall/host/host.cpp b/tests/ecall/host/host.cpp index 82f6b3f92c..d506f92bc1 100644 --- a/tests/ecall/host/host.cpp +++ b/tests/ecall/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ecall_ocall/CMakeLists.txt b/tests/ecall_ocall/CMakeLists.txt index dba0219eb4..a2e44d4039 100644 --- a/tests/ecall_ocall/CMakeLists.txt +++ b/tests/ecall_ocall/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/ecall_ocall/ecall_ocall.edl b/tests/ecall_ocall/ecall_ocall.edl index 13e30cc829..2130da8cae 100644 --- a/tests/ecall_ocall/ecall_ocall.edl +++ b/tests/ecall_ocall/ecall_ocall.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/ecall_ocall/enc/CMakeLists.txt b/tests/ecall_ocall/enc/CMakeLists.txt index 5f7dc7d1c5..a94ae6bc6b 100644 --- a/tests/ecall_ocall/enc/CMakeLists.txt +++ b/tests/ecall_ocall/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ecall_ocall.edl enclave gen) diff --git a/tests/ecall_ocall/enc/enc.cpp b/tests/ecall_ocall/enc/enc.cpp index ef2cc82609..6065bd926d 100644 --- a/tests/ecall_ocall/enc/enc.cpp +++ b/tests/ecall_ocall/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ecall_ocall/enc/helpers.h b/tests/ecall_ocall/enc/helpers.h index cffedbddf2..c59a8f7cf9 100644 --- a/tests/ecall_ocall/enc/helpers.h +++ b/tests/ecall_ocall/enc/helpers.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/tests/ecall_ocall/host/CMakeLists.txt b/tests/ecall_ocall/host/CMakeLists.txt index 70c26aab45..cfc1072293 100644 --- a/tests/ecall_ocall/host/CMakeLists.txt +++ b/tests/ecall_ocall/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ecall_ocall.edl host gen) diff --git a/tests/ecall_ocall/host/host.cpp b/tests/ecall_ocall/host/host.cpp index 79695989ca..fb690ec926 100644 --- a/tests/ecall_ocall/host/host.cpp +++ b/tests/ecall_ocall/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include @@ -250,7 +250,7 @@ static void test_cross_enclave_calls() enc_cross_enclave_call(enclave_wrap::get(0), &total, 0, SEED, 0); OE_TEST(OE_OK == result); - printf("total=%u, expected_total=%lu\n", total, expected_total); + printf("total=%u, expected_total=%zu\n", total, expected_total); OE_TEST(total == expected_total); printf("=== test_cross_enclave_calls passed\n"); diff --git a/tests/echo/CMakeLists.txt b/tests/echo/CMakeLists.txt index 848d6122a8..40b0b00e3a 100644 --- a/tests/echo/CMakeLists.txt +++ b/tests/echo/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/echo/echo.edl b/tests/echo/echo.edl index b232178d9d..81ec2facb8 100644 --- a/tests/echo/echo.edl +++ b/tests/echo/echo.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/echo/enc/CMakeLists.txt b/tests/echo/enc/CMakeLists.txt index 78c55c2a1a..8a36d36e79 100644 --- a/tests/echo/enc/CMakeLists.txt +++ b/tests/echo/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/echo/enc/enc.c b/tests/echo/enc/enc.c index 4be79999d8..15e7424102 100644 --- a/tests/echo/enc/enc.c +++ b/tests/echo/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/echo/host/CMakeLists.txt b/tests/echo/host/CMakeLists.txt index ec919b9a13..e18982fa3a 100644 --- a/tests/echo/host/CMakeLists.txt +++ b/tests/echo/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/echo/host/host.c b/tests/echo/host/host.c index 1b112e9823..0bc362d4b1 100644 --- a/tests/echo/host/host.c +++ b/tests/echo/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/enclaveparam/CMakeLists.txt b/tests/enclaveparam/CMakeLists.txt index 3e0ba3fdbc..6a4d325361 100644 --- a/tests/enclaveparam/CMakeLists.txt +++ b/tests/enclaveparam/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/enclaveparam/enc/CMakeLists.txt b/tests/enclaveparam/enc/CMakeLists.txt index f422f0fadd..f72d0c2ae7 100644 --- a/tests/enclaveparam/enc/CMakeLists.txt +++ b/tests/enclaveparam/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/enclaveparam/enc/enc.c b/tests/enclaveparam/enc/enc.c index 057b2e078f..ba5f1d9d7c 100644 --- a/tests/enclaveparam/enc/enc.c +++ b/tests/enclaveparam/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/enclaveparam/enclaveparam.edl b/tests/enclaveparam/enclaveparam.edl index 7d8d32d5a8..82f6a62fd2 100644 --- a/tests/enclaveparam/enclaveparam.edl +++ b/tests/enclaveparam/enclaveparam.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/enclaveparam/host/CMakeLists.txt b/tests/enclaveparam/host/CMakeLists.txt index c49842715f..6deae88b81 100644 --- a/tests/enclaveparam/host/CMakeLists.txt +++ b/tests/enclaveparam/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/enclaveparam/host/host.c b/tests/enclaveparam/host/host.c index 96bac0ef23..a7a0d67cbc 100644 --- a/tests/enclaveparam/host/host.c +++ b/tests/enclaveparam/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/file/CMakeLists.txt b/tests/file/CMakeLists.txt index 0f706a768c..3909e646e3 100644 --- a/tests/file/CMakeLists.txt +++ b/tests/file/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/file/enc/CMakeLists.txt b/tests/file/enc/CMakeLists.txt index 5ebede1a89..4baeb06ccd 100644 --- a/tests/file/enc/CMakeLists.txt +++ b/tests/file/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/file/enc/enc.cpp b/tests/file/enc/enc.cpp index 58ba183a05..afc2f218a6 100644 --- a/tests/file/enc/enc.cpp +++ b/tests/file/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/file/file.edl b/tests/file/file.edl index 8c83da0664..c2ad0bf824 100644 --- a/tests/file/file.edl +++ b/tests/file/file.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/file/host/CMakeLists.txt b/tests/file/host/CMakeLists.txt index 9f18b6a93a..84949a1339 100644 --- a/tests/file/host/CMakeLists.txt +++ b/tests/file/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../file.edl host gen) diff --git a/tests/file/host/host.cpp b/tests/file/host/host.cpp index d18fe5b3a0..9a7d180440 100644 --- a/tests/file/host/host.cpp +++ b/tests/file/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/file/types.h b/tests/file/types.h index b056c6babc..0762045d59 100644 --- a/tests/file/types.h +++ b/tests/file/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/tests/getenclave/CMakeLists.txt b/tests/getenclave/CMakeLists.txt index 8069ab5134..d24fb02336 100644 --- a/tests/getenclave/CMakeLists.txt +++ b/tests/getenclave/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/getenclave/enc/CMakeLists.txt b/tests/getenclave/enc/CMakeLists.txt index 83b7ade62b..1b3eace7af 100644 --- a/tests/getenclave/enc/CMakeLists.txt +++ b/tests/getenclave/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/getenclave/enc/enc.c b/tests/getenclave/enc/enc.c index e04de20981..7e9c5d8684 100644 --- a/tests/getenclave/enc/enc.c +++ b/tests/getenclave/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/getenclave/getenclave.edl b/tests/getenclave/getenclave.edl index 1523e253ec..dc6f028bf7 100644 --- a/tests/getenclave/getenclave.edl +++ b/tests/getenclave/getenclave.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/getenclave/host/CMakeLists.txt b/tests/getenclave/host/CMakeLists.txt index d743cfdacd..79acbbfb37 100644 --- a/tests/getenclave/host/CMakeLists.txt +++ b/tests/getenclave/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/getenclave/host/host.c b/tests/getenclave/host/host.c index 5855429d45..0d18a9ab2c 100644 --- a/tests/getenclave/host/host.c +++ b/tests/getenclave/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/hexdump/CMakeLists.txt b/tests/hexdump/CMakeLists.txt index 6ecbbff27d..d82dc9cdae 100644 --- a/tests/hexdump/CMakeLists.txt +++ b/tests/hexdump/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/hexdump/args.h b/tests/hexdump/args.h index 89c9b8d03a..7eca1cbba6 100644 --- a/tests/hexdump/args.h +++ b/tests/hexdump/args.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _ARGS_H diff --git a/tests/hexdump/enc/CMakeLists.txt b/tests/hexdump/enc/CMakeLists.txt index f9c4f0e5d4..0d155c959d 100644 --- a/tests/hexdump/enc/CMakeLists.txt +++ b/tests/hexdump/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/hexdump/enc/enc.c b/tests/hexdump/enc/enc.c index 9bdf1df030..ef50cdde47 100644 --- a/tests/hexdump/enc/enc.c +++ b/tests/hexdump/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/hexdump/hexdump.edl b/tests/hexdump/hexdump.edl index fbfc0628ec..27d2523f32 100644 --- a/tests/hexdump/hexdump.edl +++ b/tests/hexdump/hexdump.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/hexdump/host/CMakeLists.txt b/tests/hexdump/host/CMakeLists.txt index 5806951923..aa6ababf8e 100644 --- a/tests/hexdump/host/CMakeLists.txt +++ b/tests/hexdump/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/hexdump/host/host.c b/tests/hexdump/host/host.c index a5384f4595..175c89f336 100644 --- a/tests/hexdump/host/host.c +++ b/tests/hexdump/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/host_verify/CMakeLists.txt b/tests/host_verify/CMakeLists.txt index c4a6057bac..7a88369750 100644 --- a/tests/host_verify/CMakeLists.txt +++ b/tests/host_verify/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/host_verify/host/CMakeLists.txt b/tests/host_verify/host/CMakeLists.txt index 2278763aba..fd4703505d 100644 --- a/tests/host_verify/host/CMakeLists.txt +++ b/tests/host_verify/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(test_host_verify host.cpp) diff --git a/tests/host_verify/host/host.cpp b/tests/host_verify/host/host.cpp index cd3c7eabb4..14c52ff31a 100644 --- a/tests/host_verify/host/host.cpp +++ b/tests/host_verify/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,6 +15,9 @@ #include #include +#include "../../../common/sgx/quote.h" +#include "../../../host/sgx/sgxquoteprovider.h" + #if defined(__linux__) #include #elif defined(_WIN32) @@ -110,54 +114,122 @@ static oe_result_t _verify_cert(const char* filename, bool pass) return oe_ret; } -static int _verify_report(const char* report_filename, bool pass) +static size_t _get_filesize(FILE* fp) { - FILE* report_fp = NULL; - int ret = -1; - size_t file_size = 0; - uint8_t* data = NULL; - oe_result_t result = OE_FAILURE; + size_t size = 0; + fseek(fp, 0, SEEK_END); + size = (size_t)ftell(fp); + fseek(fp, 0, SEEK_SET); - OE_TRACE_INFO("\n\nVerifying report %s\n", report_filename); - report_fp = fopen(report_filename, "rb"); - if (report_fp == NULL) - OE_TRACE_ERROR("Failed to find file: %s\n", report_fp); + return size; +} + +static void _read_binary_file( + const char* filename, + uint8_t** data_ptr, + size_t* size_ptr) +{ + FILE* fp = fopen(filename, "rb"); + size_t size = 0; + uint8_t* data = NULL; - OE_TEST(report_fp != NULL); + if (fp == NULL) + OE_TRACE_ERROR("Failed to find file: %s\n", filename); + OE_TEST(fp != NULL); // Find file size - fseek(report_fp, 0, SEEK_END); - file_size = (size_t)ftell(report_fp); - fseek(report_fp, 0, SEEK_SET); + size = _get_filesize(fp); - data = (uint8_t*)malloc((size_t)file_size); + data = (uint8_t*)malloc(size); OE_TEST(data != NULL); - size_t bytes_read = fread(data, sizeof(uint8_t), file_size, report_fp); - OE_TEST(bytes_read == file_size); + size_t bytes_read = fread(data, sizeof(uint8_t), size, fp); + OE_TEST(bytes_read == size); - result = oe_verify_remote_report(data, file_size, NULL); - if (pass) - OE_TEST(result == OE_OK); + if (fp) + fclose(fp); + + *data_ptr = data; + *size_ptr = bytes_read; +} + +static int _verify_report( + const char* report_filename, + const char* endorsements_filename, + bool pass) +{ + int ret = -1; + size_t report_file_size = 0; + size_t endorsements_file_size = 0; + uint8_t* report_data = NULL; + uint8_t* endorsements_data = NULL; + oe_result_t result = OE_FAILURE; + + OE_TRACE_INFO( + "\n\nVerifying report %s, endorsements: %s\n", + report_filename, + endorsements_filename); + + _read_binary_file(report_filename, &report_data, &report_file_size); + + if (endorsements_filename == NULL) + { + result = oe_verify_remote_report( + report_data, report_file_size, NULL, 0, NULL); + if (pass) + OE_TEST(result == OE_OK); + else + { + // Note: The failure result code is different between linux vs + // windows. + // + OE_TEST(result != OE_OK); + OE_TRACE_INFO( + "Report %s verification failed as expected. Failure %d(%s)\n", + report_filename, + result, + oe_result_str(result)); + } + + OE_TRACE_INFO("Report %s verified successfully!\n\n", report_filename); + } else { - // Note: Failure results are different when running in linux vs windows. - OE_TEST(result != OE_OK); - OE_TRACE_INFO( - "Report %s verification failed as expected. Failure %d(%s)\n", - report_filename, - result, - oe_result_str(result)); + _read_binary_file( + endorsements_filename, &endorsements_data, &endorsements_file_size); + + result = oe_verify_sgx_quote( + report_data, + report_file_size, + endorsements_data, + endorsements_file_size, + NULL); + + if (pass) + OE_TEST(result == OE_OK); + else + { + // Note: The failure result code is different between linux vs + // windows. + // + OE_TEST(result != OE_OK); + OE_TRACE_INFO( + "Report %s and collateral %s verification failed as expected. " + "Failure %d(%s)\n", + report_filename, + endorsements_filename, + result, + oe_result_str(result)); + } + + OE_TRACE_INFO("Report %s verified successfully!\n\n", report_filename); } - - OE_TRACE_INFO("Report %s verified successfully!\n\n", report_filename); ret = 0; - if (report_fp != NULL) - fclose(report_fp); - - if (data != NULL) - free(data); + if (report_data != NULL) + free(report_data); + if (endorsements_data != NULL) + free(endorsements_data); return ret; } @@ -172,6 +244,10 @@ int main() return SKIP_RETURN_CODE; } + // + // Report only tests + // + // These files are generated by oecert and do not always exists. // Run these tests if the file exists. The Jenkins CI/CD system // is responsible for running oecert to generate these files. @@ -183,7 +259,7 @@ int main() _verify_cert(CERT_RSA_FILENAME, true); if (_validate_file(REPORT_FILENAME, false)) - _verify_report(REPORT_FILENAME, true); + _verify_report(REPORT_FILENAME, NULL, true); // These files are checked in and should always exist. if (_validate_file(CERT_EC_BAD_FILENAME, true)) @@ -193,7 +269,7 @@ int main() _verify_cert(CERT_RSA_BAD_FILENAME, false); if (_validate_file(REPORT_BAD_FILENAME, true)) - _verify_report(REPORT_BAD_FILENAME, false); + _verify_report(REPORT_BAD_FILENAME, NULL, false); return 0; } diff --git a/tests/hostcalls/CMakeLists.txt b/tests/hostcalls/CMakeLists.txt index 3572546dc1..284eaed5ae 100644 --- a/tests/hostcalls/CMakeLists.txt +++ b/tests/hostcalls/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/hostcalls/enc/CMakeLists.txt b/tests/hostcalls/enc/CMakeLists.txt index a95b0b3a03..682103e2de 100644 --- a/tests/hostcalls/enc/CMakeLists.txt +++ b/tests/hostcalls/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/hostcalls/enc/enc.cpp b/tests/hostcalls/enc/enc.cpp index 49224e62e5..cfc265d81d 100644 --- a/tests/hostcalls/enc/enc.cpp +++ b/tests/hostcalls/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/hostcalls/host/CMakeLists.txt b/tests/hostcalls/host/CMakeLists.txt index df0864d499..94136a3f7f 100644 --- a/tests/hostcalls/host/CMakeLists.txt +++ b/tests/hostcalls/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/hostcalls/host/host.cpp b/tests/hostcalls/host/host.cpp index 0af106afa6..dfb9e796d7 100644 --- a/tests/hostcalls/host/host.cpp +++ b/tests/hostcalls/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/hostcalls/hostcalls.edl b/tests/hostcalls/hostcalls.edl index a1ed57e846..aa9c90037f 100644 --- a/tests/hostcalls/hostcalls.edl +++ b/tests/hostcalls/hostcalls.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/hostcalls/types.h b/tests/hostcalls/types.h index 6ce1fe2d3f..85a0bdd576 100644 --- a/tests/hostcalls/types.h +++ b/tests/hostcalls/types.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/tests/initializers/CMakeLists.txt b/tests/initializers/CMakeLists.txt index ce98f27e39..bef9c30b2b 100644 --- a/tests/initializers/CMakeLists.txt +++ b/tests/initializers/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/initializers/enc/CMakeLists.txt b/tests/initializers/enc/CMakeLists.txt index 31d80990e7..8f23c6592c 100644 --- a/tests/initializers/enc/CMakeLists.txt +++ b/tests/initializers/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/initializers/enc/enc.c b/tests/initializers/enc/enc.c index b3eb865dd4..3fe497e549 100644 --- a/tests/initializers/enc/enc.c +++ b/tests/initializers/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/initializers/host/CMakeLists.txt b/tests/initializers/host/CMakeLists.txt index 97c71d24c1..0a3356c834 100644 --- a/tests/initializers/host/CMakeLists.txt +++ b/tests/initializers/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../initializers.edl host gen) diff --git a/tests/initializers/host/host.cpp b/tests/initializers/host/host.cpp index 00671064ba..2252d9ed32 100644 --- a/tests/initializers/host/host.cpp +++ b/tests/initializers/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/initializers/initializers.edl b/tests/initializers/initializers.edl index 54493ac973..f64989be5d 100644 --- a/tests/initializers/initializers.edl +++ b/tests/initializers/initializers.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/libc/CMakeLists.txt b/tests/libc/CMakeLists.txt index a5e8717718..effa21bf7e 100644 --- a/tests/libc/CMakeLists.txt +++ b/tests/libc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/libc/enc/CMakeLists.txt b/tests/libc/enc/CMakeLists.txt index f9d4356fa5..3c2d41fb7d 100644 --- a/tests/libc/enc/CMakeLists.txt +++ b/tests/libc/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/libc/enc/enc.c b/tests/libc/enc/enc.c index dc55985980..790b199468 100644 --- a/tests/libc/enc/enc.c +++ b/tests/libc/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libc/enc/include.c.in b/tests/libc/enc/include.c.in index ee36771d01..b9dc7e305c 100644 --- a/tests/libc/enc/include.c.in +++ b/tests/libc/enc/include.c.in @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // This is a template used by CMake. diff --git a/tests/libc/enc/tests.c.in b/tests/libc/enc/tests.c.in index 0866eb76de..631e912633 100644 --- a/tests/libc/enc/tests.c.in +++ b/tests/libc/enc/tests.c.in @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // This is a template used by CMake. diff --git a/tests/libc/host/CMakeLists.txt b/tests/libc/host/CMakeLists.txt index 0d37c61869..fcb1f14844 100644 --- a/tests/libc/host/CMakeLists.txt +++ b/tests/libc/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/libc/host/host.cpp b/tests/libc/host/host.cpp index 458bb96b0c..a327264a39 100644 --- a/tests/libc/host/host.cpp +++ b/tests/libc/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libc/libc.edl b/tests/libc/libc.edl index baced94d3e..90da019518 100644 --- a/tests/libc/libc.edl +++ b/tests/libc/libc.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/libc/tests.all b/tests/libc/tests.all index b05f22d3a3..42305aac72 100644 --- a/tests/libc/tests.all +++ b/tests/libc/tests.all @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. 3rdparty/musl/libc-test/src/api/main.c diff --git a/tests/libc/tests.cmake b/tests/libc/tests.cmake index ff22892220..2706ae7f30 100644 --- a/tests/libc/tests.cmake +++ b/tests/libc/tests.cmake @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) diff --git a/tests/libc/tests.supported.gcc b/tests/libc/tests.supported.gcc index e95892c7f2..7ff3710445 100644 --- a/tests/libc/tests.supported.gcc +++ b/tests/libc/tests.supported.gcc @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # The following tests need to be skipped when built with Clang using these cmake flags. diff --git a/tests/libcxx/CMakeLists.txt b/tests/libcxx/CMakeLists.txt index 6bbec32dfe..5cf4f1f8b7 100644 --- a/tests/libcxx/CMakeLists.txt +++ b/tests/libcxx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # read tests.supported, sanitize the cpp-file, and create the test-case diff --git a/tests/libcxx/enc/CMakeLists.txt b/tests/libcxx/enc/CMakeLists.txt index 040ec9defc..50c0a21f38 100644 --- a/tests/libcxx/enc/CMakeLists.txt +++ b/tests/libcxx/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # create a binary for each testcase listed in ../tests.supported diff --git a/tests/libcxx/enc/enc.cpp b/tests/libcxx/enc/enc.cpp index 284cb302b0..0214493d5a 100644 --- a/tests/libcxx/enc/enc.cpp +++ b/tests/libcxx/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libcxx/enc/fuzzing.cpp b/tests/libcxx/enc/fuzzing.cpp index e2db62e0cc..690eb089f2 100644 --- a/tests/libcxx/enc/fuzzing.cpp +++ b/tests/libcxx/enc/fuzzing.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../../3rdparty/libcxx/libcxx/fuzzing/fuzzing.cpp" diff --git a/tests/libcxx/enc/main.cpp b/tests/libcxx/enc/main.cpp index 205f60e3c3..385cc81cda 100644 --- a/tests/libcxx/enc/main.cpp +++ b/tests/libcxx/enc/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // This file exists so that each test has its own copy of diff --git a/tests/libcxx/enc/memory_resource.cpp b/tests/libcxx/enc/memory_resource.cpp index de8f99a31d..ac0c050e5d 100644 --- a/tests/libcxx/enc/memory_resource.cpp +++ b/tests/libcxx/enc/memory_resource.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../../3rdparty/libcxx/libcxx/src/experimental/memory_resource.cpp" diff --git a/tests/libcxx/host/CMakeLists.txt b/tests/libcxx/host/CMakeLists.txt index bc7f28e9fa..f4329f4850 100644 --- a/tests/libcxx/host/CMakeLists.txt +++ b/tests/libcxx/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../libcxx.edl host gen) diff --git a/tests/libcxx/host/host.cpp b/tests/libcxx/host/host.cpp index f7365a8085..694152550f 100644 --- a/tests/libcxx/host/host.cpp +++ b/tests/libcxx/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libcxx/host/threadArgs.h b/tests/libcxx/host/threadArgs.h index 47137676e5..7937196855 100644 --- a/tests/libcxx/host/threadArgs.h +++ b/tests/libcxx/host/threadArgs.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _THREAD_ARGS_H diff --git a/tests/libcxx/libcxx.edl b/tests/libcxx/libcxx.edl index 092cf94568..fab42b80d7 100644 --- a/tests/libcxx/libcxx.edl +++ b/tests/libcxx/libcxx.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/libcxxrt/CMakeLists.txt b/tests/libcxxrt/CMakeLists.txt index 7ba5d6fae9..de360a5cf7 100644 --- a/tests/libcxxrt/CMakeLists.txt +++ b/tests/libcxxrt/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/libcxxrt/enc/CMakeLists.txt b/tests/libcxxrt/enc/CMakeLists.txt index 646f0b70da..c4fe54bd50 100644 --- a/tests/libcxxrt/enc/CMakeLists.txt +++ b/tests/libcxxrt/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/libcxxrt/enc/enc.cpp b/tests/libcxxrt/enc/enc.cpp index 05206f608b..634312c8bc 100644 --- a/tests/libcxxrt/enc/enc.cpp +++ b/tests/libcxxrt/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/tests/libcxxrt/enc/main.cpp b/tests/libcxxrt/enc/main.cpp index 7365181f16..e70e480505 100644 --- a/tests/libcxxrt/enc/main.cpp +++ b/tests/libcxxrt/enc/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. const char* __TEST__NAME = __TEST__; diff --git a/tests/libcxxrt/enc/test.cpp b/tests/libcxxrt/enc/test.cpp index 034fdcbfa4..a950167807 100644 --- a/tests/libcxxrt/enc/test.cpp +++ b/tests/libcxxrt/enc/test.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/tests/libcxxrt/enc/test_exception.cpp b/tests/libcxxrt/enc/test_exception.cpp index cda50c40bd..06aa0fff29 100644 --- a/tests/libcxxrt/enc/test_exception.cpp +++ b/tests/libcxxrt/enc/test_exception.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../../3rdparty/libcxxrt/libcxxrt/test/test_exception.cc" diff --git a/tests/libcxxrt/enc/test_foreign_exceptions.cpp b/tests/libcxxrt/enc/test_foreign_exceptions.cpp index e54d1d191d..191e9e8cd8 100644 --- a/tests/libcxxrt/enc/test_foreign_exceptions.cpp +++ b/tests/libcxxrt/enc/test_foreign_exceptions.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../../3rdparty/libcxxrt/libcxxrt/test/test_foreign_exceptions.cc" diff --git a/tests/libcxxrt/enc/test_guard.cpp b/tests/libcxxrt/enc/test_guard.cpp index 0a6e5fa0ed..4313ff196f 100644 --- a/tests/libcxxrt/enc/test_guard.cpp +++ b/tests/libcxxrt/enc/test_guard.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../../3rdparty/libcxxrt/libcxxrt/test/test_guard.cc" diff --git a/tests/libcxxrt/enc/test_typeinfo.cpp b/tests/libcxxrt/enc/test_typeinfo.cpp index 37cfdf1e09..ea9667d9bb 100644 --- a/tests/libcxxrt/enc/test_typeinfo.cpp +++ b/tests/libcxxrt/enc/test_typeinfo.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../../../3rdparty/libcxxrt/libcxxrt/test/test_typeinfo.cc" diff --git a/tests/libcxxrt/host/CMakeLists.txt b/tests/libcxxrt/host/CMakeLists.txt index 1cc3e7a49e..15c49ba7e8 100644 --- a/tests/libcxxrt/host/CMakeLists.txt +++ b/tests/libcxxrt/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/libcxxrt/host/host.cpp b/tests/libcxxrt/host/host.cpp index bd47f90bd2..f633e68bd5 100644 --- a/tests/libcxxrt/host/host.cpp +++ b/tests/libcxxrt/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. /* diff --git a/tests/libcxxrt/host/ocalls.h b/tests/libcxxrt/host/ocalls.h index 2e09bc475e..785131511d 100644 --- a/tests/libcxxrt/host/ocalls.h +++ b/tests/libcxxrt/host/ocalls.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _RUNTEST_OCALLS_H diff --git a/tests/libcxxrt/libcxxrt.edl b/tests/libcxxrt/libcxxrt.edl index f34c024c74..234fca016f 100644 --- a/tests/libcxxrt/libcxxrt.edl +++ b/tests/libcxxrt/libcxxrt.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/libcxxrt/run.bat b/tests/libcxxrt/run.bat index 54627962a5..7847d70ee0 100644 --- a/tests/libcxxrt/run.bat +++ b/tests/libcxxrt/run.bat @@ -1,4 +1,4 @@ -:: Copyright (c) Microsoft Corporation. All rights reserved. +:: Copyright (c) Open Enclave SDK contributors. :: Licensed under the MIT License. @echo off echo %1 diff --git a/tests/libunwind/CMakeLists.txt b/tests/libunwind/CMakeLists.txt index cf2ec8ff0d..31c3fdad93 100644 --- a/tests/libunwind/CMakeLists.txt +++ b/tests/libunwind/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # read tests.supported, sanitize the c-file, and create the test-case diff --git a/tests/libunwind/enc/CMakeLists.txt b/tests/libunwind/enc/CMakeLists.txt index 03b2b476ec..dcdadf923f 100644 --- a/tests/libunwind/enc/CMakeLists.txt +++ b/tests/libunwind/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Create a binary for each testcase listed in ../tests.supported diff --git a/tests/libunwind/enc/clang_varargs_extra.h b/tests/libunwind/enc/clang_varargs_extra.h index 102d372649..b67a03e79c 100644 --- a/tests/libunwind/enc/clang_varargs_extra.h +++ b/tests/libunwind/enc/clang_varargs_extra.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // Provide forward declarations of functions in libunwind test suite diff --git a/tests/libunwind/enc/enc.c b/tests/libunwind/enc/enc.c index 6042dfce7a..5257625460 100644 --- a/tests/libunwind/enc/enc.c +++ b/tests/libunwind/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libunwind/enc/pid.h b/tests/libunwind/enc/pid.h index de970921d7..621a083a59 100644 --- a/tests/libunwind/enc/pid.h +++ b/tests/libunwind/enc/pid.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TESTS_LIBUNWIND_ENC_PID_H diff --git a/tests/libunwind/enc/test_support.c b/tests/libunwind/enc/test_support.c index c2cadc3d3b..0f56f60cb1 100644 --- a/tests/libunwind/enc/test_support.c +++ b/tests/libunwind/enc/test_support.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libunwind/host/CMakeLists.txt b/tests/libunwind/host/CMakeLists.txt index a5772db299..dcc0a9e9e4 100644 --- a/tests/libunwind/host/CMakeLists.txt +++ b/tests/libunwind/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/libunwind/host/host.cpp b/tests/libunwind/host/host.cpp index f0d957da76..fa1adb550a 100644 --- a/tests/libunwind/host/host.cpp +++ b/tests/libunwind/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/libunwind/libunwind.edl b/tests/libunwind/libunwind.edl index b200168ca3..515c161e8e 100644 --- a/tests/libunwind/libunwind.edl +++ b/tests/libunwind/libunwind.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/lockless_queue/CMakeLists.txt b/tests/lockless_queue/CMakeLists.txt deleted file mode 100644 index edb85a8bac..0000000000 --- a/tests/lockless_queue/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - - -add_subdirectory(host) - -if (BUILD_ENCLAVES) - add_subdirectory(enc) -endif() - -add_enclave_test(tests/lockless_queue lockless_queue_host lockless_queue_enc) diff --git a/tests/lockless_queue/enc/CMakeLists.txt b/tests/lockless_queue/enc/CMakeLists.txt deleted file mode 100644 index 3454e6b178..0000000000 --- a/tests/lockless_queue/enc/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -oeedl_file(../lockless_queue.edl enclave gen) - -add_enclave(TARGET lockless_queue_enc UUID eb99d409-3d52-439c-b374-87f664136434 SOURCES enc.c ${gen}) - -target_include_directories(lockless_queue_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(lockless_queue_enc oelibc) diff --git a/tests/lockless_queue/enc/enc.c b/tests/lockless_queue/enc/enc.c deleted file mode 100644 index 20fd79bea6..0000000000 --- a/tests/lockless_queue/enc/enc.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. */ - -#include -#include - -#ifdef _MSC_VER -#include -#endif /* _MSC_VER */ - -void enc_push_nodes( - oe_lockless_queue* p_queue, - test_node* p_nodes, - size_t count) -{ - /* push the nodes onto the queue */ - for (size_t i = 0; i < count; ++i) - { - oe_lockless_queue_push_back(p_queue, &((p_nodes + i)->_node)); - } -} /* enc_push_nodes */ - -void enc_writer_thread( - oe_lockless_queue* p_queue, - test_node* p_nodes, - size_t* p_barrier) -{ - size_t barrier_count; - - /* wait for all of the threads to start */ -#ifdef _MSC_VER - barrier_count = _InterlockedIncrement64(data->p_barrier); - while (barrier_count < THREAD_COUNT) - { - barrier_count = _InterlockedCompareExchange64 (data->p_barrier, 0, 0)); - } -#elif defined __GNUC__ - barrier_count = __atomic_add_fetch(p_barrier, 1, __ATOMIC_ACQ_REL); - while (THREAD_COUNT > barrier_count) - { - barrier_count = __atomic_load_n(p_barrier, __ATOMIC_ACQUIRE); - } -#endif /* _MSC_VER or __GNUC__ */ - - /* push this thread's nodes onto the queue */ - enc_push_nodes(p_queue, p_nodes, TEST_COUNT); -} /* enc_writer_thread */ - -void enc_pop_nodes(oe_lockless_queue* p_queue, size_t count) -{ - size_t node_count = 0; - - /* pop the nodes off of the queue */ - while (node_count < count) - { - oe_lockless_queue_node* p_node = oe_lockless_queue_pop_front(p_queue); - if (NULL != p_node) - { - test_node* p_test_node = (test_node*)p_node; - ++(p_test_node->count); - p_test_node->pop_order = node_count; - ++node_count; - } - } -} /* enc_pop_nodes */ - -void enc_test_queue_single_threaded() -{ - oe_lockless_queue queue; - oe_lockless_queue_node nodes[TEST_COUNT]; - oe_lockless_queue_node* p_node = NULL; - - oe_lockless_queue_init(&queue); - - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - for (size_t i = 0; i < (TEST_COUNT); ++i) - { - oe_lockless_queue_node_init(nodes + i); - } - - for (size_t i = 0; i < (TEST_COUNT); ++i) - { - oe_lockless_queue_push_back(&queue, nodes + i); - } - - for (size_t i = 0; i < (TEST_COUNT); ++i) - { - p_node = oe_lockless_queue_pop_front(&queue); - OE_TEST(p_node == nodes + i); - } -} /* enc_test_queue_single_threaded */ - -OE_SET_ENCLAVE_SGX( - 1, /* ProductID */ - 1, /* SecurityVersion */ - true, /* AllowDebug */ - 1024, /* HeapPageCount */ - 128, /* StackPageCount */ - 16); /* TCSCount */ - -#define TA_UUID \ - { /* eb99d409-3d52-439c-b374-87f664136434 */ \ - 0xeb99d409, 0x3d52, 0x439c, \ - { \ - 0xb3, 0x74, 0x87, 0xf6, 0x64, 0x13, 0x64, 0x34 \ - } \ - } - -OE_SET_ENCLAVE_OPTEE( - TA_UUID, - 1 * 1024 * 1024, - 12 * 1024, - TA_FLAG_EXEC_DDR, - "1.0.0", - "Lockless Queue test") diff --git a/tests/lockless_queue/host/CMakeLists.txt b/tests/lockless_queue/host/CMakeLists.txt deleted file mode 100644 index a873708e7f..0000000000 --- a/tests/lockless_queue/host/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -oeedl_file(../lockless_queue.edl host gen) - -add_executable(lockless_queue_host host.c ${gen}) - -target_include_directories(lockless_queue_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - -target_link_libraries(lockless_queue_host oehostapp) diff --git a/tests/lockless_queue/host/host.c b/tests/lockless_queue/host/host.c deleted file mode 100644 index be20fdf342..0000000000 --- a/tests/lockless_queue/host/host.c +++ /dev/null @@ -1,507 +0,0 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. */ - -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -//#include -#include -#elif defined __GNUC__ -#include -#endif /* _MSC_VER or __GNUC__ */ - -#ifdef _MSC_VER - -#define THREAD_RETURN_TYPE DWORD WINAPI -#define THREAD_ARG_TYPE LPVOID -#define THREAD_RETURN_VAL 0 -#define THREAD_TYPE HANDLE - -typedef DWORD (*thread_op_t)(THREAD_ARG_TYPE); - -int thread_create(THREAD_TYPE* thread, thread_op_t op, THREAD_ARG_TYPE arg) -{ - *thread = CreateThread(NULL, 0, op, arg, 0, NULL); - return NULL == *thread; -} /* thread_create */ - -void thread_join(THREAD_TYPE thread) -{ - WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); -} /* thread_join */ - -#elif defined __GNUC__ - -#define THREAD_RETURN_TYPE void* -#define THREAD_ARG_TYPE void* -#define THREAD_RETURN_VAL NULL -#define THREAD_TYPE pthread_t - -typedef THREAD_RETURN_TYPE (*thread_op_t)(THREAD_ARG_TYPE); - -int thread_create(THREAD_TYPE* thread, thread_op_t op, THREAD_ARG_TYPE arg) -{ - return pthread_create(thread, NULL, op, arg); -} /* thread_create */ - -void thread_join(THREAD_TYPE thread) -{ - pthread_join(thread, NULL); -} /* thread_join */ - -#endif /* _MSC_VER or __GNUC__ */ - -static void host_queue_single_thread_test() -{ - oe_lockless_queue queue; - oe_lockless_queue_node nodes[TEST_COUNT]; - oe_lockless_queue_node* p_node = NULL; - - printf("\n"); - - oe_lockless_queue_init(&queue); - - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - oe_lockless_queue_node_init(nodes + i); - } - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - oe_lockless_queue_push_back(&queue, nodes + i); - } - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - p_node = oe_lockless_queue_pop_front(&queue); - OE_TEST(p_node == nodes + i); - } - - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - printf("\n"); -} /* host_queue_single_thread_test */ - -static void test_node_init(test_node* p_node) -{ - oe_lockless_queue_node_init(&(p_node->_node)); - p_node->count = 0; - p_node->pop_order = 0; -} /* test_node_init */ - -typedef struct _thread_data -{ - oe_lockless_queue* p_queue; - test_node* p_nodes; - size_t* p_barrier; - THREAD_TYPE thread; - oe_enclave_t* enclave; -} thread_data; - -THREAD_RETURN_TYPE host_writer_thread(THREAD_ARG_TYPE _data) -{ - size_t barrier_count; - thread_data* data = (thread_data*)_data; - - printf(" host_writer_thread started\n"); - - /* wait for all threads to start */ -#ifdef _MSC_VER - barrier_count = _InterlockedIncrement64(data->p_barrier); - while (barrier_count < THREAD_COUNT) - { - barrier_count = _InterlockedCompareExchange64(data->p_barrier, 0, 0); - } -#elif defined __GNUC__ - barrier_count = __atomic_add_fetch(data->p_barrier, 1, __ATOMIC_ACQ_REL); - while (barrier_count < THREAD_COUNT) - { - barrier_count = __atomic_load_n(data->p_barrier, __ATOMIC_ACQUIRE); - } -#endif /* _MSC_VER or __GNUC__ */ - - /* push this thread's nodes onto the queue */ - for (size_t i = 0; i < TEST_COUNT; ++i) - { - oe_lockless_queue_push_back( - data->p_queue, (&(data->p_nodes + i)->_node)); - } - - printf(" host_writer_thread finished\n"); - - return THREAD_RETURN_VAL; -} /* host_writer_thread */ - -THREAD_RETURN_TYPE host_reader_thread(THREAD_ARG_TYPE _data) -{ - oe_lockless_queue* p_queue = (oe_lockless_queue*)_data; - size_t node_count = 0; - - printf(" host_reader_thread - started\n"); - - /* pop the nodes off of the queue */ - while (node_count < TEST_COUNT * THREAD_COUNT) - { - oe_lockless_queue_node* p_node = oe_lockless_queue_pop_front(p_queue); - if (NULL != p_node) - { - test_node* p_test_node = (test_node*)p_node; - ++(p_test_node->count); - p_test_node->pop_order = node_count; - ++node_count; - } - } - printf(" host_reader_thread - finished\n"); - return THREAD_RETURN_VAL; -} /* host_reader_thread */ - -THREAD_RETURN_TYPE enc_writer_thread_wrapper(THREAD_ARG_TYPE _data) -{ - OE_UNUSED(_data); - thread_data* data = (thread_data*)_data; - - printf(" enc_writer_thread - started\n"); - OE_TEST( - OE_OK == - enc_writer_thread( - data->enclave, data->p_queue, data->p_nodes, data->p_barrier)); - printf(" enc_writer_thread - finished\n"); - return THREAD_RETURN_VAL; -} /* enc_writer_thread */ - -THREAD_RETURN_TYPE enc_reader_thread_wrapper(THREAD_ARG_TYPE _data) -{ - thread_data* data = (thread_data*)_data; - printf(" enc_reader_thread started\n"); - OE_TEST( - OE_OK == - enc_pop_nodes(data->enclave, data->p_queue, TEST_COUNT * THREAD_COUNT)); - printf(" enc_reader_thread finished\n"); - return THREAD_RETURN_VAL; -} /* host_reader_thread */ - -static void host_queue_multi_thread_test() -{ - size_t barrier = 0; - thread_data threads[THREAD_COUNT]; - test_node nodes[THREAD_COUNT * TEST_COUNT]; - THREAD_TYPE reader; - oe_lockless_queue queue; - - printf("\n"); - - oe_lockless_queue_init(&queue); - for (size_t i = 0; i < THREAD_COUNT * TEST_COUNT; ++i) - { - test_node_init(nodes + i); - } - - OE_TEST(0 == thread_create(&reader, host_reader_thread, &queue)); - - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - threads[i].p_barrier = &barrier; - threads[i].p_nodes = nodes + i * TEST_COUNT; - threads[i].p_queue = &queue; - threads[i].enclave = NULL; - OE_TEST( - 0 == thread_create( - &(threads[i].thread), host_writer_thread, threads + i)); - } - - thread_join(reader); - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - size_t last_pop_order = 0; - thread_join(threads[i].thread); - OE_TEST(1 == nodes[TEST_COUNT * i].count); - last_pop_order = nodes[TEST_COUNT * i].pop_order; - for (size_t j = 1; j < TEST_COUNT; ++j) - { - OE_TEST(1 == nodes[TEST_COUNT * i + j].count); - OE_TEST(last_pop_order <= nodes[TEST_COUNT * i + j].pop_order); - last_pop_order = nodes[TEST_COUNT * i + j].pop_order; - } - } - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - printf("\n"); -} /* host_queue_multi_thread_test */ - -static void enc_queue_single_thread_test(oe_enclave_t* enclave) -{ - printf("\n"); - - OE_TEST(OE_OK == enc_test_queue_single_threaded(enclave)); - - printf("\n"); -} /* enc_queue_single_thread_test */ - -static void enc_queue_multi_thread_test(oe_enclave_t* enclave) -{ - size_t barrier = 0; - thread_data threads[THREAD_COUNT]; - test_node nodes[THREAD_COUNT * TEST_COUNT]; - oe_lockless_queue queue; - thread_data reader_thread; - - printf("\n"); - - oe_lockless_queue_init(&queue); - for (size_t i = 0; i < THREAD_COUNT * TEST_COUNT; ++i) - { - test_node_init(nodes + i); - } - - reader_thread.enclave = enclave; - reader_thread.p_queue = &queue; - - OE_TEST( - 0 == thread_create( - &(reader_thread.thread), - enc_reader_thread_wrapper, - &reader_thread)); - - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - threads[i].p_barrier = &barrier; - threads[i].p_nodes = nodes + i * TEST_COUNT; - threads[i].p_queue = &queue; - threads[i].enclave = enclave; - OE_TEST( - 0 == - thread_create( - &(threads[i].thread), enc_writer_thread_wrapper, threads + i)); - } - - thread_join(reader_thread.thread); - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - size_t last_pop_order = 0; - thread_join(threads[i].thread); - OE_TEST(1 == nodes[TEST_COUNT * i].count); - last_pop_order = nodes[TEST_COUNT * i].pop_order; - for (size_t j = 1; j < TEST_COUNT; ++j) - { - OE_TEST(1 == nodes[TEST_COUNT * i + j].count); - OE_TEST(last_pop_order <= nodes[TEST_COUNT * i + j].pop_order); - last_pop_order = nodes[TEST_COUNT * i + j].pop_order; - } - } - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - printf("\n"); -} /*enc_queue_multi_thread_test */ - -static void host_enq_enc_deq_single_thread_test(oe_enclave_t* enclave) -{ - oe_lockless_queue queue; - test_node nodes[TEST_COUNT]; - - printf("\n"); - - oe_lockless_queue_init(&queue); - - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - test_node_init(nodes + i); - } - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - oe_lockless_queue_push_back( - &queue, (oe_lockless_queue_node*)&(nodes[i]._node)); - } - - OE_TEST(OE_OK == enc_pop_nodes(enclave, &queue, TEST_COUNT)); - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - OE_TEST(1 == nodes[i].count); - OE_TEST(i == nodes[i].pop_order); - } - - printf("\n"); -} /* host_enq_enc_deq_single_thread_test */ - -static void host_enq_enc_deq_multi_thread_test(oe_enclave_t* enclave) -{ - size_t barrier = 0; - thread_data threads[THREAD_COUNT]; - test_node nodes[THREAD_COUNT * TEST_COUNT]; - oe_lockless_queue queue; - thread_data reader_thread; - - printf("\n"); - - oe_lockless_queue_init(&queue); - for (size_t i = 0; i < THREAD_COUNT * TEST_COUNT; ++i) - { - test_node_init(nodes + i); - } - - reader_thread.enclave = enclave; - reader_thread.p_queue = &queue; - - OE_TEST( - 0 == thread_create( - &(reader_thread.thread), - enc_reader_thread_wrapper, - &reader_thread)); - - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - threads[i].p_barrier = &barrier; - threads[i].p_nodes = nodes + i * TEST_COUNT; - threads[i].p_queue = &queue; - threads[i].enclave = NULL; - OE_TEST( - 0 == thread_create( - &(threads[i].thread), host_writer_thread, threads + i)); - } - - thread_join(reader_thread.thread); - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - size_t last_pop_order = 0; - thread_join(threads[i].thread); - OE_TEST(1 == nodes[TEST_COUNT * i].count); - last_pop_order = nodes[TEST_COUNT * i].pop_order; - for (size_t j = 1; j < TEST_COUNT; ++j) - { - OE_TEST(1 == nodes[TEST_COUNT * i + j].count); - OE_TEST(last_pop_order <= nodes[TEST_COUNT * i + j].pop_order); - last_pop_order = nodes[TEST_COUNT * i + j].pop_order; - } - } - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - printf("\n"); -} /* host_enq_enc_deq_multi_thread_test */ - -static void enc_enq_host_deq_single_thread_test(oe_enclave_t* enclave) -{ - test_node nodes[TEST_COUNT]; - oe_lockless_queue queue; - test_node* p_node = NULL; - - printf("\n"); - - oe_lockless_queue_init(&queue); - for (size_t i = 0; i < TEST_COUNT; ++i) - { - test_node_init(nodes + i); - } - - OE_TEST(OE_OK == enc_push_nodes(enclave, &queue, nodes, TEST_COUNT)); - - for (size_t i = 0; i < TEST_COUNT; ++i) - { - p_node = (test_node*)oe_lockless_queue_pop_front(&queue); - OE_TEST(p_node == nodes + i); - } - - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - printf("\n"); -} /* enc_enq_host_deq_single_thread_test */ - -static void enc_enq_host_deq_multi_thread_test(oe_enclave_t* enclave) -{ - size_t barrier = 0; - thread_data threads[THREAD_COUNT]; - test_node nodes[THREAD_COUNT * TEST_COUNT]; - THREAD_TYPE reader_thread; - oe_lockless_queue queue; - - printf("\n"); - - oe_lockless_queue_init(&queue); - for (size_t i = 0; i < THREAD_COUNT * TEST_COUNT; ++i) - { - test_node_init(nodes + i); - } - - OE_TEST(0 == thread_create(&reader_thread, host_reader_thread, &queue)); - - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - threads[i].p_barrier = &barrier; - threads[i].p_nodes = nodes + i * TEST_COUNT; - threads[i].p_queue = &queue; - threads[i].enclave = enclave; - OE_TEST( - 0 == - thread_create( - &(threads[i].thread), enc_writer_thread_wrapper, threads + i)); - } - - thread_join(reader_thread); - for (size_t i = 0; i < THREAD_COUNT; ++i) - { - size_t last_pop_order = 0; - thread_join(threads[i].thread); - OE_TEST(1 == nodes[TEST_COUNT * i].count); - last_pop_order = nodes[TEST_COUNT * i].pop_order; - for (size_t j = 1; j < TEST_COUNT; ++j) - { - OE_TEST(1 == nodes[TEST_COUNT * i + j].count); - OE_TEST(last_pop_order <= nodes[TEST_COUNT * i + j].pop_order); - last_pop_order = nodes[TEST_COUNT * i + j].pop_order; - } - } - OE_TEST(NULL == oe_lockless_queue_pop_front(&queue)); - - printf("\n"); -} /* enc_enq_host_deq_multi_thread_test */ - -int main(int argc, const char** argv) -{ - oe_result_t result = OE_OK; - const uint32_t flags = oe_get_create_flags(); - oe_enclave_t* enclave; - - if (argc != 2) - { - fprintf(stderr, "Usage: %s ENCLAVE\n", argv[0]); - exit(1); - } - - /* these tests are executed within the host */ - host_queue_single_thread_test(); - host_queue_multi_thread_test(); - - result = oe_create_lockless_queue_enclave( - argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave); - if (OE_OK != result) - { - oe_put_err("oe_create_lockless_queue_enclave(): result=%u", result); - } - - /* these tests are executed within the enclave */ - enc_queue_single_thread_test(enclave); - enc_queue_multi_thread_test(enclave); - - /* these tests enqueue nodes from the host and dequeue nodes from the - * enclave */ - host_enq_enc_deq_single_thread_test(enclave); - host_enq_enc_deq_multi_thread_test(enclave); - - /* these tests enqueue nodes from the enclave and dequeue nodes from the - * host */ - enc_enq_host_deq_single_thread_test(enclave); - enc_enq_host_deq_multi_thread_test(enclave); - - oe_terminate_enclave(enclave); - - return 0; -} diff --git a/tests/lockless_queue/lockless_queue.edl b/tests/lockless_queue/lockless_queue.edl deleted file mode 100644 index 63b29c8428..0000000000 --- a/tests/lockless_queue/lockless_queue.edl +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -enclave { - include "openenclave/internal/lockless_queue.h" - - enum constants { - TEST_COUNT = 1024, - THREAD_COUNT = 5 - }; - - struct test_node{ - oe_lockless_queue_node _node; - size_t count; - size_t pop_order; - }; - - trusted { - public void enc_push_nodes( - [user_check] oe_lockless_queue* p_queue, - [user_check] test_node* p_nodes, - size_t count); - - public void enc_writer_thread( - [user_check] oe_lockless_queue* p_queue, - [user_check] test_node* p_nodes, - [user_check] size_t* p_barrier); - - public void enc_pop_nodes( - [user_check] oe_lockless_queue* p_queue, - size_t count); - - public void enc_test_queue_single_threaded(); - }; -}; diff --git a/tests/logging/CMakeLists.txt b/tests/logging/CMakeLists.txt new file mode 100644 index 0000000000..2562003596 --- /dev/null +++ b/tests/logging/CMakeLists.txt @@ -0,0 +1,7 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_executable(logging main.c) +target_link_libraries(logging oehost) + +add_test(NAME tests/logging COMMAND logging WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/tests/logging/main.c b/tests/logging/main.c new file mode 100644 index 0000000000..e32cf32457 --- /dev/null +++ b/tests/logging/main.c @@ -0,0 +1,85 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ + { \ + { \ + } \ + } + +#include +#include +#include "../host/traceh.c" + +void test_escaped_msg(const char* msg, const char* expected, bool expect_ok) +{ + size_t msg_size = strlen(msg); + size_t max_msg_size = MAX_ESCAPED_MSG_MULTIPLIER * msg_size + 1; + char* msg_escaped = malloc(max_msg_size); + bool ok = _escape_characters(msg, msg_escaped, msg_size, max_msg_size); + if (!ok || !expect_ok) + { + if (ok != expect_ok) + { + oe_put_err( + "Expected escape result \"%s\" does not match actual escape " + "result \"%s\". Original log: %s | escaped log: %s", + expect_ok ? "true" : "false", + ok ? "true" : "false", + msg, + msg_escaped); + } + free(msg_escaped); + OE_TEST(!ok && !expect_ok); + return; + } + OE_TEST(strcmp(msg_escaped, expected) == 0); + free(msg_escaped); +} + +int TestEscapedCharacters() +{ + { + char msg[] = "Hey"; + char expected[] = "Hey"; + test_escaped_msg(msg, expected, true); + } + { + char msg[] = "\u2605"; +#if defined(__linux__) + test_escaped_msg(msg, "", false); +#else + char expected[] = "?"; + test_escaped_msg(msg, expected, true); +#endif + } + +#if defined(__linux__) + { + char msg[] = "\200"; + test_escaped_msg(msg, "", false); + } + { + char msg[] = "\037"; + char expected[] = "\\\\u001f"; + test_escaped_msg(msg, expected, true); + } + { + char msg[] = "\u2605\u0024"; + test_escaped_msg(msg, "", false); + } +#endif + { + char msg[] = "\\\\\\\\"; + char expected[] = "\\\\\\\\\\\\\\\\"; + test_escaped_msg(msg, expected, true); + } + printf("=== passed TestEscapedCharachters()\n"); + return 0; +} + +int main() +{ + TestEscapedCharacters(); + return 0; +} diff --git a/tests/mbed/CMakeLists.txt b/tests/mbed/CMakeLists.txt index c0344f7ccb..eb02f8ca8e 100644 --- a/tests/mbed/CMakeLists.txt +++ b/tests/mbed/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # read tests.supported, sanitize the cpp-file, and create the test-case diff --git a/tests/mbed/enc/CMakeLists.txt b/tests/mbed/enc/CMakeLists.txt index dd17b9ed0d..e6b9432e31 100644 --- a/tests/mbed/enc/CMakeLists.txt +++ b/tests/mbed/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # >> In one of the test "ssl" we are using a variable called new which is a function in C++ @@ -20,14 +20,23 @@ function(add_mbed_test_enclave NAME) set(MBEDTLS_TESTS_DIR "${PROJECT_SOURCE_DIR}/3rdparty/mbedtls/mbedtls/tests") + string(CONCAT GEN_TEST_CODE_SCRIPT "${MBEDTLS_TESTS_DIR}/scripts/generate_test_code.py" + " --suites-dir ${MBEDTLS_TESTS_DIR}/suites" + " --functions-file ${MBEDTLS_TESTS_DIR}/suites/test_suite_${suite_name}.function" + " --data-file ${MBEDTLS_TESTS_DIR}/suites/test_suite_${data_name}.data" + " --helpers-file ${MBEDTLS_TESTS_DIR}/suites/helpers.function" + " --template-file ${MBEDTLS_TESTS_DIR}/suites/main_test.function" + " --platform-file ${MBEDTLS_TESTS_DIR}/suites/host_test.function" + " --out-dir ${CMAKE_CURRENT_BINARY_DIR}") add_custom_command( - OUTPUT test_suite_${NAME}.c - COMMAND ${BASH} -c "perl ${MBEDTLS_TESTS_DIR}/scripts/generate_code.pl ${MBEDTLS_TESTS_DIR}/suites test_suite_${suite_name} test_suite_${data_name}" + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_suite_${NAME}.c + COMMAND ${OE_BASH} -c "python ${GEN_TEST_CODE_SCRIPT}" DEPENDS mbedcrypto - ${MBEDTLS_TESTS_DIR}/scripts/generate_code.pl + ${MBEDTLS_TESTS_DIR}/scripts/generate_test_code.py ${MBEDTLS_TESTS_DIR}/suites/helpers.function ${MBEDTLS_TESTS_DIR}/suites/main_test.function + ${MBEDTLS_TESTS_DIR}/suites/host_test.function ${MBEDTLS_TESTS_DIR}/suites/test_suite_${suite_name}.function ${MBEDTLS_TESTS_DIR}/suites/test_suite_${data_name}.data) diff --git a/tests/mbed/enc/enc.c b/tests/mbed/enc/enc.c index 2bdc686e79..21f8593d87 100644 --- a/tests/mbed/enc/enc.c +++ b/tests/mbed/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -146,6 +146,12 @@ static oe_result_t _syscall_hook( result = mbed_test_close(&rval, (int)arg1); break; } + case SYS_lseek: + { + int rval = 0; + result = mbed_test_lseek(&rval, (int)arg1, (off_t)arg2, (int)arg3); + break; + } case SYS_readv: default: { diff --git a/tests/mbed/enc/selftest_wrapper.c b/tests/mbed/enc/selftest_wrapper.c index 4d79e9d136..e615fbd2b8 100644 --- a/tests/mbed/enc/selftest_wrapper.c +++ b/tests/mbed/enc/selftest_wrapper.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/mbed/host/CMakeLists.txt b/tests/mbed/host/CMakeLists.txt index d076923ca2..07f9ad8355 100644 --- a/tests/mbed/host/CMakeLists.txt +++ b/tests/mbed/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. @@ -6,7 +6,7 @@ oeedl_file(../mbed.edl host gen) add_executable(libmbedtest_host host.c ocalls.c ${gen}) -target_compile_definitions(libmbedtest_host PRIVATE PROJECT_DIR="${CMAKE_SOURCE_DIR}/") +target_compile_definitions(libmbedtest_host PRIVATE PROJECT_DIR="${CMAKE_CURRENT_BINARY_DIR}/") if (NOT WIN32) target_compile_options(libmbedtest_host PRIVATE -Wno-error) endif() diff --git a/tests/mbed/host/host.c b/tests/mbed/host/host.c index f5fbeffcac..be003684d9 100644 --- a/tests/mbed/host/host.c +++ b/tests/mbed/host/host.c @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include #include +#include #include #include #include @@ -14,7 +15,7 @@ char* find_data_file(char* str, size_t size) { - char* tail = ".data"; + char* tail = ".datax"; char* checker = "test_suite_"; char* token; @@ -37,7 +38,7 @@ char* find_data_file(char* str, size_t size) void datafileloc(char* data_file_name, char* path) { - char* tail = "3rdparty/mbedtls/mbedtls/tests/suites/"; + char* tail = "../enc/"; #ifdef PROJECT_DIR strcpy(path, PROJECT_DIR); #else @@ -59,6 +60,14 @@ void datafileloc(char* data_file_name, char* path) strcat(path, tail); strcat(path, data_file_name); +#if defined(_WIN32) + /* On Windows, replace forward slashes with backslashes in the path */ + for (char* next = strchr(path, '/'); next; next = strchr(path, '/')) + { + *next = '\\'; + } +#endif + printf("######## data_fileloc: %s ###### \n", path); return; } @@ -78,6 +87,7 @@ void Test(oe_enclave_t* enclave, int selftest, char* data_file_name) oe_result_t result = test(enclave, &return_value, in_testname, out_testname, &args); + OE_TEST(result == OE_OK); if (!selftest) { @@ -109,6 +119,7 @@ int main(int argc, const char* argv[]) int selftest = 0; uint32_t flags = oe_get_create_flags(); char* data_file_name = NULL; + // Check argument count: if (argc != 2) { diff --git a/tests/mbed/host/ocalls.c b/tests/mbed/host/ocalls.c index f3ce724b26..9dce7d2581 100644 --- a/tests/mbed/host/ocalls.c +++ b/tests/mbed/host/ocalls.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -25,3 +25,8 @@ int mbed_test_close(int fd) { return close(fd); } + +int mbed_test_lseek(int fd, int offset, int whence) +{ + return lseek(fd, offset, whence); +} diff --git a/tests/mbed/mbed.edl b/tests/mbed/mbed.edl index 535d153037..c99ab30170 100644 --- a/tests/mbed/mbed.edl +++ b/tests/mbed/mbed.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { @@ -37,6 +37,11 @@ enclave { int mbed_test_close( int fd); + int mbed_test_lseek( + int fd, + int offset, + int whence); + void ocall_exit( int arg); }; diff --git a/tests/mbed/myfileio.h b/tests/mbed/myfileio.h index 6032f09914..322e50fd99 100644 --- a/tests/mbed/myfileio.h +++ b/tests/mbed/myfileio.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef TEST_MBED_MYFILEIO_H diff --git a/tests/mem/CMakeLists.txt b/tests/mem/CMakeLists.txt index e72861b4c2..cdc4b3ee54 100644 --- a/tests/mem/CMakeLists.txt +++ b/tests/mem/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(mem main.c) diff --git a/tests/mem/main.c b/tests/mem/main.c index eebc00947a..9e8f322b77 100644 --- a/tests/mem/main.c +++ b/tests/mem/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define MEM_MIN_CAP 1 diff --git a/tests/memory/CMakeLists.txt b/tests/memory/CMakeLists.txt index a2b8a6c169..cb3b2aafb2 100644 --- a/tests/memory/CMakeLists.txt +++ b/tests/memory/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/memory/enc/CMakeLists.txt b/tests/memory/enc/CMakeLists.txt index 6c9b48e5d3..40560818d1 100644 --- a/tests/memory/enc/CMakeLists.txt +++ b/tests/memory/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/memory/enc/basic.c b/tests/memory/enc/basic.c index 548014e6a2..1f27392071 100644 --- a/tests/memory/enc/basic.c +++ b/tests/memory/enc/basic.c @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include #include +#include #include #include @@ -168,3 +169,31 @@ void test_posix_memalign(void) /* Should fail if alignment isn't possible. */ OE_TEST(posix_memalign(&ptr, max, 64) != 0); } + +void test_malloc_usable_size(void) +{ + int* p1 = (int*)malloc(sizeof *p1); + OE_TEST(p1); + int* p2 = (int*)malloc(sizeof *p2); + OE_TEST(p2); + + /* Ensure that p1 < p2 so that we can use p2 as upper bound. */ + if (p1 > p2) + { + int* const tmp = p1; + p1 = p2; + p2 = tmp; + } + OE_TEST(p1 < p2); + + const size_t s1 = malloc_usable_size(p1); + OE_TEST(sizeof *p1 <= s1 && s1 <= (size_t)(p2 - p1) * sizeof *p1); + + OE_TEST(sizeof *p2 <= malloc_usable_size(p2)); + + const size_t end = s1 / sizeof *p1; + _set_buffer(p1, 0, end); + _check_buffer(p1, 0, end); + free(p1); + free(p2); +} diff --git a/tests/memory/enc/boundaries.c b/tests/memory/enc/boundaries.c index 335ab22cb7..808dafadd2 100644 --- a/tests/memory/enc/boundaries.c +++ b/tests/memory/enc/boundaries.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/memory/enc/enc.c b/tests/memory/enc/enc.c index ecb68cd0fe..465d788e75 100644 --- a/tests/memory/enc/enc.c +++ b/tests/memory/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/memory/enc/stress.c b/tests/memory/enc/stress.c index 85fca88a38..45a108a67d 100644 --- a/tests/memory/enc/stress.c +++ b/tests/memory/enc/stress.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/memory/host/CMakeLists.txt b/tests/memory/host/CMakeLists.txt index 5455c4191e..82e69abd46 100644 --- a/tests/memory/host/CMakeLists.txt +++ b/tests/memory/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/memory/host/host.cpp b/tests/memory/host/host.cpp index ab1d5f3840..8593848b34 100644 --- a/tests/memory/host/host.cpp +++ b/tests/memory/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -22,6 +22,7 @@ static void _malloc_basic_test(oe_enclave_t* enclave) OE_TEST(test_realloc(enclave) == OE_OK); OE_TEST(test_memalign(enclave) == OE_OK); OE_TEST(test_posix_memalign(enclave) == OE_OK); + OE_TEST(test_malloc_usable_size(enclave) == OE_OK); } static void _malloc_stress_test_single_thread( diff --git a/tests/memory/memory.edl b/tests/memory/memory.edl index 7cdcb64918..5853467b4e 100644 --- a/tests/memory/memory.edl +++ b/tests/memory/memory.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { @@ -13,6 +13,7 @@ enclave { public void test_realloc(); public void test_memalign(); public void test_posix_memalign(); + public void test_malloc_usable_size(); public void init_malloc_stress_test(); public void malloc_stress_test(int threads); diff --git a/tests/mixed_c_cpp/CMakeLists.txt b/tests/mixed_c_cpp/CMakeLists.txt index 64a82f487a..41ae97e1af 100644 --- a/tests/mixed_c_cpp/CMakeLists.txt +++ b/tests/mixed_c_cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/mixed_c_cpp/enc/CMakeLists.txt b/tests/mixed_c_cpp/enc/CMakeLists.txt index 0d645bfbe5..5b1c59741a 100644 --- a/tests/mixed_c_cpp/enc/CMakeLists.txt +++ b/tests/mixed_c_cpp/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/mixed_c_cpp/enc/enc.cpp b/tests/mixed_c_cpp/enc/enc.cpp index 435964823a..ae86704459 100644 --- a/tests/mixed_c_cpp/enc/enc.cpp +++ b/tests/mixed_c_cpp/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/mixed_c_cpp/enc/foo.c b/tests/mixed_c_cpp/enc/foo.c index 0d77fcdf3f..6e955d6ce5 100644 --- a/tests/mixed_c_cpp/enc/foo.c +++ b/tests/mixed_c_cpp/enc/foo.c @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/mixed_c_cpp/host/CMakeLists.txt b/tests/mixed_c_cpp/host/CMakeLists.txt index 6a3c2f8325..8cb448a04a 100644 --- a/tests/mixed_c_cpp/host/CMakeLists.txt +++ b/tests/mixed_c_cpp/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../mixed.edl host gen) diff --git a/tests/mixed_c_cpp/host/host.cpp b/tests/mixed_c_cpp/host/host.cpp index a723ddc118..4b48e0447a 100644 --- a/tests/mixed_c_cpp/host/host.cpp +++ b/tests/mixed_c_cpp/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/mixed_c_cpp/mixed.edl b/tests/mixed_c_cpp/mixed.edl index 36aaa4f2b5..9befc67855 100644 --- a/tests/mixed_c_cpp/mixed.edl +++ b/tests/mixed_c_cpp/mixed.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/ocall-create/CMakeLists.txt b/tests/ocall-create/CMakeLists.txt index 5a568120da..9f244d4d5f 100644 --- a/tests/ocall-create/CMakeLists.txt +++ b/tests/ocall-create/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/ocall-create/enc/CMakeLists.txt b/tests/ocall-create/enc/CMakeLists.txt index c765017b5f..6687357ffe 100644 --- a/tests/ocall-create/enc/CMakeLists.txt +++ b/tests/ocall-create/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ocall_create.edl enclave gen) diff --git a/tests/ocall-create/enc/enc.c b/tests/ocall-create/enc/enc.c index 40cf13ba46..d4a3f723b6 100644 --- a/tests/ocall-create/enc/enc.c +++ b/tests/ocall-create/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ocall-create/host/CMakeLists.txt b/tests/ocall-create/host/CMakeLists.txt index d35332025a..1039c6eb17 100644 --- a/tests/ocall-create/host/CMakeLists.txt +++ b/tests/ocall-create/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ocall_create.edl host gen) diff --git a/tests/ocall-create/host/host.c b/tests/ocall-create/host/host.c index 9c49ee5930..07d3feae26 100644 --- a/tests/ocall-create/host/host.c +++ b/tests/ocall-create/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ocall-create/ocall_create.edl b/tests/ocall-create/ocall_create.edl index 76f7bbca22..30f95b07ed 100644 --- a/tests/ocall-create/ocall_create.edl +++ b/tests/ocall-create/ocall_create.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/ocall/CMakeLists.txt b/tests/ocall/CMakeLists.txt index 6480dcaeb0..de09db8e15 100644 --- a/tests/ocall/CMakeLists.txt +++ b/tests/ocall/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/ocall/enc/CMakeLists.txt b/tests/ocall/enc/CMakeLists.txt index a5c9c1feac..88150759c7 100644 --- a/tests/ocall/enc/CMakeLists.txt +++ b/tests/ocall/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ocall.edl enclave gen) diff --git a/tests/ocall/enc/enc.cpp b/tests/ocall/enc/enc.cpp index 15b1578233..6290ed98f8 100644 --- a/tests/ocall/enc/enc.cpp +++ b/tests/ocall/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ocall/host/CMakeLists.txt b/tests/ocall/host/CMakeLists.txt index 0f855a7cf7..8b5d7459ed 100644 --- a/tests/ocall/host/CMakeLists.txt +++ b/tests/ocall/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../ocall.edl host gen) diff --git a/tests/ocall/host/host.cpp b/tests/ocall/host/host.cpp index a88c1a5d47..6efd018e5c 100644 --- a/tests/ocall/host/host.cpp +++ b/tests/ocall/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/ocall/ocall.edl b/tests/ocall/ocall.edl index 109d7a966e..5a1780de2c 100644 --- a/tests/ocall/ocall.edl +++ b/tests/ocall/ocall.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/CMakeLists.txt b/tests/oeedger8r/CMakeLists.txt index a44b2fd84a..a093e0d447 100644 --- a/tests/oeedger8r/CMakeLists.txt +++ b/tests/oeedger8r/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/oeedger8r/behavior/CMakeLists.txt b/tests/oeedger8r/behavior/CMakeLists.txt index eb9221d265..45294f83a5 100644 --- a/tests/oeedger8r/behavior/CMakeLists.txt +++ b/tests/oeedger8r/behavior/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. set(EDGER8R_ARGS --header-only --search-path ${CMAKE_CURRENT_SOURCE_DIR}) @@ -18,7 +18,7 @@ set_tests_properties(edger8r_allow_list_warning PROPERTIES # as the first instance is found. add_test(NAME edger8r_switchless_trusted_warning COMMAND edger8r ${EDGER8R_ARGS} switchless_trusted.edl) set_tests_properties(edger8r_switchless_trusted_warning PROPERTIES - PASS_REGULAR_EXPRESSION "error: Function 'foo': switchless ecalls are not yet supported by Open Enclave SDK.") + PASS_REGULAR_EXPRESSION "error: Function 'foo': trusted switchless ecalls are not yet supported by Open Enclave SDK.") # These need to be separate tests to ensure that each type, for both # trusted and untrusted functions, generate the appropriate warning, diff --git a/tests/oeedger8r/behavior/allow_list.edl b/tests/oeedger8r/behavior/allow_list.edl index da911a75e1..beefdcb517 100644 --- a/tests/oeedger8r/behavior/allow_list.edl +++ b/tests/oeedger8r/behavior/allow_list.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/count_signedness.edl b/tests/oeedger8r/behavior/count_signedness.edl index b7bc9a6ceb..ed1422affa 100644 --- a/tests/oeedger8r/behavior/count_signedness.edl +++ b/tests/oeedger8r/behavior/count_signedness.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/deepcopy_value.edl b/tests/oeedger8r/behavior/deepcopy_value.edl index 94f87e66ad..546609ddc4 100644 --- a/tests/oeedger8r/behavior/deepcopy_value.edl +++ b/tests/oeedger8r/behavior/deepcopy_value.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/portability.edl b/tests/oeedger8r/behavior/portability.edl index 3cae9c4d85..2103664b9e 100644 --- a/tests/oeedger8r/behavior/portability.edl +++ b/tests/oeedger8r/behavior/portability.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/private_trusted.edl b/tests/oeedger8r/behavior/private_trusted.edl index 01d02f305f..90b3565b3a 100644 --- a/tests/oeedger8r/behavior/private_trusted.edl +++ b/tests/oeedger8r/behavior/private_trusted.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/size_and_count.edl b/tests/oeedger8r/behavior/size_and_count.edl index 3c96ecaa85..c33e8a2977 100644 --- a/tests/oeedger8r/behavior/size_and_count.edl +++ b/tests/oeedger8r/behavior/size_and_count.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/size_signedness.edl b/tests/oeedger8r/behavior/size_signedness.edl index 10cf2c25e8..7d5121708d 100644 --- a/tests/oeedger8r/behavior/size_signedness.edl +++ b/tests/oeedger8r/behavior/size_signedness.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/switchless_trusted.edl b/tests/oeedger8r/behavior/switchless_trusted.edl index 157d13c3d3..0e8392817f 100644 --- a/tests/oeedger8r/behavior/switchless_trusted.edl +++ b/tests/oeedger8r/behavior/switchless_trusted.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/behavior/switchless_untrusted.edl b/tests/oeedger8r/behavior/switchless_untrusted.edl deleted file mode 100644 index 1226540a8f..0000000000 --- a/tests/oeedger8r/behavior/switchless_untrusted.edl +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -enclave { - untrusted { - // Switchless functions not supported. - void switchless() transition_using_threads; - }; -}; diff --git a/tests/oeedger8r/edl/aliasing.edl b/tests/oeedger8r/edl/aliasing.edl index a497e40fe0..c60d308833 100644 --- a/tests/oeedger8r/edl/aliasing.edl +++ b/tests/oeedger8r/edl/aliasing.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/all.edl b/tests/oeedger8r/edl/all.edl index 33c983bdce..d77a21c87c 100644 --- a/tests/oeedger8r/edl/all.edl +++ b/tests/oeedger8r/edl/all.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/array.edl b/tests/oeedger8r/edl/array.edl index c32e8cad28..76a43a2928 100644 --- a/tests/oeedger8r/edl/array.edl +++ b/tests/oeedger8r/edl/array.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/basic.edl b/tests/oeedger8r/edl/basic.edl index ff852bdfba..45f3e4049e 100644 --- a/tests/oeedger8r/edl/basic.edl +++ b/tests/oeedger8r/edl/basic.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/deepcopy.edl b/tests/oeedger8r/edl/deepcopy.edl index ec3b85ec99..ca7ae3dc4c 100644 --- a/tests/oeedger8r/edl/deepcopy.edl +++ b/tests/oeedger8r/edl/deepcopy.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { @@ -108,6 +108,9 @@ enclave { // Test handling of null values. public void deepcopy_null([in, out, count=1] CountStruct* s); + // Test that it is only copied in, not out. + public void deepcopy_in([in, count=1] CountStruct* s); + // Deep copy of one `CountStruct` with an embedded array out // should take place. public void deepcopy_out_count([in, out, count=1] CountStruct* s); diff --git a/tests/oeedger8r/edl/enum.edl b/tests/oeedger8r/edl/enum.edl index eeeb86d057..5559b1d1ca 100644 --- a/tests/oeedger8r/edl/enum.edl +++ b/tests/oeedger8r/edl/enum.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/errno.edl b/tests/oeedger8r/edl/errno.edl index bd8ca69a24..341a9ce178 100644 --- a/tests/oeedger8r/edl/errno.edl +++ b/tests/oeedger8r/edl/errno.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/foreign.edl b/tests/oeedger8r/edl/foreign.edl index b86d3f9112..b07bb5079b 100644 --- a/tests/oeedger8r/edl/foreign.edl +++ b/tests/oeedger8r/edl/foreign.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/other.edl b/tests/oeedger8r/edl/other.edl index 838742e184..92dbe020d4 100644 --- a/tests/oeedger8r/edl/other.edl +++ b/tests/oeedger8r/edl/other.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/pointer.edl b/tests/oeedger8r/edl/pointer.edl index 34e37023c7..6c44f0cd3e 100644 --- a/tests/oeedger8r/edl/pointer.edl +++ b/tests/oeedger8r/edl/pointer.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/string.edl b/tests/oeedger8r/edl/string.edl index b6689da863..05aa881e75 100644 --- a/tests/oeedger8r/edl/string.edl +++ b/tests/oeedger8r/edl/string.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/struct.edl b/tests/oeedger8r/edl/struct.edl index 2f980e9736..be26eef6b9 100644 --- a/tests/oeedger8r/edl/struct.edl +++ b/tests/oeedger8r/edl/struct.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/edl/switchless.edl b/tests/oeedger8r/edl/switchless.edl index afccbf8862..a29797bb70 100644 --- a/tests/oeedger8r/edl/switchless.edl +++ b/tests/oeedger8r/edl/switchless.edl @@ -1,10 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { trusted { - public int ecall_sum(int a, int b); - public int switchless_ecall_sum(int a, int b) transition_using_threads; + // OE SDK does not support trusted switchless ecalls. public void test_switchless_edl_ocalls(); }; diff --git a/tests/oeedger8r/edltestutils.h b/tests/oeedger8r/edltestutils.h index 57aa7627e1..7b36887c81 100644 --- a/tests/oeedger8r/edltestutils.h +++ b/tests/oeedger8r/edltestutils.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/tests/oeedger8r/enc/CMakeLists.txt b/tests/oeedger8r/enc/CMakeLists.txt index 0a73fd3652..118f408f03 100644 --- a/tests/oeedger8r/enc/CMakeLists.txt +++ b/tests/oeedger8r/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command( diff --git a/tests/oeedger8r/enc/bar.cpp b/tests/oeedger8r/enc/bar.cpp index cea440cae2..bfd9272c54 100644 --- a/tests/oeedger8r/enc/bar.cpp +++ b/tests/oeedger8r/enc/bar.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "bar_t.h" diff --git a/tests/oeedger8r/enc/config.cpp b/tests/oeedger8r/enc/config.cpp index 9b80527886..3e24775b41 100644 --- a/tests/oeedger8r/enc/config.cpp +++ b/tests/oeedger8r/enc/config.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include diff --git a/tests/oeedger8r/enc/foo.cpp b/tests/oeedger8r/enc/foo.cpp index 008acd6a03..ee78600ece 100644 --- a/tests/oeedger8r/enc/foo.cpp +++ b/tests/oeedger8r/enc/foo.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "all_t.h" diff --git a/tests/oeedger8r/enc/testaliasing.cpp b/tests/oeedger8r/enc/testaliasing.cpp index 5f95487be3..50fa96c4f2 100644 --- a/tests/oeedger8r/enc/testaliasing.cpp +++ b/tests/oeedger8r/enc/testaliasing.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/oeedger8r/enc/testarray.cpp b/tests/oeedger8r/enc/testarray.cpp index b0b0b52900..dcf5d78cc6 100644 --- a/tests/oeedger8r/enc/testarray.cpp +++ b/tests/oeedger8r/enc/testarray.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testbasic.cpp b/tests/oeedger8r/enc/testbasic.cpp index cf4faf47e9..93a1babed6 100644 --- a/tests/oeedger8r/enc/testbasic.cpp +++ b/tests/oeedger8r/enc/testbasic.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testdeepcopy.cpp b/tests/oeedger8r/enc/testdeepcopy.cpp index 0d9d3dfd24..93fb8b6324 100644 --- a/tests/oeedger8r/enc/testdeepcopy.cpp +++ b/tests/oeedger8r/enc/testdeepcopy.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" @@ -195,6 +195,15 @@ void deepcopy_null(CountStruct* s) OE_UNUSED(s); } +void deepcopy_in(CountStruct* s) +{ + // Assert that it was copied in correctly. + deepcopy_count(s); + // Cause it to copy out incorrectly. + for (size_t i = 0; i < 3; ++i) + s->ptr[i] = i; +} + void deepcopy_out_count(CountStruct* s) { OE_TEST(s->count == 0); diff --git a/tests/oeedger8r/enc/testenum.cpp b/tests/oeedger8r/enc/testenum.cpp index 5caf582768..ba13ab2da4 100644 --- a/tests/oeedger8r/enc/testenum.cpp +++ b/tests/oeedger8r/enc/testenum.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testerrno.cpp b/tests/oeedger8r/enc/testerrno.cpp index a330683d76..bd61020838 100644 --- a/tests/oeedger8r/enc/testerrno.cpp +++ b/tests/oeedger8r/enc/testerrno.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testforeign.cpp b/tests/oeedger8r/enc/testforeign.cpp index 427b58b763..9decd3d282 100644 --- a/tests/oeedger8r/enc/testforeign.cpp +++ b/tests/oeedger8r/enc/testforeign.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testmisc.cpp b/tests/oeedger8r/enc/testmisc.cpp index b087894efd..a7015d38ff 100644 --- a/tests/oeedger8r/enc/testmisc.cpp +++ b/tests/oeedger8r/enc/testmisc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "all_t.h" diff --git a/tests/oeedger8r/enc/testother.cpp b/tests/oeedger8r/enc/testother.cpp index 6866f0049b..30e423c553 100644 --- a/tests/oeedger8r/enc/testother.cpp +++ b/tests/oeedger8r/enc/testother.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testpointer.cpp b/tests/oeedger8r/enc/testpointer.cpp index cc32abb3c7..d4b21c250b 100644 --- a/tests/oeedger8r/enc/testpointer.cpp +++ b/tests/oeedger8r/enc/testpointer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/teststring.cpp b/tests/oeedger8r/enc/teststring.cpp index 18e5947e74..03578cc56e 100644 --- a/tests/oeedger8r/enc/teststring.cpp +++ b/tests/oeedger8r/enc/teststring.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/teststruct.cpp b/tests/oeedger8r/enc/teststruct.cpp index f218f5416a..04dd58d8d7 100644 --- a/tests/oeedger8r/enc/teststruct.cpp +++ b/tests/oeedger8r/enc/teststruct.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/enc/testswitchless.cpp b/tests/oeedger8r/enc/testswitchless.cpp index e4ce6b9408..ec95ccdb86 100644 --- a/tests/oeedger8r/enc/testswitchless.cpp +++ b/tests/oeedger8r/enc/testswitchless.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include @@ -16,13 +16,3 @@ void test_switchless_edl_ocalls() printf("=== test_switchless_edl_ocalls passed\n"); } - -int ecall_sum(int a, int b) -{ - return a + b; -} - -int switchless_ecall_sum(int a, int b) -{ - return a + b; -} diff --git a/tests/oeedger8r/host/CMakeLists.txt b/tests/oeedger8r/host/CMakeLists.txt index abf73f50cd..5acd4d8246 100644 --- a/tests/oeedger8r/host/CMakeLists.txt +++ b/tests/oeedger8r/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command( diff --git a/tests/oeedger8r/host/bar.cpp b/tests/oeedger8r/host/bar.cpp index a86a74080c..e4990f0bff 100644 --- a/tests/oeedger8r/host/bar.cpp +++ b/tests/oeedger8r/host/bar.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "bar_u.h" diff --git a/tests/oeedger8r/host/foo.cpp b/tests/oeedger8r/host/foo.cpp index a2419c7aa4..ea0042a743 100644 --- a/tests/oeedger8r/host/foo.cpp +++ b/tests/oeedger8r/host/foo.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "all_u.h" diff --git a/tests/oeedger8r/host/main.cpp b/tests/oeedger8r/host/main.cpp index 6013a66de9..a28395c04b 100644 --- a/tests/oeedger8r/host/main.cpp +++ b/tests/oeedger8r/host/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -24,7 +24,6 @@ void test_enum_edl_ecalls(oe_enclave_t* enclave); void test_foreign_edl_ecalls(oe_enclave_t* enclave); void test_other_edl_ecalls(oe_enclave_t* enclave); void test_deepcopy_edl_ecalls(oe_enclave_t* enclave); -void test_switchless_edl_ecalls(oe_enclave_t* enclave); int main(int argc, const char* argv[]) { @@ -98,7 +97,6 @@ int main(int argc, const char* argv[]) test_deepcopy_edl_ecalls(enclave); - test_switchless_edl_ecalls(enclave); OE_TEST(test_switchless_edl_ocalls(enclave) == OE_OK); done: oe_terminate_enclave(enclave); diff --git a/tests/oeedger8r/host/testarray.cpp b/tests/oeedger8r/host/testarray.cpp index fc95b50482..0577004f49 100644 --- a/tests/oeedger8r/host/testarray.cpp +++ b/tests/oeedger8r/host/testarray.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/testbasic.cpp b/tests/oeedger8r/host/testbasic.cpp index b8db8b5f92..84bd78432d 100644 --- a/tests/oeedger8r/host/testbasic.cpp +++ b/tests/oeedger8r/host/testbasic.cpp @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/testdeepcopy.cpp b/tests/oeedger8r/host/testdeepcopy.cpp index 4ac76c50f3..cd55006b64 100644 --- a/tests/oeedger8r/host/testdeepcopy.cpp +++ b/tests/oeedger8r/host/testdeepcopy.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" @@ -168,6 +168,13 @@ void test_deepcopy_edl_ecalls(oe_enclave_t* enclave) OE_TEST(s.ptr == nullptr); } + { + auto s = init_struct(); + OE_TEST(deepcopy_in(enclave, &s) == OE_OK); + // Assert the struct was not changed (as if it were "out"). + test_struct(s, 3); + } + { CountStruct s{}; uint64_t p[3] = {0, 0, 0}; diff --git a/tests/oeedger8r/host/testenum.cpp b/tests/oeedger8r/host/testenum.cpp index 6767706fce..f66f8ed4e6 100644 --- a/tests/oeedger8r/host/testenum.cpp +++ b/tests/oeedger8r/host/testenum.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/testerrno.cpp b/tests/oeedger8r/host/testerrno.cpp index 7f775f19ac..9a9fc90017 100644 --- a/tests/oeedger8r/host/testerrno.cpp +++ b/tests/oeedger8r/host/testerrno.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/testforeign.cpp b/tests/oeedger8r/host/testforeign.cpp index f6bc15c9e1..3aa5cde2d8 100644 --- a/tests/oeedger8r/host/testforeign.cpp +++ b/tests/oeedger8r/host/testforeign.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/testother.cpp b/tests/oeedger8r/host/testother.cpp index ae66b80bb2..ab63838743 100644 --- a/tests/oeedger8r/host/testother.cpp +++ b/tests/oeedger8r/host/testother.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/testpointer.cpp b/tests/oeedger8r/host/testpointer.cpp index 088e6026a7..aef85e2ef4 100644 --- a/tests/oeedger8r/host/testpointer.cpp +++ b/tests/oeedger8r/host/testpointer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" diff --git a/tests/oeedger8r/host/teststring.cpp b/tests/oeedger8r/host/teststring.cpp index 0de52701aa..4491da1744 100644 --- a/tests/oeedger8r/host/teststring.cpp +++ b/tests/oeedger8r/host/teststring.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../edltestutils.h" @@ -276,7 +276,6 @@ void test_string_edl_ecalls(oe_enclave_t* enclave) } // Test wstrings without null terminators. { - OE_UNUSED(ecall_wstring_no_null_terminator_modified); // wchar_t is not a portable type. Hence the test is performed // only on Linux. #ifdef __linux__ @@ -384,7 +383,7 @@ void test_wstring_edl_ecalls(oe_enclave_t* enclave) if (!g_enabled[TYPE_WCHAR_T]) return; - swprintf(str, 50, L"%S", str_value); + swprintf(str, 50, L"%lS", str_value); // wchar_t* OE_TEST(ecall_wstring_fun1(enclave, str) == OE_OK); @@ -399,7 +398,7 @@ void test_wstring_edl_ecalls(oe_enclave_t* enclave) OE_TEST(wcscmp(str, L"Goodbye\n") == 0); // Restore value. - swprintf(str, 50, L"%S", str_value); + swprintf(str, 50, L"%lS", str_value); // wchar_t* user check. OE_TEST(ecall_wstring_fun5(enclave, str) == OE_OK); diff --git a/tests/oeedger8r/host/teststruct.cpp b/tests/oeedger8r/host/teststruct.cpp index dc6073338b..76627d7fc2 100644 --- a/tests/oeedger8r/host/teststruct.cpp +++ b/tests/oeedger8r/host/teststruct.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/oeedger8r/host/testswitchless.cpp b/tests/oeedger8r/host/testswitchless.cpp index 55f33b8b26..6c9cda1d70 100644 --- a/tests/oeedger8r/host/testswitchless.cpp +++ b/tests/oeedger8r/host/testswitchless.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -6,17 +6,6 @@ #include "all_u.h" -void test_switchless_edl_ecalls(oe_enclave_t* enclave) -{ - int c = 0; - OE_TEST(ecall_sum(enclave, &c, 5, 6) == OE_OK); - - // Switchless calls are not yet implemented - OE_TEST(switchless_ecall_sum(enclave, &c, 5, 6) == OE_UNSUPPORTED); - - printf("=== test_switchless_edl_ecalls passed\n"); -} - int ocall_sum(int a, int b) { return a + b; diff --git a/tests/oeedger8r/moreedl/bar.edl b/tests/oeedger8r/moreedl/bar.edl index 52d7e43de9..ed62e59798 100644 --- a/tests/oeedger8r/moreedl/bar.edl +++ b/tests/oeedger8r/moreedl/bar.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // This edl is compiled only in header only mode. diff --git a/tests/oeedger8r/moreedl/foo.edl b/tests/oeedger8r/moreedl/foo.edl index 276cdcbccb..ccb05a4327 100644 --- a/tests/oeedger8r/moreedl/foo.edl +++ b/tests/oeedger8r/moreedl/foo.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/oeedger8r/mytypes.h b/tests/oeedger8r/mytypes.h index e35f85c2a9..ba8c3930d6 100644 --- a/tests/oeedger8r/mytypes.h +++ b/tests/oeedger8r/mytypes.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #pragma once diff --git a/tests/pingpong-shared/CMakeLists.txt b/tests/pingpong-shared/CMakeLists.txt index 30477d4f96..a54faeeb11 100644 --- a/tests/pingpong-shared/CMakeLists.txt +++ b/tests/pingpong-shared/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/pingpong-shared/enc/CMakeLists.txt b/tests/pingpong-shared/enc/CMakeLists.txt index 6fbf626310..f7f420f0c6 100644 --- a/tests/pingpong-shared/enc/CMakeLists.txt +++ b/tests/pingpong-shared/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/pingpong-shared/enc/enc.cpp b/tests/pingpong-shared/enc/enc.cpp index 0c4086b4ef..6c98549550 100644 --- a/tests/pingpong-shared/enc/enc.cpp +++ b/tests/pingpong-shared/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/pingpong-shared/host/CMakeLists.txt b/tests/pingpong-shared/host/CMakeLists.txt index a542d0056e..9deb9421b6 100644 --- a/tests/pingpong-shared/host/CMakeLists.txt +++ b/tests/pingpong-shared/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../pingpong.edl host gen) diff --git a/tests/pingpong-shared/host/host.cpp b/tests/pingpong-shared/host/host.cpp index 050743a59c..9640608f4f 100644 --- a/tests/pingpong-shared/host/host.cpp +++ b/tests/pingpong-shared/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/pingpong-shared/host/main.cpp b/tests/pingpong-shared/host/main.cpp index d260727e82..a77e469058 100644 --- a/tests/pingpong-shared/host/main.cpp +++ b/tests/pingpong-shared/host/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. extern int main_shared(int argc, const char* argv[]); diff --git a/tests/pingpong-shared/main.cpp b/tests/pingpong-shared/main.cpp index da45678164..2d6b32b668 100644 --- a/tests/pingpong-shared/main.cpp +++ b/tests/pingpong-shared/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. extern "C" __attribute__((section(".ecall"))) void __ping(void* args); diff --git a/tests/pingpong-shared/pingpong.edl b/tests/pingpong-shared/pingpong.edl index c4a9d1f906..c8e9ae436d 100644 --- a/tests/pingpong-shared/pingpong.edl +++ b/tests/pingpong-shared/pingpong.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/pingpong/CMakeLists.txt b/tests/pingpong/CMakeLists.txt index 45365b4cb3..a290fb3afe 100644 --- a/tests/pingpong/CMakeLists.txt +++ b/tests/pingpong/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/pingpong/enc/CMakeLists.txt b/tests/pingpong/enc/CMakeLists.txt index 56770bb127..d77de95449 100644 --- a/tests/pingpong/enc/CMakeLists.txt +++ b/tests/pingpong/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/pingpong/enc/enc.cpp b/tests/pingpong/enc/enc.cpp index 7ac77a61a8..6f1d23fb00 100644 --- a/tests/pingpong/enc/enc.cpp +++ b/tests/pingpong/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/pingpong/host/CMakeLists.txt b/tests/pingpong/host/CMakeLists.txt index 615c4f8c9e..777048faee 100644 --- a/tests/pingpong/host/CMakeLists.txt +++ b/tests/pingpong/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../pingpong.edl host gen) diff --git a/tests/pingpong/host/host.cpp b/tests/pingpong/host/host.cpp index a6f5424dc4..ac8dccd63c 100644 --- a/tests/pingpong/host/host.cpp +++ b/tests/pingpong/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/pingpong/main.cpp b/tests/pingpong/main.cpp index da45678164..2d6b32b668 100644 --- a/tests/pingpong/main.cpp +++ b/tests/pingpong/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. extern "C" __attribute__((section(".ecall"))) void __ping(void* args); diff --git a/tests/pingpong/pingpong.edl b/tests/pingpong/pingpong.edl index c4a9d1f906..c8e9ae436d 100644 --- a/tests/pingpong/pingpong.edl +++ b/tests/pingpong/pingpong.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/print/CMakeLists.txt b/tests/print/CMakeLists.txt index c574aeb2ff..8cd915d256 100644 --- a/tests/print/CMakeLists.txt +++ b/tests/print/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/print/enc/CMakeLists.txt b/tests/print/enc/CMakeLists.txt index 6649180413..5aa9449da8 100644 --- a/tests/print/enc/CMakeLists.txt +++ b/tests/print/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/print/enc/enc.cpp b/tests/print/enc/enc.cpp index b4b040ca9a..68836aa3ed 100644 --- a/tests/print/enc/enc.cpp +++ b/tests/print/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/print/host/CMakeLists.txt b/tests/print/host/CMakeLists.txt index 2419741c0e..d57566006d 100644 --- a/tests/print/host/CMakeLists.txt +++ b/tests/print/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/print/host/host.cpp b/tests/print/host/host.cpp index 9b85f1a2ca..3d8aca6334 100644 --- a/tests/print/host/host.cpp +++ b/tests/print/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/print/print.edl b/tests/print/print.edl index 64f629d9bd..9fd024138f 100644 --- a/tests/print/print.edl +++ b/tests/print/print.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/props/CMakeLists.txt b/tests/props/CMakeLists.txt index 8621bd9f44..0fc7d36ff1 100644 --- a/tests/props/CMakeLists.txt +++ b/tests/props/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/props/enc/CMakeLists.txt b/tests/props/enc/CMakeLists.txt index c60169c7b6..0579656a20 100644 --- a/tests/props/enc/CMakeLists.txt +++ b/tests/props/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/props/enc/enc.c b/tests/props/enc/enc.c index 932dab79f4..9e3ce423ed 100644 --- a/tests/props/enc/enc.c +++ b/tests/props/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/props/enc/props.c b/tests/props/enc/props.c index 7f49264d21..c01882ae76 100644 --- a/tests/props/enc/props.c +++ b/tests/props/enc/props.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/props/enc/sign.conf b/tests/props/enc/sign.conf index b1450e80d4..004f535b91 100644 --- a/tests/props/enc/sign.conf +++ b/tests/props/enc/sign.conf @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # Enclave settings: diff --git a/tests/props/host/CMakeLists.txt b/tests/props/host/CMakeLists.txt index e40e20f303..874e9c6fdc 100644 --- a/tests/props/host/CMakeLists.txt +++ b/tests/props/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/props/host/host.c b/tests/props/host/host.c index 97d1e00527..d9cb93b1a9 100644 --- a/tests/props/host/host.c +++ b/tests/props/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/props/props.edl b/tests/props/props.edl index cee9b57d6f..26a0f5371f 100644 --- a/tests/props/props.edl +++ b/tests/props/props.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/qeidentity/CMakeLists.txt b/tests/qeidentity/CMakeLists.txt index 9401cccd57..ce84892311 100644 --- a/tests/qeidentity/CMakeLists.txt +++ b/tests/qeidentity/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/qeidentity/common/includes.h b/tests/qeidentity/common/includes.h index b5292699aa..ff2d078799 100644 --- a/tests/qeidentity/common/includes.h +++ b/tests/qeidentity/common/includes.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _COMMON_INCLUDES_H_ diff --git a/tests/qeidentity/data_v2/qe_identity_missing_attributes.json b/tests/qeidentity/data_v2/qe_identity_missing_attributes.json new file mode 100644 index 0000000000..06000c62b7 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_attributes.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_attributesmask.json b/tests/qeidentity/data_v2/qe_identity_missing_attributesmask.json new file mode 100644 index 0000000000..30c44cc16e --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_attributesmask.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_id.json b/tests/qeidentity/data_v2/qe_identity_missing_id.json new file mode 100644 index 0000000000..7b8ff2e5ea --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_id.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_issuedate.json b/tests/qeidentity/data_v2/qe_identity_missing_issuedate.json new file mode 100644 index 0000000000..c95c4c934d --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_issuedate.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_isvprodid.json b/tests/qeidentity/data_v2/qe_identity_missing_isvprodid.json new file mode 100644 index 0000000000..a1932dccf2 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_isvprodid.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_isvsvn.json b/tests/qeidentity/data_v2/qe_identity_missing_isvsvn.json new file mode 100644 index 0000000000..31d8251bdf --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_isvsvn.json @@ -0,0 +1,29 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{:2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_miscselect.json b/tests/qeidentity/data_v2/qe_identity_missing_miscselect.json new file mode 100644 index 0000000000..704d7eca8b --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_miscselect.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_miscselectmask.json b/tests/qeidentity/data_v2/qe_identity_missing_miscselectmask.json new file mode 100644 index 0000000000..44e6f6c8f1 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_miscselectmask.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_mrsigner.json b/tests/qeidentity/data_v2/qe_identity_missing_mrsigner.json new file mode 100644 index 0000000000..906e2f5821 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_mrsigner.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_nextupdate.json b/tests/qeidentity/data_v2/qe_identity_missing_nextupdate.json new file mode 100644 index 0000000000..f0d6662cdb --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_nextupdate.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_qeidentity.json b/tests/qeidentity/data_v2/qe_identity_missing_qeidentity.json new file mode 100644 index 0000000000..55ac2fee60 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_qeidentity.json @@ -0,0 +1,29 @@ +{ + : + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_signature.json b/tests/qeidentity/data_v2/qe_identity_missing_signature.json new file mode 100644 index 0000000000..ee8d002636 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_signature.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + } +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_tcb_date.json b/tests/qeidentity/data_v2/qe_identity_missing_tcb_date.json new file mode 100644 index 0000000000..865f3a1b6f --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_tcb_date.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_tcb_eval_data_num.json b/tests/qeidentity/data_v2/qe_identity_missing_tcb_eval_data_num.json new file mode 100644 index 0000000000..daf5d52db8 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_tcb_eval_data_num.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_tcb_levels.json b/tests/qeidentity/data_v2/qe_identity_missing_tcb_levels.json new file mode 100644 index 0000000000..1677ec9b0e --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_tcb_levels.json @@ -0,0 +1,17 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1 + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_tcb_status.json b/tests/qeidentity/data_v2/qe_identity_missing_tcb_status.json new file mode 100644 index 0000000000..f59063d23b --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_tcb_status.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_missing_version.json b/tests/qeidentity/data_v2/qe_identity_missing_version.json new file mode 100644 index 0000000000..40bd23675c --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_missing_version.json @@ -0,0 +1,28 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_ok.json b/tests/qeidentity/data_v2/qe_identity_ok.json new file mode 100644 index 0000000000..f65721e944 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_ok.json @@ -0,0 +1,29 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2018-10-18T01:26:20Z", + "nextUpdate":"2018-11-17T01:26:20Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T01:02:03Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"3ad9d2811548ac36b5d5648a74e352377ea681c2d780b75f579bb5058998c487a13c6fbf27b5bae23e77f7d55657fefef110c30ae9197202462913a963e6802b" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qe_identity_with_advisoryids.json b/tests/qeidentity/data_v2/qe_identity_with_advisoryids.json new file mode 100644 index 0000000000..1d42b19ed0 --- /dev/null +++ b/tests/qeidentity/data_v2/qe_identity_with_advisoryids.json @@ -0,0 +1,30 @@ +{ + "enclaveIdentity": + { + "id":"QE", + "version":2, + "issueDate":"2019-11-08T00:59:29Z", + "nextUpdate":"2019-12-08T00:59:29Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate", + "advisoryIDs":["INTEL-SA-00079", "INTEL-SA-00076"] + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"d258943a7f496eb3b0acbfed97594b3f9f26a5b818af1726089799e6b2238289fa3557423622968be8bb6602a697ab3db8895a01186d831b60d3230d05e5bf08" +} \ No newline at end of file diff --git a/tests/qeidentity/data_v2/qve_identity_ok.json b/tests/qeidentity/data_v2/qve_identity_ok.json new file mode 100644 index 0000000000..cb9732e1d3 --- /dev/null +++ b/tests/qeidentity/data_v2/qve_identity_ok.json @@ -0,0 +1,29 @@ +{ + "enclaveIdentity": + { + "id":"QVE", + "version":2, + "issueDate":"2018-10-18T01:26:20Z", + "nextUpdate":"2018-11-17T01:26:20Z", + "tcbEvaluationDataNumber":5, + "miscselect":"00000000", + "miscselectMask":"FFFFFFFF", + "attributes":"11000000000000000000000000000000", + "attributesMask":"FBFFFFFFFFFFFFFF0000000000000000", + "mrsigner":"8C4F5775D796503E96137F77C68A829A0056AC8DED70140B081B094490C57BFF", + "isvprodid":1, + "tcbLevels":[ + { + "tcb":{"isvsvn":2}, + "tcbDate":"2019-05-15T01:02:03Z", + "tcbStatus":"UpToDate" + }, + { + "tcb":{"isvsvn":1}, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus":"OutOfDate" + } + ] + }, + "signature":"3ad9d2811548ac36b5d5648a74e352377ea681c2d780b75f579bb5058998c487a13c6fbf27b5bae23e77f7d55657fefef110c30ae9197202462913a963e6802b" +} \ No newline at end of file diff --git a/tests/qeidentity/enc/CMakeLists.txt b/tests/qeidentity/enc/CMakeLists.txt index 21aa379c05..16781c29cb 100644 --- a/tests/qeidentity/enc/CMakeLists.txt +++ b/tests/qeidentity/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. @@ -6,8 +6,8 @@ oeedl_file(../tests.edl enclave gen) # TODO: Does this need CXX? add_enclave(TARGET qeidentity_enc UUID a656f3b1-d319-4692-bcd6-a2f50d9fb1e5 SOURCES enc.cpp ${gen}) -if(USE_LIBSGX) - target_compile_definitions(qeidentity_enc PRIVATE OE_USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(qeidentity_enc PRIVATE HAS_QUOTE_PROVIDER) endif() target_include_directories(qeidentity_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../common) diff --git a/tests/qeidentity/enc/enc.cpp b/tests/qeidentity/enc/enc.cpp index aaa95865c7..49330c5877 100644 --- a/tests/qeidentity/enc/enc.cpp +++ b/tests/qeidentity/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -14,13 +14,18 @@ oe_result_t test_verify_qe_identity_info( const char* info_json, + oe_qe_identity_info_tcb_level_t* platform_tcb_level, oe_parsed_qe_identity_info_t* parsed_info) { -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL return oe_parse_qe_identity_info_json( - (const uint8_t*)info_json, strlen(info_json) + 1, parsed_info); + (const uint8_t*)info_json, + strlen(info_json) + 1, + platform_tcb_level, + parsed_info); #else OE_UNUSED(info_json); + OE_UNUSED(platform_tcb_level); OE_UNUSED(parsed_info); return OE_OK; #endif diff --git a/tests/qeidentity/host/CMakeLists.txt b/tests/qeidentity/host/CMakeLists.txt index 483585a5d3..20bee2c8e4 100644 --- a/tests/qeidentity/host/CMakeLists.txt +++ b/tests/qeidentity/host/CMakeLists.txt @@ -1,16 +1,17 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../tests.edl host gen) add_executable(qeidentity_host host.cpp qeidentifyinfo.cpp ${gen}) -if(USE_LIBSGX) - target_compile_definitions(qeidentity_host PRIVATE OE_USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(qeidentity_host PRIVATE OE_LINK_SGX_DCAP_QL) endif() add_custom_command(TARGET qeidentity_host COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../data ${CMAKE_CURRENT_BINARY_DIR}/../data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../data_v2 ${CMAKE_CURRENT_BINARY_DIR}/../data_v2 ) target_include_directories(qeidentity_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../common) diff --git a/tests/qeidentity/host/host.cpp b/tests/qeidentity/host/host.cpp index b21e036346..6d012bfe5a 100644 --- a/tests/qeidentity/host/host.cpp +++ b/tests/qeidentity/host/host.cpp @@ -1,8 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include -#include #include #include #include @@ -15,7 +14,9 @@ #define SKIP_RETURN_CODE 2 +extern void run_parse_advisoryids_json_test(); extern void run_qe_identity_test_cases(oe_enclave_t* enclave); +extern void run_qe_identity_v2_test_cases(oe_enclave_t* enclave); extern std::vector FileToBytes(const char* path); int main(int argc, const char* argv[]) @@ -46,9 +47,11 @@ int main(int argc, const char* argv[]) oe_put_err("oe_create_enclave(): result=%u", result); } -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL + run_parse_advisoryids_json_test(); run_qe_identity_test_cases(enclave); + run_qe_identity_v2_test_cases(enclave); #endif diff --git a/tests/qeidentity/host/qeidentifyinfo.cpp b/tests/qeidentity/host/qeidentifyinfo.cpp index f183f01b5e..a19f450b98 100644 --- a/tests/qeidentity/host/qeidentifyinfo.cpp +++ b/tests/qeidentity/host/qeidentifyinfo.cpp @@ -1,9 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL +#include #include -#include #include #include #include @@ -41,10 +41,8 @@ std::vector FileToBytes(const char* path) return bytes; } -void check_parsed_value(oe_parsed_qe_identity_info_t& parsed_info) +void check_parsed_common_values(oe_parsed_qe_identity_info_t& parsed_info) { - OE_TEST(parsed_info.version == 1); - oe_datetime_t expected_issue_date = {2018, 10, 18, 1, 26, 20}; OE_TEST( oe_datetime_compare(&parsed_info.issue_date, &expected_issue_date) == @@ -63,7 +61,6 @@ void check_parsed_value(oe_parsed_qe_identity_info_t& parsed_info) // OE_TEST(parsed_info.attributesMask == 0xFFFFFFFF); OE_TEST(parsed_info.isvprodid == 1); - OE_TEST(parsed_info.isvsvn == 1); uint8_t expected_mrsigner[32] = { 0x8C, 0x4F, 0x57, 0x75, 0xD7, 0x96, 0x50, 0x3E, 0x96, 0x13, 0x7F, @@ -89,6 +86,31 @@ void check_parsed_value(oe_parsed_qe_identity_info_t& parsed_info) sizeof(expected_signature)) == 0); } +void check_parsed_v1_values(oe_parsed_qe_identity_info_t& parsed_info) +{ + OE_TEST(parsed_info.version == 1); + OE_TEST(parsed_info.isvsvn == 1); + check_parsed_common_values(parsed_info); +} + +void check_parsed_v2_values(oe_parsed_qe_identity_info_t& parsed_info) +{ + OE_TEST(parsed_info.version == 2); + OE_TEST(parsed_info.tcb_evaluation_data_number == 5); + OE_TEST(parsed_info.isvsvn == 2); + OE_TEST(parsed_info.tcb_level.isvsvn[0] == 2); + + oe_datetime_t expected_tcb_date = {2019, 5, 15, 1, 2, 3}; + OE_TEST( + oe_datetime_compare( + &parsed_info.tcb_level.tcb_date, &expected_tcb_date) == 0); + + OE_TEST(parsed_info.tcb_level.tcb_status.fields.up_to_date == 1); + OE_TEST(parsed_info.tcb_level.advisory_ids_size == 0); + + check_parsed_common_values(parsed_info); +} + void run_qe_identity_test_cases(oe_enclave_t* enclave) { // validate positive case @@ -104,9 +126,10 @@ void run_qe_identity_test_cases(oe_enclave_t* enclave) enclave, &ecall_result, (const char*)&positive_qe_id_info[0], + NULL, &parsed_info) == OE_OK); OE_TEST(ecall_result == OE_OK); - check_parsed_value(parsed_info); + check_parsed_v1_values(parsed_info); // validate negative case qe_identity_test_case_t test_cases[] = { @@ -140,12 +163,232 @@ void run_qe_identity_test_cases(oe_enclave_t* enclave) enclave, &ecall_result, (const char*)&qeIdInfo[0], + NULL, + &parsed_info) == OE_OK); + + printf( + "%s: ecall_result = %s expected_result = %s\n", + test_cases[i].file_name, + oe_result_str(ecall_result), + oe_result_str(test_cases[i].expected_result)); + OE_TEST(ecall_result == test_cases[i].expected_result); + printf("passed\n"); + } +} + +void run_parse_advisoryids_json_test() +{ + const uint8_t* advisoryids_test0 = (const uint8_t*)"\"advisoryId1\""; + const uint8_t* advisoryids_test1 = + (const uint8_t*)"\"advisoryId1\", \"advisoryId2\", \"advisoryId3\""; + const uint8_t* id_array[3]; + size_t id_size_array[3]; + size_t num_ids = 0; + + OE_TEST( + oe_parse_advisoryids_json( + advisoryids_test0, + strlen((const char*)advisoryids_test0), + (const uint8_t**)&id_array, + 3, + (size_t*)id_size_array, + 3, + &num_ids) == OE_OK); + OE_TEST(num_ids == 1); + + OE_TEST( + oe_parse_advisoryids_json( + advisoryids_test1, + strlen((const char*)advisoryids_test1), + (const uint8_t**)&id_array, + 3, + (size_t*)id_size_array, + 3, + &num_ids) == OE_OK); + OE_TEST(num_ids == 3); + + OE_TEST( + oe_parse_advisoryids_json( + NULL, + 0, + (const uint8_t**)&id_array, + 3, + (size_t*)id_size_array, + 3, + &num_ids) == OE_INVALID_PARAMETER); +} + +void run_qe_identity_v2_test_cases(oe_enclave_t* enclave) +{ + // validate positive case + std::vector positive_qe_id_info = + FileToBytes("./data_v2/qe_identity_ok.json"); + std::vector positive_qve_id_info = + FileToBytes("./data_v2/qve_identity_ok.json"); + std::vector positive_qe_id_info_with_advisoryids = + FileToBytes("./data_v2/qe_identity_with_advisoryids.json"); + + const uint8_t* advisoryIDs[2] = {0}; + size_t advisoryIDs_length[2] = {0}; + const char* expectedAdvisoryIDs[2] = {"INTEL-SA-00079", "INTEL-SA-00076"}; + size_t num_advisory_ids = 0; + + oe_parsed_qe_identity_info_t parsed_info = {0}; + oe_qe_identity_info_tcb_level_t platform_tcb_level = {{0}}; + oe_result_t ecall_result = OE_FAILURE; + + // QE Identity V2 positive test + platform_tcb_level.isvsvn[0] = 2; + OE_TEST( + test_verify_qe_identity_info( + enclave, + &ecall_result, + (const char*)&positive_qe_id_info[0], + &platform_tcb_level, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_OK); + OE_TEST(parsed_info.id == QE_IDENTITY_ID_QE); + check_parsed_v2_values(parsed_info); + printf("\n\nQE Identity V2 positive test. PASSED.\n"); + + // QE Identity V2 negative, OutOfDate + platform_tcb_level.isvsvn[0] = 1; + OE_TEST( + test_verify_qe_identity_info( + enclave, + &ecall_result, + (const char*)&positive_qe_id_info[0], + &platform_tcb_level, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_TCB_LEVEL_INVALID); + OE_TEST(parsed_info.id == QE_IDENTITY_ID_QE); + OE_TEST(parsed_info.tcb_level.tcb_status.fields.outofdate == 1); + printf("\n\nQE Identity V2 positive test, OutOfDate. PASSED.\n"); + + // QE Identity V2 positive with advisoryIDs + platform_tcb_level.isvsvn[0] = 2; + OE_TEST( + test_verify_qe_identity_info( + enclave, + &ecall_result, + (const char*)&positive_qe_id_info_with_advisoryids[0], + &platform_tcb_level, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_OK); + OE_TEST(parsed_info.id == QE_IDENTITY_ID_QE); + OE_TEST(parsed_info.tcb_level.tcb_status.fields.up_to_date == 1); + OE_TEST(parsed_info.tcb_level.advisory_ids_size > 0); + OE_TEST( + parsed_info.tcb_level.advisory_ids_offset < + positive_qe_id_info_with_advisoryids.size()); + + const char* ptr = (const char*)&positive_qe_id_info_with_advisoryids + [parsed_info.tcb_level.advisory_ids_offset]; + OE_TEST( + oe_parse_advisoryids_json( + (const uint8_t*)ptr, + parsed_info.tcb_level.advisory_ids_size, + (const uint8_t**)&advisoryIDs, + 2, + (size_t*)&advisoryIDs_length, + 2, + &num_advisory_ids) == OE_OK); + OE_TEST(num_advisory_ids == 2); + for (int i = 0; i < 2; i++) + { + printf( + "AdvisoryIDs[%d]: %.*s\n", + i, + (int)advisoryIDs_length[i], + advisoryIDs[i]); + OE_TEST( + strncmp( + (const char*)advisoryIDs[i], + expectedAdvisoryIDs[i], + advisoryIDs_length[i]) == 0); + } + printf("QE Identity V2 positive test, with advisoryIDs. PASSED\n"); + + // QVE Identity V2 positive test + platform_tcb_level.isvsvn[0] = 2; + OE_TEST( + test_verify_qe_identity_info( + enclave, + &ecall_result, + (const char*)&positive_qve_id_info[0], + &platform_tcb_level, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_OK); + OE_TEST(parsed_info.id == QE_IDENTITY_ID_QVE); + check_parsed_v2_values(parsed_info); + printf("\n\nQVE Identity V2 positive test. PASSED.\n"); + + // negative test without a valid platform_tcb_level + OE_TEST( + test_verify_qe_identity_info( + enclave, + &ecall_result, + (const char*)&positive_qe_id_info[0], + NULL, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_INVALID_PARAMETER); + printf("\n\nQE Identity V2 negative test with invalid platform_tcb_level. " + "PASSED.\n"); + + // validate negative case + qe_identity_test_case_t test_cases[] = { + {"./data_v2/qe_identity_missing_qeidentity.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_version.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_issuedate.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_nextupdate.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_miscselect.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_miscselectmask.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_attributes.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_attributesmask.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_isvprodid.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_isvsvn.json", OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_signature.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_id.json", OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_mrsigner.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_tcb_date.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_tcb_eval_data_num.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_tcb_levels.json", + OE_JSON_INFO_PARSE_ERROR}, + {"./data_v2/qe_identity_missing_tcb_status.json", + OE_JSON_INFO_PARSE_ERROR}}; + + for (size_t i = 0; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i) + { + std::vector qeIdInfo = FileToBytes(test_cases[i].file_name); + oe_parsed_qe_identity_info_t parsed_info = {0}; + oe_result_t ecall_result = OE_FAILURE; + printf("Testing file %s ", test_cases[i].file_name); + OE_TEST( + test_verify_qe_identity_info( + enclave, + &ecall_result, + (const char*)&qeIdInfo[0], + &platform_tcb_level, &parsed_info) == OE_OK); printf( - "ecall_result = %d expected_result = %d\n", - ecall_result, - test_cases[i].expected_result); + "%s: ecall_result = %s expected_result = %s\n", + test_cases[i].file_name, + oe_result_str(ecall_result), + oe_result_str(test_cases[i].expected_result)); OE_TEST(ecall_result == test_cases[i].expected_result); printf("passed\n"); } diff --git a/tests/qeidentity/tests.edl b/tests/qeidentity/tests.edl index bf7c1ed511..1bf5e43db1 100644 --- a/tests/qeidentity/tests.edl +++ b/tests/qeidentity/tests.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { @@ -7,7 +7,8 @@ enclave { // qe identity info tests. public oe_result_t test_verify_qe_identity_info( [in, string] const char* info_json, - [user_check] oe_parsed_qe_identity_info_t* parsed_info); + [in] oe_qe_identity_info_tcb_level_t* platform_tcb_level, + [out] oe_parsed_qe_identity_info_t* parsed_info); }; untrusted { }; diff --git a/tests/report/CMakeLists.txt b/tests/report/CMakeLists.txt index 90f785654b..01d37793e6 100644 --- a/tests/report/CMakeLists.txt +++ b/tests/report/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) @@ -15,3 +15,7 @@ set_tests_properties(tests/report PROPERTIES SKIP_RETURN_CODE 2) add_enclave_test(tests/report_attestation_without_enclave report_host report_enc --attest-generated-report) set_tests_properties(tests/report_attestation_without_enclave PROPERTIES SKIP_RETURN_CODE 2) + +# Run all tests with EEID +add_enclave_test(tests/report-eeid report_host report_enc_eeid --eeid) +set_tests_properties(tests/report PROPERTIES SKIP_RETURN_CODE 2) \ No newline at end of file diff --git a/tests/report/common/includes.h b/tests/report/common/includes.h index b5292699aa..ff2d078799 100644 --- a/tests/report/common/includes.h +++ b/tests/report/common/includes.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _COMMON_INCLUDES_H_ diff --git a/tests/report/common/tests.cpp b/tests/report/common/tests.cpp index cd2517e19a..517ee5c5db 100644 --- a/tests/report/common/tests.cpp +++ b/tests/report/common/tests.cpp @@ -1,16 +1,329 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "../common/tests.h" +#include +#include +#include #include +#ifndef OE_BUILD_ENCLAVE +#include "../../../host/sgx/sgxquoteprovider.h" +#endif +#include "../../../common/oe_host_stdlib.h" +#include "../../../common/sgx/endorsements.h" +#include "../../../common/sgx/qeidentity.h" +#include "../../../common/sgx/quote.h" +#include "../../../common/sgx/revocation.h" + +#include + +/** + * Get collateral data which can be used with future function + * oe_verify_report_with_collaterals(). + * + * @param[in] enclave The instance of the enclave that will be used. + * @param[in] collaterals_buffer The buffer containing the collaterals to parse. + * @param[in] collaterals_buffer_size The size of the **collaterals_buffer**. + * + * @retval OE_OK The collaterals were successfully retrieved. + */ +oe_result_t oe_get_collaterals( +#ifndef OE_BUILD_ENCLAVE + oe_enclave_t* enclave, +#endif + uint8_t** collaterals_buffer, + size_t* collaterals_buffer_size) +{ + oe_result_t result = OE_UNEXPECTED; + size_t report_size = OE_MAX_REPORT_SIZE; + uint8_t* remote_report = NULL; + oe_report_t* parsed_report = NULL; + oe_report_header_t* header = NULL; + + OE_TRACE_INFO("Enter enclave call %s\n", __FUNCTION__); + + if ((collaterals_buffer == NULL) || (collaterals_buffer_size == NULL)) + { + OE_RAISE(OE_INVALID_PARAMETER); + } + + *collaterals_buffer = NULL; + *collaterals_buffer_size = 0; + +#ifdef OE_BUILD_ENCLAVE + // Get a remote OE report. + // We need a report in order to fetch the uris of the certificates in the + // sgx quote. + OE_CHECK_MSG( + oe_get_report( + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + NULL, + 0, + NULL, + 0, + (uint8_t**)&remote_report, + &report_size), + "Failed to get OE remote report. %s", + oe_result_str(result)); + header = (oe_report_header_t*)remote_report; + + OE_CHECK_MSG( + oe_verify_report(remote_report, report_size, parsed_report), + "Failed to verify OE remote report. %s", + oe_result_str(result)); +#else + OE_CHECK_MSG( + oe_initialize_quote_provider(), + "Failed to initialize quote provider. %s", + oe_result_str(result)); + + OE_CHECK_MSG( + oe_get_report( + enclave, + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + NULL, + 0, + (uint8_t**)&remote_report, + &report_size), + "Failed to get OE remote report. %s", + oe_result_str(result)); + header = (oe_report_header_t*)remote_report; + + OE_CHECK_MSG( + oe_verify_report(enclave, remote_report, report_size, parsed_report), + "Failed to verify OE remote report. %s", + oe_result_str(result)); +#endif + + OE_CHECK_MSG( + oe_get_sgx_endorsements( + header->report, + header->report_size, + collaterals_buffer, + collaterals_buffer_size), + "Failed to get collaterals. %s", + oe_result_str(result)); + + result = OE_OK; +done: + if (remote_report) + oe_free_report(remote_report); + + OE_TRACE_INFO( + "Exit enclave call %s: %d(%s)\n", + __FUNCTION__, + result, + oe_result_str(result)); + + return result; +} + +/** + * Verify the integrity of the report and its signature, + * with optional collateral data that is associated with the report. + * + * This function verifies that the report signature is valid. This only applies + * to remote reports. For remote reports it verifies that the signing authority + * is rooted to a trusted authority such as the enclave platform manufacturer. + * + * @param[in] enclave The instance of the enclave that will be used. + * @param[in] report The buffer containing the report to verify. + * @param[in] report_size The size of the **report** buffer. + * @param[in] collaterals Optional The collateral data that is associated with + * the report. + * @param[in] collaterals_size The size of the **collaterals** buffer. + * @param[in] input_validation_time Optional datetime to use when validating + * collaterals. If not specified, it will used the creation_datetime of the + * collaterals (if any collaterals are provided). + * @param[out] parsed_report Optional **oe_report_t** structure to populate with + * the report properties in a standard format. + * + * @retval OE_OK The report was successfully created. + * @retval OE_INVALID_PARAMETER At least one parameter is invalid. + * + */ +static oe_result_t oe_verify_report_with_collaterals( +#ifndef OE_BUILD_ENCLAVE + oe_enclave_t* enclave, +#endif + const uint8_t* report, + size_t report_size, + const uint8_t* collaterals, + size_t collaterals_size, + oe_datetime_t* input_validation_time, + oe_report_t* parsed_report) +{ + oe_result_t result = OE_UNEXPECTED; + oe_report_t oe_report = {0}; + oe_report_header_t* header = (oe_report_header_t*)report; + + if (report == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + if (report_size == 0 || report_size > OE_MAX_REPORT_SIZE) + OE_RAISE(OE_INVALID_PARAMETER); + + // Ensure that the report is parseable before using the header. + OE_CHECK(oe_parse_report(report, report_size, &oe_report)); + + if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE) + { +#ifndef OE_BUILD_ENCLAVE + // Intialize the quote provider if we want to verify a remote quote. + // Note that we don't have the OE_LINK_SGX_DCAP_QL guard here since we + // don't need the sgx libraries to verify the quote. All we need is the + // quote provider. + OE_CHECK(oe_initialize_quote_provider()); +#endif + + // Quote attestation can be done entirely on the host side. + OE_CHECK(oe_verify_sgx_quote( + header->report, + header->report_size, + collaterals, + collaterals_size, + input_validation_time)); + + // Optionally return parsed report. + if (parsed_report != NULL) + OE_CHECK(oe_parse_report(report, report_size, parsed_report)); + } + else if (header->report_type == OE_REPORT_TYPE_SGX_LOCAL) + { + if (collaterals != NULL || collaterals_size > 0) + { + OE_RAISE_MSG( + OE_UNSUPPORTED, + "Local reports should not have collaterals.", + NULL); + } + +#ifndef OE_BUILD_ENCLAVE + if (enclave == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + OE_CHECK(oe_verify_report(enclave, report, report_size, parsed_report)); +#else + OE_CHECK(oe_verify_report(report, report_size, parsed_report)); +#endif + } + else + { + OE_RAISE(OE_INVALID_PARAMETER); + } + + result = OE_OK; +done: + return result; +} + +/** + * Free up any resources allocated by oe_get_collateras() + * + * @param[in] collaterals_buffer The buffer containing the collaterals. + */ +static void oe_free_collaterals(uint8_t* collaterals_buffer) +{ + oe_free_sgx_endorsements(collaterals_buffer); +} + +/*! + * Find the valid datetime range for the given **remote report** and + * collaterals. This function accounts for the following items: + * + * 1. From the quote: + * a) Root CA. + * b) Intermediate CA. + * b) PCK CA. + * 2. From the revocation info: + * a) Root CA CRL. + * b) Intermediate CA CRL. + * c) PCK CA CRL. + * d) TCB info cert. + * e) TCB info. + * 3. From QE identity info + * a) QE identity cert. + * b) QE identity. + * + * @param[in] report The buffer containing the report to verify. + * @param[in] report_size The size of the **report** buffer. + * @param[in] endorsements Endorsements related to the quote. + * @param[in] endorsements_size The size of the endorsements. + * @param[out] valid_from validity_from The date from which the quote is valid. + * @param[out] valid_until validity_until The date which the quote expires. + */ +static oe_result_t oe_get_quote_validity_with_collaterals( + const uint8_t* report, + const size_t report_size, + const uint8_t* endorsements, + size_t endorsements_size, + oe_datetime_t* valid_from, + oe_datetime_t* valid_until) +{ + oe_result_t result = OE_UNEXPECTED; + oe_report_t oe_report = {0}; + oe_report_header_t* header = (oe_report_header_t*)report; + oe_sgx_endorsements_t sgx_endorsements; + + if (report == NULL || endorsements == NULL || valid_from == NULL || + valid_until == NULL) + OE_RAISE(OE_INVALID_PARAMETER); + + if (report_size == 0 || report_size > OE_MAX_REPORT_SIZE || + endorsements_size == 0) + OE_RAISE(OE_INVALID_PARAMETER); + + // Ensure that the report is parseable before using the header. + OE_CHECK(oe_parse_report(report, report_size, &oe_report)); + + if (header->report_type == OE_REPORT_TYPE_SGX_REMOTE) + { +#ifndef OE_BUILD_ENCLAVE + // Intialize the quote provider if we want to verify a remote quote. + // Note that we don't have the OE_LINK_SGX_DCAP_QL guard here since we + // don't need the sgx libraries to verify the quote. All we need is the + // quote provider. + OE_CHECK(oe_initialize_quote_provider()); +#endif + + OE_CHECK_MSG( + oe_parse_sgx_endorsements( + (oe_endorsements_t*)endorsements, + endorsements_size, + &sgx_endorsements), + "Failed to parse SGX endorsements.", + oe_result_str(result)); + + // Quote attestation can be done entirely on the host side. + OE_CHECK(oe_get_sgx_quote_validity( + header->report, + header->report_size, + &sgx_endorsements, + valid_from, + valid_until)); + } + else + { + OE_RAISE(OE_INVALID_PARAMETER); + } + + result = OE_OK; +done: + return result; +} + #ifdef OE_BUILD_ENCLAVE #include #define GetReport oe_get_report #define GetReport_v2 oe_get_report_v2 -#define VerifyReport oe_verify_report +#define GetCollaterals oe_get_collaterals + +#define VerifyReport oe_verify_report_eeid +#define VerifyReportWithCollaterals oe_verify_report_with_collaterals +#define GetQuoteValidityWithCollaterals oe_get_quote_validity_with_collaterals #else @@ -24,10 +337,15 @@ oe_enclave_t* g_enclave = NULL; #define GetReport_v2(flags, rd, rds, op, ops, rb, rbs) \ oe_get_report_v2(g_enclave, flags, op, ops, rb, rbs) +// Get collateral macros. Host side API has an additional enclave object. +#define GetCollaterals(data, data_size) \ + oe_get_collaterals(g_enclave, data, data_size) + oe_result_t VerifyReport( const uint8_t* report, size_t report_size, - oe_report_t* parsed_report) + oe_report_t* parsed_report, + oe_eeid_t* eeid = NULL) { oe_report_t tmp_report = {0}; OE_TEST(oe_parse_report(report, report_size, &tmp_report) == OE_OK); @@ -36,11 +354,68 @@ oe_result_t VerifyReport( { // Check that remote attestation can be done entirely on the host side. // No enclave is passed to oe_verify_report. - return oe_verify_report(NULL, report, report_size, parsed_report); + return oe_verify_report_eeid( + NULL, report, report_size, parsed_report, eeid); } // Local attestation requires enclave. - return oe_verify_report(g_enclave, report, report_size, parsed_report); + return oe_verify_report_eeid( + g_enclave, report, report_size, parsed_report, eeid); +} + +oe_result_t VerifyReportWithCollaterals( + const uint8_t* report, + size_t report_size, + const uint8_t* collaterals, + size_t collaterals_size, + oe_datetime_t* input_validation_time, + oe_report_t* parsed_report) +{ + oe_report_t tmp_report = {0}; + OE_TEST(oe_parse_report(report, report_size, &tmp_report) == OE_OK); + + if (tmp_report.identity.attributes & OE_REPORT_ATTRIBUTES_REMOTE) + { + return oe_verify_report_with_collaterals( + g_enclave, + report, + report_size, + collaterals, + collaterals_size, + input_validation_time, + parsed_report); + } + else + { + return OE_UNSUPPORTED; + } +} + +oe_result_t GetQuoteValidityWithCollaterals( + const uint8_t* report, + size_t report_size, + const uint8_t* collaterals, + size_t collaterals_size, + oe_datetime_t* valid_from, + oe_datetime_t* valid_until) +{ + oe_report_t tmp_report = {0}; + OE_TEST(oe_parse_report(report, report_size, &tmp_report) == OE_OK); + + if (tmp_report.identity.attributes & OE_REPORT_ATTRIBUTES_REMOTE) + { + return oe_get_quote_validity_with_collaterals( + report, + report_size, + collaterals, + collaterals_size, + valid_from, + valid_until); + } + else + { + return OE_UNSUPPORTED; + } } #endif @@ -761,7 +1136,7 @@ static void GetSGXTargetInfo(sgx_target_info_t* sgx_target_info) oe_free_report(report_buffer); } -void test_local_verify_report() +void test_local_verify_report(oe_eeid_t* eeid) { uint8_t target_info[sizeof(sgx_target_info_t)]; size_t target_info_size = sizeof(target_info); @@ -788,7 +1163,7 @@ void test_local_verify_report() target_info_size, &report_ptr, &report_size) == OE_OK); - OE_TEST(VerifyReport(report_ptr, report_size, NULL) == OE_OK); + OE_TEST(VerifyReport(report_ptr, report_size, NULL, eeid) == OE_OK); oe_free_report(report_ptr); // 2. Report with full custom report data. @@ -802,7 +1177,7 @@ void test_local_verify_report() target_info_size, &report_ptr, &report_size) == OE_OK); - OE_TEST(VerifyReport(report_ptr, report_size, NULL) == OE_OK); + OE_TEST(VerifyReport(report_ptr, report_size, NULL, eeid) == OE_OK); oe_free_report(report_ptr); // 3. Report with partial custom report data. @@ -815,7 +1190,7 @@ void test_local_verify_report() target_info_size, &report_ptr, &report_size) == OE_OK); - OE_TEST(VerifyReport(report_ptr, report_size, NULL) == OE_OK); + OE_TEST(VerifyReport(report_ptr, report_size, NULL, eeid) == OE_OK); oe_free_report(report_ptr); #endif @@ -835,12 +1210,12 @@ void test_local_verify_report() &report_ptr, &report_size) == OE_OK); OE_TEST( - VerifyReport(report_ptr, report_size, NULL) == + VerifyReport(report_ptr, report_size, NULL, eeid) == OE_VERIFY_FAILED_AES_CMAC_MISMATCH); oe_free_report(report_ptr); } -void test_remote_verify_report() +void test_remote_verify_report(oe_eeid_t* eeid) { uint8_t* report_ptr; size_t report_size; @@ -868,7 +1243,7 @@ void test_remote_verify_report() OE_TEST( GetReport_v2(flags, NULL, 0, NULL, 0, &report_ptr, &report_size) == OE_OK); - OE_TEST(VerifyReport(report_ptr, report_size, NULL) == OE_OK); + OE_TEST(VerifyReport(report_ptr, report_size, NULL, eeid) == OE_OK); oe_free_report(report_ptr); #if OE_BUILD_ENCLAVE @@ -882,8 +1257,136 @@ void test_remote_verify_report() 0, &report_ptr, &report_size) == OE_OK); - OE_TEST(VerifyReport(report_ptr, report_size, NULL) == OE_OK); + OE_TEST(VerifyReport(report_ptr, report_size, NULL, eeid) == OE_OK); oe_free_report(report_ptr); #endif } } + +void test_verify_report_with_collaterals() +{ + uint32_t flags = OE_REPORT_FLAGS_REMOTE_ATTESTATION; + + size_t report_ptr_size; + uint8_t* report_buffer_ptr; + + size_t collaterals_ptr_size = 0; + uint8_t* collaterals_buffer_ptr = NULL; + + /* Test 1: Verify report with collaterals */ + OE_TEST( + GetReport_v2( + flags, NULL, 0, NULL, 0, &report_buffer_ptr, &report_ptr_size) == + OE_OK); + + /* Verify report without collaterals */ + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, report_ptr_size, NULL, 0, NULL, NULL) == OE_OK); + + if (GetCollaterals(&collaterals_buffer_ptr, &collaterals_ptr_size) == OE_OK) + { + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + NULL, // Validate using current time + NULL) == OE_OK); + + /* Test with time in the past */ + time_t t; + struct tm* timeinfo; + time(&t); + timeinfo = gmtime(&t); + + // convert tm to oe_datetime_t + oe_datetime_t past = {(uint32_t)timeinfo->tm_year + 1890, + (uint32_t)timeinfo->tm_mon + 1, + (uint32_t)timeinfo->tm_mday, + (uint32_t)timeinfo->tm_hour, + (uint32_t)timeinfo->tm_min, + (uint32_t)timeinfo->tm_sec}; + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &past, + NULL) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); + + /* Test with time in the future */ + oe_datetime_t future = {(uint32_t)timeinfo->tm_year + 1910, + (uint32_t)timeinfo->tm_mon + 1, + (uint32_t)timeinfo->tm_mday, + (uint32_t)timeinfo->tm_hour, + (uint32_t)timeinfo->tm_min, + (uint32_t)timeinfo->tm_sec}; + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &future, + NULL) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); + + /* Get validity range and use it to validate edge cases.*/ + oe_datetime_t valid_from = {0}; + oe_datetime_t valid_until = {0}; + OE_TEST( + GetQuoteValidityWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &valid_from, + &valid_until) == OE_OK); + /* At latest valid from date */ + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &valid_from, + NULL) == OE_OK); + /* At earliest expiration date */ + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &valid_until, + NULL) == OE_OK); + + valid_from.year -= 1; + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &valid_from, + NULL) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); + + valid_until.year += 1; + OE_TEST( + VerifyReportWithCollaterals( + report_buffer_ptr, + report_ptr_size, + collaterals_buffer_ptr, + collaterals_ptr_size, + &valid_until, + NULL) == OE_VERIFY_FAILED_TO_FIND_VALIDITY_PERIOD); + } + + oe_free_collaterals(collaterals_buffer_ptr); + oe_free_report(report_buffer_ptr); + + collaterals_buffer_ptr = NULL; + report_buffer_ptr = NULL; +} diff --git a/tests/report/common/tests.h b/tests/report/common/tests.h index c8a4911bd4..0f9ddad825 100644 --- a/tests/report/common/tests.h +++ b/tests/report/common/tests.h @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _TESTS_H_ #define _TESTS_H_ +#include #include #ifdef OE_BUILD_ENCLAVE @@ -23,7 +24,8 @@ extern oe_enclave_t* g_enclave; void test_local_report(sgx_target_info_t* target_info); void test_remote_report(); void test_parse_report_negative(); -void test_local_verify_report(); -void test_remote_verify_report(); +void test_local_verify_report(oe_eeid_t* eeid); +void test_remote_verify_report(oe_eeid_t* eeid); +void test_verify_report_with_collaterals(); #endif diff --git a/tests/report/data/tcbInfoNegativeCompSvn.json b/tests/report/data/tcbInfoNegativeCompSvn.json index b41296286b..47d4a40fa5 100644 --- a/tests/report/data/tcbInfoNegativeCompSvn.json +++ b/tests/report/data/tcbInfoNegativeCompSvn.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativeFloat.json b/tests/report/data/tcbInfoNegativeFloat.json index e5ea823c94..1e3644b760 100644 --- a/tests/report/data/tcbInfoNegativeFloat.json +++ b/tests/report/data/tcbInfoNegativeFloat.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1.234, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativeIntegerOverflow.json b/tests/report/data/tcbInfoNegativeIntegerOverflow.json index d75dc24b32..d581bbb604 100644 --- a/tests/report/data/tcbInfoNegativeIntegerOverflow.json +++ b/tests/report/data/tcbInfoNegativeIntegerOverflow.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 10000000000000000000000000000000000, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativeIntegerWithSign.json b/tests/report/data/tcbInfoNegativeIntegerWithSign.json index c37bf74139..bd4dd7f80f 100644 --- a/tests/report/data/tcbInfoNegativeIntegerWithSign.json +++ b/tests/report/data/tcbInfoNegativeIntegerWithSign.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": -1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativeInvalidIssueDate.json b/tests/report/data/tcbInfoNegativeInvalidIssueDate.json index 6cabd038ff..50582b6fe2 100644 --- a/tests/report/data/tcbInfoNegativeInvalidIssueDate.json +++ b/tests/report/data/tcbInfoNegativeInvalidIssueDate.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-16-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePceSvn.json b/tests/report/data/tcbInfoNegativePceSvn.json index 77bb2acf1c..e45a9aa52c 100644 --- a/tests/report/data/tcbInfoNegativePceSvn.json +++ b/tests/report/data/tcbInfoNegativePceSvn.json @@ -1,7 +1,8 @@ { "tcbInfo": { - "version": 10000000000000000000000000000000000, + "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyMissingLevel1.json b/tests/report/data/tcbInfoNegativePropertyMissingLevel1.json index 2845e65fbf..4cd01c0e08 100644 --- a/tests/report/data/tcbInfoNegativePropertyMissingLevel1.json +++ b/tests/report/data/tcbInfoNegativePropertyMissingLevel1.json @@ -2,6 +2,7 @@ "tcbInfo": { "VERSION": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyMissingLevel2.json b/tests/report/data/tcbInfoNegativePropertyMissingLevel2.json index dcc45f3e9a..2b4c994d7e 100644 --- a/tests/report/data/tcbInfoNegativePropertyMissingLevel2.json +++ b/tests/report/data/tcbInfoNegativePropertyMissingLevel2.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyMissingLevel3.json b/tests/report/data/tcbInfoNegativePropertyMissingLevel3.json index 54749432d6..9057df7bc8 100644 --- a/tests/report/data/tcbInfoNegativePropertyMissingLevel3.json +++ b/tests/report/data/tcbInfoNegativePropertyMissingLevel3.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel0.json b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel0.json index 60c8b0aad9..0b082f6346 100644 --- a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel0.json +++ b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel0.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel1.json b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel1.json index 2ec898120d..037cc4241f 100644 --- a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel1.json +++ b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel1.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": 90610000, "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel2.json b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel2.json index 9ccb6f19eb..9bc9a0ffc3 100644 --- a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel2.json +++ b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel2.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel3.json b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel3.json index 788d5ecb52..b37a54f02a 100644 --- a/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel3.json +++ b/tests/report/data/tcbInfoNegativePropertyWrongTypeLevel3.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativeSignature.json b/tests/report/data/tcbInfoNegativeSignature.json index a77dc83a5d..8371279bbe 100644 --- a/tests/report/data/tcbInfoNegativeSignature.json +++ b/tests/report/data/tcbInfoNegativeSignature.json @@ -1,7 +1,8 @@ { "tcbInfo": { - "version": 10000000000000000000000000000000000, + "version": 1, "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data/tcbInfoNegativeStringEscape.json b/tests/report/data/tcbInfoNegativeStringEscape.json index 9eb7ed2454..425924ef7e 100644 --- a/tests/report/data/tcbInfoNegativeStringEscape.json +++ b/tests/report/data/tcbInfoNegativeStringEscape.json @@ -2,6 +2,7 @@ "tcbInfo": { "version": 1, "issueDate": "2018-\n06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", "fmspc": "00906EA10000", "tcbLevels": [ { diff --git a/tests/report/data_v2/tcbInfo.json b/tests/report/data_v2/tcbInfo.json new file mode 100644 index 0000000000..20c31db540 --- /dev/null +++ b/tests/report/data_v2/tcbInfo.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoAdvisoryIds.json b/tests/report/data_v2/tcbInfoAdvisoryIds.json new file mode 100644 index 0000000000..d805c042ca --- /dev/null +++ b/tests/report/data_v2/tcbInfoAdvisoryIds.json @@ -0,0 +1,129 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus":"UpToDate", + "advisoryIDs":["INTEL-SA-00079", "INTEL-SA-00076"] + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeCompSvn.json b/tests/report/data_v2/tcbInfoNegativeCompSvn.json new file mode 100644 index 0000000000..ab35696e7d --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeCompSvn.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 257, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeFloat.json b/tests/report/data_v2/tcbInfoNegativeFloat.json new file mode 100644 index 0000000000..86fddd6677 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeFloat.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2.234, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeIntegerOverflow.json b/tests/report/data_v2/tcbInfoNegativeIntegerOverflow.json new file mode 100644 index 0000000000..a139922235 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeIntegerOverflow.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 10000000000000000000000000000000000, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeIntegerWithSign.json b/tests/report/data_v2/tcbInfoNegativeIntegerWithSign.json new file mode 100644 index 0000000000..e44a4e7f8b --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeIntegerWithSign.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": -1, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeInvalidIssueDate.json b/tests/report/data_v2/tcbInfoNegativeInvalidIssueDate.json new file mode 100644 index 0000000000..3f4f599469 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeInvalidIssueDate.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-16-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeInvalidNextUpdate.json b/tests/report/data_v2/tcbInfoNegativeInvalidNextUpdate.json new file mode 100644 index 0000000000..fc015a9167 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeInvalidNextUpdate.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-16-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeMissingNextUpdate.json b/tests/report/data_v2/tcbInfoNegativeMissingNextUpdate.json new file mode 100644 index 0000000000..32e51143a1 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeMissingNextUpdate.json @@ -0,0 +1,127 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePceSvn.json b/tests/report/data_v2/tcbInfoNegativePceSvn.json new file mode 100644 index 0000000000..bc3c2fcf68 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePceSvn.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":65537 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel0.json b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel0.json new file mode 100644 index 0000000000..56774bab0e --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel0.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "SIGNATURE": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel1.json b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel1.json new file mode 100644 index 0000000000..13571b4179 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel1.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "VERSION": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel2.json b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel2.json new file mode 100644 index 0000000000..d5f434c2e9 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel2.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "TCBDATE":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel3.json b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel3.json new file mode 100644 index 0000000000..0b214ad3f1 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyMissingLevel3.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "PCESVN":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel0.json b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel0.json new file mode 100644 index 0000000000..b177198b7c --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel0.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": 123456 +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel1.json b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel1.json new file mode 100644 index 0000000000..b51236e0df --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel1.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": 90610000, + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel2.json b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel2.json new file mode 100644 index 0000000000..18b992d30f --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel2.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":1 + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel3.json b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel3.json new file mode 100644 index 0000000000..852e2af0f0 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativePropertyWrongTypeLevel3.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": "128", + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeSignature.json b/tests/report/data_v2/tcbInfoNegativeSignature.json new file mode 100644 index 0000000000..c16ac9e2e4 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeSignature.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "1c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfoNegativeStringEscape.json b/tests/report/data_v2/tcbInfoNegativeStringEscape.json new file mode 100644 index 0000000000..f0ce9392b3 --- /dev/null +++ b/tests/report/data_v2/tcbInfoNegativeStringEscape.json @@ -0,0 +1,128 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-\n06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2019-05-15T00:00:00Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-08-15T00:00:00Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T00:00:00Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/data_v2/tcbInfo_with_pceid.json b/tests/report/data_v2/tcbInfo_with_pceid.json new file mode 100644 index 0000000000..e904ba82e7 --- /dev/null +++ b/tests/report/data_v2/tcbInfo_with_pceid.json @@ -0,0 +1,129 @@ +{ + "tcbInfo": { + "version": 2, + "issueDate": "2018-06-06T10:12:17Z", + "nextUpdate": "2019-06-06T10:12:17Z", + "fmspc": "00906EA10000", + "pceId":"0000", + "tcbType": 0, + "tcbEvaluationDataNumber":5, + "tcbLevels": [ + { + "tcb":{ + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn":6 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus":"UpToDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 4, + "sgxtcbcomp02svn": 4, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 5 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "OutOfDateConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 4 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "ConfigurationNeeded" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 3 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "OutOfDate" + }, + { + "tcb": { + "sgxtcbcomp01svn": 2, + "sgxtcbcomp02svn": 2, + "sgxtcbcomp03svn": 2, + "sgxtcbcomp04svn": 4, + "sgxtcbcomp05svn": 1, + "sgxtcbcomp06svn": 128, + "sgxtcbcomp07svn": 1, + "sgxtcbcomp08svn": 1, + "sgxtcbcomp09svn": 1, + "sgxtcbcomp10svn": 1, + "sgxtcbcomp11svn": 1, + "sgxtcbcomp12svn": 1, + "sgxtcbcomp13svn": 1, + "sgxtcbcomp14svn": 1, + "sgxtcbcomp15svn": 1, + "sgxtcbcomp16svn": 1, + "pcesvn": 2 + }, + "tcbDate":"2018-01-04T01:02:03Z", + "tcbStatus": "Revoked" + } + ] + }, + "signature": "62d181c4ba863213b825d1c0b66b92a3dbdb27b8ff7c7250cb2b2ab87a8f90d5e5a1416914369d8f82c56cd3d875caa54ae4b917caf4af7a93dec52067cbfd7b" +} diff --git a/tests/report/enc/CMakeLists.txt b/tests/report/enc/CMakeLists.txt index 40f4304703..a2ee0b144b 100644 --- a/tests/report/enc/CMakeLists.txt +++ b/tests/report/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. @@ -12,3 +12,15 @@ target_include_directories(report_enc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../common) target_link_libraries(report_enc oelibc) + + +add_enclave(TARGET report_enc_eeid UUID 20b1a091-50da-4e57-b58c-0a8489cb64a7 + SOURCES enc.cpp datetime.cpp ../common/tests.cpp ${gen}) + +target_compile_definitions(report_enc_eeid PUBLIC EEID_ENABLED) + +target_include_directories(report_enc_eeid PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../common) + +target_link_libraries(report_enc_eeid oelibc) \ No newline at end of file diff --git a/tests/report/enc/datetime.cpp b/tests/report/enc/datetime.cpp index 43f7f8d2dd..fedbac19f5 100644 --- a/tests/report/enc/datetime.cpp +++ b/tests/report/enc/datetime.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/report/enc/enc.cpp b/tests/report/enc/enc.cpp index 3e71365de1..e2931e7455 100644 --- a/tests/report/enc/enc.cpp +++ b/tests/report/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include @@ -14,10 +14,10 @@ oe_result_t test_verify_tcb_info( const char* tcb_info, - oe_tcb_level_t* platform_tcb_level, + oe_tcb_info_tcb_level_t* platform_tcb_level, oe_parsed_tcb_info_t* parsed_tcb_info) { -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL return oe_parse_tcb_info_json( (const uint8_t*)tcb_info, strlen(tcb_info) + 1, @@ -33,7 +33,7 @@ oe_result_t test_verify_tcb_info( void test_minimum_issue_date(oe_datetime_t now) { -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL static uint8_t* report; size_t report_size = 0; static uint8_t* report_v2; @@ -94,6 +94,10 @@ void test_minimum_issue_date(oe_datetime_t now) oe_verify_report(report_v2, report_v2_size, NULL) == OE_INVALID_REVOCATION_INFO); + // Restore default minimum CRL/TCB issue date + OE_TEST( + __oe_sgx_set_minimum_crl_tcb_issue_date(2017, 3, 17, 0, 0, 0) == OE_OK); + oe_free_report(report); oe_free_report(report_v2); @@ -118,16 +122,30 @@ void enclave_test_parse_report_negative() test_parse_report_negative(); } -void enclave_test_local_verify_report() +void enclave_test_local_verify_report(oe_eeid_t* eeid) +{ + test_local_verify_report(eeid); +} + +void enclave_test_remote_verify_report(oe_eeid_t* eeid) { - test_local_verify_report(); + test_remote_verify_report(eeid); } -void enclave_test_remote_verify_report() +void enclave_test_verify_report_with_collaterals() { - test_remote_verify_report(); + test_verify_report_with_collaterals(); } +#ifdef EEID_ENABLED +OE_SET_ENCLAVE_SGX( + 0, /* ProductID */ + 0, /* SecurityVersion */ + true, /* AllowDebug */ + 0, /* HeapPageCount */ + 0, /* StackPageCount */ + 0); /* TCSCount */ +#else OE_SET_ENCLAVE_SGX( 0, /* ProductID */ 0, /* SecurityVersion */ @@ -135,3 +153,4 @@ OE_SET_ENCLAVE_SGX( 1024, /* HeapPageCount */ 1024, /* StackPageCount */ 2); /* TCSCount */ +#endif \ No newline at end of file diff --git a/tests/report/host/CMakeLists.txt b/tests/report/host/CMakeLists.txt index aa39a12873..6ea3a62325 100644 --- a/tests/report/host/CMakeLists.txt +++ b/tests/report/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(add_dcap_client_target) @@ -6,12 +6,13 @@ include(add_dcap_client_target) oeedl_file(../tests.edl host gen) add_executable(report_host host.cpp tcbinfo.cpp ../common/tests.cpp ${gen}) -if(USE_LIBSGX) - target_compile_definitions(report_host PRIVATE OE_USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(report_host PRIVATE OE_LINK_SGX_DCAP_QL) endif() add_custom_command(TARGET report_host COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../data ${CMAKE_CURRENT_BINARY_DIR}/../data + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../data_v2 ${CMAKE_CURRENT_BINARY_DIR}/../data_v2 ) target_include_directories(report_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../common) diff --git a/tests/report/host/host.cpp b/tests/report/host/host.cpp index 5c17b0a9f6..2077072f9a 100644 --- a/tests/report/host/host.cpp +++ b/tests/report/host/host.cpp @@ -1,8 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include -#include #include #include #include @@ -14,6 +13,8 @@ #include "../common/tests.h" #include "tests_u.h" +#include "../host/signkey.h" + #ifdef _WIN32 #include #include @@ -24,11 +25,19 @@ extern void TestVerifyTCBInfo( oe_enclave_t* enclave, const char* test_file_name); +extern void TestVerifyTCBInfoV2( + oe_enclave_t* enclave, + const char* test_filename); +extern void TestVerifyTCBInfoV2_AdvisoryIDs( + oe_enclave_t* enclave, + const char* test_filename); extern int FileToBytes(const char* path, std::vector* output); +oe_eeid_t* eeid = NULL; + void generate_and_save_report(oe_enclave_t* enclave) { -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL static uint8_t* report; size_t report_size; OE_TEST( @@ -69,10 +78,11 @@ int load_and_verify_report() int main(int argc, const char* argv[]) { - sgx_target_info_t target_info; oe_result_t result; oe_enclave_t* enclave = NULL; + sgx_target_info_t target_info = {{0}}; + #ifdef _WIN32 /* This is a workaround for running in Visual Studio 2017 Test Explorer * where the environment variables are not correctly propagated to the @@ -125,26 +135,45 @@ int main(int argc, const char* argv[]) { return load_and_verify_report(); } + else if (argc == 3 && strcmp(argv[2], "--eeid") == 0) + { + uint64_t sz = oe_round_up_to_page_size(sizeof(oe_eeid_t) + 512); + eeid = (oe_eeid_t*)calloc(1, sz); + eeid->size_settings.num_heap_pages = 1024; + eeid->size_settings.num_stack_pages = 1024; + eeid->size_settings.num_tcs = 2; + eeid->data_size = 512; + for (size_t i = 0; i < eeid->data_size; i++) + eeid->data[i] = (uint8_t)i; + } /* Check arguments */ - if (argc != 2) + if (argc != 2 && argc != 3) { fprintf(stderr, "Usage: %s ENCLAVE\n", argv[0]); exit(1); } /* Create the enclave */ - if ((result = oe_create_tests_enclave( - argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave)) != OE_OK) + if (eeid) { - oe_put_err("oe_create_tests_enclave(): result=%u", result); + if ((result = oe_create_tests_enclave_eeid( + argv[1], + OE_ENCLAVE_TYPE_SGX, + flags, + NULL, + 0, + eeid, + &enclave)) != OE_OK) + oe_put_err("oe_create_tests_enclave_eeid(): result=%u", result); } - - /* Initialize the target info */ + else { - if ((result = sgx_get_qetarget_info(&target_info)) != OE_OK) + if ((result = oe_create_tests_enclave( + argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave)) != + OE_OK) { - oe_put_err("sgx_get_qetarget_info(): result=%u", result); + oe_put_err("oe_create_tests_enclave(): result=%u", result); } } @@ -153,13 +182,24 @@ int main(int argc, const char* argv[]) */ g_enclave = enclave; -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL + + /* Initialize the target info */ + { + if ((result = sgx_get_qetarget_info(&target_info)) != OE_OK) + { + oe_put_err("sgx_get_qetarget_info(): result=%u", result); + } + } + test_local_report(&target_info); test_remote_report(); test_parse_report_negative(); - test_local_verify_report(); + test_local_verify_report(eeid); + + test_remote_verify_report(eeid); - test_remote_verify_report(); + test_verify_report_with_collaterals(); OE_TEST(test_iso8601_time(enclave) == OE_OK); OE_TEST(test_iso8601_time_negative(enclave) == OE_OK); @@ -172,13 +212,20 @@ int main(int argc, const char* argv[]) OE_TEST(enclave_test_parse_report_negative(enclave) == OE_OK); - OE_TEST(enclave_test_local_verify_report(enclave) == OE_OK); + OE_TEST(enclave_test_local_verify_report(enclave, eeid) == OE_OK); - OE_TEST(enclave_test_remote_verify_report(enclave) == OE_OK); + OE_TEST(enclave_test_remote_verify_report(enclave, eeid) == OE_OK); + + OE_TEST(enclave_test_verify_report_with_collaterals(enclave) == OE_OK); TestVerifyTCBInfo(enclave, "./data/tcbInfo.json"); TestVerifyTCBInfo(enclave, "./data/tcbInfo_with_pceid.json"); + TestVerifyTCBInfoV2(enclave, "./data_v2/tcbInfo.json"); + TestVerifyTCBInfoV2(enclave, "./data_v2/tcbInfo_with_pceid.json"); + TestVerifyTCBInfoV2_AdvisoryIDs( + enclave, "./data_v2/tcbInfoAdvisoryIds.json"); + // Get current time and pass it to enclave. std::time_t t = std::time(0); std::tm* tm = std::gmtime(&t); @@ -194,7 +241,6 @@ int main(int argc, const char* argv[]) test_minimum_issue_date(enclave, now); generate_and_save_report(enclave); - #else test_local_report(&target_info); test_parse_report_negative(); diff --git a/tests/report/host/tcbinfo.cpp b/tests/report/host/tcbinfo.cpp index 1725bd9153..d650a9f923 100644 --- a/tests/report/host/tcbinfo.cpp +++ b/tests/report/host/tcbinfo.cpp @@ -1,8 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include -#include #include #include #include @@ -37,9 +36,9 @@ int FileToBytes(const char* path, std::vector* out) return 0; } -void AssertParsedValues(oe_parsed_tcb_info_t& parsed_info) +void AssertParsedValues(oe_parsed_tcb_info_t& parsed_info, uint32_t version) { - OE_TEST(parsed_info.version == 1); + OE_TEST(parsed_info.version == version); oe_datetime_t expected_issue_date = {2018, 6, 6, 10, 12, 17}; OE_TEST( @@ -68,23 +67,33 @@ void AssertParsedValues(oe_parsed_tcb_info_t& parsed_info) parsed_info.signature, expected_signature, sizeof(expected_signature)) == 0); + + if (version == 2) + { + //"tcbDate":"2018-01-04T01:02:03Z", + oe_datetime_t expected_tcb_date = {2018, 1, 4, 1, 2, 3}; + OE_TEST( + oe_datetime_compare( + &parsed_info.tcb_level.tcb_date, &expected_tcb_date) == 0); + } } void TestVerifyTCBInfo( oe_enclave_t* enclave, const char* test_filename, - oe_tcb_level_t* platform_tcb_level, - oe_result_t expected) + oe_tcb_info_tcb_level_t* platform_tcb_level, + oe_parsed_tcb_info_t* parsed_info, + oe_result_t expected, + uint32_t version) { std::vector tcbInfo; OE_TEST(FileToBytes(test_filename, &tcbInfo) == 0); - oe_parsed_tcb_info_t parsed_info = {0}; oe_result_t ecall_result = OE_FAILURE; // Contains nextUpdate field. - memset(&parsed_info, 0, sizeof(parsed_info)); - platform_tcb_level->status = OE_TCB_LEVEL_STATUS_UNKNOWN; + memset(parsed_info, 0, sizeof(oe_parsed_tcb_info_t)); + platform_tcb_level->status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; OE_TEST( test_verify_tcb_info( @@ -92,20 +101,20 @@ void TestVerifyTCBInfo( &ecall_result, (const char*)&tcbInfo[0], platform_tcb_level, - &parsed_info) == OE_OK); + parsed_info) == OE_OK); OE_TEST(ecall_result == expected); - AssertParsedValues(parsed_info); + AssertParsedValues(*parsed_info, version); oe_datetime_t nextUpdate = {2019, 6, 6, 10, 12, 17}; - OE_TEST(oe_datetime_compare(&parsed_info.next_update, &nextUpdate) == 0); + OE_TEST(oe_datetime_compare(&parsed_info->next_update, &nextUpdate) == 0); } void TestVerifyTCBInfo(oe_enclave_t* enclave, const char* test_filename) { - oe_tcb_level_t platform_tcb_level = { - {4, 4, 2, 4, 1, 128, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - 8, - OE_TCB_LEVEL_STATUS_UNKNOWN}; + const uint32_t version = 1; + oe_tcb_info_tcb_level_t platform_tcb_level = { + {4, 4, 2, 4, 1, 128, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 8}; + oe_parsed_tcb_info_t parsed_info = {0}; // ./data/tcbInfo.json contains 4 tcb levels. // The first level with pce svn = 5 is up to date. @@ -115,50 +124,76 @@ void TestVerifyTCBInfo(oe_enclave_t* enclave, const char* test_filename) // Set platform pce svn to 8 and assert that // the determined status is up to date. - platform_tcb_level.status = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; platform_tcb_level.pce_svn = 8; - TestVerifyTCBInfo(enclave, test_filename, &platform_tcb_level, OE_OK); - OE_TEST(platform_tcb_level.status == OE_TCB_LEVEL_STATUS_UP_TO_DATE); + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_OK, + version); + OE_TEST(platform_tcb_level.status.fields.up_to_date == 1); printf("UptoDate TCB Level determination test passed.\n"); // Set platform pce svn to 4 and assert that // the determined status is configuration needed. - platform_tcb_level.status = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; platform_tcb_level.pce_svn = 4; TestVerifyTCBInfo( - enclave, test_filename, &platform_tcb_level, OE_TCB_LEVEL_INVALID); - OE_TEST( - platform_tcb_level.status == OE_TCB_LEVEL_STATUS_CONFIGURATION_NEEDED); + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.configuration_needed == 1); printf("ConfigurationNeeded TCB Level determination test passed.\n"); // Set platform pce svn to 3 and assert that // the determined status is out of date. - platform_tcb_level.status = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; platform_tcb_level.pce_svn = 3; TestVerifyTCBInfo( - enclave, test_filename, &platform_tcb_level, OE_TCB_LEVEL_INVALID); - OE_TEST(platform_tcb_level.status == OE_TCB_LEVEL_STATUS_OUT_OF_DATE); + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.outofdate == 1); printf("OutOfDate TCB Level determination test passed.\n"); // Set platform pce svn to 2 and assert that // the determined status is revoked. - platform_tcb_level.status = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; platform_tcb_level.pce_svn = 2; TestVerifyTCBInfo( - enclave, test_filename, &platform_tcb_level, OE_TCB_LEVEL_INVALID); - OE_TEST(platform_tcb_level.status == OE_TCB_LEVEL_STATUS_REVOKED); - printf("OutOfDate TCB Level determination test passed.\n"); + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.revoked == 1); + printf("Revoked TCB Level determination test passed.\n"); // Set each of the fields to a value not listed in the json and // test that the determined status is OE_TCB_LEVEL_INVALID for (uint32_t i = 0; i < OE_COUNTOF(platform_tcb_level.sgx_tcb_comp_svn); ++i) { - platform_tcb_level.status = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; platform_tcb_level.sgx_tcb_comp_svn[i] = 0; TestVerifyTCBInfo( - enclave, test_filename, &platform_tcb_level, OE_TCB_LEVEL_INVALID); - OE_TEST(platform_tcb_level.status == OE_TCB_LEVEL_STATUS_UNKNOWN); + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST( + platform_tcb_level.status.AsUINT32 == OE_TCB_LEVEL_STATUS_UNKNOWN); platform_tcb_level.sgx_tcb_comp_svn[i] = 1; } printf("Unknown TCB Level determination test passed.\n"); @@ -212,7 +247,7 @@ void TestVerifyTCBInfo(oe_enclave_t* enclave, const char* test_filename) OE_TEST(FileToBytes(negative_files[i], &tcbInfo) == 0); oe_parsed_tcb_info_t parsed_info = {0}; - oe_tcb_level_t platform_tcb_level = {{0}}; + oe_tcb_info_tcb_level_t platform_tcb_level = {{0}}; oe_result_t ecall_result = OE_FAILURE; OE_TEST( test_verify_tcb_info( @@ -226,3 +261,245 @@ void TestVerifyTCBInfo(oe_enclave_t* enclave, const char* test_filename) "TestVerifyTCBInfo: Negative Test %s passed\n", negative_files[i]); } } + +void TestVerifyTCBInfoV2(oe_enclave_t* enclave, const char* test_filename) +{ + const uint32_t version = 2; + oe_tcb_info_tcb_level_t platform_tcb_level = { + {4, 4, 2, 4, 1, 128, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 8}; + oe_parsed_tcb_info_t parsed_info = {0}; + + printf("TCB Info Version 2 tests:\n"); + // ./data_v2/tcbInfo.json contains 5 tcb levels. + // The first level with pce svn = 6 is up to date. + // The second level with pce svn = 5 is OutOfDateConfigurationNeeded + // The third level with pce svn = 4 needs configuration. + // The fourth level with pce svn = 3 is out of date. + // The fifth level with pce svn = 2 is revoked. + + // Set platform pce svn to 8 and assert that + // the determined status is up to date. + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.pce_svn = 8; + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_OK, + version); + OE_TEST(platform_tcb_level.status.fields.up_to_date == 1); + printf("UptoDate TCB Level determination test passed.\n"); + + // Set platform pce svn to 5 and assert that + // the determined status is out of date configuration needed. + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.pce_svn = 5; + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.qe_identity_out_of_date == 1); + OE_TEST(platform_tcb_level.status.fields.configuration_needed == 1); + printf( + "OutOfDateConfigurationNeeded TCB Level determination test passed.\n"); + + // Set platform pce svn to 4 and assert that + // the determined status is configuration needed. + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.pce_svn = 4; + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.configuration_needed == 1); + printf("ConfigurationNeeded TCB Level determination test passed.\n"); + + // Set platform pce svn to 3 and assert that + // the determined status is out of date. + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.pce_svn = 3; + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.outofdate == 1); + printf("OutOfDate TCB Level determination test passed.\n"); + + // Set platform pce svn to 2 and assert that + // the determined status is revoked. + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.pce_svn = 2; + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST(platform_tcb_level.status.fields.revoked == 1); + printf("Revoked TCB Level determination test passed.\n"); + + // Set each of the fields to a value not listed in the json and + // test that the determined status is OE_TCB_LEVEL_INVALID + for (uint32_t i = 0; i < OE_COUNTOF(platform_tcb_level.sgx_tcb_comp_svn); + ++i) + { + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.sgx_tcb_comp_svn[i] = 0; + TestVerifyTCBInfo( + enclave, + test_filename, + &platform_tcb_level, + &parsed_info, + OE_TCB_LEVEL_INVALID, + version); + OE_TEST( + platform_tcb_level.status.AsUINT32 == OE_TCB_LEVEL_STATUS_UNKNOWN); + platform_tcb_level.sgx_tcb_comp_svn[i] = 2; + } + printf("Unknown TCB Level determination test passed.\n"); + + printf("TestVerifyTCBInfo V2: Positive Tests passed\n"); + + const char* negative_files[] = { + // In the following files, a property in corresponding level has been + // capitalized. JSON is case sensitive and therefore schema validation + // should fail. + "./data_v2/tcbInfoNegativePropertyMissingLevel0.json", + "./data_v2/tcbInfoNegativePropertyMissingLevel1.json", + "./data_v2/tcbInfoNegativePropertyMissingLevel2.json", + "./data_v2/tcbInfoNegativePropertyMissingLevel3.json", + // In the following files, a property in corresponding level has wrong + // type. + "./data_v2/tcbInfoNegativePropertyWrongTypeLevel0.json", + "./data_v2/tcbInfoNegativePropertyWrongTypeLevel1.json", + "./data_v2/tcbInfoNegativePropertyWrongTypeLevel2.json", + "./data_v2/tcbInfoNegativePropertyWrongTypeLevel3.json", + + // Comp Svn greater than uint8_t + "./data_v2/tcbInfoNegativeCompSvn.json", + + // pce Svn greater than uint16_t + "./data_v2/tcbInfoNegativePceSvn.json", + + // Invalid issueDate field. + "./data_v2/tcbInfoNegativeInvalidIssueDate.json", + + // Invalid nextUpdate field. + "./data_v2/tcbInfoNegativeInvalidNextUpdate.json", + + // Missing nextUpdate field. + "./data_v2/tcbInfoNegativeMissingNextUpdate.json", + + // Signature != 64 bytes + "./data_v2/tcbInfoNegativeSignature.json", + + // Unsupported JSON constructs + "./data_v2/tcbInfoNegativeStringEscape.json", + "./data_v2/tcbInfoNegativeIntegerOverflow.json", + "./data_v2/tcbInfoNegativeIntegerWithSign.json", + "./data_v2/tcbInfoNegativeFloat.json", + }; + + for (size_t i = 0; i < sizeof(negative_files) / sizeof(negative_files[0]); + ++i) + { + std::vector tcbInfo; + OE_TEST(FileToBytes(negative_files[i], &tcbInfo) == 0); + + oe_parsed_tcb_info_t parsed_info = {0}; + oe_tcb_info_tcb_level_t platform_tcb_level = {{0}}; + oe_result_t ecall_result = OE_FAILURE; + OE_TEST( + test_verify_tcb_info( + enclave, + &ecall_result, + (const char*)&tcbInfo[0], + &platform_tcb_level, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_JSON_INFO_PARSE_ERROR); + printf( + "TestVerifyTCBInfoV2: Negative Test %s passed\n", + negative_files[i]); + } +} + +void TestVerifyTCBInfoV2_AdvisoryIDs( + oe_enclave_t* enclave, + const char* test_filename) +{ + std::vector tcbInfo; + oe_result_t ecall_result = OE_FAILURE; + OE_TEST(FileToBytes(test_filename, &tcbInfo) == 0); + + oe_tcb_info_tcb_level_t platform_tcb_level = { + {4, 4, 2, 4, 1, 128, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 8}; + oe_parsed_tcb_info_t parsed_info = {0}; + + // Set platform pce svn to 8 and assert that + // the determined status is up to date. + platform_tcb_level.status.AsUINT32 = OE_TCB_LEVEL_STATUS_UNKNOWN; + platform_tcb_level.pce_svn = 8; + + // Contains nextUpdate field. + memset(&parsed_info, 0, sizeof(parsed_info)); + + OE_TEST( + test_verify_tcb_info( + enclave, + &ecall_result, + (const char*)&tcbInfo[0], + &platform_tcb_level, + &parsed_info) == OE_OK); + OE_TEST(ecall_result == OE_OK); + OE_TEST(platform_tcb_level.status.fields.up_to_date == 1); + + AssertParsedValues(parsed_info, 2); + oe_datetime_t nextUpdate = {2019, 6, 6, 10, 12, 17}; + OE_TEST(oe_datetime_compare(&parsed_info.next_update, &nextUpdate) == 0); + + OE_TEST(parsed_info.tcb_level.status.fields.up_to_date == 1); + OE_TEST(parsed_info.tcb_level.advisory_ids_size > 0); + OE_TEST(parsed_info.tcb_level.advisory_ids_offset < tcbInfo.size()); + + const char* ptr = + (const char*)&tcbInfo[parsed_info.tcb_level.advisory_ids_offset]; + const uint8_t* advisoryIDs[2] = {0}; + size_t advisoryIDs_length[2] = {0}; + const char* expectedAdvisoryIDs[2] = {"INTEL-SA-00079", "INTEL-SA-00076"}; + size_t num_advisory_ids = 0; + OE_TEST( + oe_parse_advisoryids_json( + (const uint8_t*)ptr, + parsed_info.tcb_level.advisory_ids_size, + (const uint8_t**)&advisoryIDs, + 2, + (size_t*)&advisoryIDs_length, + 2, + &num_advisory_ids) == OE_OK); + OE_TEST(num_advisory_ids == 2); + for (int i = 0; i < 2; i++) + { + printf( + "AdvisoryIDs[%d]: %.*s\n", + i, + (int)advisoryIDs_length[i], + advisoryIDs[i]); + OE_TEST( + strncmp( + (const char*)advisoryIDs[i], + expectedAdvisoryIDs[i], + advisoryIDs_length[i]) == 0); + } + printf("TCB Info V2 positive test, with advisoryIDs. PASSED\n"); +} \ No newline at end of file diff --git a/tests/report/tests.edl b/tests/report/tests.edl index e5e791e117..ae7a206f2a 100644 --- a/tests/report/tests.edl +++ b/tests/report/tests.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { @@ -12,7 +12,7 @@ enclave { // tcb info tests. public oe_result_t test_verify_tcb_info( [in, string] const char* tcb_info, - [user_check] oe_tcb_level_t* platform_tcb_level, + [user_check] oe_tcb_info_tcb_level_t* platform_tcb_level, [out] oe_parsed_tcb_info_t* parsed_tcb_info ); @@ -22,12 +22,12 @@ enclave { [in, out]sgx_target_info_t* target_info); public void enclave_test_remote_report(); public void enclave_test_parse_report_negative(); - public void enclave_test_local_verify_report(); - public void enclave_test_remote_verify_report(); + public void enclave_test_local_verify_report([in] oe_eeid_t* eeid); + public void enclave_test_remote_verify_report([in] oe_eeid_t* eeid); + public void enclave_test_verify_report_with_collaterals(); }; untrusted { - + }; }; - diff --git a/tests/safecrt/CMakeLists.txt b/tests/safecrt/CMakeLists.txt index 59f315da21..1eb4056e2b 100644 --- a/tests/safecrt/CMakeLists.txt +++ b/tests/safecrt/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/safecrt/common/test.cpp b/tests/safecrt/common/test.cpp index 0fabfe348a..e0787f9b39 100644 --- a/tests/safecrt/common/test.cpp +++ b/tests/safecrt/common/test.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(OE_BUILD_ENCLAVE) diff --git a/tests/safecrt/common/test.h b/tests/safecrt/common/test.h index 8de53e091c..d7728e869f 100644 --- a/tests/safecrt/common/test.h +++ b/tests/safecrt/common/test.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. void test_memcpy_s(); diff --git a/tests/safecrt/enc/CMakeLists.txt b/tests/safecrt/enc/CMakeLists.txt index ef43fe70ca..f1ac0db2b8 100644 --- a/tests/safecrt/enc/CMakeLists.txt +++ b/tests/safecrt/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/safecrt/enc/enc.cpp b/tests/safecrt/enc/enc.cpp index 529fcc1dfd..82ad63a7f3 100644 --- a/tests/safecrt/enc/enc.cpp +++ b/tests/safecrt/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/safecrt/host/CMakeLists.txt b/tests/safecrt/host/CMakeLists.txt index 14948dce4f..aa1b5415d0 100644 --- a/tests/safecrt/host/CMakeLists.txt +++ b/tests/safecrt/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/safecrt/host/host.cpp b/tests/safecrt/host/host.cpp index 750c6eb5a0..faa9b1ab99 100644 --- a/tests/safecrt/host/host.cpp +++ b/tests/safecrt/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/safecrt/safecrt.edl b/tests/safecrt/safecrt.edl index 9f28fa8147..5739d304c5 100644 --- a/tests/safecrt/safecrt.edl +++ b/tests/safecrt/safecrt.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/safemath/CMakeLists.txt b/tests/safemath/CMakeLists.txt index fcdfb05d98..fb7a5e8bd7 100644 --- a/tests/safemath/CMakeLists.txt +++ b/tests/safemath/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(safemath main.cpp) diff --git a/tests/safemath/main.cpp b/tests/safemath/main.cpp index 4aff45a619..9c427b74e0 100644 --- a/tests/safemath/main.cpp +++ b/tests/safemath/main.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/sealKey/CMakeLists.txt b/tests/sealKey/CMakeLists.txt index e11633a50a..92125cd033 100644 --- a/tests/sealKey/CMakeLists.txt +++ b/tests/sealKey/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/sealKey/args.h b/tests/sealKey/args.h index e551e47548..9b9e49daf5 100644 --- a/tests/sealKey/args.h +++ b/tests/sealKey/args.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _SEALKEY_ARGS_H diff --git a/tests/sealKey/enc/CMakeLists.txt b/tests/sealKey/enc/CMakeLists.txt index 638b70d32b..82377292f8 100644 --- a/tests/sealKey/enc/CMakeLists.txt +++ b/tests/sealKey/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/sealKey/enc/enc.cpp b/tests/sealKey/enc/enc.cpp index 1a37d30cf9..073dbaf88c 100644 --- a/tests/sealKey/enc/enc.cpp +++ b/tests/sealKey/enc/enc.cpp @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/sealKey/host/CMakeLists.txt b/tests/sealKey/host/CMakeLists.txt index be4c2b67c8..753bc73bf6 100644 --- a/tests/sealKey/host/CMakeLists.txt +++ b/tests/sealKey/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include (oeedl_file) diff --git a/tests/sealKey/host/host.cpp b/tests/sealKey/host/host.cpp index 5cde3b5819..10286da24b 100644 --- a/tests/sealKey/host/host.cpp +++ b/tests/sealKey/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/sealKey/sealKey.edl b/tests/sealKey/sealKey.edl index 48416cad55..64bb22c0d9 100644 --- a/tests/sealKey/sealKey.edl +++ b/tests/sealKey/sealKey.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/stack_smashing_protector/CMakeLists.txt b/tests/stack_smashing_protector/CMakeLists.txt new file mode 100644 index 0000000000..a028f2ed06 --- /dev/null +++ b/tests/stack_smashing_protector/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_subdirectory(host) + +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() + +add_enclave_test(tests/stack_smashing_protector ssp_host ssp_enc) +set_tests_properties(tests/stack_smashing_protector PROPERTIES SKIP_RETURN_CODE 2) diff --git a/tests/stack_smashing_protector/enc/CMakeLists.txt b/tests/stack_smashing_protector/enc/CMakeLists.txt new file mode 100644 index 0000000000..c729cf4ae6 --- /dev/null +++ b/tests/stack_smashing_protector/enc/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command(OUTPUT ssp_t.h ssp_t.c ssp_args.h + DEPENDS ../ssp.edl edger8r + COMMAND edger8r --trusted ${CMAKE_CURRENT_SOURCE_DIR}/../ssp.edl) + +add_enclave(TARGET ssp_enc SOURCES enc.cpp ${CMAKE_CURRENT_BINARY_DIR}/ssp_t.c) + +# The flag -fstack-protector-all can make sure stack protector is turned on. +set_source_files_properties(enc.cpp PROPERTIES COMPILE_FLAGS -fstack-protector-all) + +# Need for the generated file ssp_t.h +target_include_directories(ssp_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(ssp_enc oelibcxx) diff --git a/tests/stack_smashing_protector/enc/enc.cpp b/tests/stack_smashing_protector/enc/enc.cpp new file mode 100644 index 0000000000..288b4a2a5d --- /dev/null +++ b/tests/stack_smashing_protector/enc/enc.cpp @@ -0,0 +1,89 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ssp_t.h" + +static oe_once_t g_once = OE_ONCE_INIT; +static oe_thread_key_t g_key = OE_THREADKEY_INITIALIZER; + +static bool g_destructor_called = false; + +static void _destructor(void* data) +{ + char* str = (char*)data; + + if (oe_strcmp(str, "TSD-DATA") == 0) + { + oe_host_free(str); + g_destructor_called = true; + OE_TEST(oe_thread_setspecific(g_key, NULL) == 0); + } +} + +static void _init() +{ + if (oe_thread_key_create(&g_key, _destructor) != 0) + { + oe_abort(); + } +} +int enc_set_thread_variable(void* value) +{ + int rval = 0; + /* Initialize this the first time */ + if (oe_once(&g_once, _init) != 0 || + oe_thread_setspecific(g_key, value) != 0) + { + rval = -1; + } + return rval; +} + +void* enc_get_thread_specific_data() +{ + return oe_thread_getspecific(g_key); +} + +bool was_destructor_called() +{ + return g_destructor_called; +} + +void* ssp_test_sub() +{ + /* The test should change the canary in the current stack. + * But in Debug mode the canary is at $rbp-0x8, and in Release mode + * the canary is at $rsp+0x20. To avoid unseen cases, here the %%fs:0x28 is + * modified. + */ + uint64_t canary; + asm("mov %%fs:0x28, %0" : "=r"(canary)); + canary /= 2; + asm("mov %0, %%fs:0x28" : : "r"(canary)); + + return 0; +} + +void* ssp_test() +{ + ssp_test_sub(); + return (void*)0; +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 1024, /* HeapPageCount */ + 128, /* StackPageCount */ + 16); /* TCSCount */ diff --git a/tests/stack_smashing_protector/host/CMakeLists.txt b/tests/stack_smashing_protector/host/CMakeLists.txt new file mode 100644 index 0000000000..d683ff8236 --- /dev/null +++ b/tests/stack_smashing_protector/host/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command(OUTPUT ssp_u.h ssp_u.c ssp_args.h + DEPENDS ../ssp.edl edger8r + COMMAND edger8r --untrusted ${CMAKE_CURRENT_SOURCE_DIR}/../ssp.edl) + +add_executable(ssp_host host.cpp ${CMAKE_CURRENT_BINARY_DIR}/ssp_u.c) + +target_include_directories(ssp_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(ssp_host oehost) diff --git a/tests/stack_smashing_protector/host/host.cpp b/tests/stack_smashing_protector/host/host.cpp new file mode 100644 index 0000000000..50e9f8b284 --- /dev/null +++ b/tests/stack_smashing_protector/host/host.cpp @@ -0,0 +1,69 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include "ssp_u.h" + +#define SKIP_RETURN_CODE 2 + +int main(int argc, const char* argv[]) +{ + if (argc != 2) + { + fprintf(stderr, "Usage: %s ENCLAVE\n", argv[0]); + exit(1); + } + + const uint32_t flags = oe_get_create_flags(); + oe_enclave_t* enclave = NULL; + oe_result_t result = oe_create_ssp_enclave( + argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave); + if (OE_OK != result) + { + oe_put_err("oe_create_ocall_enclave(): result=%u", result); + } + + /* Call enc_set_thread_variable */ + { + int ret_val = -1; + result = enc_set_thread_variable(enclave, &ret_val, strdup("TSD-DATA")); + OE_TEST(OE_OK == result); + OE_TEST(0 == ret_val); + } + + /* Call was_destructor_called */ + { + bool ret_destroyed = false; + result = was_destructor_called(enclave, &ret_destroyed); + OE_TEST(OE_OK == result); + OE_TEST(ret_destroyed); + } + + /* Call enc_get_thread_specific_data */ + { + void* ret_value = NULL; + result = enc_get_thread_specific_data(enclave, &ret_value); + OE_TEST(OE_OK == result); + OE_TEST(NULL == ret_value); + } + + /* Call ssp_test */ + { + void* ret_value = NULL; + result = ssp_test(enclave, &ret_value); + OE_TEST(OE_ENCLAVE_ABORTING == result); + OE_TEST(NULL == ret_value); + } + + oe_terminate_enclave(enclave); + + printf("=== passed all tests (%s)\n", argv[0]); + + return 0; +} diff --git a/tests/stack_smashing_protector/ssp.edl b/tests/stack_smashing_protector/ssp.edl new file mode 100644 index 0000000000..080cd1eb21 --- /dev/null +++ b/tests/stack_smashing_protector/ssp.edl @@ -0,0 +1,14 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + public bool was_destructor_called(); + + public int enc_set_thread_variable([user_check] void* value); + + public void* enc_get_thread_specific_data(); + + public void* ssp_test(); + }; +}; diff --git a/tests/stdc/CMakeLists.txt b/tests/stdc/CMakeLists.txt index 363fc1fecd..322f132fe6 100644 --- a/tests/stdc/CMakeLists.txt +++ b/tests/stdc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/stdc/enc/CMakeLists.txt b/tests/stdc/enc/CMakeLists.txt index 962ddc2b2c..fe8d9ea137 100644 --- a/tests/stdc/enc/CMakeLists.txt +++ b/tests/stdc/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/stdc/enc/enc.cpp b/tests/stdc/enc/enc.cpp index 44a1e7caf7..b4c679556c 100644 --- a/tests/stdc/enc/enc.cpp +++ b/tests/stdc/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/stdc/host/CMakeLists.txt b/tests/stdc/host/CMakeLists.txt index 9156fa0819..3cadcb7d37 100644 --- a/tests/stdc/host/CMakeLists.txt +++ b/tests/stdc/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/stdc/host/host.cpp b/tests/stdc/host/host.cpp index 7613c5a50d..836f67fb0a 100644 --- a/tests/stdc/host/host.cpp +++ b/tests/stdc/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/stdc/stdc.edl b/tests/stdc/stdc.edl index 3d3d0ae7f1..0964ee54c6 100644 --- a/tests/stdc/stdc.edl +++ b/tests/stdc/stdc.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/stdcxx/CMakeLists.txt b/tests/stdcxx/CMakeLists.txt index aa884cbe77..167cd374fa 100644 --- a/tests/stdcxx/CMakeLists.txt +++ b/tests/stdcxx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) @@ -8,4 +8,9 @@ if (BUILD_ENCLAVES) endif() add_enclave_test(tests/stdcxx stdcxx_host stdcxx_enc OE_OK) + +# Some expection test will fail in simulation mode, due to the failure of +# isolation of exception in enclave then host process will be terminated. + add_enclave_test(tests/global_init_exception stdcxx_host global_init_exception_enc OE_ENCLAVE_ABORTING) +set_tests_properties(tests/global_init_exception PROPERTIES SKIP_RETURN_CODE 2) diff --git a/tests/stdcxx/enc/CMakeLists.txt b/tests/stdcxx/enc/CMakeLists.txt index 70aaab3bd5..a3e9b5bc8f 100644 --- a/tests/stdcxx/enc/CMakeLists.txt +++ b/tests/stdcxx/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../stdcxx.edl enclave gen) diff --git a/tests/stdcxx/enc/enc.cpp b/tests/stdcxx/enc/enc.cpp index 5ed1e9f9e4..86fe9fd9dc 100644 --- a/tests/stdcxx/enc/enc.cpp +++ b/tests/stdcxx/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -204,7 +204,7 @@ int enc_test(bool* caught, bool* dynamic_cast_works, size_t* n_constructions) int* p = new int[64]; ptrs.push_back(p); } - catch (std::bad_alloc) + catch (std::bad_alloc&) { bad_alloc_caught = true; printf("std::bad_alloc caught\n"); diff --git a/tests/stdcxx/enc/f.cpp b/tests/stdcxx/enc/f.cpp index b13bb401f9..b4c77e9ecc 100644 --- a/tests/stdcxx/enc/f.cpp +++ b/tests/stdcxx/enc/f.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/stdcxx/enc/global_init_exception.cpp b/tests/stdcxx/enc/global_init_exception.cpp index 761510cee3..9416a4d885 100644 --- a/tests/stdcxx/enc/global_init_exception.cpp +++ b/tests/stdcxx/enc/global_init_exception.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/stdcxx/host/CMakeLists.txt b/tests/stdcxx/host/CMakeLists.txt index 96044f92d3..abe53b0d8d 100644 --- a/tests/stdcxx/host/CMakeLists.txt +++ b/tests/stdcxx/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../stdcxx.edl host gen) diff --git a/tests/stdcxx/host/host.cpp b/tests/stdcxx/host/host.cpp index e5b815c375..1ca87e57a7 100644 --- a/tests/stdcxx/host/host.cpp +++ b/tests/stdcxx/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -14,6 +14,8 @@ #define ECHO #endif +#define SKIP_RETURN_CODE 2 + void test_stdcxx(oe_enclave_t* enclave) { int ret = -1; @@ -43,7 +45,18 @@ int main(int argc, const char* argv[]) exit(1); } + /* + Some expection test will fail in simulation mode, due to the failure of + isolation of exception in enclave then host process will be terminated. + */ const uint32_t flags = oe_get_create_flags(); + if ((flags & OE_ENCLAVE_FLAG_SIMULATE) != 0 && + strstr(argv[1], "global_init_exception_enc") != 0) + { + printf("=== Skipped unsupported test in simulation mode " + "(global_init_exception_enc)\n"); + return SKIP_RETURN_CODE; + } result = oe_create_stdcxx_enclave( argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave); diff --git a/tests/stdcxx/stdcxx.edl b/tests/stdcxx/stdcxx.edl index 09c2f10dda..6c0af703d1 100644 --- a/tests/stdcxx/stdcxx.edl +++ b/tests/stdcxx/stdcxx.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/str/CMakeLists.txt b/tests/str/CMakeLists.txt index 91d7c33391..0ebfdd1009 100644 --- a/tests/str/CMakeLists.txt +++ b/tests/str/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(str main.c) diff --git a/tests/str/main.c b/tests/str/main.c index e19835313e..1bf3f88073 100644 --- a/tests/str/main.c +++ b/tests/str/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define MEM_MIN_CAP 1 diff --git a/tests/switchless/CMakeLists.txt b/tests/switchless/CMakeLists.txt index b07a753795..39064ab70b 100644 --- a/tests/switchless/CMakeLists.txt +++ b/tests/switchless/CMakeLists.txt @@ -1,8 +1,6 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. -add_custom_target(switchless_gen DEPENDS switchless_enc_gen switchless_host_gen) - add_subdirectory(host) if (BUILD_ENCLAVES) diff --git a/tests/switchless/enc/CMakeLists.txt b/tests/switchless/enc/CMakeLists.txt index 0e4c7ec0f2..3e259415cb 100644 --- a/tests/switchless/enc/CMakeLists.txt +++ b/tests/switchless/enc/CMakeLists.txt @@ -1,15 +1,9 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. -add_custom_command( - OUTPUT switchless_t.h switchless_t.c switchless_args.h - DEPENDS ../switchless.edl - COMMAND edger8r --experimental --trusted --search-path ${CMAKE_CURRENT_SOURCE_DIR}/.. switchless.edl) +oeedl_file(../switchless.edl enclave gen) -# Dummy target used for generating from EDL on demand. -add_custom_target(switchless_enc_gen DEPENDS switchless_t.h switchless_t.c switchless_args.h) - -add_enclave(TARGET switchless_enc UUID d497e154-9e8e-4029-a53d-c0a36533fb95 SOURCES enc.c switchless_t.c) +add_enclave(TARGET switchless_enc UUID d497e154-9e8e-4029-a53d-c0a36533fb95 SOURCES enc.c ${gen}) target_include_directories(switchless_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(switchless_enc oelibc) diff --git a/tests/switchless/enc/enc.c b/tests/switchless/enc/enc.c index 1829f26c40..544a9c46e1 100644 --- a/tests/switchless/enc/enc.c +++ b/tests/switchless/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -6,56 +6,71 @@ #include #include "switchless_t.h" -char* oe_host_strdup(const char* str) -{ - size_t n = oe_strlen(str); - - char* dup = (char*)oe_host_calloc(1, n + 1); - - if (dup) - memcpy(dup, str, n + 1); +#define STRING_LEN 100 +#define STRING_HELLO "Hello World" +#define HOST_PARAM_STRING "host string parameter" +#define HOST_STACK_STRING "host string on stack" - return dup; -} - -int enc_echo(char* in, char out[100]) +int enc_echo_switchless(const char* in, char out[STRING_LEN], int repeats) { oe_result_t result; - if (oe_strcmp(in, "Hello World") != 0) + if (oe_strcmp(in, STRING_HELLO) != 0) { return -1; } - char* host_allocated_str = oe_host_strdup("oe_host_strdup2"); - if (host_allocated_str == NULL) + char stack_allocated_str[STRING_LEN] = HOST_STACK_STRING; + int return_val; + + for (int i = 0; i < repeats; i++) { - return -1; + result = host_echo_switchless( + &return_val, in, out, HOST_PARAM_STRING, stack_allocated_str); + if (result != OE_OK) + { + return -1; + } + + if (return_val != 0) + { + return -1; + } } - char stack_allocated_str[100] = "oe_host_strdup3"; - int return_val; + oe_host_printf("Hello from switchless Echo function!\n"); - result = host_echo( - &return_val, - in, - out, - "oe_host_strdup1", - host_allocated_str, - stack_allocated_str); - if (result != OE_OK) + return 0; +} + +int enc_echo_regular(const char* in, char out[STRING_LEN], int repeats) +{ + oe_result_t result; + + if (oe_strcmp(in, STRING_HELLO) != 0) { return -1; } - if (return_val != 0) + char stack_allocated_str[STRING_LEN] = HOST_STACK_STRING; + int return_val; + + for (int i = 0; i < repeats; i++) { - return -1; - } + result = host_echo_regular( + &return_val, in, out, HOST_PARAM_STRING, stack_allocated_str); + if (result != OE_OK) + { + return -1; + } - oe_host_printf("Hello from Echo function!\n"); + if (return_val != 0) + { + return -1; + } + } - oe_host_free(host_allocated_str); + oe_host_printf("Hello from regular Echo function!\n"); return 0; } @@ -64,6 +79,6 @@ OE_SET_ENCLAVE_SGX( 1, /* ProductID */ 1, /* SecurityVersion */ true, /* AllowDebug */ - 1024, /* HeapPageCount */ - 1024, /* StackPageCount */ + 64, /* HeapPageCount */ + 64, /* StackPageCount */ 16); /* TCSCount */ diff --git a/tests/switchless/host/CMakeLists.txt b/tests/switchless/host/CMakeLists.txt index 3464b68275..2f318e504d 100644 --- a/tests/switchless/host/CMakeLists.txt +++ b/tests/switchless/host/CMakeLists.txt @@ -1,15 +1,9 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. -add_custom_command( - OUTPUT switchless_u.h switchless_u.c switchless_args.h - DEPENDS ../switchless.edl - COMMAND edger8r --experimental --untrusted --search-path ${CMAKE_CURRENT_SOURCE_DIR}/.. switchless.edl) +oeedl_file(../switchless.edl host gen) -# Dummy target used for generating from EDL on demand. -add_custom_target(switchless_host_gen DEPENDS switchless_u.h switchless_u.c switchless_args.h) - -add_executable(switchless_host host.c switchless_u.c) +add_executable(switchless_host host.c ${gen}) target_include_directories(switchless_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(switchless_host oehostapp) diff --git a/tests/switchless/host/host.c b/tests/switchless/host/host.c index 907c245f1d..1e74cec7b1 100644 --- a/tests/switchless/host/host.c +++ b/tests/switchless/host/host.c @@ -1,47 +1,103 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#include #include #include +#include #include #include -#include #include #include #include +#include +#include "../../../host/hostthread.h" #include "../../../host/strings.h" #include "switchless_u.h" -#define NUM_HOST_THREADS 16 +// Increase this number to have a meaningful performance measurement +#define NUM_OCALLS (100000) -int host_echo(char* in, char* out, char* str1, char* str2, char str3[100]) +#define STRING_LEN 100 + +#if defined(__linux__) + +double get_relative_time_in_microseconds() { - OE_TEST(strcmp(str1, "oe_host_strdup1") == 0); - OE_TEST(strcmp(str2, "oe_host_strdup2") == 0); - OE_TEST(strcmp(str3, "oe_host_strdup3") == 0); + struct timespec current_time; + clock_gettime(CLOCK_REALTIME, ¤t_time); + return (double)current_time.tv_sec * 1000000 + + (double)current_time.tv_nsec / 1000.0; +} + +#elif defined(_WIN32) + +#include + +static double frequency; +double get_relative_time_in_microseconds() +{ + LARGE_INTEGER current_time; + QueryPerformanceCounter(¤t_time); + return current_time.QuadPart / frequency; +} + +#endif + +int host_echo_switchless( + const char* in, + char* out, + const char* str1, + char str2[STRING_LEN]) +{ + OE_TEST(strcmp(str1, "host string parameter") == 0); + OE_TEST(strcmp(str2, "host string on stack") == 0); strcpy(out, in); return 0; } -void* host_thread(void* arg) +int host_echo_regular( + const char* in, + char* out, + const char* str1, + char str2[STRING_LEN]) { - char out[100]; - int return_val; - - oe_enclave_t* enclave = (oe_enclave_t*)arg; - oe_result_t result = enc_echo(enclave, &return_val, "Hello World", out); + OE_TEST(strcmp(str1, "host string parameter") == 0); + OE_TEST(strcmp(str2, "host string on stack") == 0); - if (result != OE_OK) - oe_put_err("oe_call_enclave() failed: result=%u", result); + strcpy(out, in); - if (return_val != 0) - oe_put_err("ECALL failed args.result=%d", return_val); + return 0; +} - if (strcmp("Hello World", out) != 0) - oe_put_err("ecall failed: %s != %s\n", "Hello World", out); +double make_repeated_switchless_ocalls(oe_enclave_t* enclave) +{ + char out[STRING_LEN]; + int return_val; + double start, end; + + double switchless_microseconds = 0.0; + + start = get_relative_time_in_microseconds(); + OE_TEST( + enc_echo_switchless( + enclave, &return_val, "Hello World", out, NUM_OCALLS) == OE_OK); + OE_TEST(return_val == 0); + end = get_relative_time_in_microseconds(); + switchless_microseconds += end - start; + + printf( + "%d switchless calls took %d msecs.\n", + NUM_OCALLS, + (int)(switchless_microseconds / 1000.0)); + return switchless_microseconds; +} +void* launch_enclave_thread(void* e) +{ + make_repeated_switchless_ocalls((oe_enclave_t*)e); return NULL; } @@ -50,38 +106,96 @@ int main(int argc, const char* argv[]) oe_enclave_t* enclave = NULL; oe_result_t result; - if (argc != 2) + if (argc < 2) { - fprintf(stderr, "Usage: %s ENCLAVE_PATH\n", argv[0]); + fprintf( + stderr, + "Usage: %s ENCLAVE_PATH [num-host-threads] [num-enclave-threads]\n", + argv[0]); return 1; } + uint64_t num_host_threads = 1; + uint64_t num_enclave_threads = 2; + + if (argc >= 3) + { + sscanf(argv[2], "%" SCNu64, &num_host_threads); + } + + if (argc == 4) + { + sscanf(argv[3], "%" SCNu64, &num_enclave_threads); + } + +#if defined(__WIN32) + QueryPerformanceFrequency(&frequency); + frequency /= 1000000; // convert to microseconds +#endif + const uint32_t flags = oe_get_create_flags(); + // Enable switchless and configure host worker number + oe_enclave_setting_context_switchless_t switchless_setting = { + num_host_threads, 0}; + oe_enclave_setting_t settings[] = { + {.setting_type = OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS, + .u.context_switchless_setting = &switchless_setting}}; + if ((result = oe_create_switchless_enclave( - argv[1], OE_ENCLAVE_TYPE_SGX, flags, NULL, 0, &enclave)) != OE_OK) + argv[1], + OE_ENCLAVE_TYPE_SGX, + flags, + settings, + OE_COUNTOF(settings), + &enclave)) != OE_OK) oe_put_err("oe_create_enclave(): result=%u", result); - pthread_t threads[NUM_HOST_THREADS]; - for (int i = 0; i < NUM_HOST_THREADS; i++) + char out[STRING_LEN]; + int return_val; + + uint64_t num_extra_enc_threads = num_enclave_threads - 1; + oe_thread_t tid[32] = {0}; + for (uint64_t i = 0; i < num_extra_enc_threads; ++i) { int ret = 0; - if ((ret = pthread_create(&threads[i], 0, host_thread, enclave))) + if ((ret = oe_thread_create(&tid[i], launch_enclave_thread, enclave))) { - oe_put_err("pthread_create(host): ret=%u", ret); + oe_put_err("thread_create(host): ret=%u", ret); } - else - printf("created thread %u\n", i); + printf("Launched enclave producer thread %" PRIu64 "\n", i); } + printf("Using main enclave thread\n"); + double switchless_microseconds = make_repeated_switchless_ocalls(enclave); + + printf("Making regular ocalls\n"); + double regular_microseconds = 0; + double start, end; + start = get_relative_time_in_microseconds(); + + OE_TEST( + enc_echo_regular( + enclave, &return_val, "Hello World", out, NUM_OCALLS) == OE_OK); + + end = get_relative_time_in_microseconds(); + regular_microseconds = end - start; - for (int i = 0; i < NUM_HOST_THREADS; i++) + for (uint64_t i = 0; i < num_extra_enc_threads; ++i) { - pthread_join(threads[i], NULL); + if (tid[i]) + oe_thread_join(tid[i]); } result = oe_terminate_enclave(enclave); OE_TEST(result == OE_OK); + printf( + "Time spent in repeating OCALL %d times: switchless %d vs " + "regular %d ms, speed up: %.2f\n", + NUM_OCALLS, + (int)switchless_microseconds / 1000, + (int)regular_microseconds / 1000, + (double)regular_microseconds / switchless_microseconds); printf("=== passed all tests (switchless)\n"); return 0; diff --git a/tests/switchless/switchless.edl b/tests/switchless/switchless.edl index 6cc0cf7dd9..04da614f6e 100644 --- a/tests/switchless/switchless.edl +++ b/tests/switchless/switchless.edl @@ -1,20 +1,30 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { trusted { - public int enc_echo( - [string, in] char* in, - [out] char out[100]); + public int enc_echo_switchless( + [string, in] const char* in, + [out] char out[100], + int repeats); + public int enc_echo_regular( + [string, in] const char* in, + [out] char out[100], + int repeats); }; untrusted { - int host_echo( - [string, in] char* in, + int host_echo_switchless( + [string, in] const char* in, [out] char out[100], - [string, in] char* str1, - [user_check] char* str2, - [in] char str3[100]) + [string, in] const char* str1, + [in] char str2[100]) transition_using_threads; + + int host_echo_regular( + [string, in] const char* in, + [out] char out[100], + [string, in] const char* str1, + [in] char str2[100]); }; }; diff --git a/tests/switchless_threads/CMakeLists.txt b/tests/switchless_threads/CMakeLists.txt new file mode 100644 index 0000000000..729dd9b04b --- /dev/null +++ b/tests/switchless_threads/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_subdirectory(host) + +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() + +add_enclave_test(tests/switchless_threads switchless_threads_host switchless_threads_enc) diff --git a/tests/switchless_threads/enc/CMakeLists.txt b/tests/switchless_threads/enc/CMakeLists.txt new file mode 100644 index 0000000000..55ebe7a4b8 --- /dev/null +++ b/tests/switchless_threads/enc/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +oeedl_file(../switchless_threads.edl enclave gen) + +add_enclave(TARGET switchless_threads_enc UUID 6e818629-0ce7-46cd-822a-6c7e081fc68b SOURCES enc.c ${gen}) + +target_include_directories(switchless_threads_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(switchless_threads_enc oelibc) diff --git a/tests/switchless_threads/enc/enc.c b/tests/switchless_threads/enc/enc.c new file mode 100644 index 0000000000..fbf6e321d4 --- /dev/null +++ b/tests/switchless_threads/enc/enc.c @@ -0,0 +1,75 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include "switchless_threads_t.h" + +#define STRING_LEN 100 +#define STRING_HELLO "Hello World" +#define HOST_PARAM_STRING "host string parameter" +#define HOST_STACK_STRING "host string on stack" + +int enc_echo_single(char* in, char out[100]) +{ + oe_result_t result; + + if (oe_strcmp(in, STRING_HELLO) != 0) + { + return -1; + } + + char stack_allocated_str[STRING_LEN] = HOST_STACK_STRING; + int return_val; + + result = host_echo_regular( + &return_val, in, out, HOST_PARAM_STRING, stack_allocated_str); + + if (result != OE_OK || return_val != 0) + return -1; + + result = host_echo_switchless( + &return_val, in, out, HOST_PARAM_STRING, stack_allocated_str); + + if (result != OE_OK || return_val != 0) + return -1; + + return 0; +} + +int enc_echo_multiple(char* in, char out[STRING_LEN], int repeats) +{ + oe_result_t result; + + if (oe_strcmp(in, STRING_HELLO) != 0) + { + return -1; + } + + char stack_allocated_str[STRING_LEN] = HOST_STACK_STRING; + int return_val; + + for (int i = 0; i < repeats; i++) + { + result = host_echo_regular( + &return_val, in, out, HOST_PARAM_STRING, stack_allocated_str); + if (result != OE_OK || return_val != 0) + return -1; + + result = host_echo_switchless( + &return_val, in, out, HOST_PARAM_STRING, stack_allocated_str); + if (result != OE_OK || return_val != 0) + return -1; + } + + return 0; +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 128, /* HeapPageCount */ + 128, /* StackPageCount */ + 8); /* TCSCount */ diff --git a/tests/switchless_threads/host/CMakeLists.txt b/tests/switchless_threads/host/CMakeLists.txt new file mode 100644 index 0000000000..3acdfa75f8 --- /dev/null +++ b/tests/switchless_threads/host/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +oeedl_file(../switchless_threads.edl host gen) + +add_executable(switchless_threads_host host.c ${gen}) + +target_include_directories(switchless_threads_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_link_libraries(switchless_threads_host oehostapp) diff --git a/tests/switchless_threads/host/host.c b/tests/switchless_threads/host/host.c new file mode 100644 index 0000000000..936977079a --- /dev/null +++ b/tests/switchless_threads/host/host.c @@ -0,0 +1,130 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include + +#include +#include +#include +#if _MSC_VER +#include +#endif +#include "../../../host/hostthread.h" +#include "switchless_threads_u.h" + +// For SGX, the enclave supports up to 8 concurrent threads in it. We have +// to reserve one for the main host thread (calling into enc_echo_multiple). +// This leaves us 7 host threads to call into enc_echo_single. +#define NUM_HOST_THREADS 7 +#define STRING_LEN 100 +#define STRING_HELLO "Hello World" +#define HOST_PARAM_STRING "host string parameter" +#define HOST_STACK_STRING "host string on stack" + +int host_echo_switchless(char* in, char* out, char* str1, char str2[STRING_LEN]) +{ + OE_TEST(strcmp(str1, HOST_PARAM_STRING) == 0); + OE_TEST(strcmp(str2, HOST_STACK_STRING) == 0); + + strcpy(out, in); + + return 0; +} + +int host_echo_regular(char* in, char* out, char* str1, char str2[STRING_LEN]) +{ + OE_TEST(strcmp(str1, HOST_PARAM_STRING) == 0); + OE_TEST(strcmp(str2, HOST_STACK_STRING) == 0); + + strcpy(out, in); + + return 0; +} + +void* thread_func(void* arg) +{ + char out[100]; + int return_val; + + oe_enclave_t* enclave = (oe_enclave_t*)arg; + oe_result_t result = + enc_echo_single(enclave, &return_val, "Hello World", out); + + if (result != OE_OK) + oe_put_err("oe_call_enclave() failed: result=%u", result); + + if (return_val != 0) + oe_put_err("ECALL failed args.result=%d", return_val); + + if (strcmp("Hello World", out) != 0) + oe_put_err("ecall failed: %s != %s\n", "Hello World", out); + + return NULL; +} + +int main(int argc, const char* argv[]) +{ + oe_enclave_t* enclave = NULL; + oe_result_t result; + + if (argc != 2) + { + fprintf(stderr, "Usage: %s ENCLAVE_PATH\n", argv[0]); + return 1; + } + + const uint32_t flags = oe_get_create_flags(); + + // Enable switchless and configure host worker number + oe_enclave_setting_context_switchless_t switchless_setting = {2, 0}; + oe_enclave_setting_t settings[] = { + {.setting_type = OE_ENCLAVE_SETTING_CONTEXT_SWITCHLESS, + .u.context_switchless_setting = &switchless_setting}}; + + if ((result = oe_create_switchless_threads_enclave( + argv[1], + OE_ENCLAVE_TYPE_SGX, + flags, + settings, + OE_COUNTOF(settings), + &enclave)) != OE_OK) + oe_put_err("oe_create_enclave(): result=%u", result); + + oe_thread_t threads[NUM_HOST_THREADS]; + + // Start threads that each invokes 'enc_echo_single', an ECALL that makes + // only one regular OCALL and one switchless OCALL. + for (int i = 0; i < NUM_HOST_THREADS; i++) + { + int ret = 0; + if ((ret = oe_thread_create(&threads[i], thread_func, enclave))) + { + oe_put_err("thread_create(host): ret=%u", ret); + } + } + + // Invoke 'enc_echo_multiple` which makes multiple regular OCALLs and + // multiple switchless OCALLs. + char out[STRING_LEN]; + int return_val; + int repeats = 10; + OE_TEST( + enc_echo_multiple(enclave, &return_val, "Hello World", out, repeats) == + OE_OK); + + // Wait for the threads to complete. + for (int i = 0; i < NUM_HOST_THREADS; i++) + { + oe_thread_join(threads[i]); + } + + result = oe_terminate_enclave(enclave); + OE_TEST(result == OE_OK); + + printf("=== passed all tests (switchless_threads)\n"); + + return 0; +} diff --git a/tests/switchless_threads/switchless_threads.edl b/tests/switchless_threads/switchless_threads.edl new file mode 100644 index 0000000000..b9728ee7e2 --- /dev/null +++ b/tests/switchless_threads/switchless_threads.edl @@ -0,0 +1,29 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + public int enc_echo_single( + [string, in] char* in, + [out] char out[100]); + public int enc_echo_multiple( + [string, in] char* in, + [out] char out[100], + int repeats); + }; + + untrusted { + int host_echo_switchless( + [string, in] char* in, + [out] char out[100], + [string, in] char* str1, + [in] char str2[100]) + transition_using_threads; + + int host_echo_regular( + [string, in] char* in, + [out] char out[100], + [string, in] char* str1, + [in] char str2[100]); + }; +}; diff --git a/tests/syscall/CMakeLists.txt b/tests/syscall/CMakeLists.txt index 689c334a53..549f314ac4 100644 --- a/tests/syscall/CMakeLists.txt +++ b/tests/syscall/CMakeLists.txt @@ -1,16 +1,18 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. +add_subdirectory(socket) + if(UNIX) add_subdirectory(cpio) add_subdirectory(datagram) add_subdirectory(dup) +add_subdirectory(epoll) add_subdirectory(fs) add_subdirectory(hostfs) add_subdirectory(ids) add_subdirectory(poller) add_subdirectory(resolver) -add_subdirectory(socket) add_subdirectory(socketpair) add_subdirectory(sendmsg) endif() diff --git a/tests/syscall/cpio/CMakeLists.txt b/tests/syscall/cpio/CMakeLists.txt index ca2656f76a..c560225e2a 100644 --- a/tests/syscall/cpio/CMakeLists.txt +++ b/tests/syscall/cpio/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_library(oecpio STATIC commands.c cpio.c strarr.c) diff --git a/tests/syscall/cpio/commands.c b/tests/syscall/cpio/commands.c index a0a62cd291..717bfaa0f6 100644 --- a/tests/syscall/cpio/commands.c +++ b/tests/syscall/cpio/commands.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define _GNU_SOURCE diff --git a/tests/syscall/cpio/commands.h b/tests/syscall/cpio/commands.h index 41dac66997..e67ed94309 100644 --- a/tests/syscall/cpio/commands.h +++ b/tests/syscall/cpio/commands.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_COMMANDS_H diff --git a/tests/syscall/cpio/cpio.c b/tests/syscall/cpio/cpio.c index 1ff1c1c930..b506acf766 100644 --- a/tests/syscall/cpio/cpio.c +++ b/tests/syscall/cpio/cpio.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _GNU_SOURCE diff --git a/tests/syscall/cpio/cpio.h b/tests/syscall/cpio/cpio.h index 360df72824..cc7b025a75 100644 --- a/tests/syscall/cpio/cpio.h +++ b/tests/syscall/cpio/cpio.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_CPIO_H diff --git a/tests/syscall/cpio/strarr.c b/tests/syscall/cpio/strarr.c index 712acf3079..74380ac125 100644 --- a/tests/syscall/cpio/strarr.c +++ b/tests/syscall/cpio/strarr.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "strarr.h" diff --git a/tests/syscall/cpio/strarr.h b/tests/syscall/cpio/strarr.h index 40f11047d6..8ad44c5c04 100644 --- a/tests/syscall/cpio/strarr.h +++ b/tests/syscall/cpio/strarr.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_STRARR_H diff --git a/tests/syscall/cpio/trace.h b/tests/syscall/cpio/trace.h index 2ee41c8fcf..721adc6faa 100644 --- a/tests/syscall/cpio/trace.h +++ b/tests/syscall/cpio/trace.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _CPIO_TRACE_H diff --git a/tests/syscall/cpio/utils.h b/tests/syscall/cpio/utils.h index e4be388d97..e76ea11cf9 100644 --- a/tests/syscall/cpio/utils.h +++ b/tests/syscall/cpio/utils.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_UTILS_H diff --git a/tests/syscall/datagram/CMakeLists.txt b/tests/syscall/datagram/CMakeLists.txt index a02ac478c9..3a50a636e9 100644 --- a/tests/syscall/datagram/CMakeLists.txt +++ b/tests/syscall/datagram/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/datagram/enc/CMakeLists.txt b/tests/syscall/datagram/enc/CMakeLists.txt index f50c583ccf..c5310fd487 100644 --- a/tests/syscall/datagram/enc/CMakeLists.txt +++ b/tests/syscall/datagram/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/datagram/enc/enc.c b/tests/syscall/datagram/enc/enc.c index f5974a18fb..ddca2d35f9 100644 --- a/tests/syscall/datagram/enc/enc.c +++ b/tests/syscall/datagram/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/datagram/host/CMakeLists.txt b/tests/syscall/datagram/host/CMakeLists.txt index dfba754e6d..4a76330d45 100644 --- a/tests/syscall/datagram/host/CMakeLists.txt +++ b/tests/syscall/datagram/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/datagram/host/host.c b/tests/syscall/datagram/host/host.c index 0532309da6..fa5d4a8256 100644 --- a/tests/syscall/datagram/host/host.c +++ b/tests/syscall/datagram/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/datagram/test_datagram.edl b/tests/syscall/datagram/test_datagram.edl index 7032305b0b..60a4976ceb 100644 --- a/tests/syscall/datagram/test_datagram.edl +++ b/tests/syscall/datagram/test_datagram.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/dup/CMakeLists.txt b/tests/syscall/dup/CMakeLists.txt index 5e76faff19..0bab7ce8b0 100644 --- a/tests/syscall/dup/CMakeLists.txt +++ b/tests/syscall/dup/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/dup/enc/CMakeLists.txt b/tests/syscall/dup/enc/CMakeLists.txt index 1fddfc974c..1ff6b8a27f 100644 --- a/tests/syscall/dup/enc/CMakeLists.txt +++ b/tests/syscall/dup/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/dup/enc/enc.c b/tests/syscall/dup/enc/enc.c index 0084de161c..3fc5cc1f08 100644 --- a/tests/syscall/dup/enc/enc.c +++ b/tests/syscall/dup/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/dup/enc/main.c b/tests/syscall/dup/enc/main.c index af4bcfcbc2..482176795b 100644 --- a/tests/syscall/dup/enc/main.c +++ b/tests/syscall/dup/enc/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/dup/host/CMakeLists.txt b/tests/syscall/dup/host/CMakeLists.txt index dd7b2cdd05..f1d993e609 100644 --- a/tests/syscall/dup/host/CMakeLists.txt +++ b/tests/syscall/dup/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/dup/host/host.c b/tests/syscall/dup/host/host.c index 0bad1ec1e5..c129da743e 100644 --- a/tests/syscall/dup/host/host.c +++ b/tests/syscall/dup/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/dup/test_dup.edl b/tests/syscall/dup/test_dup.edl index fa4a26a887..3dbe15d494 100644 --- a/tests/syscall/dup/test_dup.edl +++ b/tests/syscall/dup/test_dup.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/epoll/CMakeLists.txt b/tests/syscall/epoll/CMakeLists.txt new file mode 100644 index 0000000000..7b70890be8 --- /dev/null +++ b/tests/syscall/epoll/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_subdirectory(host) + +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() + +add_enclave_test(tests/epoll epoll_host epoll_enc) diff --git a/tests/syscall/epoll/README.md b/tests/syscall/epoll/README.md new file mode 100644 index 0000000000..e2e14bcf3b --- /dev/null +++ b/tests/syscall/epoll/README.md @@ -0,0 +1,5 @@ +epoll test: +=========== + +This test uses epoll concurrently. One thread waits on an epoll instance while +another thread adds and deletes file descriptors. diff --git a/tests/syscall/epoll/enc/CMakeLists.txt b/tests/syscall/epoll/enc/CMakeLists.txt new file mode 100644 index 0000000000..0f64dc72ee --- /dev/null +++ b/tests/syscall/epoll/enc/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +oeedl_file(../epoll.edl enclave gen) + +add_executable(epoll_enc enc.cpp ${gen}) + +maybe_build_using_clangw(epoll_enc) + +target_link_libraries(epoll_enc oelibcxx oeenclave oehostepoll oehostsock) diff --git a/tests/syscall/epoll/enc/enc.cpp b/tests/syscall/epoll/enc/enc.cpp new file mode 100644 index 0000000000..9dac612bda --- /dev/null +++ b/tests/syscall/epoll/enc/enc.cpp @@ -0,0 +1,123 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include + +enum class action_t : uint8_t +{ + stop, + run +}; + +static const uint16_t _port = 12347; +static sockaddr_in _addr; +static int _epfd; +static int _sockfd; + +extern "C" void set_up() +{ + OE_TEST(oe_load_module_host_socket_interface() == OE_OK); + OE_TEST(oe_load_module_host_epoll() == OE_OK); + + _addr.sin_family = AF_INET; + _addr.sin_port = htons(_port); + _addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + // create and bind UDP socket + _sockfd = socket(AF_INET, SOCK_DGRAM, 0); + OE_TEST(_sockfd >= 0); + OE_TEST( + bind(_sockfd, reinterpret_cast(&_addr), sizeof(_addr)) == 0); + + // create epoll instance + _epfd = epoll_create(1); + OE_TEST(_epfd >= 0); +} + +extern "C" void tear_down() +{ + OE_TEST(close(_epfd) == 0); + OE_TEST(close(_sockfd) == 0); +} + +extern "C" void wait_for_events() +{ + action_t action = action_t::run; + + while (action == action_t::run) + { + epoll_event event{}; + + int n; + do + { + n = epoll_wait(_epfd, &event, 1, -1); + } while (n == -1 && errno == EINTR); + + if (n == 1) + { + OE_TEST(event.data.fd == _sockfd); + OE_TEST(read(_sockfd, &action, sizeof(action)) == sizeof(action)); + } + else + OE_TEST(n == 0); // fd has been deleted + } + + OE_TEST(action == action_t::stop); +} + +static void _send(action_t action) +{ + const int sockfd = socket(AF_INET, SOCK_DGRAM, 0); + OE_TEST(sockfd >= 0); + OE_TEST( + connect(sockfd, reinterpret_cast(&_addr), sizeof(_addr)) == + 0); + OE_TEST(write(sockfd, &action, sizeof(action)) == sizeof(action)); + OE_TEST(close(sockfd) == 0); +} + +extern "C" void trigger_and_add_event() +{ + _send(action_t::run); + + // add fd to the epoll instance + epoll_event event{}; + event.events = EPOLLIN; + event.data.fd = _sockfd; + OE_TEST(epoll_ctl(_epfd, EPOLL_CTL_ADD, _sockfd, &event) == 0); +} + +extern "C" void trigger_and_delete_event() +{ + _send(action_t::run); + + // delete fd from the epoll instance + OE_TEST(epoll_ctl(_epfd, EPOLL_CTL_DEL, _sockfd, nullptr) == 0); +} + +extern "C" void cancel_wait() +{ + // add fd to the epoll instance + epoll_event event{}; + event.events = EPOLLIN; + event.data.fd = _sockfd; + OE_TEST(epoll_ctl(_epfd, EPOLL_CTL_ADD, _sockfd, &event) == 0); + + _send(action_t::stop); +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 1024, /* HeapPageCount */ + 256, /* StackPageCount */ + 9); /* TCSCount */ diff --git a/tests/syscall/epoll/epoll.edl b/tests/syscall/epoll/epoll.edl new file mode 100644 index 0000000000..280eb9d19c --- /dev/null +++ b/tests/syscall/epoll/epoll.edl @@ -0,0 +1,13 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + public void set_up(); + public void tear_down(); + public void wait_for_events(); + public void trigger_and_add_event(); + public void trigger_and_delete_event(); + public void cancel_wait(); + }; +}; diff --git a/tests/syscall/epoll/host/CMakeLists.txt b/tests/syscall/epoll/host/CMakeLists.txt new file mode 100644 index 0000000000..546124f8de --- /dev/null +++ b/tests/syscall/epoll/host/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +oeedl_file(../epoll.edl host gen) + +add_executable(epoll_host host.cpp ${gen}) + +target_include_directories(epoll_host PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(epoll_host oehostapp) diff --git a/tests/syscall/epoll/host/host.cpp b/tests/syscall/epoll/host/host.cpp new file mode 100644 index 0000000000..cb62f0e1b2 --- /dev/null +++ b/tests/syscall/epoll/host/host.cpp @@ -0,0 +1,51 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include "epoll_u.h" + +using namespace std; + +int main(int argc, const char* argv[]) +{ + oe_result_t r; + const uint32_t flags = oe_get_create_flags(); + const oe_enclave_type_t type = OE_ENCLAVE_TYPE_SGX; + + if (argc != 2) + { + fprintf(stderr, "Usage: %s ENCLAVE_PATH\n", argv[0]); + return 1; + } + + oe_enclave_t* enclave; + r = oe_create_epoll_enclave(argv[1], type, flags, NULL, 0, &enclave); + OE_TEST(r == OE_OK); + + set_up(enclave); + + thread wait_thread( + [enclave] { OE_TEST(wait_for_events(enclave) == OE_OK); }); + this_thread::sleep_for(100ms); // give wait_thread time to initialize + + for (int i = 0; i < 100; ++i) + { + OE_TEST(trigger_and_add_event(enclave) == OE_OK); + OE_TEST(trigger_and_delete_event(enclave) == OE_OK); + } + + cancel_wait(enclave); + wait_thread.join(); + tear_down(enclave); + + r = oe_terminate_enclave(enclave); + OE_TEST(r == OE_OK); + + printf("=== passed all tests (epoll)\n"); + fflush(stdout); + + return 0; +} diff --git a/tests/syscall/fs/CMakeLists.txt b/tests/syscall/fs/CMakeLists.txt index a58f5415cc..a6cbd6c31d 100644 --- a/tests/syscall/fs/CMakeLists.txt +++ b/tests/syscall/fs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/fs/enc/CMakeLists.txt b/tests/syscall/fs/enc/CMakeLists.txt index e7d1cb674c..e9fb309ca7 100644 --- a/tests/syscall/fs/enc/CMakeLists.txt +++ b/tests/syscall/fs/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if(UNIX) diff --git a/tests/syscall/fs/enc/enc.cpp b/tests/syscall/fs/enc/enc.cpp index 4f765b7fcd..c1fbc99a28 100644 --- a/tests/syscall/fs/enc/enc.cpp +++ b/tests/syscall/fs/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -326,6 +326,17 @@ static void test_unlink_file(FILE_SYSTEM& fs, const char* tmp_dir) OE_TEST(fs.stat(path, &buf) != 0); } +template +static void test_invalid_path(FILE_SYSTEM& fs) +{ + const char* const path = "doesnotexist"; + printf("--- %s()\n", __FUNCTION__); + OE_TEST(fs.open(path, O_RDONLY, 0) == FILE_SYSTEM::invalid_file_handle); + OE_TEST(fs.opendir(path) == FILE_SYSTEM::invalid_dir_handle); + OE_TEST(fs.rmdir(path) == -1); + OE_TEST(fs.truncate(path, 0) == -1); +} + template void test_all(FILE_SYSTEM& fs, const char* tmp_dir) { @@ -338,6 +349,7 @@ void test_all(FILE_SYSTEM& fs, const char* tmp_dir) test_readdir(fs, tmp_dir); test_truncate_file(fs, tmp_dir); test_unlink_file(fs, tmp_dir); + test_invalid_path(fs); cleanup(fs, tmp_dir); } @@ -616,12 +628,44 @@ void test_fs(const char* src_dir, const char* tmp_dir) test_all(fs, tmp_dir); } + /* Test reading from enclave relative path */ + { + char path[OE_PATH_MAX]; + int fd; + mkpath(path, tmp_dir, "testfile"); + + // Create file in tmp dir + OE_TEST( + oe_mount("/", "/", OE_DEVICE_NAME_HOST_FILE_SYSTEM, 0, NULL) == 0); + const int flags = OE_O_CREAT | OE_O_TRUNC | OE_O_WRONLY; + OE_TEST((fd = oe_open(path, flags, MODE)) != -1); + OE_TEST(close(fd) != -1); + OE_TEST(oe_umount("/") == 0); + + // Open file in tmp dir using a relative path + OE_TEST( + oe_mount( + tmp_dir, tmp_dir, OE_DEVICE_NAME_HOST_FILE_SYSTEM, 0, NULL) == + 0); + OE_TEST(oe_chdir(tmp_dir) == 0); + OE_TEST((fd = oe_open("./testfile", OE_O_RDONLY, MODE)) != -1); + OE_TEST(close(fd) != -1); + OE_TEST(oe_umount(tmp_dir) == 0); + + // Change workdir back for other tests. + OE_TEST( + oe_mount("/", "/", OE_DEVICE_NAME_HOST_FILE_SYSTEM, 0, NULL) == 0); + OE_TEST(oe_chdir("/") == 0); + OE_TEST(oe_umount("/") == 0); + } + /* Test writing to a read-only mounted file system. */ { char path[OE_PATH_MAX]; mkpath(path, tmp_dir, "somefile"); const int flags = OE_O_CREAT | OE_O_TRUNC | OE_O_WRONLY; + // Create file OE_TEST( oe_mount( "/", @@ -629,8 +673,10 @@ void test_fs(const char* src_dir, const char* tmp_dir) OE_DEVICE_NAME_HOST_FILE_SYSTEM, OE_MS_RDONLY, NULL) == 0); + OE_TEST(oe_open(path, flags, MODE) == -1); OE_TEST(oe_errno == EPERM); + OE_TEST(oe_umount("/") == 0); } diff --git a/tests/syscall/fs/enc/file_system.h b/tests/syscall/fs/enc/file_system.h index f192142515..86eae95c81 100644 --- a/tests/syscall/fs/enc/file_system.h +++ b/tests/syscall/fs/enc/file_system.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _file_system_h @@ -30,6 +30,9 @@ class oe_fd_file_system typedef struct oe_stat stat_type; typedef struct oe_dirent dirent_type; + static constexpr file_handle invalid_file_handle = -1; + static constexpr dir_handle invalid_dir_handle = nullptr; + oe_fd_file_system(void) { } @@ -158,6 +161,9 @@ class fd_file_system typedef struct oe_stat stat_type; typedef struct dirent dirent_type; + static constexpr file_handle invalid_file_handle = -1; + static constexpr dir_handle invalid_dir_handle = nullptr; + fd_file_system(void) { } @@ -286,6 +292,9 @@ class stream_file_system typedef struct stat stat_type; typedef struct dirent dirent_type; + static constexpr file_handle invalid_file_handle = nullptr; + static constexpr dir_handle invalid_dir_handle = nullptr; + stream_file_system(void) { } diff --git a/tests/syscall/fs/host/CMakeLists.txt b/tests/syscall/fs/host/CMakeLists.txt index 4af8b1778d..46b9d7448a 100644 --- a/tests/syscall/fs/host/CMakeLists.txt +++ b/tests/syscall/fs/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if(UNIX) diff --git a/tests/syscall/fs/host/host.c b/tests/syscall/fs/host/host.c index 342326b59b..16e4e7451a 100644 --- a/tests/syscall/fs/host/host.c +++ b/tests/syscall/fs/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/fs/linux/fs.edl b/tests/syscall/fs/linux/fs.edl index 02fb3b2fe8..fd80839e27 100644 --- a/tests/syscall/fs/linux/fs.edl +++ b/tests/syscall/fs/linux/fs.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/fs/windows/fs.edl b/tests/syscall/fs/windows/fs.edl index bbd649ae8a..848404c88d 100644 --- a/tests/syscall/fs/windows/fs.edl +++ b/tests/syscall/fs/windows/fs.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/hostfs/CMakeLists.txt b/tests/syscall/hostfs/CMakeLists.txt index 8ca84504f3..5d5a97d683 100644 --- a/tests/syscall/hostfs/CMakeLists.txt +++ b/tests/syscall/hostfs/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/hostfs/enc/CMakeLists.txt b/tests/syscall/hostfs/enc/CMakeLists.txt index 43cf80fde1..b210b33ddd 100644 --- a/tests/syscall/hostfs/enc/CMakeLists.txt +++ b/tests/syscall/hostfs/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/hostfs/enc/enc.c b/tests/syscall/hostfs/enc/enc.c index 5fbd1e5f23..e5005005d7 100644 --- a/tests/syscall/hostfs/enc/enc.c +++ b/tests/syscall/hostfs/enc/enc.c @@ -1,7 +1,8 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include +#include #include #include #include @@ -18,6 +19,19 @@ void test_hostfs(const char* tmp_dir) exit(1); } + /* Mount with a relative source should fail */ + if (mount(".", "/", OE_HOST_FILE_SYSTEM, 0, NULL) == 0) + { + fprintf(stderr, "mount() with relative path should not succeed\n"); + exit(1); + } + else if (oe_errno != OE_EINVAL) + { + fprintf( + stderr, "mount() with relative path should fail with OE_EINVAL\n"); + exit(1); + } + if (mount("/", "/", OE_HOST_FILE_SYSTEM, 0, NULL) != 0) { fprintf(stderr, "mount() failed\n"); diff --git a/tests/syscall/hostfs/enc/main.c b/tests/syscall/hostfs/enc/main.c index af4bcfcbc2..482176795b 100644 --- a/tests/syscall/hostfs/enc/main.c +++ b/tests/syscall/hostfs/enc/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/hostfs/host/CMakeLists.txt b/tests/syscall/hostfs/host/CMakeLists.txt index 65373a538d..d51929ea09 100644 --- a/tests/syscall/hostfs/host/CMakeLists.txt +++ b/tests/syscall/hostfs/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/hostfs/host/host.c b/tests/syscall/hostfs/host/host.c index 8abda18dcd..08bec65ace 100644 --- a/tests/syscall/hostfs/host/host.c +++ b/tests/syscall/hostfs/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/hostfs/test_hostfs.edl b/tests/syscall/hostfs/test_hostfs.edl index 016184078c..ed944ecb12 100644 --- a/tests/syscall/hostfs/test_hostfs.edl +++ b/tests/syscall/hostfs/test_hostfs.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/ids/CMakeLists.txt b/tests/syscall/ids/CMakeLists.txt index f0a4798613..d6f130ffa6 100644 --- a/tests/syscall/ids/CMakeLists.txt +++ b/tests/syscall/ids/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/ids/enc/CMakeLists.txt b/tests/syscall/ids/enc/CMakeLists.txt index 171d74f64b..b78491d5c4 100644 --- a/tests/syscall/ids/enc/CMakeLists.txt +++ b/tests/syscall/ids/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/ids/enc/enc.c b/tests/syscall/ids/enc/enc.c index b89f0b2cb7..95c5670d67 100644 --- a/tests/syscall/ids/enc/enc.c +++ b/tests/syscall/ids/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/ids/enc/main.c b/tests/syscall/ids/enc/main.c index af4bcfcbc2..482176795b 100644 --- a/tests/syscall/ids/enc/main.c +++ b/tests/syscall/ids/enc/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/ids/host/CMakeLists.txt b/tests/syscall/ids/host/CMakeLists.txt index b773b9f117..894c824724 100644 --- a/tests/syscall/ids/host/CMakeLists.txt +++ b/tests/syscall/ids/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/ids/host/host.c b/tests/syscall/ids/host/host.c index 377098d32e..963ef4b1ca 100644 --- a/tests/syscall/ids/host/host.c +++ b/tests/syscall/ids/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/ids/test_ids.edl b/tests/syscall/ids/test_ids.edl index 4fd60f25ff..ff6d20cdd1 100644 --- a/tests/syscall/ids/test_ids.edl +++ b/tests/syscall/ids/test_ids.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/platform/linux.h b/tests/syscall/platform/linux.h index 87853cde87..0537ca5c9f 100644 --- a/tests/syscall/platform/linux.h +++ b/tests/syscall/platform/linux.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _PLATFORM_LINUX_H diff --git a/tests/syscall/platform/windows.h b/tests/syscall/platform/windows.h index d177924cce..163f49c4a1 100644 --- a/tests/syscall/platform/windows.h +++ b/tests/syscall/platform/windows.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _PLATFORM_WINDOWS_H @@ -20,6 +20,7 @@ typedef SOCKET socket_t; typedef int socklen_t; typedef int length_t; typedef void pthread_attr_t; +typedef uint16_t in_port_t; OE_INLINE int sleep(unsigned int seconds) { diff --git a/tests/syscall/poller/CMakeLists.txt b/tests/syscall/poller/CMakeLists.txt index 72404b9411..39222728a5 100644 --- a/tests/syscall/poller/CMakeLists.txt +++ b/tests/syscall/poller/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/poller/client.cpp b/tests/syscall/poller/client.cpp index f8eadc84b8..c09560c7fc 100644 --- a/tests/syscall/poller/client.cpp +++ b/tests/syscall/poller/client.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "client.h" diff --git a/tests/syscall/poller/client.h b/tests/syscall/poller/client.h index f30a7bc12a..0606577411 100644 --- a/tests/syscall/poller/client.h +++ b/tests/syscall/poller/client.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TESTS_LIBCSOCKETS_CLIENT_H diff --git a/tests/syscall/poller/enc/CMakeLists.txt b/tests/syscall/poller/enc/CMakeLists.txt index 248901374f..6d891b622f 100644 --- a/tests/syscall/poller/enc/CMakeLists.txt +++ b/tests/syscall/poller/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../poller.edl enclave gen) diff --git a/tests/syscall/poller/enc/enc.cpp b/tests/syscall/poller/enc/enc.cpp index 5bf214521c..7793fb8013 100644 --- a/tests/syscall/poller/enc/enc.cpp +++ b/tests/syscall/poller/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/poller/host/CMakeLists.txt b/tests/syscall/poller/host/CMakeLists.txt index c4b9da9d25..0788c09df4 100644 --- a/tests/syscall/poller/host/CMakeLists.txt +++ b/tests/syscall/poller/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/poller/host/host.cpp b/tests/syscall/poller/host/host.cpp index 68406584ab..1c4cd08337 100644 --- a/tests/syscall/poller/host/host.cpp +++ b/tests/syscall/poller/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(_WIN32) diff --git a/tests/syscall/poller/poller.cpp b/tests/syscall/poller/poller.cpp index 0bddd189bd..2a8945b327 100644 --- a/tests/syscall/poller/poller.cpp +++ b/tests/syscall/poller/poller.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "poller.h" @@ -377,7 +377,11 @@ int epoll_poller::wait(std::vector& events) events.clear(); - int n = epoll_wait(_epfd, epoll_events, MAX_EPOLL_EVENTS, -1); + int n; + do + { + n = epoll_wait(_epfd, epoll_events, MAX_EPOLL_EVENTS, -1); + } while (n < 0 && errno == EINTR); if (n < 0) return -1; diff --git a/tests/syscall/poller/poller.edl b/tests/syscall/poller/poller.edl index 84086aa65c..217c6c9f01 100644 --- a/tests/syscall/poller/poller.edl +++ b/tests/syscall/poller/poller.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/poller/poller.h b/tests/syscall/poller/poller.h index f6a37d33cb..e86bac34ec 100644 --- a/tests/syscall/poller/poller.h +++ b/tests/syscall/poller/poller.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _POLLER_H diff --git a/tests/syscall/poller/server.cpp b/tests/syscall/poller/server.cpp index 9ce2c60b69..8e656ab3e9 100644 --- a/tests/syscall/poller/server.cpp +++ b/tests/syscall/poller/server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if defined(_MSC_VER) diff --git a/tests/syscall/poller/server.h b/tests/syscall/poller/server.h index 0422414f40..786180db60 100644 --- a/tests/syscall/poller/server.h +++ b/tests/syscall/poller/server.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TESTS_LIBCSOCKETS_SERVER_H diff --git a/tests/syscall/resolver/CMakeLists.txt b/tests/syscall/resolver/CMakeLists.txt index 13710156c9..ea2a06e0b1 100644 --- a/tests/syscall/resolver/CMakeLists.txt +++ b/tests/syscall/resolver/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/resolver/enc/CMakeLists.txt b/tests/syscall/resolver/enc/CMakeLists.txt index 0a296efbf4..706797320f 100644 --- a/tests/syscall/resolver/enc/CMakeLists.txt +++ b/tests/syscall/resolver/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../resolver_test.edl diff --git a/tests/syscall/resolver/enc/enc.c b/tests/syscall/resolver/enc/enc.c index 77a2fb8170..6f9f2eb20a 100644 --- a/tests/syscall/resolver/enc/enc.c +++ b/tests/syscall/resolver/enc/enc.c @@ -1,4 +1,4 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Copyright (c) Open Enclave SDK contributors. */ /* Licensed under the MIT License. */ #include diff --git a/tests/syscall/resolver/host/CMakeLists.txt b/tests/syscall/resolver/host/CMakeLists.txt index ac3214ead0..0f502b3c7b 100644 --- a/tests/syscall/resolver/host/CMakeLists.txt +++ b/tests/syscall/resolver/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) diff --git a/tests/syscall/resolver/host/host.c b/tests/syscall/resolver/host/host.c index d1cb117e0b..3127ad6b97 100644 --- a/tests/syscall/resolver/host/host.c +++ b/tests/syscall/resolver/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #define OE_LIBC_SUPPRESS_DEPRECATIONS diff --git a/tests/syscall/resolver/resolver_test.edl b/tests/syscall/resolver/resolver_test.edl index 6110698c66..647a85346a 100644 --- a/tests/syscall/resolver/resolver_test.edl +++ b/tests/syscall/resolver/resolver_test.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/resolver/utils.h b/tests/syscall/resolver/utils.h index 7b7897c742..c535a1e7b4 100644 --- a/tests/syscall/resolver/utils.h +++ b/tests/syscall/resolver/utils.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _TEST_RESOLVER_UTILS_H diff --git a/tests/syscall/sendmsg/CMakeLists.txt b/tests/syscall/sendmsg/CMakeLists.txt index cbb262c2b0..4ce3eeb020 100644 --- a/tests/syscall/sendmsg/CMakeLists.txt +++ b/tests/syscall/sendmsg/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/sendmsg/client.c b/tests/syscall/sendmsg/client.c index 9c303813ce..07a24fbdaa 100644 --- a/tests/syscall/sendmsg/client.c +++ b/tests/syscall/sendmsg/client.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "client.h" diff --git a/tests/syscall/sendmsg/client.h b/tests/syscall/sendmsg/client.h index f30a7bc12a..0606577411 100644 --- a/tests/syscall/sendmsg/client.h +++ b/tests/syscall/sendmsg/client.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TESTS_LIBCSOCKETS_CLIENT_H diff --git a/tests/syscall/sendmsg/enc/CMakeLists.txt b/tests/syscall/sendmsg/enc/CMakeLists.txt index 231d3a8699..45f827820f 100644 --- a/tests/syscall/sendmsg/enc/CMakeLists.txt +++ b/tests/syscall/sendmsg/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../sendmsg.edl enclave gen) diff --git a/tests/syscall/sendmsg/enc/enc.c b/tests/syscall/sendmsg/enc/enc.c index f294289c5e..cad5937b3c 100644 --- a/tests/syscall/sendmsg/enc/enc.c +++ b/tests/syscall/sendmsg/enc/enc.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/sendmsg/host/CMakeLists.txt b/tests/syscall/sendmsg/host/CMakeLists.txt index 0db12d2586..1efa4131a6 100644 --- a/tests/syscall/sendmsg/host/CMakeLists.txt +++ b/tests/syscall/sendmsg/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/syscall/sendmsg/host/host.c b/tests/syscall/sendmsg/host/host.c index 7abc1cbbc0..67c42440de 100644 --- a/tests/syscall/sendmsg/host/host.c +++ b/tests/syscall/sendmsg/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/sendmsg/main.c b/tests/syscall/sendmsg/main.c index 50006f96dc..97b9cc5fd6 100644 --- a/tests/syscall/sendmsg/main.c +++ b/tests/syscall/sendmsg/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/syscall/sendmsg/sendmsg.edl b/tests/syscall/sendmsg/sendmsg.edl index b8e604ab4d..929c793737 100644 --- a/tests/syscall/sendmsg/sendmsg.edl +++ b/tests/syscall/sendmsg/sendmsg.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/sendmsg/server.c b/tests/syscall/sendmsg/server.c index 8c75956712..1ca057f09a 100644 --- a/tests/syscall/sendmsg/server.c +++ b/tests/syscall/sendmsg/server.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include "server.h" diff --git a/tests/syscall/sendmsg/server.h b/tests/syscall/sendmsg/server.h index c7c0fc9c10..5963f6e98c 100644 --- a/tests/syscall/sendmsg/server.h +++ b/tests/syscall/sendmsg/server.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _OE_TESTS_LIBCSOCKETS_SERVER_H diff --git a/tests/syscall/socket/CMakeLists.txt b/tests/syscall/socket/CMakeLists.txt index c32c0df579..3cdcd6fff7 100644 --- a/tests/syscall/socket/CMakeLists.txt +++ b/tests/syscall/socket/CMakeLists.txt @@ -1,8 +1,10 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) -add_subdirectory(enc) +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() add_enclave_test(tests/sockets socket_host socket_enc) diff --git a/tests/syscall/socket/enc/CMakeLists.txt b/tests/syscall/socket/enc/CMakeLists.txt index 2a54936fd2..5ebcf3c295 100644 --- a/tests/syscall/socket/enc/CMakeLists.txt +++ b/tests/syscall/socket/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../socket_test.edl diff --git a/tests/syscall/socket/enc/enc.c b/tests/syscall/socket/enc/enc.c index 60a9c3ec0e..2329b43a6e 100644 --- a/tests/syscall/socket/enc/enc.c +++ b/tests/syscall/socket/enc/enc.c @@ -1,4 +1,4 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Copyright (c) Open Enclave SDK contributors. */ /* Licensed under the MIT License. */ #include @@ -144,7 +144,16 @@ int ecall_run_server() { oe_sleep_msec(1); printf("enc: accepting\n"); - connfd = oe_accept(listenfd, (struct oe_sockaddr*)NULL, NULL); + + struct oe_sockaddr_in peer_addr = {0}; + oe_socklen_t peer_addr_len = sizeof(peer_addr); + connfd = oe_accept( + listenfd, (struct oe_sockaddr*)&peer_addr, &peer_addr_len); + OE_TEST(peer_addr_len == sizeof(peer_addr)); + OE_TEST(peer_addr.sin_family == OE_AF_INET); + OE_TEST(oe_ntohs(peer_addr.sin_port) >= 1024); + OE_TEST(oe_ntohl(peer_addr.sin_addr.s_addr) == OE_INADDR_LOOPBACK); + if (connfd >= 0) { printf("enc: accepted fd = %d\n", connfd); diff --git a/tests/syscall/socket/host/CMakeLists.txt b/tests/syscall/socket/host/CMakeLists.txt index cc4bccc7b8..b89e5bbb57 100644 --- a/tests/syscall/socket/host/CMakeLists.txt +++ b/tests/syscall/socket/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) diff --git a/tests/syscall/socket/host/host.c b/tests/syscall/socket/host/host.c index 39061dc0a3..1e111dae16 100644 --- a/tests/syscall/socket/host/host.c +++ b/tests/syscall/socket/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // ATTN: #define OE_LIBC_SUPPRESS_DEPRECATIONS @@ -9,6 +9,7 @@ #include "../../platform/linux.h" #endif +#include #include #include #include @@ -16,6 +17,10 @@ #define SERVER_PORT "12345" +#if _WIN32 +#define errno WSAGetLastError() +#endif + void* enclave_server_thread(void* arg) { oe_enclave_t* enclave = NULL; @@ -87,7 +92,7 @@ char* host_client(in_port_t port) static char recvBuff[1024]; struct sockaddr_in serv_addr = {0}; - memset(recvBuff, '0', sizeof(recvBuff)); + memset(recvBuff, '\0', sizeof(recvBuff)); if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("\n Error : Could not create socket \n"); @@ -113,7 +118,12 @@ char* host_client(in_port_t port) sock_close(sockfd); return NULL; } - else +#if _WIN32 + else if (errno == WSAEISCONN) + { + break; + } +#endif { printf("Connect Failed. errno = %d Retrying \n", errno); sleep_msec(100); @@ -125,7 +135,7 @@ char* host_client(in_port_t port) if ((n = sock_recv(sockfd, recvBuff, sizeof(recvBuff), 0)) > 0) { recvBuff[n] = '\0'; - printf("host finished reading: %ld bytes...\n", n); + printf("host finished reading: %" PRIu64 " bytes...\n", n); break; } else diff --git a/tests/syscall/socket/socket_test.edl b/tests/syscall/socket/socket_test.edl index f7ecf55c23..3d8f364687 100644 --- a/tests/syscall/socket/socket_test.edl +++ b/tests/syscall/socket/socket_test.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/syscall/socketpair/CMakeLists.txt b/tests/syscall/socketpair/CMakeLists.txt index b6d4fc01cf..2531b479dc 100644 --- a/tests/syscall/socketpair/CMakeLists.txt +++ b/tests/syscall/socketpair/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/syscall/socketpair/enc/CMakeLists.txt b/tests/syscall/socketpair/enc/CMakeLists.txt index 769bca67cd..483f9a513b 100644 --- a/tests/syscall/socketpair/enc/CMakeLists.txt +++ b/tests/syscall/socketpair/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../socketpair_test.edl diff --git a/tests/syscall/socketpair/enc/enc.c b/tests/syscall/socketpair/enc/enc.c index 944ff8d714..4ecf42023e 100644 --- a/tests/syscall/socketpair/enc/enc.c +++ b/tests/syscall/socketpair/enc/enc.c @@ -1,4 +1,4 @@ -/* Copyright (c) Microsoft Corporation. All rights reserved. */ +/* Copyright (c) Open Enclave SDK contributors. */ /* Licensed under the MIT License. */ #include diff --git a/tests/syscall/socketpair/host/CMakeLists.txt b/tests/syscall/socketpair/host/CMakeLists.txt index 3e62292ec4..ec924ea6c4 100644 --- a/tests/syscall/socketpair/host/CMakeLists.txt +++ b/tests/syscall/socketpair/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) diff --git a/tests/syscall/socketpair/host/host.c b/tests/syscall/socketpair/host/host.c index 3172f819c2..40553eedcf 100644 --- a/tests/syscall/socketpair/host/host.c +++ b/tests/syscall/socketpair/host/host.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #if !defined(_MSC_VER) diff --git a/tests/syscall/socketpair/socketpair_test.edl b/tests/syscall/socketpair/socketpair_test.edl index 2a044591b5..503ee2781c 100644 --- a/tests/syscall/socketpair/socketpair_test.edl +++ b/tests/syscall/socketpair/socketpair_test.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/thread/CMakeLists.txt b/tests/thread/CMakeLists.txt index 8632ba8548..b8d327b10e 100644 --- a/tests/thread/CMakeLists.txt +++ b/tests/thread/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/thread/enc/CMakeLists.txt b/tests/thread/enc/CMakeLists.txt index 3a554522c5..700e4f2c4d 100644 --- a/tests/thread/enc/CMakeLists.txt +++ b/tests/thread/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/thread/enc/cond_tests.cpp b/tests/thread/enc/cond_tests.cpp index 9aa9aa901a..b4c36808b9 100644 --- a/tests/thread/enc/cond_tests.cpp +++ b/tests/thread/enc/cond_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef _PTHREAD_ENC_ diff --git a/tests/thread/enc/enc.cpp b/tests/thread/enc/enc.cpp index 5c789bb8d8..494a24963f 100644 --- a/tests/thread/enc/enc.cpp +++ b/tests/thread/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef _PTHREAD_ENC_ diff --git a/tests/thread/enc/rwlock_tests.cpp b/tests/thread/enc/rwlock_tests.cpp index 6563f53f98..204b6d05f2 100644 --- a/tests/thread/enc/rwlock_tests.cpp +++ b/tests/thread/enc/rwlock_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifdef _PTHREAD_ENC_ diff --git a/tests/thread/enc/thread.h b/tests/thread/enc/thread.h index d428aae3fb..65afa10d6f 100644 --- a/tests/thread/enc/thread.h +++ b/tests/thread/enc/thread.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // Intentionally using the same guard as the internal thread.h as we diff --git a/tests/thread/host/CMakeLists.txt b/tests/thread/host/CMakeLists.txt index ae11b86ea5..659e6cbeca 100644 --- a/tests/thread/host/CMakeLists.txt +++ b/tests/thread/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../thread.edl host gen) diff --git a/tests/thread/host/host.cpp b/tests/thread/host/host.cpp index f9774582a0..8a15d7c24f 100644 --- a/tests/thread/host/host.cpp +++ b/tests/thread/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread/host/rwlocks_test_host.cpp b/tests/thread/host/rwlocks_test_host.cpp index a8a897792b..e3eb1b153b 100644 --- a/tests/thread/host/rwlocks_test_host.cpp +++ b/tests/thread/host/rwlocks_test_host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread/rwlock_tests.h b/tests/thread/rwlock_tests.h index 2edf378a3a..4be6cee1f2 100644 --- a/tests/thread/rwlock_tests.h +++ b/tests/thread/rwlock_tests.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _rwlock_tests_h diff --git a/tests/thread/thread.edl b/tests/thread/thread.edl index bde8862425..2be205f78e 100644 --- a/tests/thread/thread.edl +++ b/tests/thread/thread.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/thread_local/CMakeLists.txt b/tests/thread_local/CMakeLists.txt index 8761d6ec2d..04f145cfdb 100644 --- a/tests/thread_local/CMakeLists.txt +++ b/tests/thread_local/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/thread_local/enc/CMakeLists.txt b/tests/thread_local/enc/CMakeLists.txt index 962daab116..6ec3bb109f 100644 --- a/tests/thread_local/enc/CMakeLists.txt +++ b/tests/thread_local/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/thread_local/enc/enc.cpp b/tests/thread_local/enc/enc.cpp index ec38602cf0..97f645b5fc 100644 --- a/tests/thread_local/enc/enc.cpp +++ b/tests/thread_local/enc/enc.cpp @@ -1,6 +1,6 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread_local/enc/externs.cpp b/tests/thread_local/enc/externs.cpp index 0e5f08ef45..ba1bb88740 100644 --- a/tests/thread_local/enc/externs.cpp +++ b/tests/thread_local/enc/externs.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread_local/enc/visibility.h b/tests/thread_local/enc/visibility.h index 1a8cc9915e..3501020c24 100644 --- a/tests/thread_local/enc/visibility.h +++ b/tests/thread_local/enc/visibility.h @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #ifndef _VISIBILITY_SPEC_H diff --git a/tests/thread_local/host/CMakeLists.txt b/tests/thread_local/host/CMakeLists.txt index f32dd32824..54d398de1c 100644 --- a/tests/thread_local/host/CMakeLists.txt +++ b/tests/thread_local/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/thread_local/host/host.cpp b/tests/thread_local/host/host.cpp index b4a8f7f7b8..c4bff4bec6 100644 --- a/tests/thread_local/host/host.cpp +++ b/tests/thread_local/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread_local/thread_local.edl b/tests/thread_local/thread_local.edl index c3b3aa17e5..b020dfcc3e 100644 --- a/tests/thread_local/thread_local.edl +++ b/tests/thread_local/thread_local.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/thread_local_no_tdata/CMakeLists.txt b/tests/thread_local_no_tdata/CMakeLists.txt index 2259847018..ee970b321a 100644 --- a/tests/thread_local_no_tdata/CMakeLists.txt +++ b/tests/thread_local_no_tdata/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/thread_local_no_tdata/enc/CMakeLists.txt b/tests/thread_local_no_tdata/enc/CMakeLists.txt index 0d39d67508..d24113006c 100644 --- a/tests/thread_local_no_tdata/enc/CMakeLists.txt +++ b/tests/thread_local_no_tdata/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/thread_local_no_tdata/enc/enc.cpp b/tests/thread_local_no_tdata/enc/enc.cpp index 643bfadd93..6a6af39992 100644 --- a/tests/thread_local_no_tdata/enc/enc.cpp +++ b/tests/thread_local_no_tdata/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread_local_no_tdata/host/#host.cpp# b/tests/thread_local_no_tdata/host/#host.cpp# index f179b99099..060e621a6b 100644 --- a/tests/thread_local_no_tdata/host/#host.cpp# +++ b/tests/thread_local_no_tdata/host/#host.cpp# @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread_local_no_tdata/host/CMakeLists.txt b/tests/thread_local_no_tdata/host/CMakeLists.txt index a14807dcce..89137a3b9f 100644 --- a/tests/thread_local_no_tdata/host/CMakeLists.txt +++ b/tests/thread_local_no_tdata/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. diff --git a/tests/thread_local_no_tdata/host/host.cpp b/tests/thread_local_no_tdata/host/host.cpp index ae9fe24a0c..3c283c4674 100644 --- a/tests/thread_local_no_tdata/host/host.cpp +++ b/tests/thread_local_no_tdata/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/thread_local_no_tdata/no_tdata.edl b/tests/thread_local_no_tdata/no_tdata.edl index 0b7e553271..2b794f40eb 100644 --- a/tests/thread_local_no_tdata/no_tdata.edl +++ b/tests/thread_local_no_tdata/no_tdata.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/thread_locals/CMakeLists.txt b/tests/thread_locals/CMakeLists.txt index 1876b6898f..5cc4ee737d 100644 --- a/tests/thread_locals/CMakeLists.txt +++ b/tests/thread_locals/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(core) diff --git a/tests/threadcxx/CMakeLists.txt b/tests/threadcxx/CMakeLists.txt index 774f5eff87..01de514d96 100644 --- a/tests/threadcxx/CMakeLists.txt +++ b/tests/threadcxx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(host) diff --git a/tests/threadcxx/enc/CMakeLists.txt b/tests/threadcxx/enc/CMakeLists.txt index 23089fb5ca..a2ba07b235 100644 --- a/tests/threadcxx/enc/CMakeLists.txt +++ b/tests/threadcxx/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../threadcxx.edl enclave gen) diff --git a/tests/threadcxx/enc/cond_tests.cpp b/tests/threadcxx/enc/cond_tests.cpp index 94d92dc04d..32f057863d 100644 --- a/tests/threadcxx/enc/cond_tests.cpp +++ b/tests/threadcxx/enc/cond_tests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/threadcxx/enc/enc.cpp b/tests/threadcxx/enc/enc.cpp index a3876ca43a..02ad0ec693 100644 --- a/tests/threadcxx/enc/enc.cpp +++ b/tests/threadcxx/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/threadcxx/host/CMakeLists.txt b/tests/threadcxx/host/CMakeLists.txt index 706eca8675..a54e2c7172 100644 --- a/tests/threadcxx/host/CMakeLists.txt +++ b/tests/threadcxx/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. oeedl_file(../threadcxx.edl host gen) diff --git a/tests/threadcxx/host/host.cpp b/tests/threadcxx/host/host.cpp index 5c0463ad34..0863c18baf 100644 --- a/tests/threadcxx/host/host.cpp +++ b/tests/threadcxx/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/threadcxx/threadcxx.edl b/tests/threadcxx/threadcxx.edl index a1a8b8aa7f..a4ce4e3942 100644 --- a/tests/threadcxx/threadcxx.edl +++ b/tests/threadcxx/threadcxx.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/tls_e2e/CMakeLists.txt b/tests/tls_e2e/CMakeLists.txt index 71d2f7a12d..984a85851d 100644 --- a/tests/tls_e2e/CMakeLists.txt +++ b/tests/tls_e2e/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (BUILD_ENCLAVES) diff --git a/tests/tls_e2e/client_enc/CMakeLists.txt b/tests/tls_e2e/client_enc/CMakeLists.txt index deabcfddad..9d723c9fb7 100644 --- a/tests/tls_e2e/client_enc/CMakeLists.txt +++ b/tests/tls_e2e/client_enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) @@ -7,8 +7,8 @@ oeedl_file(../tls_e2e.edl enclave gen) add_enclave(TARGET tls_client_enc SOURCES client.cpp tls_e2e_t.c ../common/utility.cpp ${gen}) -if(USE_LIBSGX) - target_compile_definitions(tls_client_enc PRIVATE OE_USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(tls_client_enc PRIVATE OE_LINK_SGX_DCAP_QL) endif() set_source_files_properties( diff --git a/tests/tls_e2e/client_enc/client.cpp b/tests/tls_e2e/client_enc/client.cpp index 5cd120194c..3c5b7732a3 100644 --- a/tests/tls_e2e/client_enc/client.cpp +++ b/tests/tls_e2e/client_enc/client.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -195,7 +195,9 @@ int launch_tls_client( oe_module_loaded = true; } +#if !defined(NDEBUG) mbedtls_debug_set_threshold(DEBUG_LEVEL); +#endif // Initialize the RNG and the session data mbedtls_net_init(&server_fd); diff --git a/tests/tls_e2e/common/utility.cpp b/tests/tls_e2e/common/utility.cpp index aa989eabd1..147b07730a 100644 --- a/tests/tls_e2e/common/utility.cpp +++ b/tests/tls_e2e/common/utility.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off diff --git a/tests/tls_e2e/common/utility.h b/tests/tls_e2e/common/utility.h index 8a8b7dc683..c30d7bc623 100644 --- a/tests/tls_e2e/common/utility.h +++ b/tests/tls_e2e/common/utility.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off diff --git a/tests/tls_e2e/host/CMakeLists.txt b/tests/tls_e2e/host/CMakeLists.txt index 434874578b..e83db9a811 100644 --- a/tests/tls_e2e/host/CMakeLists.txt +++ b/tests/tls_e2e/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. #include(oeedl_file) diff --git a/tests/tls_e2e/host/host.cpp b/tests/tls_e2e/host/host.cpp index 3d3849db9e..eebf386460 100644 --- a/tests/tls_e2e/host/host.cpp +++ b/tests/tls_e2e/host/host.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -6,13 +6,17 @@ #include #include #include -#include #include #include #include #include #include "tls_e2e_u.h" +#include +#include +#include +#include + #define SERVER_PORT "12345" #define SERVER_IP "127.0.0.1" @@ -60,20 +64,22 @@ typedef enum test_config_type oe_enclave_t* g_server_enclave = NULL; oe_enclave_t* g_client_enclave = NULL; + int g_server_thread_exit_code = 0; int g_client_thread_exit_code = 0; -pthread_mutex_t server_mutex; -pthread_cond_t server_cond; bool g_server_condition = false; -pthread_t server_thread_id; + +std::mutex g_server_mutex; +std::condition_variable g_server_cond; +std::thread g_server_thread; int server_is_ready() { OE_TRACE_INFO("TLS server_is_ready!\n"); - pthread_mutex_lock(&server_mutex); + g_server_mutex.lock(); g_server_condition = true; - pthread_cond_signal(&server_cond); - pthread_mutex_unlock(&server_mutex); + g_server_cond.notify_all(); + g_server_mutex.unlock(); return 1; } @@ -118,7 +124,7 @@ oe_result_t enclave_identity_verifier(oe_identity_t* identity, void* arg) return result; } -void* server_thread(void* arg) +void run_server(void* arg) { oe_result_t result = OE_FAILURE; tls_thread_context_config_t* config = &(((tls_test_configs_t*)arg)->server); @@ -148,20 +154,19 @@ void* server_thread(void* arg) } OE_TRACE_INFO("Leaving server thread...\n"); - fflush(stdout); - pthread_exit((void*)&g_server_thread_exit_code); + +// Label needed for OE_CHECK* macros done: - return NULL; + fflush(stdout); } -void* client_thread(void* arg) +void run_client(void* arg) { oe_result_t result = OE_FAILURE; tls_thread_context_config_t* client_config = &(((tls_test_configs_t*)arg)->client); tls_thread_context_config_t* server_config = &(((tls_test_configs_t*)arg)->server); - void* retval = NULL; OE_TRACE_INFO("Client thread: call launch_tls_client()\n"); result = launch_tls_client( @@ -186,10 +191,10 @@ void* client_thread(void* arg) OE_TRACE_INFO("Waiting for the server thread to terminate...\n"); // block client thread until the server thread is done - pthread_join(server_thread_id, (void**)&retval); + g_server_thread.join(); // enforce server return value - OE_TRACE_INFO("server returns retval = [%d]\n", *(int*)retval); + OE_TRACE_INFO("server returns retval = [%d]\n", g_server_thread_exit_code); if (server_config->args.fail_cert_verify_callback || server_config->args.fail_enclave_identity_verifier_callback || @@ -197,7 +202,7 @@ void* client_thread(void* arg) { // since this test ignores SIGPIPE, ther client thread will terminiate // with 0 - OE_TEST(*(int*)(retval) == 0); + OE_TEST(g_server_thread_exit_code == 0); } // In the no-fault-injection test case, the client thread should return @@ -216,52 +221,35 @@ void* client_thread(void* arg) // g_client_thread_exit_code could be any values in negative test cases g_client_thread_exit_code = 0; } - pthread_exit((void*)&g_client_thread_exit_code); - fflush(stdout); + +// Label needed for OE_CHECK* macros done: - return NULL; + fflush(stdout); } int run_test_with_config(tls_test_configs_t* test_configs) { - pthread_attr_t server_tattr; - pthread_attr_t client_tattr; - pthread_t client_thread_id; - int ret = 0; - void* retval = NULL; - // create server thread - ret = pthread_attr_init(&server_tattr); - if (ret) - oe_put_err("pthread_attr_init(server): ret=%u", ret); - - ret = pthread_create( - &server_thread_id, NULL, server_thread, (void*)test_configs); - if (ret) - oe_put_err("pthread_create(server): ret=%u", ret); + g_server_thread = std::thread(run_server, (void*)test_configs); OE_TRACE_INFO("wait until TLS server is ready to accept client request\n"); - pthread_mutex_lock(&server_mutex); - while (!g_server_condition) - pthread_cond_wait(&server_cond, &server_mutex); - pthread_mutex_unlock(&server_mutex); + + { + // Release lock on scope exit + std::unique_lock server_lock(g_server_mutex); + g_server_cond.wait(server_lock, [] { return g_server_condition; }); + } fflush(stdout); // create client thread - ret = pthread_attr_init(&client_tattr); - if (ret) - oe_put_err("pthread_attr_init(client): ret=%u", ret); - - ret = pthread_create( - &client_thread_id, NULL, client_thread, (void*)test_configs); - if (ret) - oe_put_err("pthread_create(client): ret=%u", ret); + std::thread client_thread(run_client, (void*)test_configs); + client_thread.join(); + OE_TRACE_INFO( + "Client thread terminated with ret =%d... \n", + g_client_thread_exit_code); - pthread_join(client_thread_id, &retval); - ret = *(int*)retval; - OE_TRACE_INFO("Client thread terminated with ret =%d... \n", ret); - return ret; + return g_client_thread_exit_code; } int run_scenarios_tests() @@ -281,7 +269,9 @@ int run_scenarios_tests() {false, false, true}, NEGATIVE_TEST}}; +#ifndef _WIN32 signal(SIGPIPE, SIG_IGN); +#endif test_configs.server.enclave = g_server_enclave; test_configs.client.enclave = g_client_enclave; @@ -335,7 +325,7 @@ int run_scenarios_tests() int main(int argc, const char* argv[]) { -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL oe_result_t result = OE_FAILURE; uint32_t flags = OE_ENCLAVE_FLAG_DEBUG; int ret = 0; @@ -391,11 +381,12 @@ int main(int argc, const char* argv[]) return 0; #else - // this test should not run on any platforms where OE_USE_LIBSGX is not - // defined + // this test should not run on any platforms where OE_LINK_SGX_DCAP_QL is + // not defined OE_UNUSED(argc); OE_UNUSED(argv); - OE_TRACE_INFO("=== tests skipped when built with OE_USE_LIBSGX=OFF\n"); + OE_TRACE_INFO( + "=== tests skipped when built with OE_LINK_SGX_DCAP_QL=OFF\n"); return SKIP_RETURN_CODE; #endif } diff --git a/tests/tls_e2e/host/tls_enc2enc.edl b/tests/tls_e2e/host/tls_enc2enc.edl index 26e4d9d813..64f9c68b95 100644 --- a/tests/tls_e2e/host/tls_enc2enc.edl +++ b/tests/tls_e2e/host/tls_enc2enc.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/tls_e2e/server_enc/CMakeLists.txt b/tests/tls_e2e/server_enc/CMakeLists.txt index 89baaf8283..3be9f722d1 100644 --- a/tests/tls_e2e/server_enc/CMakeLists.txt +++ b/tests/tls_e2e/server_enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(oeedl_file) @@ -6,8 +6,8 @@ include(oeedl_file) oeedl_file(../tls_e2e.edl enclave gen) add_enclave(TARGET tls_server_enc SOURCES server.cpp tls_e2e_t.c ../common/utility.cpp ${gen}) -if(USE_LIBSGX) - target_compile_definitions(tls_server_enc PRIVATE OE_USE_LIBSGX) +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(tls_server_enc PRIVATE OE_LINK_SGX_DCAP_QL) endif() set_source_files_properties( diff --git a/tests/tls_e2e/server_enc/server.cpp b/tests/tls_e2e/server_enc/server.cpp index 240dd99b0c..a1dc758f6d 100644 --- a/tests/tls_e2e/server_enc/server.cpp +++ b/tests/tls_e2e/server_enc/server.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. // clang-format off @@ -217,7 +217,10 @@ int setup_tls_server(struct tls_control_args* config, char* server_port) mbedtls_entropy_init(&entropy); mbedtls_ctr_drbg_init(&ctr_drbg); +#if !defined(NDEBUG) mbedtls_debug_set_threshold(DEBUG_LEVEL); +#endif + g_control_config = *config; OE_TRACE_INFO( diff --git a/tests/tls_e2e/tls_e2e.edl b/tests/tls_e2e/tls_e2e.edl index 0517695b8c..4c99bd6e4d 100644 --- a/tests/tls_e2e/tls_e2e.edl +++ b/tests/tls_e2e/tls_e2e.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/tools/CMakeLists.txt b/tests/tools/CMakeLists.txt index af3bd6422a..251913c0fb 100644 --- a/tests/tools/CMakeLists.txt +++ b/tests/tools/CMakeLists.txt @@ -1,6 +1,7 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (OE_SGX) add_subdirectory(oecert) + add_subdirectory(oecertdump) endif() diff --git a/tests/tools/oecert/CMakeLists.txt b/tests/tools/oecert/CMakeLists.txt index aba00fe372..7da568ee38 100644 --- a/tests/tools/oecert/CMakeLists.txt +++ b/tests/tools/oecert/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. if (BUILD_ENCLAVES) diff --git a/tests/tools/oecert/enc/CMakeLists.txt b/tests/tools/oecert/enc/CMakeLists.txt index 78936ab659..b78b5a483e 100644 --- a/tests/tools/oecert/enc/CMakeLists.txt +++ b/tests/tools/oecert/enc/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT oecert_t.h oecert_t.c oecert_args.h diff --git a/tests/tools/oecert/enc/enc.cpp b/tests/tools/oecert/enc/enc.cpp index 0edae0c31e..208811a1f8 100644 --- a/tests/tools/oecert/enc/enc.cpp +++ b/tests/tools/oecert/enc/enc.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include diff --git a/tests/tools/oecert/host/CMakeLists.txt b/tests/tools/oecert/host/CMakeLists.txt index 8b708231da..8b56e19549 100644 --- a/tests/tools/oecert/host/CMakeLists.txt +++ b/tests/tools/oecert/host/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_custom_command(OUTPUT oecert_u.h oecert_u.c oecert_args.h diff --git a/tests/tools/oecert/host/host.cpp b/tests/tools/oecert/host/host.cpp index 0dd6424a0b..7cd4ec2124 100644 --- a/tests/tools/oecert/host/host.cpp +++ b/tests/tools/oecert/host/host.cpp @@ -1,15 +1,18 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include #include +#include #include #include #include #include #include "oecert_u.h" -#ifdef OE_USE_LIBSGX +#include "../../../../common/sgx/endorsements.h" + +#ifdef OE_LINK_SGX_DCAP_QL #define INPUT_PARAM_OPTION_CERT "--cert" #define INPUT_PARAM_OPTION_REPORT "--report" @@ -189,6 +192,47 @@ static oe_result_t _gen_report( // TODO: Dump report. } } + + char collateral_filename[1024 + 1]; + + if (strlen(report_filename) < (1024 - 4)) + { + uint8_t* collaterals = NULL; + size_t collaterals_size = 0; + oe_report_header_t* header = (oe_report_header_t*)remote_report; + + sprintf(collateral_filename, "%s.col", report_filename); + printf("Generatting collateral file: %s\n", collateral_filename); + + result = oe_get_sgx_endorsements( + header->report, + header->report_size, + &collaterals, + &collaterals_size); + if (result != OE_OK) + { + printf("Failed to create SGX endorsements."); + result = OE_FAILURE; + goto exit; + } + + FILE* col_fp = fopen(collateral_filename, "wb"); + if (!col_fp) + { + printf( + "Failed to open collateral file %s\n", collateral_filename); + result = OE_FAILURE; + goto exit; + } + fwrite(collaterals, collaterals_size, 1, col_fp); + fclose(col_fp); + printf("collaterals_size = %zu\n", collaterals_size); + } + else + { + printf("ERROR: Report filename is too long.\n"); + exit(1); + } } else { @@ -210,7 +254,8 @@ static void _display_help(const char* cmd) "\t%s PRIVKEY PUBKEY: generate der remote attestation certificate.\n", INPUT_PARAM_OPTION_CERT); printf( - "\t%s : generate binary enclave report.\n", INPUT_PARAM_OPTION_REPORT); + "\t%s : generate binary enclave evidence and endorsements.\n", + INPUT_PARAM_OPTION_REPORT); printf("\t%s : output filename.\n", INPUT_PARAM_OPTION_OUT_FILE); // TODO: Add option to display certs @@ -271,7 +316,6 @@ static int _parse_args(int argc, const char* argv[]) if (argc >= i) { _params.gen_report = true; - i += 1; } else @@ -288,7 +332,6 @@ static int _parse_args(int argc, const char* argv[]) if (argc >= i + 1) { _params.out_filename = argv[i + 1]; - i += 2; } else @@ -402,13 +445,13 @@ static oe_result_t _process_params(oe_enclave_t* enclave) return result; } -#endif // OE_USE_LIBSGX +#endif // OE_LINK_SGX_DCAP_QL int main(int argc, const char* argv[]) { int ret = 0; -#ifdef OE_USE_LIBSGX +#ifdef OE_LINK_SGX_DCAP_QL oe_result_t result; oe_enclave_t* enclave = NULL; @@ -444,8 +487,8 @@ int main(int argc, const char* argv[]) result = oe_terminate_enclave(enclave); exit: #else -#pragma message \ - "OE_USE_LIBSGX is not set to ON. This tool requires SGX libraries." +#pragma message( \ + "OE_LINK_SGX_DCAP_QL is not set to ON. This tool requires DCAP libraries.") OE_UNUSED(argc); OE_UNUSED(argv); #endif diff --git a/tests/tools/oecert/oecert.edl b/tests/tools/oecert/oecert.edl index 8c4e07f531..fe54a474be 100644 --- a/tests/tools/oecert/oecert.edl +++ b/tests/tools/oecert/oecert.edl @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. enclave { diff --git a/tests/tools/oecertdump/CMakeLists.txt b/tests/tools/oecertdump/CMakeLists.txt new file mode 100644 index 0000000000..45fe19551b --- /dev/null +++ b/tests/tools/oecertdump/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +if (BUILD_ENCLAVES) + add_subdirectory(enc) +endif() + +add_subdirectory(host) diff --git a/tests/tools/oecertdump/README.md b/tests/tools/oecertdump/README.md new file mode 100644 index 0000000000..7af6beafaa --- /dev/null +++ b/tests/tools/oecertdump/README.md @@ -0,0 +1,19 @@ +oecertdump +===== + +oecertdump is a utility that generates and validates reports and certificates. +Generation and validation logs are saved to a log file specified by the --out option. +Default log filename is "oecertdump_out.log". + +Usage: oecertdump ENCLAVE_PATH Options + +where Options are: + --out FILENAME : specify output filename. + +Example: host/oecertdump enc/oecertdump_enc --out myoutput.log + +If the validation succeeds, oecertdump returns 0 and prints success message to stdout. For example, + "oecertdump succeeded. Log file oecertdump_out.log created." + +If the validation fails, oecertdump returns non zero and prints failure message to stdout. For example, + "Failed to process parameters." \ No newline at end of file diff --git a/tests/tools/oecertdump/enc/CMakeLists.txt b/tests/tools/oecertdump/enc/CMakeLists.txt new file mode 100644 index 0000000000..2cd6258ca6 --- /dev/null +++ b/tests/tools/oecertdump/enc/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +add_custom_command(OUTPUT oecertdump_t.h oecertdump_t.c oecertdump_args.h + DEPENDS ../oecertdump.edl edger8r + COMMAND edger8r --trusted ${CMAKE_CURRENT_SOURCE_DIR}/../oecertdump.edl) + +add_enclave(TARGET oecertdump_enc SOURCES enc.cpp ${CMAKE_CURRENT_BINARY_DIR}/oecertdump_t.c) + +# Need for the generated file oecertdump_t.h +target_include_directories(oecertdump_enc PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + +target_link_libraries(oecertdump_enc oeenclave oelibc) diff --git a/tests/tools/oecertdump/enc/enc.cpp b/tests/tools/oecertdump/enc/enc.cpp new file mode 100644 index 0000000000..4368db3cab --- /dev/null +++ b/tests/tools/oecertdump/enc/enc.cpp @@ -0,0 +1,310 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "oecertdump_t.h" + +// This is the identity validation callback. A TLS connecting party (client or +// server) can verify the passed in identity information to decide whether to +// accept a connection request +oe_result_t enclave_identity_verifier(oe_identity_t* identity, void* arg) +{ + oe_result_t result = OE_VERIFY_FAILED; + + OE_UNUSED(arg); + OE_TRACE_INFO("enclave_identity_verifier is called with parsed report:\n"); + + // Check the enclave's security version + if (identity->security_version < 1) + { + OE_TRACE_ERROR( + "identity->security_version checking failed (%d)\n", + identity->security_version); + goto done; + } + + // Dump an enclave's unique ID, signer ID and Product ID. They are + // MRENCLAVE, MRSIGNER and ISVPRODID for SGX enclaves. In a real scenario, + // custom id checking should be done here + + OE_TRACE_INFO("identity->signer_id :\n"); + for (int i = 0; i < OE_UNIQUE_ID_SIZE; i++) + OE_TRACE_INFO("0x%0x ", (uint8_t)identity->signer_id[i]); + + OE_TRACE_INFO("\nparsed_report->identity.signer_id :\n"); + for (int i = 0; i < OE_SIGNER_ID_SIZE; i++) + OE_TRACE_INFO("0x%0x ", (uint8_t)identity->signer_id[i]); + + OE_TRACE_INFO("\nidentity->product_id :\n"); + for (int i = 0; i < OE_PRODUCT_ID_SIZE; i++) + OE_TRACE_INFO("0x%0x ", (uint8_t)identity->product_id[i]); + + result = OE_OK; +done: + return result; +} + +// input: input_data and input_data_len +// output: key, key_size +oe_result_t generate_key_pair( + int key_type, + uint8_t** public_key, + size_t* public_key_size, + uint8_t** private_key, + size_t* private_key_size) +{ + oe_result_t result = OE_FAILURE; + oe_asymmetric_key_params_t params; + char user_data[] = "test user data!"; + size_t user_data_size = sizeof(user_data) - 1; + uint8_t* local_public_key = NULL; + uint8_t* local_private_key = NULL; + + if (key_type == MBEDTLS_PK_ECKEY) + { + params.type = + OE_ASYMMETRIC_KEY_EC_SECP256P1; // MBEDTLS_ECP_DP_SECP256R1 + params.format = OE_ASYMMETRIC_KEY_PEM; + params.user_data = user_data; + params.user_data_size = user_data_size; + result = oe_get_public_key_by_policy( + OE_SEAL_POLICY_UNIQUE, + ¶ms, + public_key, + public_key_size, + NULL, + NULL); + OE_CHECK(result); + + result = oe_get_private_key_by_policy( + OE_SEAL_POLICY_UNIQUE, + ¶ms, + private_key, + private_key_size, + NULL, + NULL); + OE_CHECK(result); + } + else if (key_type == MBEDTLS_PK_RSA) + { + int res = -1; + mbedtls_ctr_drbg_context ctr_drbg_context; + mbedtls_entropy_context entropy_context; + mbedtls_pk_context pk_context; + size_t local_public_key_size = 512; + size_t local_private_key_size = 2048; + + mbedtls_ctr_drbg_init(&ctr_drbg_context); + mbedtls_entropy_init(&entropy_context); + mbedtls_pk_init(&pk_context); + + // Initialize entropy. + res = mbedtls_ctr_drbg_seed( + &ctr_drbg_context, mbedtls_entropy_func, &entropy_context, NULL, 0); + if (res != 0) + { + OE_TRACE_ERROR("mbedtls_ctr_drbg_seed failed."); + goto clean_rsa; + } + + // Initialize RSA context. + res = mbedtls_pk_setup( + &pk_context, mbedtls_pk_info_from_type(MBEDTLS_PK_RSA)); + if (res != 0) + { + OE_TRACE_ERROR("mbedtls_pk_setup failed (%d).", res); + goto clean_rsa; + } + + // Generate an ephemeral 2048-bit RSA key pair with + // exponent 65537 for the enclave. + res = mbedtls_rsa_gen_key( + mbedtls_pk_rsa(pk_context), + mbedtls_ctr_drbg_random, + &ctr_drbg_context, + 2048, + 65537); + if (res != 0) + { + OE_TRACE_ERROR("mbedtls_rsa_gen_key failed (%d)\n", res); + goto clean_rsa; + } + + /* Call again with the allocated memory. */ + local_public_key = (uint8_t*)malloc(local_public_key_size); + if (local_public_key == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + memset((void*)local_public_key, 0, local_public_key_size); + + local_private_key = (uint8_t*)malloc(local_private_key_size); + if (local_private_key == NULL) + OE_RAISE(OE_OUT_OF_MEMORY); + memset((void*)local_private_key, 0, local_private_key_size); + + // Write out the public/private key in PEM format for exchange with + // other enclaves. + res = mbedtls_pk_write_pubkey_pem( + &pk_context, local_public_key, local_public_key_size); + if (res != 0) + { + OE_TRACE_ERROR("mbedtls_pk_write_pubkey_pem failed (%d)\n", res); + goto clean_rsa; + } + + res = mbedtls_pk_write_key_pem( + &pk_context, local_private_key, local_private_key_size); + if (res != 0) + { + OE_TRACE_ERROR("mbedtls_pk_write_key_pem failed (%d)\n", res); + goto clean_rsa; + } + + *public_key = local_public_key; + // plus one to make sure \0 at the end is counted + *public_key_size = strlen((const char*)local_public_key) + 1; + + *private_key = local_private_key; + *private_key_size = strlen((const char*)local_private_key) + 1; + + local_public_key = NULL; + local_private_key = NULL; + + OE_TRACE_INFO("public_key_size\n[%d]\n", *public_key_size); + OE_TRACE_INFO("public_key\n[%s]\n", *public_key); + result = OE_OK; + + clean_rsa: + mbedtls_pk_free(&pk_context); + mbedtls_ctr_drbg_free(&ctr_drbg_context); + mbedtls_entropy_free(&entropy_context); + } + else + { + OE_TRACE_ERROR("Unsupported key type [%d]\n", key_type); + } + +done: + if (local_public_key) + free(local_public_key); + if (local_private_key) + free(local_private_key); + + return result; +} + +static oe_result_t get_tls_cert_signed_with_key( + int key_type, + unsigned char** cert, + size_t* cert_size) +{ + oe_result_t result = OE_FAILURE; + uint8_t* host_cert_buf = NULL; + + uint8_t* output_cert = NULL; + size_t output_cert_size = 0; + + uint8_t* private_key = NULL; + size_t private_key_size = 0; + uint8_t* public_key = NULL; + size_t public_key_size = 0; + + OE_TRACE_INFO("called into enclave\n"); + + // generate public/private key pair + result = generate_key_pair( + key_type, + &public_key, + &public_key_size, + &private_key, + &private_key_size); + if (result != OE_OK) + { + OE_TRACE_ERROR(" failed with %s\n", oe_result_str(result)); + goto done; + } + if (result != OE_OK) + { + OE_TRACE_ERROR(" failed with %s\n", oe_result_str(result)); + goto done; + } + + OE_TRACE_INFO("private key:[%s]\n", private_key); + OE_TRACE_INFO("public key:[%s]\n", public_key); + + result = oe_generate_attestation_certificate( + (const unsigned char*)"CN=Open Enclave SDK,O=OESDK TLS,C=US", + private_key, + private_key_size, + public_key, + public_key_size, + &output_cert, + &output_cert_size); + if (result != OE_OK) + { + OE_TRACE_ERROR(" failed with %s\n", oe_result_str(result)); + goto done; + } + + OE_TRACE_INFO("output_cert_size = 0x%x", output_cert_size); + // validate cert inside the enclave + result = oe_verify_attestation_certificate( + output_cert, output_cert_size, enclave_identity_verifier, NULL); + OE_TRACE_INFO( + "\nFrom inside enclave: verifying the certificate... %s\n", + result == OE_OK ? "Success" : "Fail"); + + // copy cert to host memory + host_cert_buf = (uint8_t*)oe_host_malloc(output_cert_size); + if (host_cert_buf == NULL) + { + result = OE_OUT_OF_MEMORY; + goto done; + } + + // copy to the host for host-side validation test + memcpy(host_cert_buf, output_cert, output_cert_size); + *cert_size = output_cert_size; + *cert = host_cert_buf; + OE_TRACE_INFO("*cert = %p", *cert); + OE_TRACE_INFO("*cert_size = 0x%x", *cert_size); + +done: + + free(private_key); + free(public_key); + oe_free_attestation_certificate(output_cert); + + return result; +} + +oe_result_t get_tls_cert_signed_with_ec_key( + unsigned char** cert, + size_t* cert_size) +{ + return get_tls_cert_signed_with_key(MBEDTLS_PK_ECKEY, cert, cert_size); +} + +oe_result_t get_tls_cert_signed_with_rsa_key( + unsigned char** cert, + size_t* cert_size) +{ + return get_tls_cert_signed_with_key(MBEDTLS_PK_RSA, cert, cert_size); +} + +OE_SET_ENCLAVE_SGX( + 1, /* ProductID */ + 1, /* SecurityVersion */ + true, /* AllowDebug */ + 128, /* HeapPageCount */ + 128, /* StackPageCount */ + 1); /* TCSCount */ diff --git a/tests/tools/oecertdump/host/CMakeLists.txt b/tests/tools/oecertdump/host/CMakeLists.txt new file mode 100644 index 0000000000..5793895ca8 --- /dev/null +++ b/tests/tools/oecertdump/host/CMakeLists.txt @@ -0,0 +1,20 @@ +# Copyright (c) Open Enclave SDK contributors. +# Licensed under the MIT License. + +find_package(OpenSSL REQUIRED) + +add_custom_command(OUTPUT oecertdump_u.h oecertdump_u.c oecertdump_args.h + DEPENDS ../oecertdump.edl edger8r + COMMAND edger8r --untrusted ${CMAKE_CURRENT_SOURCE_DIR}/../oecertdump.edl) + +add_executable(oecertdump host.cpp sgx_quote.cpp ${CMAKE_CURRENT_BINARY_DIR}/oecertdump_u.c) + +target_include_directories(oecertdump PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + -I/usr/include/openssl) + +target_link_libraries(oecertdump oehost) + +if(HAS_QUOTE_PROVIDER) + target_compile_definitions(oecertdump PRIVATE OE_LINK_SGX_DCAP_QL) +endif() diff --git a/tests/tools/oecertdump/host/host.cpp b/tests/tools/oecertdump/host/host.cpp new file mode 100644 index 0000000000..dbc8bcda44 --- /dev/null +++ b/tests/tools/oecertdump/host/host.cpp @@ -0,0 +1,328 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include +#include +#include +#include +#include +#include +#include +#include +#include "oecertdump_u.h" + +#if defined(__linux__) +#include +#include +#include +#include +#endif + +#include "sgx_quote.h" + +#ifdef OE_LINK_SGX_DCAP_QL + +#define INPUT_PARAM_OPTION_OUT_FILE "--out" +#define INPUT_PARAM_USAGE "--help" +#define DEFAULT_OUTPUTFILE "oecertdump_out.log" + +// Structure to store input parameters +// +typedef struct _input_params +{ + const char* enclave_filename; + const char* out_filename; +} input_params_t; + +static input_params_t _params; + +FILE* log_file = NULL; + +// This is the identity validation callback. A TLS connecting party (client or +// server) can verify the passed in "identity" information to decide whether to +// accept an connection request +oe_result_t enclave_identity_verifier(oe_identity_t* identity, void* arg) +{ + oe_result_t result = OE_VERIFY_FAILED; + + OE_UNUSED(arg); + log("enclave_identity_verifier is called with parsed report:\n"); + + // Check the enclave's security version + log("identity.security_version = %d\n", identity->security_version); + if (identity->security_version < 1) + { + log("identity.security_version check failed (%d)\n", + identity->security_version); + goto done; + } + + // Dump an enclave's unique ID, signer ID and Product ID. They are + // MRENCLAVE, MRSIGNER and ISVPRODID for SGX enclaves. In a real scenario, + // custom id checking should be done here + log("identity->signer_id :\n"); + for (int i = 0; i < OE_UNIQUE_ID_SIZE; i++) + log("0x%0x ", (uint8_t)identity->signer_id[i]); + + log("\nidentity->signer_id :\n"); + for (int i = 0; i < OE_SIGNER_ID_SIZE; i++) + log("0x%0x ", (uint8_t)identity->signer_id[i]); + + log("\nidentity->product_id :\n"); + for (int i = 0; i < OE_PRODUCT_ID_SIZE; i++) + log("0x%0x ", (uint8_t)identity->product_id[i]); + log("\n"); + + result = OE_OK; +done: + return result; +} + +void output_certificate(const uint8_t* data, size_t data_len) +{ +#if defined(__linux__) + if (log_file) + { + fprintf(log_file, "\n"); + X509* x509; + BIO* input = BIO_new_mem_buf(data, (int)data_len); + x509 = d2i_X509_bio(input, NULL); + if (x509) + { + X509_print_ex_fp( + log_file, x509, XN_FLAG_COMPAT, XN_FLAG_SEP_CPLUS_SPC); + } + BIO_free_all(input); + fprintf(log_file, "\n"); + } +#endif + OE_UNUSED(data); + OE_UNUSED(data_len); +} + +void validate_certificate(uint8_t* cert, size_t cert_size) +{ + oe_result_t result; + + result = oe_verify_attestation_certificate( + cert, cert_size, enclave_identity_verifier, NULL); + + log("Certificate verification result: %s\n", oe_result_str(result)); +} + +static oe_result_t _gen_cert(oe_enclave_t* enclave) +{ + oe_result_t result = OE_FAILURE; + oe_result_t ecall_result; + unsigned char* cert = NULL; + size_t cert_size = 0; + + log("========== Getting certificates\n"); + + // EC Key + result = get_tls_cert_signed_with_ec_key( + enclave, &ecall_result, &cert, &cert_size); + if ((result != OE_OK) || (ecall_result != OE_OK)) + { + log("Failed to create EC certificate. Enclave: %s, Host: %s\n", + oe_result_str(ecall_result), + oe_result_str(result)); + + goto exit; + } + else + { + output_certificate(cert, cert_size); + validate_certificate(cert, cert_size); + } + if (cert) + { + free(cert); + cert = NULL; + } + cert_size = 0; + + // RSA Key + result = get_tls_cert_signed_with_rsa_key( + enclave, &ecall_result, &cert, &cert_size); + if ((result != OE_OK) || (ecall_result != OE_OK)) + { + log("Failed to create RSA certificate. Enclave: %s, Host: %s\n", + oe_result_str(ecall_result), + oe_result_str(result)); + + goto exit; + } + else + { + output_certificate(cert, cert_size); + validate_certificate(cert, cert_size); + } + +exit: + // deallcate resources + if (cert) + free(cert); + + return result; +} + +static void _display_help(const char* cmd) +{ + printf("Usage: %s ENCLAVE_PATH Options\n", cmd); + printf("\tOptions:\n"); + printf("\t%s : output filename.\n", INPUT_PARAM_OPTION_OUT_FILE); +} + +static int _parse_args(int argc, const char* argv[]) +{ + if (argc < 1) + { + _display_help(argv[0]); + return 1; + } + + // clear params memory + memset(&_params, 0, sizeof(_params)); + + int i = 1; // current index + // save + _params.enclave_filename = argv[i++]; + _params.out_filename = DEFAULT_OUTPUTFILE; + + // Verify enclave file is valid + FILE* fp = fopen(_params.enclave_filename, "rb"); + if (!fp) + { + printf("Failed to find file: %s\n", _params.enclave_filename); + return 1; + } + else + fclose(fp); + + while (i < argc) + { + if (strcmp(INPUT_PARAM_OPTION_OUT_FILE, argv[i]) == 0) + { + if (argc >= i + 1) + { + _params.out_filename = argv[i + 1]; + i += 2; + } + else + { + printf( + "%s has invalid number of parameters.\n", + INPUT_PARAM_OPTION_OUT_FILE); + _display_help(argv[0]); + return 1; + } + } + else if (strcmp(INPUT_PARAM_USAGE, argv[i]) == 0) + { + _display_help(argv[0]); + return 1; + } + else + { + printf("Invalid option: %s\n", argv[i]); + return 1; + } + } + + return 0; +} + +static oe_result_t _process_params(oe_enclave_t* enclave) +{ + oe_result_t result = OE_FAILURE; + + result = gen_report(enclave); + if (result != OE_OK) + return result; + + result = _gen_cert(enclave); + + return result; +} + +#endif // OE_LINK_SGX_DCAP_QL + +int main(int argc, const char* argv[]) +{ + int ret = 0; + +#ifdef OE_LINK_SGX_DCAP_QL + oe_result_t result; + oe_enclave_t* enclave = NULL; + + const uint32_t flags = oe_get_create_flags(); + if ((flags & OE_ENCLAVE_FLAG_SIMULATE) != 0) + { + printf("oecertdump not supported in simulation mode.\n"); + goto exit; + } + + ret = _parse_args(argc, argv); + if (ret != 0) + goto exit; + + if ((result = oe_create_oecertdump_enclave( + _params.enclave_filename, + OE_ENCLAVE_TYPE_AUTO, + OE_ENCLAVE_FLAG_DEBUG, + NULL, + 0, + &enclave)) != OE_OK) + { + printf( + "Failed to create enclave. result=%u (%s)\n", + result, + oe_result_str(result)); + ret = 1; + goto exit; + } + + // Create log file + log_file = fopen(_params.out_filename, "w"); + if (!log_file) + { + printf("Failed to open log file %s\n", _params.out_filename); + ret = 1; + goto exit; + } + + set_log_callback(); + + if ((result = _process_params(enclave)) != OE_OK) + { + printf( + "Failed to process parameters. result=%u (%s)\n", + result, + oe_result_str(result)); + ret = 1; + goto exit; + } + + printf( + "oecertdump succeeded. Log file %s created.\n", _params.out_filename); + +exit: + if (enclave) + oe_terminate_enclave(enclave); + + if (log_file) + { + fflush(log_file); + fclose(log_file); + } + +#else +#pragma message( \ + "OE_LINK_SGX_DCAP_QL is not set to ON. This tool requires DCAP libraries.") + OE_UNUSED(argc); + OE_UNUSED(argv); + printf("oecertdump requires DCAP libraries.\n"); +#endif + return ret; +} diff --git a/tests/tools/oecertdump/host/sgx_quote.cpp b/tests/tools/oecertdump/host/sgx_quote.cpp new file mode 100644 index 0000000000..4b4f81615b --- /dev/null +++ b/tests/tools/oecertdump/host/sgx_quote.cpp @@ -0,0 +1,178 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#include "sgx_quote.h" + +#include +#include +#include +#include +#include +#include +#include +#include "oecertdump_u.h" + +#if defined(__linux__) +#include +#include +#include +#include +#endif + +#include "../../../../common/sgx/quote.h" +#include "../../../../common/sgx/revocation.h" +#include "../../../../host/sgx/sgxquoteprovider.h" + +#ifdef OE_LINK_SGX_DCAP_QL + +extern FILE* log_file; + +void log(const char* fmt, ...) +{ + char message[4096]; + va_list args; + va_start(args, fmt); + vsnprintf(message, sizeof(message), fmt, args); + va_end(args); + + // ensure buf is always null-terminated + message[sizeof(message) - 1] = 0; + + if (log_file) + { + fprintf(log_file, "%s", message); + } + else + { + printf("%s", message); + } +} + +// DCAP client (libdcap_quoteprov) log callback to this function. +void oecertdump_quote_provider_log( + sgx_ql_log_level_t level, + const char* message) +{ + const char* level_string = level == 0 ? "ERROR" : "INFO"; + + log("[%s]: %s\n", level_string, message); +} + +// Set DCAP client (libdcap_quoteprov) log callback +void set_log_callback() +{ +#if defined(__linux__) + extern oe_sgx_quote_provider_t provider; + + // Initialize quote provider and set log callback + oe_initialize_quote_provider(); + + sgx_ql_set_logging_function_t set_log_fcn = + (sgx_ql_set_logging_function_t)dlsym( + provider.handle, "sgx_ql_set_logging_function"); + if (set_log_fcn != NULL) + { + set_log_fcn(oecertdump_quote_provider_log); + } +#endif +} + +oe_result_t gen_report(oe_enclave_t* enclave) +{ + size_t report_size = OE_MAX_REPORT_SIZE; + uint8_t* remote_report = NULL; + + log("========== Getting report\n"); + + oe_result_t result = oe_get_report( + enclave, + OE_REPORT_FLAGS_REMOTE_ATTESTATION, + NULL, // opt_params must be null + 0, + (uint8_t**)&remote_report, + &report_size); + if (result == OE_OK) + { + log("========== Got report, size = %zu\n\n", report_size); + + oe_report_header_t* header = (oe_report_header_t*)remote_report; + sgx_quote_t* quote = (sgx_quote_t*)header->report; + uint64_t quote_size = header->report_size; + + log("CPU_SVN: '"); + for (uint64_t n = 0; n < SGX_CPUSVN_SIZE; n++) + { + log("%02x", quote->report_body.cpusvn[n]); + } + log("'\nQEID: '"); + for (uint64_t n = 0; n < 16; n++) + { + log("%02x", quote->user_data[n]); + } + log("'\n"); + + // Print endorsements + { + uint8_t* endorsements_data = NULL; + size_t endorsements_data_size = 0; + + result = oe_get_sgx_endorsements( + (const uint8_t*)quote, + quote_size, + &endorsements_data, + &endorsements_data_size); + if (result != OE_OK) + { + log("ERROR: Failed to get endorsements\n"); + goto exit; + } + + log("========== Got endorsements, size = %zu\n", + endorsements_data_size); + oe_sgx_endorsements_t endorsements; + result = oe_parse_sgx_endorsements( + (oe_endorsements_t*)endorsements_data, + endorsements_data_size, + &endorsements); + + log("Revocation TCB_INFO:\n"); + oe_sgx_endorsement_item tcb_info = + endorsements.items[OE_SGX_ENDORSEMENT_FIELD_TCB_INFO]; + log("%s\n\n", tcb_info.data); + + oe_free_sgx_endorsements(endorsements_data); + } + + // Verify report + { + log("========== Verifying report\n"); + + oe_report_t parsed_report; + result = oe_verify_report( + NULL, remote_report, report_size, &parsed_report); + if (result != OE_OK) + { + log("Failed to verify report. result=%u (%s)\n", + result, + oe_result_str(result)); + goto exit; + } + else + { + log("========== Report verified\n\n"); + } + } + } + else + { + log("Failed to create report. Error: %s\n", oe_result_str(result)); + } + +exit: + if (remote_report) + oe_free_report(remote_report); + + return result; +} + +#endif // OE_LINK_SGX_DCAP_QL diff --git a/tests/tools/oecertdump/host/sgx_quote.h b/tests/tools/oecertdump/host/sgx_quote.h new file mode 100644 index 0000000000..679c592626 --- /dev/null +++ b/tests/tools/oecertdump/host/sgx_quote.h @@ -0,0 +1,18 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +#ifndef _SGX_QUOTE +#define _SGX_QUOTE + +#include +#include "../../../../host/sgx/platformquoteprovider.h" + +void log(const char* fmt, ...); +void oecertdump_quote_provider_log( + sgx_ql_log_level_t level, + const char* message); +void set_log_callback(); + +oe_result_t gen_report(oe_enclave_t* enclave); + +#endif // _SGX_QUOTE \ No newline at end of file diff --git a/tests/tools/oecertdump/oecertdump.edl b/tests/tools/oecertdump/oecertdump.edl new file mode 100644 index 0000000000..e423b5bfe4 --- /dev/null +++ b/tests/tools/oecertdump/oecertdump.edl @@ -0,0 +1,14 @@ +// Copyright (c) Open Enclave SDK contributors. +// Licensed under the MIT License. + +enclave { + trusted { + public oe_result_t get_tls_cert_signed_with_ec_key( + [out] unsigned char** data, + [out] size_t* data_size); + + public oe_result_t get_tls_cert_signed_with_rsa_key( + [out] unsigned char** data, + [out] size_t* data_size); + }; +}; diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 18f757bcb5..b63c8a014b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_subdirectory(oeedger8r) diff --git a/tools/oeedger8r/.gitignore b/tools/oeedger8r/.gitignore new file mode 100644 index 0000000000..c1eda1a597 --- /dev/null +++ b/tools/oeedger8r/.gitignore @@ -0,0 +1,8 @@ +.merlin +node_modules/ +_build +_esy +_release +*.byte +*.native +*.install diff --git a/tools/oeedger8r/.merlin b/tools/oeedger8r/.merlin deleted file mode 100644 index f8064b3f07..0000000000 --- a/tools/oeedger8r/.merlin +++ /dev/null @@ -1,4 +0,0 @@ -S intel -S ../../build/tools/oeedger8r - -B ../../build/tools/oeedger8r diff --git a/tools/oeedger8r/CMakeLists.txt b/tools/oeedger8r/CMakeLists.txt index 7189b9c0a6..ed037afd6b 100644 --- a/tools/oeedger8r/CMakeLists.txt +++ b/tools/oeedger8r/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. # NOTE: The custom commands below first copy the input files to the @@ -6,69 +6,54 @@ # do not emit to the current working directory, they always emit to # the location of the input file. -# Check prerequisites -find_program(OCAMLLEX ocamllex) -find_program(OCAMLYACC ocamlyacc) -find_program(OCAMLOPT ocamlopt) -if ((NOT OCAMLLEX) OR (NOT OCAMLYACC) OR (NOT OCAMLOPT)) - message(FATAL_ERROR "Please check your OCAML installation and make sure you installed 'ocaml-native-compilers'") +find_program(ESY esy) +if (NOT ESY) + message(FATAL_ERROR "Please check your esy installation") endif () -# Generate Lexer. +# An artifact of using `esy` is that the generated binary is always +# `main.exe` regardless of platform. We rename it for installation in +# the package. +set(BINARY ${CMAKE_CURRENT_BINARY_DIR}/_build/default/src/main.exe) add_custom_command( - OUTPUT Lexer.ml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/intel/Lexer.mll ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ocamllex Lexer.mll - DEPENDS intel/Lexer.mll) - -# Generate Parser. -add_custom_command( - OUTPUT Parser.ml Parser.mli - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/intel/Parser.mly ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ocamlyacc Parser.mly - DEPENDS intel/Parser.mly) - -# Compile -set(BINARY oeedger8r${CMAKE_EXECUTABLE_SUFFIX}) -add_custom_command( - OUTPUT ${BINARY} - COMMAND ocamlopt -c -bin-annot -I . -o Ast.cmx ${CMAKE_CURRENT_SOURCE_DIR}/intel/Ast.ml - COMMAND ocamlopt -c -bin-annot -I . -o Util.cmx ${CMAKE_CURRENT_SOURCE_DIR}/intel/Util.ml - COMMAND ocamlopt -c -bin-annot -I . -o SimpleStack.cmx ${CMAKE_CURRENT_SOURCE_DIR}/intel/SimpleStack.ml - COMMAND ocamlopt -c -bin-annot -I . -o Plugin.cmx ${CMAKE_CURRENT_SOURCE_DIR}/intel/Plugin.ml - COMMAND ocamlopt -c -bin-annot -I . -o Preprocessor.cmx ${CMAKE_CURRENT_SOURCE_DIR}/intel/Preprocessor.ml - COMMAND ocamlopt -c -bin-annot -I . -o Parser.cmi ${CMAKE_CURRENT_BINARY_DIR}/Parser.mli - COMMAND ocamlopt -c -bin-annot -I . -o Parser.cmx ${CMAKE_CURRENT_BINARY_DIR}/Parser.ml - COMMAND ocamlopt -c -bin-annot -I . -o Lexer.cmx ${CMAKE_CURRENT_BINARY_DIR}/Lexer.ml - COMMAND ocamlopt -c -bin-annot -I . -o CodeGen.cmx ${CMAKE_CURRENT_SOURCE_DIR}/intel/CodeGen.ml - COMMAND ocamlopt -c -bin-annot -I . -o Emitter.cmx ${CMAKE_CURRENT_SOURCE_DIR}/Emitter.ml - COMMAND ocamlopt -c -bin-annot -I . -o main.cmx ${CMAKE_CURRENT_SOURCE_DIR}/main.ml - COMMAND ocamlopt str.cmxa unix.cmxa Ast.cmx Util.cmx SimpleStack.cmx Plugin.cmx - Preprocessor.cmx Parser.cmx Lexer.cmx CodeGen.cmx Emitter.cmx main.cmx - -o ${BINARY} - - # Add dependency to generated Lexer and Parser, and all of the sources. - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Lexer.ml - ${CMAKE_CURRENT_BINARY_DIR}/Parser.ml - ${CMAKE_CURRENT_BINARY_DIR}/Parser.mli - Emitter.ml - main.ml - intel/Ast.ml - intel/CodeGen.ml - intel/Edger8r.ml - intel/Plugin.ml - intel/Preprocessor.ml - intel/SimpleStack.ml - intel/Util.ml) + OUTPUT ${BINARY} + # NOTE: We copy only the files we need to build in order to allow + # for developers to build in the source tree (as this is easier for + # testing changes and new packages and formatting etc.). We cannot + # just copy the entire folder as CMake crashes with the + # `node_modules`. + COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/esy.lock ${CMAKE_CURRENT_BINARY_DIR}/esy.lock + COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/intel ${CMAKE_CURRENT_BINARY_DIR}/intel + COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND cmake -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/dune-project ${CMAKE_CURRENT_SOURCE_DIR}/package.json ${CMAKE_CURRENT_BINARY_DIR} + COMMAND esy install + COMMAND esy build --release + DEPENDS dune-project + package.json + src/dune + src/Emitter.ml + src/main.ml + intel/dune + intel/Ast.ml + intel/CodeGen.ml + intel/Edger8r.ml + intel/Lexer.mll + intel/Parser.mly + intel/Plugin.ml + intel/Preprocessor.ml + intel/SimpleStack.ml + intel/Util.ml) # The names here are important because the output file must be named # `oeedger8r`, and our targets must not clash with that. add_executable(edger8r IMPORTED GLOBAL) -set_target_properties(edger8r PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${BINARY}) +set_target_properties(edger8r PROPERTIES IMPORTED_LOCATION ${BINARY}) add_custom_target(oeedger8r_target DEPENDS ${BINARY}) add_dependencies(edger8r oeedger8r_target) # Can't use `install(TARGETS)` on an imported executable, because it # causes CMake to crash. Instead, see `openenclave-config.cmake.in` # for the manual "export" of this target. -install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${BINARY} DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(PROGRAMS ${BINARY} + RENAME oeedger8r${CMAKE_EXECUTABLE_SUFFIX} + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/tools/oeedger8r/Emitter.ml b/tools/oeedger8r/Emitter.ml deleted file mode 100644 index ec641db196..0000000000 --- a/tools/oeedger8r/Emitter.ml +++ /dev/null @@ -1,1466 +0,0 @@ -(* Copyright (c) Microsoft Corporation. All rights reserved. - Licensed under the MIT License. *) - -(** This module is Open Enclave's plugin for Intel's Edger8r, allowing - us to share the same Enclave Definition Language, but emit our - SDK's bindings. *) - -open Ast -open Plugin -open Printf -open Util - -(** ----- Begin code borrowed and tweaked from {!CodeGen.ml}. ----- *) -let is_foreign_array (pt : parameter_type) = - match pt with - | PTVal _ -> false - | PTPtr (t, a) -> ( match t with Foreign _ -> a.pa_isary | _ -> false ) - -(** Get the array declaration from a list of array dimensions. Empty - [ns] indicates the corresponding declarator is a simple identifier. - Element of value -1 means that user does not specify the dimension - size. *) -let get_array_dims (ns : int list) = - let get_dim n = if n = -1 then "[]" else sprintf "[%d]" n in - String.concat "" (List.map get_dim ns) - -let get_typed_declr_str (ty : atype) (declr : declarator) = - let tystr = get_tystr ty in - let dmstr = get_array_dims declr.array_dims in - sprintf "%s %s%s" tystr declr.identifier dmstr - -(** Check whether given parameter [pt] is [const] specified. *) -let is_const_ptr (pt : parameter_type) = - let aty = get_param_atype pt in - match pt with - | PTVal _ -> false - | PTPtr (_, pa) -> ( - if not pa.pa_rdonly then false - else match aty with Foreign _ -> false | _ -> true ) - -(** Generate parameter [p] representation. *) -let gen_parm_str (p : pdecl) = - let pt, (declr : declarator) = p in - let aty = get_param_atype pt in - let str = get_typed_declr_str aty declr in - if is_const_ptr pt then "const " ^ str else str - -(** [conv_array_to_ptr] is used to convert Array form into Pointer form. - {[ - int array[10][20] => [count = 200] int* array - ]} - - This function is called when generating proxy/bridge code and the - marshalling structure. *) -let conv_array_to_ptr (pd : pdecl) : pdecl = - let pt, declr = pd in - let get_count_attr ilist = - (* XXX: assume the size of each dimension will be > 0. *) - ANumber (List.fold_left (fun acc i -> acc * i) 1 ilist) - in - match pt with - | PTVal _ -> (pt, declr) - | PTPtr (aty, pa) -> - if is_array declr then - let tmp_declr = {declr with array_dims= []} in - let tmp_aty = Ptr aty in - let tmp_cnt = get_count_attr declr.array_dims in - let tmp_pa = - {pa with pa_size= {empty_ptr_size with ps_count= Some tmp_cnt}} - in - (PTPtr (tmp_aty, tmp_pa), tmp_declr) - else (pt, declr) - -(** ----- End code borrowed and tweaked from {!CodeGen.ml} ----- *) - -(* Helper to map and filter out None at the same time. *) -let filter_map f l = - (* Would be [List.of_seq (Seq.filter_map f (List.to_seq l))] if we - had 4.07 everywhere. *) - List.map - (function Some x -> x | None -> invalid_arg "None") - (List.filter (function Some _ -> true | None -> false) (List.map f l)) - -(* Helper to flatten and map at the same time. *) -let flatten_map f l = List.flatten (List.map f l) - -let is_in_ptr = function - | PTVal _ -> false - | PTPtr (_, a) -> a.pa_chkptr && a.pa_direction = PtrIn - -let is_out_ptr = function - | PTVal _ -> false - | PTPtr (_, a) -> a.pa_chkptr && a.pa_direction = PtrOut - -let is_inout_ptr = function - | PTVal _ -> false - | PTPtr (_, a) -> a.pa_chkptr && a.pa_direction = PtrInOut - -let is_in_or_inout_ptr (p, _) = is_in_ptr p || is_inout_ptr p - -let is_out_or_inout_ptr (p, _) = is_out_ptr p || is_inout_ptr p - -let is_str_ptr = function PTVal _ -> false | PTPtr (_, a) -> a.pa_isstr - -let is_wstr_ptr = function PTVal _ -> false | PTPtr (_, a) -> a.pa_iswstr - -let is_str_or_wstr_ptr (p, _) = is_str_ptr p || is_wstr_ptr p - -(* This tests if the member has a non-empty size attribute, - implying that it should be marshalled. *) -let is_marshalled_ptr = function - | PTPtr (_, attr) -> attr.pa_size <> empty_ptr_size - | PTVal _ -> false - -let gen_c_for level count body = - if count = "1" then body - else - let i = sprintf "_i_%i" level in - [ [sprintf "for (size_t %s = 0; %s < %s; %s++)" i i count i] - ; ["{"] - ; List.map (( ^ ) " ") body - ; ["}"] ] - |> List.flatten - -let gen_c_deref level i = if i = "1" then "->" else sprintf "[_i_%i]." level - -(** [write_file] opens [filename] in the directory [dir] and emits a - comment noting the file is auto generated followed by the - [content], it then closes the file. *) -let write_file (content : string list) (filename : string) (dir : string) = - let os = - if dir = "." then open_out filename - else open_out (dir ^ separator_str ^ filename) - in - fprintf os "%s" - (String.concat "\n" - ( [ "/*" - ; " * This file is auto generated by oeedger8r. DO NOT EDIT." - ; " */" ] - @ content )) ; - close_out os - -let get_type_expr ptype = - (* Get the base type of the parameter. That is, yield its [atype], - unless it is a pointer, in which case decompose and yield the - [atype] the pointer points to. *) - let param_atype = - let a = get_param_atype ptype in - match a with Ptr p -> p | _ -> a - in - let tystr = get_tystr param_atype in - match ptype with - | PTPtr (_, ptr_attr) when ptr_attr.pa_isptr -> sprintf "*(%s)0" tystr - | _ -> tystr - -(** For a list of args and current count, get the corresponding - argstruct variable name. The prefix is usually, but not always, - ["_args."].*) -let oe_get_argstruct prefix args count = - match args with - | [] -> prefix - | hd :: _ -> prefix ^ hd ^ gen_c_deref (List.length args) count - -let attr_value_to_string argstruct = function - | None -> None - | Some (ANumber n) -> Some (string_of_int n) - | Some (AString s) -> Some (argstruct ^ s) - -(** For a parameter, get its size expression. *) -let get_param_size (ptype, decl, argstruct) = - let type_expr = get_type_expr ptype in - let get_ptr_or_decl_size (p : ptr_size) = - let size = attr_value_to_string argstruct p.ps_size - and count = attr_value_to_string argstruct p.ps_count in - match (size, count) with - | Some s, None -> s - | None, Some c -> sprintf "(%s * sizeof(%s))" c type_expr - (* TODO: Check that this is an even multiple of the size of type. *) - | Some s, Some c -> sprintf "(%s * %s)" s c - | None, None -> - sprintf "sizeof(%s%s)" type_expr (get_array_dims decl.array_dims) - in - match ptype with - | PTPtr (_, ptr_attr) -> - if ptr_attr.pa_isstr then - Some (argstruct ^ decl.identifier ^ "_len * sizeof(char)") - else if ptr_attr.pa_iswstr then - Some (argstruct ^ decl.identifier ^ "_len * sizeof(wchar_t)") - else if ptr_attr.pa_chkptr then - Some (get_ptr_or_decl_size ptr_attr.pa_size) - else None - (* Values have no marshalling size. *) - | _ -> None - -let oe_get_param_size (ptype, decl, argstruct) = - match get_param_size (ptype, decl, argstruct) with - | Some size -> size - | None -> failwithf "Error: No size for " ^ decl.identifier - -(** For a parameter, get its count expression. *) -let get_param_count (ptype, decl, argstruct) = - let type_expr = get_type_expr ptype in - let get_ptr_or_decl_count (p : ptr_size) = - let size = attr_value_to_string argstruct p.ps_size - and count = attr_value_to_string argstruct p.ps_count in - match (size, count) with - (* TODO: Check that these are even multiples of the size of type. *) - | Some s, None -> sprintf "(%s / sizeof(%s))" s type_expr - | None, Some c -> c - | Some s, Some c -> sprintf "((%s * %s) / sizeof(%s))" s c type_expr - | None, None -> - let dims = List.map string_of_int decl.array_dims in - String.concat " * " dims - in - match ptype with - | PTPtr (_, ptr_attr) -> - (* The count of a string is its length. *) - if ptr_attr.pa_isstr || ptr_attr.pa_iswstr then - (* TODO: Double-check that this length includes the - null-terminator. *) - Some (argstruct ^ decl.identifier ^ "_len") - else if ptr_attr.pa_chkptr then - Some (get_ptr_or_decl_count ptr_attr.pa_size) - (* TODO: Should be able to return [Some "1"] for plain - pointers and values. *) - else None - | PTVal _ -> None - -let oe_get_param_count (ptype, decl, argstruct) = - match get_param_count (ptype, decl, argstruct) with - | Some count -> count - | None -> failwithf "Error: No count for " ^ decl.identifier - -(** Generate the prototype for a given function. *) -let oe_gen_prototype (fd : func_decl) = - let plist_str = - let args = List.map gen_parm_str fd.plist in - match args with - | [] -> "void" - | [arg] -> arg - | _ -> "\n " ^ String.concat ",\n " args - in - sprintf "%s %s(%s)" (get_tystr fd.rtype) fd.fname plist_str - -(** Generate the wrapper prototype for a given function. Optionally - add an [oe_enclave_t*] first parameter. *) -let oe_gen_wrapper_prototype (fd : func_decl) (is_ecall : bool) = - let plist_str = - let args = - [ (if is_ecall then ["oe_enclave_t* enclave"] else []) - ; ( match fd.rtype with - | Void -> [] - | _ -> [get_tystr fd.rtype ^ "* _retval"] ) - ; List.map gen_parm_str fd.plist ] - |> List.flatten - in - match args with - | [arg] -> arg - | _ -> "\n " ^ String.concat ",\n " args - in - sprintf "oe_result_t %s(%s)" fd.fname plist_str - -(** Emit [struct], [union], or [enum]. *) -let emit_composite_type = - let emit_struct (s : struct_def) = - [ "typedef struct " ^ s.sname - ; "{" - ; String.concat "\n" - (List.map - (fun (ptype, decl) -> - sprintf " %s %s%s;" - (get_tystr (get_param_atype ptype)) - decl.identifier - (get_array_dims decl.array_dims) ) - s.smlist) - ; "} " ^ s.sname ^ ";" - ; "" ] - in - let emit_union (u : union_def) = - [ "typedef union " ^ u.uname - ; "{" - ; String.concat "\n" - (List.map - (fun (atype, decl) -> - sprintf " %s %s%s;" (get_tystr atype) decl.identifier - (get_array_dims decl.array_dims) ) - u.umlist) - ; "} " ^ u.uname ^ ";" - ; "" ] - in - let emit_enum (e : enum_def) = - [ "typedef enum " ^ e.enname - ; "{" - ; String.concat ",\n" - (List.map - (fun (name, value) -> - sprintf " %s%s" name - ( match value with - | EnumVal (AString s) -> " = " ^ s - | EnumVal (ANumber n) -> " = " ^ string_of_int n - | EnumValNone -> "" ) ) - e.enbody) - ; "} " ^ e.enname ^ ";" - ; "" ] - in - function - | StructDef s -> emit_struct s - | UnionDef u -> emit_union u - | EnumDef e -> emit_enum e - -(** Generate a cast expression for a pointer argument. Pointer - arguments need to be cast to their root type, since the marshalling - struct has the root pointer. For example: - {[ - int a[10][20] - ]} - needs to be cast to [int *]. - - NOTE: Foreign arrays are marshalled as [void *], but foreign pointers - are marshalled as-is. *) -let get_cast_to_mem_expr (ptype, decl) (parens : bool) = - match ptype with - | PTVal _ -> "" - | PTPtr (t, _) -> - let tystr = get_tystr t in - if is_array decl then - let s = tystr ^ "*" in - if parens then sprintf "(%s)" s else s - else if is_foreign_array ptype then - let s = if parens then "(void*)" else "void*" in - sprintf "/* foreign array of type %s */ %s" tystr s - else if parens then sprintf "(%s)" tystr - else tystr - -(** Generate a cast expression to a specific pointer type. For example, - [int*] needs to be cast to - {[ - *(int ( * )[5][6]) - ]}. *) -let get_cast_from_mem_expr (ptype, decl) = - match ptype with - | PTVal _ -> "" - | PTPtr (t, attr) -> - if is_array decl then - sprintf "*(%s(*)%s)" (get_tystr t) (get_array_dims decl.array_dims) - else if is_foreign_array ptype then - sprintf "/* foreign array */ *(%s*)" (get_tystr t) - else if attr.pa_rdonly then - (* for ptrs, only constness is removed; add it back *) - sprintf "(const %s)" (get_tystr t) - else "" - -let oe_gen_call_user_function (fd : func_decl) = - [ "/* Call user function. */" - ; (match fd.rtype with Void -> "" | _ -> "pargs_out->_retval = ") - ^ fd.fname ^ "(" - ; String.concat ",\n " - (List.map - (fun (ptype, decl) -> - let cast_expr = get_cast_from_mem_expr (ptype, decl) in - sprintf " %spargs_in->%s" cast_expr decl.identifier ) - fd.plist) - ^ ");" ] - -let warn_non_portable_types (fd : func_decl) = - (* Check if any of the parameters or the return type has the given - root type. *) - let uses_type (t : atype) = - t = fd.rtype || List.exists (fun (p, _) -> t = get_param_atype p) fd.plist - in - let print_portability_warning ty = - printf - "Warning: Function '%s': %s has different sizes on Windows and Linux. \ - This enclave cannot be built in Linux and then safely loaded in \ - Windows.\n" - fd.fname ty - in - let print_portability_warning_with_recommendation ty recommendation = - printf - "Warning: Function '%s': %s has different sizes on Windows and Linux. \ - This enclave cannot be built in Linux and then safely loaded in \ - Windows. Consider using %s instead.\n" - fd.fname ty recommendation - in - (* longs are represented as an Int type *) - let long_t = Int {ia_signedness= Signed; ia_shortness= ILong} in - let ulong_t = Int {ia_signedness= Unsigned; ia_shortness= ILong} in - if uses_type WChar then print_portability_warning "wchar_t" ; - if uses_type LDouble then print_portability_warning "long double" ; - (* Handle long type *) - if uses_type (Long Signed) || uses_type long_t then - print_portability_warning_with_recommendation "long" "int64_t or int32_t" ; - (* Handle unsigned long type *) - if uses_type (Long Unsigned) || uses_type ulong_t then - print_portability_warning_with_recommendation "unsigned long" - "uint64_t or uint32_t" - -let warn_signed_size_or_count_types (fd : func_decl) = - let print_signedness_warning p = - printf - "Warning: Function '%s': Size or count parameter '%s' should not be \ - signed.\n" - fd.fname p - in - (* Get the names of all size and count parameters for the function [fd]. *) - let size_params = - filter_map - (fun (ptype, _) -> - (* The size may be either a [count] or [size], and then - either a number or string. We are interested in the - strings, as they indicate named [size] or [count] - parameters. *) - let param_name {ps_size; ps_count} = - match (ps_size, ps_count) with - (* [s] is the name of the parameter as a string. *) - | None, Some (AString s) | Some (AString s), None -> Some s - (* TODO: Check for [Some (ANumber n)] that [n < 1] *) - | _ -> None - in - (* Only variables that are pointers where [chkptr] is true may - have size parameters. *) - match ptype with - | PTPtr (_, a) when a.pa_chkptr -> param_name a.pa_size - | _ -> None ) - fd.plist - in - (* Print warnings for size parameters that are [Signed]. *) - List.iter - (fun (ptype, decl) -> - let id = decl.identifier in - if List.mem id size_params then - match ptype with - | PTVal (Long s | LLong s) when s = Signed -> - print_signedness_warning id - | PTVal (Int i) when i.ia_signedness = Signed -> - print_signedness_warning id - | _ -> () ) - fd.plist - -let warn_size_and_count_params (fd : func_decl) = - let print_size_and_count_warning {ps_size; ps_count} = - match (ps_size, ps_count) with - | Some (AString p), Some (AString q) -> - failwithf - "Function '%s': simultaneous 'size' and 'count' parameters '%s' and \ - '%s' are not supported by oeedger8r.\n" - fd.fname p q - | _ -> () - in - List.iter - (fun (ptype, _) -> - match ptype with - | PTPtr (_, ptr_attr) when ptr_attr.pa_chkptr -> - print_size_and_count_warning ptr_attr.pa_size - | _ -> () ) - fd.plist - -(** Generate the Enclave code. *) -let gen_enclave_code (ec : enclave_content) (ep : edger8r_params) = - (* Short aliases for the trusted and untrusted function - declarations. *) - let tfs = ec.tfunc_decls in - let ufs = ec.ufunc_decls in - (* Validate Open Enclave supported EDL features. NOTE: This - validation has the side effects of printed warnings or failure - with an error message. *) - if ep.use_prefix then - failwithf "--use_prefix option is not supported by oeedger8r." ; - List.iter - (fun f -> - if f.tf_is_priv then - failwithf - "Function '%s': 'private' specifier is not supported by oeedger8r" - f.tf_fdecl.fname ; - if f.tf_is_switchless && not ep.experimental then - failwithf - "Function '%s': switchless ecalls are not yet supported \ - by Open Enclave SDK." - f.tf_fdecl.fname ) - tfs ; - List.iter - (fun f -> - ( if f.uf_fattr.fa_convention <> CC_NONE then - let cconv_str = get_call_conv_str f.uf_fattr.fa_convention in - printf - "Warning: Function '%s': Calling convention '%s' for ocalls is not \ - supported by oeedger8r.\n" - f.uf_fdecl.fname cconv_str ) ; - if f.uf_fattr.fa_dllimport then - failwithf "Function '%s': dllimport is not supported by oeedger8r." - f.uf_fdecl.fname ; - if f.uf_allow_list != [] then - printf - "Warning: Function '%s': Reentrant ocalls are not supported by Open \ - Enclave. Allow list ignored.\n" - f.uf_fdecl.fname ; - if f.uf_is_switchless && not ep.experimental then - failwithf - "Function '%s': switchless ocalls are not yet supported \ - by Open Enclave SDK." - f.uf_fdecl.fname ) - ufs ; - (* Map warning functions over trusted and untrusted function - declarations *) - let ufuncs = List.map (fun f -> f.uf_fdecl) ufs in - let tfuncs = List.map (fun f -> f.tf_fdecl) tfs in - let funcs = List.append ufuncs tfuncs in - List.iter - (fun f -> - warn_non_portable_types f ; - warn_signed_size_or_count_types f ; - warn_size_and_count_params f ) - funcs ; - (* End EDL validation. *) - (* Given [name], return the corresponding [StructDef], or [None]. *) - let get_struct_by_name name = - (* [ec.comp_defs] is a list of all composite types, but we're only - interested in the structs, so we filter out the rest and unwrap - them from [composite_type]. *) - let structs = - filter_map (function StructDef s -> Some s | _ -> None) ec.comp_defs - in - (* TODO: [List.find_opt] is better, but requires 4.05. *) - if List.exists (fun s -> s.sname = name) structs then - Some (List.find (fun s -> s.sname = name) structs) - else None - in - (* We need to check [Ptr]s for [Foreign] or [Struct] types, then - check those against the user's [Struct]s, and then check if any - members should be deep copied. What we return is the list of - members of the [Struct] which should be deep-copied, otherwise we - return an empty list. *) - let get_deepcopy_members (a : atype) = - let should_deepcopy_a = function - | Ptr (Struct n) | Ptr (Foreign n) -> get_struct_by_name n - | _ -> None - in - (* Only enabled with --experimental! *) - if ep.experimental then - match should_deepcopy_a a with - | Some s -> List.filter (fun (p, _) -> is_marshalled_ptr p) s.smlist - | None -> [] - else [] - in - let get_function_id (f : func_decl) = - ec.enclave_name ^ "_fcn_id_" ^ f.fname - in - (* Emit IDs in enum for trusted functions. *) - let emit_trusted_function_ids = - [ "enum" - ; "{" - ; String.concat "\n" - (List.mapi - (fun i f -> sprintf " %s = %d," (get_function_id f.tf_fdecl) i) - tfs) - ; " " ^ ec.enclave_name ^ "_fcn_id_trusted_call_id_max = OE_ENUM_MAX" - ; "};" ] - in - (* Emit IDs in enum for untrusted functions. *) - let emit_untrusted_function_ids = - [ "enum" - ; "{" - ; String.concat "\n" - (List.mapi - (fun i f -> sprintf " %s = %d," (get_function_id f.uf_fdecl) i) - ufs) - ; " " ^ ec.enclave_name ^ "_fcn_id_untrusted_call_max = OE_ENUM_MAX" - ; "};" ] - in - (* Generate [args.h] which contains [struct]s for ecalls and ocalls *) - let oe_gen_args_header = - let oe_gen_marshal_struct (fd : func_decl) (errno : bool) = - let gen_member_decl (ptype, decl) = - let aty = get_param_atype ptype in - let tystr = get_tystr aty in - let tystr = - if is_foreign_array ptype then - sprintf "/* foreign array of type %s */ void*" tystr - else tystr - in - let need_strlen = - is_str_or_wstr_ptr (ptype, decl) && is_in_or_inout_ptr (ptype, decl) - in - let id = decl.identifier in - [ [tystr ^ " " ^ id ^ ";"] - ; (if need_strlen then [sprintf "size_t %s_len;" id] else []) ] - |> List.flatten - in - let struct_name = fd.fname ^ "_args_t" in - let retval_decl = {identifier= "_retval"; array_dims= []} in - let members = - [ ["oe_result_t _result;"] - ; ( if fd.rtype = Void then [] - else gen_member_decl (PTVal fd.rtype, retval_decl) ) - ; (if errno then ["int _ocall_errno;"] else []) - ; flatten_map gen_member_decl (List.map conv_array_to_ptr fd.plist) ] - |> List.flatten - in - [ "typedef struct _" ^ struct_name - ; "{" - ; " " ^ String.concat "\n " members - ; "} " ^ struct_name ^ ";" - ; "" ] - in - let oe_gen_user_includes (includes : string list) = - if includes <> [] then List.map (sprintf "#include \"%s\"") includes - else ["/* There were no user includes. */"] - in - let oe_gen_user_types (cts : composite_type list) = - if cts <> [] then flatten_map emit_composite_type cts - else ["/* There were no user defined types. */"; ""] - in - let oe_gen_ecall_marshal_structs = - if tfs <> [] then - flatten_map (fun tf -> oe_gen_marshal_struct tf.tf_fdecl false) tfs - else ["/* There were no ecalls. */"; ""] - in - let oe_gen_ocall_marshal_structs = - if ufs <> [] then - flatten_map - (fun uf -> oe_gen_marshal_struct uf.uf_fdecl uf.uf_propagate_errno) - ufs - else ["/* There were no ocalls. */"; ""] - in - let with_errno = List.exists (fun uf -> uf.uf_propagate_errno) ufs in - let guard_macro = - "EDGER8R_" ^ String.uppercase ec.enclave_name ^ "_ARGS_H" - in - [ "#ifndef " ^ guard_macro - ; "#define " ^ guard_macro - ; "" - ; "#include " - ; "#include /* for wchar_t */" - ; "" - ; (let s = "#include " in - if with_errno then s - else - sprintf "/* %s - Errno propagation not enabled so not included. */" s) - ; "" - ; "#include " - ; "" - ; "/**** User includes. ****/" - ; String.concat "\n" (oe_gen_user_includes ec.include_list) - ; "" - ; "/**** User defined types in EDL. ****/" - ; String.concat "\n" (oe_gen_user_types ec.comp_defs) - ; "/**** ECALL marshalling structs. ****/" - ; String.concat "\n" oe_gen_ecall_marshal_structs - ; "/**** OCALL marshalling structs. ****/" - ; String.concat "\n" oe_gen_ocall_marshal_structs - ; "/**** Trusted function IDs ****/" - ; String.concat "\n" emit_trusted_function_ids - ; "" - ; "/**** Untrusted function IDs. ****/" - ; String.concat "\n" emit_untrusted_function_ids - ; "" - ; "#endif // " ^ guard_macro - ; "" ] - in - (* Prepare [input_buffer]. *) - let oe_prepare_input_buffer (fd : func_decl) (alloc_func : string) = - let oe_compute_buffer_size buffer predicate plist = - let rec gen_add_size args count (ptype, decl) = - let argstruct = oe_get_argstruct "_args." args count in - let size = oe_get_param_size (ptype, decl, argstruct) in - let arg = - match args with - | [] -> decl.identifier - | hd :: _ -> - hd ^ gen_c_deref (List.length args) count ^ decl.identifier - in - gen_c_for (List.length args) count - ( [ [ sprintf "if (%s)" - (String.concat " && " (List.rev (arg :: args))) ] - ; [sprintf " OE_ADD_SIZE(%s, %s);" buffer size] - ; (let param_count = oe_get_param_count (ptype, decl, argstruct) in - flatten_map - (gen_add_size (arg :: args) param_count) - (get_deepcopy_members (get_param_atype ptype))) ] - |> List.flatten ) - in - let params = - flatten_map (gen_add_size [] "1") (List.filter predicate plist) - in - (* Note that the indentation for the first line is applied by the - parent function. *) - if params <> [] then String.concat "\n " params - else "/* There were no corresponding parameters. */" - in - let oe_compute_input_buffer_size = - oe_compute_buffer_size "_input_buffer_size" is_in_or_inout_ptr - in - let oe_compute_output_buffer_size = - oe_compute_buffer_size "_output_buffer_size" is_out_or_inout_ptr - in - let oe_serialize_buffer_inputs (plist : pdecl list) = - let rec gen_serialize args count (ptype, decl) = - let argstruct = oe_get_argstruct "_args." args count in - let size = oe_get_param_size (ptype, decl, argstruct) in - let arg = - match args with - | [] -> decl.identifier - | hd :: _ -> - hd ^ gen_c_deref (List.length args) count ^ decl.identifier - in - let tystr = get_cast_to_mem_expr (ptype, decl) false in - (* These need to be in order and so done together. *) - gen_c_for (List.length args) count - ( [ (* NOTE: This makes the embedded check in the `OE_` macro superfluous. *) - [ sprintf "if (%s)" - (String.concat " && " (List.rev (arg :: args))) ] - ; [ sprintf " OE_WRITE_%s_PARAM(%s, %s, %s);" - (if is_in_ptr ptype then "IN" else "IN_OUT") - arg size tystr ] - ; (let param_count = oe_get_param_count (ptype, decl, argstruct) in - flatten_map - (gen_serialize (arg :: args) param_count) - (get_deepcopy_members (get_param_atype ptype))) ] - |> List.flatten ) - in - let params = - flatten_map (gen_serialize [] "1") - (List.filter is_in_or_inout_ptr plist) - in - (* Note that the indentation for the first line is applied by the - parent function. *) - if params <> [] then String.concat "\n " params - else "/* There were no in nor in-out parameters. */" - in - [ "/* Compute input buffer size. Include in and in-out parameters. */" - ; sprintf "OE_ADD_SIZE(_input_buffer_size, sizeof(%s_args_t));" fd.fname - ; oe_compute_input_buffer_size fd.plist - ; "" - ; "/* Compute output buffer size. Include out and in-out parameters. */" - ; sprintf "OE_ADD_SIZE(_output_buffer_size, sizeof(%s_args_t));" fd.fname - ; oe_compute_output_buffer_size fd.plist - ; "" - ; "/* Allocate marshalling buffer. */" - ; "_total_buffer_size = _input_buffer_size;" - ; "OE_ADD_SIZE(_total_buffer_size, _output_buffer_size);" - ; sprintf "_buffer = (uint8_t*)%s(_total_buffer_size);" alloc_func - ; "_input_buffer = _buffer;" - ; "_output_buffer = _buffer + _input_buffer_size;" - ; "if (_buffer == NULL)" - ; "{" - ; " _result = OE_OUT_OF_MEMORY;" - ; " goto done;" - ; "}" - ; "" - ; "/* Serialize buffer inputs (in and in-out parameters). */" - ; sprintf "_pargs_in = (%s_args_t*)_input_buffer;" fd.fname - ; "OE_ADD_SIZE(_input_buffer_offset, sizeof(*_pargs_in));" - ; oe_serialize_buffer_inputs fd.plist - ; "" - ; "/* Copy args structure (now filled) to input buffer. */" - ; "memcpy(_pargs_in, &_args, sizeof(*_pargs_in));" ] - in - let gen_times count body = - (* The first two conditionals check for the multiplicative identity - and prevent unnecessary expressions from being generated. - Otherwise we multiply the sum of [body] by [count]. *) - if count = "1" || body = [] then body - else if List.length body = 1 && List.hd body = "1" then [count] - else [count ^ " * (" ^ String.concat " + " body ^ ")"] - in - let rec gen_ptr_count args count (ptype, decl) = - let id = decl.identifier in - (* TODO: The use of [gen_c_deref] does not work here as we are not - within a [gen_c_for] loop when producing the count. Therefore - arrays of structs which use members for the count of another - nested parameter are not yet supported. *) - let argstruct = oe_get_argstruct "" args count in - let arg = - match args with - | [] -> id - | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ id - in - let param_count = oe_get_param_count (ptype, decl, argstruct) in - let members = get_deepcopy_members (get_param_atype ptype) in - if is_marshalled_ptr ptype then - (* The base case is a marshalled pointer. We count 1 for every - one of these, except for the top-level pointers as they are - the original function arguments, and so do not need to be - saved/restored. - - For a marshalled pointer, we then need to recurse. If there - are no members to recurse on, then [members] is the empty - list and the recursion is a no-op, leaving us back at the - base case of counting 1. If there are members to recurse on, - then we count 1 plus the current [param_count] times the - number of members for each nested structure. *) - (if args <> [] then ["1"] else []) - @ gen_times param_count - (flatten_map (gen_ptr_count (arg :: args) param_count) members) - else [] - in - let gen_ptr_array (plist : pdecl list) = - let count = - flatten_map (gen_ptr_count [] "1") - (List.filter is_out_or_inout_ptr plist) - in - if count <> [] then - (* TODO: Switch to malloc() to handle variable lengths. *) - [ "size_t _ptrs_index = 0;" - ; sprintf "void** _ptrs = malloc(sizeof(void*) * (%s));" - (String.concat " + " count) - ; "if (_ptrs == NULL)" - ; "{" - ; " _result = OE_OUT_OF_MEMORY;" - ; " goto done;" - ; "}" ] - else ["/* No pointers to save for deep copy. */"] - in - let gen_reset_ptr_index (plist : pdecl list) = - let count = - flatten_map (gen_ptr_count [] "1") - (List.filter is_out_or_inout_ptr plist) - in - if count <> [] then "_ptrs_index = 0; /* For deep copy. */" - else "/* No pointers to restore for deep copy. */" - in - let gen_free_ptrs (plist : pdecl list) = - let count = - flatten_map (gen_ptr_count [] "1") - (List.filter is_out_or_inout_ptr plist) - in - if count <> [] then ["if (_ptrs)"; " free(_ptrs);"] - else ["/* No `_ptrs` to free for deep copy. */"] - in - let oe_process_output_buffer (fd : func_decl) = - let oe_serialize_buffer_outputs (plist : pdecl list) = - let rec gen_serialize args count (ptype, decl) = - let argstruct = oe_get_argstruct "_args." args count in - let size = oe_get_param_size (ptype, decl, argstruct) in - let arg = - match args with - | [] -> decl.identifier - | hd :: _ -> - hd ^ gen_c_deref (List.length args) count ^ decl.identifier - in - gen_c_for (List.length args) count - ( [ ( if is_str_or_wstr_ptr (ptype, decl) then - [ sprintf - "OE_CHECK_NULL_TERMINATOR%s(_output_buffer + \ - _output_buffer_offset, _args.%s_len);" - (if is_wstr_ptr ptype then "_WIDE" else "") - arg ] - else [] ) - ; (let s = - sprintf "OE_READ_%s_PARAM(%s, (size_t)(%s));" - (if is_out_ptr ptype then "OUT" else "IN_OUT") - arg size - in - match args with - | [] -> [s] - | _ -> - let tystr = get_cast_to_mem_expr (ptype, decl) true in - [ sprintf "if (%s)" (String.concat " && " (List.rev args)) - ; "{" - ; " /* Restore original pointer. */" - ; sprintf " %s = %s_ptrs[_ptrs_index++];" arg tystr - ; " " ^ s - ; "}" ]) - ; (let param_count = oe_get_param_count (ptype, decl, argstruct) in - flatten_map - (gen_serialize (arg :: args) param_count) - (get_deepcopy_members (get_param_atype ptype))) ] - |> List.flatten ) - in - let params = - flatten_map (gen_serialize [] "1") - (List.filter is_out_or_inout_ptr plist) - in - if params <> [] then String.concat "\n " params - else "/* There were no out nor in-out parameters. */" - in - [ (* Verify that the ecall succeeded *) - "/* Setup output arg struct pointer. */" - ; sprintf "_pargs_out = (%s_args_t*)_output_buffer;" fd.fname - ; "OE_ADD_SIZE(_output_buffer_offset, sizeof(*_pargs_out));" - ; "" - ; "/* Check if the call succeeded. */" - ; "if ((_result = _pargs_out->_result) != OE_OK)" - ; " goto done;" - ; "" - ; "/* Currently exactly _output_buffer_size bytes must be written. */" - ; "if (_output_bytes_written != _output_buffer_size)" - ; "{" - ; " _result = OE_FAILURE;" - ; " goto done;" - ; "}" - ; "" - ; "/* Unmarshal return value and out, in-out parameters. */" - ; ( if fd.rtype <> Void then "*_retval = _pargs_out->_retval;" - else "/* No return value. */" ) - ; gen_reset_ptr_index fd.plist - ; oe_serialize_buffer_outputs fd.plist ] - in - let rec oe_gen_set_pointers args count setter (ptype, decl) = - let argstruct = oe_get_argstruct "pargs_in->" args count in - let size = oe_get_param_size (ptype, decl, argstruct) in - let arg = - match args with - | [] -> decl.identifier - | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ decl.identifier - in - let tystr = get_cast_to_mem_expr (ptype, decl) false in - gen_c_for (List.length args) count - ( [ (* NOTE: This makes the embedded check in the `OE_` macro superfluous. *) - [ sprintf "if (pargs_in->%s)" - (String.concat " && pargs_in->" (List.rev (arg :: args))) ] - ; [ sprintf " OE_%s_POINTER(%s, %s, %s);" (setter ptype) arg size - tystr ] - ; (let param_count = oe_get_param_count (ptype, decl, argstruct) in - flatten_map - (oe_gen_set_pointers (arg :: args) param_count setter) - (get_deepcopy_members (get_param_atype ptype))) ] - |> List.flatten ) - in - let oe_gen_in_and_inout_setters (plist : pdecl list) = - let params = - flatten_map - (oe_gen_set_pointers [] "1" (fun p -> - (* TODO: Right now we assume all nested pointers should - be [SET_IN_OUT], since nested pointers don't actually - satisfy either [is_in_ptr] or [is_inout_ptr] - predicates. *) - if is_in_ptr p then "SET_IN" else "SET_IN_OUT" )) - (List.filter is_in_or_inout_ptr plist) - in - " " - ^ String.concat "\n " - [ "/* Set in and in-out pointers. */" - ; ( if params <> [] then String.concat "\n " params - else "/* There were no in nor in-out parameters. */" ) ] - in - let oe_gen_out_and_inout_setters (plist : pdecl list) = - let params = - flatten_map - (oe_gen_set_pointers [] "1" (fun p -> - (* TODO: Right now we assume all nested pointers should - be [COPY_AND_SET_IN_OUT], since nested pointers don't - actually satisfy either [is_out_ptr] or [is_inout_ptr] - predicates. *) - if is_out_ptr p then "SET_OUT" else "COPY_AND_SET_IN_OUT" )) - (List.filter is_out_or_inout_ptr plist) - in - " " - ^ String.concat "\n " - [ "/* Set out and in-out pointers. */" - ; "/* In-out parameters are copied to output buffer. */" - ; ( if params <> [] then String.concat "\n " params - else "/* There were no out nor in-out parameters. */" ) ] - in - (* Generate ecall function. *) - let oe_gen_ecall_function (tf : trusted_func) = - let fd = tf.tf_fdecl in - [ sprintf "void ecall_%s(" fd.fname - ; " uint8_t* input_buffer," - ; " size_t input_buffer_size," - ; " uint8_t* output_buffer," - ; " size_t output_buffer_size," - ; " size_t* output_bytes_written)" - ; "{" - ; (* Variable declarations *) - " oe_result_t _result = OE_FAILURE;" - ; "" - ; " /* Prepare parameters. */" - ; sprintf " %s_args_t* pargs_in = (%s_args_t*)input_buffer;" fd.fname - fd.fname - ; sprintf " %s_args_t* pargs_out = (%s_args_t*)output_buffer;" fd.fname - fd.fname - ; "" - ; " size_t input_buffer_offset = 0;" - ; " size_t output_buffer_offset = 0;" - ; " OE_ADD_SIZE(input_buffer_offset, sizeof(*pargs_in));" - ; " OE_ADD_SIZE(output_buffer_offset, sizeof(*pargs_out));" - ; "" - ; (* Buffer validation *) - " /* Make sure input and output buffers lie within the enclave. */" - ; " if (!input_buffer || !oe_is_within_enclave(input_buffer, \ - input_buffer_size))" - ; " goto done;" - ; "" - ; " if (!output_buffer || !oe_is_within_enclave(output_buffer, \ - output_buffer_size))" - ; " goto done;" - ; "" - ; (* Prepare in and in-out parameters *) - oe_gen_in_and_inout_setters fd.plist - ; "" - ; (* Prepare out and in-out parameters. The in-out parameter is - copied to output buffer. *) - oe_gen_out_and_inout_setters fd.plist - ; "" - ; " /* Check that in/in-out strings are null terminated. */" - (* NOTE: We do not support deep copy for strings, so there is not - (yet) anything to do here. *) - ; (let params = - List.map - (fun (ptype, decl) -> - sprintf - " OE_CHECK_NULL_TERMINATOR%s(pargs_in->%s, pargs_in->%s_len);" - (if is_wstr_ptr ptype then "_WIDE" else "") - decl.identifier decl.identifier ) - (List.filter - (fun p -> is_str_or_wstr_ptr p && is_in_or_inout_ptr p) - fd.plist) - in - if params <> [] then String.concat "\n" params - else " /* There were no in nor in-out string parameters. */") - ; "" - ; " /* lfence after checks. */" - ; " oe_lfence();" - ; "" - ; (* Call the enclave function *) - " " ^ String.concat "\n " (oe_gen_call_user_function fd) - ; "" - ; (* Mark call as success *) - " /* Success. */" - ; " _result = OE_OK;" - ; " *output_bytes_written = output_buffer_offset;" - ; "" - ; "done:" - ; " if (pargs_out && output_buffer_size >= sizeof(*pargs_out))" - ; " pargs_out->_result = _result;" - ; "}" - ; "" ] - in - let gen_fill_marshal_struct (fd : func_decl) = - (* Generate assignment argument to corresponding field in args. This - is necessary for all arguments, not just copy-as-value, because - they are used directly by later marshalling code. *) - let gen_assignment (ptype, decl) = - let arg = decl.identifier in - [ [ sprintf "_args.%s = %s%s;" arg - (get_cast_to_mem_expr (ptype, decl) true) - arg ] - ; (* for string parameter fill the len field *) - ( if is_str_ptr ptype then - [sprintf "_args.%s_len = (%s) ? (strlen(%s) + 1) : 0;" arg arg arg] - else if is_wstr_ptr ptype then - [sprintf "_args.%s_len = (%s) ? (wcslen(%s) + 1) : 0;" arg arg arg] - else [] ) ] - |> List.flatten - in - flatten_map gen_assignment fd.plist - @ - let rec gen_save_ptrs args count (ptype, decl) = - let id = decl.identifier in - let argstruct = oe_get_argstruct "_args." args count in - let arg = - match args with - | [] -> id - | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ id - in - gen_c_for (List.length args) count - ( [ ( if args <> [] then - [sprintf "if (%s)" (String.concat " && " (List.rev args))] - else [] ) - ; ( if args <> [] && is_marshalled_ptr ptype then - [" _ptrs[_ptrs_index++] = (void*)" ^ arg ^ ";"] - else [] ) - ; (let param_count = oe_get_param_count (ptype, decl, argstruct) in - flatten_map - (gen_save_ptrs (arg :: args) param_count) - (get_deepcopy_members (get_param_atype ptype))) ] - |> List.flatten ) - in - flatten_map (gen_save_ptrs [] "1") - (List.filter is_out_or_inout_ptr fd.plist) - in - (* Generate host ECALL wrapper function. *) - let oe_gen_host_ecall_wrapper (tf : trusted_func) = - let fd = tf.tf_fdecl in - let oe_ecall_function = - if tf.tf_is_switchless then "oe_switchless_call_enclave_function" - else "oe_call_enclave_function" - in - [ oe_gen_wrapper_prototype fd true - ; "{" - ; " oe_result_t _result = OE_FAILURE;" - ; "" - ; " /* Marshalling struct. */" - ; sprintf " %s_args_t _args, *_pargs_in = NULL, *_pargs_out = NULL;" - fd.fname - ; "" - ; " /* Marshalling buffer and sizes. */" - ; " size_t _input_buffer_size = 0;" - ; " size_t _output_buffer_size = 0;" - ; " size_t _total_buffer_size = 0;" - ; " uint8_t* _buffer = NULL;" - ; " uint8_t* _input_buffer = NULL;" - ; " uint8_t* _output_buffer = NULL;" - ; " size_t _input_buffer_offset = 0;" - ; " size_t _output_buffer_offset = 0;" - ; " size_t _output_bytes_written = 0;" - ; "" - ; " /* Deep copy buffer. */" - ; " " ^ String.concat "\n " (gen_ptr_array fd.plist) - ; "" - ; " /* Fill marshalling struct. */" - ; " memset(&_args, 0, sizeof(_args));" - ; " " ^ String.concat "\n " (gen_fill_marshal_struct fd) - ; "" - ; " " ^ String.concat "\n " (oe_prepare_input_buffer fd "malloc") - ; "" - ; " /* Call enclave function. */" - ; " if ((_result = " ^ oe_ecall_function ^ "(" - ; " " - ^ String.concat ",\n " - [ "enclave" - ; get_function_id fd - ; "_input_buffer" - ; "_input_buffer_size" - ; "_output_buffer" - ; "_output_buffer_size" - ; "&_output_bytes_written)) != OE_OK)" ] - ; " goto done;" - ; "" - ; " " ^ String.concat "\n " (oe_process_output_buffer fd) - ; "" - ; " _result = OE_OK;" - ; "" - ; "done:" - ; " if (_buffer)" - ; " free(_buffer);" - ; "" - ; " " ^ String.concat "\n " (gen_free_ptrs fd.plist) - ; "" - ; " return _result;" - ; "}" - ; "" ] - in - (* Generate enclave OCALL wrapper function. *) - let oe_gen_enclave_ocall_wrapper (uf : untrusted_func) = - let fd = uf.uf_fdecl in - let allocate_buffer, call_function, free_buffer = - if uf.uf_is_switchless then - ( "oe_allocate_switchless_ocall_buffer" - , "oe_switchless_call_host_function" - , "oe_free_switchless_ocall_buffer" ) - else - ( "oe_allocate_ocall_buffer" - , "oe_call_host_function" - , "oe_free_ocall_buffer" ) - in - [ oe_gen_wrapper_prototype fd false - ; "{" - ; " oe_result_t _result = OE_FAILURE;" - ; "" - ; " /* If the enclave is in crashing/crashed status, new OCALL should \ - fail" - ; " immediately. */" - ; " if (oe_get_enclave_status() != OE_OK)" - ; " return oe_get_enclave_status();" - ; "" - ; " /* Marshalling struct. */" - ; sprintf " %s_args_t _args, *_pargs_in = NULL, *_pargs_out = NULL;" - fd.fname - ; " " ^ String.concat "\n " (gen_ptr_array fd.plist) - ; "" - ; " /* Marshalling buffer and sizes. */" - ; " size_t _input_buffer_size = 0;" - ; " size_t _output_buffer_size = 0;" - ; " size_t _total_buffer_size = 0;" - ; " uint8_t* _buffer = NULL;" - ; " uint8_t* _input_buffer = NULL;" - ; " uint8_t* _output_buffer = NULL;" - ; " size_t _input_buffer_offset = 0;" - ; " size_t _output_buffer_offset = 0;" - ; " size_t _output_bytes_written = 0;" - ; "" - ; " /* Fill marshalling struct. */" - ; " memset(&_args, 0, sizeof(_args));" - ; " " ^ String.concat "\n " (gen_fill_marshal_struct fd) - ; "" - ; " " - ^ String.concat "\n " (oe_prepare_input_buffer fd allocate_buffer) - ; "" - ; " /* Call host function. */" - ; " if ((_result = " ^ call_function ^ "(" - ; " " - ^ String.concat ",\n " - [ get_function_id fd - ; "_input_buffer" - ; "_input_buffer_size" - ; "_output_buffer" - ; "_output_buffer_size" - ; "&_output_bytes_written)) != OE_OK)" ] - ; " goto done;" - ; "" - ; " " ^ String.concat "\n " (oe_process_output_buffer fd) - ; "" - ; " /* Retrieve propagated errno from OCALL. */" - ; ( if uf.uf_propagate_errno then " errno = _pargs_out->_ocall_errno;\n" - else sprintf " /* Errno propagation not enabled. */" ) - ; "" - ; " _result = OE_OK;" - ; "" - ; "done:" - ; " if (_buffer)" - ; " " ^ free_buffer ^ "(_buffer);" - ; " return _result;" - ; "}" - ; "" ] - in - (* Generate ocall function. *) - let oe_gen_ocall_function (uf : untrusted_func) = - let fd = uf.uf_fdecl in - [ sprintf "void ocall_%s(" fd.fname - ; " uint8_t* input_buffer," - ; " size_t input_buffer_size," - ; " uint8_t* output_buffer," - ; " size_t output_buffer_size," - ; " size_t* output_bytes_written)" - ; "{" - ; (* Variable declarations *) - " oe_result_t _result = OE_FAILURE;" - ; " OE_UNUSED(input_buffer_size);" - ; "" - ; " /* Prepare parameters. */" - ; sprintf " %s_args_t* pargs_in = (%s_args_t*)input_buffer;" fd.fname - fd.fname - ; sprintf " %s_args_t* pargs_out = (%s_args_t*)output_buffer;" fd.fname - fd.fname - ; "" - ; " size_t input_buffer_offset = 0;" - ; " size_t output_buffer_offset = 0;" - ; " OE_ADD_SIZE(input_buffer_offset, sizeof(*pargs_in));" - ; " OE_ADD_SIZE(output_buffer_offset, sizeof(*pargs_out));" - ; "" - ; (* Buffer validation *) - " /* Make sure input and output buffers are valid. */" - ; " if (!input_buffer || !output_buffer) {" - ; " _result = OE_INVALID_PARAMETER;" - ; " goto done;" - ; " }" - ; "" - ; (* Prepare in and in-out parameters *) - oe_gen_in_and_inout_setters fd.plist - ; "" - ; (* Prepare out and in-out parameters. The in-out parameter is copied to output buffer. *) - oe_gen_out_and_inout_setters fd.plist - ; "" - ; (* Call the host function *) - " " ^ String.concat "\n " (oe_gen_call_user_function fd) - ; "" - ; " /* Propagate errno back to enclave. */" - ; ( if uf.uf_propagate_errno then " pargs_out->_ocall_errno = errno;" - else " /* Errno propagation not enabled. */" ) - ; "" - ; (* Mark call as success *) - " /* Success. */" - ; " _result = OE_OK;" - ; " *output_bytes_written = output_buffer_offset;" - ; "" - ; "done:" - ; " if (pargs_out && output_buffer_size >= sizeof(*pargs_out))" - ; " pargs_out->_result = _result;" - ; "}" - ; "" ] - in - (* Includes are emitted in [args.h]. Imported functions have already - been brought into function lists. *) - let gen_t_h = - let oe_gen_tfunc_prototypes = - if tfs <> [] then - List.map (fun f -> sprintf "%s;" (oe_gen_prototype f.tf_fdecl)) tfs - else ["/* There were no ecalls. */"] - in - let oe_gen_ufunc_wrapper_prototypes = - if ufs <> [] then - List.map - (fun f -> sprintf "%s;" (oe_gen_wrapper_prototype f.uf_fdecl false)) - ufs - else ["/* There were no ocalls. */"] - in - let guard = "EDGER8R_" ^ String.uppercase ec.file_shortnm ^ "_T_H" in - [ "#ifndef " ^ guard - ; "#define " ^ guard - ; "" - ; "#include " - ; "" - ; sprintf "#include \"%s_args.h\"" ec.file_shortnm - ; "" - ; "OE_EXTERNC_BEGIN" - ; "" - ; "/**** ECALL prototypes. ****/" - ; String.concat "\n\n" oe_gen_tfunc_prototypes - ; "" - ; "/**** OCALL prototypes. ****/" - ; String.concat "\n\n" oe_gen_ufunc_wrapper_prototypes - ; "" - ; "OE_EXTERNC_END" - ; "" - ; "#endif // " ^ guard - ; "" ] - in - let gen_t_c = - let oe_gen_ecall_functions = - if tfs <> [] then flatten_map oe_gen_ecall_function tfs - else ["/* There were no ecalls. */"] - in - let oe_gen_ecall_table = - let table = "__oe_ecalls_table" in - if tfs <> [] then - [ sprintf "oe_ecall_func_t %s[] = {" table - ; " " - ^ String.concat ",\n " - (List.map - (fun f -> "(oe_ecall_func_t) ecall_" ^ f.tf_fdecl.fname) - tfs) - ; "};" - ; "" - ; sprintf "size_t %s_size = OE_COUNTOF(%s);" table table ] - else ["/* There were no ecalls. */"] - in - let oe_gen_enclave_ocall_wrappers = - if ufs <> [] then flatten_map oe_gen_enclave_ocall_wrapper ufs - else ["/* There were no ocalls. */"] - in - [ sprintf "#include \"%s_t.h\"" ec.file_shortnm - ; "" - ; "#include " - ; "" - ; "#include " - ; "#include " - ; "#include " - ; "" - ; "OE_EXTERNC_BEGIN" - ; "" - ; "/**** ECALL functions. ****/" - ; "" - ; String.concat "\n" oe_gen_ecall_functions - ; "/**** ECALL function table. ****/" - ; "" - ; String.concat "\n" oe_gen_ecall_table - ; "" - ; "/**** OCALL function wrappers. ****/" - ; "" - ; String.concat "\n" oe_gen_enclave_ocall_wrappers - ; "OE_EXTERNC_END" - ; "" ] - in - let gen_u_h = - let oe_gen_tfunc_wrapper_prototypes = - if tfs <> [] then - List.map (fun f -> oe_gen_wrapper_prototype f.tf_fdecl true ^ ";") tfs - else ["/* There were no ecalls. */"] - in - let oe_gen_ufunc_prototypes = - if ufs <> [] then - List.map (fun f -> oe_gen_prototype f.uf_fdecl ^ ";") ufs - else ["/* There were no ocalls. */"] - in - let guard = "EDGER8R_" ^ String.uppercase ec.file_shortnm ^ "_U_H" in - [ "#ifndef " ^ guard - ; "#define " ^ guard - ; "" - ; "#include " - ; "" - ; sprintf "#include \"%s_args.h\"" ec.file_shortnm - ; "" - ; "OE_EXTERNC_BEGIN" - ; "" - ; sprintf "oe_result_t oe_create_%s_enclave(" ec.enclave_name - ; " const char* path," - ; " oe_enclave_type_t type," - ; " uint32_t flags," - ; " const void* config," - ; " uint32_t config_size," - ; " oe_enclave_t** enclave);" - ; "" - ; "/**** ECALL prototypes. ****/" - ; String.concat "\n\n" oe_gen_tfunc_wrapper_prototypes - ; "" - ; "/**** OCALL prototypes. ****/" - ; String.concat "\n\n" oe_gen_ufunc_prototypes - ; "" - ; "OE_EXTERNC_END" - ; "" - ; "#endif // " ^ guard - ; "" ] - in - let gen_u_c = - let oe_gen_host_ecall_wrappers = - if tfs <> [] then flatten_map oe_gen_host_ecall_wrapper tfs - else ["/* There were no ecalls. */"] - in - let oe_gen_ocall_functions = - if ufs <> [] then flatten_map oe_gen_ocall_function ufs - else ["/* There were no ocalls. */"] - in - let oe_gen_ocall_table = - [ sprintf "static oe_ocall_func_t __%s_ocall_function_table[] = {" - ec.enclave_name - ; " " - ^ String.concat "\n " - (List.map - (fun f -> "(oe_ocall_func_t) ocall_" ^ f.uf_fdecl.fname ^ ",") - ufs) - ; " NULL" - ; "};" ] - in - [ sprintf "#include \"%s_u.h\"" ec.file_shortnm - ; "" - ; "#include " - ; "" - ; "#include " - ; "#include " - ; "#include " - ; "" - ; "OE_EXTERNC_BEGIN" - ; "" - ; "/**** ECALL function wrappers. ****/" - ; "" - ; String.concat "\n" oe_gen_host_ecall_wrappers - ; "/**** OCALL functions. ****/" - ; "" - ; String.concat "\n" oe_gen_ocall_functions - ; "/**** OCALL function table. ****/" - ; "" - ; String.concat "\n" oe_gen_ocall_table - ; "" - ; sprintf "oe_result_t oe_create_%s_enclave(" ec.enclave_name - ; " const char* path," - ; " oe_enclave_type_t type," - ; " uint32_t flags," - ; " const void* config," - ; " uint32_t config_size," - ; " oe_enclave_t** enclave)" - ; "{" - ; " return oe_create_enclave(" - ; " path," - ; " type," - ; " flags," - ; " config," - ; " config_size," - ; sprintf " __%s_ocall_function_table," ec.enclave_name - ; sprintf " %d," (List.length ufs) - ; " enclave);" - ; "}" - ; "" - ; "OE_EXTERNC_END" - ; "" ] - in - (* NOTE: The below code encapsulates all our file I/O. *) - let args_h = ec.file_shortnm ^ "_args.h" in - if ep.gen_trusted then ( - write_file oe_gen_args_header args_h ep.trusted_dir ; - write_file gen_t_h (ec.file_shortnm ^ "_t.h") ep.trusted_dir ; - if not ep.header_only then - write_file gen_t_c (ec.file_shortnm ^ "_t.c") ep.trusted_dir ) ; - if ep.gen_untrusted then ( - write_file oe_gen_args_header args_h ep.untrusted_dir ; - write_file gen_u_h (ec.file_shortnm ^ "_u.h") ep.untrusted_dir ; - if not ep.header_only then - write_file gen_u_c (ec.file_shortnm ^ "_u.c") ep.untrusted_dir ) ; - printf "Success.\n" - -(** Install the plugin. *) -let _ = - Printf.printf "Generating edge routines for the Open Enclave SDK.\n" ; - Plugin.instance.available <- true ; - Plugin.instance.gen_edge_routines <- gen_enclave_code diff --git a/tools/oeedger8r/README.md b/tools/oeedger8r/README.md index ff2a1a374c..1e2852829b 100644 --- a/tools/oeedger8r/README.md +++ b/tools/oeedger8r/README.md @@ -15,6 +15,16 @@ To build from source, please follow [Advanced Build Info](../../docs/GettingStartedDocs/Contributors/AdvancedBuildInfo.md). The `oeedger8r` is built by the CMake target `oeedger8r_target`. +The `oeedger8r` tool is written in OCaml, and builds using +[esy](https://esy.sh/). This is a tool that provides OCaml package management +and reproducible build environments. Instead of installing the native OCaml +tools, `esy` parses the `package.json` file to download and install the exact +OCaml dependencies (including the OCaml compilers and tools, and the `dune` +build system). Running just the command `esy` is equivalent to `esy install && +esy build` which installs the packages and kicks off the `dune` build, in the +correct environment (this is similar to tools like `pyenv`), and in a +cross-platform manner. + For more information on using writing EDL files and using this tool, please see [Edger8r Getting Started](../../docs/GettingStartedDocs/Edger8rGettingStarted.md). @@ -52,6 +62,10 @@ else ( defining the `enclave_content` record in `Ast.ml` and redefining it as an equivalent type in `CodeGen.ml`. +4. Dune build for the Intel sources. This required adding the prefix `Intel.` to + uses of types defined in the Intel sources in both `main.ml` and + `Emitter.ml`. + ### Edge Routine Emitter The edge routine emitter for Open Enclave is implemented in `Emitter.ml`. It @@ -61,10 +75,17 @@ improved plugin model as it is a copy of Intel's code. ### Best Practices -We use [ocamlformat](https://github.com/ocaml-ppx/ocamlformat) to format our -code (such as `Emitter.ml`, but not Intel's code). It is the final say in -formatting. This should be setup to run automatically in one's editor, as it has -not yet been setup in CI. +We use [ocamlformat v0.12](https://github.com/ocaml-ppx/ocamlformat) (bundled +via `esy`) to format our code (such as `Emitter.ml`, but not Intel's code). It +is the final say in formatting. The developer build (that is, just `esy build`, +not `esy build --release`) is setup to automatically run `ocamlformat` before +compiling, and if any changes are necessary it will update the files and then +exit with an error. Run the build a second time to complete the build with the +fixed files (and don't forget to commit them). + +> Note that because we copy the sources to the build directory for CMake, the +> CMake build uses `esy build --release` which does not run the formatter, as it +> would not make sense to do on copied files. We follow [OCamlverse Best Practices](https://ocamlverse.github.io/content/best_practices.html) (which includes using `ocamlformat`). diff --git a/tools/oeedger8r/dune-project b/tools/oeedger8r/dune-project new file mode 100644 index 0000000000..1c50ff9a28 --- /dev/null +++ b/tools/oeedger8r/dune-project @@ -0,0 +1,20 @@ +(lang dune 1.11) + +; Copyright (c) Open Enclave SDK contributors. +; Licensed under the MIT License. + +(name oeedger8r) +(license MIT) +(version 0.7.0) +(authors "Open Enclave SDK") +(maintainers "Open Enclave SDK") +(source (github openenclave/openenclave)) + +(using fmt 1.2) ; NOTE: Dune 2.0 will make this automatic. + +(package + (name oeedger8r) + (synopsis "An OCaml tool for processing Enclave Definition Language files") + (description "Generates edge routines from EDL files for the Open Enclave SDK") + (depends + (dune (>= 1.11)))) diff --git a/tools/oeedger8r/esy.lock/.gitattributes b/tools/oeedger8r/esy.lock/.gitattributes new file mode 100644 index 0000000000..25366aee7a --- /dev/null +++ b/tools/oeedger8r/esy.lock/.gitattributes @@ -0,0 +1,3 @@ + +# Set eol to LF so files aren't converted to CRLF-eol on Windows. +* text eol=lf diff --git a/tools/oeedger8r/esy.lock/.gitignore b/tools/oeedger8r/esy.lock/.gitignore new file mode 100644 index 0000000000..a221be227e --- /dev/null +++ b/tools/oeedger8r/esy.lock/.gitignore @@ -0,0 +1,3 @@ + +# Reset any possible .gitignore, we want all esy.lock to be un-ignored. +!* diff --git a/tools/oeedger8r/esy.lock/index.json b/tools/oeedger8r/esy.lock/index.json new file mode 100644 index 0000000000..37d4d7d2de --- /dev/null +++ b/tools/oeedger8r/esy.lock/index.json @@ -0,0 +1,885 @@ +{ + "checksum": "28ece31f2d1499e7e2f4bd8bb580fab1", + "root": "oeedger8r@link-dev:./package.json", + "node": { + "oeedger8r@link-dev:./package.json": { + "id": "oeedger8r@link-dev:./package.json", + "name": "oeedger8r", + "version": "link-dev:./package.json", + "source": { + "type": "link-dev", + "path": ".", + "manifest": "package.json" + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/ocamlformat@opam:0.12@35299172", + "@opam/merlin@opam:3.3.2@7a364181" + ] + }, + "ocaml@4.8.1000@d41d8cd9": { + "id": "ocaml@4.8.1000@d41d8cd9", + "name": "ocaml", + "version": "4.8.1000", + "source": { + "type": "install", + "source": [ + "archive:https://registry.npmjs.org/ocaml/-/ocaml-4.8.1000.tgz#sha1:abc435b5d4ddea2acba8b2df7efb81e2d1690db1" + ] + }, + "overrides": [], + "dependencies": [], + "devDependencies": [] + }, + "@opam/yojson@opam:1.7.0@7056d985": { + "id": "@opam/yojson@opam:1.7.0@7056d985", + "name": "@opam/yojson", + "version": "opam:1.7.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/b8/b89d39ca3f8c532abe5f547ad3b8f84d#md5:b89d39ca3f8c532abe5f547ad3b8f84d", + "archive:https://github.com/ocaml-community/yojson/releases/download/1.7.0/yojson-1.7.0.tbz#md5:b89d39ca3f8c532abe5f547ad3b8f84d" + ], + "opam": { + "name": "yojson", + "version": "1.7.0", + "path": "esy.lock/opam/yojson.1.7.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", + "@opam/dune@opam:1.11.4@21d66ccd", "@opam/cppo@opam:1.6.6@f4f83858", + "@opam/biniou@opam:1.2.1@d7570399", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", + "@opam/dune@opam:1.11.4@21d66ccd", "@opam/biniou@opam:1.2.1@d7570399" + ] + }, + "@opam/uutf@opam:1.0.2@4440868f": { + "id": "@opam/uutf@opam:1.0.2@4440868f", + "name": "@opam/uutf", + "version": "opam:1.0.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/a7/a7c542405a39630c689a82bd7ef2292c#md5:a7c542405a39630c689a82bd7ef2292c", + "archive:http://erratique.ch/software/uutf/releases/uutf-1.0.2.tbz#md5:a7c542405a39630c689a82bd7ef2292c" + ], + "opam": { + "name": "uutf", + "version": "1.0.2", + "path": "esy.lock/opam/uutf.1.0.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uchar@opam:0.0.2@c8218eea", + "@opam/topkg@opam:1.0.1@a42c631e", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uchar@opam:0.0.2@c8218eea" + ] + }, + "@opam/uuseg@opam:12.0.0@bf82c4c7": { + "id": "@opam/uuseg@opam:12.0.0@bf82c4c7", + "name": "@opam/uuseg", + "version": "opam:12.0.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/1d/1d4487ddf5154e3477e55021b978d58a#md5:1d4487ddf5154e3477e55021b978d58a", + "archive:https://erratique.ch/software/uuseg/releases/uuseg-12.0.0.tbz#md5:1d4487ddf5154e3477e55021b978d58a" + ], + "opam": { + "name": "uuseg", + "version": "12.0.0", + "path": "esy.lock/opam/uuseg.12.0.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", + "@opam/uucp@opam:12.0.0@b7d4c3df", "@opam/uchar@opam:0.0.2@c8218eea", + "@opam/topkg@opam:1.0.1@a42c631e", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uucp@opam:12.0.0@b7d4c3df", + "@opam/uchar@opam:0.0.2@c8218eea" + ] + }, + "@opam/uucp@opam:12.0.0@b7d4c3df": { + "id": "@opam/uucp@opam:12.0.0@b7d4c3df", + "name": "@opam/uucp", + "version": "opam:12.0.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/cf/cf210ed43375b7f882c0540874e2cb81#md5:cf210ed43375b7f882c0540874e2cb81", + "archive:https://erratique.ch/software/uucp/releases/uucp-12.0.0.tbz#md5:cf210ed43375b7f882c0540874e2cb81" + ], + "opam": { + "name": "uucp", + "version": "12.0.0", + "path": "esy.lock/opam/uucp.12.0.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", + "@opam/uchar@opam:0.0.2@c8218eea", "@opam/topkg@opam:1.0.1@a42c631e", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uchar@opam:0.0.2@c8218eea" + ] + }, + "@opam/uchar@opam:0.0.2@c8218eea": { + "id": "@opam/uchar@opam:0.0.2@c8218eea", + "name": "@opam/uchar", + "version": "opam:0.0.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/c9/c9ba2c738d264c420c642f7bb1cf4a36#md5:c9ba2c738d264c420c642f7bb1cf4a36", + "archive:https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz#md5:c9ba2c738d264c420c642f7bb1cf4a36" + ], + "opam": { + "name": "uchar", + "version": "0.0.2", + "path": "esy.lock/opam/uchar.0.0.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ] + }, + "@opam/tyxml@opam:4.3.0@c1da25f1": { + "id": "@opam/tyxml@opam:4.3.0@c1da25f1", + "name": "@opam/tyxml", + "version": "opam:4.3.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/fd/fd834a567f813bf447cab5f4c3a723e2#md5:fd834a567f813bf447cab5f4c3a723e2", + "archive:https://github.com/ocsigen/tyxml/releases/download/4.3.0/tyxml-4.3.0.tbz#md5:fd834a567f813bf447cab5f4c3a723e2" + ], + "opam": { + "name": "tyxml", + "version": "4.3.0", + "path": "esy.lock/opam/tyxml.4.3.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", + "@opam/seq@opam:base@d8d7de1d", "@opam/re@opam:1.9.0@d4d5e13d", + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", + "@opam/seq@opam:base@d8d7de1d", "@opam/re@opam:1.9.0@d4d5e13d", + "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/topkg@opam:1.0.1@a42c631e": { + "id": "@opam/topkg@opam:1.0.1@a42c631e", + "name": "@opam/topkg", + "version": "opam:1.0.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/16/16b90e066d8972a5ef59655e7c28b3e9#md5:16b90e066d8972a5ef59655e7c28b3e9", + "archive:http://erratique.ch/software/topkg/releases/topkg-1.0.1.tbz#md5:16b90e066d8972a5ef59655e7c28b3e9" + ], + "opam": { + "name": "topkg", + "version": "1.0.1", + "path": "esy.lock/opam/topkg.1.0.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/ocamlbuild@opam:0.14.0@6ac75d03" + ] + }, + "@opam/stdio@opam:v0.12.0@04b3b004": { + "id": "@opam/stdio@opam:v0.12.0@04b3b004", + "name": "@opam/stdio", + "version": "opam:v0.12.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/b2/b261ff2d5667fde960c95e50cff668da#md5:b261ff2d5667fde960c95e50cff668da", + "archive:https://ocaml.janestreet.com/ocaml-core/v0.12/files/stdio-v0.12.0.tar.gz#md5:b261ff2d5667fde960c95e50cff668da" + ], + "opam": { + "name": "stdio", + "version": "v0.12.0", + "path": "esy.lock/opam/stdio.v0.12.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/base@opam:v0.12.2@d687150c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/base@opam:v0.12.2@d687150c" + ] + }, + "@opam/sexplib0@opam:v0.12.0@e432406d": { + "id": "@opam/sexplib0@opam:v0.12.0@e432406d", + "name": "@opam/sexplib0", + "version": "opam:v0.12.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/24/2486a25d3a94da9a94acc018b5f09061#md5:2486a25d3a94da9a94acc018b5f09061", + "archive:https://ocaml.janestreet.com/ocaml-core/v0.12/files/sexplib0-v0.12.0.tar.gz#md5:2486a25d3a94da9a94acc018b5f09061" + ], + "opam": { + "name": "sexplib0", + "version": "v0.12.0", + "path": "esy.lock/opam/sexplib0.v0.12.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/seq@opam:base@d8d7de1d": { + "id": "@opam/seq@opam:base@d8d7de1d", + "name": "@opam/seq", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "seq", + "version": "base", + "path": "esy.lock/opam/seq.base" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ] + }, + "@opam/result@opam:1.4@dc720aef": { + "id": "@opam/result@opam:1.4@dc720aef", + "name": "@opam/result", + "version": "opam:1.4", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/d3/d3162dbc501a2af65c8c71e0866541da#md5:d3162dbc501a2af65c8c71e0866541da", + "archive:https://github.com/janestreet/result/archive/1.4.tar.gz#md5:d3162dbc501a2af65c8c71e0866541da" + ], + "opam": { + "name": "result", + "version": "1.4", + "path": "esy.lock/opam/result.1.4" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/re@opam:1.9.0@d4d5e13d": { + "id": "@opam/re@opam:1.9.0@d4d5e13d", + "name": "@opam/re", + "version": "opam:1.9.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/bd/bddaed4f386a22cace7850c9c7dac296#md5:bddaed4f386a22cace7850c9c7dac296", + "archive:https://github.com/ocaml/ocaml-re/releases/download/1.9.0/re-1.9.0.tbz#md5:bddaed4f386a22cace7850c9c7dac296" + ], + "opam": { + "name": "re", + "version": "1.9.0", + "path": "esy.lock/opam/re.1.9.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d", + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d", + "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/ppx_derivers@opam:1.2.1@ecf0aa45": { + "id": "@opam/ppx_derivers@opam:1.2.1@ecf0aa45", + "name": "@opam/ppx_derivers", + "version": "opam:1.2.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/5d/5dc2bf130c1db3c731fe0fffc5648b41#md5:5dc2bf130c1db3c731fe0fffc5648b41", + "archive:https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz#md5:5dc2bf130c1db3c731fe0fffc5648b41" + ], + "opam": { + "name": "ppx_derivers", + "version": "1.2.1", + "path": "esy.lock/opam/ppx_derivers.1.2.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/odoc@opam:1.4.2@6f058006": { + "id": "@opam/odoc@opam:1.4.2@6f058006", + "name": "@opam/odoc", + "version": "opam:1.4.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/d7/d75ce63539040cd199d22203d46fc5f3#md5:d75ce63539040cd199d22203d46fc5f3", + "archive:https://github.com/ocaml/odoc/archive/1.4.2.tar.gz#md5:d75ce63539040cd199d22203d46fc5f3" + ], + "opam": { + "name": "odoc", + "version": "1.4.2", + "path": "esy.lock/opam/odoc.1.4.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/tyxml@opam:4.3.0@c1da25f1", + "@opam/result@opam:1.4@dc720aef", "@opam/fpath@opam:0.7.2@45477b93", + "@opam/dune@opam:1.11.4@21d66ccd", "@opam/cppo@opam:1.6.6@f4f83858", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@opam/astring@opam:0.8.3@4e5e17d5", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/ocamlformat@opam:0.12@35299172": { + "id": "@opam/ocamlformat@opam:0.12@35299172", + "name": "@opam/ocamlformat", + "version": "opam:0.12", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/f2/f2b64ff7f5cb9b4e19c6fc4e3f0fbd1747ef09d24848238540e2c27652e928fe#sha256:f2b64ff7f5cb9b4e19c6fc4e3f0fbd1747ef09d24848238540e2c27652e928fe", + "archive:https://github.com/ocaml-ppx/ocamlformat/releases/download/0.12/ocamlformat-0.12.tbz#sha256:f2b64ff7f5cb9b4e19c6fc4e3f0fbd1747ef09d24848238540e2c27652e928fe" + ], + "opam": { + "name": "ocamlformat", + "version": "0.12", + "path": "esy.lock/opam/ocamlformat.0.12" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", + "@opam/uuseg@opam:12.0.0@bf82c4c7", + "@opam/stdio@opam:v0.12.0@04b3b004", "@opam/re@opam:1.9.0@d4d5e13d", + "@opam/odoc@opam:1.4.2@6f058006", + "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d", + "@opam/fpath@opam:0.7.2@45477b93", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@opam/base-unix@opam:base@87d0b2eb", + "@opam/base@opam:v0.12.2@d687150c", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/uutf@opam:1.0.2@4440868f", + "@opam/uuseg@opam:12.0.0@bf82c4c7", + "@opam/stdio@opam:v0.12.0@04b3b004", "@opam/re@opam:1.9.0@d4d5e13d", + "@opam/odoc@opam:1.4.2@6f058006", + "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d", + "@opam/fpath@opam:0.7.2@45477b93", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/cmdliner@opam:1.0.4@93208aac", + "@opam/base-unix@opam:base@87d0b2eb", + "@opam/base@opam:v0.12.2@d687150c" + ] + }, + "@opam/ocamlfind@opam:1.8.1@ff07b0f9": { + "id": "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "name": "@opam/ocamlfind", + "version": "opam:1.8.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/18/18ca650982c15536616dea0e422cbd8c#md5:18ca650982c15536616dea0e422cbd8c", + "archive:http://download2.camlcity.org/download/findlib-1.8.1.tar.gz#md5:18ca650982c15536616dea0e422cbd8c", + "archive:http://download.camlcity.org/download/findlib-1.8.1.tar.gz#md5:18ca650982c15536616dea0e422cbd8c" + ], + "opam": { + "name": "ocamlfind", + "version": "1.8.1", + "path": "esy.lock/opam/ocamlfind.1.8.1" + } + }, + "overrides": [ + { + "opamoverride": + "esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override" + } + ], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/conf-m4@opam:1@3b2b148a", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ] + }, + "@opam/ocamlbuild@opam:0.14.0@6ac75d03": { + "id": "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "name": "@opam/ocamlbuild", + "version": "opam:0.14.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/87/87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78#sha256:87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78", + "archive:https://github.com/ocaml/ocamlbuild/archive/0.14.0.tar.gz#sha256:87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78" + ], + "opam": { + "name": "ocamlbuild", + "version": "0.14.0", + "path": "esy.lock/opam/ocamlbuild.0.14.0" + } + }, + "overrides": [ + { + "opamoverride": + "esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override" + } + ], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ] + }, + "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d": { + "id": "@opam/ocaml-migrate-parsetree@opam:1.4.0@0c4ec62d", + "name": "@opam/ocaml-migrate-parsetree", + "version": "opam:1.4.0", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/23/231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8#sha256:231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8", + "archive:https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.4.0/ocaml-migrate-parsetree-v1.4.0.tbz#sha256:231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8" + ], + "opam": { + "name": "ocaml-migrate-parsetree", + "version": "1.4.0", + "path": "esy.lock/opam/ocaml-migrate-parsetree.1.4.0" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", + "@opam/ppx_derivers@opam:1.2.1@ecf0aa45", + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", + "@opam/ppx_derivers@opam:1.2.1@ecf0aa45", + "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/merlin@opam:3.3.2@7a364181": { + "id": "@opam/merlin@opam:3.3.2@7a364181", + "name": "@opam/merlin", + "version": "opam:3.3.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/1d/1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801#sha256:1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801", + "archive:https://github.com/ocaml/merlin/releases/download/v3.3.2/merlin-v3.3.2.tbz#sha256:1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801" + ], + "opam": { + "name": "merlin", + "version": "3.3.2", + "path": "esy.lock/opam/merlin.3.3.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/fpath@opam:0.7.2@45477b93": { + "id": "@opam/fpath@opam:0.7.2@45477b93", + "name": "@opam/fpath", + "version": "opam:0.7.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/52/52c7ecb0bf180088336f3c645875fa41#md5:52c7ecb0bf180088336f3c645875fa41", + "archive:http://erratique.ch/software/fpath/releases/fpath-0.7.2.tbz#md5:52c7ecb0bf180088336f3c645875fa41" + ], + "opam": { + "name": "fpath", + "version": "0.7.2", + "path": "esy.lock/opam/fpath.0.7.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/topkg@opam:1.0.1@a42c631e", + "@opam/result@opam:1.4@dc720aef", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@opam/astring@opam:0.8.3@4e5e17d5", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef", + "@opam/astring@opam:0.8.3@4e5e17d5" + ] + }, + "@opam/easy-format@opam:1.3.2@0484b3c4": { + "id": "@opam/easy-format@opam:1.3.2@0484b3c4", + "name": "@opam/easy-format", + "version": "opam:1.3.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/34/3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926#sha256:3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926", + "archive:https://github.com/mjambon/easy-format/releases/download/1.3.2/easy-format-1.3.2.tbz#sha256:3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926" + ], + "opam": { + "name": "easy-format", + "version": "1.3.2", + "path": "esy.lock/opam/easy-format.1.3.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/dune-configurator@opam:1.0.0@4873acd8": { + "id": "@opam/dune-configurator@opam:1.0.0@4873acd8", + "name": "@opam/dune-configurator", + "version": "opam:1.0.0", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "dune-configurator", + "version": "1.0.0", + "path": "esy.lock/opam/dune-configurator.1.0.0" + } + }, + "overrides": [], + "dependencies": [ + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "@opam/dune@opam:1.11.4@21d66ccd" ] + }, + "@opam/dune@opam:1.11.4@21d66ccd": { + "id": "@opam/dune@opam:1.11.4@21d66ccd", + "name": "@opam/dune", + "version": "opam:1.11.4", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/77/77cb5f483221b266ded2b85fc84173ae0089a25134a086be922e82c131456ce6#sha256:77cb5f483221b266ded2b85fc84173ae0089a25134a086be922e82c131456ce6", + "archive:https://github.com/ocaml/dune/releases/download/1.11.4/dune-build-info-1.11.4.tbz#sha256:77cb5f483221b266ded2b85fc84173ae0089a25134a086be922e82c131456ce6" + ], + "opam": { + "name": "dune", + "version": "1.11.4", + "path": "esy.lock/opam/dune.1.11.4" + } + }, + "overrides": [ + { + "opamoverride": + "esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override" + } + ], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb", + "@opam/base-threads@opam:base@36803084", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb", + "@opam/base-threads@opam:base@36803084" + ] + }, + "@opam/cppo@opam:1.6.6@f4f83858": { + "id": "@opam/cppo@opam:1.6.6@f4f83858", + "name": "@opam/cppo", + "version": "opam:1.6.6", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/e7/e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0#sha256:e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0", + "archive:https://github.com/ocaml-community/cppo/releases/download/v1.6.6/cppo-v1.6.6.tbz#sha256:e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0" + ], + "opam": { + "name": "cppo", + "version": "1.6.6", + "path": "esy.lock/opam/cppo.1.6.6" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/base-unix@opam:base@87d0b2eb", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:1.11.4@21d66ccd", + "@opam/base-unix@opam:base@87d0b2eb" + ] + }, + "@opam/conf-m4@opam:1@3b2b148a": { + "id": "@opam/conf-m4@opam:1@3b2b148a", + "name": "@opam/conf-m4", + "version": "opam:1", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "conf-m4", + "version": "1", + "path": "esy.lock/opam/conf-m4.1" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/cmdliner@opam:1.0.4@93208aac": { + "id": "@opam/cmdliner@opam:1.0.4@93208aac", + "name": "@opam/cmdliner", + "version": "opam:1.0.4", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/fe/fe2213d0bc63b1e10a2d0aa66d2fc8d9#md5:fe2213d0bc63b1e10a2d0aa66d2fc8d9", + "archive:http://erratique.ch/software/cmdliner/releases/cmdliner-1.0.4.tbz#md5:fe2213d0bc63b1e10a2d0aa66d2fc8d9" + ], + "opam": { + "name": "cmdliner", + "version": "1.0.4", + "path": "esy.lock/opam/cmdliner.1.0.4" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ] + }, + "@opam/biniou@opam:1.2.1@d7570399": { + "id": "@opam/biniou@opam:1.2.1@d7570399", + "name": "@opam/biniou", + "version": "opam:1.2.1", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/sha256/35/35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335#sha256:35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335", + "archive:https://github.com/mjambon/biniou/releases/download/1.2.1/biniou-1.2.1.tbz#sha256:35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335" + ], + "opam": { + "name": "biniou", + "version": "1.2.1", + "path": "esy.lock/opam/biniou.1.2.1" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4", + "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/base-unix@opam:base@87d0b2eb": { + "id": "@opam/base-unix@opam:base@87d0b2eb", + "name": "@opam/base-unix", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "base-unix", + "version": "base", + "path": "esy.lock/opam/base-unix.base" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/base-threads@opam:base@36803084": { + "id": "@opam/base-threads@opam:base@36803084", + "name": "@opam/base-threads", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "base-threads", + "version": "base", + "path": "esy.lock/opam/base-threads.base" + } + }, + "overrides": [], + "dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ], + "devDependencies": [] + }, + "@opam/base-bytes@opam:base@19d0c2ff": { + "id": "@opam/base-bytes@opam:base@19d0c2ff", + "name": "@opam/base-bytes", + "version": "opam:base", + "source": { + "type": "install", + "source": [ "no-source:" ], + "opam": { + "name": "base-bytes", + "version": "base", + "path": "esy.lock/opam/base-bytes.base" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/ocamlfind@opam:1.8.1@ff07b0f9" + ] + }, + "@opam/base@opam:v0.12.2@d687150c": { + "id": "@opam/base@opam:v0.12.2@d687150c", + "name": "@opam/base", + "version": "opam:v0.12.2", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/71/7150e848a730369a2549d01645fb6c72#md5:7150e848a730369a2549d01645fb6c72", + "archive:https://github.com/janestreet/base/archive/v0.12.2.tar.gz#md5:7150e848a730369a2549d01645fb6c72" + ], + "opam": { + "name": "base", + "version": "v0.12.2", + "path": "esy.lock/opam/base.v0.12.2" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/sexplib0@opam:v0.12.0@e432406d", + "@opam/dune-configurator@opam:1.0.0@4873acd8", + "@opam/dune@opam:1.11.4@21d66ccd", "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/sexplib0@opam:v0.12.0@e432406d", + "@opam/dune-configurator@opam:1.0.0@4873acd8", + "@opam/dune@opam:1.11.4@21d66ccd" + ] + }, + "@opam/astring@opam:0.8.3@4e5e17d5": { + "id": "@opam/astring@opam:0.8.3@4e5e17d5", + "name": "@opam/astring", + "version": "opam:0.8.3", + "source": { + "type": "install", + "source": [ + "archive:https://opam.ocaml.org/cache/md5/c5/c5bf6352b9ac27fbeab342740f4fa870#md5:c5bf6352b9ac27fbeab342740f4fa870", + "archive:http://erratique.ch/software/astring/releases/astring-0.8.3.tbz#md5:c5bf6352b9ac27fbeab342740f4fa870" + ], + "opam": { + "name": "astring", + "version": "0.8.3", + "path": "esy.lock/opam/astring.0.8.3" + } + }, + "overrides": [], + "dependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/topkg@opam:1.0.1@a42c631e", + "@opam/ocamlfind@opam:1.8.1@ff07b0f9", + "@opam/ocamlbuild@opam:0.14.0@6ac75d03", + "@opam/base-bytes@opam:base@19d0c2ff", + "@esy-ocaml/substs@0.0.1@d41d8cd9" + ], + "devDependencies": [ + "ocaml@4.8.1000@d41d8cd9", "@opam/base-bytes@opam:base@19d0c2ff" + ] + }, + "@esy-ocaml/substs@0.0.1@d41d8cd9": { + "id": "@esy-ocaml/substs@0.0.1@d41d8cd9", + "name": "@esy-ocaml/substs", + "version": "0.0.1", + "source": { + "type": "install", + "source": [ + "archive:https://registry.npmjs.org/@esy-ocaml/substs/-/substs-0.0.1.tgz#sha1:59ebdbbaedcda123fc7ed8fb2b302b7d819e9a46" + ] + }, + "overrides": [], + "dependencies": [], + "devDependencies": [] + } + } +} \ No newline at end of file diff --git a/tools/oeedger8r/esy.lock/opam/astring.0.8.3/opam b/tools/oeedger8r/esy.lock/opam/astring.0.8.3/opam new file mode 100644 index 0000000000..578ba1fae2 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/astring.0.8.3/opam @@ -0,0 +1,38 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "http://erratique.ch/software/astring" +doc: "http://erratique.ch/software/astring/doc" +dev-repo: "git+http://erratique.ch/repos/astring.git" +bug-reports: "https://github.com/dbuenzli/astring/issues" +tags: [ "string" "org:erratique" ] +license: "ISC" +depends: [ + "ocaml" {>= "4.01.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build} + "base-bytes" +] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--pinned" "%{pinned}%" ]] +synopsis: "Alternative String module for OCaml" +description: """ +Astring exposes an alternative `String` module for OCaml. This module +tries to balance minimality and expressiveness for basic, index-free, +string processing and provides types and functions for substrings, +string sets and string maps. + +Remaining compatible with the OCaml `String` module is a non-goal. The +`String` module exposed by Astring has exception safe functions, +removes deprecated and rarely used functions, alters some signatures +and names, adds a few missing functions and fully exploits OCaml's +newfound string immutability. + +Astring depends only on the OCaml standard library. It is distributed +under the ISC license.""" +url { + src: "http://erratique.ch/software/astring/releases/astring-0.8.3.tbz" + checksum: "md5=c5bf6352b9ac27fbeab342740f4fa870" +} diff --git a/tools/oeedger8r/esy.lock/opam/base-bytes.base/opam b/tools/oeedger8r/esy.lock/opam/base-bytes.base/opam new file mode 100644 index 0000000000..f1cae506c6 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/base-bytes.base/opam @@ -0,0 +1,9 @@ +opam-version: "2.0" +maintainer: " " +authors: " " +homepage: " " +depends: [ + "ocaml" {>= "4.02.0"} + "ocamlfind" {>= "1.5.3"} +] +synopsis: "Bytes library distributed with the OCaml compiler" diff --git a/tools/oeedger8r/esy.lock/opam/base-threads.base/opam b/tools/oeedger8r/esy.lock/opam/base-threads.base/opam new file mode 100644 index 0000000000..914ff50ceb --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/base-threads.base/opam @@ -0,0 +1,6 @@ +opam-version: "2.0" +maintainer: "https://github.com/ocaml/opam-repository/issues" +description: """ +Threads library distributed with the OCaml compiler +""" + diff --git a/tools/oeedger8r/esy.lock/opam/base-unix.base/opam b/tools/oeedger8r/esy.lock/opam/base-unix.base/opam new file mode 100644 index 0000000000..b973540bcb --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/base-unix.base/opam @@ -0,0 +1,6 @@ +opam-version: "2.0" +maintainer: "https://github.com/ocaml/opam-repository/issues" +description: """ +Unix library distributed with the OCaml compiler +""" + diff --git a/tools/oeedger8r/esy.lock/opam/base.v0.12.2/opam b/tools/oeedger8r/esy.lock/opam/base.v0.12.2/opam new file mode 100644 index 0000000000..861024cf57 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/base.v0.12.2/opam @@ -0,0 +1,39 @@ +opam-version: "2.0" +maintainer: "opensource@janestreet.com" +authors: ["Jane Street Group, LLC "] +homepage: "https://github.com/janestreet/base" +bug-reports: "https://github.com/janestreet/base/issues" +dev-repo: "git+https://github.com/janestreet/base.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/base/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.04.2" & < "4.10.0"} + "sexplib0" {>= "v0.12" & < "v0.13"} + "dune" {>= "1.5.1"} + "dune-configurator" +] +depopts: [ + "base-native-int63" +] +synopsis: "Full standard library replacement for OCaml" +description: " +Full standard library replacement for OCaml + +Base is a complete and portable alternative to the OCaml standard +library. It provides all standard functionalities one would expect +from a language standard library. It uses consistent conventions +across all of its module. + +Base aims to be usable in any context. As a result system dependent +features such as I/O are not offered by Base. They are instead +provided by companion libraries such as stdio: + + https://github.com/janestreet/stdio +" +url { + src: "https://github.com/janestreet/base/archive/v0.12.2.tar.gz" + checksum: "md5=7150e848a730369a2549d01645fb6c72" +} diff --git a/tools/oeedger8r/esy.lock/opam/biniou.1.2.1/opam b/tools/oeedger8r/esy.lock/opam/biniou.1.2.1/opam new file mode 100644 index 0000000000..b706b4251a --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/biniou.1.2.1/opam @@ -0,0 +1,45 @@ +opam-version: "2.0" +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "@doc"] {with-doc} +] +maintainer: ["martin@mjambon.com"] +authors: ["Martin Jambon"] +bug-reports: "https://github.com/mjambon/biniou/issues" +homepage: "https://github.com/mjambon/biniou" +doc: "https://mjambon.github.io/biniou/" +license: "BSD-3-Clause" +dev-repo: "git+https://github.com/mjambon/biniou.git" +synopsis: + "Binary data format designed for speed, safety, ease of use and backward compatibility as protocols evolve" +description: """ + +Biniou (pronounced "be new") is a binary data format designed for speed, safety, +ease of use and backward compatibility as protocols evolve. Biniou is vastly +equivalent to JSON in terms of functionality but allows implementations several +times faster (4 times faster than yojson), with 25-35% space savings. + +Biniou data can be decoded into human-readable form without knowledge of type +definitions except for field and variant names which are represented by 31-bit +hashes. A program named bdump is provided for routine visualization of biniou +data files. + +The program atdgen is used to derive OCaml-Biniou serializers and deserializers +from type definitions. + +Biniou format specification: mjambon.github.io/atdgen-doc/biniou-format.txt""" +depends: [ + "easy-format" + "dune" {>= "1.10"} + "ocaml" {>= "4.02.3"} +] +url { + src: + "https://github.com/mjambon/biniou/releases/download/1.2.1/biniou-1.2.1.tbz" + checksum: [ + "sha256=35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335" + "sha512=82670cc77bf3e869ee26e5fbe5a5affa45a22bc8b6c4bd7e85473912780e0111baca59b34a2c14feae3543ce6e239d7fddaeab24b686a65bfe642cdb91d27ebf" + ] +} diff --git a/tools/oeedger8r/esy.lock/opam/cmdliner.1.0.4/opam b/tools/oeedger8r/esy.lock/opam/cmdliner.1.0.4/opam new file mode 100644 index 0000000000..b2187dc5b6 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/cmdliner.1.0.4/opam @@ -0,0 +1,36 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "http://erratique.ch/software/cmdliner" +doc: "http://erratique.ch/software/cmdliner/doc/Cmdliner" +dev-repo: "git+http://erratique.ch/repos/cmdliner.git" +bug-reports: "https://github.com/dbuenzli/cmdliner/issues" +tags: [ "cli" "system" "declarative" "org:erratique" ] +license: "ISC" +depends:[ "ocaml" {>= "4.03.0"} ] +build: [[ make "all" "PREFIX=%{prefix}%" ]] +install: +[[make "install" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%" ] + [make "install-doc" "LIBDIR=%{_:lib}%" "DOCDIR=%{_:doc}%" ]] + +synopsis: """Declarative definition of command line interfaces for OCaml""" +description: """\ + +Cmdliner allows the declarative definition of command line interfaces +for OCaml. + +It provides a simple and compositional mechanism to convert command +line arguments to OCaml values and pass them to your functions. The +module automatically handles syntax errors, help messages and UNIX man +page generation. It supports programs with single or multiple commands +and respects most of the [POSIX][1] and [GNU][2] conventions. + +Cmdliner has no dependencies and is distributed under the ISC license. + +[1]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html +[2]: http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html +""" +url { +archive: "http://erratique.ch/software/cmdliner/releases/cmdliner-1.0.4.tbz" +checksum: "fe2213d0bc63b1e10a2d0aa66d2fc8d9" +} diff --git a/tools/oeedger8r/esy.lock/opam/conf-m4.1/opam b/tools/oeedger8r/esy.lock/opam/conf-m4.1/opam new file mode 100644 index 0000000000..c6feb2a746 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/conf-m4.1/opam @@ -0,0 +1,22 @@ +opam-version: "2.0" +maintainer: "tim@gfxmonk.net" +homepage: "http://www.gnu.org/software/m4/m4.html" +bug-reports: "https://github.com/ocaml/opam-repository/issues" +authors: "GNU Project" +license: "GPL-3.0-only" +build: [["sh" "-exc" "echo | m4"]] +depexts: [ + ["m4"] {os-family = "debian"} + ["m4"] {os-distribution = "fedora"} + ["m4"] {os-distribution = "rhel"} + ["m4"] {os-distribution = "centos"} + ["m4"] {os-distribution = "alpine"} + ["m4"] {os-distribution = "nixos"} + ["m4"] {os-family = "suse"} + ["m4"] {os-distribution = "ol"} + ["m4"] {os-distribution = "arch"} +] +synopsis: "Virtual package relying on m4" +description: + "This package can only install if the m4 binary is installed on the system." +flags: conf diff --git a/tools/oeedger8r/esy.lock/opam/cppo.1.6.6/opam b/tools/oeedger8r/esy.lock/opam/cppo.1.6.6/opam new file mode 100644 index 0000000000..f683f8b416 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/cppo.1.6.6/opam @@ -0,0 +1,37 @@ +opam-version: "2.0" +maintainer: "martin@mjambon.com" +authors: "Martin Jambon" +license: "BSD-3-Clause" +homepage: "http://mjambon.com/cppo.html" +doc: "https://ocaml-community.github.io/cppo/" +bug-reports: "https://github.com/ocaml-community/cppo/issues" +depends: [ + "ocaml" {>= "4.03"} + "dune" {>= "1.0"} + "base-unix" +] +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +dev-repo: "git+https://github.com/ocaml-community/cppo.git" +synopsis: "Code preprocessor like cpp for OCaml" +description: """ +Cppo is an equivalent of the C preprocessor for OCaml programs. +It allows the definition of simple macros and file inclusion. + +Cppo is: + +* more OCaml-friendly than cpp +* easy to learn without consulting a manual +* reasonably fast +* simple to install and to maintain +""" +url { + src: "https://github.com/ocaml-community/cppo/releases/download/v1.6.6/cppo-v1.6.6.tbz" + checksum: [ + "sha256=e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0" + "sha512=44ecf9d225d9e45490a2feac0bde04865ca398dba6c3579e3370fcd1ea255707b8883590852af8b2df87123801062b9f3acce2455c092deabf431f9c4fb8d8eb" + ] +} diff --git a/tools/oeedger8r/esy.lock/opam/dune-configurator.1.0.0/opam b/tools/oeedger8r/esy.lock/opam/dune-configurator.1.0.0/opam new file mode 100644 index 0000000000..6e2b712edc --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/dune-configurator.1.0.0/opam @@ -0,0 +1,9 @@ +opam-version: "2.0" +authors: ["Jérémie Dimino"] +homepage: "https://github.com/ocaml/dune" +bug-reports: "https://github.com/ocaml/dune/issues" +maintainer: "Jérémie Dimino" +description: """ +dune.configurator library distributed with Dune 1.x +""" +depends: ["dune" {<"2.0.0"}] diff --git a/tools/oeedger8r/esy.lock/opam/dune.1.11.4/opam b/tools/oeedger8r/esy.lock/opam/dune.1.11.4/opam new file mode 100644 index 0000000000..19e25117e2 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/dune.1.11.4/opam @@ -0,0 +1,53 @@ +opam-version: "2.0" +synopsis: "Fast, portable and opinionated build system" +description: """ + +dune is a build system that was designed to simplify the release of +Jane Street packages. It reads metadata from "dune" files following a +very simple s-expression syntax. + +dune is fast, it has very low-overhead and support parallel builds on +all platforms. It has no system dependencies, all you need to build +dune and packages using dune is OCaml. You don't need or make or bash +as long as the packages themselves don't use bash explicitly. + +dune supports multi-package development by simply dropping multiple +repositories into the same directory. + +It also supports multi-context builds, such as building against +several opam roots/switches simultaneously. This helps maintaining +packages across several versions of OCaml and gives cross-compilation +for free. +""" +maintainer: ["Jane Street Group, LLC "] +authors: ["Jane Street Group, LLC "] +license: "MIT" +homepage: "https://github.com/ocaml/dune" +doc: "https://dune.readthedocs.io/" +bug-reports: "https://github.com/ocaml/dune/issues" +depends: [ + "ocaml" {>= "4.02"} + "base-unix" + "base-threads" +] +conflicts: [ + "jbuilder" {!= "transition"} + "odoc" {< "1.3.0"} + "dune-release" {< "1.3.0"} +] +dev-repo: "git+https://github.com/ocaml/dune.git" +build: [ + # opam 2 sets OPAM_SWITCH_PREFIX, so we don't need a hardcoded path + ["ocaml" "configure.ml" "--libdir" lib] {opam-version < "2"} + ["ocaml" "bootstrap.ml"] + ["./boot.exe" "--release" "--subst"] {pinned} + ["./boot.exe" "--release" "-j" jobs] +] +url { + src: + "https://github.com/ocaml/dune/releases/download/1.11.4/dune-build-info-1.11.4.tbz" + checksum: [ + "sha256=77cb5f483221b266ded2b85fc84173ae0089a25134a086be922e82c131456ce6" + "sha512=02f00fd872aa49b832fc8c1e928409f23c79ddf84a53009a58875f222cca36fbb92c905e12c539caec9cbad723f195a8aa24218382dca35a903b3f52b11f06f2" + ] +} diff --git a/tools/oeedger8r/esy.lock/opam/easy-format.1.3.2/opam b/tools/oeedger8r/esy.lock/opam/easy-format.1.3.2/opam new file mode 100644 index 0000000000..138d0fb23e --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/easy-format.1.3.2/opam @@ -0,0 +1,46 @@ +opam-version: "2.0" +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "-p" name "@doc"] {with-doc} +] +maintainer: ["martin@mjambon.com" "rudi.grinberg@gmail.com"] +authors: ["Martin Jambon"] +bug-reports: "https://github.com/mjambon/easy-format/issues" +homepage: "https://github.com/mjambon/easy-format" +doc: "https://mjambon.github.io/easy-format/" +license: "BSD-3-Clause" +dev-repo: "git+https://github.com/mjambon/easy-format.git" +synopsis: + "High-level and functional interface to the Format module of the OCaml standard library" +description: """ + +This module offers a high-level and functional interface to the Format module of +the OCaml standard library. It is a pretty-printing facility, i.e. it takes as +input some code represented as a tree and formats this code into the most +visually satisfying result, breaking and indenting lines of code where +appropriate. + +Input data must be first modelled and converted into a tree using 3 kinds of +nodes: + +* atoms +* lists +* labelled nodes + +Atoms represent any text that is guaranteed to be printed as-is. Lists can model +any sequence of items such as arrays of data or lists of definitions that are +labelled with something like "int main", "let x =" or "x:".""" +depends: [ + "dune" {>= "1.10"} + "ocaml" {>= "4.02.3"} +] +url { + src: + "https://github.com/mjambon/easy-format/releases/download/1.3.2/easy-format-1.3.2.tbz" + checksum: [ + "sha256=3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926" + "sha512=e39377a2ff020ceb9ac29e8515a89d9bdbc91dfcfa871c4e3baafa56753fac2896768e5d9822a050dc1e2ade43c8967afb69391a386c0a8ecd4e1f774e236135" + ] +} diff --git a/tools/oeedger8r/esy.lock/opam/fpath.0.7.2/opam b/tools/oeedger8r/esy.lock/opam/fpath.0.7.2/opam new file mode 100644 index 0000000000..2613a6accb --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/fpath.0.7.2/opam @@ -0,0 +1,34 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "http://erratique.ch/software/fpath" +doc: "http://erratique.ch/software/fpath/doc" +dev-repo: "git+http://erratique.ch/repos/fpath.git" +bug-reports: "https://github.com/dbuenzli/fpath/issues" +tags: [ "file" "system" "path" "org:erratique" ] +license: "ISC" +depends: [ + "ocaml" {>= "4.01.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build & >= "0.9.0"} + "result" + "astring" +] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--dev-pkg" "%{pinned}%" ]] +synopsis: "File system paths for OCaml" +description: """ +Fpath is an OCaml module for handling file system paths with POSIX or +Windows conventions. Fpath processes paths without accessing the file +system and is independent from any system library. + +Fpath depends on [Astring][astring] and is distributed under the ISC +license. + +[astring]: http://erratique.ch/software/astring""" +url { + src: "http://erratique.ch/software/fpath/releases/fpath-0.7.2.tbz" + checksum: "md5=52c7ecb0bf180088336f3c645875fa41" +} diff --git a/tools/oeedger8r/esy.lock/opam/merlin.3.3.2/opam b/tools/oeedger8r/esy.lock/opam/merlin.3.3.2/opam new file mode 100644 index 0000000000..47fb8f5e00 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/merlin.3.3.2/opam @@ -0,0 +1,70 @@ +opam-version: "2.0" +name: "merlin" +maintainer: "defree@gmail.com" +authors: "The Merlin team" +homepage: "https://github.com/ocaml/merlin" +bug-reports: "https://github.com/ocaml/merlin/issues" +dev-repo: "git+https://github.com/ocaml/merlin.git" +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.02.1" & < "4.09"} + "dune" {>= "1.8.0"} + "ocamlfind" {>= "1.5.2"} + "yojson" + "mdx" {with-test & >= "1.3.0"} +] +synopsis: + "Editor helper, provides completion, typing and source browsing in Vim and Emacs" +description: + "Merlin is an assistant for editing OCaml code. It aims to provide the features available in modern IDEs: error reporting, auto completion, source browsing and much more." +post-messages: [ + "merlin installed. + +Quick setup for VIM +------------------- +Append this to your .vimrc to add merlin to vim's runtime-path: + let g:opamshare = substitute(system('opam config var share'),'\\n$','','''') + execute \"set rtp+=\" . g:opamshare . \"/merlin/vim\" + +Also run the following line in vim to index the documentation: + :execute \"helptags \" . g:opamshare . \"/merlin/vim/doc\" + +Quick setup for EMACS +------------------- +Add opam emacs directory to your load-path by appending this to your .emacs: + (let ((opam-share (ignore-errors (car (process-lines \"opam\" \"config\" \"var\" \"share\"))))) + (when (and opam-share (file-directory-p opam-share)) + ;; Register Merlin + (add-to-list 'load-path (expand-file-name \"emacs/site-lisp\" opam-share)) + (autoload 'merlin-mode \"merlin\" nil t nil) + ;; Automatically start it in OCaml buffers + (add-hook 'tuareg-mode-hook 'merlin-mode t) + (add-hook 'caml-mode-hook 'merlin-mode t) + ;; Use opam switch to lookup ocamlmerlin binary + (setq merlin-command 'opam))) + +Take a look at https://github.com/ocaml/merlin for more information + +Quick setup with opam-user-setup +-------------------------------- + +Opam-user-setup support Merlin. + + $ opam user-setup install + +should take care of basic setup. +See https://github.com/OCamlPro/opam-user-setup +" + {success & !user-setup:installed} +] +url { + src: + "https://github.com/ocaml/merlin/releases/download/v3.3.2/merlin-v3.3.2.tbz" + checksum: [ + "sha256=1d1c71e663b1e58acf19069cebd1e8d18f7dbe513c6065347d162cdd2c2de801" + "sha512=3ae021669808a40b4449f1cbdaca40b605ea5779a6204addd8b0ee4af9f14f528d55ca43a8dd3c7d547fb8e4cb256c09a9151d5559ef24dad83b5ab05aa146a2" + ] +} diff --git a/tools/oeedger8r/esy.lock/opam/ocaml-migrate-parsetree.1.4.0/opam b/tools/oeedger8r/esy.lock/opam/ocaml-migrate-parsetree.1.4.0/opam new file mode 100644 index 0000000000..66d40bacda --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ocaml-migrate-parsetree.1.4.0/opam @@ -0,0 +1,37 @@ +opam-version: "2.0" +maintainer: "frederic.bour@lakaban.net" +authors: [ + "Frédéric Bour " + "Jérémie Dimino " +] +license: "LGPL-2.1-only with OCaml-LGPL-linking-exception" +homepage: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree" +bug-reports: "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/issues" +dev-repo: "git+https://github.com/ocaml-ppx/ocaml-migrate-parsetree.git" +doc: "https://ocaml-ppx.github.io/ocaml-migrate-parsetree/" +tags: [ "syntax" "org:ocamllabs" ] +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "result" + "ppx_derivers" + "dune" {>= "1.9.0"} + "ocaml" {>= "4.02.3"} +] +synopsis: "Convert OCaml parsetrees between different versions" +description: """ +Convert OCaml parsetrees between different versions + +This library converts parsetrees, outcometree and ast mappers between +different OCaml versions. High-level functions help making PPX +rewriters independent of a compiler version. +""" +url { + src: + "https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.4.0/ocaml-migrate-parsetree-v1.4.0.tbz" + checksum: [ + "sha256=231fbdc205187b3ee266b535d9cfe44b599067b2f6e97883c782ea7bb577d3b8" + "sha512=61ee91d2d146cc2d2ff2d5dc4ef5dea4dc4d3c8dbd8b4c9586d64b6ad7302327ab35547aa0a5b0103c3f07b66b13d416a1bee6d4d117293cd3cabe44113ec6d4" + ] +} diff --git a/tools/oeedger8r/esy.lock/opam/ocamlbuild.0.14.0/opam b/tools/oeedger8r/esy.lock/opam/ocamlbuild.0.14.0/opam new file mode 100644 index 0000000000..8deabeedfb --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ocamlbuild.0.14.0/opam @@ -0,0 +1,36 @@ +opam-version: "2.0" +maintainer: "Gabriel Scherer " +authors: ["Nicolas Pouillard" "Berke Durak"] +homepage: "https://github.com/ocaml/ocamlbuild/" +bug-reports: "https://github.com/ocaml/ocamlbuild/issues" +license: "LGPL-2.1-only with OCaml-LGPL-linking-exception" +doc: "https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc" +dev-repo: "git+https://github.com/ocaml/ocamlbuild.git" +build: [ + [ + make + "-f" + "configure.make" + "all" + "OCAMLBUILD_PREFIX=%{prefix}%" + "OCAMLBUILD_BINDIR=%{bin}%" + "OCAMLBUILD_LIBDIR=%{lib}%" + "OCAMLBUILD_MANDIR=%{man}%" + "OCAML_NATIVE=%{ocaml:native}%" + "OCAML_NATIVE_TOOLS=%{ocaml:native}%" + ] + [make "check-if-preinstalled" "all" "opam-install"] +] +conflicts: [ + "base-ocamlbuild" + "ocamlfind" {< "1.6.2"} +] +synopsis: + "OCamlbuild is a build system with builtin rules to easily build most OCaml projects." +depends: [ + "ocaml" {>= "4.03"} +] +url { + src: "https://github.com/ocaml/ocamlbuild/archive/0.14.0.tar.gz" + checksum: "sha256=87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78" +} diff --git a/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/files/ocaml-stub b/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/files/ocaml-stub new file mode 100644 index 0000000000..e5ad9907e8 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/files/ocaml-stub @@ -0,0 +1,4 @@ +#!/bin/sh + +BINDIR=$(dirname "$(command -v ocamlc)") +"$BINDIR/ocaml" -I "$OCAML_TOPLEVEL_PATH" "$@" diff --git a/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/files/ocamlfind.install b/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/files/ocamlfind.install new file mode 100644 index 0000000000..295c62545f --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/files/ocamlfind.install @@ -0,0 +1,6 @@ +bin: [ + "src/findlib/ocamlfind" {"ocamlfind"} + "?src/findlib/ocamlfind_opt" {"ocamlfind"} + "?tools/safe_camlp4" +] +toplevel: ["src/findlib/topfind"] diff --git a/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/opam b/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/opam new file mode 100644 index 0000000000..d757d669ca --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ocamlfind.1.8.1/opam @@ -0,0 +1,50 @@ +opam-version: "2.0" +synopsis: "A library manager for OCaml" +maintainer: "Thomas Gazagnaire " +authors: "Gerd Stolpmann " +homepage: "http://projects.camlcity.org/projects/findlib.html" +bug-reports: "https://gitlab.camlcity.org/gerd/lib-findlib/issues" +dev-repo: "git+https://gitlab.camlcity.org/gerd/lib-findlib.git" +description: """ +Findlib is a library manager for OCaml. It provides a convention how +to store libraries, and a file format ("META") to describe the +properties of libraries. There is also a tool (ocamlfind) for +interpreting the META files, so that it is very easy to use libraries +in programs and scripts. +""" +build: [ + [ + "./configure" + "-bindir" + bin + "-sitelib" + lib + "-mandir" + man + "-config" + "%{lib}%/findlib.conf" + "-no-custom" + "-no-camlp4" {!ocaml:preinstalled & ocaml:version >= "4.02.0"} + "-no-topfind" {ocaml:preinstalled} + ] + [make "all"] + [make "opt"] {ocaml:native} +] +install: [ + [make "install"] + ["install" "-m" "0755" "ocaml-stub" "%{bin}%/ocaml"] {ocaml:preinstalled} +] +depends: [ + "ocaml" {>= "4.00.0"} + "conf-m4" {build} +] +extra-files: [ + ["ocamlfind.install" "md5=06f2c282ab52d93aa6adeeadd82a2543"] + ["ocaml-stub" "md5=181f259c9e0bad9ef523e7d4abfdf87a"] +] +url { + src: "http://download.camlcity.org/download/findlib-1.8.1.tar.gz" + checksum: "md5=18ca650982c15536616dea0e422cbd8c" + mirrors: "http://download2.camlcity.org/download/findlib-1.8.1.tar.gz" +} +depopts: ["graphics"] diff --git a/tools/oeedger8r/esy.lock/opam/ocamlformat.0.12/opam b/tools/oeedger8r/esy.lock/opam/ocamlformat.0.12/opam new file mode 100644 index 0000000000..00df987727 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ocamlformat.0.12/opam @@ -0,0 +1,35 @@ +opam-version: "2.0" +maintainer: "OCamlFormat Team " +authors: "Josh Berdine " +homepage: "https://github.com/ocaml-ppx/ocamlformat" +bug-reports: "https://github.com/ocaml-ppx/ocamlformat/issues" +dev-repo: "git+https://github.com/ocaml-ppx/ocamlformat.git" +url { + src: + "https://github.com/ocaml-ppx/ocamlformat/releases/download/0.12/ocamlformat-0.12.tbz" + checksum: [ + "sha256=f2b64ff7f5cb9b4e19c6fc4e3f0fbd1747ef09d24848238540e2c27652e928fe" + "sha512=1785ec8e7fe5d7f9f4bdd056be612e8ee170dcf4886bea0dde6f58602fa1729579d352e3a15df3229d124dac467b91f32ef900ff30e19a53c42feb1904c8a352" + ] +} +license: "MIT" +build: [ + ["ocaml" "tools/gen_version.mlt" "src/Version.ml" version] {pinned} + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.06"} + "base" {>= "v0.11.0" & < "v0.13"} + "base-unix" + "cmdliner" + "dune" {>= "1.11.1"} + "fpath" + "ocaml-migrate-parsetree" {>= "1.3.1"} + "odoc" {>= "1.4.2"} + "re" + "stdio" {< "v0.13"} + "uuseg" {>= "10.0.0"} + "uutf" {>= "1.0.1"} +] +synopsis: "Auto-formatter for OCaml code" +description: "OCamlFormat is a tool to automatically format OCaml code in a uniform style." diff --git a/tools/oeedger8r/esy.lock/opam/odoc.1.4.2/opam b/tools/oeedger8r/esy.lock/opam/odoc.1.4.2/opam new file mode 100644 index 0000000000..d34a983faf --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/odoc.1.4.2/opam @@ -0,0 +1,45 @@ +opam-version: "2.0" + +version: "1.4.2" +homepage: "http://github.com/ocaml/odoc" +doc: "https://github.com/ocaml/odoc#readme" +bug-reports: "https://github.com/ocaml/odoc/issues" +license: "ISC" + +authors: [ + "Thomas Refis " + "David Sheets " + "Leo White " +] +maintainer: "Anton Bachin " +dev-repo: "git+https://github.com/ocaml/odoc.git" + +synopsis: "OCaml documentation generator" + +depends: [ + "astring" {build} + "cmdliner" {build & >= "1.0.0"} + "cppo" {build} + "dune" + "fpath" {build} + "ocaml" {>= "4.02.0"} + "result" {build} + "tyxml" {build & >= "4.3.0"} + + "alcotest" {dev & >= "0.8.3"} + "markup" {dev & >= "0.8.0"} + "ocamlfind" {dev} + "sexplib" {dev & >= "113.33.00" & < "v0.13"} + + "bisect_ppx" {with-test & >= "1.3.0"} +] + +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] +] + +url { + src: "https://github.com/ocaml/odoc/archive/1.4.2.tar.gz" + checksum: "md5=d75ce63539040cd199d22203d46fc5f3" +} diff --git a/tools/oeedger8r/esy.lock/opam/ppx_derivers.1.2.1/opam b/tools/oeedger8r/esy.lock/opam/ppx_derivers.1.2.1/opam new file mode 100644 index 0000000000..3d10814e04 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/ppx_derivers.1.2.1/opam @@ -0,0 +1,23 @@ +opam-version: "2.0" +maintainer: "jeremie@dimino.org" +authors: ["Jérémie Dimino"] +license: "BSD-3-Clause" +homepage: "https://github.com/ocaml-ppx/ppx_derivers" +bug-reports: "https://github.com/ocaml-ppx/ppx_derivers/issues" +dev-repo: "git://github.com/ocaml-ppx/ppx_derivers.git" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" + "dune" +] +synopsis: "Shared [@@deriving] plugin registry" +description: """ +Ppx_derivers is a tiny package whose sole purpose is to allow +ppx_deriving and ppx_type_conv to inter-operate gracefully when linked +as part of the same ocaml-migrate-parsetree driver.""" +url { + src: "https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz" + checksum: "md5=5dc2bf130c1db3c731fe0fffc5648b41" +} diff --git a/tools/oeedger8r/esy.lock/opam/re.1.9.0/opam b/tools/oeedger8r/esy.lock/opam/re.1.9.0/opam new file mode 100644 index 0000000000..f7987544d1 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/re.1.9.0/opam @@ -0,0 +1,42 @@ +opam-version: "2.0" + +maintainer: "rudi.grinberg@gmail.com" +authors: [ + "Jerome Vouillon" + "Thomas Gazagnaire" + "Anil Madhavapeddy" + "Rudi Grinberg" + "Gabriel Radanne" +] +license: "LGPL-2.0-only with OCaml-LGPL-linking-exception" +homepage: "https://github.com/ocaml/ocaml-re" +bug-reports: "https://github.com/ocaml/ocaml-re/issues" +dev-repo: "git+https://github.com/ocaml/ocaml-re.git" + +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] + +depends: [ + "ocaml" {>= "4.02"} + "dune" + "ounit" {with-test} + "seq" +] + +synopsis: "RE is a regular expression library for OCaml" +description: """ +Pure OCaml regular expressions with: +* Perl-style regular expressions (module Re.Perl) +* Posix extended regular expressions (module Re.Posix) +* Emacs-style regular expressions (module Re.Emacs) +* Shell-style file globbing (module Re.Glob) +* Compatibility layer for OCaml's built-in Str module (module Re.Str) +""" +url { + src: + "https://github.com/ocaml/ocaml-re/releases/download/1.9.0/re-1.9.0.tbz" + checksum: "md5=bddaed4f386a22cace7850c9c7dac296" +} diff --git a/tools/oeedger8r/esy.lock/opam/result.1.4/opam b/tools/oeedger8r/esy.lock/opam/result.1.4/opam new file mode 100644 index 0000000000..b44aeead8b --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/result.1.4/opam @@ -0,0 +1,22 @@ +opam-version: "2.0" +maintainer: "opensource@janestreet.com" +authors: ["Jane Street Group, LLC "] +homepage: "https://github.com/janestreet/result" +dev-repo: "git+https://github.com/janestreet/result.git" +bug-reports: "https://github.com/janestreet/result/issues" +license: "BSD-3-Clause" +build: [["dune" "build" "-p" name "-j" jobs]] +depends: [ + "ocaml" + "dune" {>= "1.0"} +] +synopsis: "Compatibility Result module" +description: """ +Projects that want to use the new result type defined in OCaml >= 4.03 +while staying compatible with older version of OCaml should use the +Result module defined in this library.""" +url { + src: + "https://github.com/janestreet/result/archive/1.4.tar.gz" + checksum: "md5=d3162dbc501a2af65c8c71e0866541da" +} diff --git a/tools/oeedger8r/esy.lock/opam/seq.base/files/META.seq b/tools/oeedger8r/esy.lock/opam/seq.base/files/META.seq new file mode 100644 index 0000000000..06b95eff3f --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/seq.base/files/META.seq @@ -0,0 +1,4 @@ +name="seq" +version="[distributed with OCaml 4.07 or above]" +description="dummy backward-compatibility package for iterators" +requires="" diff --git a/tools/oeedger8r/esy.lock/opam/seq.base/files/seq.install b/tools/oeedger8r/esy.lock/opam/seq.base/files/seq.install new file mode 100644 index 0000000000..c4d70206e1 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/seq.base/files/seq.install @@ -0,0 +1,3 @@ +lib:[ + "META.seq" {"META"} +] diff --git a/tools/oeedger8r/esy.lock/opam/seq.base/opam b/tools/oeedger8r/esy.lock/opam/seq.base/opam new file mode 100644 index 0000000000..b33d8c7da1 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/seq.base/opam @@ -0,0 +1,15 @@ +opam-version: "2.0" +maintainer: " " +authors: " " +homepage: " " +depends: [ + "ocaml" {>= "4.07.0"} +] +dev-repo: "git+https://github.com/ocaml/ocaml.git" +bug-reports: "https://caml.inria.fr/mantis/main_page.php" +synopsis: + "Compatibility package for OCaml's standard iterator type starting from 4.07." +extra-files: [ + ["seq.install" "md5=026b31e1df290373198373d5aaa26e42"] + ["META.seq" "md5=b33c8a1a6c7ed797816ce27df4855107"] +] diff --git a/tools/oeedger8r/esy.lock/opam/sexplib0.v0.12.0/opam b/tools/oeedger8r/esy.lock/opam/sexplib0.v0.12.0/opam new file mode 100644 index 0000000000..9b45864bd4 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/sexplib0.v0.12.0/opam @@ -0,0 +1,26 @@ +opam-version: "2.0" +maintainer: "opensource@janestreet.com" +authors: ["Jane Street Group, LLC "] +homepage: "https://github.com/janestreet/sexplib0" +bug-reports: "https://github.com/janestreet/sexplib0/issues" +dev-repo: "git+https://github.com/janestreet/sexplib0.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/sexplib0/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.04.2"} + "dune" {>= "1.5.1"} +] +synopsis: "Library containing the definition of S-expressions and some base converters" +description: " +Part of Jane Street's Core library +The Core suite of libraries is an industrial strength alternative to +OCaml's standard library that was developed by Jane Street, the +largest industrial user of OCaml. +" +url { + src: "https://ocaml.janestreet.com/ocaml-core/v0.12/files/sexplib0-v0.12.0.tar.gz" + checksum: "md5=2486a25d3a94da9a94acc018b5f09061" +} diff --git a/tools/oeedger8r/esy.lock/opam/stdio.v0.12.0/opam b/tools/oeedger8r/esy.lock/opam/stdio.v0.12.0/opam new file mode 100644 index 0000000000..477c74579e --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/stdio.v0.12.0/opam @@ -0,0 +1,27 @@ +opam-version: "2.0" +maintainer: "opensource@janestreet.com" +authors: ["Jane Street Group, LLC "] +homepage: "https://github.com/janestreet/stdio" +bug-reports: "https://github.com/janestreet/stdio/issues" +dev-repo: "git+https://github.com/janestreet/stdio.git" +doc: "https://ocaml.janestreet.com/ocaml-core/latest/doc/stdio/index.html" +license: "MIT" +build: [ + ["dune" "build" "-p" name "-j" jobs] +] +depends: [ + "ocaml" {>= "4.04.2"} + "base" {>= "v0.12" & < "v0.13"} + "dune" {>= "1.5.1"} +] +synopsis: "Standard IO library for OCaml" +description: " +Stdio implements simple input/output functionalities for OCaml. + +It re-exports the input/output functions of the OCaml standard +libraries using a more consistent API. +" +url { + src: "https://ocaml.janestreet.com/ocaml-core/v0.12/files/stdio-v0.12.0.tar.gz" + checksum: "md5=b261ff2d5667fde960c95e50cff668da" +} diff --git a/tools/oeedger8r/esy.lock/opam/topkg.1.0.1/opam b/tools/oeedger8r/esy.lock/opam/topkg.1.0.1/opam new file mode 100644 index 0000000000..77ae1f42d5 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/topkg.1.0.1/opam @@ -0,0 +1,48 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "http://erratique.ch/software/topkg" +doc: "http://erratique.ch/software/topkg/doc" +license: "ISC" +dev-repo: "git+http://erratique.ch/repos/topkg.git" +bug-reports: "https://github.com/dbuenzli/topkg/issues" +tags: ["packaging" "ocamlbuild" "org:erratique"] +depends: [ + "ocaml" {>= "4.03.0"} + "ocamlfind" {build & >= "1.6.1"} + "ocamlbuild" ] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--pkg-name" name + "--dev-pkg" "%{pinned}%" ]] +synopsis: """The transitory OCaml software packager""" +description: """\ + +Topkg is a packager for distributing OCaml software. It provides an +API to describe the files a package installs in a given build +configuration and to specify information about the package's +distribution, creation and publication procedures. + +The optional topkg-care package provides the `topkg` command line tool +which helps with various aspects of a package's life cycle: creating +and linting a distribution, releasing it on the WWW, publish its +documentation, add it to the OCaml opam repository, etc. + +Topkg is distributed under the ISC license and has **no** +dependencies. This is what your packages will need as a *build* +dependency. + +Topkg-care is distributed under the ISC license it depends on +[fmt][fmt], [logs][logs], [bos][bos], [cmdliner][cmdliner], +[webbrowser][webbrowser] and `opam-format`. + +[fmt]: http://erratique.ch/software/fmt +[logs]: http://erratique.ch/software/logs +[bos]: http://erratique.ch/software/bos +[cmdliner]: http://erratique.ch/software/cmdliner +[webbrowser]: http://erratique.ch/software/webbrowser +""" +url { +archive: "http://erratique.ch/software/topkg/releases/topkg-1.0.1.tbz" +checksum: "16b90e066d8972a5ef59655e7c28b3e9" +} diff --git a/tools/oeedger8r/esy.lock/opam/tyxml.4.3.0/opam b/tools/oeedger8r/esy.lock/opam/tyxml.4.3.0/opam new file mode 100644 index 0000000000..93872f8b3c --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/tyxml.4.3.0/opam @@ -0,0 +1,45 @@ +opam-version: "2.0" +maintainer: "dev@ocsigen.org" +homepage: "https://github.com/ocsigen/tyxml/" +bug-reports: "https://github.com/ocsigen/tyxml/issues" +doc: "https://ocsigen.org/tyxml/manual/" +dev-repo: "git+https://github.com/ocsigen/tyxml.git" +license: "LGPL-2.1-only with OCaml-LGPL-linking-exception" + +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] + +depends: [ + "ocaml" {>= "4.02"} + "re" {>= "1.5.0"} + ("ocaml" {>= "4.07"} | "re" {>= "1.8.0"}) + "dune" + "alcotest" {with-test} + "seq" + "uutf" {>= "1.0.0"} +] + +synopsis:"TyXML is a library for building correct HTML and SVG documents" +description:""" +TyXML provides a set of convenient combinators that uses the OCaml +type system to ensure the validity of the generated documents. TyXML +can be used with any representation of HTML and SVG: the textual one, +provided directly by this package, or DOM trees (`js_of_ocaml-tyxml`) +virtual DOM (`virtual-dom`) and reactive or replicated trees +(`eliom`). You can also create your own representation and use it to +instantiate a new set of combinators. + +```ocaml +open Tyxml +let to_ocaml = Html.(a ~a:[a_href "ocaml.org"] [txt "OCaml!"]) +``` +""" +authors: "The ocsigen team" +url { + src: + "https://github.com/ocsigen/tyxml/releases/download/4.3.0/tyxml-4.3.0.tbz" + checksum: "md5=fd834a567f813bf447cab5f4c3a723e2" +} diff --git a/tools/oeedger8r/esy.lock/opam/uchar.0.0.2/opam b/tools/oeedger8r/esy.lock/opam/uchar.0.0.2/opam new file mode 100644 index 0000000000..428d7aa6f8 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/uchar.0.0.2/opam @@ -0,0 +1,36 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "http://ocaml.org" +doc: "https://ocaml.github.io/uchar/" +dev-repo: "git+https://github.com/ocaml/uchar.git" +bug-reports: "https://github.com/ocaml/uchar/issues" +tags: [ "text" "character" "unicode" "compatibility" "org:ocaml.org" ] +license: "typeof OCaml system" +depends: [ + "ocaml" {>= "3.12.0"} + "ocamlbuild" {build} +] +build: [ + ["ocaml" "pkg/git.ml"] + [ + "ocaml" + "pkg/build.ml" + "native=%{ocaml:native}%" + "native-dynlink=%{ocaml:native-dynlink}%" + ] +] +synopsis: "Compatibility library for OCaml's Uchar module" +description: """ +The `uchar` package provides a compatibility library for the +[`Uchar`][1] module introduced in OCaml 4.03. + +The `uchar` package is distributed under the license of the OCaml +compiler. See [LICENSE](LICENSE) for details. + +[1]: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Uchar.html""" +url { + src: + "https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz" + checksum: "md5=c9ba2c738d264c420c642f7bb1cf4a36" +} diff --git a/tools/oeedger8r/esy.lock/opam/uucp.12.0.0/opam b/tools/oeedger8r/esy.lock/opam/uucp.12.0.0/opam new file mode 100644 index 0000000000..18bf0a8410 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/uucp.12.0.0/opam @@ -0,0 +1,47 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: [ + "Daniel Bünzli " + "David Kaloper Meršinjak " +] +homepage: "https://erratique.ch/software/uucp" +doc: "https://erratique.ch/software/uucp/doc/Uucp" +dev-repo: "git+https://erratique.ch/repos/uucp.git" +bug-reports: "https://github.com/dbuenzli/uucp/issues" +tags: [ "unicode" "text" "character" "org:erratique" ] +license: "ISC" +depends: [ + "ocaml" {>= "4.01.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build} + "uchar" + "uucd" {with-test} # dev really + "uunf" {with-test} + "uutf" {with-test} + ] +depopts: [ "uunf" "uutf" "cmdliner" ] +conflicts: [ "uutf" {< "1.0.1"} + "cmdliner" {< "1.0.0"} ] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--dev-pkg" "%{pinned}%" + "--with-uutf" "%{uutf:installed}%" + "--with-uunf" "%{uunf:installed}%" + "--with-cmdliner" "%{cmdliner:installed}%" +]] +synopsis: """Unicode character properties for OCaml""" +description: """\ + +Uucp is an OCaml library providing efficient access to a selection of +character properties of the [Unicode character database][1]. + +Uucp is independent from any Unicode text data structure and has no +dependencies. It is distributed under the ISC license. + +[1]: http://www.unicode.org/reports/tr44/ +""" +url { +archive: "https://erratique.ch/software/uucp/releases/uucp-12.0.0.tbz" +checksum: "cf210ed43375b7f882c0540874e2cb81" +} diff --git a/tools/oeedger8r/esy.lock/opam/uuseg.12.0.0/opam b/tools/oeedger8r/esy.lock/opam/uuseg.12.0.0/opam new file mode 100644 index 0000000000..57dbdc65b1 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/uuseg.12.0.0/opam @@ -0,0 +1,50 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "https://erratique.ch/software/uuseg" +doc: "https://erratique.ch/software/uuseg" +dev-repo: "git+https://erratique.ch/repos/uuseg.git" +bug-reports: "https://github.com/dbuenzli/uuseg/issues" +tags: [ "segmentation" "text" "unicode" "org:erratique" ] +license: "ISC" +depends: [ "ocaml" {>= "4.01.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build} + "uchar" + "uucp" {>= "12.0.0" & < "13.0.0"} ] +depopts: [ "uutf" + "cmdliner" + "uutf" {with-test} + "cmdliner" {with-test} ] +conflicts: [ "uutf" {< "1.0.0"} ] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--pinned" "%{pinned}%" + "--with-uutf" "%{uutf:installed}%" + "--with-cmdliner" "%{cmdliner:installed}%" ]] + +synopsis: """Unicode text segmentation for OCaml""" +description: """\ + +Uuseg is an OCaml library for segmenting Unicode text. It implements +the locale independent [Unicode text segmentation algorithms][1] to +detect grapheme cluster, word and sentence boundaries and the +[Unicode line breaking algorithm][2] to detect line break +opportunities. + +The library is independent from any IO mechanism or Unicode text data +structure and it can process text without a complete in-memory +representation. + +Uuseg depends on [Uucp](http://erratique.ch/software/uucp) and +optionally on [Uutf](http://erratique.ch/software/uutf) for support on +OCaml UTF-X encoded strings. It is distributed under the ISC license. + +[1]: http://www.unicode.org/reports/tr29/ +[2]: http://www.unicode.org/reports/tr14/ +""" +url { +archive: "https://erratique.ch/software/uuseg/releases/uuseg-12.0.0.tbz" +checksum: "1d4487ddf5154e3477e55021b978d58a" +} diff --git a/tools/oeedger8r/esy.lock/opam/uutf.1.0.2/opam b/tools/oeedger8r/esy.lock/opam/uutf.1.0.2/opam new file mode 100644 index 0000000000..3a9f5678d2 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/uutf.1.0.2/opam @@ -0,0 +1,40 @@ +opam-version: "2.0" +maintainer: "Daniel Bünzli " +authors: ["Daniel Bünzli "] +homepage: "http://erratique.ch/software/uutf" +doc: "http://erratique.ch/software/uutf/doc/Uutf" +dev-repo: "git+http://erratique.ch/repos/uutf.git" +bug-reports: "https://github.com/dbuenzli/uutf/issues" +tags: [ "unicode" "text" "utf-8" "utf-16" "codec" "org:erratique" ] +license: "ISC" +depends: [ + "ocaml" {>= "4.01.0"} + "ocamlfind" {build} + "ocamlbuild" {build} + "topkg" {build} + "uchar" +] +depopts: ["cmdliner"] +conflicts: ["cmdliner" { < "0.9.6"} ] +build: [[ + "ocaml" "pkg/pkg.ml" "build" + "--pinned" "%{pinned}%" + "--with-cmdliner" "%{cmdliner:installed}%" ]] +synopsis: """Non-blocking streaming Unicode codec for OCaml""" +description: """\ + +Uutf is a non-blocking streaming codec to decode and encode the UTF-8, +UTF-16, UTF-16LE and UTF-16BE encoding schemes. It can efficiently +work character by character without blocking on IO. Decoders perform +character position tracking and support newline normalization. + +Functions are also provided to fold over the characters of UTF encoded +OCaml string values and to directly encode characters in OCaml +Buffer.t values. + +Uutf has no dependency and is distributed under the ISC license. +""" +url { +archive: "http://erratique.ch/software/uutf/releases/uutf-1.0.2.tbz" +checksum: "a7c542405a39630c689a82bd7ef2292c" +} diff --git a/tools/oeedger8r/esy.lock/opam/yojson.1.7.0/opam b/tools/oeedger8r/esy.lock/opam/yojson.1.7.0/opam new file mode 100644 index 0000000000..ffef0682a7 --- /dev/null +++ b/tools/oeedger8r/esy.lock/opam/yojson.1.7.0/opam @@ -0,0 +1,38 @@ +opam-version: "2.0" +maintainer: "martin@mjambon.com" +authors: ["Martin Jambon"] +homepage: "https://github.com/ocaml-community/yojson" +bug-reports: "https://github.com/ocaml-community/yojson/issues" +dev-repo: "git+https://github.com/ocaml-community/yojson.git" +doc: "https://ocaml-community.github.io/yojson/" +build: [ + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] +] +run-test: [["dune" "runtest" "-p" name "-j" jobs]] +depends: [ + "ocaml" {>= "4.02.3"} + "dune" + "cppo" {build} + "easy-format" + "biniou" {>= "1.2.0"} + "alcotest" {with-test & >= "0.8.5"} +] +synopsis: + "Yojson is an optimized parsing and printing library for the JSON format" +description: """ +Yojson is an optimized parsing and printing library for the JSON format. + +It addresses a few shortcomings of json-wheel including 2x speedup, +polymorphic variants and optional syntax for tuples and variants. + +ydump is a pretty-printing command-line program provided with the +yojson package. + +The program atdgen can be used to derive OCaml-JSON serializers and +deserializers from type definitions.""" +url { + src: + "https://github.com/ocaml-community/yojson/releases/download/1.7.0/yojson-1.7.0.tbz" + checksum: "md5=b89d39ca3f8c532abe5f547ad3b8f84d" +} diff --git a/tools/oeedger8r/esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override/package.json b/tools/oeedger8r/esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override/package.json new file mode 100644 index 0000000000..064c7e390d --- /dev/null +++ b/tools/oeedger8r/esy.lock/overrides/opam__s__dune_opam__c__1.11.4_opam_override/package.json @@ -0,0 +1,14 @@ +{ + "build": [ + [ + "ocaml", + "bootstrap.ml" + ], + [ + "./boot.exe", + "--release", + "-j", + "4" + ] + ] +} diff --git a/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch new file mode 100644 index 0000000000..4d5bea0e09 --- /dev/null +++ b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch @@ -0,0 +1,463 @@ +--- ./Makefile ++++ ./Makefile +@@ -213,7 +213,7 @@ + rm -f man/ocamlbuild.1 + + man/options_man.byte: src/ocamlbuild_pack.cmo +- $(OCAMLC) $^ -I src man/options_man.ml -o man/options_man.byte ++ $(OCAMLC) -I +unix unix.cma $^ -I src man/options_man.ml -o man/options_man.byte + + clean:: + rm -f man/options_man.cm* +--- ./src/command.ml ++++ ./src/command.ml +@@ -148,9 +148,10 @@ + let self = string_of_command_spec_with_calls call_with_tags call_with_target resolve_virtuals in + let b = Buffer.create 256 in + (* The best way to prevent bash from switching to its windows-style +- * quote-handling is to prepend an empty string before the command name. *) ++ * quote-handling is to prepend an empty string before the command name. ++ * space seems to work, too - and the ouput is nicer *) + if Sys.os_type = "Win32" then +- Buffer.add_string b "''"; ++ Buffer.add_char b ' '; + let first = ref true in + let put_space () = + if !first then +@@ -260,7 +261,7 @@ + + let execute_many ?(quiet=false) ?(pretend=false) cmds = + add_parallel_stat (List.length cmds); +- let degraded = !*My_unix.is_degraded || Sys.os_type = "Win32" in ++ let degraded = !*My_unix.is_degraded in + let jobs = !jobs in + if jobs < 0 then invalid_arg "jobs < 0"; + let max_jobs = if jobs = 0 then None else Some jobs in +--- ./src/findlib.ml ++++ ./src/findlib.ml +@@ -66,9 +66,6 @@ + (fun command -> lexer & Lexing.from_string & run_and_read command) + command + +-let run_and_read command = +- Printf.ksprintf run_and_read command +- + let rec query name = + try + Hashtbl.find packages name +@@ -135,7 +132,8 @@ + with Not_found -> s + + let list () = +- List.map before_space (split_nl & run_and_read "%s list" ocamlfind) ++ let cmd = Shell.quote_filename_if_needed ocamlfind ^ " list" in ++ List.map before_space (split_nl & run_and_read cmd) + + (* The closure algorithm is easy because the dependencies are already closed + and sorted for each package. We only have to make the union. We could also +--- ./src/main.ml ++++ ./src/main.ml +@@ -162,6 +162,9 @@ + Tags.mem "traverse" tags + || List.exists (Pathname.is_prefix path_name) !Options.include_dirs + || List.exists (Pathname.is_prefix path_name) target_dirs) ++ && ((* beware: !Options.build_dir is an absolute directory *) ++ Pathname.normalize !Options.build_dir ++ <> Pathname.normalize (Pathname.pwd/path_name)) + end + end + end +--- ./src/my_std.ml ++++ ./src/my_std.ml +@@ -271,13 +271,107 @@ + try Array.iter (fun x -> if x = basename then raise Exit) a; false + with Exit -> true + ++let command_plain = function ++| [| |] -> 0 ++| margv -> ++ let rec waitpid a b = ++ match Unix.waitpid a b with ++ | exception (Unix.Unix_error(Unix.EINTR,_,_)) -> waitpid a b ++ | x -> x ++ in ++ let pid = Unix.(create_process margv.(0) margv stdin stdout stderr) in ++ let pid', process_status = waitpid [] pid in ++ assert (pid = pid'); ++ match process_status with ++ | Unix.WEXITED n -> n ++ | Unix.WSIGNALED _ -> 2 (* like OCaml's uncaught exceptions *) ++ | Unix.WSTOPPED _ -> 127 ++ ++(* can't use Lexers because of circular dependency *) ++let split_path_win str = ++ let rec aux pos = ++ try ++ let i = String.index_from str pos ';' in ++ let len = i - pos in ++ if len = 0 then ++ aux (succ i) ++ else ++ String.sub str pos (i - pos) :: aux (succ i) ++ with Not_found | Invalid_argument _ -> ++ let len = String.length str - pos in ++ if len = 0 then [] else [String.sub str pos len] ++ in ++ aux 0 ++ ++let windows_shell = lazy begin ++ let rec iter = function ++ | [] -> [| "bash.exe" ; "--norc" ; "--noprofile" |] ++ | hd::tl -> ++ let dash = Filename.concat hd "dash.exe" in ++ if Sys.file_exists dash then [|dash|] else ++ let bash = Filename.concat hd "bash.exe" in ++ if Sys.file_exists bash = false then iter tl else ++ (* if sh.exe and bash.exe exist in the same dir, choose sh.exe *) ++ let sh = Filename.concat hd "sh.exe" in ++ if Sys.file_exists sh then [|sh|] else [|bash ; "--norc" ; "--noprofile"|] ++ in ++ split_path_win (try Sys.getenv "PATH" with Not_found -> "") |> iter ++end ++ ++let prep_windows_cmd cmd = ++ (* workaround known ocaml bug, remove later *) ++ if String.contains cmd '\t' && String.contains cmd ' ' = false then ++ " " ^ cmd ++ else ++ cmd ++ ++let run_with_shell = function ++| "" -> 0 ++| cmd -> ++ let cmd = prep_windows_cmd cmd in ++ let shell = Lazy.force windows_shell in ++ let qlen = Filename.quote cmd |> String.length in ++ (* old versions of dash had problems with bs *) ++ try ++ if qlen < 7_900 then ++ command_plain (Array.append shell [| "-ec" ; cmd |]) ++ else begin ++ (* it can still work, if the called command is a cygwin tool *) ++ let ch_closed = ref false in ++ let file_deleted = ref false in ++ let fln,ch = ++ Filename.open_temp_file ++ ~mode:[Open_binary] ++ "ocamlbuildtmp" ++ ".sh" ++ in ++ try ++ let f_slash = String.map ( fun x -> if x = '\\' then '/' else x ) fln in ++ output_string ch cmd; ++ ch_closed:= true; ++ close_out ch; ++ let ret = command_plain (Array.append shell [| "-e" ; f_slash |]) in ++ file_deleted:= true; ++ Sys.remove fln; ++ ret ++ with ++ | x -> ++ if !ch_closed = false then ++ close_out_noerr ch; ++ if !file_deleted = false then ++ (try Sys.remove fln with _ -> ()); ++ raise x ++ end ++ with ++ | (Unix.Unix_error _) as x -> ++ (* Sys.command doesn't raise an exception, so run_with_shell also won't ++ raise *) ++ Printexc.to_string x ^ ":" ^ cmd |> prerr_endline; ++ 1 ++ + let sys_command = +- match Sys.os_type with +- | "Win32" -> fun cmd -> +- if cmd = "" then 0 else +- let cmd = "bash --norc -c " ^ Filename.quote cmd in +- Sys.command cmd +- | _ -> fun cmd -> if cmd = "" then 0 else Sys.command cmd ++ if Sys.win32 then run_with_shell ++ else fun cmd -> if cmd = "" then 0 else Sys.command cmd + + (* FIXME warning fix and use Filename.concat *) + let filename_concat x y = +--- ./src/my_std.mli ++++ ./src/my_std.mli +@@ -69,3 +69,6 @@ + + val split_ocaml_version : (int * int * int * string) option + (** (major, minor, patchlevel, rest) *) ++ ++val windows_shell : string array Lazy.t ++val prep_windows_cmd : string -> string +--- ./src/ocamlbuild_executor.ml ++++ ./src/ocamlbuild_executor.ml +@@ -34,6 +34,8 @@ + job_stdin : out_channel; + job_stderr : in_channel; + job_buffer : Buffer.t; ++ job_pid : int; ++ job_tmp_file: string option; + mutable job_dying : bool; + };; + +@@ -76,6 +78,61 @@ + in + loop 0 + ;; ++ ++let open_process_full_win cmd env = ++ let (in_read, in_write) = Unix.pipe () in ++ let (out_read, out_write) = Unix.pipe () in ++ let (err_read, err_write) = Unix.pipe () in ++ Unix.set_close_on_exec in_read; ++ Unix.set_close_on_exec out_write; ++ Unix.set_close_on_exec err_read; ++ let inchan = Unix.in_channel_of_descr in_read in ++ let outchan = Unix.out_channel_of_descr out_write in ++ let errchan = Unix.in_channel_of_descr err_read in ++ let shell = Lazy.force Ocamlbuild_pack.My_std.windows_shell in ++ let test_cmd = ++ String.concat " " (List.map Filename.quote (Array.to_list shell)) ^ ++ "-ec " ^ ++ Filename.quote (Ocamlbuild_pack.My_std.prep_windows_cmd cmd) in ++ let argv,tmp_file = ++ if String.length test_cmd < 7_900 then ++ Array.append ++ shell ++ [| "-ec" ; Ocamlbuild_pack.My_std.prep_windows_cmd cmd |],None ++ else ++ let fln,ch = Filename.open_temp_file ~mode:[Open_binary] "ocamlbuild" ".sh" in ++ output_string ch (Ocamlbuild_pack.My_std.prep_windows_cmd cmd); ++ close_out ch; ++ let fln' = String.map (function '\\' -> '/' | c -> c) fln in ++ Array.append ++ shell ++ [| "-c" ; fln' |], Some fln in ++ let pid = ++ Unix.create_process_env argv.(0) argv env out_read in_write err_write in ++ Unix.close out_read; ++ Unix.close in_write; ++ Unix.close err_write; ++ (pid, inchan, outchan, errchan,tmp_file) ++ ++let close_process_full_win (pid,inchan, outchan, errchan, tmp_file) = ++ let delete tmp_file = ++ match tmp_file with ++ | None -> () ++ | Some x -> try Sys.remove x with Sys_error _ -> () in ++ let tmp_file_deleted = ref false in ++ try ++ close_in inchan; ++ close_out outchan; ++ close_in errchan; ++ let res = snd(Unix.waitpid [] pid) in ++ tmp_file_deleted := true; ++ delete tmp_file; ++ res ++ with ++ | x when tmp_file <> None && !tmp_file_deleted = false -> ++ delete tmp_file; ++ raise x ++ + (* ***) + (*** execute *) + (* XXX: Add test for non reentrancy *) +@@ -130,10 +187,16 @@ + (*** add_job *) + let add_job cmd rest result id = + (*display begin fun oc -> fp oc "Job %a is %s\n%!" print_job_id id cmd; end;*) +- let (stdout', stdin', stderr') = open_process_full cmd env in ++ let (pid,stdout', stdin', stderr', tmp_file) = ++ if Sys.win32 then open_process_full_win cmd env else ++ let a,b,c = open_process_full cmd env in ++ -1,a,b,c,None ++ in + incr jobs_active; +- set_nonblock (doi stdout'); +- set_nonblock (doi stderr'); ++ if not Sys.win32 then ( ++ set_nonblock (doi stdout'); ++ set_nonblock (doi stderr'); ++ ); + let job = + { job_id = id; + job_command = cmd; +@@ -143,7 +206,9 @@ + job_stdin = stdin'; + job_stderr = stderr'; + job_buffer = Buffer.create 1024; +- job_dying = false } ++ job_dying = false; ++ job_tmp_file = tmp_file; ++ job_pid = pid } + in + outputs := FDM.add (doi stdout') job (FDM.add (doi stderr') job !outputs); + jobs := JS.add job !jobs; +@@ -199,6 +264,7 @@ + try + read fd u 0 (Bytes.length u) + with ++ | Unix.Unix_error(Unix.EPIPE,_,_) when Sys.win32 -> 0 + | Unix.Unix_error(e,_,_) -> + let msg = error_message e in + display (fun oc -> fp oc +@@ -241,14 +307,19 @@ + decr jobs_active; + + (* PR#5371: we would get EAGAIN below otherwise *) +- clear_nonblock (doi job.job_stdout); +- clear_nonblock (doi job.job_stderr); +- ++ if not Sys.win32 then ( ++ clear_nonblock (doi job.job_stdout); ++ clear_nonblock (doi job.job_stderr); ++ ); + do_read ~loop:true (doi job.job_stdout) job; + do_read ~loop:true (doi job.job_stderr) job; + outputs := FDM.remove (doi job.job_stdout) (FDM.remove (doi job.job_stderr) !outputs); + jobs := JS.remove job !jobs; +- let status = close_process_full (job.job_stdout, job.job_stdin, job.job_stderr) in ++ let status = ++ if Sys.win32 then ++ close_process_full_win (job.job_pid, job.job_stdout, job.job_stdin, job.job_stderr, job.job_tmp_file) ++ else ++ close_process_full (job.job_stdout, job.job_stdin, job.job_stderr) in + + let shown = ref false in + +--- ./src/ocamlbuild_unix_plugin.ml ++++ ./src/ocamlbuild_unix_plugin.ml +@@ -48,12 +48,22 @@ + end + + let run_and_open s kont = ++ let s_orig = s in ++ let s = ++ (* Be consistent! My_unix.run_and_open uses My_std.sys_command and ++ sys_command uses bash. *) ++ if Sys.win32 = false then s else ++ let l = match Lazy.force My_std.windows_shell |> Array.to_list with ++ | hd::tl -> (Filename.quote hd)::tl ++ | _ -> assert false in ++ "\"" ^ (String.concat " " l) ^ " -ec " ^ Filename.quote (" " ^ s) ^ "\"" ++ in + let ic = Unix.open_process_in s in + let close () = + match Unix.close_process_in ic with + | Unix.WEXITED 0 -> () + | Unix.WEXITED _ | Unix.WSIGNALED _ | Unix.WSTOPPED _ -> +- failwith (Printf.sprintf "Error while running: %s" s) in ++ failwith (Printf.sprintf "Error while running: %s" s_orig) in + let res = try + kont ic + with e -> (close (); raise e) +--- ./src/options.ml ++++ ./src/options.ml +@@ -174,11 +174,24 @@ + build_dir := Filename.concat (Sys.getcwd ()) s + else + build_dir := s ++ ++let slashify = ++ if Sys.win32 then fun p -> String.map (function '\\' -> '/' | x -> x) p ++ else fun p ->p ++ ++let sb () = ++ match Sys.os_type with ++ | "Win32" -> ++ (try set_binary_mode_out stdout true with _ -> ()); ++ | _ -> () ++ ++ + let spec = ref ( + let print_version () = ++ sb (); + Printf.printf "ocamlbuild %s\n%!" Ocamlbuild_config.version; raise Exit_OK + in +- let print_vnum () = print_endline Ocamlbuild_config.version; raise Exit_OK in ++ let print_vnum () = sb (); print_endline Ocamlbuild_config.version; raise Exit_OK in + Arg.align + [ + "-version", Unit print_version , " Display the version"; +@@ -257,8 +270,8 @@ + "-build-dir", String set_build_dir, " Set build directory (implies no-links)"; + "-install-lib-dir", Set_string Ocamlbuild_where.libdir, " Set the install library directory"; + "-install-bin-dir", Set_string Ocamlbuild_where.bindir, " Set the install binary directory"; +- "-where", Unit (fun () -> print_endline !Ocamlbuild_where.libdir; raise Exit_OK), " Display the install library directory"; +- "-which", String (fun cmd -> print_endline (find_tool cmd); raise Exit_OK), " Display path to the tool command"; ++ "-where", Unit (fun () -> sb (); print_endline (slashify !Ocamlbuild_where.libdir); raise Exit_OK), " Display the install library directory"; ++ "-which", String (fun cmd -> sb (); print_endline (slashify (find_tool cmd)); raise Exit_OK), " Display path to the tool command"; + "-ocamlc", set_cmd ocamlc, " Set the OCaml bytecode compiler"; + "-plugin-ocamlc", set_cmd plugin_ocamlc, " Set the OCaml bytecode compiler \ + used when building myocamlbuild.ml (only)"; +--- ./src/pathname.ml ++++ ./src/pathname.ml +@@ -84,6 +84,26 @@ + | x :: xs -> x :: normalize_list xs + + let normalize x = ++ let x = ++ if Sys.win32 = false then ++ x ++ else ++ let len = String.length x in ++ let b = Bytes.create len in ++ for i = 0 to pred len do ++ match x.[i] with ++ | '\\' -> Bytes.set b i '/' ++ | c -> Bytes.set b i c ++ done; ++ if len > 1 then ( ++ let c1 = Bytes.get b 0 in ++ let c2 = Bytes.get b 1 in ++ if c2 = ':' && c1 >= 'a' && c1 <= 'z' && ++ ( len = 2 || Bytes.get b 2 = '/') then ++ Bytes.set b 0 (Char.uppercase_ascii c1) ++ ); ++ Bytes.unsafe_to_string b ++ in + if Glob.eval not_normal_form_re x then + let root, paths = split x in + join root (normalize_list paths) +--- ./src/shell.ml ++++ ./src/shell.ml +@@ -24,12 +24,26 @@ + | 'a'..'z' | 'A'..'Z' | '0'..'9' | '.' | '-' | '/' | '_' | ':' | '@' | '+' | ',' -> loop (pos + 1) + | _ -> false in + loop 0 ++ ++let generic_quote quotequote s = ++ let l = String.length s in ++ let b = Buffer.create (l + 20) in ++ Buffer.add_char b '\''; ++ for i = 0 to l - 1 do ++ if s.[i] = '\'' ++ then Buffer.add_string b quotequote ++ else Buffer.add_char b s.[i] ++ done; ++ Buffer.add_char b '\''; ++ Buffer.contents b ++let unix_quote = generic_quote "'\\''" ++ + let quote_filename_if_needed s = + if is_simple_filename s then s + (* We should probably be using [Filename.unix_quote] except that function + * isn't exported. Users on Windows will have to live with not being able to + * install OCaml into c:\o'caml. Too bad. *) +- else if Sys.os_type = "Win32" then Printf.sprintf "'%s'" s ++ else if Sys.os_type = "Win32" then unix_quote s + else Filename.quote s + let chdir dir = + reset_filesys_cache (); +@@ -37,7 +51,7 @@ + let run args target = + reset_readdir_cache (); + let cmd = String.concat " " (List.map quote_filename_if_needed args) in +- if !*My_unix.is_degraded || Sys.os_type = "Win32" then ++ if !*My_unix.is_degraded then + begin + Log.event cmd target Tags.empty; + let st = sys_command cmd in diff --git a/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json new file mode 100644 index 0000000000..b24be7b5bc --- /dev/null +++ b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json @@ -0,0 +1,27 @@ +{ + "build": [ + [ + "bash", + "-c", + "#{os == 'windows' ? 'patch -p1 < ocamlbuild-0.14.0.patch' : 'true'}" + ], + [ + "make", + "-f", + "configure.make", + "all", + "OCAMLBUILD_PREFIX=#{self.install}", + "OCAMLBUILD_BINDIR=#{self.bin}", + "OCAMLBUILD_LIBDIR=#{self.lib}", + "OCAMLBUILD_MANDIR=#{self.man}", + "OCAMLBUILD_NATIVE=true", + "OCAMLBUILD_NATIVE_TOOLS=true" + ], + [ + "make", + "check-if-preinstalled", + "all", + "#{os == 'windows' ? 'install' : 'opam-install'}" + ] + ] +} diff --git a/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/files/findlib-1.8.1.patch b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/files/findlib-1.8.1.patch new file mode 100644 index 0000000000..3e3ee5a24f --- /dev/null +++ b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/files/findlib-1.8.1.patch @@ -0,0 +1,471 @@ +--- ./Makefile ++++ ./Makefile +@@ -57,16 +57,16 @@ + cat findlib.conf.in | \ + $(SH) tools/patch '@SITELIB@' '$(OCAML_SITELIB)' >findlib.conf + if ./tools/cmd_from_same_dir ocamlc; then \ +- echo 'ocamlc="ocamlc.opt"' >>findlib.conf; \ ++ echo 'ocamlc="ocamlc.opt$(EXEC_SUFFIX)"' >>findlib.conf; \ + fi + if ./tools/cmd_from_same_dir ocamlopt; then \ +- echo 'ocamlopt="ocamlopt.opt"' >>findlib.conf; \ ++ echo 'ocamlopt="ocamlopt.opt$(EXEC_SUFFIX)"' >>findlib.conf; \ + fi + if ./tools/cmd_from_same_dir ocamldep; then \ +- echo 'ocamldep="ocamldep.opt"' >>findlib.conf; \ ++ echo 'ocamldep="ocamldep.opt$(EXEC_SUFFIX)"' >>findlib.conf; \ + fi + if ./tools/cmd_from_same_dir ocamldoc; then \ +- echo 'ocamldoc="ocamldoc.opt"' >>findlib.conf; \ ++ echo 'ocamldoc="ocamldoc.opt$(EXEC_SUFFIX)"' >>findlib.conf; \ + fi + + .PHONY: install-doc +--- ./src/findlib/findlib_config.mlp ++++ ./src/findlib/findlib_config.mlp +@@ -24,3 +24,5 @@ + | "MacOS" -> "" (* don't know *) + | _ -> failwith "Unknown Sys.os_type" + ;; ++ ++let exec_suffix = "@EXEC_SUFFIX@";; +--- ./src/findlib/findlib.ml ++++ ./src/findlib/findlib.ml +@@ -28,15 +28,20 @@ + let conf_ldconf = ref "";; + let conf_ignore_dups_in = ref ([] : string list);; + +-let ocamlc_default = "ocamlc";; +-let ocamlopt_default = "ocamlopt";; +-let ocamlcp_default = "ocamlcp";; +-let ocamloptp_default = "ocamloptp";; +-let ocamlmklib_default = "ocamlmklib";; +-let ocamlmktop_default = "ocamlmktop";; +-let ocamldep_default = "ocamldep";; +-let ocamlbrowser_default = "ocamlbrowser";; +-let ocamldoc_default = "ocamldoc";; ++let add_exec str = ++ match Findlib_config.exec_suffix with ++ | "" -> str ++ | a -> str ^ a ;; ++let ocamlc_default = add_exec "ocamlc";; ++let ocamlopt_default = add_exec "ocamlopt";; ++let ocamlcp_default = add_exec "ocamlcp";; ++let ocamloptp_default = add_exec "ocamloptp";; ++let ocamlmklib_default = add_exec "ocamlmklib";; ++let ocamlmktop_default = add_exec "ocamlmktop";; ++let ocamldep_default = add_exec "ocamldep";; ++let ocamlbrowser_default = add_exec "ocamlbrowser";; ++let ocamldoc_default = add_exec "ocamldoc";; ++ + + + let init_manually +--- ./src/findlib/fl_package_base.ml ++++ ./src/findlib/fl_package_base.ml +@@ -133,7 +133,15 @@ + List.find (fun def -> def.def_var = "exists_if") p.package_defs in + let files = Fl_split.in_words def.def_value in + List.exists +- (fun file -> Sys.file_exists (Filename.concat d' file)) ++ (fun file -> ++ let fln = Filename.concat d' file in ++ let e = Sys.file_exists fln in ++ (* necessary for ppx executables *) ++ if e || Sys.os_type <> "Win32" || Filename.check_suffix fln ".exe" then ++ e ++ else ++ Sys.file_exists (fln ^ ".exe") ++ ) + files + with Not_found -> true in + +--- ./src/findlib/fl_split.ml ++++ ./src/findlib/fl_split.ml +@@ -126,10 +126,17 @@ + | '/' | '\\' -> true + | _ -> false in + let norm_dir_win() = +- if l >= 1 && s.[0] = '/' then +- Buffer.add_char b '\\' else Buffer.add_char b s.[0]; +- if l >= 2 && s.[1] = '/' then +- Buffer.add_char b '\\' else Buffer.add_char b s.[1]; ++ if l >= 1 then ( ++ if s.[0] = '/' then ++ Buffer.add_char b '\\' ++ else ++ Buffer.add_char b s.[0] ; ++ if l >= 2 then ++ if s.[1] = '/' then ++ Buffer.add_char b '\\' ++ else ++ Buffer.add_char b s.[1]; ++ ); + for k = 2 to l - 1 do + let c = s.[k] in + if is_slash c then ( +--- ./src/findlib/frontend.ml ++++ ./src/findlib/frontend.ml +@@ -31,10 +31,18 @@ + else + Sys_error (arg ^ ": " ^ Unix.error_message code) + ++let is_win = Sys.os_type = "Win32" ++ ++let () = ++ match Findlib_config.system with ++ | "win32" | "win64" | "mingw" | "cygwin" | "mingw64" | "cygwin64" -> ++ (try set_binary_mode_out stdout true with _ -> ()); ++ (try set_binary_mode_out stderr true with _ -> ()); ++ | _ -> () + + let slashify s = + match Findlib_config.system with +- | "mingw" | "mingw64" | "cygwin" -> ++ | "win32" | "win64" | "mingw" | "cygwin" | "mingw64" | "cygwin64" -> + let b = Buffer.create 80 in + String.iter + (function +@@ -49,7 +57,7 @@ + + let out_path ?(prefix="") s = + match Findlib_config.system with +- | "mingw" | "mingw64" | "cygwin" -> ++ | "win32" | "win64" | "mingw" | "mingw64" | "cygwin" -> + let u = slashify s in + prefix ^ + (if String.contains u ' ' then +@@ -273,11 +281,9 @@ + + + let identify_dir d = +- match Sys.os_type with +- | "Win32" -> +- failwith "identify_dir" (* not available *) +- | _ -> +- let s = Unix.stat d in ++ if is_win then ++ failwith "identify_dir"; (* not available *) ++ let s = Unix.stat d in + (s.Unix.st_dev, s.Unix.st_ino) + ;; + +@@ -459,6 +465,96 @@ + ) + packages + ++let rewrite_cmd s = ++ if s = "" || not is_win then ++ s ++ else ++ let s = ++ let l = String.length s in ++ let b = Buffer.create l in ++ for i = 0 to pred l do ++ match s.[i] with ++ | '/' -> Buffer.add_char b '\\' ++ | x -> Buffer.add_char b x ++ done; ++ Buffer.contents b ++ in ++ if (Filename.is_implicit s && String.contains s '\\' = false) || ++ Filename.check_suffix (String.lowercase s) ".exe" then ++ s ++ else ++ let s' = s ^ ".exe" in ++ if Sys.file_exists s' then ++ s' ++ else ++ s ++ ++let rewrite_cmd s = ++ if s = "" || not is_win then s else ++ let s = ++ let l = String.length s in ++ let b = Buffer.create l in ++ for i = 0 to pred l do ++ match s.[i] with ++ | '/' -> Buffer.add_char b '\\' ++ | x -> Buffer.add_char b x ++ done; ++ Buffer.contents b ++ in ++ if (Filename.is_implicit s && String.contains s '\\' = false) || ++ Filename.check_suffix (String.lowercase s) ".exe" then ++ s ++ else ++ let s' = s ^ ".exe" in ++ if Sys.file_exists s' then ++ s' ++ else ++ s ++ ++let rewrite_pp cmd = ++ if not is_win then cmd else ++ let module T = struct exception Keep end in ++ let is_whitespace = function ++ | ' ' | '\011' | '\012' | '\n' | '\r' | '\t' -> true ++ | _ -> false in ++ (* characters that triggers special behaviour (cmd.exe, not unix shell) *) ++ let is_unsafe_char = function ++ | '(' | ')' | '%' | '!' | '^' | '<' | '>' | '&' -> true ++ | _ -> false in ++ let len = String.length cmd in ++ let buf = Buffer.create (len + 4) in ++ let buf_cmd = Buffer.create len in ++ let rec iter_ws i = ++ if i >= len then () else ++ let cur = cmd.[i] in ++ if is_whitespace cur then ( ++ Buffer.add_char buf cur; ++ iter_ws (succ i) ++ ) ++ else ++ iter_cmd i ++ and iter_cmd i = ++ if i >= len then add_buf_cmd () else ++ let cur = cmd.[i] in ++ if is_unsafe_char cur || cur = '"' || cur = '\'' then ++ raise T.Keep; ++ if is_whitespace cur then ( ++ add_buf_cmd (); ++ Buffer.add_substring buf cmd i (len - i) ++ ) ++ else ( ++ Buffer.add_char buf_cmd cur; ++ iter_cmd (succ i) ++ ) ++ and add_buf_cmd () = ++ if Buffer.length buf_cmd > 0 then ++ Buffer.add_string buf (rewrite_cmd (Buffer.contents buf_cmd)) ++ in ++ try ++ iter_ws 0; ++ Buffer.contents buf ++ with ++ | T.Keep -> cmd + + let process_pp_spec syntax_preds packages pp_opts = + (* Returns: pp_command *) +@@ -549,7 +645,7 @@ + None -> [] + | Some cmd -> + ["-pp"; +- cmd ^ " " ^ ++ (rewrite_cmd cmd) ^ " " ^ + String.concat " " (List.map Filename.quote pp_i_options) ^ " " ^ + String.concat " " (List.map Filename.quote pp_archives) ^ " " ^ + String.concat " " (List.map Filename.quote pp_opts)] +@@ -625,9 +721,11 @@ + in + try + let preprocessor = ++ rewrite_cmd ( + resolve_path + ~base ~explicit:true +- (package_property predicates pname "ppx") in ++ (package_property predicates pname "ppx") ) ++ in + ["-ppx"; String.concat " " (preprocessor :: options)] + with Not_found -> [] + ) +@@ -895,6 +993,14 @@ + switch (e.g. -L instead of -L ) + *) + ++(* We may need to remove files on which we do not have complete control. ++ On Windows, removing a read-only file fails so try to change the ++ mode of the file first. *) ++let remove_file fname = ++ try Sys.remove fname ++ with Sys_error _ when is_win -> ++ (try Unix.chmod fname 0o666 with Unix.Unix_error _ -> ()); ++ Sys.remove fname + + let ocamlc which () = + +@@ -1022,9 +1128,12 @@ + + "-intf", + Arg.String (fun s -> pass_files := !pass_files @ [ Intf(slashify s) ]); +- ++ + "-pp", +- Arg.String (fun s -> pp_specified := true; add_spec_fn "-pp" s); ++ Arg.String (fun s -> pp_specified := true; add_spec_fn "-pp" (rewrite_pp s)); ++ ++ "-ppx", ++ Arg.String (fun s -> add_spec_fn "-ppx" (rewrite_pp s)); + + "-thread", + Arg.Unit (fun _ -> threads := threads_default); +@@ -1237,7 +1346,7 @@ + with + any -> + close_out initl; +- Sys.remove initl_file_name; ++ remove_file initl_file_name; + raise any + end; + +@@ -1245,9 +1354,9 @@ + at_exit + (fun () -> + let tr f x = try f x with _ -> () in +- tr Sys.remove initl_file_name; +- tr Sys.remove (Filename.chop_extension initl_file_name ^ ".cmi"); +- tr Sys.remove (Filename.chop_extension initl_file_name ^ ".cmo"); ++ tr remove_file initl_file_name; ++ tr remove_file (Filename.chop_extension initl_file_name ^ ".cmi"); ++ tr remove_file (Filename.chop_extension initl_file_name ^ ".cmo"); + ); + + let exclude_list = [ stdlibdir; threads_dir; vmthreads_dir ] in +@@ -1493,7 +1602,9 @@ + [ "-v", Arg.Unit (fun () -> verbose := Verbose); + "-pp", Arg.String (fun s -> + pp_specified := true; +- options := !options @ ["-pp"; s]); ++ options := !options @ ["-pp"; rewrite_pp s]); ++ "-ppx", Arg.String (fun s -> ++ options := !options @ ["-ppx"; rewrite_pp s]); + ] + ) + ) +@@ -1672,7 +1783,9 @@ + Arg.String (fun s -> add_spec_fn "-I" (slashify (resolve_path s))); + + "-pp", Arg.String (fun s -> pp_specified := true; +- add_spec_fn "-pp" s); ++ add_spec_fn "-pp" (rewrite_pp s)); ++ "-ppx", Arg.String (fun s -> add_spec_fn "-ppx" (rewrite_pp s)); ++ + ] + ) + ) +@@ -1830,7 +1943,10 @@ + output_string ch_out append; + close_out ch_out; + close_in ch_in; +- Unix.utimes outpath s.Unix.st_mtime s.Unix.st_mtime; ++ (try Unix.utimes outpath s.Unix.st_mtime s.Unix.st_mtime ++ with Unix.Unix_error(e,_,_) -> ++ prerr_endline("Warning: setting utimes for " ^ outpath ++ ^ ": " ^ Unix.error_message e)); + + prerr_endline("Installed " ^ outpath); + with +@@ -1882,6 +1998,8 @@ + Unix.openfile (Filename.concat dir owner_file) [Unix.O_RDONLY] 0 in + let f = + Unix.in_channel_of_descr fd in ++ if is_win then ++ set_binary_mode_in f false; + try + let line = input_line f in + let is_my_file = (line = pkg) in +@@ -2208,7 +2326,7 @@ + let lines = read_ldconf !ldconf in + let dlldir_norm = Fl_split.norm_dir dlldir in + let dlldir_norm_lc = string_lowercase_ascii dlldir_norm in +- let ci_filesys = (Sys.os_type = "Win32") in ++ let ci_filesys = is_win in + let check_dir d = + let d' = Fl_split.norm_dir d in + (d' = dlldir_norm) || +@@ -2356,7 +2474,7 @@ + List.iter + (fun file -> + let absfile = Filename.concat dlldir file in +- Sys.remove absfile; ++ remove_file absfile; + prerr_endline ("Removed " ^ absfile) + ) + dll_files +@@ -2365,7 +2483,7 @@ + (* Remove the files from the package directory: *) + if Sys.file_exists pkgdir then begin + let files = Sys.readdir pkgdir in +- Array.iter (fun f -> Sys.remove (Filename.concat pkgdir f)) files; ++ Array.iter (fun f -> remove_file (Filename.concat pkgdir f)) files; + Unix.rmdir pkgdir; + prerr_endline ("Removed " ^ pkgdir) + end +@@ -2415,7 +2533,9 @@ + + + let print_configuration() = ++ let sl = slashify in + let dir s = ++ let s = sl s in + if Sys.file_exists s then + s + else +@@ -2453,27 +2573,27 @@ + if md = "" then "the corresponding package directories" else dir md + ); + Printf.printf "The standard library is assumed to reside in:\n %s\n" +- (Findlib.ocaml_stdlib()); ++ (sl (Findlib.ocaml_stdlib())); + Printf.printf "The ld.conf file can be found here:\n %s\n" +- (Findlib.ocaml_ldconf()); ++ (sl (Findlib.ocaml_ldconf())); + flush stdout + | Some "conf" -> +- print_endline (Findlib.config_file()) ++ print_endline (sl (Findlib.config_file())) + | Some "path" -> +- List.iter print_endline (Findlib.search_path()) ++ List.iter ( fun x -> print_endline (sl x)) (Findlib.search_path()) + | Some "destdir" -> +- print_endline (Findlib.default_location()) ++ print_endline ( sl (Findlib.default_location())) + | Some "metadir" -> +- print_endline (Findlib.meta_directory()) ++ print_endline ( sl (Findlib.meta_directory())) + | Some "metapath" -> + let mdir = Findlib.meta_directory() in + let ddir = Findlib.default_location() in +- print_endline +- (if mdir <> "" then mdir ^ "/META.%s" else ddir ^ "/%s/META") ++ print_endline ( sl ++ (if mdir <> "" then mdir ^ "/META.%s" else ddir ^ "/%s/META")) + | Some "stdlib" -> +- print_endline (Findlib.ocaml_stdlib()) ++ print_endline ( sl (Findlib.ocaml_stdlib())) + | Some "ldconf" -> +- print_endline (Findlib.ocaml_ldconf()) ++ print_endline ( sl (Findlib.ocaml_ldconf())) + | _ -> + assert false + ;; +@@ -2481,7 +2601,7 @@ + + let ocamlcall pkg cmd = + let dir = package_directory pkg in +- let path = Filename.concat dir cmd in ++ let path = rewrite_cmd (Filename.concat dir cmd) in + begin + try Unix.access path [ Unix.X_OK ] + with +@@ -2647,6 +2767,10 @@ + | Sys_error f -> + prerr_endline ("ocamlfind: " ^ f); + exit 2 ++ | Unix.Unix_error (e, fn, f) -> ++ prerr_endline ("ocamlfind: " ^ fn ^ " " ^ f ++ ^ ": " ^ Unix.error_message e); ++ exit 2 + | Findlib.No_such_package(pkg,info) -> + prerr_endline ("ocamlfind: Package `" ^ pkg ^ "' not found" ^ + (if info <> "" then " - " ^ info else "")); +--- ./src/findlib/Makefile ++++ ./src/findlib/Makefile +@@ -90,6 +90,7 @@ + cat findlib_config.mlp | \ + $(SH) $(TOP)/tools/patch '@CONFIGFILE@' '$(OCAMLFIND_CONF)' | \ + $(SH) $(TOP)/tools/patch '@STDLIB@' '$(OCAML_CORE_STDLIB)' | \ ++ $(SH) $(TOP)/tools/patch '@EXEC_SUFFIX@' '$(EXEC_SUFFIX)' | \ + sed -e 's;@AUTOLINK@;$(OCAML_AUTOLINK);g' \ + -e 's;@SYSTEM@;$(SYSTEM);g' \ + >findlib_config.ml diff --git a/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/package.json b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/package.json new file mode 100644 index 0000000000..9314f87088 --- /dev/null +++ b/tools/oeedger8r/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/package.json @@ -0,0 +1,61 @@ +{ + "build": [ + [ + "bash", + "-c", + "#{os == 'windows' ? 'patch -p1 < findlib-1.8.1.patch' : 'true'}" + ], + [ + "./configure", + "-bindir", + "#{self.bin}", + "-sitelib", + "#{self.lib}", + "-mandir", + "#{self.man}", + "-config", + "#{self.lib}/findlib.conf", + "-no-custom", + "-no-topfind" + ], + [ + "make", + "all" + ], + [ + "make", + "opt" + ] + ], + "install": [ + [ + "make", + "install" + ], + [ + "install", + "-m", + "0755", + "ocaml-stub", + "#{self.bin}/ocaml" + ], + [ + "mkdir", + "-p", + "#{self.toplevel}" + ], + [ + "install", + "-m", + "0644", + "src/findlib/topfind", + "#{self.toplevel}/topfind" + ] + ], + "exportedEnv": { + "OCAML_TOPLEVEL_PATH": { + "val": "#{self.toplevel}", + "scope": "global" + } + } +} diff --git a/tools/oeedger8r/intel/dune b/tools/oeedger8r/intel/dune new file mode 100644 index 0000000000..7c00ccb169 --- /dev/null +++ b/tools/oeedger8r/intel/dune @@ -0,0 +1,15 @@ +(library + (name intel) + (synopsis "Upstream Intel edger8r") + (libraries str unix)) + +(ocamllex Lexer) + +(ocamlyacc Parser) + +; TODO: Upstream code has a lot of warnings still. + +(env + (dev + (flags + (:standard -warn-error -A)))) diff --git a/tools/oeedger8r/package.json b/tools/oeedger8r/package.json new file mode 100644 index 0000000000..a3cc0f43bd --- /dev/null +++ b/tools/oeedger8r/package.json @@ -0,0 +1,34 @@ +{ + "name": "oeedger8r", + "version": "0.7.0", + "description": "The Open Enclave SDK's oeedger8r", + "license": "MIT", + + "esy": { + "build": [ + "dune build -p #{self.name}" + ], + "buildDev": [ + "dune build -p #{self.name} @fmt --auto-promote", + "dune build -p #{self.name}" + ], + "buildsInSource": "_build", + "release": { + "bin": "oeedger8r", + "includePackages": [ + "root" + ] + } + }, + + "dependencies": { + "@opam/dune": "~1.11.3", + "ocaml": "~4.8.0" + }, + + "devDependencies": { + "@opam/merlin": "~3.3.2", + "@opam/ocamlformat": "0.12", + "ocaml": "~4.8.0" + } +} diff --git a/tools/oeedger8r/src/.ocamlformat b/tools/oeedger8r/src/.ocamlformat new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tools/oeedger8r/src/.ocamlformat-ignore b/tools/oeedger8r/src/.ocamlformat-ignore new file mode 100644 index 0000000000..d389d15661 --- /dev/null +++ b/tools/oeedger8r/src/.ocamlformat-ignore @@ -0,0 +1 @@ +main.ml diff --git a/tools/oeedger8r/src/Common.ml b/tools/oeedger8r/src/Common.ml new file mode 100644 index 0000000000..f1b867b745 --- /dev/null +++ b/tools/oeedger8r/src/Common.ml @@ -0,0 +1,101 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +open Intel.Ast +open Printf + +(** ----- Begin code borrowed and tweaked from {!CodeGen.ml}. ----- *) + +let is_foreign_array = function + | PTVal _ -> false + | PTPtr (t, a) -> ( match t with Foreign _ -> a.pa_isary | _ -> false ) + +(** Get the array declaration from a list of array dimensions. Empty + [ns] indicates the corresponding declarator is a simple identifier. + Element of value -1 means that user does not specify the dimension + size. *) +let get_array_dims (ns : int list) = + let get_dim n = if n = -1 then "[]" else sprintf "[%d]" n in + String.concat "" (List.map get_dim ns) + +let get_typed_declr_str (ty : atype) (declr : declarator) = + let tystr = get_tystr ty in + let dmstr = get_array_dims declr.array_dims in + sprintf "%s %s%s" tystr declr.identifier dmstr + +(** Check whether given parameter [pt] is [const] specified. *) +let is_const_ptr (pt : parameter_type) = + let aty = get_param_atype pt in + match pt with + | PTVal _ -> false + | PTPtr (_, pa) -> ( + if not pa.pa_rdonly then false + else match aty with Foreign _ -> false | _ -> true ) + +(** Generate parameter [p] representation. *) +let get_parameter_str (p : pdecl) = + let pt, (declr : declarator) = p in + let aty = get_param_atype pt in + let str = get_typed_declr_str aty declr in + if is_const_ptr pt then "const " ^ str else str + +(** ----- End code borrowed and tweaked from {!CodeGen.ml} ----- *) + +(* Helper to map and filter out None at the same time. *) +let filter_map f l = List.of_seq (Seq.filter_map f (List.to_seq l)) + +(* Helper to flatten and map at the same time. *) +let flatten_map f l = List.flatten (List.map f l) + +let flatten_map2 f l m = List.flatten (List.map2 f l m) + +let is_in_ptr = function + | PTVal _ -> false + | PTPtr (_, a) -> a.pa_chkptr && a.pa_direction = PtrIn + +let is_out_ptr = function + | PTVal _ -> false + | PTPtr (_, a) -> a.pa_chkptr && a.pa_direction = PtrOut + +let is_inout_ptr = function + | PTVal _ -> false + | PTPtr (_, a) -> a.pa_chkptr && a.pa_direction = PtrInOut + +let is_in_or_inout_ptr (p, _) = is_in_ptr p || is_inout_ptr p + +let is_out_or_inout_ptr (p, _) = is_out_ptr p || is_inout_ptr p + +let is_str_ptr = function PTVal _ -> false | PTPtr (_, a) -> a.pa_isstr + +let is_wstr_ptr = function PTVal _ -> false | PTPtr (_, a) -> a.pa_iswstr + +let is_str_or_wstr_ptr (p, _) = is_str_ptr p || is_wstr_ptr p + +(* This tests if the member has a non-empty size attribute, + implying that it should be marshalled. *) +let is_marshalled_ptr = function + | PTPtr (_, attr) -> attr.pa_size <> empty_ptr_size + | PTVal _ -> false + +(** Generate the wrapper prototype for a given function. Optionally + add an [oe_enclave_t*] first parameter. *) +let get_wrapper_prototype (fd : func_decl) (is_ecall : bool) = + let plist_str = + let args = + [ + (if is_ecall then [ "oe_enclave_t* enclave" ] else []); + ( match fd.rtype with + | Void -> [] + | _ -> [ get_tystr fd.rtype ^ "* _retval" ] ); + List.map get_parameter_str fd.plist; + ] + |> List.flatten + in + match args with + | [ arg ] -> arg + | _ -> "\n " ^ String.concat ",\n " args + in + sprintf "oe_result_t %s(%s)" fd.fname plist_str + +let get_function_id (enclave_name : string) (f : func_decl) = + enclave_name ^ "_fcn_id_" ^ f.fname diff --git a/tools/oeedger8r/src/Common.mli b/tools/oeedger8r/src/Common.mli new file mode 100644 index 0000000000..889b15428e --- /dev/null +++ b/tools/oeedger8r/src/Common.mli @@ -0,0 +1,36 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +val is_foreign_array : Intel.Ast.parameter_type -> bool + +val get_array_dims : int list -> string + +val get_parameter_str : Intel.Ast.pdecl -> string + +val filter_map : ('a -> 'b option) -> 'a list -> 'b list + +val flatten_map : ('a -> 'b list) -> 'a list -> 'b list + +val flatten_map2 : ('a -> 'b -> 'c list) -> 'a list -> 'b list -> 'c list + +val is_in_ptr : Intel.Ast.parameter_type -> bool + +val is_out_ptr : Intel.Ast.parameter_type -> bool + +val is_inout_ptr : Intel.Ast.parameter_type -> bool + +val is_in_or_inout_ptr : Intel.Ast.parameter_type * 'a -> bool + +val is_out_or_inout_ptr : Intel.Ast.parameter_type * 'a -> bool + +val is_str_ptr : Intel.Ast.parameter_type -> bool + +val is_wstr_ptr : Intel.Ast.parameter_type -> bool + +val is_str_or_wstr_ptr : Intel.Ast.parameter_type * 'a -> bool + +val is_marshalled_ptr : Intel.Ast.parameter_type -> bool + +val get_wrapper_prototype : Intel.Ast.func_decl -> bool -> string + +val get_function_id : string -> Intel.Ast.func_decl -> string diff --git a/tools/oeedger8r/src/Emitter.ml b/tools/oeedger8r/src/Emitter.ml new file mode 100644 index 0000000000..7fa23f9eff --- /dev/null +++ b/tools/oeedger8r/src/Emitter.ml @@ -0,0 +1,201 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +(** This module is Open Enclave's plugin for Intel's Edger8r, allowing + us to share the same Enclave Definition Language, but emit our + SDK's bindings. *) + +open Intel.Ast +open Printf +open Common + +(** [write_file] opens [filename] in the directory [dir] and emits a + comment noting the file is auto generated followed by the + [content], it then closes the file. *) +let write_file (content : string list) (filename : string) (dir : string) = + let os = + if dir = "." then open_out filename + else open_out (dir ^ Intel.Util.separator_str ^ filename) + in + fprintf os "%s" + (String.concat "\n" + ( [ + "/*"; + " * This file is auto generated by oeedger8r. DO NOT EDIT."; + " */"; + ] + @ content )); + close_out os + +let warn_non_portable_types (fd : func_decl) = + (* Check if any of the parameters or the return type has the given + root type. *) + let uses_type (t : atype) = + t = fd.rtype || List.exists (fun (p, _) -> t = get_param_atype p) fd.plist + in + let print_portability_warning ty = + printf + "Warning: Function '%s': %s has different sizes on Windows and Linux. \ + This enclave cannot be built in Linux and then safely loaded in Windows.\n" + fd.fname ty + in + let print_portability_warning_with_recommendation ty recommendation = + printf + "Warning: Function '%s': %s has different sizes on Windows and Linux. \ + This enclave cannot be built in Linux and then safely loaded in \ + Windows. Consider using %s instead.\n" + fd.fname ty recommendation + in + (* longs are represented as an Int type *) + let long_t = Int { ia_signedness = Signed; ia_shortness = ILong } in + let ulong_t = Int { ia_signedness = Unsigned; ia_shortness = ILong } in + if uses_type WChar then print_portability_warning "wchar_t"; + if uses_type LDouble then print_portability_warning "long double"; + (* Handle long type *) + if uses_type (Long Signed) || uses_type long_t then + print_portability_warning_with_recommendation "long" "int64_t or int32_t"; + (* Handle unsigned long type *) + if uses_type (Long Unsigned) || uses_type ulong_t then + print_portability_warning_with_recommendation "unsigned long" + "uint64_t or uint32_t" + +let warn_signed_size_or_count_types (fd : func_decl) = + let print_signedness_warning p = + printf + "Warning: Function '%s': Size or count parameter '%s' should not be \ + signed.\n" + fd.fname p + in + (* Get the names of all size and count parameters for the function [fd]. *) + let size_params = + filter_map + (fun (ptype, _) -> + (* The size may be either a [count] or [size], and then + either a number or string. We are interested in the + strings, as they indicate named [size] or [count] + parameters. *) + let param_name { ps_size; ps_count } = + match (ps_size, ps_count) with + (* [s] is the name of the parameter as a string. *) + | None, Some (AString s) | Some (AString s), None -> Some s + (* TODO: Check for [Some (ANumber n)] that [n < 1] *) + | _ -> None + in + (* Only variables that are pointers where [chkptr] is true may + have size parameters. *) + match ptype with + | PTPtr (_, a) when a.pa_chkptr -> param_name a.pa_size + | _ -> None) + fd.plist + in + (* Print warnings for size parameters that are [Signed]. *) + List.iter + (fun (ptype, decl) -> + let id = decl.identifier in + if List.mem id size_params then + match ptype with + | PTVal (Long s | LLong s) when s = Signed -> + print_signedness_warning id + | PTVal (Int i) when i.ia_signedness = Signed -> + print_signedness_warning id + | _ -> ()) + fd.plist + +let warn_size_and_count_params (fd : func_decl) = + let print_size_and_count_warning { ps_size; ps_count } = + match (ps_size, ps_count) with + | Some (AString p), Some (AString q) -> + Intel.Util.failwithf + "Function '%s': simultaneous 'size' and 'count' parameters '%s' and \ + '%s' are not supported by oeedger8r.\n" + fd.fname p q + | _ -> () + in + List.iter + (fun (ptype, _) -> + match ptype with + | PTPtr (_, ptr_attr) when ptr_attr.pa_chkptr -> + print_size_and_count_warning ptr_attr.pa_size + | _ -> ()) + fd.plist + +(** Generate the Enclave code. *) +let write_enclave_code (ec : enclave_content) (ep : Intel.Util.edger8r_params) = + (* Short aliases for the trusted and untrusted function + declarations. *) + let tfs = ec.tfunc_decls in + let ufs = ec.ufunc_decls in + (* Validate Open Enclave supported EDL features. NOTE: This + validation has the side effects of printed warnings or failure + with an error message. *) + if ep.use_prefix then + Intel.Util.failwithf "--use_prefix option is not supported by oeedger8r."; + List.iter + (fun f -> + if f.tf_is_priv then + Intel.Util.failwithf + "Function '%s': 'private' specifier is not supported by oeedger8r" + f.tf_fdecl.fname; + if f.tf_is_switchless then + Intel.Util.failwithf + "Function '%s': trusted switchless ecalls are not yet supported by \ + Open Enclave SDK." + f.tf_fdecl.fname) + tfs; + List.iter + (fun f -> + ( if f.uf_fattr.fa_convention <> CC_NONE then + let cconv_str = get_call_conv_str f.uf_fattr.fa_convention in + printf + "Warning: Function '%s': Calling convention '%s' for ocalls is not \ + supported by oeedger8r.\n" + f.uf_fdecl.fname cconv_str ); + if f.uf_fattr.fa_dllimport then + Intel.Util.failwithf + "Function '%s': dllimport is not supported by oeedger8r." + f.uf_fdecl.fname; + if f.uf_allow_list != [] then + printf + "Warning: Function '%s': Reentrant ocalls are not supported by Open \ + Enclave. Allow list ignored.\n" + f.uf_fdecl.fname) + ufs; + (* Map warning functions over trusted and untrusted function + declarations *) + let ufuncs = List.map (fun f -> f.uf_fdecl) ufs in + let tfuncs = List.map (fun f -> f.tf_fdecl) tfs in + let funcs = List.append ufuncs tfuncs in + List.iter + (fun f -> + warn_non_portable_types f; + warn_signed_size_or_count_types f; + warn_size_and_count_params f) + funcs; + (* End EDL validation. *) + (* NOTE: The below code encapsulates all our file I/O. *) + let args_h = ec.file_shortnm ^ "_args.h" in + if ep.gen_trusted then ( + write_file (Headers.generate_args ec) args_h ep.trusted_dir; + write_file + (Headers.generate_trusted ec) + (ec.file_shortnm ^ "_t.h") ep.trusted_dir; + if not ep.header_only then + write_file + (Sources.generate_trusted ec ep) + (ec.file_shortnm ^ "_t.c") ep.trusted_dir ); + if ep.gen_untrusted then ( + write_file (Headers.generate_args ec) args_h ep.untrusted_dir; + write_file + (Headers.generate_untrusted ec) + (ec.file_shortnm ^ "_u.h") ep.untrusted_dir; + if not ep.header_only then + write_file + (Sources.generate_untrusted ec ep) + (ec.file_shortnm ^ "_u.c") ep.untrusted_dir ); + printf "Success.\n" + +(** Install the plugin. *) +let _ = + Printf.printf "Generating edge routines for the Open Enclave SDK.\n"; + Intel.Plugin.instance.available <- true; + Intel.Plugin.instance.gen_edge_routines <- write_enclave_code diff --git a/tools/oeedger8r/src/Headers.ml b/tools/oeedger8r/src/Headers.ml new file mode 100644 index 0000000000..7cb05f40f2 --- /dev/null +++ b/tools/oeedger8r/src/Headers.ml @@ -0,0 +1,329 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +open Intel.Ast +open Common +open Printf + +(** ----- Begin code borrowed and tweaked from {!CodeGen.ml}. ----- *) + +(** [conv_array_to_ptr] is used to convert Array form into Pointer form. + {[ + int array[10][20] => [count = 200] int* array + ]} + + This function is called when generating proxy/bridge code and the + marshalling structure. *) +let conv_array_to_ptr (pd : pdecl) : pdecl = + let pt, declr = pd in + let get_count_attr ilist = + (* XXX: assume the size of each dimension will be > 0. *) + ANumber (List.fold_left (fun acc i -> acc * i) 1 ilist) + in + match pt with + | PTVal _ -> (pt, declr) + | PTPtr (aty, pa) -> + if is_array declr then + let tmp_declr = { declr with array_dims = [] } in + let tmp_aty = Ptr aty in + let tmp_cnt = get_count_attr declr.array_dims in + let tmp_pa = + { pa with pa_size = { empty_ptr_size with ps_count = Some tmp_cnt } } + in + (PTPtr (tmp_aty, tmp_pa), tmp_declr) + else (pt, declr) + +(** ----- End code borrowed and tweaked from {!CodeGen.ml} ----- *) + +(** Generate the prototype for a given function. *) +let get_function_prototype (fd : func_decl) = + let plist_str = + let args = List.map get_parameter_str fd.plist in + match args with + | [] -> "void" + | [ arg ] -> arg + | _ -> "\n " ^ String.concat ",\n " args + in + sprintf "%s %s(%s)" (get_tystr fd.rtype) fd.fname plist_str + +(** Emit [struct], [union], or [enum]. *) +let get_composite_type = + let get_struct (s : struct_def) = + [ + "typedef struct " ^ s.sname; + "{"; + String.concat "\n" + (List.map + (fun (ptype, decl) -> + sprintf " %s %s%s;" + (get_tystr (get_param_atype ptype)) + decl.identifier + (get_array_dims decl.array_dims)) + s.smlist); + "} " ^ s.sname ^ ";"; + ""; + ] + in + let get_union (u : union_def) = + [ + "typedef union " ^ u.uname; + "{"; + String.concat "\n" + (List.map + (fun (atype, decl) -> + sprintf " %s %s%s;" (get_tystr atype) decl.identifier + (get_array_dims decl.array_dims)) + u.umlist); + "} " ^ u.uname ^ ";"; + ""; + ] + in + let get_enum (e : enum_def) = + [ + "typedef enum " ^ e.enname; + "{"; + String.concat ",\n" + (List.map + (fun (name, value) -> + sprintf " %s%s" name + ( match value with + | EnumVal (AString s) -> " = " ^ s + | EnumVal (ANumber n) -> " = " ^ string_of_int n + | EnumValNone -> "" )) + e.enbody); + "} " ^ e.enname ^ ";"; + ""; + ] + in + function + | StructDef s -> get_struct s + | UnionDef u -> get_union u + | EnumDef e -> get_enum e + +let get_marshal_struct (fd : func_decl) (errno : bool) = + let get_member_decl (ptype, decl) = + let aty = get_param_atype ptype in + let tystr = get_tystr aty in + let tystr = + if is_foreign_array ptype then + sprintf "/* foreign array of type %s */ void*" tystr + else tystr + in + let need_strlen = + is_str_or_wstr_ptr (ptype, decl) && is_in_or_inout_ptr (ptype, decl) + in + let id = decl.identifier in + [ + [ tystr ^ " " ^ id ^ ";" ]; + (if need_strlen then [ sprintf "size_t %s_len;" id ] else []); + ] + |> List.flatten + in + let struct_name = fd.fname ^ "_args_t" in + let retval_decl = { identifier = "_retval"; array_dims = [] } in + let members = + [ + [ "oe_result_t _result;" ]; + ( if fd.rtype = Void then [] + else get_member_decl (PTVal fd.rtype, retval_decl) ); + (if errno then [ "int _ocall_errno;" ] else []); + flatten_map get_member_decl (List.map conv_array_to_ptr fd.plist); + ] + |> List.flatten + in + [ + "typedef struct _" ^ struct_name; + "{"; + " " ^ String.concat "\n " members; + "} " ^ struct_name ^ ";"; + ""; + ] + +(* Generate [args.h] which contains [struct]s for ecalls and ocalls *) +let generate_args (ec : enclave_content) = + let tfs = ec.tfunc_decls in + let ufs = ec.ufunc_decls in + let trusted_function_ids = + [ + "enum"; + "{"; + String.concat "\n" + (List.mapi + (fun i f -> + sprintf " %s = %d," + (get_function_id ec.enclave_name f.tf_fdecl) + i) + tfs); + " " ^ ec.enclave_name ^ "_fcn_id_trusted_call_id_max = OE_ENUM_MAX"; + "};"; + ] + in + let untrusted_function_ids = + [ + "enum"; + "{"; + String.concat "\n" + (List.mapi + (fun i f -> + sprintf " %s = %d," + (get_function_id ec.enclave_name f.uf_fdecl) + i) + ufs); + " " ^ ec.enclave_name ^ "_fcn_id_untrusted_call_max = OE_ENUM_MAX"; + "};"; + ] + in + let guard_macro = + "EDGER8R_" ^ String.uppercase_ascii ec.enclave_name ^ "_ARGS_H" + in + let include_errno = + let s = "#include " in + if List.exists (fun uf -> uf.uf_propagate_errno) ufs then s + else sprintf "/* %s - Errno propagation not enabled so not included. */" s + in + let user_includes = + let includes = ec.include_list in + if includes <> [] then List.map (sprintf "#include \"%s\"") includes + else [ "/* There were no user includes. */" ] + in + let user_types = + let cts = ec.comp_defs in + if cts <> [] then flatten_map get_composite_type cts + else [ "/* There were no user defined types. */"; "" ] + in + let ecall_marshal_structs = + if tfs <> [] then + flatten_map (fun tf -> get_marshal_struct tf.tf_fdecl false) tfs + else [ "/* There were no ecalls. */"; "" ] + in + let ocall_marshal_structs = + if ufs <> [] then + flatten_map + (fun uf -> get_marshal_struct uf.uf_fdecl uf.uf_propagate_errno) + ufs + else [ "/* There were no ocalls. */"; "" ] + in + [ + "#ifndef " ^ guard_macro; + "#define " ^ guard_macro; + ""; + "#include "; + "#include /* for wchar_t */"; + ""; + include_errno; + ""; + "#include "; + "#include "; + ""; + "/**** User includes. ****/"; + String.concat "\n" user_includes; + ""; + "/**** User defined types in EDL. ****/"; + String.concat "\n" user_types; + "/**** ECALL marshalling structs. ****/"; + String.concat "\n" ecall_marshal_structs; + "/**** OCALL marshalling structs. ****/"; + String.concat "\n" ocall_marshal_structs; + "/**** Trusted function IDs ****/"; + String.concat "\n" trusted_function_ids; + ""; + "/**** Untrusted function IDs. ****/"; + String.concat "\n" untrusted_function_ids; + ""; + "#endif // " ^ guard_macro; + ""; + ] + +(* Includes are emitted in [args.h]. Imported functions have already + been brought into function lists. *) +let generate_trusted (ec : enclave_content) = + let guard = "EDGER8R_" ^ String.uppercase_ascii ec.file_shortnm ^ "_T_H" in + let tfunc_prototypes = + let tfs = ec.tfunc_decls in + if tfs <> [] then + List.map (fun f -> sprintf "%s;" (get_function_prototype f.tf_fdecl)) tfs + else [ "/* There were no ecalls. */" ] + in + let ufunc_wrapper_prototypes = + let ufs = ec.ufunc_decls in + if ufs <> [] then + List.map + (fun f -> sprintf "%s;" (get_wrapper_prototype f.uf_fdecl false)) + ufs + else [ "/* There were no ocalls. */" ] + in + [ + "#ifndef " ^ guard; + "#define " ^ guard; + ""; + "#include "; + ""; + sprintf "#include \"%s_args.h\"" ec.file_shortnm; + ""; + "OE_EXTERNC_BEGIN"; + ""; + "/**** ECALL prototypes. ****/"; + String.concat "\n\n" tfunc_prototypes; + ""; + "/**** OCALL prototypes. ****/"; + String.concat "\n\n" ufunc_wrapper_prototypes; + ""; + "OE_EXTERNC_END"; + ""; + "#endif // " ^ guard; + ""; + ] + +let generate_untrusted (ec : enclave_content) = + let guard = "EDGER8R_" ^ String.uppercase_ascii ec.file_shortnm ^ "_U_H" in + let tfunc_wrapper_prototypes = + let tfs = ec.tfunc_decls in + if tfs <> [] then + List.map (fun f -> get_wrapper_prototype f.tf_fdecl true ^ ";") tfs + else [ "/* There were no ecalls. */" ] + in + let ufunc_prototypes = + let ufs = ec.ufunc_decls in + if ufs <> [] then + List.map (fun f -> get_function_prototype f.uf_fdecl ^ ";") ufs + else [ "/* There were no ocalls. */" ] + in + [ + "#ifndef " ^ guard; + "#define " ^ guard; + ""; + "#include "; + ""; + sprintf "#include \"%s_args.h\"" ec.file_shortnm; + ""; + "OE_EXTERNC_BEGIN"; + ""; + sprintf "oe_result_t oe_create_%s_enclave(" ec.enclave_name; + " const char* path,"; + " oe_enclave_type_t type,"; + " uint32_t flags,"; + " const oe_enclave_setting_t* settings,"; + " uint32_t setting_count,"; + " oe_enclave_t** enclave);"; + ""; + "struct oe_eeid_t_;"; + sprintf "oe_result_t oe_create_%s_enclave_eeid(" ec.enclave_name; + " const char* path,"; + " oe_enclave_type_t type,"; + " uint32_t flags,"; + " const oe_enclave_setting_t* settings,"; + " uint32_t setting_count,"; + " struct oe_eeid_t_ *eeid,"; + " oe_enclave_t** enclave);"; + ""; + "/**** ECALL prototypes. ****/"; + String.concat "\n\n" tfunc_wrapper_prototypes; + ""; + "/**** OCALL prototypes. ****/"; + String.concat "\n\n" ufunc_prototypes; + ""; + "OE_EXTERNC_END"; + ""; + "#endif // " ^ guard; + ""; + ] diff --git a/tools/oeedger8r/src/Headers.mli b/tools/oeedger8r/src/Headers.mli new file mode 100644 index 0000000000..32a6466338 --- /dev/null +++ b/tools/oeedger8r/src/Headers.mli @@ -0,0 +1,8 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +val generate_args : Intel.Ast.enclave_content -> string list + +val generate_trusted : Intel.Ast.enclave_content -> string list + +val generate_untrusted : Intel.Ast.enclave_content -> string list diff --git a/tools/oeedger8r/src/Sources.ml b/tools/oeedger8r/src/Sources.ml new file mode 100644 index 0000000000..b9d34e524b --- /dev/null +++ b/tools/oeedger8r/src/Sources.ml @@ -0,0 +1,999 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +open Intel.Ast +open Common +open Printf + +(** Given [name], return the corresponding [StructDef], or [None]. *) +let get_struct_by_name (cts : composite_type list) (name : string) = + (* [cts] is a list of all composite types, but we're only + interested in the structs, so we filter out the rest and unwrap + them from [composite_type]. *) + let structs = filter_map (function StructDef s -> Some s | _ -> None) cts in + List.find_opt (fun s -> s.sname = name) structs + +(** We need to check [Ptr]s for [Foreign] or [Struct] types, then + check those against the user's [Struct]s, and then check if any + members should be deep copied. What we return is the list of + members of the [Struct] which should be deep-copied, otherwise we + return an empty list. + + NOTE: This is a higher-order function that is mean to have its + first two arguments partially applied, and then used repeatedly. *) +let get_deepcopy_function (enabled : bool) (cts : composite_type list) + (a : atype) = + let should_deepcopy_a = function + | Ptr (Struct n) | Ptr (Foreign n) -> get_struct_by_name cts n + | _ -> None + in + if enabled then + match should_deepcopy_a a with + | Some s -> List.filter (fun (p, _) -> is_marshalled_ptr p) s.smlist + | None -> [] + else [] + +let gen_c_for level count body = + if count = "1" then body + else + let i = sprintf "_i_%i" level in + [ + [ sprintf "for (size_t %s = 0; %s < %s; %s++)" i i count i ]; + [ "{" ]; + List.map (( ^ ) " ") body; + [ "}" ]; + ] + |> List.flatten + +let gen_c_deref level i = if i = "1" then "->" else sprintf "[_i_%i]." level + +let attr_value_to_string argstruct = function + | None -> None + | Some (ANumber n) -> Some (string_of_int n) + | Some (AString s) -> Some (argstruct ^ s) + +(** For a list of args and current count, get the corresponding + argstruct variable name. The prefix is usually, but not always, + ["_args."].*) +let get_argstruct prefix args count = + match args with + | [] -> prefix + | hd :: _ -> prefix ^ hd ^ gen_c_deref (List.length args) count + +let get_type_expr ptype = + (* Get the base type of the parameter. That is, yield its [atype], + unless it is a pointer, in which case decompose and yield the + [atype] the pointer points to. *) + let param_atype = + let a = get_param_atype ptype in + match a with Ptr p -> p | _ -> a + in + let tystr = get_tystr param_atype in + match ptype with + | PTPtr (_, ptr_attr) when ptr_attr.pa_isptr -> sprintf "*(%s)0" tystr + | _ -> tystr + +(** For a parameter, get its size expression. *) +let _get_param_size (ptype, decl, argstruct) = + let type_expr = get_type_expr ptype in + let get_ptr_or_decl_size (p : ptr_size) = + let size = attr_value_to_string argstruct p.ps_size + and count = attr_value_to_string argstruct p.ps_count in + match (size, count) with + | Some s, None -> s + (* TODO: Check that c actually fits in size_t. Also check for overflow, + * similar to oe_add_size *) + | None, Some c -> sprintf "((size_t)%s * sizeof(%s))" c type_expr + (* TODO: Check that this is an even multiple of the size of type. *) + | Some s, Some c -> sprintf "(%s * %s)" s c + | None, None -> + sprintf "sizeof(%s%s)" type_expr (get_array_dims decl.array_dims) + in + match ptype with + | PTPtr (_, ptr_attr) -> + if ptr_attr.pa_isstr then + Some (argstruct ^ decl.identifier ^ "_len * sizeof(char)") + else if ptr_attr.pa_iswstr then + Some (argstruct ^ decl.identifier ^ "_len * sizeof(wchar_t)") + else if ptr_attr.pa_chkptr then + Some (get_ptr_or_decl_size ptr_attr.pa_size) + else None + (* Values have no marshalling size. *) + | _ -> None + +let get_param_size (ptype, decl, argstruct) = + match _get_param_size (ptype, decl, argstruct) with + | Some size -> size + | None -> Intel.Util.failwithf "Error: No size for " ^ decl.identifier + +(** For a parameter, get its count expression. *) +let _get_param_count (ptype, decl, argstruct) = + let type_expr = get_type_expr ptype in + let get_ptr_or_decl_count (p : ptr_size) = + let size = attr_value_to_string argstruct p.ps_size + and count = attr_value_to_string argstruct p.ps_count in + match (size, count) with + (* TODO: Check that these are even multiples of the size of type. *) + | Some s, None -> sprintf "(%s / sizeof(%s))" s type_expr + | None, Some c -> c + | Some s, Some c -> sprintf "((%s * %s) / sizeof(%s))" s c type_expr + | None, None -> + let dims = List.map string_of_int decl.array_dims in + String.concat " * " dims + in + match ptype with + | PTPtr (_, ptr_attr) -> + (* The count of a string is its length. *) + if ptr_attr.pa_isstr || ptr_attr.pa_iswstr then + (* TODO: Double-check that this length includes the + null-terminator. *) + Some (argstruct ^ decl.identifier ^ "_len") + else if ptr_attr.pa_chkptr then + Some (get_ptr_or_decl_count ptr_attr.pa_size) + (* TODO: Should be able to return [Some "1"] for plain + pointers and values. *) + else None + | PTVal _ -> None + +let get_param_count (ptype, decl, argstruct) = + match _get_param_count (ptype, decl, argstruct) with + | Some count -> count + | None -> Intel.Util.failwithf "Error: No count for " ^ decl.identifier + +(** Generate a cast expression for a pointer argument. Pointer + arguments need to be cast to their root type, since the marshalling + struct has the root pointer. For example: + {[ + int a[10][20] + ]} + needs to be cast to [int *]. + + NOTE: Foreign arrays are marshalled as [void *], but foreign pointers + are marshalled as-is. *) +let get_cast_to_mem_expr (ptype, decl) (parens : bool) = + match ptype with + | PTVal _ -> "" + | PTPtr (t, _) -> + let tystr = get_tystr t in + if is_array decl then + let s = tystr ^ "*" in + if parens then sprintf "(%s)" s else s + else if is_foreign_array ptype then + let s = if parens then "(void*)" else "void*" in + sprintf "/* foreign array of type %s */ %s" tystr s + else if parens then sprintf "(%s)" tystr + else tystr + +(** Recursively generates [if (a && a->b) OE_SET_PTR(a->b->c);] + statements. *) +let rec get_ptr_setter get_deepcopy args count setter (ptype, decl) = + let argstruct = get_argstruct "pargs_in->" args count in + let size = get_param_size (ptype, decl, argstruct) in + let arg = + match args with + | [] -> decl.identifier + | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ decl.identifier + in + let tystr = get_cast_to_mem_expr (ptype, decl) false in + gen_c_for (List.length args) count + ( [ + (* NOTE: This makes the embedded check in the `OE_` macro superfluous. *) + [ + sprintf "if (pargs_in->%s)" + (String.concat " && pargs_in->" (List.rev (arg :: args))); + ]; + [ sprintf " OE_%s_POINTER(%s, %s, %s);" setter arg size tystr ]; + (let param_count = get_param_count (ptype, decl, argstruct) in + flatten_map + (get_ptr_setter get_deepcopy (arg :: args) param_count setter) + (get_deepcopy (get_param_atype ptype))); + ] + |> List.flatten ) + +(** Generates pointer setters for in and in-out pointers. *) +let get_in_ptr_setter get_deepcopy (plist : pdecl list) = + let params = + let ptrs = List.filter is_in_or_inout_ptr plist in + let setters = + List.map + (fun (p, _) -> if is_in_ptr p then "SET_IN" else "SET_IN_OUT") + ptrs + in + flatten_map2 (get_ptr_setter get_deepcopy [] "1") setters ptrs + in + " " + ^ String.concat "\n " + [ + "/* Set in and in-out pointers. */"; + ( if params <> [] then String.concat "\n " params + else "/* There were no in nor in-out parameters. */" ); + ] + +(** Generates pointer setters for out and in-out pointers. *) +let get_out_ptr_setter get_deepcopy (plist : pdecl list) = + let params = + let ptrs = List.filter is_out_or_inout_ptr plist in + let setters = + List.map + (fun (p, _) -> + if is_out_ptr p then "SET_OUT" else "COPY_AND_SET_IN_OUT") + ptrs + in + flatten_map2 (get_ptr_setter get_deepcopy [] "1") setters ptrs + in + " " + ^ String.concat "\n " + [ + "/* Set out and in-out pointers. */"; + "/* In-out parameters are copied to output buffer. */"; + ( if params <> [] then String.concat "\n " params + else "/* There were no out nor in-out parameters. */" ); + ] + +(** Generates an expression representing the total number of pointers + we need to save and restore, used as the size for the pointer + array. *) +let rec get_ptr_count get_deepcopy args count (ptype, decl) = + let get_multiplication_expr count body = + (* The first two conditionals check for the multiplicative identity + and prevent unnecessary expressions from being generated. + Otherwise we multiply the sum of [body] by [count]. *) + if count = "1" || body = [] then body + else if List.length body = 1 && List.hd body = "1" then [ count ] + else [ count ^ " * (" ^ String.concat " + " body ^ ")" ] + in + let id = decl.identifier in + (* TODO: The use of [gen_c_deref] does not work here as we are not + within a [gen_c_for] loop when producing the count. Therefore + arrays of structs which use members for the count of another + nested parameter are not yet supported. *) + let argstruct = get_argstruct "" args count in + let arg = + match args with + | [] -> id + | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ id + in + let param_count = get_param_count (ptype, decl, argstruct) in + let members = get_deepcopy (get_param_atype ptype) in + if is_marshalled_ptr ptype then + (* The base case is a marshalled pointer. We count 1 for every one + of these, except for the top-level pointers as they are the + original function arguments, and so do not need to be + saved/restored. + + For a marshalled pointer, we then need to recurse. If there are + no members to recurse on, then [members] is the empty list and + the recursion is a no-op, leaving us back at the base case of + counting 1. If there are members to recurse on, then we count 1 + plus the current [param_count] times the number of members for + each nested structure. *) + (if args <> [] then [ "1" ] else []) + @ get_multiplication_expr param_count + (flatten_map + (get_ptr_count get_deepcopy (arg :: args) param_count) + members) + else [] + +(** Generates the array used to save the original pointers. *) +let get_ptr_array get_deepcopy (plist : pdecl list) = + let count = + flatten_map + (get_ptr_count get_deepcopy [] "1") + (List.filter is_out_or_inout_ptr plist) + in + if count <> [] then + [ + "size_t _ptrs_index = 0;"; + sprintf "void** _ptrs = malloc(sizeof(void*) * (%s));" + (String.concat " + " count); + "if (_ptrs == NULL)"; + "{"; + " _result = OE_OUT_OF_MEMORY;"; + " goto done;"; + "}"; + ] + else [ "/* No pointers to save for deep copy. */" ] + +(** Generates expression to reset the index into the pointer array. *) +let get_ptr_index_reset get_deepcopy (plist : pdecl list) = + let count = + flatten_map + (get_ptr_count get_deepcopy [] "1") + (List.filter is_out_or_inout_ptr plist) + in + if count <> [] then "_ptrs_index = 0; /* For deep copy. */" + else "/* No pointers to restore for deep copy. */" + +let get_ptr_free_expr get_deepcopy (plist : pdecl list) = + let count = + flatten_map + (get_ptr_count get_deepcopy [] "1") + (List.filter is_out_or_inout_ptr plist) + in + if count <> [] then [ "if (_ptrs)"; " free(_ptrs);" ] + else [ "/* No `_ptrs` to free for deep copy. */" ] + +let get_filled_marshal_struct get_deepcopy (fd : func_decl) = + (* Generate assignment argument to corresponding field in args. This + is necessary for all arguments, not just copy-as-value, because + they are used directly by later marshalling code. *) + let get_assignment_to_args (ptype, decl) = + let arg = decl.identifier in + [ + [ + sprintf "_args.%s = %s%s;" arg + (get_cast_to_mem_expr (ptype, decl) true) + arg; + ]; + (* for string parameter fill the len field *) + ( if is_str_ptr ptype then + [ sprintf "_args.%s_len = (%s) ? (strlen(%s) + 1) : 0;" arg arg arg ] + else if is_wstr_ptr ptype then + [ sprintf "_args.%s_len = (%s) ? (wcslen(%s) + 1) : 0;" arg arg arg ] + else [] ); + ] + |> List.flatten + in + flatten_map get_assignment_to_args fd.plist + @ + let rec get_saved_ptrs args count (ptype, decl) = + let id = decl.identifier in + let argstruct = get_argstruct "_args." args count in + let arg = + match args with + | [] -> id + | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ id + in + gen_c_for (List.length args) count + ( [ + ( if args <> [] then + [ sprintf "if (%s)" (String.concat " && " (List.rev args)) ] + else [] ); + ( if args <> [] && is_marshalled_ptr ptype then + [ " _ptrs[_ptrs_index++] = (void*)" ^ arg ^ ";" ] + else [] ); + (let param_count = get_param_count (ptype, decl, argstruct) in + flatten_map + (get_saved_ptrs (arg :: args) param_count) + (get_deepcopy (get_param_atype ptype))); + ] + |> List.flatten ) + in + flatten_map (get_saved_ptrs [] "1") (List.filter is_out_or_inout_ptr fd.plist) + +(* Prepare [input_buffer]. *) +let get_input_buffer get_deepcopy (fd : func_decl) (alloc_func : string) = + let get_buffer_size buffer predicate plist = + let rec get_add_size_expr args count (ptype, decl) = + let argstruct = get_argstruct "_args." args count in + let size = get_param_size (ptype, decl, argstruct) in + let arg = + match args with + | [] -> decl.identifier + | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ decl.identifier + in + gen_c_for (List.length args) count + ( [ + [ sprintf "if (%s)" (String.concat " && " (List.rev (arg :: args))) ]; + [ sprintf " OE_ADD_SIZE(%s, %s);" buffer size ]; + (let param_count = get_param_count (ptype, decl, argstruct) in + flatten_map + (get_add_size_expr (arg :: args) param_count) + (get_deepcopy (get_param_atype ptype))); + ] + |> List.flatten ) + in + let params = + flatten_map (get_add_size_expr [] "1") (List.filter predicate plist) + in + (* Note that the indentation for the first line is applied by the + parent function. *) + if params <> [] then String.concat "\n " params + else "/* There were no corresponding parameters. */" + in + let get_input_buffer_size = + get_buffer_size "_input_buffer_size" is_in_or_inout_ptr + in + let get_output_buffer_size = + get_buffer_size "_output_buffer_size" is_out_or_inout_ptr + in + let get_serialized_buffer_inputs (plist : pdecl list) = + let rec get_serializer args count (ptype, decl) = + let argstruct = get_argstruct "_args." args count in + let size = get_param_size (ptype, decl, argstruct) in + let arg = + match args with + | [] -> decl.identifier + | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ decl.identifier + in + let tystr = get_cast_to_mem_expr (ptype, decl) false in + (* These need to be in order and so done together. *) + gen_c_for (List.length args) count + ( [ + (* NOTE: This makes the embedded check in the `OE_` macro superfluous. *) + [ + sprintf "if (%s)" (String.concat " && " (List.rev (arg :: args))); + ]; + [ + (* NOTE: The [WRITE_IN_OUT] macro is defined to be the + [WRITE_IN] macro. *) + sprintf " OE_WRITE_%s_PARAM(%s, %s, %s);" + (if is_in_ptr ptype then "IN" else "IN_OUT") + arg size tystr; + ]; + (let param_count = get_param_count (ptype, decl, argstruct) in + flatten_map + (get_serializer (arg :: args) param_count) + (get_deepcopy (get_param_atype ptype))); + ] + |> List.flatten ) + in + let params = + flatten_map (get_serializer [] "1") (List.filter is_in_or_inout_ptr plist) + in + (* Note that the indentation for the first line is applied by the + parent function. *) + if params <> [] then String.concat "\n " params + else "/* There were no in nor in-out parameters. */" + in + [ + "/* Compute input buffer size. Include in and in-out parameters. */"; + sprintf "OE_ADD_SIZE(_input_buffer_size, sizeof(%s_args_t));" fd.fname; + get_input_buffer_size fd.plist; + ""; + "/* Compute output buffer size. Include out and in-out parameters. */"; + sprintf "OE_ADD_SIZE(_output_buffer_size, sizeof(%s_args_t));" fd.fname; + get_output_buffer_size fd.plist; + ""; + "/* Allocate marshalling buffer. */"; + "_total_buffer_size = _input_buffer_size;"; + "OE_ADD_SIZE(_total_buffer_size, _output_buffer_size);"; + sprintf "_buffer = (uint8_t*)%s(_total_buffer_size);" alloc_func; + "_input_buffer = _buffer;"; + "_output_buffer = _buffer + _input_buffer_size;"; + "if (_buffer == NULL)"; + "{"; + " _result = OE_OUT_OF_MEMORY;"; + " goto done;"; + "}"; + ""; + "/* Serialize buffer inputs (in and in-out parameters). */"; + sprintf "_pargs_in = (%s_args_t*)_input_buffer;" fd.fname; + "OE_ADD_SIZE(_input_buffer_offset, sizeof(*_pargs_in));"; + get_serialized_buffer_inputs fd.plist; + ""; + "/* Copy args structure (now filled) to input buffer. */"; + "memcpy(_pargs_in, &_args, sizeof(*_pargs_in));"; + ] + +let get_output_buffer get_deepcopy (fd : func_decl) = + let get_serialized_buffer_outputs (plist : pdecl list) = + let rec get_serializer args count (ptype, decl) = + let argstruct = get_argstruct "_args." args count in + let size = get_param_size (ptype, decl, argstruct) in + let arg = + match args with + | [] -> decl.identifier + | hd :: _ -> hd ^ gen_c_deref (List.length args) count ^ decl.identifier + in + gen_c_for (List.length args) count + ( [ + ( if is_str_or_wstr_ptr (ptype, decl) then + [ + sprintf + "OE_CHECK_NULL_TERMINATOR%s(_output_buffer + \ + _output_buffer_offset, _args.%s_len);" + (if is_wstr_ptr ptype then "_WIDE" else "") + arg; + ] + else [] ); + (let s = + sprintf "OE_READ_%s_PARAM(%s, (size_t)(%s));" + (if is_out_ptr ptype then "OUT" else "IN_OUT") + arg size + in + match args with + | [] -> [ s ] + | _ -> + let tystr = get_cast_to_mem_expr (ptype, decl) true in + [ + sprintf "if (%s)" (String.concat " && " (List.rev args)); + "{"; + " /* Restore original pointer. */"; + sprintf " %s = %s_ptrs[_ptrs_index++];" arg tystr; + " " ^ s; + "}"; + ]); + (let param_count = get_param_count (ptype, decl, argstruct) in + flatten_map + (get_serializer (arg :: args) param_count) + (get_deepcopy (get_param_atype ptype))); + ] + |> List.flatten ) + in + let params = + flatten_map (get_serializer [] "1") + (List.filter is_out_or_inout_ptr plist) + in + if params <> [] then String.concat "\n " params + else "/* There were no out nor in-out parameters. */" + in + [ + (* Verify that the ecall succeeded *) + "/* Setup output arg struct pointer. */"; + sprintf "_pargs_out = (%s_args_t*)_output_buffer;" fd.fname; + "OE_ADD_SIZE(_output_buffer_offset, sizeof(*_pargs_out));"; + ""; + "/* Check if the call succeeded. */"; + "if ((_result = _pargs_out->_result) != OE_OK)"; + " goto done;"; + ""; + "/* Currently exactly _output_buffer_size bytes must be written. */"; + "if (_output_bytes_written != _output_buffer_size)"; + "{"; + " _result = OE_FAILURE;"; + " goto done;"; + "}"; + ""; + "/* Unmarshal return value and out, in-out parameters. */"; + ( if fd.rtype <> Void then "*_retval = _pargs_out->_retval;" + else "/* No return value. */" ); + get_ptr_index_reset get_deepcopy fd.plist; + get_serialized_buffer_outputs fd.plist; + ] + +(** Generate a cast expression to a specific pointer type. For example, + [int*] needs to be cast to + {[ + *(int ( * )[5][6]) + ]}. *) +let get_cast_from_mem_expr (ptype, decl) = + match ptype with + | PTVal _ -> "" + | PTPtr (t, attr) -> + if is_array decl then + sprintf "*(%s(*)%s)" (get_tystr t) (get_array_dims decl.array_dims) + else if is_foreign_array ptype then + sprintf "/* foreign array */ *(%s*)" (get_tystr t) + else if attr.pa_rdonly then + (* for ptrs, only constness is removed; add it back *) + sprintf "(const %s)" (get_tystr t) + else "" + +(** Generate an expression to call the user function [fd]. *) +let get_call_user_function (fd : func_decl) = + [ + "/* Call user function. */"; + (match fd.rtype with Void -> "" | _ -> "pargs_out->_retval = ") + ^ fd.fname ^ "("; + String.concat ",\n " + (List.map + (fun (ptype, decl) -> + let cast_expr = get_cast_from_mem_expr (ptype, decl) in + sprintf " %spargs_in->%s" cast_expr decl.identifier) + fd.plist) + ^ ");"; + ] + +(** Generate ecall function definition. *) +let get_ecall_function get_deepcopy (tf : trusted_func) = + let fd = tf.tf_fdecl in + [ + sprintf "void ecall_%s(" fd.fname; + " uint8_t* input_buffer,"; + " size_t input_buffer_size,"; + " uint8_t* output_buffer,"; + " size_t output_buffer_size,"; + " size_t* output_bytes_written)"; + "{"; + (* Variable declarations *) + " oe_result_t _result = OE_FAILURE;"; + ""; + " /* Prepare parameters. */"; + sprintf " %s_args_t* pargs_in = (%s_args_t*)input_buffer;" fd.fname + fd.fname; + sprintf " %s_args_t* pargs_out = (%s_args_t*)output_buffer;" fd.fname + fd.fname; + ""; + " size_t input_buffer_offset = 0;"; + " size_t output_buffer_offset = 0;"; + " OE_ADD_SIZE(input_buffer_offset, sizeof(*pargs_in));"; + " OE_ADD_SIZE(output_buffer_offset, sizeof(*pargs_out));"; + ""; + (* Buffer validation *) + " /* Make sure input and output buffers lie within the enclave. */"; + " if (!input_buffer || !oe_is_within_enclave(input_buffer, \ + input_buffer_size))"; + " goto done;"; + ""; + " if (!output_buffer || !oe_is_within_enclave(output_buffer, \ + output_buffer_size))"; + " goto done;"; + ""; + (* Prepare in and in-out parameters *) + get_in_ptr_setter get_deepcopy fd.plist; + ""; + (* Prepare out and in-out parameters. The in-out parameter is + copied to output buffer. *) + get_out_ptr_setter get_deepcopy fd.plist; + ""; + " /* Check that in/in-out strings are null terminated. */" + (* NOTE: We do not support deep copy for strings, so there is not + (yet) anything to do here. *); + (let params = + List.map + (fun (ptype, decl) -> + sprintf + " OE_CHECK_NULL_TERMINATOR%s(pargs_in->%s, pargs_in->%s_len);" + (if is_wstr_ptr ptype then "_WIDE" else "") + decl.identifier decl.identifier) + (List.filter + (fun p -> is_str_or_wstr_ptr p && is_in_or_inout_ptr p) + fd.plist) + in + if params <> [] then String.concat "\n" params + else " /* There were no in nor in-out string parameters. */"); + ""; + " /* lfence after checks. */"; + " oe_lfence();"; + ""; + (* Call the enclave function *) + " " ^ String.concat "\n " (get_call_user_function fd); + ""; + (* Mark call as success *) + " /* Success. */"; + " _result = OE_OK;"; + " *output_bytes_written = output_buffer_offset;"; + ""; + "done:"; + " if (pargs_out && output_buffer_size >= sizeof(*pargs_out))"; + " pargs_out->_result = _result;"; + "}"; + ""; + ] + +(** Generate enclave OCALL wrapper function. *) +let get_ocall_function_wrapper get_deepcopy enclave_name (uf : untrusted_func) = + let fd = uf.uf_fdecl in + let allocate_buffer, call_function, free_buffer = + if uf.uf_is_switchless then + ( "oe_allocate_switchless_ocall_buffer", + "oe_switchless_call_host_function", + "oe_free_switchless_ocall_buffer" ) + else + ( "oe_allocate_ocall_buffer", + "oe_call_host_function", + "oe_free_ocall_buffer" ) + in + [ + get_wrapper_prototype fd false; + "{"; + " oe_result_t _result = OE_FAILURE;"; + ""; + " /* If the enclave is in crashing/crashed status, new OCALL should fail"; + " immediately. */"; + " if (oe_get_enclave_status() != OE_OK)"; + " return oe_get_enclave_status();"; + ""; + " /* Marshalling struct. */"; + sprintf " %s_args_t _args, *_pargs_in = NULL, *_pargs_out = NULL;" + fd.fname; + " " ^ String.concat "\n " (get_ptr_array get_deepcopy fd.plist); + ""; + " /* Marshalling buffer and sizes. */"; + " size_t _input_buffer_size = 0;"; + " size_t _output_buffer_size = 0;"; + " size_t _total_buffer_size = 0;"; + " uint8_t* _buffer = NULL;"; + " uint8_t* _input_buffer = NULL;"; + " uint8_t* _output_buffer = NULL;"; + " size_t _input_buffer_offset = 0;"; + " size_t _output_buffer_offset = 0;"; + " size_t _output_bytes_written = 0;"; + ""; + " /* Fill marshalling struct. */"; + " memset(&_args, 0, sizeof(_args));"; + " " ^ String.concat "\n " (get_filled_marshal_struct get_deepcopy fd); + ""; + " " + ^ String.concat "\n " (get_input_buffer get_deepcopy fd allocate_buffer); + ""; + " /* Call host function. */"; + " if ((_result = " ^ call_function ^ "("; + " " + ^ String.concat ",\n " + [ + get_function_id enclave_name fd; + "_input_buffer"; + "_input_buffer_size"; + "_output_buffer"; + "_output_buffer_size"; + "&_output_bytes_written)) != OE_OK)"; + ]; + " goto done;"; + ""; + " " ^ String.concat "\n " (get_output_buffer get_deepcopy fd); + ""; + " /* Retrieve propagated errno from OCALL. */"; + ( if uf.uf_propagate_errno then " errno = _pargs_out->_ocall_errno;\n" + else sprintf " /* Errno propagation not enabled. */" ); + ""; + " _result = OE_OK;"; + ""; + "done:"; + " if (_buffer)"; + " " ^ free_buffer ^ "(_buffer);"; + " return _result;"; + "}"; + ""; + ] + +let generate_trusted (ec : enclave_content) (ep : Intel.Util.edger8r_params) = + let get_deepcopy = get_deepcopy_function ep.experimental ec.comp_defs in + let tfs = ec.tfunc_decls in + let ufs = ec.ufunc_decls in + let ecall_functions = + if tfs <> [] then flatten_map (get_ecall_function get_deepcopy) tfs + else [ "/* There were no ecalls. */" ] + in + let ecall_table = + let table = "__oe_ecalls_table" in + if tfs <> [] then + [ + sprintf "oe_ecall_func_t %s[] = {" table; + " " + ^ String.concat ",\n " + (List.map + (fun f -> "(oe_ecall_func_t) ecall_" ^ f.tf_fdecl.fname) + tfs); + "};"; + ""; + sprintf "size_t %s_size = OE_COUNTOF(%s);" table table; + ] + else [ "/* There were no ecalls. */" ] + in + let ocall_function_wrappers = + if ufs <> [] then + flatten_map (get_ocall_function_wrapper get_deepcopy ec.enclave_name) ufs + else [ "/* There were no ocalls. */" ] + in + [ + sprintf "#include \"%s_t.h\"" ec.file_shortnm; + ""; + "#include "; + ""; + "#include "; + "#include "; + "#include "; + ""; + "OE_EXTERNC_BEGIN"; + ""; + "/**** ECALL functions. ****/"; + ""; + String.concat "\n" ecall_functions; + "/**** ECALL function table. ****/"; + ""; + String.concat "\n" ecall_table; + ""; + "/**** OCALL function wrappers. ****/"; + ""; + String.concat "\n" ocall_function_wrappers; + "OE_EXTERNC_END"; + ""; + ] + +(* Generate host ECALL wrapper function. *) +let get_host_ecall_wrapper get_deepcopy enclave_name (tf : trusted_func) = + let fd = tf.tf_fdecl in + let ecall_function = + if tf.tf_is_switchless then "oe_switchless_call_enclave_function" + else "oe_call_enclave_function" + in + [ + get_wrapper_prototype fd true; + "{"; + " oe_result_t _result = OE_FAILURE;"; + ""; + " /* Marshalling struct. */"; + sprintf " %s_args_t _args, *_pargs_in = NULL, *_pargs_out = NULL;" + fd.fname; + ""; + " /* Marshalling buffer and sizes. */"; + " size_t _input_buffer_size = 0;"; + " size_t _output_buffer_size = 0;"; + " size_t _total_buffer_size = 0;"; + " uint8_t* _buffer = NULL;"; + " uint8_t* _input_buffer = NULL;"; + " uint8_t* _output_buffer = NULL;"; + " size_t _input_buffer_offset = 0;"; + " size_t _output_buffer_offset = 0;"; + " size_t _output_bytes_written = 0;"; + ""; + " /* Deep copy buffer. */"; + " " ^ String.concat "\n " (get_ptr_array get_deepcopy fd.plist); + ""; + " /* Fill marshalling struct. */"; + " memset(&_args, 0, sizeof(_args));"; + " " ^ String.concat "\n " (get_filled_marshal_struct get_deepcopy fd); + ""; + " " ^ String.concat "\n " (get_input_buffer get_deepcopy fd "malloc"); + ""; + " /* Call enclave function. */"; + " if ((_result = " ^ ecall_function ^ "("; + " " + ^ String.concat ",\n " + [ + "enclave"; + get_function_id enclave_name fd; + "_input_buffer"; + "_input_buffer_size"; + "_output_buffer"; + "_output_buffer_size"; + "&_output_bytes_written)) != OE_OK)"; + ]; + " goto done;"; + ""; + " " ^ String.concat "\n " (get_output_buffer get_deepcopy fd); + ""; + " _result = OE_OK;"; + ""; + "done:"; + " if (_buffer)"; + " free(_buffer);"; + ""; + " " ^ String.concat "\n " (get_ptr_free_expr get_deepcopy fd.plist); + ""; + " return _result;"; + "}"; + ""; + ] + +(* Generate ocall function. *) +let get_ocall_function get_deepcopy (uf : untrusted_func) = + let fd = uf.uf_fdecl in + [ + sprintf "void ocall_%s(" fd.fname; + " uint8_t* input_buffer,"; + " size_t input_buffer_size,"; + " uint8_t* output_buffer,"; + " size_t output_buffer_size,"; + " size_t* output_bytes_written)"; + "{"; + (* Variable declarations *) + " oe_result_t _result = OE_FAILURE;"; + " OE_UNUSED(input_buffer_size);"; + ""; + " /* Prepare parameters. */"; + sprintf " %s_args_t* pargs_in = (%s_args_t*)input_buffer;" fd.fname + fd.fname; + sprintf " %s_args_t* pargs_out = (%s_args_t*)output_buffer;" fd.fname + fd.fname; + ""; + " size_t input_buffer_offset = 0;"; + " size_t output_buffer_offset = 0;"; + " OE_ADD_SIZE(input_buffer_offset, sizeof(*pargs_in));"; + " OE_ADD_SIZE(output_buffer_offset, sizeof(*pargs_out));"; + ""; + (* Buffer validation *) + " /* Make sure input and output buffers are valid. */"; + " if (!input_buffer || !output_buffer) {"; + " _result = OE_INVALID_PARAMETER;"; + " goto done;"; + " }"; + ""; + (* Prepare in and in-out parameters *) + get_in_ptr_setter get_deepcopy fd.plist; + ""; + (* Prepare out and in-out parameters: the in-out parameter is + copied to output buffer. *) + get_out_ptr_setter get_deepcopy fd.plist; + ""; + (* Call the host function *) + " " ^ String.concat "\n " (get_call_user_function fd); + ""; + " /* Propagate errno back to enclave. */"; + ( if uf.uf_propagate_errno then " pargs_out->_ocall_errno = errno;" + else " /* Errno propagation not enabled. */" ); + ""; + (* Mark call as success *) + " /* Success. */"; + " _result = OE_OK;"; + " *output_bytes_written = output_buffer_offset;"; + ""; + "done:"; + " if (pargs_out && output_buffer_size >= sizeof(*pargs_out))"; + " pargs_out->_result = _result;"; + "}"; + ""; + ] + +let generate_untrusted (ec : enclave_content) (ep : Intel.Util.edger8r_params) = + let get_deepcopy = get_deepcopy_function ep.experimental ec.comp_defs in + let host_ecall_wrappers = + let tfs = ec.tfunc_decls in + if tfs <> [] then + flatten_map (get_host_ecall_wrapper get_deepcopy ec.enclave_name) tfs + else [ "/* There were no ecalls. */" ] + in + let ocall_functions = + let ufs = ec.ufunc_decls in + if ufs <> [] then flatten_map (get_ocall_function get_deepcopy) ufs + else [ "/* There were no ocalls. */" ] + in + let ocall_table = + [ + sprintf "static oe_ocall_func_t __%s_ocall_function_table[] = {" + ec.enclave_name; + " " + ^ String.concat "\n " + (List.map + (fun f -> "(oe_ocall_func_t) ocall_" ^ f.uf_fdecl.fname ^ ",") + ec.ufunc_decls); + " NULL"; + "};"; + ] + in + [ + sprintf "#include \"%s_u.h\"" ec.file_shortnm; + ""; + "#include "; + ""; + "#include "; + "#include "; + "#include "; + ""; + "OE_EXTERNC_BEGIN"; + ""; + "/**** ECALL function wrappers. ****/"; + ""; + String.concat "\n" host_ecall_wrappers; + "/**** OCALL functions. ****/"; + ""; + String.concat "\n" ocall_functions; + "/**** OCALL function table. ****/"; + ""; + String.concat "\n" ocall_table; + ""; + sprintf "oe_result_t oe_create_%s_enclave(" ec.enclave_name; + " const char* path,"; + " oe_enclave_type_t type,"; + " uint32_t flags,"; + " const oe_enclave_setting_t* settings,"; + " uint32_t setting_count,"; + " oe_enclave_t** enclave)"; + "{"; + " return oe_create_enclave("; + " path,"; + " type,"; + " flags,"; + " settings,"; + " setting_count,"; + sprintf " __%s_ocall_function_table," ec.enclave_name; + sprintf " %d," (List.length ec.ufunc_decls); + " enclave);"; + "}"; + ""; + sprintf "oe_result_t oe_create_%s_enclave_eeid(" ec.enclave_name; + " const char* path,"; + " oe_enclave_type_t type,"; + " uint32_t flags,"; + " const oe_enclave_setting_t* settings,"; + " uint32_t setting_count,"; + " struct oe_eeid_t_ *eeid,"; + " oe_enclave_t** enclave)"; + "{"; + " return oe_create_enclave_eeid("; + " path,"; + " type,"; + " flags,"; + " settings,"; + " setting_count,"; + sprintf " __%s_ocall_function_table," ec.enclave_name; + sprintf " %d," (List.length ec.ufunc_decls); + " eeid,"; + " enclave);"; + "}"; + ""; + "OE_EXTERNC_END"; + ""; + ] diff --git a/tools/oeedger8r/src/Sources.mli b/tools/oeedger8r/src/Sources.mli new file mode 100644 index 0000000000..fd50eb047a --- /dev/null +++ b/tools/oeedger8r/src/Sources.mli @@ -0,0 +1,8 @@ +(* Copyright (c) Open Enclave SDK contributors. + Licensed under the MIT License. *) + +val generate_trusted : + Intel.Ast.enclave_content -> Intel.Util.edger8r_params -> string list + +val generate_untrusted : + Intel.Ast.enclave_content -> Intel.Util.edger8r_params -> string list diff --git a/tools/oeedger8r/src/dune b/tools/oeedger8r/src/dune new file mode 100644 index 0000000000..9825272bf5 --- /dev/null +++ b/tools/oeedger8r/src/dune @@ -0,0 +1,7 @@ +; Copyright (c) Open Enclave SDK contributors. +; Licensed under the MIT License. + +(executable + (name main) + (public_name oeedger8r) + (libraries intel)) diff --git a/tools/oeedger8r/main.ml b/tools/oeedger8r/src/main.ml similarity index 87% rename from tools/oeedger8r/main.ml rename to tools/oeedger8r/src/main.ml index 50f23a96c1..cb413add52 100644 --- a/tools/oeedger8r/main.ml +++ b/tools/oeedger8r/src/main.ml @@ -42,14 +42,14 @@ let main = let progname = Sys.argv.(0) in let argc = Array.length Sys.argv in let args = if argc = 1 then [||] else Array.sub Sys.argv 1 (argc-1) in - let cmd_params = Util.parse_cmdline progname (Array.to_list args) in + let cmd_params = Intel.Util.parse_cmdline progname (Array.to_list args) in let real_ast_handler fname = try - CodeGen.gen_enclave_code (CodeGen.start_parsing fname) cmd_params + Intel.CodeGen.gen_enclave_code (Intel.CodeGen.start_parsing fname) cmd_params with Failure s -> (Printf.eprintf "error: %s\n" s; exit (-1)) in - if cmd_params.Util.input_files = [] then Util.usage progname - else List.iter real_ast_handler cmd_params.Util.input_files + if cmd_params.input_files = [] then Intel.Util.usage progname + else List.iter real_ast_handler cmd_params.input_files diff --git a/tools/oesgx/CMakeLists.txt b/tools/oesgx/CMakeLists.txt index 44876a349f..6b191d3cfe 100644 --- a/tools/oesgx/CMakeLists.txt +++ b/tools/oesgx/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. add_executable(oesgx oesgx.c) diff --git a/tools/oesgx/oesgx.c b/tools/oesgx/oesgx.c index 645467d235..fe7c80fddb 100644 --- a/tools/oesgx/oesgx.c +++ b/tools/oesgx/oesgx.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -152,7 +152,8 @@ int main(int argc, const char* argv[]) epc_size = ((regs.ecx & 0x0fffff000) | ((uint64_t)(regs.edx & 0x0fffff) << 32)); - printf("EPC size on the platform: %lu\n", epc_size); + printf( + "EPC size on the platform: %llu\n", (unsigned long long)epc_size); } return 0; } diff --git a/tools/oesign/CMakeLists.txt b/tools/oesign/CMakeLists.txt index 15a50c4a2b..8f42d7fee1 100644 --- a/tools/oesign/CMakeLists.txt +++ b/tools/oesign/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Open Enclave SDK contributors. # Licensed under the MIT License. include(CheckSymbolExists) diff --git a/tools/oesign/main.c b/tools/oesign/main.c index d08f6c1a7b..d578900451 100644 --- a/tools/oesign/main.c +++ b/tools/oesign/main.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. #include @@ -580,8 +580,8 @@ int oesign(const char* enclave, const char* conffile, const char* keyfile) } /* Build an enclave to obtain the MRENCLAVE measurement */ - if ((result = oe_sgx_build_enclave(&context, enclave, &props, &enc)) != - OE_OK) + if ((result = oe_sgx_build_enclave( + &context, enclave, &props, NULL, &enc)) != OE_OK) { Err("oe_sgx_build_enclave(): result=%s (%u)", oe_result_str(result), diff --git a/tools/oesign/oedump.c b/tools/oesign/oedump.c index ba678bf926..fe994ecd83 100644 --- a/tools/oesign/oedump.c +++ b/tools/oesign/oedump.c @@ -1,6 +1,7 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Open Enclave SDK contributors. // Licensed under the MIT License. +#include #include #include #include @@ -179,7 +180,7 @@ void dump_enclave_properties(const oe_sgx_enclave_properties_t* props) bool debug = props->config.attributes & OE_SGX_FLAGS_DEBUG; printf("debug=%u\n", debug); - printf("xfrm=%lx\n", props->config.xfrm); + printf("xfrm=%" PRIx64 "\n", props->config.xfrm); printf( "num_heap_pages=%llu\n",