[git] GPGME - branch, master, updated. gpgme-1.6.0-205-gfc02672

by Andre Heinecke cvs at cvs.gnupg.org
Wed Jul 6 15:10:14 CEST 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  fc0267233239b42e9fb74a8acd7511503e287a9e (commit)
       via  e41ae4db9e70d9aebf80ebbd4ce03977435c2ccf (commit)
       via  9f93346d21271b916f15d80420669f5d659a40de (commit)
       via  c28007d0407bcc3621b8266d6d77eb0d069aec35 (commit)
      from  4934893e27a50f5715dcd4d2907ecbe629921b32 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fc0267233239b42e9fb74a8acd7511503e287a9e
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Jul 6 15:09:16 2016 +0200

    Qt: Add test for publicKeyAlgorithmAsString
    
    * lang/qt/tests/t-keylist.cpp (testPubkeyAlgoAsString): New.

diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp
index 591a552..38d315f 100644
--- a/lang/qt/tests/t-keylist.cpp
+++ b/lang/qt/tests/t-keylist.cpp
@@ -32,6 +32,7 @@
 #include <QDebug>
 #include <QTest>
 #include <QSignalSpy>
+#include <QMap>
 #include "keylistjob.h"
 #include "qgpgmebackend.h"
 #include "keylistresult.h"
@@ -64,6 +65,27 @@ private Q_SLOTS:
         Q_ASSERT (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E);
     }
 
+    void testPubkeyAlgoAsString()
+    {
+        static const QMap<Subkey::PubkeyAlgo, QString> expected {
+            { Subkey::AlgoRSA,    QStringLiteral("RSA") },
+            { Subkey::AlgoRSA_E,  QStringLiteral("RSA-E") },
+            { Subkey::AlgoRSA_S,  QStringLiteral("RSA-S") },
+            { Subkey::AlgoELG_E,  QStringLiteral("ELG-E") },
+            { Subkey::AlgoDSA,    QStringLiteral("DSA") },
+            { Subkey::AlgoECC,    QStringLiteral("ECC") },
+            { Subkey::AlgoELG,    QStringLiteral("ELG") },
+            { Subkey::AlgoECDSA,  QStringLiteral("ECDSA") },
+            { Subkey::AlgoECDH,   QStringLiteral("ECDH") },
+            { Subkey::AlgoEDDSA,  QStringLiteral("EdDSA") },
+            { Subkey::AlgoUnknown, QString() }
+        };
+        Q_FOREACH (Subkey::PubkeyAlgo algo, expected.keys()) {
+            Q_ASSERT(QString::fromUtf8(Subkey::publicKeyAlgorithmAsString(algo)) ==
+                     expected.value(algo));
+        }
+    }
+
     void testKeyListAsync()
     {
         KeyListJob *job = openpgp()->keyListJob();

commit e41ae4db9e70d9aebf80ebbd4ce03977435c2ccf
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Jul 6 15:07:34 2016 +0200

    Cpp: Expose gpgme_pubkey_algo_name
    
    * lang/cpp/src/key.cpp (Subkey::publicKeyAlgorithmAsString): New
    static variant.
    * lang/cpp/src/key.h: Declare function. Clarify comment about name
    mismatch.

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 9e57013..d99c5ec 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -383,6 +383,15 @@ const char *Subkey::publicKeyAlgorithmAsString() const
     return gpgme_pubkey_algo_name(subkey ? subkey->pubkey_algo : (gpgme_pubkey_algo_t)0);
 }
 
+/* static */
+const char *Subkey::publicKeyAlgorithmAsString(PubkeyAlgo algo)
+{
+    if (algo == AlgoUnknown) {
+        return NULL;
+    }
+    return gpgme_pubkey_algo_name(static_cast<gpgme_pubkey_algo_t>(algo));
+}
+
 std::string Subkey::algoName() const
 {
     char *gpgmeStr;
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 845b5db..bb0487b 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -233,11 +233,16 @@ public:
     */
     const char *publicKeyAlgorithmAsString() const;
 
+    /** @brief Same as publicKeyAlgorithmAsString but static. */
+    static const char *publicKeyAlgorithmAsString(PubkeyAlgo algo);
+
     /**
        @brief Get the key algo string like GnuPG 2.1 prints it.
 
        This returns combinations of size and algorithm. Like
-       bp512 or rsa2048
+       bp512 or rsa2048. Misnamed because publicKeyAlgorithmAsString
+       already used the older pubkey_algo_name.
+       Actually uses gpgme_pubkey_algo_string.
 
        @returns the key algorithm as string. Empty string on error.
     */

commit 9f93346d21271b916f15d80420669f5d659a40de
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Jul 6 13:39:43 2016 +0200

    Qt: Add check for pubkeyAlgo in t-keylist
    
    * lang/qt/tests/t-keylist.cpp (testSingleKeyListSync): Check
    pubkeyAlgo.

diff --git a/lang/qt/tests/t-keylist.cpp b/lang/qt/tests/t-keylist.cpp
index 5d63fca..591a552 100644
--- a/lang/qt/tests/t-keylist.cpp
+++ b/lang/qt/tests/t-keylist.cpp
@@ -58,6 +58,10 @@ private Q_SLOTS:
         Q_ASSERT (keys.size() == 1);
         const QString kId = QLatin1String(keys.front().keyID());
         Q_ASSERT (kId == QStringLiteral("2D727CC768697734"));
+
+        Q_ASSERT (keys[0].subkeys().size() == 2);
+        Q_ASSERT (keys[0].subkeys()[0].publicKeyAlgorithm() == Subkey::AlgoDSA);
+        Q_ASSERT (keys[0].subkeys()[1].publicKeyAlgorithm() == Subkey::AlgoELG_E);
     }
 
     void testKeyListAsync()

commit c28007d0407bcc3621b8266d6d77eb0d069aec35
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Wed Jul 6 13:38:20 2016 +0200

    Cpp: Add PubkeyAlgo enum
    
    * lang/cpp/src/key.h (Subkey::PubkeyAlgo): New enum.
    (Subkey::publicKeyAlgorithm): Change return type.
    * lang/cpp/src/key.cpp (Subkey::publicKeyAlgorithm): Use enum.

diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp
index 55eb058..9e57013 100644
--- a/lang/cpp/src/key.cpp
+++ b/lang/cpp/src/key.cpp
@@ -373,9 +373,9 @@ const char *Subkey::fingerprint() const
     return subkey ? subkey->fpr : 0 ;
 }
 
-unsigned int Subkey::publicKeyAlgorithm() const
+Subkey::PubkeyAlgo Subkey::publicKeyAlgorithm() const
 {
-    return subkey ? subkey->pubkey_algo : 0 ;
+    return subkey ? static_cast<PubkeyAlgo>(subkey->pubkey_algo) : AlgoUnknown;
 }
 
 const char *Subkey::publicKeyAlgorithmAsString() const
diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h
index 7322f65..845b5db 100644
--- a/lang/cpp/src/key.h
+++ b/lang/cpp/src/key.h
@@ -205,7 +205,23 @@ public:
 
     bool isSecret() const;
 
-    unsigned int publicKeyAlgorithm() const;
+    /** Same as gpgme_pubkey_algo_t */
+    enum PubkeyAlgo {
+        AlgoUnknown = 0,
+        AlgoRSA     = 1,
+        AlgoRSA_E   = 2,
+        AlgoRSA_S   = 3,
+        AlgoELG_E   = 16,
+        AlgoDSA     = 17,
+        AlgoECC     = 18,
+        AlgoELG     = 20,
+        AlgoECDSA   = 301,
+        AlgoECDH    = 302,
+        AlgoEDDSA   = 303,
+        AlgoMax     = 1 << 31
+    };
+
+    PubkeyAlgo publicKeyAlgorithm() const;
 
     /**
       @brief Get the public key algorithm name.

-----------------------------------------------------------------------

Summary of changes:
 lang/cpp/src/key.cpp        | 13 +++++++++++--
 lang/cpp/src/key.h          | 25 +++++++++++++++++++++++--
 lang/qt/tests/t-keylist.cpp | 26 ++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list