crypto: xxhash - Implement xxhash support
Subsystems (2)
PATCH v4 1/1 crypto: xxhash - Implement xxhash support
xxhash is currently implemented as a self-contained module in /lib. This patch enables that module to be used as part of the generic kernel crypto framework. It adds a simple wrapper to the 64bit version.
I've also added test vectors (with help from Nick Terrell). The upstream xxhash code is tested by running hashing operation on random 222 byte data with seed values of 0 and a prime number. The upstream test
suite can be found at https://github.com/Cyan4973/xxHash/blob/cf46e0c/xxhsum.c#L664
Essentially hashing is run on data of length 0,1,14,222 with the aforementioned seed values 0 and prime 2654435761. The particular random 222 byte string was provided to me by Nick Terrell by reading /dev/random and the checksums were calculated by the upstream xxsum utility with the following bash script:
dd if=/dev/random of=TEST_VECTOR bs=1 count=222
for a in 0 1; do
for l in 0 1 14 222; do for s in 0 2654435761; do echo algo $a length $l seed $s; head -c $l TEST_VECTOR | ~/projects/kernel/xxHash/xxhsum -H$a -s$s done done
done
This produces output as follows:
algo 0 length 0 seed 002cc5d05 stdin
algo 0 length 0 seed 265443576102cc5d05 stdin
algo 0 length 1 seed 0
25201171 stdin
algo 0 length 1 seed 2654435761
25201171 stdin
algo 0 length 14 seed 0c1d95975 stdin
algo 0 length 14 seed 2654435761c1d95975 stdin
algo 0 length 222 seed 0b38662a6 stdin
algo 0 length 222 seed 2654435761b38662a6 stdin
algo 1 length 0 seed 0ef46db3751d8e999 stdin
algo 1 length 0 seed 2654435761ac75fda2929b17ef stdin
algo 1 length 1 seed 027c3f04c2881203a stdin
algo 1 length 1 seed 26544357614a15ed26415dfe4d stdin
algo 1 length 14 seed 03d33dc700231dfad stdin
algo 1 length 14 seed 2654435761ea5f7ddef9a64f80 stdin
algo 1 length 222 seed 05f3d3c08ec2bef34 stdin
algo 1 length 222 seed 26544357616a9df59664c7ed62 stdin
algo 1 is xx64 variant, algo 0 is the 32 bit variant which is currently not hooked up.
---
V4:
* Renamed couple more shash_desc_ctx variable to "dctx" (Eric Biggers)
* Removed _finup method (Eric Biggers)
* Implemented _digest method by directly calling xxh64() (Eric Biggers)
crypto/Kconfig | 8 +++ crypto/Makefile | 1 + crypto/testmgr.c | 7 +++ crypto/testmgr.h | 106 +++++++++++++++++++++++++++++++++++++++ crypto/xxhash_generic.c | 108 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 crypto/xxhash_generic.c
crypto/Kconfig +8 -0
@@ -665,6 +665,14 @@ config CRYPTO_CRC32_MIPS instructions, when available. +config CRYPTO_XXHASH + tristate "xxHash hash algorithm" + select CRYPTO_HASH + select XXHASH + help + xxHash non-cryptographic hash algorithm. Extremely fast, working at + speeds close to RAM limits. + config CRYPTO_CRCT10DIF tristate "CRCT10DIF algorithm" select CRYPTO_HASH
crypto/Makefile +1 -0
@@ -131,6 +131,7 @@ obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o obj-$(CONFIG_CRYPTO_LZO) += lzo.o lzo-rle.o obj-$(CONFIG_CRYPTO_LZ4) += lz4.o obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o +obj-$(CONFIG_CRYPTO_XXHASH) += xxhash_generic.o obj-$(CONFIG_CRYPTO_842) += 842.o obj-$(CONFIG_CRYPTO_RNG2) += rng.o obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
crypto/testmgr.c +7 -0
@@ -3879,6 +3879,13 @@ static const struct alg_test_desc alg_test_descs[] = { .alg = "xts512(paes)", .test = alg_test_null, .fips_allowed = 1, + }, { + .alg = "xxhash64", + .test = alg_test_hash, + .fips_allowed = 1, + .suite = { + .hash = __VECS(xxhash64_tv_template) + } }, { .alg = "zlib-deflate", .test = alg_test_comp,
crypto/testmgr.h +106 -0
112 lines not on this page · raw message
crypto/xxhash_generic.c new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 61 lines · Nikolay Borisov
xxhash is currently implemented as a self-contained module in /lib. This patch enables that module to be used as part of the generic kernel crypto framework. It adds a simple wrapper to the 64bit version.
I've also added test vectors (with help from Nick Terrell). The upstream xxhash code is tested by running hashing operation on random 222 byte data with seed values of 0 and a prime number. The upstream test
suite can be found at https://github.com/Cyan4973/xxHash/blob/cf46e0c/xxhsum.c#L664Essentially hashing is run on data of length 0,1,14,222 with the aforementioned seed values 0 and prime 2654435761. The particular random 222 byte string was provided to me by Nick Terrell by reading
/dev/randomand the checksums were calculated by the upstream xxsum utility with the following bash script:dd if=/dev/random of=TEST_VECTOR bs=1 count=222
for a in 0 1; do
for l in 0 1 14 222; do for s in 0 2654435761; do echo algo $a length $l seed $s; head -c $l TEST_VECTOR | ~/projects/kernel/xxHash/xxhsum -H$a -s$s done donedone
This produces output as follows:
algo 0 length 0 seed 0
02cc5d05stdin
algo 0 length 0 seed 265443576102cc5d05stdin
algo 0 length 1 seed 0
25201171 stdin
algo 0 length 1 seed 2654435761
25201171 stdin
algo 0 length 14 seed 0c1d95975stdin
algo 0 length 14 seed 2654435761c1d95975stdin
algo 0 length 222 seed 0b38662a6stdin
algo 0 length 222 seed 2654435761b38662a6stdin
algo 1 length 0 seed 0ef46db3751d8e999stdin
algo 1 length 0 seed 2654435761ac75fda2929b17efstdin
algo 1 length 1 seed 027c3f04c2881203astdin
algo 1 length 1 seed 26544357614a15ed26415dfe4dstdin
algo 1 length 14 seed 03d33dc700231dfadstdin
algo 1 length 14 seed 2654435761ea5f7ddef9a64f80stdin
algo 1 length 222 seed 05f3d3c08ec2bef34stdin
algo 1 length 222 seed 26544357616a9df59664c7ed62stdin
Quoted 5 lines
algo 1 is xx64 variant, algo 0 is the 32 bit variant which is currently not hooked up.
Signed-off-by Nikolay Borisov <[email protected]>---
Looks fine now.
- Eric
Herbert Xu
maintainerQuoted 72 lines · Nikolay Borisov
xxhash is currently implemented as a self-contained module in /lib. This patch enables that module to be used as part of the generic kernel crypto framework. It adds a simple wrapper to the 64bit version.
I've also added test vectors (with help from Nick Terrell). The upstream xxhash code is tested by running hashing operation on random 222 byte data with seed values of 0 and a prime number. The upstream test
suite can be found at https://github.com/Cyan4973/xxHash/blob/cf46e0c/xxhsum.c#L664Essentially hashing is run on data of length 0,1,14,222 with the aforementioned seed values 0 and prime 2654435761. The particular random 222 byte string was provided to me by Nick Terrell by reading
/dev/randomand the checksums were calculated by the upstream xxsum utility with the following bash script:dd if=/dev/random of=TEST_VECTOR bs=1 count=222
for a in 0 1; do
for l in 0 1 14 222; do for s in 0 2654435761; do echo algo $a length $l seed $s; head -c $l TEST_VECTOR | ~/projects/kernel/xxHash/xxhsum -H$a -s$s done donedone
This produces output as follows:
algo 0 length 0 seed 0
02cc5d05stdin
algo 0 length 0 seed 265443576102cc5d05stdin
algo 0 length 1 seed 0
25201171 stdin
algo 0 length 1 seed 2654435761
25201171 stdin
algo 0 length 14 seed 0c1d95975stdin
algo 0 length 14 seed 2654435761c1d95975stdin
algo 0 length 222 seed 0b38662a6stdin
algo 0 length 222 seed 2654435761b38662a6stdin
algo 1 length 0 seed 0ef46db3751d8e999stdin
algo 1 length 0 seed 2654435761ac75fda2929b17efstdin
algo 1 length 1 seed 027c3f04c2881203astdin
algo 1 length 1 seed 26544357614a15ed26415dfe4dstdin
algo 1 length 14 seed 03d33dc700231dfadstdin
algo 1 length 14 seed 2654435761ea5f7ddef9a64f80stdin
algo 1 length 222 seed 05f3d3c08ec2bef34stdin
algo 1 length 222 seed 26544357616a9df59664c7ed62stdinalgo 1 is xx64 variant, algo 0 is the 32 bit variant which is currently not hooked up.
Signed-off-by Nikolay Borisov <[email protected]>---
V4:
* Renamed couple moreshash_desc_ctxvariable to "dctx" (Eric Biggers)
* Removed_finupmethod (Eric Biggers)
* Implemented_digestmethod by directly callingxxh64()(Eric Biggers)
Quoted 7 lines
crypto/Kconfig | 8 +++ crypto/Makefile | 1 + crypto/testmgr.c | 7 +++ crypto/testmgr.h | 106 +++++++++++++++++++++++++++++++++++++++ crypto/xxhash_generic.c | 108 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 crypto/xxhash_generic.c
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt