From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:46365) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inmCe-00017i-DU for guix-patches@gnu.org; Sat, 04 Jan 2020 11:23:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1inmCc-0007z8-TU for guix-patches@gnu.org; Sat, 04 Jan 2020 11:23:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:37315) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1inmCc-0007xD-M4 for guix-patches@gnu.org; Sat, 04 Jan 2020 11:23:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1inmCc-0006MK-H7 for guix-patches@gnu.org; Sat, 04 Jan 2020 11:23:02 -0500 Subject: [bug#38920] [PATCH] file-systems: Handle v2 LUKS header Resent-Message-ID: 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 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 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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 38920@debbugs.gnu.org Cc: dave@trudgian.net 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