Commit Graph

2819 Commits

Author SHA1 Message Date
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
Ben McGinnes
f3fe47e8fd 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.
2018-03-20 09:47:39 +11:00
Ben McGinnes
f0790f224d example: encrypt file
* Fixed typo in second encryption call.
2018-03-20 09:39:48 +11:00
Ben McGinnes
7ab42e79ad 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.
2018-03-20 09:25:34 +11:00
Ben McGinnes
cfbdcb7fb3 example: python bindings key count
* Added script wo count the number of keys in both the public and
  secret key stores.
2018-03-20 08:55:01 +11:00
Ben McGinnes
b30ebf8972 doc: python bindings examples
* Explicitly stated that all this code is released under the GPLv2+
  and the LGPLv2.1+.
2018-03-20 08:39:49 +11:00
Ben McGinnes
8f7672ad1b 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).
2018-03-20 08:31:53 +11:00
Ben McGinnes
6950a63e63 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.
2018-03-20 08:26:57 +11:00
Ben McGinnes
3e0f68fdff 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.
2018-03-20 08:07:22 +11:00
Ben McGinnes
d5f6dec048 doc: python bindings howto
* Slight python-gnupg clarification.  See also this thread:
  https://lists.gnupg.org/pipermail/gnupg-devel/2018-March/033528.html
2018-03-19 15:03:00 +11:00
Ben McGinnes
0fb8a5d45c 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.
2018-03-19 13:09:46 +11:00
Ben McGinnes
bf67cf433f 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.
2018-03-19 12:46:41 +11:00
Ben McGinnes
1779d7b9d6 doc: python bindings howto
* deconstructing multi-recipient encryption.
2018-03-19 10:39:53 +11:00
Ben McGinnes
64c5886132 doc: python bindings howto
* Replaced the single encryption methods with one main way (i.e. cut
  the low level stuff involving SEEK_SET instructions).
2018-03-19 10:00:44 +11:00
Ben McGinnes
4811ff7b6c 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.
2018-03-19 08:49:17 +11:00
Ben McGinnes
82c5af225f doc: python bindings howto
* Stripped decryption example to the bare bones as suggested by Justus.
2018-03-19 08:43:36 +11:00
Ben McGinnes
b549f69d05 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.
2018-03-17 03:46:02 +11:00
Werner Koch
d2b31d8c10
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>
2018-03-16 13:55:48 +01:00
Werner Koch
81c90d0cd0
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>
2018-03-16 13:36:04 +01:00
Ben McGinnes
431897a4c4 doc: python bindings howto
* Added clarification on why it's not on PyPI.
2018-03-16 03:52:58 +11:00
Andre Heinecke
ad95288d3b
cpp: Expose skipped_v3_keys
* lang/cpp/src/importresult.cpp,
 lang/cpp/src/importresult.h (ImportResult::numV3KeysSkipped): New.

--
GnuPG-Bug-Id: T3776
2018-03-15 16:23:18 +01:00
Andre Heinecke
a630a1e3e7
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
2018-03-15 16:23:18 +01:00
Ben McGinnes
22e2445bee doc: python bindings howto
* fixed custom_id for decryption so the XHTML validates.
2018-03-16 01:48:56 +11:00
Ben McGinnes
94a95ac123 doc: python bindings howto
* Promoted final encryption example so that it will appear as heading
  6.1.3 when exported to HTML or PDF.
2018-03-16 01:34:22 +11:00
Ben McGinnes
3d0c7a2202 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>
2018-03-15 16:13:34 +11:00
Ben McGinnes
961aea212e doc: python bindings howto
* Added key signing.
2018-03-15 15:51:01 +11:00
Ben McGinnes
7ac65b1083 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.
2018-03-15 15:16:23 +11:00
Ben McGinnes
9e3e4a835c doc: python bindings howto
* Spell checking and fixing the few errors.
2018-03-15 14:59:36 +11:00
Ben McGinnes
b02d9d0a7b doc: python bindings howto
* Added an encryption subkey to Danger Mouse's primary key.
2018-03-15 14:43:44 +11:00
Ben McGinnes
5432e5f9d1 doc: python bindings howto
* generated a new primary key for Danger Mouse in an alternative homedir.
2018-03-15 14:01:30 +11:00
Ben McGinnes
5d1dd2abe5 doc: python bindings howto
* Added sections for key generation and key editing.
2018-03-15 12:27:45 +11:00
Ben McGinnes
1d05e6aa4e doc: python bindings howto
* Added c.get_key instructions and examples.
2018-03-15 12:14:29 +11:00
Ben McGinnes
b35aaef7a3 doc: python bindings howto
* Added text for verifying signatures.
2018-03-15 11:18:02 +11:00
Ben McGinnes
6bc12a0eeb doc: python bindings howto
* Added 4 signature verification methods and partial text for them.
2018-03-15 07:20:31 +11:00
Ben McGinnes
e5c85fba25 doc: python bindings howto
* Added description for detached signatures.
2018-03-15 04:07:57 +11:00
Ben McGinnes
ada059b071 doc: python bindings howto
* Fixed multiple sample code examples of writing output to a file.
* Added the description of detached signatures.
2018-03-15 03:51:51 +11:00
Werner Koch
8eb08b3189
core: Import cJSON code from the payproc project.
* src/cJSON.c: New.
* src/cJSON.h: New.
* src/cJSON.readme: New.
--

This is a copy of the code from the payproc commit
af5d6b4f820ee19e246a2cab6f56465fe91f1233.  The code was originally
added to payproc with the commit below.

Signed-off-by: Werner Koch <wk@gnupg.org>

===============================================
commit 7ae7ef29bc5ec19e005e6a5a739233d655f3f05f
Author:     Werner Koch <wk@gnupg.org>
AuthorDate: Wed Apr 2 09:01:42 2014 +0200
Commit:     Werner Koch <wk@gnupg.org>
CommitDate: Wed Apr 2 09:12:02 2014 +0200

Simplify cJSON and add new macros.

* src/cJSON.h: Re-indented.
(cjson_t): New.
(cjson_is_): New macros.
* src/cJSON.c: Re-indented.  Include errno.h and our util.h.
(ep): Remove global var.
(cJSON_GetErrorPtr): Remove.
(cJSON_strcasecmp): Cast args for use with tolower.
(cJSON_malloc, cJSON_free): Remove.  Change callers to use xtrymalloc
and xfree.
(cJSON_InitHooks): Remove.
(cJSON_strdup): Remove.  Change callers to use xtrystrdup.
(cJSON_New_Item): Simplify.
(cJSON_ParseWithOpts, cJSON_Parse): Add arg R_ERROFF.
(parse_string, parse_value, parse_array, parse_object): Add arg EP.
--

cJSON has been taken from cjson-code-58.zip.  The README file has been
renamed to cJSON.readme and the files have been changed to GNU coding
standards.  Because that parser is small enough to be source copied it
does not make sense to treat it as a library and I changed the memory
allocation functions to the usual xmalloc ones. The only external
dependency now is out util.h which declares those functions.

The lowercase cjson_t better fits into our coding style as well as the
new macros.  Thanks to Dave Gamble for this nice parser.
===============================================
2018-03-14 11:10:12 +01:00
Ben McGinnes
ef27f3781a doc: python bindings todo
* minor phrasing fix.
2018-03-14 20:40:50 +11:00
Ben McGinnes
423fdcd465 doc: python bindings howto
* Added recommended method of single encryption with description.
2018-03-14 20:36:30 +11:00
Ben McGinnes
a71205dc3b doc: python binding howto
* Clarified which English dialects this is written in.
* Translating to American can happen *after* it's done.
** The Yank version would probably want to change some of the examples
   anyway.
* Began the description for normal/default signing.
2018-03-14 02:40:41 +11:00
Ben McGinnes
a10dcb4f13 doc: python bindings howto
* Added a section on key selection.
* Included recommendation for using fingerprint when selecting one
  specific key.
* Also included the most ironically amusing example of multiple key
  selection in a GPG guide.  Hey, it's public data ... (heh).
2018-03-14 02:21:44 +11:00
Ben McGinnes
952b6042f7 doc: python bindings howto
* Added explanation of the ascendance of Python 3 over Python 2 in the
  guide to the intro.
* Expanded key selection description so people know what not to
  include regarding key IDs with this key selection method.
2018-03-14 01:41:21 +11:00
Ben McGinnes
c92da2c7eb doc: python bindings howto
* Added key selection for specifying signing key or keys.
2018-03-13 19:20:44 +11:00