Commit Graph

520 Commits (87536c194ee8ab21f25f600083b0ed30b8fbdec2)

Author SHA1 Message Date
Isis Lovecruft 87536c194e
Rewrite unittest for file encryption and decryption. 2013-05-27 09:33:24 +00:00
Isis Lovecruft fa57bc6158
Change unittest for symmetric encryption to include correct boolean options. 2013-05-27 09:30:05 +00:00
Isis Lovecruft 690b0efc76
Rewrite unittest for encryption/decryption to multi recipients. 2013-05-27 09:28:18 +00:00
Isis Lovecruft c1fb532c53
Change unittest, recipients doesn't need to be list, and data should be string. 2013-05-27 09:25:34 +00:00
Isis Lovecruft 622544ef13
Rewrite test_encryption_multi_recipient to also test separate keyrings option. 2013-05-27 09:23:32 +00:00
Isis Lovecruft 348c5b59fb
If setting Key-Length, also set Subkey-Length, else GnuPG defaults to 1024. 2013-05-27 09:20:51 +00:00
Isis Lovecruft 70ceb50744
Fix a unittest so that the data returned is a human readable string. 2013-05-27 09:18:13 +00:00
Isis Lovecruft c4ab6bd5d6
Change unittest, recipients don't need to be lists/tuples. 2013-05-27 09:17:27 +00:00
Isis Lovecruft 2c577466c3
Add two helpful debug statements, remove two superfluous asserts from unittest. 2013-05-27 09:14:38 +00:00
Isis Lovecruft a9ea5a1e48
Change unittest because recipients don't needs to be lists/tuples anymore. 2013-05-27 09:13:55 +00:00
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