mini_buildd.gnupg module¶
-
class
mini_buildd.gnupg.
Colons
(colons_line)¶ Bases:
object
Provide a colon->name mapping for the gpg script-parsable ‘–with-colons’ output.
See /usr/share/doc/gnupg/DETAILS.gz.
-
type
¶
-
key_id
¶
-
creation_date
¶
-
expiration_date
¶
-
user_id
¶ fingerprint for ‘fpr’ type
-
-
class
mini_buildd.gnupg.
BaseGnuPG
(home)¶ Bases:
object
-
classmethod
get_flavor
()¶ Ugly-parse GPG binary flavor(=major.minor) “1.4” (“classic”), “2.0” (“stable”) or “2.1” (“modern”) from “gpg –version” output (like “gpg (GnuPG) 2.1.14”). Don’t fail but return “unknown” if anything nasty happens.
-
gen_secret_key
(template)¶
-
export
(dest_file, identity='')¶
-
get_pub_key
(identity)¶
-
get_pub_colons
(type_regex='pub')¶
-
get_sec_colons
(type_regex='sec')¶
-
get_first_sec_colon
(type_regex)¶
-
get_first_sec_key
()¶
-
get_first_sec_key_fingerprint
()¶
-
get_first_sec_key_user_id
()¶
-
import_pub_key
(keyserver, identity)¶
-
add_pub_key
(key)¶
-
add_keyring
(keyring)¶
-
verify
(signature, data=None)¶
-
sign
(file_name, identity=None)¶
-
classmethod
-
class
mini_buildd.gnupg.
GnuPG
(template, fullname, email)¶ Bases:
mini_buildd.gnupg.BaseGnuPG
-
prepare
()¶
-
remove
()¶
-
get_pub_key
(identity=None)¶
-
-
class
mini_buildd.gnupg.
TmpGnuPG
¶ Bases:
mini_buildd.gnupg.BaseGnuPG
,mini_buildd.misc.TmpDir
>>> # mini_buildd.setup.DEBUG.append("keep") # Enable 'keep' for debugging only >>> gnupg_home = mini_buildd.misc.TmpDir() >>> dummy = shutil.copy2("test-data/gpg/secring.gpg", gnupg_home.tmpdir) >>> dummy = shutil.copy2("test-data/gpg/pubring.gpg", gnupg_home.tmpdir) >>> gnupg = BaseGnuPG(home=gnupg_home.tmpdir)
>>> gnupg.get_first_sec_colon("sec").type 'sec' >>> gnupg.get_first_sec_key_user_id() '\xdcdo \xdcmlaut <test@key.org>' >>> gnupg.get_first_sec_key() 'AF95FC80FC40A82E' >>> gnupg.get_first_sec_key_fingerprint() '4FB13BDD777C046D72D4E7D3AF95FC80FC40A82E'
>>> export = tempfile.NamedTemporaryFile() >>> gnupg.export(export.name)
>>> t = tempfile.NamedTemporaryFile() >>> t.write(b"A test file\n") 12 >>> t.flush() >>> gnupg.sign(file_name=t.name, identity="test@key.org") >>> gnupg.verify(t.name) >>> pub_key = gnupg.get_pub_key(identity="test@key.org") >>> tgnupg = TmpGnuPG() >>> tgnupg.add_pub_key(pub_key) >>> tgnupg.verify(t.name)
>>> tgnupg.close() >>> gnupg_home.close()