1/*
2 * Copyright 2015-2024 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10/* clang-format off */
11
12/* clang-format on */
13
14#ifndef OPENSSL_COMP_H
15#define OPENSSL_COMP_H
16#pragma once
17
18#include <openssl/macros.h>
19#ifndef OPENSSL_NO_DEPRECATED_3_0
20#define HEADER_COMP_H
21#endif
22
23#include <openssl/opensslconf.h>
24
25#include <openssl/crypto.h>
26#include <openssl/comperr.h>
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#ifndef OPENSSL_NO_COMP
32
33COMP_CTX *COMP_CTX_new(COMP_METHOD *meth);
34const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx);
35int COMP_CTX_get_type(const COMP_CTX *comp);
36int COMP_get_type(const COMP_METHOD *meth);
37const char *COMP_get_name(const COMP_METHOD *meth);
38void COMP_CTX_free(COMP_CTX *ctx);
39
40int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen,
41 unsigned char *in, int ilen);
42int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen,
43 unsigned char *in, int ilen);
44
45COMP_METHOD *COMP_zlib(void);
46COMP_METHOD *COMP_zlib_oneshot(void);
47COMP_METHOD *COMP_brotli(void);
48COMP_METHOD *COMP_brotli_oneshot(void);
49COMP_METHOD *COMP_zstd(void);
50COMP_METHOD *COMP_zstd_oneshot(void);
51
52#ifndef OPENSSL_NO_DEPRECATED_1_1_0
53#define COMP_zlib_cleanup() \
54 while (0) \
55 continue
56#endif
57
58#ifdef OPENSSL_BIO_H
59const BIO_METHOD *BIO_f_zlib(void);
60const BIO_METHOD *BIO_f_brotli(void);
61const BIO_METHOD *BIO_f_zstd(void);
62#endif
63
64#endif
65
66typedef struct ssl_comp_st SSL_COMP;
67
68/* clang-format off */
69SKM_DEFINE_STACK_OF_INTERNAL(SSL_COMP, SSL_COMP, SSL_COMP)
70#define sk_SSL_COMP_num(sk) OPENSSL_sk_num(ossl_check_const_SSL_COMP_sk_type(sk))
71#define sk_SSL_COMP_value(sk, idx) ((SSL_COMP *)OPENSSL_sk_value(ossl_check_const_SSL_COMP_sk_type(sk), (idx)))
72#define sk_SSL_COMP_new(cmp) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new(ossl_check_SSL_COMP_compfunc_type(cmp)))
73#define sk_SSL_COMP_new_null() ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_null())
74#define sk_SSL_COMP_new_reserve(cmp, n) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_new_reserve(ossl_check_SSL_COMP_compfunc_type(cmp), (n)))
75#define sk_SSL_COMP_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_SSL_COMP_sk_type(sk), (n))
76#define sk_SSL_COMP_free(sk) OPENSSL_sk_free(ossl_check_SSL_COMP_sk_type(sk))
77#define sk_SSL_COMP_zero(sk) OPENSSL_sk_zero(ossl_check_SSL_COMP_sk_type(sk))
78#define sk_SSL_COMP_delete(sk, i) ((SSL_COMP *)OPENSSL_sk_delete(ossl_check_SSL_COMP_sk_type(sk), (i)))
79#define sk_SSL_COMP_delete_ptr(sk, ptr) ((SSL_COMP *)OPENSSL_sk_delete_ptr(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr)))
80#define sk_SSL_COMP_push(sk, ptr) OPENSSL_sk_push(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
81#define sk_SSL_COMP_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
82#define sk_SSL_COMP_pop(sk) ((SSL_COMP *)OPENSSL_sk_pop(ossl_check_SSL_COMP_sk_type(sk)))
83#define sk_SSL_COMP_shift(sk) ((SSL_COMP *)OPENSSL_sk_shift(ossl_check_SSL_COMP_sk_type(sk)))
84#define sk_SSL_COMP_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_freefunc_type(freefunc))
85#define sk_SSL_COMP_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), (idx))
86#define sk_SSL_COMP_set(sk, idx, ptr) ((SSL_COMP *)OPENSSL_sk_set(ossl_check_SSL_COMP_sk_type(sk), (idx), ossl_check_SSL_COMP_type(ptr)))
87#define sk_SSL_COMP_find(sk, ptr) OPENSSL_sk_find(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
88#define sk_SSL_COMP_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr))
89#define sk_SSL_COMP_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_type(ptr), pnum)
90#define sk_SSL_COMP_sort(sk) OPENSSL_sk_sort(ossl_check_SSL_COMP_sk_type(sk))
91#define sk_SSL_COMP_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_SSL_COMP_sk_type(sk))
92#define sk_SSL_COMP_dup(sk) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_dup(ossl_check_const_SSL_COMP_sk_type(sk)))
93#define sk_SSL_COMP_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(SSL_COMP) *)OPENSSL_sk_deep_copy(ossl_check_const_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_copyfunc_type(copyfunc), ossl_check_SSL_COMP_freefunc_type(freefunc)))
94#define sk_SSL_COMP_set_cmp_func(sk, cmp) ((sk_SSL_COMP_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_SSL_COMP_sk_type(sk), ossl_check_SSL_COMP_compfunc_type(cmp)))
95
96/* clang-format on */
97
98#ifdef __cplusplus
99}
100#endif
101#endif
102