|
SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
|
Client and server SSL/TLS examples.
See the examples getting started guide for an introduction to the examples.
A client program is a network program that opens and establishes a connection to a server.
We include a generic WebSocket client library and an example program that demonstrates use of the library:
Initialize the cryptographic RNG before sending frames, even without TLS. WsEchoClient.c uses the same demonstration seed as the other examples. Replace it with proper platform entropy in a product. A nonzero initialization result stops the example before connecting. The client rejects TinyMT and stops sending if it cannot obtain a masking key. See wscProtocolHandshake for the client's remaining protocol limits.
A generic secure SMTP library. SMTP is a common method for sending notifications from devices.
A server program is a network program that waits for and responds to requests from client network programs.
The MinnowServer is a secure WebSocket server library. The two demo programs WsChatServer.c and WsLedServer.c show how to use the APIs in the WebSocket server library.
The source file (CertCheck.c) shows how to implement a full server certificate check. The code includes most common root certificates, so it should technically be able to certify any server on the internet with a valid certificate.
The source file selib.c includes a generic TCP/IP socket wrapper around the transport agnostic SharkSSL API. All SharkSSL socket examples/demos use this library.
Makefiles and project files can be found in ../build
Modules | |
| Minnow Server | |
| Compact HTTPS and WebSocket Server. | |
| SharkMQ | |
| A secure SimpleMQ client designed for SharkSSL. | |
| SharkMQTT | |
| A secure MQTT client designed for SharkSSL. | |
| WebSocket Client Lib | |
| A compact WebSocket client library. | |
| SharkSSL Socket Example Lib | |
| The SharkSSL Socket Example Lib (selib.h/selib.c) is a basic module that wraps the transport agnostic SharkSSL functions for encoding and decoding into functions that interface to TCP/IP socket calls. | |
| Simple Mail Transfer Protocol | |
| A minimal secure SMTP client library (SMTPS and STARTTLS). | |
| SharkMQ proxy connections | |
| Define ENABLE_PROXY when compiling both SharkMQ.c and its callers to include HTTP CONNECT and SOCKS5. | |
Functions | |
| U8 * | msstrstrn (U8 *str, int slen, const U8 *substr) |
| Find a case-insensitive substring in a bounded text buffer. More... | |
| int | MS_send (MS *o, U8 opCode, int len) |
| Send a WebSocket frame from the prepared Minnow send buffer. More... | |
| void | SeCtx_save (SeCtx *o) |
| Suspend the active bare-metal socket context and save its stack. More... | |
| void | SeCtx_restore (SeCtx *o) |
| Restore a previously saved bare-metal socket context. More... | |
| int MS_send | ( | MS * | o, |
| U8 | opCode, | ||
| int | len | ||
| ) |
Send a WebSocket frame from the prepared Minnow send buffer.
Fill only the returned payload space before calling. This helper does not allocate or copy the payload.
| o | MS *; Required active Minnow WebSocket object whose send buffer was prepared with MS_prepSend. |
| opCode | U8; WebSocket opcode and FIN flags for the frame. |
| len | int; Nonnegative payload length in bytes, within the prepared buffer and at most 65535; must agree with its short/extended header form. |
| U8 * msstrstrn | ( | U8 * | str, |
| int | slen, | ||
| const U8 * | substr | ||
| ) |
Find a case-insensitive substring in a bounded text buffer.
| str | U8 *; Required borrowed input text; search also stops at its first NUL. |
| slen | int; Nonnegative maximum number of input bytes to inspect. |
| substr | const U8 *; Required NUL-terminated search text, borrowed for the call. |
| void SeCtx_restore | ( | SeCtx * | o | ) |
Restore a previously saved bare-metal socket context.
Clears the saved/ready flags and transfers control to the saved execution point. Does not return normally to its caller; use only with the matching SeCtx port and scheduler.
| o | SeCtx *; Required context with a saved stack; its original stack environment must still be valid. |
| void SeCtx_save | ( | SeCtx * | o | ) |
Suspend the active bare-metal socket context and save its stack.
For the supported bare-metal selib port only. Transfers control to the scheduler and resumes here after SeCtx_restore; do not use as a portable thread primitive.
| o | SeCtx *; Required initialized active context with no saved context and ready cleared. |