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

Add support for unknown PGP key types #1696

Closed
wants to merge 7 commits into from

Conversation

vanitasvitae
Copy link
Contributor

@vanitasvitae vanitasvitae commented Jun 4, 2024

This PR adds support for OpenPGP (v6) keys with unknown public key algorithms.

The v6 test key

-----BEGIN PGP PUBLIC KEY BLOCK-----

xhQGZl7182MAAAAKAAECAwQFBgcICQ==
=anvn
-----END PGP PUBLIC KEY BLOCK-----

contains a key with unknown algorithm 99 and consists of the octets 0-9:

Public-Key Packet, new CTB, 2 header bytes + 20 bytes
    Version: 6
    Creation time: 2024-06-04 11:09:39 UTC
    Pk algo: Unknown algo 99
    Fingerprint: ACD6CEC3A014079F78DA9A60B98F9E3D4E7321834E1EBEC68A1C3701F882D5A3
    KeyID: ACD6CEC3A014079F
  
    00000000  c6                                                 CTB
    00000001     14                                              length
    00000002        06                                           version
    00000003           66 5e f5 f3                               creation_time
    00000007                       63                            pk_algo
    00000008                           00 00 00 0a               public_len
    0000000c                                       00 01 02 03   rest
    00000010  04 05 06 07 08 09

Handling unknown keys gracefully is possible with v6 keys, since the key encoding length is known.

TODO: Figure out, if we can also support unknown v4/v5 keys.

@vanitasvitae
Copy link
Contributor Author

We can only gracefully parse v5, v6 keys, since secret key packets simply append the secret key material after the public key material, so when parsing a v4 secret key, we don't know, when to stop parsing the public key material.
V5 and v6 keys include an additional field encoding the public key length to enable graceful parsing (as implemented here).

@jill-kleiber jill-kleiber self-assigned this Jul 11, 2024
@dghgit dghgit closed this Jul 24, 2024
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