Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1440641imd; Thu, 1 Nov 2018 15:57:20 -0700 (PDT) X-Google-Smtp-Source: AJdET5f+LUwyB4245qdV+WwkK8ZucZLl2qvRdBk6tq82zfe++3GdCDxCfxqiONrn/qpN72ENMOEo X-Received: by 2002:a63:a401:: with SMTP id c1mr8795674pgf.403.1541113040619; Thu, 01 Nov 2018 15:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541113040; cv=none; d=google.com; s=arc-20160816; b=JLU2Ikc/OhVjzEPh5CrRI2d5sVn168pu3YcST8w1TZ7BViJfZpgF7RpsfYmDCjKHn8 PSxbXRXLDqFD3fjotznYB1vCVTbvpl/YlB784dLElC3HIJ9282qIx1+ct948NPB7TNYN 7qGeLgTprbs4gaNZ5SPiWZ7NW3cPcQTFrfd2aRpT7KHkZcryYZbQCFX1w4gAcKFrHWZo 0PaZvbpXe1HayEwF/ROakc5nutRxwagnNY1TIb/k2g+o9D7c561D5DpW0SlSQZzX9HbD S+LDGiB3L6eRbmO3QYeD6/NfaQKhtwA/sOlwcScG+jENonr5o2Zz1+bU0Wi4ksHrfWtg pJqw== 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=3HW3FbOueykcy0+N/uBOl20qyGyyMlvt2TtlgTR4Knc=; b=d8F5ahCRZiaQOymBU9PZ2oaQIbMZ/Ac6Z5oa/0SPAS5+OSQuZTwFPRSnm96KkeTkpL jpo87EoBrORgSehDx5v+a9dQiSCBdRDWT+IcPXtMZJskdfYt4DYk+ZTYcYOLua5J+pE8 +8Xk48T5YE/qapwFTUkCVwHsNcjZMZ50YCWm54sJT2QPQqr4rhkUw+hIiVHjADoy31MU pXaDcTYQVVoopKAy1oXzqCz+SAFVElnBC4wZDvBQty9btOTn9sYePKlCoXyn8pR1icOb +3DkO8Q/OC1Sp3/7A+jrOcGE8SrtXYKQKDT7hqmXBCIQyrLelAlttqNpcVWwGvSOVWcY M9kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N6iKpHLI; 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 o19-v6si10508272pgb.196.2018.11.01.15.57.06; Thu, 01 Nov 2018 15:57:20 -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=N6iKpHLI; 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 S1728306AbeKBIAC (ORCPT + 99 others); Fri, 2 Nov 2018 04:00:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:52164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728083AbeKBH7Q (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 76AD02086D; 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=6aWfDT8BFa0Xa9diw5+HNmJhJldqF+mtmBKHTyX1P4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N6iKpHLIFP/bsmTWDW9CXDlwyhBA33HpZ0VjIMCloQzhOzbz3hG1MOdiS+DbqxI1E /Jxo0o7CX2QZfIWbY7Zo5vPEROBH3BAujEzaFs8fzlNH+9UkK33AaER6yOZOYP9D4g XCutFPCjcy1XmnMdjb2PQt59Iz0oq9LmCrgzksxw= 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 08/12] fs-verity: add CRC-32C support Date: Thu, 1 Nov 2018 15:52:26 -0700 Message-Id: <20181101225230.88058-9-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 CRC-32C support to fs-verity, to provide a faster alternative to SHA-256 for users who want integrity-only (not authenticity), i.e. who want to detect only accidental corruption, not malicious changes. CRC-32C is chosen over CRC-32 because the CRC-32C polynomial is believed to provide slightly better error-detection properties; and CRC-32C is just as fast (or can be just as fast) as CRC-32, or even faster e.g. on some x86 processors that have a CRC-32C instruction but not CRC-32. We use "crc32c" from the crypto API, so the polynomial convention is bitwise little-endian, the digest is bytewise little-endian, and the CRC bits are inverted at the beginning and end (which is desirable). Signed-off-by: Eric Biggers --- fs/verity/hash_algs.c | 4 ++++ include/uapi/linux/fsverity.h | 1 + 2 files changed, 5 insertions(+) diff --git a/fs/verity/hash_algs.c b/fs/verity/hash_algs.c index 3174a0c08785d..109afeec60fc9 100644 --- a/fs/verity/hash_algs.c +++ b/fs/verity/hash_algs.c @@ -23,6 +23,10 @@ struct fsverity_hash_alg fsverity_hash_algs[] = { .digest_size = 64, .cryptographic = true, }, + [FS_VERITY_ALG_CRC32C] = { + .name = "crc32c", + .digest_size = 4, + }, }; /* diff --git a/include/uapi/linux/fsverity.h b/include/uapi/linux/fsverity.h index 67ed830ae2ece..a96bbf87077de 100644 --- a/include/uapi/linux/fsverity.h +++ b/include/uapi/linux/fsverity.h @@ -29,6 +29,7 @@ struct fsverity_digest { /* Supported hash algorithms */ #define FS_VERITY_ALG_SHA256 1 #define FS_VERITY_ALG_SHA512 2 +#define FS_VERITY_ALG_CRC32C 3 /* for integrity only */ /* Metadata stored near the end of verity files, after the Merkle tree */ /* This structure is 64 bytes long */ -- 2.19.1.568.g152ad8e336-goog