tenAsys INtime RTOS port. Porting complete for mutex semaphores, threading, file, socket and RNG. Added projects for libwolfssl and wolfExamples. The wolfExamples project includes examples for wolfCrypt Test/Benchmark and wolfSSL TLS client/server. Provided reference user_settings.h with comments and enable/disable gates. Added README.md with overview and instructions. Fixed issue building master with NO_WOLFSSL_DIR defined. Added check if old TLS is enabled that SHA and MD5 are enabled. Cleanup of the wolfCrypt test use of USE_CERT_BUFFERS with file system enabled.

pull/778/head
David Garske 2017-03-13 09:48:55 -07:00
parent a6cbfe6f93
commit e98a0465ae
30 changed files with 2844 additions and 893 deletions

1
.gitignore vendored
View File

@ -190,3 +190,4 @@ wrapper/CSharp/x64/
# Visual Studio Code Workspace Files
*.vscode
IDE/INTIME-RTOS/Debug_*

View File

@ -0,0 +1,53 @@
# tenAsys INtime RTOS Port
## Overview
This port is for the tenAsys INtime RTOS available [here](http://www.tenasys.com/tenasys-products/intime-rtos-family/overview-rtos).
To enable use the define `INTIME_RTOS`.
## Usage
The wolfExamples.sln is a Visual Studio 2015 project. You must have the INtime SDK installed and an INtime RTOS agent running.
The default configuration is set inside the `IDE/INTIME-RTOS/user_settings.h` file.
The example application provides a simple menu interface to select difference application functions to test.
```
wolfExamples started
wolfExamples finished initialization
MENU
t. WolfCrypt Test
b. WolfCrypt Benchmark
c. WolfSSL Client Example
s. WolfSSL Server Example
l. WolfSSL Localhost Client/Server Example
Please select one of the above options:
```
### `t`wolfCrypt Test
Performs testing of all crypto algorithms.
### `b` wolfCrypt Benchmark
Performs benchmark of crypto algorithms.
### `c` wolfSSL Client
To configure the host address and port modify the `TLS_HOST_REMOTE` and `TLS_PORT` macros at top of `wolfExamples.c`. This example uses TLS 1.2 to connect to a remote host.
### `s` wolfSSL Server
To configure the port to listen on modify `TLS_PORT` at top of `wolfExamples.c`.
### `l` wolfSSL Localhost Server/Client
Starts a TLS server thread listening on localhost. Starts the TLS client and performs connect, exchanges some data and disconnects.
## References
For more information please contact info@wolfssl.com.

View File

@ -0,0 +1,13 @@
# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root
EXTRA_DIST += \
IDE/INTIME-RTOS/README.md \
IDE/INTIME-RTOS/user_settings.h \
IDE/INTIME-RTOS/libwolfssl.c \
IDE/INTIME-RTOS/libwolfssl.vcxproj \
IDE/INTIME-RTOS/wolfExamples.c \
IDE/INTIME-RTOS/wolfExamples.h \
IDE/INTIME-RTOS/wolfExamples.vcxproj \
IDE/INTIME-RTOS/wolfExamples.sln

View File

@ -0,0 +1,20 @@
// libwolfssl.c
// Defines the entry point for the DLL application
#include <rt.h>
BOOLEAN __stdcall RslMain( RTHANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call) {
case RSL_PROCESS_ATTACH:
case RSL_THREAD_ATTACH:
case RSL_THREAD_DETACH:
case RSL_PROCESS_DETACH:
break;
}
return TRUE;
}

View File

@ -0,0 +1,225 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|INtime">
<Configuration>Debug</Configuration>
<Platform>INtime</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|INtime">
<Configuration>Release</Configuration>
<Platform>INtime</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<Text Include="README.md" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="libwolfssl.c" />
<ClCompile Include="..\..\src\crl.c" />
<ClCompile Include="..\..\src\internal.c" />
<ClCompile Include="..\..\src\io.c" />
<ClCompile Include="..\..\src\keys.c" />
<ClCompile Include="..\..\src\ocsp.c" />
<ClCompile Include="..\..\src\sniffer.c" />
<ClCompile Include="..\..\src\ssl.c" />
<ClCompile Include="..\..\src\tls.c" />
<ClCompile Include="..\..\wolfcrypt\src\aes.c" />
<ClCompile Include="..\..\wolfcrypt\src\arc4.c" />
<ClCompile Include="..\..\wolfcrypt\src\asm.c" />
<ClCompile Include="..\..\wolfcrypt\src\asn.c" />
<ClCompile Include="..\..\wolfcrypt\src\async.c" />
<ClCompile Include="..\..\wolfcrypt\src\blake2b.c" />
<ClCompile Include="..\..\wolfcrypt\src\camellia.c" />
<ClCompile Include="..\..\wolfcrypt\src\chacha.c" />
<ClCompile Include="..\..\wolfcrypt\src\chacha20_poly1305.c" />
<ClCompile Include="..\..\wolfcrypt\src\cmac.c" />
<ClCompile Include="..\..\wolfcrypt\src\coding.c" />
<ClCompile Include="..\..\wolfcrypt\src\compress.c" />
<ClCompile Include="..\..\wolfcrypt\src\curve25519.c" />
<ClCompile Include="..\..\wolfcrypt\src\des3.c" />
<ClCompile Include="..\..\wolfcrypt\src\dh.c" />
<ClCompile Include="..\..\wolfcrypt\src\dsa.c" />
<ClCompile Include="..\..\wolfcrypt\src\ecc.c" />
<ClCompile Include="..\..\wolfcrypt\src\ecc_fp.c" />
<ClCompile Include="..\..\wolfcrypt\src\ed25519.c" />
<ClCompile Include="..\..\wolfcrypt\src\error.c" />
<ClCompile Include="..\..\wolfcrypt\src\fe_low_mem.c" />
<ClCompile Include="..\..\wolfcrypt\src\fe_operations.c" />
<ClCompile Include="..\..\wolfcrypt\src\ge_low_mem.c" />
<ClCompile Include="..\..\wolfcrypt\src\ge_operations.c" />
<ClCompile Include="..\..\wolfcrypt\src\hash.c" />
<ClCompile Include="..\..\wolfcrypt\src\hc128.c" />
<ClCompile Include="..\..\wolfcrypt\src\hmac.c" />
<ClCompile Include="..\..\wolfcrypt\src\idea.c" />
<ClCompile Include="..\..\wolfcrypt\src\integer.c" />
<ClCompile Include="..\..\wolfcrypt\src\logging.c" />
<ClCompile Include="..\..\wolfcrypt\src\md2.c" />
<ClCompile Include="..\..\wolfcrypt\src\md4.c" />
<ClCompile Include="..\..\wolfcrypt\src\md5.c" />
<ClCompile Include="..\..\wolfcrypt\src\memory.c" />
<ClCompile Include="..\..\wolfcrypt\src\pkcs12.c" />
<ClCompile Include="..\..\wolfcrypt\src\pkcs7.c" />
<ClCompile Include="..\..\wolfcrypt\src\poly1305.c" />
<ClCompile Include="..\..\wolfcrypt\src\pwdbased.c" />
<ClCompile Include="..\..\wolfcrypt\src\rabbit.c" />
<ClCompile Include="..\..\wolfcrypt\src\random.c" />
<ClCompile Include="..\..\wolfcrypt\src\ripemd.c" />
<ClCompile Include="..\..\wolfcrypt\src\rsa.c" />
<ClCompile Include="..\..\wolfcrypt\src\sha.c" />
<ClCompile Include="..\..\wolfcrypt\src\sha256.c" />
<ClCompile Include="..\..\wolfcrypt\src\sha512.c" />
<ClCompile Include="..\..\wolfcrypt\src\signature.c" />
<ClCompile Include="..\..\wolfcrypt\src\srp.c" />
<ClCompile Include="..\..\wolfcrypt\src\tfm.c" />
<ClCompile Include="..\..\wolfcrypt\src\wc_encrypt.c" />
<ClCompile Include="..\..\wolfcrypt\src\wc_port.c" />
<ClCompile Include="..\..\wolfcrypt\src\wolfevent.c" />
<ClCompile Include="..\..\wolfcrypt\src\wolfmath.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="user_settings.h" />
<ClInclude Include="..\..\wolfssl\callbacks.h" />
<ClInclude Include="..\..\wolfssl\certs_test.h" />
<ClInclude Include="..\..\wolfssl\crl.h" />
<ClInclude Include="..\..\wolfssl\error-ssl.h" />
<ClInclude Include="..\..\wolfssl\internal.h" />
<ClInclude Include="..\..\wolfssl\ocsp.h" />
<ClInclude Include="..\..\wolfssl\options.h" />
<ClInclude Include="..\..\wolfssl\sniffer.h" />
<ClInclude Include="..\..\wolfssl\sniffer_error.h" />
<ClInclude Include="..\..\wolfssl\ssl.h" />
<ClInclude Include="..\..\wolfssl\test.h" />
<ClInclude Include="..\..\wolfssl\version.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\aes.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\arc4.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\asn.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\asn_public.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\async.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\blake2-impl.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\blake2-int.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\blake2.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\camellia.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\chacha.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\chacha20_poly1305.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\cmac.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\coding.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\compress.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\curve25519.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\des3.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\dh.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\dsa.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\ecc.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\ed25519.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\error-crypt.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\fe_operations.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\fips_test.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\ge_operations.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\hash.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\hc128.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\hmac.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\idea.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\integer.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\logging.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\md2.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\md4.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\md5.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\memory.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\mem_track.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\misc.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\mpi_class.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\mpi_superclass.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\pkcs12.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\pkcs7.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\poly1305.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\pwdbased.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\rabbit.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\random.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\ripemd.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\rsa.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\settings.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\sha.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\sha256.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\sha512.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\signature.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\srp.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\tfm.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\types.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\visibility.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\wc_encrypt.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\wc_port.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\wolfevent.h" />
<ClInclude Include="..\..\wolfssl\wolfcrypt\wolfmath.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1731767D-573F-45C9-A466-191DA0D180CF}</ProjectGuid>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|INtime'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|INtime'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'">
<IntDir>$(Configuration)_$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|INtime'">
<IntDir>$(Configuration)_$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'">
<ClCompile>
</ClCompile>
<Link>
<Version>21076.20052</Version>
<AdditionalOptions>/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>rt.lib;pcibus.lib;netlib.lib;clib.lib;vshelper.lib</AdditionalDependencies>
<OutputFile>$(SolutionDir)$(Configuration)\\libwolfssl.rsl</OutputFile>
</Link>
<ClCompile>
<ExceptionHandling>Async</ExceptionHandling>
<PreprocessorDefinitions>_USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|INtime'">
<ClCompile>
</ClCompile>
<Link>
<Version>21076.20052</Version>
<AdditionalOptions>/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>rt.lib;pcibus.lib;netlib.lib;clib.lib;vshelper.lib</AdditionalDependencies>
<OutputFile>$(SolutionDir)$(Configuration)\\libwolfssl.rsl</OutputFile>
</Link>
<ClCompile>
<ExceptionHandling>Async</ExceptionHandling>
<PreprocessorDefinitions>_USRDLL;WOLFSSL_DLL;BUILDING_WOLFSSL;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,506 @@
/* Example custom user settings for wolfSSL and INtime RTOS port */
#ifndef WOLFSSL_USER_SETTINGS_H
#define WOLFSSL_USER_SETTINGS_H
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------------------------------------------------------- */
/* Port - Platform */
/* ------------------------------------------------------------------------- */
#undef INTIME_RTOS
#define INTIME_RTOS
#undef INTIME_RTOS_MUTEX_MAX
#define INTIME_RTOS_MUTEX_MAX 10
#undef WOLF_EXAMPLES_STACK
#define WOLF_EXAMPLES_STACK 131072
#undef WOLFSSL_GENERAL_ALIGNMENT
#define WOLFSSL_GENERAL_ALIGNMENT 4
/* platform already has min()/max() */
#undef WOLFSSL_HAVE_MIN
#define WOLFSSL_HAVE_MIN
#undef WOLFSSL_HAVE_MAX
#define WOLFSSL_HAVE_MAX
/* disable directory support */
#undef NO_WOLFSSL_DIR
#define NO_WOLFSSL_DIR
#undef NO_WRITEV
#define NO_WRITEV
#undef NO_MAIN_DRIVER
#define NO_MAIN_DRIVER
/* if using in single threaded mode */
#undef SINGLE_THREADED
//#define SINGLE_THREADED
/* reduces stack usage, by using malloc/free for stack variables over 100 bytes */
#undef WOLFSSL_SMALL_STACK
//#define WOLFSSL_SMALL_STACK
/* ------------------------------------------------------------------------- */
/* Math Configuration */
/* ------------------------------------------------------------------------- */
/* fast math uses stack and inline assembly to speed up math */
#undef USE_FAST_MATH
#define USE_FAST_MATH
#ifdef USE_FAST_MATH
/* timing resistance for side-channel attack protection */
#undef TFM_TIMING_RESISTANT
#define TFM_TIMING_RESISTANT
#endif
/* ------------------------------------------------------------------------- */
/* Crypto */
/* ------------------------------------------------------------------------- */
/* ECC */
#if 1
#undef HAVE_ECC
#define HAVE_ECC
/* Support for custom curves */
#define WOLFSSL_CUSTOM_CURVES
/* Curve types */
//#define NO_ECC_SECP
#define HAVE_ECC_SECPR2
#define HAVE_ECC_SECPR3
#define HAVE_ECC_BRAINPOOL
#define HAVE_ECC_KOBLITZ
/* Curve sizes */
#undef HAVE_ALL_CURVES
//#define HAVE_ALL_CURVES
#ifndef HAVE_ALL_CURVES
#undef ECC_USER_CURVES
#define ECC_USER_CURVES
#define HAVE_ECC192
#define HAVE_ECC224
//#define NO_ECC256
#define HAVE_ECC384
#define HAVE_ECC521
#endif
/* Fixed point cache (speeds repeated operations against same private key) */
#undef FP_ECC
#define FP_ECC
#ifdef FP_ECC
/* Bits / Entries */
#undef FP_ENTRIES
#define FP_ENTRIES 2
#undef FP_LUT
#define FP_LUT 4
#endif
/* Optional ECC calculation method */
/* Note: doubles heap usage, but slightly faster */
#undef ECC_SHAMIR
#define ECC_SHAMIR
/* Reduces heap usage, but slower */
/* timing resistance for side-channel attack protection */
#undef ECC_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#ifdef USE_FAST_MATH
/* use reduced size math buffers for ecc points */
#undef ALT_ECC_SIZE
#define ALT_ECC_SIZE
/* Enable TFM optimizations for ECC */
#if defined(HAVE_ECC192) || defined(HAVE_ALL_CURVES)
#define TFM_ECC192
#endif
#if defined(HAVE_ECC224) || defined(HAVE_ALL_CURVES)
#define TFM_ECC224
#endif
#if !defined(NO_ECC256) || defined(HAVE_ALL_CURVES)
#define TFM_ECC256
#endif
#if defined(HAVE_ECC384) || defined(HAVE_ALL_CURVES)
#define TFM_ECC384
#endif
#if defined(HAVE_ECC521) || defined(HAVE_ALL_CURVES)
#define TFM_ECC521
#endif
#endif
#endif
/* RSA */
#undef NO_RSA
#if 1
#ifdef USE_FAST_MATH
/* Maximum math bits (Max RSA key bits * 2) */
#undef FP_MAX_BITS
#define FP_MAX_BITS 4096
#endif
/* half as much memory but twice as slow */
#undef RSA_LOW_MEM
//#define RSA_LOW_MEM
/* RSA blinding countermeasures */
#undef WC_RSA_BLINDING
#define WC_RSA_BLINDING
#else
#define NO_RSA
#endif
/* AES */
#undef NO_AES
#if 1
#undef HAVE_AESGCM
#define HAVE_AESGCM
#ifdef HAVE_AESGCM
/* GCM Method: GCM_SMALL, GCM_WORD32 or GCM_TABLE */
//#define GCM_SMALL
#define GCM_TABLE
#endif
#undef WOLFSSL_AES_COUNTER
#define WOLFSSL_AES_COUNTER
#undef HAVE_AESCCM
#define HAVE_AESCCM
#undef WOLFSSL_AES_DIRECT
#define WOLFSSL_AES_DIRECT
#undef HAVE_AES_KEYWRAP
#define HAVE_AES_KEYWRAP
#else
#define NO_AES
#endif
/* ChaCha20 / Poly1305 */
#undef HAVE_CHACHA
#undef HAVE_POLY1305
#if 1
#define HAVE_CHACHA
#define HAVE_POLY1305
/* Needed for Poly1305 */
#undef HAVE_ONE_TIME_AUTH
#define HAVE_ONE_TIME_AUTH
#endif
/* Ed25519 / Curve25519 */
#undef HAVE_CURVE25519
#undef HAVE_ED25519
#if 1
#define HAVE_CURVE25519
#define HAVE_ED25519
/* Optionally use small math (less flash usage, but much slower) */
#if 0
#define CURVED25519_SMALL
#endif
#endif
/* ------------------------------------------------------------------------- */
/* Hashing */
/* ------------------------------------------------------------------------- */
/* Sha */
#undef NO_SHA
#if 1
/* 1k smaller, but 25% slower */
//#define USE_SLOW_SHA
#else
#define NO_SHA
#endif
/* Sha256 */
#undef NO_SHA256
#if 1
#else
#define NO_SHA256
#endif
/* Sha512 */
#undef WOLFSSL_SHA512
#if 1
#define WOLFSSL_SHA512
/* Sha384 */
#undef WOLFSSL_SHA384
#if 1
#define WOLFSSL_SHA384
#endif
/* over twice as small, but 50% slower */
//#define USE_SLOW_SHA2
#endif
/* MD5 */
#undef NO_MD5
#if 1
#else
#define NO_MD5
#endif
/* ------------------------------------------------------------------------- */
/* Enable Features */
/* ------------------------------------------------------------------------- */
#undef KEEP_PEER_CERT
#define KEEP_PEER_CERT
#undef HAVE_COMP_KEY
#define HAVE_COMP_KEY
#undef HAVE_ECC_ENCRYPT
#define HAVE_ECC_ENCRYPT
#undef HAVE_TLS_EXTENSIONS
#define HAVE_TLS_EXTENSIONS
#undef HAVE_SUPPORTED_CURVES
#define HAVE_SUPPORTED_CURVES
#undef HAVE_EXTENDED_MASTER
#define HAVE_EXTENDED_MASTER
#undef WOLFSSL_DTLS
#define WOLFSSL_DTLS
#undef OPENSSL_EXTRA
#define OPENSSL_EXTRA
#undef WOLFSSL_BASE64_ENCODE
#define WOLFSSL_BASE64_ENCODE
#undef HAVE_HKDF
#define HAVE_HKDF
#undef WOLFSSL_CMAC
#define WOLFSSL_CMAC
#undef WOLFSSL_KEY_GEN
#define WOLFSSL_KEY_GEN
#undef WOLFSSL_CERT_GEN
#define WOLFSSL_CERT_GEN
#undef WOLFSSL_CERT_REQ
#define WOLFSSL_CERT_REQ
#undef WOLFSSL_CERT_EXT
#define WOLFSSL_CERT_EXT
#undef HAVE_PK_CALLBACKS
#define HAVE_PK_CALLBACKS
#undef HAVE_ALPN
#define HAVE_ALPN
#undef HAVE_SNI
#define HAVE_SNI
#undef HAVE_MAX_FRAGMENT
#define HAVE_MAX_FRAGMENT
#undef HAVE_TRUNCATED_HMAC
#define HAVE_TRUNCATED_HMAC
#undef SESSION_CERTS
#define SESSION_CERTS
#undef HAVE_SESSION_TICKET
#define HAVE_SESSION_TICKET
#undef WOLFCRYPT_HAVE_SRP
#define WOLFCRYPT_HAVE_SRP
#undef WOLFSSL_HAVE_CERT_SERVICE
#define WOLFSSL_HAVE_CERT_SERVICE
#undef HAVE_PKCS7
#define HAVE_PKCS7
#undef HAVE_X963_KDF
#define HAVE_X963_KDF
#undef WOLFSSL_HAVE_WOLFSCEP
#define WOLFSSL_HAVE_WOLFSCEP
#undef WOLFSSL_ALWAYS_KEEP_SNI
#define WOLFSSL_ALWAYS_KEEP_SNI
#undef WOLFSSL_ALWAYS_VERIFY_CB
#define WOLFSSL_ALWAYS_VERIFY_CB
#undef WOLFSSL_SEP
#define WOLFSSL_SEP
#undef ATOMIC_USER
#define ATOMIC_USER
#undef HAVE_OCSP
#define HAVE_OCSP
#undef HAVE_CERTIFICATE_STATUS_REQUEST
#define HAVE_CERTIFICATE_STATUS_REQUEST
#undef HAVE_CERTIFICATE_STATUS_REQUEST_V2
#define HAVE_CERTIFICATE_STATUS_REQUEST_V2
#undef HAVE_CRL
#define HAVE_CRL
#undef PERSIST_CERT_CACHE
//#define PERSIST_CERT_CACHE
#undef PERSIST_SESSION_CACHE
//#define PERSIST_SESSION_CACHE
#undef WOLFSSL_DER_LOAD
//#define WOLFSSL_DER_LOAD
#undef WOLFSSL_DES_ECB
//#define WOLFSSL_DES_ECB
#undef HAVE_CAMELLIA
//#define HAVE_CAMELLIA
#undef HAVE_NULL_CIPHER
//#define HAVE_NULL_CIPHER
#undef WOLFSSL_RIPEMD
//#define WOLFSSL_RIPEMD
/* TLS Session Cache */
#if 1
#define SMALL_SESSION_CACHE
//#define MEDIUM_SESSION_CACHE
//#define BIG_SESSION_CACHE
//#define HUGE_SESSION_CACHE
#else
#define NO_SESSION_CACHE
#endif
/* ------------------------------------------------------------------------- */
/* Disable Features */
/* ------------------------------------------------------------------------- */
#undef NO_WOLFSSL_SERVER
//#define NO_WOLFSSL_SERVER
#undef NO_WOLFSSL_CLIENT
//#define NO_WOLFSSL_CLIENT
/* disables TLS 1.0/1.1 support */
#undef NO_OLD_TLS
//#define NO_OLD_TLS
/* disable access to filesystem */
#undef NO_FILESYSTEM
//#define NO_FILESYSTEM
#undef NO_RC4
#define NO_RC4
#undef NO_HC128
#define NO_HC128
#undef NO_RABBIT
#define NO_RABBIT
#undef NO_MD4
#define NO_MD4
/* Pre-shared keys */
#undef NO_PSK
//#define NO_PSK
#undef NO_DSA
//#define NO_DSA
#undef NO_DH
//#define NO_DH
#undef NO_DES3
//#define NO_DES3
#undef NO_PWDBASED
//#define NO_PWDBASED
/* encoding/decoding support */
#undef NO_CODING
//#define NO_CODING
/* memory wrappers and memory callbacks */
#undef NO_WOLFSSL_MEMORY
//#define NO_WOLFSSL_MEMORY
/* In-lining of misc.c functions */
/* If defined, must include wolfcrypt/src/misc.c in build */
/* Slower, but about 1k smaller */
#undef NO_INLINE
//#define NO_INLINE
/* ------------------------------------------------------------------------- */
/* Benchmark / Test */
/* ------------------------------------------------------------------------- */
#undef NO_CRYPT_TEST
//#define NO_CRYPT_TEST
#undef NO_CRYPT_BENCHMARK
//#define NO_CRYPT_BENCHMARK
/* Use reduced benchmark / test sizes */
#undef BENCH_EMBEDDED
#define BENCH_EMBEDDED
#undef USE_CERT_BUFFERS_2048
#define USE_CERT_BUFFERS_2048
#undef USE_CERT_BUFFERS_256
#define USE_CERT_BUFFERS_256
/* ------------------------------------------------------------------------- */
/* Debugging */
/* ------------------------------------------------------------------------- */
#undef WOLFSSL_DEBUG
#define WOLFSSL_DEBUG
#ifdef WOLFSSL_DEBUG
/* Use this to measure / print heap usage */
#if 0
#undef USE_WOLFSSL_MEMORY
#define USE_WOLFSSL_MEMORY
#undef WOLFSSL_TRACK_MEMORY
#define WOLFSSL_TRACK_MEMORY
#endif
/* Math debugging (adds support for mp_dump) */
#undef WOLFSSL_DEBUG_MATH
//#define WOLFSSL_DEBUG_MATH
#else
#undef NO_ERROR_STRINGS
//#define NO_ERROR_STRINGS
#endif
#ifdef __cplusplus
}
#endif
#endif /* WOLFSSL_USER_SETTINGS_H */

View File

@ -0,0 +1,619 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <rt.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <io.h>
#include "wolfExamples.h"
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <wolfssl/certs_test.h>
#include <wolfcrypt/test/test.h>
#include <wolfcrypt/benchmark/benchmark.h>
/*****************************************************************************
* Globals
****************************************************************************/
RTHANDLE hRootProcess;
DWORD dwKtickInUsecs;
INIT_STRUCT gInit;
static int gServerExit = 0;
static int gServerReady = 0;
static const char menu1[] = "\r\n"
"\tt. WolfCrypt Test\r\n"
"\tb. WolfCrypt Benchmark\r\n"
"\tc. WolfSSL Client Example\r\n"
"\ts. WolfSSL Server Example\r\n"
"\tl. WolfSSL Localhost Client/Server Example\r\n";
/*****************************************************************************
* Configuration
****************************************************************************/
#define TLS_MAXDATASIZE 4096 /* maximum acceptable amount of data */
#define TLS_PORT 11111 /* define default port number */
#define TLS_HOST_LOCAL "127.0.0.1"
#define TLS_HOST_REMOTE "192.168.0.112"
#define SOCK_MAX_PENDING 5
#define THREAD_BASE_PRIO 150
/*****************************************************************************
* TLS Client
****************************************************************************/
int wolfExample_TLSClient(const char* ip, int port)
{
int ret = 0;
WOLFSSL_CTX* ctx = NULL;
WOLFSSL* ssl = NULL; /* create WOLFSSL object */
int sockFd = -1; /* socket file descriptor */
struct sockaddr_in servAddr; /* struct for server address */
char sendBuff[TLS_MAXDATASIZE], rcvBuff[TLS_MAXDATASIZE];
/* wait for server to be ready */
while (gServerReady != 1) {
RtSleep(0);
}
sockFd = socket(AF_INET, SOCK_STREAM, 0);
if (sockFd < 0) {
printf("Failed to create socket. Error: %d\n", errno);
return errno;
}
memset(&servAddr, 0, sizeof(servAddr)); /* clears memory block for use */
servAddr.sin_family = AF_INET; /* sets addressfamily to internet*/
servAddr.sin_port = htons(port); /* sets port to defined port */
/* looks for the server at the entered address (ip in the command line) */
if (inet_pton(AF_INET, ip, &servAddr.sin_addr) < 1) {
/* checks validity of address */
ret = errno;
printf("Invalid Address. Error: %d\n", ret);
goto exit;
}
if (connect(sockFd, (struct sockaddr *)&servAddr, sizeof(servAddr)) < 0) {
/* if socket fails to connect to the server*/
ret = errno;
printf("Connect error. Error: %d\n", ret);
goto exit;
}
/* create and initialize WOLFSSL_CTX structure */
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
printf("SSL_CTX_new error.\n");
goto exit;
}
/* load CA certificates into wolfSSL_CTX. which will verify the server */
ret = wolfSSL_CTX_load_verify_buffer(ctx, ca_cert_der_2048,
sizeof_ca_cert_der_2048, SSL_FILETYPE_ASN1);
if (ret != SSL_SUCCESS) {
printf("Error %d loading CA cert\n", ret);
goto exit;
}
if ((ssl = wolfSSL_new(ctx)) == NULL) {
printf("wolfSSL_new error.\n");
goto exit;
}
wolfSSL_set_fd(ssl, sockFd);
ret = wolfSSL_connect(ssl);
if (ret == SSL_SUCCESS) {
printf("Message for server:\t");
fgets(sendBuff, TLS_MAXDATASIZE, stdin);
if (wolfSSL_write(ssl, sendBuff, strlen(sendBuff)) != strlen(sendBuff)) {
/* the message is not able to send, or error trying */
ret = wolfSSL_get_error(ssl, 0);
printf("Write error: Error: %d\n", ret);
goto exit;
}
memset(rcvBuff, 0, TLS_MAXDATASIZE);
if (wolfSSL_read(ssl, rcvBuff, TLS_MAXDATASIZE) < 0) {
/* the server failed to send data, or error trying */
ret = wolfSSL_get_error(ssl, 0);
printf("Read error. Error: %d\n", ret);
goto exit;
}
printf("Recieved: \t%s\n", rcvBuff);
}
exit:
/* frees all data before client termination */
if (sockFd != -1)
close(sockFd);
wolfSSL_free(ssl);
wolfSSL_CTX_free(ctx);
gServerExit = 1;
return ret;
}
/*****************************************************************************
* TLS Server
****************************************************************************/
int wolfExample_TLSServer(int port)
{
int ret = 0;
WOLFSSL_CTX* ctx = NULL;
WOLFSSL* ssl = NULL;
int sockFd = -1, clientFd = -1;
struct sockaddr_in serverAddr = {0}, clientAddr = {0};
const char reply[] = "I hear ya fa shizzle!\n";
int addrSize = sizeof(clientAddr);
char buff[256];
sockFd = socket(AF_INET, SOCK_STREAM, 0);
if (sockFd < 0) {
printf("Failed to create socket. Error: %d\n", errno);
return errno;
}
/* create and initialize WOLFSSL_CTX structure */
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method())) == NULL) {
fprintf(stderr, "wolfSSL_CTX_new error.\n");
goto exit;
}
/* Load server certificate into WOLFSSL_CTX */
ret = wolfSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048,
sizeof_server_cert_der_2048, SSL_FILETYPE_ASN1);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "Error %d loading server-cert!\n", ret);
goto exit;
}
/* Load server key into WOLFSSL_CTX */
ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, server_key_der_2048,
sizeof_server_key_der_2048, SSL_FILETYPE_ASN1);
if (ret != SSL_SUCCESS) {
fprintf(stderr, "Error %d loading server-key!\n", ret);
goto exit;
}
/* Initialize the server address struct to zero */
memset((char *)&serverAddr, 0, sizeof(serverAddr));
/* Fill the server's address family */
serverAddr.sin_family = AF_INET;
serverAddr.sin_addr.s_addr = INADDR_ANY;
serverAddr.sin_port = htons(port);
/* Attach the server socket to our port */
if (bind(sockFd, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) {
printf("ERROR: failed to bind\n");
goto exit;
}
printf("Waiting for a connection...\n");
gServerReady = 1;
/* Continuously accept connects while not in an active connection */
while (gServerExit == 0) {
/* listen for a new connection */
ret = listen(sockFd, SOCK_MAX_PENDING);
if (ret == 0) {
/* Wait until a client connects */
clientFd = accept(sockFd, (struct sockaddr*)&clientAddr, &addrSize);
/* If fails to connect, loop back up and wait for a new connection */
if (clientFd == -1) {
printf("failed to accept the connection..\n");
}
/* If it connects, read in and reply to the client */
else {
printf("Client connected successfully\n");
ssl = wolfSSL_new(ctx);
if (ssl == NULL) {
fprintf(stderr, "wolfSSL_new error.\n");
break;
}
/* direct our ssl to our clients connection */
wolfSSL_set_fd(ssl, clientFd);
printf("Using Non-Blocking I/O: %d\n",
wolfSSL_get_using_nonblock(ssl));
for ( ; ; ) {
/* Clear the buffer memory for anything possibly left over */
memset(&buff, 0, sizeof(buff));
/* Read the client data into our buff array */
ret = wolfSSL_read(ssl, buff, sizeof(buff) - 1);
if (ret > 0) {
/* Print any data the client sends to the console */
printf("Client: %s\n", buff);
/* Reply back to the client */
ret = wolfSSL_write(ssl, reply, sizeof(reply) - 1);
if (ret < 0) {
printf("wolfSSL_write error = %d\n",
wolfSSL_get_error(ssl, ret));
gServerExit = 1;
break;
}
}
/* if the client disconnects break the loop */
else {
if (ret < 0)
printf("wolfSSL_read error = %d\n",
wolfSSL_get_error(ssl, ret));
else if (ret == 0)
printf("The client has closed the connection.\n");
gServerExit = 1;
break;
}
}
wolfSSL_free(ssl); /* Free the WOLFSSL object */
ssl = NULL;
}
close(clientFd); /* close the connected socket */
clientFd = -1;
}
} /* while */
exit:
if (clientFd != -1)
close(clientFd);
if (sockFd != -1)
close(sockFd);
wolfSSL_free(ssl); /* Free the WOLFSSL object */
wolfSSL_CTX_free(ctx); /* Free WOLFSSL_CTX */
return ret;
}
/*****************************************************************************
* TLS Local Test
****************************************************************************/
static void wolfSSLLocalServerThread(void* param)
{
int port = (int)((int*)param);
wolfExample_TLSServer(port);
}
int wolfExample_TLSLocal(int port)
{
int ret;
RTHANDLE srvHandle;
/* start server thread */
srvHandle = CreateRtThread(THREAD_BASE_PRIO + 10,
(LPPROC)wolfSSLLocalServerThread, WOLF_EXAMPLES_STACK, (void*)port);
if (srvHandle == BAD_RTHANDLE) {
Fail("Cannot create server thread");
return -1;
}
/* run client */
ret = wolfExample_TLSClient(TLS_HOST_LOCAL, port);
return ret;
}
/*****************************************************************************
* Thread
memset(&args, 0, sizeof(args));
****************************************************************************/
typedef struct func_args {
int argc;
char** argv;
int return_code;
} func_args;
static void wolfExampleThread(void* param)
{
func_args args;
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
/* initialize wolfSSL */
wolfSSL_Init();
while (1) {
char rc;
gServerExit = 0;
gServerReady = 0;
printf("\r\n\t\t\t\tMENU\r\n");
printf(menu1);
printf("Please select one of the above options: ");
rc = getchar();
switch (rc) {
case 't':
printf("\nCrypt Test\n");
wolfcrypt_test(&args);
printf("Crypt Test: Return code %d\n", args.return_code);
break;
case 'b':
printf("\nBenchmark Test\n");
benchmark_test(&args);
printf("Benchmark Test: Return code %d\n", args.return_code);
break;
case 'c':
wolfExample_TLSClient(TLS_HOST_REMOTE, TLS_PORT);
break;
case 's':
wolfExample_TLSServer(TLS_PORT);
break;
case 'l':
wolfExample_TLSLocal(TLS_PORT);
break;
// All other cases go here
default:
if (rc != '\r' && rc != '\n')
printf("\r\nSelection %c out of range\r\n", rc);
break;
}
}
wolfSSL_Cleanup();
}
/*****************************************************************************
* FUNCTION: Catalog
*
* PARAMETERS: 1. handle of the process whose object directory must be used
* 2. the object whose handle must be cataloged
* 3. the name to be used (upto 14 characters)
*
* RETURNS: TRUE on success
*
* DESCRIPTION: If the given name already exists,
* and the existing name refers to a non-existing object,
* then the existing name is removed before cataloging.
\*****************************************************************************/
BOOLEAN Catalog(
RTHANDLE hProcess,
RTHANDLE hObject,
LPSTR lpszName)
{
RTHANDLE hOld;
if (CatalogRtHandle(hProcess, hObject, lpszName))
return TRUE;
// something wrong: check for the case mentioned above
if (((hOld = LookupRtHandle(hProcess, lpszName, NO_WAIT)) != BAD_RTHANDLE) &&
(GetRtHandleType(hOld) == INVALID_TYPE))
{
// this is the case mentioned above: remove the old entry and try again
if (UncatalogRtHandle(hProcess, lpszName))
return (CatalogRtHandle(hProcess, hObject, lpszName));
}
return FALSE;
}
/*****************************************************************************
* FUNCTION: Cleanup (local function)
*
* DESCRIPTION:
* Tell threads to delete themselves and wait a while;
* if any thread still exists, kill it.
* Remove all other objects as far as they have been created.
\*****************************************************************************/
void Cleanup(void)
{
// indicate that we are cleaning up
gInit.state = CLEANUP_BUSY;
gInit.bShutdown = TRUE;
#ifdef _DEBUG
fprintf(stderr, "wolfExamples started cleaning up\n");
#endif
// remove our name from the root process
if (gInit.bCataloged) {
if (!UncatalogRtHandle(hRootProcess, "wolfExample"))
Fail("Cannot remove my own name");
}
#ifdef _DEBUG
fprintf(stderr, "wolfExamples finished cleaning up\n");
#endif
// lie down
exit(0);
}
/*****************************************************************************
* FUNCTION: Fail
*
* PARAMETERS: same parameters as expected by printf
*
* DESCRIPTION:
* If in debug mode, prints the message, appending a new line and the error number.
* Then the current process is killed graciously:
* If the current thread is the main thread, this is done directly.
* if the current thread is another one, a terminate request is sent and
* the function returns to the calling thread.
\*****************************************************************************/
void Fail(LPSTR lpszMessage, ...)
{
EXCEPTION eh;
RTHANDLE hDelMbx;
DWORD dwTerminate;
#ifdef _DEBUG
va_list ap;
va_start(ap, lpszMessage);
vfprintf(stderr, lpszMessage, ap);
va_end(ap);
fprintf(stderr, "\nError nr=%x %s\n", GetLastRtError(), GetRtErrorText(GetLastRtError()));
#endif
// make sure that exceptions are returned for inline handling
GetRtExceptionHandlerInfo(THREAD_HANDLER, &eh);
eh.ExceptionMode = 0;
SetRtExceptionHandler(&eh);
// if we had not started initializing yet, just get out
if (BEFORE_INIT == gInit.state)
exit(0);
if (gInit.hMain == GetRtThreadHandles(THIS_THREAD))
{
// this is the main thread:
// if we are busy initializing, then do Cleanup
if (INIT_BUSY == gInit.state)
Cleanup(); // does not return
// this is the main thread, but we are not initializing: just return
return;
}
// this is not the main thread:
// ask main thread to do cleanup
// (allow some time to setup the deletion mailbox, ignore errors)
hDelMbx = LookupRtHandle(NULL_RTHANDLE, "R?EXIT_MBOX", 5000);
dwTerminate = TERMINATE;
SendRtData(hDelMbx, &dwTerminate, 4);
}
/*****************************************************************************
*
* FUNCTION: UsecsToKticks
*
* PARAMETERS: 1. number of usecs
*
* RETURNS: number of low level ticks
*
* DESCRIPTION: returns the parameter if it is WAIT_FOREVER
* otherwise rounds up to number of low level ticks
\*****************************************************************************/
DWORD UsecsToKticks(DWORD dwUsecs)
{
if (dwUsecs == WAIT_FOREVER)
return WAIT_FOREVER;
return (dwUsecs + dwKtickInUsecs - 1) / dwKtickInUsecs;
}
/*****************************************************************************
* FUNCTION: main
*
* DESCRIPTION:
* This is the main program module.
* It creates global objects and all threads.
* The main thread then waits for notifications and acts accordingly
\*****************************************************************************/
int main(int argc, char* argv[])
{
SYSINFO sysinfo;
EVENTINFO eiEventInfo;
RTHANDLE taskHandle;
#ifdef _DEBUG
fprintf(stderr, "wolfExamples started\n");
#endif
// obtain handle of root process (cannot fail)
hRootProcess = GetRtThreadHandles(ROOT_PROCESS);
// initialize the structure for cleaning up
memset(&gInit, 0, sizeof(gInit));
gInit.state = BEFORE_INIT;
// get low level tick length in usecs
if (!CopyRtSystemInfo(&sysinfo))
Fail("Cannot copy system info");
dwKtickInUsecs = 10000 / sysinfo.KernelTickRatio;
if (dwKtickInUsecs == 0)
Fail("Invalid low level tick length");
// adjust process max priority (ignore error)
// TODO adjust the 2nd parameter to a value closer to zero if you want to allow more priorities
SetRtProcessMaxPriority(NULL_RTHANDLE, THREAD_BASE_PRIO);
// obtain main thread's handle
gInit.hMain = GetRtThreadHandles(THIS_THREAD);
gInit.state = INIT_BUSY;
// attempt to catalog the thread but ignore error
Catalog(NULL_RTHANDLE, gInit.hMain, "TMain");
// catalog the handle of this process in the root process
if (!Catalog(hRootProcess, GetRtThreadHandles(THIS_PROCESS), "wolfExample")) {
Fail("Cannot catalog process name");
}
gInit.bCataloged = TRUE;
// create thread
taskHandle = CreateRtThread(THREAD_BASE_PRIO + 20,
(LPPROC)wolfExampleThread, WOLF_EXAMPLES_STACK, 0);
if (taskHandle == BAD_RTHANDLE) {
Fail("Cannot create thread");
}
// indicate that initialization has finished
gInit.state = INIT_DONE;
#ifdef _DEBUG
fprintf(stderr, "wolfExamples finished initialization\n");
#endif
// wait for notifications
while (RtNotifyEvent(RT_SYSTEM_NOTIFICATIONS | RT_EXIT_NOTIFICATIONS,
WAIT_FOREVER, &eiEventInfo))
{
switch(eiEventInfo.dwNotifyType)
{
case TERMINATE:
// TODO: this process should terminate
// cleanup the environment
Cleanup(); // does not return
case NT_HOST_UP:
// TODO: react to a Windows host that has come back
break;
case NT_BLUESCREEN:
// TODO: react to a Windows blue screen
break;
case KERNEL_STOPPING:
// TODO: react to the INtime kernel stopping
break;
case NT_HOST_HIBERNATE:
// TODO: react to the Windows host going in hibernation
break;
case NT_HOST_STANDBY:
// TODO: react to the Windows host going in standby mode
break;
case NT_HOST_SHUTDOWN_PENDING:
// TODO: react to a Windows host that is about to shutdown
break;
}
}
Fail("Notify failed");
return 0;
}

View File

@ -0,0 +1,47 @@
#ifndef _WOLFEXAMPLES_H_
#define _WOLFEXAMPLES_H_
#include <rt.h>
#ifdef __cplusplus
extern "C" {
#endif
// support functions for all threads
BOOLEAN Catalog(RTHANDLE hProcess, RTHANDLE hObject, LPSTR lpszName);
void Cleanup(void);
void Fail(LPSTR lpszMessage, ...);
DWORD UsecsToKticks(DWORD dwUsecs);
/* Example API's */
int wolfExample_TLSServer(int port);
int wolfExample_TLSClient(const char* ip, int port);
int wolfExample_TLSLocal(int port);
// global type definitions
typedef enum {
BEFORE_INIT,
INIT_BUSY,
INIT_DONE,
CLEANUP_BUSY
} INIT_STATE;
typedef struct {
RTHANDLE hMain; // RTHANDLE of main thread
INIT_STATE state; // main thread state
BOOLEAN bCataloged; // TRUE if we cataloged process name in root
BOOLEAN bShutdown; // TRUE if all threads have to terminate
} INIT_STRUCT;
// global variables
extern RTHANDLE hRootProcess; // RTHANDLE of root process
extern DWORD dwKtickInUsecs; // length of one low level tick in usecs
extern INIT_STRUCT gInit; // structure describing all global objects
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _WOLFEXAMPLES_H_ */

View File

@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wolfExamples", "wolfExamples.vcxproj", "{557A7EFD-2627-478A-A855-50F518DD13EE}"
ProjectSection(ProjectDependencies) = postProject
{1731767D-573F-45C9-A466-191DA0D180CF} = {1731767D-573F-45C9-A466-191DA0D180CF}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwolfssl", "libwolfssl.vcxproj", "{1731767D-573F-45C9-A466-191DA0D180CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|INtime = Debug|INtime
Release|INtime = Release|INtime
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{557A7EFD-2627-478A-A855-50F518DD13EE}.Debug|INtime.ActiveCfg = Debug|INtime
{557A7EFD-2627-478A-A855-50F518DD13EE}.Debug|INtime.Build.0 = Debug|INtime
{557A7EFD-2627-478A-A855-50F518DD13EE}.Release|INtime.ActiveCfg = Release|INtime
{557A7EFD-2627-478A-A855-50F518DD13EE}.Release|INtime.Build.0 = Release|INtime
{1731767D-573F-45C9-A466-191DA0D180CF}.Debug|INtime.ActiveCfg = Debug|INtime
{1731767D-573F-45C9-A466-191DA0D180CF}.Debug|INtime.Build.0 = Debug|INtime
{1731767D-573F-45C9-A466-191DA0D180CF}.Release|INtime.ActiveCfg = Release|INtime
{1731767D-573F-45C9-A466-191DA0D180CF}.Release|INtime.Build.0 = Release|INtime
{AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Debug|INtime.ActiveCfg = Debug|INtime
{AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Debug|INtime.Build.0 = Debug|INtime
{AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Release|INtime.ActiveCfg = Release|INtime
{AA35919C-9D2D-4753-8FD1-E5D1644ABE65}.Release|INtime.Build.0 = Release|INtime
{A7A65D11-2A66-4936-9476-16646CF896CA}.Debug|INtime.ActiveCfg = Debug|INtime
{A7A65D11-2A66-4936-9476-16646CF896CA}.Debug|INtime.Build.0 = Debug|INtime
{A7A65D11-2A66-4936-9476-16646CF896CA}.Release|INtime.ActiveCfg = Release|INtime
{A7A65D11-2A66-4936-9476-16646CF896CA}.Release|INtime.Build.0 = Release|INtime
{2359342B-C023-4443-8170-3471928C9334}.Debug|INtime.ActiveCfg = Debug|INtime
{2359342B-C023-4443-8170-3471928C9334}.Debug|INtime.Build.0 = Debug|INtime
{2359342B-C023-4443-8170-3471928C9334}.Release|INtime.ActiveCfg = Release|INtime
{2359342B-C023-4443-8170-3471928C9334}.Release|INtime.Build.0 = Release|INtime
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|INtime">
<Configuration>Debug</Configuration>
<Platform>INtime</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|INtime">
<Configuration>Release</Configuration>
<Platform>INtime</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<Text Include="README.md" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="wolfExamples.c" />
<ClCompile Include="..\..\wolfcrypt\test\test.c" />
<ClCompile Include="..\..\wolfcrypt\benchmark\benchmark.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="user_settings.h" />
<ClInclude Include="wolfExamples.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{557A7EFD-2627-478A-A855-50F518DD13EE}</ProjectGuid>
<ProjectName>wolfExamples</ProjectName>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|INtime'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>NotSet</CharacterSet>
<PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|INtime'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'">
<IntDir>$(Configuration)_$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|INtime'">
<IntDir>$(Configuration)_$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|INtime'">
<ClCompile>
</ClCompile>
<Link>
<Version>21076.20053</Version>
<AdditionalOptions>/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>rt.lib;pcibus.lib;netlib.lib;clib.lib;vshelper.lib;libwolfssl.lib</AdditionalDependencies>
<OutputFile>$(SolutionDir)$(Configuration)\\wolfExamples.rta</OutputFile>
<AdditionalLibraryDirectories>$(ProjectDir)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ClCompile>
<ExceptionHandling>Async</ExceptionHandling>
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|INtime'">
<ClCompile>
</ClCompile>
<Link>
<Version>21076.20053</Version>
<AdditionalOptions>/SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>rt.lib;pcibus.lib;netlib.lib;clib.lib;vshelper.lib;libwolfssl.lib</AdditionalDependencies>
<OutputFile>$(SolutionDir)$(Configuration)\\wolfExamples.rta</OutputFile>
<AdditionalLibraryDirectories>$(ProjectDir)$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<ClCompile>
<ExceptionHandling>Async</ExceptionHandling>
<PreprocessorDefinitions>WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\..\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
</ClCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -8,5 +8,6 @@ include IDE/WIN-SGX/include.am
include IDE/WORKBENCH/include.am
include IDE/ROWLEY-CROSSWORKS-ARM/include.am
include IDE/ARDUINO/include.am
include IDE/INTIME-RTOS/include.am
EXTRA_DIST+= IDE/IAR-EWARM IDE/MDK-ARM IDE/MDK5-ARM IDE/MYSQL IDE/LPCXPRESSO

View File

@ -246,7 +246,7 @@
/* Micrium will use Visual Studio for compilation but not the Win32 API */
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) \
&& !defined(EBSNET) && !defined(CYASSL_EROAD)
&& !defined(EBSNET) && !defined(CYASSL_EROAD) && !defined(INTIME_RTOS)
#define USE_WINDOWS_API
#endif

View File

@ -55,6 +55,7 @@ my @fileList_2048 = (
[ "./certs/dh2048.der", "dh_key_der_2048" ],
[ "./certs/dsa2048.der", "dsa_key_der_2048" ],
[ "./certs/rsa2048.der", "rsa_key_der_2048" ],
[ "./certs/ca-key.der", "ca_key_der_2048" ],
[ "./certs/ca-cert.der", "ca_cert_der_2048" ],
[ "./certs/server-key.der", "server_key_der_2048" ],
[ "./certs/server-cert.der", "server_cert_der_2048" ]

View File

@ -82,6 +82,15 @@
#include <errno.h>
#elif defined(WOLFSSL_ATMEL)
#include "socket/include/socket.h"
#elif defined(INTIME_RTOS)
#undef MIN
#undef MAX
#include <rt.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <io.h>
#else
#include <sys/types.h>
#include <errno.h>

View File

@ -5089,6 +5089,7 @@ int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX* ctx, const char* file,
ret = ProcessFile(ctx, file, SSL_FILETYPE_PEM, CA_TYPE, NULL, 0, NULL);
if (ret == SSL_SUCCESS && path) {
#ifndef NO_WOLFSSL_DIR
char* name = NULL;
#ifdef WOLFSSL_SMALL_STACK
ReadDirCtx* readCtx = NULL;
@ -5114,6 +5115,9 @@ int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX* ctx, const char* file,
#ifdef WOLFSSL_SMALL_STACK
XFREE(readCtx, ctx->heap, DYNAMIC_TYPE_TMP_BUFFER);
#endif
#else
ret = NOT_COMPILED_IN;
#endif
}
return ret;

View File

@ -1390,7 +1390,7 @@ static word16 TLSX_SNI_GetSize(SNI* list)
switch (sni->type) {
case WOLFSSL_SNI_HOST_NAME:
length += XSTRLEN((char*)sni->data.host_name);
length += (word16)XSTRLEN((char*)sni->data.host_name);
break;
}
}
@ -1412,7 +1412,7 @@ static word16 TLSX_SNI_Write(SNI* list, byte* output)
switch (sni->type) {
case WOLFSSL_SNI_HOST_NAME:
length = XSTRLEN((char*)sni->data.host_name);
length = (word16)XSTRLEN((char*)sni->data.host_name);
c16toa(length, output + offset); /* sni length */
offset += OPAQUE16_LEN;
@ -1675,7 +1675,7 @@ word16 TLSX_SNI_GetRequest(TLSX* extensions, byte type, void** data)
switch (sni->type) {
case WOLFSSL_SNI_HOST_NAME:
*data = sni->data.host_name;
return XSTRLEN((char*)*data);
return (word16)XSTRLEN((char*)*data);
}
}

View File

@ -2545,7 +2545,7 @@ void bench_ed25519KeySign(void)
#endif /* HAVE_ED25519 */
#ifdef _WIN32
#if defined(_WIN32) && !defined(INTIME_RTOS)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

View File

@ -183,7 +183,7 @@ static void raw_add(byte *x, const byte *p)
for (i = 0; i < F25519_SIZE; i++) {
c += ((word16)x[i]) + ((word16)p[i]);
x[i] = c;
x[i] = (byte)c;
c >>= 8;
}
}
@ -197,11 +197,11 @@ static void raw_try_sub(byte *x, const byte *p)
for (i = 0; i < F25519_SIZE; i++) {
c = ((word16)x[i]) - ((word16)p[i]) - c;
minusp[i] = c;
minusp[i] = (byte)c;
c = (c >> 8) & 1;
}
fprime_select(x, minusp, x, c);
fprime_select(x, minusp, x, (byte)c);
}
@ -271,7 +271,7 @@ void fprime_mul(byte *r, const byte *a, const byte *b,
for (j = 0; j < F25519_SIZE; j++) {
c |= ((word16)r[j]) << 1;
r[j] = c;
r[j] = (byte)c;
c >>= 8;
}
raw_try_sub(r, modulus);
@ -310,7 +310,7 @@ void fe_normalize(byte *x)
for (i = 0; i < F25519_SIZE; i++) {
c += x[i];
x[i] = c;
x[i] = (byte)c;
c >>= 8;
}
@ -322,12 +322,12 @@ void fe_normalize(byte *x)
for (i = 0; i + 1 < F25519_SIZE; i++) {
c += x[i];
minusp[i] = c;
minusp[i] = (byte)c;
c >>= 8;
}
c += ((word16)x[i]) - 128;
minusp[31] = c;
minusp[31] = (byte)c;
/* Load x-p if no underflow */
fe_select(x, minusp, x, (c >> 15) & 1);
@ -355,7 +355,7 @@ void fe_add(fe r, const fe a, const fe b)
for (i = 0; i < F25519_SIZE; i++) {
c >>= 8;
c += ((word16)a[i]) + ((word16)b[i]);
r[i] = c;
r[i] = (byte)c;
}
/* Reduce with 2^255 = 19 mod p */
@ -364,7 +364,7 @@ void fe_add(fe r, const fe a, const fe b)
for (i = 0; i < F25519_SIZE; i++) {
c += r[i];
r[i] = c;
r[i] = (byte)c;
c >>= 8;
}
}

4
wolfcrypt/src/fe_operations.c 100644 → 100755
View File

@ -942,7 +942,7 @@ replace (f,g) with (f,g) if b == 0.
Preconditions: b in {0,1}.
*/
void fe_cswap(fe f,fe g,unsigned int b)
void fe_cswap(fe f, fe g, int b)
{
int32_t f0 = f[0];
int32_t f1 = f[1];
@ -1353,7 +1353,7 @@ replace (f,g) with (f,g) if b == 0.
Preconditions: b in {0,1}.
*/
void fe_cmov(fe f,const fe g,unsigned int b)
void fe_cmov(fe f, const fe g, int b)
{
int32_t f0 = f[0];
int32_t f1 = f[1];

View File

@ -274,38 +274,38 @@ void sc_reduce(byte* s)
carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21;
carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21;
s[0] = s0 >> 0;
s[1] = s0 >> 8;
s[2] = (s0 >> 16) | (s1 << 5);
s[3] = s1 >> 3;
s[4] = s1 >> 11;
s[5] = (s1 >> 19) | (s2 << 2);
s[6] = s2 >> 6;
s[7] = (s2 >> 14) | (s3 << 7);
s[8] = s3 >> 1;
s[9] = s3 >> 9;
s[10] = (s3 >> 17) | (s4 << 4);
s[11] = s4 >> 4;
s[12] = s4 >> 12;
s[13] = (s4 >> 20) | (s5 << 1);
s[14] = s5 >> 7;
s[15] = (s5 >> 15) | (s6 << 6);
s[16] = s6 >> 2;
s[17] = s6 >> 10;
s[18] = (s6 >> 18) | (s7 << 3);
s[19] = s7 >> 5;
s[20] = s7 >> 13;
s[21] = s8 >> 0;
s[22] = s8 >> 8;
s[23] = (s8 >> 16) | (s9 << 5);
s[24] = s9 >> 3;
s[25] = s9 >> 11;
s[26] = (s9 >> 19) | (s10 << 2);
s[27] = s10 >> 6;
s[28] = (s10 >> 14) | (s11 << 7);
s[29] = s11 >> 1;
s[30] = s11 >> 9;
s[31] = s11 >> 17;
s[0] = (byte)(s0 >> 0);
s[1] = (byte)(s0 >> 8);
s[2] = (byte)((s0 >> 16) | (s1 << 5));
s[3] = (byte)(s1 >> 3);
s[4] = (byte)(s1 >> 11);
s[5] = (byte)((s1 >> 19) | (s2 << 2));
s[6] = (byte)(s2 >> 6);
s[7] = (byte)((s2 >> 14) | (s3 << 7));
s[8] = (byte)(s3 >> 1);
s[9] = (byte)(s3 >> 9);
s[10] = (byte)((s3 >> 17) | (s4 << 4));
s[11] = (byte)(s4 >> 4);
s[12] = (byte)(s4 >> 12);
s[13] = (byte)((s4 >> 20) | (s5 << 1));
s[14] = (byte)(s5 >> 7);
s[15] = (byte)((s5 >> 15) | (s6 << 6));
s[16] = (byte)(s6 >> 2);
s[17] = (byte)(s6 >> 10);
s[18] = (byte)((s6 >> 18) | (s7 << 3));
s[19] = (byte)(s7 >> 5);
s[20] = (byte)(s7 >> 13);
s[21] = (byte)(s8 >> 0);
s[22] = (byte)(s8 >> 8);
s[23] = (byte)((s8 >> 16) | (s9 << 5));
s[24] = (byte)(s9 >> 3);
s[25] = (byte)(s9 >> 11);
s[26] = (byte)((s9 >> 19) | (s10 << 2));
s[27] = (byte)(s10 >> 6);
s[28] = (byte)((s10 >> 14) | (s11 << 7));
s[29] = (byte)(s11 >> 1);
s[30] = (byte)(s11 >> 9);
s[31] = (byte)(s11 >> 17);
/* hush warnings after setting values to 0 */
(void)s12;
@ -640,38 +640,38 @@ void sc_muladd(byte* s, const byte* a, const byte* b, const byte* c)
carry9 = s9 >> 21; s10 += carry9; s9 -= carry9 << 21;
carry10 = s10 >> 21; s11 += carry10; s10 -= carry10 << 21;
s[0] = s0 >> 0;
s[1] = s0 >> 8;
s[2] = (s0 >> 16) | (s1 << 5);
s[3] = s1 >> 3;
s[4] = s1 >> 11;
s[5] = (s1 >> 19) | (s2 << 2);
s[6] = s2 >> 6;
s[7] = (s2 >> 14) | (s3 << 7);
s[8] = s3 >> 1;
s[9] = s3 >> 9;
s[10] = (s3 >> 17) | (s4 << 4);
s[11] = s4 >> 4;
s[12] = s4 >> 12;
s[13] = (s4 >> 20) | (s5 << 1);
s[14] = s5 >> 7;
s[15] = (s5 >> 15) | (s6 << 6);
s[16] = s6 >> 2;
s[17] = s6 >> 10;
s[18] = (s6 >> 18) | (s7 << 3);
s[19] = s7 >> 5;
s[20] = s7 >> 13;
s[21] = s8 >> 0;
s[22] = s8 >> 8;
s[23] = (s8 >> 16) | (s9 << 5);
s[24] = s9 >> 3;
s[25] = s9 >> 11;
s[26] = (s9 >> 19) | (s10 << 2);
s[27] = s10 >> 6;
s[28] = (s10 >> 14) | (s11 << 7);
s[29] = s11 >> 1;
s[30] = s11 >> 9;
s[31] = s11 >> 17;
s[0] = (byte)(s0 >> 0);
s[1] = (byte)(s0 >> 8);
s[2] = (byte)((s0 >> 16) | (s1 << 5));
s[3] = (byte)(s1 >> 3);
s[4] = (byte)(s1 >> 11);
s[5] = (byte)((s1 >> 19) | (s2 << 2));
s[6] = (byte)(s2 >> 6);
s[7] = (byte)((s2 >> 14) | (s3 << 7));
s[8] = (byte)(s3 >> 1);
s[9] = (byte)(s3 >> 9);
s[10] = (byte)((s3 >> 17) | (s4 << 4));
s[11] = (byte)(s4 >> 4);
s[12] = (byte)(s4 >> 12);
s[13] = (byte)((s4 >> 20) | (s5 << 1));
s[14] = (byte)(s5 >> 7);
s[15] = (byte)((s5 >> 15) | (s6 << 6));
s[16] = (byte)(s6 >> 2);
s[17] = (byte)(s6 >> 10);
s[18] = (byte)((s6 >> 18) | (s7 << 3));
s[19] = (byte)(s7 >> 5);
s[20] = (byte)(s7 >> 13);
s[21] = (byte)(s8 >> 0);
s[22] = (byte)(s8 >> 8);
s[23] = (byte)((s8 >> 16) | (s9 << 5));
s[24] = (byte)(s9 >> 3);
s[25] = (byte)(s9 >> 11);
s[26] = (byte)((s9 >> 19) | (s10 << 2));
s[27] = (byte)(s10 >> 6);
s[28] = (byte)((s10 >> 14) | (s11 << 7));
s[29] = (byte)(s11 >> 1);
s[30] = (byte)(s11 >> 9);
s[31] = (byte)(s11 >> 17);
/* hush warnings after setting values to 0 */
(void)s12;
@ -754,7 +754,7 @@ static unsigned char negative(signed char b)
unsigned long long x = b; /* 18446744073709551361..18446744073709551615:
yes; 0..255: no */
x >>= 63; /* 1: yes; 0: no */
return x;
return (unsigned char)x;
}

View File

@ -600,7 +600,7 @@ int wc_Poly1305_MAC(Poly1305* ctx, byte* additional, word32 addSz,
if ((ret = wc_Poly1305Update(ctx, additional, addSz)) != 0) {
return ret;
}
paddingLen = -addSz & (WC_POLY1305_PAD_SZ - 1);
paddingLen = -((int)addSz) & (WC_POLY1305_PAD_SZ - 1);
if (paddingLen) {
if ((ret = wc_Poly1305Update(ctx, padding, paddingLen)) != 0) {
return ret;
@ -611,7 +611,7 @@ int wc_Poly1305_MAC(Poly1305* ctx, byte* additional, word32 addSz,
if ((ret = wc_Poly1305Update(ctx, input, sz)) != 0) {
return ret;
}
paddingLen = -sz & (WC_POLY1305_PAD_SZ - 1);
paddingLen = -((int)sz) & (WC_POLY1305_PAD_SZ - 1);
if (paddingLen) {
if ((ret = wc_Poly1305Update(ctx, padding, paddingLen)) != 0) {
return ret;

View File

@ -1674,6 +1674,24 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
return ret;
}
#elif defined(INTIME_RTOS)
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int ret = 0;
(void)os;
if (output == NULL) {
return BUFFER_E;
}
/* Note: Investigate better solution */
/* no return to check */
arc4random_buf(output, sz);
return ret;
}
#elif defined(NO_DEV_RANDOM)
#error "you need to write an os specific wc_GenerateSeed() here"

270
wolfcrypt/src/wc_port.c 100644 → 100755
View File

@ -264,13 +264,15 @@ wolfSSL_Mutex* wc_InitAndAllocMutex()
{
wolfSSL_Mutex* m = (wolfSSL_Mutex*) XMALLOC(sizeof(wolfSSL_Mutex), NULL,
DYNAMIC_TYPE_MUTEX);
if(m && wc_InitMutex(m) == 0)
if (m && wc_InitMutex(m) == 0)
return m;
XFREE(m, NULL, DYNAMIC_TYPE_MUTEX);
m = NULL;
return m;
}
#if WOLFSSL_CRYPT_HW_MUTEX
/* Mutex for protection of cryptography hardware */
static wolfSSL_Mutex wcCryptHwMutex;
@ -310,37 +312,38 @@ int wolfSSL_CryptHwMutexUnLock(void) {
#endif /* WOLFSSL_CRYPT_HW_MUTEX */
/* ---------------------------------------------------------------------------*/
/* Mutex Ports */
/* ---------------------------------------------------------------------------*/
#ifdef SINGLE_THREADED
int wc_InitMutex(wolfSSL_Mutex* m)
{
int wc_InitMutex(wolfSSL_Mutex* m)
{
(void)m;
return 0;
}
}
int wc_FreeMutex(wolfSSL_Mutex *m)
{
int wc_FreeMutex(wolfSSL_Mutex *m)
{
(void)m;
return 0;
}
}
int wc_LockMutex(wolfSSL_Mutex *m)
{
int wc_LockMutex(wolfSSL_Mutex *m)
{
(void)m;
return 0;
}
}
int wc_UnLockMutex(wolfSSL_Mutex *m)
{
int wc_UnLockMutex(wolfSSL_Mutex *m)
{
(void)m;
return 0;
}
}
#else /* MULTI_THREAD */
#if defined(FREERTOS) || defined(FREERTOS_TCP) || \
#elif defined(FREERTOS) || defined(FREERTOS_TCP) || \
defined(FREESCALE_FREE_RTOS)
int wc_InitMutex(wolfSSL_Mutex* m)
@ -356,7 +359,6 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return iReturn;
}
int wc_FreeMutex(wolfSSL_Mutex* m)
{
vSemaphoreDelete( *m );
@ -376,7 +378,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return 0;
}
#elif defined(WOLFSSL_SAFERTOS)
#elif defined(WOLFSSL_SAFERTOS)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -406,8 +408,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return 0;
}
#elif defined(USE_WINDOWS_API)
#elif defined(USE_WINDOWS_API)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -436,7 +437,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return 0;
}
#elif defined(WOLFSSL_PTHREADS)
#elif defined(WOLFSSL_PTHREADS)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -473,7 +474,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E;
}
#elif defined(THREADX)
#elif defined(THREADX)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -501,7 +502,6 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E;
}
int wc_UnLockMutex(wolfSSL_Mutex* m)
{
if (tx_mutex_put(m) == 0)
@ -510,7 +510,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E;
}
#elif defined(MICRIUM)
#elif defined(MICRIUM)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -524,7 +524,6 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
#endif
}
int wc_FreeMutex(wolfSSL_Mutex* m)
{
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
@ -537,7 +536,6 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
#endif
}
int wc_LockMutex(wolfSSL_Mutex* m)
{
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
@ -550,7 +548,6 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
#endif
}
int wc_UnLockMutex(wolfSSL_Mutex* m)
{
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
@ -564,7 +561,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
}
#elif defined(EBSNET)
#elif defined(EBSNET)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -594,7 +591,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return 0;
}
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
int wc_InitMutex(wolfSSL_Mutex* m)
{
@ -628,22 +625,26 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return BAD_MUTEX_E;
}
#elif defined (WOLFSSL_TIRTOS)
#elif defined(WOLFSSL_TIRTOS)
#include <xdc/runtime/Error.h>
int wc_InitMutex(wolfSSL_Mutex* m)
{
Semaphore_Params params;
Error_Block eb;
Error_init(&eb);
Semaphore_Params_init(&params);
params.mode = Semaphore_Mode_BINARY;
*m = Semaphore_create(1, &params, &eb);
if( Error_check( &eb ) )
{
Error_raise( &eb, Error_E_generic, "Failed to Create the semaphore.",NULL);
if (Error_check(&eb)) {
Error_raise(&eb, Error_E_generic, "Failed to Create the semaphore.",
NULL);
return BAD_MUTEX_E;
} else return 0;
}
else
return 0;
}
int wc_FreeMutex(wolfSSL_Mutex* m)
@ -667,16 +668,15 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
return 0;
}
#elif defined(WOLFSSL_uITRON4)
#include "stddef.h"
#include "kernel.h"
#elif defined(WOLFSSL_uITRON4)
int wc_InitMutex(wolfSSL_Mutex* m)
{
int iReturn;
m->sem.sematr = TA_TFIFO ;
m->sem.isemcnt = 1 ;
m->sem.maxsem = 1 ;
m->sem.name = NULL ;
m->sem.sematr = TA_TFIFO;
m->sem.isemcnt = 1;
m->sem.maxsem = 1;
m->sem.name = NULL;
m->id = acre_sem(&m->sem);
if( m->id != E_OK )
@ -706,12 +706,12 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
}
/**** uITRON malloc/free ***/
static ID ID_wolfssl_MPOOL = 0 ;
static ID ID_wolfssl_MPOOL = 0;
static T_CMPL wolfssl_MPOOL = {TA_TFIFO, 0, NULL, "wolfSSL_MPOOL"};
int uITRON4_minit(size_t poolsz) {
ER ercd;
wolfssl_MPOOL.mplsz = poolsz ;
wolfssl_MPOOL.mplsz = poolsz;
ercd = acre_mpl(&wolfssl_MPOOL);
if (ercd > 0) {
ID_wolfssl_MPOOL = ercd;
@ -723,49 +723,49 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
void *uITRON4_malloc(size_t sz) {
ER ercd;
void *p ;
void *p;
ercd = get_mpl(ID_wolfssl_MPOOL, sz, (VP)&p);
if (ercd == E_OK) {
return p;
} else {
return 0 ;
return 0;
}
}
void *uITRON4_realloc(void *p, size_t sz) {
ER ercd;
void *newp ;
void *newp;
if(p) {
ercd = get_mpl(ID_wolfssl_MPOOL, sz, (VP)&newp);
if (ercd == E_OK) {
XMEMCPY(newp, p, sz) ;
XMEMCPY(newp, p, sz);
ercd = rel_mpl(ID_wolfssl_MPOOL, (VP)p);
if (ercd == E_OK) {
return newp;
}
}
}
return 0 ;
return 0;
}
void uITRON4_free(void *p) {
ER ercd;
ercd = rel_mpl(ID_wolfssl_MPOOL, (VP)p);
if (ercd == E_OK) {
return ;
return;
} else {
return ;
return;
}
}
#elif defined(WOLFSSL_uTKERNEL2)
#include "tk/tkernel.h"
int wc_InitMutex(wolfSSL_Mutex* m)
{
int iReturn;
m->sem.sematr = TA_TFIFO ;
m->sem.isemcnt = 1 ;
m->sem.maxsem = 1 ;
m->sem.sematr = TA_TFIFO;
m->sem.isemcnt = 1;
m->sem.maxsem = 1;
m->id = tk_cre_sem(&m->sem);
if( m->id != NULL )
@ -795,14 +795,14 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
}
/**** uT-Kernel malloc/free ***/
static ID ID_wolfssl_MPOOL = 0 ;
static ID ID_wolfssl_MPOOL = 0;
static T_CMPL wolfssl_MPOOL =
{(void *)NULL,
TA_TFIFO , 0, "wolfSSL_MPOOL"};
int uTKernel_init_mpool(unsigned int sz) {
ER ercd;
wolfssl_MPOOL.mplsz = sz ;
wolfssl_MPOOL.mplsz = sz;
ercd = tk_cre_mpl(&wolfssl_MPOOL);
if (ercd > 0) {
ID_wolfssl_MPOOL = ercd;
@ -814,41 +814,43 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
void *uTKernel_malloc(unsigned int sz) {
ER ercd;
void *p ;
void *p;
ercd = tk_get_mpl(ID_wolfssl_MPOOL, sz, (VP)&p, TMO_FEVR);
if (ercd == E_OK) {
return p;
} else {
return 0 ;
return 0;
}
}
void *uTKernel_realloc(void *p, unsigned int sz) {
ER ercd;
void *newp ;
void *newp;
if(p) {
ercd = tk_get_mpl(ID_wolfssl_MPOOL, sz, (VP)&newp, TMO_FEVR);
if (ercd == E_OK) {
XMEMCPY(newp, p, sz) ;
XMEMCPY(newp, p, sz);
ercd = tk_rel_mpl(ID_wolfssl_MPOOL, (VP)p);
if (ercd == E_OK) {
return newp;
}
}
}
return 0 ;
return 0;
}
void uTKernel_free(void *p) {
ER ercd;
ercd = tk_rel_mpl(ID_wolfssl_MPOOL, (VP)p);
if (ercd == E_OK) {
return ;
return;
} else {
return ;
return;
}
}
#elif defined (WOLFSSL_FROSTED)
#elif defined (WOLFSSL_FROSTED)
int wc_InitMutex(wolfSSL_Mutex* m)
{
*m = mutex_init();
@ -861,7 +863,7 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
int wc_FreeMutex(wolfSSL_Mutex* m)
{
mutex_destroy(*m);
return(0) ;
return(0);
}
int wc_LockMutex(wolfSSL_Mutex* m)
@ -875,53 +877,52 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
mutex_unlock(*m);
return 0;
}
#elif defined(WOLFSSL_MDK_ARM)|| defined(WOLFSSL_CMSIS_RTOS)
#if defined(WOLFSSL_CMSIS_RTOS)
#include "cmsis_os.h"
#elif defined(WOLFSSL_CMSIS_RTOS)
#define CMSIS_NMUTEX 10
osMutexDef(wolfSSL_mt0) ; osMutexDef(wolfSSL_mt1) ; osMutexDef(wolfSSL_mt2) ;
osMutexDef(wolfSSL_mt3) ; osMutexDef(wolfSSL_mt4) ; osMutexDef(wolfSSL_mt5) ;
osMutexDef(wolfSSL_mt6) ; osMutexDef(wolfSSL_mt7) ; osMutexDef(wolfSSL_mt8) ;
osMutexDef(wolfSSL_mt9) ;
osMutexDef(wolfSSL_mt0); osMutexDef(wolfSSL_mt1); osMutexDef(wolfSSL_mt2);
osMutexDef(wolfSSL_mt3); osMutexDef(wolfSSL_mt4); osMutexDef(wolfSSL_mt5);
osMutexDef(wolfSSL_mt6); osMutexDef(wolfSSL_mt7); osMutexDef(wolfSSL_mt8);
osMutexDef(wolfSSL_mt9);
static const osMutexDef_t *CMSIS_mutex[] = { osMutex(wolfSSL_mt0),
osMutex(wolfSSL_mt1), osMutex(wolfSSL_mt2), osMutex(wolfSSL_mt3),
osMutex(wolfSSL_mt4), osMutex(wolfSSL_mt5), osMutex(wolfSSL_mt6),
osMutex(wolfSSL_mt7), osMutex(wolfSSL_mt8), osMutex(wolfSSL_mt9) } ;
osMutex(wolfSSL_mt7), osMutex(wolfSSL_mt8), osMutex(wolfSSL_mt9) };
static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0} ;
static osMutexId CMSIS_mutexID[CMSIS_NMUTEX] = {0};
int wc_InitMutex(wolfSSL_Mutex* m)
{
int i ;
int i;
for (i=0; i<CMSIS_NMUTEX; i++) {
if(CMSIS_mutexID[i] == 0) {
CMSIS_mutexID[i] = osMutexCreate(CMSIS_mutex[i]) ;
(*m) = CMSIS_mutexID[i] ;
return 0 ;
CMSIS_mutexID[i] = osMutexCreate(CMSIS_mutex[i]);
(*m) = CMSIS_mutexID[i];
return 0;
}
}
return -1 ;
return -1;
}
int wc_FreeMutex(wolfSSL_Mutex* m)
{
int i ;
osMutexDelete (*m) ;
int i;
osMutexDelete (*m);
for (i=0; i<CMSIS_NMUTEX; i++) {
if(CMSIS_mutexID[i] == (*m)) {
CMSIS_mutexID[i] = 0 ;
return(0) ;
CMSIS_mutexID[i] = 0;
return(0);
}
}
return(-1) ;
return(-1);
}
int wc_LockMutex(wolfSSL_Mutex* m)
{
osMutexWait(*m, osWaitForever) ;
return(0) ;
osMutexWait(*m, osWaitForever);
return(0);
}
int wc_UnLockMutex(wolfSSL_Mutex* m)
@ -929,7 +930,9 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
osMutexRelease (*m);
return 0;
}
#else
#elif defined(WOLFSSL_MDK_ARM)
int wc_InitMutex(wolfSSL_Mutex* m)
{
os_mut_init (m);
@ -938,13 +941,13 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
int wc_FreeMutex(wolfSSL_Mutex* m)
{
return(0) ;
return(0);
}
int wc_LockMutex(wolfSSL_Mutex* m)
{
os_mut_wait (m, 0xffff);
return(0) ;
return(0);
}
int wc_UnLockMutex(wolfSSL_Mutex* m)
@ -952,10 +955,93 @@ int wc_UnLockMutex(wolfSSL_Mutex *m)
os_mut_release (m);
return 0;
}
#endif
#endif /* USE_WINDOWS_API */
#endif /* SINGLE_THREADED */
#elif defined(INTIME_RTOS)
#ifndef INTIME_RTOS_MUTEX_MAX
#define INTIME_RTOS_MUTEX_MAX 10
#endif
int wc_InitMutex(wolfSSL_Mutex* m)
{
int ret = 0;
if (m == NULL)
return BAD_FUNC_ARG;
*m = CreateRtSemaphore(
1, /* initial unit count */
INTIME_RTOS_MUTEX_MAX, /* maximum unit count */
PRIORITY_QUEUING /* creation flags: FIFO_QUEUING or PRIORITY_QUEUING */
);
if (*m == BAD_RTHANDLE) {
ret = GetLastRtError();
if (ret != E_OK)
ret = BAD_MUTEX_E;
}
return ret;
}
int wc_FreeMutex(wolfSSL_Mutex* m)
{
int ret = 0;
BOOLEAN del;
if (m == NULL)
return BAD_FUNC_ARG;
del = DeleteRtSemaphore(
*m /* handle for RT semaphore */
);
if (del != TRUE)
ret = BAD_MUTEX_E;
return ret;
}
int wc_LockMutex(wolfSSL_Mutex* m)
{
int ret = 0;
DWORD lck;
if (m == NULL)
return BAD_FUNC_ARG;
lck = WaitForRtSemaphore(
*m, /* handle for RT semaphore */
1, /* number of units to wait for */
WAIT_FOREVER /* number of milliseconds to wait for units */
);
if (lck == WAIT_FAILED) {
ret = GetLastRtError();
if (ret != E_OK)
ret = BAD_MUTEX_E;
}
return ret;
}
int wc_UnLockMutex(wolfSSL_Mutex* m)
{
int ret = 0;
BOOLEAN rel;
if (m == NULL)
return BAD_FUNC_ARG;
rel = ReleaseRtSemaphore(
*m, /* handle for RT semaphore */
1 /* number of units to release to semaphore */
);
if (rel != TRUE)
ret = BAD_MUTEX_E;
return ret;
}
#else
#warning No mutex handling defined
#endif
#if defined(WOLFSSL_TI_CRYPT) || defined(WOLFSSL_TI_HASH)
#include <wolfcrypt/src/port/ti/ti-ccm.c> /* initialize and Mutex for TI Crypt Engine */

File diff suppressed because it is too large Load Diff

View File

@ -1219,6 +1219,132 @@ static const unsigned char rsa_key_der_2048[] =
};
static const int sizeof_rsa_key_der_2048 = sizeof(rsa_key_der_2048);
/* ./certs/ca-key.der, 2048-bit */
static const unsigned char ca_key_der_2048[] =
{
0x30, 0x82, 0x04, 0xA4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01,
0x01, 0x00, 0xBF, 0x0C, 0xCA, 0x2D, 0x14, 0xB2, 0x1E, 0x84,
0x42, 0x5B, 0xCD, 0x38, 0x1F, 0x4A, 0xF2, 0x4D, 0x75, 0x10,
0xF1, 0xB6, 0x35, 0x9F, 0xDF, 0xCA, 0x7D, 0x03, 0x98, 0xD3,
0xAC, 0xDE, 0x03, 0x66, 0xEE, 0x2A, 0xF1, 0xD8, 0xB0, 0x7D,
0x6E, 0x07, 0x54, 0x0B, 0x10, 0x98, 0x21, 0x4D, 0x80, 0xCB,
0x12, 0x20, 0xE7, 0xCC, 0x4F, 0xDE, 0x45, 0x7D, 0xC9, 0x72,
0x77, 0x32, 0xEA, 0xCA, 0x90, 0xBB, 0x69, 0x52, 0x10, 0x03,
0x2F, 0xA8, 0xF3, 0x95, 0xC5, 0xF1, 0x8B, 0x62, 0x56, 0x1B,
0xEF, 0x67, 0x6F, 0xA4, 0x10, 0x41, 0x95, 0xAD, 0x0A, 0x9B,
0xE3, 0xA5, 0xC0, 0xB0, 0xD2, 0x70, 0x76, 0x50, 0x30, 0x5B,
0xA8, 0xE8, 0x08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x55, 0xD3, 0x57, 0x0B, 0xF0, 0xA5, 0x35, 0x6A, 0xB0, 0xAE,
0x31, 0xBA, 0x43, 0x96, 0xCA, 0x00, 0xC7, 0x4B, 0xE3, 0x19,
0x12, 0x43, 0xD3, 0x42, 0xFA, 0x6F, 0xEA, 0x80, 0xC0, 0xD1,
0x02, 0x81, 0x81, 0x00, 0xB9, 0xDB, 0x89, 0x20, 0x34, 0x27,
0x70, 0x62, 0x34, 0xEA, 0x5F, 0x25, 0x62, 0x12, 0xF3, 0x9D,
0x81, 0xBF, 0x48, 0xEE, 0x9A, 0x0E, 0xC1, 0x8D, 0x10, 0xFF,
0x65, 0x9A, 0x9D, 0x2D, 0x1A, 0x8A, 0x94, 0x5A, 0xC8, 0xC0,
0xA5, 0xA5, 0x84, 0x61, 0x9E, 0xD4, 0x24, 0xB9, 0xEF, 0xA9,
0x9D, 0xC9, 0x77, 0x0B, 0xC7, 0x70, 0x66, 0x3D, 0xBA, 0xC8,
0x54, 0xDF, 0xD2, 0x33, 0xE1, 0xF5, 0x7F, 0xF9, 0x27, 0x61,
0xBE, 0x57, 0x45, 0xDD, 0xB7, 0x45, 0x17, 0x24, 0xF5, 0x23,
0xE4, 0x38, 0x0E, 0x91, 0x27, 0xEE, 0xE3, 0x20, 0xD8, 0x14,
0xC8, 0x94, 0x47, 0x77, 0x40, 0x77, 0x45, 0x18, 0x9E, 0x0D,
0xCE, 0x79, 0x3F, 0x57, 0x31, 0x56, 0x09, 0x49, 0x67, 0xBE,
0x94, 0x58, 0x4F, 0xF6, 0xC4, 0xAB, 0xE2, 0x89, 0xE3, 0xE3,
0x8A, 0xC0, 0x05, 0x55, 0x2C, 0x24, 0xC0, 0x4A, 0x97, 0x04,
0x27, 0x9A
};
static const int sizeof_ca_key_der_2048 = sizeof(ca_key_der_2048);
/* ./certs/ca-cert.der, 2048-bit */
static const unsigned char ca_cert_der_2048[] =
{

2
wolfssl/internal.h 100644 → 100755
View File

@ -140,6 +140,8 @@
#elif defined(MBED)
#elif defined(WOLFSSL_TIRTOS)
/* do nothing */
#elif defined(INTIME_RTOS)
#include <rt.h>
#else
#ifndef SINGLE_THREADED
#define WOLFSSL_PTHREADS

View File

@ -71,9 +71,9 @@ WOLFSSL_LOCAL void fe_tobytes(unsigned char *, const fe);
WOLFSSL_LOCAL void fe_sq(fe, const fe);
WOLFSSL_LOCAL void fe_sq2(fe,const fe);
WOLFSSL_LOCAL void fe_frombytes(fe,const unsigned char *);
WOLFSSL_LOCAL void fe_cswap(fe,fe,unsigned int);
WOLFSSL_LOCAL void fe_cswap(fe, fe, int);
WOLFSSL_LOCAL void fe_mul121666(fe,fe);
WOLFSSL_LOCAL void fe_cmov(fe,const fe,unsigned int);
WOLFSSL_LOCAL void fe_cmov(fe,const fe, int);
WOLFSSL_LOCAL void fe_pow22523(fe,const fe);
/* 64 type needed for SHA512 */

View File

@ -440,7 +440,7 @@
/* Micrium will use Visual Studio for compilation but not the Win32 API */
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
!defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_EROAD) && \
!defined(WOLFSSL_UTASKER)
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
#define USE_WINDOWS_API
#endif
@ -1493,6 +1493,10 @@ static char *fgets(char *buff, int sz, FILE *fp)
#endif
#endif
#if !defined(NO_OLD_TLS) && (defined(NO_SHA) || defined(NO_MD5))
#error old TLS requires MD5 and SHA
#endif
/* Place any other flags or defines here */

View File

@ -133,7 +133,8 @@
/* set up rotate style */
#if (defined(_MSC_VER) || defined(__BCPLUSPLUS__)) && !defined(WOLFSSL_SGX)
#if (defined(_MSC_VER) || defined(__BCPLUSPLUS__)) && \
!defined(WOLFSSL_SGX) && !defined(INTIME_RTOS)
#define INTEL_INTRINSICS
#define FAST_ROTATE
#elif defined(__MWERKS__) && TARGET_CPU_PPC
@ -148,7 +149,10 @@
/* set up thread local storage if available */
#ifdef HAVE_THREAD_LS
#if defined(_MSC_VER)
#if defined(INTIME_RTOS)
/* Thread local storage not supported */
#define THREAD_LS_T
#elif defined(_MSC_VER)
#define THREAD_LS_T __declspec(thread)
/* Thread local storage only in FreeRTOS v8.2.1 and higher */
#elif defined(FREERTOS)
@ -163,7 +167,8 @@
/* Micrium will use Visual Studio for compilation but not the Win32 API */
#if defined(_WIN32) && !defined(MICRIUM) && !defined(FREERTOS) && \
!defined(FREERTOS_TCP) && !defined(EBSNET) && !defined(WOLFSSL_UTASKER)
!defined(FREERTOS_TCP) && !defined(EBSNET) && \
!defined(WOLFSSL_UTASKER) && !defined(INTIME_RTOS)
#define USE_WINDOWS_API
#endif
@ -252,7 +257,7 @@
#if defined(WOLFSSL_CERT_EXT) || defined(HAVE_ALPN)
/* use only Thread Safe version of strtok */
#ifndef USE_WINDOWS_API
#if !defined(USE_WINDOWS_API) && !defined(INTIME_RTOS)
#define XSTRTOK strtok_r
#else
#define XSTRTOK strtok_s

View File

@ -44,8 +44,8 @@
#include <winsock2.h>
#endif
#include <windows.h>
#endif
#endif /* WOLFSSL_SGX */
#endif
#elif defined(THREADX)
#ifndef SINGLE_THREADED
#include "tx_api.h"
@ -61,6 +61,7 @@
#elif defined(FREESCALE_FREE_RTOS)
#include "fsl_os_abstraction.h"
#elif defined(WOLFSSL_uITRON4)
#include "stddef.h"
#include "kernel.h"
#elif defined(WOLFSSL_uTKERNEL2)
#include "tk/tkernel.h"
@ -77,6 +78,9 @@
#include <ti/sysbios/knl/Semaphore.h>
#elif defined(WOLFSSL_FROSTED)
#include <semaphore.h>
#elif defined(INTIME_RTOS)
#include <rt.h>
#include <io.h>
#else
#ifndef SINGLE_THREADED
#define WOLFSSL_PTHREADS
@ -146,6 +150,8 @@
typedef ti_sysbios_knl_Semaphore_Handle wolfSSL_Mutex;
#elif defined(WOLFSSL_FROSTED)
typedef mutex_t * wolfSSL_Mutex;
#elif defined(INTIME_RTOS)
typedef RTHANDLE wolfSSL_Mutex;
#else
#error Need a mutex type in multithreaded mode
#endif /* USE_WINDOWS_API */