summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls.h
diff options
context:
space:
mode:
authorjsing <>2014-10-31 13:46:17 +0000
committerjsing <>2014-10-31 13:46:17 +0000
commitcd85e00508e178758948e7a759609d0f1e7764df (patch)
tree44ea21a19ccf529a3e38fb107d3a2d1330f58d8e /src/lib/libtls/tls.h
parente83bdb8edcd9388f13b71372b277fdcce386a9b0 (diff)
downloadopenbsd-cd85e00508e178758948e7a759609d0f1e7764df.tar.gz
openbsd-cd85e00508e178758948e7a759609d0f1e7764df.tar.bz2
openbsd-cd85e00508e178758948e7a759609d0f1e7764df.zip
Rename libressl to libtls to avoid confusion and to make it easier to
distinguish between LibreSSL (the project) and libressl (the library). Discussed with many.
Diffstat (limited to 'src/lib/libtls/tls.h')
-rw-r--r--src/lib/libtls/tls.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/lib/libtls/tls.h b/src/lib/libtls/tls.h
new file mode 100644
index 0000000000..0fa776e584
--- /dev/null
+++ b/src/lib/libtls/tls.h
@@ -0,0 +1,74 @@
1/* $OpenBSD: tls.h,v 1.1 2014/10/31 13:46:17 jsing Exp $ */
2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef HEADER_TLS_H
19#define HEADER_TLS_H
20
21#define TLS_API 20141031
22
23#define TLS_PROTOCOL_TLSv1_0 (1 << 1)
24#define TLS_PROTOCOL_TLSv1_1 (1 << 2)
25#define TLS_PROTOCOL_TLSv1_2 (1 << 3)
26#define TLS_PROTOCOL_TLSv1 \
27 (TLS_PROTOCOL_TLSv1_0|TLS_PROTOCOL_TLSv1_1|TLS_PROTOCOL_TLSv1_2)
28#define TLS_PROTOCOLS_DEFAULT TLS_PROTOCOL_TLSv1
29
30#define TLS_READ_AGAIN -2
31#define TLS_WRITE_AGAIN -3
32
33struct tls;
34struct tls_config;
35
36int tls_init(void);
37
38const char *tls_error(struct tls *ctx);
39
40struct tls_config *tls_config_new(void);
41void tls_config_free(struct tls_config *config);
42
43int tls_config_set_ca_file(struct tls_config *config, const char *ca_file);
44int tls_config_set_ca_path(struct tls_config *config, const char *ca_path);
45int tls_config_set_cert_file(struct tls_config *config, const char *cert_file);
46int tls_config_set_cert_mem(struct tls_config *config, const uint8_t *cert,
47 size_t len);
48int tls_config_set_ciphers(struct tls_config *config, const char *ciphers);
49int tls_config_set_ecdhcurve(struct tls_config *config, const char *name);
50int tls_config_set_key_file(struct tls_config *config, const char *key_file);
51int tls_config_set_key_mem(struct tls_config *config, const uint8_t *key,
52 size_t len);
53void tls_config_set_protocols(struct tls_config *config, uint32_t protocols);
54void tls_config_set_verify_depth(struct tls_config *config, int verify_depth);
55
56void tls_config_clear_keys(struct tls_config *config);
57void tls_config_insecure_noverifyhost(struct tls_config *config);
58void tls_config_insecure_noverifycert(struct tls_config *config);
59void tls_config_verify(struct tls_config *config);
60
61struct tls *tls_client(void);
62struct tls *tls_server(void);
63int tls_configure(struct tls *ctx, struct tls_config *config);
64void tls_reset(struct tls *ctx);
65void tls_free(struct tls *ctx);
66
67int tls_accept_socket(struct tls *ctx, struct tls **cctx, int socket);
68int tls_connect(struct tls *ctx, const char *host, const char *port);
69int tls_connect_socket(struct tls *ctx, int s, const char *hostname);
70int tls_read(struct tls *ctx, void *buf, size_t buflen, size_t *outlen);
71int tls_write(struct tls *ctx, const void *buf, size_t buflen, size_t *outlen);
72int tls_close(struct tls *ctx);
73
74#endif /* HEADER_TLS_H */