Commit Graph

100 Commits

Author SHA1 Message Date
Michael Greene
2514c3908d fixed broken subkey translation when generating the public half of a private key - fixes #168 2017-02-16 17:22:35 -08:00
Michael Greene
5d08583856 always return consistent argument numbers 2016-12-20 14:31:59 -08:00
Michael Greene
a893965ebe more test coverage 2016-04-21 16:48:58 -07:00
Michael Greene
2817059e8f unit test coverage and a couple of minor fixed bugs found from running those tests 2016-04-21 16:07:31 -07:00
Michael Greene
137c5d4df4 - fixed improper munging of non-unicode inputs - #154
- added additional unicode tests - #153
 - fixed mixin/base class ordering of PGPObject subclasses
2016-02-26 16:23:02 -08:00
Michael Greene
a7742540ec - started adding memoryview stuff for further reducing parsing IO [#145]
added a memoryview wrapper for python 2 to make this usage more uniform
 - started implementing __copy__ methods to make copying PGP* objects less useless
 - added an initial set of copy tests
 - moved _parent stuff to a new mixin class ParentRef to reduce code duplication
   this also wraps _parent references in weakrefs to help reduce cycles
 - implemented recovering a public key from a private key [closes #92]
   added a test for this as well
2016-02-19 20:54:18 -08:00
Michael Greene
13e8d27f8e implemented Marker packet 2016-02-16 16:19:58 -08:00
Michael Greene
f31a802c73 - Implemented proper parsing of ECDH keys - closes #110
- Additional code needed to generate ECDH keys also added
 - Encrypt/decrypt using ECDH also works
 - Added some code to the test harness to start making it work with gpg 2.1
 - Fixed key generation tests to test generating keys using all possible algorithms
 - Updated documentation sources to reflect these changes
2016-02-15 22:48:01 -08:00
Michael Greene
9c6d9636b4 - implemented key protection such that unprotected private keys can be protected with passphrases, and already-protected passphrases can be re-protected with a new passphrase, and unit tests for these two scenarios - closes #149
- updated CI configs so that Python 3.2 can actually finish running the test suite without crashing since it is stuck on an older version of Cryptography
- added additional tests to test setup.py on all versions of Python after I noticed that a recent change would have made it break on Python 3.2
- enum34 should no longer be installed needlessly on Python 3.4 or newer
- added --no-cache-dir to tox's call to pip to install dependencies needed for testing
2015-06-11 19:55:07 -07:00
Michael Greene
c76ba55ee5 - Implemented proper parsing of ECDSA keys - closes #109
- Added ECDSA signing and verification - closes #111
 - ECDSA key generation is also supported
 - refactored some of the signing/verification machinery to simplify code in PGPKey._sign and PGPKey.verify
 - fixed a bug with Signature subpacket ByteFlags where the byte output was not being properly null-padded to the length of the subpacket when necessary, which led to the potential for key outputs that would fail to parse properly if update_hlen was not called (which is silly)
 - fixed string formatting UserID packets when the comment and/or email address are missing - closes #142
 - implemented OpaquePubKey and OpaquePrivKey so that keys using unimplemented formats can still be loaded without error, even if they can't be used
 - enabled initial key action testing using ecc.1.pub.asc and ecc.1.sec.asc (which also required copying the two signatures from ecc.1.pub.asc to ecc.1.sec.asc)
 - improved test output for some tests with auto-ids that were formed in an unfortunate manner
2015-06-10 22:39:21 -07:00
Michael Greene
f3300d3895 - fixed __all__ in each __init__.py (elements should be strings, not class references); added __all__ where appropriate to other files
- added preliminary test data for ecdh/ecdsa keys [obtained from https://sites.google.com/site/brainhub/pgpecckeys#TOC-ECC-NIST-P-256-key-no-passphrase]
   - also added logic to skip actually testing against that test data as it doesn't work yet
 - updated need.txt
[skip ci]
2015-06-05 20:10:04 -07:00
Michael Greene
84567e085f - PEP8
- modified tox.ini so that py32 can continue to be tested even though cryptography no longer supports it
 - Key Generation - #147 :
   - implemented new API method
   - added unit tests for generating keys, adding user ids, and adding new subkeys
   - added unit tests to test basic expected exception raising when trying to use incomplete keys
   - added a very basic key-completeness test to the @KeyAction decorator
 - added __contains__ to SignatureVerification
2015-06-01 17:45:41 -07:00
Michael Greene
f05e9e9a37 - bumped version to 0.4.0 (forgot to do this earlier)
- Key generation - #147 :
   - backend implementation for generating RSA and DSA keys is complete
   - first pass of making the API accomodate it appropriately
   - generating subkeys is not worked into the API yet
   - unit tests are not written yet
2015-05-29 18:38:05 -07:00
Michael Greene
6d3e4ab6f6 abstracted the serialization of PGP objects into binary form into new __bytearray__ methods to reduce IO and defer conversion to an immutable bytes/str object until the entire serialization task is complete 2015-04-12 18:58:13 -07:00
Michael Greene
accac2f702 - Selection of signing/encrypting user id is now possible; closes #121
- Forced ByteFlag subpackets to take/return sets now instead of lists
 - removed some properties from PGPKey
 - added new classmethod `from_blob` to Armorable
 - made some modifications to the unit tests to work with this stuff
2014-10-06 13:12:32 -07:00
Michael Greene
008c911877 fixed some unicode stuff and some encoding stuff; added more thorough unicode testing; moved deque sorting functions into a new subclass of deque; fixed some broken tests 2014-10-02 19:11:23 -07:00
Michael Greene
c8a34762bd Python 2.x fix 2014-10-02 10:50:26 -07:00
Michael Greene
92e02291ee fixed some property setter method names 2014-10-01 10:54:31 -07:00
Michael Greene
851f645cdd 100% test coverage - closes #115 2014-09-30 18:38:10 -07:00
Michael Greene
70038ef002 fixed a null-byte padding issue with decryption using RSA 2014-09-30 15:58:45 -07:00
Michael Greene
e52d130704 more coverage 2014-09-30 14:24:52 -07:00
Michael Greene
6d8c6c7171 PEP 8 2014-09-29 15:43:23 -07:00
Michael Greene
45afe9946f decrypting messages encrypted with multiple passphrases now works reliably; the MDC packet is now actually checked (using a constant time comparison function) after decryption 2014-09-29 15:21:17 -07:00
Michael Greene
9583136c35 creating new photo UIDs now works - #118; signing photo UIDs is now actually being tested 2014-09-25 13:15:19 -07:00
Michael Greene
61bf253a0f Python 2.x compatibility fixes 2014-09-25 11:46:28 -07:00
Michael Greene
919c6357b2 replaced TypedProperty with sdproperty; replaced ClassProperty with classproperty 2014-09-24 15:55:42 -07:00
Michael Greene
0141513cf8 can now encrypt a single PGPMessage with multiple passphrase(s) - closes #114 2014-09-15 17:11:10 -07:00
Michael Greene
73f38a4638 signing messages and adding those signatures to them now works - #114 2014-09-15 16:17:34 -07:00
Michael Greene
2387fc9c2d Verify key certifications - #99 2014-09-08 17:21:47 -07:00
Michael Greene
3c5a23d046 Message encryption using RSA - closes #105 2014-09-08 12:31:10 -07:00
Michael Greene
f9fbc64d69 Moved s2k count tuning to constants.HashAlgorithm - closes #116
Moved session key generator method to constants.gen_key, to facilitate encrypting messages with multiple decryption methods (e.g. several recipients private keys, or multiple passwords)
2014-09-05 17:11:48 -07:00
Michael Greene
7596d38f67 First pass for encrypting messages/storage using symmetric encryption only (via passphrase) - closes #113 2014-09-05 15:19:32 -07:00
Michael Greene
508c1fc634 PGPKey.unlock is now functionally implemented as a context manager, complete with basic memory wiping; basic unit test also implemented 2014-09-03 16:43:22 -07:00
Michael Greene
5265e32ffe header length updating first pass - closes #93 2014-09-03 14:15:45 -07:00
Michael Greene
f4458cc02e Passphrase-protected (symmetrically encrypted only; no public-key encryption) messages can now be decrypted - #113
Also fixed a parsing issue in SKESessionKeyV4
2014-08-27 15:37:53 -07:00
Michael Greene
b1eb37df64 - fixed the arguments for _decrypt in PrivKey.decrypt_keyblob
- UnsupportedAlgorithm is now re-raised as PGPDecryptionError in all cases as it should - closes #112
 - Reorganized some issuer/message retrieval code in PGPMessage
 - Simplified PGPMessage parsing logic; it now assumes those messages are correctly formatted, instead of trying to make sense of them at parsing time
 - Regenerated encrypted message test material to all be usable to test decryption using multiple public key algorithms (at this point, RSA and ElGamal (as DSA)); added a passphrase to one, as well, to test that
2014-08-27 14:32:54 -07:00
Michael Greene
658450640f - abstracted symmetric decryption so the actual cipher object construction and ciphertext decryption happens in one place to make the code easier to maintain
- moved asymmetric decryption into PKESessionKey as it makes more sense to have it in the one place where asymmetric decryption is even used
2014-08-27 12:57:05 -07:00
Michael Greene
30ffc7fd78 signing binary documents works again - first pass (still some cleanup to do, but this is a good start) 2014-08-25 17:22:33 -07:00
Michael Greene
07c4343841 verification of signatures of binary documents works again 2014-08-25 15:03:28 -07:00
Michael Greene
3b9f72e1d4 had the nested flag backwards 2014-08-25 11:36:06 -07:00
Michael Greene
3e9c136c5a added parsing of One-Pass signature packets 2014-08-25 11:29:54 -07:00
Michael Greene
98af166e90 added literal and compressed messages - #102 2014-08-22 20:59:50 -07:00
Michael Greene
9a55f873d8 can now parse Symmetric-Key Encrypted Session Key v4 packets; corrected a typo 2014-08-21 13:23:49 -07:00
Michael Greene
9ad050623d can now load Symmetrically Encrypted Data packets (tag 9); cannot yet decrypt them 2014-08-21 13:07:40 -07:00
Michael Greene
2dc7bf0a72 can now load parse (but not yet decrypt) packet tag 18 - Symmetrically Encrypted and Integrity Protected Data; added new test piece, Exportable Certification 2014-08-21 13:03:29 -07:00
Michael Greene
88d7836c57 compressed data packets can contain more than one packet 2014-08-21 11:44:42 -07:00
Michael Greene
c4e6cc9fea renamed 08.compressed to 08.compressed.deflate; added compress/decompress methods to the CompressionAlgorithm enum so CompressedData(Packet) can actually decompress the compressed packet within itself 2014-08-20 23:34:54 -07:00
Michael Greene
c1761abf51 - Implemented parser classes for Public-Key Encrypted Session Key v3 packets, Compressed Data packets, and Literal Data packets
- Added stub classes for Symmetric-Key Encrypted Session Key v4 packets, One-Pass Signature v4 packets, Symmetric-Key Encrypted Data packets, Marker packets, Symmetric-Key Encrypted and Integrity Protected Data v1 packets, and Modification Detection Code packets
 - Updated PGPKeyring a bit; now returns a list of unique fingerprints loaded by PPGKeyring.load and PGPKeyring.fingerprints
 - Added a shortcut property to PrivKeyV4 that returns True if the secret key material is encrypted, otherwise False
 - Fixed a small parsing bug in Opaque(Packet) that parsed incorrect lengths on versioned packets. This was previously dead code, so it would not have appeared before adding the versioned packet stubs.
2014-08-20 18:45:26 -07:00
Michael Greene
1ce179a4c4 - partially reimplemented PGPKeyring - #80
- fixed a typo in UserID packet regex that was causing it to capture well-formatted comments as part of the name
 - changed _signature fields for PGPKey and PGPUID to deques
 - moved is_ascii and is_path into FileLoader as staticmethods
 - fixed comment0 header in pubtest.asc
 - changed Fingerprint.__hash__ to return the hash of the fingerprint without any spaces
 - partially added first unit test for PGPKeyring
2014-08-15 01:17:00 -07:00
Michael Greene
95deebdc0d PGPKey is alive again! - #80
- Filled out EmbeddedSignature finally
 - Added EmbeddedSignatureHeader since Embeded Signatures don't have a tag or a length, just a version
 - Fixed a logic error in SubPackets.__contains__
 - Added tag class bases to *Key classes
 - Added a PacketTag enum
 - Shortened the names of the certification signature types in SignatureType
 - Expanded PGPSignature.prefs into separate methods
 - Added unit tests for PGPKey (for an rsa public key and an rsa private key)
 - This also brings us one step away from completing #76 and #71
2014-08-13 20:02:21 -07:00