Make ecdsa_verify() return value more explicit
diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h
index 36c6185..ad31bff 100644
--- a/include/polarssl/ecp.h
+++ b/include/polarssl/ecp.h
@@ -34,8 +34,9 @@
*/
#define POLARSSL_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */
#define POLARSSL_ERR_ECP_BUFFER_TOO_SMALL -0x4F00 /**< The buffer is too small to write to. */
-#define POLARSSL_ERR_ECP_GENERIC -0x4E80 /**< Generic ECP error */
+#define POLARSSL_ERR_ECP_GENERIC -0x4E80 /**< Generic ECP error. */
#define POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE -0x4E00 /**< Requested curve not available. */
+#define POLARSSL_ERR_ECP_VERIFY_FAILED -0x4E00 /**< The signature is not valid. */
#ifdef __cplusplus
extern "C" {
diff --git a/library/ecdsa.c b/library/ecdsa.c
index bdb3567..67774c9 100644
--- a/library/ecdsa.c
+++ b/library/ecdsa.c
@@ -134,7 +134,7 @@
if( mpi_cmp_int( r, 1 ) < 0 || mpi_cmp_mpi( r, &grp->N ) >= 0 ||
mpi_cmp_int( s, 1 ) < 0 || mpi_cmp_mpi( s, &grp->N ) >= 0 )
{
- ret = POLARSSL_ERR_ECP_BAD_INPUT_DATA;
+ ret = POLARSSL_ERR_ECP_VERIFY_FAILED;
goto cleanup;
}
@@ -168,7 +168,7 @@
if( ecp_is_zero( &R ) )
{
- ret = POLARSSL_ERR_ECP_BAD_INPUT_DATA;
+ ret = POLARSSL_ERR_ECP_VERIFY_FAILED;
goto cleanup;
}
@@ -177,7 +177,7 @@
*/
if( mpi_cmp_mpi( &R.X, r ) != 0 )
{
- ret = POLARSSL_ERR_ECP_BAD_INPUT_DATA;
+ ret = POLARSSL_ERR_ECP_VERIFY_FAILED;
goto cleanup;
}