lsquic_crt_compress.h revision 5392f7a3
1/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc. See LICENSE. */ 2#ifndef __LSQUIC_CRT_COMPRESS_H__ 3#define __LSQUIC_CRT_COMPRESS_H__ 4 5#include <stdint.h> 6 7struct lsquic_str; 8 9#ifdef __cplusplus 10extern "C" { 11#endif 12 13 14enum entry_type { 15 END_OF_LIST = 0, 16 ENTRY_COMPRESSED = 1, 17 ENTRY_CACHED = 2, 18 ENTRY_COMMON = 3, 19}; 20 21typedef struct cert_entry_st { 22 enum entry_type type; 23 uint32_t index; 24 uint64_t hash; 25 uint64_t set_hash; 26} cert_entry_t; 27 28 29typedef struct common_cert_st 30{ 31 size_t num_certs; 32 const unsigned char* const* certs; 33 const size_t* lens; 34 uint64_t hash; 35} common_cert_t; 36 37struct lsquic_str * get_common_certs_hash(); 38 39 40int get_common_cert(uint64_t hash, uint32_t index, struct lsquic_str *buf); 41int match_common_cert(struct lsquic_str * cert, struct lsquic_str * common_set_hashes, 42 uint64_t* out_hash, uint32_t* out_index); 43 44int compress_certs(struct lsquic_str **certs, size_t certs_count, 45 struct lsquic_str *client_common_set_hashes, 46 struct lsquic_str *client_cached_cert_hashes, 47 struct lsquic_str *result); 48 49int get_certs_count(struct lsquic_str *compressed_crt_buf); 50int decompress_certs(const unsigned char *in, const unsigned char *in_end, 51 struct lsquic_str *cached_certs, size_t cached_certs_count, 52 struct lsquic_str **out_certs, 53 size_t *out_certs_count); 54 55void 56lsquic_crt_cleanup (void); 57 58 59#ifdef __cplusplus 60} 61#endif 62 63 64#endif //__LSQUIC_CRT_COMPRESS_H__ 65