From: Sebastian Siewior <sebastian@breakpoint.cc>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Subject: [RFC 3/3] pass keysize to crypto_alloc_blkcipher()
Date: Tue, 9 Oct 2007 21:43:56 +0200 [thread overview]
Message-ID: <E1IfejW-0005Er-DT@Chamillionaire.breakpoint.cc> (raw)
In-Reply-To: <20071010164400.GA19471@Chamillionaire.breakpoint.cc>
[-- Attachment #1: Type: text/plain, Size: 370 bytes --]
and fix dm-crypt, wlan stack and trcypt
---
crypto/tcrypt.c | 26 +++++++++++++++-----------
drivers/md/dm-crypt.c | 2 +-
include/linux/crypto.h | 6 +++---
net/ieee80211/ieee80211_crypt_tkip.c | 4 ++--
net/ieee80211/ieee80211_crypt_wep.c | 6 ++++--
5 files changed, 25 insertions(+), 19 deletions(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 31317613c156e71eb741afded34554c35ddc83fc.diff --]
[-- Type: text/x-patch; name="31317613c156e71eb741afded34554c35ddc83fc.diff", Size: 4577 bytes --]
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 18d489c..456eb2b 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -501,21 +501,11 @@ static void test_cipher_speed(char *algo, int enc, unsigned int sec,
printk("\ntesting speed of %s %s\n", algo, e);
- tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
-
- if (IS_ERR(tfm)) {
- printk("failed to load transform for %s: %ld\n", algo,
- PTR_ERR(tfm));
- return;
- }
- desc.tfm = tfm;
- desc.flags = 0;
-
for (i = 0; speed[i].klen != 0; i++) {
if ((speed[i].blen + speed[i].klen) > TVMEMSIZE) {
printk("template (%u) too big for tvmem (%u)\n",
speed[i].blen + speed[i].klen, TVMEMSIZE);
- goto out;
+ return;
}
printk("test %u (%d bit key, %d byte blocks): ", i,
@@ -531,6 +521,18 @@ static void test_cipher_speed(char *algo, int enc, unsigned int sec,
break;
}
}
+
+ tfm = crypto_alloc_blkcipher(algo, speed[i].klen, 0,
+ CRYPTO_ALG_ASYNC);
+
+ if (IS_ERR(tfm)) {
+ printk("failed to load transform for %s: %ld\n", algo,
+ PTR_ERR(tfm));
+ return;
+ }
+ desc.tfm = tfm;
+ desc.flags = 0;
+
p = (unsigned char *)tvmem + speed[i].klen;
ret = crypto_blkcipher_setkey(tfm, key, speed[i].klen);
@@ -556,7 +558,9 @@ static void test_cipher_speed(char *algo, int enc, unsigned int sec,
printk("%s() failed flags=%x\n", e, desc.flags);
break;
}
+ crypto_free_blkcipher(tfm);
}
+ return;
out:
crypto_free_blkcipher(tfm);
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index bdc52d6..ba5a7df 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -794,7 +794,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
goto bad1;
}
- tfm = crypto_alloc_blkcipher(cc->cipher, 0, CRYPTO_ALG_ASYNC);
+ tfm = crypto_alloc_blkcipher(cc->cipher, key_size, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(tfm)) {
ti->error = "Error allocating crypto tfm";
goto bad1;
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index bbc15d0..c6b6d30 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -860,14 +860,14 @@ static inline struct crypto_blkcipher *crypto_blkcipher_cast(
}
static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
- const char *alg_name, u32 type, u32 mask)
+ const char *alg_name, u32 keysize, u32 type, u32 mask)
{
type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
type |= CRYPTO_ALG_TYPE_BLKCIPHER;
mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC;
- return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, 0, type,
- mask));
+ return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, keysize,
+ type, mask));
}
static inline struct crypto_tfm *crypto_blkcipher_tfm(
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 5a48d8e..696a451 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -89,7 +89,7 @@ static void *ieee80211_tkip_init(int key_idx)
priv->key_idx = key_idx;
- priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
+ priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_arc4)) {
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
@@ -107,7 +107,7 @@ static void *ieee80211_tkip_init(int key_idx)
goto fail;
}
- priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
+ priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm_arc4)) {
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
diff --git a/net/ieee80211/ieee80211_crypt_wep.c b/net/ieee80211/ieee80211_crypt_wep.c
index 8d18245..fcf989d 100644
--- a/net/ieee80211/ieee80211_crypt_wep.c
+++ b/net/ieee80211/ieee80211_crypt_wep.c
@@ -47,7 +47,8 @@ static void *prism2_wep_init(int keyidx)
goto fail;
priv->key_idx = keyidx;
- priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
+ priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 0,
+ CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
"crypto API arc4\n");
@@ -55,7 +56,8 @@ static void *prism2_wep_init(int keyidx)
goto fail;
}
- priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
+ priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 0,
+ CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm)) {
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
"crypto API arc4\n");
next prev parent reply other threads:[~2007-10-10 16:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-10 16:44 [RFC] consider keysize in algorithm selection Sebastian Siewior
2007-10-09 16:17 ` [RFC 1/3] [crypto] add keysize parameter Sebastian Siewior
2007-10-09 17:50 ` [RFC 2/3] crypto, keysize fixup crypto API intern calls Sebastian Siewior
2007-10-09 19:43 ` Sebastian Siewior [this message]
2007-10-11 11:47 ` [RFC] consider keysize in algorithm selection Herbert Xu
2007-10-11 12:43 ` Sebastian Siewior
2007-10-11 13:01 ` Herbert Xu
2007-10-11 13:28 ` Sebastian Siewior
2007-10-11 13:44 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1IfejW-0005Er-DT@Chamillionaire.breakpoint.cc \
--to=sebastian@breakpoint.cc \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).