Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oNgQG-0006gl-ND for mharc-grub-devel@gnu.org; Mon, 15 Aug 2022 16:10:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNgQE-0006bT-3W for grub-devel@gnu.org; Mon, 15 Aug 2022 16:10:50 -0400 Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:38426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNgQC-0008Ma-2C for grub-devel@gnu.org; Mon, 15 Aug 2022 16:10:49 -0400 Received: by mail-qk1-x72e.google.com with SMTP id g21so2680720qka.5 for ; Mon, 15 Aug 2022 13:10:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc; bh=oHLAUzDyg9l/e6dOttEss4X9prbKY+gCekRm9Xd1uSA=; b=uWkbwaEIPxGbAkFzS7vabTAPiavTRUOYdHIphXuFZ8y1oKlbyy+px9eF2xWac5skCt RHppFRucthi6li/iL95MNL64RxG4oHmqTTPUJKVlsmDyOVxGiLMwgz34Uj4kWoF4x4M7 Z5CZMbg0dVlnFg0rbAG5Zs0N/KPsJf1PemMUgp0oDgnatLlK/CEPT+XD3CRD6Bn9dnr0 bh45k3NohwffNtOyIvwc7ljpwTc5DsplrHMNiMiNQQ/q6J2DQ6qX1c4xAtlwzQrJRIKa 6QMsQ52Sf+SfEigx9WuIsW1CaivglyVUjAV2kjsFwAeAe22wsfcW03ycIMDYixHgisDi Fefg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc; bh=oHLAUzDyg9l/e6dOttEss4X9prbKY+gCekRm9Xd1uSA=; b=qAFVUieSEW5zaVuBnKwIEeEWNLc9AumsYvhJgWpLrjIlsmRuXCXmqpEbMZg+AsitsP 5MSfYIlI0pz6l4mYSGjPlJWcBKInNtLDlGn/TcI73OzHwNxPjT8mFt9BMtOlT3iTNvS1 m0wFiConFAOuVRFurIKfaPAJnlmk+VwsMPEz6RyvF98I5MNQjuUzcVm5xgqed7dMj3Kw TvLOuZ/cpxQ/EBpAHS3/FncFF3mm56218JmZqexJxILbspKqyhq/XM6Yw71ydYcI0MAl C2W1XBiEg8hHKuyAlopMjVb/SgFvTl+r1uB6RuglCNUNtfvNk4i1GihEHZJQozR/0hJq P2nQ== X-Gm-Message-State: ACgBeo1n61FFia6FHC26HtD854tUycrbBaKA8JfkXVELp/j83Nj3bH3K W6XHjcd0M+WsbFDsKnLtNHcBGw== X-Google-Smtp-Source: AA6agR5AimoRXNKw7kxr5ABW2Qa0huwfmNGsNp2J3TMCJP1nQulPZELsYejaIeGcki2ZB/eVslxllQ== X-Received: by 2002:a05:620a:24d6:b0:6bb:1dca:92be with SMTP id m22-20020a05620a24d600b006bb1dca92bemr5355067qkn.323.1660594246503; Mon, 15 Aug 2022 13:10:46 -0700 (PDT) Received: from crass-HP-ZBook-15-G2 ([37.218.244.251]) by smtp.gmail.com with ESMTPSA id u11-20020a05620a430b00b006b99b78751csm10075449qko.112.2022.08.15.13.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 13:10:46 -0700 (PDT) Date: Mon, 15 Aug 2022 15:10:41 -0500 From: Glenn Washburn To: Patrick Steinhardt Cc: grub-devel@gnu.org, Daniel Kiper , Nicholas Vinson Subject: Re: [PATCH v6 0/2] luks2: Fix decoding of digests and salts with escaped chars Message-ID: <20220815151041.052d8bf0@crass-HP-ZBook-15-G2> In-Reply-To: References: Reply-To: development@efficientek.com X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=development@efficientek.com; helo=mail-qk1-x72e.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: Mon, 15 Aug 2022 20:10:50 -0000 On Mon, 15 Aug 2022 17:52:45 +0200 Patrick Steinhardt wrote: > Hi, > > this is the sixth version of my patch series which fixes decoding of > digests and salts in LUKS2 headers in case they happen to contain > escaped characters. While modern cryptsetup versions in fact don't > escape any characters part of the Base64 alphabet, old versions of > cryptsetup did this until v2.0.2. > > There's only a single change compared to v5, which is a removed type > cast that was not in fact needed. I didn't include the feedback from > Nicholas to make the JSON string parsing more lenient. While sensible, > it's rather a theoretical concern right now as theer was only a single > version of cryptsetup that ever wrote escaped characters, and even then > of the Base64 alphabet only the backslash may have been escaped. So I > think we should rather defer any improvements until there we discover > real-world problems or until there are more usecases for this function. I support and concur with this rationale. We can change it when it becomes an issue. Glenn > > Patrick > > Patrick Steinhardt (2): > json: Add function to unescape JSON-encoded strings > luks2: Fix decoding of digests and salts with escaped chars > > grub-core/disk/luks2.c | 28 +++++++-- > grub-core/lib/json/json.c | 118 ++++++++++++++++++++++++++++++++++++++ > grub-core/lib/json/json.h | 12 ++++ > 3 files changed, 154 insertions(+), 4 deletions(-) > > Range-diff against v5: > 1: ebab6b092 ! 1: c44675566 json: Add function to unescape JSON-encoded strings > @@ Commit message > Add a new function `grub_json_unescape ()` that takes a potentially > escaped JSON string as input and returns a new unescaped string. > > + Reviewed-by: Daniel Kiper > Signed-off-by: Patrick Steinhardt > > ## grub-core/lib/json/json.c ## > 2: 60ccd669d ! 2: 16ae4ef05 luks2: Fix decoding of digests and salts with escaped chars > @@ Commit message > that handles unescaping for us. > > Reported-by: Afdal > + Reviewed-by: Daniel Kiper > Signed-off-by: Patrick Steinhardt > > ## grub-core/disk/luks2.c ## > @@ grub-core/disk/luks2.c: luks2_scan (grub_disk_t disk, grub_cryptomount_args_t ca > + if (grub_json_unescape (&unescaped, &unescaped_len, in, inlen) != GRUB_ERR_NONE) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("could not unescape Base64 string")); > + > -+ successful = base64_decode (unescaped, (grub_size_t) unescaped_len, (char *) decoded, decodedlen); > ++ successful = base64_decode (unescaped, unescaped_len, (char *) decoded, decodedlen); > + grub_free (unescaped); > + if (!successful) > + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("could not decode Base64 string"));