Commit Graph

3461 Commits

Author SHA1 Message Date
Werner Koch
4b2fa657d1
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>
2018-03-28 20:53:21 +02:00
Andre Heinecke
7c220e387d
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.
2018-03-27 11:24:55 +02:00
Ben McGinnes
a2eedef630 doc: python bindings howto
* Fixed some minor PEP8 compliance issues in the key creation examples.
2018-03-27 12:42:06 +11:00
Ben McGinnes
f9159b1d75 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.
2018-03-27 12:29:08 +11:00
Ben McGinnes
1b5da37a47 script: temp homedir config
* added passphrase caching of 5 minutes.
2018-03-27 12:16:29 +11:00
Ben McGinnes
5b32efbaf3 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.
2018-03-25 22:25:52 +11:00
Ben McGinnes
40a9dea5d5 script: temp homedir
* Fixed whitespace.
2018-03-25 11:54:05 +11:00
Ben McGinnes
3b724aae42 doc: python bindings howto
* Added a reference to new script which will setup a temporary homedir
  for a user.
2018-03-25 11:35:11 +11:00
Ben McGinnes
dde1aae312 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).
2018-03-25 11:26:26 +11:00
Ben McGinnes
22247f658c doc: python bindings howto
* Fixed the plaintext, result and verify_result references in the
  decryption section.
2018-03-25 10:01:14 +11:00
Ben McGinnes
d0bb4ec4ec Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme 2018-03-25 09:44:51 +11:00
Ben McGinnes
e6180f2b36 doc: python bindings howto
* Fixed a minor spelling error and a minor grammatical error.
2018-03-24 06:41:36 +11:00
Werner Koch
4763974ef6
core: Need to increase an array in the gpg engine.
* src/engine-gpg.c (build_argv): Allcate one slot more for ARGV.
--

Fixes-commit: b9000bc293
2018-03-23 15:46:18 +01:00
Werner Koch
e5abf4827a
json: Use a request origin of "browser".
* src/gpgme-json.c (_create_new_context): Set flag.

Signed-off-by: Werner Koch <wk@gnupg.org>
2018-03-23 15:32:06 +01:00
Werner Koch
b9000bc293
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>
2018-03-23 15:27:32 +01:00
Werner Koch
eee68c1b13
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>
2018-03-23 12:36:19 +01:00
Werner Koch
c7bb12da52
Merge branch 'json-tool' 2018-03-23 11:31:20 +01:00
Werner Koch
d83482a1d7
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>
2018-03-23 11:27:59 +01:00
Werner Koch
6525d78d0a
json: Add a new function to cJSON.
* src/cJSON.c (cJSON_CreateStringConvey): New.
2018-03-23 11:26:36 +01:00
Ben McGinnes
65ed4ac825 doc: python bindings howto
* Fixed table.
2018-03-22 10:06:53 +11:00
Ben McGinnes
5722148bac 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>
2018-03-22 06:37:02 +11:00
Ben McGinnes
76055dd5c7 Merge branch 'ben/docs/2018-03' of ssh+git://playfair.gnupg.org/git/gpgme into ben/docs/2018-03 2018-03-22 06:33:16 +11:00
Ben McGinnes
05e5993305 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.
2018-03-22 06:19:36 +11:00
Ben McGinnes
61a988036b example: group encryption
* Troubleshooting.
2018-03-22 06:18:13 +11:00
Ben McGinnes
7ddff71908 examples: encryption
* Fixed two incorrect Context() objects.
2018-03-22 06:05:10 +11:00
Ben McGinnes
c6a0395f0a example: key selection
* Removed extraneous blank line.
2018-03-22 05:55:53 +11:00
Ben McGinnes
0a0d57fd41 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.
2018-03-22 05:52:55 +11:00
Ben McGinnes
0ccc57c951 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.
2018-03-22 05:40:02 +11:00
Werner Koch
e14f1f687f
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>
2018-03-21 19:26:03 +01:00
Ben McGinnes
8b401bfc76 example: group key selection
* Example of preparing a keylist object using an existing group line
  from the gpg.conf file.
2018-03-22 05:20:51 +11:00
Ben McGinnes
6c6af9a7b0 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).
2018-03-22 05:07:56 +11:00
Ben McGinnes
a4e3f82765 example: groups
* Added a docstring.
2018-03-22 04:04:05 +11:00
Ben McGinnes
ad6cb4f9b8 example: verify signatures
* Added example for verifying detached signatures against the files
  they're the signatures for.
2018-03-22 03:58:58 +11:00
Ben McGinnes
ae2767eb27 example: verify signed file
* Added example to verify normal and clearsigned files.
2018-03-22 01:50:08 +11:00
Ben McGinnes
e57388a69f doc: python bindings howto
* Fixed minor error in one of the verification examples.
2018-03-22 01:48:41 +11:00
Ben McGinnes
ac6a552c37 example: detach sign file
* Added example to make detached signatures of a file with key selection.
2018-03-22 01:30:32 +11:00
Ben McGinnes
af6cbba18b example: encrypt-sign-file.py
* Adjusted the doc string.
2018-03-22 01:26:43 +11:00
Ben McGinnes
6fa2a34428 examples: doc strings
* Fixed minor errors in two doc strings.
2018-03-22 01:24:52 +11:00
Ben McGinnes
1fdd1f306d example: clear signing
* Added example to clear sign a file with signing key selection.
2018-03-22 01:18:37 +11:00
Ben McGinnes
1d2746433c doc: python bindings howto
* deconstructed and fixed all three signing methods.
2018-03-22 01:12:36 +11:00
Ben McGinnes
0390ede186 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).
2018-03-21 12:28:03 +11:00
Werner Koch
6073789a6d
json: Implement op:encrypt
Signed-off-by: Werner Koch <wk@gnupg.org>
2018-03-20 11:14:26 +01:00
Werner Koch
44f9e80ea9
Merge branch 'master' into json-tool 2018-03-20 11:13:14 +01:00
Werner Koch
343d3e2232
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>
2018-03-20 10:41:18 +01:00
Werner Koch
9e1e655483
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: a630a1e3e7
Signed-off-by: Werner Koch <wk@gnupg.org>
2018-03-20 10:38:36 +01:00
Ben McGinnes
52e262991f doc: python bindings howto
* Fixed typos in examples.
2018-03-20 14:57:26 +11:00
Ben McGinnes
96d0395bcc example: keycount
* Fixed missing parenthesis.
2018-03-20 14:55:05 +11:00
Ben McGinnes
51258975d7 example: decrypt file
* Decrypts a file taking file names as command line parameters.
2018-03-20 14:32:53 +11:00
Ben McGinnes
29e918171f 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.
2018-03-20 14:19:16 +11:00
Ben McGinnes
7221bb6764 example: encrypt file
* Nested encryption in try/except statement in case recipient key is
  untrusted or invalid.
2018-03-20 09:53:27 +11:00