lsquic_crt_compress.h revision a5fa05f9
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 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
135392f7a3SLiteSpeed Tech
1450aadb33SDmitri Tikhonovenum entry_type {
1550aadb33SDmitri Tikhonov    END_OF_LIST = 0,
1650aadb33SDmitri Tikhonov    ENTRY_COMPRESSED = 1,
1750aadb33SDmitri Tikhonov    ENTRY_CACHED = 2,
1850aadb33SDmitri Tikhonov    ENTRY_COMMON = 3,
1950aadb33SDmitri Tikhonov};
2050aadb33SDmitri Tikhonov
2150aadb33SDmitri Tikhonovtypedef struct cert_entry_st {
2250aadb33SDmitri Tikhonov    enum entry_type type;
2350aadb33SDmitri Tikhonov    uint32_t index;
2450aadb33SDmitri Tikhonov    uint64_t hash;
2550aadb33SDmitri Tikhonov    uint64_t set_hash;
2650aadb33SDmitri Tikhonov} cert_entry_t;
2750aadb33SDmitri Tikhonov
285392f7a3SLiteSpeed Tech
2950aadb33SDmitri Tikhonovtypedef struct common_cert_st
3050aadb33SDmitri Tikhonov{
3150aadb33SDmitri Tikhonov    size_t num_certs;
3250aadb33SDmitri Tikhonov    const unsigned char* const* certs;
3350aadb33SDmitri Tikhonov    const size_t* lens;
3450aadb33SDmitri Tikhonov    uint64_t hash;
3550aadb33SDmitri Tikhonov} common_cert_t;
3650aadb33SDmitri Tikhonov
37a5fa05f9SDmitri Tikhonovstruct lsquic_str * lsquic_get_common_certs_hash();
3850aadb33SDmitri Tikhonov
395392f7a3SLiteSpeed Tech
40a5fa05f9SDmitri Tikhonovint lsquic_get_common_cert(uint64_t hash, uint32_t index, struct lsquic_str *buf);
415392f7a3SLiteSpeed Tech
42a5fa05f9SDmitri Tikhonovint lsquic_compress_certs(struct lsquic_str **certs, size_t certs_count,
435392f7a3SLiteSpeed Tech                   struct lsquic_str *client_common_set_hashes,
445392f7a3SLiteSpeed Tech                   struct lsquic_str *client_cached_cert_hashes,
455392f7a3SLiteSpeed Tech                   struct lsquic_str *result);
465392f7a3SLiteSpeed Tech
47a5fa05f9SDmitri Tikhonovint lsquic_get_certs_count(struct lsquic_str *compressed_crt_buf);
48a5fa05f9SDmitri Tikhonovint lsquic_decompress_certs(const unsigned char *in, const unsigned char *in_end,
4950aadb33SDmitri Tikhonov                     struct lsquic_str *cached_certs, size_t cached_certs_count,
5050aadb33SDmitri Tikhonov                     struct lsquic_str **out_certs,
5150aadb33SDmitri Tikhonov                     size_t *out_certs_count);
5250aadb33SDmitri Tikhonov
5350aadb33SDmitri Tikhonovvoid
5450aadb33SDmitri Tikhonovlsquic_crt_cleanup (void);
5550aadb33SDmitri Tikhonov
565392f7a3SLiteSpeed Tech
5750aadb33SDmitri Tikhonov#ifdef __cplusplus
5850aadb33SDmitri Tikhonov}
5950aadb33SDmitri Tikhonov#endif
6050aadb33SDmitri Tikhonov
615392f7a3SLiteSpeed Tech
6250aadb33SDmitri Tikhonov#endif //__LSQUIC_CRT_COMPRESS_H__
63