X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=security%2Fseclvl.c;h=8f6291991fbcb165fee06155e390027bbbcabd67;hb=2be344c4461d29b99113f62fa91c5ceab9997329;hp=441beaf1bbc1d104ea7c51706bd2f777feac44e2;hpb=a41622eaa97e40c811fb7756f403c0d4caa65654;p=powerpc.git diff --git a/security/seclvl.c b/security/seclvl.c index 441beaf1bb..8f6291991f 100644 --- a/security/seclvl.c +++ b/security/seclvl.c @@ -16,7 +16,7 @@ * (at your option) any later version. */ -#include +#include #include #include #include @@ -198,26 +198,27 @@ static unsigned char hashedPassword[SHA1_DIGEST_SIZE]; static int plaintext_to_sha1(unsigned char *hash, const char *plaintext, unsigned int len) { - struct crypto_tfm *tfm; + struct hash_desc desc; struct scatterlist sg; + int err; + if (len > PAGE_SIZE) { seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d " "characters). Largest possible is %lu " "bytes.\n", len, PAGE_SIZE); return -EINVAL; } - tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP); - if (tfm == NULL) { + desc.tfm = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC); + if (IS_ERR(desc.tfm)) { seclvl_printk(0, KERN_ERR, "Failed to load transform for SHA1\n"); return -EINVAL; } sg_init_one(&sg, (u8 *)plaintext, len); - crypto_digest_init(tfm); - crypto_digest_update(tfm, &sg, 1); - crypto_digest_final(tfm, hash); - crypto_free_tfm(tfm); - return 0; + desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; + err = crypto_hash_digest(&desc, &sg, len, hash); + crypto_free_hash(desc.tfm); + return err; } /**