Rewrite PGPKeyConverter classes to fix support for X448,Ed448,X25519,… #1663
+1,716
−165
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()
BcPGPKeyConverter
BcPGPKeyConverter.getPrivateBCPGKey()
BcPGPKeyConverter.getPublicBCPGKey()
to detect key types based on algorithm IDEd448PublicBCPGKey
->EdDSAPublicBCPGKey
X448PublicBCPGKey
->ECDHPublicBCPGKey
JcaPGPKeyConverter.getPGPPublicKey()
:JcaPGPKeyConverter.getPublicKey()
:JcaPGPKeyConverter.getPublicBCPGKey()
to detect key types based on algorithm IDXDHPublicKeyImpl
keysPublicKeyAlgorithmTags
) to use native encoding for the private key materialPublicKeyAlgorithmTags.EDDSA_LEGACY
together with an Ed448 key (BC15EdDSAPublicKey
passed intoJcaPGPKeyConverter
) causedPGPException
(unknown key class))setProvider()
is not called onJcaPGPKeyConverter
)BcPGPKeyPair
of Ed25519 key + ECDH algorithm tag cannot be converted toJcaPGPKeyPair
EdDSAPublicKeyImpl
is not recognized inJcaPGPKeyConverter.getPublicBCPGKey()
->PGPException("unknown key class")
JcaPGPKeyPair
,PublicKeyAlgorithmTags.ECDH
together with an X448 key)BC11XDHPublicKey
is not recognized inJcaPGPKeyConverter.getPublicBCPGKey()
BcPGPKeyPair
withPublicKeyAlgorithmTags.EDDSA_LEGACY
and anXDHPublicKeyImpl
cannot be converted to aJcaPGPKeyPair
) (ifsetProvider()
is not called onJcaPGPKeyConverter
)JcaPGPKeyConverter.getPublicBCPGKey()
does not recognizeXDHPublicKeyImpl
Further, 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.