Merge tag 'for-linus-5.3' of git://github.com/cminyard/linux-ipmi
[sfrench/cifs-2.6.git] / crypto / skcipher.c
index df735148000f2823f1f6fb922cb15be0a0c4995a..5d836fc3df3e71632e5c192da82c1f10776a5373 100644 (file)
@@ -837,6 +837,40 @@ static int skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
        return 0;
 }
 
+int crypto_skcipher_encrypt(struct skcipher_request *req)
+{
+       struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
+       struct crypto_alg *alg = tfm->base.__crt_alg;
+       unsigned int cryptlen = req->cryptlen;
+       int ret;
+
+       crypto_stats_get(alg);
+       if (crypto_skcipher_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
+               ret = -ENOKEY;
+       else
+               ret = tfm->encrypt(req);
+       crypto_stats_skcipher_encrypt(cryptlen, ret, alg);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_skcipher_encrypt);
+
+int crypto_skcipher_decrypt(struct skcipher_request *req)
+{
+       struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
+       struct crypto_alg *alg = tfm->base.__crt_alg;
+       unsigned int cryptlen = req->cryptlen;
+       int ret;
+
+       crypto_stats_get(alg);
+       if (crypto_skcipher_get_flags(tfm) & CRYPTO_TFM_NEED_KEY)
+               ret = -ENOKEY;
+       else
+               ret = tfm->decrypt(req);
+       crypto_stats_skcipher_decrypt(cryptlen, ret, alg);
+       return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_skcipher_decrypt);
+
 static void crypto_skcipher_exit_tfm(struct crypto_tfm *tfm)
 {
        struct crypto_skcipher *skcipher = __crypto_skcipher_cast(tfm);