Skip to content

Commit 9ef9d60

Browse files
author
gefeili
committed
Replace lambdas in JcaPGPKeyConverter with anonymous classes
1 parent 716cb36 commit 9ef9d60

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcaPGPKeyConverter.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,24 +795,52 @@ else if (pubKey.getAlgorithm().regionMatches(true, 0, "XDH", 0, 3))
795795
// Modern Ed25519 (1.3.6.1.4.1.11591.15.1 & 1.3.101.112)
796796
case PublicKeyAlgorithmTags.Ed25519:
797797
{
798-
return getPublicBCPGKey(pubKey, Ed25519PublicBCPGKey.LENGTH, Ed25519PublicBCPGKey::new);
798+
return getPublicBCPGKey(pubKey, Ed25519PublicBCPGKey.LENGTH, new BCPGKeyOperation()
799+
{
800+
@Override
801+
public BCPGKey getBCPGKey(byte[] key)
802+
{
803+
return new Ed25519PublicBCPGKey(key);
804+
}
805+
});
799806
}
800807

801808
// Modern Ed448 (1.3.101.113)
802809
case PublicKeyAlgorithmTags.Ed448:
803810
{
804-
return getPublicBCPGKey(pubKey, Ed448PublicBCPGKey.LENGTH, Ed448PublicBCPGKey::new);
811+
return getPublicBCPGKey(pubKey, Ed448PublicBCPGKey.LENGTH, new BCPGKeyOperation()
812+
{
813+
@Override
814+
public BCPGKey getBCPGKey(byte[] key)
815+
{
816+
return new Ed448PublicBCPGKey(key);
817+
}
818+
});
805819
}
806820

807821
// Modern X25519 (1.3.6.1.4.1.3029.1.5.1 & 1.3.101.110)
808822
case PublicKeyAlgorithmTags.X25519:
809823
{
810-
return getPublicBCPGKey(pubKey, X25519PublicBCPGKey.LENGTH, X25519PublicBCPGKey::new);
824+
return getPublicBCPGKey(pubKey, X25519PublicBCPGKey.LENGTH, new BCPGKeyOperation()
825+
{
826+
@Override
827+
public BCPGKey getBCPGKey(byte[] key)
828+
{
829+
return new X25519PublicBCPGKey(key);
830+
}
831+
});
811832
}
812833
// Modern X448 (1.3.101.111)
813834
case PublicKeyAlgorithmTags.X448:
814835
{
815-
return getPublicBCPGKey(pubKey, X448PublicBCPGKey.LENGTH, X448PublicBCPGKey::new);
836+
return getPublicBCPGKey(pubKey, X448PublicBCPGKey.LENGTH, new BCPGKeyOperation()
837+
{
838+
@Override
839+
public BCPGKey getBCPGKey(byte[] key)
840+
{
841+
return new X448PublicBCPGKey(key);
842+
}
843+
});
816844
}
817845

818846
default:

0 commit comments

Comments
 (0)