- fix capitalization and spelling of SecurityIssues flag members
- pythonize the names of SAFE_CURVES and MINIMUM_ASYMMETRIC_KE?Y_LENGTHS
- move the functionality of is_hash_considered_secure into a HashAlgorithm property called is_considered_secure where it always should have been
- move the functionality of check_assymetric_algo_and_its_parameters into a PubKeyAlgorithm function called validate_params like it always should have been
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
As new versions of OpenPGP signatures are defined, implementations may
provide multiple signatures, one of an older version for legacy
clients and one of a new version for clients that can read the new
signature form.
PGPy should skip over any signature whose version is not recognized.
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.
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>
In some cases, no selfsig will exist for PGPUID. In the event that a
selfsig-less PGPUIDs is compared with one that has a selfsig, the
missing selfsig should be "less than" the other.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
In some circumstances, no selfsig will be available. This change
ensures that is_primary doesn't raise an exception in those
circumstances.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.