Find the code in Application Code Hub as Secure Encrypted Ethernet End Nodes
This project implements a configurable secure encrypted Ethernet communication node that can operate in three different modes—Transmit (TX), Receive (RX) and Intruder —selected at build time using compile‑time macros. Depending on which macro is enabled during compilation, the firmware conditionally includes only the logic required for that mode.
/* Macro for NODE selection: Select TX_BOARD, RX_BOARD or INTRUDER_BOARD and
* flash its corresponding profile */
#define TX_BOARD (1u) /* TX_BOARD is selected */
#define RX_BOARD (0u)
#define INTRUDER_BOARD (0u)
TX Node Mode (TX_BOARD) - In this mode, the device encrypts an image and transmits Ethernet frames when the transmission button is pressed. If the encrypt button is pressed, the Ethernet frames will contain the encrypted image. If the encrypt button is not pressed, the Ethernet frames will contain the base image.
RX Node Mode (RX_BOARD) - The device listens for incoming Ethernet frames and processes the data to display the received image in the LCD display. When the encrypt button is pressed the decryption is enabled.
Intruder Node Mode (INTRUDER_BOARD) - The device listens for incoming Ethernet frames and processes the data to display the received image in the LCD display. Intruder does not have access to decryption.
This project has the option to define if the on-board push buttons are used or external user push buttons connected to PTE24 and PTE25.
/* Macro for BUTTON selection: Select INTERNAL_BUTTONS or EXTERNAL_BUTTONS and
* flash its corresponding profile.*/
#define INTERNAL_BUTTONS (1u) // SW2 = Encryption, SW3 = Transmission
#define EXTERNAL_BUTTONS (0u) // PTE24 = Encryption, PTE25 = Transmission
The application runs on an NXP S32K344 MCU and demonstrates a complete image encryption, transmission, reception, and optional encryption pipeline.
The code encrypts an image using the HSE, transmits it over Ethernet, receives encrypted data, decrypts it using HSE, and displays it. The summarized functionality is the next:
This project makes extensive use of the AUTOSAR Crypto Stack, specifically the Crypto_43_HSE driver and the HSE embedded hardware module as the accelerator performing all AES operations. Some of the key functions and features to understand are:
RetVal = Crypto_43_HSE_Exts_FormatKeyCatalogs();
Crypto_43_HSE_KeyElementSet(APP_AES128_KEY_ID,KEY_MATERIAL_ELEMENT_ID_U32, App_au8Aes128EcbKey_1, APP_AES128_KEY_SIZE);
Crypto_43_HSE_KeySetValid(APP_AES128_KEY_ID);
Crypto_43_HSE_ProcessJob(APP_SYMMETRIC_CDO_ID, &App_JobAes128EcbEncrypt);
Crypto_43_HSE_ProcessJob(APP_SYMMETRIC_CDO_ID, &App_JobAes128EcbDecrypt);
#define CRYPTO_43_HSE_START_SEC_VAR_INIT_8_NO_CACHEABLE
The demo was developed using the FRDM Automotive Bundle for S32K3. To download and install the complete software and tools ecosystem, use the following link: S32K3 FRDM Automotive Board Installation Package.
As the application uses cryptography and the Hardware Security Engine (HSE) peripheral, it is necessary to download the Security Real-time drivers Crypto 7.0.0 QLP02 and the S32K344 HSE Standard Firmware to the bundle by following the next steps:
Open S32 Design Studio IDE, in the Dashboard Panel, choose Import project from Application Code Hub.
Found the demo you need by searching the name directly. Open the project, click the GitHub link, S32 Design Studio IDE will automatically retrieve project attributes then click Next>.
Select main branch and then click Next>.
Select your local path for the repo in Destination->Directory: window. The S32 Design Studio IDE will clone the repo into this path, click Next>.
Select Import existing Eclipse projects then click Next>.
Select the project in this repo (only one project in this repo) then click Finish.
Before connecting the display to the board it is necessary to solder 3 SMD pads to enable SPI transmission. The pads correspond to SI, SO and SCK marked in the silkscreen as 11, 12 and 13 respectivelly (yellow circle in the image). To connect the display to the board, follow the next image to make sure the pins in the board marked by red coincide with the pins in the display marked by red.
Note: This is a mandatory step to compile the Secure Encrypted Ethernet Communication project.
To generate the other executables, the macros must be modified to use the other node mode. In the app_cfg.h file within the src folder. Change the macro definition from: #define TX_BOARD (1u) to #define TX_BOARD (0u) and #define RX_BOARD (0u) to #define RX_BOARD (1u).
To set the intruder, repeat previous steps but set TX_BOARD and RX_BOARD to (0u) and INTRUDER_BOARD to (1u) in the macro definition for the intruder board.
Then clean project and build again to generate the RX node executable.
Go to Debug and select Debug Configurations. Select GDB PEMicro Interface Debugging:
Use the controls to control the program flow.
Note: The GDB PEMicro Interface Debugging configuration uses default ports 6224 and 7224. In example are provided 2 debug configurations, one with default ports and another one with custom ports to support debugging of 2 boards simultaneously on the same PC. You must change the
C/C++ Applicationpath in the debug configuration to point to the generated *.elf file, one for TX node and one for RX node. In one launch configuration, select one board (for example USB1) and in the second launch configuration, select the other board (for example USB2).
When one board is connected as transmitter, one as receiver and other as intruder, using three ETH cables to the Switch, the image on the transmitter board will appear in the display, on the receiver and intruder board, the image will appear when the transmit button is pressed in the transmitter. If the encrypt button is pressed in both transmitter and receiver, the image will show complete but encrypted in the intruder.
Questions regarding the content/correctness of this example can be entered as Issues within this GitHub repository or directly in the commentary section.
Warning: For more general technical questions regarding NXP Microcontrollers and the difference in expected functionality, enter your questions on the NXP Community Forum
This project implements a configurable secure encrypted Ethernet communication node with the transmission of a large data image.