Rewrite PGPKeyConverter classes to fix support for X448,Ed448,X25519,… - #1663
Merged
Conversation
Contributor
Author
|
I noticed, that crypto-refresh-13 states that X25519 keys using the dedicated algorithm ID not only do not use MPI encoding, but also do not encode the key in reverse order. |
Contributor
Author
|
I think I got it. The reverse coding only affects secret key material. I was mostly focussing on public key material during my investigations. |
vanitasvitae
force-pushed
the
fixKeyConversion
branch
from
May 21, 2024 10:33
196a9ec to
8f258b1
Compare
Contributor
Author
|
I rebased the PR into two commits. Edit: This PR also fixes #1584 |
This was referenced May 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…Ed25519 keys
Obsoletes #1658
This patch
PGPKeyConverter.implGetKdfParameters()BcPGPKeyConverterBcPGPKeyConverter.getPrivateBCPGKey()BcPGPKeyConverter.getPublicBCPGKey()to detect key types based on algorithm IDEd448PublicBCPGKey->EdDSAPublicBCPGKeyX448PublicBCPGKey->ECDHPublicBCPGKeyJcaPGPKeyConverter.getPGPPublicKey():JcaPGPKeyConverter.getPublicKey():JcaPGPKeyConverter.getPublicBCPGKey()to detect key types based on algorithm IDXDHPublicKeyImplkeysPublicKeyAlgorithmTags) to use native encoding for the private key materialPublicKeyAlgorithmTags.EDDSA_LEGACYtogether with an Ed448 key (BC15EdDSAPublicKeypassed intoJcaPGPKeyConverter) causedPGPException(unknown key class))setProvider()is not called onJcaPGPKeyConverter)BcPGPKeyPairof Ed25519 key + ECDH algorithm tag cannot be converted toJcaPGPKeyPairEdDSAPublicKeyImplis not recognized inJcaPGPKeyConverter.getPublicBCPGKey()->PGPException("unknown key class")JcaPGPKeyPair,PublicKeyAlgorithmTags.ECDHtogether with an X448 key)BC11XDHPublicKeyis not recognized inJcaPGPKeyConverter.getPublicBCPGKey()BcPGPKeyPairwithPublicKeyAlgorithmTags.EDDSA_LEGACYand anXDHPublicKeyImplcannot be converted to aJcaPGPKeyPair) (ifsetProvider()is not called onJcaPGPKeyConverter)JcaPGPKeyConverter.getPublicBCPGKey()does not recognizeXDHPublicKeyImplFurther, this patch adds comments to make it easier to distinguish the different branches for different key types.
With the patch, X25519, X448, Ed25519, Ed448 keys can be properly converted between BC, JCA whether or not
JcaPGPKeyConverter.setProvider(new BouncyCastleProvider())is called.