Port old tls code to new codec