X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=include%2Fcrypto%2Fhash.h;h=9fa0f77632a0121198b69750b43ab02139aa2d23;hb=ab14cc411c8ce8d07e266b0f2ac626f7e35f7f83;hp=26cb1eb16f4c0df0be234d081a419596fb081167;hpb=a9280fed383082da08a40af3f38daccaed6d8d62;p=pandora-kernel.git diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 26cb1eb16f4c..9fa0f77632a0 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -192,12 +192,22 @@ static inline int crypto_ahash_export(struct ahash_request *req, void *out) static inline int crypto_ahash_import(struct ahash_request *req, const void *in) { - return crypto_ahash_reqtfm(req)->import(req, in); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + + if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY) + return -ENOKEY; + + return tfm->import(req, in); } static inline int crypto_ahash_init(struct ahash_request *req) { - return crypto_ahash_reqtfm(req)->init(req); + struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); + + if (crypto_ahash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY) + return -ENOKEY; + + return tfm->init(req); } static inline int crypto_ahash_update(struct ahash_request *req) @@ -336,12 +346,22 @@ static inline int crypto_shash_export(struct shash_desc *desc, void *out) static inline int crypto_shash_import(struct shash_desc *desc, const void *in) { - return crypto_shash_alg(desc->tfm)->import(desc, in); + struct crypto_shash *tfm = desc->tfm; + + if (crypto_shash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY) + return -ENOKEY; + + return crypto_shash_alg(tfm)->import(desc, in); } static inline int crypto_shash_init(struct shash_desc *desc) { - return crypto_shash_alg(desc->tfm)->init(desc); + struct crypto_shash *tfm = desc->tfm; + + if (crypto_shash_get_flags(tfm) & CRYPTO_TFM_NEED_KEY) + return -ENOKEY; + + return crypto_shash_alg(tfm)->init(desc); } int crypto_shash_update(struct shash_desc *desc, const u8 *data,