SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSSL Kinetis K60 cryptography

Use this backend for Kinetis K60 cryptography with the Memory-Mapped Cryptographic Acceleration Unit (MMCAU) and Cortex-M assembly.

Requirements

Use a little-endian K60 target, compatible assembler and the platform MMCAU/RNG support required by SharkSslCrypto_K60.c. Supply the target types, memory, time, mutex and entropy integration for the application.

Build integration

1. Add big-integer assembly

Compile SharkSslBigInt_M3.s together with SharkSslBigInt.c and enable the assembly backend:

/* Use the Cortex-M big-integer assembly routines. */
#define SHARKSSL_OPTIMIZED_BIGINT_ASM 1

2. Set the target configuration

Add these definitions to TargConfig.h:

/* Configure the little-endian K60 target. */
#define BA_BYTE_ORDER BA_BYTE_ORDER_LITTLE_ENDIAN
#define SHARKSSL_UNALIGNED_ACCESS 1

3. Select the K60 crypto implementation

Compile SharkSslCrypto_K60.c in place of SharkSslCrypto.c. Enable the Memory-Mapped Cryptographic Acceleration Unit (MMCAU):

/* Select the K60 hardware crypto implementation. */
#define SHARKSSL_USE_MMCAU 1

The hash footprint options apply when the corresponding hash is enabled. For each option, 1 selects smaller, slower code; 0 selects larger, faster code.

Hash Enabled by Footprint option
MD5 SHARKSSL_USE_MD5 SHARKSSL_MD5_SMALL_FOOTPRINT
SHA-1 SHARKSSL_USE_SHA1 SHARKSSL_SHA1_SMALL_FOOTPRINT
SHA-256 SHARKSSL_USE_SHA_256 SHARKSSL_SHA256_SMALL_FOOTPRINT

4. Initialize entropy and platform services

The K60 implementation uses the native Hash_DRBG random generator. Supply unpredictable entropy through sharkssl_entropyEx before operations that require randomness. Follow the random-generator configuration for seed sizes and initialization order. Provide the target mutex services needed to serialize access to MMCAU.

5. Add ChaCha20 and Poly1305 assembly

Compile SharkSslCrypto_M3.s and enable both assembly implementations:

/* Use assembly for encryption and message authentication. */
#define SHARKSSL_OPTIMIZED_POLY1305_ASM 1
#define SHARKSSL_OPTIMIZED_CHACHA_ASM 1

Configuration

Apply the same algorithm and optimization definitions throughout the build. Select only the hashes and ciphers needed by the application. The hash footprint switches above accept integer 0 or 1; follow the current configuration header for their defaults.

Keep SHARKSSL_OPTIMIZED_AES_ASM, SHARKSSL_OPTIMIZED_GCM_ASM and SHARKSSL_OPTIMIZED_GHASH_ASM at 0. The K60 replacement file does not select those x86/AArch64 backends.

Behavior and limitations

SharkSslCrypto_K60.c replaces SharkSslCrypto.c; do not compile both. The K60 file uses MMCAU for AES rounds and C for GHASH. With the portable SharkSslCrypto.c instead, AES uses the bitsliced C implementation and unsupported assembly selectors are rejected.

The MMCAU selection does not supply application entropy or initialize the target scheduler. Supply the required initialization and locking for the application's runtime.

SHA and HMAC context operations return int: check for 0 on success and a negative result on failure. Use SharkSslHMACCtx_destructor to clear the context after use, including after failed initialization. MMCAU hash operations do not expose a separate hardware-fault status channel. Supply the application clock when using a port that requires baGetUnixTime.

The AES block API, CBC, CTR and CCM use SharkSslAesCtx. These application APIs do not add TLS cipher suites. SharkSSL TLS uses AES-GCM or ChaCha20-Poly1305 for record protection.