]> git.lizzy.rs Git - plan9front.git/blob - sys/man/3/tls
devvga: implement screen tilting, remove panning and overlays
[plan9front.git] / sys / man / 3 / tls
1 .TH TLS 3 
2 .SH NAME
3 tls \- TLS and SSL3 record layer
4 .SH SYNOPSIS
5 .nf
6 .B bind -a #a /net
7
8 .B /net/tls/clone
9 .B /net/tls/encalgs
10 .B /net/tls/hashalgs
11 .BI /net/tls/ n 
12 .BI /net/tls/ n /ctl
13 .BI /net/tls/ n /data
14 .BI /net/tls/ n /hand
15 .BI /net/tls/ n /stats
16 .BI /net/tls/ n /status
17 .fi
18 .SH DESCRIPTION
19 The TLS device implements the record layer protocols
20 of Transport Layer Security version 1.0-1.2 and Secure Sockets Layer version 3.0.
21 It does not implement the handshake protocols, which are responsible for
22 mutual authentication and key exchange.
23 The
24 .I tls
25 device can be thought of as filters providing optional encryption and anti-tampering.
26 .PP
27 The top level directory contains a
28 .B clone
29 file and subdirectories numbered from zero through at least the last active filter.
30 Opening the
31 .B clone
32 file reserves a filter.
33 The file descriptor returned from the
34 .IR open (2)
35 will point to the control file,
36 .BR ctl ,
37 of the newly allocated filter.
38 Reading the
39 .B ctl
40 file returns a text string containing the number of the filter directory.
41 .PP
42 The filter initially cannot be used to pass messages
43 and will not encrypt or digest messages.
44 It is configured and controlled by writing commands to
45 .BR ctl .
46 .PP
47 The following commands are supported:
48 .TP
49 .BI fd \ open-fd\ vers
50 Pass record messages over the communications channel
51 .IR open-fd .
52 Initially, outgoing messages use version
53 .I vers
54 format records, but incoming messages of either version are accepted.
55 Valid versions are
56 .B 0x300
57 for SSLv3.0 and
58 .BR 0x301 ,
59 .B 0x302
60 and
61 .B 0x303
62 for TLSv1.0 (which could be known as SSLv3.01), TLSv1.1 and TLSv1.2.
63 This command must be issued before any other command
64 and before reading or writing any messages;
65 it may only be executed once.
66 .TP
67 .BI version \ vers
68 Use
69 .I vers
70 format records for all future records,
71 both outgoing and incoming.
72 This command may only be executed once.
73 .TP
74 .BI secret \ hashalg\ encalg\ isclient\ secretdata
75 Set up the digesting and encryption algorithms and secrets.
76 .I Hashalg
77 and
78 .I encalg
79 must be algorithm names returned by the corresponding files.
80 .I Secretdata
81 is the base-64 encoded (see
82 .IR encode (2))
83 secret data used for the algorithms.
84 It must contain at least enough data to populate the
85 secrets for digesting and encrypting.
86 These secrets are divided into three categories: digest secrets, keys, and initialization vectors.
87 The secrets are packed in this order, with no extra padding.
88 Within each category, the secret for data traveling from the client to the server comes first.
89 The incoming and outgoing secrets are automatically selected by devtls based on the
90 .I isclient
91 argument, which must be non-zero for the client of the TLS handshake,
92 and zero for the server.
93 .br
94 This command must be issued after
95 .BR version ,
96 and may be issued more than once.
97 At least one new
98 .I secret
99 command must be issued before each
100 .I changecipher
101 command; similarly, at least one new
102 .I secret command
103 must precede each incoming changecipher message.
104 .TP
105 .BI changecipher
106 Enable outgoing encryption and digesting as configured by the previous
107 .I secret
108 command.
109 This command sends a
110 .I changecipher
111 message.
112 .TP
113 .BI opened
114 Enable data messages.
115 This command may be issued any number of times,
116 although only the first is significant.
117 It must follow at least one successful
118 .I changecipher
119 command.
120 .TP
121 .BI alert \ alertno
122 Send an alert message.
123 .I Alertno
124 may be a valid alert code for either SSLv3.0 or TLS,
125 and is mapped to an appropriate code for the protocol in use.
126 If it is a fatal alert, the filter is set into an error state.
127 .PP
128 Application messages and handshake messages are communicated using
129 .I data
130 and
131 .IR hand ,
132 respectively.
133 Only one
134 .IR open (2)
135 of
136 .I hand
137 is allowed at a time.
138 .PP
139 Any record layer headers and trailers are inserted and
140 stripped automatically, and are not visible from the outside.
141 The device tries to synchronize record boundaries with reads and writes.
142 Each read will return data from exactly one record,
143 and will return all of the data from the record as long as
144 the buffer is big enough.
145 Each write will be converted into an integral number of records,
146 with all but potentially the last being maximal size.
147 The maximum record length supported is 16384 bytes.
148 This behavior is not specified in the protocols,
149 and may not be followed by other implementations.
150 .PP
151 If a fatal alert message is received, or a fatal
152 .I alert
153 command issued, the filter is set into an error state.
154 All further correspondence is halted,
155 although some pending operations may not be terminated.
156 Operations on
157 .I data
158 will fail with a
159 .BR "'tls error'" ,
160 and operations on
161 .I hand
162 will fail with a textual decoding of the alert.
163 The current non-fatal alert messages are
164 .BR "'close notify'" ,
165 .BR "'no renegotiation'" ,
166 and
167 .BR "'handshake canceled by user'" .
168 Receipt of one of these alerts cause the next read on
169 .I hand
170 to terminate with an error.
171 If the alert is
172 .BR "'close notify'",
173 all future reads will terminate with a
174 .B "tls hungup"
175 error.
176 A
177 .B "'close notify'"
178 .I alert
179 command will terminate all future writes or reads from
180 .I data
181 with a
182 .B "'tls hungup'"
183 error.
184 .PP
185 If an error is encountered while reading or writing
186 the underlying communications channel, the error is returned
187 to the offending operation.
188 If the error is not
189 .BR "'interrupted'" ,
190 the filter is set into the error state.
191 In this case, all future operations on
192 .I hand
193 will fail with a
194 .BR "'channel error'" .
195 .PP
196 When all file descriptors for a filter have been closed,
197 the session is terminated and the filter reclaimed for future use.
198 A
199 .B "'close notify'"
200 alert will be sent on the underlying communications channel
201 unless one has already been sent or the filter is in the error state.
202 .PP
203 Reading
204 .I stats
205 or
206 .I status
207 returns information about the filter.
208 Each datum is returned on a single line of the form
209 .IB tag ": " data .
210 .I Stats
211 returns the number of bytes communicated by the
212 .B data
213 and
214 .B hand
215 channels.
216 The four lines returned are tagged by, in order,
217 .BR DataIn ,
218 .BR DataOut ,
219 .BR HandIn ,
220 and
221 .BR HandOut .
222 .I Status
223 returns lines following tags:
224 .BR State ,
225 .BR Version ,
226 .BR EncIn ,
227 .BR HashIn ,
228 .BR NewEncIn ,
229 .BR NewHashIn ,
230 .BR EncOut ,
231 .BR HashOut ,
232 .BR NewEncOut ,
233 and
234 .BR NewHashOut .
235 .BR State 's
236 value is a string describing the status of the connection,
237 and is one of the following:
238 .BR 'Handshaking' ,
239 .BR 'Established' ,
240 .BR 'RemoteClosed' ,
241 .BR 'LocalClosed' ,
242 .BR 'Alerting' ,
243 .BR 'Errored' ,
244 or
245 .BR 'Closed' .
246 .BR Version 's
247 give the hexadecimal record layer version in use.
248 The
249 .B Enc
250 and
251 .B Hash
252 fields return name of the current algorithms in use
253 or ready to be used, if any.
254 .PP
255 Reading
256 .I encalgs
257 and 
258 .I hashalgs
259 will give the space-separated list of algorithms implemented.
260 This will always include
261 .BR clear ,
262 meaning no encryption or digesting.
263 Currently implemented encryption algorithms for use with TLSv1.0 and TLSv1.1 are:
264 .BR rc4_128 ,
265 .BR 3des_ede_cbc ,
266 .B aes_128_cbc
267 and
268 .BR aes_256_cbc .
269 For TLSv1.2, which adds support for authenticated encryption with
270 associated data (AEAD), the following ciphers are supported:
271 .BR ccpoly64_aead ,
272 .BR ccpoly96_aead ,
273 .B aes_128_gcm_aead
274 and
275 .BR aes_256_gcm_aead .
276 Currently implemented hashing algorithms are:
277 .BR md5 ,
278 .B sha1
279 and
280 .BR sha256 .
281 For an AEAD cipher, the hashing algorithm should be set to
282 .BR clear .
283 .SH "SEE ALSO"
284 .IR listen (8),
285 .IR dial (2),
286 .IR pushtls (2)
287 .SH SOURCE
288 .B /sys/src/9/port/devtls.c