mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
mbedtls_psa_pake_get_implicit_key: move psa_key_derivation_input_bytes call to upper layer
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
@ -7295,11 +7295,34 @@ psa_status_t psa_pake_get_implicit_key(
|
||||
psa_pake_operation_t *operation,
|
||||
psa_key_derivation_operation_t *output)
|
||||
{
|
||||
psa_status_t status = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
uint8_t shared_key[MBEDTLS_PSA_PAKE_BUFFER_SIZE];
|
||||
size_t shared_key_len = 0;
|
||||
|
||||
if (operation->id == 0) {
|
||||
return PSA_ERROR_BAD_STATE;
|
||||
}
|
||||
|
||||
return psa_driver_wrapper_pake_get_implicit_key(operation, output);
|
||||
status = psa_driver_wrapper_pake_get_implicit_key(operation,
|
||||
shared_key,
|
||||
&shared_key_len);
|
||||
|
||||
if (status != PSA_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = psa_key_derivation_input_bytes(output,
|
||||
PSA_KEY_DERIVATION_INPUT_SECRET,
|
||||
shared_key,
|
||||
shared_key_len);
|
||||
|
||||
if (status != PSA_SUCCESS) {
|
||||
psa_key_derivation_abort(output);
|
||||
}
|
||||
|
||||
mbedtls_platform_zeroize(shared_key, MBEDTLS_PSA_PAKE_BUFFER_SIZE);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
psa_status_t psa_pake_abort(
|
||||
|
@ -454,7 +454,7 @@ psa_status_t psa_driver_wrapper_pake_input(
|
||||
|
||||
psa_status_t psa_driver_wrapper_pake_get_implicit_key(
|
||||
psa_pake_operation_t *operation,
|
||||
psa_key_derivation_operation_t *output);
|
||||
uint8_t *output, size_t *output_size);
|
||||
|
||||
psa_status_t psa_driver_wrapper_pake_abort(
|
||||
psa_pake_operation_t *operation);
|
||||
|
@ -835,7 +835,7 @@ psa_status_t mbedtls_psa_pake_input(mbedtls_psa_pake_operation_t *operation,
|
||||
|
||||
psa_status_t mbedtls_psa_pake_get_implicit_key(
|
||||
mbedtls_psa_pake_operation_t *operation,
|
||||
psa_key_derivation_operation_t *output)
|
||||
uint8_t *output, size_t *output_size)
|
||||
{
|
||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||
@ -863,16 +863,14 @@ psa_status_t mbedtls_psa_pake_get_implicit_key(
|
||||
return mbedtls_ecjpake_to_psa_error(ret);
|
||||
}
|
||||
|
||||
status = psa_key_derivation_input_bytes(output,
|
||||
PSA_KEY_DERIVATION_INPUT_SECRET,
|
||||
operation->buffer,
|
||||
operation->buffer_length);
|
||||
memcpy(output, operation->buffer, operation->buffer_length);
|
||||
*output_size = operation->buffer_length;
|
||||
|
||||
mbedtls_platform_zeroize(operation->buffer, MBEDTLS_PSA_PAKE_BUFFER_SIZE);
|
||||
|
||||
mbedtls_psa_pake_abort(operation);
|
||||
|
||||
return status;
|
||||
return PSA_SUCCESS;
|
||||
} else
|
||||
#else
|
||||
(void) output;
|
||||
@ -880,7 +878,6 @@ psa_status_t mbedtls_psa_pake_get_implicit_key(
|
||||
{ status = PSA_ERROR_NOT_SUPPORTED; }
|
||||
|
||||
error:
|
||||
psa_key_derivation_abort(output);
|
||||
mbedtls_psa_pake_abort(operation);
|
||||
|
||||
return status;
|
||||
|
@ -442,7 +442,7 @@ psa_status_t mbedtls_psa_pake_input(mbedtls_psa_pake_operation_t *operation,
|
||||
*/
|
||||
psa_status_t mbedtls_psa_pake_get_implicit_key(
|
||||
mbedtls_psa_pake_operation_t *operation,
|
||||
psa_key_derivation_operation_t *output);
|
||||
uint8_t *output, size_t *output_size);
|
||||
|
||||
/** Abort a PAKE operation.
|
||||
*
|
||||
|
Reference in New Issue
Block a user