SharkSSL™ Embedded SSL/TLS Stack
SharkSSL Renesas RX Assembly

This guide explains how to add the RX assembly implementations to an existing SharkSSL build. Cipher acceleration and big-integer acceleration are configured separately.

ChaCha20 and Poly1305

Add the assembly implementation

Compile SharkSslCrypto_RX.s together with SharkSslCrypto.c:

/* Enable the RX encryption and message-authentication assembly hooks. */
#define SHARKSSL_OPTIMIZED_POLY1305_ASM 1
#define SHARKSSL_OPTIMIZED_CHACHA_ASM 1

Set the following in TargConfig.h:

/* Match the RX target's byte order and access configuration. */
#define B_LITTLE_ENDIAN
#define SHARKSSL_UNALIGNED_ACCESS

Enable the algorithms

Enable the algorithms required by your application:

/* Include the algorithms used by these assembly implementations. */
#define SHARKSSL_USE_POLY1305 1
#define SHARKSSL_USE_CHACHA20 1

See SharkSslCrypto.h for the APIs. The Poly1305 implementation is based on Daniel J. Bernstein's "The Poly1305-AES message-authentication code", but this API does not use AES. The ChaCha20 implementation is based on his "The ChaCha family of stream ciphers".

When ChaCha20 assembly is excluded, SHARKSSL_CHACHA_SMALL_FOOTPRINT=1 selects a smaller, slightly slower C implementation.

Big-integer assembly

Compile SharkSslBigInt_RX.s together with SharkSslBigInt.c:

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

Set the following in TargConfig.h:

/* Configure little-endian byte order and 32-bit arithmetic words. */
#define B_LITTLE_ENDIAN
#define SHARKSSL_BIGINT_WORDSIZE 32
#define SHARKSSL_UNALIGNED_ACCESS 1

Compare configuration examples

The historical speed and size examples are shown side by side below. Enable CCM only if your application needs it.

These values are reference examples, not a production TLS preset. In particular, SHARKSSL_USE_RNG_TINYMT=1 selects a generator unsuitable for cryptographic use. For a current build, follow build configuration and the configuration API.

Setting Speed example Size example
B_LITTLE_ENDIAN 1 1
SHARKSSL_AES_CIPHER_LOOP_UNROLL 1 0
SHARKSSL_BIGINT_EXP_SLIDING_WINDOW_K 5 1
SHARKSSL_BIGINT_WORDSIZE 32 32
SHARKSSL_DES_CIPHER_LOOP_UNROLL 1 0
SHARKSSL_ENABLE_AES_CCM 1 /* IF NEEDED */ 1 /* IF NEEDED */
SHARKSSL_ENABLE_AES_CTR_MODE 0 0
SHARKSSL_ENABLE_AES_GCM 1 1
SHARKSSL_ENABLE_RSA_BLINDING 1 1
SHARKSSL_MD5_SMALL_FOOTPRINT 0 1
SHARKSSL_OPTIMIZED_BIGINT_ASM 1 1
SHARKSSL_SHA1_SMALL_FOOTPRINT 0 1
SHARKSSL_SHA256_SMALL_FOOTPRINT 0 1
SHARKSSL_UNALIGNED_ACCESS 1 1
SHARKSSL_USE_3DES 1 1
SHARKSSL_USE_AES_128 1 1
SHARKSSL_USE_AES_256 1 1
SHARKSSL_USE_ARC4 0 0
SHARKSSL_USE_DES 0 0
SHARKSSL_USE_ECC 1 1
SHARKSSL_USE_RNG_TINYMT 1 1
SHARKSSL_USE_SHA_256 1 1

Performance and benefit

The RX routines provide processor-specific implementations of ChaCha20, Poly1305, and big-integer arithmetic. Their intended benefit is lower cryptographic processing cost without changing application APIs. Performance depends on the selected routines, compiler settings, and RX processor. Measure the selected configuration on the intended RX processor before estimating application throughput.