psa_crypto_pake.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * PSA PAKE layer on top of Mbed TLS software crypto
  3. */
  4. /*
  5. * Copyright The Mbed TLS Contributors
  6. * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  7. */
  8. #ifndef PSA_CRYPTO_PAKE_H
  9. #define PSA_CRYPTO_PAKE_H
  10. #include <psa/crypto.h>
  11. /** Set the session information for a password-authenticated key exchange.
  12. *
  13. * \note The signature of this function is that of a PSA driver
  14. * pake_setup entry point. This function behaves as a pake_setup
  15. * entry point as defined in the PSA driver interface specification for
  16. * transparent drivers.
  17. *
  18. * \param[in,out] operation The operation object to set up. It must have
  19. * been initialized but not set up yet.
  20. * \param[in] inputs Inputs required for PAKE operation (role, password,
  21. * key lifetime, cipher suite)
  22. *
  23. * \retval #PSA_SUCCESS
  24. * Success.
  25. * \retval #PSA_ERROR_NOT_SUPPORTED
  26. * The algorithm in \p cipher_suite is not a supported PAKE algorithm,
  27. * or the PAKE primitive in \p cipher_suite is not supported or not
  28. * compatible with the PAKE algorithm, or the hash algorithm in
  29. * \p cipher_suite is not supported or not compatible with the PAKE
  30. * algorithm and primitive.
  31. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
  32. * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
  33. */
  34. psa_status_t mbedtls_psa_pake_setup(mbedtls_psa_pake_operation_t *operation,
  35. const psa_crypto_driver_pake_inputs_t *inputs);
  36. /** Get output for a step of a password-authenticated key exchange.
  37. *
  38. * \note The signature of this function is that of a PSA driver
  39. * pake_output entry point. This function behaves as a pake_output
  40. * entry point as defined in the PSA driver interface specification for
  41. * transparent drivers.
  42. *
  43. * \param[in,out] operation Active PAKE operation.
  44. * \param step The step of the algorithm for which the output is
  45. * requested.
  46. * \param[out] output Buffer where the output is to be written in the
  47. * format appropriate for this driver \p step. Refer to
  48. * the documentation of psa_crypto_driver_pake_step_t for
  49. * more information.
  50. * \param output_size Size of the \p output buffer in bytes. This must
  51. * be at least #PSA_PAKE_OUTPUT_SIZE(\p alg, \p
  52. * primitive, \p step) where \p alg and
  53. * \p primitive are the PAKE algorithm and primitive
  54. * in the operation's cipher suite, and \p step is
  55. * the output step.
  56. *
  57. * \param[out] output_length On success, the number of bytes of the returned
  58. * output.
  59. *
  60. * \retval #PSA_SUCCESS
  61. * Success.
  62. * \retval #PSA_ERROR_BUFFER_TOO_SMALL
  63. * The size of the \p output buffer is too small.
  64. * \retval #PSA_ERROR_INSUFFICIENT_ENTROPY \emptydescription
  65. * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
  66. * \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
  67. * \retval #PSA_ERROR_DATA_INVALID \emptydescription
  68. */
  69. psa_status_t mbedtls_psa_pake_output(mbedtls_psa_pake_operation_t *operation,
  70. psa_crypto_driver_pake_step_t step,
  71. uint8_t *output,
  72. size_t output_size,
  73. size_t *output_length);
  74. /** Provide input for a step of a password-authenticated key exchange.
  75. *
  76. * \note The signature of this function is that of a PSA driver
  77. * pake_input entry point. This function behaves as a pake_input
  78. * entry point as defined in the PSA driver interface specification for
  79. * transparent drivers.
  80. *
  81. * \note The core checks that input_length is smaller than PSA_PAKE_INPUT_MAX_SIZE.
  82. *
  83. * \param[in,out] operation Active PAKE operation.
  84. * \param step The driver step for which the input is provided.
  85. * \param[in] input Buffer containing the input in the format
  86. * appropriate for this \p step. Refer to the
  87. * documentation of psa_crypto_driver_pake_step_t
  88. * for more information.
  89. * \param input_length Size of the \p input buffer in bytes.
  90. *
  91. * \retval #PSA_SUCCESS
  92. * Success.
  93. * \retval #PSA_ERROR_INVALID_SIGNATURE
  94. * The verification fails for a zero-knowledge input step.
  95. * \retval #PSA_ERROR_INVALID_ARGUMENT
  96. * the \p input is not valid for the \p operation's algorithm, cipher suite
  97. * or \p step.
  98. * \retval #PSA_ERROR_NOT_SUPPORTED
  99. * the \p input is not supported for the \p operation's algorithm, cipher
  100. * suite or \p step.
  101. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
  102. * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
  103. * \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
  104. * \retval #PSA_ERROR_DATA_INVALID \emptydescription
  105. */
  106. psa_status_t mbedtls_psa_pake_input(mbedtls_psa_pake_operation_t *operation,
  107. psa_crypto_driver_pake_step_t step,
  108. const uint8_t *input,
  109. size_t input_length);
  110. /** Get implicitly confirmed shared secret from a PAKE.
  111. *
  112. * \note The signature of this function is that of a PSA driver
  113. * pake_get_implicit_key entry point. This function behaves as a
  114. * pake_get_implicit_key entry point as defined in the PSA driver
  115. * interface specification for transparent drivers.
  116. *
  117. * \param[in,out] operation Active PAKE operation.
  118. * \param[out] output Output buffer for implicit key.
  119. * \param output_size Size of the output buffer in bytes.
  120. * \param[out] output_length On success, the number of bytes of the implicit key.
  121. *
  122. * \retval #PSA_SUCCESS
  123. * Success.
  124. * \retval #PSA_ERROR_NOT_SUPPORTED
  125. * Input from a PAKE is not supported by the algorithm in the \p output
  126. * key derivation operation.
  127. * \retval #PSA_ERROR_INSUFFICIENT_MEMORY \emptydescription
  128. * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
  129. * \retval #PSA_ERROR_DATA_CORRUPT \emptydescription
  130. * \retval #PSA_ERROR_DATA_INVALID \emptydescription
  131. */
  132. psa_status_t mbedtls_psa_pake_get_implicit_key(
  133. mbedtls_psa_pake_operation_t *operation,
  134. uint8_t *output, size_t output_size,
  135. size_t *output_length);
  136. /** Abort a PAKE operation.
  137. *
  138. * \note The signature of this function is that of a PSA driver
  139. * pake_abort entry point. This function behaves as a pake_abort
  140. * entry point as defined in the PSA driver interface specification for
  141. * transparent drivers.
  142. *
  143. * \param[in,out] operation The operation to abort.
  144. *
  145. * \retval #PSA_SUCCESS
  146. * Success.
  147. * \retval #PSA_ERROR_CORRUPTION_DETECTED \emptydescription
  148. */
  149. psa_status_t mbedtls_psa_pake_abort(mbedtls_psa_pake_operation_t *operation);
  150. #endif /* PSA_CRYPTO_PAKE_H */