Commit 0c01aed50d4844f54f59e875e05d211e80874464
Committed by
Herbert Xu
1 parent
bf68e65ec9
crypto: testmgr - add zlib test
Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 4 changed files with 158 additions and 1 deletions Side-by-side Diff
crypto/Kconfig
crypto/tcrypt.c
... | ... | @@ -53,7 +53,7 @@ |
53 | 53 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
54 | 54 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
55 | 55 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
56 | - "lzo", "cts", NULL | |
56 | + "lzo", "cts", "zlib", NULL | |
57 | 57 | }; |
58 | 58 | |
59 | 59 | static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, |
... | ... | @@ -659,6 +659,10 @@ |
659 | 659 | |
660 | 660 | case 43: |
661 | 661 | tcrypt_test("ecb(seed)"); |
662 | + break; | |
663 | + | |
664 | + case 44: | |
665 | + tcrypt_test("zlib"); | |
662 | 666 | break; |
663 | 667 | |
664 | 668 | case 100: |
crypto/testmgr.c
... | ... | @@ -2018,6 +2018,21 @@ |
2018 | 2018 | } |
2019 | 2019 | } |
2020 | 2020 | } |
2021 | + }, { | |
2022 | + .alg = "zlib", | |
2023 | + .test = alg_test_pcomp, | |
2024 | + .suite = { | |
2025 | + .pcomp = { | |
2026 | + .comp = { | |
2027 | + .vecs = zlib_comp_tv_template, | |
2028 | + .count = ZLIB_COMP_TEST_VECTORS | |
2029 | + }, | |
2030 | + .decomp = { | |
2031 | + .vecs = zlib_decomp_tv_template, | |
2032 | + .count = ZLIB_DECOMP_TEST_VECTORS | |
2033 | + } | |
2034 | + } | |
2035 | + } | |
2021 | 2036 | } |
2022 | 2037 | }; |
2023 | 2038 |
crypto/testmgr.h
... | ... | @@ -15,6 +15,9 @@ |
15 | 15 | #ifndef _CRYPTO_TESTMGR_H |
16 | 16 | #define _CRYPTO_TESTMGR_H |
17 | 17 | |
18 | +#include <linux/netlink.h> | |
19 | +#include <linux/zlib.h> | |
20 | + | |
18 | 21 | #include <crypto/compress.h> |
19 | 22 | |
20 | 23 | #define MAX_DIGEST_SIZE 64 |
... | ... | @@ -8361,6 +8364,7 @@ |
8361 | 8364 | * Deflate test vectors (null-terminated strings). |
8362 | 8365 | * Params: winbits=-11, Z_DEFAULT_COMPRESSION, MAX_MEM_LEVEL. |
8363 | 8366 | */ |
8367 | + | |
8364 | 8368 | #define DEFLATE_COMP_TEST_VECTORS 2 |
8365 | 8369 | #define DEFLATE_DECOMP_TEST_VECTORS 2 |
8366 | 8370 | |
... | ... | @@ -8424,6 +8428,139 @@ |
8424 | 8428 | "compression algorithm. This document defines the application of " |
8425 | 8429 | "the DEFLATE algorithm to the IP Payload Compression Protocol.", |
8426 | 8430 | }, { |
8431 | + .inlen = 38, | |
8432 | + .outlen = 70, | |
8433 | + .input = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56" | |
8434 | + "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51" | |
8435 | + "\x28\xce\x48\x2c\x4a\x55\x28\xc9" | |
8436 | + "\x48\x55\x28\xce\x4f\x2b\x29\x07" | |
8437 | + "\x71\xbc\x08\x2b\x01\x00", | |
8438 | + .output = "Join us now and share the software " | |
8439 | + "Join us now and share the software ", | |
8440 | + }, | |
8441 | +}; | |
8442 | + | |
8443 | +#define ZLIB_COMP_TEST_VECTORS 2 | |
8444 | +#define ZLIB_DECOMP_TEST_VECTORS 2 | |
8445 | + | |
8446 | +static const struct { | |
8447 | + struct nlattr nla; | |
8448 | + int val; | |
8449 | +} deflate_comp_params[] = { | |
8450 | + { | |
8451 | + .nla = { | |
8452 | + .nla_len = NLA_HDRLEN + sizeof(int), | |
8453 | + .nla_type = ZLIB_COMP_LEVEL, | |
8454 | + }, | |
8455 | + .val = Z_DEFAULT_COMPRESSION, | |
8456 | + }, { | |
8457 | + .nla = { | |
8458 | + .nla_len = NLA_HDRLEN + sizeof(int), | |
8459 | + .nla_type = ZLIB_COMP_METHOD, | |
8460 | + }, | |
8461 | + .val = Z_DEFLATED, | |
8462 | + }, { | |
8463 | + .nla = { | |
8464 | + .nla_len = NLA_HDRLEN + sizeof(int), | |
8465 | + .nla_type = ZLIB_COMP_WINDOWBITS, | |
8466 | + }, | |
8467 | + .val = -11, | |
8468 | + }, { | |
8469 | + .nla = { | |
8470 | + .nla_len = NLA_HDRLEN + sizeof(int), | |
8471 | + .nla_type = ZLIB_COMP_MEMLEVEL, | |
8472 | + }, | |
8473 | + .val = MAX_MEM_LEVEL, | |
8474 | + }, { | |
8475 | + .nla = { | |
8476 | + .nla_len = NLA_HDRLEN + sizeof(int), | |
8477 | + .nla_type = ZLIB_COMP_STRATEGY, | |
8478 | + }, | |
8479 | + .val = Z_DEFAULT_STRATEGY, | |
8480 | + } | |
8481 | +}; | |
8482 | + | |
8483 | +static const struct { | |
8484 | + struct nlattr nla; | |
8485 | + int val; | |
8486 | +} deflate_decomp_params[] = { | |
8487 | + { | |
8488 | + .nla = { | |
8489 | + .nla_len = NLA_HDRLEN + sizeof(int), | |
8490 | + .nla_type = ZLIB_DECOMP_WINDOWBITS, | |
8491 | + }, | |
8492 | + .val = -11, | |
8493 | + } | |
8494 | +}; | |
8495 | + | |
8496 | +static struct pcomp_testvec zlib_comp_tv_template[] = { | |
8497 | + { | |
8498 | + .params = &deflate_comp_params, | |
8499 | + .paramsize = sizeof(deflate_comp_params), | |
8500 | + .inlen = 70, | |
8501 | + .outlen = 38, | |
8502 | + .input = "Join us now and share the software " | |
8503 | + "Join us now and share the software ", | |
8504 | + .output = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56" | |
8505 | + "\xc8\xcb\x2f\x57\x48\xcc\x4b\x51" | |
8506 | + "\x28\xce\x48\x2c\x4a\x55\x28\xc9" | |
8507 | + "\x48\x55\x28\xce\x4f\x2b\x29\x07" | |
8508 | + "\x71\xbc\x08\x2b\x01\x00", | |
8509 | + }, { | |
8510 | + .params = &deflate_comp_params, | |
8511 | + .paramsize = sizeof(deflate_comp_params), | |
8512 | + .inlen = 191, | |
8513 | + .outlen = 122, | |
8514 | + .input = "This document describes a compression method based on the DEFLATE" | |
8515 | + "compression algorithm. This document defines the application of " | |
8516 | + "the DEFLATE algorithm to the IP Payload Compression Protocol.", | |
8517 | + .output = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04" | |
8518 | + "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09" | |
8519 | + "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8" | |
8520 | + "\x24\xdb\x67\xd9\x47\xc1\xef\x49" | |
8521 | + "\x68\x12\x51\xae\x76\x67\xd6\x27" | |
8522 | + "\x19\x88\x1a\xde\x85\xab\x21\xf2" | |
8523 | + "\x08\x5d\x16\x1e\x20\x04\x2d\xad" | |
8524 | + "\xf3\x18\xa2\x15\x85\x2d\x69\xc4" | |
8525 | + "\x42\x83\x23\xb6\x6c\x89\x71\x9b" | |
8526 | + "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f" | |
8527 | + "\xed\x62\xa9\x4c\x80\xff\x13\xaf" | |
8528 | + "\x52\x37\xed\x0e\x52\x6b\x59\x02" | |
8529 | + "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98" | |
8530 | + "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a" | |
8531 | + "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79" | |
8532 | + "\xfa\x02", | |
8533 | + }, | |
8534 | +}; | |
8535 | + | |
8536 | +static struct pcomp_testvec zlib_decomp_tv_template[] = { | |
8537 | + { | |
8538 | + .params = &deflate_decomp_params, | |
8539 | + .paramsize = sizeof(deflate_decomp_params), | |
8540 | + .inlen = 122, | |
8541 | + .outlen = 191, | |
8542 | + .input = "\x5d\x8d\x31\x0e\xc2\x30\x10\x04" | |
8543 | + "\xbf\xb2\x2f\xc8\x1f\x10\x04\x09" | |
8544 | + "\x89\xc2\x85\x3f\x70\xb1\x2f\xf8" | |
8545 | + "\x24\xdb\x67\xd9\x47\xc1\xef\x49" | |
8546 | + "\x68\x12\x51\xae\x76\x67\xd6\x27" | |
8547 | + "\x19\x88\x1a\xde\x85\xab\x21\xf2" | |
8548 | + "\x08\x5d\x16\x1e\x20\x04\x2d\xad" | |
8549 | + "\xf3\x18\xa2\x15\x85\x2d\x69\xc4" | |
8550 | + "\x42\x83\x23\xb6\x6c\x89\x71\x9b" | |
8551 | + "\xef\xcf\x8b\x9f\xcf\x33\xca\x2f" | |
8552 | + "\xed\x62\xa9\x4c\x80\xff\x13\xaf" | |
8553 | + "\x52\x37\xed\x0e\x52\x6b\x59\x02" | |
8554 | + "\xd9\x4e\xe8\x7a\x76\x1d\x02\x98" | |
8555 | + "\xfe\x8a\x87\x83\xa3\x4f\x56\x8a" | |
8556 | + "\xb8\x9e\x8e\x5c\x57\xd3\xa0\x79" | |
8557 | + "\xfa\x02", | |
8558 | + .output = "This document describes a compression method based on the DEFLATE" | |
8559 | + "compression algorithm. This document defines the application of " | |
8560 | + "the DEFLATE algorithm to the IP Payload Compression Protocol.", | |
8561 | + }, { | |
8562 | + .params = &deflate_decomp_params, | |
8563 | + .paramsize = sizeof(deflate_decomp_params), | |
8427 | 8564 | .inlen = 38, |
8428 | 8565 | .outlen = 70, |
8429 | 8566 | .input = "\xf3\xca\xcf\xcc\x53\x28\x2d\x56" |