# std.crypto.tls.Client: rework the read function · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/e4a9b19a1490d5c41a4d8c10f47ba5639de48404)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: e4a9b19a1490d5c41a4d8c10f47ba5639de48404

Requested commit: e4a9b19a1490d5c41a4d8c10f47ba5639de48404

Commit: e4a9b19a1490d5c41a4d8c10f47ba5639de48404

Tree: 0ed259b5e272adab65c2f81dfa4c384ebe259096

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
std.crypto.tls.Client: rework the read function

Here's what I landed on for the TLS client. It's 16896 bytes
(max_ciphertext_record_len is 16640). I believe this is the theoretical
minimum size, give or take a few bytes.

These constraints are satisfied:
 * a call to the readvAdvanced() function makes at most one call to the
   underlying readv function
 * iovecs are provided by the API, and used by the implementation for
   underlying readv() calls to the socket
 * the theoretical minimum number of memcpy() calls are issued in all
   circumstances
 * decryption is only performed once for any given TLS record
 * large read buffers are fully exploited

This is accomplished by using the partial read buffer to storing both
cleartext and ciphertext.

```

## Parents

- [7391df2be5143db8308ab7c5281842aea99cb1d7](https://git.cafe/gitcafe/zig/commit/7391df2be5143db8308ab7c5281842aea99cb1d7?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/e4a9b19a1490d5c41a4d8c10f47ba5639de48404?format=markdown)
