1231 Commits

Author SHA1 Message Date
James Morris
0c27e02cea Make sure apt-get is always called with '-y' 2020-07-16 16:53:12 -04: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
James Morris
9440ed0b62 Corrected python version for pep8 test 2020-07-16 12:29:28 -04:00
James Morris
7d6119ceed Pin PyYAML so Python 3.4 tests will pass 2020-07-13 14:06:22 -04:00
James Morris
4ea9d0f654 Merge pull request #324 from MatthewWesley/patch-1
Fix comment to align with example
2020-07-13 13:03:34 -04:00
Matthew Wesley
d39ff814ab Fix comment to align with example
The example code sets the key to expire in one year using timedelta(days=365), although the leading comment implies it will be set to ten years.
2020-06-26 14:57:40 -06:00
Mac Malone
26f5b358ee Added one-pass signature order regression test 2019-12-02 16:45:17 -05:00
Mac Malone
c885f7c4f7 Fixed the ordering of OnePassSignatures 2019-11-03 20:22:37 -05:00
Michael Greene
3c18597753 Merge pull request #301 from dkg/s2k-on-modern-hardware
Max out S2K parameters
2019-11-02 09:27:20 -07:00
Michael Greene
986f5d2722 try utf-8 first; fall back to charmap if that fails 2019-11-01 22:57:40 -07: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
Michael Greene
2b9de7490c Merge pull request #280 from dkg/simplify-userid
User IDs: simplify, treat as UTF-8 strings
2019-11-01 16:36:37 -07:00
Michael Greene
f308827477 Merge pull request #285 from dkg/intended-recipient
handle and generate Intended Recipient subpackets
2019-11-01 16:35:42 -07:00
Michael Greene
d32aebe19f Merge branch 'master' into intended-recipient 2019-11-01 16:35:34 -07:00
Michael Greene
1324e0ac79 Merge pull request #287 from dkg/attested-certifications
Implement First-Party Attested Third-Party Certifications (1PA3PC)
2019-11-01 16:33:10 -07:00
Michael Greene
1db28e58a7 Merge pull request #299 from dkg/quieter-generation
Avoid noisy warnings when generating messages
2019-11-01 16:31:50 -07:00
Daniel Kahn Gillmor
6e34a00a50 Avoid noisy warnings when generating messages
Similar to the concerns in #297, there are noisy warnings produced
when encrypting data to or signing data with a primary key, if a
subkey is ultimately what ends up being used:

```
./generate-test-vectors:279: UserWarning: Key F231550C4F47E38E does not have the required usage flag EncryptStorage, EncryptCommunications; using subkey 4766F6B9D5F21EB6
  encmsg = alice_key.pubkey.encrypt(payloadmsg, cipher=cipher, sessionkey=sessionkey)
```

This change converts these warnings to debug information.

In #298, we just removed the noisy warnings on consuming data -- the
caller really has no choice in how to consume the data, so there's no
point in sending them alerts.  Either we can decrypt or verify with
the primary key or one of the subkeys, or we can't.

But in the situation where the caller is producing data -- signing or
encrypting -- we might want be a little bit noisier, because the user
really might have some obscure reason that they prefer to use a
specific subkey that the library isn't in a position to understand.
So giving the user a hint at debug-level about what's going on is
probably reasonable.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-11-01 16:46:03 -04:00
Michael Greene
2f53b9fbc9 Merge pull request #298 from dkg/fix-297
Drop noisy warning on decrypting with subkey
2019-11-01 13:38:41 -07:00
Daniel Kahn Gillmor
2152e4b261 Removing warning about signature verification with subkey
Commod0re requested this change, in line with the change I requested
in #297 about decrypting with subkeys.  I think it's the right thing
to do.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-11-01 16:28:32 -04:00
Daniel Kahn Gillmor
14656c962f Drop noisy warning on decrypting with subkey
This warning doesn't appear to be actionable, and is likely to only
encourage users of PGPy to do extra gymnastics before calling
decrypt().

Closes #297

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-11-01 16:07:31 -04:00
James Morris
865dce1904 Merge pull request #296 from dkg/fixup-286
Fix up minor bug introduced in #286
2019-10-31 11:14:36 -04:00
Daniel Kahn Gillmor
a75e3a008a Fix up minor bug introduced in #286 2019-10-31 02:20:01 -04:00
Michael Greene
a3830cc831 Merge pull request #286 from dkg/specify-creation-time
specify creation time more completely
2019-10-26 10:10:57 -07:00
Michael Greene
43b4d4efe8 Merge pull request #284 from dkg/gen-issuer-fingerprint
PGPKey._sign: include hashed Issuer Fingerprint subpacket by default.
2019-10-26 10:10:09 -07:00
Michael Greene
445f912ce1 Merge pull request #282 from dkg/keyserver-prefs
KeyServerPreferences is a bitfield, not a list
2019-10-26 10:09:33 -07:00
Michael Greene
c2bb150784 Merge pull request #292 from dkg/sigtime-utc
When Signature Creation Time is supplied, use UTC
2019-10-26 10:07:57 -07:00
Michael Greene
cf7cc98cd1 update changelog for next version 2019-10-26 10:03:03 -07:00
Michael Greene
8de7c64ae6 passphrases should be unicode, not latin-1 2019-10-26 10:01:34 -07:00
James Morris
1132a75925 Merge pull request #283 from dkg/document-exportable
PGPKey.certify: document exportable flag
2019-10-25 19:43:16 -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
c300d9b6f3 PGPUID: add convenience functions to retrieve attested 3PCs
These helper functions make it easy to verify which third-party
certifications are currently attested to by the primary key.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-09-18 19:28:28 -04:00
Daniel Kahn Gillmor
1c9b55a0df Implement Attested Certifications
This makes the No-modify flag for Key Server Preferences actionable,
by allowing the primary key holder the ability to indicate which
third-party certifications are acceptable for redistribution.

See https://gitlab.com/openpgp-wg/rfc4880bis/merge_requests/20 for
more details.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-09-18 19:28:28 -04:00
Daniel Kahn Gillmor
f623661d99 handle and generate Intended Recipient subpackets
In rfc4880bis version 08, we have a specification for the Intended
Recipients subpacket, which can help to defend against certain kinds
of subtle attacks that involve re-wrapping a signed message to encrypt
it to someone else.

See https://gitlab.com/openpgp-wg/rfc4880bis/merge_requests/19 and
https://0xacab.org/schleuder/schleuder/issues/158 for more details
about this subpacket.

Assuming that `alice` is the PGPKey of the sender, and `bob` is the
PGPKey of the recipient, The simplest way to use this when generating
a message in PGPy is:

```
msg = PGPMessage.new('test message')
msg |= alice.sign(msg, intended_recipients=[bob])
msg = bob.encrypt(msg)
```

And it can be checked on Bob's side with:

```
cleartext = bob.decrypt(msg)
for sigvfy in alice.verify(cleartext).good_signatures:
    if bob.fingerprint in sigvfy.signature.intended_recipients:
        print("meant for Bob")
```

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-09-11 21:55:36 -04:00
Daniel Kahn Gillmor
afb2aa103c SignatureV4: add canonical_bytes() function
This function allows the user to easily get the canonicalized
bytestring representation of the signature.  This is useful for making
third-party confirmation signatures (sig type 0x50), as well as
Signature Target subpackets (subpacket 31), and other pointers to
specific signatures.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-09-01 15:58:49 -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
ae1f29072f specify creation time
While #262 made it possible to set creation times in some places, it
missed some others.

This makes the created= argument functional in all the contexts where
it could be useful.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-28 01:34:22 -04:00
Daniel Kahn Gillmor
30eb24aaf7 PGPKey._sign: include hashed Issuer Fingerprint subpacket by default.
GnuPG has been including hashed Issuer Fingerprint subpackets by
default in signatures since 2016-10-08.  This subpacket makes it
possible to distinguish between a bad signature and a signature that
we happen to not have the issuer's key for.

We add it here for normal signature, certifications, and revocations,
unless the signer explicitly requests that it not be included.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-27 18:47:56 -04:00
Daniel Kahn Gillmor
df87950519 User IDs: simplify, treat as UTF-8 strings
Over in #271, we discussed simplifying the lower-level UserID packet
object, and moving the <name,comment,email> splitting logic up into
the higher-layer PGPUID API.

This patch does that work, and also exposes an additional
PGPUID.userid property, which is the full UTF-8 string.

If this gets merged, it will obsolete #271.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-27 16:52:33 -04:00
Daniel Kahn Gillmor
c639a03858 PGPKey.certify: document exportable flag
The exportable flag is already implemented, but it is not documented
in the docstring.  This addresses that concern.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-27 16:50:45 -04:00
Michael Greene
21cbf0d006 Merge pull request #278 from dkg/avoid-python-gpg-segv
tests: avoid references to gpg.Context after deletion
2019-08-27 10:26:59 -07:00
Michael Greene
d7bbf73dd3 Merge pull request #281 from jonathancross/ed25519-docs
progress.rst : Updating Ed25519 status
2019-08-27 10:25:45 -07:00
Michael Greene
e2893da8b2 Merge pull request #277 from dkg/unarmor-liberally
types: Unarmor more liberally
2019-08-27 10:22:18 -07:00
Jonathan Cross
600c7f6cee progress.rst : Updating Ed25519 status 2019-08-27 19:06:35 +02:00
Daniel Kahn Gillmor
75beb08733 types: Unarmor 76-character-long lines
When 76-char base64 lines were present, PGPy was failing to de-armor
them.

Closes: #276
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-27 11:54:10 -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
9fc933834a Merge pull request #273 from dkg/issuer-fingerprint
IssuerFingerprint - include spec and update length for v5
2019-08-02 14:26:55 -07:00
Michael Greene
da1356b07f Merge pull request #272 from dkg/allow-skipping-cross-signing
Permit skipping cross-signing unless strictly required
2019-08-02 14:24:59 -07:00
Michael Greene
a2ce861afa Merge pull request #275 from dkg/docstring-cleanup
Fix sphinx warnings about IDEA documentation
2019-08-02 14:24:07 -07:00
Daniel Kahn Gillmor
138b0d555a Fix sphinx warnings about IDEA documentation
Without this change, the warning about IDEA is not properly rendered
in html, and ./setup.py build_sphinx itself produces a warning:

…/pgpy/constants.py:docstring of pgpy.constants.SymmetricKeyAlgorithm.IDEA:1: WARNING: Content block expected for the "warning" directive; none found.
…/pgpy/constants.py:docstring of pgpy.constants.SymmetricKeyAlgorithm.IDEA:2: WARNING: Explicit markup ends without a blank line; unexpected unindent.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
2019-08-02 16:56:01 -04:00
Daniel Kahn Gillmor
c066719eb4 Permit skipping cross-signing unless strictly required
This is done by setting 'crosssign' to False in the prefs parameter to
the sign function.

You probably don't want to use this feature! It is likely to make
OpenPGP certificates without cross-signatures that some other
implementations will reject.
2019-08-02 15:53:23 -04:00