mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-07-30 16:26:33 +08: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 <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
801f3b3f42
commit
559525cd7f
2
3rdparty/everest/library/x25519.c
vendored
2
3rdparty/everest/library/x25519.c
vendored
@ -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];
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user