diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2019-01-21 13:45:58 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2019-01-21 13:45:58 +0000 |
commit | 60bbdcb85a3f5d62f272f34886d323f2197d9e72 (patch) | |
tree | f125bda090b1d3c84fc8367369062e13f8450992 /lib/libssl/tls13_lib.c | |
parent | 44d2bf3b4bd98b62d4c9f6363bf0e0034a9ad3c8 (diff) |
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 'lib/libssl/tls13_lib.c')
-rw-r--r-- | lib/libssl/tls13_lib.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/lib/libssl/tls13_lib.c b/lib/libssl/tls13_lib.c index c4cce26ca53..3860ddefef6 100644 --- a/lib/libssl/tls13_lib.c +++ b/lib/libssl/tls13_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_lib.c,v 1.2 2019/01/21 10:24:25 jsing Exp $ */ +/* $OpenBSD: tls13_lib.c,v 1.3 2019/01/21 13:45:57 jsing Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> * @@ -61,6 +61,39 @@ tls13_cipher_hash(const SSL_CIPHER *cipher) return NULL; } +struct tls13_ctx * +tls13_ctx_new(int mode) +{ + struct tls13_ctx *ctx = NULL; + + if ((ctx = calloc(sizeof(struct tls13_ctx), 1)) == NULL) + goto err; + + ctx->mode = mode; + + if ((ctx->rl = tls13_record_layer_new(tls13_legacy_wire_read_cb, + tls13_legacy_wire_write_cb, NULL, NULL, ctx)) == NULL) + goto err; + + return ctx; + + err: + tls13_ctx_free(ctx); + + return NULL; +} + +void +tls13_ctx_free(struct tls13_ctx *ctx) +{ + if (ctx == NULL) + return; + + tls13_record_layer_free(ctx->rl); + + freezero(ctx, sizeof(struct tls13_ctx)); +} + static ssize_t tls13_legacy_wire_read(SSL *ssl, uint8_t *buf, size_t len) { @@ -131,7 +164,7 @@ tls13_legacy_wire_write_cb(const void *buf, size_t n, void *arg) return tls13_legacy_wire_write(ctx->ssl, buf, n); } -static int +int tls13_legacy_return_code(SSL *ssl, ssize_t ret) { if (ret > INT_MAX) { @@ -139,7 +172,7 @@ tls13_legacy_return_code(SSL *ssl, ssize_t ret) return -1; } - /* A successful read or write. */ + /* A successful read, write or other operation. */ if (ret > 0) return ret; |