project-everest / mitls-fstar

Verified implementation of TLS 1.3 in F*
https://www.mitls.org
Other
173 stars 16 forks source link

A memory and data model for miTLS #240

Open nikswamy opened 5 years ago

nikswamy commented 5 years ago

We have in several related branches a prototype implementation of the miTLS memory model https://github.com/mitls/mitls-papers/wiki/The-Memory-Model-of-miTLS (private link)

To merge this into the no_hsl branch of miTLS the following work items need to be completed

F* branch: nik_dynamic_regions to be merged to master

assume
val sub (c:buffer 'a) (i:uint_32) (len:Ghost.erased uint_32)
  : Stack (buffer 'a)
    (requires fun h ->
      live h c /\
      U32.v i + U32.v (Ghost.reveal len) <= length c)
    (ensures fun h0 c' h1 ->
      h0 == h1 /\
      c' `sub_buffer i (Ghost.reveal len)` c)

EverParse changes

let accessor (p1:parser k1 t1) (p2:parser k2 t2) (g:gaccessor p1 p2 l) =
    pos:u32 -> b:buffer u8 -> len:erased u32 -> 
    Stack u32
    (requires fun h -> 
        valid (as_slice b len) p1 pos h /\ ... )
    ...
let ptr = R.repr_ptr_p t t_parser
let pos (b:R.const_slice) = R.repr_pos_p t b t_parser

And for each field it should produce, either a FieldAccessor or a FieldReader

e.g.,

/// Reader for the protocol version
noextract
unfold
let version_reader =
  R.FieldReader
    CH.accessor_clientHello_version
    Parsers.ProtocolVersion.protocolVersion_reader

/// Accessor for the extensions
noextract
unfold
let extensions_field =
  R.FieldAccessor CH.accessor_clientHello_extensions
                  Parsers.ClientHelloExtensions.clientHelloExtensions_jumper
                  Parsers.ClientHelloExtensions.clientHelloExtensions_parser32

As we figure out how to do lists, we will require more things to be emitted by QD

miTLS changes

We should maintain the functionality of no_hsl, as defined by CI

ad-l commented 5 years ago

Sounds like a good plan, I'm happy to take care of the QD changes as soon as LowParse.Repr.fst is moved to LowParse

aseemr commented 5 years ago

The support for the witnessed buffer lemma and dynamic regions is in F* master. Remaining tasks there:

Hope to finish them soon.