[Pkg-gnupg-commit] [gpgme] 64/412: Cpp: Add support for pubkey_algo_name

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:26:16 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch master
in repository gpgme.

commit 5489532ad6ccf3a9b59405686b8a17352f1ecf06
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Apr 12 16:08:10 2016 +0200

    Cpp: Add support for pubkey_algo_name
    
    * lang/cpp/src/key.cpp (Subkey::algoName): New.
    * lang/cpp/src/key.h: Declare.
---
 lang/cpp/src/key.cpp | 11 +++++++++++
 lang/cpp/src/key.h   | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index d8b3c29..55eb058 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -383,6 +383,17 @@ const char *Subkey::publicKeyAlgorithmAsString() const
     return gpgme_pubkey_algo_name(subkey ? subkey->pubkey_algo : (gpgme_pubkey_algo_t)0);
 }
 
+std::string Subkey::algoName() const
+{
+    char *gpgmeStr;
+    if (subkey && (gpgmeStr = gpgme_pubkey_algo_string(subkey))) {
+        std::string ret = std::string(gpgmeStr);
+        gpgme_free(gpgmeStr);
+        return ret;
+    }
+    return std::string();
+}
+
 bool Subkey::canEncrypt() const
 {
     return subkey && subkey->can_encrypt;
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 30badea..7322f65 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -206,8 +206,27 @@ public:
     bool isSecret() const;
 
     unsigned int publicKeyAlgorithm() const;
+
+    /**
+      @brief Get the public key algorithm name.
+
+      This only works for the pre 2.1 algorithms for ECC NULL is returned.
+
+      @returns a statically allocated string with the name of the public
+               key algorithm, or NULL if that name is not known.
+    */
     const char *publicKeyAlgorithmAsString() const;
 
+    /**
+       @brief Get the key algo string like GnuPG 2.1 prints it.
+
+       This returns combinations of size and algorithm. Like
+       bp512 or rsa2048
+
+       @returns the key algorithm as string. Empty string on error.
+    */
+    std::string algoName() const;
+
     unsigned int length() const;
 
     const char *cardSerialNumber() const;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list