Skip to content

Async support#1

Closed
dinosaure wants to merge 33 commits into
janestreet:masterfrom
dinosaure:async
Closed

Async support#1
dinosaure wants to merge 33 commits into
janestreet:masterfrom
dinosaure:async

Conversation

@dinosaure
Copy link
Copy Markdown

No description provided.

Comment thread async/bin/thales.ml
| `AES_256_CBC_SHA256
| `AES_256_CCM
| `AES_256_GCM_SHA384
| `_3DES_EDE_CBC_SHA
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this due to the odd type name, and then wondered if we shouldn't be disabling the 3DES ciphers by default due to their insecurity. See here for a discussion about this particular cipher combination and its effective entropy. If most clients in the wild support AES ciphers, then perhaps we can drop the older ones from async-tls.

Comment thread async/lib/x509_async.mli Outdated
Comment thread async/lib/x509_async.mli Outdated
Comment thread async/lib/x509_async.ml Outdated
Comment thread async/lib/x509_async.ml Outdated
Comment thread async/lib/x509_async.ml Outdated
Comment thread async/lib/x509_async.ml Outdated
Comment thread async/lib/x509_async.ml Outdated
Comment thread async/lib/x509_async.ml Outdated
Comment thread async/lib/jbuild Outdated
Comment thread async/lib/jbuild Outdated
Copy link
Copy Markdown
Member

@seliopou seliopou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'm back on review. Sorry it's taken so long.

As a general comment, there are some functions in the tls_async.ml that raise when really they could just return a Deferred.Or_error.t. That would make "exception-raising" behavior of the functions more explicit and is a bit more idiomatic. More coming but I thought I'd point this out as I continue on with more specific comments.

Comment thread async/lib/tls_async.ml Outdated
Comment thread async/lib/tls_async.ml Outdated
Comment thread async/lib/tls_async.ml Outdated
@seliopou
Copy link
Copy Markdown
Member

seliopou commented Dec 6, 2018

As a concrete example of a function that should return Deferred.Or_error.t, look at reneg. I imagine others could benefit from this change as well.

@seliopou
Copy link
Copy Markdown
Member

seliopou commented Dec 6, 2018

Another piece of general feedback, there are a lot of places where assert false is being used, I believe, to just raise an error. See the TODO in reneg and the assert false in accept. These should all be replaced with informative error messages. If an assert false is used to indicate an impossible case, that's fine, but a comment as to why should also accompany it. I see that this approach was taken in epoch, which is great!

Comment thread async/lib/tls_async.ml
cstruct_to_bigstring buf
@@ fun buf ~pos ~len ->
Unix.Syscall_result.Int.ok_or_unix_error_exn ~syscall_name:"read"
@@ Bigstring.read_assume_fd_is_nonblocking fd buf ~pos ~len
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylistic, but this @@ style is a kindof unreadable.

Comment thread async/lib/tls_async.ml Outdated
@dinosaure
Copy link
Copy Markdown
Author

I think, all serious feedbacks was done with the second pass (with more explicit commits). At the end, stylistic issue can be fixed and _3DES_EDE_CBC_SHA can be removed. I removed all assert false (noticed with a TODO). Most of them are replaced by an exception. On the LWT back-end, it's exactly the same - but, instead to have our own exceptions, LWT back-end raises Invalid_argument.

@dinosaure
Copy link
Copy Markdown
Author

And if all are happy with this impl. it could be a gift for Christmas?

hannesm and others added 14 commits January 7, 2019 20:50
this fixes interoperability with (at least) android 4.4 devices
lib: do not require the list of ciphersuites sent by the client to be a proper set
previously, if handle_tls returned a response to the peer, write was called,
which may error out (recording it's error in the state and Lwt.fail). the
received data was never returned to the caller.

now, similar to the semantics in tls_mirage, the error from write is only
recorded in the state, and returned on the next function call (write/..).
this ensures proper Lwt_io interoperability, esp. if an Eof has been received,
which in the TLS world is replied to with a close_notify alert -- this write
can certainly fail. earlier, this resulted in an `Error state, now the `Eof
state is retained and Lwt_io can read all application data.
Comment thread async/lib/x509_async.ml
Fpath.pp path Error.pp err ;
[] )

let authenticator meth =
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Is there a reason that now not just called time so it can be applied with ~time instead of ~time:now ?
  • This reads the current time and does time conversion for all cases, including `No_authentication where it's not needed.
    ping @dinosaure

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmhmm, for sure we can update time to be unit -> Ptime.t and call it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants