Commit 9783e1df authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'HEAD' of master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6

Conflicts:

	crypto/Kconfig
parents 4387ff75 dc2e2f33
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -193,6 +193,7 @@ Original developers of the crypto algorithms:
  Kartikey Mahendra Bhatt (CAST6)
  Kartikey Mahendra Bhatt (CAST6)
  Jon Oberheide (ARC4)
  Jon Oberheide (ARC4)
  Jouni Malinen (Michael MIC)
  Jouni Malinen (Michael MIC)
  NTT(Nippon Telegraph and Telephone Corporation) (Camellia)


SHA1 algorithm contributors:
SHA1 algorithm contributors:
  Jean-Francois Dive
  Jean-Francois Dive
@@ -246,6 +247,9 @@ Tiger algorithm contributors:
VIA PadLock contributors:
VIA PadLock contributors:
  Michal Ludvig
  Michal Ludvig


Camellia algorithm contributors:
  NTT(Nippon Telegraph and Telephone Corporation) (Camellia)

Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>
Generic scatterwalk code by Adam J. Richter <adam@yggdrasil.com>


Please send any credits updates or corrections to:
Please send any credits updates or corrections to:
+31 −0
Original line number Original line Diff line number Diff line
@@ -149,6 +149,15 @@ config CRYPTO_CBC
	  CBC: Cipher Block Chaining mode
	  CBC: Cipher Block Chaining mode
	  This block cipher algorithm is required for IPSec.
	  This block cipher algorithm is required for IPSec.


config CRYPTO_PCBC
	tristate "PCBC support"
	select CRYPTO_BLKCIPHER
	select CRYPTO_MANAGER
	default m
	help
	  PCBC: Propagating Cipher Block Chaining mode
	  This block cipher algorithm is required for RxRPC.

config CRYPTO_LRW
config CRYPTO_LRW
	tristate "LRW support (EXPERIMENTAL)"
	tristate "LRW support (EXPERIMENTAL)"
	depends on EXPERIMENTAL
	depends on EXPERIMENTAL
@@ -168,6 +177,13 @@ config CRYPTO_DES
	help
	help
	  DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).
	  DES cipher algorithm (FIPS 46-2), and Triple DES EDE (FIPS 46-3).


config CRYPTO_FCRYPT
	tristate "FCrypt cipher algorithm"
	select CRYPTO_ALGAPI
	select CRYPTO_BLKCIPHER
	help
	  FCrypt algorithm used by RxRPC.

config CRYPTO_BLOWFISH
config CRYPTO_BLOWFISH
	tristate "Blowfish cipher algorithm"
	tristate "Blowfish cipher algorithm"
	select CRYPTO_ALGAPI
	select CRYPTO_ALGAPI
@@ -409,6 +425,21 @@ config CRYPTO_CRC32C
	  See Castagnoli93.  This implementation uses lib/libcrc32c.
	  See Castagnoli93.  This implementation uses lib/libcrc32c.
          Module will be crc32c.
          Module will be crc32c.


config CRYPTO_CAMELLIA
	tristate "Camellia cipher algorithms"
	depends on CRYPTO
	select CRYPTO_ALGAPI
	help
	  Camellia cipher algorithms module.

	  Camellia is a symmetric key block cipher developed jointly
	  at NTT and Mitsubishi Electric Corporation.

	  The Camellia specifies three key sizes: 128, 192 and 256 bits.

	  See also:
	  <https://info.isl.ntt.co.jp/crypt/eng/camellia/index_s.html>

config CRYPTO_TEST
config CRYPTO_TEST
	tristate "Testing module"
	tristate "Testing module"
	depends on m
	depends on m
+3 −0
Original line number Original line Diff line number Diff line
@@ -27,13 +27,16 @@ obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
obj-$(CONFIG_CRYPTO_ECB) += ecb.o
obj-$(CONFIG_CRYPTO_ECB) += ecb.o
obj-$(CONFIG_CRYPTO_CBC) += cbc.o
obj-$(CONFIG_CRYPTO_CBC) += cbc.o
obj-$(CONFIG_CRYPTO_PCBC) += pcbc.o
obj-$(CONFIG_CRYPTO_LRW) += lrw.o
obj-$(CONFIG_CRYPTO_LRW) += lrw.o
obj-$(CONFIG_CRYPTO_DES) += des.o
obj-$(CONFIG_CRYPTO_DES) += des.o
obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
obj-$(CONFIG_CRYPTO_SERPENT) += serpent.o
obj-$(CONFIG_CRYPTO_AES) += aes.o
obj-$(CONFIG_CRYPTO_AES) += aes.o
obj-$(CONFIG_CRYPTO_CAMELLIA) += camellia.o
obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
obj-$(CONFIG_CRYPTO_CAST5) += cast5.o
obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
obj-$(CONFIG_CRYPTO_CAST6) += cast6.o
obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
obj-$(CONFIG_CRYPTO_ARC4) += arc4.o
+12 −3
Original line number Original line Diff line number Diff line
@@ -377,7 +377,8 @@ void crypto_drop_spawn(struct crypto_spawn *spawn)
}
}
EXPORT_SYMBOL_GPL(crypto_drop_spawn);
EXPORT_SYMBOL_GPL(crypto_drop_spawn);


struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn)
struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
				    u32 mask)
{
{
	struct crypto_alg *alg;
	struct crypto_alg *alg;
	struct crypto_alg *alg2;
	struct crypto_alg *alg2;
@@ -396,11 +397,19 @@ struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn)
		return ERR_PTR(-EAGAIN);
		return ERR_PTR(-EAGAIN);
	}
	}


	tfm = __crypto_alloc_tfm(alg, 0);
	tfm = ERR_PTR(-EINVAL);
	if (unlikely((alg->cra_flags ^ type) & mask))
		goto out_put_alg;

	tfm = __crypto_alloc_tfm(alg, type, mask);
	if (IS_ERR(tfm))
	if (IS_ERR(tfm))
		crypto_mod_put(alg);
		goto out_put_alg;


	return tfm;
	return tfm;

out_put_alg:
	crypto_mod_put(alg);
	return tfm;
}
}
EXPORT_SYMBOL_GPL(crypto_spawn_tfm);
EXPORT_SYMBOL_GPL(crypto_spawn_tfm);


+16 −64
Original line number Original line Diff line number Diff line
@@ -212,31 +212,12 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask)
}
}
EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup);
EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup);


static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
static int crypto_init_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
{
{
	tfm->crt_flags = flags & CRYPTO_TFM_REQ_MASK;
	const struct crypto_type *type_obj = tfm->__crt_alg->cra_type;
	flags &= ~CRYPTO_TFM_REQ_MASK;


	switch (crypto_tfm_alg_type(tfm)) {
	if (type_obj)
	case CRYPTO_ALG_TYPE_CIPHER:
		return type_obj->init(tfm, type, mask);
		return crypto_init_cipher_flags(tfm, flags);
		
	case CRYPTO_ALG_TYPE_DIGEST:
		return crypto_init_digest_flags(tfm, flags);
		
	case CRYPTO_ALG_TYPE_COMPRESS:
		return crypto_init_compress_flags(tfm, flags);
	}
	
	return 0;
}

static int crypto_init_ops(struct crypto_tfm *tfm)
{
	const struct crypto_type *type = tfm->__crt_alg->cra_type;

	if (type)
		return type->init(tfm);


	switch (crypto_tfm_alg_type(tfm)) {
	switch (crypto_tfm_alg_type(tfm)) {
	case CRYPTO_ALG_TYPE_CIPHER:
	case CRYPTO_ALG_TYPE_CIPHER:
@@ -285,29 +266,29 @@ static void crypto_exit_ops(struct crypto_tfm *tfm)
	}
	}
}
}


static unsigned int crypto_ctxsize(struct crypto_alg *alg, int flags)
static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask)
{
{
	const struct crypto_type *type = alg->cra_type;
	const struct crypto_type *type_obj = alg->cra_type;
	unsigned int len;
	unsigned int len;


	len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1);
	len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1);
	if (type)
	if (type_obj)
		return len + type->ctxsize(alg);
		return len + type_obj->ctxsize(alg, type, mask);


	switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
	switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) {
	default:
	default:
		BUG();
		BUG();


	case CRYPTO_ALG_TYPE_CIPHER:
	case CRYPTO_ALG_TYPE_CIPHER:
		len += crypto_cipher_ctxsize(alg, flags);
		len += crypto_cipher_ctxsize(alg);
		break;
		break;
		
		
	case CRYPTO_ALG_TYPE_DIGEST:
	case CRYPTO_ALG_TYPE_DIGEST:
		len += crypto_digest_ctxsize(alg, flags);
		len += crypto_digest_ctxsize(alg);
		break;
		break;
		
		
	case CRYPTO_ALG_TYPE_COMPRESS:
	case CRYPTO_ALG_TYPE_COMPRESS:
		len += crypto_compress_ctxsize(alg, flags);
		len += crypto_compress_ctxsize(alg);
		break;
		break;
	}
	}


@@ -322,24 +303,21 @@ void crypto_shoot_alg(struct crypto_alg *alg)
}
}
EXPORT_SYMBOL_GPL(crypto_shoot_alg);
EXPORT_SYMBOL_GPL(crypto_shoot_alg);


struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 flags)
struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type,
				      u32 mask)
{
{
	struct crypto_tfm *tfm = NULL;
	struct crypto_tfm *tfm = NULL;
	unsigned int tfm_size;
	unsigned int tfm_size;
	int err = -ENOMEM;
	int err = -ENOMEM;


	tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, flags);
	tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask);
	tfm = kzalloc(tfm_size, GFP_KERNEL);
	tfm = kzalloc(tfm_size, GFP_KERNEL);
	if (tfm == NULL)
	if (tfm == NULL)
		goto out_err;
		goto out_err;


	tfm->__crt_alg = alg;
	tfm->__crt_alg = alg;


	err = crypto_init_flags(tfm, flags);
	err = crypto_init_ops(tfm, type, mask);
	if (err)
		goto out_free_tfm;
		
	err = crypto_init_ops(tfm);
	if (err)
	if (err)
		goto out_free_tfm;
		goto out_free_tfm;


@@ -362,31 +340,6 @@ out:
}
}
EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);
EXPORT_SYMBOL_GPL(__crypto_alloc_tfm);


struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
{
	struct crypto_tfm *tfm = NULL;
	int err;

	do {
		struct crypto_alg *alg;

		alg = crypto_alg_mod_lookup(name, 0, CRYPTO_ALG_ASYNC);
		err = PTR_ERR(alg);
		if (IS_ERR(alg))
			continue;

		tfm = __crypto_alloc_tfm(alg, flags);
		err = 0;
		if (IS_ERR(tfm)) {
			crypto_mod_put(alg);
			err = PTR_ERR(tfm);
			tfm = NULL;
		}
	} while (err == -EAGAIN && !signal_pending(current));

	return tfm;
}

/*
/*
 *	crypto_alloc_base - Locate algorithm and allocate transform
 *	crypto_alloc_base - Locate algorithm and allocate transform
 *	@alg_name: Name of algorithm
 *	@alg_name: Name of algorithm
@@ -420,7 +373,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask)
			goto err;
			goto err;
		}
		}


		tfm = __crypto_alloc_tfm(alg, 0);
		tfm = __crypto_alloc_tfm(alg, type, mask);
		if (!IS_ERR(tfm))
		if (!IS_ERR(tfm))
			return tfm;
			return tfm;


@@ -466,7 +419,6 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
	kfree(tfm);
	kfree(tfm);
}
}


EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
EXPORT_SYMBOL_GPL(crypto_free_tfm);
EXPORT_SYMBOL_GPL(crypto_free_tfm);


int crypto_has_alg(const char *name, u32 type, u32 mask)
int crypto_has_alg(const char *name, u32 type, u32 mask)
Loading