Commit 1edb82d2 authored by Herbert Xu's avatar Herbert Xu

nfsd: Use shash

This patch replaces uses of the long obsolete hash interface with
shash.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 69110e3c
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
* *
*/ */
#include <crypto/hash.h>
#include <linux/file.h> #include <linux/file.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/crypto.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -104,29 +104,35 @@ static int ...@@ -104,29 +104,35 @@ static int
nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
{ {
struct xdr_netobj cksum; struct xdr_netobj cksum;
struct hash_desc desc; struct crypto_shash *tfm;
struct scatterlist sg;
int status; int status;
dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n", dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
clname->len, clname->data); clname->len, clname->data);
desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; tfm = crypto_alloc_shash("md5", 0, 0);
desc.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(tfm)) {
if (IS_ERR(desc.tfm)) { status = PTR_ERR(tfm);
status = PTR_ERR(desc.tfm);
goto out_no_tfm; goto out_no_tfm;
} }
cksum.len = crypto_hash_digestsize(desc.tfm); cksum.len = crypto_shash_digestsize(tfm);
cksum.data = kmalloc(cksum.len, GFP_KERNEL); cksum.data = kmalloc(cksum.len, GFP_KERNEL);
if (cksum.data == NULL) { if (cksum.data == NULL) {
status = -ENOMEM; status = -ENOMEM;
goto out; goto out;
} }
sg_init_one(&sg, clname->data, clname->len); {
SHASH_DESC_ON_STACK(desc, tfm);
desc->tfm = tfm;
desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
status = crypto_shash_digest(desc, clname->data, clname->len,
cksum.data);
shash_desc_zero(desc);
}
status = crypto_hash_digest(&desc, &sg, sg.length, cksum.data);
if (status) if (status)
goto out; goto out;
...@@ -135,7 +141,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) ...@@ -135,7 +141,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
status = 0; status = 0;
out: out:
kfree(cksum.data); kfree(cksum.data);
crypto_free_hash(desc.tfm); crypto_free_shash(tfm);
out_no_tfm: out_no_tfm:
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment