SharkSSL is a compact C library that brings Transport Layer Security (TLS) 1.3 and 1.2 to embedded clients and servers. The TLS core comes in one source file and works with your existing networking code on bare metal (no operating system), a real-time operating system (RTOS), or embedded Linux.
- Post-quantum cryptography (PQC) lets a TLS 1.3 connection establish its keys using both classical cryptography and ML-KEM, an algorithm designed to resist attacks by future quantum computers. Your device can also verify post-quantum signatures on firmware updates.
- Platform Security Architecture (PSA) lets SharkSSL use your device's cryptography service. On hardware with an isolated key store, the service can sign a TLS handshake while the private key stays out of application memory.
The unmodified Eclipse Paho MQTT C client runs on Zephyr on NXP's FRDM-RW612 board. SharkSSL's OpenSSL adapter supplies the TLS calls Paho already uses, and the board's PSA service handles the cryptography. You can run the same publisher on Windows or Linux and watch the messages arrive with the included Python subscriber. Build the Paho MQTT example · OpenSSL adapter
The package also includes cryptographic functions you can use independently of TLS and five protocol libraries for messaging, web connections, and email. Included protocol libraries · SharkSSL product overview · Integration guides
A TLS connection starts with a handshake: the two sides agree on settings and establish secret keys to protect the data they exchange. In a typical connection, the server also proves its identity using a certificate and a private key.
The certificate management guide explains the pieces:
- A certificate associates an identity, such as a server name, with a public key. Others can use that public key to check digital signatures made with the matching private key, which must remain secret.
- A certificate authority (CA) signs certificates. Your application decides which authorities to trust. A certificate chain links the server's certificate through its issuers to a trusted authority.
- Mutual TLS (mTLS) adds a client certificate so the server can verify the client's identity too.
To give a device its own identity, use SharkSSL to create a certificate signing request (CSR) for the device's public key. The issuer approves the requested names and uses SharkSSL's optional signing API to issue a TLS client or server certificate. The device can then check the key, names, issuer, and validity dates before installing the certificate. Certificate request and issuance example
An encrypted connection still needs an identity check. Before sending sensitive data, a client must check certificate trust and the expected server name. Certificate validity checks also require the correct device time and date to be enabled. See the certificate tutorial for an introduction, and the management guide for SharkSSL's configuration and trust-checking functions.
Use the steps below for the native SharkSSL examples on Linux or Windows. For the complete Paho application on Zephyr, Windows or Linux, follow the Paho build guide, which builds its required components for you.
Only the LED-JSON example needs the separate RealTimeLogic JSON library, which handles JSON, a text format for structured data. To build all 15 standard examples, clone the two repositories side by side. You can skip the JSON checkout if you do not need that example.
git clone https://github.com/RealTimeLogic/SharkSSL.git
# Optional: needed only for the LED-JSON example.
git clone https://github.com/RealTimeLogic/JSON.git
cd SharkSSLInstall Git, GNU Make, and the GCC C/C++ compilers. From the repository root, build the examples and run RayCrypto-ECDSA. ECDSA means Elliptic Curve Digital Signature Algorithm: it lets a private key sign data and the matching public key verify that signature. This example runs locally with demonstration keys; it does not need a server or account.
make -C build -j4
# Sign and verify data locally; this example does not open a TLS connection.
./build/RayCrypto-ECDSAThe program should report successful signature verification. The example guide explains the other programs and their setup. The build writes the examples, three certificate tools, and the libraries they use to build/. Without the JSON checkout, it builds the other 14 examples.
Install Git and Visual Studio with Desktop development with C++ and the Windows Software Development Kit (SDK). Open SharkSSL.sln, select Debug or Release and x64 (64-bit) or Win32 (32-bit), then choose Build Solution. If you skipped the JSON checkout, unload LED-JSON in Solution Explorer first.
To try the same local signature example, right-click RayCrypto-ECDSA, select Set as Startup Project, and run it. Executables go to build/VS/bin/<platform>/<configuration>/. You can also build the solution from a Visual Studio Developer Command Prompt:
msbuild build\VS\SharkSSL.sln /m /p:Configuration=Release /p:Platform=x64If your JSON checkout is elsewhere, pass JSON_ROOT=/path/to/JSON to Make or /p:JsonRoot=C:\path\to\JSON to MSBuild. Before running a network example, follow its setup instructions; email and cloud examples need your service address and credentials.
When you are ready to integrate SharkSSL, choose an application programming interface (API), the functions your code calls. The API selection guide distinguishes TLS connections, individual cryptographic operations, and the protocol libraries.
For TLS, choose how SharkSSL connects to your networking code:
- Your application already handles network data: use the transport-independent API. SharkSSL processes TLS data; your code sends and receives the bytes through a reliable, ordered connection.
- Your platform has sockets: use the socket example library,
selib, with the matching platform port. A socket is the application's interface to a network connection. The normalselibcalls are blocking: they wait for an operation to complete or time out. - Using our IoT protocols, but your device has no operating system: see the bare metal integration guide. The optional
SeCtxsocket context manager supports the documented ports for event-driven networking, where incoming data triggers processing.
The main files are:
| File or directory | Purpose |
|---|---|
src/SharkSSL.c |
Combined, platform-independent TLS and cryptography implementation. |
inc/SharkSSL.h |
Public SharkSSL API declarations. |
inc/arch/<platform>/TargConfig.h |
Target settings and adaptation to the operating system and processor. |
src/selib.c |
Socket helpers used by the protocol examples. |
src/arch/ |
Network-specific support for selib where required. |
src/SeCtx.c |
Socket context manager for supported bare metal ports. |
For example, on Linux you can use the POSIX port, which targets standard Unix-style operating-system interfaces, to build a static library (compiled code that you link into your application):
# Compile the core, then package the object file into a library.
gcc -c src/SharkSSL.c -Iinc -Iinc/arch/Posix
ar rcs libsharkssl.a SharkSSL.oFor firmware, use the matching platform port and cross compiler, which builds code for your device rather than your development computer. Follow Configure SharkSSL for Your Build for feature settings, memory, device time, and a source of unpredictable data for generating cryptographic keys. Example keys and demonstration random-number inputs must be replaced for a product.
OpenSSL is another TLS and cryptography library with its own API. If your application already uses it, the OpenSSL adapter lets you retain supported calls such as SSL_connect and SSL_read_ex while SharkSSL does the work underneath. It supports a documented subset of OpenSSL interfaces. Recompile your application with the adapter headers and the matching SharkSSL build. The supplied examples select the sources and settings for their target.
Start with a complete networked application: the Paho MQTT C example runs the unmodified Eclipse Paho MQTT C client on Windows, Linux and Zephyr. Windows and Linux use SharkSSL's native cryptography. On NXP's FRDM-RW612, SharkSSL uses the PSA Crypto service in Trusted Firmware-M (TF-M), isolated from Zephyr by Arm TrustZone. The example includes the adapter settings and platform integration; Paho's source stays unchanged. Follow the instructions for your target, then use the supplied Python subscriber to watch the publisher's numbered messages.
To explore individual adapter APIs, start with the crypto example. Using fixed demonstration inputs, it shows three operations described in the adapter guide: SHA-256 hashing (making a fixed-size fingerprint of data), HMAC (detecting message changes using a shared secret), and HKDF (deriving keys from an input secret).
make -C build SharkSslOsslCryptoExample
./build/SharkSslOsslCryptoExampleThe TLS example runs a client and server in one process. It passes encrypted bytes through memory BIOs, OpenSSL-style input/output buffers, instead of a network connection. The client verifies the server's certificate and hostname before exchanging messages.
Supply your server certificate chain, its matching unencrypted private key, and the trusted CA certificate in PEM format, a text encoding used for certificates and keys. The final argument is the server name to verify. These files are inputs you provide; use localhost below only if your certificate covers that name.
make -C build SharkSslOsslTlsExample
./build/SharkSslOsslTlsExample server.pem key.pem ca.pem localhostThe optional dispatcher integration reuses components from the Barracuda Embedded Web Server: the SoDisp portable socket dispatcher and the BaTimer timer manager. The OpenSSL adapter does not use selib, the socket library used by SharkSSL's native examples.
SoDisp provides socket and event interfaces across supported operating systems, including RTOSs. The HTTPS client helper opens a TCP connection and attaches it to TLS through a dispatcher BIO. When TLS needs more data or room to send, SoDisp reports socket readiness so the application's callback can continue. BaTimer schedules buffered work and checks timeouts even when the peer is silent. Multiple TLS connections can share one dispatcher and timer manager.
Use SoDisp when the same application needs to run on several platforms. Applications that already manage their own sockets, such as Paho, can use the adapter's direct socket integration instead. The dispatcher HTTPS client example shows the SoDisp path: it verifies the server's certificate and hostname, sends a request and prints the response.
To try it locally, start an HTTPS server in one terminal using the certificate and key from the previous example. This command uses the OpenSSL command-line tool as the test server.
openssl s_server -accept 9443 -cert server.pem -key key.pem -wwwIn a second terminal, build and run the client. You can also supply your own server's DNS name, port, and trusted CA file.
make -C build SharkSslOsslDispatcherExample
./build/SharkSslOsslDispatcherExample localhost 9443 ca.pemOn Windows, build and run the projects with the same names in the solution. For your own desktop application using native cryptography, add compat/openssl/include to its header search path and apply the adapter build configuration when compiling each source file that uses the adapter. These builds include the native SharkSSL core in libSharkSSLOpenSSL.a on Linux and SharkSSLOpenSSL.lib on Windows. For a dispatcher-based application, also link libSharkSSLDispatcher.a or SharkSSLDispatcher.lib. The Paho builds use their own configuration supplied with the integration.
The bundled dispatcher includes the shared connection code and the OS and network porting layers. The Makefile pairs POSIX threads with the select dispatcher on Linux. The Visual Studio project pairs Windows threads with Winsock. For firmware, choose the thread and socket ports for your RTOS and TCP/IP stack and provide the corresponding vendor SDK. See the adapter build guide.
The default build uses SharkSSL's native C cryptography. Apply the same feature settings to the library and the application that includes its headers; the defaults are in inc/SharkSSL_cfg.h.
This package provides AES (Advanced Encryption Standard), an encryption algorithm, and AES-GCM, which combines AES encryption with checks for altered data. Their portable C implementations are constant-time with respect to secret values: secret keys and data do not select branches or memory-access patterns in these implementations. This reduces exposure to attacks that try to infer secrets from execution timing; it does not mean every message takes the same time to process. See constant-time cryptography and acceleration for the scope of these protections.
The full SharkSSL SDK adds processor-specific, assembler-optimized cryptography across many platforms. Those assembly sources are supplied separately from this amalgamated package. For example, supported x86/x64 and 64-bit Arm implementations use dedicated processor instructions to encrypt TLS data faster through the same API. The acceleration guide lists platforms, algorithms, and build requirements.
SharkSSL supports two families of post-quantum algorithms. ML-KEM helps two peers establish a shared secret. ML-DSA creates and verifies digital signatures. You can enable the features your product needs.
- Protect a TLS connection. Enable
SHARKSSL_ENABLE_PQCfor TLS 1.3 hybrid key exchange. For example, X25519MLKEM768 combines conventional elliptic-curve key exchange with ML-KEM-768. You can allow conventional connections as a fallback or require a hybrid connection. - Authenticate a TLS peer. Enable
SHARKSSL_ENABLE_MLDSA_CERTto verify ML-DSA signatures on certificates and in TLS 1.3 handshakes. AddSHARKSSL_ENABLE_MLDSA_SIGNto sign with a native ML-DSA private key. SharkSSL supports ML-DSA-44, ML-DSA-65, and ML-DSA-87. - Verify a firmware update. With
SHARKSSL_USE_MLDSAenabled, an updater can read the image in chunks and verify its signature with a trusted public key before accepting it. Only a chunk of the image needs to fit in RAM at a time. This works independently of TLS.
These features are disabled by default. The PQC guide covers compatible peers, configuration, and how much extra memory and network traffic to budget for during a handshake. Post-quantum integration guide
The Platform Security Architecture (PSA) Crypto API gives SharkSSL a standard way to request cryptographic operations from your platform's provider, the software that performs them and manages keys. Key protection, hardware acceleration, and available algorithms depend on the provider and the device.
On the NXP FRDM-RW612, Arm TrustZone isolates the PSA service in Trusted Firmware-M (TF-M) from the Zephyr application. The Paho example uses that service to encrypt its connection to the broker. It connects anonymously and has no client credentials to store. See Paho on Zephyr for details.
Our Xedge example for Zephyr runs a Lua application server on the same board and also uses PSA to protect stored secrets. When a browser connects over HTTPS, TF-M signs the handshake and keeps the private key in its secure environment. Xedge stores its user database in a configuration file encrypted with a key derived from a device-specific secret in TF-M. Copying the file to another board leaves the database encrypted. See Xedge on the FRDM-RW612 for details.
To use your own platform's provider, select a supported SHARKSSL_PSA_CONSUMER configuration and link the provider with its matching headers and settings. PSA consumer integration guide
TLS protects a connection; an application protocol defines the messages sent over it. These five libraries are included free of charge and work with SharkSSL when encryption is required. Their use remains subject to the SharkSSL Amalgamated license terms.
| Library and documentation | What you can build | Source |
|---|---|---|
| SharkMQ | A secure SMQ messaging client. Devices publish messages and subscribe to messages they want to receive, with a broker routing them. | src/SharkMQ.c |
| SharkMQTT | A compact MQTT client. MQTT is a messaging protocol in which a broker forwards published messages to clients subscribed to the matching topics. | src/SharkMQTT.c |
| WebSocket Client Lib | A WebSocket client for a persistent connection that lets either side send messages without waiting for a request. | src/WsClientLib.c |
| SMTP client | An email sender using the Simple Mail Transfer Protocol. It supports TLS from the start (SMTPS) or upgrading a connection to TLS (STARTTLS). | src/SMTP/SMTP.c |
| Minnow Server | A small web and WebSocket server. It serves HTTP, the web's request/response protocol, or HTTPS, which protects HTTP with TLS. | src/MinnowServer/MSLib.c |
The optional src/SMTP/BufPrint.c and src/MinnowServer/ZipFileSystem.c files support the SMTP and Minnow Server libraries. The complete Minnow Server reference example is maintained in a separate repository. Importing this example into SharkSSL will make the connections use HTTPS.
To compile the MQTT chat example directly on Linux, add its protocol source and the POSIX socket layer:
gcc -pthread -Iinc -Iinc/arch/Posix -Isrc/arch/Posix -o Chat-MQTT \
src/SharkSSL.c src/SharkMQTT.c src/selib.c examples/Chat-MQTT.cSharkSSL lets you select the algorithms and features your application needs to fit your device's memory budget. Program storage (flash or ROM) holds the compiled code and embedded certificate data. RAM (working memory) is needed for active connections, TLS buffers, certificate handling, and temporary calculations during a handshake. The amount required depends on your platform and configuration, including whether you enable post-quantum cryptography.
Measure program size and peak RAM use on your target device with the certificates and number of simultaneous connections your product will use. Include both connection handshakes and normal data transfers. The guide to reducing code and memory use explains how to reduce the build while preserving the security checks and compatibility your application needs.
SharkSSL's memory allocator, the code that reserves and releases working memory, is configurable. Use the allocator in examples/malloc or provide your own. Select it and other target-specific options in inc/arch/<platform>/TargConfig.h.
The examples directory includes, among others:
LED-SMQ.c: Controls a device through SimpleMQ.Chat-MQTT.c: Sends and receives MQTT chat messages.AWS-MQTT.c: Connects to Amazon Web Services' IoT Core, a cloud service for connected devices, using MQTT. Supply your service address and device credentials before running it.WsEchoClient.c: Connects to a WebSocket service that sends received messages back to the client.SMTP-example.c: Sends email using SMTP. Configure your email account first.SharkTrust.c: Uses SharkTrust with Minnow Server to automate HTTPS certificate enrollment and renewal.
See the official example documentation for setup and API details. The tools directory contains certificate and key conversion utilities documented under SharkSSL certificate management.
For a guided device setup, see the SharkSSL development environment for ESP32, an educational package using the FreeRTOS real-time operating system.
For an embedded SSH server, see the separate SharkSSH repository.
SharkSSL Amalgamated is licensed under either GPLv2 or a standard commercial license. See LICENSE for the GPLv2 terms.
If GPLv2 is not suitable for your product, a commercial license is available. A free commercial license may be available to qualifying small companies; see the startup license for details.
This distribution includes cryptographic software. The country in which you reside may restrict the import, possession, use, or re-export of encryption software. Before using this software, check the applicable laws, regulations, and policies. See the Wassenaar Arrangement for more information.
The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software under Export Commodity Control Number (ECCN) 5D002.C.1. This classification includes information-security software that uses or performs cryptographic functions with asymmetric algorithms. The form and manner of this distribution make it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception. See Section 740.13 of the BIS Export Administration Regulations for the applicable requirements.