mirror of
https://github.com/espressif/mbedtls.git
synced 2026-09-14 14:29:55 +00:00
ECDH: use more precise error code
The documentation says "or another error code", so it's OK to change the error code returned here for a more correct one. Signed-off-by: Manuel Pégourié-Gonnard <[email protected]>
This commit is contained in:
Vendored
+1
-1
@@ -129,7 +129,7 @@ int mbedtls_x25519_calc_secret( mbedtls_x25519_context *ctx, size_t *olen,
|
||||
*olen = MBEDTLS_X25519_KEY_SIZE_BYTES;
|
||||
|
||||
if( blen < *olen )
|
||||
return( MBEDTLS_ERR_ECP_BAD_INPUT_DATA );
|
||||
return( MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL );
|
||||
|
||||
/* scalarmult modifies this input, let's make a copy... */
|
||||
unsigned char secret[MBEDTLS_X25519_KEY_SIZE_BYTES];
|
||||
|
||||
+1
-1
@@ -649,7 +649,7 @@ static int ecdh_calc_secret_internal(mbedtls_ecdh_context_mbed *ctx,
|
||||
size_t p_bytes = ctx->grp.pbits / 8 + ((ctx->grp.pbits % 8) != 0);
|
||||
|
||||
if (p_bytes > blen) {
|
||||
return MBEDTLS_ERR_ECP_BAD_INPUT_DATA;
|
||||
return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
*olen = p_bytes;
|
||||
|
||||
@@ -441,7 +441,7 @@ void ecdh_exchange_calc_secret(int grp_id,
|
||||
|
||||
/* Try again with an output buffer that's too short. */
|
||||
TEST_CALLOC(buf, min_buf_size - 1);
|
||||
TEST_EQUAL(MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||
TEST_EQUAL(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL,
|
||||
mbedtls_ecdh_calc_secret(
|
||||
&ecdh, &shared_secret_length,
|
||||
buf, min_buf_size - 1,
|
||||
|
||||
Reference in New Issue
Block a user