-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged applications source code version main.
- Loading branch information
Showing
858 changed files
with
253,496 additions
and
0 deletions.
There are no files selected for viewing
333 changes: 333 additions & 0 deletions
333
applications/user-crypto/miv-rv32-aes-cryptography/.cproject
Large diffs are not rendered by default.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
applications/user-crypto/miv-rv32-aes-cryptography/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/.settings/ | ||
/*miv-rv32-imc-debug*/ | ||
/*miv-rv32-imc-release*/ |
26 changes: 26 additions & 0 deletions
26
applications/user-crypto/miv-rv32-aes-cryptography/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>miv-rv32-aes-cryptography</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> | ||
<triggers>clean,full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> | ||
<triggers>full,incremental,</triggers> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.cdt.core.cnature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> | ||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> | ||
</natures> | ||
</projectDescription> |
158 changes: 158 additions & 0 deletions
158
applications/user-crypto/miv-rv32-aes-cryptography/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
PolarFire User Crypto AES Cryptography Services example | ||
================================================================================ | ||
This example project demonstrate the use of symmetric key encryption and | ||
decryption services. The following PolarFire User Crypto service functions are used | ||
|
||
- CALSymEncrypt() | ||
- CALSymEncryptDMA() | ||
- CALSymDecrypt() | ||
- CALSymDecryptDMA() | ||
|
||
There are two different build configurations provided with this project which | ||
configure this SoftConsole project for RISC-V IMC instruction extension. | ||
The following configurations are provided with the example: | ||
|
||
- miv-rv32-imc-debug | ||
- miv-rv32-imc-release | ||
|
||
Mi-V Soft Processor | ||
-------------------------------------------------------------------------------- | ||
This example uses Mi-V SoftProcessor MiV_RV32.The design is built for debugging | ||
MiV_RV32 through the PolarFire FPGA programming JTAG port using a FlashPro5. | ||
To achieve this the CoreJTAGDebug IP is used to connect to the JTAG port of the | ||
MiV_RV32. | ||
|
||
All the platform/design specific definitions such as peripheral base addresses, | ||
system clock frequency etc. are included in fpga_design_config.h. The | ||
fpga_design_config.h is located at the root folder of this project. | ||
|
||
The Mi-V Soft Processor MiV_RV32 firmware projects needs the miv_rv32_hal and | ||
the hal firmware(RISC-V HAL). | ||
|
||
The RISC-V HAL is available at GitHub [Mi-V-Soft-RISC-V](https://mi-v-ecosystem.github.io/redirects/platform). | ||
|
||
How to use this example | ||
-------------------------------------------------------------------------------- | ||
This example project is targeted at a MIV_RV32 design running on a PolarFire-Eval-Kit | ||
connected via a USB-UART serial cable to a host PC running a terminal emulator | ||
such as TeraTerm or Putty configured as follows: | ||
|
||
- 115200 baud | ||
- 8 data bits | ||
- 1 stop bit | ||
- no parity | ||
- no flow control. | ||
|
||
Run the example project using a debugger. A greeting message will appear over the | ||
UART terminal followed by a menu system and instructions. | ||
|
||
This program displays the return data from User Crypto processor for encryption | ||
and decryption services. | ||
|
||
fpga_design_config (formerly known as hw_config.h) | ||
-------------------------------------------------------------------------------- | ||
The SoftConsole project targeted for Mi-V processors now use an improved | ||
directory structure. The fpga_design_config.h must be stored as shown below | ||
|
||
` | ||
<project-root>/boards/<board-name>/fpga_design_config/fpga_design_config.h | ||
` | ||
|
||
Currently, this file must be hand crafted when using the Mi-V Soft Processor. | ||
In future, all the design and soft IP configurations will be automatically | ||
generated from the Libero design description data. | ||
|
||
You can use the sample file provided with MIV_RV32 HAL as an example. Rename it | ||
from sample_fpga_design_config.h to fpga_design_config.h and then customize it | ||
per your hardware design such as SYS_CLK_FREQ, peripheral BASE addresses, | ||
interrupt numbers, definition of MSCC_STDIO_UART_BASE_ADDR if you want a | ||
CoreUARTapb mapped to STDIO, etc. | ||
|
||
### Data Encryption | ||
|
||
Select option '1' for data encryption using AES-256 algorithm based on electronic | ||
code book encryption (ECB) mode and key. This example project reads the plain | ||
text and an encryption key from URAT terminal and calls **CALSymEncrypt()** or | ||
**CALSymEncryptDMA()** function. The **CALSymEncrypt()** and **CALSymEncryptDMA()** | ||
functions encrypt the message based on electronic code book encryption (ECB) | ||
mode and symmetric encryption key and generate the cipher text. This cipher | ||
text is also displayed on UART terminal. | ||
|
||
### Data Decryption | ||
|
||
Select option '2' for data decryption using AES-256 algorithm based on electronic | ||
code book (ECB) mode and key. This example project reads a cipher text and a | ||
decryption key from URAT terminal and calls **CALSymDecrypt()** or **CALSymDecrypt()** | ||
function. The **CALSymDecrypt()** and **CALSymDecryptDMA()** functions decrypt the | ||
cipher text based on ECB mode and symmetric encryption key, and generate the | ||
plain text. The generated plain text is also displayed on UART terminal. You | ||
have to provide same key to decrypt the cipher text, which is used for encryption. | ||
|
||
**NOTE:** | ||
If you try to enter data values other than 0 - 9, a - f, A - F, an error | ||
message will be displayed on the serial port terminal. | ||
|
||
### Configurations | ||
|
||
The CAL library needs a config_user.h containing the configuration data. | ||
This application provides following settings as per CAL requirement | ||
1. A variable which provides the base address of the User Crypto hardware block | ||
is defined in main.c | ||
|
||
`uint32_t g_user_crypto_base_addr = 0x62000000UL;` | ||
|
||
2. A symbol INC_STDINT_H is defined in project preprocessor setting. | ||
For more detail, please refer to caltypes.h file present in CAL folder. | ||
|
||
### Test script | ||
|
||
A test script is provided with this example which automatically enters the NIST | ||
vectors and associated data to verify the functionality. You can use | ||
RV32_AES_Cryptography.ttl Tera Term Macro script present in project directory for | ||
testing AES Cryptography example project. | ||
|
||
**NOTE:** | ||
1. Tera Term Macros don’t work with Windows 10 build 14393.0. You should update | ||
to Windows 10 build 14393.0.105 or [later.](https://osdn.net/ticket/browse.php?group_id=1412&tid=36526) | ||
2. Before running Tera Term Macro script, set language as English | ||
(Setup->General->Language). Also setup transmit delay in (Setup->Serial port) | ||
to 5msec/char and 5msec/line. | ||
3. By default, Tera Term log will be stored in Tera Term installation Directory. | ||
|
||
## Target hardware | ||
|
||
This project was tested on PolarFire-Eval-Kit with CFG4 configuration of the | ||
MIV_RV32 design available [here](https://github.com/Mi-V-Soft-RISC-V/PolarFire-Eval-Kit/tree/main/Libero_Projects) | ||
|
||
All the design specific definitions such as peripheral base addresses, system | ||
clock frequency etc. are included in fpga_design_config.h. | ||
|
||
The firmware projects needs the HAL and the MIV_RV32 HAL firmware components. | ||
|
||
This example project can be used with another design using a different hardware | ||
configurations. This can be achieved by overwriting the content of this example | ||
project's "fpga_design_config.h" file with the correct data per your Libero design. | ||
|
||
### Booting the system | ||
|
||
Currently the example project is configured to use FlashPro debugger to execute | ||
from LSRAM in both Debug and Release mode. | ||
|
||
In the release mode build configuration, following setting is used | ||
`--change-section-lma *-0x80000000` under | ||
Tool Settings > Cross RISCV GNU Create Flash Image > General > Other flags. | ||
|
||
This will allow you to attach the release mode executable as the memory | ||
initialization client in Libero when you want to execute it from non-volatile memory. | ||
|
||
## Silicon revision dependencies | ||
|
||
This example is tested on PolarFire MPF300TS device. | ||
|
||
### CAL library src | ||
|
||
To obtain the CAL source code and a SoftConsole project to generate the CAL | ||
library archive file (*.a) refer [SoftConsole Documentation](https://mi-v-ecosystem.github.io/SoftConsole-Documentation/SoftConsole-v2021.3/using_softconsole/other.html#crypto-application-library). | ||
The CAL source code is bound by license agreement and it will be available as | ||
part of the SoftConsole installation if the CAL specific license was agreed | ||
while installing it. |
Oops, something went wrong.