mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: - Optimised AES/SHA1 for ARM. - IPsec ESN support in talitos and caam. - x86_64/avx implementation of cast5/cast6. - Add/use multi-algorithm registration helpers where possible. - Added IBM Power7+ in-Nest support. - Misc fixes. Fix up trivial conflicts in crypto/Kconfig due to the sparc64 crypto config options being added next to the new ARM ones. [ Side note: cut-and-paste duplicate help texts make those conflicts harder to read than necessary, thanks to git being smart about minimizing conflicts and maximizing the common parts... ] * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (71 commits) crypto: x86/glue_helper - fix storing of new IV in CBC encryption crypto: cast5/avx - fix storing of new IV in CBC encryption crypto: tcrypt - add missing tests for camellia and ghash crypto: testmgr - make test_aead also test 'dst != src' code paths crypto: testmgr - make test_skcipher also test 'dst != src' code paths crypto: testmgr - add test vectors for CTR mode IV increasement crypto: testmgr - add test vectors for partial ctr(cast5) and ctr(cast6) crypto: testmgr - allow non-multi page and multi page skcipher tests from same test template crypto: caam - increase TRNG clocks per sample crypto, tcrypt: remove local_bh_disable/enable() around local_irq_disable/enable() crypto: tegra-aes - fix error return code crypto: crypto4xx - fix error return code crypto: hifn_795x - fix error return code crypto: ux500 - fix error return code crypto: caam - fix error IDs for SEC v5.x RNG4 hwrng: mxc-rnga - Access data via structure hwrng: mxc-rnga - Adapt clocks to new i.mx clock framework crypto: caam - add IPsec ESN support crypto: 842 - remove .cra_list initialization Revert "[CRYPTO] cast6: inline bloat--" ...
This commit is contained in:
commit
d66e6737d4
100 changed files with 12277 additions and 2557 deletions
182
crypto/842.c
Normal file
182
crypto/842.c
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Cryptographic API for the 842 compression algorithm.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* Copyright (C) IBM Corporation, 2011
|
||||
*
|
||||
* Authors: Robert Jennings <rcj@linux.vnet.ibm.com>
|
||||
* Seth Jennings <sjenning@linux.vnet.ibm.com>
|
||||
*/
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/nx842.h>
|
||||
#include <linux/lzo.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
static int nx842_uselzo;
|
||||
|
||||
struct nx842_ctx {
|
||||
void *nx842_wmem; /* working memory for 842/lzo */
|
||||
};
|
||||
|
||||
enum nx842_crypto_type {
|
||||
NX842_CRYPTO_TYPE_842,
|
||||
NX842_CRYPTO_TYPE_LZO
|
||||
};
|
||||
|
||||
#define NX842_SENTINEL 0xdeadbeef
|
||||
|
||||
struct nx842_crypto_header {
|
||||
unsigned int sentinel; /* debug */
|
||||
enum nx842_crypto_type type;
|
||||
};
|
||||
|
||||
static int nx842_init(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct nx842_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
int wmemsize;
|
||||
|
||||
wmemsize = max_t(int, nx842_get_workmem_size(), LZO1X_MEM_COMPRESS);
|
||||
ctx->nx842_wmem = kmalloc(wmemsize, GFP_NOFS);
|
||||
if (!ctx->nx842_wmem)
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nx842_exit(struct crypto_tfm *tfm)
|
||||
{
|
||||
struct nx842_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
|
||||
kfree(ctx->nx842_wmem);
|
||||
}
|
||||
|
||||
static void nx842_reset_uselzo(unsigned long data)
|
||||
{
|
||||
nx842_uselzo = 0;
|
||||
}
|
||||
|
||||
static DEFINE_TIMER(failover_timer, nx842_reset_uselzo, 0, 0);
|
||||
|
||||
static int nx842_crypto_compress(struct crypto_tfm *tfm, const u8 *src,
|
||||
unsigned int slen, u8 *dst, unsigned int *dlen)
|
||||
{
|
||||
struct nx842_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
struct nx842_crypto_header *hdr;
|
||||
unsigned int tmp_len = *dlen;
|
||||
size_t lzodlen; /* needed for lzo */
|
||||
int err;
|
||||
|
||||
*dlen = 0;
|
||||
hdr = (struct nx842_crypto_header *)dst;
|
||||
hdr->sentinel = NX842_SENTINEL; /* debug */
|
||||
dst += sizeof(struct nx842_crypto_header);
|
||||
tmp_len -= sizeof(struct nx842_crypto_header);
|
||||
lzodlen = tmp_len;
|
||||
|
||||
if (likely(!nx842_uselzo)) {
|
||||
err = nx842_compress(src, slen, dst, &tmp_len, ctx->nx842_wmem);
|
||||
|
||||
if (likely(!err)) {
|
||||
hdr->type = NX842_CRYPTO_TYPE_842;
|
||||
*dlen = tmp_len + sizeof(struct nx842_crypto_header);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* hardware failed */
|
||||
nx842_uselzo = 1;
|
||||
|
||||
/* set timer to check for hardware again in 1 second */
|
||||
mod_timer(&failover_timer, jiffies + msecs_to_jiffies(1000));
|
||||
}
|
||||
|
||||
/* no hardware, use lzo */
|
||||
err = lzo1x_1_compress(src, slen, dst, &lzodlen, ctx->nx842_wmem);
|
||||
if (err != LZO_E_OK)
|
||||
return -EINVAL;
|
||||
|
||||
hdr->type = NX842_CRYPTO_TYPE_LZO;
|
||||
*dlen = lzodlen + sizeof(struct nx842_crypto_header);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nx842_crypto_decompress(struct crypto_tfm *tfm, const u8 *src,
|
||||
unsigned int slen, u8 *dst, unsigned int *dlen)
|
||||
{
|
||||
struct nx842_ctx *ctx = crypto_tfm_ctx(tfm);
|
||||
struct nx842_crypto_header *hdr;
|
||||
unsigned int tmp_len = *dlen;
|
||||
size_t lzodlen; /* needed for lzo */
|
||||
int err;
|
||||
|
||||
*dlen = 0;
|
||||
hdr = (struct nx842_crypto_header *)src;
|
||||
|
||||
if (unlikely(hdr->sentinel != NX842_SENTINEL))
|
||||
return -EINVAL;
|
||||
|
||||
src += sizeof(struct nx842_crypto_header);
|
||||
slen -= sizeof(struct nx842_crypto_header);
|
||||
|
||||
if (likely(hdr->type == NX842_CRYPTO_TYPE_842)) {
|
||||
err = nx842_decompress(src, slen, dst, &tmp_len,
|
||||
ctx->nx842_wmem);
|
||||
if (err)
|
||||
return -EINVAL;
|
||||
*dlen = tmp_len;
|
||||
} else if (hdr->type == NX842_CRYPTO_TYPE_LZO) {
|
||||
lzodlen = tmp_len;
|
||||
err = lzo1x_decompress_safe(src, slen, dst, &lzodlen);
|
||||
if (err != LZO_E_OK)
|
||||
return -EINVAL;
|
||||
*dlen = lzodlen;
|
||||
} else
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct crypto_alg alg = {
|
||||
.cra_name = "842",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
|
||||
.cra_ctxsize = sizeof(struct nx842_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_init = nx842_init,
|
||||
.cra_exit = nx842_exit,
|
||||
.cra_u = { .compress = {
|
||||
.coa_compress = nx842_crypto_compress,
|
||||
.coa_decompress = nx842_crypto_decompress } }
|
||||
};
|
||||
|
||||
static int __init nx842_mod_init(void)
|
||||
{
|
||||
del_timer(&failover_timer);
|
||||
return crypto_register_alg(&alg);
|
||||
}
|
||||
|
||||
static void __exit nx842_mod_exit(void)
|
||||
{
|
||||
crypto_unregister_alg(&alg);
|
||||
}
|
||||
|
||||
module_init(nx842_mod_init);
|
||||
module_exit(nx842_mod_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("842 Compression Algorithm");
|
||||
|
|
@ -460,6 +460,15 @@ config CRYPTO_SHA1_SPARC64
|
|||
SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented
|
||||
using sparc64 crypto instructions, when available.
|
||||
|
||||
config CRYPTO_SHA1_ARM
|
||||
tristate "SHA1 digest algorithm (ARM-asm)"
|
||||
depends on ARM
|
||||
select CRYPTO_SHA1
|
||||
select CRYPTO_HASH
|
||||
help
|
||||
SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2) implemented
|
||||
using optimized ARM assembler.
|
||||
|
||||
config CRYPTO_SHA256
|
||||
tristate "SHA224 and SHA256 digest algorithm"
|
||||
select CRYPTO_HASH
|
||||
|
|
@ -609,6 +618,8 @@ config CRYPTO_AES_NI_INTEL
|
|||
select CRYPTO_CRYPTD
|
||||
select CRYPTO_ABLK_HELPER_X86
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_LRW
|
||||
select CRYPTO_XTS
|
||||
help
|
||||
Use Intel AES-NI instructions for AES algorithm.
|
||||
|
||||
|
|
@ -661,6 +672,30 @@ config CRYPTO_AES_SPARC64
|
|||
for some popular block cipher mode is supported too, including
|
||||
ECB and CBC.
|
||||
|
||||
config CRYPTO_AES_ARM
|
||||
tristate "AES cipher algorithms (ARM-asm)"
|
||||
depends on ARM
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_AES
|
||||
help
|
||||
Use optimized AES assembler routines for ARM platforms.
|
||||
|
||||
AES cipher algorithms (FIPS-197). AES uses the Rijndael
|
||||
algorithm.
|
||||
|
||||
Rijndael appears to be consistently a very good performer in
|
||||
both hardware and software across a wide range of computing
|
||||
environments regardless of its use in feedback or non-feedback
|
||||
modes. Its key setup time is excellent, and its key agility is
|
||||
good. Rijndael's very low memory requirements make it very well
|
||||
suited for restricted-space environments, in which it also
|
||||
demonstrates excellent performance. Rijndael's operations are
|
||||
among the easiest to defend against power and timing attacks.
|
||||
|
||||
The AES specifies three key sizes: 128, 192 and 256 bits
|
||||
|
||||
See <http://csrc.nist.gov/encryption/aes/> for more information.
|
||||
|
||||
config CRYPTO_ANUBIS
|
||||
tristate "Anubis cipher algorithm"
|
||||
select CRYPTO_ALGAPI
|
||||
|
|
@ -781,6 +816,20 @@ config CRYPTO_CAST5
|
|||
The CAST5 encryption algorithm (synonymous with CAST-128) is
|
||||
described in RFC2144.
|
||||
|
||||
config CRYPTO_CAST5_AVX_X86_64
|
||||
tristate "CAST5 (CAST-128) cipher algorithm (x86_64/AVX)"
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_CRYPTD
|
||||
select CRYPTO_ABLK_HELPER_X86
|
||||
select CRYPTO_CAST5
|
||||
help
|
||||
The CAST5 encryption algorithm (synonymous with CAST-128) is
|
||||
described in RFC2144.
|
||||
|
||||
This module provides the Cast5 cipher algorithm that processes
|
||||
sixteen blocks parallel using the AVX instruction set.
|
||||
|
||||
config CRYPTO_CAST6
|
||||
tristate "CAST6 (CAST-256) cipher algorithm"
|
||||
select CRYPTO_ALGAPI
|
||||
|
|
@ -788,6 +837,23 @@ config CRYPTO_CAST6
|
|||
The CAST6 encryption algorithm (synonymous with CAST-256) is
|
||||
described in RFC2612.
|
||||
|
||||
config CRYPTO_CAST6_AVX_X86_64
|
||||
tristate "CAST6 (CAST-256) cipher algorithm (x86_64/AVX)"
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_ALGAPI
|
||||
select CRYPTO_CRYPTD
|
||||
select CRYPTO_ABLK_HELPER_X86
|
||||
select CRYPTO_GLUE_HELPER_X86
|
||||
select CRYPTO_CAST6
|
||||
select CRYPTO_LRW
|
||||
select CRYPTO_XTS
|
||||
help
|
||||
The CAST6 encryption algorithm (synonymous with CAST-256) is
|
||||
described in RFC2612.
|
||||
|
||||
This module provides the Cast6 cipher algorithm that processes
|
||||
eight blocks parallel using the AVX instruction set.
|
||||
|
||||
config CRYPTO_DES
|
||||
tristate "DES and Triple DES EDE cipher algorithms"
|
||||
select CRYPTO_ALGAPI
|
||||
|
|
@ -1106,6 +1172,15 @@ config CRYPTO_LZO
|
|||
help
|
||||
This is the LZO algorithm.
|
||||
|
||||
config CRYPTO_842
|
||||
tristate "842 compression algorithm"
|
||||
depends on CRYPTO_DEV_NX_COMPRESS
|
||||
# 842 uses lzo if the hardware becomes unavailable
|
||||
select LZO_COMPRESS
|
||||
select LZO_DECOMPRESS
|
||||
help
|
||||
This is the 842 algorithm.
|
||||
|
||||
comment "Random Number Generation"
|
||||
|
||||
config CRYPTO_ANSI_CPRNG
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@ obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
|
|||
obj-$(CONFIG_CRYPTO_SERPENT) += serpent_generic.o
|
||||
obj-$(CONFIG_CRYPTO_AES) += aes_generic.o
|
||||
obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia_generic.o
|
||||
obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
|
||||
obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
|
||||
obj-$(CONFIG_CRYPTO_CAST5) += cast5_generic.o
|
||||
obj-$(CONFIG_CRYPTO_CAST6) += cast6_generic.o
|
||||
obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
|
||||
obj-$(CONFIG_CRYPTO_TEA) += tea.o
|
||||
obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o
|
||||
|
|
@ -82,6 +82,7 @@ obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
|
|||
obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o
|
||||
obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o
|
||||
obj-$(CONFIG_CRYPTO_LZO) += lzo.o
|
||||
obj-$(CONFIG_CRYPTO_842) += 842.o
|
||||
obj-$(CONFIG_CRYPTO_RNG2) += rng.o
|
||||
obj-$(CONFIG_CRYPTO_RNG2) += krng.o
|
||||
obj-$(CONFIG_CRYPTO_ANSI_CPRNG) += ansi_cprng.o
|
||||
|
|
|
|||
|
|
@ -1448,7 +1448,6 @@ static struct crypto_alg aes_alg = {
|
|||
.cra_ctxsize = sizeof(struct crypto_aes_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(aes_alg.cra_list),
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = AES_MIN_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -382,26 +382,6 @@ static int cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct crypto_alg rng_alg = {
|
||||
.cra_name = "stdrng",
|
||||
.cra_driver_name = "ansi_cprng",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_RNG,
|
||||
.cra_ctxsize = sizeof(struct prng_context),
|
||||
.cra_type = &crypto_rng_type,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(rng_alg.cra_list),
|
||||
.cra_init = cprng_init,
|
||||
.cra_exit = cprng_exit,
|
||||
.cra_u = {
|
||||
.rng = {
|
||||
.rng_make_random = cprng_get_random,
|
||||
.rng_reset = cprng_reset,
|
||||
.seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CRYPTO_FIPS
|
||||
static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
|
||||
unsigned int dlen)
|
||||
|
|
@ -438,8 +418,27 @@ static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
|
|||
out:
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct crypto_alg fips_rng_alg = {
|
||||
static struct crypto_alg rng_algs[] = { {
|
||||
.cra_name = "stdrng",
|
||||
.cra_driver_name = "ansi_cprng",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_RNG,
|
||||
.cra_ctxsize = sizeof(struct prng_context),
|
||||
.cra_type = &crypto_rng_type,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_init = cprng_init,
|
||||
.cra_exit = cprng_exit,
|
||||
.cra_u = {
|
||||
.rng = {
|
||||
.rng_make_random = cprng_get_random,
|
||||
.rng_reset = cprng_reset,
|
||||
.seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ,
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_CRYPTO_FIPS
|
||||
}, {
|
||||
.cra_name = "fips(ansi_cprng)",
|
||||
.cra_driver_name = "fips_ansi_cprng",
|
||||
.cra_priority = 300,
|
||||
|
|
@ -447,7 +446,6 @@ static struct crypto_alg fips_rng_alg = {
|
|||
.cra_ctxsize = sizeof(struct prng_context),
|
||||
.cra_type = &crypto_rng_type,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(rng_alg.cra_list),
|
||||
.cra_init = cprng_init,
|
||||
.cra_exit = cprng_exit,
|
||||
.cra_u = {
|
||||
|
|
@ -457,33 +455,18 @@ static struct crypto_alg fips_rng_alg = {
|
|||
.seedsize = DEFAULT_PRNG_KSZ + 2*DEFAULT_BLK_SZ,
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
} };
|
||||
|
||||
/* Module initalization */
|
||||
static int __init prng_mod_init(void)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
rc = crypto_register_alg(&rng_alg);
|
||||
#ifdef CONFIG_CRYPTO_FIPS
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
rc = crypto_register_alg(&fips_rng_alg);
|
||||
|
||||
out:
|
||||
#endif
|
||||
return rc;
|
||||
return crypto_register_algs(rng_algs, ARRAY_SIZE(rng_algs));
|
||||
}
|
||||
|
||||
static void __exit prng_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&rng_alg);
|
||||
#ifdef CONFIG_CRYPTO_FIPS
|
||||
crypto_unregister_alg(&fips_rng_alg);
|
||||
#endif
|
||||
return;
|
||||
crypto_unregister_algs(rng_algs, ARRAY_SIZE(rng_algs));
|
||||
}
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
|
|||
|
|
@ -678,7 +678,6 @@ static struct crypto_alg anubis_alg = {
|
|||
.cra_ctxsize = sizeof (struct anubis_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(anubis_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = ANUBIS_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = ANUBIS_MAX_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ static struct crypto_alg alg = {
|
|||
.cra_ctxsize = sizeof(struct bf_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = BF_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = BF_MAX_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -1072,7 +1072,6 @@ static struct crypto_alg camellia_alg = {
|
|||
.cra_ctxsize = sizeof(struct camellia_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(camellia_alg.cra_list),
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = CAMELLIA_MIN_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
* Derived from GnuPG implementation of cast5.
|
||||
*
|
||||
* Major Changes.
|
||||
* Complete conformance to rfc2144.
|
||||
* Supports key size from 40 to 128 bits.
|
||||
* Complete conformance to rfc2144.
|
||||
* Supports key size from 40 to 128 bits.
|
||||
*
|
||||
* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
|
||||
* Copyright (C) 2003 Kartikey Mahendra Bhatt <kartik_me@hotmail.com>.
|
||||
|
|
@ -28,19 +28,10 @@
|
|||
#include <linux/errno.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define CAST5_BLOCK_SIZE 8
|
||||
#define CAST5_MIN_KEY_SIZE 5
|
||||
#define CAST5_MAX_KEY_SIZE 16
|
||||
|
||||
struct cast5_ctx {
|
||||
u32 Km[16];
|
||||
u8 Kr[16];
|
||||
int rr; /* rr?number of rounds = 16:number of rounds = 12; (rfc 2144) */
|
||||
};
|
||||
#include <crypto/cast5.h>
|
||||
|
||||
|
||||
static const u32 s1[256] = {
|
||||
const u32 cast5_s1[256] = {
|
||||
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f,
|
||||
0x9c004dd3, 0x6003e540, 0xcf9fc949,
|
||||
0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0,
|
||||
|
|
@ -106,7 +97,8 @@ static const u32 s1[256] = {
|
|||
0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c,
|
||||
0x5ac9f049, 0xdd8f0f00, 0x5c8165bf
|
||||
};
|
||||
static const u32 s2[256] = {
|
||||
EXPORT_SYMBOL_GPL(cast5_s1);
|
||||
const u32 cast5_s2[256] = {
|
||||
0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a,
|
||||
0xeec5207a, 0x55889c94, 0x72fc0651,
|
||||
0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef,
|
||||
|
|
@ -172,7 +164,8 @@ static const u32 s2[256] = {
|
|||
0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539,
|
||||
0x73bfbe70, 0x83877605, 0x4523ecf1
|
||||
};
|
||||
static const u32 s3[256] = {
|
||||
EXPORT_SYMBOL_GPL(cast5_s2);
|
||||
const u32 cast5_s3[256] = {
|
||||
0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff,
|
||||
0x369fe44b, 0x8c1fc644, 0xaececa90,
|
||||
0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806,
|
||||
|
|
@ -238,7 +231,8 @@ static const u32 s3[256] = {
|
|||
0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636,
|
||||
0xa133c501, 0xe9d3531c, 0xee353783
|
||||
};
|
||||
static const u32 s4[256] = {
|
||||
EXPORT_SYMBOL_GPL(cast5_s3);
|
||||
const u32 cast5_s4[256] = {
|
||||
0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb,
|
||||
0x64ad8c57, 0x85510443, 0xfa020ed1,
|
||||
0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43,
|
||||
|
|
@ -304,6 +298,7 @@ static const u32 s4[256] = {
|
|||
0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0,
|
||||
0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cast5_s4);
|
||||
static const u32 s5[256] = {
|
||||
0x7ec90c04, 0x2c6e74b9, 0x9b0e66df, 0xa6337911, 0xb86a7fff,
|
||||
0x1dd358f5, 0x44dd9d44, 0x1731167f,
|
||||
|
|
@ -569,17 +564,21 @@ static const u32 sb8[256] = {
|
|||
0xeaee6801, 0x8db2a283, 0xea8bf59e
|
||||
};
|
||||
|
||||
#define s1 cast5_s1
|
||||
#define s2 cast5_s2
|
||||
#define s3 cast5_s3
|
||||
#define s4 cast5_s4
|
||||
|
||||
#define F1(D, m, r) ((I = ((m) + (D))), (I = rol32(I, (r))), \
|
||||
(((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
|
||||
(((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
|
||||
#define F2(D, m, r) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \
|
||||
(((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
|
||||
(((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
|
||||
#define F3(D, m, r) ((I = ((m) - (D))), (I = rol32(I, (r))), \
|
||||
(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
|
||||
(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
|
||||
|
||||
|
||||
static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
void __cast5_encrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
struct cast5_ctx *c = crypto_tfm_ctx(tfm);
|
||||
const __be32 *src = (const __be32 *)inbuf;
|
||||
__be32 *dst = (__be32 *)outbuf;
|
||||
u32 l, r, t;
|
||||
|
|
@ -628,10 +627,15 @@ static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
|||
dst[0] = cpu_to_be32(r);
|
||||
dst[1] = cpu_to_be32(l);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__cast5_encrypt);
|
||||
|
||||
static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
__cast5_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
|
||||
}
|
||||
|
||||
void __cast5_decrypt(struct cast5_ctx *c, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
struct cast5_ctx *c = crypto_tfm_ctx(tfm);
|
||||
const __be32 *src = (const __be32 *)inbuf;
|
||||
__be32 *dst = (__be32 *)outbuf;
|
||||
u32 l, r, t;
|
||||
|
|
@ -667,6 +671,12 @@ static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
|||
dst[0] = cpu_to_be32(r);
|
||||
dst[1] = cpu_to_be32(l);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__cast5_decrypt);
|
||||
|
||||
static void cast5_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
__cast5_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
|
||||
}
|
||||
|
||||
static void key_schedule(u32 *x, u32 *z, u32 *k)
|
||||
{
|
||||
|
|
@ -743,7 +753,7 @@ static void key_schedule(u32 *x, u32 *z, u32 *k)
|
|||
}
|
||||
|
||||
|
||||
static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned key_len)
|
||||
int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len)
|
||||
{
|
||||
struct cast5_ctx *c = crypto_tfm_ctx(tfm);
|
||||
int i;
|
||||
|
|
@ -771,20 +781,22 @@ static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned key_len)
|
|||
c->Kr[i] = k[i] & 0x1f;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cast5_setkey);
|
||||
|
||||
static struct crypto_alg alg = {
|
||||
.cra_name = "cast5",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = CAST5_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct cast5_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_u = {
|
||||
.cra_name = "cast5",
|
||||
.cra_driver_name = "cast5-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = CAST5_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct cast5_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = CAST5_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = CAST5_MAX_KEY_SIZE,
|
||||
.cia_setkey = cast5_setkey,
|
||||
.cia_setkey = cast5_setkey,
|
||||
.cia_encrypt = cast5_encrypt,
|
||||
.cia_decrypt = cast5_decrypt
|
||||
}
|
||||
|
|
@ -806,4 +818,4 @@ module_exit(cast5_mod_fini);
|
|||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Cast5 Cipher Algorithm");
|
||||
|
||||
MODULE_ALIAS("cast5");
|
||||
|
|
@ -25,24 +25,21 @@
|
|||
#include <linux/errno.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
#include <crypto/cast6.h>
|
||||
|
||||
#define CAST6_BLOCK_SIZE 16
|
||||
#define CAST6_MIN_KEY_SIZE 16
|
||||
#define CAST6_MAX_KEY_SIZE 32
|
||||
|
||||
struct cast6_ctx {
|
||||
u32 Km[12][4];
|
||||
u8 Kr[12][4];
|
||||
};
|
||||
#define s1 cast6_s1
|
||||
#define s2 cast6_s2
|
||||
#define s3 cast6_s3
|
||||
#define s4 cast6_s4
|
||||
|
||||
#define F1(D, r, m) ((I = ((m) + (D))), (I = rol32(I, (r))), \
|
||||
(((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
|
||||
(((s1[I >> 24] ^ s2[(I>>16)&0xff]) - s3[(I>>8)&0xff]) + s4[I&0xff]))
|
||||
#define F2(D, r, m) ((I = ((m) ^ (D))), (I = rol32(I, (r))), \
|
||||
(((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
|
||||
(((s1[I >> 24] - s2[(I>>16)&0xff]) + s3[(I>>8)&0xff]) ^ s4[I&0xff]))
|
||||
#define F3(D, r, m) ((I = ((m) - (D))), (I = rol32(I, (r))), \
|
||||
(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
|
||||
(((s1[I >> 24] + s2[(I>>16)&0xff]) ^ s3[(I>>8)&0xff]) - s4[I&0xff]))
|
||||
|
||||
static const u32 s1[256] = {
|
||||
const u32 cast6_s1[256] = {
|
||||
0x30fb40d4, 0x9fa0ff0b, 0x6beccd2f, 0x3f258c7a, 0x1e213f2f,
|
||||
0x9c004dd3, 0x6003e540, 0xcf9fc949,
|
||||
0xbfd4af27, 0x88bbbdb5, 0xe2034090, 0x98d09675, 0x6e63a0e0,
|
||||
|
|
@ -108,8 +105,9 @@ static const u32 s1[256] = {
|
|||
0x1a69e783, 0x02cc4843, 0xa2f7c579, 0x429ef47d, 0x427b169c,
|
||||
0x5ac9f049, 0xdd8f0f00, 0x5c8165bf
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cast6_s1);
|
||||
|
||||
static const u32 s2[256] = {
|
||||
const u32 cast6_s2[256] = {
|
||||
0x1f201094, 0xef0ba75b, 0x69e3cf7e, 0x393f4380, 0xfe61cf7a,
|
||||
0xeec5207a, 0x55889c94, 0x72fc0651,
|
||||
0xada7ef79, 0x4e1d7235, 0xd55a63ce, 0xde0436ba, 0x99c430ef,
|
||||
|
|
@ -175,8 +173,9 @@ static const u32 s2[256] = {
|
|||
0x43d79572, 0x7e6dd07c, 0x06dfdf1e, 0x6c6cc4ef, 0x7160a539,
|
||||
0x73bfbe70, 0x83877605, 0x4523ecf1
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cast6_s2);
|
||||
|
||||
static const u32 s3[256] = {
|
||||
const u32 cast6_s3[256] = {
|
||||
0x8defc240, 0x25fa5d9f, 0xeb903dbf, 0xe810c907, 0x47607fff,
|
||||
0x369fe44b, 0x8c1fc644, 0xaececa90,
|
||||
0xbeb1f9bf, 0xeefbcaea, 0xe8cf1950, 0x51df07ae, 0x920e8806,
|
||||
|
|
@ -242,8 +241,9 @@ static const u32 s3[256] = {
|
|||
0xf7baefd5, 0x4142ed9c, 0xa4315c11, 0x83323ec5, 0xdfef4636,
|
||||
0xa133c501, 0xe9d3531c, 0xee353783
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cast6_s3);
|
||||
|
||||
static const u32 s4[256] = {
|
||||
const u32 cast6_s4[256] = {
|
||||
0x9db30420, 0x1fb6e9de, 0xa7be7bef, 0xd273a298, 0x4a4f7bdb,
|
||||
0x64ad8c57, 0x85510443, 0xfa020ed1,
|
||||
0x7e287aff, 0xe60fb663, 0x095f35a1, 0x79ebf120, 0xfd059d43,
|
||||
|
|
@ -309,6 +309,7 @@ static const u32 s4[256] = {
|
|||
0x7ae5290c, 0x3cb9536b, 0x851e20fe, 0x9833557e, 0x13ecf0b0,
|
||||
0xd3ffb372, 0x3f85c5c1, 0x0aef7ed2
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(cast6_s4);
|
||||
|
||||
static const u32 Tm[24][8] = {
|
||||
{ 0x5a827999, 0xc95c653a, 0x383650db, 0xa7103c7c, 0x15ea281d,
|
||||
|
|
@ -369,7 +370,7 @@ static const u8 Tr[4][8] = {
|
|||
};
|
||||
|
||||
/* forward octave */
|
||||
static void W(u32 *key, unsigned int i)
|
||||
static inline void W(u32 *key, unsigned int i)
|
||||
{
|
||||
u32 I;
|
||||
key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]);
|
||||
|
|
@ -382,14 +383,12 @@ static void W(u32 *key, unsigned int i)
|
|||
key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]);
|
||||
}
|
||||
|
||||
static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
|
||||
unsigned key_len)
|
||||
int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key,
|
||||
unsigned key_len, u32 *flags)
|
||||
{
|
||||
int i;
|
||||
u32 key[8];
|
||||
__be32 p_key[8]; /* padded key */
|
||||
struct cast6_ctx *c = crypto_tfm_ctx(tfm);
|
||||
u32 *flags = &tfm->crt_flags;
|
||||
|
||||
if (key_len % 4 != 0) {
|
||||
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
|
||||
|
|
@ -425,9 +424,17 @@ static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
|
|||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__cast6_setkey);
|
||||
|
||||
int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
|
||||
{
|
||||
return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen,
|
||||
&tfm->crt_flags);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cast6_setkey);
|
||||
|
||||
/*forward quad round*/
|
||||
static void Q(u32 *block, u8 *Kr, u32 *Km)
|
||||
static inline void Q(u32 *block, u8 *Kr, u32 *Km)
|
||||
{
|
||||
u32 I;
|
||||
block[2] ^= F1(block[3], Kr[0], Km[0]);
|
||||
|
|
@ -437,7 +444,7 @@ static void Q(u32 *block, u8 *Kr, u32 *Km)
|
|||
}
|
||||
|
||||
/*reverse quad round*/
|
||||
static void QBAR(u32 *block, u8 *Kr, u32 *Km)
|
||||
static inline void QBAR(u32 *block, u8 *Kr, u32 *Km)
|
||||
{
|
||||
u32 I;
|
||||
block[3] ^= F1(block[0], Kr[3], Km[3]);
|
||||
|
|
@ -446,9 +453,8 @@ static void QBAR(u32 *block, u8 *Kr, u32 *Km)
|
|||
block[2] ^= F1(block[3], Kr[0], Km[0]);
|
||||
}
|
||||
|
||||
static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
void __cast6_encrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
struct cast6_ctx *c = crypto_tfm_ctx(tfm);
|
||||
const __be32 *src = (const __be32 *)inbuf;
|
||||
__be32 *dst = (__be32 *)outbuf;
|
||||
u32 block[4];
|
||||
|
|
@ -478,10 +484,15 @@ static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
|||
dst[2] = cpu_to_be32(block[2]);
|
||||
dst[3] = cpu_to_be32(block[3]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__cast6_encrypt);
|
||||
|
||||
static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
__cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
|
||||
}
|
||||
|
||||
void __cast6_decrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
struct cast6_ctx *c = crypto_tfm_ctx(tfm);
|
||||
const __be32 *src = (const __be32 *)inbuf;
|
||||
__be32 *dst = (__be32 *)outbuf;
|
||||
u32 block[4];
|
||||
|
|
@ -511,15 +522,22 @@ static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
|||
dst[2] = cpu_to_be32(block[2]);
|
||||
dst[3] = cpu_to_be32(block[3]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__cast6_decrypt);
|
||||
|
||||
static void cast6_decrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
|
||||
{
|
||||
__cast6_decrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
|
||||
}
|
||||
|
||||
static struct crypto_alg alg = {
|
||||
.cra_name = "cast6",
|
||||
.cra_driver_name = "cast6-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = CAST6_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct cast6_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = CAST6_MIN_KEY_SIZE,
|
||||
|
|
@ -545,3 +563,4 @@ module_exit(cast6_mod_fini);
|
|||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("Cast6 Cipher Algorithm");
|
||||
MODULE_ALIAS("cast6");
|
||||
|
|
@ -94,18 +94,6 @@ static int skcipher_null_crypt(struct blkcipher_desc *desc,
|
|||
return err;
|
||||
}
|
||||
|
||||
static struct crypto_alg compress_null = {
|
||||
.cra_name = "compress_null",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
|
||||
.cra_blocksize = NULL_BLOCK_SIZE,
|
||||
.cra_ctxsize = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(compress_null.cra_list),
|
||||
.cra_u = { .compress = {
|
||||
.coa_compress = null_compress,
|
||||
.coa_decompress = null_compress } }
|
||||
};
|
||||
|
||||
static struct shash_alg digest_null = {
|
||||
.digestsize = NULL_DIGEST_SIZE,
|
||||
.setkey = null_hash_setkey,
|
||||
|
|
@ -122,22 +110,19 @@ static struct shash_alg digest_null = {
|
|||
}
|
||||
};
|
||||
|
||||
static struct crypto_alg cipher_null = {
|
||||
static struct crypto_alg null_algs[3] = { {
|
||||
.cra_name = "cipher_null",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = NULL_BLOCK_SIZE,
|
||||
.cra_ctxsize = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(cipher_null.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = NULL_KEY_SIZE,
|
||||
.cia_max_keysize = NULL_KEY_SIZE,
|
||||
.cia_setkey = null_setkey,
|
||||
.cia_encrypt = null_crypt,
|
||||
.cia_decrypt = null_crypt } }
|
||||
};
|
||||
|
||||
static struct crypto_alg skcipher_null = {
|
||||
}, {
|
||||
.cra_name = "ecb(cipher_null)",
|
||||
.cra_driver_name = "ecb-cipher_null",
|
||||
.cra_priority = 100,
|
||||
|
|
@ -146,7 +131,6 @@ static struct crypto_alg skcipher_null = {
|
|||
.cra_type = &crypto_blkcipher_type,
|
||||
.cra_ctxsize = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(skcipher_null.cra_list),
|
||||
.cra_u = { .blkcipher = {
|
||||
.min_keysize = NULL_KEY_SIZE,
|
||||
.max_keysize = NULL_KEY_SIZE,
|
||||
|
|
@ -154,7 +138,16 @@ static struct crypto_alg skcipher_null = {
|
|||
.setkey = null_setkey,
|
||||
.encrypt = skcipher_null_crypt,
|
||||
.decrypt = skcipher_null_crypt } }
|
||||
};
|
||||
}, {
|
||||
.cra_name = "compress_null",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
|
||||
.cra_blocksize = NULL_BLOCK_SIZE,
|
||||
.cra_ctxsize = 0,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_u = { .compress = {
|
||||
.coa_compress = null_compress,
|
||||
.coa_decompress = null_compress } }
|
||||
} };
|
||||
|
||||
MODULE_ALIAS("compress_null");
|
||||
MODULE_ALIAS("digest_null");
|
||||
|
|
@ -164,40 +157,26 @@ static int __init crypto_null_mod_init(void)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = crypto_register_alg(&cipher_null);
|
||||
ret = crypto_register_algs(null_algs, ARRAY_SIZE(null_algs));
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = crypto_register_alg(&skcipher_null);
|
||||
if (ret < 0)
|
||||
goto out_unregister_cipher;
|
||||
|
||||
ret = crypto_register_shash(&digest_null);
|
||||
if (ret < 0)
|
||||
goto out_unregister_skcipher;
|
||||
goto out_unregister_algs;
|
||||
|
||||
ret = crypto_register_alg(&compress_null);
|
||||
if (ret < 0)
|
||||
goto out_unregister_digest;
|
||||
return 0;
|
||||
|
||||
out_unregister_algs:
|
||||
crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs));
|
||||
out:
|
||||
return ret;
|
||||
|
||||
out_unregister_digest:
|
||||
crypto_unregister_shash(&digest_null);
|
||||
out_unregister_skcipher:
|
||||
crypto_unregister_alg(&skcipher_null);
|
||||
out_unregister_cipher:
|
||||
crypto_unregister_alg(&cipher_null);
|
||||
goto out;
|
||||
}
|
||||
|
||||
static void __exit crypto_null_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&compress_null);
|
||||
crypto_unregister_shash(&digest_null);
|
||||
crypto_unregister_alg(&skcipher_null);
|
||||
crypto_unregister_alg(&cipher_null);
|
||||
crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs));
|
||||
}
|
||||
|
||||
module_init(crypto_null_mod_init);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "internal.h"
|
||||
|
||||
DEFINE_MUTEX(crypto_cfg_mutex);
|
||||
static DEFINE_MUTEX(crypto_cfg_mutex);
|
||||
|
||||
/* The crypto netlink socket */
|
||||
static struct sock *crypto_nlsk;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,6 @@ static struct crypto_alg alg = {
|
|||
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
|
||||
.cra_ctxsize = sizeof(struct deflate_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_init = deflate_init,
|
||||
.cra_exit = deflate_exit,
|
||||
.cra_u = { .compress = {
|
||||
|
|
|
|||
|
|
@ -943,59 +943,44 @@ static void des3_ede_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
|||
d[1] = cpu_to_le32(L);
|
||||
}
|
||||
|
||||
static struct crypto_alg des_alg = {
|
||||
static struct crypto_alg des_algs[2] = { {
|
||||
.cra_name = "des",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = DES_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct des_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_alignmask = 3,
|
||||
.cra_list = LIST_HEAD_INIT(des_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = DES_KEY_SIZE,
|
||||
.cia_max_keysize = DES_KEY_SIZE,
|
||||
.cia_setkey = des_setkey,
|
||||
.cia_encrypt = des_encrypt,
|
||||
.cia_decrypt = des_decrypt } }
|
||||
};
|
||||
|
||||
static struct crypto_alg des3_ede_alg = {
|
||||
}, {
|
||||
.cra_name = "des3_ede",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = DES3_EDE_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct des3_ede_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_alignmask = 3,
|
||||
.cra_list = LIST_HEAD_INIT(des3_ede_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = DES3_EDE_KEY_SIZE,
|
||||
.cia_max_keysize = DES3_EDE_KEY_SIZE,
|
||||
.cia_setkey = des3_ede_setkey,
|
||||
.cia_encrypt = des3_ede_encrypt,
|
||||
.cia_decrypt = des3_ede_decrypt } }
|
||||
};
|
||||
} };
|
||||
|
||||
MODULE_ALIAS("des3_ede");
|
||||
|
||||
static int __init des_generic_mod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = crypto_register_alg(&des_alg);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = crypto_register_alg(&des3_ede_alg);
|
||||
if (ret < 0)
|
||||
crypto_unregister_alg(&des_alg);
|
||||
out:
|
||||
return ret;
|
||||
return crypto_register_algs(des_algs, ARRAY_SIZE(des_algs));
|
||||
}
|
||||
|
||||
static void __exit des_generic_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&des3_ede_alg);
|
||||
crypto_unregister_alg(&des_alg);
|
||||
crypto_unregister_algs(des_algs, ARRAY_SIZE(des_algs));
|
||||
}
|
||||
|
||||
module_init(des_generic_mod_init);
|
||||
|
|
|
|||
|
|
@ -396,7 +396,6 @@ static struct crypto_alg fcrypt_alg = {
|
|||
.cra_ctxsize = sizeof(struct fcrypt_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_alignmask = 3,
|
||||
.cra_list = LIST_HEAD_INIT(fcrypt_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = 8,
|
||||
.cia_max_keysize = 8,
|
||||
|
|
|
|||
|
|
@ -153,7 +153,6 @@ static struct shash_alg ghash_alg = {
|
|||
.cra_blocksize = GHASH_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct ghash_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(ghash_alg.base.cra_list),
|
||||
.cra_exit = ghash_exit_tfm,
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -853,7 +853,6 @@ static struct crypto_alg khazad_alg = {
|
|||
.cra_ctxsize = sizeof (struct khazad_ctx),
|
||||
.cra_alignmask = 7,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(khazad_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = KHAZAD_KEY_SIZE,
|
||||
.cia_max_keysize = KHAZAD_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ static struct crypto_alg krng_alg = {
|
|||
.cra_ctxsize = 0,
|
||||
.cra_type = &crypto_rng_type,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(krng_alg.cra_list),
|
||||
.cra_u = {
|
||||
.rng = {
|
||||
.rng_make_random = krng_get_random,
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ static struct crypto_alg alg = {
|
|||
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
|
||||
.cra_ctxsize = sizeof(struct lzo_ctx),
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_init = lzo_init,
|
||||
.cra_exit = lzo_exit,
|
||||
.cra_u = { .compress = {
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ static struct crypto_alg alg = {
|
|||
.cra_ctxsize = sizeof(struct salsa20_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_u = {
|
||||
.blkcipher = {
|
||||
.setkey = setkey,
|
||||
|
|
|
|||
|
|
@ -449,7 +449,6 @@ static struct crypto_alg seed_alg = {
|
|||
.cra_ctxsize = sizeof(struct seed_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(seed_alg.cra_list),
|
||||
.cra_u = {
|
||||
.cipher = {
|
||||
.cia_min_keysize = SEED_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -567,24 +567,6 @@ static void serpent_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
|||
__serpent_decrypt(ctx, dst, src);
|
||||
}
|
||||
|
||||
static struct crypto_alg serpent_alg = {
|
||||
.cra_name = "serpent",
|
||||
.cra_driver_name = "serpent-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(serpent_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = SERPENT_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = SERPENT_MAX_KEY_SIZE,
|
||||
.cia_setkey = serpent_setkey,
|
||||
.cia_encrypt = serpent_encrypt,
|
||||
.cia_decrypt = serpent_decrypt } }
|
||||
};
|
||||
|
||||
static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
|
|
@ -637,41 +619,44 @@ static void tnepres_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
|||
d[3] = swab32(rd[0]);
|
||||
}
|
||||
|
||||
static struct crypto_alg tnepres_alg = {
|
||||
static struct crypto_alg srp_algs[2] = { {
|
||||
.cra_name = "serpent",
|
||||
.cra_driver_name = "serpent-generic",
|
||||
.cra_priority = 100,
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = SERPENT_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = SERPENT_MAX_KEY_SIZE,
|
||||
.cia_setkey = serpent_setkey,
|
||||
.cia_encrypt = serpent_encrypt,
|
||||
.cia_decrypt = serpent_decrypt } }
|
||||
}, {
|
||||
.cra_name = "tnepres",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(serpent_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = SERPENT_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = SERPENT_MAX_KEY_SIZE,
|
||||
.cia_setkey = tnepres_setkey,
|
||||
.cia_encrypt = tnepres_encrypt,
|
||||
.cia_decrypt = tnepres_decrypt } }
|
||||
};
|
||||
} };
|
||||
|
||||
static int __init serpent_mod_init(void)
|
||||
{
|
||||
int ret = crypto_register_alg(&serpent_alg);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = crypto_register_alg(&tnepres_alg);
|
||||
|
||||
if (ret)
|
||||
crypto_unregister_alg(&serpent_alg);
|
||||
|
||||
return ret;
|
||||
return crypto_register_algs(srp_algs, ARRAY_SIZE(srp_algs));
|
||||
}
|
||||
|
||||
static void __exit serpent_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&tnepres_alg);
|
||||
crypto_unregister_alg(&serpent_alg);
|
||||
crypto_unregister_algs(srp_algs, ARRAY_SIZE(srp_algs));
|
||||
}
|
||||
|
||||
module_init(serpent_mod_init);
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ static int sha256_import(struct shash_desc *desc, const void *in)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct shash_alg sha256 = {
|
||||
static struct shash_alg sha256_algs[2] = { {
|
||||
.digestsize = SHA256_DIGEST_SIZE,
|
||||
.init = sha256_init,
|
||||
.update = sha256_update,
|
||||
|
|
@ -352,9 +352,7 @@ static struct shash_alg sha256 = {
|
|||
.cra_blocksize = SHA256_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static struct shash_alg sha224 = {
|
||||
}, {
|
||||
.digestsize = SHA224_DIGEST_SIZE,
|
||||
.init = sha224_init,
|
||||
.update = sha256_update,
|
||||
|
|
@ -367,29 +365,16 @@ static struct shash_alg sha224 = {
|
|||
.cra_blocksize = SHA224_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
} };
|
||||
|
||||
static int __init sha256_generic_mod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = crypto_register_shash(&sha224);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
ret = crypto_register_shash(&sha256);
|
||||
|
||||
if (ret < 0)
|
||||
crypto_unregister_shash(&sha224);
|
||||
|
||||
return ret;
|
||||
return crypto_register_shashes(sha256_algs, ARRAY_SIZE(sha256_algs));
|
||||
}
|
||||
|
||||
static void __exit sha256_generic_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_shash(&sha224);
|
||||
crypto_unregister_shash(&sha256);
|
||||
crypto_unregister_shashes(sha256_algs, ARRAY_SIZE(sha256_algs));
|
||||
}
|
||||
|
||||
module_init(sha256_generic_mod_init);
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ static int sha384_final(struct shash_desc *desc, u8 *hash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct shash_alg sha512 = {
|
||||
static struct shash_alg sha512_algs[2] = { {
|
||||
.digestsize = SHA512_DIGEST_SIZE,
|
||||
.init = sha512_init,
|
||||
.update = sha512_update,
|
||||
|
|
@ -254,9 +254,7 @@ static struct shash_alg sha512 = {
|
|||
.cra_blocksize = SHA512_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static struct shash_alg sha384 = {
|
||||
}, {
|
||||
.digestsize = SHA384_DIGEST_SIZE,
|
||||
.init = sha384_init,
|
||||
.update = sha512_update,
|
||||
|
|
@ -268,24 +266,16 @@ static struct shash_alg sha384 = {
|
|||
.cra_blocksize = SHA384_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
} };
|
||||
|
||||
static int __init sha512_generic_mod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if ((ret = crypto_register_shash(&sha384)) < 0)
|
||||
goto out;
|
||||
if ((ret = crypto_register_shash(&sha512)) < 0)
|
||||
crypto_unregister_shash(&sha384);
|
||||
out:
|
||||
return ret;
|
||||
return crypto_register_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
|
||||
}
|
||||
|
||||
static void __exit sha512_generic_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_shash(&sha384);
|
||||
crypto_unregister_shash(&sha512);
|
||||
crypto_unregister_shashes(sha512_algs, ARRAY_SIZE(sha512_algs));
|
||||
}
|
||||
|
||||
module_init(sha512_generic_mod_init);
|
||||
|
|
|
|||
|
|
@ -629,6 +629,42 @@ int crypto_unregister_shash(struct shash_alg *alg)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_unregister_shash);
|
||||
|
||||
int crypto_register_shashes(struct shash_alg *algs, int count)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
ret = crypto_register_shash(&algs[i]);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
for (--i; i >= 0; --i)
|
||||
crypto_unregister_shash(&algs[i]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_register_shashes);
|
||||
|
||||
int crypto_unregister_shashes(struct shash_alg *algs, int count)
|
||||
{
|
||||
int i, ret;
|
||||
|
||||
for (i = count - 1; i >= 0; --i) {
|
||||
ret = crypto_unregister_shash(&algs[i]);
|
||||
if (ret)
|
||||
pr_err("Failed to unregister %s %s: %d\n",
|
||||
algs[i].base.cra_driver_name,
|
||||
algs[i].base.cra_name, ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_unregister_shashes);
|
||||
|
||||
int shash_register_instance(struct crypto_template *tmpl,
|
||||
struct shash_instance *inst)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc,
|
|||
int ret = 0;
|
||||
int i;
|
||||
|
||||
local_bh_disable();
|
||||
local_irq_disable();
|
||||
|
||||
/* Warm-up run. */
|
||||
|
|
@ -130,7 +129,6 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc,
|
|||
|
||||
out:
|
||||
local_irq_enable();
|
||||
local_bh_enable();
|
||||
|
||||
if (ret == 0)
|
||||
printk("1 operation in %lu cycles (%d bytes)\n",
|
||||
|
|
@ -300,7 +298,6 @@ static int test_hash_cycles_digest(struct hash_desc *desc,
|
|||
int i;
|
||||
int ret;
|
||||
|
||||
local_bh_disable();
|
||||
local_irq_disable();
|
||||
|
||||
/* Warm-up run. */
|
||||
|
|
@ -327,7 +324,6 @@ static int test_hash_cycles_digest(struct hash_desc *desc,
|
|||
|
||||
out:
|
||||
local_irq_enable();
|
||||
local_bh_enable();
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -348,7 +344,6 @@ static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg,
|
|||
if (plen == blen)
|
||||
return test_hash_cycles_digest(desc, sg, blen, out);
|
||||
|
||||
local_bh_disable();
|
||||
local_irq_disable();
|
||||
|
||||
/* Warm-up run. */
|
||||
|
|
@ -391,7 +386,6 @@ static int test_hash_cycles(struct hash_desc *desc, struct scatterlist *sg,
|
|||
|
||||
out:
|
||||
local_irq_enable();
|
||||
local_bh_enable();
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -1037,10 +1031,16 @@ static int do_test(int m)
|
|||
|
||||
case 14:
|
||||
ret += tcrypt_test("ecb(cast5)");
|
||||
ret += tcrypt_test("cbc(cast5)");
|
||||
ret += tcrypt_test("ctr(cast5)");
|
||||
break;
|
||||
|
||||
case 15:
|
||||
ret += tcrypt_test("ecb(cast6)");
|
||||
ret += tcrypt_test("cbc(cast6)");
|
||||
ret += tcrypt_test("ctr(cast6)");
|
||||
ret += tcrypt_test("lrw(cast6)");
|
||||
ret += tcrypt_test("xts(cast6)");
|
||||
break;
|
||||
|
||||
case 16:
|
||||
|
|
@ -1112,6 +1112,9 @@ static int do_test(int m)
|
|||
case 32:
|
||||
ret += tcrypt_test("ecb(camellia)");
|
||||
ret += tcrypt_test("cbc(camellia)");
|
||||
ret += tcrypt_test("ctr(camellia)");
|
||||
ret += tcrypt_test("lrw(camellia)");
|
||||
ret += tcrypt_test("xts(camellia)");
|
||||
break;
|
||||
case 33:
|
||||
ret += tcrypt_test("sha224");
|
||||
|
|
@ -1165,6 +1168,10 @@ static int do_test(int m)
|
|||
ret += tcrypt_test("rfc4309(ccm(aes))");
|
||||
break;
|
||||
|
||||
case 46:
|
||||
ret += tcrypt_test("ghash");
|
||||
break;
|
||||
|
||||
case 100:
|
||||
ret += tcrypt_test("hmac(md5)");
|
||||
break;
|
||||
|
|
@ -1359,6 +1366,44 @@ static int do_test(int m)
|
|||
speed_template_8);
|
||||
break;
|
||||
|
||||
case 209:
|
||||
test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
break;
|
||||
|
||||
case 210:
|
||||
test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_32_48);
|
||||
test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_32_48);
|
||||
test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_32_64);
|
||||
test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_32_64);
|
||||
break;
|
||||
|
||||
case 300:
|
||||
/* fall through */
|
||||
|
||||
|
|
@ -1639,6 +1684,44 @@ static int do_test(int m)
|
|||
speed_template_8);
|
||||
break;
|
||||
|
||||
case 506:
|
||||
test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_8_16);
|
||||
break;
|
||||
|
||||
case 507:
|
||||
test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_16_32);
|
||||
test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_32_48);
|
||||
test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_32_48);
|
||||
test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
|
||||
speed_template_32_64);
|
||||
test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
|
||||
speed_template_32_64);
|
||||
break;
|
||||
|
||||
case 1000:
|
||||
test_available();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ static struct cipher_speed_template des3_speed_template[] = {
|
|||
*/
|
||||
static u8 speed_template_8[] = {8, 0};
|
||||
static u8 speed_template_24[] = {24, 0};
|
||||
static u8 speed_template_8_16[] = {8, 16, 0};
|
||||
static u8 speed_template_8_32[] = {8, 32, 0};
|
||||
static u8 speed_template_16_32[] = {16, 32, 0};
|
||||
static u8 speed_template_16_24_32[] = {16, 24, 32, 0};
|
||||
|
|
|
|||
41
crypto/tea.c
41
crypto/tea.c
|
|
@ -219,84 +219,55 @@ static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
|
|||
out[1] = cpu_to_le32(z);
|
||||
}
|
||||
|
||||
static struct crypto_alg tea_alg = {
|
||||
static struct crypto_alg tea_algs[3] = { {
|
||||
.cra_name = "tea",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = TEA_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof (struct tea_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(tea_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = TEA_KEY_SIZE,
|
||||
.cia_max_keysize = TEA_KEY_SIZE,
|
||||
.cia_setkey = tea_setkey,
|
||||
.cia_encrypt = tea_encrypt,
|
||||
.cia_decrypt = tea_decrypt } }
|
||||
};
|
||||
|
||||
static struct crypto_alg xtea_alg = {
|
||||
}, {
|
||||
.cra_name = "xtea",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = XTEA_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof (struct xtea_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(xtea_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = XTEA_KEY_SIZE,
|
||||
.cia_max_keysize = XTEA_KEY_SIZE,
|
||||
.cia_setkey = xtea_setkey,
|
||||
.cia_encrypt = xtea_encrypt,
|
||||
.cia_decrypt = xtea_decrypt } }
|
||||
};
|
||||
|
||||
static struct crypto_alg xeta_alg = {
|
||||
}, {
|
||||
.cra_name = "xeta",
|
||||
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
|
||||
.cra_blocksize = XTEA_BLOCK_SIZE,
|
||||
.cra_ctxsize = sizeof (struct xtea_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(xtea_alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = XTEA_KEY_SIZE,
|
||||
.cia_max_keysize = XTEA_KEY_SIZE,
|
||||
.cia_setkey = xtea_setkey,
|
||||
.cia_encrypt = xeta_encrypt,
|
||||
.cia_decrypt = xeta_decrypt } }
|
||||
};
|
||||
} };
|
||||
|
||||
static int __init tea_mod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = crypto_register_alg(&tea_alg);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = crypto_register_alg(&xtea_alg);
|
||||
if (ret < 0) {
|
||||
crypto_unregister_alg(&tea_alg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = crypto_register_alg(&xeta_alg);
|
||||
if (ret < 0) {
|
||||
crypto_unregister_alg(&tea_alg);
|
||||
crypto_unregister_alg(&xtea_alg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
return ret;
|
||||
return crypto_register_algs(tea_algs, ARRAY_SIZE(tea_algs));
|
||||
}
|
||||
|
||||
static void __exit tea_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_alg(&tea_alg);
|
||||
crypto_unregister_alg(&xtea_alg);
|
||||
crypto_unregister_alg(&xeta_alg);
|
||||
crypto_unregister_algs(tea_algs, ARRAY_SIZE(tea_algs));
|
||||
}
|
||||
|
||||
MODULE_ALIAS("xtea");
|
||||
|
|
|
|||
472
crypto/testmgr.c
472
crypto/testmgr.c
|
|
@ -358,8 +358,9 @@ out_nobuf:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int test_aead(struct crypto_aead *tfm, int enc,
|
||||
struct aead_testvec *template, unsigned int tcount)
|
||||
static int __test_aead(struct crypto_aead *tfm, int enc,
|
||||
struct aead_testvec *template, unsigned int tcount,
|
||||
const bool diff_dst)
|
||||
{
|
||||
const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm));
|
||||
unsigned int i, j, k, n, temp;
|
||||
|
|
@ -367,15 +368,18 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
char *q;
|
||||
char *key;
|
||||
struct aead_request *req;
|
||||
struct scatterlist sg[8];
|
||||
struct scatterlist asg[8];
|
||||
const char *e;
|
||||
struct scatterlist *sg;
|
||||
struct scatterlist *asg;
|
||||
struct scatterlist *sgout;
|
||||
const char *e, *d;
|
||||
struct tcrypt_result result;
|
||||
unsigned int authsize;
|
||||
void *input;
|
||||
void *output;
|
||||
void *assoc;
|
||||
char iv[MAX_IVLEN];
|
||||
char *xbuf[XBUFSIZE];
|
||||
char *xoutbuf[XBUFSIZE];
|
||||
char *axbuf[XBUFSIZE];
|
||||
|
||||
if (testmgr_alloc_buf(xbuf))
|
||||
|
|
@ -383,6 +387,21 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
if (testmgr_alloc_buf(axbuf))
|
||||
goto out_noaxbuf;
|
||||
|
||||
if (diff_dst && testmgr_alloc_buf(xoutbuf))
|
||||
goto out_nooutbuf;
|
||||
|
||||
/* avoid "the frame size is larger than 1024 bytes" compiler warning */
|
||||
sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 3 : 2), GFP_KERNEL);
|
||||
if (!sg)
|
||||
goto out_nosg;
|
||||
asg = &sg[8];
|
||||
sgout = &asg[8];
|
||||
|
||||
if (diff_dst)
|
||||
d = "-ddst";
|
||||
else
|
||||
d = "";
|
||||
|
||||
if (enc == ENCRYPT)
|
||||
e = "encryption";
|
||||
else
|
||||
|
|
@ -392,8 +411,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
|
||||
req = aead_request_alloc(tfm, GFP_KERNEL);
|
||||
if (!req) {
|
||||
printk(KERN_ERR "alg: aead: Failed to allocate request for "
|
||||
"%s\n", algo);
|
||||
pr_err("alg: aead%s: Failed to allocate request for %s\n",
|
||||
d, algo);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -432,9 +451,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
ret = crypto_aead_setkey(tfm, key,
|
||||
template[i].klen);
|
||||
if (!ret == template[i].fail) {
|
||||
printk(KERN_ERR "alg: aead: setkey failed on "
|
||||
"test %d for %s: flags=%x\n", j, algo,
|
||||
crypto_aead_get_flags(tfm));
|
||||
pr_err("alg: aead%s: setkey failed on test %d for %s: flags=%x\n",
|
||||
d, j, algo, crypto_aead_get_flags(tfm));
|
||||
goto out;
|
||||
} else if (ret)
|
||||
continue;
|
||||
|
|
@ -442,18 +460,26 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
authsize = abs(template[i].rlen - template[i].ilen);
|
||||
ret = crypto_aead_setauthsize(tfm, authsize);
|
||||
if (ret) {
|
||||
printk(KERN_ERR "alg: aead: Failed to set "
|
||||
"authsize to %u on test %d for %s\n",
|
||||
authsize, j, algo);
|
||||
pr_err("alg: aead%s: Failed to set authsize to %u on test %d for %s\n",
|
||||
d, authsize, j, algo);
|
||||
goto out;
|
||||
}
|
||||
|
||||
sg_init_one(&sg[0], input,
|
||||
template[i].ilen + (enc ? authsize : 0));
|
||||
|
||||
if (diff_dst) {
|
||||
output = xoutbuf[0];
|
||||
sg_init_one(&sgout[0], output,
|
||||
template[i].ilen +
|
||||
(enc ? authsize : 0));
|
||||
} else {
|
||||
output = input;
|
||||
}
|
||||
|
||||
sg_init_one(&asg[0], assoc, template[i].alen);
|
||||
|
||||
aead_request_set_crypt(req, sg, sg,
|
||||
aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
|
||||
template[i].ilen, iv);
|
||||
|
||||
aead_request_set_assoc(req, asg, template[i].alen);
|
||||
|
|
@ -466,10 +492,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
case 0:
|
||||
if (template[i].novrfy) {
|
||||
/* verification was supposed to fail */
|
||||
printk(KERN_ERR "alg: aead: %s failed "
|
||||
"on test %d for %s: ret was 0, "
|
||||
"expected -EBADMSG\n",
|
||||
e, j, algo);
|
||||
pr_err("alg: aead%s: %s failed on test %d for %s: ret was 0, expected -EBADMSG\n",
|
||||
d, e, j, algo);
|
||||
/* so really, we got a bad message */
|
||||
ret = -EBADMSG;
|
||||
goto out;
|
||||
|
|
@ -489,15 +513,15 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
continue;
|
||||
/* fall through */
|
||||
default:
|
||||
printk(KERN_ERR "alg: aead: %s failed on test "
|
||||
"%d for %s: ret=%d\n", e, j, algo, -ret);
|
||||
pr_err("alg: aead%s: %s failed on test %d for %s: ret=%d\n",
|
||||
d, e, j, algo, -ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
q = input;
|
||||
q = output;
|
||||
if (memcmp(q, template[i].result, template[i].rlen)) {
|
||||
printk(KERN_ERR "alg: aead: Test %d failed on "
|
||||
"%s for %s\n", j, e, algo);
|
||||
pr_err("alg: aead%s: Test %d failed on %s for %s\n",
|
||||
d, j, e, algo);
|
||||
hexdump(q, template[i].rlen);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
|
|
@ -522,9 +546,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
|
||||
ret = crypto_aead_setkey(tfm, key, template[i].klen);
|
||||
if (!ret == template[i].fail) {
|
||||
printk(KERN_ERR "alg: aead: setkey failed on "
|
||||
"chunk test %d for %s: flags=%x\n", j,
|
||||
algo, crypto_aead_get_flags(tfm));
|
||||
pr_err("alg: aead%s: setkey failed on chunk test %d for %s: flags=%x\n",
|
||||
d, j, algo, crypto_aead_get_flags(tfm));
|
||||
goto out;
|
||||
} else if (ret)
|
||||
continue;
|
||||
|
|
@ -533,6 +556,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
|
||||
ret = -EINVAL;
|
||||
sg_init_table(sg, template[i].np);
|
||||
if (diff_dst)
|
||||
sg_init_table(sgout, template[i].np);
|
||||
for (k = 0, temp = 0; k < template[i].np; k++) {
|
||||
if (WARN_ON(offset_in_page(IDX[k]) +
|
||||
template[i].tap[k] > PAGE_SIZE))
|
||||
|
|
@ -551,14 +576,26 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
q[n] = 0;
|
||||
|
||||
sg_set_buf(&sg[k], q, template[i].tap[k]);
|
||||
|
||||
if (diff_dst) {
|
||||
q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
|
||||
memset(q, 0, template[i].tap[k]);
|
||||
if (offset_in_page(q) + n < PAGE_SIZE)
|
||||
q[n] = 0;
|
||||
|
||||
sg_set_buf(&sgout[k], q,
|
||||
template[i].tap[k]);
|
||||
}
|
||||
|
||||
temp += template[i].tap[k];
|
||||
}
|
||||
|
||||
ret = crypto_aead_setauthsize(tfm, authsize);
|
||||
if (ret) {
|
||||
printk(KERN_ERR "alg: aead: Failed to set "
|
||||
"authsize to %u on chunk test %d for "
|
||||
"%s\n", authsize, j, algo);
|
||||
pr_err("alg: aead%s: Failed to set authsize to %u on chunk test %d for %s\n",
|
||||
d, authsize, j, algo);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +608,9 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
}
|
||||
|
||||
sg[k - 1].length += authsize;
|
||||
|
||||
if (diff_dst)
|
||||
sgout[k - 1].length += authsize;
|
||||
}
|
||||
|
||||
sg_init_table(asg, template[i].anp);
|
||||
|
|
@ -588,7 +628,7 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
temp += template[i].atap[k];
|
||||
}
|
||||
|
||||
aead_request_set_crypt(req, sg, sg,
|
||||
aead_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
|
||||
template[i].ilen,
|
||||
iv);
|
||||
|
||||
|
|
@ -602,10 +642,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
case 0:
|
||||
if (template[i].novrfy) {
|
||||
/* verification was supposed to fail */
|
||||
printk(KERN_ERR "alg: aead: %s failed "
|
||||
"on chunk test %d for %s: ret "
|
||||
"was 0, expected -EBADMSG\n",
|
||||
e, j, algo);
|
||||
pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret was 0, expected -EBADMSG\n",
|
||||
d, e, j, algo);
|
||||
/* so really, we got a bad message */
|
||||
ret = -EBADMSG;
|
||||
goto out;
|
||||
|
|
@ -625,32 +663,35 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
continue;
|
||||
/* fall through */
|
||||
default:
|
||||
printk(KERN_ERR "alg: aead: %s failed on "
|
||||
"chunk test %d for %s: ret=%d\n", e, j,
|
||||
algo, -ret);
|
||||
pr_err("alg: aead%s: %s failed on chunk test %d for %s: ret=%d\n",
|
||||
d, e, j, algo, -ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = -EINVAL;
|
||||
for (k = 0, temp = 0; k < template[i].np; k++) {
|
||||
q = xbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
if (diff_dst)
|
||||
q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
else
|
||||
q = xbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
|
||||
n = template[i].tap[k];
|
||||
if (k == template[i].np - 1)
|
||||
n += enc ? authsize : -authsize;
|
||||
|
||||
if (memcmp(q, template[i].result + temp, n)) {
|
||||
printk(KERN_ERR "alg: aead: Chunk "
|
||||
"test %d failed on %s at page "
|
||||
"%u for %s\n", j, e, k, algo);
|
||||
pr_err("alg: aead%s: Chunk test %d failed on %s at page %u for %s\n",
|
||||
d, j, e, k, algo);
|
||||
hexdump(q, n);
|
||||
goto out;
|
||||
}
|
||||
|
||||
q += n;
|
||||
if (k == template[i].np - 1 && !enc) {
|
||||
if (memcmp(q, template[i].input +
|
||||
if (!diff_dst &&
|
||||
memcmp(q, template[i].input +
|
||||
temp + n, authsize))
|
||||
n = authsize;
|
||||
else
|
||||
|
|
@ -661,11 +702,8 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
;
|
||||
}
|
||||
if (n) {
|
||||
printk(KERN_ERR "alg: aead: Result "
|
||||
"buffer corruption in chunk "
|
||||
"test %d on %s at page %u for "
|
||||
"%s: %u bytes:\n", j, e, k,
|
||||
algo, n);
|
||||
pr_err("alg: aead%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
|
||||
d, j, e, k, algo, n);
|
||||
hexdump(q, n);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -679,6 +717,11 @@ static int test_aead(struct crypto_aead *tfm, int enc,
|
|||
|
||||
out:
|
||||
aead_request_free(req);
|
||||
kfree(sg);
|
||||
out_nosg:
|
||||
if (diff_dst)
|
||||
testmgr_free_buf(xoutbuf);
|
||||
out_nooutbuf:
|
||||
testmgr_free_buf(axbuf);
|
||||
out_noaxbuf:
|
||||
testmgr_free_buf(xbuf);
|
||||
|
|
@ -686,6 +729,20 @@ out_noxbuf:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int test_aead(struct crypto_aead *tfm, int enc,
|
||||
struct aead_testvec *template, unsigned int tcount)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* test 'dst == src' case */
|
||||
ret = __test_aead(tfm, enc, template, tcount, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* test 'dst != src' case */
|
||||
return __test_aead(tfm, enc, template, tcount, true);
|
||||
}
|
||||
|
||||
static int test_cipher(struct crypto_cipher *tfm, int enc,
|
||||
struct cipher_testvec *template, unsigned int tcount)
|
||||
{
|
||||
|
|
@ -761,8 +818,9 @@ out_nobuf:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
||||
struct cipher_testvec *template, unsigned int tcount)
|
||||
static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
||||
struct cipher_testvec *template, unsigned int tcount,
|
||||
const bool diff_dst)
|
||||
{
|
||||
const char *algo =
|
||||
crypto_tfm_alg_driver_name(crypto_ablkcipher_tfm(tfm));
|
||||
|
|
@ -770,16 +828,26 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
char *q;
|
||||
struct ablkcipher_request *req;
|
||||
struct scatterlist sg[8];
|
||||
const char *e;
|
||||
struct scatterlist sgout[8];
|
||||
const char *e, *d;
|
||||
struct tcrypt_result result;
|
||||
void *data;
|
||||
char iv[MAX_IVLEN];
|
||||
char *xbuf[XBUFSIZE];
|
||||
char *xoutbuf[XBUFSIZE];
|
||||
int ret = -ENOMEM;
|
||||
|
||||
if (testmgr_alloc_buf(xbuf))
|
||||
goto out_nobuf;
|
||||
|
||||
if (diff_dst && testmgr_alloc_buf(xoutbuf))
|
||||
goto out_nooutbuf;
|
||||
|
||||
if (diff_dst)
|
||||
d = "-ddst";
|
||||
else
|
||||
d = "";
|
||||
|
||||
if (enc == ENCRYPT)
|
||||
e = "encryption";
|
||||
else
|
||||
|
|
@ -789,8 +857,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
|
||||
req = ablkcipher_request_alloc(tfm, GFP_KERNEL);
|
||||
if (!req) {
|
||||
printk(KERN_ERR "alg: skcipher: Failed to allocate request "
|
||||
"for %s\n", algo);
|
||||
pr_err("alg: skcipher%s: Failed to allocate request for %s\n",
|
||||
d, algo);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -804,7 +872,7 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
else
|
||||
memset(iv, 0, MAX_IVLEN);
|
||||
|
||||
if (!(template[i].np)) {
|
||||
if (!(template[i].np) || (template[i].also_non_np)) {
|
||||
j++;
|
||||
|
||||
ret = -EINVAL;
|
||||
|
|
@ -822,16 +890,21 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
ret = crypto_ablkcipher_setkey(tfm, template[i].key,
|
||||
template[i].klen);
|
||||
if (!ret == template[i].fail) {
|
||||
printk(KERN_ERR "alg: skcipher: setkey failed "
|
||||
"on test %d for %s: flags=%x\n", j,
|
||||
algo, crypto_ablkcipher_get_flags(tfm));
|
||||
pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n",
|
||||
d, j, algo,
|
||||
crypto_ablkcipher_get_flags(tfm));
|
||||
goto out;
|
||||
} else if (ret)
|
||||
continue;
|
||||
|
||||
sg_init_one(&sg[0], data, template[i].ilen);
|
||||
if (diff_dst) {
|
||||
data = xoutbuf[0];
|
||||
sg_init_one(&sgout[0], data, template[i].ilen);
|
||||
}
|
||||
|
||||
ablkcipher_request_set_crypt(req, sg, sg,
|
||||
ablkcipher_request_set_crypt(req, sg,
|
||||
(diff_dst) ? sgout : sg,
|
||||
template[i].ilen, iv);
|
||||
ret = enc ?
|
||||
crypto_ablkcipher_encrypt(req) :
|
||||
|
|
@ -850,16 +923,15 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
}
|
||||
/* fall through */
|
||||
default:
|
||||
printk(KERN_ERR "alg: skcipher: %s failed on "
|
||||
"test %d for %s: ret=%d\n", e, j, algo,
|
||||
-ret);
|
||||
pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
|
||||
d, e, j, algo, -ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
q = data;
|
||||
if (memcmp(q, template[i].result, template[i].rlen)) {
|
||||
printk(KERN_ERR "alg: skcipher: Test %d "
|
||||
"failed on %s for %s\n", j, e, algo);
|
||||
pr_err("alg: skcipher%s: Test %d failed on %s for %s\n",
|
||||
d, j, e, algo);
|
||||
hexdump(q, template[i].rlen);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
|
|
@ -886,9 +958,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
ret = crypto_ablkcipher_setkey(tfm, template[i].key,
|
||||
template[i].klen);
|
||||
if (!ret == template[i].fail) {
|
||||
printk(KERN_ERR "alg: skcipher: setkey failed "
|
||||
"on chunk test %d for %s: flags=%x\n",
|
||||
j, algo,
|
||||
pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n",
|
||||
d, j, algo,
|
||||
crypto_ablkcipher_get_flags(tfm));
|
||||
goto out;
|
||||
} else if (ret)
|
||||
|
|
@ -897,6 +968,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
temp = 0;
|
||||
ret = -EINVAL;
|
||||
sg_init_table(sg, template[i].np);
|
||||
if (diff_dst)
|
||||
sg_init_table(sgout, template[i].np);
|
||||
for (k = 0; k < template[i].np; k++) {
|
||||
if (WARN_ON(offset_in_page(IDX[k]) +
|
||||
template[i].tap[k] > PAGE_SIZE))
|
||||
|
|
@ -913,11 +986,24 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
q[template[i].tap[k]] = 0;
|
||||
|
||||
sg_set_buf(&sg[k], q, template[i].tap[k]);
|
||||
if (diff_dst) {
|
||||
q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
|
||||
sg_set_buf(&sgout[k], q,
|
||||
template[i].tap[k]);
|
||||
|
||||
memset(q, 0, template[i].tap[k]);
|
||||
if (offset_in_page(q) +
|
||||
template[i].tap[k] < PAGE_SIZE)
|
||||
q[template[i].tap[k]] = 0;
|
||||
}
|
||||
|
||||
temp += template[i].tap[k];
|
||||
}
|
||||
|
||||
ablkcipher_request_set_crypt(req, sg, sg,
|
||||
ablkcipher_request_set_crypt(req, sg,
|
||||
(diff_dst) ? sgout : sg,
|
||||
template[i].ilen, iv);
|
||||
|
||||
ret = enc ?
|
||||
|
|
@ -937,23 +1023,25 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
}
|
||||
/* fall through */
|
||||
default:
|
||||
printk(KERN_ERR "alg: skcipher: %s failed on "
|
||||
"chunk test %d for %s: ret=%d\n", e, j,
|
||||
algo, -ret);
|
||||
pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
|
||||
d, e, j, algo, -ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
temp = 0;
|
||||
ret = -EINVAL;
|
||||
for (k = 0; k < template[i].np; k++) {
|
||||
q = xbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
if (diff_dst)
|
||||
q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
else
|
||||
q = xbuf[IDX[k] >> PAGE_SHIFT] +
|
||||
offset_in_page(IDX[k]);
|
||||
|
||||
if (memcmp(q, template[i].result + temp,
|
||||
template[i].tap[k])) {
|
||||
printk(KERN_ERR "alg: skcipher: Chunk "
|
||||
"test %d failed on %s at page "
|
||||
"%u for %s\n", j, e, k, algo);
|
||||
pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n",
|
||||
d, j, e, k, algo);
|
||||
hexdump(q, template[i].tap[k]);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -962,11 +1050,8 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
for (n = 0; offset_in_page(q + n) && q[n]; n++)
|
||||
;
|
||||
if (n) {
|
||||
printk(KERN_ERR "alg: skcipher: "
|
||||
"Result buffer corruption in "
|
||||
"chunk test %d on %s at page "
|
||||
"%u for %s: %u bytes:\n", j, e,
|
||||
k, algo, n);
|
||||
pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
|
||||
d, j, e, k, algo, n);
|
||||
hexdump(q, n);
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -979,11 +1064,28 @@ static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
|||
|
||||
out:
|
||||
ablkcipher_request_free(req);
|
||||
if (diff_dst)
|
||||
testmgr_free_buf(xoutbuf);
|
||||
out_nooutbuf:
|
||||
testmgr_free_buf(xbuf);
|
||||
out_nobuf:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int test_skcipher(struct crypto_ablkcipher *tfm, int enc,
|
||||
struct cipher_testvec *template, unsigned int tcount)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* test 'dst == src' case */
|
||||
ret = __test_skcipher(tfm, enc, template, tcount, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* test 'dst != src' case */
|
||||
return __test_skcipher(tfm, enc, template, tcount, true);
|
||||
}
|
||||
|
||||
static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate,
|
||||
struct comp_testvec *dtemplate, int ctcount, int dtcount)
|
||||
{
|
||||
|
|
@ -1534,6 +1636,36 @@ static int alg_test_null(const struct alg_test_desc *desc,
|
|||
/* Please keep this list sorted by algorithm name. */
|
||||
static const struct alg_test_desc alg_test_descs[] = {
|
||||
{
|
||||
.alg = "__cbc-cast5-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__cbc-cast6-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__cbc-serpent-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
|
|
@ -1594,6 +1726,36 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__driver-cbc-cast5-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__driver-cbc-cast6-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__driver-cbc-serpent-avx",
|
||||
.test = alg_test_null,
|
||||
|
|
@ -1655,6 +1817,36 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__driver-ecb-cast5-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__driver-ecb-cast6-avx",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "__driver-ecb-serpent-avx",
|
||||
.test = alg_test_null,
|
||||
|
|
@ -1817,6 +2009,36 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "cbc(cast5)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = cast5_cbc_enc_tv_template,
|
||||
.count = CAST5_CBC_ENC_TEST_VECTORS
|
||||
},
|
||||
.dec = {
|
||||
.vecs = cast5_cbc_dec_tv_template,
|
||||
.count = CAST5_CBC_DEC_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "cbc(cast6)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = cast6_cbc_enc_tv_template,
|
||||
.count = CAST6_CBC_ENC_TEST_VECTORS
|
||||
},
|
||||
.dec = {
|
||||
.vecs = cast6_cbc_dec_tv_template,
|
||||
.count = CAST6_CBC_DEC_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "cbc(des)",
|
||||
.test = alg_test_skcipher,
|
||||
|
|
@ -1936,6 +2158,36 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "cryptd(__driver-ecb-cast5-avx)",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "cryptd(__driver-ecb-cast6-avx)",
|
||||
.test = alg_test_null,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
},
|
||||
.dec = {
|
||||
.vecs = NULL,
|
||||
.count = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "cryptd(__driver-ecb-serpent-avx)",
|
||||
.test = alg_test_null,
|
||||
|
|
@ -2053,6 +2305,36 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "ctr(cast5)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = cast5_ctr_enc_tv_template,
|
||||
.count = CAST5_CTR_ENC_TEST_VECTORS
|
||||
},
|
||||
.dec = {
|
||||
.vecs = cast5_ctr_dec_tv_template,
|
||||
.count = CAST5_CTR_DEC_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "ctr(cast6)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = cast6_ctr_enc_tv_template,
|
||||
.count = CAST6_CTR_ENC_TEST_VECTORS
|
||||
},
|
||||
.dec = {
|
||||
.vecs = cast6_ctr_dec_tv_template,
|
||||
.count = CAST6_CTR_DEC_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "ctr(serpent)",
|
||||
.test = alg_test_skcipher,
|
||||
|
|
@ -2529,6 +2811,21 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "lrw(cast6)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = cast6_lrw_enc_tv_template,
|
||||
.count = CAST6_LRW_ENC_TEST_VECTORS
|
||||
},
|
||||
.dec = {
|
||||
.vecs = cast6_lrw_dec_tv_template,
|
||||
.count = CAST6_LRW_DEC_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "lrw(serpent)",
|
||||
.test = alg_test_skcipher,
|
||||
|
|
@ -2881,6 +3178,21 @@ static const struct alg_test_desc alg_test_descs[] = {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "xts(cast6)",
|
||||
.test = alg_test_skcipher,
|
||||
.suite = {
|
||||
.cipher = {
|
||||
.enc = {
|
||||
.vecs = cast6_xts_enc_tv_template,
|
||||
.count = CAST6_XTS_ENC_TEST_VECTORS
|
||||
},
|
||||
.dec = {
|
||||
.vecs = cast6_xts_dec_tv_template,
|
||||
.count = CAST6_XTS_DEC_TEST_VECTORS
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
.alg = "xts(serpent)",
|
||||
.test = alg_test_skcipher,
|
||||
|
|
|
|||
3525
crypto/testmgr.h
3525
crypto/testmgr.h
File diff suppressed because it is too large
Load diff
|
|
@ -628,7 +628,7 @@ static int tgr128_final(struct shash_desc *desc, u8 * out)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct shash_alg tgr192 = {
|
||||
static struct shash_alg tgr_algs[3] = { {
|
||||
.digestsize = TGR192_DIGEST_SIZE,
|
||||
.init = tgr192_init,
|
||||
.update = tgr192_update,
|
||||
|
|
@ -640,9 +640,7 @@ static struct shash_alg tgr192 = {
|
|||
.cra_blocksize = TGR192_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static struct shash_alg tgr160 = {
|
||||
}, {
|
||||
.digestsize = TGR160_DIGEST_SIZE,
|
||||
.init = tgr192_init,
|
||||
.update = tgr192_update,
|
||||
|
|
@ -654,9 +652,7 @@ static struct shash_alg tgr160 = {
|
|||
.cra_blocksize = TGR192_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static struct shash_alg tgr128 = {
|
||||
}, {
|
||||
.digestsize = TGR128_DIGEST_SIZE,
|
||||
.init = tgr192_init,
|
||||
.update = tgr192_update,
|
||||
|
|
@ -668,38 +664,16 @@ static struct shash_alg tgr128 = {
|
|||
.cra_blocksize = TGR192_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
} };
|
||||
|
||||
static int __init tgr192_mod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = crypto_register_shash(&tgr192);
|
||||
|
||||
if (ret < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = crypto_register_shash(&tgr160);
|
||||
if (ret < 0) {
|
||||
crypto_unregister_shash(&tgr192);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = crypto_register_shash(&tgr128);
|
||||
if (ret < 0) {
|
||||
crypto_unregister_shash(&tgr192);
|
||||
crypto_unregister_shash(&tgr160);
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
return crypto_register_shashes(tgr_algs, ARRAY_SIZE(tgr_algs));
|
||||
}
|
||||
|
||||
static void __exit tgr192_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_shash(&tgr192);
|
||||
crypto_unregister_shash(&tgr160);
|
||||
crypto_unregister_shash(&tgr128);
|
||||
crypto_unregister_shashes(tgr_algs, ARRAY_SIZE(tgr_algs));
|
||||
}
|
||||
|
||||
MODULE_ALIAS("tgr160");
|
||||
|
|
|
|||
|
|
@ -188,7 +188,6 @@ static struct crypto_alg alg = {
|
|||
.cra_ctxsize = sizeof(struct twofish_ctx),
|
||||
.cra_alignmask = 3,
|
||||
.cra_module = THIS_MODULE,
|
||||
.cra_list = LIST_HEAD_INIT(alg.cra_list),
|
||||
.cra_u = { .cipher = {
|
||||
.cia_min_keysize = TF_MIN_KEY_SIZE,
|
||||
.cia_max_keysize = TF_MAX_KEY_SIZE,
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@
|
|||
* Constants and masks
|
||||
*/
|
||||
#define UINT64_C(x) x##ULL
|
||||
const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */
|
||||
const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */
|
||||
const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */
|
||||
const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */
|
||||
const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */
|
||||
static const u64 p64 = UINT64_C(0xfffffffffffffeff); /* 2^64 - 257 prime */
|
||||
static const u64 m62 = UINT64_C(0x3fffffffffffffff); /* 62-bit mask */
|
||||
static const u64 m63 = UINT64_C(0x7fffffffffffffff); /* 63-bit mask */
|
||||
static const u64 m64 = UINT64_C(0xffffffffffffffff); /* 64-bit mask */
|
||||
static const u64 mpoly = UINT64_C(0x1fffffff1fffffff); /* Poly key mask */
|
||||
|
||||
#define pe64_to_cpup le64_to_cpup /* Prefer little endian */
|
||||
|
||||
|
|
|
|||
|
|
@ -1119,7 +1119,7 @@ static int wp256_final(struct shash_desc *desc, u8 *out)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static struct shash_alg wp512 = {
|
||||
static struct shash_alg wp_algs[3] = { {
|
||||
.digestsize = WP512_DIGEST_SIZE,
|
||||
.init = wp512_init,
|
||||
.update = wp512_update,
|
||||
|
|
@ -1131,9 +1131,7 @@ static struct shash_alg wp512 = {
|
|||
.cra_blocksize = WP512_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static struct shash_alg wp384 = {
|
||||
}, {
|
||||
.digestsize = WP384_DIGEST_SIZE,
|
||||
.init = wp512_init,
|
||||
.update = wp512_update,
|
||||
|
|
@ -1145,9 +1143,7 @@ static struct shash_alg wp384 = {
|
|||
.cra_blocksize = WP512_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
|
||||
static struct shash_alg wp256 = {
|
||||
}, {
|
||||
.digestsize = WP256_DIGEST_SIZE,
|
||||
.init = wp512_init,
|
||||
.update = wp512_update,
|
||||
|
|
@ -1159,39 +1155,16 @@ static struct shash_alg wp256 = {
|
|||
.cra_blocksize = WP512_BLOCK_SIZE,
|
||||
.cra_module = THIS_MODULE,
|
||||
}
|
||||
};
|
||||
} };
|
||||
|
||||
static int __init wp512_mod_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret = crypto_register_shash(&wp512);
|
||||
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
ret = crypto_register_shash(&wp384);
|
||||
if (ret < 0)
|
||||
{
|
||||
crypto_unregister_shash(&wp512);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = crypto_register_shash(&wp256);
|
||||
if (ret < 0)
|
||||
{
|
||||
crypto_unregister_shash(&wp512);
|
||||
crypto_unregister_shash(&wp384);
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
return crypto_register_shashes(wp_algs, ARRAY_SIZE(wp_algs));
|
||||
}
|
||||
|
||||
static void __exit wp512_mod_fini(void)
|
||||
{
|
||||
crypto_unregister_shash(&wp512);
|
||||
crypto_unregister_shash(&wp384);
|
||||
crypto_unregister_shash(&wp256);
|
||||
crypto_unregister_shashes(wp_algs, ARRAY_SIZE(wp_algs));
|
||||
}
|
||||
|
||||
MODULE_ALIAS("wp384");
|
||||
|
|
|
|||
Loading…
Reference in a new issue