diff options
-rw-r--r-- | crypto/lz4.c | 23 | ||||
-rw-r--r-- | crypto/lz4hc.c | 23 | ||||
-rw-r--r-- | crypto/testmgr.h | 142 |
3 files changed, 120 insertions, 68 deletions
diff --git a/crypto/lz4.c b/crypto/lz4.c index 99c1b2cc2976..71eff9b01b12 100644 --- a/crypto/lz4.c +++ b/crypto/lz4.c | |||
@@ -66,15 +66,13 @@ static void lz4_exit(struct crypto_tfm *tfm) | |||
66 | static int __lz4_compress_crypto(const u8 *src, unsigned int slen, | 66 | static int __lz4_compress_crypto(const u8 *src, unsigned int slen, |
67 | u8 *dst, unsigned int *dlen, void *ctx) | 67 | u8 *dst, unsigned int *dlen, void *ctx) |
68 | { | 68 | { |
69 | size_t tmp_len = *dlen; | 69 | int out_len = LZ4_compress_default(src, dst, |
70 | int err; | 70 | slen, *dlen, ctx); |
71 | 71 | ||
72 | err = lz4_compress(src, slen, dst, &tmp_len, ctx); | 72 | if (!out_len) |
73 | |||
74 | if (err < 0) | ||
75 | return -EINVAL; | 73 | return -EINVAL; |
76 | 74 | ||
77 | *dlen = tmp_len; | 75 | *dlen = out_len; |
78 | return 0; | 76 | return 0; |
79 | } | 77 | } |
80 | 78 | ||
@@ -96,16 +94,13 @@ static int lz4_compress_crypto(struct crypto_tfm *tfm, const u8 *src, | |||
96 | static int __lz4_decompress_crypto(const u8 *src, unsigned int slen, | 94 | static int __lz4_decompress_crypto(const u8 *src, unsigned int slen, |
97 | u8 *dst, unsigned int *dlen, void *ctx) | 95 | u8 *dst, unsigned int *dlen, void *ctx) |
98 | { | 96 | { |
99 | int err; | 97 | int out_len = LZ4_decompress_safe(src, dst, slen, *dlen); |
100 | size_t tmp_len = *dlen; | ||
101 | size_t __slen = slen; | ||
102 | 98 | ||
103 | err = lz4_decompress_unknownoutputsize(src, __slen, dst, &tmp_len); | 99 | if (out_len < 0) |
104 | if (err < 0) | 100 | return out_len; |
105 | return -EINVAL; | ||
106 | 101 | ||
107 | *dlen = tmp_len; | 102 | *dlen = out_len; |
108 | return err; | 103 | return 0; |
109 | } | 104 | } |
110 | 105 | ||
111 | static int lz4_sdecompress(struct crypto_scomp *tfm, const u8 *src, | 106 | static int lz4_sdecompress(struct crypto_scomp *tfm, const u8 *src, |
diff --git a/crypto/lz4hc.c b/crypto/lz4hc.c index 75ffc4a3f786..03a34a8109c0 100644 --- a/crypto/lz4hc.c +++ b/crypto/lz4hc.c | |||
@@ -65,15 +65,13 @@ static void lz4hc_exit(struct crypto_tfm *tfm) | |||
65 | static int __lz4hc_compress_crypto(const u8 *src, unsigned int slen, | 65 | static int __lz4hc_compress_crypto(const u8 *src, unsigned int slen, |
66 | u8 *dst, unsigned int *dlen, void *ctx) | 66 | u8 *dst, unsigned int *dlen, void *ctx) |
67 | { | 67 | { |
68 | size_t tmp_len = *dlen; | 68 | int out_len = LZ4_compress_HC(src, dst, slen, |
69 | int err; | 69 | *dlen, LZ4HC_DEFAULT_CLEVEL, ctx); |
70 | 70 | ||
71 | err = lz4hc_compress(src, slen, dst, &tmp_len, ctx); | 71 | if (!out_len) |
72 | |||
73 | if (err < 0) | ||
74 | return -EINVAL; | 72 | return -EINVAL; |
75 | 73 | ||
76 | *dlen = tmp_len; | 74 | *dlen = out_len; |
77 | return 0; | 75 | return 0; |
78 | } | 76 | } |
79 | 77 | ||
@@ -97,16 +95,13 @@ static int lz4hc_compress_crypto(struct crypto_tfm *tfm, const u8 *src, | |||
97 | static int __lz4hc_decompress_crypto(const u8 *src, unsigned int slen, | 95 | static int __lz4hc_decompress_crypto(const u8 *src, unsigned int slen, |
98 | u8 *dst, unsigned int *dlen, void *ctx) | 96 | u8 *dst, unsigned int *dlen, void *ctx) |
99 | { | 97 | { |
100 | int err; | 98 | int out_len = LZ4_decompress_safe(src, dst, slen, *dlen); |
101 | size_t tmp_len = *dlen; | ||
102 | size_t __slen = slen; | ||
103 | 99 | ||
104 | err = lz4_decompress_unknownoutputsize(src, __slen, dst, &tmp_len); | 100 | if (out_len < 0) |
105 | if (err < 0) | 101 | return out_len; |
106 | return -EINVAL; | ||
107 | 102 | ||
108 | *dlen = tmp_len; | 103 | *dlen = out_len; |
109 | return err; | 104 | return 0; |
110 | } | 105 | } |
111 | 106 | ||
112 | static int lz4hc_sdecompress(struct crypto_scomp *tfm, const u8 *src, | 107 | static int lz4hc_sdecompress(struct crypto_scomp *tfm, const u8 *src, |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index f85e51cf7dcc..006ecc434351 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
@@ -34293,61 +34293,123 @@ static struct hash_testvec bfin_crc_tv_template[] = { | |||
34293 | 34293 | ||
34294 | static struct comp_testvec lz4_comp_tv_template[] = { | 34294 | static struct comp_testvec lz4_comp_tv_template[] = { |
34295 | { | 34295 | { |
34296 | .inlen = 70, | 34296 | .inlen = 255, |
34297 | .outlen = 45, | 34297 | .outlen = 218, |
34298 | .input = "Join us now and share the software " | 34298 | .input = "LZ4 is lossless compression algorithm, providing" |
34299 | "Join us now and share the software ", | 34299 | " compression speed at 400 MB/s per core, scalable " |
34300 | .output = "\xf0\x10\x4a\x6f\x69\x6e\x20\x75" | 34300 | "with multi-cores CPU. It features an extremely fast " |
34301 | "\x73\x20\x6e\x6f\x77\x20\x61\x6e" | 34301 | "decoder, with speed in multiple GB/s per core, " |
34302 | "\x64\x20\x73\x68\x61\x72\x65\x20" | 34302 | "typically reaching RAM speed limits on multi-core " |
34303 | "\x74\x68\x65\x20\x73\x6f\x66\x74" | 34303 | "systems.", |
34304 | "\x77\x0d\x00\x0f\x23\x00\x0b\x50" | 34304 | .output = "\xf9\x21\x4c\x5a\x34\x20\x69\x73\x20\x6c\x6f\x73\x73" |
34305 | "\x77\x61\x72\x65\x20", | 34305 | "\x6c\x65\x73\x73\x20\x63\x6f\x6d\x70\x72\x65\x73\x73" |
34306 | "\x69\x6f\x6e\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d" | ||
34307 | "\x2c\x20\x70\x72\x6f\x76\x69\x64\x69\x6e\x67\x21\x00" | ||
34308 | "\xf0\x21\x73\x70\x65\x65\x64\x20\x61\x74\x20\x34\x30" | ||
34309 | "\x30\x20\x4d\x42\x2f\x73\x20\x70\x65\x72\x20\x63\x6f" | ||
34310 | "\x72\x65\x2c\x20\x73\x63\x61\x6c\x61\x62\x6c\x65\x20" | ||
34311 | "\x77\x69\x74\x68\x20\x6d\x75\x6c\x74\x69\x2d\x1a\x00" | ||
34312 | "\xf0\x00\x73\x20\x43\x50\x55\x2e\x20\x49\x74\x20\x66" | ||
34313 | "\x65\x61\x74\x75\x11\x00\xf2\x0b\x61\x6e\x20\x65\x78" | ||
34314 | "\x74\x72\x65\x6d\x65\x6c\x79\x20\x66\x61\x73\x74\x20" | ||
34315 | "\x64\x65\x63\x6f\x64\x65\x72\x2c\x3d\x00\x02\x67\x00" | ||
34316 | "\x22\x69\x6e\x46\x00\x5a\x70\x6c\x65\x20\x47\x6c\x00" | ||
34317 | "\xf0\x00\x74\x79\x70\x69\x63\x61\x6c\x6c\x79\x20\x72" | ||
34318 | "\x65\x61\x63\x68\xa7\x00\x33\x52\x41\x4d\x38\x00\x83" | ||
34319 | "\x6c\x69\x6d\x69\x74\x73\x20\x6f\x3f\x00\x01\x85\x00" | ||
34320 | "\x90\x20\x73\x79\x73\x74\x65\x6d\x73\x2e", | ||
34321 | |||
34306 | }, | 34322 | }, |
34307 | }; | 34323 | }; |
34308 | 34324 | ||
34309 | static struct comp_testvec lz4_decomp_tv_template[] = { | 34325 | static struct comp_testvec lz4_decomp_tv_template[] = { |
34310 | { | 34326 | { |
34311 | .inlen = 45, | 34327 | .inlen = 218, |
34312 | .outlen = 70, | 34328 | .outlen = 255, |
34313 | .input = "\xf0\x10\x4a\x6f\x69\x6e\x20\x75" | 34329 | .input = "\xf9\x21\x4c\x5a\x34\x20\x69\x73\x20\x6c\x6f\x73\x73" |
34314 | "\x73\x20\x6e\x6f\x77\x20\x61\x6e" | 34330 | "\x6c\x65\x73\x73\x20\x63\x6f\x6d\x70\x72\x65\x73\x73" |
34315 | "\x64\x20\x73\x68\x61\x72\x65\x20" | 34331 | "\x69\x6f\x6e\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d" |
34316 | "\x74\x68\x65\x20\x73\x6f\x66\x74" | 34332 | "\x2c\x20\x70\x72\x6f\x76\x69\x64\x69\x6e\x67\x21\x00" |
34317 | "\x77\x0d\x00\x0f\x23\x00\x0b\x50" | 34333 | "\xf0\x21\x73\x70\x65\x65\x64\x20\x61\x74\x20\x34\x30" |
34318 | "\x77\x61\x72\x65\x20", | 34334 | "\x30\x20\x4d\x42\x2f\x73\x20\x70\x65\x72\x20\x63\x6f" |
34319 | .output = "Join us now and share the software " | 34335 | "\x72\x65\x2c\x20\x73\x63\x61\x6c\x61\x62\x6c\x65\x20" |
34320 | "Join us now and share the software ", | 34336 | "\x77\x69\x74\x68\x20\x6d\x75\x6c\x74\x69\x2d\x1a\x00" |
34337 | "\xf0\x00\x73\x20\x43\x50\x55\x2e\x20\x49\x74\x20\x66" | ||
34338 | "\x65\x61\x74\x75\x11\x00\xf2\x0b\x61\x6e\x20\x65\x78" | ||
34339 | "\x74\x72\x65\x6d\x65\x6c\x79\x20\x66\x61\x73\x74\x20" | ||
34340 | "\x64\x65\x63\x6f\x64\x65\x72\x2c\x3d\x00\x02\x67\x00" | ||
34341 | "\x22\x69\x6e\x46\x00\x5a\x70\x6c\x65\x20\x47\x6c\x00" | ||
34342 | "\xf0\x00\x74\x79\x70\x69\x63\x61\x6c\x6c\x79\x20\x72" | ||
34343 | "\x65\x61\x63\x68\xa7\x00\x33\x52\x41\x4d\x38\x00\x83" | ||
34344 | "\x6c\x69\x6d\x69\x74\x73\x20\x6f\x3f\x00\x01\x85\x00" | ||
34345 | "\x90\x20\x73\x79\x73\x74\x65\x6d\x73\x2e", | ||
34346 | .output = "LZ4 is lossless compression algorithm, providing" | ||
34347 | " compression speed at 400 MB/s per core, scalable " | ||
34348 | "with multi-cores CPU. It features an extremely fast " | ||
34349 | "decoder, with speed in multiple GB/s per core, " | ||
34350 | "typically reaching RAM speed limits on multi-core " | ||
34351 | "systems.", | ||
34321 | }, | 34352 | }, |
34322 | }; | 34353 | }; |
34323 | 34354 | ||
34324 | static struct comp_testvec lz4hc_comp_tv_template[] = { | 34355 | static struct comp_testvec lz4hc_comp_tv_template[] = { |
34325 | { | 34356 | { |
34326 | .inlen = 70, | 34357 | .inlen = 255, |
34327 | .outlen = 45, | 34358 | .outlen = 216, |
34328 | .input = "Join us now and share the software " | 34359 | .input = "LZ4 is lossless compression algorithm, providing" |
34329 | "Join us now and share the software ", | 34360 | " compression speed at 400 MB/s per core, scalable " |
34330 | .output = "\xf0\x10\x4a\x6f\x69\x6e\x20\x75" | 34361 | "with multi-cores CPU. It features an extremely fast " |
34331 | "\x73\x20\x6e\x6f\x77\x20\x61\x6e" | 34362 | "decoder, with speed in multiple GB/s per core, " |
34332 | "\x64\x20\x73\x68\x61\x72\x65\x20" | 34363 | "typically reaching RAM speed limits on multi-core " |
34333 | "\x74\x68\x65\x20\x73\x6f\x66\x74" | 34364 | "systems.", |
34334 | "\x77\x0d\x00\x0f\x23\x00\x0b\x50" | 34365 | .output = "\xf9\x21\x4c\x5a\x34\x20\x69\x73\x20\x6c\x6f\x73\x73" |
34335 | "\x77\x61\x72\x65\x20", | 34366 | "\x6c\x65\x73\x73\x20\x63\x6f\x6d\x70\x72\x65\x73\x73" |
34367 | "\x69\x6f\x6e\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d" | ||
34368 | "\x2c\x20\x70\x72\x6f\x76\x69\x64\x69\x6e\x67\x21\x00" | ||
34369 | "\xf0\x21\x73\x70\x65\x65\x64\x20\x61\x74\x20\x34\x30" | ||
34370 | "\x30\x20\x4d\x42\x2f\x73\x20\x70\x65\x72\x20\x63\x6f" | ||
34371 | "\x72\x65\x2c\x20\x73\x63\x61\x6c\x61\x62\x6c\x65\x20" | ||
34372 | "\x77\x69\x74\x68\x20\x6d\x75\x6c\x74\x69\x2d\x1a\x00" | ||
34373 | "\xf0\x00\x73\x20\x43\x50\x55\x2e\x20\x49\x74\x20\x66" | ||
34374 | "\x65\x61\x74\x75\x11\x00\xf2\x0b\x61\x6e\x20\x65\x78" | ||
34375 | "\x74\x72\x65\x6d\x65\x6c\x79\x20\x66\x61\x73\x74\x20" | ||
34376 | "\x64\x65\x63\x6f\x64\x65\x72\x2c\x3d\x00\x02\x67\x00" | ||
34377 | "\x22\x69\x6e\x46\x00\x5a\x70\x6c\x65\x20\x47\x6c\x00" | ||
34378 | "\xf0\x00\x74\x79\x70\x69\x63\x61\x6c\x6c\x79\x20\x72" | ||
34379 | "\x65\x61\x63\x68\xa7\x00\x33\x52\x41\x4d\x38\x00\x97" | ||
34380 | "\x6c\x69\x6d\x69\x74\x73\x20\x6f\x6e\x85\x00\x90\x20" | ||
34381 | "\x73\x79\x73\x74\x65\x6d\x73\x2e", | ||
34382 | |||
34336 | }, | 34383 | }, |
34337 | }; | 34384 | }; |
34338 | 34385 | ||
34339 | static struct comp_testvec lz4hc_decomp_tv_template[] = { | 34386 | static struct comp_testvec lz4hc_decomp_tv_template[] = { |
34340 | { | 34387 | { |
34341 | .inlen = 45, | 34388 | .inlen = 216, |
34342 | .outlen = 70, | 34389 | .outlen = 255, |
34343 | .input = "\xf0\x10\x4a\x6f\x69\x6e\x20\x75" | 34390 | .input = "\xf9\x21\x4c\x5a\x34\x20\x69\x73\x20\x6c\x6f\x73\x73" |
34344 | "\x73\x20\x6e\x6f\x77\x20\x61\x6e" | 34391 | "\x6c\x65\x73\x73\x20\x63\x6f\x6d\x70\x72\x65\x73\x73" |
34345 | "\x64\x20\x73\x68\x61\x72\x65\x20" | 34392 | "\x69\x6f\x6e\x20\x61\x6c\x67\x6f\x72\x69\x74\x68\x6d" |
34346 | "\x74\x68\x65\x20\x73\x6f\x66\x74" | 34393 | "\x2c\x20\x70\x72\x6f\x76\x69\x64\x69\x6e\x67\x21\x00" |
34347 | "\x77\x0d\x00\x0f\x23\x00\x0b\x50" | 34394 | "\xf0\x21\x73\x70\x65\x65\x64\x20\x61\x74\x20\x34\x30" |
34348 | "\x77\x61\x72\x65\x20", | 34395 | "\x30\x20\x4d\x42\x2f\x73\x20\x70\x65\x72\x20\x63\x6f" |
34349 | .output = "Join us now and share the software " | 34396 | "\x72\x65\x2c\x20\x73\x63\x61\x6c\x61\x62\x6c\x65\x20" |
34350 | "Join us now and share the software ", | 34397 | "\x77\x69\x74\x68\x20\x6d\x75\x6c\x74\x69\x2d\x1a\x00" |
34398 | "\xf0\x00\x73\x20\x43\x50\x55\x2e\x20\x49\x74\x20\x66" | ||
34399 | "\x65\x61\x74\x75\x11\x00\xf2\x0b\x61\x6e\x20\x65\x78" | ||
34400 | "\x74\x72\x65\x6d\x65\x6c\x79\x20\x66\x61\x73\x74\x20" | ||
34401 | "\x64\x65\x63\x6f\x64\x65\x72\x2c\x3d\x00\x02\x67\x00" | ||
34402 | "\x22\x69\x6e\x46\x00\x5a\x70\x6c\x65\x20\x47\x6c\x00" | ||
34403 | "\xf0\x00\x74\x79\x70\x69\x63\x61\x6c\x6c\x79\x20\x72" | ||
34404 | "\x65\x61\x63\x68\xa7\x00\x33\x52\x41\x4d\x38\x00\x97" | ||
34405 | "\x6c\x69\x6d\x69\x74\x73\x20\x6f\x6e\x85\x00\x90\x20" | ||
34406 | "\x73\x79\x73\x74\x65\x6d\x73\x2e", | ||
34407 | .output = "LZ4 is lossless compression algorithm, providing" | ||
34408 | " compression speed at 400 MB/s per core, scalable " | ||
34409 | "with multi-cores CPU. It features an extremely fast " | ||
34410 | "decoder, with speed in multiple GB/s per core, " | ||
34411 | "typically reaching RAM speed limits on multi-core " | ||
34412 | "systems.", | ||
34351 | }, | 34413 | }, |
34352 | }; | 34414 | }; |
34353 | 34415 | ||