aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
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/sunrpc
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/sunrpc')
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c38
1 files changed, 24 insertions, 14 deletions
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);