diff options
Diffstat (limited to 'lang')
| -rw-r--r-- | lang/cpp/src/key.cpp | 21 | ||||
| -rw-r--r-- | lang/cpp/src/key.h | 14 | ||||
| -rw-r--r-- | lang/python/tests/Makefile.am | 21 | ||||
| -rw-r--r-- | lang/qt/tests/Makefile.am | 10 | 
4 files changed, 48 insertions, 18 deletions
| diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index 66fdea96..0e86a19e 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -371,6 +371,27 @@ void Key::update()      return;  } +// static +Key Key::locate(const char *mbox) +{ +    if (!mbox) { +        return Key(); +    } + +    auto ctx = Context::createForProtocol(OpenPGP); +    if (!ctx) { +        return Key(); +    } + +    ctx->setKeyListMode (Extern | Local); + +    Error e = ctx->startKeyListing (mbox); +    auto ret = ctx->nextKey (e); +    delete ctx; + +    return ret; +} +  //  //  // class Subkey diff --git a/lang/cpp/src/key.h b/lang/cpp/src/key.h index 829bd266..c3c711c1 100644 --- a/lang/cpp/src/key.h +++ b/lang/cpp/src/key.h @@ -164,6 +164,20 @@ public:       * @returns a possible error.       **/      Error addUid(const char *uid); + +    /** +     * @brief try to locate the best pgp key for a given mailbox. +     * +     * Boils down to gpg --locate-key <mbox> +     * This may take some time if remote sources are also +     * used. +     * +     * @param mbox should be a mail address does not need to be normalized. +     * +     * @returns The best key for a mailbox or a null key. +     */ +    static Key locate(const char *mbox); +  private:      gpgme_key_t impl() const      { diff --git a/lang/python/tests/Makefile.am b/lang/python/tests/Makefile.am index 25b15f2b..3864f8ba 100644 --- a/lang/python/tests/Makefile.am +++ b/lang/python/tests/Makefile.am @@ -18,8 +18,6 @@  GPG = gpg  GPG_AGENT = gpg-agent -export GNUPGHOME := $(abs_builddir) -export GPG_AGENT_INFO :=  test_srcdir = $(top_srcdir)/tests/gpg @@ -79,7 +77,7 @@ xcheck:	all  CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \  	gpg-agent.conf pubring.kbx~ gpg.conf pubring.gpg~ \  	random_seed .gpg-v21-migrated tofu.db \ -        pubring-stamp private-keys-v1.d/gpg-sample.stamp +        pubring-stamp gpg-sample.stamp  private_keys = \          $(test_srcdir)/13CD0F3BDF24BE53FE192D62F18737256FF6E4FD \ @@ -89,26 +87,25 @@ private_keys = \          $(test_srcdir)/7A030357C0F253A5BBCD282FFC4E521B37558F5C  clean-local: -	-$(top_srcdir)/tests/start-stop-agent --stop +	-$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop  	-rm -fR -- private-keys-v1.d openpgp-revocs.d S.gpg-agent sshcontrol  BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \ -           private-keys-v1.d/gpg-sample.stamp +           gpg-sample.stamp -private-keys-v1.d/gpg-sample.stamp: $(private_keys) -	-gpgconf --kill all +gpg-sample.stamp: $(private_keys) +	-$(TESTS_ENVIRONMENT) gpgconf --kill all  	$(MKDIR_P) ./private-keys-v1.d  	for k in $(private_keys); do \            cp $$k private-keys-v1.d/$${k#$(test_srcdir)/}.key; \          done -	echo x > ./private-keys-v1.d/gpg-sample.stamp +	echo x > ./gpg-sample.stamp -pubring-stamp: $(test_srcdir)/pubdemo.asc           \ -                 ./private-keys-v1.d/gpg-sample.stamp -	$(GPG) --batch --no-permission-warning \ +pubring-stamp: $(test_srcdir)/pubdemo.asc gpg-sample.stamp +	$(TESTS_ENVIRONMENT) $(GPG) --batch --no-permission-warning \                 --import $(test_srcdir)/pubdemo.asc -	-$(GPG) --batch --no-permission-warning \ +	-$(TESTS_ENVIRONMENT) $(GPG) --batch --no-permission-warning \  		--import $(test_srcdir)/secdemo.asc  	echo x > ./pubring-stamp diff --git a/lang/qt/tests/Makefile.am b/lang/qt/tests/Makefile.am index a662b4cf..104672e4 100644 --- a/lang/qt/tests/Makefile.am +++ b/lang/qt/tests/Makefile.am @@ -70,21 +70,19 @@ CLEANFILES = secring.gpg pubring.gpg pubring.kbx trustdb.gpg dirmngr.conf \  	gpg.conf tofu.db  clean-local: -	-$(top_srcdir)/tests/start-stop-agent --stop +	-$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop  	-rm -fR  private-keys-v1.d crls.d -export GNUPGHOME := $(abs_builddir) -  pubring-stamp: $(top_srcdir)/tests/gpg/pubdemo.asc \  	             $(top_srcdir)/tests/gpg/secdemo.asc -	-gpgconf --kill all +	-$(TESTS_ENVIRONMENT) gpgconf --kill all  	echo "ignore-invalid-option allow-loopback-pinentry" > $(abs_builddir)/gpg-agent.conf  	echo "allow-loopback-pinentry" >> gpg-agent.conf  	echo "ignore-invalid-option pinentry-mode" > gpg.conf  	echo "pinentry-mode loopback" >> gpg.conf -	$(GPG) --no-permission-warning \ +	$(TESTS_ENVIRONMENT) $(GPG) --no-permission-warning \             --import $(top_srcdir)/tests/gpg/pubdemo.asc -	$(GPG) --no-permission-warning \ +	$(TESTS_ENVIRONMENT) $(GPG) --no-permission-warning \  		   --passphrase "abc" \             --import $(top_srcdir)/tests/gpg/secdemo.asc  	touch pubring-stamp | 
