2022-05-06 16:49:46 +00:00
|
|
|
/* Copyright (c) 2017 - 2022 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;
|
|
|
|
|
2020-10-01 12:53:35 +00:00
|
|
|
int
|
|
|
|
lsquic_crt_init (void);
|
|
|
|
|
2020-03-12 12:41:53 +00:00
|
|
|
struct lsquic_str * lsquic_get_common_certs_hash();
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2020-03-12 12:41:53 +00:00
|
|
|
int lsquic_get_common_cert(uint64_t hash, uint32_t index, struct lsquic_str *buf);
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2020-10-07 13:41:26 +00:00
|
|
|
struct compressed_cert
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
unsigned refcnt;
|
|
|
|
unsigned char buf[0]; /* len bytes */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Returns newly allocated structure or NULL on error */
|
|
|
|
struct compressed_cert *
|
|
|
|
lsquic_compress_certs(struct lsquic_str **certs, size_t certs_count,
|
2019-09-11 15:27:58 +00:00
|
|
|
struct lsquic_str *client_common_set_hashes,
|
2020-10-07 13:41:26 +00:00
|
|
|
struct lsquic_str *client_cached_cert_hashes);
|
|
|
|
|
|
|
|
int
|
|
|
|
lsquic_get_certs_count (const struct compressed_cert *);
|
2019-09-11 15:27:58 +00:00
|
|
|
|
2020-03-12 12:41:53 +00:00
|
|
|
int lsquic_decompress_certs(const unsigned char *in, const unsigned char *in_end,
|
2017-09-22 21:00:03 +00:00
|
|
|
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__
|