diff options
| author | jsing <> | 2019-01-21 13:45:57 +0000 |
|---|---|---|
| committer | jsing <> | 2019-01-21 13:45:57 +0000 |
| commit | f21a3bd76c1dc4754f327f6fce96c1c3de33219e (patch) | |
| tree | 14969b4304a48b9fdbf41d756aec5076c5ac5d69 /src/lib/libssl/tls13_lib.c | |
| parent | d2fc06dd0ef9edf05b0e1fb4198cc10bd27363d6 (diff) | |
| download | openbsd-f21a3bd76c1dc4754f327f6fce96c1c3de33219e.tar.gz openbsd-f21a3bd76c1dc4754f327f6fce96c1c3de33219e.tar.bz2 openbsd-f21a3bd76c1dc4754f327f6fce96c1c3de33219e.zip | |
Provide the initial TLSv1.3 client implementation.
Move tls13_connect() to a new tls13_client.c file and provide a legacy
wrapper to it, which allocates a struct tls_ctx if necessary. Also move
tls13_client_hello_send() to tls13_client.c and actual implement the
building of a client hello.
ok tb@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libssl/tls13_lib.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/lib/libssl/tls13_lib.c b/src/lib/libssl/tls13_lib.c index c4cce26ca5..3860ddefef 100644 --- a/src/lib/libssl/tls13_lib.c +++ b/src/lib/libssl/tls13_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_lib.c,v 1.2 2019/01/21 10:24:25 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_lib.c,v 1.3 2019/01/21 13:45:57 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -61,6 +61,39 @@ tls13_cipher_hash(const SSL_CIPHER *cipher) | |||
| 61 | return NULL; | 61 | return NULL; |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | struct tls13_ctx * | ||
| 65 | tls13_ctx_new(int mode) | ||
| 66 | { | ||
| 67 | struct tls13_ctx *ctx = NULL; | ||
| 68 | |||
| 69 | if ((ctx = calloc(sizeof(struct tls13_ctx), 1)) == NULL) | ||
| 70 | goto err; | ||
| 71 | |||
| 72 | ctx->mode = mode; | ||
| 73 | |||
| 74 | if ((ctx->rl = tls13_record_layer_new(tls13_legacy_wire_read_cb, | ||
| 75 | tls13_legacy_wire_write_cb, NULL, NULL, ctx)) == NULL) | ||
| 76 | goto err; | ||
| 77 | |||
| 78 | return ctx; | ||
| 79 | |||
| 80 | err: | ||
| 81 | tls13_ctx_free(ctx); | ||
| 82 | |||
| 83 | return NULL; | ||
| 84 | } | ||
| 85 | |||
| 86 | void | ||
| 87 | tls13_ctx_free(struct tls13_ctx *ctx) | ||
| 88 | { | ||
| 89 | if (ctx == NULL) | ||
| 90 | return; | ||
| 91 | |||
| 92 | tls13_record_layer_free(ctx->rl); | ||
| 93 | |||
| 94 | freezero(ctx, sizeof(struct tls13_ctx)); | ||
| 95 | } | ||
| 96 | |||
| 64 | static ssize_t | 97 | static ssize_t |
| 65 | tls13_legacy_wire_read(SSL *ssl, uint8_t *buf, size_t len) | 98 | tls13_legacy_wire_read(SSL *ssl, uint8_t *buf, size_t len) |
| 66 | { | 99 | { |
| @@ -131,7 +164,7 @@ tls13_legacy_wire_write_cb(const void *buf, size_t n, void *arg) | |||
| 131 | return tls13_legacy_wire_write(ctx->ssl, buf, n); | 164 | return tls13_legacy_wire_write(ctx->ssl, buf, n); |
| 132 | } | 165 | } |
| 133 | 166 | ||
| 134 | static int | 167 | int |
| 135 | tls13_legacy_return_code(SSL *ssl, ssize_t ret) | 168 | tls13_legacy_return_code(SSL *ssl, ssize_t ret) |
| 136 | { | 169 | { |
| 137 | if (ret > INT_MAX) { | 170 | if (ret > INT_MAX) { |
| @@ -139,7 +172,7 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret) | |||
| 139 | return -1; | 172 | return -1; |
| 140 | } | 173 | } |
| 141 | 174 | ||
| 142 | /* A successful read or write. */ | 175 | /* A successful read, write or other operation. */ |
| 143 | if (ret > 0) | 176 | if (ret > 0) |
| 144 | return ret; | 177 | return ret; |
| 145 | 178 | ||
