At 01:20 AM 5/8/01 +0200, Lutz wrote:
>On Mon, May 07, 2001 at 04:25:10PM -0400, Tom Biggs wrote:
> > Say an application uses SSL_write() to write out (on a non-blocking socket)
> > a large buffer, which contains more bytes than an underlying SSL record
> can
> > carry.
> > What is the behavior if, for example, one SSL record is successfully
> written,
> > but EWOULDBLOCK is returned when OpenSSL tries to write the next SSL
> record?
> > What value would be returned by SSL_write()? Would it be
> > A: the number of bytes which were transmitted, or
> > B: -1 to indicate a failure?
>
>1. I would also recommend Eric Rescorla's book, as the other poster did,
> as a good book about the SSL/TLS protocol and implementations.
Thanks for the tip - I have the book, I read the chapter, but I must
have blown past the part describing *non-blocking* SSL_write().
I just read it again; but your comments have helped clarify it.
>2. Having this said: unlike write() SSL_write() will only return with
> "success", when the complete buffer was written. Partial writes are
> not supported. Thus for the scenario you describe, option "B"
> applies.
So, to make sure I understand: Even if the write will require one or more
max-size SSL records plus a 'remainder' SSL record, and the socket is
non-blocking,
it will repeatedly return -1 [ and SSL_get_error() == WANT_WRITE ] until
every last byte has been written - at which time it will return the
entire byte count ('len')... Is that correct?
> > Or, if case 'B' is true, does that imply that the OpenSSL library tracks
> > how many
> > bytes have been written and keeps an offset pointer into 'buf' so that it
> > knows
> > where to start the next write?
>
>Yes. It keeps the necessary information internally (whether by an
>absolute pointer or an offset pointer I don't know without looking
>into the source).
I seem to have confused matters. Looking at s3_pkt.c just now, I see
that s->s3->wb.offset and .left keep track of how much of the encrypted
buffer has been written out. s->s3->wnum is used as an offset into
the caller's buffer, for writes which exceed the max SSL record size.
Thanks for your help Lutz.
Tom Biggs
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]