aboutsummaryrefslogtreecommitdiffstats
path: root/security
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 /security
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 'security')
-rw-r--r--security/seclvl.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/security/seclvl.c b/security/seclvl.c
index c26dd7de0471..8f6291991fbc 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -16,6 +16,7 @@
16 * (at your option) any later version. 16 * (at your option) any later version.
17 */ 17 */
18 18
19#include <linux/err.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/moduleparam.h> 21#include <linux/moduleparam.h>
21#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -197,26 +198,27 @@ static unsigned char hashedPassword[SHA1_DIGEST_SIZE];
197static int 198static int
198plaintext_to_sha1(unsigned char *hash, const char *plaintext, unsigned int len) 199plaintext_to_sha1(unsigned char *hash, const char *plaintext, unsigned int len)
199{ 200{
200 struct crypto_tfm *tfm; 201 struct hash_desc desc;
201 struct scatterlist sg; 202 struct scatterlist sg;
203 int err;
204
202 if (len > PAGE_SIZE) { 205 if (len > PAGE_SIZE) {
203 seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d " 206 seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d "
204 "characters). Largest possible is %lu " 207 "characters). Largest possible is %lu "
205 "bytes.\n", len, PAGE_SIZE); 208 "bytes.\n", len, PAGE_SIZE);
206 return -EINVAL; 209 return -EINVAL;
207 } 210 }
208 tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP); 211 desc.tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
209 if (tfm == NULL) { 212 if (IS_ERR(desc.tfm)) {
210 seclvl_printk(0, KERN_ERR, 213 seclvl_printk(0, KERN_ERR,
211 "Failed to load transform for SHA1\n"); 214 "Failed to load transform for SHA1\n");
212 return -EINVAL; 215 return -EINVAL;
213 } 216 }
214 sg_init_one(&sg, (u8 *)plaintext, len); 217 sg_init_one(&sg, (u8 *)plaintext, len);
215 crypto_digest_init(tfm); 218 desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP;
216 crypto_digest_update(tfm, &sg, 1); 219 err = crypto_hash_digest(&desc, &sg, len, hash);
217 crypto_digest_final(tfm, hash); 220 crypto_free_hash(desc.tfm);
218 crypto_free_tfm(tfm); 221 return err;
219 return 0;
220} 222}
221 223
222/** 224/**