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

by Ben McGinnes cvs at cvs.gnupg.org
Tue Mar 13 16:24:41 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  a10dcb4f138eb5a21881cdbc4806c25129d4ae4e (commit)
       via  952b6042f78017c476452088261af8d352cfa729 (commit)
      from  c92da2c7eb148ce9fb06495a8470dd9caf662f9a (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 a10dcb4f138eb5a21881cdbc4806c25129d4ae4e
Author: Ben McGinnes <ben at adversary.org>
Date:   Wed Mar 14 02:21:44 2018 +1100

    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).

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index ae9e9e7..ea4b111 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -285,9 +285,68 @@
   :CUSTOM_ID: howto-keys
   :END:
 
+** Key selection
+   :PROPERTIES:
+   :CUSTOM_ID: howto-keys-selection
+   :END:
+
+   Selecting keys to encrypt to or to sign with will be a common
+   occurrence when working with GPGMe and the means available for
+   doing so are quite simple.
+
+   They do depend on utilising a Context; however once the data is
+   recorded in another variable, that Context does not need to be the
+   same one which subsequent operations are performed.
+
+   The easiest way to select a specific key is by searching for that
+   key's key ID or fingerprint, preferably the full fingerprint
+   without any spaces in it.  A long key ID will probably be okay, but
+   is not advised and short key IDs are already a problem with some
+   being generated to match specific patterns.  It does not matter
+   whether the pattern is upper or lower case.
+
+   So this is the best method:
+
+   #+begin_src python
+     import gpg
+
+     k = gpg.Context().keylist(pattern="258E88DCBD3CD44D8E7AB43F6ECB6AF0DEADBEEF")
+     keys = list(k)
+   #+end_src
+
+   This is passable and very likely to be common:
+
+   #+begin_src python
+     import gpg
+
+     k = gpg.Context().keylist(pattern="0x6ECB6AF0DEADBEEF")
+     keys = list(k)
+   #+end_src
+
+   And this is a really bad idea:
+
+   #+begin_src python
+     import gpg
+
+     k = gpg.Context().keylist(pattern="0xDEADBEEF")
+     keys = list(k)
+   #+end_src
+
+   Alternatively it may be that the intention is to create a list of
+   keys which all match a particular search string.  For instance all
+   the addresses at a particular domain, like this:
+
+   #+begin_src python
+     import gpg
+
+     ncsc = gpg.Context().keylist(pattern="ncsc.mil")
+     nsa = list(ncsc)
+   #+end_src
+
+
 ** Counting keys
    :PROPERTIES:
-   :CUSTOM_ID: howto-basic-verification
+   :CUSTOM_ID: howto-keys-counting
    :END:
 
    Counting the number of keys in your public keybox (=pubring.kbx=),

commit 952b6042f78017c476452088261af8d352cfa729
Author: Ben McGinnes <ben at adversary.org>
Date:   Wed Mar 14 01:41:21 2018 +1100

    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.

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index ea1b765..ae9e9e7 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -21,6 +21,31 @@
   This document provides basic instruction in how to use the GPGME
   Python bindings to programmatically leverage the GPGME library.
 
+** Python 2 versus Python 3
+   :PROPERTIES:
+   :CUSTOM_ID: py2-vs-py3
+   :END:
+
+   Though the GPGME Python bindings themselves provide support for
+   both Python 2 and 3, the focus is unequivocally on Python 3 and
+   specifically from Python 3.4 and above.  As a consequence all the
+   examples and instructions in this guide use Python 3 code.
+
+   Much of it will work with Python 2, but much of it also deals with
+   Python 3 byte literals, particularly when reading and writing data.
+   Developers concentrating on Python 2.7, and possibly even 2.6, will
+   need to make the approprate modifications to support the older
+   string and unicode types as opposted to bytes.
+
+   There are multiple reasons for concentrating on Python 3; some of
+   which relate to the immediate integration of these bindings, some
+   of which relate to longer term plans for both GPGME and the python
+   bindings and some of which relate to the impending EOL period for
+   Python 2.7.  Essentially, though, there is little value in tying
+   the bindings to a version of the language which is a dead end and
+   the advantages offered by Python 3 over Python 2 make handling the
+   data types with which GPGME deals considerably easier.
+
 
 * GPGME Concepts
   :PROPERTIES:
@@ -59,7 +84,7 @@
    =gpgme.h= generated when GPGME is compiled.
 
    This means that a version of the Python bindings is fundamentally
-   tied to the exact same version of GPGME used to gemerate that copy
+   tied to the exact same version of GPGME used to generate that copy
    of =gpgme.h=.
 
 ** Difference between the Python bindings and other GnuPG Python packages
@@ -411,13 +436,13 @@
 
       c = gpg.Context(armor=True)
       rpattern = list(c.keylist(pattern="@gnupg.org", secret=False))
-      rlogrus = []
+      logrus = []
 
       for i in range(len(rpattern)):
 	  if rpattern[i].can_encrypt == 1:
-	      rlogrus.append(rpattern[i])
+	      logrus.append(rpattern[i])
 
-      cipher = c.encrypt(text, recipients=rlogrus, sign=False, always_trust=True)
+      cipher = c.encrypt(text, recipients=logrus, sign=False, always_trust=True)
 
       afile = open("secret_plans.txt.asc", "wb")
       afile.write(cipher[0])
@@ -429,7 +454,7 @@
     be to change the =c.encrypt= line to this:
 
     #+begin_src python
-      cipher = c.encrypt(text, recipients=rlogrus, always_trust=True,
+      cipher = c.encrypt(text, recipients=logrus, always_trust=True,
 			 add_encrypt_to=True)
     #+end_src
 
@@ -452,23 +477,23 @@
 
       c = gpg.Context(armor=True)
       rpattern = list(c.keylist(pattern="@gnupg.org", secret=False))
-      rlogrus = []
+      logrus = []
 
       for i in range(len(rpattern)):
 	  if rpattern[i].can_encrypt == 1:
-	      rlogrus.append(rpattern[i])
+	      logrus.append(rpattern[i])
 
       try:
-	  cipher = c.encrypt(text, recipients=rlogrus, add_encrypt_to=True)
+	  cipher = c.encrypt(text, recipients=logrus, add_encrypt_to=True)
       except gpg.errors.InvalidRecipients as e:
 	  for i in range(len(e.recipients)):
-	      for n in range(len(rlogrus)):
-		  if rlogrus[n].fpr == e.recipients[i].fpr:
-		      rlogrus.remove(rlogrus[n])
+	      for n in range(len(logrus)):
+		  if logrus[n].fpr == e.recipients[i].fpr:
+		      logrus.remove(logrus[n])
                   else:
                       pass
 	  try:
-	      cipher = c.encrypt(text, recipients=rlogrus, add_encrypt_to=True)
+	      cipher = c.encrypt(text, recipients=logrus, add_encrypt_to=True)
 	  except:
 	      pass
 
@@ -532,7 +557,7 @@
    :CUSTOM_ID: howto-basic-signing
    :END:
 
-   X
+   The following sections demonstrate how to specify
 
 *** Signing key selection
     :PROPERTIES:
@@ -558,6 +583,12 @@
     examples; once where the resulting signature would be ASCII
     armoured and once where it would not be armoured.
 
+    While it would be possible to enter a key ID or fingerprint here
+    to match a specific key, it is not possible to enter two
+    fingerprints and match two keys since the patten expects a string,
+    bytes or None and not a list.  A string with two fingerprints
+    won't match any single key.
+
 *** Normal or default signing messages or files
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-signing-normal

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

Summary of changes:
 lang/python/docs/GPGMEpythonHOWTOen.org | 118 ++++++++++++++++++++++++++++----
 1 file changed, 104 insertions(+), 14 deletions(-)


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




More information about the Gnupg-commits mailing list