From 4ad08a8998fa16f8329fb57b0a47fe7a9b973700 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 17 Jul 2025 09:31:31 +0900 Subject: agent: Fix for smartcard decryption returning x-coordinate only. * agent/divert-scd.c (agent_card_ecc_kem): Handle the case where smartcard returns x-coordinate only. -- GnuPG-bug-id: 7709 Signed-off-by: NIIBE Yutaka --- agent/divert-scd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/agent/divert-scd.c b/agent/divert-scd.c index 1e5de4671..7e0d8eccb 100644 --- a/agent/divert-scd.c +++ b/agent/divert-scd.c @@ -517,6 +517,12 @@ agent_card_ecc_kem (ctrl_t ctrl, const unsigned char *ecc_ct, if (len == ecc_point_len) memcpy (ecc_ecdh, ecdh, len); + else if ((len - 1) * 2 == ecc_point_len - 1 && ecdh[0] == 0x02) + { + /* It's x-coordinate-only (compressed) point representation. */ + memcpy (ecc_ecdh, ecdh, len); + memset (ecc_ecdh + len, 0, ecc_point_len - len); + } else if (len == ecc_point_len + 1 && ecdh[0] == 0x40) /* The prefix */ memcpy (ecc_ecdh, ecdh + 1, len - 1); else -- cgit v1.2.3