Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: tcrypt - do not attempt to write to readonly variable
  random: update interface comments to reflect reality
  crypto: picoxcell - add support for the picoxcell crypto engines
  crypto: sha1 - Add test vector to test partial block processing
  hwrng: omap - Convert release_resource to release_region/release_mem_region
  crypto: aesni-intel - Fix remaining leak in rfc4106_set_hash_key
  crypto: omap-sham - don't treat NULL clk as an error
  crypto: omap-aes - don't treat NULL clk as an error
  crypto: testmgr - mark ghash as fips_allowed
  crypto: testmgr - mark xts(aes) as fips_allowed
  crypto: skcipher - remove redundant NULL check
  hwrng: pixocell - add support for picoxcell TRNG
  crypto: aesni-intel - Don't leak memory in rfc4106_set_hash_subkey
  • Loading branch information
torvalds committed Mar 16, 2011
2 parents 3ae2a1c + f07ef1d commit 0d2ecee
Show file tree
Hide file tree
Showing 16 changed files with 2,299 additions and 33 deletions.
24 changes: 11 additions & 13 deletions arch/x86/crypto/aesni-intel_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,22 +873,18 @@ rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len)
crypto_ablkcipher_clear_flags(ctr_tfm, ~0);

ret = crypto_ablkcipher_setkey(ctr_tfm, key, key_len);
if (ret) {
crypto_free_ablkcipher(ctr_tfm);
return ret;
}
if (ret)
goto out_free_ablkcipher;

ret = -ENOMEM;
req = ablkcipher_request_alloc(ctr_tfm, GFP_KERNEL);
if (!req) {
crypto_free_ablkcipher(ctr_tfm);
return -EINVAL;
}
if (!req)
goto out_free_ablkcipher;

req_data = kmalloc(sizeof(*req_data), GFP_KERNEL);
if (!req_data) {
crypto_free_ablkcipher(ctr_tfm);
return -ENOMEM;
}
if (!req_data)
goto out_free_request;

memset(req_data->iv, 0, sizeof(req_data->iv));

/* Clear the data in the hash sub key container to zero.*/
Expand All @@ -913,8 +909,10 @@ rfc4106_set_hash_subkey(u8 *hash_subkey, const u8 *key, unsigned int key_len)
if (!ret)
ret = req_data->result.err;
}
ablkcipher_request_free(req);
kfree(req_data);
out_free_request:
ablkcipher_request_free(req);
out_free_ablkcipher:
crypto_free_ablkcipher(ctr_tfm);
return ret;
}
Expand Down
3 changes: 1 addition & 2 deletions crypto/ablkcipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ int ablkcipher_walk_done(struct ablkcipher_request *req,

if (walk->iv != req->info)
memcpy(req->info, walk->iv, tfm->crt_ablkcipher.ivsize);
if (walk->iv_buffer)
kfree(walk->iv_buffer);
kfree(walk->iv_buffer);

return err;
}
Expand Down
3 changes: 2 additions & 1 deletion crypto/tcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ static void test_cipher_speed(const char *algo, int enc, unsigned int sec,
unsigned int tcount, u8 *keysize)
{
unsigned int ret, i, j, iv_len;
const char *key, iv[128];
const char *key;
char iv[128];
struct crypto_blkcipher *tfm;
struct blkcipher_desc desc;
const char *e;
Expand Down
2 changes: 2 additions & 0 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,7 @@ static const struct alg_test_desc alg_test_descs[] = {
}, {
.alg = "ghash",
.test = alg_test_hash,
.fips_allowed = 1,
.suite = {
.hash = {
.vecs = ghash_tv_template,
Expand Down Expand Up @@ -2453,6 +2454,7 @@ static const struct alg_test_desc alg_test_descs[] = {
}, {
.alg = "xts(aes)",
.test = alg_test_skcipher,
.fips_allowed = 1,
.suite = {
.cipher = {
.enc = {
Expand Down
30 changes: 29 additions & 1 deletion crypto/testmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,9 @@ static struct hash_testvec rmd320_tv_template[] = {

/*
* SHA1 test vectors from from FIPS PUB 180-1
* Long vector from CAVS 5.0
*/
#define SHA1_TEST_VECTORS 2
#define SHA1_TEST_VECTORS 3

static struct hash_testvec sha1_tv_template[] = {
{
Expand All @@ -467,6 +468,33 @@ static struct hash_testvec sha1_tv_template[] = {
"\x4a\xa1\xf9\x51\x29\xe5\xe5\x46\x70\xf1",
.np = 2,
.tap = { 28, 28 }
}, {
.plaintext = "\xec\x29\x56\x12\x44\xed\xe7\x06"
"\xb6\xeb\x30\xa1\xc3\x71\xd7\x44"
"\x50\xa1\x05\xc3\xf9\x73\x5f\x7f"
"\xa9\xfe\x38\xcf\x67\xf3\x04\xa5"
"\x73\x6a\x10\x6e\x92\xe1\x71\x39"
"\xa6\x81\x3b\x1c\x81\xa4\xf3\xd3"
"\xfb\x95\x46\xab\x42\x96\xfa\x9f"
"\x72\x28\x26\xc0\x66\x86\x9e\xda"
"\xcd\x73\xb2\x54\x80\x35\x18\x58"
"\x13\xe2\x26\x34\xa9\xda\x44\x00"
"\x0d\x95\xa2\x81\xff\x9f\x26\x4e"
"\xcc\xe0\xa9\x31\x22\x21\x62\xd0"
"\x21\xcc\xa2\x8d\xb5\xf3\xc2\xaa"
"\x24\x94\x5a\xb1\xe3\x1c\xb4\x13"
"\xae\x29\x81\x0f\xd7\x94\xca\xd5"
"\xdf\xaf\x29\xec\x43\xcb\x38\xd1"
"\x98\xfe\x4a\xe1\xda\x23\x59\x78"
"\x02\x21\x40\x5b\xd6\x71\x2a\x53"
"\x05\xda\x4b\x1b\x73\x7f\xce\x7c"
"\xd2\x1c\x0e\xb7\x72\x8d\x08\x23"
"\x5a\x90\x11",
.psize = 163,
.digest = "\x97\x01\x11\xc4\xe7\x7b\xcc\x88\xcc\x20"
"\x45\x9c\x02\xb6\x9b\x4a\xa8\xf5\x82\x17",
.np = 4,
.tap = { 63, 64, 31, 5 }
}
};

Expand Down
12 changes: 12 additions & 0 deletions drivers/char/hw_random/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,15 @@ config HW_RANDOM_NOMADIK
module will be called nomadik-rng.

If unsure, say Y.

config HW_RANDOM_PICOXCELL
tristate "Picochip picoXcell true random number generator support"
depends on HW_RANDOM && ARCH_PICOXCELL && PICOXCELL_PC3X3
---help---
This driver provides kernel-side support for the Random Number
Generator hardware found on Picochip PC3x3 and later devices.

To compile this driver as a module, choose M here: the
module will be called picoxcell-rng.

If unsure, say Y.
1 change: 1 addition & 0 deletions drivers/char/hw_random/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o
obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o
obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o
obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o
14 changes: 6 additions & 8 deletions drivers/char/hw_random/omap-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static struct hwrng omap_rng_ops = {

static int __devinit omap_rng_probe(struct platform_device *pdev)
{
struct resource *res, *mem;
struct resource *res;
int ret;

/*
Expand All @@ -116,14 +116,12 @@ static int __devinit omap_rng_probe(struct platform_device *pdev)
if (!res)
return -ENOENT;

mem = request_mem_region(res->start, resource_size(res),
pdev->name);
if (mem == NULL) {
if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
ret = -EBUSY;
goto err_region;
}

dev_set_drvdata(&pdev->dev, mem);
dev_set_drvdata(&pdev->dev, res);
rng_base = ioremap(res->start, resource_size(res));
if (!rng_base) {
ret = -ENOMEM;
Expand All @@ -146,7 +144,7 @@ static int __devinit omap_rng_probe(struct platform_device *pdev)
iounmap(rng_base);
rng_base = NULL;
err_ioremap:
release_resource(mem);
release_mem_region(res->start, resource_size(res));
err_region:
if (cpu_is_omap24xx()) {
clk_disable(rng_ick);
Expand All @@ -157,7 +155,7 @@ static int __devinit omap_rng_probe(struct platform_device *pdev)

static int __exit omap_rng_remove(struct platform_device *pdev)
{
struct resource *mem = dev_get_drvdata(&pdev->dev);
struct resource *res = dev_get_drvdata(&pdev->dev);

hwrng_unregister(&omap_rng_ops);

Expand All @@ -170,7 +168,7 @@ static int __exit omap_rng_remove(struct platform_device *pdev)
clk_put(rng_ick);
}

release_resource(mem);
release_mem_region(res->start, resource_size(res));
rng_base = NULL;

return 0;
Expand Down
Loading

0 comments on commit 0d2ecee

Please sign in to comment.