crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
[linux-block.git] / drivers / crypto / ccree / cc_aead.c
index 64d318dc0d47b5e94efa98bf8648a2abfa5064a7..d014c8e063a7c688ad5826b1a596039a0d2761f6 100644 (file)
@@ -562,7 +562,7 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key,
 
                rc = crypto_authenc_extractkeys(&keys, key, keylen);
                if (rc)
-                       goto badkey;
+                       return rc;
                enckey = keys.enckey;
                authkey = keys.authkey;
                ctx->enc_keylen = keys.enckeylen;
@@ -570,10 +570,9 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key,
 
                if (ctx->cipher_mode == DRV_CIPHER_CTR) {
                        /* the nonce is stored in bytes at end of key */
-                       rc = -EINVAL;
                        if (ctx->enc_keylen <
                            (AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE))
-                               goto badkey;
+                               return -EINVAL;
                        /* Copy nonce from last 4 bytes in CTR key to
                         *  first 4 bytes in CTR IV
                         */
@@ -591,7 +590,7 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key,
 
        rc = validate_keys_sizes(ctx);
        if (rc)
-               goto badkey;
+               return rc;
 
        /* STAT_PHASE_1: Copy key to ctx */
 
@@ -605,7 +604,7 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key,
        } else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC */
                rc = cc_get_plain_hmac_key(tfm, authkey, ctx->auth_keylen);
                if (rc)
-                       goto badkey;
+                       return rc;
        }
 
        /* STAT_PHASE_2: Create sequence */
@@ -622,8 +621,7 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key,
                break; /* No auth. key setup */
        default:
                dev_err(dev, "Unsupported authenc (%d)\n", ctx->auth_mode);
-               rc = -ENOTSUPP;
-               goto badkey;
+               return -ENOTSUPP;
        }
 
        /* STAT_PHASE_3: Submit sequence to HW */
@@ -632,18 +630,12 @@ static int cc_aead_setkey(struct crypto_aead *tfm, const u8 *key,
                rc = cc_send_sync_request(ctx->drvdata, &cc_req, desc, seq_len);
                if (rc) {
                        dev_err(dev, "send_request() failed (rc=%d)\n", rc);
-                       goto setkey_error;
+                       return rc;
                }
        }
 
        /* Update STAT_PHASE_3 */
        return rc;
-
-badkey:
-       crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
-
-setkey_error:
-       return rc;
 }
 
 static int cc_des3_aead_setkey(struct crypto_aead *aead, const u8 *key,
@@ -1925,7 +1917,6 @@ static int cc_proc_aead(struct aead_request *req,
        if (validate_data_size(ctx, direct, req)) {
                dev_err(dev, "Unsupported crypt/assoc len %d/%d.\n",
                        req->cryptlen, areq_ctx->assoclen);
-               crypto_aead_set_flags(tfm, CRYPTO_TFM_RES_BAD_BLOCK_LEN);
                return -EINVAL;
        }