SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSslPSAConsumerECDSA.h File Reference

Go to the source code of this file.

Data Structures

struct  SharkSslPSAEcdsaKey
 A volatile PSA key owned by this context Initialize once, then destroy before reusing it Signatures are fixed-width raw r||s Private signing keys can verify directly or through a temporary public PSA handle. More...
 

Typedefs

typedef struct SharkSslPSAEcdsaKey SharkSslPSAEcdsaKey
 A volatile PSA key owned by this context Initialize once, then destroy before reusing it Signatures are fixed-width raw r||s Private signing keys can verify directly or through a temporary public PSA handle. More...
 

Functions

SHARKSSL_API int SharkSslPSAEcdsaKey_generate (SharkSslPSAEcdsaKey *o, U16 curveID, psa_algorithm_t hashAlg, int deterministic)
 
SHARKSSL_API int SharkSslPSAEcdsaKey_importPrivate (SharkSslPSAEcdsaKey *o, U16 curveID, psa_algorithm_t hashAlg, int deterministic, const U8 *privateKey, U16 privateKeyLen)
 
SHARKSSL_API int SharkSslPSAEcdsaKey_importPublic (SharkSslPSAEcdsaKey *o, U16 curveID, psa_algorithm_t hashAlg, int deterministic, const U8 *publicKey, U16 publicKeyLen)
 
SHARKSSL_API int SharkSslPSAEcdsaKey_exportPublic (const SharkSslPSAEcdsaKey *o, U8 *publicKey, U16 publicKeySize, U16 *publicKeyLen)
 
SHARKSSL_API int SharkSslPSAEcdsaKey_signRaw (const SharkSslPSAEcdsaKey *o, const U8 *hash, U16 hashLen, U8 *signature, U16 signatureSize, U16 *signatureLen)
 
SHARKSSL_API int SharkSslPSAEcdsaKey_verifyRaw (const SharkSslPSAEcdsaKey *o, const U8 *hash, U16 hashLen, const U8 *signature, U16 signatureLen)
 
SHARKSSL_API int SharkSslPSAEcdsa_rawToDer (U16 curveID, const U8 *raw, U16 rawLen, U8 *der, U16 derSize, U16 *derLen)
 
SHARKSSL_API int SharkSslPSAEcdsa_derToRaw (U16 curveID, const U8 *der, U16 derLen, U8 *raw, U16 rawSize, U16 *rawLen)
 
SHARKSSL_API int SharkSslASN1Create_CSRWithPSAECDSAKey (struct SharkSslASN1Create *o, const SharkSslPSAEcdsaKey *key, struct SharkSslCertDN *certDN, const char *SAN, struct SharkSslBitExtReq *keyUsage, struct SharkSslBitExtReq *nsCertType)
 Create a PKCS#10 CSR using a private P-256, P-384, or P-521 PSA handle The handle must permit ECDSA signing with SHA-256, SHA-384, or SHA-512. More...
 
SHARKSSL_API int SharkSslASN1Create_CSRWithPSAECDSAKeyHash (struct SharkSslASN1Create *o, const SharkSslPSAEcdsaKey *key, struct SharkSslCertDN *certDN, const char *SAN, struct SharkSslBitExtReq *keyUsage, struct SharkSslBitExtReq *nsCertType, U8 hashID)
 Select a concrete digest when the signing key permits ECDSA(ANY_HASH). More...
 
SHARKSSL_API int SharkSslPSAEcdsaKey_destructor (SharkSslPSAEcdsaKey *o)
 

Detailed Description

See Choose a SharkSSL API for build scope and the owning API layer.

Typedef Documentation

◆ SharkSslPSAEcdsaKey

A volatile PSA key owned by this context Initialize once, then destroy before reusing it Signatures are fixed-width raw r||s Private signing keys can verify directly or through a temporary public PSA handle.

Function Documentation

◆ SharkSslASN1Create_CSRWithPSAECDSAKey()

int SharkSslASN1Create_CSRWithPSAECDSAKey ( struct SharkSslASN1Create *  o,
const SharkSslPSAEcdsaKey *  key,
struct SharkSslCertDN *  certDN,
const char *  SAN,
struct SharkSslBitExtReq *  keyUsage,
struct SharkSslBitExtReq *  nsCertType 
)

Create a PKCS#10 CSR using a private P-256, P-384, or P-521 PSA handle The handle must permit ECDSA signing with SHA-256, SHA-384, or SHA-512.

This creates a request, not an issued certificate.

Inputs and the private key remain owned by the caller. Supported CSR curves are P-256, P-384, and P-521. The non-Hash form derives the hash from the key algorithm; ANY_HASH requires the Hash form.

Parameters
oSharkSslASN1Create *; required freshly initialized writer with an empty caller-owned buffer (ptr=end). Retrieve the resulting DER with SharkSslASN1Create_getDataLen.
keyconst SharkSslPSAEcdsaKey *; required live private signing-key context, borrowed for the call; public-only keys are rejected.
certDNSharkSslCertDN *; required subject distinguished name, borrowed for the call.
SANconst char *; optional NUL-terminated SAN string using SharkSslASN1Create_CSR syntax; NULL omits this extension.
keyUsageSharkSslBitExtReq *; optional requested key-usage extension, or NULL.
nsCertTypeSharkSslBitExtReq *; optional Netscape certificate-type extension, or NULL.
Returns
int: 0 on success; nonzero on invalid input, insufficient writer space, allocation/signing failure, or unsupported key/hash. Discard the writer output after failure.

◆ SharkSslASN1Create_CSRWithPSAECDSAKeyHash()

int SharkSslASN1Create_CSRWithPSAECDSAKeyHash ( struct SharkSslASN1Create *  o,
const SharkSslPSAEcdsaKey *  key,
struct SharkSslCertDN *  certDN,
const char *  SAN,
struct SharkSslBitExtReq *  keyUsage,
struct SharkSslBitExtReq *  nsCertType,
U8  hashID 
)

Select a concrete digest when the signing key permits ECDSA(ANY_HASH).

This creates a request, not an issued certificate.

The key must allow SIGN_HASH for the selected digest; ANY_HASH is never passed as an operation algorithm.

Inputs and the private key remain owned by the caller. Supported CSR curves are P-256, P-384, and P-521. The non-Hash form derives the hash from the key algorithm; ANY_HASH requires the Hash form.

Parameters
oSharkSslASN1Create *; required freshly initialized writer with an empty caller-owned buffer (ptr=end). Retrieve the resulting DER with SharkSslASN1Create_getDataLen.
keyconst SharkSslPSAEcdsaKey *; required live private signing-key context, borrowed for the call; public-only keys are rejected.
certDNSharkSslCertDN *; required subject distinguished name, borrowed for the call.
SANconst char *; optional NUL-terminated SAN string using SharkSslASN1Create_CSR syntax; NULL omits this extension.
keyUsageSharkSslBitExtReq *; optional requested key-usage extension, or NULL.
nsCertTypeSharkSslBitExtReq *; optional Netscape certificate-type extension, or NULL.
hashIDU8; enabled SHARKSSL_HASHID_SHA256, SHARKSSL_HASHID_SHA384, or SHARKSSL_HASHID_SHA512 matching the key's ECDSA policy (or ANY_HASH).
Returns
int: 0 on success; nonzero on invalid input, insufficient writer space, allocation/signing failure, or unsupported key/hash. Discard the writer output after failure.

◆ SharkSslPSAEcdsa_derToRaw()

SHARKSSL_API int SharkSslPSAEcdsa_derToRaw ( U16  curveID,
const U8 *  der,
U16  derLen,
U8 *  raw,
U16  rawSize,
U16 *  rawLen 
)

◆ SharkSslPSAEcdsa_rawToDer()

SHARKSSL_API int SharkSslPSAEcdsa_rawToDer ( U16  curveID,
const U8 *  raw,
U16  rawLen,
U8 *  der,
U16  derSize,
U16 *  derLen 
)

◆ SharkSslPSAEcdsaKey_destructor()

SHARKSSL_API int SharkSslPSAEcdsaKey_destructor ( SharkSslPSAEcdsaKey *  o)

◆ SharkSslPSAEcdsaKey_exportPublic()

SHARKSSL_API int SharkSslPSAEcdsaKey_exportPublic ( const SharkSslPSAEcdsaKey *  o,
U8 *  publicKey,
U16  publicKeySize,
U16 *  publicKeyLen 
)

◆ SharkSslPSAEcdsaKey_generate()

SHARKSSL_API int SharkSslPSAEcdsaKey_generate ( SharkSslPSAEcdsaKey *  o,
U16  curveID,
psa_algorithm_t  hashAlg,
int  deterministic 
)

◆ SharkSslPSAEcdsaKey_importPrivate()

SHARKSSL_API int SharkSslPSAEcdsaKey_importPrivate ( SharkSslPSAEcdsaKey *  o,
U16  curveID,
psa_algorithm_t  hashAlg,
int  deterministic,
const U8 *  privateKey,
U16  privateKeyLen 
)

◆ SharkSslPSAEcdsaKey_importPublic()

SHARKSSL_API int SharkSslPSAEcdsaKey_importPublic ( SharkSslPSAEcdsaKey *  o,
U16  curveID,
psa_algorithm_t  hashAlg,
int  deterministic,
const U8 *  publicKey,
U16  publicKeyLen 
)

◆ SharkSslPSAEcdsaKey_signRaw()

SHARKSSL_API int SharkSslPSAEcdsaKey_signRaw ( const SharkSslPSAEcdsaKey *  o,
const U8 *  hash,
U16  hashLen,
U8 *  signature,
U16  signatureSize,
U16 *  signatureLen 
)

◆ SharkSslPSAEcdsaKey_verifyRaw()

SHARKSSL_API int SharkSslPSAEcdsaKey_verifyRaw ( const SharkSslPSAEcdsaKey *  o,
const U8 *  hash,
U16  hashLen,
const U8 *  signature,
U16  signatureLen 
)