From e0341ea7434d8427dde70743a7b4d7a7fbf3e605 Mon Sep 17 00:00:00 2001 From: Kai Engert Date: Wed, 27 May 2026 17:22:02 +0200 Subject: [PATCH] Fix rnp_op_verify_get_used_recipient to support hidden recipient, related to Issue #1275 --- src/lib/rnp.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/rnp.cpp b/src/lib/rnp.cpp index 550cb9d4d..f87d1f165 100644 --- a/src/lib/rnp.cpp +++ b/src/lib/rnp.cpp @@ -3409,6 +3409,13 @@ try { handler.ctx = &op->rnpctx; rnp_result_t ret = process_pgp_source(&handler, op->input->src); + /* For hidden recipients, patch used_recipient with the actual key id that was used. + * kparam.last still points to the key that succeeded: the stream-parse loop breaks + * immediately after a successful encrypted_try_key(), so the key provider is not + * called again after that point. */ + if (kparam.has_hidden && kparam.last && op->used_recipient) { + op->used_recipient->keyid = kparam.last->keyid(); + } /* Allow to decrypt data ignoring the signatures check if requested */ if (op->ignore_sigs && op->validated && (ret == RNP_ERROR_SIGNATURE_INVALID)) { ret = RNP_SUCCESS;