diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-22 15:51:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-22 15:51:33 -0400 |
commit | 6bbd9b6d694ff7242d63cda2faac4bd59ee4328e (patch) | |
tree | 0641aa896e2ea01f4692973e5fbea429408854f4 /security | |
parent | a489d159229fcc07bbb7566ac4fac745b79197ad (diff) | |
parent | 3c164bd8153c4644a22dc2101b003c67cd2a0d0a (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (64 commits)
[BLOCK] dm-crypt: trivial comment improvements
[CRYPTO] api: Deprecate crypto_digest_* and crypto_alg_available
[CRYPTO] padlock: Convert padlock-sha to use crypto_hash
[CRYPTO] users: Use crypto_comp and crypto_has_*
[CRYPTO] api: Add crypto_comp and crypto_has_*
[CRYPTO] users: Use crypto_hash interface instead of crypto_digest
[SCSI] iscsi: Use crypto_hash interface instead of crypto_digest
[CRYPTO] digest: Remove old HMAC implementation
[CRYPTO] doc: Update documentation for hash and me
[SCTP]: Use HMAC template and hash interface
[IPSEC]: Use HMAC template and hash interface
[CRYPTO] tcrypt: Use HMAC template and hash interface
[CRYPTO] hmac: Add crypto template implementation
[CRYPTO] digest: Added user API for new hash type
[CRYPTO] api: Mark parts of cipher interface as deprecated
[PATCH] scatterlist: Add const to sg_set_buf/sg_init_one pointer argument
[CRYPTO] drivers: Remove obsolete block cipher operations
[CRYPTO] users: Use block ciphers where applicable
[SUNRPC] GSS: Use block ciphers where applicable
[IPSEC] ESP: Use block ciphers where applicable
...
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 | /** |