1 /* $OpenBSD: tls_content.h,v 1.1 2021/09/04 16:26:12 jsing Exp $ */
3 * Copyright (c) 2020 Joel Sing <jsing@openbsd.org>
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.
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.
18 #ifndef HEADER_TLS_CONTENT_H
19 #define HEADER_TLS_CONTENT_H
21 #include "bytestring.h"
27 struct tls_content
*tls_content_new(void);
28 void tls_content_clear(struct tls_content
*content
);
29 void tls_content_free(struct tls_content
*content
);
31 CBS
*tls_content_cbs(struct tls_content
*content
);
32 int tls_content_equal(struct tls_content
*content
, const uint8_t *buf
, size_t n
);
33 size_t tls_content_remaining(struct tls_content
*content
);
34 uint8_t tls_content_type(struct tls_content
*content
);
35 uint16_t tls_content_epoch(struct tls_content
*content
);
37 int tls_content_dup_data(struct tls_content
*content
, uint8_t type
,
38 const uint8_t *data
, size_t data_len
);
39 void tls_content_set_data(struct tls_content
*content
, uint8_t type
,
40 const uint8_t *data
, size_t data_len
);
41 void tls_content_set_epoch(struct tls_content
*content
, uint16_t epoch
);
43 ssize_t
tls_content_peek(struct tls_content
*content
, uint8_t *buf
, size_t n
);
44 ssize_t
tls_content_read(struct tls_content
*content
, uint8_t *buf
, size_t n
);