summaryrefslogtreecommitdiff
path: root/src/utils.h
blob: 58c89558983b82867e4a44df724597049913adc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * utils.h
 *
 * Created on 2020-11-27
 * @author: qyc
 *
 * @explain: 
 */
#ifndef UTILS_H
#define UTILS_H

#ifdef __cplusplus
extern "C" {
#endif

#include "glib.h"

/*
 * Decodes a variable-length integer used in QUIC protocol
 * See https://tools.ietf.org/html/draft-ietf-quic-transport-08#section-8.1
 */
#define ENC_VARINT_QUIC	0x00000004

/* Explicit and implicit nonce length (RFC 5116 - Section 3.2.1) */
#define TLS13_AEAD_NONCE_LENGTH	12


/* XXX Should we use GByteArray instead? */
typedef struct _StringInfo {
	// Backing storage which may be larger than data_len
	guchar *data;
	// Length of the meaningful part of data
	guint data_len;
} StringInfo;

gboolean tls13_hkdf_expand_label(int md, const StringInfo *secret, const char *label_prefix, const char *label, guint16 out_len, guchar **out);
guint tvb_get_varint(const char *tvb, guint offset, guint maxlen, guint64 *value, const guint encoding);

#ifdef __cplusplus
}
#endif

#endif //UTILS_H