Update code to v1.0.14 (10)

This commit is contained in:
Caten
2024-02-29 19:35:00 +08:00
parent c2ee3b694c
commit a956d26f6d
3188 changed files with 2317293 additions and 146 deletions

View File

@@ -0,0 +1,211 @@
wolfSSL for Renesas RA Evaluation Kit (EK-RA6M3)
=================================================
## Description
This directory contains e2studio projects targeted at the Renesas RA 32-bit MCUs.\
The example projects include a wolfSSL TLS client and server.\
They also include benchmark and cryptography tests for the wolfCrypt library.
The wolfssl project contains both the wolfSSL and wolfCrypt libraries.\
It is built as a `Renesas RA C Library Project` and contains the Renesas RA\
configuration.
The other projects (benchmark, client, server and test) are built as a\
`Renesas RA C Project Using RA Library`, where the RA library is the wolfssl project.\
The wolfssl Project Summary is listed below and is relevant for every project.
### Project Summary
|Item|Name/Version|
|:--|:--|
|Board|EK-RA6M3|
|Device|R7FA6M3AH3CFC|
|Toolchain|GCC ARM Embedded|
|FSP Version|3.5.0|
#### Selected software components
|Components|Version|
|:--|:--|
|Board Support Package Common Files|v3.5.0|
|Arm CMSIS Version 5 - Core (M)|v5.8.0+renesas.0.fsp.3.5.0|
|FreeRTOS|v10.4.3-LTS.Patch.2+fsp.3.5.0|
|RA6M3-EK Board Support Files|v3.5.0|
|Board support package for R7FA6M3AH3CFC|v3.5.0|
|Board support package for RA6M3|v3.5.0|
|Board support package for RA6M3 - FSP Data|v3.5.0|
|FreeRTOS - Memory Management - Heap 4|v10.4.3-LTS.Patch.2+fsp.3.5.0|
|r_ether to FreeRTOS+TCP Wrapper|v3.5.0|
|Ethernet|v3.5.0|
|Ethernet PHY|v3.5.0|
|FreeRTOS+TCP|v2.3.2-LTS.Patch.1+fsp.3.5.0|
|FreeRTOS - Buffer Allocation 2|v2.3.2-LTS.Patch.1+fsp.3.5.0|
## Setup Steps
The project directories are missing files necessary to build the project.\
These files can be generated when creating a new Renesas RA Project.\
The following steps explain how to generate the missing files and where to place them.
1.) Create a 'dummy' Renesas RA C Library Project.
+ Click File->New->`RA C/C++ Project`
+ Click `Renesas RA C Library Project`. Click Next
+ Enter `dummy_library` as the project name. Click Next.
+ Under `Board: Custom User Board`, select `EK-RA6M3`.
+ Under `RTOS: No RTOS`, select `FreeRTOS`.
+ Click Next. Select `FreeRTOS - Minimal - Static Allocation`
+ Click Finish.
+ Open Smart Configurator by clicking configuration.xml in the project
+ Go to `BSP` tab and increase Heap Size under `RA Common` on Properties page, e.g. 0x1000
+ Go to `Stacks` tab
+ Add New thead and set properties
|Property|Value|
|:--|:--|
|Thread Symbol|wolfssl_tst_thread|
|Thread Name|wolf_tst_thread|
|Thread Stack size|increase depending on your environment<br> e.g. 0xA000|
|Thread MemoryAllocation|Dyamic|
|Common General Use Mutexes|Enabled|
|Common General Enable Backward Compatibility|Enabled|
|Common Memory Allocation Support Dynamic Allocation|Enabled|
|Common Memory Allocation Total Heap Size|increase depending on your environment<br> e.g. 0x20000|
+ Add `Heap 4` stack to sce_tst_thread from `New Stack` -> `RTOS` -> `FreeRTOS Heap 4`
+ Add `FreeRTOS + TCP` stack to sce_tst_thread from `New Stack` -> `Networking` -> `FreeRTOS+TCP` and set properties
|Property|Value|
|:--|:--|
|Network Events call vApplicationIPNetworkEventHook|Disable|
|Use DHCP|Disable|
2.) Create a 'dummy' Renesas RA C Project Using RA Library.
+ Click File->New->`RA C/C++ Project`
+ Click `Renesas RA C Project Using RA Library`. Click Next
+ Enter `dummy_app` as the project name. Click Next.
+ Under `Executable Using an RA Static library`
+ Enter `dummy_app` as the project name. Click Next
+ Select `dummy_library` from Select Renesas RA library project.
+ Click Finish.
3.) Import all the wolfSSL Projects into e2studio workspace.
+ Click File->`Open Projects from File System`
+ Click `Directory...` to the right of Import source
+ Select the RA6M3 folder location that contains the projects\
example path: wolfssl/IDE/Renesas/e2studio/RA6M3
+ Deselect the Non-Eclipse project, RA6M3, by clicking the checkbox\
Only the folders with 'Eclipse project' under 'Import as' need to be selected.
+ Click Finish.
4.) Copy files from `dummy_library` into `wolfSSL_RA6M3`
+ Expand the dummy_library and wolfSSL_RA6M3 projects\
(Click the drop-down arrow to the left of the project name.)
+ Select and Copy the following folders/files inside dummy_library\
`ra/`\
`ra_gen/`\
`ra_cfg/`\
`script/`\
`R7FA6M3AH3CFC.pincfg`\
`configuration.xml`
+ Paste the copied folders/files into wolfSSL_RA6M3
+ The `dummy_library` project can now be deleted.
+ Generate Project Content.
+ Click `Open RA Configuration` in the top bar (Grey Settings Cog)
+ Click `Generate Project Content` at top right (Green Icon)
+ Build wolfSSL_RA6M3.
5.) Copy files from `dummy_app` into each executable projects\
+ Select and Copy the followng folder inside dummy_app\
`script/`
+ Paste the copied folders into each executable projects which are Crypt test, benchmark, client and server projects\
+ The `dummy_app` project can now be deleted.
6.) Setup Network Environment
The client and server projects have defines inside their wolfssl_thread_entry.h.
These defines (ucIPAddress ... ucDNSServerAddress) may need to be changed
based on your internal network environment. The g_ether0_mac_address is the default
mac address found inside the RA configuration inside the wolfssl project.
The client wolfssl_thread_entry.h has defines (SERVER_IP and DEFAULT_PORT) that
will need to be changed based on the server you're trying to connect to over
the ethernet connection.
## Build and Run
### Build Each Project
Right-Click each Project and select Build.
### Run wolfCrypt Test and Benchmark
1.) Right-Click the Project name.\
2.) Select `Debug As` -> `Renesas GDB Hardware Debugging`\
3.) Select J-Link ARM. Click OK.\
4.) Select R7FA6M3AH. Click OK.
### Run the wolfSSL TLS Server Example.
1.) Right-Click the Project name.\
2.) Select `Debug As` -> `Renesas GDB Hardware Debugging`\
3.) Select J-Link ARM. Click OK.\
4.) Select R7FA6M3AH. Click OK.\
5.) Run the following wolfSSL example client command inside the base of the wolfssl directory.
```
./examples/client/client -v 4 -h "ucIPAddress" -p 11111 -A ./certs/1024/ca-cert.pem
```
**NOTE:** "ucIPAddress" is "192.168.1.241" by default. (See wolfssl_thread_entry.h)
### Run the wolfSSL TLS Client Example.
1.) Run the following wolfSSL example server command inside the base of the wolfssl directory.
```
./examples/server/server -v 4 -b -d -p 11111 -c ./certs/1024/server-cert.pem -k ./certs/1024/server-key.pem
```
**NOTE:** The port 11111 is the DEFAULT_PORT inside wolfssl_thread_entry.h.\
2.) Right-Click the Project name.\
3.) Select `Debug As` -> `Renesas GDB Hardware Debugging`\
4.) Select J-Link ARM. Click OK.\
5.) Select R7FA6M3AH. Click OK.
## Troubleshooting
+ The commands for the example client/server assumes it is being run from the
base directory of wolfssl.
+ Enter "#define DEBUG_WOLFSSL" inside user_settings.h or wolfssl_thread_entry.c\
to enable wolfssl debug messages to the Renesas Virtual Debug Console.
+ Some linking errors can be caused by the e2studio project files needing to be rebuilt and freshened.
Right-Click a project, select Index, click Rebuild and then click Freshen Files. Repeat for each project.
[Support Forum](https://www.wolfssl.com/forums/)
Support Email: support@wolfssl.com
## Resources
[wolfSSL Website](https://www.wolfssl.com/)
[wolfSSL Wiki](https://github.com/wolfSSL/wolfssl/wiki)
[wolfSSL Manual](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-toc.html)
[wolfSSL API Reference](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-wolfssl-api-reference.html)
[wolfCrypt API Reference](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-wolfcrypt-api-reference.html)
[TLS 1.3](https://www.wolfssl.com/docs/tls13/)

View File

@@ -0,0 +1,198 @@
wolfSSL for Alpha Project AP-RA6M-0A Setup Guide
=================================================
## Description
This directory contains e2studio projects targeted at the Alpha Project AP-RA6M-0A board including the Renesas RA 32-bit MCUs.
The example projects include a wolfSSL TLS client and server. They also include benchmark and cryptography tests for the wolfCrypt library.
The wolfssl project contains both the wolfSSL and wolfCrypt libraries. It is built as a `Renesas RA C Library Project` and contains the Renesas RA configuration.
The other projects (benchmark, client, server and test) are built as a `Renesas RA C Project Using RA Library`, where the RA library is the wolfssl project.
The wolfssl Project Summary is listed below and is relevant for every project.
### Project Summary
|Item|Name/Version|
|:--|:----|
|e2studio|2020-07|
|Board |AP-RA6M-0A |
|Device |R7FA6M3AH3CFC|
|Toolchain|GCC ARM Embedded
|FSP Version|1.3.0|
### Selected software components
|Component|Version|
|:--|:---|
|Board Support Package Common Files|v1.3.0|
|Arm CMSIS Version 5 - Core (M) |v5.7.0|
|Board support package for R7FA6M3AH3CFC |v1.3.0|
|Board support package for RA6M3|v1.3.0 |
|Board support package for RA6M3 - FSP Data|v1.3.0|
|FreeRTOS|v1.3.0|
|FreeRTOS - Buffer Allocation 2 |v1.3.0|
|FreeRTOS+TCP|v1.3.0|
|r_ether to FreeRTOS+TCP Wrapper|v1.3.0|
|Ethernet |v1.3.0 |
|Ethernet PHY|v1.3.0|
|I/O Port|v1.3.0 |
|BSP-Board|v1.2.0 |
## Setup Steps
The project directories are missing files necessary to build the project.\
These files can be generated when creating a new Renesas RA Project.\
The following steps explain how to generate the missing files and where to place them.
1.) Download Alpha project example program from [Alpha Project Home Page](https://www.apnet.co.jp/product/ra/ap-ra6m-0a.html)
+ Unzip the downloaded example project
2.) Create a 'dummy' Renesas RA C Library Project on e2studio
+ Click File->New->`RA C/C++ Project`
+ Enter `dummy_library` as the project name. Click Next.
+ Select `Board: Custom User Board`.
+ Select `R7FA6M3AH3CFC
+ Under `RTOS: No RTOS`, select `FreeRTOS`.
+ Click Next. Select `FreeRTOS - Minimal - Static Allocation`
+ Click `Renesas RA C Library Project`. Click Next
+ Click Finish.
3.) Create a 'dummy' Renesas RA C Project Using RA Library on e2studio
+ Click File->New->`RA C/C++ Project`
+ Enter `dummy_app` as the project name. Click Next.
+ Under `RA library project`, select `dummy_library`.
+ Click `Executable Using an RA Static Library`. Click Next
+ Click Finish.
+ Enter `dummy_app` as Project name
+ Select RA library project `dummy_library`
4.) Import all the wolfSSL Projects into e2studio workspace.
+ Click File->`Open Projects from File System`
+ Click `Directory...` to the right of Import source
+ Select the RA6M3G folder location that contains the projects
example path: wolfssl/IDE/Renesas/e2studio/RA6M3
+ Deselect the Non-Eclipse project, RA6M3G, by clicking the checkbox
Only the folders with 'Eclipse project' under 'Import as' need to be selected.
+ Click Finish.
5.) Copy files from `dummy_library` into `wolfSSL_RA6M3G`
+ Expand the dummy_library and wolfSSL_RA6M3G projects
(Click the drop-down arrow to the left of the project name.)
+ Select and Copy the following folders/files inside dummy_library
`ra/`
`ra_gen/`
`ra_cfg/`
`script/`
+ Paste the copied folders/files into wolfSSL_RA6M3G
+ The `dummy_library` project can now be deleted.
+ Copy `APRA6M0A.pincfg` from ap_ra6m_0a_sample\sample\ap_ra6m_0a_ether_sample to wolfSSL_RA6M3G
+ Delete `R7FA6M3AH3CFC.pincfg` from wolfSSL_RA6M3G
+ Generate Project Content.
+ Click `Open RA Configuration` in the top bar (Grey Settings Cog)
+ Go to `BSP` tab and import CMSIS pack file, AP.APRA6M0A.x.x.x.pack, from ap_ra6m_0a_sample\sample folder
+ Select APRA6M0A as Board
+ Go to `Pins` tab and select APRA6M0A.pincfg
+ Go to `Stacks` tab and add Heap 4 stack from New Stack(+ Icon)
+ Click `Generate Project Content` at top right (Green Icon)
+ Build wolfSSL_RA6M3G.
6.) Copy files from `dummy_app` into `./IDE/Renesas/e2studio/RA6M3/common/ra6m3g/`
**NOTE:** This may need to be done outside of the e2studio environment (e.g. File Explorer).
+ Select and Copy the followng folder inside dummy_app
`src/`
`script/`
+ Paste the copied folders into `./IDE/Renesas/e2studio/RA6M3/common/ra6m3g/`
`(The test, benchmark, client and server projects link to this folder.)`
+ The `dummy_app` project can now be deleted.
7.) Setup Network Environment
The client and server projects have defines inside their wolfssl_thread_entry.h.
These defines (ucIPAddress ... ucDNSServerAddress) may need to be changed
based on your internal network environment. The g_ether0_mac_address is the default
mac address found inside the RA configuration inside the wolfssl project.
The client wolfssl_thread_entry.h has defines (SERVER_IP and DEFAULT_PORT) that
will need to be changed based on the server you're trying to connect to over
the ethernet connection.
## Build and Run
### Build Each Project
Right-Click each Project and select Build.
### Run wolfCrypt Test and Benchmark
1.) Right-Click the Project name.
2.) Select `Debug As` -> `Renesas GDB Hardware Debugging`
3.) Select J-Link ARM. Click OK.
4.) Select R7Fa6M3AH. Click OK.
### Run the wolfSSL TLS Server Example.
1.) Right-Click the Project name.
2.) Select `Debug As` -> `Renesas GDB Hardware Debugging`
3.) Select J-Link ARM. Click OK.
4.) Select R7Fa6M3AH. Click OK.
5.) Run the following wolfSSL example client command inside the base of the wolfssl directory.
```
./examples/client/client -v 4 -h "ucIPAddress" -p 11111 -A ./certs/1024/ca-cert.pem
```
**NOTE:** "ucIPAddress" is "192.168.1.241" by default. (See wolfssl_thread_entry.h)
### Run the wolfSSL TLS Client Example.
1.) Run the following wolfSSL example server command inside the base of the wolfssl directory.
```
./examples/server/server -v 4 -b -d -p 11111 -c ./certs/1024/server-cert.pem -k ./certs/1024/server-key.pem
```
**NOTE:** The port 11111 is the DEFAULT_PORT inside wolfssl_thread_entry.h.
If DEFAULT_PORT was changed then the above command will need to match it.
2.) Right-Click the Project name.\
3.) Select `Debug As` -> `Renesas GDB Hardware Debugging`\
4.) Select J-Link ARM. Click OK.\
5.) Select R7Fa6M3AH. Click OK.
## Troubleshooting
+ The commands for the example client/server assumes it is being run from the
base directory of wolfssl.
+ Enter "#define DEBUG_WOLFSSL" inside user_settings.h or wolfssl_thread_entry.c
to enable wolfssl debug messages to the Renesas Virtual Debug Console.
+ Some linking errors can be caused by the e2studio project files needing to be rebuilt and freshened.
Right-Click a project, select Index, click Rebuild and then click Freshen Files. Repeat for each project.
[Support Forum](https://www.wolfssl.com/forums/)
Support Email: support@wolfssl.com
## Resources
[wolfSSL Website](https://www.wolfssl.com/)
[wolfSSL Wiki](https://github.com/wolfSSL/wolfssl/wiki)
[wolfSSL Manual](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-toc.html)
[wolfSSL API Reference](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-wolfssl-api-reference.html)
[wolfCrypt API Reference](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-wolfcrypt-api-reference.html)
[TLS 1.3](https://www.wolfssl.com/docs/tls13/)

View File

@@ -0,0 +1,197 @@
wolfSSL/AlphaProject AP-RA6M-0A ボードデモ セットアップガイド
=================================================
## はじめに
このフォルダにはルネサス社製 RA 32-bit MCU を搭載するアルファプロジェクト製 AP-RA6M-0A で wolfSSL を動作させるための手順です。
サンプルプログラムには、暗号テスト、ベンチマーク、及びクライアント・サーバーを含んでいます。
wolfSSL のプロジェクトファイルは、wolfSSL と wolfCrypt の両方で構成され、Renesas RA のコンフィグレーションを含む`Renesas RA C/C++ Library Project`としてビルドされます。
その他、ベンチマーク、暗号テスト、及びクライアント・サーバーのサンプルプログラムは、`Renesas RA C Project Using RA Library`としてビルドされます。
プロジェクトの概要と全ての関連するソフトウェアコンポーネントに関する情報を下記になります。
### プロジェクトの概要
|要素|名前/バージョン|
|:--|:--|
|e2studio|2020-07|
|Board|AP-RA6M-0A|
|Device|R7FA6M3AH3CFC|
|Toolchain|GCC ARM Embedded|
|FSP Version|1.3.0|
#### 必要なソフトウェアコンポーネント
|コンポーネント|バージョン|
|:--|:--|
|Board Support Package Common Files|v1.3.0|
|Arm CMSIS Version 5 - Core (M) |v5.7.0|
|Board support package for R7FA6M3AH3CFC |v1.3.0|
|Board support package for RA6M3|v1.3.0 |
|Board support package for RA6M3 - FSP Data|v1.3.0|
|FreeRTOS|v1.3.0|
|FreeRTOS - Buffer Allocation 2 |v1.3.0|
|FreeRTOS+TCP|v1.3.0|
|r_ether to FreeRTOS+TCP Wrapper|v1.3.0|
|Ethernet |v1.3.0 |
|Ethernet PHY|v1.3.0|
|I/O Port|v1.3.0 |
|BSP-Board|v1.2.0 |
## セットアップ手順
プロジェクトのフォルダーには、ビルドに必要なファイルが不足しています。そららのファイルをダミーのプロジェクトを作成し補います。
次に続くステップは、不足しているファイルを作成し、それらを必要としているプロジェクトにコピーする手順です。
1.) [アルファプロジェクト社のホームページ](https://www.apnet.co.jp/product/ra/ap-ra6m-0a.html)からサンプルプログラムをダウンロード
+ ダウンロードしたサンプルプログラムを適当なフォルダーへ解凍
2.) e2Studio で'ダミー' Renesas RA C Library プロジェクトを作成
+ ファイル→新規→`RA C/C++ Project`をクリック
+ `Renesas RA C/C++ Library Project`を選択し、次へをクリック
+ 'dummy_library` とプロジェクト名を入力します。
+ `Board:` ドロップダウンから `EK-RA6M3T`を選択します
+ `RTOS: No TROS` を `FreeRTOS` を選択します。
+ `Build Artifact Selection` の `Static Library`を選択し、次へをクリック
+ `FreeRTOS - Minimal - Static Allocation` を選択し、終了をクリック
3.) e2Studio で 'ダミー'の Renesas RA C/C++ Project Using RA Library を作成
+ ファイル→新規→`RA C/C++ Project`をクリック
+ `Renesas RA C/C++ Library Project`を選択し、次へをクリック
+ 'dummy_app` とプロジェクト名を入力します。
+ `Board:` ドロップダウンから `EK-RA6M3T`を選択します
+ `RTOS: No TROS``FreeRTOS` を選択しまし、次へをクリック
+ `Build Artifact Selection``Executable Using an RA Static Library`を選択し、終了をクリック
+ 'dummy_app` とプロジェクト名を入力し、次へクリック
+ `RA library project`の `Select RA Library`から, `dummy_library`を選択し、終了をクリック
4.) 全ての wolfSSL e2studio プロジェクトをインポート
+ メニューの「ファイル」→「ファイル・システムからプロジェクトを開く」をクリック
+ インポート元の `ディレクトリー...` をクリック
+ RA6M3 フォルダーを選択。wolfssl/IDE/Renesas/e2studio/RA6M3
+ Eclipseのプロジェクトではない、RA6M3を除外します。
その他、ベンチマーク、暗号テスト、クライアント・サーバーの各プロジェクトは選択しておく。
+ 終了をクリック
5.) `dummy_library`からwolfSSL_RA6M3Gへ必要なファイルをコピー
+ `dummy_library` と `wolfSSL_RA6M3G` プロジェクトを開く
プロジェクト名横にある矢印マークをクリック
+ `dummy_library` の以下のフォルダーとファイルを選択
`ra/`
`ra_gen/`
`ra_cfg/`
`script/`
+ 選択したフォルダーとファイルを `wolfSSL_RA6M3G`プロジェクトに貼り付け
+ `dummy_library`プロジェクトは削除しても構いません
+ `APRA6M0A.pincfg` を解凍した ap_ra6m_0a_sample\sample\ap_ra6m_0a_ether_sample から `wolfSSL_RA6M3G`プロジェクトへコピー
+ `wolfSSL_RA6M3G`フォルダー内の `R7FA6M3AH3CFC.pincfg` は削除します。
+ プロジェクトに必要なファイルを生成します。
+ `Open RA Configuration`(上部のアイコンバーにある灰色歯車ボタン)をクリック
+ `BSP` タブに移動し、CMSIS Pack のインポートボタンをクリック
+ インポート画面で、CMSIS pack ファイルを指定
ステップ 1で解凍したap_ra6m_0a_sample\sampleフォルダー中の AP.APRA6M0A.x.x.x.pack を指定します。
+ `APRA6M0A` を Board として指定
+ `Pins`タブに移動し、`APRA6M0A.pincfg`を選択
+ `Stacks`タブに移動し、Heap 4 stack を New Stack から追加
+ `Generate Project Content`(右上部にある緑色アイコン)をクリックし、ファイルを生成
+ `wolfSSL_RA6M3G`をビルド
6.) `dummy_app` から必要なファイルを`./IDE/Renesas/e2studio/RA6M3/common/ra6m3g/`へコピー
**NOTE:** この作業は、e2studio ではなく、Explorer などを使用します。
+ `dummy_app`の以下のフォルダーをコピー
`src/`
`script/`
+ 選択したフォルダーを`./IDE/Renesas/e2studio/RA6M3/common/ra6m3g/`へコピー
`(暗号テスト、ベンチマーク、クライアント・サーバーの各プロジェクトはこのフォルダーを参照)`
+ `dummy_app`プロジェクトは削除しても構いません
7.) ネットワーク環境について
クライアント・サーバーのプロジェクト内のwolfssl_thread_entry.hにネットワーク設定があります。
それらの設定ucIPAddress ... ucDNSServerAddress)は、ご使用のネットワーク環境に合わせて変更して
してください。g_ether0_mac_address は、`wolfSSL_RA6M3G`プロジェクト内の RA configuration
で定義されているデフォルトのMACアドレスです。クライアントのwolfssl_thread_entry.h は
ターゲットのサーバーのSERVER_IP と DEFAULT_PORTの定義を持ちます。それらはご使用のサーバーの
の設定に応じて変更してください。
## ビルドと実行
### 各プロジェクトをビルド
各プロジェクトで右クリックし、ビルドを選択
### 暗号テストとベンチマークを実行
1.) プロジェクト名を選択し、右クリック\
2.) `デバック` → `Renesas GDB Hardware Debugging`\
3.) `J-Link ARM`を選択し、OK をクリック\
4.) `R7FA6M3AH`を選択し、OK をクリック
### wolfSSL TLS サンプルサーバーを実行
1.) プロジェクト名を選択し、右クリック\
2.) `デバック` → `Renesas GDB Hardware Debugging`\
3.) `J-Link ARM`を選択し、OK をクリック\
4.) `R7FA6M3AH`を選択し、OK をクリック\
5.)以下のサンプルのクライアントプログラムを実行
```
./examples/client/client -v 4 -h "ucIPAddress" -p 11111 -A ./certs/1024/ca-cert.pem
```
**NOTE:** "ucIPAddress" はデフォルトでは "192.168.1.241" (参照: wolfssl_thread_entry.h)
### wolfSSL TLS サンプルクライアントを実行
1.)以下のサンプルのサーバープログラムを実行
```
./examples/server/server -b -d -p 11111 -c ./certs/1024/server-cert.pem -k ./certs/1024/server-key.pem
```
TLS 1.3 で接続する際には、引数に "-v 4" を追加します。
```
./examples/server/server -v 4 -b -d -p 11111 -c ./certs/1024/server-cert.pem -k ./certs/1024/server-key.pem
```
**NOTE:** wolfssl_thread_entry.h中にデフォルトのポート番号 11111 定義(DEFAULT_PORT)
もし、DEFAULT_PORTを変更している場合、、上記のコマンドの "-p" の値は対応するポート番号に要変更
2.) プロジェクト名を選択し、右クリック\
3.) `デバック` → `Renesas GDB Hardware Debugging`\
4.) `J-Link ARM`を選択し、OK をクリック\
5.) `R7FA6M3AH`を選択し、OK をクリック
## トラブルシューティング
+ サンプルのクライアント・サーバープログラムは、wolfSSL のルートディレクトリから実行する必要があります。
+ user_settings.h の #define DEBUG_WOLFSSL を有効にすることで、デバックメッセージを\
`Renesas Virtual Debug Console`へ出力します。
+ プロジェクトのビルドでリンクエラーが出た場合、リビルドしリフレッシュすることで解決することがあります。
[Support Forum](https://www.wolfssl.com/forums/)
Support Email: support@wolfssl.com
## 参考リンク
[wolfSSL Website](https://www.wolfssl.com/)
[wolfSSL Wiki](https://github.com/wolfSSL/wolfssl/wiki)
[wolfSSL Manual](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-toc.html)
[wolfSSL API Reference](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-17-wolfssl-api-reference.html)
[wolfCrypt API Reference](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-18-wolfcrypt-api-reference.html)
[TLS 1.3](https://www.wolfssl.com/docs/tls13/)

View File

@@ -0,0 +1,31 @@
/* wolfssl_thread_entry.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <wolfssl/wolfcrypt/settings.h>
#include "common/util.h"
int benchmark_test(void *args);
void wolfssl_thread_entry(void *pvParameters) {
FSP_PARAMETER_NOT_USED(pvParameters);
initialise_monitor_handles();
benchmark_test(0);
while (1);
}

View File

@@ -0,0 +1,164 @@
/* wolfssl_thread_entry.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/* wolfSSL */
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfio.h>
#include "wolfssl_thread_entry.h"
/* FreeRTOS */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
/* Project Specific */
#include "common/util.h"
#include <stdio.h>
#include "hal_data.h"
/* the function is called just before main() to set up pins */
/* this needs to be called to setup IO Port */
void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
if (BSP_WARM_START_POST_C == event) {
/* C runtime environment and system clocks are setup. */
/* Configure pins. */
R_IOPORT_Open(&g_ioport_ctrl, g_ioport.p_cfg);
}
}
void wolfssl_thread_entry(void *pvParameters) {
FSP_PARAMETER_NOT_USED(pvParameters);
/* FreeRTOS+TCP Objects */
BaseType_t fr_status;
socklen_t xSize = sizeof(struct freertos_sockaddr);
xSocket_t xClientSocket = NULL;
struct freertos_sockaddr xRemoteAddress;
/* Return status */
int ret = WOLFSSL_FAILURE;
/* Message to send and buffer for receive. */
const char msg[] = "Hello from wolfSSL client.";
char buff[256];
/* wolfSSL objects */
WOLFSSL_CTX *ctx = NULL;
WOLFSSL *ssl = NULL;
/* Output to Renesas Debug Virtual Console */
initialise_monitor_handles();
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
/* FreeRTOS+TCP Ethernet and IP Setup */
fr_status = FreeRTOS_IPInit(ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
g_ether0_mac_address);
if (pdPASS != fr_status) {
printf("Error [%ld]: FreeRTOS_IPInit.\n",fr_status);
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Client Socket Setup */
xRemoteAddress.sin_port = FreeRTOS_htons(DEFAULT_PORT);
xRemoteAddress.sin_addr = FreeRTOS_inet_addr(SERVER_IP);
/* Create a FreeRTOS TCP Socket and connect */
xClientSocket = FreeRTOS_socket(FREERTOS_AF_INET,
FREERTOS_SOCK_STREAM,
FREERTOS_IPPROTO_TCP);
configASSERT(xClientSocket != FREERTOS_INVALID_SOCKET);
FreeRTOS_bind(xClientSocket, &xRemoteAddress, sizeof(xSize));
/* Client Socket Connect */
ret = FreeRTOS_connect(xClientSocket,
&xRemoteAddress,
sizeof(xRemoteAddress));
if (ret != FR_SOCKET_SUCCESS) {
printf("Error [%d]: FreeRTOS_connect.\n",ret);
util_inf_loop(xClientSocket, ctx, ssl);
}
/* TLS Connection Setup */
/* Initialize wolfSSL */
wolfSSL_Init();
/* Create and initialize WOLFSSL_CTX */
ctx = wolfSSL_CTX_new(wolfSSLv23_client_method_ex((void *)NULL));
if (ctx == NULL) {
printf("Error: wolfSSL_CTX_new.\n");
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Load client certificates into WOLFSSL_CTX */
ret = wolfSSL_CTX_load_verify_buffer(ctx, CERT, SIZEOF_CERT,
WOLFSSL_FILETYPE_ASN1);
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_CTX_load_verify_buffer.\n",ret);
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Create a WOLFSSL object */
ssl = wolfSSL_new(ctx);
if (ssl == NULL) {
printf("Error: wolfSSL_new.\n");
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Attach wolfSSL to the socket */
ret = wolfSSL_set_fd(ssl, (int) xClientSocket);
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_set_fd.\n",ret);
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Connect to wolfSSL on the server side */
ret = wolfSSL_connect(ssl);
if (ret != WOLFSSL_SUCCESS) {
ret = wolfSSL_get_error(ssl, ret);
printf("Error [%d]: wolfSSL_connect.\n",ret);
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Send the message to the server */
ret = wolfSSL_write(ssl, msg, (int) XSTRLEN(msg));
if (ret < 0) {
printf("Error: wolfSSL_write.\n");
util_inf_loop(xClientSocket, ctx, ssl);
}
/* Read the server data into buff array */
XMEMSET(buff, 0, sizeof(buff));
ret = wolfSSL_read(ssl, buff, sizeof(buff) - 1);
/* Shutdown TLS connection */
wolfSSL_shutdown(ssl);
/* Cleanup */
util_inf_loop(xClientSocket, ctx, ssl);
}

View File

@@ -0,0 +1,42 @@
/* wolfssl_thread_entry.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLFSSL_THREAD_ENTRY_H_
#define WOLFSSL_THREAD_ENTRY_H_
#include <errno.h>
#include <wolfssl/certs_test.h>
extern uint8_t g_ether0_mac_address[6];
static const byte ucIPAddress[4] = { 192, 168, 11, 241 };
static const byte ucNetMask[4] = { 255, 255, 255, 0 };
static const byte ucGatewayAddress[4] = { 192, 168, 11, 1 };
static const byte ucDNSServerAddress[4] = { 192, 168, 11, 1 };
/* Client connects to the server with these details. */
#define SERVER_IP "192.168.11.40"
#define DEFAULT_PORT 11111
#define CERT ca_cert_der_1024
#define SIZEOF_CERT sizeof_ca_cert_der_1024
#define FR_SOCKET_SUCCESS 0
#endif /* WOLFSSL_THREAD_ENTRY_H_ */

View File

@@ -0,0 +1,4 @@
Create a 'dummy' Renesas RA C Project Using RA Library.
Copy and Paste the generated 'script' and 'src' folder into this folder.
These are linked to in other projects.

View File

@@ -0,0 +1,65 @@
/* freertos_tcp_port.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include "bsp_api.h"
#include "FreeRTOS.h"
#include "FreeRTOS_sockets.h"
#include "FreeRTOS_IP.h"
#include <stdlib.h>
#define HOSTNAME "wolfssl_ra6m3g"
/*
* Contains callback functions for FreeRTOS+TCP
* The following implementations are NOT SUITABLE FOR PRODUCTION.
* They currently serve to build the projects and are not secure.
*/
uint32_t ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,
uint16_t usSourcePort,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort);
const char *pcApplicationHostnameHook(void) {
return HOSTNAME;
}
uint32_t ulRand(void) {
return (uint32_t) rand();
}
/* Disabled in RA Configuration. Re-Enable within FreeRTOS+TCP Stack Properties */
void vApplicationIPNetworkEventHook(eIPCallbackEvent_t eNetworkEvent) {
(void) eNetworkEvent;
}
uint32_t ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,
uint16_t usSourcePort,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort)
{
(void) ulSourceAddress;
(void) usSourcePort;
(void) ulDestinationAddress;
(void) usDestinationPort;
return ulRand();
}

View File

@@ -0,0 +1,85 @@
/* user_settings.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef USER_SETTINGS_H_
#define USER_SETTINGS_H_
/* Temporary defines. Not suitable for production. */
#define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */
/* End temporary defines */
/* TLS 1.3 */
#define WOLFSSL_TLS13
#define HAVE_HKDF
#define WC_RSA_PSS
#if defined(WOLFSSL_TLS13)
#include <sys/time.h>
#endif
/* Operating Environment and Threading */
#define FREERTOS
#define FREERTOS_TCP
#define NO_DEV_RANDOM
#define NO_WRITEV
#define NO_MAIN_DRIVER
#define BENCH_EMBEDDED
/* Filesystem and IO */
#define NO_WOLFSSL_DIR
#define WOLFSSL_NO_CURRDIR
#define NO_FILESYSTEM
/* Cryptography Enable Options */
#define HAVE_CHACHA
#define HAVE_POLY1305
#define HAVE_ECC
#define HAVE_RSA
#define HAVE_SHA256
#define HAVE_SUPPORTED_CURVES
#define HAVE_TLS_EXTENSIONS
#define HAVE_TRUNCATED_HMAC
#define HAVE_EXTENDED_MASTER
#define HAVE_ALPN
#define HAVE_SNI
#define HAVE_OCSP
#define HAVE_AESGCM
#define HAVE_ONE_TIME_AUTH
/* Non-Fast Math may call realloc. This project has no realloc support */
#define USE_FAST_MATH
#define ALT_ECC_SIZE
#define TFM_TIMING_RESISTANT
#define ECC_TIMING_RESISTANT
#define WC_RSA_BLINDING
#define WOLFSSL_SMALL_STACK
#define WOLFSSL_DH_CONST
/* Cryptography Disable options */
#define NO_PWDBASED
#define NO_DSA
#define NO_DES3
#define NO_RC4
#define NO_MD4
void wolfssl_thread_entry(void *pvParameters);
extern void initialise_monitor_handles(void);
int strncasecmp(const char *s1, const char * s2, unsigned int sz);
#endif /* USER_SETTINGS_H_ */

View File

@@ -0,0 +1,48 @@
/* util.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef _UTIL_H_
#define _UTIL_H_
#include "common/user_settings.h"
#include <wolfssl/ssl.h>
#include "FreeRTOS_IP.h"
#include <stdio.h>
static void util_Cleanup(xSocket_t xSock, WOLFSSL_CTX *ctx, WOLFSSL *ssl) {
printf("Cleaning up socket and wolfSSL objects.\n");
if (xSock != NULL)
FreeRTOS_closesocket(xSock);
if (ssl != NULL)
wolfSSL_free(ssl);
if (ctx != NULL)
wolfSSL_CTX_free(ctx);
wolfSSL_Cleanup();
}
static inline void util_inf_loop(xSocket_t xClientSocket, WOLFSSL_CTX *ctx,
WOLFSSL *ssl) {
util_Cleanup(xClientSocket, ctx, ssl);
printf("Reached infinite loop.\n");
while (1)
;
}
#endif /* _UTIL_H */

View File

@@ -0,0 +1,35 @@
# vim:ft=automake
# included from Top Level Makefile.am
# All paths should be given relative to the root
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/src/wolfssl_thread_entry.c
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/.cproject
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/benchmark-wolfcrypt/.project
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/client-wolfssl/src/wolfssl_thread_entry.c
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/client-wolfssl/.cproject
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/client-wolfssl/.project
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/client-wolfssl/wolfssl_thread_entry.h
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/common/ra6m3g/README.md
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/common/src/freertos_tcp_port.c
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/common/user_settings.h
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/common/util.h
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/server-wolfssl/src/wolfssl_thread_entry.c
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/server-wolfssl/.cproject
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/server-wolfssl/.project
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/server-wolfssl/wolfssl_thread_entry.h
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/src/wolfssl_thread_entry.c
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/.cproject
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/test-wolfcrypt/.project
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/wolfssl/.cproject
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/wolfssl/.project
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/README.md
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3G/README.md
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/README_APRA6M_en.md
EXTRA_DIST+= IDE/Renesas/e2studio/RA6M3/README_APRA6M_jp.md

View File

@@ -0,0 +1,187 @@
/* wolfssl_thread_entry.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h>
#include <wolfssl/wolfio.h>
#include "wolfssl_thread_entry.h"
/* FreeRTOS+TCP */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
/* Project Tools */
#include "common/util.h"
#include <stdio.h>
#include "hal_data.h"
/* the function is called just before main() to set up pins */
/* this needs to be called to setup IO Port */
void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
if (BSP_WARM_START_POST_C == event) {
/* C runtime environment and system clocks are setup. */
/* Configure pins. */
R_IOPORT_Open(&g_ioport_ctrl, g_ioport.p_cfg);
}
}
void wolfssl_thread_entry(void *pvParameters) {
FSP_PARAMETER_NOT_USED(pvParameters);
/* FreeRTOS+TCP parameters and objects */
BaseType_t fr_status;
struct freertos_sockaddr xClient, xBindAddress;
Socket_t xListeningSocket, xConnectedSocket;
socklen_t xSize = sizeof(xClient);
const BaseType_t xBacklog = 1; /* Max number of connections */
static const TickType_t xReceiveTimeOut = portMAX_DELAY;
/* Return Code */
int ret = WOLFSSL_FAILURE;
/* Send/Receive Message */
const char *reply = "I hear ya fa shizzle!\n";
char buff[256];
/* wolfSSL objects */
WOLFSSL_CTX *ctx = NULL;
WOLFSSL *ssl = NULL;
/* Output to Renesas Debug Virtual Console */
initialise_monitor_handles();
#ifdef DEBUG_WOLFSSL
wolfSSL_Debugging_ON();
#endif
fr_status = FreeRTOS_IPInit(ucIPAddress,ucNetMask, ucGatewayAddress,
ucDNSServerAddress, g_ether0_mac_address);
if (pdPASS != fr_status) {
printf("Error [%ld]: FreeRTOS_IPInit.\n",fr_status);
while (1);
}
/* Attempt to open the socket. */
xListeningSocket = FreeRTOS_socket(FREERTOS_AF_INET,
FREERTOS_SOCK_STREAM,
FREERTOS_IPPROTO_TCP);
configASSERT(xListeningSocket != FREERTOS_INVALID_SOCKET);
/* Set a time out so accept() will just wait for a connection. */
FreeRTOS_setsockopt(xListeningSocket, 0,
FREERTOS_SO_RCVTIMEO, &xReceiveTimeOut, sizeof(xReceiveTimeOut));
xBindAddress.sin_port = (uint16_t) DEFAULT_PORT;
xBindAddress.sin_port = FreeRTOS_htons(xBindAddress.sin_port);
configASSERT(xListeningSocket != FREERTOS_INVALID_SOCKET);
ret = FreeRTOS_bind(xListeningSocket, &xBindAddress, sizeof(xBindAddress));
if (ret == FR_SOCKET_SUCCESS)
ret = FreeRTOS_listen(xListeningSocket, xBacklog);
if (ret != FR_SOCKET_SUCCESS) {
printf("Error [%d]: FreeRTOS_bind.\n",ret);
while (1);
}
while (1) {
ret = WOLFSSL_FAILURE;
xConnectedSocket = FreeRTOS_accept(xListeningSocket, &xClient, &xSize);
configASSERT(xConnectedSocket != FREERTOS_INVALID_SOCKET);
/* Create WOLFSSL_CTX object */
ctx = wolfSSL_CTX_new(wolfSSLv23_server_method_ex((void *)NULL));
/* Load server certificates into WOLFSSL_CTX */
if (ctx == NULL) {
printf("Error: wolfSSL_CTX_new.\n");
break;
}
ret = wolfSSL_CTX_use_certificate_buffer(ctx, CERT_BUF, SIZEOF_CERT_BUF,
SSL_FILETYPE_ASN1);
/* Load server key into WOLFSSL_CTX */
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_CTX_use_certificate_buffer.\n",ret);
break;
}
ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, KEY_BUF, SIZEOF_KEY_BUF,
SSL_FILETYPE_ASN1);
/* Create a WOLFSSL object */
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_CTX_use_PrivateKey_buffer.\n",ret);
break;
}
ssl = wolfSSL_new(ctx);
/* Attach wolfSSL to the socket */
if (ssl == NULL) {
printf("Error: wolfSSL_new.\n");
break;
}
ret = wolfSSL_set_fd(ssl, (int) xConnectedSocket);
/* Establish TLS connection */
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_set_fd.\n",ret);
break;
}
ret = wolfSSL_accept(ssl);
/* Read the client data into our buff array */
if (ret != WOLFSSL_SUCCESS) {
printf("Error [%d]: wolfSSL_set_fd.\n",ret);
break;
}
memset(buff, 0, sizeof(buff));
ret = wolfSSL_read(ssl, buff, sizeof(buff) - 1);
if (ret < 0)
break;
/* Check for server shutdown command */
if (strncmp(buff, "shutdown", 8) == 0)
break;
/* Write our reply into buff */
memset(buff, 0, sizeof(buff));
memcpy(buff, reply, strlen(reply));
/* Reply back to the client */
ret = wolfSSL_write(ssl, buff, (int) strlen(buff));
if (ret < 0)
break;
/* Cleanup after this connection */
util_Cleanup(xConnectedSocket, ctx, ssl);
}
/* Shutdown TLS Server */
ret = wolfSSL_shutdown(ssl);
if (ret == WOLFSSL_SHUTDOWN_NOT_DONE) {
wolfSSL_shutdown(ssl);
}
/* Cleanup connection */
util_inf_loop(xConnectedSocket, ctx, ssl);
}

View File

@@ -0,0 +1,44 @@
/* wolfssl_thread_entry.h
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#ifndef WOLFSSL_THREAD_ENTRY_H_
#define WOLFSSL_THREAD_ENTRY_H_
#include <wolfssl/certs_test.h>
extern uint8_t g_ether0_mac_address[6];
static const byte ucIPAddress[4] = { 192, 168, 11, 241 };
static const byte ucNetMask[4] = { 255, 255, 255, 0 };
static const byte ucGatewayAddress[4] = { 192, 168, 11, 1 };
static const byte ucDNSServerAddress[4] = { 192, 168, 11, 1 };
/* Server Cert and Key */
#define CERT_BUF server_cert_der_1024
#define SIZEOF_CERT_BUF sizeof_server_cert_der_1024
#define KEY_BUF server_key_der_1024
#define SIZEOF_KEY_BUF sizeof_server_key_der_1024
/* Port That the wolfSSL Server connects to. */
#define DEFAULT_PORT 11111
#define FR_SOCKET_SUCCESS 0
#endif /* WOLFSSL_THREAD_ENTRY_H_ */

View File

@@ -0,0 +1,32 @@
/* wolfssl_thread_entry.c
*
* Copyright (C) 2006-2022 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
#include <wolfssl/wolfcrypt/settings.h>
#include "wolfcrypt/test/test.h"
void wolfssl_thread_entry(void* pvParameters)
{
FSP_PARAMETER_NOT_USED (pvParameters);
/* Benchmark output is displayed to Renesas Debug Virtual Console */
initialise_monitor_handles();
wolfcrypt_test(0);
while(1);
}