[PATCH scd] scd: Fix Yubikey gpg decryption using Ed25519

Felipe Custodio Romero felipe at neodyme.io
Fri Dec 2 18:14:14 CET 2022


* scd/app-openpgp.c (parse_algorithm_attribute): re-enable
ECC_FLAG_DJB_TWEAK for Yubikeys with Ed25519.

--
Hi,

This patch fixes gpg decryption with Yubikeys using Ed25519 which
has been broken since 2.3.0.

Before this patch, attempting to decrypt a message with a Yubikey
using Ed25519 failed with the error `decryption failed: Invalid value`.
After this patch, the decryption succeeds.

Regards
Felipe

---
 scd/app-openpgp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index e445b2409..c2b4a9133 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -6292,9 +6292,11 @@ parse_algorithm_attribute (app_t app, int keyno)
         {
           app->app_local->keyattr[keyno].key_type = KEY_TYPE_ECC;
           app->app_local->keyattr[keyno].ecc.curve = curve;
+          /* ECC_FLAG_DJB_TWEAK needs to be set for Yubikeys with Ed25519
*/
           if ((*buffer == PUBKEY_ALGO_EDDSA
-               && !strcmp (app->app_local->keyattr[keyno].ecc.curve,
-                           "Ed25519"))
+               && (!strcmp (app->app_local->keyattr[keyno].ecc.curve,
+                           "Ed25519")
+                   || APP_CARD(app)->cardtype == CARDTYPE_YUBIKEY))
               || (*buffer == PUBKEY_ALGO_ECDH
                   && !strcmp (app->app_local->keyattr[keyno].ecc.curve,
                               "Curve25519")))
--
2.38.0

-- 
Neodyme AG
Sitz der Gesellschaft / Address: Dirnismaning 55 | Halle 13 | 
85748 Garching b.München
Postanschrift: ​Rosenthaler Straße 72a | ​10119 
Berlin

Registergericht / Registry court: München, HRB 269168
Vorstand / 
Management Board: Thomas Lambertz | Tobias Madl
Aufsichtsratsvorsitzender / 
Chairman of the Supervisory Board: Hendrik Hofstadt




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20221202/f940a0f3/attachment-0001.html>


More information about the Gnupg-devel mailing list