Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2366633ybi; Thu, 20 Jun 2019 13:54:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyW/kqbxmdfVrDw/qSJ7HMYQF9WJsC+IVB1fGacO556XyphUL3W7odbCA7M8hOelutQcSU/ X-Received: by 2002:a62:6:: with SMTP id 6mr67817384pfa.159.1561064055304; Thu, 20 Jun 2019 13:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561064055; cv=none; d=google.com; s=arc-20160816; b=mtg9dx/6nz8uBq2x2urK5ASHG52iym7+SIj3WtyqROTq2LSdYxnk9BoCh+t+sRrmqc NbtVu97GAEMbI1jEQa7ypT8/SGv94w/rcyp6KPqxykeDptTS5CyLdW30Iknz61O3/1cO TS+Y8PmoL4jbi6/qqT/faclSuikEBqKglIlXwyH4gQpl+4PFB5mOKHeuHbafVq5x6Ktz NezfZsWxIsjkKoSiL6p6frgLT+D8V614k2ylUSjlCVuuBLtCPNrHQhmPKIJ+QPUBhwbj uxJx7FyzIs2k0xr2BM+s1S3dNxxXdjjfq39BdP6dcgzn9RYqi/0VI7766odVCbtmZcl+ JTqA== 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=PjY4CJSYL+VdqtHkA3oJysEcCDTX86+zdI4Uaa2FaUU=; b=BxlWHOm5ce8VyrjgMdBSMPn2yQ5SkPQHx2BXddRfoCKsH5ZGL+YivIDfU6+YTRSMja LKjVr1o4m/BCDOPxWc1q1kiwWoTOM0R8exiGGUiLl91RK7iixzeWbYBw9ahcaSu5PTDq j0mvgKQz+mAdLGSLCrVsWQfXPJw/OxhBZkDl5FsOtTzixw4mamgbrOqE3xbu0O3FskCd ukoo/ahMlv8k8E6ARD2l7M7oqn9KLuhs5VidT9zZrrHuWz/0Vnse/0VhDkvROX+zLxKj yjEcHJJ/a/NQ6MNStsWqJcKfquPQhleeoXe26XCvPj2/z5zfYAw4VEYChmqCpBLVc4Sj f89A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gNFOfZOL; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 u10si513693pgh.83.2019.06.20.13.54.01; Thu, 20 Jun 2019 13:54:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-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=gNFOfZOL; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 S1726404AbfFTUxv (ORCPT + 99 others); Thu, 20 Jun 2019 16:53:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:56680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbfFTUxt (ORCPT ); Thu, 20 Jun 2019 16:53:49 -0400 Received: from ebiggers-linuxstation.mtv.corp.google.com (unknown [104.132.1.77]) (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 34D2C2173E; Thu, 20 Jun 2019 20:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561064028; bh=/rMdDoel18ld9zWX5CGZ6op2X7DEL5ozaTJWNfp3vo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gNFOfZOLRInrdIRb4WXvGyCooCcUvvFwPlfVOlfXvERmnmkcK7QeQK0AOK+9uz9Uu /vTd78TQdyEVMCqjwputPq+pCf4btIjfR9czX7ucK8R5EICXklEY4V6PDWQRL4GPkw +Dl16nTfksqfTMxResjY2nR29ZSns8PI2Ur7m3oY= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-integrity@vger.kernel.org, Jaegeuk Kim , "Theodore Y . Ts'o" , Victor Hsieh , Chandan Rajendra , Dave Chinner , Christoph Hellwig , "Darrick J . Wong" , Linus Torvalds Subject: [PATCH v5 12/16] fs-verity: add SHA-512 support Date: Thu, 20 Jun 2019 13:50:39 -0700 Message-Id: <20190620205043.64350-13-ebiggers@kernel.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190620205043.64350-1-ebiggers@kernel.org> References: <20190620205043.64350-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Eric Biggers Add SHA-512 support to fs-verity. This is primarily a demonstration of the trivial changes needed to support a new hash algorithm in fs-verity; most users will still use SHA-256, due to the smaller space required to store the hashes. But some users may prefer SHA-512. Reviewed-by: Theodore Ts'o 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 eaa2b3b93bbf6b..02a547f0667c13 100644 --- a/fs/verity/fsverity_private.h +++ b/fs/verity/fsverity_private.h @@ -29,7 +29,7 @@ struct ahash_request; * Largest digest size among all hash algorithms supported by fs-verity. * Currently assumed to be <= size of fsverity_descriptor::root_hash. */ -#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 46df17094fc252..e0462a010cabfb 100644 --- a/fs/verity/hash_algs.c +++ b/fs/verity/hash_algs.c @@ -17,6 +17,11 @@ struct fsverity_hash_alg fsverity_hash_algs[] = { .digest_size = SHA256_DIGEST_SIZE, .block_size = SHA256_BLOCK_SIZE, }, + [FS_VERITY_HASH_ALG_SHA512] = { + .name = "sha512", + .digest_size = SHA512_DIGEST_SIZE, + .block_size = SHA512_BLOCK_SIZE, + }, }; /** diff --git a/include/uapi/linux/fsverity.h b/include/uapi/linux/fsverity.h index 57d1d7fc0c345a..da0daf6c193b4b 100644 --- a/include/uapi/linux/fsverity.h +++ b/include/uapi/linux/fsverity.h @@ -14,6 +14,7 @@ #include #define FS_VERITY_HASH_ALG_SHA256 1 +#define FS_VERITY_HASH_ALG_SHA512 2 struct fsverity_enable_arg { __u32 version; -- 2.22.0.410.gd8fdbe21b5-goog