Functions
Platform Security Architecture (PSA) API

Functions

int wolfSSL_CTX_psa_enable (WOLFSSL_CTX *ctx)
 This function enables PSA support on the given context. More...
 
int wolfSSL_set_psa_ctx (WOLFSSL *ssl, struct psa_ssl_ctx *ctx)
 This function setup the PSA context for the given SSL session. More...
 
void wolfSSL_free_psa_ctx (struct psa_ssl_ctx *ctx)
 This function releases the resources used by a PSA context. More...
 
int wolfSSL_psa_set_private_key_id (struct psa_ssl_ctx *ctx, psa_key_id_t id)
 This function set the private key used by an SSL session. More...
 

Detailed Description

Function Documentation

int wolfSSL_CTX_psa_enable ( WOLFSSL_CTX *  ctx)

This function enables PSA support on the given context.

Parameters
ctxpointer to the WOLFSSL_CTX object on which the PSA support must be enabled
Returns
WOLFSSL_SUCCESS on success
BAD_FUNC_ARG if ctx == NULL

Example

1 WOLFSSL_CTX *ctx;
2 ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());
3 if (!ctx)
4  return NULL;
5 ret = wolfSSL_CTX_psa_enable(ctx);
6 if (ret != WOLFSSL_SUCCESS)
7  printf("can't enable PSA on ctx");
See also
wolfSSL_set_psa_ctx
void wolfSSL_free_psa_ctx ( struct psa_ssl_ctx *  ctx)

This function releases the resources used by a PSA context.

Parameters
ctxpointer to a struct psa_ssl_ctx
See also
wolfSSL_set_psa_ctx
int wolfSSL_psa_set_private_key_id ( struct psa_ssl_ctx *  ctx,
psa_key_id_t  id 
)

This function set the private key used by an SSL session.

Parameters
ctxpointer to a struct psa_ssl_ctx
idPSA id of the key to be used as private key

Example

1 // Create new ssl session
2 WOLFSSL *ssl;
3 struct psa_ssl_ctx psa_ctx = { 0 };
4 psa_key_id_t key_id;
5 
6 // key provisioning already done
7 get_private_key_id(&key_id);
8 
9 ssl = wolfSSL_new(ctx);
10 if (!ssl)
11  return NULL;
12 
13 wolfSSL_psa_set_private_key_id(&psa_ctx, key_id);
14 wolfSSL_set_psa_ctx(ssl, ctx);
See also
wolfSSL_set_psa_ctx
int wolfSSL_set_psa_ctx ( WOLFSSL *  ssl,
struct psa_ssl_ctx *  ctx 
)

This function setup the PSA context for the given SSL session.

Parameters
sslpointer to the WOLFSSL where the ctx will be enabled
ctxpointer to a struct psa_ssl_ctx (must be unique for a ssl session)
Returns
WOLFSSL_SUCCESS on success
BAD_FUNC_ARG if ssl or ctx are NULL

This function setup the PSA context for the TLS callbacks to the given SSL session. At the end of the session, the resources used by the context should be freed using wolfSSL_free_psa_ctx().

Example

1 // Create new ssl session
2 WOLFSSL *ssl;
3 struct psa_ssl_ctx psa_ctx = { 0 };
4 ssl = wolfSSL_new(ctx);
5 if (!ssl)
6  return NULL;
7 // setup PSA context
8 ret = wolfSSL_set_psa_ctx(ssl, ctx);
See also
wolfSSL_psa_set_private_key_id
wolfSSL_psa_free_psa_ctx