Bug 368462 - Add support for ECC keys (primary and subkeys)
Summary: Add support for ECC keys (primary and subkeys)
Status: RESOLVED FIXED
Alias: None
Product: kgpg
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: unspecified All
: NOR wishlist
Target Milestone: ---
Assignee: Rolf Eike Beer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-08 17:23 UTC by Justus Seifert
Modified: 2016-10-01 12:55 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
NON-PRODUCTION PATCH - implement recognition of ECC key types (2.39 KB, patch)
2016-09-17 11:04 UTC, Steven Noonan
Details
implement display of "strength" instead of "size" (11.36 KB, patch)
2016-09-17 12:19 UTC, Steven Noonan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justus Seifert 2016-09-08 17:23:25 UTC
GnuPG supports OpenPGP keys with ECC algos. These should be displayed correctly as ECC. Currently subkeys for ECC are shown as ”Unknown subkey“ which is a bit misleading because GnuPG knows about them and can even create them with the --expert option.
Comment 1 Steven Noonan 2016-09-17 11:04:45 UTC
Created attachment 101135 [details]
NON-PRODUCTION PATCH - implement recognition of ECC key types

Attached a patch (against v16.08.1) which makes it at least recognize the key types. But I strongly recommend *against* including the patch as-is. The _gpgme_map_pk_algo function I threw in there is basically just a rip of the non-exported function of the same name from here:

https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gpgme.git;a=commitdiff;h=c4b6b35bfa98e478f1d13f4ce3e664771f2604c2

It does the job, but KGPG shouldn't be responsible for converting OpenPGP algorithm identifiers into GPGME algorithm identifiers. It seems to me that KGPG should just be using the key listing APIs:

https://www.gnupg.org/documentation/manuals/gpgme/Listing-Keys.html#Listing-Keys

But it looks like KGPG doesn't link to gpgme and only uses the gpgme_validity_t type from gpgme.h?

This patch also does not take care of adding ECC key generation, and there are 9 different curves to choose from, so that means at least another dropdown in the key generation dialog. ;)
Comment 2 Steven Noonan 2016-09-17 11:15:14 UTC
Oh, I forgot to mention. Another place where my patch is useless is showing which curve is being used. I've seen some other GPG frontends replace the "size" column with a more descriptive "strength" column with values like "dsa1024", "rsa2048", "ed25519", and "secp256k1". It seems like a good idea to me since the bit length means nothing without knowing which algorithm is being used.
Comment 3 Steven Noonan 2016-09-17 12:19:47 UTC
Created attachment 101139 [details]
implement display of "strength" instead of "size"

Along with the previous patch, this implements a display of "strength" as I described in my last comment.

Screenshot of this in action here:

https://www.uplinklabs.net/files/Screenshot_20160917_050857.png

Some of the curves have horrendously long names, so I'm not too fond of that. But it does work at least...
Comment 4 Rolf Eike Beer 2016-09-17 13:06:48 UTC
Your approach looks sane so far. Please post patches to git.reviewboard.kde.org, that is the better suited tool for patch discussion.
Comment 5 Rolf Eike Beer 2016-09-17 13:07:29 UTC
And please base any feature patches on the frameworks branch if possible, if not, then use master.
Comment 6 Steven Noonan 2016-09-18 01:44:41 UTC
I submitted the first patch to review board. It didn't like the second one because it depends on files that were changed in the first one:

The specified diff file could not be parsed.
Line undefined: fatal: git cat-file 7a4f1659842222e2537cd893058fbb35c9c67c2c: bad file

I could squash the patches together but that feels naughty.
Comment 7 Steven Noonan 2016-09-18 01:57:17 UTC
Squashed patch up for review here until I find out how to make ReviewBoard cooperate:

https://git.reviewboard.kde.org/r/128931/
Comment 8 Andrius Štikonas 2016-10-01 12:39:38 UTC
Git commit 65514177e6b9d096b5f6a822a1699e474d791f03 by Andrius Štikonas.
Committed on 01/10/2016 at 12:36.
Pushed by stikonas into branch 'frameworks'.

Fix compilation with older versions of gpgme.

M  +8    -0    core/convert.cpp

http://commits.kde.org/kgpg/65514177e6b9d096b5f6a822a1699e474d791f03
Comment 9 Steven Noonan 2016-10-01 12:52:32 UTC
Andrius, that commit isn't right. You can't use #ifdef on an enum value. It would only be guaranteed to work properly with preprocessor macros.
Comment 10 Steven Noonan 2016-10-01 12:55:17 UTC
Something like this would work though:

diff --git a/core/convert.cpp b/core/convert.cpp
index 1f30739..2939767 100644
--- a/core/convert.cpp
+++ b/core/convert.cpp
@@ -28,10 +28,10 @@
 #include "kgpgsettings.h"
 
 // Backport of gpgme enums from version 1.7.0
-#ifndef GPGME_PK_EDDSA
+#if GPGME_VERSION_NUMBER < 0x010700
 #define GPGME_PK_EDDSA 303
 #endif
-#ifndef GPGME_PK_ECC
+#if GPGME_VERSION_NUMBER < 0x010500
 #define GPGME_PK_ECC 18
 #endif