1
0

psa.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*!
  2. \ingroup PSA
  3. \brief This function enables PSA support on the given context.
  4. \param ctx pointer to the WOLFSSL_CTX object on which the PSA support must be enabled
  5. \return WOLFSSL_SUCCESS on success
  6. \return BAD_FUNC_ARG if ctx == NULL
  7. _Example_
  8. \code
  9. WOLFSSL_CTX *ctx;
  10. ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());
  11. if (!ctx)
  12. return NULL;
  13. ret = wolfSSL_CTX_psa_enable(ctx);
  14. if (ret != WOLFSSL_SUCCESS)
  15. printf("can't enable PSA on ctx");
  16. \endcode
  17. \sa wolfSSL_set_psa_ctx
  18. */
  19. int wolfSSL_CTX_psa_enable(WOLFSSL_CTX *ctx);
  20. /*!
  21. \ingroup PSA
  22. \brief This function setup the PSA context for the given SSL session
  23. \param ssl pointer to the WOLFSSL where the ctx will be enabled
  24. \param ctx pointer to a struct psa_ssl_ctx (must be unique for a ssl session)
  25. \return WOLFSSL_SUCCESS on success
  26. \return BAD_FUNC_ARG if ssl or ctx are NULL
  27. This function setup the PSA context for the TLS callbacks to the given SSL
  28. session. At the end of the session, the resources used by the context
  29. should be freed using wolfSSL_free_psa_ctx().
  30. _Example_
  31. \code
  32. // Create new ssl session
  33. WOLFSSL *ssl;
  34. struct psa_ssl_ctx psa_ctx = { 0 };
  35. ssl = wolfSSL_new(ctx);
  36. if (!ssl)
  37. return NULL;
  38. // setup PSA context
  39. ret = wolfSSL_set_psa_ctx(ssl, ctx);
  40. \endcode
  41. \sa wolfSSL_psa_set_private_key_id
  42. \sa wolfSSL_psa_free_psa_ctx
  43. */
  44. int wolfSSL_set_psa_ctx(WOLFSSL *ssl, struct psa_ssl_ctx *ctx);
  45. /*!
  46. \ingroup PSA
  47. \brief This function releases the resources used by a PSA context
  48. \param ctx pointer to a struct psa_ssl_ctx
  49. \sa wolfSSL_set_psa_ctx
  50. */
  51. void wolfSSL_free_psa_ctx(struct psa_ssl_ctx *ctx);
  52. /*!
  53. \ingroup PSA
  54. \brief This function set the private key used by an SSL session
  55. \param ctx pointer to a struct psa_ssl_ctx
  56. \param id PSA id of the key to be used as private key
  57. _Example_
  58. \code
  59. // Create new ssl session
  60. WOLFSSL *ssl;
  61. struct psa_ssl_ctx psa_ctx = { 0 };
  62. psa_key_id_t key_id;
  63. // key provisioning already done
  64. get_private_key_id(&key_id);
  65. ssl = wolfSSL_new(ctx);
  66. if (!ssl)
  67. return NULL;
  68. wolfSSL_psa_set_private_key_id(&psa_ctx, key_id);
  69. wolfSSL_set_psa_ctx(ssl, ctx);
  70. \endcode
  71. \sa wolfSSL_set_psa_ctx
  72. */
  73. int wolfSSL_psa_set_private_key_id(struct psa_ssl_ctx *ctx,
  74. psa_key_id_t id);