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

Updated keyScan to ignore trailing spaces in KEYINFO attributes #10

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dovys
Copy link

@dovys dovys commented Feb 12, 2019

Hey,
I've recently ran into a rather odd issue where some keys have a trailing space at the end of the card ID:

> keyinfo --show-fpr --list --ssh-fpr
S KEYINFO 61D048F46EE1DCE... T D2760001240102010006064000390000  OPENPGP.3 - - MD5:9b:c8:3c:7b:44:... - -

This breaks key scanning as the scanner thinks there are 11 parts to it instead of 10. This change should be safe as gpg-agent returns a dash (-) when the value is actually empty.

I've recently ran into a rather odd issue where some keys have
a trailing space at the end of the card ID:
> keyinfo --show-fpr --list --ssh-fpr
S KEYINFO 61D048F46EE1DCE... T D2760001240102010006064000390000  OPENPGP.3 - - MD5:9b:c8:3c:7b:44:... - -

This breaks key scanning as the scanner thinks there are 11 parts to it
instead of 10.  This change should be safe as gpg-agent returns a dash
when the value is actually empty.
@prep
Copy link
Owner

prep commented Feb 17, 2019

That's odd. However, looking at your code, wouldn't it be simpler to change this line

	parts := strings.Split(line, " ")

to this?

	parts := strings.Split(strings.TrimSpace(line), " ")

jackkleeman and others added 5 commits February 27, 2019 15:46
…lely querying the yubikey, thus ignoring any cached keys.
Keygrips function for finding all keys on card
Trim leading signature zeros if needed
Newer versions of GPG can add an extra field to the KEYPAIRINFO lines,
for example:

S KEYPAIRINFO F877E5110AE0878B14C75747397DA0755EC51613 OPENPGP.3 sa

vs

S KEYPAIRINFO A6D4D888546D31DA593F65246BB13DB2F98DB42E OPENPGP.3

This change makes our parser tolerate this format. It adds extra
validation on the card ID and keygrip fields, ignoring ones that
are invalid.

I could not run the tests and gave up after five minutes. 🙈
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants