STCryptoLib Examples

The STCryptoLib library provides a comprehensive set of cryptographic primitives and utilities for STM32 microcontrollers. To help users understand and integrate these features, the package 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, and key exchange.

These examples are designed to:

  • Illustrate the correct usage of the STCryptoLib APIs,

  • Serve as reference implementations for common cryptographic tasks,

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

List of STCryptoLib Examples

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

Example Name

Description

example_stcryptolib_auth_verify_aes_cmac

Authenticate and verify a message using the AES CMAC algorithm.

example_stcryptolib_auth_verify_hmac_sha2

Authenticate and verify a message using the HMAC SHA2 algorithm.

example_stcryptolib_auth_verify_kmac

Generate and verify a message authentication code using the KMAC algorithm.

example_stcryptolib_cipher_aes_cbc

Perform encryption and decryption using the AES CBC algorithm.

example_stcryptolib_cipher_aes_gcm

Perform authenticated encryption/decryption using the AES GCM algorithm.

example_stcryptolib_cipher_chachapoly

Perform authenticated encryption and verified decryption using the ChaCha20-Poly1305 algorithm.

example_stcryptolib_cipher_rsa_v2_2

Encrypt and decrypt a message using the RSA PKCS#1 v2.2 compliant algorithm.

example_stcryptolib_cipher_sm4_ctr

Perform encryption and decryption using the SM4 CTR algorithm.

example_stcryptolib_drbg

Generate random numbers based on known input entropy, nonce, and personalization.

example_stcryptolib_integrity_hash_sha2

Digest a message using the SHA256 algorithm.

example_stcryptolib_integrity_hash_sha3

Hash a message using the SHA3-512 algorithm.

example_stcryptolib_integrity_hash_shake

Hash a message using the SHAKE algorithm.

example_stcryptolib_integrity_hash_sm3

Hash a message using the SM3 algorithm.

example_stcryptolib_shared_secret_gen_ecc_ecdh

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

example_stcryptolib_sign_verify_ecc_ecdsa

Sign and verify a message using the ECDSA algorithm.

example_stcryptolib_sign_verify_ecc_sm2

Perform signature and verification of a message using the SM2 algorithm.

example_stcryptolib_sign_verify_rsa_v1_5

Perform signature and verification using the RSA PKCS#1 v1.5 compliant algorithm.

example_stcryptolib_sign_verify_rsa_v2_2

Sign and verify a message using the RSA PKCS#1 v2.2 compliant algorithm.

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