From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kmlkg-0004jt-6K for mharc-grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmlke-0004ft-7y for grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:32 -0500 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]:41259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kmlkV-0000kZ-3P for grub-devel@gnu.org; Tue, 08 Dec 2020 17:46:31 -0500 Received: by mail-ot1-x344.google.com with SMTP id x13so337974oto.8 for ; Tue, 08 Dec 2020 14:46:19 -0800 (PST) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=z9BRrq+Tdkf4489o5dOnoISeeF7z877noQtCsj3J5XE=; b=Yc+N+5AO5GMrar8w7uJAcg68SlGSY3y8fWjR3mPGl8rfJyr0olhbmrd71mSWbqcoB/ 6KmSICIgsY5jWRRdJ6xWimg6RJ0Da2uc0933vyEmb80Az4tR1Y1CjiGj+/VRR8YevE/n MAW5uY8oEDtsQCaywNmShsvFz6a4u1wnSDRcipFDOJfk1Nt47amO+ijAYn6iLcmLz2tu XRLMhsCrirw5wKCmrlelp0zg4sy7SrQNa5eXZetttl1BqR96x5VNQahaGwu5QNHd2WKa b9jhqlpCLuKtC1yiVGETA+J/KMjlwlvCdZVIVazMWfkSqqGU+pGj3axlTjTQ6q29+Lbu mpeQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=z9BRrq+Tdkf4489o5dOnoISeeF7z877noQtCsj3J5XE=; b=BhTD/j+S16L5DaP6/dpidqcaCDpiL7kmAFoIMW6CjN9G9K74cxg5+VRnxuC/Q0mI98 C+JmBFFo+1FxZiL5xBltx6A0NER4akFhXVS8Ebrq2HGaufT256k4eWZDaWDPD8N1Lfff lEkaLsXMk/oHZ6Hu8Xkf68J05jYXV1TS2ZfYlKmSq3l05Do0K+nYZbxtDoMBu6E8bLa8 HXbZ7w/LO1Q9i3sDQ33T8MU10cX44az72iIld3qde9iv0jcU6WmLdiRhwbM9/tL/Ejgy BWuBWHmK4bJPUFLHO6T9aE8bA2Hx7pCi+N5AVvOmmjv90UCmtltY75LlE9S/WyXJvrt5 ktww== X-Gm-Message-State: AOAM533h+aGg2I0wKJb+QSewqIdFBaldRifkA7/geXJ1tQDyyQejQo9W 3dZf01Ew9J5+tP2MK6AZA3/V4Wv0b4BaNw== X-Google-Smtp-Source: ABdhPJy8svqNS5/3ToAHIsWz/Es5TfZ9UgWDtZnge5W5XBrpmcmDzaBs7rwjRLwC457Xx5OJhx5K0Q== X-Received: by 2002:a9d:7cc8:: with SMTP id r8mr256824otn.233.1607467578731; Tue, 08 Dec 2020 14:46:18 -0800 (PST) Received: from crass-HP-ZBook-15-G2.attlocal.net ([136.49.211.192]) by smtp.gmail.com with ESMTPSA id v8sm45538otp.10.2020.12.08.14.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:46:18 -0800 (PST) From: Glenn Washburn To: grub-devel@gnu.org Cc: Patrick Steinhardt , Daniel Kiper , Glenn Washburn Subject: [PATCH v8 07/18] luks2: Use more intuitive object name instead of json index in user messages Date: Tue, 8 Dec 2020 16:45:38 -0600 Message-Id: <1991eca5ae78d76ec70cd600cdf0b54031ebce6a.1607466704.git.development@efficientek.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::344; envelope-from=development@efficientek.com; helo=mail-ot1-x344.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: Tue, 08 Dec 2020 22:46:32 -0000 Use the object name in the json array rather than the 0 based index in the json array for keyslots, segments, and digests. This is less confusing for the end user. For example, say you have a LUKS2 device with a key in slot 1 and slot 4. When using the password for slot 4 to unlock the device, the messages using the index of the keyslot will mention keyslot 1 (its a zero-based index). Furthermore, with this change the keyslot number will align with the number used to reference the keyslot when using the --key-slot argument to cryptsetup. Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 67b1823d3..b6930b2f5 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -290,7 +290,7 @@ luks2_get_keyslot (grub_luks2_keyslot_t *k, grub_luks2_digest_t *d, grub_luks2_s break; } if (i == size) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No digest for keyslot %"PRIuGRUB_SIZE, keyslot_idx); + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No digest for keyslot \"%"PRIuGRUB_UINT64_T"\"", k->idx); /* Get segment that matches the digest. */ if (grub_json_getvalue (&segments, root, "segments") || @@ -308,7 +308,7 @@ luks2_get_keyslot (grub_luks2_keyslot_t *k, grub_luks2_digest_t *d, grub_luks2_s break; } if (i == size) - return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No segment for digest %"PRIuGRUB_SIZE); + return grub_error (GRUB_ERR_FILE_NOT_FOUND, "No segment for digest \"%"PRIuGRUB_UINT64_T"\"", d->idx); return GRUB_ERR_NONE; } @@ -604,11 +604,11 @@ luks2_recover_key (grub_disk_t source, if (keyslot.priority == 0) { - grub_dprintf ("luks2", "Ignoring keyslot %"PRIuGRUB_SIZE" due to priority\n", i); + grub_dprintf ("luks2", "Ignoring keyslot \"%"PRIuGRUB_UINT64_T"\" due to priority\n", keyslot.idx); continue; } - grub_dprintf ("luks2", "Trying keyslot %"PRIuGRUB_SIZE"\n", i); + grub_dprintf ("luks2", "Trying keyslot \"%"PRIuGRUB_UINT64_T"\"\n", keyslot.idx); /* Set up disk according to keyslot's segment. */ crypt->offset_sectors = grub_divmod64 (segment.offset, segment.sector_size, NULL); @@ -623,16 +623,16 @@ luks2_recover_key (grub_disk_t source, (const grub_uint8_t *) passphrase, grub_strlen (passphrase)); if (ret) { - grub_dprintf ("luks2", "Decryption with keyslot %"PRIuGRUB_SIZE" failed: %s\n", - i, grub_errmsg); + grub_dprintf ("luks2", "Decryption with keyslot \"%"PRIuGRUB_UINT64_T"\" failed: %s\n", + keyslot.idx, grub_errmsg); continue; } ret = luks2_verify_key (&digest, candidate_key, keyslot.key_size); if (ret) { - grub_dprintf ("luks2", "Could not open keyslot %"PRIuGRUB_SIZE": %s\n", - i, grub_errmsg); + grub_dprintf ("luks2", "Could not open keyslot \"%"PRIuGRUB_UINT64_T"\": %s\n", + keyslot.idx, grub_errmsg); continue; } @@ -640,7 +640,7 @@ luks2_recover_key (grub_disk_t source, * TRANSLATORS: It's a cryptographic key slot: one element of an array * where each element is either empty or holds a key. */ - grub_printf_ (N_("Slot %"PRIuGRUB_SIZE" opened\n"), i); + grub_printf_ (N_("Slot \"%"PRIuGRUB_UINT64_T"\" opened\n"), keyslot.idx); candidate_key_len = keyslot.key_size; break; -- 2.27.0