diff options
Diffstat (limited to 'security')
-rw-r--r-- | security/seclvl.c | 18 |
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]; | |||
197 | static int | 198 | static int |
198 | plaintext_to_sha1(unsigned char *hash, const char *plaintext, unsigned int len) | 199 | plaintext_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 | /** |