diff options
-rw-r--r-- | lib/gnutls_handshake.c | 9 | ||||
-rw-r--r-- | lib/gnutls_int.h | 1 | ||||
-rw-r--r-- | lib/gnutls_state.c | 19 | ||||
-rw-r--r-- | lib/libgnutls.map | 1 |
4 files changed, 28 insertions, 2 deletions
diff --git a/lib/gnutls_handshake.c b/lib/gnutls_handshake.c index 0d8b31225b..ce91e09395 100644 --- a/lib/gnutls_handshake.c +++ b/lib/gnutls_handshake.c @@ -1963,8 +1963,13 @@ static int send_client_hello(gnutls_session_t session, int again) return GNUTLS_E_INTERNAL_ERROR; } - tver[0] = hver->major; - tver[1] = hver->minor; + if (unlikely(session->internals.default_hello_version[0] != 0)) { + tver[0] = session->internals.default_hello_version[0]; + tver[1] = session->internals.default_hello_version[1]; + } else { + tver[0] = hver->major; + tver[1] = hver->minor; + } ret = _gnutls_buffer_append_data(&extdata, tver, 2); if (ret < 0) { gnutls_assert(); diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index d92be1aba0..ec4539d2be 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -889,6 +889,7 @@ typedef struct { /* This holds the default version that our first * record packet will have. */ uint8_t default_record_version[2]; + uint8_t default_hello_version[2]; void *user_ptr; diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index 80b757e475..40be26e847 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -735,6 +735,25 @@ _gnutls_record_set_default_version(gnutls_session_t session, session->internals.default_record_version[1] = minor; } +/*- + * _gnutls_hello_set_default_version - Used to set the default version for the first record packet + * @session: is a #gnutls_session_t structure. + * @major: is a tls major version + * @minor: is a tls minor version + * + * This function sets the default version that we will use in the first + * record packet (client hello). This function is only useful to people + * that know TLS internals and want to debug other implementations. + -*/ +void +_gnutls_hello_set_default_version(gnutls_session_t session, + unsigned char major, + unsigned char minor) +{ + session->internals.default_hello_version[0] = major; + session->internals.default_hello_version[1] = minor; +} + /** * gnutls_handshake_set_private_extensions: * @session: is a #gnutls_session_t structure. diff --git a/lib/libgnutls.map b/lib/libgnutls.map index 8ffed88935..e8e5296317 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -1111,6 +1111,7 @@ GNUTLS_PRIVATE { # Internal symbols needed by gnutls-cli-debug: _gnutls_rsa_pms_set_version; _gnutls_record_set_default_version; + _gnutls_hello_set_default_version; # Internal symbols needed by tests/gc: _gnutls_pbkdf2_sha1; # Internal symbols needed by tests/mpi: |