|
SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
|
Hash cloning, cleanup, one-shot adapters and representation helpers.
Availability follows the feature macros and selected native or PSA backend.
Functions | |
| SHARKSSL_API int | sharkssl_rng (U8 *, U16) |
| Fill a buffer using the configured random generator. More... | |
| SHARKSSL_API int | sharkssl_kmemcmp (const void *a, const void *b, U32 n) |
| Compare byte strings without early exit based on differing bytes. More... | |
| void | sharkssl_clear (void *data, U32 len) |
| Overwrite a buffer through the implementation clearing routine. More... | |
| U16 | sharkssl_getHashLen (U8 hashID) |
| Return the digest size for an enabled SharkSSL hash ID. More... | |
| int | sharkssl_hash (U8 *digest, U8 *data, U32 len, U8 hashID) |
| Compute a complete digest using a SharkSSL hash ID. More... | |
| SHARKSSL_API int | SharkSslSha1Ctx_clone (const SharkSslSha1Ctx *source, SharkSslSha1Ctx *target) |
| Clone an active PSA hash context without consuming the source. More... | |
| SHARKSSL_API int | SharkSslSha1Ctx_abort (SharkSslSha1Ctx *ctx) |
| Abort a PSA hash operation and release its resources. More... | |
| SHARKSSL_API int | SharkSslSha224Ctx_clone (const SharkSslSha224Ctx *source, SharkSslSha224Ctx *target) |
| Clone an active PSA hash context without consuming the source. More... | |
| SHARKSSL_API int | SharkSslSha224Ctx_abort (SharkSslSha224Ctx *ctx) |
| Abort a PSA hash operation and release its resources. More... | |
| SHARKSSL_API int | SharkSslSha256Ctx_clone (const SharkSslSha256Ctx *source, SharkSslSha256Ctx *target) |
| Clone an active PSA hash context without consuming the source. More... | |
| SHARKSSL_API int | SharkSslSha256Ctx_abort (SharkSslSha256Ctx *ctx) |
| Abort a PSA hash operation and release its resources. More... | |
| SHARKSSL_API int | SharkSslSha384Ctx_clone (const SharkSslSha384Ctx *source, SharkSslSha384Ctx *target) |
| Clone an active PSA hash context without consuming the source. More... | |
| SHARKSSL_API int | SharkSslSha384Ctx_abort (SharkSslSha384Ctx *ctx) |
| Abort a PSA hash operation and release its resources. More... | |
| SHARKSSL_API int | SharkSslSha512Ctx_clone (const SharkSslSha512Ctx *source, SharkSslSha512Ctx *target) |
| Clone an active PSA hash context without consuming the source. More... | |
| SHARKSSL_API int | SharkSslSha512Ctx_abort (SharkSslSha512Ctx *ctx) |
| Abort a PSA hash operation and release its resources. More... | |
| SHARKSSL_API int | SharkSslSha224Ctx_constructor (SharkSslSha224Ctx *ctx) |
| Initialize a PSA SHA-224 streaming operation. More... | |
| SHARKSSL_API int | SharkSslSha224Ctx_append (SharkSslSha224Ctx *ctx, const U8 *data, U32 len) |
| Append bytes to an active PSA SHA-224 operation. More... | |
| SHARKSSL_API int | SharkSslSha224Ctx_finish (SharkSslSha224Ctx *ctx, U8 digest[SHARKSSL_SHA224_HASH_LEN]) |
| Finish PSA SHA-224 and release the operation. More... | |
| SHARKSSL_API int | sharkssl_sha224 (const U8 *data, U32 len, U8 *digest) |
| Compute a one-shot SHA-224 digest through PSA. More... | |
| SHARKSSL_API int | SharkSslHMACCtx_destructor (SharkSslHMACCtx *ctx) |
| Clear an HMAC context and release any owned PSA resources. More... | |
| SHARKSSL_API int | SharkSslChaChaCtx_destructor (SharkSslChaChaCtx *ctx) |
| Abort a standalone PSA ChaCha20 operation and destroy its imported key. More... | |
| SHARKSSL_API int | sharkssl_chacha20poly1305_encrypt (const U8 key[32], const U8 nonce[12], const U8 *aad, const U8 *input, U8 *output, U8 tag[16], U32 len, U16 aadLen) |
| Perform one-shot ChaCha20-Poly1305 encryption and authentication. More... | |
| SHARKSSL_API int | sharkssl_chacha20poly1305_decrypt (const U8 key[32], const U8 nonce[12], const U8 *aad, const U8 *input, const U8 tag[16], U8 *output, U32 len, U16 aadLen) |
| Perform one-shot ChaCha20-Poly1305 authenticated decryption. More... | |
| SHARKSSL_API int | SharkSslAesCtx_cbc_pkcs7_decrypt (SharkSslAesCtx *ctx, const U8 iv[16], const U8 *input, U8 *output, U32 *outputLen, U32 len, U32 outputCapacity) |
| Decrypt PSA AES-CBC and remove PKCS#7 padding. More... | |
| SHARKSSL_API SHARKSSL_AES_API_STATUS | SharkSslAesCtx_ctr_mode (SharkSslAesCtx *ctx, U8 ctr[16], const U8 *input, U8 *output, U32 len) |
| Apply the SharkSSL AES counter-mode convention to complete blocks. More... | |
| int sharkssl_chacha20poly1305_decrypt | ( | const U8 | key[32], |
| const U8 | nonce[12], | ||
| const U8 * | aad, | ||
| const U8 * | input, | ||
| const U8 | tag[16], | ||
| U8 * | output, | ||
| U32 | len, | ||
| U16 | aadLen | ||
| ) |
Perform one-shot ChaCha20-Poly1305 authenticated decryption.
Requires the standalone PSA ChaCha20 adapter and provider multipart AEAD support. Output is cleared on processing failure after validation; invalid arguments may leave it unchanged.
| key | const U8[32]; Required borrowed 32-byte key. |
| nonce | const U8[12]; Required borrowed 12-byte nonce; encryption must not repeat a nonce with the same key. |
| aad | const U8 *; Borrowed additional authenticated data, or NULL when aadLen is 0. |
| input | const U8 *; Borrowed ciphertext bytes, or NULL when len is 0. |
| tag | const U8[16]; Required borrowed 16-byte expected tag. |
| output | U8 *; Required caller-owned output buffer of at least len bytes; use only on success. |
| len | U32; Payload length in bytes. |
| aadLen | U16; Additional authenticated data length in bytes. |
| int sharkssl_chacha20poly1305_encrypt | ( | const U8 | key[32], |
| const U8 | nonce[12], | ||
| const U8 * | aad, | ||
| const U8 * | input, | ||
| U8 * | output, | ||
| U8 | tag[16], | ||
| U32 | len, | ||
| U16 | aadLen | ||
| ) |
Perform one-shot ChaCha20-Poly1305 encryption and authentication.
Requires the standalone PSA ChaCha20 adapter and provider multipart AEAD support. Output is cleared on processing failure after validation; invalid arguments may leave it unchanged.
| key | const U8[32]; Required borrowed 32-byte key. |
| nonce | const U8[12]; Required borrowed 12-byte nonce; encryption must not repeat a nonce with the same key. |
| aad | const U8 *; Borrowed additional authenticated data, or NULL when aadLen is 0. |
| input | const U8 *; Borrowed plaintext bytes, or NULL when len is 0. |
| output | U8 *; Required caller-owned output buffer of at least len bytes; use only on success. |
| tag | U8[16]; Required caller-owned 16-byte output tag. |
| len | U32; Payload length in bytes. |
| aadLen | U16; Additional authenticated data length in bytes. |
| void sharkssl_clear | ( | void * | data, |
| U32 | len | ||
| ) |
Overwrite a buffer through the implementation clearing routine.
| data | void *; Required writable buffer owned by the caller. |
| len | U32; Number of bytes to overwrite with zeros. |
| U16 sharkssl_getHashLen | ( | U8 | hashID | ) |
Return the digest size for an enabled SharkSSL hash ID.
| hashID | U8; SHARKSSL_HASHID_* selector supported by the selected backend. |
| int sharkssl_hash | ( | U8 * | digest, |
| U8 * | data, | ||
| U32 | len, | ||
| U8 | hashID | ||
| ) |
Compute a complete digest using a SharkSSL hash ID.
| digest | U8 *; Required caller-owned output, at least sharkssl_getHashLen(hashID) bytes. |
| data | U8 *; Input bytes, borrowed and not modified; may be NULL only when len is 0. |
| len | U32; Input length in bytes. |
| hashID | U8; Enabled SHARKSSL_HASHID_* selector supported by the selected backend. |
| int sharkssl_kmemcmp | ( | const void * | a, |
| const void * | b, | ||
| U32 | n | ||
| ) |
Compare byte strings without early exit based on differing bytes.
| a | const void *; Required first readable buffer of n bytes. |
| b | const void *; Required second readable buffer of n bytes. |
| n | U32; Number of bytes to compare. |
| int sharkssl_rng | ( | U8 * | output, |
| U16 | len | ||
| ) |
Fill a buffer using the configured random generator.
Initialize and seed the selected RNG with sufficient entropy before cryptographic use. See sharkssl_entropyEx and the configuration guide; a successful call alone does not establish entropy quality.
| output | U8 *; Required writable caller-owned buffer of len bytes. |
| len | U16; Requested number of random bytes. |
| int sharkssl_sha224 | ( | const U8 * | data, |
| U32 | len, | ||
| U8 * | digest | ||
| ) |
Compute a one-shot SHA-224 digest through PSA.
Requires SHARKSSL_PSA_CONSUMER, SHARKSSL_USE_SHA_224 and provider SHA-224 support.
| data | const U8 *; Borrowed input, or NULL when len is 0. |
| len | U32; Input length in bytes. |
| digest | U8 *; Required caller-owned 28-byte output. |
| int SharkSslAesCtx_cbc_pkcs7_decrypt | ( | SharkSslAesCtx * | ctx, |
| const U8 | iv[16], | ||
| const U8 * | input, | ||
| U8 * | output, | ||
| U32 * | outputLen, | ||
| U32 | len, | ||
| U32 | outputCapacity | ||
| ) |
Decrypt PSA AES-CBC and remove PKCS#7 padding.
Requires SHARKSSL_PSA_CONSUMER_STANDALONE_AES and provider CBC-PKCS7 support. CBC padding does not authenticate the ciphertext. Processing failures clear outputCapacity bytes after validation.
| ctx | SharkSslAesCtx *; Required valid AES context initialized with the key. |
| iv | const U8[16]; Required borrowed 16-byte IV; unchanged. |
| input | const U8 *; Required ciphertext buffer, borrowed for the call. |
| output | U8 *; Required caller-owned plaintext buffer; only outputLen bytes are valid on success. |
| outputLen | U32 *; Required output byte count, initialized to 0. |
| len | U32; Nonzero ciphertext length in bytes, a multiple of 16. |
| outputCapacity | U32; Output capacity in bytes, at least len. |
| SHARKSSL_AES_API_STATUS SharkSslAesCtx_ctr_mode | ( | SharkSslAesCtx * | ctx, |
| U8 | ctr[16], | ||
| const U8 * | input, | ||
| U8 * | output, | ||
| U32 | len | ||
| ) |
Apply the SharkSSL AES counter-mode convention to complete blocks.
The counter increments from byte 0 with carry before encrypting each block. This little-endian convention differs from the provider PSA_ALG_CTR interface. Do not reuse a counter sequence with the same key.
| ctx | SharkSslAesCtx *; Required initialized AES context using the encryption key schedule. |
| ctr | U8[16]; Required 16-byte mutable counter, retained by the caller between calls. |
| input | const U8 *; Readable input of len bytes; required when len is nonzero. |
| output | U8 *; Writable output of len bytes; required when len is nonzero. |
| len | U32; Byte count, a multiple of 16. |
| int SharkSslChaChaCtx_destructor | ( | SharkSslChaChaCtx * | ctx | ) |
Abort a standalone PSA ChaCha20 operation and destroy its imported key.
Requires SHARKSSL_PSA_CONSUMER_STANDALONE_CHACHA20. The context is cleared; reconstruct before reuse. Native builds use the destructor macro instead.
| ctx | SharkSslChaChaCtx *; Required initialized PSA ChaCha20 context; caller retains the storage. |
| int SharkSslHMACCtx_destructor | ( | SharkSslHMACCtx * | ctx | ) |
Clear an HMAC context and release any owned PSA resources.
The native implementation clears the derived pads. The PSA consumer aborts the MAC and destroys its imported key. Do not continue appending after destruction.
| ctx | SharkSslHMACCtx *; Required initialized context; caller retains the storage. |
| int SharkSslSha1Ctx_abort | ( | SharkSslSha1Ctx * | ctx | ) |
Abort a PSA hash operation and release its resources.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Reconstruct before appending again.
| ctx | SharkSslSha1Ctx *; Required context initialized by construction or cloning. |
| int SharkSslSha1Ctx_clone | ( | const SharkSslSha1Ctx * | source, |
| SharkSslSha1Ctx * | target | ||
| ) |
Clone an active PSA hash context without consuming the source.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Finish or abort each copy independently; do not overwrite a live target.
| source | const SharkSslSha1Ctx *; Required active context, borrowed and unchanged. |
| target | SharkSslSha1Ctx *; Required distinct storage with no live PSA operation; receives an independent operation. |
| int SharkSslSha224Ctx_abort | ( | SharkSslSha224Ctx * | ctx | ) |
Abort a PSA hash operation and release its resources.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Reconstruct before appending again.
| ctx | SharkSslSha224Ctx *; Required context initialized by construction or cloning. |
| int SharkSslSha224Ctx_append | ( | SharkSslSha224Ctx * | ctx, |
| const U8 * | data, | ||
| U32 | len | ||
| ) |
Append bytes to an active PSA SHA-224 operation.
| ctx | SharkSslSha224Ctx *; Required active, unfinished context. |
| data | const U8 *; Borrowed input; may be NULL only when len is 0. |
| len | U32; Input length in bytes. |
| int SharkSslSha224Ctx_clone | ( | const SharkSslSha224Ctx * | source, |
| SharkSslSha224Ctx * | target | ||
| ) |
Clone an active PSA hash context without consuming the source.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Finish or abort each copy independently; do not overwrite a live target.
| source | const SharkSslSha224Ctx *; Required active context, borrowed and unchanged. |
| target | SharkSslSha224Ctx *; Required distinct storage with no live PSA operation; receives an independent operation. |
| int SharkSslSha224Ctx_constructor | ( | SharkSslSha224Ctx * | ctx | ) |
Initialize a PSA SHA-224 streaming operation.
Requires SHARKSSL_PSA_CONSUMER and SHARKSSL_USE_SHA_224. Finish or abort before reusing the storage.
| ctx | SharkSslSha224Ctx *; Required storage with no live operation; caller retains ownership. |
| int SharkSslSha224Ctx_finish | ( | SharkSslSha224Ctx * | ctx, |
| U8 | digest[SHARKSSL_SHA224_HASH_LEN] | ||
| ) |
Finish PSA SHA-224 and release the operation.
| ctx | SharkSslSha224Ctx *; Required active context; reconstruct before reuse. |
| digest | U8[SHARKSSL_SHA224_HASH_LEN]; Required caller-owned 28-byte output. |
| int SharkSslSha256Ctx_abort | ( | SharkSslSha256Ctx * | ctx | ) |
Abort a PSA hash operation and release its resources.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Reconstruct before appending again.
| ctx | SharkSslSha256Ctx *; Required context initialized by construction or cloning. |
| int SharkSslSha256Ctx_clone | ( | const SharkSslSha256Ctx * | source, |
| SharkSslSha256Ctx * | target | ||
| ) |
Clone an active PSA hash context without consuming the source.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Finish or abort each copy independently; do not overwrite a live target.
| source | const SharkSslSha256Ctx *; Required active context, borrowed and unchanged. |
| target | SharkSslSha256Ctx *; Required distinct storage with no live PSA operation; receives an independent operation. |
| int SharkSslSha384Ctx_abort | ( | SharkSslSha384Ctx * | ctx | ) |
Abort a PSA hash operation and release its resources.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Reconstruct before appending again.
| ctx | SharkSslSha384Ctx *; Required context initialized by construction or cloning. |
| int SharkSslSha384Ctx_clone | ( | const SharkSslSha384Ctx * | source, |
| SharkSslSha384Ctx * | target | ||
| ) |
Clone an active PSA hash context without consuming the source.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Finish or abort each copy independently; do not overwrite a live target.
| source | const SharkSslSha384Ctx *; Required active context, borrowed and unchanged. |
| target | SharkSslSha384Ctx *; Required distinct storage with no live PSA operation; receives an independent operation. |
| int SharkSslSha512Ctx_abort | ( | SharkSslSha512Ctx * | ctx | ) |
Abort a PSA hash operation and release its resources.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Reconstruct before appending again.
| ctx | SharkSslSha512Ctx *; Required context initialized by construction or cloning. |
| int SharkSslSha512Ctx_clone | ( | const SharkSslSha512Ctx * | source, |
| SharkSslSha512Ctx * | target | ||
| ) |
Clone an active PSA hash context without consuming the source.
Requires SHARKSSL_PSA_CONSUMER and the selected hash. Finish or abort each copy independently; do not overwrite a live target.
| source | const SharkSslSha512Ctx *; Required active context, borrowed and unchanged. |
| target | SharkSslSha512Ctx *; Required distinct storage with no live PSA operation; receives an independent operation. |