diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h index 1d6310a68..4b0218180 100644 --- a/include/polarssl/ecp.h +++ b/include/polarssl/ecp.h @@ -33,8 +33,9 @@ * ECP error codes */ #define POLARSSL_ERR_ECP_BAD_INPUT_DATA -0x4F80 /**< Bad input parameters to function. */ -#define POLARSSL_ERR_ECP_BUFFER_TOO_SMALL -0x4F80 /**< The buffer is too small to write to. */ -#define POLARSSL_ERR_ECP_GENERIC -0x4F00 /**< Generic ECP error */ +#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_FEATURE_UNAVAILABLE -0x4E00 /**< Requested curve not available. */ #ifdef __cplusplus extern "C" { diff --git a/include/polarssl/error.h b/include/polarssl/error.h index 7658814d4..366864c4b 100644 --- a/include/polarssl/error.h +++ b/include/polarssl/error.h @@ -71,7 +71,6 @@ * SHA2 1 0x0078-0x0078 * SHA4 1 0x007A-0x007A * PBKDF2 1 0x007C-0x007C - * ECP 1 0x007E-0x007E * * High-level module nr (3 bits - 0x1...-0x8...) * Name ID Nr of Errors @@ -81,7 +80,7 @@ * DHM 3 6 * PKCS5 3 4 (Started from top) * RSA 4 9 - * ECP 4 1 (Started from top) + * ECP 4 4 (Started from top) * MD 5 4 * CIPHER 6 5 * SSL 6 2 (Started from top) diff --git a/library/ecp.c b/library/ecp.c index 1a83ed0ce..d2d2e1809 100644 --- a/library/ecp.c +++ b/library/ecp.c @@ -604,7 +604,7 @@ int ecp_use_known_dp( ecp_group *grp, ecp_group_id id ) #endif /* POLARSSL_ECP_DP_SECP521R1_ENABLED */ } - return( POLARSSL_ERR_ECP_BAD_INPUT_DATA ); + return( POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE ); } /* diff --git a/library/error.c b/library/error.c index 833598ca5..aa0e24efa 100644 --- a/library/error.c +++ b/library/error.c @@ -207,6 +207,8 @@ void polarssl_strerror( int ret, char *buf, size_t buflen ) snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); if( use_ret == -(POLARSSL_ERR_ECP_GENERIC) ) snprintf( buf, buflen, "ECP - Generic ECP error" ); + if( use_ret == -(POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE) ) + snprintf( buf, buflen, "ECP - Requested curve not available" ); #endif /* POLARSSL_ECP_C */ #if defined(POLARSSL_MD_C) diff --git a/tests/suites/test_suite_ecp.data b/tests/suites/test_suite_ecp.data index 451976396..30fc4614d 100644 --- a/tests/suites/test_suite_ecp.data +++ b/tests/suites/test_suite_ecp.data @@ -228,7 +228,7 @@ ECP tls read group #2 (bad curve_type) ecp_tls_read_group:"010013":POLARSSL_ERR_ECP_BAD_INPUT_DATA:0 ECP tls read group #3 (unknown curve) -ecp_tls_read_group:"030010":POLARSSL_ERR_ECP_BAD_INPUT_DATA:0 +ecp_tls_read_group:"030010":POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE:0 ECP tls read group #4 (OK, buffer just fits) depends_on:POLARSSL_ECP_DP_SECP256R1_ENABLED