diff options
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/Kconfig | 58 | ||||
| -rw-r--r-- | crypto/Makefile | 2 | ||||
| -rw-r--r-- | crypto/algapi.c | 3 | ||||
| -rw-r--r-- | crypto/algboss.c | 15 | ||||
| -rw-r--r-- | crypto/api.c | 6 | ||||
| -rw-r--r-- | crypto/async_tx/Kconfig | 4 | ||||
| -rw-r--r-- | crypto/async_tx/Makefile | 1 | ||||
| -rw-r--r-- | crypto/async_tx/async_memset.c | 89 | ||||
| -rw-r--r-- | crypto/internal.h | 6 | ||||
| -rw-r--r-- | crypto/lz4.c | 106 | ||||
| -rw-r--r-- | crypto/lz4hc.c | 106 | ||||
| -rw-r--r-- | crypto/pcrypt.c | 4 | ||||
| -rw-r--r-- | crypto/sha512_generic.c | 2 | ||||
| -rw-r--r-- | crypto/testmgr.c | 166 |
14 files changed, 380 insertions, 188 deletions
diff --git a/crypto/Kconfig b/crypto/Kconfig index 622d8a48cbe9..aca01164f002 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig | |||
| @@ -820,24 +820,6 @@ config CRYPTO_BLOWFISH_X86_64 | |||
| 820 | See also: | 820 | See also: |
| 821 | <http://www.schneier.com/blowfish.html> | 821 | <http://www.schneier.com/blowfish.html> |
| 822 | 822 | ||
| 823 | config CRYPTO_BLOWFISH_AVX2_X86_64 | ||
| 824 | tristate "Blowfish cipher algorithm (x86_64/AVX2)" | ||
| 825 | depends on X86 && 64BIT | ||
| 826 | select CRYPTO_ALGAPI | ||
| 827 | select CRYPTO_CRYPTD | ||
| 828 | select CRYPTO_ABLK_HELPER_X86 | ||
| 829 | select CRYPTO_BLOWFISH_COMMON | ||
| 830 | select CRYPTO_BLOWFISH_X86_64 | ||
| 831 | help | ||
| 832 | Blowfish cipher algorithm (x86_64/AVX2), by Bruce Schneier. | ||
| 833 | |||
| 834 | This is a variable key length cipher which can use keys from 32 | ||
| 835 | bits to 448 bits in length. It's fast, simple and specifically | ||
| 836 | designed for use on "large microprocessors". | ||
| 837 | |||
| 838 | See also: | ||
| 839 | <http://www.schneier.com/blowfish.html> | ||
| 840 | |||
| 841 | config CRYPTO_CAMELLIA | 823 | config CRYPTO_CAMELLIA |
| 842 | tristate "Camellia cipher algorithms" | 824 | tristate "Camellia cipher algorithms" |
| 843 | depends on CRYPTO | 825 | depends on CRYPTO |
| @@ -1296,30 +1278,6 @@ config CRYPTO_TWOFISH_AVX_X86_64 | |||
| 1296 | See also: | 1278 | See also: |
| 1297 | <http://www.schneier.com/twofish.html> | 1279 | <http://www.schneier.com/twofish.html> |
| 1298 | 1280 | ||
| 1299 | config CRYPTO_TWOFISH_AVX2_X86_64 | ||
| 1300 | tristate "Twofish cipher algorithm (x86_64/AVX2)" | ||
| 1301 | depends on X86 && 64BIT | ||
| 1302 | select CRYPTO_ALGAPI | ||
| 1303 | select CRYPTO_CRYPTD | ||
| 1304 | select CRYPTO_ABLK_HELPER_X86 | ||
| 1305 | select CRYPTO_GLUE_HELPER_X86 | ||
| 1306 | select CRYPTO_TWOFISH_COMMON | ||
| 1307 | select CRYPTO_TWOFISH_X86_64 | ||
| 1308 | select CRYPTO_TWOFISH_X86_64_3WAY | ||
| 1309 | select CRYPTO_TWOFISH_AVX_X86_64 | ||
| 1310 | select CRYPTO_LRW | ||
| 1311 | select CRYPTO_XTS | ||
| 1312 | help | ||
| 1313 | Twofish cipher algorithm (x86_64/AVX2). | ||
| 1314 | |||
| 1315 | Twofish was submitted as an AES (Advanced Encryption Standard) | ||
| 1316 | candidate cipher by researchers at CounterPane Systems. It is a | ||
| 1317 | 16 round block cipher supporting key sizes of 128, 192, and 256 | ||
| 1318 | bits. | ||
| 1319 | |||
| 1320 | See also: | ||
| 1321 | <http://www.schneier.com/twofish.html> | ||
| 1322 | |||
| 1323 | comment "Compression" | 1281 | comment "Compression" |
| 1324 | 1282 | ||
| 1325 | config CRYPTO_DEFLATE | 1283 | config CRYPTO_DEFLATE |
| @@ -1359,6 +1317,22 @@ config CRYPTO_842 | |||
| 1359 | help | 1317 | help |
| 1360 | This is the 842 algorithm. | 1318 | This is the 842 algorithm. |
| 1361 | 1319 | ||
| 1320 | config CRYPTO_LZ4 | ||
| 1321 | tristate "LZ4 compression algorithm" | ||
| 1322 | select CRYPTO_ALGAPI | ||
| 1323 | select LZ4_COMPRESS | ||
| 1324 | select LZ4_DECOMPRESS | ||
| 1325 | help | ||
| 1326 | This is the LZ4 algorithm. | ||
| 1327 | |||
| 1328 | config CRYPTO_LZ4HC | ||
| 1329 | tristate "LZ4HC compression algorithm" | ||
| 1330 | select CRYPTO_ALGAPI | ||
| 1331 | select LZ4HC_COMPRESS | ||
| 1332 | select LZ4_DECOMPRESS | ||
| 1333 | help | ||
| 1334 | This is the LZ4 high compression mode algorithm. | ||
| 1335 | |||
| 1362 | comment "Random Number Generation" | 1336 | comment "Random Number Generation" |
| 1363 | 1337 | ||
| 1364 | config CRYPTO_ANSI_CPRNG | 1338 | config CRYPTO_ANSI_CPRNG |
diff --git a/crypto/Makefile b/crypto/Makefile index a8e9b0fefbe9..2ba0df2f908f 100644 --- a/crypto/Makefile +++ b/crypto/Makefile | |||
| @@ -85,6 +85,8 @@ obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o | |||
| 85 | obj-$(CONFIG_CRYPTO_CRC32) += crc32.o | 85 | obj-$(CONFIG_CRYPTO_CRC32) += crc32.o |
| 86 | obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o | 86 | obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o |
| 87 | obj-$(CONFIG_CRYPTO_LZO) += lzo.o | 87 | obj-$(CONFIG_CRYPTO_LZO) += lzo.o |
| 88 | obj-$(CONFIG_CRYPTO_LZ4) += lz4.o | ||
| 89 | obj-$(CONFIG_CRYPTO_LZ4HC) += lz4hc.o | ||
| 88 | obj-$(CONFIG_CRYPTO_842) += 842.o | 90 | obj-$(CONFIG_CRYPTO_842) += 842.o |
| 89 | obj-$(CONFIG_CRYPTO_RNG2) += rng.o | 91 | obj-$(CONFIG_CRYPTO_RNG2) += rng.o |
| 90 | obj-$(CONFIG_CRYPTO_RNG2) += krng.o | 92 | obj-$(CONFIG_CRYPTO_RNG2) += krng.o |
diff --git a/crypto/algapi.c b/crypto/algapi.c index 6149a6e09643..7a1ae87f1683 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
| @@ -495,7 +495,8 @@ static struct crypto_template *__crypto_lookup_template(const char *name) | |||
| 495 | 495 | ||
| 496 | struct crypto_template *crypto_lookup_template(const char *name) | 496 | struct crypto_template *crypto_lookup_template(const char *name) |
| 497 | { | 497 | { |
| 498 | return try_then_request_module(__crypto_lookup_template(name), name); | 498 | return try_then_request_module(__crypto_lookup_template(name), "%s", |
| 499 | name); | ||
| 499 | } | 500 | } |
| 500 | EXPORT_SYMBOL_GPL(crypto_lookup_template); | 501 | EXPORT_SYMBOL_GPL(crypto_lookup_template); |
| 501 | 502 | ||
diff --git a/crypto/algboss.c b/crypto/algboss.c index 769219b29309..76fc0b23fc6c 100644 --- a/crypto/algboss.c +++ b/crypto/algboss.c | |||
| @@ -45,10 +45,9 @@ struct cryptomgr_param { | |||
| 45 | } nu32; | 45 | } nu32; |
| 46 | } attrs[CRYPTO_MAX_ATTRS]; | 46 | } attrs[CRYPTO_MAX_ATTRS]; |
| 47 | 47 | ||
| 48 | char larval[CRYPTO_MAX_ALG_NAME]; | ||
| 49 | char template[CRYPTO_MAX_ALG_NAME]; | 48 | char template[CRYPTO_MAX_ALG_NAME]; |
| 50 | 49 | ||
| 51 | struct completion *completion; | 50 | struct crypto_larval *larval; |
| 52 | 51 | ||
| 53 | u32 otype; | 52 | u32 otype; |
| 54 | u32 omask; | 53 | u32 omask; |
| @@ -87,7 +86,8 @@ static int cryptomgr_probe(void *data) | |||
| 87 | crypto_tmpl_put(tmpl); | 86 | crypto_tmpl_put(tmpl); |
| 88 | 87 | ||
| 89 | out: | 88 | out: |
| 90 | complete_all(param->completion); | 89 | complete_all(¶m->larval->completion); |
| 90 | crypto_alg_put(¶m->larval->alg); | ||
| 91 | kfree(param); | 91 | kfree(param); |
| 92 | module_put_and_exit(0); | 92 | module_put_and_exit(0); |
| 93 | } | 93 | } |
| @@ -187,18 +187,19 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval) | |||
| 187 | param->otype = larval->alg.cra_flags; | 187 | param->otype = larval->alg.cra_flags; |
| 188 | param->omask = larval->mask; | 188 | param->omask = larval->mask; |
| 189 | 189 | ||
| 190 | memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME); | 190 | crypto_alg_get(&larval->alg); |
| 191 | 191 | param->larval = larval; | |
| 192 | param->completion = &larval->completion; | ||
| 193 | 192 | ||
| 194 | thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe"); | 193 | thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe"); |
| 195 | if (IS_ERR(thread)) | 194 | if (IS_ERR(thread)) |
| 196 | goto err_free_param; | 195 | goto err_put_larval; |
| 197 | 196 | ||
| 198 | wait_for_completion_interruptible(&larval->completion); | 197 | wait_for_completion_interruptible(&larval->completion); |
| 199 | 198 | ||
| 200 | return NOTIFY_STOP; | 199 | return NOTIFY_STOP; |
| 201 | 200 | ||
| 201 | err_put_larval: | ||
| 202 | crypto_alg_put(&larval->alg); | ||
| 202 | err_free_param: | 203 | err_free_param: |
| 203 | kfree(param); | 204 | kfree(param); |
| 204 | err_put_module: | 205 | err_put_module: |
diff --git a/crypto/api.c b/crypto/api.c index 033a7147e5eb..3b6180336d3d 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
| @@ -34,12 +34,6 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem); | |||
| 34 | BLOCKING_NOTIFIER_HEAD(crypto_chain); | 34 | BLOCKING_NOTIFIER_HEAD(crypto_chain); |
| 35 | EXPORT_SYMBOL_GPL(crypto_chain); | 35 | EXPORT_SYMBOL_GPL(crypto_chain); |
| 36 | 36 | ||
| 37 | static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) | ||
| 38 | { | ||
| 39 | atomic_inc(&alg->cra_refcnt); | ||
| 40 | return alg; | ||
| 41 | } | ||
| 42 | |||
| 43 | struct crypto_alg *crypto_mod_get(struct crypto_alg *alg) | 37 | struct crypto_alg *crypto_mod_get(struct crypto_alg *alg) |
| 44 | { | 38 | { |
| 45 | return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; | 39 | return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL; |
diff --git a/crypto/async_tx/Kconfig b/crypto/async_tx/Kconfig index 1b11abbb5c91..f38a58aef3ec 100644 --- a/crypto/async_tx/Kconfig +++ b/crypto/async_tx/Kconfig | |||
| @@ -10,10 +10,6 @@ config ASYNC_XOR | |||
| 10 | select ASYNC_CORE | 10 | select ASYNC_CORE |
| 11 | select XOR_BLOCKS | 11 | select XOR_BLOCKS |
| 12 | 12 | ||
| 13 | config ASYNC_MEMSET | ||
| 14 | tristate | ||
| 15 | select ASYNC_CORE | ||
| 16 | |||
| 17 | config ASYNC_PQ | 13 | config ASYNC_PQ |
| 18 | tristate | 14 | tristate |
| 19 | select ASYNC_CORE | 15 | select ASYNC_CORE |
diff --git a/crypto/async_tx/Makefile b/crypto/async_tx/Makefile index d1e0e6f72bc1..462e4abbfe69 100644 --- a/crypto/async_tx/Makefile +++ b/crypto/async_tx/Makefile | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | obj-$(CONFIG_ASYNC_CORE) += async_tx.o | 1 | obj-$(CONFIG_ASYNC_CORE) += async_tx.o |
| 2 | obj-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o | 2 | obj-$(CONFIG_ASYNC_MEMCPY) += async_memcpy.o |
| 3 | obj-$(CONFIG_ASYNC_MEMSET) += async_memset.o | ||
| 4 | obj-$(CONFIG_ASYNC_XOR) += async_xor.o | 3 | obj-$(CONFIG_ASYNC_XOR) += async_xor.o |
| 5 | obj-$(CONFIG_ASYNC_PQ) += async_pq.o | 4 | obj-$(CONFIG_ASYNC_PQ) += async_pq.o |
| 6 | obj-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o | 5 | obj-$(CONFIG_ASYNC_RAID6_RECOV) += async_raid6_recov.o |
diff --git a/crypto/async_tx/async_memset.c b/crypto/async_tx/async_memset.c deleted file mode 100644 index 05a4d1e00148..000000000000 --- a/crypto/async_tx/async_memset.c +++ /dev/null | |||
| @@ -1,89 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * memory fill offload engine support | ||
| 3 | * | ||
| 4 | * Copyright © 2006, Intel Corporation. | ||
| 5 | * | ||
| 6 | * Dan Williams <dan.j.williams@intel.com> | ||
| 7 | * | ||
| 8 | * with architecture considerations by: | ||
| 9 | * Neil Brown <neilb@suse.de> | ||
| 10 | * Jeff Garzik <jeff@garzik.org> | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify it | ||
| 13 | * under the terms and conditions of the GNU General Public License, | ||
| 14 | * version 2, as published by the Free Software Foundation. | ||
| 15 | * | ||
| 16 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
| 17 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 18 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 19 | * more details. | ||
| 20 | * | ||
| 21 | * You should have received a copy of the GNU General Public License along with | ||
| 22 | * this program; if not, write to the Free Software Foundation, Inc., | ||
| 23 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 24 | * | ||
| 25 | */ | ||
| 26 | #include <linux/kernel.h> | ||
| 27 | #include <linux/interrupt.h> | ||
| 28 | #include <linux/module.h> | ||
| 29 | #include <linux/mm.h> | ||
| 30 | #include <linux/dma-mapping.h> | ||
| 31 | #include <linux/async_tx.h> | ||
| 32 | |||
| 33 | /** | ||
| 34 | * async_memset - attempt to fill memory with a dma engine. | ||
| 35 | * @dest: destination page | ||
| 36 | * @val: fill value | ||
| 37 | * @offset: offset in pages to start transaction | ||
| 38 | * @len: length in bytes | ||
| 39 | * | ||
| 40 | * honored flags: ASYNC_TX_ACK | ||
| 41 | */ | ||
| 42 | struct dma_async_tx_descriptor * | ||
| 43 | async_memset(struct page *dest, int val, unsigned int offset, size_t len, | ||
| 44 | struct async_submit_ctl *submit) | ||
| 45 | { | ||
| 46 | struct dma_chan *chan = async_tx_find_channel(submit, DMA_MEMSET, | ||
| 47 | &dest, 1, NULL, 0, len); | ||
| 48 | struct dma_device *device = chan ? chan->device : NULL; | ||
| 49 | struct dma_async_tx_descriptor *tx = NULL; | ||
| 50 | |||
| 51 | if (device && is_dma_fill_aligned(device, offset, 0, len)) { | ||
| 52 | dma_addr_t dma_dest; | ||
| 53 | unsigned long dma_prep_flags = 0; | ||
| 54 | |||
| 55 | if (submit->cb_fn) | ||
| 56 | dma_prep_flags |= DMA_PREP_INTERRUPT; | ||
| 57 | if (submit->flags & ASYNC_TX_FENCE) | ||
| 58 | dma_prep_flags |= DMA_PREP_FENCE; | ||
| 59 | dma_dest = dma_map_page(device->dev, dest, offset, len, | ||
| 60 | DMA_FROM_DEVICE); | ||
| 61 | |||
| 62 | tx = device->device_prep_dma_memset(chan, dma_dest, val, len, | ||
| 63 | dma_prep_flags); | ||
| 64 | } | ||
| 65 | |||
| 66 | if (tx) { | ||
| 67 | pr_debug("%s: (async) len: %zu\n", __func__, len); | ||
| 68 | async_tx_submit(chan, tx, submit); | ||
| 69 | } else { /* run the memset synchronously */ | ||
| 70 | void *dest_buf; | ||
| 71 | pr_debug("%s: (sync) len: %zu\n", __func__, len); | ||
| 72 | |||
| 73 | dest_buf = page_address(dest) + offset; | ||
| 74 | |||
| 75 | /* wait for any prerequisite operations */ | ||
| 76 | async_tx_quiesce(&submit->depend_tx); | ||
| 77 | |||
| 78 | memset(dest_buf, val, len); | ||
| 79 | |||
| 80 | async_tx_sync_epilog(submit); | ||
| 81 | } | ||
| 82 | |||
| 83 | return tx; | ||
| 84 | } | ||
| 85 | EXPORT_SYMBOL_GPL(async_memset); | ||
| 86 | |||
| 87 | MODULE_AUTHOR("Intel Corporation"); | ||
| 88 | MODULE_DESCRIPTION("asynchronous memset api"); | ||
| 89 | MODULE_LICENSE("GPL"); | ||
diff --git a/crypto/internal.h b/crypto/internal.h index 9ebedae3fb54..bd39bfc92eab 100644 --- a/crypto/internal.h +++ b/crypto/internal.h | |||
| @@ -103,6 +103,12 @@ int crypto_register_notifier(struct notifier_block *nb); | |||
| 103 | int crypto_unregister_notifier(struct notifier_block *nb); | 103 | int crypto_unregister_notifier(struct notifier_block *nb); |
| 104 | int crypto_probing_notify(unsigned long val, void *v); | 104 | int crypto_probing_notify(unsigned long val, void *v); |
| 105 | 105 | ||
| 106 | static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg) | ||
| 107 | { | ||
| 108 | atomic_inc(&alg->cra_refcnt); | ||
| 109 | return alg; | ||
| 110 | } | ||
| 111 | |||
| 106 | static inline void crypto_alg_put(struct crypto_alg *alg) | 112 | static inline void crypto_alg_put(struct crypto_alg *alg) |
| 107 | { | 113 | { |
| 108 | if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) | 114 | if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy) |
diff --git a/crypto/lz4.c b/crypto/lz4.c new file mode 100644 index 000000000000..4586dd15b0d8 --- /dev/null +++ b/crypto/lz4.c | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Cryptographic API. | ||
| 3 | * | ||
| 4 | * Copyright (c) 2013 Chanho Min <chanho.min@lge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License version 2 as published by | ||
| 8 | * the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 13 | * more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License along with | ||
| 16 | * this program; if not, write to the Free Software Foundation, Inc., 51 | ||
| 17 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/init.h> | ||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/crypto.h> | ||
| 24 | #include <linux/vmalloc.h> | ||
| 25 | #include <linux/lz4.h> | ||
| 26 | |||
| 27 | struct lz4_ctx { | ||
| 28 | void *lz4_comp_mem; | ||
| 29 | }; | ||
| 30 | |||
| 31 | static int lz4_init(struct crypto_tfm *tfm) | ||
| 32 | { | ||
| 33 | struct lz4_ctx *ctx = crypto_tfm_ctx(tfm); | ||
| 34 | |||
| 35 | ctx->lz4_comp_mem = vmalloc(LZ4_MEM_COMPRESS); | ||
| 36 | if (!ctx->lz4_comp_mem) | ||
| 37 | return -ENOMEM; | ||
| 38 | |||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | |||
| 42 | static void lz4_exit(struct crypto_tfm *tfm) | ||
| 43 | { | ||
| 44 | struct lz4_ctx *ctx = crypto_tfm_ctx(tfm); | ||
| 45 | vfree(ctx->lz4_comp_mem); | ||
| 46 | } | ||
| 47 | |||
| 48 | static int lz4_compress_crypto(struct crypto_tfm *tfm, const u8 *src, | ||
| 49 | unsigned int slen, u8 *dst, unsigned int *dlen) | ||
| 50 | { | ||
| 51 | struct lz4_ctx *ctx = crypto_tfm_ctx(tfm); | ||
| 52 | size_t tmp_len = *dlen; | ||
| 53 | int err; | ||
| 54 | |||
| 55 | err = lz4_compress(src, slen, dst, &tmp_len, ctx->lz4_comp_mem); | ||
| 56 | |||
| 57 | if (err < 0) | ||
| 58 | return -EINVAL; | ||
| 59 | |||
| 60 | *dlen = tmp_len; | ||
| 61 | return 0; | ||
| 62 | } | ||
| 63 | |||
| 64 | static int lz4_decompress_crypto(struct crypto_tfm *tfm, const u8 *src, | ||
| 65 | unsigned int slen, u8 *dst, unsigned int *dlen) | ||
| 66 | { | ||
| 67 | int err; | ||
| 68 | size_t tmp_len = *dlen; | ||
| 69 | size_t __slen = slen; | ||
| 70 | |||
| 71 | err = lz4_decompress(src, &__slen, dst, tmp_len); | ||
| 72 | if (err < 0) | ||
| 73 | return -EINVAL; | ||
| 74 | |||
| 75 | *dlen = tmp_len; | ||
| 76 | return err; | ||
| 77 | } | ||
| 78 | |||
| 79 | static struct crypto_alg alg_lz4 = { | ||
| 80 | .cra_name = "lz4", | ||
| 81 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | ||
| 82 | .cra_ctxsize = sizeof(struct lz4_ctx), | ||
| 83 | .cra_module = THIS_MODULE, | ||
| 84 | .cra_list = LIST_HEAD_INIT(alg_lz4.cra_list), | ||
| 85 | .cra_init = lz4_init, | ||
| 86 | .cra_exit = lz4_exit, | ||
| 87 | .cra_u = { .compress = { | ||
| 88 | .coa_compress = lz4_compress_crypto, | ||
| 89 | .coa_decompress = lz4_decompress_crypto } } | ||
| 90 | }; | ||
| 91 | |||
| 92 | static int __init lz4_mod_init(void) | ||
| 93 | { | ||
| 94 | return crypto_register_alg(&alg_lz4); | ||
| 95 | } | ||
| 96 | |||
| 97 | static void __exit lz4_mod_fini(void) | ||
| 98 | { | ||
| 99 | crypto_unregister_alg(&alg_lz4); | ||
| 100 | } | ||
| 101 | |||
| 102 | module_init(lz4_mod_init); | ||
| 103 | module_exit(lz4_mod_fini); | ||
| 104 | |||
| 105 | MODULE_LICENSE("GPL"); | ||
| 106 | MODULE_DESCRIPTION("LZ4 Compression Algorithm"); | ||
diff --git a/crypto/lz4hc.c b/crypto/lz4hc.c new file mode 100644 index 000000000000..151ba31d34e3 --- /dev/null +++ b/crypto/lz4hc.c | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* | ||
| 2 | * Cryptographic API. | ||
| 3 | * | ||
| 4 | * Copyright (c) 2013 Chanho Min <chanho.min@lge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License version 2 as published by | ||
| 8 | * the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
| 13 | * more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License along with | ||
| 16 | * this program; if not, write to the Free Software Foundation, Inc., 51 | ||
| 17 | * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | #include <linux/init.h> | ||
| 21 | #include <linux/module.h> | ||
| 22 | #include <linux/crypto.h> | ||
| 23 | #include <linux/vmalloc.h> | ||
| 24 | #include <linux/lz4.h> | ||
| 25 | |||
| 26 | struct lz4hc_ctx { | ||
| 27 | void *lz4hc_comp_mem; | ||
| 28 | }; | ||
| 29 | |||
| 30 | static int lz4hc_init(struct crypto_tfm *tfm) | ||
| 31 | { | ||
| 32 | struct lz4hc_ctx *ctx = crypto_tfm_ctx(tfm); | ||
| 33 | |||
| 34 | ctx->lz4hc_comp_mem = vmalloc(LZ4HC_MEM_COMPRESS); | ||
| 35 | if (!ctx->lz4hc_comp_mem) | ||
| 36 | return -ENOMEM; | ||
| 37 | |||
| 38 | return 0; | ||
| 39 | } | ||
| 40 | |||
| 41 | static void lz4hc_exit(struct crypto_tfm *tfm) | ||
| 42 | { | ||
| 43 | struct lz4hc_ctx *ctx = crypto_tfm_ctx(tfm); | ||
| 44 | |||
| 45 | vfree(ctx->lz4hc_comp_mem); | ||
| 46 | } | ||
| 47 | |||
| 48 | static int lz4hc_compress_crypto(struct crypto_tfm *tfm, const u8 *src, | ||
| 49 | unsigned int slen, u8 *dst, unsigned int *dlen) | ||
| 50 | { | ||
| 51 | struct lz4hc_ctx *ctx = crypto_tfm_ctx(tfm); | ||
| 52 | size_t tmp_len = *dlen; | ||
| 53 | int err; | ||
| 54 | |||
| 55 | err = lz4hc_compress(src, slen, dst, &tmp_len, ctx->lz4hc_comp_mem); | ||
| 56 | |||
| 57 | if (err < 0) | ||
| 58 | return -EINVAL; | ||
| 59 | |||
| 60 | *dlen = tmp_len; | ||
| 61 | return 0; | ||
| 62 | } | ||
| 63 | |||
| 64 | static int lz4hc_decompress_crypto(struct crypto_tfm *tfm, const u8 *src, | ||
| 65 | unsigned int slen, u8 *dst, unsigned int *dlen) | ||
| 66 | { | ||
| 67 | int err; | ||
| 68 | size_t tmp_len = *dlen; | ||
| 69 | size_t __slen = slen; | ||
| 70 | |||
| 71 | err = lz4_decompress(src, &__slen, dst, tmp_len); | ||
| 72 | if (err < 0) | ||
| 73 | return -EINVAL; | ||
| 74 | |||
| 75 | *dlen = tmp_len; | ||
| 76 | return err; | ||
| 77 | } | ||
| 78 | |||
| 79 | static struct crypto_alg alg_lz4hc = { | ||
| 80 | .cra_name = "lz4hc", | ||
| 81 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | ||
| 82 | .cra_ctxsize = sizeof(struct lz4hc_ctx), | ||
| 83 | .cra_module = THIS_MODULE, | ||
| 84 | .cra_list = LIST_HEAD_INIT(alg_lz4hc.cra_list), | ||
| 85 | .cra_init = lz4hc_init, | ||
| 86 | .cra_exit = lz4hc_exit, | ||
| 87 | .cra_u = { .compress = { | ||
| 88 | .coa_compress = lz4hc_compress_crypto, | ||
| 89 | .coa_decompress = lz4hc_decompress_crypto } } | ||
| 90 | }; | ||
| 91 | |||
| 92 | static int __init lz4hc_mod_init(void) | ||
| 93 | { | ||
| 94 | return crypto_register_alg(&alg_lz4hc); | ||
| 95 | } | ||
| 96 | |||
| 97 | static void __exit lz4hc_mod_fini(void) | ||
| 98 | { | ||
| 99 | crypto_unregister_alg(&alg_lz4hc); | ||
| 100 | } | ||
| 101 | |||
| 102 | module_init(lz4hc_mod_init); | ||
| 103 | module_exit(lz4hc_mod_fini); | ||
| 104 | |||
| 105 | MODULE_LICENSE("GPL"); | ||
| 106 | MODULE_DESCRIPTION("LZ4HC Compression Algorithm"); | ||
diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c index b2c99dc1c5e2..f8c920cafe63 100644 --- a/crypto/pcrypt.c +++ b/crypto/pcrypt.c | |||
| @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt, | |||
| 455 | 455 | ||
| 456 | get_online_cpus(); | 456 | get_online_cpus(); |
| 457 | 457 | ||
| 458 | pcrypt->wq = alloc_workqueue(name, | 458 | pcrypt->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, |
| 459 | WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1); | 459 | 1, name); |
| 460 | if (!pcrypt->wq) | 460 | if (!pcrypt->wq) |
| 461 | goto err; | 461 | goto err; |
| 462 | 462 | ||
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c index 4c5862095679..6ed124f3ea0f 100644 --- a/crypto/sha512_generic.c +++ b/crypto/sha512_generic.c | |||
| @@ -251,6 +251,7 @@ static struct shash_alg sha512_algs[2] = { { | |||
| 251 | .descsize = sizeof(struct sha512_state), | 251 | .descsize = sizeof(struct sha512_state), |
| 252 | .base = { | 252 | .base = { |
| 253 | .cra_name = "sha512", | 253 | .cra_name = "sha512", |
| 254 | .cra_driver_name = "sha512-generic", | ||
| 254 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, | 255 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |
| 255 | .cra_blocksize = SHA512_BLOCK_SIZE, | 256 | .cra_blocksize = SHA512_BLOCK_SIZE, |
| 256 | .cra_module = THIS_MODULE, | 257 | .cra_module = THIS_MODULE, |
| @@ -263,6 +264,7 @@ static struct shash_alg sha512_algs[2] = { { | |||
| 263 | .descsize = sizeof(struct sha512_state), | 264 | .descsize = sizeof(struct sha512_state), |
| 264 | .base = { | 265 | .base = { |
| 265 | .cra_name = "sha384", | 266 | .cra_name = "sha384", |
| 267 | .cra_driver_name = "sha384-generic", | ||
| 266 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, | 268 | .cra_flags = CRYPTO_ALG_TYPE_SHASH, |
| 267 | .cra_blocksize = SHA384_BLOCK_SIZE, | 269 | .cra_blocksize = SHA384_BLOCK_SIZE, |
| 268 | .cra_module = THIS_MODULE, | 270 | .cra_module = THIS_MODULE, |
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 5823735cf381..ecddf921a9db 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
| @@ -184,8 +184,9 @@ static int do_one_async_hash_op(struct ahash_request *req, | |||
| 184 | return ret; | 184 | return ret; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, | 187 | static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, |
| 188 | unsigned int tcount, bool use_digest) | 188 | unsigned int tcount, bool use_digest, |
| 189 | const int align_offset) | ||
| 189 | { | 190 | { |
| 190 | const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm)); | 191 | const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm)); |
| 191 | unsigned int i, j, k, temp; | 192 | unsigned int i, j, k, temp; |
| @@ -216,10 +217,15 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, | |||
| 216 | if (template[i].np) | 217 | if (template[i].np) |
| 217 | continue; | 218 | continue; |
| 218 | 219 | ||
| 220 | ret = -EINVAL; | ||
| 221 | if (WARN_ON(align_offset + template[i].psize > PAGE_SIZE)) | ||
| 222 | goto out; | ||
| 223 | |||
| 219 | j++; | 224 | j++; |
| 220 | memset(result, 0, 64); | 225 | memset(result, 0, 64); |
| 221 | 226 | ||
| 222 | hash_buff = xbuf[0]; | 227 | hash_buff = xbuf[0]; |
| 228 | hash_buff += align_offset; | ||
| 223 | 229 | ||
| 224 | memcpy(hash_buff, template[i].plaintext, template[i].psize); | 230 | memcpy(hash_buff, template[i].plaintext, template[i].psize); |
| 225 | sg_init_one(&sg[0], hash_buff, template[i].psize); | 231 | sg_init_one(&sg[0], hash_buff, template[i].psize); |
| @@ -281,6 +287,10 @@ static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, | |||
| 281 | 287 | ||
| 282 | j = 0; | 288 | j = 0; |
| 283 | for (i = 0; i < tcount; i++) { | 289 | for (i = 0; i < tcount; i++) { |
| 290 | /* alignment tests are only done with continuous buffers */ | ||
| 291 | if (align_offset != 0) | ||
| 292 | break; | ||
| 293 | |||
| 284 | if (template[i].np) { | 294 | if (template[i].np) { |
| 285 | j++; | 295 | j++; |
| 286 | memset(result, 0, 64); | 296 | memset(result, 0, 64); |
| @@ -358,9 +368,36 @@ out_nobuf: | |||
| 358 | return ret; | 368 | return ret; |
| 359 | } | 369 | } |
| 360 | 370 | ||
| 371 | static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, | ||
| 372 | unsigned int tcount, bool use_digest) | ||
| 373 | { | ||
| 374 | unsigned int alignmask; | ||
| 375 | int ret; | ||
| 376 | |||
| 377 | ret = __test_hash(tfm, template, tcount, use_digest, 0); | ||
| 378 | if (ret) | ||
| 379 | return ret; | ||
| 380 | |||
| 381 | /* test unaligned buffers, check with one byte offset */ | ||
| 382 | ret = __test_hash(tfm, template, tcount, use_digest, 1); | ||
| 383 | if (ret) | ||
| 384 | return ret; | ||
| 385 | |||
| 386 | alignmask = crypto_tfm_alg_alignmask(&tfm->base); | ||
| 387 | if (alignmask) { | ||
| 388 | /* Check if alignment mask for tfm is correctly set. */ | ||
| 389 | ret = __test_hash(tfm, template, tcount, use_digest, | ||
| 390 | alignmask + 1); | ||
| 391 | if (ret) | ||
| 392 | return ret; | ||
| 393 | } | ||
| 394 | |||
| 395 | return 0; | ||
| 396 | } | ||
| 397 | |||
| 361 | static int __test_aead(struct crypto_aead *tfm, int enc, | 398 | static int __test_aead(struct crypto_aead *tfm, int enc, |
| 362 | struct aead_testvec *template, unsigned int tcount, | 399 | struct aead_testvec *template, unsigned int tcount, |
| 363 | const bool diff_dst) | 400 | const bool diff_dst, const int align_offset) |
| 364 | { | 401 | { |
| 365 | const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); | 402 | const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); |
| 366 | unsigned int i, j, k, n, temp; | 403 | unsigned int i, j, k, n, temp; |
| @@ -423,15 +460,16 @@ static int __test_aead(struct crypto_aead *tfm, int enc, | |||
| 423 | if (!template[i].np) { | 460 | if (!template[i].np) { |
| 424 | j++; | 461 | j++; |
| 425 | 462 | ||
| 426 | /* some tepmplates have no input data but they will | 463 | /* some templates have no input data but they will |
| 427 | * touch input | 464 | * touch input |
| 428 | */ | 465 | */ |
| 429 | input = xbuf[0]; | 466 | input = xbuf[0]; |
| 467 | input += align_offset; | ||
| 430 | assoc = axbuf[0]; | 468 | assoc = axbuf[0]; |
| 431 | 469 | ||
| 432 | ret = -EINVAL; | 470 | ret = -EINVAL; |
| 433 | if (WARN_ON(template[i].ilen > PAGE_SIZE || | 471 | if (WARN_ON(align_offset + template[i].ilen > |
| 434 | template[i].alen > PAGE_SIZE)) | 472 | PAGE_SIZE || template[i].alen > PAGE_SIZE)) |
| 435 | goto out; | 473 | goto out; |
| 436 | 474 | ||
| 437 | memcpy(input, template[i].input, template[i].ilen); | 475 | memcpy(input, template[i].input, template[i].ilen); |
| @@ -470,6 +508,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc, | |||
| 470 | 508 | ||
| 471 | if (diff_dst) { | 509 | if (diff_dst) { |
| 472 | output = xoutbuf[0]; | 510 | output = xoutbuf[0]; |
| 511 | output += align_offset; | ||
| 473 | sg_init_one(&sgout[0], output, | 512 | sg_init_one(&sgout[0], output, |
| 474 | template[i].ilen + | 513 | template[i].ilen + |
| 475 | (enc ? authsize : 0)); | 514 | (enc ? authsize : 0)); |
| @@ -530,6 +569,10 @@ static int __test_aead(struct crypto_aead *tfm, int enc, | |||
| 530 | } | 569 | } |
| 531 | 570 | ||
| 532 | for (i = 0, j = 0; i < tcount; i++) { | 571 | for (i = 0, j = 0; i < tcount; i++) { |
| 572 | /* alignment tests are only done with continuous buffers */ | ||
| 573 | if (align_offset != 0) | ||
| 574 | break; | ||
| 575 | |||
| 533 | if (template[i].np) { | 576 | if (template[i].np) { |
| 534 | j++; | 577 | j++; |
| 535 | 578 | ||
| @@ -732,15 +775,34 @@ out_noxbuf: | |||
| 732 | static int test_aead(struct crypto_aead *tfm, int enc, | 775 | static int test_aead(struct crypto_aead *tfm, int enc, |
| 733 | struct aead_testvec *template, unsigned int tcount) | 776 | struct aead_testvec *template, unsigned int tcount) |
| 734 | { | 777 | { |
| 778 | unsigned int alignmask; | ||
| 735 | int ret; | 779 | int ret; |
| 736 | 780 | ||
| 737 | /* test 'dst == src' case */ | 781 | /* test 'dst == src' case */ |
| 738 | ret = __test_aead(tfm, enc, template, tcount, false); | 782 | ret = __test_aead(tfm, enc, template, tcount, false, 0); |
| 739 | if (ret) | 783 | if (ret) |
| 740 | return ret; | 784 | return ret; |
| 741 | 785 | ||
| 742 | /* test 'dst != src' case */ | 786 | /* test 'dst != src' case */ |
| 743 | return __test_aead(tfm, enc, template, tcount, true); | 787 | ret = __test_aead(tfm, enc, template, tcount, true, 0); |
| 788 | if (ret) | ||
| 789 | return ret; | ||
| 790 | |||
| 791 | /* test unaligned buffers, check with one byte offset */ | ||
| 792 | ret = __test_aead(tfm, enc, template, tcount, true, 1); | ||
| 793 | if (ret) | ||
| 794 | return ret; | ||
| 795 | |||
| 796 | alignmask = crypto_tfm_alg_alignmask(&tfm->base); | ||
| 797 | if (alignmask) { | ||
| 798 | /* Check if alignment mask for tfm is correctly set. */ | ||
| 799 | ret = __test_aead(tfm, enc, template, tcount, true, | ||
| 800 | alignmask + 1); | ||
| 801 | if (ret) | ||
| 802 | return ret; | ||
| 803 | } | ||
| 804 | |||
| 805 | return 0; | ||
| 744 | } | 806 | } |
| 745 | 807 | ||
| 746 | static int test_cipher(struct crypto_cipher *tfm, int enc, | 808 | static int test_cipher(struct crypto_cipher *tfm, int enc, |
| @@ -820,7 +882,7 @@ out_nobuf: | |||
| 820 | 882 | ||
| 821 | static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, | 883 | static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, |
| 822 | struct cipher_testvec *template, unsigned int tcount, | 884 | struct cipher_testvec *template, unsigned int tcount, |
| 823 | const bool diff_dst) | 885 | const bool diff_dst, const int align_offset) |
| 824 | { | 886 | { |
| 825 | const char *algo = | 887 | const char *algo = |
| 826 | crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); | 888 | crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm)); |
| @@ -876,10 +938,12 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
| 876 | j++; | 938 | j++; |
| 877 | 939 | ||
| 878 | ret = -EINVAL; | 940 | ret = -EINVAL; |
| 879 | if (WARN_ON(template[i].ilen > PAGE_SIZE)) | 941 | if (WARN_ON(align_offset + template[i].ilen > |
| 942 | PAGE_SIZE)) | ||
| 880 | goto out; | 943 | goto out; |
| 881 | 944 | ||
| 882 | data = xbuf[0]; | 945 | data = xbuf[0]; |
| 946 | data += align_offset; | ||
| 883 | memcpy(data, template[i].input, template[i].ilen); | 947 | memcpy(data, template[i].input, template[i].ilen); |
| 884 | 948 | ||
| 885 | crypto_ablkcipher_clear_flags(tfm, ~0); | 949 | crypto_ablkcipher_clear_flags(tfm, ~0); |
| @@ -900,6 +964,7 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
| 900 | sg_init_one(&sg[0], data, template[i].ilen); | 964 | sg_init_one(&sg[0], data, template[i].ilen); |
| 901 | if (diff_dst) { | 965 | if (diff_dst) { |
| 902 | data = xoutbuf[0]; | 966 | data = xoutbuf[0]; |
| 967 | data += align_offset; | ||
| 903 | sg_init_one(&sgout[0], data, template[i].ilen); | 968 | sg_init_one(&sgout[0], data, template[i].ilen); |
| 904 | } | 969 | } |
| 905 | 970 | ||
| @@ -941,6 +1006,9 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, | |||
| 941 | 1006 | ||
| 942 | j = 0; | 1007 | j = 0; |
| 943 | for (i = 0; i < tcount; i++) { | 1008 | for (i = 0; i < tcount; i++) { |
| 1009 | /* alignment tests are only done with continuous buffers */ | ||
| 1010 | if (align_offset != 0) | ||
| 1011 | break; | ||
| 944 | 1012 | ||
| 945 | if (template[i].iv) | 1013 | if (template[i].iv) |
| 946 | memcpy(iv, template[i].iv, MAX_IVLEN); | 1014 | memcpy(iv, template[i].iv, MAX_IVLEN); |
| @@ -1075,15 +1143,34 @@ out_nobuf: | |||
| 1075 | static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, | 1143 | static int test_skcipher(struct crypto_ablkcipher *tfm, int enc, |
| 1076 | struct cipher_testvec *template, unsigned int tcount) | 1144 | struct cipher_testvec *template, unsigned int tcount) |
| 1077 | { | 1145 | { |
| 1146 | unsigned int alignmask; | ||
| 1078 | int ret; | 1147 | int ret; |
| 1079 | 1148 | ||
| 1080 | /* test 'dst == src' case */ | 1149 | /* test 'dst == src' case */ |
| 1081 | ret = __test_skcipher(tfm, enc, template, tcount, false); | 1150 | ret = __test_skcipher(tfm, enc, template, tcount, false, 0); |
| 1082 | if (ret) | 1151 | if (ret) |
| 1083 | return ret; | 1152 | return ret; |
| 1084 | 1153 | ||
| 1085 | /* test 'dst != src' case */ | 1154 | /* test 'dst != src' case */ |
| 1086 | return __test_skcipher(tfm, enc, template, tcount, true); | 1155 | ret = __test_skcipher(tfm, enc, template, tcount, true, 0); |
| 1156 | if (ret) | ||
| 1157 | return ret; | ||
| 1158 | |||
| 1159 | /* test unaligned buffers, check with one byte offset */ | ||
| 1160 | ret = __test_skcipher(tfm, enc, template, tcount, true, 1); | ||
| 1161 | if (ret) | ||
| 1162 | return ret; | ||
| 1163 | |||
| 1164 | alignmask = crypto_tfm_alg_alignmask(&tfm->base); | ||
| 1165 | if (alignmask) { | ||
| 1166 | /* Check if alignment mask for tfm is correctly set. */ | ||
| 1167 | ret = __test_skcipher(tfm, enc, template, tcount, true, | ||
| 1168 | alignmask + 1); | ||
| 1169 | if (ret) | ||
| 1170 | return ret; | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | return 0; | ||
| 1087 | } | 1174 | } |
| 1088 | 1175 | ||
| 1089 | static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, | 1176 | static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, |
| @@ -1654,16 +1741,10 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 1654 | .alg = "__cbc-twofish-avx", | 1741 | .alg = "__cbc-twofish-avx", |
| 1655 | .test = alg_test_null, | 1742 | .test = alg_test_null, |
| 1656 | }, { | 1743 | }, { |
| 1657 | .alg = "__cbc-twofish-avx2", | ||
| 1658 | .test = alg_test_null, | ||
| 1659 | }, { | ||
| 1660 | .alg = "__driver-cbc-aes-aesni", | 1744 | .alg = "__driver-cbc-aes-aesni", |
| 1661 | .test = alg_test_null, | 1745 | .test = alg_test_null, |
| 1662 | .fips_allowed = 1, | 1746 | .fips_allowed = 1, |
| 1663 | }, { | 1747 | }, { |
| 1664 | .alg = "__driver-cbc-blowfish-avx2", | ||
| 1665 | .test = alg_test_null, | ||
| 1666 | }, { | ||
| 1667 | .alg = "__driver-cbc-camellia-aesni", | 1748 | .alg = "__driver-cbc-camellia-aesni", |
| 1668 | .test = alg_test_null, | 1749 | .test = alg_test_null, |
| 1669 | }, { | 1750 | }, { |
| @@ -1688,16 +1769,10 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 1688 | .alg = "__driver-cbc-twofish-avx", | 1769 | .alg = "__driver-cbc-twofish-avx", |
| 1689 | .test = alg_test_null, | 1770 | .test = alg_test_null, |
| 1690 | }, { | 1771 | }, { |
| 1691 | .alg = "__driver-cbc-twofish-avx2", | ||
| 1692 | .test = alg_test_null, | ||
| 1693 | }, { | ||
| 1694 | .alg = "__driver-ecb-aes-aesni", | 1772 | .alg = "__driver-ecb-aes-aesni", |
| 1695 | .test = alg_test_null, | 1773 | .test = alg_test_null, |
| 1696 | .fips_allowed = 1, | 1774 | .fips_allowed = 1, |
| 1697 | }, { | 1775 | }, { |
| 1698 | .alg = "__driver-ecb-blowfish-avx2", | ||
| 1699 | .test = alg_test_null, | ||
| 1700 | }, { | ||
| 1701 | .alg = "__driver-ecb-camellia-aesni", | 1776 | .alg = "__driver-ecb-camellia-aesni", |
| 1702 | .test = alg_test_null, | 1777 | .test = alg_test_null, |
| 1703 | }, { | 1778 | }, { |
| @@ -1722,9 +1797,6 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 1722 | .alg = "__driver-ecb-twofish-avx", | 1797 | .alg = "__driver-ecb-twofish-avx", |
| 1723 | .test = alg_test_null, | 1798 | .test = alg_test_null, |
| 1724 | }, { | 1799 | }, { |
| 1725 | .alg = "__driver-ecb-twofish-avx2", | ||
| 1726 | .test = alg_test_null, | ||
| 1727 | }, { | ||
| 1728 | .alg = "__ghash-pclmulqdqni", | 1800 | .alg = "__ghash-pclmulqdqni", |
| 1729 | .test = alg_test_null, | 1801 | .test = alg_test_null, |
| 1730 | .fips_allowed = 1, | 1802 | .fips_allowed = 1, |
| @@ -1978,9 +2050,6 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 1978 | .test = alg_test_null, | 2050 | .test = alg_test_null, |
| 1979 | .fips_allowed = 1, | 2051 | .fips_allowed = 1, |
| 1980 | }, { | 2052 | }, { |
| 1981 | .alg = "cryptd(__driver-cbc-blowfish-avx2)", | ||
| 1982 | .test = alg_test_null, | ||
| 1983 | }, { | ||
| 1984 | .alg = "cryptd(__driver-cbc-camellia-aesni)", | 2053 | .alg = "cryptd(__driver-cbc-camellia-aesni)", |
| 1985 | .test = alg_test_null, | 2054 | .test = alg_test_null, |
| 1986 | }, { | 2055 | }, { |
| @@ -1994,9 +2063,6 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 1994 | .test = alg_test_null, | 2063 | .test = alg_test_null, |
| 1995 | .fips_allowed = 1, | 2064 | .fips_allowed = 1, |
| 1996 | }, { | 2065 | }, { |
| 1997 | .alg = "cryptd(__driver-ecb-blowfish-avx2)", | ||
| 1998 | .test = alg_test_null, | ||
| 1999 | }, { | ||
| 2000 | .alg = "cryptd(__driver-ecb-camellia-aesni)", | 2066 | .alg = "cryptd(__driver-ecb-camellia-aesni)", |
| 2001 | .test = alg_test_null, | 2067 | .test = alg_test_null, |
| 2002 | }, { | 2068 | }, { |
| @@ -2021,9 +2087,6 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 2021 | .alg = "cryptd(__driver-ecb-twofish-avx)", | 2087 | .alg = "cryptd(__driver-ecb-twofish-avx)", |
| 2022 | .test = alg_test_null, | 2088 | .test = alg_test_null, |
| 2023 | }, { | 2089 | }, { |
| 2024 | .alg = "cryptd(__driver-ecb-twofish-avx2)", | ||
| 2025 | .test = alg_test_null, | ||
| 2026 | }, { | ||
| 2027 | .alg = "cryptd(__driver-gcm-aes-aesni)", | 2090 | .alg = "cryptd(__driver-gcm-aes-aesni)", |
| 2028 | .test = alg_test_null, | 2091 | .test = alg_test_null, |
| 2029 | .fips_allowed = 1, | 2092 | .fips_allowed = 1, |
| @@ -3068,6 +3131,35 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 3068 | } | 3131 | } |
| 3069 | }; | 3132 | }; |
| 3070 | 3133 | ||
| 3134 | static bool alg_test_descs_checked; | ||
| 3135 | |||
| 3136 | static void alg_test_descs_check_order(void) | ||
| 3137 | { | ||
| 3138 | int i; | ||
| 3139 | |||
| 3140 | /* only check once */ | ||
| 3141 | if (alg_test_descs_checked) | ||
| 3142 | return; | ||
| 3143 | |||
| 3144 | alg_test_descs_checked = true; | ||
| 3145 | |||
| 3146 | for (i = 1; i < ARRAY_SIZE(alg_test_descs); i++) { | ||
| 3147 | int diff = strcmp(alg_test_descs[i - 1].alg, | ||
| 3148 | alg_test_descs[i].alg); | ||
| 3149 | |||
| 3150 | if (WARN_ON(diff > 0)) { | ||
| 3151 | pr_warn("testmgr: alg_test_descs entries in wrong order: '%s' before '%s'\n", | ||
| 3152 | alg_test_descs[i - 1].alg, | ||
| 3153 | alg_test_descs[i].alg); | ||
| 3154 | } | ||
| 3155 | |||
| 3156 | if (WARN_ON(diff == 0)) { | ||
| 3157 | pr_warn("testmgr: duplicate alg_test_descs entry: '%s'\n", | ||
| 3158 | alg_test_descs[i].alg); | ||
| 3159 | } | ||
| 3160 | } | ||
| 3161 | } | ||
| 3162 | |||
| 3071 | static int alg_find_test(const char *alg) | 3163 | static int alg_find_test(const char *alg) |
| 3072 | { | 3164 | { |
| 3073 | int start = 0; | 3165 | int start = 0; |
| @@ -3099,6 +3191,8 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask) | |||
| 3099 | int j; | 3191 | int j; |
| 3100 | int rc; | 3192 | int rc; |
| 3101 | 3193 | ||
| 3194 | alg_test_descs_check_order(); | ||
| 3195 | |||
| 3102 | if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { | 3196 | if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) { |
| 3103 | char nalg[CRYPTO_MAX_ALG_NAME]; | 3197 | char nalg[CRYPTO_MAX_ALG_NAME]; |
| 3104 | 3198 | ||
