45 Commits

Author SHA1 Message Date
Michael Greene
10f7d765e3 Merge pull request #394 from ignaloidas/default-to-3DES
Default to 3DES when preferred algorithms don't have any supporting algorithm
2022-11-02 21:24:56 -07: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
Ignas Kiela
e0eb8fb4a5 Default to 3DES when preferred algorithms don't have any supporting algorithm
As per RFC 4880 13.2, "Since TripleDES is the MUST-implement algorithm,
if it is not explicitly in the list, it is tacitly at the end."

Some keys in the wild do not have it explicitly in the list, so put it
there as a default.
2022-04-20 17:53:29 +03:00
James Morris
3a1f7bf3db Merge branch 'master' into master 2020-09-24 17:38:54 -04:00
Michał Górny
59c4050088 Fix dash escaping to be applied unconditionally
According to RFC 4880, 'an implementation MAY dash-escape any line,
SHOULD dash-escape lines commencing "From" followed by a space [...]'.
Therefore it is necessary to unescape all lines starting with dash-space
sequences, and not just these that have a dash following this sequence.

Fixes #341

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2020-09-08 19:37:37 +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
Mac Malone
26f5b358ee Added one-pass signature order regression test 2019-12-02 16:45:17 -05:00
Daniel Kahn Gillmor
777faa8343 Max out S2K parameters
There were issues in trying to do CPU tuning (see #279 and #157 for
examples).

The simpler approach, given the capacity of modern hardware and the
antiquity of OpenPGP's S2K parameters, is just to always use the
maximum S2K settings.  This also saves us some CPU from running
calibration steps.

This commit also drops the test for #157 entirely, because that test
embeds assumptions about the way that calibration is done that are no
longer true.

If this is merged, we should close #279 without merging it.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-11-02 00:19:03 -04:00
Daniel Kahn Gillmor
494e88473d When Signature Creation Time is supplied, use UTC
When the Signature Creation Time was supplied to the signing function,
we were ignoring the fact that it might have a different timezone than
UTC.  But the stored timestamp is supposed to always be in UTC, so it
should roundtrip correctly.

This includes a test to ensure that we don't end up with a regression.

Closes: #291
2019-10-21 13:13:04 -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
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
Michael Greene
2bd4054674 fix failing test and resolve deprecation warning 2019-08-01 14:24:27 -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
Michael Greene
fbd2796863 Merge pull request #259 from dkg/cryptography-1.5
move to python-cryptography v1.5
2019-07-31 09:08:40 -07:00
Daniel Kahn Gillmor
d281d6ec17 move to python-cryptography v1.5
version 1.5 (released nearly 3 years ago, on 2016-08-26) introduced
sign() and verify() for all asymmetric algorithms.

Without this change, with modern versions of python-cryptography, we
see warnings like:

/usr/lib/python3/dist-packages/pgpy/packet/fields.py:1177: CryptographyDeprecationWarning: signer and verifier have been deprecated. Please use sign and verify instead.

The version of python-cryptography in debian stretch (oldstable) is
1.7.1, for point of reference.
2019-07-17 04:41:27 -04:00
Daniel Kahn Gillmor
148fbf6948 Avoid warnings about bad escape characters
Python strings don't use \ to escape either * or !.  So the
declarations here were adding to the list of warnings during the run
of the test suite.

Declaring them as raw (unescaped) strings keeps the warnings more quiet.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-07-17 02:58:47 -04:00
Wolf480pl
c168de2199 #243 - add a regression test 2018-07-15 00:20:18 +02:00
Michael Greene
f1c3d68e32 #226 - added regression test 2017-11-14 14:11:59 -08: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
b7226e1777 Fix PGPKey.from_blob('') not raising an exception. Fixes #199. 2017-07-28 14:55:30 +02:00
J08nY
484b581878 Add regression tests for #192. 2017-06-29 22:22:31 +02:00
Michael Greene
b24831e243 #194 - regression test 2017-06-28 15:35:28 -07:00
Michael Greene
e7a0807093 #185 - added regression test 2017-06-21 17:32:30 -07:00
Michael Greene
efdbd5f40f #172 - regression test added 2017-04-25 17:53:29 -07: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
efbdb7305d asserting here seems wrong (and makes the test fail when that isn't entirely the point of this particular regression test) 2016-06-10 16:27:00 -07:00
Michael Greene
0c941948a3 improved the test to check that the resulting count value is actually close to the target, and improved tune_count accordingly - closes #157 2016-06-09 16:13:12 -07:00
Michael Greene
e1515f755a - made HashAlgorithm.tune_count more robust and added a regression test for it - closes #157
- PEP8
2016-06-09 14:59:13 -07:00
Michael Greene
b227af0490 regression test for #140 2015-06-01 18:21:47 -07:00
Michael Greene
275d51791f bump cryptography version to 0.8; this also requires a few changes in how keys are interfaced with 2015-04-12 18:43:50 -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
8fdc9dd1f6 Python 2.7 unit test fix 2014-09-17 12:03:31 -07:00
Michael Greene
28b1f1b86d some much needed test and testdata cleanups; fixed verification being skipped in test_reg_bug_56; resolved regression test_reg_bug_56 was meant to prevent 2014-09-16 20:22:53 -07:00
Michael Greene
8728969f3d (both One-Pass and not) signed message signature verification now works - closes #117 2014-09-08 13:29:48 -07:00
Michael Greene
4b54c9790f added unit tests:
- test verifying a signature with the wrong key
 - test verifying an invalid signature (wrong or modified subject) - closes #44
 - cleaned up test_reg_bug_56
2014-09-03 17:06:46 -07:00
Michael Greene
5265e32ffe header length updating first pass - closes #93 2014-09-03 14:15:45 -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
443604b9f6 stubbed out the new PGPKeyring and a test harness for it
incremental update to test_reg_bug_56 to begin transitioning into using PGPKey and PGPSignature instead of directly using the packets and TempExportableSig
added stub property __key__ to PGPKey
[skip ci]
2014-08-13 21:02:48 -07:00
Michael Greene
943c39c0bb fixed Python 2.7 2014-08-10 02:34:35 -07:00
Michael Greene
5ba1095ec0 python 3.2 works now 2014-08-10 01:54:12 -07:00
Michael Greene
1e30047ed8 whoops 2014-08-09 20:07:21 -07:00
Michael Greene
1c4667c7f4 refactored MPI field classes to:
- store key parts as integers #94
 - private MPI classes now also store the public key fields - #92
 - do the work to set up the Cryptography public/private key objects. Private key field objects can also return public key objects, so this is part of what is needed for #92
 - updated unit tests to work with the refactored code
2014-08-09 19:52:06 -07:00
Michael Greene
6728b0b9b3 more test stuff 2014-08-09 13:09:15 -07:00