summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2015-09-10 11:21:08 +0000
committerjsing <>2015-09-10 11:21:08 +0000
commit1ede37579e4cc08560f78fbdfce88b0ddaffc6ab (patch)
tree79dbea60bd5c2ebd6c3c1f9c1e4ca2caf09783b6 /src
parent3b4772c462030edfaf3d198f5823d096a8c1a278 (diff)
downloadopenbsd-1ede37579e4cc08560f78fbdfce88b0ddaffc6ab.tar.gz
openbsd-1ede37579e4cc08560f78fbdfce88b0ddaffc6ab.tar.bz2
openbsd-1ede37579e4cc08560f78fbdfce88b0ddaffc6ab.zip
Update libtls man page to reflect tls_handshake() related changes.
ok beck@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libtls/tls_init.372
1 files changed, 37 insertions, 35 deletions
diff --git a/src/lib/libtls/tls_init.3 b/src/lib/libtls/tls_init.3
index d321768755..70493fae03 100644
--- a/src/lib/libtls/tls_init.3
+++ b/src/lib/libtls/tls_init.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: tls_init.3,v 1.28 2015/09/10 11:00:54 beck Exp $ 1.\" $OpenBSD: tls_init.3,v 1.29 2015/09/10 11:21:08 jsing Exp $
2.\" 2.\"
3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org> 3.\" Copyright (c) 2014 Ted Unangst <tedu@openbsd.org>
4.\" 4.\"
@@ -46,7 +46,6 @@
46.Nm tls_server , 46.Nm tls_server ,
47.Nm tls_configure , 47.Nm tls_configure ,
48.Nm tls_reset , 48.Nm tls_reset ,
49.Nm tls_close ,
50.Nm tls_free , 49.Nm tls_free ,
51.Nm tls_connect , 50.Nm tls_connect ,
52.Nm tls_connect_fds , 51.Nm tls_connect_fds ,
@@ -54,8 +53,10 @@
54.Nm tls_connect_socket , 53.Nm tls_connect_socket ,
55.Nm tls_accept_fds , 54.Nm tls_accept_fds ,
56.Nm tls_accept_socket , 55.Nm tls_accept_socket ,
56.Nm tls_handshake ,
57.Nm tls_read , 57.Nm tls_read ,
58.Nm tls_write 58.Nm tls_write ,
59.Nm tls_close
59.Nd TLS client and server API 60.Nd TLS client and server API
60.Sh SYNOPSIS 61.Sh SYNOPSIS
61.In tls.h 62.In tls.h
@@ -115,8 +116,6 @@
115.Fn tls_configure "struct tls *ctx" "struct tls_config *config" 116.Fn tls_configure "struct tls *ctx" "struct tls_config *config"
116.Ft "void" 117.Ft "void"
117.Fn tls_reset "struct tls *ctx" 118.Fn tls_reset "struct tls *ctx"
118.Ft "int"
119.Fn tls_close "struct tls *ctx"
120.Ft "void" 119.Ft "void"
121.Fn tls_free "struct tls *ctx" 120.Fn tls_free "struct tls *ctx"
122.Ft "int" 121.Ft "int"
@@ -131,9 +130,13 @@
131.Ft "int" 130.Ft "int"
132.Fn tls_accept_socket "struct tls *tls" "struct tls **cctx" "int socket" 131.Fn tls_accept_socket "struct tls *tls" "struct tls **cctx" "int socket"
133.Ft "int" 132.Ft "int"
133.Fn tls_handshake "struct tls *ctx"
134.Ft "int"
134.Fn tls_read "struct tls *ctx" "void *buf" "size_t buflen" "size_t *outlen" 135.Fn tls_read "struct tls *ctx" "void *buf" "size_t buflen" "size_t *outlen"
135.Ft "int" 136.Ft "int"
136.Fn tls_write "struct tls *ctx" "const void *buf" "size_t buflen" "size_t *outlen" 137.Fn tls_write "struct tls *ctx" "const void *buf" "size_t buflen" "size_t *outlen"
138.Ft "int"
139.Fn tls_close "struct tls *ctx"
137.Sh DESCRIPTION 140.Sh DESCRIPTION
138The 141The
139.Nm tls 142.Nm tls
@@ -193,10 +196,14 @@ Alternatively, a new client connection can be accepted over a pair of existing
193file descriptors by calling 196file descriptors by calling
194.Fn tls_accept_fds . 197.Fn tls_accept_fds .
195.Pp 198.Pp
199The TLS handshake can be completed by calling
200.Fn tls_handshake .
196Two functions are provided for input and output, 201Two functions are provided for input and output,
197.Fn tls_read 202.Fn tls_read
198and 203and
199.Fn tls_write . 204.Fn tls_write .
205Both of these functions will result in the TLS handshake being performed if it
206has not already completed.
200.Pp 207.Pp
201After use, a tls 208After use, a tls
202.Em context 209.Em context
@@ -351,13 +358,6 @@ creates a new tls context for server connections.
351readies a tls context for use by applying the configuration 358readies a tls context for use by applying the configuration
352options. 359options.
353.It 360.It
354.Fn tls_close
355closes a connection after use.
356If the connection was established using
357.Fn tls_connect_fds ,
358only the TLS layer will be closed and it is the caller's responsibility to close
359the file descriptors.
360.It
361.Fn tls_free 361.Fn tls_free
362frees a tls context after use. 362frees a tls context after use.
363.El 363.El
@@ -385,20 +385,23 @@ creates a new context suitable for reading and writing on an existing pair of
385file descriptors and returns it in 385file descriptors and returns it in
386.Fa *cctx . 386.Fa *cctx .
387A configured server context should be passed in 387A configured server context should be passed in
388.Fa ctx 388.Fa ctx .
389and
390.Fa *cctx
391should be initialized to NULL.
392.It 389.It
393.Fn tls_accept_socket 390.Fn tls_accept_socket
394creates a new context suitable for reading and writing on an already 391creates a new context suitable for reading and writing on an already
395established socket connection and returns it in 392established socket connection and returns it in
396.Fa *cctx . 393.Fa *cctx .
397A configured server context should be passed in 394A configured server context should be passed in
398.Fa ctx 395.Fa ctx .
396.It
397.Fn tls_handshake
398performs the TLS handshake.
399It is only neccessary to call this function if you need to guarantee that the
400handshake has completed, as both
401.Fn tls_read
399and 402and
400.Fa *cctx 403.Fn tls_write
401should be initialized to NULL. 404will perform the TLS handshake if necessary.
402.It 405.It
403.Fn tls_read 406.Fn tls_read
404reads 407reads
@@ -416,23 +419,28 @@ bytes of data from
416to the socket. 419to the socket.
417The amount of data written is returned in 420The amount of data written is returned in
418.Fa outlen . 421.Fa outlen .
422.It
423.Fn tls_close
424closes a connection after use.
425If the connection was established using
426.Fn tls_connect_fds ,
427only the TLS layer will be closed and it is the caller's responsibility to close
428the file descriptors.
419.El 429.El
420.Sh RETURN VALUES 430.Sh RETURN VALUES
421Functions that return 431Functions that return
422.Vt int 432.Vt int
423will return 0 on success and -1 on error. 433will return 0 on success and -1 on error.
424Functions that return a pointer will return NULL on error. 434Functions that return a pointer will return NULL on error, which indicates an
435out of memory condition.
425.Pp 436.Pp
426The 437The
427.Fn tls_close , 438.Fn tls_handshake ,
428.Fn tls_read 439.Fn tls_read ,
429and 440.Fn tls_write ,
430.Fn tls_write
431functions, along with the
432.Fn tls_accept
433and 441and
434.Fn tls_connect 442.Fn tls_close
435function families, have two special return values: 443functions have two special return values:
436.Pp 444.Pp
437.Bl -tag -width "TLS_WRITE_AGAIN" -offset indent -compact 445.Bl -tag -width "TLS_WRITE_AGAIN" -offset indent -compact
438.It Dv TLS_READ_AGAIN 446.It Dv TLS_READ_AGAIN
@@ -450,13 +458,7 @@ even when calling
450.Pp 458.Pp
451While there are cases where these functions will return one or the 459While there are cases where these functions will return one or the
452other or both, the best practice is to always check for both. 460other or both, the best practice is to always check for both.
453The caller should call the appropriate function or, in the case of the 461In all cases the same function call should be repeated.
454.Fn tls_close
455and the
456.Fn tls_accept
457and
458.Fn tls_connect
459function families, repeat the call.
460.Sh EXAMPLES 462.Sh EXAMPLES
461Example showing how to handle partial TLS writes. 463Example showing how to handle partial TLS writes.
462.Bd -literal -offset indent 464.Bd -literal -offset indent