From patchwork Thu Oct 18 14:36:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 985951 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: 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=) 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="CBKwbyOF"; 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 42bX0n05rBz9sC2 for ; Fri, 19 Oct 2018 01:46:01 +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=rbiI9ndpEDF/5HgSeKX0QPGTNMcTXgQ2ZnTa8ifYRbI=; b=CBKwbyOF0M0NuS k84g6cPtpqsKaRTc4vf/rWkeSACS7ElXja5lqCpzeAbdMAm386CundK+hnKSK6sjEFKy5bAYl+sQO B6lFjuc2gx/lkvgJYY8G1B/yy7vbR3vF8OV/XJZ+Go4oJhfHlw1vlAdyW740QnrVxT1ihvVtGTBN1 HVjdYmif9oiZ73a4l7IhVh3S4+3zPVrqV3gaXxh8IEiFR5shEfOR0WP5eiPIIFeLleQzBCiEV8uwA RWq1zCveILN8cRmuFYR2dah8uODn0BqwBtli9zG8eJAD5UcfInREAVF5nbr13ViX8K3rOplvEQEKl ZmKTmuy1/W72a6T46a7A==; 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 1gD9Ya-0001PY-Um; Thu, 18 Oct 2018 14:45:48 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gD9RP-00046u-Qr for linux-mtd@lists.infradead.org; Thu, 18 Oct 2018 14:38:50 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 089A2180D9133; Thu, 18 Oct 2018 16:38:17 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH 14/42] mkfs.ubifs: Pass source/dest key len to key derive function Date: Thu, 18 Oct 2018 16:36:50 +0200 Message-Id: <20181018143718.26298-15-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_073824_209900_B4540B4D X-CRM114-Status: GOOD ( 13.08 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , david.oberhollenzer@sigma-star.at Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org fscrypto is using the max key lenth (64), so we cannot use the AES-128-ECB len. Signed-off-by: Richard Weinberger --- ubifs-utils/mkfs.ubifs/crypto.c | 4 ++-- ubifs-utils/mkfs.ubifs/crypto.h | 2 +- ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ubifs-utils/mkfs.ubifs/crypto.c b/ubifs-utils/mkfs.ubifs/crypto.c index a20bd56ba3db..f249b49b5b59 100644 --- a/ubifs-utils/mkfs.ubifs/crypto.c +++ b/ubifs-utils/mkfs.ubifs/crypto.c @@ -277,7 +277,7 @@ ssize_t encrypt_aes256_cbc_cts(const void *plaintext, size_t size, } ssize_t derive_key_aes(const void *deriving_key, const void *source_key, - void *derived_key) + size_t source_key_len, void *derived_key) { const EVP_CIPHER *cipher; size_t aes_key_len; @@ -289,7 +289,7 @@ ssize_t derive_key_aes(const void *deriving_key, const void *source_key, } aes_key_len = EVP_CIPHER_key_length(cipher); - return do_encrypt(cipher, source_key, aes_key_len, deriving_key, + return do_encrypt(cipher, source_key, source_key_len, deriving_key, aes_key_len, NULL, 0, derived_key); } diff --git a/ubifs-utils/mkfs.ubifs/crypto.h b/ubifs-utils/mkfs.ubifs/crypto.h index 4e597004ec51..5bff70fea29e 100644 --- a/ubifs-utils/mkfs.ubifs/crypto.h +++ b/ubifs-utils/mkfs.ubifs/crypto.h @@ -57,7 +57,7 @@ ssize_t encrypt_aes256_cbc_cts(const void *plaintext, size_t size, const void *key, void *ciphertext); ssize_t derive_key_aes(const void *deriving_key, const void *source_key, - void *derived_key); + size_t source_key_len, void *derived_key); struct cipher *get_cipher(const char *name); diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c index a43b2a1620b1..c315e36dd3d3 100644 --- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c +++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c @@ -526,7 +526,7 @@ static unsigned char *calc_fscrypt_subkey(struct fscrypt_context *fctx) int ret; unsigned char *new_key = xmalloc(FS_MAX_KEY_SIZE); - ret = derive_key_aes(fctx->nonce, fscrypt_masterkey, new_key); + ret = derive_key_aes(fctx->nonce, fscrypt_masterkey, FS_MAX_KEY_SIZE, new_key); if (ret < 0) { err_msg("derive_key_aes failed: %i\n", ret);