2020-01-09 16:52:25 +00:00
|
|
|
/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */
|
2017-09-22 21:00:03 +00:00
|
|
|
#ifndef __LSQUIC_CRT_COMPRESS_H__
|
|
|
|
#define __LSQUIC_CRT_COMPRESS_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
struct lsquic_str;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
enum entry_type {
|
|
|
|
END_OF_LIST = 0,
|
|
|
|
ENTRY_COMPRESSED = 1,
|
|
|
|
ENTRY_CACHED = 2,
|
|
|
|
ENTRY_COMMON = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct cert_entry_st {
|
|
|
|
enum entry_type type;
|
|
|
|
uint32_t index;
|
|
|
|
uint64_t hash;
|
|
|
|
uint64_t set_hash;
|
|
|
|
} cert_entry_t;
|
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
typedef struct common_cert_st
|
|
|
|
{
|
|
|
|
size_t num_certs;
|
|
|
|
const unsigned char* const* certs;
|
|
|
|
const size_t* lens;
|
|
|
|
uint64_t hash;
|
|
|
|
} common_cert_t;
|
|
|
|
|
|
|
|
struct lsquic_str * get_common_certs_hash();
|
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
|
|
|
|
int get_common_cert(uint64_t hash, uint32_t index, struct lsquic_str *buf);
|
|
|
|
int match_common_cert(struct lsquic_str * cert, struct lsquic_str * common_set_hashes,
|
|
|
|
uint64_t* out_hash, uint32_t* out_index);
|
|
|
|
|
|
|
|
int compress_certs(struct lsquic_str **certs, size_t certs_count,
|
|
|
|
struct lsquic_str *client_common_set_hashes,
|
|
|
|
struct lsquic_str *client_cached_cert_hashes,
|
|
|
|
struct lsquic_str *result);
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
int get_certs_count(struct lsquic_str *compressed_crt_buf);
|
|
|
|
int decompress_certs(const unsigned char *in, const unsigned char *in_end,
|
|
|
|
struct lsquic_str *cached_certs, size_t cached_certs_count,
|
|
|
|
struct lsquic_str **out_certs,
|
|
|
|
size_t *out_certs_count);
|
|
|
|
|
|
|
|
void
|
|
|
|
lsquic_crt_cleanup (void);
|
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
#endif //__LSQUIC_CRT_COMPRESS_H__
|