gpgme.git
10 months agocore: New keyword --file for OpenPGP recpstring.
Werner Koch [Tue, 17 Apr 2018 10:40:30 +0000 (12:40 +0200)]
core: New keyword --file for OpenPGP recpstring.

* src/engine-gpg.c (append_args_from_recipients_string): Add new
flags.
--

Now you can use gpgme to encrypt without first importing a key.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: For OpenPGP let offline mode disable dirmngr.
Werner Koch [Tue, 17 Apr 2018 09:06:27 +0000 (11:06 +0200)]
core: For OpenPGP let offline mode disable dirmngr.

* src/engine-gpg.c (struct engine_gpg): New flag.offline.
(gpg_set_engine_flags): Set it.  Also fix setting of no_symkey_cache.
(build_argv): Pass --disable-dirmngr in offline mode.
--

GnuPG-bug-id: 3831
Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agopython: Fix crash by leaving struct members intact
Tobias Mueller [Tue, 20 Feb 2018 16:34:14 +0000 (17:34 +0100)]
python: Fix crash by leaving struct members intact

* lang/python/setup.py.in: Copy gpgme.h instead of parsing it.
--
The python bindings tried to parse deprecated functions
out of gpgme.h. This fails for the current gpgme.h in
that it removes an entire field in the key sig struct (_obsolete_class).
Hence, the fields were off by an int and the bindings accessed struct
members via the wrong offset. That caused python program to crash.
At least on 32bit platforms, the crash can be easily triggered by
accessing key.uids[0].signatures. On 64bit platforms the compiler
probably aligns the struct so that the missing 4 bytes are not noticed.

With this change, the python bindings will expose all functions
that gpgme exposes, including the deprecated ones.

Credits go to Justus Winter for debugging and identying the issue.

Signed-off-by: Tobias Mueller <muelli@cryptobitch.de>
GnuPG-bug-id: 3892

10 months agocore: Allow for --hidden keyword in OpenPGP recpstrings.
Werner Koch [Tue, 17 Apr 2018 08:04:20 +0000 (10:04 +0200)]
core: Allow for --hidden keyword in OpenPGP recpstrings.

* src/engine-gpg.c (append_args_from_recipients_string): Add special
keywords.
--

GnuPG-bug-id: 3775
Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: New encryption flag GPGME_ENCRYPT_WANT_ADDRESS.
Werner Koch [Tue, 17 Apr 2018 07:40:27 +0000 (09:40 +0200)]
core: New encryption flag GPGME_ENCRYPT_WANT_ADDRESS.

* src/gpgme.h.in (GPGME_ENCRYPT_WANT_ADDRESS): New flag.
* src/engine-gpg.c (add_arg_recipient): New.
(add_arg_recipient_string): New.
(append_args_from_recipients): Call new helper function.
(append_args_from_recipients_string): Ditto.
* src/gpgme-json.c (op_encrypt): Add flag "want-address".
--

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: Add extended versions of the encrypt functions.
Werner Koch [Tue, 17 Apr 2018 06:33:44 +0000 (08:33 +0200)]
core: Add extended versions of the encrypt functions.

* src/gpgme.h.in (gpgme_op_encrypt_ext_start) New.
(gpgme_op_encrypt_ext): New.
(gpgme_op_encrypt_sign_ext_start): New.
(gpgme_op_encrypt_sign_ext): New.
* src/libgpgme.vers, tests/run-encrypt.c: Add them.

* src/encrypt.c (encrypt_start): Add arg recpstring.
(gpgme_op_encrypt): Factor code out to ...
(gpgme_op_encrypt_ext): new function with new arg recpstring.
(gpgme_op_encrypt_start): Factor code out to ...
(gpgme_op_encrypt_ext_start): new function with new arg recpstring.
* src/encrypt-sign.c (encrypt_sign_start): Add arg recpstring.
(gpgme_op_encrypt_sign): Factor code out to ...
(gpgme_op_encrypt_sign_ext): new function with new arg recpstring.
(gpgme_op_encrypt_sign_start): Factor code out to ...
(gpgme_op_encrypt_sign_ext_start): new function with new arg
recpstring.

* src/engine-backend.h (struct engine_ops): Change fields encrypt and
encrypt_sign.
* src/engine.c (_gpgme_engine_op_encrypt): Add arg recpstring and pass
to engine.
(_gpgme_engine_op_encrypt_sign): Ditto.
* src/engine-gpg.c (append_args_from_recipients_string): New.
(gpg_encrypt): Add arg recpstring and call new function as needed.
(gpg_encrypt_sign): Ditto.
* src/engine-gpgsm.c (set_recipients_from_string): New.
(gpgsm_encrypt): Add arg recpstring and call new function as needed.
* src/engine-uiserver.c (set_recipients_from_string): New.
(uiserver_encrypt): Add arg recpstring and call new function as
needed.

* tests/run-encrypt.c (xstrdup): New.
(main): Add option --keystring.

* src/gpgme-json.c (get_keys): Simplify.
(op_encrypt): Modify to make use of the extended encrypt function.

--

This new feature can be used to avoid the need for a key lookup and
thus several extra calls to the backend.

Note that run-test uses a semicolon as delimiter because that make
testing the feature on the command line much easier.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: Tweak STATUS_FAILURE handling.
Werner Koch [Thu, 12 Apr 2018 18:36:30 +0000 (20:36 +0200)]
core: Tweak STATUS_FAILURE handling.

* src/op-support.c (_gpgme_parse_failure): Ignore failures with
location "gpg-exit".
* tests/gpg/t-verify.c (main): Adjust for the now working checking of
the second key.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: For a failed verification return the sig's fingerprint.
Werner Koch [Thu, 12 Apr 2018 18:26:00 +0000 (20:26 +0200)]
core: For a failed verification return the sig's fingerprint.

* src/verify.c (parse_new_sig): Parse the new ERRSIG fpr.
--

This works only when the signatures features an ISSUER_FPR sub-packet
and with GnuPG >= 2.2.7.  If that is not the case the keyid is kept in
the FPR field.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agotests: Avoid segv in run-verify due to Policy URLs
Werner Koch [Thu, 12 Apr 2018 13:59:22 +0000 (15:59 +0200)]
tests: Avoid segv in run-verify due to Policy URLs

* tests/run-verify.c (print_result): Take care of Policy URLs.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agotests: Add another check to gpg/t-verify.
Werner Koch [Thu, 12 Apr 2018 13:39:20 +0000 (15:39 +0200)]
tests: Add another check to gpg/t-verify.

* tests/gpg/t-verify.c (PGM): New.  Use it instead of __FILE__.
(test_sig1_plus_unknown_key): New test signature.
(check_result): Allow checking of several signatures.
(main): Check a signature with a know and an unknown key.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: Add new context flag "no-symkey-cache".
Werner Koch [Thu, 12 Apr 2018 07:17:27 +0000 (09:17 +0200)]
core: Add new context flag "no-symkey-cache".

* src/gpgme.c (gpgme_set_ctx_flag): Set flag.
(gpgme_get_ctx_flag): Get flag.
* src/context.h (struct gpgme_context): Add field no_symkey_cache.
* src/engine-gpg.c (struct engine_gpg): Ditto.
(gpg_set_engine_flags): Set flag.
(build_argv): Pass option --no-symkey-cache to gpg.

* tests/run-decrypt.c (print_result): Fix segv for symmetric messages.
(main): New option --no-symkey-cache.
* tests/run-encrypt.c (main): New option --no-symkey-cache.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agoqt: Add test for resetting config value
Andre Heinecke [Wed, 4 Apr 2018 09:21:53 +0000 (11:21 +0200)]
qt: Add test for resetting config value

* lang/qt/tests/t-config.cpp (CryptoConfigTest::testDefault): New.

--
There is a bug around here somewhere. This test does not show
it :-(

10 months agoMerge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Thu, 29 Mar 2018 23:38:31 +0000 (10:38 +1100)]
Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme

* Also fixed a small grammatical error highlighted by a merge conflict
  (in the python bindings howto).

10 months agojson: Build only a dummy if libgpg-error is < 1.28
Werner Koch [Thu, 29 Mar 2018 13:06:47 +0000 (15:06 +0200)]
json: Build only a dummy if libgpg-error is < 1.28

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agoMerge branch 'ben/howto-update-02' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Wed, 28 Mar 2018 23:27:41 +0000 (10:27 +1100)]
Merge branch 'ben/howto-update-02' of ssh+git://playfair.gnupg.org/git/gpgme

10 months agoexample: revoke UID ben/howto-update-02
Ben McGinnes [Wed, 28 Mar 2018 23:21:52 +0000 (10:21 +1100)]
example: revoke UID

* Script to revoke a UID on an existing key.

10 months agodocs: python bindings howto
Ben McGinnes [Wed, 28 Mar 2018 23:16:07 +0000 (10:16 +1100)]
docs: python bindings howto

* Added section on revoking UIDs.

10 months agoexample: key signing
Ben McGinnes [Wed, 28 Mar 2018 22:49:08 +0000 (09:49 +1100)]
example: key signing

* Added script for signing or certifying keys.

10 months agodoc: python bindings howto
Ben McGinnes [Wed, 28 Mar 2018 22:22:17 +0000 (09:22 +1100)]
doc: python bindings howto

* Fixed a typo.

10 months agodocs python bindings howto
Ben McGinnes [Wed, 28 Mar 2018 20:22:37 +0000 (07:22 +1100)]
docs python bindings howto

* PEP8 compliance: a collection of minor edits across multiple example
  code snippets.

10 months agoexample: add user ID
Ben McGinnes [Wed, 28 Mar 2018 19:36:14 +0000 (06:36 +1100)]
example: add user ID

* Added script to add a UID to an existing key.

10 months agojson: Remove the "message" object thingy again.
Werner Koch [Wed, 28 Mar 2018 19:21:10 +0000 (21:21 +0200)]
json: Remove the "message" object thingy again.

* src/gpgme-json.c (process_request): Remove 'nm_mode'.
--

This was an error in the javascript testing code.  Thus the Mozilla
specs are correct that the request is send verbatim.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agojson: Make native messaging work.
Werner Koch [Wed, 28 Mar 2018 18:50:54 +0000 (20:50 +0200)]
json: Make native messaging work.

* src/gpgme-json.c (opt_debug): New.
(process_request): Add optional arg nm_mode.  In this mode take the
request from a "message" object.
(native_messaging_repl): Add debug output and call process_request
in NM_MODE.
(main): Add option --debug.  Parse envvar GPGME_JSON_DEBUG as an
alternative way to enable this.  Use a default log file.
--

Note that the default log file is ~/.gnupg/S.gpgme-json.log .
Thus to debug a javascript application you should start

  watchgnupg --time-only --force ~/.gnupg/S.gpgme-json.log

in a separate tty and then use

 GPGME_JSON_DEBUG=1 firefox &

to run firefox.

Signed-off-by: Werner Koch <wk@gnupg.org>
10 months agocore: Initialize key return value in gpgme_get_key
Andre Heinecke [Tue, 27 Mar 2018 09:24:55 +0000 (11:24 +0200)]
core: Initialize key return value in gpgme_get_key

* src/keylist.c (gpgme_get_key): Set r_key to NULL.

--
The c++ bindings and others assumed that r_key is set to NULL
on error. This is the behavior gpgme_op_keylist_next also
has. Even if it is not specified what happens to r_key on
error setting it to NULL should not hurt and is more
expected behavior.

This directly fixes an uninitialized memory access error
in the c++ bindings / Kleopatra:
GnuPG-Bug-Id: T3865

And will fix some additional random crashes in Kleopatra and GpgOL.

10 months agodoc: python bindings howto
Ben McGinnes [Tue, 27 Mar 2018 01:42:06 +0000 (12:42 +1100)]
doc: python bindings howto

* Fixed some minor PEP8 compliance issues in the key creation examples.

10 months agoexample: key creation
Ben McGinnes [Tue, 27 Mar 2018 01:29:08 +0000 (12:29 +1100)]
example: key creation

* Script to generate a new key with encryption subkey taking input
  from interactive prompts.
* Will also take a passphrase via pinentry and uses passphrase caching
  of five minutes when used in conjunction with the temp homedir
  script.

10 months agoscript: temp homedir config
Ben McGinnes [Tue, 27 Mar 2018 01:16:29 +0000 (12:16 +1100)]
script: temp homedir config

* added passphrase caching of 5 minutes.

10 months agodoc: python bindings howto
Ben McGinnes [Sun, 25 Mar 2018 11:25:52 +0000 (22:25 +1100)]
doc: python bindings howto

* Testing the addition of a HTML header set in org-mode in order to
  had RSS update links for files.
* This should work with any [X]HTML export from current versions of
  Org-Mode, but if it also works on website generated pages then it'll
  tick off one of the wishlist itmes.

10 months agoscript: temp homedir howto-update-01
Ben McGinnes [Sun, 25 Mar 2018 00:54:05 +0000 (11:54 +1100)]
script: temp homedir

* Fixed whitespace.

10 months agodoc: python bindings howto
Ben McGinnes [Sun, 25 Mar 2018 00:35:11 +0000 (11:35 +1100)]
doc: python bindings howto

* Added a reference to new script which will setup a temporary homedir
  for a user.

10 months agoscript: temporary homedir creation
Ben McGinnes [Sun, 25 Mar 2018 00:26:26 +0000 (11:26 +1100)]
script: temporary homedir creation

* Script to create a temporary gnupg homedir in the user's directory
  for testing or scripting purposes.
* Creates a hidden directory on POSIX systems with the correct
  permissions (700).
* Creates a gpg.conf in that directory containing the same
  configuration options as used in the "Danger Mouse" example in the
  HOWTO with the correct permissions (600).

10 months agodoc: python bindings howto
Ben McGinnes [Sat, 24 Mar 2018 23:01:14 +0000 (10:01 +1100)]
doc: python bindings howto

* Fixed the plaintext, result and verify_result references in the
  decryption section.

10 months agoMerge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme
Ben McGinnes [Sat, 24 Mar 2018 22:44:51 +0000 (09:44 +1100)]
Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme

11 months agodoc: python bindings howto
Ben McGinnes [Fri, 23 Mar 2018 19:41:36 +0000 (06:41 +1100)]
doc: python bindings howto

* Fixed a minor spelling error and a minor grammatical error.

11 months agocore: Need to increase an array in the gpg engine.
Werner Koch [Fri, 23 Mar 2018 14:46:18 +0000 (15:46 +0100)]
core: Need to increase an array in the gpg engine.

* src/engine-gpg.c (build_argv): Allcate one slot more for ARGV.
--

Fixes-commit: b9000bc293164ff62efa7e91e5cf6d5fc19d482f

11 months agojson: Use a request origin of "browser".
Werner Koch [Fri, 23 Mar 2018 14:32:06 +0000 (15:32 +0100)]
json: Use a request origin of "browser".

* src/gpgme-json.c (_create_new_context): Set flag.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agocore: New gpgme_set_ctx_flag "request-origin".
Werner Koch [Fri, 23 Mar 2018 14:27:32 +0000 (15:27 +0100)]
core: New gpgme_set_ctx_flag "request-origin".

* src/context.h (gpgme_context): Add 'request_origin'.
* src/gpgme.c (gpgme_release): Free that field.
(gpgme_set_ctx_flag, gpgme_get_ctx_flag): Add "request-origin".
* src/engine-backend.h (engine_ops): Add 'set_engine_ops' func ptr and
adjust all users.
* src/engine.c (_gpgme_engine_set_engine_flags): New.
* src/op-support.c (_gpgme_op_reset): Call that func.
* src/engine-gpg.c (struct engine_gpg): Add 'request_origin'.
(gpg_set_engine_flags): New.
(_gpgme_engine_ops_gpg): Hook it.
(build_argv): Use command line option --request-origin.
* src/engine-gpgsm.c (struct engine_gpgsm): Add 'request_origin'.
(gpgsm_set_engine_flags): New.
(_gpgme_engine_ops_gpgsm): Hook it.
(start): Send OPTION "request-origin".
* src/engine-assuan.c (struct engine_llass): Add 'request_origin'.
(gpgsm_set_engine_flags): New.
(_gpgme_engine_ops_assuan): Hook it.
(start): Send OPTION "pretend-request-origin".

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agobuild: Allow building with released libgpg-error.
Werner Koch [Fri, 23 Mar 2018 11:36:19 +0000 (12:36 +0100)]
build: Allow building with released libgpg-error.

* src/gpgme-json.c (add_base64_to_object): Return an error if building
with an older libgpg-error.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agoMerge branch 'json-tool'
Werner Koch [Fri, 23 Mar 2018 10:31:20 +0000 (11:31 +0100)]
Merge branch 'json-tool'

11 months agojson: Finish op:encrypt.
Werner Koch [Fri, 23 Mar 2018 10:27:59 +0000 (11:27 +0100)]
json: Finish op:encrypt.

* src/gpgme-json.c (add_base64_to_object): New.
(data_from_base64_string): New.
(op_encrypt): Employ them.
(process_request): Print unformated json.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agojson: Add a new function to cJSON.
Werner Koch [Fri, 23 Mar 2018 10:26:36 +0000 (11:26 +0100)]
json: Add a new function to cJSON.

* src/cJSON.c (cJSON_CreateStringConvey): New.

11 months agodoc: python bindings howto
Ben McGinnes [Wed, 21 Mar 2018 23:06:53 +0000 (10:06 +1100)]
doc: python bindings howto

* Fixed table.

11 months agodoc and examples: python bindings HOWTO
Ben McGinnes [Wed, 21 Mar 2018 19:37:02 +0000 (06:37 +1100)]
doc and examples: python bindings HOWTO

* Added GPGME Python bindings HOWTO in Australian/British English.
** en-US "translation" still to be done.
* Added several example scripts comprised of the "Basic Functions"
  section of the HOWTO (plus the work-around at the end).
** As these scripts are very basic examples they are released under
   both the GPLv2+ and the LGPLv2.1+ (just like GPGME itself).

Signed-off-by: Ben McGinnes <ben@adversary.org>
11 months agoMerge branch 'ben/docs/2018-03' of ssh+git://playfair.gnupg.org/git/gpgme into ben...
Ben McGinnes [Wed, 21 Mar 2018 19:33:16 +0000 (06:33 +1100)]
Merge branch 'ben/docs/2018-03' of ssh+git://playfair.gnupg.org/git/gpgme into ben/docs/2018-03

11 months agoexamples: multi-key selection operations ben/docs/2018-03
Ben McGinnes [Wed, 21 Mar 2018 19:19:36 +0000 (06:19 +1100)]
examples: multi-key selection operations

* Temporarily removing multi-key selection based examples.
* There are a few issues with getting the key selections to play
  nicely with gpg.Context().keylist object types.
* Will troubleshoot them separately and restore them when that's
  worked out, but I don't want these more complicated examples to
  delay merging the HOWTO with master.

11 months agoexample: group encryption
Ben McGinnes [Wed, 21 Mar 2018 19:18:13 +0000 (06:18 +1100)]
example: group encryption

* Troubleshooting.

11 months agoexamples: encryption
Ben McGinnes [Wed, 21 Mar 2018 19:05:10 +0000 (06:05 +1100)]
examples: encryption

* Fixed two incorrect Context() objects.

11 months agoexample: key selection
Ben McGinnes [Wed, 21 Mar 2018 18:55:53 +0000 (05:55 +1100)]
example: key selection

* Removed extraneous blank line.

11 months agoexample: key selection
Ben McGinnes [Wed, 21 Mar 2018 18:52:55 +0000 (05:52 +1100)]
example: key selection

* Similar to group-key-selection.py, but does not use an existing
  group from gpg.conf; instead takes multiple key IDs, fingerprints or
  patterns on the command line and adds them to a keylist object.

11 months agoexample: sign and encrypt to group
Ben McGinnes [Wed, 21 Mar 2018 18:40:02 +0000 (05:40 +1100)]
example: sign and encrypt to group

* Begins to string together some of the simpler examples to do more
  useful things.
* Signs and encrypts a file while encrypting to every key in a group
  specified in the gpg.conf file.

11 months agojson: Use gpgrt_argparse instead of argsparse.c
Werner Koch [Wed, 21 Mar 2018 18:26:03 +0000 (19:26 +0100)]
json: Use gpgrt_argparse instead of argsparse.c

* src/gpgme-json.c: Remove header argparse.h.  Define
GPGRT_ENABLE_ARGPARSE_MACROS.
(interactive_repl): Replace strusage by gpgrt_strusage.
(my_strusage): Add SPDX level.
(main): Switch to gpgrt_argparse stuff but keep very limited
functionality when building with an older libgpg-error.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agoexample: group key selection
Ben McGinnes [Wed, 21 Mar 2018 18:20:51 +0000 (05:20 +1100)]
example: group key selection

* Example of preparing a keylist object using an existing group line
  from the gpg.conf file.

11 months agoexample groups work around
Ben McGinnes [Wed, 21 Mar 2018 18:07:56 +0000 (05:07 +1100)]
example groups work around

* Updated usage so it only references importing the final list of
  lists produced.  Trying to use some of the mid-points can have
  unpredictable results (this is part of the problem with work
  arounds).

11 months agoexample: groups
Ben McGinnes [Wed, 21 Mar 2018 17:04:05 +0000 (04:04 +1100)]
example: groups

* Added a docstring.

11 months agoexample: verify signatures
Ben McGinnes [Wed, 21 Mar 2018 16:58:58 +0000 (03:58 +1100)]
example: verify signatures

* Added example for verifying detached signatures against the files
  they're the signatures for.

11 months agoexample: verify signed file
Ben McGinnes [Wed, 21 Mar 2018 14:50:08 +0000 (01:50 +1100)]
example: verify signed file

* Added example to verify normal and clearsigned files.

11 months agodoc: python bindings howto
Ben McGinnes [Wed, 21 Mar 2018 14:48:41 +0000 (01:48 +1100)]
doc: python bindings howto

* Fixed minor error in one of the verification examples.

11 months agoexample: detach sign file
Ben McGinnes [Wed, 21 Mar 2018 14:30:32 +0000 (01:30 +1100)]
example: detach sign file

* Added example to make detached signatures of a file with key selection.

11 months agoexample: encrypt-sign-file.py
Ben McGinnes [Wed, 21 Mar 2018 14:26:43 +0000 (01:26 +1100)]
example: encrypt-sign-file.py

* Adjusted the doc string.

11 months agoexamples: doc strings
Ben McGinnes [Wed, 21 Mar 2018 14:24:52 +0000 (01:24 +1100)]
examples: doc strings

* Fixed minor errors in two doc strings.

11 months agoexample: clear signing
Ben McGinnes [Wed, 21 Mar 2018 14:18:37 +0000 (01:18 +1100)]
example: clear signing

* Added example to clear sign a file with signing key selection.

11 months agodoc: python bindings howto
Ben McGinnes [Wed, 21 Mar 2018 14:12:36 +0000 (01:12 +1100)]
doc: python bindings howto

* deconstructed and fixed all three signing methods.

11 months agoexample: sign file
Ben McGinnes [Wed, 21 Mar 2018 01:28:03 +0000 (12:28 +1100)]
example: sign file

* Similar to encrypt file except for signing a file in normal mode.
* Noticed additional changes to be made to the howto to match this,
  but they will have to wait due to a power outage (currently running
  on battery and a mobile connection, but that won't last).

11 months agojson: Implement op:encrypt
Werner Koch [Tue, 20 Mar 2018 10:14:26 +0000 (11:14 +0100)]
json: Implement op:encrypt

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agoMerge branch 'master' into json-tool
Werner Koch [Tue, 20 Mar 2018 10:13:14 +0000 (11:13 +0100)]
Merge branch 'master' into json-tool

11 months agocore: Do not clobber R_KEY in gpgme_get_key on error.
Werner Koch [Tue, 20 Mar 2018 09:41:18 +0000 (10:41 +0100)]
core: Do not clobber R_KEY in gpgme_get_key on error.

* src/keylist.c (gpgme_get_key): Assign a value to the return
parameter only on success.
--

This problem could be triggered by an ambiguous key.  The problem is
that the key returned in that case is for one not expected and worse
it has not been ref-ed.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agocore: Fix ABI regression in recent commit.
Werner Koch [Tue, 20 Mar 2018 09:34:56 +0000 (10:34 +0100)]
core: Fix ABI regression in recent commit.

* src/gpgme.h.in (_gpgme_op_import_result): Move new field
'skipped_v3_keys' to the end.
--

The ABI break has not made it into a release.

Also document the new field.

Fixes-commit: a630a1e3e74c926163864b013cb164b4cd1866fc
Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agodoc: python bindings howto
Ben McGinnes [Tue, 20 Mar 2018 03:57:26 +0000 (14:57 +1100)]
doc: python bindings howto

* Fixed typos in examples.

11 months agoexample: keycount
Ben McGinnes [Tue, 20 Mar 2018 03:55:05 +0000 (14:55 +1100)]
example: keycount

* Fixed missing parenthesis.

11 months agoexample: decrypt file
Ben McGinnes [Tue, 20 Mar 2018 03:32:53 +0000 (14:32 +1100)]
example: decrypt file

* Decrypts a file taking file names as command line parameters.

11 months agoexample: groups work-around
Ben McGinnes [Tue, 20 Mar 2018 03:19:16 +0000 (14:19 +1100)]
example: groups work-around

* Added groups selection work around code.
* Intended for use as a module to be imported by other scripts,
  usually with "from groups import group_lists" or "from groups import
  group_lines" or similar.

11 months agoexample: encrypt file
Ben McGinnes [Mon, 19 Mar 2018 22:53:27 +0000 (09:53 +1100)]
example: encrypt file

* Nested encryption in try/except statement in case recipient key is
  untrusted or invalid.

11 months agoexample: sign and encrypt file
Ben McGinnes [Mon, 19 Mar 2018 22:47:39 +0000 (09:47 +1100)]
example: sign and encrypt file

* Example to sign and encrypt a file.
* Similar to encrypt-file.py except all keys are considered trusted
  and signs with the default key.
* Also encrypts to the default key.

11 months agoexample: encrypt file
Ben McGinnes [Mon, 19 Mar 2018 22:39:48 +0000 (09:39 +1100)]
example: encrypt file

* Fixed typo in second encryption call.

11 months agoexample: encrypt file
Ben McGinnes [Mon, 19 Mar 2018 22:25:34 +0000 (09:25 +1100)]
example: encrypt file

* Example to encrypt a file to a single key.
* Takes key ID and/or fpr as a CLI parameter.
* Takes path and filename as a CLI parameter.
* Encrypts to specified key only, no signing and writes the output in
  both ASCII armoured and GPG binary formats with output filenames
  based on input filename.

11 months agoexample: python bindings key count
Ben McGinnes [Mon, 19 Mar 2018 21:55:01 +0000 (08:55 +1100)]
example: python bindings key count

* Added script wo count the number of keys in both the public and
  secret key stores.

11 months agodoc: python bindings examples
Ben McGinnes [Mon, 19 Mar 2018 21:39:49 +0000 (08:39 +1100)]
doc: python bindings examples

* Explicitly stated that all this code is released under the GPLv2+
  and the LGPLv2.1+.

11 months agodoc: python bindings example README
Ben McGinnes [Mon, 19 Mar 2018 21:31:53 +0000 (08:31 +1100)]
doc: python bindings example README

* Added the same license as used with the HOWTO.
* Since these examples are so basic, they'll be dual licensed the same
  as GPGME itself (otherwise it would slip too dangerously against the
  need for permissive licensing of crypto libraries).

11 months agodocs: python bindings examples
Ben McGinnes [Mon, 19 Mar 2018 21:26:57 +0000 (08:26 +1100)]
docs: python bindings examples

* Added reference to location where all the examples included in the
  HOWTO will be available as executable scripts.
* Included a short README file in that location.

11 months agoexample: python bindings encryption
Ben McGinnes [Mon, 19 Mar 2018 21:07:22 +0000 (08:07 +1100)]
example: python bindings encryption

* Since we don't want to encourage accessing the low level functions
  (e.g. op_encrypt), but since this example can still be useful to
  understand, renaming it and will add new encryption examples to
  match the instructions in the HOWTO.

11 months agodoc: python bindings howto
Ben McGinnes [Mon, 19 Mar 2018 04:03:00 +0000 (15:03 +1100)]
doc: python bindings howto

* Slight python-gnupg clarification.  See also this thread:
  https://lists.gnupg.org/pipermail/gnupg-devel/2018-March/033528.html

11 months agodoc: python bindings howto
Ben McGinnes [Mon, 19 Mar 2018 02:09:46 +0000 (13:09 +1100)]
doc: python bindings howto

* Adjusted the python-gnupg so the comments regarding insecure
  invocation of commands via subprocess (shell=True) were a major
  historical issue and not a a current issue.
* Not including Vinay Sajip's requested change to say it is now secure
  since no audit of the current code base has been performed and my
  last major inspection of that code was around the time I first
  ported PyME to Python 3 in 2015.

11 months agodoc: python bindings todo list
Ben McGinnes [Mon, 19 Mar 2018 01:46:41 +0000 (12:46 +1100)]
doc: python bindings todo list

* Checked off several points of howto coverage as completed.
* Reorganised to move S/MIME coverage to its own separate group of tasks.
* Noted only revocation remains for howto completion.

11 months agodoc: python bindings howto
Ben McGinnes [Sun, 18 Mar 2018 23:39:53 +0000 (10:39 +1100)]
doc: python bindings howto

* deconstructing multi-recipient encryption.

11 months agodoc: python bindings howto
Ben McGinnes [Sun, 18 Mar 2018 23:00:44 +0000 (10:00 +1100)]
doc: python bindings howto

* Replaced the single encryption methods with one main way (i.e. cut
  the low level stuff involving SEEK_SET instructions).

11 months agodoc: python bindings howto
Ben McGinnes [Sun, 18 Mar 2018 21:49:17 +0000 (08:49 +1100)]
doc: python bindings howto

* moved single encrytion examples up to the first ones, pending merge
  and major cut.
* This is basically just to make future checks of revisions a little easier.

11 months agodoc: python bindings howto
Ben McGinnes [Sun, 18 Mar 2018 21:43:36 +0000 (08:43 +1100)]
doc: python bindings howto

* Stripped decryption example to the bare bones as suggested by Justus.

11 months agodoc: python bindings howto
Ben McGinnes [Fri, 16 Mar 2018 16:46:02 +0000 (03:46 +1100)]
doc: python bindings howto

* Made the changes suggested by Jakub Wilk on gnupg-devel.
* Still need to make the far more comprehensive changes suggested by Justus.

11 months agojson: Add framework for the gpgme-json tool
Werner Koch [Fri, 16 Mar 2018 12:55:48 +0000 (13:55 +0100)]
json: Add framework for the gpgme-json tool

* src/gpgme-json.c: New.
* src/Makefile.am (bin_PROGRAMS): Add gpgme-json.
(gpgme_json_SOURCES, gpgme_json_LDADD): New.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agocore: Adjust cJSON code for use in GPGME.
Werner Koch [Wed, 14 Mar 2018 10:24:38 +0000 (11:24 +0100)]
core: Adjust cJSON code for use in GPGME.

* src/cJSON.c: Remove util.h.  Use gpgrt alloc functions.
(cJSON_Delete): Do not clobber ERRNO.
(cJSON_AddItemToObject): Return OBJECT or NULL.
(cJSON_AddNullToObject): New.
(cJSON_AddTrueToObject): New.
(cJSON_AddFalseToObject): New.
(cJSON_AddBoolToObject): New.
(cJSON_AddNumberToObject): New.
(cJSON_AddStringToObject): New.
* src/cJSON.h (cJSON__h): Replace macro by cJSON_h for C compliance.
(cJSON_AddNullToObject): Remove macro.
(cJSON_AddTrueToObject): Remove macro.
(cJSON_AddFalseToObject): Remove macro.
(cJSON_AddBoolToObject): Remove macro.
(cJSON_AddNumberToObject): Remove macro.
(cJSON_AddStringToObject): Remove macro.
--

The gpgrt malloc functions are used so that we can easily mix memory
returned by gpgrt (e.g. es_read_line) with memory returned from the
JSON function.  In general that is not needed but on Windows it makes
a difference if the gpgme DLL is linked to a different C runtime
than the application.

The macros have been replaced to allow error checking (i.e out of
core) for these functions.  More error checking should be implemented
instead of silently creating objects which are not as requested.

Signed-off-by: Werner Koch <wk@gnupg.org>
11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 16:52:58 +0000 (03:52 +1100)]
doc: python bindings howto

* Added clarification on why it's not on PyPI.

11 months agocpp: Expose skipped_v3_keys
Andre Heinecke [Thu, 15 Mar 2018 15:21:00 +0000 (16:21 +0100)]
cpp: Expose skipped_v3_keys

* lang/cpp/src/importresult.cpp,
 lang/cpp/src/importresult.h (ImportResult::numV3KeysSkipped): New.

--
GnuPG-Bug-Id: T3776

11 months agocore: Parse skipped_v3_keys
Andre Heinecke [Thu, 15 Mar 2018 14:58:32 +0000 (15:58 +0100)]
core: Parse skipped_v3_keys

* src/gpgme.h.in (gpgme_import_result_t): Extend with skipped_v3_keys.
* src/import.c (gpgme_op_import_result): Extend debug with new field.
(parse_import_res): Parse skipped_v3_keys.
* tests/gpg/t-support.h, tests/run-support.h (print_import_result):
Print skipped_v3_keys.

--
This makes it possible to handle this in a GUI in a future
version.

GnuPG-Bug-Id: T3776

11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 14:48:56 +0000 (01:48 +1100)]
doc: python bindings howto

* fixed custom_id for decryption so the XHTML validates.

11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 14:34:22 +0000 (01:34 +1100)]
doc: python bindings howto

* Promoted final encryption example so that it will appear as heading
  6.1.3 when exported to HTML or PDF.

11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 05:13:34 +0000 (16:13 +1100)]
doc: python bindings howto

* Fixed a minor typographic error.
* Bumped version number in preparation for merge with master.
* While there are probably a few more things worthy of being added
  (mainly how to revoke things), this document is essentially ready
  for publication now.

Signed-off-by: Ben McGinnes <ben@adversary.org>
11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 04:51:01 +0000 (15:51 +1100)]
doc: python bindings howto

* Added key signing.

11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 04:16:23 +0000 (15:16 +1100)]
doc: python bindings howto

* Added a new user ID for Danger Mouse.
* Removed the empty entry for key preferences since that is handled
  through gpg.conf and/or editing the key directly.

11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 03:59:36 +0000 (14:59 +1100)]
doc: python bindings howto

* Spell checking and fixing the few errors.

11 months agodoc: python bindings howto
Ben McGinnes [Thu, 15 Mar 2018 03:43:44 +0000 (14:43 +1100)]
doc: python bindings howto

* Added an encryption subkey to Danger Mouse's primary key.