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

by Ben McGinnes cvs at cvs.gnupg.org
Tue Mar 13 09:22:19 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  c92da2c7eb148ce9fb06495a8470dd9caf662f9a (commit)
       via  e489ddd08af29fdad8db8aa0aec0c314daa3678c (commit)
      from  f29bda8d7146b4bc0bf73d6e613131545ff86b73 (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 c92da2c7eb148ce9fb06495a8470dd9caf662f9a
Author: Ben McGinnes <ben at adversary.org>
Date:   Tue Mar 13 19:20:44 2018 +1100

    doc: python bindings howto
    
    * Added key selection for specifying signing key or keys.

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 5ee3a82..ea1b765 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -532,9 +532,7 @@
    :CUSTOM_ID: howto-basic-signing
    :END:
 
-   Need to determine whether or not to include clearsigning and
-   detached signing here or give them separate sections.  Yes, section
-   them.
+   X
 
 *** Signing key selection
     :PROPERTIES:
@@ -547,6 +545,19 @@
     available it may be necessary to specify the key or keys with
     which to sign messages and files.
 
+    #+begin_src python
+      import gpg
+
+      logrus = input("Enter the email address or string to match signing keys to: ")
+      hancock = gpg.Context().keylist(pattern=logrus, secret=True)
+      sig_src = list(hancock)
+    #+end_src
+
+    The signing examples in the following sections include the
+    explicitly designated =signers= parameter in two of the five
+    examples; once where the resulting signature would be ASCII
+    armoured and once where it would not be armoured.
+
 *** Normal or default signing messages or files
     :PROPERTIES:
     :CUSTOM_ID: howto-basic-signing-normal
@@ -559,8 +570,7 @@
 
      """
 
-     c = gpg.Context()
-     c.armor = True
+     c = gpg.Context(armor=True, signers=sig_src)
      signed = c.sign(text, mode=0)
 
      afile = open("/path/to/statement.txt.asc", "wb")
@@ -598,8 +608,7 @@
 
      """
 
-     c = gpg.Context()
-     c.armor = True
+     c = gpg.Context(armor=True)
      signed = c.sign(text, mode=1)
 
      afile = open("/path/to/statement.txt.asc", "wb")
@@ -617,7 +626,7 @@
      text = tfile.read()
      tfile.close()
 
-     c = gpg.Context()
+     c = gpg.Context(signers=sig_src)
      signed = c.sign(text, mode=1)
 
      afile = open("/path/to/statement.txt.sig", "wb")

commit e489ddd08af29fdad8db8aa0aec0c314daa3678c
Author: Ben McGinnes <ben at adversary.org>
Date:   Tue Mar 13 18:32:30 2018 +1100

    doc: python bindings howto
    
    * During the course of working out the updated signature methods,
      determined that key selection (including counting) will beed to be
      presented before the basic functions.
    * Moved "working with keys" up.

diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 5d259a6..5ee3a82 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -255,6 +255,41 @@
    operation type has one.
 
 
+* Working with keys
+  :PROPERTIES:
+  :CUSTOM_ID: howto-keys
+  :END:
+
+** Counting keys
+   :PROPERTIES:
+   :CUSTOM_ID: howto-basic-verification
+   :END:
+
+   Counting the number of keys in your public keybox (=pubring.kbx=),
+   the format which has superceded the old keyring format
+   (=pubring.gpg= and =secring.gpg=), or the number of secret keys is
+   a very simple task.
+
+   #+begin_src python
+     import gpg
+
+     c = gpg.Context()
+     seckeys = c.keylist(pattern=None, secret=True)
+     pubkeys = c.keylist(pattern=None, secret=False)
+
+     seclist = list(seckeys)
+     secnum = len(seclist)
+
+     publist = list(pubkeys)
+     pubnum = len(publist)
+
+     print("""
+     Number of secret keys:  {0}
+     Number of public keys:  {1}
+     """.format(secnum, pubnum)
+   #+end_src
+
+
 * Basic Functions
   :PROPERTIES:
   :CUSTOM_ID: howto-the-basics
@@ -492,13 +527,30 @@
    signatures of the data in =plaintext[0]=.
 
 
-** Signing text
+** Signing text and files
    :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.
+   detached signing here or give them separate sections.  Yes, section
+   them.
+
+*** Signing key selection
+    :PROPERTIES:
+    :CUSTOM_ID: howto-basic-signing-signers
+    :END:
+
+    By default GPGME and the Python bindings will use the default key
+    configured for the user invoking the GPGME API.  If there is no
+    default key specified and there is more than one secret key
+    available it may be necessary to specify the key or keys with
+    which to sign messages and files.
+
+*** Normal or default signing messages or files
+    :PROPERTIES:
+    :CUSTOM_ID: howto-basic-signing-normal
+    :END:
 
    #+begin_src python
      import gpg
@@ -511,36 +563,38 @@
      c.armor = True
      signed = c.sign(text, mode=0)
 
-     afile = open("/path/to/statement.txt.asc", "w")
+     afile = open("/path/to/statement.txt.asc", "wb")
      for i in range(len(signed[0].splitlines())):
-	 afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+	 afile.write("{0}\n".format(signed[0].splitlines()[i]))
      afile.close()
    #+end_src
 
-   Clearsigning:
-
    #+begin_src python
      import gpg
 
-     text = """Declaration of ... something.
-
-     """
+     tfile = open("/path/to/statement.txt", "rb")
+     text = tfile.read()
+     tfile.close()
 
      c = gpg.Context()
-     signed = c.sign(text, mode=2)
+     signed = c.sign(text, mode=0)
 
-     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 = open("/path/to/statement.txt.sig", "wb")
+     afile.write(signed[0])
      afile.close()
    #+end_src
 
+*** Detached signing messages and files
+    :PROPERTIES:
+    :CUSTOM_ID: howto-basic-signing-detached
+    :END:
+
    Detached ASCII Armoured signing:
 
    #+begin_src python
      import gpg
 
-     text = """Declaration of ... something.
+     text = b"""Declaration of ... something.
 
      """
 
@@ -548,9 +602,9 @@
      c.armor = True
      signed = c.sign(text, mode=1)
 
-     afile = open("/path/to/statement.txt.asc", "w")
+     afile = open("/path/to/statement.txt.asc", "wb")
      for i in range(len(signed[0].splitlines())):
-	 afile.write("{0}\n".format(signed[0].splitlines()[i].decode('utf-8')))
+	 afile.write("{0}\n".format(signed[0].splitlines()[i]))
      afile.close()
    #+end_src
 
@@ -564,7 +618,6 @@
      tfile.close()
 
      c = gpg.Context()
-     c.armor = True
      signed = c.sign(text, mode=1)
 
      afile = open("/path/to/statement.txt.sig", "wb")
@@ -572,6 +625,27 @@
      afile.close()
    #+end_src
 
+*** Clearsigning messages or text
+    :PROPERTIES:
+    :CUSTOM_ID: howto-basic-signing-clear
+    :END:
+
+   #+begin_src python
+     import gpg
+
+     text = """Declaration of ... something.
+
+     """
+
+     c = gpg.Context()
+     signed = c.sign(text, mode=2)
+
+     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
+
 
 ** Signature verification
    :PROPERTIES:
@@ -605,41 +679,6 @@
    #+end_src
 
 
-* Working with keys
-  :PROPERTIES:
-  :CUSTOM_ID: howto-keys
-  :END:
-
-** Counting keys
-   :PROPERTIES:
-   :CUSTOM_ID: howto-basic-verification
-   :END:
-
-   Counting the number of keys in your public keybox (=pubring.kbx=),
-   the format which has superceded the old keyring format
-   (=pubring.gpg= and =secring.gpg=), or the number of secret keys is
-   a very simple task.
-
-   #+begin_src python
-     import gpg
-
-     c = gpg.Context()
-     seckeys = c.keylist(pattern=None, secret=True)
-     pubkeys = c.keylist(pattern=None, secret=False)
-
-     seclist = list(seckeys)
-     secnum = len(seclist)
-
-     publist = list(pubkeys)
-     pubnum = len(publist)
-
-     print("""
-     Number of secret keys:  {0}
-     Number of public keys:  {1}
-     """.format(secnum, pubnum)
-   #+end_src
-
-
 * Miscellaneous work-arounds
   :PROPERTIES:
   :CUSTOM_ID: cheats-and-hacks

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

Summary of changes:
 lang/python/docs/GPGMEpythonHOWTOen.org | 164 +++++++++++++++++++++-----------
 1 file changed, 106 insertions(+), 58 deletions(-)


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




More information about the Gnupg-commits mailing list