/**
 * 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
