Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lO4LS-0002oD-Us for mharc-grub-devel@gnu.org; Sun, 21 Mar 2021 16:06:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lO4LQ-0002nn-OL for grub-devel@gnu.org; Sun, 21 Mar 2021 16:06:40 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:39885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lO4LL-0002SM-JG for grub-devel@gnu.org; Sun, 21 Mar 2021 16:06:40 -0400 Received: by mail-qv1-xf30.google.com with SMTP id q9so7702283qvm.6 for ; Sun, 21 Mar 2021 13:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9McEo93YrK7ltbNhcMN8bdAvdWERn9/PI3OZddYNFmw=; b=bRtgVSom0rapbSVDGdXtyYPsb1O7pjRjTJvRTWA0eAoekDnQq0bX56muWknGrcsLNM dTCnRnz8KUN8AbOsV9mJAxSKqXYZoKi1sEt18xtlSuFv7vYjSJ6fw1ZAv5hMSKaFwZyV bfcc3VWYEF661TOLQme1yTcab2kAIQDRCd1fjFW5sjn8x4DSDvCrWAYaxX9GN8M0I+43 KKdB18TtYyU/bH2BF/uOQZSXrWD10J4vh2JdsD6sC13mO8JOLjUPeQvaHnl+fF9Hn7WU vbZx5HGP+Uj2Nh6sb+ReIFtXktTgXg3c6s0fk4WhGSmyOLWBODHi4WQ32WZd7xjvhudr c/zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9McEo93YrK7ltbNhcMN8bdAvdWERn9/PI3OZddYNFmw=; b=BKne3XBWr5+rTm8zFKPIWaa2BjLCXUevZVSNrJCkPVb1yRHiXcpJg31c/xlCUeODaU EPW+mTEXborVF0qqtJEda0LMfwaGpC+gmtsysMLTJz/yA/otB/PQBjN1IvYe4tbfEVbt Oty+yjEYKfZMFn813l2cK+qqGb/dJWohjvxZUc1cLZ8jlq8Q7RIn+6NFxjj/ZXY1A0ke t3A9p5jcPpagKOc9vRwRhU0UTQUuZkoJwCEzwJ2/plswoyx8sHQk2YTlokjoZApUVTnH 79D5JP15VYpzO6GBsLrzum/WsklXLoi465gAR2LA1FJEqiQYuMxZAjXA78kkiR0msoMl B7ZQ== X-Gm-Message-State: AOAM533Q8eAc18RbY87GPpecHs6RqkNv34XYIIfrDzn3Ok+hPYQp6bw8 geVTBAFKolcR8XlQx1NBbgA9Wnkg+9syRg== X-Google-Smtp-Source: ABdhPJxZaJ8LJXwf09HfUQTsz8fRU9qDh4K199hiC7p6+/4zNf4S2RVsEuCjmFzt4BTQ06DnJ2pyBA== X-Received: by 2002:a0c:8121:: with SMTP id 30mr18151685qvc.27.1616357193578; Sun, 21 Mar 2021 13:06:33 -0700 (PDT) Received: from localhost.localdomain ([2605:a601:ab16:db00:23af:6780:efd4:8e25]) by smtp.gmail.com with ESMTPSA id q15sm7643284qtx.47.2021.03.21.13.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Mar 2021 13:06:32 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org, Daniel Kiper Cc: Glenn Washburn Subject: [PATCH v2 0/2] cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner Date: Sun, 21 Mar 2021 15:06:20 -0500 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=development@efficientek.com; helo=mail-qv1-xf30.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Mar 2021 20:06:41 -0000 Since this has been on the shelf a while, I forgot that a null termination of the UUID field in LUKS 1/2 headers can be enforced as it is required by the spec[1][2]. So there's no need to preserve the last byte of the UUID field, as was done in the first version of the patch. I'll repeat here my comments taking into account this change. There was also an issue in v1 that prevented it from building, which has been fixed. -- I have another version of grub_uuidcasecmp which is more efficient by not copying the UUID bytes to another buffer to strip out the dashes. This also implies that it does not require null-terminated strings as inputs because one can use the n parameter to prevent access beyond length of array. However, I'm not sure we're so memory constrained that the added complexity (its not trivial to verify correctness) is worth it here, so I've chosen to submit this simpler version. If that assumption isn't valid, I can submit the more complex version. This current version uses an extra buffer copy in grub_uuidcasecmp to strip out dashes so that grub_strncasecmp can be called. Another benefit of this is that the complexity of UUID processing is moved into one place as opposed to each cryptodisk module potentially having that complexity (eg. current code duplication in LUKS1 and LUKS2 modules). -- Glenn [1] https://mirrors.edge.kernel.org/pub/linux/utils/cryptsetup/LUKS_docs/on-disk-format.pdf#7 [2] https://gitlab.com/cryptsetup/LUKS2-docs/blob/master/luks2_doc_wip.pdf Glenn Washburn (2): luks, luks2: Force header.uuid to be NULL terminated cryptodisk: Allows UUIDs to be compared in a dash-insensitive manner grub-core/disk/cryptodisk.c | 4 ++-- grub-core/disk/geli.c | 2 +- grub-core/disk/luks.c | 24 +++++++----------------- grub-core/disk/luks2.c | 16 ++++++---------- include/grub/misc.h | 27 +++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 30 deletions(-) -- 2.27.0