diff mbox

[4/5] crypto: testmgr - Add test vectors for LZS compression

Message ID 20180622143722.9406-5-jglauber@cavium.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show

Commit Message

Jan Glauber June 22, 2018, 2:37 p.m. UTC
The test vectors were generated using the ThunderX ZIP coprocessor.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
---
 crypto/testmgr.c |  9 ++++++
 crypto/testmgr.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 86 insertions(+)

Comments

Eric Biggers June 23, 2018, 2:50 a.m. UTC | #1
Hi Jan,

On Fri, Jun 22, 2018 at 04:37:21PM +0200, Jan Glauber wrote:
> The test vectors were generated using the ThunderX ZIP coprocessor.
> 
> Signed-off-by: Jan Glauber <jglauber@cavium.com>
> ---
>  crypto/testmgr.c |  9 ++++++
>  crypto/testmgr.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 86 insertions(+)
> 
> diff --git a/crypto/testmgr.c b/crypto/testmgr.c
> index cfb5fe4c5ccf..8e9ff1229e93 100644
> --- a/crypto/testmgr.c
> +++ b/crypto/testmgr.c
> @@ -3238,6 +3238,15 @@ static const struct alg_test_desc alg_test_descs[] = {
>  				.decomp = __VECS(lzo_decomp_tv_template)
>  			}
>  		}
> +	}, {
> +		.alg = "lzs",
> +		.test = alg_test_comp,
> +		.suite = {
> +			.comp = {
> +				.comp = __VECS(lzs_comp_tv_template),
> +				.decomp = __VECS(lzs_decomp_tv_template)
> +			}
> +		}
>  	}, {
>  		.alg = "md4",
>  		.test = alg_test_hash,
> diff --git a/crypto/testmgr.h b/crypto/testmgr.h
> index b950aa234e43..ae7fecadcade 100644
> --- a/crypto/testmgr.h
> +++ b/crypto/testmgr.h
> @@ -31699,6 +31699,83 @@ static const struct comp_testvec lzo_decomp_tv_template[] = {
>  	},
>  };
>  
> +/*
> + * LZS test vectors (null-terminated strings).
> + */
> +static const struct comp_testvec lzs_comp_tv_template[] = {
> +	{
> +		.inlen	= 70,
> +		.outlen	= 40,
> +		.input	= "Join us now and share the software "
> +			"Join us now and share the software ",
> +		.output	= "\x25\x1b\xcd\x26\xe1\x01\xd4\xe6"
> +			  "\x20\x37\x1b\xce\xe2\x03\x09\xb8"
> +			  "\xc8\x20\x39\x9a\x0c\x27\x23\x28"
> +			  "\x80\xe8\x68\xc2\x07\x33\x79\x98"
> +			  "\xe8\x77\xc6\xda\x3f\xfc\xc0\x00",
> +	}, {
> +		.inlen	= 184,
> +		.outlen	= 130,
> +		.input	= "This document describes a compression method based on the LZS "
> +			"compression algorithm.  This document defines the application of "
> +			"the LZS algorithm to the IP Payload Compression Protocol.",

Your comment claims that the test vectors (presumably the inputs) are
null-terminated strings, but the lengths of the inputs actually don't include
the null terminator.  The length of the first one, for example, would have to be
71 to include the null terminator, not 70.

Eric
Jan Glauber June 23, 2018, 10:20 a.m. UTC | #2
On Fri, Jun 22, 2018 at 07:50:02PM -0700, Eric Biggers wrote:
> Hi Jan,
> 
> On Fri, Jun 22, 2018 at 04:37:21PM +0200, Jan Glauber wrote:
> > The test vectors were generated using the ThunderX ZIP coprocessor.
> >
> > Signed-off-by: Jan Glauber <jglauber@cavium.com>
> > ---
> >  crypto/testmgr.c |  9 ++++++
> >  crypto/testmgr.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 86 insertions(+)
> >
> > diff --git a/crypto/testmgr.c b/crypto/testmgr.c
> > index cfb5fe4c5ccf..8e9ff1229e93 100644
> > --- a/crypto/testmgr.c
> > +++ b/crypto/testmgr.c
> > @@ -3238,6 +3238,15 @@ static const struct alg_test_desc alg_test_descs[] = {
> >                               .decomp = __VECS(lzo_decomp_tv_template)
> >                       }
> >               }
> > +     }, {
> > +             .alg = "lzs",
> > +             .test = alg_test_comp,
> > +             .suite = {
> > +                     .comp = {
> > +                             .comp = __VECS(lzs_comp_tv_template),
> > +                             .decomp = __VECS(lzs_decomp_tv_template)
> > +                     }
> > +             }
> >       }, {
> >               .alg = "md4",
> >               .test = alg_test_hash,
> > diff --git a/crypto/testmgr.h b/crypto/testmgr.h
> > index b950aa234e43..ae7fecadcade 100644
> > --- a/crypto/testmgr.h
> > +++ b/crypto/testmgr.h
> > @@ -31699,6 +31699,83 @@ static const struct comp_testvec lzo_decomp_tv_template[] = {
> >       },
> >  };
> >
> > +/*
> > + * LZS test vectors (null-terminated strings).
> > + */
> > +static const struct comp_testvec lzs_comp_tv_template[] = {
> > +     {
> > +             .inlen  = 70,
> > +             .outlen = 40,
> > +             .input  = "Join us now and share the software "
> > +                     "Join us now and share the software ",
> > +             .output = "\x25\x1b\xcd\x26\xe1\x01\xd4\xe6"
> > +                       "\x20\x37\x1b\xce\xe2\x03\x09\xb8"
> > +                       "\xc8\x20\x39\x9a\x0c\x27\x23\x28"
> > +                       "\x80\xe8\x68\xc2\x07\x33\x79\x98"
> > +                       "\xe8\x77\xc6\xda\x3f\xfc\xc0\x00",
> > +     }, {
> > +             .inlen  = 184,
> > +             .outlen = 130,
> > +             .input  = "This document describes a compression method based on the LZS "
> > +                     "compression algorithm.  This document defines the application of "
> > +                     "the LZS algorithm to the IP Payload Compression Protocol.",
> 
> Your comment claims that the test vectors (presumably the inputs) are
> null-terminated strings, but the lengths of the inputs actually don't include
> the null terminator.  The length of the first one, for example, would have to be
> 71 to include the null terminator, not 70.

I just copied that from the deflate & LZO testcases that use the same test vector.
If I add the null terminator I guess we would need to change the output
for deflate & LZO too.

How about just removing the null-terminated comment?

--Jan
diff mbox

Patch

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index cfb5fe4c5ccf..8e9ff1229e93 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -3238,6 +3238,15 @@  static const struct alg_test_desc alg_test_descs[] = {
 				.decomp = __VECS(lzo_decomp_tv_template)
 			}
 		}
+	}, {
+		.alg = "lzs",
+		.test = alg_test_comp,
+		.suite = {
+			.comp = {
+				.comp = __VECS(lzs_comp_tv_template),
+				.decomp = __VECS(lzs_decomp_tv_template)
+			}
+		}
 	}, {
 		.alg = "md4",
 		.test = alg_test_hash,
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index b950aa234e43..ae7fecadcade 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -31699,6 +31699,83 @@  static const struct comp_testvec lzo_decomp_tv_template[] = {
 	},
 };
 
+/*
+ * LZS test vectors (null-terminated strings).
+ */
+static const struct comp_testvec lzs_comp_tv_template[] = {
+	{
+		.inlen	= 70,
+		.outlen	= 40,
+		.input	= "Join us now and share the software "
+			"Join us now and share the software ",
+		.output	= "\x25\x1b\xcd\x26\xe1\x01\xd4\xe6"
+			  "\x20\x37\x1b\xce\xe2\x03\x09\xb8"
+			  "\xc8\x20\x39\x9a\x0c\x27\x23\x28"
+			  "\x80\xe8\x68\xc2\x07\x33\x79\x98"
+			  "\xe8\x77\xc6\xda\x3f\xfc\xc0\x00",
+	}, {
+		.inlen	= 184,
+		.outlen	= 130,
+		.input	= "This document describes a compression method based on the LZS "
+			"compression algorithm.  This document defines the application of "
+			"the LZS algorithm to the IP Payload Compression Protocol.",
+		.output	= "\x2a\x1a\x0d\x27\x31\x01\x90\xde"
+			  "\x63\x3a\x9b\x4c\xa6\xe3\xa6\x24"
+			  "\x32\x9c\xcc\x67\x23\x49\x8b\x0c"
+			  "\x08\x0c\x22\x03\x19\xbc\xda\x70"
+			  "\x39\x62\x83\x99\xa4\xde\x6e\x10"
+			  "\x67\x43\xa1\xa0\xde\x64\x10\x18"
+			  "\x8c\x27\x33\x2e\x18\xc8\x38\xe0"
+			  "\xca\x20\x26\x16\x8a\x7a\x4f\x53"
+			  "\x09\xb0\xce\x6f\xde\x19\xa0\xda"
+			  "\x2e\x10\x08\x3a\xdf\x06\x63\x49"
+			  "\xb8\xca\x73\xdb\x61\x84\xe0\x70"
+			  "\x36\x1a\x4c\x66\x13\xa6\xca\x37"
+			  "\x99\xb9\x3e\x3b\xdf\x1c\x90\x6f"
+			  "\xca\xe1\x24\xa0\x20\x28\x18\x4f"
+			  "\x26\xc3\x79\x87\xe0\x10\xfc\xbe"
+			  "\x65\x03\x91\xbf\x42\x7d\x83\x60"
+			  "\xbb\x00",
+	},
+};
+
+static const struct comp_testvec lzs_decomp_tv_template[] = {
+	{
+		.inlen	= 130,
+		.outlen	= 184,
+		.input	= "\x2a\x1a\x0d\x27\x31\x01\x90\xde"
+			  "\x63\x3a\x9b\x4c\xa6\xe3\xa6\x24"
+			  "\x32\x9c\xcc\x67\x23\x49\x8b\x0c"
+			  "\x08\x0c\x22\x03\x19\xbc\xda\x70"
+			  "\x39\x62\x83\x99\xa4\xde\x6e\x10"
+			  "\x67\x43\xa1\xa0\xde\x64\x10\x18"
+			  "\x8c\x27\x33\x2e\x18\xc8\x38\xe0"
+			  "\xca\x20\x26\x16\x8a\x7a\x4f\x53"
+			  "\x09\xb0\xce\x6f\xde\x19\xa0\xda"
+			  "\x2e\x10\x08\x3a\xdf\x06\x63\x49"
+			  "\xb8\xca\x73\xdb\x61\x84\xe0\x70"
+			  "\x36\x1a\x4c\x66\x13\xa6\xca\x37"
+			  "\x99\xb9\x3e\x3b\xdf\x1c\x90\x6f"
+			  "\xca\xe1\x24\xa0\x20\x28\x18\x4f"
+			  "\x26\xc3\x79\x87\xe0\x10\xfc\xbe"
+			  "\x65\x03\x91\xbf\x42\x7d\x83\x60"
+			  "\xbb\x00",
+		.output	= "This document describes a compression method based on the LZS "
+			"compression algorithm.  This document defines the application of "
+			"the LZS algorithm to the IP Payload Compression Protocol.",
+	}, {
+		.inlen	= 40,
+		.outlen	= 70,
+		.input	= "\x25\x1b\xcd\x26\xe1\x01\xd4\xe6"
+			  "\x20\x37\x1b\xce\xe2\x03\x09\xb8"
+			  "\xc8\x20\x39\x9a\x0c\x27\x23\x28"
+			  "\x80\xe8\x68\xc2\x07\x33\x79\x98"
+			  "\xe8\x77\xc6\xda\x3f\xfc\xc0\x00",
+		.output	= "Join us now and share the software "
+			"Join us now and share the software ",
+	},
+};
+
 /*
  * Michael MIC test vectors from IEEE 802.11i
  */