tls implementation in c