2012-12-06 03:19:18 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
SSL's Buffers: enumerated and explained.
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
incoming:
|
|
|
|
|
|
|
|
gs = ss->gather
|
|
|
|
hs = ss->ssl3->hs
|
|
|
|
|
2016-04-12 15:40:44 +03:00
|
|
|
gs->inbuf incoming (encrypted) ssl records are placed here,
|
2016-02-23 02:50:19 +03:00
|
|
|
and then decrypted (or copied) to gs->buf.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-04-12 15:40:44 +03:00
|
|
|
gs->buf ssl3_HandleHandshake puts decrypted ssl records here.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-04-12 15:40:44 +03:00
|
|
|
hs.msg_body When an incoming handshake message spans more
|
2016-02-23 02:50:19 +03:00
|
|
|
than one ssl record, the first part(s) of it are accumulated
|
|
|
|
here until it all arrives.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-04-12 15:40:44 +03:00
|
|
|
hs.msgState an alternative set of pointers/lengths for gs->buf.
|
2016-02-23 02:50:19 +03:00
|
|
|
Used only when a handleHandshake function returns SECWouldBlock.
|
|
|
|
ssl3_HandleHandshake remembers how far it previously got by
|
|
|
|
using these pointers instead of gs->buf when it is called
|
|
|
|
after a previous SECWouldBlock return.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
outgoing:
|
|
|
|
|
|
|
|
sec = ss->sec
|
2016-02-23 02:50:19 +03:00
|
|
|
ci = ss->sec->ci /* connect info */
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
ci->sendBuf Outgoing handshake messages are appended to this buffer.
|
|
|
|
This buffer will then be sent as a single SSL record.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
sec->writeBuf outgoing ssl records are constructed here and encrypted in
|
|
|
|
place before being written or copied to pendingBuf.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
ss->pendingBuf contains outgoing ciphertext that was saved after a write
|
|
|
|
attempt to the socket failed, e.g. EWouldBlock.
|
|
|
|
Generally empty with blocking sockets (should be no incomplete
|
|
|
|
writes).
|
2008-06-06 16:40:11 +04:00
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
ss->saveBuf Used only by socks code. Intended to be used to buffer
|
|
|
|
outgoing data until a socks handshake completes. However,
|
|
|
|
this buffer is always empty. There is no code to put
|
|
|
|
anything into it.
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
SECWouldBlock means that the function cannot make progress because it is
|
|
|
|
waiting for some event OTHER THAN socket I/O completion (e.g. waiting for
|
2008-06-06 16:40:11 +04:00
|
|
|
user dialog to finish). It is not the same as EWOULDBLOCK.
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Rank (order) of locks
|
|
|
|
|
2011-08-19 19:27:10 +04:00
|
|
|
recvLock ->\ firstHandshake -> recvbuf -> ssl3Handshake -> xmitbuf -> "spec"
|
|
|
|
sendLock ->/
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
crypto and hash Data that must be protected while turning plaintext into
|
|
|
|
ciphertext:
|
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
SSl3: (in ssl3_SendPlainText)
|
|
|
|
ss->ssl3 (the pointer)
|
|
|
|
ss->ssl3->current_write* (the pointer and the data in the spec
|
|
|
|
and any data referenced by the spec.
|
|
|
|
|
|
|
|
ss->sec->isServer
|
|
|
|
ss->sec->writebuf* (ptr & content) locked by xmitBufLock
|
|
|
|
"buf" locked by xmitBufLock
|
|
|
|
|
|
|
|
crypto and hash data that must be protected while turning ciphertext into
|
2008-06-06 16:40:11 +04:00
|
|
|
plaintext:
|
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
SSL3: (in ssl3_HandleRecord )
|
|
|
|
ssl3->current_read* (the pointer and all data refernced)
|
|
|
|
ss->sec->isServer
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
Data that must be protected while being used by a "writer":
|
|
|
|
|
|
|
|
ss->pendingBuf.*
|
2016-02-23 02:50:19 +03:00
|
|
|
ss->saveBuf.* (which is dead)
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
in ssl3_sendPlainText
|
|
|
|
|
|
|
|
ss->ssl3->current_write-> (spec)
|
|
|
|
ss->sec->writeBuf.*
|
2016-02-23 02:50:19 +03:00
|
|
|
ss->sec->isServer
|
2008-06-06 16:40:11 +04:00
|
|
|
|
|
|
|
in SendBlock
|
|
|
|
|
|
|
|
ss->sec->writeBuf.*
|
|
|
|
ss->pendingBuf
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------
|
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
Data variables (not const) protected by the "sslGlobalDataLock".
|
2008-06-06 16:40:11 +04:00
|
|
|
Note, this really should be a reader/writer lock.
|
|
|
|
|
2016-02-23 02:50:19 +03:00
|
|
|
cipherSuites[] ssl3con.c
|