[git] GPGME - branch, ben/howto-update-02, updated. gpgme-1.10.0-174-g3b91f6a
by Ben McGinnes
cvs at cvs.gnupg.org
Thu Mar 29 01:26:08 CEST 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/howto-update-02 has been updated
via 3b91f6af378ccc37dcf8924cbc157894c35b5192 (commit)
via d65864989c0560b5f51cb8d05d9ea9f1957b453e (commit)
from 56bbfd39acea90eb87a28b11a515b0314cdda54c (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 3b91f6af378ccc37dcf8924cbc157894c35b5192
Author: Ben McGinnes <ben at adversary.org>
Date: Thu Mar 29 10:21:52 2018 +1100
example: revoke UID
* Script to revoke a UID on an existing key.
diff --git a/lang/python/examples/howto/revoke-userid.py b/lang/python/examples/howto/revoke-userid.py
new file mode 100755
index 0000000..7a3d190
--- /dev/null
+++ b/lang/python/examples/howto/revoke-userid.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+from __future__ import absolute_import, division, unicode_literals
+
+# Copyright (C) 2018 Ben McGinnes <ben at gnupg.org>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License and the GNU
+# Lesser General Public Licensefor more details.
+#
+# You should have received a copy of the GNU General Public License and the GNU
+# Lesser General Public along with this program; if not, see
+# <http://www.gnu.org/licenses/>.
+
+import gpg
+import os.path
+
+print("""
+This script revokes a user ID on an existing key.
+
+The gpg-agent and pinentry are invoked to enter the passphrase.
+""")
+
+c = gpg.Context()
+
+homedir = input("Enter the GPG configuration directory path (optional): ")
+fpr0 = input("Enter the fingerprint of the key to modify: ")
+uid_name = input("Enter the name of the user ID: ")
+uid_email = input("Enter the email address of the user ID: ")
+uid_cmnt = input("Enter a comment to include (optional): ")
+
+if homedir.startswith("~"):
+ if os.path.exists(os.path.expanduser(homedir)) is True:
+ c.home_dir = os.path.expanduser(homedir)
+ else:
+ pass
+elif os.path.exists(homedir) is True:
+ c.home_dir = homedir
+else:
+ pass
+
+fpr = "".join(fpr0.split())
+
+if len(uid_cmnt) > 0:
+ userid = "{0} ({1}) <{2}>".format(uid_name, uid_cmnt, uid_email)
+else:
+ userid = "{0} <{2}>".format(uid_name, uid_email)
+
+key = c.get_key(fpr, secret=True)
+c.key_revoke_uid(key, userid)
commit d65864989c0560b5f51cb8d05d9ea9f1957b453e
Author: Ben McGinnes <ben at adversary.org>
Date: Thu Mar 29 10:16:07 2018 +1100
docs: python bindings howto
* Added section on revoking UIDs.
diff --git a/lang/python/docs/GPGMEpythonHOWTOen.org b/lang/python/docs/GPGMEpythonHOWTOen.org
index 4cd4098..d51eb11 100644
--- a/lang/python/docs/GPGMEpythonHOWTOen.org
+++ b/lang/python/docs/GPGMEpythonHOWTOen.org
@@ -1214,38 +1214,66 @@
:CUSTOM_ID: keygen-uids
:END:
- By comparison to creating primary keys and subkeys, adding a new
- user ID to an existing key is much simpler. The method used to do
- this is =key_add_uid= and the only arguments it takes are for the
- =key= and the new =uid=.
- #+begin_src python
- import gpg
+*** Adding User IDs
+ :PROPERTIES:
+ :CUSTOM_ID: keygen-uids-add
+ :END:
- c = gpg.Context()
- c.home_dir = "~/.gnupg-dm"
+ By comparison to creating primary keys and subkeys, adding a new
+ user ID to an existing key is much simpler. The method used to do
+ this is =key_add_uid= and the only arguments it takes are for the
+ =key= and the new =uid=.
- dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
- key = c.get_key(dmfpr, secret=True)
- uid = "Danger Mouse <danger.mouse at secret.example.net>"
+ #+begin_src python
+ import gpg
- c.key_add_uid(key, uid)
- #+end_src
+ c = gpg.Context()
+ c.home_dir = "~/.gnupg-dm"
- Unsurprisingly the result of this is:
+ dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
+ key = c.get_key(dmfpr, secret=True)
+ uid = "Danger Mouse <danger.mouse at secret.example.net>"
- #+begin_src shell
- bash-4.4$ gpg --homedir ~/.gnupg-dm -K
- ~/.gnupg-dm/pubring.kbx
- ----------------------
- sec rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
- 177B7C25DB99745EE2EE13ED026D2F19E99E63AA
- uid [ultimate] Danger Mouse <danger.mouse at secret.example.net>
- uid [ultimate] Danger Mouse <dm at secret.example.net>
- ssb rsa3072 2018-03-15 [E] [expires: 2018-09-13]
+ c.key_add_uid(key, uid)
+ #+end_src
- bash-4.4$
- #+end_src
+ Unsurprisingly the result of this is:
+
+ #+begin_src shell
+ bash-4.4$ gpg --homedir ~/.gnupg-dm -K
+ ~/.gnupg-dm/pubring.kbx
+ ----------------------
+ sec rsa3072 2018-03-15 [SC] [expires: 2019-03-15]
+ 177B7C25DB99745EE2EE13ED026D2F19E99E63AA
+ uid [ultimate] Danger Mouse <danger.mouse at secret.example.net>
+ uid [ultimate] Danger Mouse <dm at secret.example.net>
+ ssb rsa3072 2018-03-15 [E] [expires: 2018-09-13]
+
+ bash-4.4$
+ #+end_src
+
+
+*** Revokinging User IDs
+ :PROPERTIES:
+ :CUSTOM_ID: keygen-uids-revoke
+ :END:
+
+ Revoking a user ID is a fairly similar process, except that it
+ uses the =key_revoke_uid= method.
+
+ #+begin_src python
+ import gpg
+
+ c = gpg.Context()
+ c.home_dir = "~/.gnupg-dm"
+
+ dmfpr = "177B7C25DB99745EE2EE13ED026D2F19E99E63AA"
+ key = c.get_key(dmfpr, secret=True)
+ uid = "Danger Mouse <danger.mouse at secret.example.net>"
+
+ c.key_revoke_uid(key, uid)
+ #+end_src
** Key certification
-----------------------------------------------------------------------
Summary of changes:
lang/python/docs/GPGMEpythonHOWTOen.org | 78 +++++++++++++++-------
.../howto/{add-userid.py => revoke-userid.py} | 4 +-
2 files changed, 55 insertions(+), 27 deletions(-)
copy lang/python/examples/howto/{add-userid.py => revoke-userid.py} (96%)
hooks/post-receive
--
GnuPG Made Easy
http://git.gnupg.org
More information about the Gnupg-commits
mailing list