SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSSL Renesas RX cryptography (GCC)

Use this backend for native cryptography in a Renesas RX application. It supplies optional arithmetic, cipher and hash implementations through the normal SharkSSL APIs.

Requirements

Use little-endian Renesas RX with 32-bit BigInt words and GNU RX. Match the RX instruction-set version in C and assembly. BigInt, X25519, ChaCha20, Poly1305 and SHA-2 support RXv1/v2/v3; P-256/P-384 assembly requires RXv2 or RXv3 (-misa=v2 or -misa=v3).

Build integration

Keep SharkSslCrypto.c, SharkSslBigInt.c and, for elliptic curves, SharkSslECC.c. Add the desired files:

File Integer switches set to 1
SharkSslCrypto_RX.S SHARKSSL_OPTIMIZED_CHACHA_ASM, SHARKSSL_OPTIMIZED_POLY1305_ASM, SHARKSSL_OPTIMIZED_SHA256_ASM, SHARKSSL_OPTIMIZED_SHA384_ASM, as needed
SharkSslBigInt_RX.S SHARKSSL_OPTIMIZED_BIGINT_ASM
SharkSslX25519_RX.S SHARKSSL_ECC_USE_CURVE25519, SHARKSSL_X25519_DEDICATED, SHARKSSL_X25519_ASM
SharkSslP256_RX.S SHARKSSL_ECC_USE_SECP256R1, SHARKSSL_ECC_P256_ASM
SharkSslP384_RX.S SHARKSSL_ECC_USE_SECP384R1, SHARKSSL_ECC_P384_ASM

Enable the corresponding algorithms as well as their assembly selectors. For ChaCha20 and Poly1305 these are SHARKSSL_USE_CHACHA20=1 and SHARKSSL_USE_POLY1305=1. The files are independent; include the shared crypto file only once. Do not link another BigInt backend with the RX BigInt file.

Assemble uppercase .S through the GNU RX compiler driver so it preprocesses SharkSSL_cfg.h. Pass the same target, include paths and feature definitions as C.

Configuration

Set BA_BYTE_ORDER=BA_BYTE_ORDER_LITTLE_ENDIAN in TargConfig.h. Set SHARKSSL_UNALIGNED_ACCESS according to the target and memory-region requirements. Select only the required algorithm optimizations; 0 keeps C. SHARKSSL_OPTIMIZED_SHA384_ASM selects the compressor shared by SHA-384 and SHA-512. When ChaCha20 assembly is disabled, SHARKSSL_CHACHA_SMALL_FOOTPRINT=1 selects the smaller C implementation. SHARKSSL_SHA256_SMALL_FOOTPRINT similarly controls the C SHA-256 path.

On RXv2/RXv3, BigInt and curve multiplication use the accumulator A0. Interrupt handlers using DSP instructions must save that accumulator. SHARKSSL_RX_BIGINT_UNROLL controls unrolled 8- and 12-word BigInt paths; set it to 0 to omit them. Temporary digit storage grows with operand length: allow 4 * (o1->len + o2->len + 2) bytes in the relevant BigInt multiplication path, in addition to the rest of the call stack.

Behavior and limitations

AES-GCM and the AES block API use the bitsliced C AES in SharkSslAesGcmCT.h. Keep SHARKSSL_OPTIMIZED_AES_ASM, SHARKSSL_OPTIMIZED_GCM_ASM and SHARKSSL_OPTIMIZED_GHASH_ASM at 0: the generic crypto implementation rejects these options on this target.

This backend does not use the Trusted Secure IP (TSIP) peripheral present on some RX parts. The Cortex-M GHASH helper is also unavailable on RX.

X25519 provides dedicated field arithmetic and the ladder independently of generic BigInt assembly. P-256/P-384 replace field-prime arithmetic; other curves and arithmetic modulo the scalar order retain their normal paths. Keep timing protections enabled and account for compiler-generated code and target instruction timing when assessing the complete operation.

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.