tls 6.9 KB

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