diff options
Diffstat (limited to 'net/mac802154/llsec.c')
-rw-r--r-- | net/mac802154/llsec.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/net/mac802154/llsec.c b/net/mac802154/llsec.c index a13d02b7cee4..6a3e1c2181d3 100644 --- a/net/mac802154/llsec.c +++ b/net/mac802154/llsec.c | |||
@@ -17,9 +17,9 @@ | |||
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | #include <linux/bug.h> | 18 | #include <linux/bug.h> |
19 | #include <linux/completion.h> | 19 | #include <linux/completion.h> |
20 | #include <linux/crypto.h> | ||
21 | #include <linux/ieee802154.h> | 20 | #include <linux/ieee802154.h> |
22 | #include <crypto/aead.h> | 21 | #include <crypto/aead.h> |
22 | #include <crypto/skcipher.h> | ||
23 | 23 | ||
24 | #include "ieee802154_i.h" | 24 | #include "ieee802154_i.h" |
25 | #include "llsec.h" | 25 | #include "llsec.h" |
@@ -144,18 +144,18 @@ llsec_key_alloc(const struct ieee802154_llsec_key *template) | |||
144 | goto err_tfm; | 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 | if (IS_ERR(key->tfm0)) | 148 | if (IS_ERR(key->tfm0)) |
149 | goto err_tfm; | 149 | goto err_tfm; |
150 | 150 | ||
151 | if (crypto_blkcipher_setkey(key->tfm0, template->key, | 151 | if (crypto_skcipher_setkey(key->tfm0, template->key, |
152 | IEEE802154_LLSEC_KEY_SIZE)) | 152 | IEEE802154_LLSEC_KEY_SIZE)) |
153 | goto err_tfm0; | 153 | goto err_tfm0; |
154 | 154 | ||
155 | return key; | 155 | return key; |
156 | 156 | ||
157 | err_tfm0: | 157 | err_tfm0: |
158 | crypto_free_blkcipher(key->tfm0); | 158 | crypto_free_skcipher(key->tfm0); |
159 | err_tfm: | 159 | err_tfm: |
160 | for (i = 0; i < ARRAY_SIZE(key->tfm); i++) | 160 | for (i = 0; i < ARRAY_SIZE(key->tfm); i++) |
161 | if (key->tfm[i]) | 161 | if (key->tfm[i]) |
@@ -175,7 +175,7 @@ static void llsec_key_release(struct kref *ref) | |||
175 | for (i = 0; i < ARRAY_SIZE(key->tfm); i++) | 175 | for (i = 0; i < ARRAY_SIZE(key->tfm); i++) |
176 | crypto_free_aead(key->tfm[i]); | 176 | crypto_free_aead(key->tfm[i]); |
177 | 177 | ||
178 | crypto_free_blkcipher(key->tfm0); | 178 | crypto_free_skcipher(key->tfm0); |
179 | kzfree(key); | 179 | kzfree(key); |
180 | } | 180 | } |
181 | 181 | ||
@@ -620,15 +620,17 @@ llsec_do_encrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec, | |||
620 | { | 620 | { |
621 | u8 iv[16]; | 621 | u8 iv[16]; |
622 | struct scatterlist src; | 622 | struct scatterlist src; |
623 | struct blkcipher_desc req = { | 623 | SKCIPHER_REQUEST_ON_STACK(req, key->tfm0); |
624 | .tfm = key->tfm0, | 624 | int err; |
625 | .info = iv, | ||
626 | .flags = 0, | ||
627 | }; | ||
628 | 625 | ||
629 | llsec_geniv(iv, sec->params.hwaddr, &hdr->sec); | 626 | llsec_geniv(iv, sec->params.hwaddr, &hdr->sec); |
630 | sg_init_one(&src, skb->data, skb->len); | 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 | static struct crypto_aead* | 636 | static struct crypto_aead* |
@@ -830,11 +832,8 @@ llsec_do_decrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec, | |||
830 | unsigned char *data; | 832 | unsigned char *data; |
831 | int datalen; | 833 | int datalen; |
832 | struct scatterlist src; | 834 | struct scatterlist src; |
833 | struct blkcipher_desc req = { | 835 | SKCIPHER_REQUEST_ON_STACK(req, key->tfm0); |
834 | .tfm = key->tfm0, | 836 | int err; |
835 | .info = iv, | ||
836 | .flags = 0, | ||
837 | }; | ||
838 | 837 | ||
839 | llsec_geniv(iv, dev_addr, &hdr->sec); | 838 | llsec_geniv(iv, dev_addr, &hdr->sec); |
840 | data = skb_mac_header(skb) + skb->mac_len; | 839 | data = skb_mac_header(skb) + skb->mac_len; |
@@ -842,7 +841,13 @@ llsec_do_decrypt_unauth(struct sk_buff *skb, const struct mac802154_llsec *sec, | |||
842 | 841 | ||
843 | sg_init_one(&src, data, datalen); | 842 | sg_init_one(&src, data, datalen); |
844 | 843 | ||
845 | return crypto_blkcipher_decrypt_iv(&req, &src, &src, datalen); | 844 | skcipher_request_set_tfm(req, key->tfm0); |
845 | skcipher_request_set_callback(req, 0, NULL, NULL); | ||
846 | skcipher_request_set_crypt(req, &src, &src, datalen, iv); | ||
847 | |||
848 | err = crypto_skcipher_decrypt(req); | ||
849 | skcipher_request_zero(req); | ||
850 | return err; | ||
846 | } | 851 | } |
847 | 852 | ||
848 | static int | 853 | static int |