Properly namespace enum values within PSA_JPAKE_

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-06-08 15:37:12 +01:00
parent e7f21e65b6
commit 5da9560178
2 changed files with 27 additions and 27 deletions

View File

@ -2029,14 +2029,14 @@ typedef enum psa_crypto_driver_pake_step {
} psa_crypto_driver_pake_step_t;
typedef enum psa_jpake_round {
FIRST = 0,
SECOND = 1,
FINISHED = 2
PSA_JPAKE_FIRST = 0,
PSA_JPAKE_SECOND = 1,
PSA_JPAKE_FINISHED = 2
} psa_jpake_round_t;
typedef enum psa_jpake_io_mode {
INPUT = 0,
OUTPUT = 1
PSA_JPAKE_INPUT = 0,
PSA_JPAKE_OUTPUT = 1
} psa_jpake_io_mode_t;
struct psa_jpake_computation_stage_s {
@ -2052,8 +2052,8 @@ struct psa_jpake_computation_stage_s {
psa_pake_step_t MBEDTLS_PRIVATE(step);
};
#define PSA_JPAKE_EXPECTED_INPUTS(round) (((round) == FIRST) ? 2 : 1)
#define PSA_JPAKE_EXPECTED_OUTPUTS(round) (((round) == FIRST) ? 2 : 1)
#define PSA_JPAKE_EXPECTED_INPUTS(round) (((round) == PSA_JPAKE_FIRST) ? 2 : 1)
#define PSA_JPAKE_EXPECTED_OUTPUTS(round) (((round) == PSA_JPAKE_FIRST) ? 2 : 1)
struct psa_pake_operation_s {
/** Unique ID indicating which driver got assigned to do the

View File

@ -7767,8 +7767,8 @@ psa_status_t psa_pake_setup(
psa_jpake_computation_stage_t *computation_stage =
&operation->computation_stage.jpake;
computation_stage->round = FIRST;
computation_stage->mode = INPUT;
computation_stage->round = PSA_JPAKE_FIRST;
computation_stage->mode = PSA_JPAKE_INPUT;
computation_stage->inputs = 0;
computation_stage->outputs = 0;
computation_stage->step = PSA_PAKE_STEP_KEY_SHARE;
@ -7945,9 +7945,9 @@ exit:
static psa_crypto_driver_pake_step_t convert_jpake_computation_stage_to_driver_step(
psa_jpake_computation_stage_t *stage)
{
if (stage->round == FIRST) {
if (stage->round == PSA_JPAKE_FIRST) {
int is_x1;
if (stage->mode == OUTPUT) {
if (stage->mode == PSA_JPAKE_OUTPUT) {
is_x1 = (stage->outputs < 1);
} else {
is_x1 = (stage->inputs < 1);
@ -7976,8 +7976,8 @@ static psa_crypto_driver_pake_step_t convert_jpake_computation_stage_to_driver_s
return PSA_JPAKE_STEP_INVALID;
}
}
} else if (stage->round == SECOND) {
if (stage->mode == OUTPUT) {
} else if (stage->round == PSA_JPAKE_SECOND) {
if (stage->mode == PSA_JPAKE_OUTPUT) {
switch (stage->step) {
case PSA_PAKE_STEP_KEY_SHARE:
return PSA_JPAKE_X2S_STEP_KEY_SHARE;
@ -8042,8 +8042,8 @@ static psa_status_t psa_pake_complete_inputs(
operation->stage = PSA_PAKE_OPERATION_STAGE_COMPUTATION;
psa_jpake_computation_stage_t *computation_stage =
&operation->computation_stage.jpake;
computation_stage->round = FIRST;
computation_stage->mode = INPUT;
computation_stage->round = PSA_JPAKE_FIRST;
computation_stage->mode = PSA_JPAKE_INPUT;
computation_stage->inputs = 0;
computation_stage->outputs = 0;
computation_stage->step = PSA_PAKE_STEP_KEY_SHARE;
@ -8071,8 +8071,8 @@ static psa_status_t psa_jpake_prologue(
psa_jpake_computation_stage_t *computation_stage =
&operation->computation_stage.jpake;
if (computation_stage->round != FIRST &&
computation_stage->round != SECOND) {
if (computation_stage->round != PSA_JPAKE_FIRST &&
computation_stage->round != PSA_JPAKE_SECOND) {
return PSA_ERROR_BAD_STATE;
}
@ -8095,7 +8095,7 @@ static psa_status_t psa_jpake_prologue(
/* Check that we do not already have enough inputs/outputs
* this round */
if (function_mode == INPUT) {
if (function_mode == PSA_JPAKE_INPUT) {
if (computation_stage->inputs >=
PSA_JPAKE_EXPECTED_INPUTS(computation_stage->round)) {
return PSA_ERROR_BAD_STATE;
@ -8118,16 +8118,16 @@ static psa_status_t psa_jpake_epilogue(
if (stage->step == PSA_PAKE_STEP_ZK_PROOF) {
/* End of an input/output */
if (function_mode == INPUT) {
if (function_mode == PSA_JPAKE_INPUT) {
stage->inputs++;
if (stage->inputs >= PSA_JPAKE_EXPECTED_INPUTS(stage->round)) {
stage->mode = OUTPUT;
stage->mode = PSA_JPAKE_OUTPUT;
}
}
if (function_mode == OUTPUT) {
if (function_mode == PSA_JPAKE_OUTPUT) {
stage->outputs++;
if (stage->outputs >= PSA_JPAKE_EXPECTED_OUTPUTS(stage->round)) {
stage->mode = INPUT;
stage->mode = PSA_JPAKE_INPUT;
}
}
if (stage->inputs >= PSA_JPAKE_EXPECTED_INPUTS(stage->round) &&
@ -8177,7 +8177,7 @@ psa_status_t psa_pake_output(
switch (operation->alg) {
#if defined(PSA_WANT_ALG_JPAKE)
case PSA_ALG_JPAKE:
status = psa_jpake_prologue(operation, step, OUTPUT);
status = psa_jpake_prologue(operation, step, PSA_JPAKE_OUTPUT);
if (status != PSA_SUCCESS) {
goto exit;
}
@ -8201,7 +8201,7 @@ psa_status_t psa_pake_output(
switch (operation->alg) {
#if defined(PSA_WANT_ALG_JPAKE)
case PSA_ALG_JPAKE:
status = psa_jpake_epilogue(operation, OUTPUT);
status = psa_jpake_epilogue(operation, PSA_JPAKE_OUTPUT);
if (status != PSA_SUCCESS) {
goto exit;
}
@ -8250,7 +8250,7 @@ psa_status_t psa_pake_input(
switch (operation->alg) {
#if defined(PSA_WANT_ALG_JPAKE)
case PSA_ALG_JPAKE:
status = psa_jpake_prologue(operation, step, INPUT);
status = psa_jpake_prologue(operation, step, PSA_JPAKE_INPUT);
if (status != PSA_SUCCESS) {
goto exit;
}
@ -8274,7 +8274,7 @@ psa_status_t psa_pake_input(
switch (operation->alg) {
#if defined(PSA_WANT_ALG_JPAKE)
case PSA_ALG_JPAKE:
status = psa_jpake_epilogue(operation, INPUT);
status = psa_jpake_epilogue(operation, PSA_JPAKE_INPUT);
if (status != PSA_SUCCESS) {
goto exit;
}
@ -8309,7 +8309,7 @@ psa_status_t psa_pake_get_implicit_key(
if (operation->alg == PSA_ALG_JPAKE) {
psa_jpake_computation_stage_t *computation_stage =
&operation->computation_stage.jpake;
if (computation_stage->round != FINISHED) {
if (computation_stage->round != PSA_JPAKE_FINISHED) {
status = PSA_ERROR_BAD_STATE;
goto exit;
}