Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix 281, warn if expiration subpacket is not hashed #288

Merged
merged 1 commit into from
Jun 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions in_toto/gpg/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ def _get_verified_subkeys(bundle):
except Exception as e:
log.info(e)
continue

# NOTE: As per the V4 key structure diagram in RFC4880 section 12.1., a
# subkey must be followed by exactly one Primary-Key-Binding-Signature.
# Based on inspection of real-world keys and other parts of the RFC (e.g.
Expand All @@ -467,7 +466,6 @@ def _get_verified_subkeys(bundle):
"signatures ({}), must be exactly 1.".format(subkey["keyid"],
len(key_binding_signatures)))
continue

is_valid = handler.gpg_verify_signature(signature,
bundle[PACKET_TYPE_PRIMARY_KEY]["key"], signed_content,
signature["info"]["hash_algorithm"])
Expand Down Expand Up @@ -714,9 +712,18 @@ def parse_signature_packet(data, supported_signature_types=None,
# conflict resolution scheme that makes more sense.
# (see RFC4880 5.2.4.1.)
# Below we only consider the last and favor hashed over unhashed subpackets
# TODO: Should we warn if a we use an unhashed subpacket?
for subpacket_type, subpacket_data in \
unhashed_subpacket_info + hashed_subpacket_info:
for idx, subpacket_tuple in \
enumerate(unhashed_subpacket_info + hashed_subpacket_info):

is_hashed = (idx >= len(unhashed_subpacket_info))
subpacket_type, subpacket_data = subpacket_tuple

# Warn if expiration subpacket is not hashed
if subpacket_type == KEY_EXPIRATION_SUBPACKET:
if not is_hashed:
log.warning("Expiration subpacket not hashed, gpg client possibly "
"exporting a weakly configured key.")

if subpacket_type == FULL_KEYID_SUBPACKET: # pragma: no cover
# Exclude from coverage for consistent results across test envs
# NOTE: The first byte of the subpacket payload is a version number
Expand Down