STFCF Examples

The STFCF (STM32 Flexible Crypto Framework) library provides a robust set of cryptographic services and utilities for STM32 microcontrollers. To help users understand and integrate these features, the library includes a variety of example applications. Each example demonstrates a specific cryptographic operation or use case, ranging from message authentication and hashing to encryption, decryption, digital signatures, key management, and key exchange.

These examples are designed to:

  • Illustrate the correct usage of the STFCF APIs,

  • Serve as reference implementations for common cryptographic tasks,

  • Accelerate development and integration of security features in STM32-based projects.

The examples use a default implementation but can be tailored to the hardware in use. This flexibility lets you adapt the examples to best leverage the specific cryptographic capabilities of the target STM32 device.

List of STFCF Examples

Below is a list of available examples, each with a brief description of its purpose and functionality:

Example Name

Description

example_stfcf_auth_verify_aes_cmac

Authenticate and verify a message using the AES CMAC algorithm.

example_stfcf_auth_verify_hmac_sha2

Perform the generation and the verification of a known message authentication code (MAC) of a plaintext using the HMAC SHA256 algorithm.

example_stfcf_cipher_aes_cbc

Perform encryption and decryption using the AES CBC algorithm.

example_stfcf_cipher_aes_ccm

Perform authenticated encryption/decryption with associated data (AEAD/ADAD) using the AES CCM algorithm.

example_stfcf_cipher_aes_ecb

Use the PSA Crypto opaque driver based on the STM32 Key Wrap Engine to wrap the AES‑ECB private key. Then use the wrapped key to perform encryption and verify the decryption with the AES‑CBC algorithm.

example_stfcf_cipher_aes_gcm

Perform authenticated encryption/decryption with associated data (AEAD/ADAD) using the AES GCM algorithm.

example_stfcf_cipher_chachapoly

Perform an authenticated encryption and a verified decryption using the Chacha-Poly1305 algorithm.

example_stfcf_cipher_rsa_v2_2_crt

Perform encryption and decryption of a message using the RSA PKCS#1 v2.2 compliant algorithm.

example_stfcf_cipher_rsa_v2_2_std

Perform encryption and decryption of a message using the RSA PKCS#1 v2.2 compliant algorithm.

example_stfcf_drbg

Use the RandomGeneration DRBG.

example_stfcf_integrity_hash_sha2

Perform the digest of a known message using the SHA256 algorithm.

example_stfcf_public_key_export_ecc_ecdsa

Use the Mbed TLS PSA opaque driver with the STM32 Key Wrap Engine to wrap ECDSA keys. Then use the wrapped key to export the public key.

example_stfcf_shared_secret_gen_ecc_ecdh

Establish and verify a shared secret using the ECDH algorithm over SECP256 curve.

example_stfcf_sign_verify_ecc_ecdsa

Perform the signature and verification of a known message using the ECDSA algorithm over SECP256 curve.

example_stfcf_sign_verify_rsa_v1_5_crt

Perform the signature and verification of a known message using the RSA PKCS#1 v1.5 compliant algorithm.

example_stfcf_sign_verify_rsa_v1_5_std

Perform the signature and the verification of a known message using the RSA PKCS#1 v1.5 compliant algorithm.

example_stfcf_sign_verify_rsa_v2_2_crt

Perform the signature and the verification of a known message using the RSA PKCS#1 v2.2 with the Chinese Remainder Theorem (CRT) representation.

example_stfcf_sign_verify_rsa_v2_2_std

Perform the signature and the verification of a known message using the RSA PKCS#1 v2.2 compliant algorithm.

example_stfcf_wrapped_key_gen_ecc_ecdsa

Use the Mbed TLS PSA opaque driver with STM32 Key Wrap Engine to generate a wrapped ECDH private key.

For the complete list of STFCF examples, see STFCF examples.