This repository contains an example demonstrating the compilation and use of PSA Crypto on Mbed OS.
This example requires the PSA Crypto API:
target.extra_labels_add": ["MBED_PSA_SRV"]
to target_overrides
in getting-started/mbed_app.json
. Note that
this cannot coexist with TF-M.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.
mbed-tools import mbed-os-example-mbed-crypto
mbed import mbed-os-example-mbed-crypto
mbed-os-example-mbed-crypto/getting-started
.Run the following command to build the example project, program the microcontroller flash memory and open a serial monitor:
$ mbed-tools compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
$ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
Your PC may take a few minutes to compile your code.
-- 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 --
If you have problems, you can review the documentation for suggestions on what could be wrong and how to fix it.
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.