summaryrefslogtreecommitdiffstats
path: root/apps/enc.c
diff options
context:
space:
mode:
authorTodd Short <tshort@akamai.com>2021-08-09 16:56:37 -0400
committerTodd Short <todd.short@me.com>2022-10-18 09:30:21 -0400
commitcaf9317d7d75213990014e07048384be15688889 (patch)
tree50cf59d363c17f389d6c8dbc2372795e3e53658d /apps/enc.c
parent12e96a23604a7aa1cd8f83486b02f1bcab6d468f (diff)
Add ZSTD compression support (RFC8478bis)
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18186)
Diffstat (limited to 'apps/enc.c')
-rw-r--r--apps/enc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/enc.c b/apps/enc.c
index 4da2342791..cbeaeaa8aa 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -136,6 +136,8 @@ int enc_main(int argc, char **argv)
#endif
int do_brotli = 0;
BIO *bbrot = NULL;
+ int do_zstd = 0;
+ BIO *bzstd = NULL;
/* first check the command name */
if (strcmp(argv[0], "base64") == 0)
@@ -148,6 +150,10 @@ int enc_main(int argc, char **argv)
else if (strcmp(argv[0], "brotli") == 0)
do_brotli = 1;
#endif
+#ifndef OPENSSL_NO_ZSTD
+ else if (strcmp(argv[0], "zstd") == 0)
+ do_zstd = 1;
+#endif
else if (strcmp(argv[0], "enc") != 0)
ciphername = argv[0];
@@ -332,6 +338,8 @@ int enc_main(int argc, char **argv)
#endif
if (do_brotli)
base64 = 0;
+ if (do_zstd)
+ base64 = 0;
if (base64) {
if (enc)
@@ -436,6 +444,19 @@ int enc_main(int argc, char **argv)
else
rbio = BIO_push(bbrot, rbio);
}
+
+ if (do_zstd) {
+ if ((bzstd = BIO_new(BIO_f_zstd())) == NULL)
+ goto end;
+ if (debug) {
+ BIO_set_callback_ex(bzstd, BIO_debug_callback_ex);
+ BIO_set_callback_arg(bzstd, (char *)bio_err);
+ }
+ if (enc)
+ wbio = BIO_push(bzstd, wbio);
+ else
+ rbio = BIO_push(bzstd, rbio);
+ }
#endif
if (base64) {
@@ -682,6 +703,7 @@ int enc_main(int argc, char **argv)
BIO_free(bzl);
#endif
BIO_free(bbrot);
+ BIO_free(bzstd);
release_engine(e);
OPENSSL_free(pass);
return ret;