Commit Graph

62 Commits

Author SHA1 Message Date
Daniel Kahn Gillmor
c880d72902 Generate and use TZ-aware datetime objects
pgpy has been using TZ-naive datetime objects, despite all OpenPGP
wire-format dates being essentially UTC.

Better to represent the datetime objects explicitly as UTC.

Closes: #401
2022-11-09 07:52:28 -05:00
Kian-Meng Ang
6e5b685be3 Fix typos
Found via `codespell -L nd,wth,te,useg,bu,fpr,fo,clen,varius,unce`
2022-10-10 17:13:41 +08:00
James Morris
2536f36067 Fix mispelled tests messing with ordering 2021-09-23 18:59:41 -04:00
Gabriel Cruz
50ef17a9b1 Feature:: Support for keys without usage flags (#371)
Co-authored-by: James Morris <jmorris@securityinnovation.com>
2021-07-08 15:52:09 -04:00
Paul Mulders
e2f427ea5c Port tests/test_05_actions.py to pytest-order 2021-06-23 17:58:34 +02:00
James Morris
feabf6c2fd Fixed import try/except in tests so that pypy doesn't immediately choke 2020-07-16 16:37:46 -04:00
Daniel Kahn Gillmor
6d7877d167 KeyServerPreferences is a bitfield, not a list
Key Server Preferences (RFC 4880 §5.2.3.17) is a bitfield, more like
Key Flags (RFC 4880 §5.2.3.21) than Preferred Hash Algorithms (RFC
4880 §5.2.3.8).

The caller should be able to invoke this as a set when calling
PGPKey.certify().

This patch also improves documentation for PGPKey.certify() to
indicate how to pass in these flags.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-28 02:09:55 -04:00
Daniel Kahn Gillmor
a972df5672 tests: avoid references to gpg.Context after deletion
Some older versions of the python bindings for GPGME produce python
objects that reference the underlying gpg.Context objects.

When a gpg.Context is used in a "with" clause, it is disposed of at
the end, and any resulting objects that reference that context object
are dangling.

This doesn't seem to be a problem with gpgme 1.13.1 (the current
version), but i was seeing segfaults in the PGPy test suite when used
with gpgme 1.12.0 :(

These fixes should make PGPy's test suite more robust against this
kind of failure.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-27 11:15:50 -04:00
Michael Greene
e19e4181af ACTUAL fix for this bug 2019-08-01 19:24:36 -07:00
Michael Greene
15c90e2513 - correct missed copyright notices (need to add more of these)
- bump version string to 0.5.0
- change a list to a set
2019-08-01 16:09:13 -07:00
Michael Greene
824f2649fb soft unit test update pass:
- first pass super basic integration test separation
- BCPG decryption tests now pass so removed XFAIL marker
- remove unused imports
- added some warning filtering to reduce noise
2019-08-01 15:45:47 -07:00
rot42
d601655c27 support for Ed25519 signatures
This increases the versioned dependency on the cryptography module to
2.6, since that is the version that provides the necessary ed25519
functionality.

We also add a "pure" 25519 OpenPGP certificate for testing purposes.

Closes #221, #222, #247

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-01 15:57:48 -04:00
rot42
53c6c3ba94 support for ECDH encryption using Curve25519 (cv25519)
This increases the minimum versioned dependency on the cryptography
module to 2.5, where the necessary features are exposed.

We also add a mixed RSA + ECDH OepnPGP certificate for testing
purposes.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-01 15:54:06 -04:00
Daniel Kahn Gillmor
e0e516ed7f test the names of the curves against the stored list
We were testing the wrong version of the curve string.  With this
change on python-cryptography 2.6.1 and openssl 1.1.1c, we drop from
26 xfailed to 14 xfailed tests.
2019-07-17 02:49:29 -04:00
Michael Greene
db7d00fc3f Merge pull request #207 from J08nY/feature/key-revocations
Add revocation_signatures property to PGPKey.
2019-06-07 14:45:42 -07:00
Michael Greene
0cc3fe6bc1 gpg is finnicky sometimes 2017-08-18 13:04:07 -07:00
Michael Greene
bdd04fba1e try building libgpgme and libgpg-error 2017-08-16 18:42:24 -07:00
Michael Greene
ca7ca6b24d bugfixen
- added missed call to _compute.chksum in ECDSAPriv
- replaced all gpg wrapper fixtures in the unit test suite with gpg package
- moved test suite gnupghome location to tests/gnupghome
2017-08-15 21:43:37 -07:00
J08nY
e9733da494 Add revocation_signatures property to PGPKey.
- Exposes the revocation signatures of the key(primary or sub).

> OpenPGP users may transfer public keys.  The essential elements of a
>   transferable public key are as follows:
>
>     - One Public-Key packet
>
>     - Zero or more revocation signatures
2017-08-07 17:13:36 +02:00
Michael Greene
41bff26e46 test suite kerjiggering 2017-08-04 13:19:32 -07:00
Michael Greene
0610b3d464 add some logic so that test_gen_key and test_add_subkey can imperatively skip generating keys that the current OpenSSL build does not have available 2017-08-04 12:58:34 -07:00
Michael Greene
b86829a3c6 handle non-unicode locales. Fixes #173 2017-08-04 12:33:55 -07:00
J08nY
26b6f70297 Add tests for signing an encrypted message. 2017-06-29 13:36:00 +02:00
Michael Greene
c9d39e3ebc unit test cleanups and additions 2017-02-27 10:05:57 -08:00
Michael Greene
0ab3a67288 cleanup
[skip ci]
2017-02-16 20:36:00 -08:00
Michael Greene
c5d26db522 unit test suite is finally fixed, I think! 2017-02-16 20:25:43 -08:00
Michael Greene
325281c63d typo city 2017-01-23 11:39:01 -08:00
Michael Greene
8163d535cb more test checks to eliminate unintended failures 2017-01-23 11:23:48 -08:00
Michael Greene
d1abdcb518 test checks to eliminate unintended failures 2017-01-23 11:16:44 -08:00
Michael Greene
b3a86fe0d8 cleanup 2017-01-23 11:09:48 -08:00
Michael Greene
3321022287 significantly updated unit test suite to work with py.test 3.x; renamed a few files 2017-01-11 14:04:42 -08:00
Michael Greene
a0486e116c this is fine 2016-12-20 14:38:37 -08:00
Michael Greene
761637d395 some gpg improvements; hopefully this will be a little more version resilient 2016-12-20 14:32:26 -08:00
Michael Greene
6a47ed5259 bah! 2016-06-02 17:02:44 -07:00
Michael Greene
fcb5058ae5 - better organization for running the tests, plus slight change to the fix itself [#156]
- locked py.test to 2.9.1 for now so I can figure out the changes to fixtures that are breaking my tests later
2016-06-02 16:47:44 -07:00
Michael Greene
7c6f01e7af very minor organization tweak
[skip ci]
2016-04-22 17:15:00 -07:00
Michael Greene
2a5e8209ea - added Brainpool Standard curve support (matching GnuPG) for users with openssl >= 1.0.2
- bumped dev branch version to 0.5.0
2016-04-22 17:10:51 -07:00
Michael Greene
848c8afe28 - added SECP256K1 curve to EllipticCurveOID because GnuPG supports it
- marked some regression tests as such
 - minor organization stuff
[skip ci]
2016-04-21 18:46:28 -07: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
9fb619067e expanded PGPMessage testing somewhat and organized the literal data files a bit better
[skip ci]
2016-02-26 16:20:43 -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
3cbad620e1 - generalized/refactored away some repeated code in MPIs subclasses
- updated __all__ in a few places
- improved test_exports
- pep8
2016-02-16 21:05:21 -08:00
Michael Greene
e8326b4771 - correctly deriving the KEK length now for KDF
- added missing OIDs for EllipticCurveOID enum members
 - expanded test of expected key generation failures to test all ECC OIDs that aren't implemented yet
 - some minor code cleanups
2016-02-16 16:23:13 -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
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
8ee07a2ef8 - renamed PGPSignature.expired to PGPSignature.is_expired for consistency
- renamed PGPSignature.expires to PGPSignature.expires_at for consistency
 - added missing property PGPKey.expires_at
 - added documentation to PGPUID's class docstring to indicate that it implements __format__ for GnuPG-like formatting of User IDs.
2014-10-17 14:44:57 -07:00