crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
[linux-block.git] / drivers / crypto / chelsio / chcr_algo.c
index 1b4a5664e6040c811a0ef31f833c4fccc98c954c..720b2ff5546404ac1897d794ee64b019e87bbbd7 100644 (file)
@@ -912,7 +912,6 @@ static int chcr_aes_cbc_setkey(struct crypto_skcipher *cipher,
        ablkctx->ciph_mode = CHCR_SCMD_CIPHER_MODE_AES_CBC;
        return 0;
 badkey_err:
-       crypto_skcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
        ablkctx->enckey_len = 0;
 
        return err;
@@ -943,7 +942,6 @@ static int chcr_aes_ctr_setkey(struct crypto_skcipher *cipher,
 
        return 0;
 badkey_err:
-       crypto_skcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
        ablkctx->enckey_len = 0;
 
        return err;
@@ -981,7 +979,6 @@ static int chcr_aes_rfc3686_setkey(struct crypto_skcipher *cipher,
 
        return 0;
 badkey_err:
-       crypto_skcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
        ablkctx->enckey_len = 0;
 
        return err;
@@ -1379,7 +1376,8 @@ static int chcr_device_init(struct chcr_context *ctx)
                txq_perchan = ntxq / u_ctx->lldi.nchan;
                spin_lock(&ctx->dev->lock_chcr_dev);
                ctx->tx_chan_id = ctx->dev->tx_channel_id;
-               ctx->dev->tx_channel_id = !ctx->dev->tx_channel_id;
+               ctx->dev->tx_channel_id =
+                       (ctx->dev->tx_channel_id + 1) %  u_ctx->lldi.nchan;
                spin_unlock(&ctx->dev->lock_chcr_dev);
                rxq_idx = ctx->tx_chan_id * rxq_perchan;
                rxq_idx += id % rxq_perchan;
@@ -2173,7 +2171,6 @@ static int chcr_aes_xts_setkey(struct crypto_skcipher *cipher, const u8 *key,
        ablkctx->ciph_mode = CHCR_SCMD_CIPHER_MODE_AES_XTS;
        return 0;
 badkey_err:
-       crypto_skcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
        ablkctx->enckey_len = 0;
 
        return err;
@@ -3195,9 +3192,6 @@ static int chcr_gcm_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
                aeadctx->mayverify = VERIFY_SW;
                break;
        default:
-
-                 crypto_tfm_set_flags((struct crypto_tfm *) tfm,
-                       CRYPTO_TFM_RES_BAD_KEY_LEN);
                return -EINVAL;
        }
        return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize);
@@ -3222,8 +3216,6 @@ static int chcr_4106_4309_setauthsize(struct crypto_aead *tfm,
                aeadctx->mayverify = VERIFY_HW;
                break;
        default:
-               crypto_tfm_set_flags((struct crypto_tfm *)tfm,
-                                    CRYPTO_TFM_RES_BAD_KEY_LEN);
                return -EINVAL;
        }
        return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize);
@@ -3264,8 +3256,6 @@ static int chcr_ccm_setauthsize(struct crypto_aead *tfm,
                aeadctx->mayverify = VERIFY_HW;
                break;
        default:
-               crypto_tfm_set_flags((struct crypto_tfm *)tfm,
-                                    CRYPTO_TFM_RES_BAD_KEY_LEN);
                return -EINVAL;
        }
        return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize);
@@ -3290,8 +3280,6 @@ static int chcr_ccm_common_setkey(struct crypto_aead *aead,
                ck_size = CHCR_KEYCTX_CIPHER_KEY_SIZE_256;
                mk_size = CHCR_KEYCTX_MAC_KEY_SIZE_256;
        } else {
-               crypto_tfm_set_flags((struct crypto_tfm *)aead,
-                                    CRYPTO_TFM_RES_BAD_KEY_LEN);
                aeadctx->enckey_len = 0;
                return  -EINVAL;
        }
@@ -3329,8 +3317,6 @@ static int chcr_aead_rfc4309_setkey(struct crypto_aead *aead, const u8 *key,
        int error;
 
        if (keylen < 3) {
-               crypto_tfm_set_flags((struct crypto_tfm *)aead,
-                                    CRYPTO_TFM_RES_BAD_KEY_LEN);
                aeadctx->enckey_len = 0;
                return  -EINVAL;
        }
@@ -3380,8 +3366,6 @@ static int chcr_gcm_setkey(struct crypto_aead *aead, const u8 *key,
        } else if (keylen == AES_KEYSIZE_256) {
                ck_size = CHCR_KEYCTX_CIPHER_KEY_SIZE_256;
        } else {
-               crypto_tfm_set_flags((struct crypto_tfm *)aead,
-                                    CRYPTO_TFM_RES_BAD_KEY_LEN);
                pr_err("GCM: Invalid key length %d\n", keylen);
                ret = -EINVAL;
                goto out;
@@ -3438,10 +3422,8 @@ static int chcr_authenc_setkey(struct crypto_aead *authenc, const u8 *key,
        if (err)
                goto out;
 
-       if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) {
-               crypto_aead_set_flags(authenc, CRYPTO_TFM_RES_BAD_KEY_LEN);
+       if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
                goto out;
-       }
 
        if (get_alg_config(&param, max_authsize)) {
                pr_err("chcr : Unsupported digest size\n");
@@ -3568,10 +3550,9 @@ static int chcr_aead_digest_null_setkey(struct crypto_aead *authenc,
        if (err)
                goto out;
 
-       if (crypto_authenc_extractkeys(&keys, key, keylen) != 0) {
-               crypto_aead_set_flags(authenc, CRYPTO_TFM_RES_BAD_KEY_LEN);
+       if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
                goto out;
-       }
+
        subtype = get_aead_subtype(authenc);
        if (subtype == CRYPTO_ALG_SUB_TYPE_CTR_SHA ||
            subtype == CRYPTO_ALG_SUB_TYPE_CTR_NULL) {