[git] GPGME - branch, ben/docs/2018-03, updated. gpgme-1.10.0-65-gf685cda

by Ben McGinnes cvs at cvs.gnupg.org
Thu Mar 8 23:33:26 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, ben/docs/2018-03 has been updated
       via  f685cda281c6148072e8a6cd139c990cb041ea3d (commit)
       via  e846c3daeeb4e7092169cdb7bf4f55e0b105aac3 (commit)
       via  6849924ffbd48ba3f9d32b4a59a02e1d2083fc19 (commit)
       via  fa4927146b68dd045903285f1c45fb64deb2e361 (commit)
       via  c767a4a3590bd8a224d0268746df443942cb28c2 (commit)
       via  75463d589522cba427f9e5a3a408192ffad8bb21 (commit)
      from  a98f2c556fe6e33a9cd38279e64e4b09f05cc675 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f685cda281c6148072e8a6cd139c990cb041ea3d
Merge: fa49271 e846c3d
Author: Ben McGinnes <ben at adversary.org>
Date:   Fri Mar 9 09:31:44 2018 +1100

    Merge branch 'master' of ssh+git://playfair.gnupg.org/git/gpgme into ben/docs/2018-03
    
    * Fixed conflicts with TODO.

diff --cc TODO
index a431651,5f03fb6..a915ed7
--- a/TODO
+++ b/TODO
@@@ -1,5 -1,38 +1,61 @@@
+ #+TITLE: TODO List
  Hey Emacs, this is -*- org -*- mode!
  
+ * IMPORTANT!
+   :PROPERTIES:
+   :CUSTOM_ID: dev-gnupg-org
+   :END:
+ 
+   There was a nine year gap (2009 to 2018) between edits of this file,
+   so it is likely that much of the old information in it is wrong or
+   no longer applicable.
+ 
+   Bugs, feature requests and other development related work will be
+   tracked through the [[https://dev.gnupg.org/][dev.gnupg.org]] site.
+ 
+ 
 -* TODO Document all the new stuff.
++* Documentation
+   :PROPERTIES:
 -  :CUSTOM_ID: more-docs-is-better
++  :CUSTOM_ID: documentation
+   :END:
+ 
 -** STARTED Fix this TODO list.
++** Document all the new stuff.
+    :PROPERTIES:
 -   :CUSTOM_ID: fix-todo
++   :CUSTOM_ID: more-docs-is-better
+    :END:
 -   - State "STARTED"    from "TODO"       [2018-03-09 Fri 08:31]
 -   Clean up the current TODO list.  Include properties as relevant (so
 -   if someone does make a PDF or HTML version the TOC will work).
+ 
 -   Also check ans see if some of these ancient things can be removed
 -   (e.g. do we really need to fix things that were broken in GPG
 -   1.3.x?  I'm thinking not so much).
++*** TODO Fix this TODO list.
++    :PROPERTIES:
++    :CUSTOM_ID: fix-todo
++    :END:
++
++    Clean up the current TODO list.  Include properties as relevant (so
++    if someone does make a PDF or HTML version the TOC will work).
++
++    Also check ans see if some of these ancient things can be removed
++    (e.g. do we really need to fix things that were broken in GPG
++    1.3.x?  I'm thinking not so much).
++
++**** DONE fix TODO items
++     CLOSED: [2018-03-04 Sun 08:55]
++     :PROPERTIES:
++     :CUSTOM_ID: fix-todo-items
++     :END:
++
++     Adjust todo items so each can now be referenced by custom-id and
++     checked off as necessary.
+ 
++** TODO Document validity and trust issues.
++   :PROPERTIES:
++   :CUSTOM_ID: valid-trust-issues
++   :END:
++
++** In gpgme.texi: Register callbacks under the right letter in the index.
++   :PROPERTIES:
++   :CUSTOM_ID: gpgme-texi
++   :END:
+ 
+ 
  * Fix the remaining UI Server problems:
    :PROPERTIES:
    :CUSTOM_ID: ui-server-fix
@@@ -30,109 -63,112 +86,137 @@@
     :END:
     Right now we block reading the next line with assuan.
  
++
  * Before release:
    :PROPERTIES:
    :CUSTOM_ID: pre-release
    :END:
- ** Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
++
+ ** CANCELLED Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
+    CLOSED: [2018-03-09 Fri 08:16]
     :PROPERTIES:
     :CUSTOM_ID: gpg-1-3-4-really
     :END:
+    - State "CANCELLED"  from "TODO"       [2018-03-09 Fri 08:16] \\
+      WON'T FIX — too old or no longer applies.
     The test is currently disabled there and in gpg/t-import.
++
  ** When gpg supports it, write binary subpackets directly,
     :PROPERTIES:
     :CUSTOM_ID: binary-subpackets
     :END:
     and parse SUBPACKET status lines.
  
++
  * ABI's to break:
    :PROPERTIES:
    :CUSTOM_ID: abi-breakage-apparently-on-purpose
    :END:
++
  ** Old opassuan interface.
     :PROPERTIES:
     :CUSTOM_ID: old-opassuan
     :END:
++
  ** Implementation: Remove support for old style error codes in
     :PROPERTIES:
     :CUSTOM_ID: remove-old-error-codes
     :END:
     conversion.c::_gpgme_map_gnupg_error.
++
  ** gpgme_edit_cb_t: Add "processed" return argument
     :PROPERTIES:
     :CUSTOM_ID: add-processed-return
     :END:
     (see edit.c::command_handler).
++
  ** I/O and User Data could be made extensible.  But this can be done
     :PROPERTIES:
     :CUSTOM_ID: add-io-user-data
     :END:
     without breaking the ABI hopefully.
++
  ** All enums should be replaced by ints and simple macros for
     :PROPERTIES:
     :CUSTOM_ID: enums-should-be-ints
     :END:
     maximum compatibility.
++
  ** Compatibility interfaces that can be removed in future versions:
     :PROPERTIES:
     :CUSTOM_ID: compat-interfaces-to-go
     :END:
++
  *** gpgme_data_new_from_filepart
      :PROPERTIES:
      :CUSTOM_ID: gpgme-data-new-from-filepart
      :END:
++
  *** gpgme_data_new_from_file
      :PROPERTIES:
      :CUSTOM_ID: gpgme-data-new-from-file
      :END:
++
  *** gpgme_data_new_with_read_cb
      :PROPERTIES:
      :CUSTOM_ID: gpgme-data-new-with-read-cb
      :END:
++
  *** gpgme_data_rewind
      :PROPERTIES:
      :CUSTOM_ID: gpgme-data-rewind
      :END:
++
  *** gpgme_op_import_ext
      :PROPERTIES:
      :CUSTOM_ID: gpgme-op-import-ext
      :END:
++
  *** gpgme_get_sig_key
      :PROPERTIES:
      :CUSTOM_ID: gpgme-get-sig-key
      :END:
++
  *** gpgme_get_sig_ulong_attr
      :PROPERTIES:
      :CUSTOM_ID: gpgme-get-sig-ulong-attr
      :END:
++
  *** gpgme_get_sig_string_attr
      :PROPERTIES:
      :CUSTOM_ID: gpgme-get-sig-string-attr
      :END:
++
  *** GPGME_SIG_STAT_*
      :PROPERTIES:
      :CUSTOM_ID: gpgme-sig-stat
      :END:
++
  *** gpgme_get_sig_status
      :PROPERTIES:
      :CUSTOM_ID: gpgme-get-sig-status
      :END:
++
  *** gpgme_trust_item_release
      :PROPERTIES:
      :CUSTOM_ID: gpgme-trust-item-release
      :END:
++
  *** gpgme_trust_item_get_string_attr
      :PROPERTIES:
      :CUSTOM_ID: gpgme-trust-item-get-string-attr
      :END:
++
  *** gpgme_trust_item_get_ulong_attr
      :PROPERTIES:
      :CUSTOM_ID: gpgme-trust-item-get-ulong-attr
      :END:
++
  *** gpgme_attr_t
      :PROPERTIES:
      :CUSTOM_ID: gpgme-attr-t
      :END:
++
  *** All Gpgme* typedefs.
      :PROPERTIES:
      :CUSTOM_ID: all-gpgme-typedefs
@@@ -143,20 -179,20 +227,24 @@@
    :PROPERTIES:
    :CUSTOM_ID: threads
    :END:
++
  ** When GNU Pth supports sendmsg/recvmsg, wrap them properly.
     :PROPERTIES:
     :CUSTOM_ID: wrap-oth
     :END:
++
  ** Without timegm (3) support our ISO time parser is not thread safe.
     :PROPERTIES:
     :CUSTOM_ID: time-threads
     :END:
     There is a configure time warning, though.
  
++
  * New features:
    :PROPERTIES:
    :CUSTOM_ID: new-features
    :END:
++
  ** Flow control for data objects.
     :PROPERTIES:
     :CUSTOM_ID: flow-control-is-not-a-euphemism-for-an-s-bend
@@@ -169,11 -205,11 +257,13 @@@
     respective event loop.  or (B) a way for gpgme data objects to be
     associated with a waitable object, that can be registered with the
     user event loop.  Neither is particularly simple.
++
  ** Extended notation support.  When gpg supports arbitrary binary
     :PROPERTIES:
     :CUSTOM_ID: extended-notation
     :END:
     notation data, provide a user interface for that.
++
  ** notification system
     :PROPERTIES:
     :CUSTOM_ID: notification-system
@@@ -200,25 -236,25 +290,30 @@@
     :PROPERTIES:
     :CUSTOM_ID: stat-data
     :END:
++
  ** Implement support for photo ids.
     :PROPERTIES:
     :CUSTOM_ID: photo-id
     :END:
++
  ** Allow selection of subkeys
     :PROPERTIES:
     :CUSTOM_ID: subkey-selection
     :END:
++
  ** Allow to return time stamps in ISO format
     :PROPERTIES:
     :CUSTOM_ID: iso-format-datetime
     :END:
--  This allows us to handle years later than 2037 properly.  With the
--  time_t interface they are all mapped to 2037-12-31
++   This allows us to handle years later than 2037 properly.  With the
++   time_t interface they are all mapped to 2037-12-31
++
  ** New features requested by our dear users, but rejected or left for
     :PROPERTIES:
     :CUSTOM_ID: feature-requests
     :END:
     later consideration:
++
  *** Allow to export secret keys.
      :PROPERTIES:
      :CUSTOM_ID: export-secret-keys
@@@ -226,6 -262,6 +321,7 @@@
      Rejected because this is conceptually flawed.  Secret keys on a
      smart card can not be exported, for example.
      May eventually e supproted with a keywrapping system.
++
  *** Selecting the key ring, setting the version or comment in output.
      :PROPERTIES:
      :CUSTOM_ID: select-keyring-version
@@@ -233,61 -269,46 +329,23 @@@
      Rejected because the naive implementation is engine specific, the
      configuration is part of the engine's configuration or readily
      worked around in a different way
++
  *** Selecting the symmetric cipher.
      :PROPERTIES:
      :CUSTOM_ID: symmetric-cipher-selection
      :END:
++
  *** Exchanging keys with key servers.
      :PROPERTIES:
      :CUSTOM_ID: key-server-exchange
      :END:
  
  
--* Documentation
--  :PROPERTIES:
--  :CUSTOM_ID: documentation
--  :END:
- 
--** TODO Document validity and trust issues.
--   :PROPERTIES:
--   :CUSTOM_ID: valid-trust-issues
--   :END:
- 
--** In gpgme.texi: Register callbacks under the right letter in the index.
--   :PROPERTIES:
--   :CUSTOM_ID: gpgme-texi
--   :END:
- 
- ** Document all the new stuff.
 -** TODO Update TODO file
--   :PROPERTIES:
-    :CUSTOM_ID: more-docs-is-better
 -   :CUSTOM_ID: todo-update
--   :END:
--
- *** TODO Fix this TODO list.
 -*** DONE fix TODO items
 -    CLOSED: [2018-03-04 Sun 08:55]
--    :PROPERTIES:
-     :CUSTOM_ID: fix-todo
 -    :CUSTOM_ID: fix-todo-items
--    :END:
- 
-     Clean up the current TODO list.  Include properties as relevant (so
-     if someone does make a PDF or HTML version the TOC will work).
- 
-     Also check ans see if some of these ancient things can be removed
-     (e.g. do we really need to fix things that were broken in GPG
-     1.3.x?  I'm thinking not so much).
- 
- **** DONE fix TODO items
-      CLOSED: [2018-03-04 Sun 08:55]
-      :PROPERTIES:
-      :CUSTOM_ID: fix-todo-items
-      :END:
--
-      Adjust todo items so each can now be referenced by custom-id and
-      checked off as necessary.
 -    Adjust todo items so each can now be referenced by custom-id and
 -    checked off as necessary.
--
  * Engines
    :PROPERTIES:
    :CUSTOM_ID: engines
    :END:
++
  ** Do not create/destroy engines, but create engine and then reset it.
     :PROPERTIES:
     :CUSTOM_ID: reset-engine-is-not-quite-just-ignition
@@@ -300,26 -321,26 +358,31 @@@
     Note that we need support in gpgsm to set include-certs to default
     as RESET does not reset it, also for no_encrypt_to and probably
     other options.
++
  ** Optimize the case where a data object has an underlying fd we can pass
     :PROPERTIES:
     :CUSTOM_ID: optimus-data-cousin-of-optimus-prime
     :END:
     directly to the engine.  This will be automatic with socket I/O and
     descriptor passing.
++
  ** Move code common to all engines up from gpg to engine.
     :PROPERTIES:
     :CUSTOM_ID: move-code-common-to-engines-out-of-gpg
     :END:
++
  ** engine operations can return General Error on unknown protocol
     :PROPERTIES:
     :CUSTOM_ID: general-error-looking-to-be-court-martialled
     :END:
     (it's an internal error, as select_protocol checks already).
++
  ** When server mode is implemented properly, more care has to be taken to
     :PROPERTIES:
     :CUSTOM_ID: server-mode
     :END:
     release all resources on error (for example to free assuan_cmd).
++
  ** op_import_keys and op_export_keys have a limit in the number of keys.
     :PROPERTIES:
     :CUSTOM_ID: import-export-problems
@@@ -333,11 -354,15 +396,17 @@@
    :PROPERTIES:
    :CUSTOM_ID: gpg-breakage
    :END:
- ** gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key.
++
+ ** CANCELLED gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key.
+    CLOSED: [2018-03-09 Fri 08:19]
     :PROPERTIES:
     :CUSTOM_ID: gpg-classic-lacks-stuff
     :END:
- ** gpg 1.4.2 does crappy error reporting (namely none at all) when
+    - State "CANCELLED"  from "TODO"       [2018-03-09 Fri 08:19] \\
+      WON'T FIX.
++
+ ** CANCELLED gpg 1.4.2 does crappy error reporting (namely none at all) when
+    CLOSED: [2018-03-09 Fri 08:20]
     :PROPERTIES:
     :CUSTOM_ID: gpg-classic-problems-but-do-we-care
     :END:
@@@ -347,12 -374,16 +418,18 @@@
      gpg: signing failed: general error
      [GNUPG:] BEGIN_ENCRYPTION 2 10
      gpg: test: sign+encrypt failed: general error
- ** Without agent and with wrong passphrase, gpg 1.4.2 enters into an
++
+ ** DONE Without agent and with wrong passphrase, gpg 1.4.2 enters into an
+    CLOSED: [2018-03-09 Fri 08:20]
     :PROPERTIES:
     :CUSTOM_ID: recursive-gpg-classic
     :END:
+    - State "DONE"       from "TODO"       [2018-03-09 Fri 08:20] \\
+      Must have been fixed in a subsequent release.
     infinite loop.
- ** Use correct argv[0]
++
+ ** CANCELLED Use correct argv[0]
+    CLOSED: [2018-03-09 Fri 08:24]
     :PROPERTIES:
     :CUSTOM_ID: correct-argv
     :END:
@@@ -365,71 -402,71 +448,86 @@@
    :PROPERTIES:
    :CUSTOM_ID: operations-are-not-surgical
    :END:
++
  ** Include cert values -2, -1, 0 and 1 should be defined as macros.
     :PROPERTIES:
     :CUSTOM_ID: certified-macros
     :END:
++
  ** If an operation failed, make sure that the result functions don't return
     :PROPERTIES:
     :CUSTOM_ID: operation-failure
     :END:
     corrupt partial information. !!!
     NOTE: The EOF status handler is not called in this case !!!
++
  ** Verify must not fail on NODATA premature if auto-key-retrieval failed.
     :PROPERTIES:
     :CUSTOM_ID: autobot-key-retrieval
     :END:
     It should not fail silently if it knows there is an error. !!!
++
  ** All operations: Better error reporting. !!
     :PROPERTIES:
     :CUSTOM_ID: better-reporting-not-like-fox-news
     :END:
++
  ** Export status handler need much more work. !!!
     :PROPERTIES:
     :CUSTOM_ID: export-status-handler
     :END:
++
  ** Import should return a useful error when one happened.
     :PROPERTIES:
     :CUSTOM_ID: import-useful-stuff-even-wrong-stuff
     :END:
++
  *** Import does not take notice of NODATA status report.
      :PROPERTIES:
      :CUSTOM_ID: import-no-data
      :END:
++
  *** When GPGSM does issue IMPORT_OK status reports, make sure to check for
      :PROPERTIES:
      :CUSTOM_ID: gpgsm-import-ok
      :END:
      them in tests/gpgs m/t-import.c.
++
  ** Verify can include info about version/algo/class, but currently
     :PROPERTIES:
     :CUSTOM_ID: verify-class
     :END:
     this is only available for gpg, not gpgsm.
++
  ** Return ENC_TO output in verify result.  Again, this is not available
     :PROPERTIES:
     :CUSTOM_ID: return-to-enc
     :END:
     for gpgsm.
++
  ** Genkey should return something more useful than General_Error.
     :PROPERTIES:
     :CUSTOM_ID: general-key-assumed-command-from-general-error
     :END:
++
  ** If possible, use --file-setsize to set the file size for proper progress
     :PROPERTIES:
     :CUSTOM_ID: file-setsize
     :END:
     callback handling.  Write data interface for file size.
++
  ** Optimize the file descriptor list, so the number of open fds is
     :PROPERTIES:
     :CUSTOM_ID: optimus-descriptus-younger-brother-of-optimus-prime
     :END:
     always known easily.
++
  ** Encryption: It should be verified that the behaviour for partially untrusted
     :PROPERTIES:
     :CUSTOM_ID: only-mostly-dead-means-partially-alive
     :END:
     recipients is correct.
++
  ** When GPG issues INV_something for invalid signers, catch them.
     :PROPERTIES:
     :CUSTOM_ID: invalid-sig
@@@ -440,15 -477,15 +538,18 @@@
    :PROPERTIES:
    :CUSTOM_ID: error-value
    :END:
++
  ** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !!
     :PROPERTIES:
     :CUSTOM_ID: map-ass-error
     :END:
++
  ** Some error values should identify the source more correctly (mostly error
     :PROPERTIES:
     :CUSTOM_ID: source-errors
     :END:
     values derived from status messages).
++
  ** In rungpg.c we need to check the version of the engine
     :PROPERTIES:
     :CUSTOM_ID: rungpg-c-engine-ver
@@@ -461,6 -498,6 +562,7 @@@
    :PROPERTIES:
    :CUSTOM_ID: tests
    :END:
++
  ** TODO Write a fake gpg-agent so that we can supply known passphrases to
     :PROPERTIES:
     :CUSTOM_ID: test-fake-gpg-agent
@@@ -468,23 -505,23 +570,28 @@@
     gpgsm and setup the configuration files to use the agent.  Without
     this we are testing a currently running gpg-agent which is not a
     clever idea. !
++
  ** t-data
     :PROPERTIES:
     :CUSTOM_ID: test-data
     :END:
++
  *** Test gpgme_data_release_and_get_mem.
      :PROPERTIES:
      :CUSTOM_ID: test-gpgme-data-release-mem
      :END:
++
  *** Test gpgme_data_seek for invalid types.
      :PROPERTIES:
      :CUSTOM_ID: test-gpgme-data-seek
      :END:
++
  ** t-keylist
     :PROPERTIES:
     :CUSTOM_ID: test-keylist
     :END:
     Write a test for ext_keylist.
++
  ** Test reading key signatures.
     :PROPERTIES:
     :CUSTOM_ID: test-key-sig
@@@ -495,6 -532,6 +602,7 @@@
    :PROPERTIES:
    :CUSTOM_ID: debug
    :END:
++
  ** Tracepoints should be added at: Every public interface enter/leave,
     :PROPERTIES:
     :CUSTOM_ID: tracepoint-pub-int
@@@ -510,6 -547,6 +618,7 @@@
     decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c
     genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c
     sig-notation.c trust-item.c trustlist.c verify.c
++
  ** TODO Handle malloc and vasprintf errors.  But decide first if they should be
     :PROPERTIES:
     :CUSTOM_ID: malloc-vasprintf
@@@ -522,10 -559,10 +631,12 @@@
    :PROPERTIES:
    :CUSTOM_ID: build-suite
    :END:
++
  ** TODO Make sure everything is cleaned correctly (esp. test area).
     :PROPERTIES:
     :CUSTOM_ID: clean-tests
     :END:
++
  ** TODO Enable AC_CONFIG_MACRO_DIR and bump up autoconf version requirement.
     :PROPERTIES:
     :CUSTOM_ID: autoconf-macros
@@@ -538,6 -575,6 +649,7 @@@
    :PROPERTIES:
    :CUSTOM_ID: error-checking
    :END:
++
  ** TODO engine-gpgsm, with-validation
     :PROPERTIES:
     :CUSTOM_ID: gpgsm-validation

commit fa4927146b68dd045903285f1c45fb64deb2e361
Author: Ben McGinnes <ben at adversary.org>
Date:   Fri Mar 9 07:53:57 2018 +1100

    docs: python bindings howto update.
    
    * Added all four signing code examples that are most likely to be
      used: armoured, clearsigned, detached armoured and detached binary.
    * May remove some examples and just discuss the differences, but it
      depends on the way the text is filled out.

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index ab7e9db..17ec428 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -338,6 +338,96 @@ Python bindings to programmatically leverage the GPGME library.
 	 pass
    #+end_src
 
+** Signing text
+   :PROPERTIES:
+   :CUSTOM_ID: howto-basic-signing
+   :END:
+
+   Need to determine whether or not to include clearsigning and
+   detached signing here or give them separate sections.
+
+   #+begin_src python
+     import gpg
+
+     text = """Declaration of ... something.
+
+     """
+
+     c = gpg.Context()
+     c.armor = True
+     signed = c.sign(text, mode=mode.NORMAL)
+
+     afile = open("/path/to/statement.txt.asc", "w")
+     for i in range(len(signed[0].splitlines())):
+	 afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+     afile.close()
+   #+end_src
+
+   Clearsigning:
+
+   #+begin_src python
+     import gpg
+
+     text = """Declaration of ... something.
+
+     """
+
+     c = gpg.Context()
+     c.armor = True
+     signed = c.sign(text, mode=mode.CLEAR)
+
+     afile = open("/path/to/statement.txt.asc", "w")
+     for i in range(len(signed[0].splitlines())):
+	 afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+     afile.close()
+   #+end_src
+
+   Detached ASCII Armoured signing:
+
+   #+begin_src python
+     import gpg
+
+     text = """Declaration of ... something.
+
+     """
+
+     c = gpg.Context()
+     c.armor = True
+     signed = c.sign(text, mode=mode.DETACH)
+
+     afile = open("/path/to/statement.txt.asc", "w")
+     for i in range(len(signed[0].splitlines())):
+	 afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+     afile.close()
+   #+end_src
+
+   Detached binary signing (maybe change text to be reading a file's
+   content):
+
+   #+begin_src python
+import gpg
+
+text = """Declaration of ... something.
+
+"""
+
+c = gpg.Context()
+c.armor = True
+signed = c.sign(text, mode=mode.DETACH)
+
+afile = open("/path/to/statement.txt.sig", "wb")
+afile.write(signed[0])
+afile.close()
+   #+end_src
+
+
+** Signature verification
+   :PROPERTIES:
+   :CUSTOM_ID: howto-basic-verification
+   :END:
+
+x
+
 
 * Copyright and Licensing
   :PROPERTIES:

commit c767a4a3590bd8a224d0268746df443942cb28c2
Author: Ben McGinnes <ben at adversary.org>
Date:   Fri Mar 9 05:25:49 2018 +1100

    doc: python bindings howto update
    
    * Added example of decryption.
    * included some quick notes for myself regarding aspects to explain
      when I flesh out the explanatory text.

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 8f81511..ab7e9db 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -269,7 +269,6 @@ Python bindings to programmatically leverage the GPGME library.
    #+begin_src python
      import gpg
      import os
-     import os.path
 
      rkey = "0x12345678DEADBEEF"
      text = """
@@ -297,13 +296,48 @@ Python bindings to programmatically leverage the GPGME library.
 	     cipher.seek(0, os.SEEK_SET)
 	     del(text)
 	     del(plain)
-	     afile = open("secret_plans.txt.asc", "wb")
+	     afile = open("secret_plans.org.asc", "wb")
 	     afile.write(cipher.read())
 	     afile.close()
 	 except gpg.errors.GPGMEError as ex:
 	     print(ex.getstring())
    #+end_src
 
+** Decryption
+   :PROPERTIES:
+   :CUSTOM_ID: howto-basic-encryption
+   :END:
+
+   Decrypting something encrypted to a key in one's secret keyring
+   (will display some extra data you normally wouldn't show, but which
+   may be of use):
+
+   #+begin_src python
+     import os.path
+     import gpg
+
+     if os.path.exists("/path/to/secret_plans.org.asc") is True:
+	 ciphertext = "/path/to/secret_plans.org.asc"
+     elif os.path.exists("/path/to/secret_plans.org.gpg") is True:
+	 ciphertext = "/path/to/secret_plans.org.gpg"
+     else:
+	 ciphertext = None
+
+     if ciphertext is not None:
+	 afile = open(ciphertext, "rb")
+	 plaintext = gpg.Context().decrypt(afile)
+	 afile.close()
+	 newfile = open("/path/to/secret_plans.org", "wb")
+	 newfile.write(plaintext[0])
+	 newfile.close()
+	 print(plaintext[0])
+	 plaintext[1]
+	 plaintext[2]
+	 del(plaintext)
+     else:
+	 pass
+   #+end_src
+
 
 * Copyright and Licensing
   :PROPERTIES:

commit 75463d589522cba427f9e5a3a408192ffad8bb21
Author: Ben McGinnes <ben at adversary.org>
Date:   Fri Mar 9 04:42:41 2018 +1100

    doc: Basic operation of the python bindings
    
    * Added sample code for encrypting some text to a single key.
    * Basically I'm just lifting existing production code and changing the
      key IDs from mine to "0x12345678DEADBEEF" for these first few
      examples.
    * I'll fill in the text description after.
    * Note: due to my regional location, I might split some tasks into
      more commits in order to be sure no work gets lost in case of
      emergency (or to put it another way: I know Telstra too well to
      trust them).

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index e7dc53d..8f81511 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -254,6 +254,57 @@ Python bindings to programmatically leverage the GPGME library.
    operation type has one.
 
 
+* Basic Functions
+  :PROPERTIES:
+  :CUSTOM_ID: howto-the-basics
+  :END:
+
+** Encryption
+   :PROPERTIES:
+   :CUSTOM_ID: howto-basic-encryption
+   :END:
+
+   Encrypting to one key:
+
+   #+begin_src python
+     import gpg
+     import os
+     import os.path
+
+     rkey = "0x12345678DEADBEEF"
+     text = """
+     Some plain text to test with.  Obtained from any input source Python can read.
+
+     It makes no difference whether it is string or bytes, but the bindings always
+     produce byte output data.  Which is useful to know when writing out either the
+     encrypted or decrypted results.
+
+     """
+
+     plain = gpg.core.Data(text)
+     cipher = gpg.core.Data()
+     c = gpg.core.Context()
+     c.set_armor(1)
+
+     c.op_keylist_start(rkey, 0)
+     r = c.op_keylist_next()
+
+     if r == None:
+	 print("""The key for user "{0}" was not found""".format(rkey))
+     else:
+	 try:
+	     c.op_encrypt([r], 1, plain, cipher)
+	     cipher.seek(0, os.SEEK_SET)
+	     del(text)
+	     del(plain)
+	     afile = open("secret_plans.txt.asc", "wb")
+	     afile.write(cipher.read())
+	     afile.close()
+	 except gpg.errors.GPGMEError as ex:
+	     print(ex.getstring())
+   #+end_src
+
+
 * Copyright and Licensing
   :PROPERTIES:
   :CUSTOM_ID: copyright-and-license

-----------------------------------------------------------------------

Summary of changes:
 TODO                                    | 208 ++++++++++++++++++++++++--------
 lang/python/docs/GPGMEpythonHOWTOen.org | 175 +++++++++++++++++++++++++++
 2 files changed, 335 insertions(+), 48 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list