lsquic_crt_compress.h revision 2f4629f2
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
372f4629f2SDmitri Tikhonovint
382f4629f2SDmitri Tikhonovlsquic_crt_init (void);
392f4629f2SDmitri Tikhonov
40a5fa05f9SDmitri Tikhonovstruct lsquic_str * lsquic_get_common_certs_hash();
4150aadb33SDmitri Tikhonov
425392f7a3SLiteSpeed Tech
43a5fa05f9SDmitri Tikhonovint lsquic_get_common_cert(uint64_t hash, uint32_t index, struct lsquic_str *buf);
445392f7a3SLiteSpeed Tech
45a5fa05f9SDmitri Tikhonovint lsquic_compress_certs(struct lsquic_str **certs, size_t certs_count,
465392f7a3SLiteSpeed Tech                   struct lsquic_str *client_common_set_hashes,
475392f7a3SLiteSpeed Tech                   struct lsquic_str *client_cached_cert_hashes,
485392f7a3SLiteSpeed Tech                   struct lsquic_str *result);
495392f7a3SLiteSpeed Tech
50a5fa05f9SDmitri Tikhonovint lsquic_get_certs_count(struct lsquic_str *compressed_crt_buf);
51a5fa05f9SDmitri Tikhonovint lsquic_decompress_certs(const unsigned char *in, const unsigned char *in_end,
5250aadb33SDmitri Tikhonov                     struct lsquic_str *cached_certs, size_t cached_certs_count,
5350aadb33SDmitri Tikhonov                     struct lsquic_str **out_certs,
5450aadb33SDmitri Tikhonov                     size_t *out_certs_count);
5550aadb33SDmitri Tikhonov
5650aadb33SDmitri Tikhonovvoid
5750aadb33SDmitri Tikhonovlsquic_crt_cleanup (void);
5850aadb33SDmitri Tikhonov
595392f7a3SLiteSpeed Tech
6050aadb33SDmitri Tikhonov#ifdef __cplusplus
6150aadb33SDmitri Tikhonov}
6250aadb33SDmitri Tikhonov#endif
6350aadb33SDmitri Tikhonov
645392f7a3SLiteSpeed Tech
6550aadb33SDmitri Tikhonov#endif //__LSQUIC_CRT_COMPRESS_H__
66