From patchwork Thu Mar 16 14:39:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 9628415 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E967D60244 for ; Thu, 16 Mar 2017 14:40:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB5B7285EE for ; Thu, 16 Mar 2017 14:40:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFE362866E; Thu, 16 Mar 2017 14:40:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 52DD7285EE for ; Thu, 16 Mar 2017 14:40:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F49861E61; Thu, 16 Mar 2017 14:40:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5F49861E61 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5F49861E61 Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l2fpb6nj" Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 396BF88E11; Thu, 16 Mar 2017 14:40:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 04D7A1853D02; Thu, 16 Mar 2017 14:40:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2GEeDA9029490 for ; Thu, 16 Mar 2017 10:40:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0965560A9E; Thu, 16 Mar 2017 14:40:13 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0162E53CE7 for ; Thu, 16 Mar 2017 14:40:09 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80FB6C057FA4 for ; Thu, 16 Mar 2017 14:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80FB6C057FA4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=gmazyland@gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 80FB6C057FA4 Received: by mail-wm0-f68.google.com with SMTP id n11so10117080wma.0 for ; Thu, 16 Mar 2017 07:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=cBBq4KmR/mBxmUEXbDeSLez/si49ouCvBe3nCReJwJ8=; b=l2fpb6njKyp0QjkbrrY3oUQFCtRnl+OY/ax7TLWL/6kYC1mbDGZ9KGxA7lGZeKAmUA 3O4zsZwm19QIRJ/lci7Jw0HX7P+aLu3nqzoYUs9DiXPFIB++1iwgpWlF17V9GWOHw/82 ay5FsWlpRpoEwWRgOgqmYjhGb8tGxCQutPRKeNsTzoFifvanuk/aGgSc4ofA6q4Z2V1F dRssUyA/LFBfIjGO3OOdt8nXI1niJHdIOJVB2CgRq9cydSYhmmhuOFnj6Vmel9Pv1hGm b/3l9AlHL1e6fcpICnVOM4kaQFcATO4XbDwLrg6iv15mb0VCjT5GJkIH4ptpkP8EBIsc loPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=cBBq4KmR/mBxmUEXbDeSLez/si49ouCvBe3nCReJwJ8=; b=rXJyHFU7ijSbE9gfwVcY8WCPzF9vnj1dDJgVCOcZP2mZGv/o3RTtEsZ4ka4A4krJFu cqFWn7uArnv3bSRhP412YTZwbvMdAz/5NE1Kq8KA3yZq+wvcRGi1Er80M5vclNCT81ek MAsiwrxrVaajADgm1MHZSQ6BHL8Wre+86fJ1oPwAaKkVdPnT8kvW0qIKj63F4EfNR7k/ AOLYnZXeRtPq4MmpYVBdBQnPIT5jYn7Qtx0/XT4FRxI+yAWbXEKxJWe23P+vlA+vxucM J/iAHFb9iLQ0n8jz797BjFjSQmDJFdoYTMbFDeoxk/m+PNQZXnVXWynaYLwe3yRznq4i FcKg== X-Gm-Message-State: AFeK/H1VUvcUQF1Ku4+uLnKiG+kMiwZlVclDkCiNg3R7QBJ9JyPZbaRnR25N+LScJiZ/HA== X-Received: by 10.28.94.194 with SMTP id s185mr24417868wmb.52.1489675204954; Thu, 16 Mar 2017 07:40:04 -0700 (PDT) Received: from merlot.mazyland.net (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.googlemail.com with ESMTPSA id i203sm4553466wmf.12.2017.03.16.07.40.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Mar 2017 07:40:04 -0700 (PDT) From: Milan Broz To: dm-devel@redhat.com Date: Thu, 16 Mar 2017 15:39:43 +0100 Message-Id: <20170316143944.19843-7-gmazyland@gmail.com> In-Reply-To: <20170316143944.19843-1-gmazyland@gmail.com> References: <20170316143944.19843-1-gmazyland@gmail.com> In-Reply-To: References: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 16 Mar 2017 14:40:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 16 Mar 2017 14:40:07 +0000 (UTC) for IP:'74.125.82.68' DOMAIN:'mail-wm0-f68.google.com' HELO:'mail-wm0-f68.google.com' FROM:'gmazyland@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.07 * (BAYES_50, DCC_REPUT_13_19, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, SPF_PASS) 74.125.82.68 mail-wm0-f68.google.com 74.125.82.68 mail-wm0-f68.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Milan Broz Subject: [dm-devel] [PATCH 6/7] dm-crypt: Remove obsolete integrity_mode function. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 16 Mar 2017 14:40:18 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The HMAC composed mode is not processed the same as the normal AEAD mode, so this patch removes no longer needed flag and "hmac" specification for the table integrity argument. Signed-off-by: Milan Broz --- drivers/md/dm-crypt.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 3a4bf5791a3b..270adba14717 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c @@ -129,7 +129,6 @@ enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID, enum cipher_flags { CRYPT_MODE_INTEGRITY_AEAD, /* Use authenticated mode for cihper */ - CRYPT_MODE_INTEGRITY_HMAC, /* Compose authenticated mode from normal mode and HMAC */ }; /* @@ -876,16 +875,11 @@ static bool crypt_integrity_hmac(struct crypt_config *cc) return crypt_integrity_aead(cc) && cc->key_mac_size; } -static bool crypt_integrity_mode(struct crypt_config *cc) -{ - return crypt_integrity_aead(cc); -} - /* Get sg containing data */ static struct scatterlist *crypt_get_sg_data(struct crypt_config *cc, struct scatterlist *sg) { - if (unlikely(crypt_integrity_mode(cc))) + if (unlikely(crypt_integrity_aead(cc))) return &sg[2]; return sg; @@ -936,7 +930,7 @@ static int crypt_integrity_ctr(struct crypt_config *cc, struct dm_target *ti) return -EINVAL; } - if (crypt_integrity_mode(cc)) { + if (crypt_integrity_aead(cc)) { cc->integrity_tag_size = cc->on_disk_tag_size - cc->integrity_iv_size; DMINFO("Integrity AEAD, tag size %u, IV size %u.", cc->integrity_tag_size, cc->integrity_iv_size); @@ -990,7 +984,7 @@ static void *req_of_dmreq(struct crypt_config *cc, struct dm_crypt_request *dmre static u8 *iv_of_dmreq(struct crypt_config *cc, struct dm_crypt_request *dmreq) { - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) return (u8 *)ALIGN((unsigned long)(dmreq + 1), crypto_aead_alignmask(any_tfm_aead(cc)) + 1); else @@ -1235,7 +1229,7 @@ static void crypt_alloc_req_aead(struct crypt_config *cc, static void crypt_alloc_req(struct crypt_config *cc, struct convert_context *ctx) { - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) crypt_alloc_req_aead(cc, ctx); else crypt_alloc_req_skcipher(cc, ctx); @@ -1261,7 +1255,7 @@ static void crypt_free_req_aead(struct crypt_config *cc, static void crypt_free_req(struct crypt_config *cc, void *req, struct bio *base_bio) { - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) crypt_free_req_aead(cc, req, base_bio); else crypt_free_req_skcipher(cc, req, base_bio); @@ -1284,7 +1278,7 @@ static int crypt_convert(struct crypt_config *cc, atomic_inc(&ctx->cc_pending); - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) r = crypt_convert_block_aead(cc, ctx, ctx->r.req_aead, tag_offset); else r = crypt_convert_block_skcipher(cc, ctx, ctx->r.req, tag_offset); @@ -1849,7 +1843,7 @@ static void crypt_free_tfms_skcipher(struct crypt_config *cc) static void crypt_free_tfms(struct crypt_config *cc) { - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) crypt_free_tfms_aead(cc); else crypt_free_tfms_skcipher(cc); @@ -1897,7 +1891,7 @@ static int crypt_alloc_tfms_aead(struct crypt_config *cc, char *ciphermode) static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode) { - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) return crypt_alloc_tfms_aead(cc, ciphermode); else return crypt_alloc_tfms_skcipher(cc, ciphermode); @@ -2184,7 +2178,7 @@ static int crypt_ctr_ivmode(struct dm_target *ti, const char *ivmode) { struct crypt_config *cc = ti->private; - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) cc->iv_size = crypto_aead_ivsize(any_tfm_aead(cc)); else cc->iv_size = crypto_skcipher_ivsize(any_tfm(cc)); @@ -2376,7 +2370,7 @@ static int crypt_ctr_cipher_old(struct dm_target *ti, char *cipher_in, char *key int ret = -EINVAL; char dummy; - if (strchr(cipher_in, '(')) { + if (strchr(cipher_in, '(') || crypt_integrity_aead(cc)) { ti->error = "Bad cipher specification"; return -EINVAL; } @@ -2543,15 +2537,6 @@ static int crypt_ctr_optional(struct dm_target *ti, unsigned int argc, char **ar } if (!strcasecmp(sval, "aead")) { set_bit(CRYPT_MODE_INTEGRITY_AEAD, &cc->cipher_flags); - } else if (!strncasecmp(sval, "hmac(", strlen("hmac("))) { - struct crypto_ahash *hmac_tfm = crypto_alloc_ahash(sval, 0, 0); - if (IS_ERR(hmac_tfm)) { - ti->error = "Error initializing HMAC integrity hash."; - return PTR_ERR(hmac_tfm); - } - cc->key_mac_size = crypto_ahash_digestsize(hmac_tfm); - crypto_free_ahash(hmac_tfm); - set_bit(CRYPT_MODE_INTEGRITY_HMAC, &cc->cipher_flags); } else if (strcasecmp(sval, "none")) { ti->error = "Unknown integrity profile"; return -EINVAL; @@ -2614,7 +2599,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) if (ret < 0) goto bad; - if (crypt_integrity_mode(cc)) { + if (crypt_integrity_aead(cc)) { cc->dmreq_start = sizeof(struct aead_request); cc->dmreq_start += crypto_aead_reqsize(any_tfm_aead(cc)); align_mask = crypto_aead_alignmask(any_tfm_aead(cc)); @@ -2691,7 +2676,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) } cc->start = tmpll; - if (crypt_integrity_mode(cc) || cc->integrity_iv_size) { + if (crypt_integrity_aead(cc) || cc->integrity_iv_size) { ret = crypt_integrity_ctr(cc, ti); if (ret) goto bad; @@ -2789,7 +2774,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio) } } - if (crypt_integrity_mode(cc)) + if (crypt_integrity_aead(cc)) io->ctx.r.req_aead = (struct aead_request *)(io + 1); else io->ctx.r.req = (struct skcipher_request *)(io + 1);