Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Running PSA Crypto examples on Mbed OS

This repository contains an example demonstrating the compilation and use of PSA Crypto on Mbed OS.

Prerequisites

This example requires the PSA Crypto API:

  • On TF-M targets, this API is provided by TF-M and always enabled.
  • On other targets, Mbed OS PSA can be enabled by adding target.extra_labels_add": ["MBED_PSA_SRV"] to target_overrides in getting-started/mbed_app.json. Note that this cannot coexist with TF-M.

Mbed OS build tools

Mbed CLI 2

Starting with version 6.5, Mbed OS uses Mbed CLI 2. It uses Ninja as a build system, and CMake to generate the build environment and manage the build process in a compiler-independent manner. If you are working with Mbed OS version prior to 6.5 then check the section Mbed CLI 1.

  1. Install Mbed CLI 2.
  2. From the command-line, import the example: mbed-tools import mbed-os-example-mbed-crypto

Mbed CLI 1

  1. Install Mbed CLI 1.
  2. From the command-line, import the example: mbed import mbed-os-example-mbed-crypto

Building and running

  1. Change the current directory to mbed-os-example-mbed-crypto/getting-started.

  2. Connect a USB cable between the USB port on the board and the host computer.

  3. Run the following command to build the example project, program the microcontroller flash memory and open a serial monitor:

    • Mbed CLI 2
    $ mbed-tools compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
    • Mbed CLI 1
    $ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm

Your PC may take a few minutes to compile your code.

Expected output

-- Begin PSA Crypto Getting Started --

Import an AES key...    Imported a key
Sign a message...       Signed a message
Encrypt with cipher...  Encrypted plaintext
Decrypt with cipher...  Decrypted ciphertext
Hash a message...       Hashed a message
Verify a hash...        Verified a hash
Generate random...      Generated random data
Derive a key (HKDF)...  Derived key
Authenticate encrypt... Authenticated and encrypted
Authenticate decrypt... Authenticated and decrypted
Generate a key pair...  Exported a public key

-- End PSA Crypto Getting Started --

Troubleshooting

If you have problems, you can review the documentation for suggestions on what could be wrong and how to fix it.

License and contributions

The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info.

This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide.