From unknown Sat Jun 14 14:27:43 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#38920] [PATCH] file-systems: Handle v2 LUKS header Resent-From: David Trudgian Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 04 Jan 2020 16:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 38920 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 38920@debbugs.gnu.org Cc: dave@trudgian.net X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.157815495024391 (code B ref -1); Sat, 04 Jan 2020 16:23:02 +0000 Received: (at submit) by debbugs.gnu.org; 4 Jan 2020 16:22:30 +0000 Received: from localhost ([127.0.0.1]:43288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inmC5-0006LK-Fa for submit@debbugs.gnu.org; Sat, 04 Jan 2020 11:22:30 -0500 Received: from lists.gnu.org ([209.51.188.17]:50549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inlD9-0004WA-8B for submit@debbugs.gnu.org; Sat, 04 Jan 2020 10:19:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33004) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inlD7-0000cd-W4 for guix-patches@gnu.org; Sat, 04 Jan 2020 10:19:31 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1inlD5-0002La-LM for guix-patches@gnu.org; Sat, 04 Jan 2020 10:19:29 -0500 Received: from sender4-op-o19.zoho.com ([136.143.188.19]:17916) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1inlD5-00026B-BK for guix-patches@gnu.org; Sat, 04 Jan 2020 10:19:27 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1578151162; cv=none; d=zohomail.com; s=zohoarc; b=dwRdgxziaZBwzU5+xTWOludCwkh1NwtO2iBuPKFzwcvlpUSf5rE2SJQ/FgHHm52CQycgq8L9QFIR7lfSy+bRQopqWlFdbMSDCFqhljE+grGhViz7y8kqAxUEuMOEVi08MXIPG3owfq/qTyAqEvgn9mE1CCBMKqGxv1SP1m8RveM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578151162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=W2QTMdrKJsLhZ2tfWS3uK0MyhQemzaf1hKPsYZ0xE4I=; b=OJe/VW1Wj4WRUjhinek2EhfFoOFOwIysu3eKg1f77448f69T2e589ewBPoKZry3MCiQ9XUzr+RrSRBqIxaUHc27fEdZOwfUqRdwv/G31lbac0XJ5jlPlIlo4fjYIN+JOezO14dMCVoVOu+K3TVX2H+tI1ZLjQjYy6++86fqxA70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=trudgian.net; spf=pass smtp.mailfrom=dave@trudgian.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1578151162; s=main; d=trudgian.net; i=dave@trudgian.net; h=Date:From:To:Cc:Message-ID:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=W2QTMdrKJsLhZ2tfWS3uK0MyhQemzaf1hKPsYZ0xE4I=; b=oivWk0cu933FvoNWBy205e8vJ5jRjiuSYcvgv0UOsmSi/EdOe2PUE1w5pP8W9vHO zFEadZmkkn9SUDT11xT8FNkFN2lZIfc2aHQ0CGhgOmxFB7F+DDEYMMh4N22nM/BUjAg QzDb4iaNg0Jgx9A9JanTBHw9g4sSIeGE+CIYWgxo= Received: from lappy.randomroad.net (cpe-70-119-131-248.tx.res.rr.com [70.119.131.248]) by mx.zohomail.com with SMTPS id 1578151158496808.3454234098187; Sat, 4 Jan 2020 07:19:18 -0800 (PST) Date: Sat, 4 Jan 2020 09:19:17 -0600 From: David Trudgian Message-ID: <20200104151917.GA8616@lappy.randomroad.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 136.143.188.19 X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Sat, 04 Jan 2020 11:22:28 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Let luks-superblock? read a LUKS2 header. The binary header prior to the JSON LUKS2 data is backward compatible with LUKS1, so the UUID can be read from the same location, and we just need to accept version=3D2. --- gnu/build/file-systems.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 9299cc2e4c..df06905c4e 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -4,6 +4,7 @@ ;;; Copyright =A9 2017 Mathieu Othacehe ;;; Copyright =A9 2019 Guillaume Le Vaillant ;;; Copyright =A9 2019 Tobias Geerinckx-Rice +;;; Copyright =A9 2019 David C. Trudgian ;;; ;;; This file is part of GNU Guix. ;;; @@ -343,6 +344,10 @@ if DEVICE does not contain a JFS file system." ;; . We fol= low ;; version 1.2.1 of this document. =20 +;; The LUKS2 header format is described in "LUKS2 On-Disk Format Specifica= tion": +;; . +;; This is a WIP document. + (define-syntax %luks-endianness ;; Endianness of LUKS headers. (identifier-syntax (endianness big))) @@ -356,12 +361,16 @@ if DEVICE does not contain a JFS file system." (let ((magic (sub-bytevector sblock 0 6)) (version (bytevector-u16-ref sblock 6 %luks-endianness))) (and (bytevector=3D? magic %luks-magic) - (=3D version 1)))) + (or (=3D version 1) (=3D version 2))))) =20 (define (read-luks-header file) "Read a LUKS header from FILE. Return the raw header on success, and #f= if not valid header was found." - ;; Size in bytes of the LUKS header, including key slots. + ;; Size in bytes of the LUKS binary header, which includes key slots in + ;; LUKS1. In LUKS2 the binary header is partially backward compatible, = so + ;; that UUID can be extracted as for LUKS1. Keyslots and other metadata = are + ;; not part of this header in LUKS2, but are included in the JSON metada= ta + ;; area that follows. (read-superblock file 0 592 luks-superblock?)) =20 (define (luks-header-uuid header) --=20 2.24.1 From unknown Sat Jun 14 14:27:43 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: David Trudgian Subject: bug#38920: closed (Re: [bug#38920] [PATCH] file-systems: Handle v2 LUKS header) Message-ID: References: <20200105111536.22dfc557@scratchpost.org> <20200104151917.GA8616@lappy.randomroad.net> X-Gnu-PR-Message: they-closed 38920 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 38920@debbugs.gnu.org Date: Sun, 05 Jan 2020 10:16:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1578219362-24984-1" This is a multi-part message in MIME format... ------------=_1578219362-24984-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #38920: [PATCH] file-systems: Handle v2 LUKS header which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 38920@debbugs.gnu.org. --=20 38920: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D38920 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1578219362-24984-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 38920-done) by debbugs.gnu.org; 5 Jan 2020 10:15:41 +0000 Received: from localhost ([127.0.0.1]:43664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1io2wf-0006UO-4k for submit@debbugs.gnu.org; Sun, 05 Jan 2020 05:15:41 -0500 Received: from dd26836.kasserver.com ([85.13.145.193]:45320) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1io2wd-0006UG-68 for 38920-done@debbugs.gnu.org; Sun, 05 Jan 2020 05:15:39 -0500 Received: from localhost (unknown [185.17.13.127]) by dd26836.kasserver.com (Postfix) with ESMTPSA id B7DCF33655E1; Sun, 5 Jan 2020 11:15:37 +0100 (CET) Date: Sun, 5 Jan 2020 11:15:36 +0100 From: Danny Milosavljevic To: David Trudgian Subject: Re: [bug#38920] [PATCH] file-systems: Handle v2 LUKS header Message-ID: <20200105111536.22dfc557@scratchpost.org> In-Reply-To: <20200104151917.GA8616@lappy.randomroad.net> References: <20200104151917.GA8616@lappy.randomroad.net> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/IFuAvUuhI7++tv2StPWJg=e"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 38920-done Cc: 38920-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --Sig_/IFuAvUuhI7++tv2StPWJg=e Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi David, thanks for the patch! Pushed as commit 7aa28eb339dd667d07cfb8b5347e159d5da3ccd7 to guix master. --Sig_/IFuAvUuhI7++tv2StPWJg=e Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl4Rt0gACgkQ5xo1VCww uqWztwf/egPHOFSPO8XPeQ+mTajy5aCM3/i3GLDb9UsqTp/wvw3DR8byi28sSvko hgAXb6mm5gJBVD+6wu0Ub6QCyww68lvfXXOLv99TNsIEAXtIJ7OCSac7cNzKQF2i viuYgbaYlpWYukW7D+rXWeoeEbCYPn8bBLBM5xIMv0sf1PXNYutrSbiVf/cCJm1D mNV4YMCLctwumML20C/WN3NM/vx+YD0WzdaZrpaU+Dcb9Xrq7CETAkXy9yaF81Up EVWsi24R/vdhzdb4EzR6Fx9YoFxyudzljg47Wo1g7DUBqqt6OtwV8SvwPpxXJUkx ssjOcLu+Ow7eB5hwvwxV+UrF0QGsUg== =3Zhn -----END PGP SIGNATURE----- --Sig_/IFuAvUuhI7++tv2StPWJg=e-- ------------=_1578219362-24984-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 4 Jan 2020 16:22:30 +0000 Received: from localhost ([127.0.0.1]:43288 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inmC5-0006LK-Fa for submit@debbugs.gnu.org; Sat, 04 Jan 2020 11:22:30 -0500 Received: from lists.gnu.org ([209.51.188.17]:50549) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1inlD9-0004WA-8B for submit@debbugs.gnu.org; Sat, 04 Jan 2020 10:19:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33004) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inlD7-0000cd-W4 for guix-patches@gnu.org; Sat, 04 Jan 2020 10:19:31 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1inlD5-0002La-LM for guix-patches@gnu.org; Sat, 04 Jan 2020 10:19:29 -0500 Received: from sender4-op-o19.zoho.com ([136.143.188.19]:17916) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1inlD5-00026B-BK for guix-patches@gnu.org; Sat, 04 Jan 2020 10:19:27 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1578151162; cv=none; d=zohomail.com; s=zohoarc; b=dwRdgxziaZBwzU5+xTWOludCwkh1NwtO2iBuPKFzwcvlpUSf5rE2SJQ/FgHHm52CQycgq8L9QFIR7lfSy+bRQopqWlFdbMSDCFqhljE+grGhViz7y8kqAxUEuMOEVi08MXIPG3owfq/qTyAqEvgn9mE1CCBMKqGxv1SP1m8RveM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578151162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=W2QTMdrKJsLhZ2tfWS3uK0MyhQemzaf1hKPsYZ0xE4I=; b=OJe/VW1Wj4WRUjhinek2EhfFoOFOwIysu3eKg1f77448f69T2e589ewBPoKZry3MCiQ9XUzr+RrSRBqIxaUHc27fEdZOwfUqRdwv/G31lbac0XJ5jlPlIlo4fjYIN+JOezO14dMCVoVOu+K3TVX2H+tI1ZLjQjYy6++86fqxA70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=trudgian.net; spf=pass smtp.mailfrom=dave@trudgian.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1578151162; s=main; d=trudgian.net; i=dave@trudgian.net; h=Date:From:To:Cc:Message-ID:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=W2QTMdrKJsLhZ2tfWS3uK0MyhQemzaf1hKPsYZ0xE4I=; b=oivWk0cu933FvoNWBy205e8vJ5jRjiuSYcvgv0UOsmSi/EdOe2PUE1w5pP8W9vHO zFEadZmkkn9SUDT11xT8FNkFN2lZIfc2aHQ0CGhgOmxFB7F+DDEYMMh4N22nM/BUjAg QzDb4iaNg0Jgx9A9JanTBHw9g4sSIeGE+CIYWgxo= Received: from lappy.randomroad.net (cpe-70-119-131-248.tx.res.rr.com [70.119.131.248]) by mx.zohomail.com with SMTPS id 1578151158496808.3454234098187; Sat, 4 Jan 2020 07:19:18 -0800 (PST) Date: Sat, 4 Jan 2020 09:19:17 -0600 From: David Trudgian To: guix-patches@gnu.org Message-ID: <20200104151917.GA8616@lappy.randomroad.net> Subject: [PATCH] file-systems: Handle v2 LUKS header MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 136.143.188.19 X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sat, 04 Jan 2020 11:22:28 -0500 Cc: dave@trudgian.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Let luks-superblock? read a LUKS2 header. The binary header prior to the JSON LUKS2 data is backward compatible with LUKS1, so the UUID can be read from the same location, and we just need to accept version=3D2. --- gnu/build/file-systems.scm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 9299cc2e4c..df06905c4e 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -4,6 +4,7 @@ ;;; Copyright =A9 2017 Mathieu Othacehe ;;; Copyright =A9 2019 Guillaume Le Vaillant ;;; Copyright =A9 2019 Tobias Geerinckx-Rice +;;; Copyright =A9 2019 David C. Trudgian ;;; ;;; This file is part of GNU Guix. ;;; @@ -343,6 +344,10 @@ if DEVICE does not contain a JFS file system." ;; . We fol= low ;; version 1.2.1 of this document. =20 +;; The LUKS2 header format is described in "LUKS2 On-Disk Format Specifica= tion": +;; . +;; This is a WIP document. + (define-syntax %luks-endianness ;; Endianness of LUKS headers. (identifier-syntax (endianness big))) @@ -356,12 +361,16 @@ if DEVICE does not contain a JFS file system." (let ((magic (sub-bytevector sblock 0 6)) (version (bytevector-u16-ref sblock 6 %luks-endianness))) (and (bytevector=3D? magic %luks-magic) - (=3D version 1)))) + (or (=3D version 1) (=3D version 2))))) =20 (define (read-luks-header file) "Read a LUKS header from FILE. Return the raw header on success, and #f= if not valid header was found." - ;; Size in bytes of the LUKS header, including key slots. + ;; Size in bytes of the LUKS binary header, which includes key slots in + ;; LUKS1. In LUKS2 the binary header is partially backward compatible, = so + ;; that UUID can be extracted as for LUKS1. Keyslots and other metadata = are + ;; not part of this header in LUKS2, but are included in the JSON metada= ta + ;; area that follows. (read-superblock file 0 592 luks-superblock?)) =20 (define (luks-header-uuid header) --=20 2.24.1 ------------=_1578219362-24984-1--