From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1qKPjL-0003LE-7t for mharc-grub-devel@gnu.org; Fri, 14 Jul 2023 16:49:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qKPjJ-0003Kr-4f for grub-devel@gnu.org; Fri, 14 Jul 2023 16:49:33 -0400 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qKPjH-0004eM-An for grub-devel@gnu.org; Fri, 14 Jul 2023 16:49:32 -0400 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-4036d80caaeso15351951cf.2 for ; Fri, 14 Jul 2023 13:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20221208.gappssmtp.com; s=20221208; t=1689367770; x=1691959770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HiA81r53WipoJEPfz9QB9E3GU975IVgSouQK6peFux8=; b=W8PXSQstMaOQR2hjod5U8xJUdndQPKQj5wMvd6+SA/P25NKT7vN/J5yON2VL7S1b5s AGmSk1HknQMq7XoVtSrSLcNhLKNUH+BcKEQf0COBS82EWHVzc5Ce3PDRNE/+Tn5RQgd7 zPGUC/jB3WbndnbO3vi71LbrkQlHJH1vYObiPPiDB6SHeM+ykLVcw26ze/fXeDet/lDB /GwciNtFAyRPomnvsuLbyLouiBe3NsNsK99bgJA342DftpYN7m7z5sQHUlCbLnHtGZO6 qkfFTqhzvP4pK9TH6kbKzcB0Nk2uOAcd0Uk0NR6VqBvL4jKf63IfaaowOjOM5Ddp+rur UpOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689367770; x=1691959770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HiA81r53WipoJEPfz9QB9E3GU975IVgSouQK6peFux8=; b=aMDLXTKd2oUgUijKR/2/x6yktyKcPpn1pOEUH/KhQQBiLO8UShKcji8hMdbNEXSJzf hpE9aiAy+Ry5uauso1LDAWQ2THVueZs5OYBu1UWow5n7ZQoWTtE8Mk5nxDnU8XCAHvkP ghAGz1nbllpP4mKmRvIf3hcQBdt76UEKsxEMvSDte0nyuTdyKpn66MOMIYI8IpGAAPU4 N947L8Pfhkt8IgCTnVINNnmqaip1eONgqLZ3wI/zCXWjFFk9nFLxGB6xkmq6kd4SRxw/ 5Ufcx+IVCuWH0IJ7suxQMJINXUc/MgdLgXy7zp3KbXNXGoT3iaYoSgHy+Y+OtF1ELQ6P 2JUw== X-Gm-Message-State: ABy/qLa+LKmq8bedGnRQunDhWWuEN4jXrFKx0d5WiwGnUA65Du2kuHCt D5R+rbXYlCBlQQCXV3IzrqfUJMa0M4bhA1bZTQA+EA== X-Google-Smtp-Source: APBJJlFYdIHSe6DpgNuuX1dTqavCWrhlZloJs0EEFnW9nFibslPafOrU+5Wifyfars8DbUyq1R+jYQ== X-Received: by 2002:ac8:5914:0:b0:403:ae76:d0a3 with SMTP id 20-20020ac85914000000b00403ae76d0a3mr6581196qty.8.1689367769762; Fri, 14 Jul 2023 13:49:29 -0700 (PDT) Received: from localhost.localdomain ([199.58.83.12]) by smtp.gmail.com with ESMTPSA id g2-20020ac87d02000000b0040328b5fbe2sm1426120qtb.58.2023.07.14.13.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 13:49:29 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Patrick Steinhardt , Glenn Washburn Subject: [PATCH v3 0/2] Add LUKS2 support to luks_script Date: Fri, 14 Jul 2023 15:49:16 -0500 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::832; envelope-from=development@efficientek.com; helo=mail-qt1-x832.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jul 2023 20:49:33 -0000 v3: * Fix inconsistencies noted in v2 * Add a separate patch for optimization and changes in v2 * Use 6 digits for sector size, instead of previous 5, for really really future proofing v2: * Use PRIxGRUB_OFFSET instead of PRIuGRUB_UINT64_T * use %u for unsigned log sector size Glenn Glenn Washburn (2): cryptodisk: Optimize luks_script_get cryptodisk: Add support for LUKS2 in (proc)/luks_script grub-core/disk/cryptodisk.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) Range-diff against v2: -: ------------ > 1: 7a32d780a2f7 cryptodisk: Optimize luks_script_get 1: dbf695eef1ab ! 2: fe0164ae1db0 luks2: Add support for LUKS2 in (proc)/luks_script @@ Metadata Author: Glenn Washburn ## Commit message ## - luks2: Add support for LUKS2 in (proc)/luks_script + cryptodisk: Add support for LUKS2 in (proc)/luks_script - The sector size in bytes is added to each line and it is allowed to be 5 + The sector size in bytes is added to each line and it is allowed to be 6 decimal digits long, which covers the most common cases of 512 and 4096 - byte sectors with space for an additional digit as future-proofing. The - size allocation is updated to reflect this additional field, allow up to - 5 characters and 1 space added. + byte sectors with space for two additional digits as future-proofing. The + size allocation is updated to reflect this additional field. Also make + clearer the size allocation calculation. ## grub-core/disk/cryptodisk.c ## @@ grub-core/disk/cryptodisk.c: luks_script_get (grub_size_t *sz) @@ grub-core/disk/cryptodisk.c: luks_script_get (grub_size_t *sz) + /* + * Add space in the line for (in order) spaces, cipher mode, cipher IV + * mode, sector offset, sector size and the trailing newline. This is -+ * an upper bound on the size of this data. There are 16 extra bytes ++ * an upper bound on the size of this data. There are 15 extra bytes + * in an earlier version of this code that are unaccounted for. It is + * left in the calculations in case it is needed. At worst, its short- + * lived wasted space. + */ -+ size += 5 + 5 + 8 + 20 + 5 + 1 + 16; ++ size += 5 + 5 + 8 + 20 + 6 + 1 + 15; if (i->essiv_hash) size += grub_strlen (i->essiv_hash->name); size += i->keysize * 2; @@ grub-core/disk/cryptodisk.c: luks_script_get (grub_size_t *sz) + ptr = grub_stpcpy (ptr, "_mount "); ptr = grub_stpcpy (ptr, i->uuid); *ptr++ = ' '; -- grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset_sectors); -- while (*ptr) -- ptr++; -+ ptr += grub_snprintf (ptr, 21, "%" PRIxGRUB_OFFSET " ", -+ i->offset_sectors); -+ ptr += grub_snprintf (ptr, 7, "%u ", 1 << i->log_sector_size); + ptr += grub_snprintf (ptr, 21, "%" PRIxGRUB_OFFSET, i->offset_sectors); + *ptr++ = ' '; ++ ptr += grub_snprintf (ptr, 7, "%u", 1 << i->log_sector_size); ++ *ptr++ = ' '; for (iptr = i->cipher->cipher->name; *iptr; iptr++) *ptr++ = grub_tolower (*iptr); switch (i->mode) -- 2.34.1