commit - e634cfa6578c0a2950abf661c07c899201b50925
commit + 0e0994b2df05d5286a0b1d7fec24819ce2845588
blob - dfa05c13c0fa7597a9567b88d18a1eeac21377e6
blob + 4122b01441fd4b887a274040156e14a1cda1aa3f
--- bufio.c
+++ bufio.c
return (ev);
}
+int
+bufio_handshake(struct bufio *bio)
+{
+ if (bio->ctx == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ switch (tls_handshake(bio->ctx)) {
+ case 0:
+ return (0);
+ case TLS_WANT_POLLIN:
+ case TLS_WANT_POLLOUT:
+ errno = EAGAIN;
+ bio->pflags = EV_READ | EV_WRITE;
+ /* fallthrough */
+ default:
+ return (-1);
+ }
+}
+
ssize_t
bufio_read(struct bufio *bio)
{
blob - cdf4c6716a1564598318b82601354caf3d0406f1
blob + 1737c9fd2ca66ff5e99368d0fcb3a5c2d3f95e64
--- bufio.h
+++ bufio.h
int bufio_starttls(struct bufio *, const char *, int,
const uint8_t *, size_t, const uint8_t *, size_t);
int bufio_ev(struct bufio *);
+int bufio_handshake(struct bufio *);
ssize_t bufio_read(struct bufio *);
ssize_t bufio_write(struct bufio *);
int bufio_compose(struct bufio *, const void *, size_t);