summaryrefslogtreecommitdiff
path: root/selftest
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2022-11-17 14:24:52 +1300
committerJoseph Sutton <jsutton@samba.org>2022-12-01 22:56:39 +0000
commitf86035c65bf4ae41a2c210dbff132dbce499f03c (patch)
tree357a873b7ffc81b5ce58b44dff99c4dbf2e76625 /selftest
parentbd35feaf7ed649968465a2643b42982d3e6f3d56 (diff)
downloadsamba-f86035c65bf4ae41a2c210dbff132dbce499f03c.tar.gz
lib/compression: add LZ77 + Huffman decompression
This format is described in [MS-XCA] 2.1 and 2.2, with exegesis in many posts on the cifs-protocol list[1]. The two public functions are: ssize_t lzxpress_huffman_decompress(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size); uint8_t *lzxpress_huffman_decompress_talloc(TALLOC_CTX *mem_ctx, const uint8_t *input_bytes, size_t input_size, size_t output_size); In both cases the caller needs to know the *exact* decompressed size, which is essential for decompression. The _talloc version allocates the buffer for you, and uses the talloc context to allocate a 128k working buffer. THe non-talloc function will allocate the working buffer on the stack. This compression format gives better compression for messages of several kilobytes than the "plain" LXZPRESS compression, but is probably a bit slower to decompress and is certainly worse for very short messages, having a fixed 256 byte overhead for the first Huffman table. Experiments show decompression rates between 20 and 500 MB per second, depending on the compression ratio and data size, on an i5-1135G7 with no compiler optimisations. This compression format is used in AD claims and in SMB, but that doesn't happen with this commit. I will not try to describe LZ77 or Huffman encoding here. Don't expect an answer in MS-XCA either; instead read the code and/or Wikipedia. [1] Much of that starts here: https://lists.samba.org/archive/cifs-protocol/2022-October/ but there's more earlier, particularly in June/July 2020, when Aurélien Aptel was working on an implementation that ended up in Wireshark. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Pair-programmed-with: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'selftest')
-rw-r--r--selftest/tests.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/selftest/tests.py b/selftest/tests.py
index 4cc2e7f8918..c774f18af3e 100644
--- a/selftest/tests.py
+++ b/selftest/tests.py
@@ -478,3 +478,6 @@ plantestsuite("samba.unittests.gnutls_aead_aes_256_cbc_hmac_sha512", "none",
[os.path.join(bindir(), "test_gnutls_aead_aes_256_cbc_hmac_sha512")])
plantestsuite("samba.unittests.encode_decode", "none",
[os.path.join(bindir(), "test_encode_decode")])
+
+plantestsuite("samba.unittests.compression.lzxpress_huffman", "none",
+ [os.path.join(bindir(), "default/lib/compression/test_lzx_huffman")])