Fix documentation and tests
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
diff --git a/docs/proposed/psa-driver-interface.md b/docs/proposed/psa-driver-interface.md
index 0a52557..0027ec7 100644
--- a/docs/proposed/psa-driver-interface.md
+++ b/docs/proposed/psa-driver-interface.md
@@ -379,16 +379,16 @@
size_t *user_len);
psa_status_t psa_crypto_driver_pake_get_user(
- const psa_crypto_driver_pake_inputs_t *inputs,
- uint8_t *buffer, size_t buffer_size, size_t *buffer_length);
+ const psa_crypto_driver_pake_inputs_t *inputs,
+ uint8_t *user_id, size_t user_id_size, size_t *user_id_len);
psa_status_t psa_crypto_driver_pake_get_peer_len(
const psa_crypto_driver_pake_inputs_t *inputs,
size_t *peer_len);
psa_status_t psa_crypto_driver_pake_get_peer(
- const psa_crypto_driver_pake_inputs_t *inputs,
- uint8_t *buffer, size_t buffer_size, size_t *buffer_length);
+ const psa_crypto_driver_pake_inputs_t *inputs,
+ uint8_t *peer_id, size_t peer_id_size, size_t *peer_id_length);
psa_status_t psa_crypto_driver_pake_get_role(
const psa_crypto_driver_pake_inputs_t *inputs,
diff --git a/include/psa/crypto_extra.h b/include/psa/crypto_extra.h
index e491a86..4920508 100644
--- a/include/psa/crypto_extra.h
+++ b/include/psa/crypto_extra.h
@@ -1300,10 +1300,10 @@
*/
static psa_pake_operation_t psa_pake_operation_init(void);
-/** Get the lengths of the password in bytes from given inputs.
+/** Get the length of the password in bytes from given inputs.
*
* \param[in] inputs Operation inputs.
- * \param[out] password_len Return buffer for password length.
+ * \param[out] password_len Password length.
*
* \retval #PSA_SUCCESS
* Success.
@@ -1344,10 +1344,10 @@
const psa_crypto_driver_pake_inputs_t *inputs,
psa_pake_role_t *role);
-/** Get the lengths of the user id in bytes from given inputs.
+/** Get the length of the user id in bytes from given inputs.
*
* \param[in] inputs Operation inputs.
- * \param[out] user_len Return buffer for user id length.
+ * \param[out] user_len User id length.
*
* \retval #PSA_SUCCESS
* Success.
@@ -1358,10 +1358,10 @@
const psa_crypto_driver_pake_inputs_t *inputs,
size_t *user_len);
-/** Get the lengths of the peer id in bytes from given inputs.
+/** Get the length of the peer id in bytes from given inputs.
*
* \param[in] inputs Operation inputs.
- * \param[out] peer_len Return buffer for peer id length.
+ * \param[out] peer_len Peer id length.
*
* \retval #PSA_SUCCESS
* Success.
@@ -1375,38 +1375,38 @@
/** Get the user id from given inputs.
*
* \param[in] inputs Operation inputs.
- * \param[out] buffer Return buffer for user id.
- * \param buffer_size Size of the return buffer in bytes.
- * \param[out] buffer_length Actual size of the password in bytes.
+ * \param[out] user_id User id.
+ * \param user_id_size Size of \p user_id in bytes.
+ * \param[out] user_id_len Size of the user id in bytes.
*
* \retval #PSA_SUCCESS
* Success.
* \retval #PSA_ERROR_BAD_STATE
* User id hasn't been set yet.
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
- * The size of the \p buffer is too small.
+ * The size of the \p user_id is too small.
*/
psa_status_t psa_crypto_driver_pake_get_user(
const psa_crypto_driver_pake_inputs_t *inputs,
- uint8_t *buffer, size_t buffer_size, size_t *buffer_length);
+ uint8_t *user_id, size_t user_id_size, size_t *user_id_len);
/** Get the peer id from given inputs.
*
* \param[in] inputs Operation inputs.
- * \param[out] buffer Return buffer for user id.
- * \param buffer_size Size of the return buffer in bytes.
- * \param[out] buffer_length Actual size of the password in bytes.
+ * \param[out] peer_id Peer id.
+ * \param peer_id_size Size of \p peer_id in bytes.
+ * \param[out] peer_id_length Size of the peer id in bytes.
*
* \retval #PSA_SUCCESS
* Success.
* \retval #PSA_ERROR_BAD_STATE
* Peer id hasn't been set yet.
* \retval #PSA_ERROR_BUFFER_TOO_SMALL
- * The size of the \p buffer is too small.
+ * The size of the \p peer_id is too small.
*/
psa_status_t psa_crypto_driver_pake_get_peer(
const psa_crypto_driver_pake_inputs_t *inputs,
- uint8_t *buffer, size_t buffer_size, size_t *buffer_length);
+ uint8_t *peer_id, size_t peer_id_size, size_t *peer_id_length);
/** Get the cipher suite from given inputs.
*
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index b875412..d0cdd62 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -7228,18 +7228,18 @@
psa_status_t psa_crypto_driver_pake_get_user(
const psa_crypto_driver_pake_inputs_t *inputs,
- uint8_t *buffer, size_t buffer_size, size_t *buffer_length)
+ uint8_t *user_id, size_t user_id_size, size_t *user_id_len)
{
if (inputs->user_len == 0) {
return PSA_ERROR_BAD_STATE;
}
- if (buffer_size < inputs->user_len) {
+ if (user_id_size < inputs->user_len) {
return PSA_ERROR_BUFFER_TOO_SMALL;
}
- memcpy(buffer, inputs->user, inputs->user_len);
- *buffer_length = inputs->user_len;
+ memcpy(user_id, inputs->user, inputs->user_len);
+ *user_id_len = inputs->user_len;
return PSA_SUCCESS;
}
@@ -7259,18 +7259,18 @@
psa_status_t psa_crypto_driver_pake_get_peer(
const psa_crypto_driver_pake_inputs_t *inputs,
- uint8_t *buffer, size_t buffer_size, size_t *buffer_length)
+ uint8_t *peer_id, size_t peer_id_size, size_t *peer_id_length)
{
if (inputs->peer_len == 0) {
return PSA_ERROR_BAD_STATE;
}
- if (buffer_size < inputs->peer_len) {
+ if (peer_id_size < inputs->peer_len) {
return PSA_ERROR_BUFFER_TOO_SMALL;
}
- memcpy(buffer, inputs->peer, inputs->peer_len);
- *buffer_length = inputs->peer_len;
+ memcpy(peer_id, inputs->peer, inputs->peer_len);
+ *peer_id_length = inputs->peer_len;
return PSA_SUCCESS;
}
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index f43bb73..5f79568 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -1949,7 +1949,6 @@
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
#if defined(MBEDTLS_USE_PSA_CRYPTO)
-/* The only two JPAKE user/peer identifiers supported for the time being. */
static const uint8_t jpake_server_id[] = { 's', 'e', 'r', 'v', 'e', 'r' };
static const uint8_t jpake_client_id[] = { 'c', 'l', 'i', 'e', 'n', 't' };
diff --git a/tests/suites/test_suite_psa_crypto_pake.function b/tests/suites/test_suite_psa_crypto_pake.function
index 00b5c2f..88f24dd 100644
--- a/tests/suites/test_suite_psa_crypto_pake.function
+++ b/tests/suites/test_suite_psa_crypto_pake.function
@@ -1060,13 +1060,13 @@
}
/* END_CASE */
-/* BEGIN_CASE depends_on:PSA_WANT_ALG_JPAKE:PSA_ALG_SHA_256 */
+/* BEGIN_CASE depends_on:PSA_WANT_ALG_JPAKE */
void pake_input_getters_user()
{
psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init();
psa_pake_operation_t operation = psa_pake_operation_init();
- const uint8_t user[] = "server";
- const size_t user_len = strlen("server");
+ const uint8_t user[] = { 's', 'e', 'r', 'v', 'e', 'r' };
+ const size_t user_len = sizeof(user);
uint8_t user_ret[20] = { 0 }; // max user length is 20 bytes
size_t user_len_ret = 0;
size_t buffer_len_ret = 0;
@@ -1118,13 +1118,13 @@
}
/* END_CASE */
-/* BEGIN_CASE depends_on:PSA_WANT_ALG_JPAKE:PSA_ALG_SHA_256 */
+/* BEGIN_CASE depends_on:PSA_WANT_ALG_JPAKE */
void pake_input_getters_peer()
{
psa_pake_cipher_suite_t cipher_suite = psa_pake_cipher_suite_init();
psa_pake_operation_t operation = psa_pake_operation_init();
- const uint8_t peer[] = "server";
- const size_t peer_len = strlen("server");
+ const uint8_t peer[] = { 's', 'e', 'r', 'v', 'e', 'r' };
+ const size_t peer_len = sizeof(peer);
uint8_t peer_ret[20] = { 0 }; // max peer length is 20 bytes
size_t peer_len_ret = 0;
size_t buffer_len_ret = 0;