Introduce specific error for ver/cfg mismatch on deserialization
This commit introduces a new SSL error code
`MBEDTLS_ERR_SSL_VERSION_MISMATCH`
which can be used to indicate operation failure due to a
mismatch of version or configuration.
It is put to use in the implementation of `mbedtls_ssl_session_load()`
to signal the attempt to de-serialize a session which has been serialized
in a build of Mbed TLS using a different version or configuration.
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index cc42171..39ee494 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -9088,8 +9088,7 @@
if( memcmp( p, ssl_serialized_session_header,
sizeof( ssl_serialized_session_header ) ) != 0 )
{
- /* A more specific error code might be used here. */
- return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
+ return( MBEDTLS_ERR_SSL_VERSION_MISMATCH );
}
p += sizeof( ssl_serialized_session_header );