SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
PSA consumer application APIs

Detailed Description

Adapters that call the selected external provider.

See Choose a PSA Integration.

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...
 

Function Documentation

◆ SharkSslPSAEcdsa_derToRaw()

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.

Parameters
curveIDU16; 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.
derconst U8 *; Required borrowed input buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs.
derLenU16; Input length in bytes; raw must be twice the curve width and DER must contain exactly one complete signature.
rawU8 *; Required caller-owned output buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs.
rawSizeU16; Output buffer capacity in bytes; raw requires twice the curve width, DER may require up to twice (curve width + 1) plus 7 bytes.
rawLenU16 *; Required output byte count, initialized to 0.
Returns
int: 0 on success; -1 for invalid encoding, curve, arguments or capacity. Discard output on failure.

◆ SharkSslPSAEcdsa_rawToDer()

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.

Parameters
curveIDU16; 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.
rawconst U8 *; Required borrowed input buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs.
rawLenU16; Input length in bytes; raw must be twice the curve width and DER must contain exactly one complete signature.
derU8 *; Required caller-owned output buffer. Raw format is fixed-width big-endian r||s; DER is a SEQUENCE of two nonnegative INTEGERs.
derSizeU16; Output buffer capacity in bytes; raw requires twice the curve width, DER may require up to twice (curve width + 1) plus 7 bytes.
derLenU16 *; Required output byte count, initialized to 0.
Returns
int: 0 on success; -1 for invalid encoding, curve, arguments or capacity. Discard output on failure.

◆ SharkSslPSAEcdsaKey_destructor()

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.

Parameters
oSharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEcdsaKey_exportPublic()

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.

Parameters
oconst SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
publicKeyU8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed.
publicKeySizeU16; Writable public-key buffer capacity in bytes, sufficient for the selected curve.
publicKeyLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEcdsaKey_generate()

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.

Parameters
oSharkSslPSAEcdsaKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
curveIDU16; 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.
hashAlgpsa_algorithm_t; PSA_ALG_SHA_256, PSA_ALG_SHA_384 or PSA_ALG_SHA_512, supported by the provider.
deterministicint; 0 for randomized ECDSA; nonzero for deterministic ECDSA.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEcdsaKey_importPrivate()

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.

Parameters
oSharkSslPSAEcdsaKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
curveIDU16; 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.
hashAlgpsa_algorithm_t; PSA_ALG_SHA_256, PSA_ALG_SHA_384 or PSA_ALG_SHA_512, supported by the provider.
deterministicint; 0 for randomized ECDSA; nonzero for deterministic ECDSA.
privateKeyconst U8 *; Required borrowed big-endian private scalar, exactly one curve-width component.
privateKeyLenU16; Private scalar length in bytes, matching the selected curve.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEcdsaKey_importPublic()

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.

Parameters
oSharkSslPSAEcdsaKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
curveIDU16; 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.
hashAlgpsa_algorithm_t; PSA_ALG_SHA_256, PSA_ALG_SHA_384 or PSA_ALG_SHA_512, supported by the provider.
deterministicint; 0 for randomized ECDSA; nonzero for deterministic ECDSA.
publicKeyconst U8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed.
publicKeyLenU16; Input public-key length in bytes, matching the selected curve.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEcdsaKey_signRaw()

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.

Parameters
oconst SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
hashconst U8 *; Required borrowed digest matching the context hash algorithm.
hashLenU16; Digest length in bytes, matching the context algorithm.
signatureU8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification.
signatureSizeU16; Output capacity in bytes, sufficient for the complete signature.
signatureLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEcdsaKey_verifyRaw()

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.

Parameters
oconst SharkSslPSAEcdsaKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
hashconst U8 *; Required borrowed digest matching the context hash algorithm.
hashLenU16; Digest length in bytes, matching the context algorithm.
signatureconst U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification.
signatureLenU16; Signature length in bytes, matching the selected algorithm.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_destructor()

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.

Parameters
oSharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_exportPublic()

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.

Parameters
oconst SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
publicKeyU8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed.
publicKeySizeU16; Writable public-key buffer capacity in bytes, sufficient for the selected curve.
publicKeyLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_generate()

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.

Parameters
oSharkSslPSAEdDSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
bitsU16; 255 for Ed25519 or 448 for Ed448; the provider must support the selected algorithm.
prehashint; 0 for PureEdDSA; nonzero for Ed25519ph/Ed448ph. Sign/verify accept the original message and hash it internally in prehash mode.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_importPrivate()

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.

Parameters
oSharkSslPSAEdDSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
seedconst U8 *; Required borrowed private seed: 32 bytes for Ed25519 or 57 for Ed448.
seedLenU16; Private seed length in bytes, exactly 32 or 57 for the chosen curve.
bitsU16; 255 for Ed25519 or 448 for Ed448; the provider must support the selected algorithm.
prehashint; 0 for PureEdDSA; nonzero for Ed25519ph/Ed448ph. Sign/verify accept the original message and hash it internally in prehash mode.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_importPublic()

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.

Parameters
oSharkSslPSAEdDSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
publicKeyconst U8 *; Required SEC1 uncompressed public point for ECDSA, or raw encoded EdDSA public key; output buffers are caller-owned, input buffers are borrowed.
publicKeyLenU16; Input public-key length in bytes, matching the selected curve.
bitsU16; 255 for Ed25519 or 448 for Ed448; the provider must support the selected algorithm.
prehashint; 0 for PureEdDSA; nonzero for Ed25519ph/Ed448ph. Sign/verify accept the original message and hash it internally in prehash mode.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_sign()

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.

Parameters
oconst SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
messageconst U8 *; Borrowed original message bytes; may be NULL when messageLen is 0.
messageLenU32; Original message length in bytes.
signatureU8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification.
signatureSizeU16; Output capacity in bytes, sufficient for the complete signature.
signatureLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSAEdDSAKey_verify()

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.

Parameters
oconst SharkSslPSAEdDSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
messageconst U8 *; Borrowed original message bytes; may be NULL when messageLen is 0.
messageLenU32; Original message length in bytes.
signatureconst U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification.
signatureLenU16; Signature length in bytes, matching the selected algorithm.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_decrypt()

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.

Parameters
oconst SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
ciphertextconst U8 *; Required ciphertext buffer; caller-owned on encryption, borrowed on decryption.
labelconst U8 *; Borrowed OAEP label, or NULL for zero labelLen; PKCS1v1.5 encryption requires an empty label.
plaintextU8 *; Plaintext bytes, borrowed on encryption (NULL only for zero length), required caller-owned output on decryption.
ciphertextLenU16; Input ciphertext length in bytes, exactly the RSA modulus width.
labelLenU16; Label length in bytes; must be 0 for PKCS1v1.5 encryption.
plaintextSizeU16; Writable plaintext output capacity in bytes.
plaintextLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_destructor()

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.

Parameters
oSharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_encrypt()

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.

Parameters
oconst SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
plaintextconst U8 *; Plaintext bytes, borrowed on encryption (NULL only for zero length), required caller-owned output on decryption.
labelconst U8 *; Borrowed OAEP label, or NULL for zero labelLen; PKCS1v1.5 encryption requires an empty label.
ciphertextU8 *; Required ciphertext buffer; caller-owned on encryption, borrowed on decryption.
plaintextLenU16; Input plaintext length in bytes, within the RSA padding/algorithm limit.
labelLenU16; Label length in bytes; must be 0 for PKCS1v1.5 encryption.
ciphertextSizeU16; Writable ciphertext output capacity in bytes, at least the RSA modulus width.
ciphertextLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_exportPrivate()

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.

Parameters
oconst SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
privateDerU8 *; Required PKCS#1 private-key DER buffer; borrowed on import, caller-owned on export.
privateDerSizeU16; Private-key output capacity in bytes.
privateDerLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_exportPublic()

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.

Parameters
oconst SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
publicDerU8 *; Required PKCS#1 public-key DER buffer; borrowed on import, caller-owned on export.
publicDerSizeU16; Public-key output capacity in bytes.
publicDerLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_generate()

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.

Parameters
oSharkSslPSARSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
algpsa_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.
exportableint; 0 to prohibit private export; nonzero to request PSA_KEY_USAGE_EXPORT. Does not affect public export.
bitsU16; Nonzero RSA modulus size in bits, a multiple of 8 and supported by the provider.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_importPrivate()

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.

Parameters
oSharkSslPSARSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
privateDerconst U8 *; Required PKCS#1 private-key DER buffer; borrowed on import, caller-owned on export.
algpsa_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.
exportableint; 0 to prohibit private export; nonzero to request PSA_KEY_USAGE_EXPORT. Does not affect public export.
privateDerLenU16; Input private-key DER length in bytes.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_importPublic()

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.

Parameters
oSharkSslPSARSAKey *; Required caller-owned context. Must not own a live key; receives ownership of a new volatile PSA key. Destroy before reusing storage.
publicDerconst U8 *; Required PKCS#1 public-key DER buffer; borrowed on import, caller-owned on export.
algpsa_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.
publicDerLenU16; Input public-key DER length in bytes.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_signHash()

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.

Parameters
oconst SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
hashconst U8 *; Required borrowed digest matching the context hash algorithm.
signatureU8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification.
signatureLenU16 *; Required output byte count, initialized to 0; valid output is reported only on success.
hashLenU16; Digest length in bytes, matching the context algorithm.
signatureSizeU16; Output capacity in bytes, sufficient for the complete signature.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.

◆ SharkSslPSARSAKey_verifyHash()

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.

Parameters
oconst SharkSslPSARSAKey *; Required caller-owned context. Must contain a valid key created or imported by this adapter.
hashconst U8 *; Required borrowed digest matching the context hash algorithm.
signatureconst U8 *; Required raw signature buffer; caller-owned for signing, borrowed for verification.
hashLenU16; Digest length in bytes, matching the context algorithm.
signatureLenU16; Signature length in bytes, matching the selected algorithm.
Returns
int: 0 on success (including a verified signature); -1 for invalid arguments, unsupported algorithms/policies, insufficient output capacity, verification mismatch or provider failure, as applicable.