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

Exporting public keys from PGPSecretKeyRing does denote sub keys as normal keys #381

Closed
vanitasvitae opened this issue Jul 11, 2018 · 4 comments

Comments

@vanitasvitae
Copy link
Contributor

@vanitasvitae vanitasvitae commented Jul 11, 2018

Hi!
My issue is the following: If I create a PGPSecretKeyRing containing a master key and a sub key, and then try to extract a PGPPublicKeyRing from it, the resulting key ring does only contain one key, as the sub keys are ignored. The cause for this is, that the sub keys are not carrying a PUBLIC_SUBKEY packet tag, but instead a PUBLIC_KEY tag. When creating the PGPPublicKeyRing, the sub keys are therefore ignored due to this line.

Inspecting the encoded PGPPublicKeyRing with gpg --list-packets also suggests, that only two normal public keys are exported.

I created this minimal example for you to recreate the issue.

@ghost
Copy link
Collaborator

@ghost ghost commented Jul 13, 2018

Thanks for the report. Yes, it's a bit dodgy... oh dear... try the latest beta, I think that should now be making sure the keys are converted into subkeys immediately.

https://www.bouncycastle.org/betas

Let us know how you go.

hubot pushed a commit that referenced this issue Jul 13, 2018
…is introduced immediately.
@vanitasvitae
Copy link
Contributor Author

@vanitasvitae vanitasvitae commented Jul 13, 2018

It seems to work now :)
Can you point me to which commit exactly fixed this issue, so I can try to create a workaround for my project until BC 1.61 is released?

Edit: Ah I see some related changes in 486c6d3

@ghost
Copy link
Collaborator

@ghost ghost commented Jul 13, 2018

Yes, it's the change to PGPKeyRingGenerator

@vanitasvitae
Copy link
Contributor Author

@vanitasvitae vanitasvitae commented Jul 16, 2018

For the record, I created this workaround for fixing this issue in retrospect on existing keys.
A quick test suggests, that it is working as intended, but I give no guarantees :D

neuhalje added a commit to neuhalje/bouncy-gpg that referenced this issue Dec 23, 2018
From the issue[1]:

  My issue is the following: If I create a PGPSecretKeyRing containing
  a master key and a sub key, and then try to extract a PGPPublicKeyRing
  from it, the resulting key ring does only contain one key, as the
  sub keys are ignored. The cause for this is, that the sub keys are not
  carrying a PUBLIC_SUBKEY packet tag, but instead a PUBLIC_KEY tag.

  When creating the PGPPublicKeyRing, the sub keys are therefore ignored
  due to this line.

  Inspecting the encoded PGPPublicKeyRing with gpg --list-packets also
  suggests, that only two normal public keys are exported.

[1] bcgit/bc-java#381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant