tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

notes.txt (3458B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 SSL's Buffers: enumerated and explained.
      6 
      7 ---------------------------------------------------------------------------
      8 incoming:
      9 
     10 gs = ss->gather
     11 hs = ss->ssl3->hs
     12 
     13 gs->inbuf   incoming (encrypted) ssl records are placed here,
     14        and then decrypted (or copied) to gs->buf.
     15 
     16 gs->buf     ssl3_HandleHandshake puts decrypted ssl records here.
     17 
     18 hs.msg_body When an incoming handshake message spans more
     19        than one ssl record, the first part(s) of it are accumulated
     20        here until it all arrives.
     21 
     22 hs.msgState an alternative set of pointers/lengths for gs->buf.
     23        Used only when a handleHandshake function returns SECWouldBlock.
     24        ssl3_HandleHandshake remembers how far it previously got by
     25        using these pointers instead of gs->buf when it is called
     26        after a previous SECWouldBlock return.
     27 
     28 ---------------------------------------------------------------------------
     29 outgoing:
     30 
     31 sec = ss->sec
     32 ci  = ss->sec->ci   /* connect info */
     33 
     34 ci->sendBuf Outgoing handshake messages are appended to this buffer.
     35        This buffer will then be sent as a single SSL record.
     36 
     37 sec->writeBuf   outgoing ssl records are constructed here and encrypted in
     38        place before being written or copied to pendingBuf.
     39 
     40 ss->pendingBuf  contains outgoing ciphertext that was saved after a write
     41        attempt to the socket failed, e.g. EWouldBlock.
     42        Generally empty with blocking sockets (should be no incomplete
     43        writes).
     44 
     45 ss->saveBuf Used only by socks code.  Intended to be used to buffer
     46        outgoing data until a socks handshake completes.  However,
     47        this buffer is always empty.  There is no code to put
     48        anything into it.
     49 
     50 ---------------------------------------------------------------------------
     51 
     52 SECWouldBlock means that the function cannot make progress because it is
     53 waiting for some event OTHER THAN socket I/O completion (e.g. waiting for
     54 user dialog to finish).  It is not the same as EWOULDBLOCK.
     55 
     56 ---------------------------------------------------------------------------
     57 
     58 Rank (order) of locks
     59 
     60 recvLock ->\ firstHandshake -> recvbuf -> ssl3Handshake -> xmitbuf -> "spec"
     61 sendLock ->/
     62 
     63 crypto and hash Data that must be protected while turning plaintext into
     64 ciphertext:
     65 
     66 SSl3:   (in ssl3_SendPlainText)
     67    ss->ssl3            (the pointer)
     68    ss->ssl3->current_write*    (the pointer and the data in the spec
     69                     and any data referenced by the spec.
     70 
     71    ss->sec->isServer
     72    ss->sec->writebuf* (ptr & content) locked by xmitBufLock
     73    "buf"                  locked by xmitBufLock
     74 
     75 crypto and hash data that must be protected while turning ciphertext into
     76 plaintext:
     77 
     78 SSL3:   (in ssl3_HandleRecord )
     79    ssl3->current_read* (the pointer and all data refernced)
     80    ss->sec->isServer
     81 
     82 
     83 Data that must be protected while being used by a "writer":
     84 
     85 ss->pendingBuf.*
     86 ss->saveBuf.*       (which is dead)
     87 
     88 in ssl3_sendPlainText
     89 
     90 ss->ssl3->current_write-> (spec)
     91 ss->sec->writeBuf.*
     92 ss->sec->isServer
     93 
     94 in SendBlock
     95 
     96 ss->sec->writeBuf.*
     97 ss->pendingBuf
     98 
     99 --------------------------------------------------------------------------
    100 
    101 Data variables (not const) protected by the "sslGlobalDataLock".
    102 Note, this really should be a reader/writer lock.
    103 
    104 cipherSuites[]      ssl3con.c