libtls: Add downgrade protection for TLS 1.3 and TLS 1.2