After upgrading to GPGME 1.24.1, I encountered an issue when handling RSA keys. When using gpgme_pubkey_algo_string to retrieve the algorithm details, it returns "UNKNOWN" instead of "rsa2048". However, for non-RSA keys such as Curve25519, it functions correctly.
To investigate, I wrote a simple C program to test this behavior:
#include <stdio.h> #include <stdlib.h> #include <gpgme.h> void check_gpgme_error(gpgme_error_t err) { if (err) { fprintf(stderr, "GPGME Error: %s\n", gpgme_strerror(err)); exit(EXIT_FAILURE); } } int main() { gpgme_ctx_t ctx; gpgme_key_t key; gpgme_error_t err; gpgme_check_version(NULL); err = gpgme_new(&ctx); check_gpgme_error(err); err = gpgme_op_keylist_start(ctx, NULL, 0); check_gpgme_error(err); while (!(err = gpgme_op_keylist_next(ctx, &key))) { if (key->subkeys && key->subkeys->pubkey_algo) { printf("Key Fingerprint: %s\n", key->subkeys->fpr); printf("Public Key Algorithm: %s\n", gpgme_pubkey_algo_name(key->subkeys->pubkey_algo)); char* buffer = gpgme_pubkey_algo_string(key->subkeys); printf("Public Key Algorithm Details: %s\n", buffer); gpgme_free(buffer); } gpgme_key_unref(key); } gpgme_op_keylist_end(ctx); gpgme_release(ctx); return 0; }
Running the program produced the following output:
Key Fingerprint: 9490795B78F8AF**** Public Key Algorithm: RSA Public Key Algorithm Details: unknown Key Fingerprint: 6DAA6E64A76D2**** Public Key Algorithm: EdDSA Public Key Algorithm Details: ed25519 Key Fingerprint: 02F38DFF731FF9**** Public Key Algorithm: ECDSA Public Key Algorithm Details: brainpoolP256r1 Key Fingerprint: 6F2802C9996627**** Public Key Algorithm: EdDSA Public Key Algorithm Details: ed25519 Key Fingerprint: 12F7E8858CF15BE**** Public Key Algorithm: RSA Public Key Algorithm Details: unknown Key Fingerprint: C6BAE57E27E25FF**** Public Key Algorithm: DSA Public Key Algorithm Details: dsa2048 Key Fingerprint: 467F14220CE8DCF*** Public Key Algorithm: RSA Public Key Algorithm Details: unknown Key Fingerprint: 8933EB283A18995F*** Public Key Algorithm: RSA Public Key Algorithm Details: unknown Key Fingerprint: DA47FADF3104CA7*** Public Key Algorithm: EdDSA Public Key Algorithm Details: ed448
As seen in the output, the function works correctly for EdDSA, ECDSA, and DSA keys, but for RSA keys, it always returns "unknown".
By the way, I am currently using GnuPG 2.4.7:
➜ ~ gpg --version gpg (GnuPG) 2.4.7 libgcrypt 1.10.3 Copyright (C) 2024 g10 Code GmbH License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: /Users/erich/.gnupg Supported algorithms: Public key: RSA, ELG, DSA, ECDH, ECDSA, EDDSA Encryption: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 Hashing: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: none, ZIP, ZLIB, BZIP2
It seems that gpgme_pubkey_algo_string fails to return the correct algorithm details for RSA keys in GPGME 1.24.1. Has anyone else encountered this issue, or is there an alternative approach to retrieve the correct RSA algorithm name? Any insights would be greatly appreciated!