Skip to content

Commit

Permalink
Bug Fix: mbedtls_ecdsa_verify_restartable fails with ECDSA_SIGN_ALT
Browse files Browse the repository at this point in the history
When ECDSA_SIGN_ALT but not ECDSA_VERIFY_ALT, mbedtls_ecdsa_can_do was not being defined causing mbedtls_ecdsa_verify_restartable to always fail

Signed-off-by: JonathanWitthoeft <[email protected]>
  • Loading branch information
JonathanWitthoeft authored and gilles-peskine-arm committed Sep 29, 2023
1 parent dce82cd commit bfb0b39
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions library/ecdsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,24 @@ static int derive_mpi(const mbedtls_ecp_group *grp, mbedtls_mpi *x,
}
#endif /* ECDSA_DETERMINISTIC || !ECDSA_SIGN_ALT || !ECDSA_VERIFY_ALT */

#if !defined(MBEDTLS_ECDSA_SIGN_ALT) || \
!defined(MBEDTLS_ECDSA_VERIFY_ALT)

int mbedtls_ecdsa_can_do(mbedtls_ecp_group_id gid)
{
switch (gid) {
#ifdef MBEDTLS_ECP_DP_CURVE25519_ENABLED
case MBEDTLS_ECP_DP_CURVE25519: return 0;
#endif
#ifdef MBEDTLS_ECP_DP_CURVE448_ENABLED
case MBEDTLS_ECP_DP_CURVE448: return 0;
#endif
default: return 1;
}
}

#endif /* !ECDSA_SIGN_ALT || !ECDSA_VERIFY_ALT */

#if !defined(MBEDTLS_ECDSA_SIGN_ALT)
/*
* Compute ECDSA signature of a hashed message (SEC1 4.1.3)
Expand Down Expand Up @@ -379,19 +397,6 @@ static int ecdsa_sign_restartable(mbedtls_ecp_group *grp,
return ret;
}

int mbedtls_ecdsa_can_do(mbedtls_ecp_group_id gid)
{
switch (gid) {
#ifdef MBEDTLS_ECP_DP_CURVE25519_ENABLED
case MBEDTLS_ECP_DP_CURVE25519: return 0;
#endif
#ifdef MBEDTLS_ECP_DP_CURVE448_ENABLED
case MBEDTLS_ECP_DP_CURVE448: return 0;
#endif
default: return 1;
}
}

/*
* Compute ECDSA signature of a hashed message
*/
Expand Down

0 comments on commit bfb0b39

Please sign in to comment.