networking · intermediate · ~15 min

TLS record content type

Read the TLS record type byte.

Challenge

A TLS record starts with a 1-byte content type (22 = handshake, 23 = application data). Implement int tls_record_type(const unsigned char *rec) returning rec[0].

Starter code

int tls_record_type(const unsigned char *rec) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.