Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1439603imd; Thu, 1 Nov 2018 15:56:00 -0700 (PDT) X-Google-Smtp-Source: AJdET5eyYWzGXPjt6wG/Mh9TZy9o3LgTINH5f4k2KSjRE1rKQrGJY9mK95lWcmVr/E/2vQr1XFgl X-Received: by 2002:a63:af18:: with SMTP id w24mr8871048pge.385.1541112960699; Thu, 01 Nov 2018 15:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541112960; cv=none; d=google.com; s=arc-20160816; b=shSKPPtjbRyhmN35o/4cIGsQABmulUaSF/HcZC8OMxUHcexKecOi2XphbwiQsmdwj0 odtBpCiR1bs13VdBoNgR95BA3UTSWZVTHOs02L6KtBYOAVFpa6oKIbovpccAl5Gg32Pj B5cM8hxpJjU0At7lrPwChoBvwR27KThZD44Cy11g7PXyY8mZ54nBWfLYPvYWLOmr2tpr hH8PoaL5aKVLYNxaOkCDCeC8ZDNhgnZa5KHIX203IUCKFZFXvFOpKthgirJ/LDjEi0AZ ReKa/pBqz/Os2aB77PxrKfAmxYHOgC0OLHEvBidDrozWzEahFTo/jP+0qm8uowf4OR5Z 0WKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jWQn5R6VZhKjX0nO96kmZyaLHD8vIgFIUijHf+6QCsg=; b=0Tswft2Oi/lkyfmOPcJrvLif1kJNeO6VHtA1X4iFDH5kO505F9e3fL9qCC/e/+rL/6 KisfS/0UUBFgX/fZeKaXUvIVLxtc6j0bLpxaF40kWB9gjpiQ7LemkagpdrjPcdBxYx3E FopGDpJdYjjLb2euKRJSktRBpF4BOKVpr+hdsFqWhHXX7S2FY/ejfdKnVYhzlj/kvYVH y6fEizoObp0/Yr7GhGOswEu/8U2SJo9lDlFVSVUfTy2ioLKtdNQ83luo4VzzCplNYjKC 1A9FXMUjV80MLFuyO0e7whHHOWXUkyA0waR7n+UQXLeUWVO2qAdXx3g1W48khR7CkFYM bHRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q+BRq6OC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1-v6si31461593pls.17.2018.11.01.15.55.46; Thu, 01 Nov 2018 15:56:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q+BRq6OC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728141AbeKBH7R (ORCPT + 99 others); Fri, 2 Nov 2018 03:59:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbeKBH7Q (ORCPT ); Fri, 2 Nov 2018 03:59:16 -0400 Received: from ebiggers-linuxstation.kir.corp.google.com (unknown [104.132.51.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E98F20866; Thu, 1 Nov 2018 22:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541112857; bh=GU3tCBUJ8zIG8Ivryy6fFaMUuIw2pxPwqQtzuo7iW/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+BRq6OCbxF+9/cLhbFrN9807OQMQGG0XKP3YOqwngFsWbePmDcwMzbYNTqkXuhIl GeDN+KeB/AVZv5hkZ+6HTG+rWbEzXE5oLCUWOLN/8nIThRruGayC29einhihCvchzZ ynM8mya8E8+xSdI6kDAgniGI8k3jiW3mybxTwwGg= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, "Theodore Y . Ts'o" , Jaegeuk Kim , Victor Hsieh , Chandan Rajendra Subject: [PATCH v2 07/12] fs-verity: add SHA-512 support Date: Thu, 1 Nov 2018 15:52:25 -0700 Message-Id: <20181101225230.88058-8-ebiggers@kernel.org> X-Mailer: git-send-email 2.19.1.568.g152ad8e336-goog In-Reply-To: <20181101225230.88058-1-ebiggers@kernel.org> References: <20181101225230.88058-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers Add SHA-512 support to fs-verity. This is primarily a demonstration of the (small) changes needed to support a new hash algorithm; it's anticipated that most users will still prefer SHA-256 due to the smaller space required to store the hashes, though some may prefer SHA-512. Signed-off-by: Eric Biggers --- fs/verity/fsverity_private.h | 2 +- fs/verity/hash_algs.c | 5 +++++ include/uapi/linux/fsverity.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h index dfdbac3874d74..c3a261a598557 100644 --- a/fs/verity/fsverity_private.h +++ b/fs/verity/fsverity_private.h @@ -30,7 +30,7 @@ * Largest digest size among all hash algorithms supported by fs-verity. This * can be increased if needed. */ -#define FS_VERITY_MAX_DIGEST_SIZE SHA256_DIGEST_SIZE +#define FS_VERITY_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE /* A hash algorithm supported by fs-verity */ struct fsverity_hash_alg { diff --git a/fs/verity/hash_algs.c b/fs/verity/hash_algs.c index 9c19c9553f120..3174a0c08785d 100644 --- a/fs/verity/hash_algs.c +++ b/fs/verity/hash_algs.c @@ -18,6 +18,11 @@ struct fsverity_hash_alg fsverity_hash_algs[] = { .digest_size = 32, .cryptographic = true, }, + [FS_VERITY_ALG_SHA512] = { + .name = "sha512", + .digest_size = 64, + .cryptographic = true, + }, }; /* diff --git a/include/uapi/linux/fsverity.h b/include/uapi/linux/fsverity.h index 55b9f32676220..67ed830ae2ece 100644 --- a/include/uapi/linux/fsverity.h +++ b/include/uapi/linux/fsverity.h @@ -28,6 +28,7 @@ struct fsverity_digest { /* Supported hash algorithms */ #define FS_VERITY_ALG_SHA256 1 +#define FS_VERITY_ALG_SHA512 2 /* Metadata stored near the end of verity files, after the Merkle tree */ /* This structure is 64 bytes long */ -- 2.19.1.568.g152ad8e336-goog