Skip to content

Commit

Permalink
Merged null source code ref b72e0eee.
Browse files Browse the repository at this point in the history
  • Loading branch information
HA-harshit committed Nov 14, 2023
2 parents 51fe95d + 980c63e commit a2b0cf1
Show file tree
Hide file tree
Showing 3,925 changed files with 2,011,048 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
570 changes: 570 additions & 0 deletions applications/user-crypto/mpfs-user-crypto-aes-cryptography/.cproject

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/LIM-Debug*/
/LIM-Release*/
/DDR-Release*/
/eNVM-Scratchpad-Release*/
/.settings*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>mpfs-user-crypto-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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
; Tera Term Setting:
; 1. Before running Tera Term Macro script, you should set language as English
; and transmit delay in Serial port setup to 5msec/char and 5msec/line.
; 2. By default, Tera Term log will be stored in Tera Term installation Directory.

changedir '.'
logopen "AES_Cryptography.log" 0 0 0 1

settitle 'PolarFire User Crypto AES-128'

setsync 1

;Clear screen
clearscreen 0

; Set baud rate to 115200
setbaud 115200

; local echo off
setecho 0

;; Send Dummy
send $0

; ---------------------------------------------------------------------------------------------------------------
; AES-128 Encryption
; ---------------------------------------------------------------------------------------------------------------
;Test Case 1 - using DMA
; INPUT
; KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
; PLAINTEXT = 00000000000000000000000000000000
; OUTPUT
; CIPHERTEXT = 46f2fb342d6f0ab477476fc501242c5f
; ---------------------------------------------------------------------------------------------------------------
send '1'
pause 1

;key
send 'c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;PLAINTEXT
send '00000000000000000000000000000000'
send 13
pause 1

;DMA enabled
send '1'
pause 4

;Press any key
send $0

; ---------------------------------------------------------------------------------------------------------------
;Test Case 2 - non DMA
; INPUT
; KEY = c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558
; PLAINTEXT = 00000000000000000000000000000000
; OUTPUT
; CIPHERTEXT = 46f2fb342d6f0ab477476fc501242c5f
; ---------------------------------------------------------------------------------------------------------------
send '1'
pause 1

;key
send 'c47b0294dbbbee0fec4757f22ffeee3587ca4730c3d33b691df38bab076bc558'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;PLAINTEXT
send '00000000000000000000000000000000'
send 13
pause 1

;DMA disabled
send '0'
pause 4

;Press any key
send $0

; ---------------------------------------------------------------------------------------------------------------
; Test Case 3 - DMA enabled
; INPUT
; KEY = 0000000000000000000000000000000000000000000000000000000000000000
; PLAINTEXT = 91fbef2d15a97816060bee1feaa49afe
; OUTPUT
; CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
; ---------------------------------------------------------------------------------------------------------------
send '1'
pause 1

;key
send '0000000000000000000000000000000000000000000000000000000000000000'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;PLAINTEXT
send '91fbef2d15a97816060bee1feaa49afe'
send 13
pause 1

;DMA Enabled
send '1'
pause 4

;Press any key
send $0

; ---------------------------------------------------------------------------------------------------------------
; Test Case 4 - DMA disabled
; INPUT
; KEY = 0000000000000000000000000000000000000000000000000000000000000000
; PLAINTEXT = 91fbef2d15a97816060bee1feaa49afe
; OUTPUT
; CIPHERTEXT = 1bc704f1bce135ceb810341b216d7abe
; ---------------------------------------------------------------------------------------------------------------
send '1'
pause 1

;key
send '0000000000000000000000000000000000000000000000000000000000000000'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;PLAINTEXT
send '91fbef2d15a97816060bee1feaa49afe'
send 13
pause 1

;DMA Disabled
send '0'
pause 4

;Press any key
send $0


; ---------------------------------------------------------------------------------------------------------------
; Test Case 5 - DMA Enabled
; INPUT
; KEY = 1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9
; PLAINTEXT = 00000000000000000000000000000000
; OUTPUT
; CIPHERTEXT = 531c2c38344578b84d50b3c917bbb6e1
; ---------------------------------------------------------------------------------------------------------------
send '1'
pause 1

;key
send '1d85a181b54cde51f0e098095b2962fdc93b51fe9b88602b3f54130bf76a5bd9'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;PLAINTEXT
send '00000000000000000000000000000000'
send 13
pause 1

;DMA Enabled
send '1'
pause 4

;Press any key
send $0

; ---------------------------------------------------------------------------------------------------------------
; AES-128 Decryption
; ---------------------------------------------------------------------------------------------------------------
; ---------------------------------------------------------------------------------------------------------------
; Test Case 6 - non DMA
; INPUT
; KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
; CIPHERTEXT = 4bf3b0a69aeb6657794f2901b1440ad4
; OUTPUT
; PLAINTEXT = 00000000000000000000000000000000
; ---------------------------------------------------------------------------------------------------------------
send '2'
pause 1

;key
send '28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;CIPHERTEXT
send '4bf3b0a69aeb6657794f2901b1440ad4'
pause 1

;DMA disabed
send '0'
pause 4

;Press any key
send $0


; ---------------------------------------------------------------------------------------------------------------
; Test Case 7 - DMA
; INPUT
; KEY = 28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64
; CIPHERTEXT = 4bf3b0a69aeb6657794f2901b1440ad4
; OUTPUT
; PLAINTEXT = 00000000000000000000000000000000
; ---------------------------------------------------------------------------------------------------------------
send '2'
pause 1

;key
send '28d46cffa158533194214a91e712fc2b45b518076675affd910edeca5f41ac64'
pause 1

;Initialization Vector(IV)
send '00000000000000000000000000000000'
pause 1

;CIPHERTEXT
send '4bf3b0a69aeb6657794f2901b1440ad4'
pause 1

;DMA enabed
send '1'

pause 5
logclose
114 changes: 114 additions & 0 deletions applications/user-crypto/mpfs-user-crypto-aes-cryptography/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# PolarFire SoC MSS User Crypto AES Cryptography Services Example

This example project demonstrate the use of symmetric key encryption and
decryption services. The following PolarFire (SoC) User Crypto service functions
are used:

- CALSymEncrypt()
- CALSymEncryptDMA()
- CALSymDecrypt()
- CALSymDecryptDMA()

## How to use this example

On connecting PolarFire SoC Video kit J12 to the host PC, you should see 4 COM
port interfaces connected. To use this project configure the COM port
**interface1** as below:
- 115200 baud
- 8 data bits
- 1 stop bit
- no parity
- no flow control

The example project will display instructions over the serial port. A greeting
message and menu instructions are displayed over the UART. Follow the instruction
to use different menu options provided by the example project and input data
when requested. This program also displays the return data from User Crypto
processor for encryption and decryption services.

#### Options

- **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 generates 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.

## Target Hardware

This example project is targeted at PolarFire SoC Video kit (MPFS250TS-1FCG1152I).
The reference design for the PolarFire SoC video kit is available in the
following GitHub repository: [PolarFire® SoC Video Kit Reference Design.](https://github.com/polarfire-soc/polarfire-soc-video-kit-reference-design)

The steps mentioned [here](https://github.com/polarfire-soc/polarfire-soc-video-kit-reference-design)
can be used to generate a *FlashPro Express* job file from above mentioned tcl
script.

This project provides build configurations and debug launchers as explained [here](https://mi-v-ecosystem.github.io/redirects/repo-polarfire-soc-bare-metal-examples)

## Configurations

- **PolarFire User Crypto Driver Configuration**
- **config_user.h** is a custom configuration file for PolarFire SoC CAL
library. Following are the recommended configuration for config_user.h file.

- Define **g_user_crypto_base_address** global variable as shown below.
This will used to configure the **PKX0_BASE** (defined in config_user.h)
and to connect to the User Crypto Co-processor in the Libero design.

`uint32_t g_user_crypto_base_addr 0x22000000UL;`

- **SAT_LITTLE_ENDIAN** - Endianness of the processor executing CAL
Library customization definitions. These definitions enable the
respective cryptographic services in the CAL which are supported by the
User Crypto Processor. It is recommended that these definitions are not
removed or changed unless required.

- A symbol INC_STDINT_H is defined in project preprocessor setting. For more
detail, please refer to caltypes.h file present in CAL folder.

**NOTE:**
You must enter all input data as whole bytes. If you enter the 128-bit key
{1230...0} as 0x12 0x3 and press return, this will be treated as byte0 =0x12,
byte1 = 0x30, byte2-127 = 0x00.

## Macro Script

A macro script is provided with this example which automatically enters the NIST
vectors and associated data to verify the functionality. You can use
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.

## Silicon Revision Dependencies

This example is tested on PolarFire SoC Video kit (MPFS250TS-1FCG1152I).

## CAL Library Src

The CAL source code is bound by license agreement. If you need access to the CAL
source code, please contact FPGA_marketing@microchip.com for further details on
NDA requirements.
Loading

0 comments on commit a2b0cf1

Please sign in to comment.