From patchwork Sat Jan 4 15:19:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Trudgian X-Patchwork-Id: 19579 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9AB53179DE; Sat, 4 Jan 2020 16:23:11 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 32BBC17984 for ; Sat, 4 Jan 2020 16:23:11 +0000 (GMT) Received: from localhost ([::1]:35034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1inmCk-000185-Jf for patchwork@mira.cbaines.net; Sat, 04 Jan 2020 11:23:10 -0500 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 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 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-Disposition: inline X-ZohoMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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=2. --- 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 © 2017 Mathieu Othacehe ;;; Copyright © 2019 Guillaume Le Vaillant ;;; Copyright © 2019 Tobias Geerinckx-Rice +;;; Copyright © 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 follow ;; version 1.2.1 of this document. +;; The LUKS2 header format is described in "LUKS2 On-Disk Format Specification": +;; . +;; 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=? magic %luks-magic) - (= version 1)))) + (or (= version 1) (= version 2))))) (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 metadata + ;; area that follows. (read-superblock file 0 592 luks-superblock?)) (define (luks-header-uuid header)