2 #define TLS_BUFFER_H_ 1
9 * 0x1 secure: zero memory when used
10 * 0x2 fixed: buffer doesn't belong to you, and size says how big it is
21 struct tls_buffer_reader {
26 uint32_t tls_buffer_next3(struct tls_buffer_reader *rb);
27 uint16_t tls_buffer_next2(struct tls_buffer_reader *rb);
28 uint8_t tls_buffer_next(struct tls_buffer_reader *rb);
29 void tls_buffer_nextn(struct tls_buffer_reader *rb, unsigned char *b, size_t n);
31 void tls_buffer_init(struct tls_buffer *b, size_t initial);
33 /* makes sure there's at least need bytes free */
34 void tls_buffer_expand(struct tls_buffer *b, size_t need);
35 void tls_buffer_free(struct tls_buffer *b);
36 void tls_buffer_set(struct tls_buffer *buffer, int ch);
37 void tls_buffer_compact(struct tls_buffer *b);
38 void tls_buffer_append(struct tls_buffer *b, const unsigned char *bytes, size_t n);
39 void tls_buffer_append16(struct tls_buffer *b, uint16_t n);
40 void tls_buffer_append24(struct tls_buffer *b, uint32_t n);
41 void tls_buffer_append_byte(struct tls_buffer *b, uint8_t n);
42 void tls_buffer_shift(struct tls_buffer *b, size_t n);
43 void tls_buffer_write16(struct tls_buffer *b, uint16_t n, size_t at);
44 void tls_buffer_writebe(struct tls_buffer *b, int bytes, size_t at, uint64_t val);
45 uint64_t tls_buffer_readbe(struct tls_buffer *b, int bytes, size_t at);
47 /* make room at the beginning */
48 void tls_buffer_unshift(struct tls_buffer *b, size_t n);