aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-08-24 05:10:20 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-09-20 21:46:21 -0400
commit35058687912aa2f0b4554383cc10be4e0683b9a4 (patch)
tree3e18d13aef6682553887076c1e9872e91e6fc5c4 /net
parentdc64ddf4918f0da52df10d83c2a5941a547c2035 (diff)
[CRYPTO] users: Use crypto_hash interface instead of crypto_digest
This patch converts all remaining crypto_digest users to use the new crypto_hash interface. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net')
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c25
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c38
2 files changed, 38 insertions, 25 deletions
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index d60ce9b49b4f..407a17495b61 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -54,7 +54,7 @@ struct ieee80211_tkip_data {
54 int key_idx; 54 int key_idx;
55 55
56 struct crypto_blkcipher *tfm_arc4; 56 struct crypto_blkcipher *tfm_arc4;
57 struct crypto_tfm *tfm_michael; 57 struct crypto_hash *tfm_michael;
58 58
59 /* scratch buffers for virt_to_page() (crypto API) */ 59 /* scratch buffers for virt_to_page() (crypto API) */
60 u8 rx_hdr[16], tx_hdr[16]; 60 u8 rx_hdr[16], tx_hdr[16];
@@ -95,10 +95,12 @@ static void *ieee80211_tkip_init(int key_idx)
95 goto fail; 95 goto fail;
96 } 96 }
97 97
98 priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0); 98 priv->tfm_michael = crypto_alloc_hash("michael_mic", 0,
99 if (priv->tfm_michael == NULL) { 99 CRYPTO_ALG_ASYNC);
100 if (IS_ERR(priv->tfm_michael)) {
100 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate " 101 printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
101 "crypto API michael_mic\n"); 102 "crypto API michael_mic\n");
103 priv->tfm_michael = NULL;
102 goto fail; 104 goto fail;
103 } 105 }
104 106
@@ -107,7 +109,7 @@ static void *ieee80211_tkip_init(int key_idx)
107 fail: 109 fail:
108 if (priv) { 110 if (priv) {
109 if (priv->tfm_michael) 111 if (priv->tfm_michael)
110 crypto_free_tfm(priv->tfm_michael); 112 crypto_free_hash(priv->tfm_michael);
111 if (priv->tfm_arc4) 113 if (priv->tfm_arc4)
112 crypto_free_blkcipher(priv->tfm_arc4); 114 crypto_free_blkcipher(priv->tfm_arc4);
113 kfree(priv); 115 kfree(priv);
@@ -120,7 +122,7 @@ static void ieee80211_tkip_deinit(void *priv)
120{ 122{
121 struct ieee80211_tkip_data *_priv = priv; 123 struct ieee80211_tkip_data *_priv = priv;
122 if (_priv && _priv->tfm_michael) 124 if (_priv && _priv->tfm_michael)
123 crypto_free_tfm(_priv->tfm_michael); 125 crypto_free_hash(_priv->tfm_michael);
124 if (_priv && _priv->tfm_arc4) 126 if (_priv && _priv->tfm_arc4)
125 crypto_free_blkcipher(_priv->tfm_arc4); 127 crypto_free_blkcipher(_priv->tfm_arc4);
126 kfree(priv); 128 kfree(priv);
@@ -485,6 +487,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
485static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr, 487static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr,
486 u8 * data, size_t data_len, u8 * mic) 488 u8 * data, size_t data_len, u8 * mic)
487{ 489{
490 struct hash_desc desc;
488 struct scatterlist sg[2]; 491 struct scatterlist sg[2];
489 492
490 if (tkey->tfm_michael == NULL) { 493 if (tkey->tfm_michael == NULL) {
@@ -499,12 +502,12 @@ static int michael_mic(struct ieee80211_tkip_data *tkey, u8 * key, u8 * hdr,
499 sg[1].offset = offset_in_page(data); 502 sg[1].offset = offset_in_page(data);
500 sg[1].length = data_len; 503 sg[1].length = data_len;
501 504
502 crypto_digest_init(tkey->tfm_michael); 505 if (crypto_hash_setkey(tkey->tfm_michael, key, 8))
503 crypto_digest_setkey(tkey->tfm_michael, key, 8); 506 return -1;
504 crypto_digest_update(tkey->tfm_michael, sg, 2);
505 crypto_digest_final(tkey->tfm_michael, mic);
506 507
507 return 0; 508 desc.tfm = tkey->tfm_michael;
509 desc.flags = 0;
510 return crypto_hash_digest(&desc, sg, data_len + 16, mic);
508} 511}
509 512
510static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr) 513static void michael_mic_hdr(struct sk_buff *skb, u8 * hdr)
@@ -628,7 +631,7 @@ static int ieee80211_tkip_set_key(void *key, int len, u8 * seq, void *priv)
628{ 631{
629 struct ieee80211_tkip_data *tkey = priv; 632 struct ieee80211_tkip_data *tkey = priv;
630 int keyidx; 633 int keyidx;
631 struct crypto_tfm *tfm = tkey->tfm_michael; 634 struct crypto_hash *tfm = tkey->tfm_michael;
632 struct crypto_blkcipher *tfm2 = tkey->tfm_arc4; 635 struct crypto_blkcipher *tfm2 = tkey->tfm_arc4;
633 636
634 keyidx = tkey->key_idx; 637 keyidx = tkey->key_idx;
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 57192dfe3065..e11a40b25cce 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -34,6 +34,7 @@
34 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 34 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
35 */ 35 */
36 36
37#include <linux/err.h>
37#include <linux/types.h> 38#include <linux/types.h>
38#include <linux/mm.h> 39#include <linux/mm.h>
39#include <linux/slab.h> 40#include <linux/slab.h>
@@ -199,11 +200,9 @@ out:
199static int 200static int
200checksummer(struct scatterlist *sg, void *data) 201checksummer(struct scatterlist *sg, void *data)
201{ 202{
202 struct crypto_tfm *tfm = (struct crypto_tfm *)data; 203 struct hash_desc *desc = data;
203 204
204 crypto_digest_update(tfm, sg, 1); 205 return crypto_hash_update(desc, sg, sg->length);
205
206 return 0;
207} 206}
208 207
209/* checksum the plaintext data and hdrlen bytes of the token header */ 208/* checksum the plaintext data and hdrlen bytes of the token header */
@@ -212,8 +211,9 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
212 int body_offset, struct xdr_netobj *cksum) 211 int body_offset, struct xdr_netobj *cksum)
213{ 212{
214 char *cksumname; 213 char *cksumname;
215 struct crypto_tfm *tfm = NULL; /* XXX add to ctx? */ 214 struct hash_desc desc; /* XXX add to ctx? */
216 struct scatterlist sg[1]; 215 struct scatterlist sg[1];
216 int err;
217 217
218 switch (cksumtype) { 218 switch (cksumtype) {
219 case CKSUMTYPE_RSA_MD5: 219 case CKSUMTYPE_RSA_MD5:
@@ -224,18 +224,28 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
224 " unsupported checksum %d", cksumtype); 224 " unsupported checksum %d", cksumtype);
225 return GSS_S_FAILURE; 225 return GSS_S_FAILURE;
226 } 226 }
227 if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP))) 227 desc.tfm = crypto_alloc_hash(cksumname, 0, CRYPTO_ALG_ASYNC);
228 if (IS_ERR(desc.tfm))
228 return GSS_S_FAILURE; 229 return GSS_S_FAILURE;
229 cksum->len = crypto_tfm_alg_digestsize(tfm); 230 cksum->len = crypto_hash_digestsize(desc.tfm);
231 desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
230 232
231 crypto_digest_init(tfm); 233 err = crypto_hash_init(&desc);
234 if (err)
235 goto out;
232 sg_set_buf(sg, header, hdrlen); 236 sg_set_buf(sg, header, hdrlen);
233 crypto_digest_update(tfm, sg, 1); 237 err = crypto_hash_update(&desc, sg, hdrlen);
234 process_xdr_buf(body, body_offset, body->len - body_offset, 238 if (err)
235 checksummer, tfm); 239 goto out;
236 crypto_digest_final(tfm, cksum->data); 240 err = process_xdr_buf(body, body_offset, body->len - body_offset,
237 crypto_free_tfm(tfm); 241 checksummer, &desc);
238 return 0; 242 if (err)
243 goto out;
244 err = crypto_hash_final(&desc, cksum->data);
245
246out:
247 crypto_free_hash(desc.tfm);
248 return err ? GSS_S_FAILURE : 0;
239} 249}
240 250
241EXPORT_SYMBOL(make_checksum); 251EXPORT_SYMBOL(make_checksum);