Message ID | 20181018143718.26298-33-richard@nod.at |
---|---|
State | Accepted |
Delegated to: | David Oberhollenzer |
Headers | show
Return-Path: <linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Zk9ipLez"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="pRnIyUlK"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bXZ96zC5z9sC2 for <incoming@patchwork.ozlabs.org>; Fri, 19 Oct 2018 02:11:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZU6as34rX7ClFpGKNVBQgy2JzHY46Gxe0Fcv/8EohK0=; b=Zk9ipLezIz5wwK NuJaVW37inY3HnpGnJSqqQFip6xFdpN3F0g7OW4nmcjz2flcX9dGLFpa4lArfktiW7FV4b7g3KtID BElSbb9pwiuCNZTqmD5jHPRvSkwGxQwUXAKtV8bwSC58eEvg+mv9aSLXvbjzE1+2gBzJnH7UgLDMx Vn8b8hW0cn+l1KxUeWy07N5J+2PYck89BEIP88TguNSrXTbjk4WpYpVyfZwvtcgr6iby2dMN7K+Ma 5Cs/IDr/tOkFMJqzMHpKhUiBabINA2IJJP5hAGv974B1UcvJAzMGp2jK3Euj0PRDWJh+ef3YYb8O2 wEu0xPOhj+R2q0xx5UNw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD9xI-0007RX-RS; Thu, 18 Oct 2018 15:11:20 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD9T9-00053K-Qz for linux-mtd@bombadil.infradead.org; Thu, 18 Oct 2018 14:40:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CO3J8RlbL3sjIFgG6FUQb/JvF1crc8OeiMhVGuRIPU8=; b=pRnIyUlKnh2OolNdfAoZ/Cif0m Qi4h7nvvZa7/9RGBitSwfybKPnTx875yQRL/1Gig0I2MFW4dqByKwqtXfFwMeBzhL/P/gm2f2h7OS 5HE+Xi7BC9GzM3uxJWVu7IHPNdWQVwGhmDea0FqB2WBQ8YiDO+gqmTIuzoTahdXYa56UlTmaD8ltW 4ejMTZTPtc2ybPpJn56pSaeNdBVnq5i2F+GIYQuavQAJXV2VkqDe6aOm6GoVTzpEy0QRBLGs2VoNz eksb32eEronRH6sw9wk/sDdEwAGQqhqSw9+KhLTK26RA2Sqb53bIn0DbCqOkGiv4Ko6qiAmLzoxXS 1Fb/Fb+A==; Received: from lilium.sigma-star.at ([109.75.188.150]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD9SC-0002Rg-Pr for linux-mtd@lists.infradead.org; Thu, 18 Oct 2018 14:39:15 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 8FA9618011B7B; Thu, 18 Oct 2018 16:38:58 +0200 (CEST) From: Richard Weinberger <richard@nod.at> To: linux-mtd@lists.infradead.org Subject: [PATCH 32/42] mkfs.ubifs: Correctly use iv lengths in aes-cts mode Date: Thu, 18 Oct 2018 16:37:08 +0200 Message-Id: <20181018143718.26298-33-richard@nod.at> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181018143718.26298-1-richard@nod.at> References: <20181018143718.26298-1-richard@nod.at> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181018_153913_003171_95E59B2F X-CRM114-Status: GOOD ( 11.21 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list <linux-mtd.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mtd>, <mailto:linux-mtd-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-mtd/> List-Post: <mailto:linux-mtd@lists.infradead.org> List-Help: <mailto:linux-mtd-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mtd>, <mailto:linux-mtd-request@lists.infradead.org?subject=subscribe> Cc: Richard Weinberger <richard@nod.at>, david.oberhollenzer@sigma-star.at Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" <linux-mtd-bounces@lists.infradead.org> Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org |
Series |
mtd-utils: Add fscrypt support to mkfs.ubifs
|
expand
|
diff --git a/ubifs-utils/mkfs.ubifs/crypto.c b/ubifs-utils/mkfs.ubifs/crypto.c index bd3273767a5b..8d113f198bb2 100644 --- a/ubifs-utils/mkfs.ubifs/crypto.c +++ b/ubifs-utils/mkfs.ubifs/crypto.c @@ -207,32 +207,32 @@ static ssize_t encrypt_cbc_cts(const void *plaintext, size_t size, memset(iv, 0, ivsize); - diff = size % key_len; + diff = size % ivsize; if (diff) { - padded_size = size - diff + key_len; + padded_size = size - diff + ivsize; padded = size > 256 ? malloc(padded_size) : alloca(padded_size); memcpy(padded, plaintext, size); memset(padded + size, 0, padded_size - size); ret = do_encrypt(cipher, padded, padded_size, key, key_len, - iv, sizeof(iv), ciphertext); + iv, ivsize, ciphertext); if (size > 256) free(padded); } else { ret = do_encrypt(cipher, plaintext, size, key, key_len, - iv, sizeof(iv), ciphertext); + iv, ivsize, ciphertext); } if (ret < 0) return ret; - count = ret / key_len; + count = ret / ivsize; if (count > 1) - block_swap(ciphertext, count - 2, count - 1, key_len); + block_swap(ciphertext, count - 2, count - 1, ivsize); return size; }
The key length can be very long, for example in xts mode. So we have to use the right sizes for block and iv lengths. Signed-off-by: Richard Weinberger <richard@nod.at> --- ubifs-utils/mkfs.ubifs/crypto.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)