|
SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
|
Adapters that call the selected external provider.
Files | |
| file | SharkSslPSAConsumerCMAC.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerCurves.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerECDH.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerECDSA.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerEdDSA.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerHash.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerKeyWrap.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerPBKDF2.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerRSA.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
| file | SharkSslPSAConsumerSP800108.h |
| See Choose a SharkSSL API for build scope and the owning API layer. | |
Functions | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_generate (SharkSslPSAEcdsaKey *o, U16 curveID, psa_algorithm_t hashAlg, int deterministic) |
| Generate a volatile private key through the selected PSA provider. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_importPrivate (SharkSslPSAEcdsaKey *o, U16 curveID, psa_algorithm_t hashAlg, int deterministic, const U8 *privateKey, U16 privateKeyLen) |
| Import a private key into an owned volatile PSA handle. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_importPublic (SharkSslPSAEcdsaKey *o, U16 curveID, psa_algorithm_t hashAlg, int deterministic, const U8 *publicKey, U16 publicKeyLen) |
| Import a public verification/encryption key into a volatile PSA handle. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_exportPublic (const SharkSslPSAEcdsaKey *o, U8 *publicKey, U16 publicKeySize, U16 *publicKeyLen) |
| Export the public key without transferring handle ownership. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_signRaw (const SharkSslPSAEcdsaKey *o, const U8 *hash, U16 hashLen, U8 *signature, U16 signatureSize, U16 *signatureLen) |
| Sign a digest and return fixed-width raw ECDSA r||s. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_verifyRaw (const SharkSslPSAEcdsaKey *o, const U8 *hash, U16 hashLen, const U8 *signature, U16 signatureLen) |
| Verify a fixed-width raw ECDSA r||s signature over a digest. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsaKey_destructor (SharkSslPSAEcdsaKey *o) |
| Destroy the owned volatile PSA key and clear the context. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_generate (SharkSslPSAEdDSAKey *o, U16 bits, int prehash) |
| Generate a volatile private key through the selected PSA provider. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_importPrivate (SharkSslPSAEdDSAKey *o, const U8 *seed, U16 seedLen, U16 bits, int prehash) |
| Import a private key into an owned volatile PSA handle. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_importPublic (SharkSslPSAEdDSAKey *o, const U8 *publicKey, U16 publicKeyLen, U16 bits, int prehash) |
| Import a public verification/encryption key into a volatile PSA handle. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_exportPublic (const SharkSslPSAEdDSAKey *o, U8 *publicKey, U16 publicKeySize, U16 *publicKeyLen) |
| Export the public key without transferring handle ownership. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_sign (const SharkSslPSAEdDSAKey *o, const U8 *message, U32 messageLen, U8 *signature, U16 signatureSize, U16 *signatureLen) |
| Sign the original message using the selected EdDSA mode. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_verify (const SharkSslPSAEdDSAKey *o, const U8 *message, U32 messageLen, const U8 *signature, U16 signatureLen) |
| Verify an EdDSA signature over the original message. More... | |
| SHARKSSL_API int | SharkSslPSAEdDSAKey_destructor (SharkSslPSAEdDSAKey *o) |
| Destroy the owned volatile PSA key and clear the context. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_generate (SharkSslPSARSAKey *o, psa_algorithm_t alg, int exportable, U16 bits) |
| Generate a volatile private key through the selected PSA provider. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_importPrivate (SharkSslPSARSAKey *o, const U8 *privateDer, psa_algorithm_t alg, int exportable, U16 privateDerLen) |
| Import a private key into an owned volatile PSA handle. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_importPublic (SharkSslPSARSAKey *o, const U8 *publicDer, psa_algorithm_t alg, U16 publicDerLen) |
| Import a public verification/encryption key into a volatile PSA handle. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_exportPrivate (const SharkSslPSARSAKey *o, U8 *privateDer, U16 privateDerSize, U16 *privateDerLen) |
| Export an RSA private key created with export permission. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_exportPublic (const SharkSslPSARSAKey *o, U8 *publicDer, U16 publicDerSize, U16 *publicDerLen) |
| Export the public key without transferring handle ownership. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_encrypt (const SharkSslPSARSAKey *o, const U8 *plaintext, const U8 *label, U8 *ciphertext, U16 plaintextLen, U16 labelLen, U16 ciphertextSize, U16 *ciphertextLen) |
| Encrypt with an imported RSA public-key context. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_decrypt (const SharkSslPSARSAKey *o, const U8 *ciphertext, const U8 *label, U8 *plaintext, U16 ciphertextLen, U16 labelLen, U16 plaintextSize, U16 *plaintextLen) |
| Decrypt with an RSA private-key context. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_signHash (const SharkSslPSARSAKey *o, const U8 *hash, U8 *signature, U16 *signatureLen, U16 hashLen, U16 signatureSize) |
| Sign a digest with the RSA context algorithm. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_verifyHash (const SharkSslPSARSAKey *o, const U8 *hash, const U8 *signature, U16 hashLen, U16 signatureLen) |
| Verify an RSA signature over a digest. More... | |
| SHARKSSL_API int | SharkSslPSARSAKey_destructor (SharkSslPSARSAKey *o) |
| Destroy the owned volatile PSA key and clear the context. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsa_rawToDer (U16 curveID, const U8 *raw, U16 rawLen, U8 *der, U16 derSize, U16 *derLen) |
| Convert an ECDSA signature from raw r||s to DER. More... | |
| SHARKSSL_API int | SharkSslPSAEcdsa_derToRaw (U16 curveID, const U8 *der, U16 derLen, U8 *raw, U16 rawSize, U16 *rawLen) |
| Convert an ECDSA signature from DER to raw r||s. More... | |
| int SharkSslPSAEcdsa_derToRaw | ( | U16 | curveID, |
| const U8 * | der, | ||
| U16 | derLen, | ||
| U8 * | raw, | ||
| U16 | rawSize, | ||
| U16 * | rawLen | ||
| ) |
Convert an ECDSA signature from DER to raw r||s.
Encoding conversion does not verify the signature. Buffers must not overlap.
| curveID | U16; Supported SharkSSL Weierstrass curve ID: NIST P-224/256/384/521, Brainpool P-224/256/320/384/512 or secp256k1. Provider support is also required. |
| der | const U8 *; Required borrowed input buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs. |
| derLen | U16; Input length in bytes; raw must be twice the curve width and DER must contain exactly one complete signature. |
| raw | U8 *; Required caller-owned output buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs. |
| rawSize | U16; Output buffer capacity in bytes; raw requires twice the curve width, DER may require up to twice (curve width + 1) plus 7 bytes. |
| rawLen | U16 *; Required output byte count, initialized to 0. |
| int SharkSslPSAEcdsa_rawToDer | ( | U16 | curveID, |
| const U8 * | raw, | ||
| U16 | rawLen, | ||
| U8 * | der, | ||
| U16 | derSize, | ||
| U16 * | derLen | ||
| ) |
Convert an ECDSA signature from raw r||s to DER.
Encoding conversion does not verify the signature. Buffers must not overlap.
| curveID | U16; Supported SharkSSL Weierstrass curve ID: NIST P-224/256/384/521, Brainpool P-224/256/320/384/512 or secp256k1. Provider support is also required. |
| raw | const U8 *; Required borrowed input buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs. |
| rawLen | U16; Input length in bytes; raw must be twice the curve width and DER must contain exactly one complete signature. |
| der | U8 *; Required caller-owned output buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs. |
| derSize | U16; Output buffer capacity in bytes; raw requires twice the curve width, DER may require up to twice (curve width + 1) plus 7 bytes. |
| derLen | U16 *; Required output byte count, initialized to 0. |
| int SharkSslPSAEcdsaKey_destructor | ( | SharkSslPSAEcdsaKey * | o | ) |
Destroy the owned volatile PSA key and clear the context.
Requires SHARKSSL_PSA_CONSUMER. An already empty initialized context is allowed. On PSA destruction failure the handle is retained so cleanup can be retried; do not overwrite it.
| o | SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| int SharkSslPSAEcdsaKey_exportPublic | ( | const SharkSslPSAEcdsaKey * | o, |
| U8 * | publicKey, | ||
| U16 | publicKeySize, | ||
| U16 * | publicKeyLen | ||
| ) |
Export the public key without transferring handle ownership.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| publicKey | U8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed. |
| publicKeySize | U16; Writable public-key buffer capacity in bytes, sufficient for the selected curve. |
| publicKeyLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSAEcdsaKey_generate | ( | SharkSslPSAEcdsaKey * | o, |
| U16 | curveID, | ||
| psa_algorithm_t | hashAlg, | ||
| int | deterministic | ||
| ) |
Generate a volatile private key through the selected PSA provider.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSAEcdsaKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| curveID | U16; Supported SharkSSL Weierstrass curve ID: NIST P-224/256/384/521, Brainpool P-224/256/320/384/512 or secp256k1. Provider support is also required. |
| hashAlg | psa_algorithm_t; PSA_ALG_SHA_256, PSA_ALG_SHA_384 or PSA_ALG_SHA_512, supported by the provider. |
| deterministic | int; 0 for randomized ECDSA; nonzero for deterministic ECDSA. |
| int SharkSslPSAEcdsaKey_importPrivate | ( | SharkSslPSAEcdsaKey * | o, |
| U16 | curveID, | ||
| psa_algorithm_t | hashAlg, | ||
| int | deterministic, | ||
| const U8 * | privateKey, | ||
| U16 | privateKeyLen | ||
| ) |
Import a private key into an owned volatile PSA handle.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSAEcdsaKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| curveID | U16; Supported SharkSSL Weierstrass curve ID: NIST P-224/256/384/521, Brainpool P-224/256/320/384/512 or secp256k1. Provider support is also required. |
| hashAlg | psa_algorithm_t; PSA_ALG_SHA_256, PSA_ALG_SHA_384 or PSA_ALG_SHA_512, supported by the provider. |
| deterministic | int; 0 for randomized ECDSA; nonzero for deterministic ECDSA. |
| privateKey | const U8 *; Required borrowed big-endian private scalar, exactly one curve-width component. |
| privateKeyLen | U16; Private scalar length in bytes, matching the selected curve. |
| int SharkSslPSAEcdsaKey_importPublic | ( | SharkSslPSAEcdsaKey * | o, |
| U16 | curveID, | ||
| psa_algorithm_t | hashAlg, | ||
| int | deterministic, | ||
| const U8 * | publicKey, | ||
| U16 | publicKeyLen | ||
| ) |
Import a public verification/encryption key into a volatile PSA handle.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSAEcdsaKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| curveID | U16; Supported SharkSSL Weierstrass curve ID: NIST P-224/256/384/521, Brainpool P-224/256/320/384/512 or secp256k1. Provider support is also required. |
| hashAlg | psa_algorithm_t; PSA_ALG_SHA_256, PSA_ALG_SHA_384 or PSA_ALG_SHA_512, supported by the provider. |
| deterministic | int; 0 for randomized ECDSA; nonzero for deterministic ECDSA. |
| publicKey | const U8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed. |
| publicKeyLen | U16; Input public-key length in bytes, matching the selected curve. |
| int SharkSslPSAEcdsaKey_signRaw | ( | const SharkSslPSAEcdsaKey * | o, |
| const U8 * | hash, | ||
| U16 | hashLen, | ||
| U8 * | signature, | ||
| U16 | signatureSize, | ||
| U16 * | signatureLen | ||
| ) |
Sign a digest and return fixed-width raw ECDSA r||s.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. ECDSA signatures contain two curve-width components; Ed25519/Ed448 signatures contain 64/114 bytes respectively.
| o | const SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| hash | const U8 *; Required borrowed digest matching the context hash algorithm. |
| hashLen | U16; Digest length in bytes, matching the context algorithm. |
| signature | U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification. |
| signatureSize | U16; Output capacity in bytes, sufficient for the complete signature. |
| signatureLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSAEcdsaKey_verifyRaw | ( | const SharkSslPSAEcdsaKey * | o, |
| const U8 * | hash, | ||
| U16 | hashLen, | ||
| const U8 * | signature, | ||
| U16 | signatureLen | ||
| ) |
Verify a fixed-width raw ECDSA r||s signature over a digest.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| hash | const U8 *; Required borrowed digest matching the context hash algorithm. |
| hashLen | U16; Digest length in bytes, matching the context algorithm. |
| signature | const U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification. |
| signatureLen | U16; Signature length in bytes, matching the selected algorithm. |
| int SharkSslPSAEdDSAKey_destructor | ( | SharkSslPSAEdDSAKey * | o | ) |
Destroy the owned volatile PSA key and clear the context.
Requires SHARKSSL_PSA_CONSUMER. An already empty initialized context is allowed. On PSA destruction failure the handle is retained so cleanup can be retried; do not overwrite it.
| o | SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| int SharkSslPSAEdDSAKey_exportPublic | ( | const SharkSslPSAEdDSAKey * | o, |
| U8 * | publicKey, | ||
| U16 | publicKeySize, | ||
| U16 * | publicKeyLen | ||
| ) |
Export the public key without transferring handle ownership.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| publicKey | U8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed. |
| publicKeySize | U16; Writable public-key buffer capacity in bytes, sufficient for the selected curve. |
| publicKeyLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSAEdDSAKey_generate | ( | SharkSslPSAEdDSAKey * | o, |
| U16 | bits, | ||
| int | prehash | ||
| ) |
Generate a volatile private key through the selected PSA provider.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSAEdDSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| bits | U16; 255 for Ed25519 or 448 for Ed448; the provider must support the selected algorithm. |
| prehash | int; 0 for PureEdDSA; nonzero for Ed25519ph/Ed448ph. Sign/verify accept the original message and hash it internally in prehash mode. |
| int SharkSslPSAEdDSAKey_importPrivate | ( | SharkSslPSAEdDSAKey * | o, |
| const U8 * | seed, | ||
| U16 | seedLen, | ||
| U16 | bits, | ||
| int | prehash | ||
| ) |
Import a private key into an owned volatile PSA handle.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSAEdDSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| seed | const U8 *; Required borrowed private seed: 32 bytes for Ed25519 or 57 for Ed448. |
| seedLen | U16; Private seed length in bytes, exactly 32 or 57 for the chosen curve. |
| bits | U16; 255 for Ed25519 or 448 for Ed448; the provider must support the selected algorithm. |
| prehash | int; 0 for PureEdDSA; nonzero for Ed25519ph/Ed448ph. Sign/verify accept the original message and hash it internally in prehash mode. |
| int SharkSslPSAEdDSAKey_importPublic | ( | SharkSslPSAEdDSAKey * | o, |
| const U8 * | publicKey, | ||
| U16 | publicKeyLen, | ||
| U16 | bits, | ||
| int | prehash | ||
| ) |
Import a public verification/encryption key into a volatile PSA handle.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSAEdDSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| publicKey | const U8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed. |
| publicKeyLen | U16; Input public-key length in bytes, matching the selected curve. |
| bits | U16; 255 for Ed25519 or 448 for Ed448; the provider must support the selected algorithm. |
| prehash | int; 0 for PureEdDSA; nonzero for Ed25519ph/Ed448ph. Sign/verify accept the original message and hash it internally in prehash mode. |
| int SharkSslPSAEdDSAKey_sign | ( | const SharkSslPSAEdDSAKey * | o, |
| const U8 * | message, | ||
| U32 | messageLen, | ||
| U8 * | signature, | ||
| U16 | signatureSize, | ||
| U16 * | signatureLen | ||
| ) |
Sign the original message using the selected EdDSA mode.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. ECDSA signatures contain two curve-width components; Ed25519/Ed448 signatures contain 64/114 bytes respectively. Prehash mode hashes the message internally; do not pass a precomputed digest as the message.
| o | const SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| message | const U8 *; Borrowed original message bytes; may be NULL when messageLen is 0. |
| messageLen | U32; Original message length in bytes. |
| signature | U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification. |
| signatureSize | U16; Output capacity in bytes, sufficient for the complete signature. |
| signatureLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSAEdDSAKey_verify | ( | const SharkSslPSAEdDSAKey * | o, |
| const U8 * | message, | ||
| U32 | messageLen, | ||
| const U8 * | signature, | ||
| U16 | signatureLen | ||
| ) |
Verify an EdDSA signature over the original message.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. Prehash mode hashes the message internally; do not pass a precomputed digest as the message.
| o | const SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| message | const U8 *; Borrowed original message bytes; may be NULL when messageLen is 0. |
| messageLen | U32; Original message length in bytes. |
| signature | const U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification. |
| signatureLen | U16; Signature length in bytes, matching the selected algorithm. |
| int SharkSslPSARSAKey_decrypt | ( | const SharkSslPSARSAKey * | o, |
| const U8 * | ciphertext, | ||
| const U8 * | label, | ||
| U8 * | plaintext, | ||
| U16 | ciphertextLen, | ||
| U16 | labelLen, | ||
| U16 | plaintextSize, | ||
| U16 * | plaintextLen | ||
| ) |
Decrypt with an RSA private-key context.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| ciphertext | const U8 *; Required ciphertext buffer; caller-owned on encryption, borrowed on decryption. |
| label | const U8 *; Borrowed OAEP label, or NULL for zero labelLen; PKCS1v1.5 encryption requires an empty label. |
| plaintext | U8 *; Plaintext bytes, borrowed on encryption (NULL only for zero length), required caller-owned output on decryption. |
| ciphertextLen | U16; Input ciphertext length in bytes, exactly the RSA modulus width. |
| labelLen | U16; Label length in bytes; must be 0 for PKCS1v1.5 encryption. |
| plaintextSize | U16; Writable plaintext output capacity in bytes. |
| plaintextLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSARSAKey_destructor | ( | SharkSslPSARSAKey * | o | ) |
Destroy the owned volatile PSA key and clear the context.
Requires SHARKSSL_PSA_CONSUMER. An already empty initialized context is allowed. On PSA destruction failure the handle is retained so cleanup can be retried; do not overwrite it.
| o | SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| int SharkSslPSARSAKey_encrypt | ( | const SharkSslPSARSAKey * | o, |
| const U8 * | plaintext, | ||
| const U8 * | label, | ||
| U8 * | ciphertext, | ||
| U16 | plaintextLen, | ||
| U16 | labelLen, | ||
| U16 | ciphertextSize, | ||
| U16 * | ciphertextLen | ||
| ) |
Encrypt with an imported RSA public-key context.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. A private-key context cannot be passed here; export and import its public key first.
| o | const SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| plaintext | const U8 *; Plaintext bytes, borrowed on encryption (NULL only for zero length), required caller-owned output on decryption. |
| label | const U8 *; Borrowed OAEP label, or NULL for zero labelLen; PKCS1v1.5 encryption requires an empty label. |
| ciphertext | U8 *; Required ciphertext buffer; caller-owned on encryption, borrowed on decryption. |
| plaintextLen | U16; Input plaintext length in bytes, within the RSA padding/algorithm limit. |
| labelLen | U16; Label length in bytes; must be 0 for PKCS1v1.5 encryption. |
| ciphertextSize | U16; Writable ciphertext output capacity in bytes, at least the RSA modulus width. |
| ciphertextLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSARSAKey_exportPrivate | ( | const SharkSslPSARSAKey * | o, |
| U8 * | privateDer, | ||
| U16 | privateDerSize, | ||
| U16 * | privateDerLen | ||
| ) |
Export an RSA private key created with export permission.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| privateDer | U8 *; Required PKCS#1 private-key DER buffer; borrowed on import, caller-owned on export. |
| privateDerSize | U16; Private-key output capacity in bytes. |
| privateDerLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSARSAKey_exportPublic | ( | const SharkSslPSARSAKey * | o, |
| U8 * | publicDer, | ||
| U16 | publicDerSize, | ||
| U16 * | publicDerLen | ||
| ) |
Export the public key without transferring handle ownership.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| publicDer | U8 *; Required PKCS#1 public-key DER buffer; borrowed on import, caller-owned on export. |
| publicDerSize | U16; Public-key output capacity in bytes. |
| publicDerLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| int SharkSslPSARSAKey_generate | ( | SharkSslPSARSAKey * | o, |
| psa_algorithm_t | alg, | ||
| int | exportable, | ||
| U16 | bits | ||
| ) |
Generate a volatile private key through the selected PSA provider.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSARSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| alg | psa_algorithm_t; Supported concrete PSA RSA encryption or signature algorithm: PKCS1v1.5 encryption, OAEP with a hash, PKCS1v1.5 hash signature, or PSS with standard salt and a hash. Provider support is required. |
| exportable | int; 0 to prohibit private export; nonzero to request PSA_KEY_USAGE_EXPORT. Does not affect public export. |
| bits | U16; Nonzero RSA modulus size in bits, a multiple of 8 and supported by the provider. |
| int SharkSslPSARSAKey_importPrivate | ( | SharkSslPSARSAKey * | o, |
| const U8 * | privateDer, | ||
| psa_algorithm_t | alg, | ||
| int | exportable, | ||
| U16 | privateDerLen | ||
| ) |
Import a private key into an owned volatile PSA handle.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSARSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| privateDer | const U8 *; Required PKCS#1 private-key DER buffer; borrowed on import, caller-owned on export. |
| alg | psa_algorithm_t; Supported concrete PSA RSA encryption or signature algorithm: PKCS1v1.5 encryption, OAEP with a hash, PKCS1v1.5 hash signature, or PSS with standard salt and a hash. Provider support is required. |
| exportable | int; 0 to prohibit private export; nonzero to request PSA_KEY_USAGE_EXPORT. Does not affect public export. |
| privateDerLen | U16; Input private-key DER length in bytes. |
| int SharkSslPSARSAKey_importPublic | ( | SharkSslPSARSAKey * | o, |
| const U8 * | publicDer, | ||
| psa_algorithm_t | alg, | ||
| U16 | publicDerLen | ||
| ) |
Import a public verification/encryption key into a volatile PSA handle.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure. This operation initializes PSA Crypto. Do not reuse live context storage: initialization does not destroy a previous key.
| o | SharkSslPSARSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage. |
| publicDer | const U8 *; Required PKCS#1 public-key DER buffer; borrowed on import, caller-owned on export. |
| alg | psa_algorithm_t; Supported concrete PSA RSA encryption or signature algorithm: PKCS1v1.5 encryption, OAEP with a hash, PKCS1v1.5 hash signature, or PSS with standard salt and a hash. Provider support is required. |
| publicDerLen | U16; Input public-key DER length in bytes. |
| int SharkSslPSARSAKey_signHash | ( | const SharkSslPSARSAKey * | o, |
| const U8 * | hash, | ||
| U8 * | signature, | ||
| U16 * | signatureLen, | ||
| U16 | hashLen, | ||
| U16 | signatureSize | ||
| ) |
Sign a digest with the RSA context algorithm.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| hash | const U8 *; Required borrowed digest matching the context hash algorithm. |
| signature | U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification. |
| signatureLen | U16 *; Required output byte count, initialized to 0; valid output is reported only on success. |
| hashLen | U16; Digest length in bytes, matching the context algorithm. |
| signatureSize | U16; Output capacity in bytes, sufficient for the complete signature. |
| int SharkSslPSARSAKey_verifyHash | ( | const SharkSslPSARSAKey * | o, |
| const U8 * | hash, | ||
| const U8 * | signature, | ||
| U16 | hashLen, | ||
| U16 | signatureLen | ||
| ) |
Verify an RSA signature over a digest.
Requires SHARKSSL_PSA_CONSUMER and the corresponding adapter source. Input buffers are borrowed for the call. Output buffers must be discarded on failure.
| o | const SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter. |
| hash | const U8 *; Required borrowed digest matching the context hash algorithm. |
| signature | const U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification. |
| hashLen | U16; Digest length in bytes, matching the context algorithm. |
| signatureLen | U16; Signature length in bytes, matching the selected algorithm. |