networking · beginner · ~15 min
Gate on a minimum protocol version.
TLS versions are encoded as a (major, minor) pair on the wire: TLS 1.2 is (3,3) and TLS 1.3 is (3,4). Modern servers reject the deprecated TLS 1.0/1.1. Gate a version against a minimum of TLS 1.2.
Implement int tls_version_ok(int major, int minor) that returns 1 if the version is TLS 1.2 or newer (major == 3 and minor >= 3), otherwise 0.
major, minor: the wire version pair.Returns 1 if the version is acceptable (TLS 1.2+), else 0.
tls_version_ok(3, 3) -> 1 (TLS 1.2)
tls_version_ok(3, 4) -> 1 (TLS 1.3)
tls_version_ok(3, 1) -> 0 (TLS 1.0, too old)
Two integers: the wire major and minor TLS version.
1 if major == 3 and minor >= 3 (TLS 1.2+), else 0.
TLS 1.2 is (3,3) and TLS 1.3 is (3,4); accept major 3 with minor >= 3.
int tls_version_ok(int major, int minor) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.