1/* $OpenBSD: tls_content.h,v 1.2 2022/11/11 17:15:27 jsing Exp $ */
2/*
3 * Copyright (c) 2020 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_CONTENT_H
19#define HEADER_TLS_CONTENT_H
20
21#include "bytestring.h"
22
23__BEGIN_HIDDEN_DECLS
24
25struct tls_content;
26
27struct tls_content *tls_content_new(void);
28void tls_content_clear(struct tls_content *content);
29void tls_content_free(struct tls_content *content);
30
31CBS *tls_content_cbs(struct tls_content *content);
32int tls_content_equal(struct tls_content *content, const uint8_t *buf, size_t n);
33size_t tls_content_remaining(struct tls_content *content);
34uint8_t tls_content_type(struct tls_content *content);
35uint16_t tls_content_epoch(struct tls_content *content);
36
37int tls_content_dup_data(struct tls_content *content, uint8_t type,
38    const uint8_t *data, size_t data_len);
39void tls_content_set_data(struct tls_content *content, uint8_t type,
40    const uint8_t *data, size_t data_len);
41int tls_content_set_bounds(struct tls_content *content, size_t offset,
42    size_t len);
43void tls_content_set_epoch(struct tls_content *content, uint16_t epoch);
44
45ssize_t tls_content_peek(struct tls_content *content, uint8_t *buf, size_t n);
46ssize_t tls_content_read(struct tls_content *content, uint8_t *buf, size_t n);
47
48__END_HIDDEN_DECLS
49
50#endif
51