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

Use this backend with the Carambola 3 OpenWrt target to select MIPS BigInt word operations and an optional ChaCha20 implementation.

Requirements

The assembly targets the QCA4531 MIPS 24Kc: big-endian MIPS32, o32 ABI, with 32-bit BigInt words. Use the OpenWrt ath79 GCC toolchain and -march=24kc. These files are not compatible with little-endian MIPS.

Build integration

Keep SharkSslBigInt.c and SharkSslCrypto.c in the library build.

File Switch Scope
SharkSslBigInt_MIPS.S SHARKSSL_OPTIMIZED_BIGINT_WORD_ASM=1 Add, subtract and right shift; multiplication and Montgomery reduction remain in C
SharkSslChaCha_MIPS.S SHARKSSL_OPTIMIZED_CHACHA_ASM=1 Optional ChaCha20 block implementation

Assemble uppercase .S through the GCC driver with matching configuration and include paths. For example, from the SharkSSL root:

# Use the big-endian o32 target and the word-operation selector in C as well.
mips-openwrt-linux-musl-gcc -O3 -march=24kc -DBA_BYTE_ORDER=BA_BYTE_ORDER_BIG_ENDIAN -DSHARKSSL_OPTIMIZED_BIGINT_WORD_ASM=1 -Iinc -Iinc/arch/Posix -Isrc -c src/crypto/MIPS_GCC/SharkSslBigInt_MIPS.S -o SharkSslBigInt_MIPS_asm.o

Link the resulting object into the application. Include the ChaCha20 file only when its independent selector and algorithm are enabled.

Configuration

Set BA_BYTE_ORDER=BA_BYTE_ORDER_BIG_ENDIAN consistently for all sources. Keep SHARKSSL_OPTIMIZED_BIGINT_ASM=0; the full and word-only BigInt selectors are mutually exclusive. The o32 BigInt structure layout is 12 bytes. Keep SHARKSSL_X25519_ASM=0 for this target.

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.

Poly1305, SHA-2, X25519 and P-256/P-384 field arithmetic use their C paths. The optional ChaCha20 hook does not guarantee a speed improvement for every compiler or workload. Preserve normal timing protections.

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.