From a9e5a25b56abb7f27812f333c287a7adae9e18e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Thu, 5 Oct 2023 15:27:52 +0200 Subject: [PATCH] cpp: Support new key capability flags * lang/cpp/src/key.cpp, lang/cpp/src/key.h (class Key): New methods hasCertify, hasSign, hasEncrypt, hasAuthenticate. -- GnuPG-bug-id: 6748 --- NEWS | 4 ++++ lang/cpp/src/key.cpp | 20 ++++++++++++++++++++ lang/cpp/src/key.h | 17 +++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/NEWS b/NEWS index 64e03c19..9c609ac8 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,10 @@ Noteworthy changes in version 1.23.0 (unreleased) gpgme_key_t EXTENDED: New field has_sign. gpgme_key_t EXTENDED: New field has_certify. gpgme_key_t EXTENDED: New field has_authenticate. + cpp: Key::canCertify NEW. + cpp: Key::canSign NEW. + cpp: Key::canEncrypt NEW. + cpp: Key::canAuthenticate NEW. qt: Protocol::wkdRefreshJob NEW. qt: WKDRefreshJob NEW. diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index b18cfaee..9cbd188b 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -247,6 +247,26 @@ bool Key::isDeVs() const return true; } +bool Key::hasCertify() const +{ + return key && key->has_certify; +} + +bool Key::hasSign() const +{ + return key && key->has_sign; +} + +bool Key::hasEncrypt() const +{ + return key && key->has_encrypt; +} + +bool Key::hasAuthenticate() const +{ + return key && key->has_authenticate; +} + const char *Key::issuerSerial() const { return key ? key->issuer_serial : nullptr ; diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index 9e827f63..bdcc18d2 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -109,14 +109,31 @@ public: * isDisabled || isInvalid */ bool isBad() const; + /** Returns true, if the key can be used for encryption (i.e. it's not bad + * and has an encryption subkey) or if the primary subkey can encrypt. */ bool canEncrypt() const; + /** Returns true, if the key can be used for signing (i.e. it's not bad + * and has a signing subkey) or if the primary subkey can sign. */ bool canSign() const; GPGMEPP_DEPRECATED bool canReallySign() const; + /** Returns true, if the key can be used for certification (i.e. it's not bad + * and has a certification subkey) or if the primary subkey can certify. */ bool canCertify() const; + /** Returns true, if the key can be used for authentication (i.e. it's not bad + * and has a authentication subkey) or if the primary subkey can authenticate. */ bool canAuthenticate() const; bool isQualified() const; bool isDeVs() const; + /** Returns true, if the key has a certification subkey. */ + bool hasCertify() const; + /** Returns true, if the key has a signing subkey. */ + bool hasSign() const; + /** Returns true, if the key has an encryption subkey. */ + bool hasEncrypt() const; + /** Returns true, if the key has an authentication subkey. */ + bool hasAuthenticate() const; + bool hasSecret() const; GPGMEPP_DEPRECATED bool isSecret() const {