lsquic_crt_compress.h revision 2f4629f2
1/* Copyright (c) 2017 - 2020 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 37int 38lsquic_crt_init (void); 39 40struct lsquic_str * lsquic_get_common_certs_hash(); 41 42 43int lsquic_get_common_cert(uint64_t hash, uint32_t index, struct lsquic_str *buf); 44 45int lsquic_compress_certs(struct lsquic_str **certs, size_t certs_count, 46 struct lsquic_str *client_common_set_hashes, 47 struct lsquic_str *client_cached_cert_hashes, 48 struct lsquic_str *result); 49 50int lsquic_get_certs_count(struct lsquic_str *compressed_crt_buf); 51int lsquic_decompress_certs(const unsigned char *in, const unsigned char *in_end, 52 struct lsquic_str *cached_certs, size_t cached_certs_count, 53 struct lsquic_str **out_certs, 54 size_t *out_certs_count); 55 56void 57lsquic_crt_cleanup (void); 58 59 60#ifdef __cplusplus 61} 62#endif 63 64 65#endif //__LSQUIC_CRT_COMPRESS_H__ 66