Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac802154: Use skcipher

This patch replaces uses of blkcipher with skcipher.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: Stefan Schmidt <stefan@osg.samsung.com>

+24 -20
+23 -18
net/mac802154/llsec.c
··· 17 17 #include <linux/err.h> 18 18 #include <linux/bug.h> 19 19 #include <linux/completion.h> 20 - #include <linux/crypto.h> 21 20 #include <linux/ieee802154.h> 22 21 #include <crypto/aead.h> 22 + #include <crypto/skcipher.h> 23 23 24 24 #include "ieee802154_i.h" 25 25 #include "llsec.h" ··· 144 144 goto err_tfm; 145 145 } 146 146 147 - key->tfm0 = crypto_alloc_blkcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC); 147 + key->tfm0 = crypto_alloc_skcipher("ctr(aes)", 0, CRYPTO_ALG_ASYNC); 148 148 if (IS_ERR(key->tfm0)) 149 149 goto err_tfm; 150 150 151 - if (crypto_blkcipher_setkey(key->tfm0, template->key, 152 - IEEE802154_LLSEC_KEY_SIZE)) 151 + if (crypto_skcipher_setkey(key->tfm0, template->key, 152 + IEEE802154_LLSEC_KEY_SIZE)) 153 153 goto err_tfm0; 154 154 155 155 return key; 156 156 157 157 err_tfm0: 158 - crypto_free_blkcipher(key->tfm0); 158 + crypto_free_skcipher(key->tfm0); 159 159 err_tfm: 160 160 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) 161 161 if (key->tfm[i]) ··· 175 175 for (i = 0; i < ARRAY_SIZE(key->tfm); i++) 176 176 crypto_free_aead(key->tfm[i]); 177 177 178 - crypto_free_blkcipher(key->tfm0); 178 + crypto_free_skcipher(key->tfm0); 179 179 kzfree(key); 180 180 } 181 181 ··· 620 620 { 621 621 u8 iv[16]; 622 622 struct scatterlist src; 623 - struct blkcipher_desc req = { 624 - .tfm = key->tfm0, 625 - .info = iv, 626 - .flags = 0, 627 - }; 623 + SKCIPHER_REQUEST_ON_STACK(req, key->tfm0); 624 + int err; 628 625 629 626 llsec_geniv(iv, sec->params.hwaddr, &hdr->sec); 630 627 sg_init_one(&src, skb->data, skb->len); 631 - return crypto_blkcipher_encrypt_iv(&req, &src, &src, skb->len); 628 + skcipher_request_set_tfm(req, key->tfm0); 629 + skcipher_request_set_callback(req, 0, NULL, NULL); 630 + skcipher_request_set_crypt(req, &src, &src, skb->len, iv); 631 + err = crypto_skcipher_encrypt(req); 632 + skcipher_request_zero(req); 633 + return err; 632 634 } 633 635 634 636 static struct crypto_aead* ··· 832 830 unsigned char *data; 833 831 int datalen; 834 832 struct scatterlist src; 835 - struct blkcipher_desc req = { 836 - .tfm = key->tfm0, 837 - .info = iv, 838 - .flags = 0, 839 - }; 833 + SKCIPHER_REQUEST_ON_STACK(req, key->tfm0); 834 + int err; 840 835 841 836 llsec_geniv(iv, dev_addr, &hdr->sec); 842 837 data = skb_mac_header(skb) + skb->mac_len; ··· 841 842 842 843 sg_init_one(&src, data, datalen); 843 844 844 - return crypto_blkcipher_decrypt_iv(&req, &src, &src, datalen); 845 + skcipher_request_set_tfm(req, key->tfm0); 846 + skcipher_request_set_callback(req, 0, NULL, NULL); 847 + skcipher_request_set_crypt(req, &src, &src, datalen, iv); 848 + 849 + err = crypto_skcipher_decrypt(req); 850 + skcipher_request_zero(req); 851 + return err; 845 852 } 846 853 847 854 static int
+1 -2
net/mac802154/llsec.h
··· 19 19 20 20 #include <linux/slab.h> 21 21 #include <linux/hashtable.h> 22 - #include <linux/crypto.h> 23 22 #include <linux/kref.h> 24 23 #include <linux/spinlock.h> 25 24 #include <net/af_ieee802154.h> ··· 29 30 30 31 /* one tfm for each authsize (4/8/16) */ 31 32 struct crypto_aead *tfm[3]; 32 - struct crypto_blkcipher *tfm0; 33 + struct crypto_skcipher *tfm0; 33 34 34 35 struct kref ref; 35 36 };