SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSslPSAConsumerRSA.h File Reference
#include "SharkSSL.h"

Go to the source code of this file.

Data Structures

struct  SharkSslPSARSAKey
 An RSA key owned by the external PSA provider. More...
 

Typedefs

typedef struct SharkSslPSARSAKey SharkSslPSARSAKey
 An RSA key owned by the external PSA provider. More...
 

Functions

SHARKSSL_API int SharkSslPSARSAKey_generate (SharkSslPSARSAKey *o, psa_algorithm_t alg, int exportable, U16 bits)
 
SHARKSSL_API int SharkSslPSARSAKey_importPrivate (SharkSslPSARSAKey *o, const U8 *privateDer, psa_algorithm_t alg, int exportable, U16 privateDerLen)
 
SHARKSSL_API int SharkSslPSARSAKey_importPublic (SharkSslPSARSAKey *o, const U8 *publicDer, psa_algorithm_t alg, U16 publicDerLen)
 
SHARKSSL_API int SharkSslPSARSAKey_exportPrivate (const SharkSslPSARSAKey *o, U8 *privateDer, U16 privateDerSize, U16 *privateDerLen)
 
SHARKSSL_API int SharkSslPSARSAKey_exportPublic (const SharkSslPSARSAKey *o, U8 *publicDer, U16 publicDerSize, U16 *publicDerLen)
 
SHARKSSL_API int SharkSslPSARSAKey_encrypt (const SharkSslPSARSAKey *o, const U8 *plaintext, const U8 *label, U8 *ciphertext, U16 plaintextLen, U16 labelLen, U16 ciphertextSize, U16 *ciphertextLen)
 
SHARKSSL_API int SharkSslPSARSAKey_decrypt (const SharkSslPSARSAKey *o, const U8 *ciphertext, const U8 *label, U8 *plaintext, U16 ciphertextLen, U16 labelLen, U16 plaintextSize, U16 *plaintextLen)
 
SHARKSSL_API int SharkSslPSARSAKey_signHash (const SharkSslPSARSAKey *o, const U8 *hash, U8 *signature, U16 *signatureLen, U16 hashLen, U16 signatureSize)
 
SHARKSSL_API int SharkSslPSARSAKey_verifyHash (const SharkSslPSARSAKey *o, const U8 *hash, const U8 *signature, U16 hashLen, U16 signatureLen)
 
SHARKSSL_API int SharkSslASN1Create_CSRWithPSARSAKey (struct SharkSslASN1Create *o, const SharkSslPSARSAKey *key, struct SharkSslCertDN *certDN, const char *SAN, struct SharkSslBitExtReq *keyUsage, struct SharkSslBitExtReq *nsCertType)
 Create a PKCS#10 CSR with a non-exportable RSA private key The key policy must select PKCS#1 v1.5 or standard-salt PSS with SHA-256, SHA-384, or SHA-512 The public key is exported from the same PSA handle. More...
 
SHARKSSL_API int SharkSslPSARSAKey_destructor (SharkSslPSARSAKey *o)
 

Detailed Description

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

Typedef Documentation

◆ SharkSslPSARSAKey

An RSA key owned by the external PSA provider.

Algorithm is either PSA_ALG_RSA_PKCS1V15_CRYPT, PSA_ALG_RSA_OAEP(hash), PSA_ALG_RSA_PKCS1V15_SIGN(hash), or PSA_ALG_RSA_PSS(hash) with standard salt length Private keys may be non-exportable; the public key can always be exported A signing key can verify with its private handle when the provider supports it Otherwise, verification uses a temporary public handle Initialize once, then call destructor before reusing this context

Function Documentation

◆ SharkSslASN1Create_CSRWithPSARSAKey()

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

Create a PKCS#10 CSR with a non-exportable RSA private key The key policy must select PKCS#1 v1.5 or standard-salt PSS with SHA-256, SHA-384, or SHA-512 The public key is exported from the same PSA handle.

This creates a request, not an issued certificate.

Inputs and the private key remain owned by the caller.

Parameters
oSharkSslASN1Create *; required freshly initialized writer with an empty caller-owned buffer (ptr=end). Retrieve the resulting DER with SharkSslASN1Create_getDataLen.
keyconst SharkSslPSARSAKey *; 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.

◆ SharkSslPSARSAKey_decrypt()

SHARKSSL_API int SharkSslPSARSAKey_decrypt ( const SharkSslPSARSAKey *  o,
const U8 *  ciphertext,
const U8 *  label,
U8 *  plaintext,
U16  ciphertextLen,
U16  labelLen,
U16  plaintextSize,
U16 *  plaintextLen 
)

◆ SharkSslPSARSAKey_destructor()

SHARKSSL_API int SharkSslPSARSAKey_destructor ( SharkSslPSARSAKey *  o)

◆ SharkSslPSARSAKey_encrypt()

SHARKSSL_API int SharkSslPSARSAKey_encrypt ( const SharkSslPSARSAKey *  o,
const U8 *  plaintext,
const U8 *  label,
U8 *  ciphertext,
U16  plaintextLen,
U16  labelLen,
U16  ciphertextSize,
U16 *  ciphertextLen 
)

◆ SharkSslPSARSAKey_exportPrivate()

SHARKSSL_API int SharkSslPSARSAKey_exportPrivate ( const SharkSslPSARSAKey *  o,
U8 *  privateDer,
U16  privateDerSize,
U16 *  privateDerLen 
)

◆ SharkSslPSARSAKey_exportPublic()

SHARKSSL_API int SharkSslPSARSAKey_exportPublic ( const SharkSslPSARSAKey *  o,
U8 *  publicDer,
U16  publicDerSize,
U16 *  publicDerLen 
)

◆ SharkSslPSARSAKey_generate()

SHARKSSL_API int SharkSslPSARSAKey_generate ( SharkSslPSARSAKey *  o,
psa_algorithm_t  alg,
int  exportable,
U16  bits 
)

◆ SharkSslPSARSAKey_importPrivate()

SHARKSSL_API int SharkSslPSARSAKey_importPrivate ( SharkSslPSARSAKey *  o,
const U8 *  privateDer,
psa_algorithm_t  alg,
int  exportable,
U16  privateDerLen 
)

◆ SharkSslPSARSAKey_importPublic()

SHARKSSL_API int SharkSslPSARSAKey_importPublic ( SharkSslPSARSAKey *  o,
const U8 *  publicDer,
psa_algorithm_t  alg,
U16  publicDerLen 
)

◆ SharkSslPSARSAKey_signHash()

SHARKSSL_API int SharkSslPSARSAKey_signHash ( const SharkSslPSARSAKey *  o,
const U8 *  hash,
U8 *  signature,
U16 *  signatureLen,
U16  hashLen,
U16  signatureSize 
)

◆ SharkSslPSARSAKey_verifyHash()

SHARKSSL_API int SharkSslPSARSAKey_verifyHash ( const SharkSslPSARSAKey *  o,
const U8 *  hash,
const U8 *  signature,
U16  hashLen,
U16  signatureLen 
)