lsquic_crt_compress.h revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov#ifndef __LSQUIC_CRT_COMPRESS_H__
350aadb33SDmitri Tikhonov#define __LSQUIC_CRT_COMPRESS_H__
450aadb33SDmitri Tikhonov
550aadb33SDmitri Tikhonov#include <stdint.h>
650aadb33SDmitri Tikhonov
750aadb33SDmitri Tikhonovstruct lsquic_str;
850aadb33SDmitri Tikhonov
950aadb33SDmitri Tikhonov#ifdef __cplusplus
1050aadb33SDmitri Tikhonovextern "C" {
1150aadb33SDmitri Tikhonov#endif
1250aadb33SDmitri Tikhonov
1350aadb33SDmitri Tikhonovenum entry_type {
1450aadb33SDmitri Tikhonov    END_OF_LIST = 0,
1550aadb33SDmitri Tikhonov    ENTRY_COMPRESSED = 1,
1650aadb33SDmitri Tikhonov    ENTRY_CACHED = 2,
1750aadb33SDmitri Tikhonov    ENTRY_COMMON = 3,
1850aadb33SDmitri Tikhonov};
1950aadb33SDmitri Tikhonov
2050aadb33SDmitri Tikhonovtypedef struct cert_entry_st {
2150aadb33SDmitri Tikhonov    enum entry_type type;
2250aadb33SDmitri Tikhonov    uint32_t index;
2350aadb33SDmitri Tikhonov    uint64_t hash;
2450aadb33SDmitri Tikhonov    uint64_t set_hash;
2550aadb33SDmitri Tikhonov} cert_entry_t;
2650aadb33SDmitri Tikhonov
2750aadb33SDmitri Tikhonovtypedef struct common_cert_st
2850aadb33SDmitri Tikhonov{
2950aadb33SDmitri Tikhonov    size_t num_certs;
3050aadb33SDmitri Tikhonov    const unsigned char* const* certs;
3150aadb33SDmitri Tikhonov    const size_t* lens;
3250aadb33SDmitri Tikhonov    uint64_t hash;
3350aadb33SDmitri Tikhonov} common_cert_t;
3450aadb33SDmitri Tikhonov
3550aadb33SDmitri Tikhonovstruct lsquic_str * get_common_certs_hash();
3650aadb33SDmitri Tikhonov
3750aadb33SDmitri Tikhonovint get_certs_count(struct lsquic_str *compressed_crt_buf);
3850aadb33SDmitri Tikhonovint decompress_certs(const unsigned char *in, const unsigned char *in_end,
3950aadb33SDmitri Tikhonov                     struct lsquic_str *cached_certs, size_t cached_certs_count,
4050aadb33SDmitri Tikhonov                     struct lsquic_str **out_certs,
4150aadb33SDmitri Tikhonov                     size_t *out_certs_count);
4250aadb33SDmitri Tikhonov
4350aadb33SDmitri Tikhonovvoid
4450aadb33SDmitri Tikhonovlsquic_crt_cleanup (void);
4550aadb33SDmitri Tikhonov
4650aadb33SDmitri Tikhonov#ifdef __cplusplus
4750aadb33SDmitri Tikhonov}
4850aadb33SDmitri Tikhonov#endif
4950aadb33SDmitri Tikhonov
5050aadb33SDmitri Tikhonov#endif //__LSQUIC_CRT_COMPRESS_H__
51