Isis Lovecruft
dad755ec3a
Awkwardly, fingerprints need to always be strings. Change unittests to do so.
2013-05-27 09:13:04 +00:00
Isis Lovecruft
611184f242
Add '--no-options' to unittest on _make_options() output.
2013-05-27 09:09:32 +00:00
Isis Lovecruft
490574c3ec
Change variable name file→filename in GPG.decrypt_file().
2013-05-27 09:08:49 +00:00
Isis Lovecruft
688ceb9a6d
Change parameter name data→message in GPG.decrypt().
2013-05-27 09:08:26 +00:00
Isis Lovecruft
bfbb189459
GPG.encrypt() should now be called with each recipient as a single parameter.
2013-05-27 09:04:15 +00:00
Isis Lovecruft
7c9c00a957
Rewrite encrypt_file() to handle unicode/str, fn/files, and multi recipients.
2013-05-27 09:01:48 +00:00
Isis Lovecruft
8b355d5541
Update docstring for GPG.encrypt_file() with new parameter type requirements.
...
* GPG.encrypt_file() isn't ever directly used now, and so we should switch to
calling it in the same way that GPG._sign_file() is now called when
necessary though GPG.sign().
2013-05-27 08:59:10 +00:00
Isis Lovecruft
897f32307e
Make the kwargs for GPG.encrypt_file() appear slightly less overwhelming.
2013-05-27 08:53:18 +00:00
Isis Lovecruft
b6076a7f65
Add support for using separate keyrings during key generation.
...
* If GPG.gen_key_input() is called with 'separate_keyring = True', then a
unique temporary keyring filename will be created in the format:
username@hostname_timestamp.[pub|sec]ring
where the timestamp is an integer representing seconds since epoch for
UTC. The filename for the two temporary keyrings are stored in the class
attribute GPG.temp_keyring and GPG.temp_secring, so that when GPG.gen_key()
is called with results of GPG.gen_key_input([...], separate_keyring=True),
the keys are created using the temporary keyrings, which are then renamed
to:
fingerprint.[pub|sec]ring
where fingerprint is the fingerprint of the key which has just been
generated. The attributes GPG.temp_keyring and GPG.temp_secring are then
both reset to None, so that these attributes, if the hold anything, only
hold the filenames for the last call to GPG.gen_key_input().
* I didn't especially want to add new features right now, but this turned out
to be necessary for cases where we want to generate a bunch of keys and
then use them right away. Without doing this, it would have been necessary
to store the results of the freshly generated key in memory and then write
them to a file by hand, which proved to be rather volatile and error-prone,
as none of the unittests for encryption/decryption for multiple recipients
were passing, nor had ever passed. (A note again on the latter: upstream's
unittests for encryption and decryption are entirely encased in try/except
blocks which CATCH ALL ERRORS. Qu'est-que fuck is the point of a unittest
if it catches all errors?)
2013-05-27 08:47:17 +00:00
Isis Lovecruft
ea58623e75
Fix doctest for GPG.recv_keys().
2013-05-27 08:23:35 +00:00
Isis Lovecruft
3516431da9
Comment out the pretty printing of results for GPG.import_key() for now.
2013-05-27 08:22:35 +00:00
Isis Lovecruft
eb93fd48de
Fix doctest for GPG.import_key().
2013-05-27 08:22:00 +00:00
Isis Lovecruft
434a650799
Change ivar name p→proc.
2013-05-27 08:21:25 +00:00
Isis Lovecruft
de36fe52d1
Change varable name keyid→default_key.
2013-05-27 08:20:27 +00:00
Isis Lovecruft
77bb8d8500
Make GPG._make_args() shorter and prettier.
2013-05-27 08:16:35 +00:00
Isis Lovecruft
e501afb6a7
Add initialization of GPG.temp_keyring and GPG.temp_secring objects.
2013-05-27 08:15:50 +00:00
Isis Lovecruft
1dfadbf32f
Remove excessive log statement.
2013-05-27 08:15:10 +00:00
Isis Lovecruft
efc10b6791
Remove unused import for socket module.
2013-05-27 08:14:52 +00:00
Isis Lovecruft
a0e1d4db6e
Add a utility for getting the current UTC seconds-since-epoch time.
2013-05-27 08:14:08 +00:00
Isis Lovecruft
50b057918b
Change line to check multiple types in the same isinstance() call.
2013-05-27 08:13:27 +00:00
Isis Lovecruft
bf591c2dd0
Add a utility for creating a 'user@hostname' string.
2013-05-27 08:12:54 +00:00
Isis Lovecruft
cce8785f39
Slice equiv. bytes from strings as we read() from file handles in _copy_data().
2013-05-27 07:50:36 +00:00
Isis Lovecruft
e252f63341
Switch to calling a bound super on Crypt for handle_status() method again.
2013-05-27 07:49:10 +00:00
Isis Lovecruft
1d326f8808
GnuPG only *sometimes* returns the filename for the plaintext.
...
* We can't split twice at first, because sometimes there isn't a third field
in the string.
* There isn't any rhyme or reason to when the filename is present or
missing. It just is.
2013-05-27 07:46:54 +00:00
Isis Lovecruft
1c3f0c3c9a
There are lots of these list(dict.items()) in the old codebase. Total nonsense.
...
* These evaluate in all interpreters to functionally the same bytecode, with
an extra LOAD_GLOBAL and then a CALL_FUNCTION for that GLOBAL which doesn't
gets a passthrough value. I have absolutely no idea why someone thought it
was necessary to code it this way, unless there used to be some weird dict
bug in some version of Python (which is totally possible) that I don't
remember and have never heard about. Disassembled:
>>> def normal(things):
... for k,v in things.items():
... print "%s=%s" % (k,v)
...
...
>>> def notnormal(things):
... for k,v in list(things.items()):
... print "%s=%s" % (k,v)
...
>>> dis.dis(normal)
2 0 SETUP_LOOP 41 (to 44)
3 LOAD_FAST 0 (things)
6 LOAD_ATTR 0 (items)
9 CALL_FUNCTION 0
12 GET_ITER
>> 13 FOR_ITER 27 (to 43)
16 UNPACK_SEQUENCE 2
19 STORE_FAST 1 (k)
22 STORE_FAST 2 (v)
3 25 LOAD_CONST 1 ('%s=%s')
28 LOAD_FAST 1 (k)
31 LOAD_FAST 2 (v)
34 BUILD_TUPLE 2
37 BINARY_MODULO
38 PRINT_ITEM
39 PRINT_NEWLINE
40 JUMP_ABSOLUTE 13
>> 43 POP_BLOCK
>> 44 LOAD_CONST 0 (None)
47 RETURN_VALUE
>>> dis.dis(notnormal)
2 0 SETUP_LOOP 47 (to 50)
3 LOAD_GLOBAL 0 (list)
6 LOAD_FAST 0 (things)
9 LOAD_ATTR 1 (items)
12 CALL_FUNCTION 0
15 CALL_FUNCTION 1
18 GET_ITER
>> 19 FOR_ITER 27 (to 49)
22 UNPACK_SEQUENCE 2
25 STORE_FAST 1 (k)
28 STORE_FAST 2 (v)
3 31 LOAD_CONST 1 ('%s=%s')
34 LOAD_FAST 1 (k)
37 LOAD_FAST 2 (v)
40 BUILD_TUPLE 2
43 BINARY_MODULO
44 PRINT_ITEM
45 PRINT_NEWLINE
46 JUMP_ABSOLUTE 19
>> 49 POP_BLOCK
>> 50 LOAD_CONST 0 (None)
53 RETURN_VALUE
2013-05-27 07:28:03 +00:00
Isis Lovecruft
c31e1303ba
GnuPG status code '17' on imports means '16'. That wasn't documented anywhere.
2013-05-27 07:26:15 +00:00
Isis Lovecruft
c3dcd34f5a
This log statement didn't need 2LOC.
2013-05-27 07:25:27 +00:00
Isis Lovecruft
e52e9001d1
Rewrite _check_option() in _sanitise() to be way more efficient and readable.
2013-05-27 07:24:31 +00:00
Isis Lovecruft
f65022500d
Add note on using itertools.dropwhile() for efficiency in _is_allowed().
...
* If/when it's rewritten, a simple speed/efficiency check can be done with:
>>> import dis
>>> dis.dis(_is_allowed_orig('--dragons'))
>>> dis.dis(_is_allowed_orig('--encrypt'))
>>> dis.dis(_is_allowed_new('--dragons'))
>>> dis.dis(_is_allowed_new('--encrypt'))
2013-05-27 07:19:40 +00:00
Isis Lovecruft
69c6981b66
A unicode(list()) versus a unicode(str()) are different.
2013-05-27 07:15:33 +00:00
Isis Lovecruft
30223d4203
Don't attempt to set up logging to file unless logging is actually enabled.
2013-05-27 07:14:03 +00:00
Isis Lovecruft
7700b012b1
Only gnupg.__version__, not gnupg._version, should be accessible in module.
2013-05-27 07:12:50 +00:00
Isis Lovecruft
4c67e45759
Add batch file save functionality, including creating a README in that dir.
2013-05-23 08:56:20 +00:00
Isis Lovecruft
0921ca7a2b
If Key-Type is 'default', force 'Subkey-Type' to also be 'default'.
2013-05-23 08:54:05 +00:00
Isis Lovecruft
9e5bdafffa
Remove excess EOL whitespace.
2013-05-23 08:52:18 +00:00
Isis Lovecruft
22aa8d2ee1
Add a parameter to GPG.gen_key_input for saving batch files.
2013-05-23 08:49:27 +00:00
Isis Lovecruft
51e2b33265
Add .../homedir/batch-files and .../homedir/generated-keys directories.
2013-05-23 08:47:47 +00:00
Isis Lovecruft
8afd189d36
InheritablePropery→_util.InheritableProperty
2013-05-23 07:06:11 +00:00
Isis Lovecruft
c7a4845ce4
Also get set GPG.filesystemencoding in case we have to save a file.
2013-05-23 07:05:14 +00:00
Isis Lovecruft
de9eb4ca77
Add utility for getting the timestamp in ISO 8601 format.
2013-05-23 07:03:55 +00:00
Isis Lovecruft
55ca5487bb
Change sign/sign_with param in GPG.encrypt* to be named 'default_key'.
2013-05-23 05:15:22 +00:00
Isis Lovecruft
b50e91bd5e
Remove two extra functions from GPGWrapper class.
2013-05-22 17:58:22 +00:00
Isis Lovecruft
9aa7ad8c69
Add class attrs and docs to Verify, add new _parsers.Crypt class.
2013-05-22 17:38:35 +00:00
Isis Lovecruft
bac7e52fc0
Update docs for _parsers.Verify.
2013-05-22 17:37:37 +00:00
Isis Lovecruft
596d6cd2d3
Parse NODATA status code in _parsers.Sign.
2013-05-22 17:37:05 +00:00
Isis Lovecruft
75f3a4a89e
_handle_status→handle_status
2013-05-22 17:36:28 +00:00
Isis Lovecruft
18ffc52aca
Add better parsing of PROGRESS and NODATA status codes in _parsers.GenKey.
2013-05-22 17:34:46 +00:00
Isis Lovecruft
88352ef95c
Remove extra Verify and Crypt from _parsers.
2013-05-22 17:29:06 +00:00
Isis Lovecruft
10014d5401
Rewrite multi-recipient encryption test
2013-05-22 17:25:57 +00:00
Isis Lovecruft
345ca75e85
Minor fixes to encryption with iso-8859-1 encodings test.
2013-05-22 17:25:21 +00:00