mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-11 01:11:42 +08:00
Make mbedtls_sa_ecp_load_public_part return psa_status_t
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
efebad0d67
commit
2c9843f2a4
@ -3787,10 +3787,10 @@ psa_status_t mbedtls_psa_verify_hash_start(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = mbedtls_psa_ecp_load_public_part(operation->ctx);
|
status = mbedtls_psa_ecp_load_public_part(operation->ctx);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (status != PSA_SUCCESS) {
|
||||||
return mbedtls_to_psa_error(ret);
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We only need to store the same length of hash as the private key size
|
/* We only need to store the same length of hash as the private key size
|
||||||
|
@ -404,7 +404,7 @@ cleanup:
|
|||||||
return mbedtls_to_psa_error(ret);
|
return mbedtls_to_psa_error(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_psa_ecp_load_public_part(mbedtls_ecp_keypair *ecp)
|
psa_status_t mbedtls_psa_ecp_load_public_part(mbedtls_ecp_keypair *ecp)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ int mbedtls_psa_ecp_load_public_part(mbedtls_ecp_keypair *ecp)
|
|||||||
MBEDTLS_PSA_RANDOM_STATE);
|
MBEDTLS_PSA_RANDOM_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return mbedtls_to_psa_error(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
psa_status_t mbedtls_psa_ecdsa_verify_hash(
|
psa_status_t mbedtls_psa_ecdsa_verify_hash(
|
||||||
@ -427,7 +427,6 @@ psa_status_t mbedtls_psa_ecdsa_verify_hash(
|
|||||||
{
|
{
|
||||||
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED;
|
||||||
mbedtls_ecp_keypair *ecp = NULL;
|
mbedtls_ecp_keypair *ecp = NULL;
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
|
||||||
size_t curve_bytes;
|
size_t curve_bytes;
|
||||||
mbedtls_mpi r, s;
|
mbedtls_mpi r, s;
|
||||||
|
|
||||||
@ -447,30 +446,39 @@ psa_status_t mbedtls_psa_ecdsa_verify_hash(
|
|||||||
mbedtls_mpi_init(&s);
|
mbedtls_mpi_init(&s);
|
||||||
|
|
||||||
if (signature_length != 2 * curve_bytes) {
|
if (signature_length != 2 * curve_bytes) {
|
||||||
ret = MBEDTLS_ERR_ECP_VERIFY_FAILED;
|
status = PSA_ERROR_INVALID_SIGNATURE;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&r,
|
status = mbedtls_to_psa_error(mbedtls_mpi_read_binary(&r,
|
||||||
signature,
|
signature,
|
||||||
curve_bytes));
|
curve_bytes));
|
||||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&s,
|
if (status != PSA_SUCCESS) {
|
||||||
signature + curve_bytes,
|
goto cleanup;
|
||||||
curve_bytes));
|
}
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK(mbedtls_psa_ecp_load_public_part(ecp));
|
status = mbedtls_to_psa_error(mbedtls_mpi_read_binary(&s,
|
||||||
|
signature + curve_bytes,
|
||||||
|
curve_bytes));
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = mbedtls_psa_ecp_load_public_part(ecp);
|
||||||
|
if (status != PSA_SUCCESS) {
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = mbedtls_ecdsa_verify(&ecp->grp, hash, hash_length,
|
status = mbedtls_to_psa_error(mbedtls_ecdsa_verify(&ecp->grp, hash,
|
||||||
&ecp->Q, &r, &s);
|
hash_length, &ecp->Q,
|
||||||
|
&r, &s));
|
||||||
cleanup:
|
cleanup:
|
||||||
mbedtls_mpi_free(&r);
|
mbedtls_mpi_free(&r);
|
||||||
mbedtls_mpi_free(&s);
|
mbedtls_mpi_free(&s);
|
||||||
mbedtls_ecp_keypair_free(ecp);
|
mbedtls_ecp_keypair_free(ecp);
|
||||||
mbedtls_free(ecp);
|
mbedtls_free(ecp);
|
||||||
|
|
||||||
return mbedtls_to_psa_error(ret);
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
#endif /* defined(MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||||
|
@ -52,10 +52,10 @@ psa_status_t mbedtls_psa_ecp_load_representation(psa_key_type_t type,
|
|||||||
*
|
*
|
||||||
* \param ecp The ECP context to load the public part for.
|
* \param ecp The ECP context to load the public part for.
|
||||||
*
|
*
|
||||||
* \return 0 on success, otherwise an MPI error.
|
* \return PSA_SUCCESS on success, otherwise an MPI error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int mbedtls_psa_ecp_load_public_part(mbedtls_ecp_keypair *ecp);
|
psa_status_t mbedtls_psa_ecp_load_public_part(mbedtls_ecp_keypair *ecp);
|
||||||
|
|
||||||
/** Import an ECP key in binary format.
|
/** Import an ECP key in binary format.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user