mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-23 16:20:49 +00:00
Properly namespace enum values within PSA_JPAKE_
Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
e7f21e65b6
commit
5da9560178
@ -2029,14 +2029,14 @@ typedef enum psa_crypto_driver_pake_step {
|
|||||||
} psa_crypto_driver_pake_step_t;
|
} psa_crypto_driver_pake_step_t;
|
||||||
|
|
||||||
typedef enum psa_jpake_round {
|
typedef enum psa_jpake_round {
|
||||||
FIRST = 0,
|
PSA_JPAKE_FIRST = 0,
|
||||||
SECOND = 1,
|
PSA_JPAKE_SECOND = 1,
|
||||||
FINISHED = 2
|
PSA_JPAKE_FINISHED = 2
|
||||||
} psa_jpake_round_t;
|
} psa_jpake_round_t;
|
||||||
|
|
||||||
typedef enum psa_jpake_io_mode {
|
typedef enum psa_jpake_io_mode {
|
||||||
INPUT = 0,
|
PSA_JPAKE_INPUT = 0,
|
||||||
OUTPUT = 1
|
PSA_JPAKE_OUTPUT = 1
|
||||||
} psa_jpake_io_mode_t;
|
} psa_jpake_io_mode_t;
|
||||||
|
|
||||||
struct psa_jpake_computation_stage_s {
|
struct psa_jpake_computation_stage_s {
|
||||||
@ -2052,8 +2052,8 @@ struct psa_jpake_computation_stage_s {
|
|||||||
psa_pake_step_t MBEDTLS_PRIVATE(step);
|
psa_pake_step_t MBEDTLS_PRIVATE(step);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PSA_JPAKE_EXPECTED_INPUTS(round) (((round) == FIRST) ? 2 : 1)
|
#define PSA_JPAKE_EXPECTED_INPUTS(round) (((round) == PSA_JPAKE_FIRST) ? 2 : 1)
|
||||||
#define PSA_JPAKE_EXPECTED_OUTPUTS(round) (((round) == FIRST) ? 2 : 1)
|
#define PSA_JPAKE_EXPECTED_OUTPUTS(round) (((round) == PSA_JPAKE_FIRST) ? 2 : 1)
|
||||||
|
|
||||||
struct psa_pake_operation_s {
|
struct psa_pake_operation_s {
|
||||||
/** Unique ID indicating which driver got assigned to do the
|
/** Unique ID indicating which driver got assigned to do the
|
||||||
|
@ -7767,8 +7767,8 @@ psa_status_t psa_pake_setup(
|
|||||||
psa_jpake_computation_stage_t *computation_stage =
|
psa_jpake_computation_stage_t *computation_stage =
|
||||||
&operation->computation_stage.jpake;
|
&operation->computation_stage.jpake;
|
||||||
|
|
||||||
computation_stage->round = FIRST;
|
computation_stage->round = PSA_JPAKE_FIRST;
|
||||||
computation_stage->mode = INPUT;
|
computation_stage->mode = PSA_JPAKE_INPUT;
|
||||||
computation_stage->inputs = 0;
|
computation_stage->inputs = 0;
|
||||||
computation_stage->outputs = 0;
|
computation_stage->outputs = 0;
|
||||||
computation_stage->step = PSA_PAKE_STEP_KEY_SHARE;
|
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(
|
static psa_crypto_driver_pake_step_t convert_jpake_computation_stage_to_driver_step(
|
||||||
psa_jpake_computation_stage_t *stage)
|
psa_jpake_computation_stage_t *stage)
|
||||||
{
|
{
|
||||||
if (stage->round == FIRST) {
|
if (stage->round == PSA_JPAKE_FIRST) {
|
||||||
int is_x1;
|
int is_x1;
|
||||||
if (stage->mode == OUTPUT) {
|
if (stage->mode == PSA_JPAKE_OUTPUT) {
|
||||||
is_x1 = (stage->outputs < 1);
|
is_x1 = (stage->outputs < 1);
|
||||||
} else {
|
} else {
|
||||||
is_x1 = (stage->inputs < 1);
|
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;
|
return PSA_JPAKE_STEP_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (stage->round == SECOND) {
|
} else if (stage->round == PSA_JPAKE_SECOND) {
|
||||||
if (stage->mode == OUTPUT) {
|
if (stage->mode == PSA_JPAKE_OUTPUT) {
|
||||||
switch (stage->step) {
|
switch (stage->step) {
|
||||||
case PSA_PAKE_STEP_KEY_SHARE:
|
case PSA_PAKE_STEP_KEY_SHARE:
|
||||||
return PSA_JPAKE_X2S_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;
|
operation->stage = PSA_PAKE_OPERATION_STAGE_COMPUTATION;
|
||||||
psa_jpake_computation_stage_t *computation_stage =
|
psa_jpake_computation_stage_t *computation_stage =
|
||||||
&operation->computation_stage.jpake;
|
&operation->computation_stage.jpake;
|
||||||
computation_stage->round = FIRST;
|
computation_stage->round = PSA_JPAKE_FIRST;
|
||||||
computation_stage->mode = INPUT;
|
computation_stage->mode = PSA_JPAKE_INPUT;
|
||||||
computation_stage->inputs = 0;
|
computation_stage->inputs = 0;
|
||||||
computation_stage->outputs = 0;
|
computation_stage->outputs = 0;
|
||||||
computation_stage->step = PSA_PAKE_STEP_KEY_SHARE;
|
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 =
|
psa_jpake_computation_stage_t *computation_stage =
|
||||||
&operation->computation_stage.jpake;
|
&operation->computation_stage.jpake;
|
||||||
|
|
||||||
if (computation_stage->round != FIRST &&
|
if (computation_stage->round != PSA_JPAKE_FIRST &&
|
||||||
computation_stage->round != SECOND) {
|
computation_stage->round != PSA_JPAKE_SECOND) {
|
||||||
return PSA_ERROR_BAD_STATE;
|
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
|
/* Check that we do not already have enough inputs/outputs
|
||||||
* this round */
|
* this round */
|
||||||
if (function_mode == INPUT) {
|
if (function_mode == PSA_JPAKE_INPUT) {
|
||||||
if (computation_stage->inputs >=
|
if (computation_stage->inputs >=
|
||||||
PSA_JPAKE_EXPECTED_INPUTS(computation_stage->round)) {
|
PSA_JPAKE_EXPECTED_INPUTS(computation_stage->round)) {
|
||||||
return PSA_ERROR_BAD_STATE;
|
return PSA_ERROR_BAD_STATE;
|
||||||
@ -8118,16 +8118,16 @@ static psa_status_t psa_jpake_epilogue(
|
|||||||
|
|
||||||
if (stage->step == PSA_PAKE_STEP_ZK_PROOF) {
|
if (stage->step == PSA_PAKE_STEP_ZK_PROOF) {
|
||||||
/* End of an input/output */
|
/* End of an input/output */
|
||||||
if (function_mode == INPUT) {
|
if (function_mode == PSA_JPAKE_INPUT) {
|
||||||
stage->inputs++;
|
stage->inputs++;
|
||||||
if (stage->inputs >= PSA_JPAKE_EXPECTED_INPUTS(stage->round)) {
|
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++;
|
stage->outputs++;
|
||||||
if (stage->outputs >= PSA_JPAKE_EXPECTED_OUTPUTS(stage->round)) {
|
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) &&
|
if (stage->inputs >= PSA_JPAKE_EXPECTED_INPUTS(stage->round) &&
|
||||||
@ -8177,7 +8177,7 @@ psa_status_t psa_pake_output(
|
|||||||
switch (operation->alg) {
|
switch (operation->alg) {
|
||||||
#if defined(PSA_WANT_ALG_JPAKE)
|
#if defined(PSA_WANT_ALG_JPAKE)
|
||||||
case PSA_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) {
|
if (status != PSA_SUCCESS) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -8201,7 +8201,7 @@ psa_status_t psa_pake_output(
|
|||||||
switch (operation->alg) {
|
switch (operation->alg) {
|
||||||
#if defined(PSA_WANT_ALG_JPAKE)
|
#if defined(PSA_WANT_ALG_JPAKE)
|
||||||
case PSA_ALG_JPAKE:
|
case PSA_ALG_JPAKE:
|
||||||
status = psa_jpake_epilogue(operation, OUTPUT);
|
status = psa_jpake_epilogue(operation, PSA_JPAKE_OUTPUT);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -8250,7 +8250,7 @@ psa_status_t psa_pake_input(
|
|||||||
switch (operation->alg) {
|
switch (operation->alg) {
|
||||||
#if defined(PSA_WANT_ALG_JPAKE)
|
#if defined(PSA_WANT_ALG_JPAKE)
|
||||||
case PSA_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) {
|
if (status != PSA_SUCCESS) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -8274,7 +8274,7 @@ psa_status_t psa_pake_input(
|
|||||||
switch (operation->alg) {
|
switch (operation->alg) {
|
||||||
#if defined(PSA_WANT_ALG_JPAKE)
|
#if defined(PSA_WANT_ALG_JPAKE)
|
||||||
case PSA_ALG_JPAKE:
|
case PSA_ALG_JPAKE:
|
||||||
status = psa_jpake_epilogue(operation, INPUT);
|
status = psa_jpake_epilogue(operation, PSA_JPAKE_INPUT);
|
||||||
if (status != PSA_SUCCESS) {
|
if (status != PSA_SUCCESS) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -8309,7 +8309,7 @@ psa_status_t psa_pake_get_implicit_key(
|
|||||||
if (operation->alg == PSA_ALG_JPAKE) {
|
if (operation->alg == PSA_ALG_JPAKE) {
|
||||||
psa_jpake_computation_stage_t *computation_stage =
|
psa_jpake_computation_stage_t *computation_stage =
|
||||||
&operation->computation_stage.jpake;
|
&operation->computation_stage.jpake;
|
||||||
if (computation_stage->round != FINISHED) {
|
if (computation_stage->round != PSA_JPAKE_FINISHED) {
|
||||||
status = PSA_ERROR_BAD_STATE;
|
status = PSA_ERROR_BAD_STATE;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user