From 9ef9d6036b6c1dd9a88e1adfba9268d004115338 Mon Sep 17 00:00:00 2001 From: gefeili Date: Wed, 18 Dec 2024 12:32:52 +1030 Subject: [PATCH] Replace lambdas in JcaPGPKeyConverter with anonymous classes --- .../operator/jcajce/JcaPGPKeyConverter.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcaPGPKeyConverter.java b/pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcaPGPKeyConverter.java index c54ce3bc1c..28cd4bb57f 100644 --- a/pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcaPGPKeyConverter.java +++ b/pg/src/main/java/org/bouncycastle/openpgp/operator/jcajce/JcaPGPKeyConverter.java @@ -795,24 +795,52 @@ else if (pubKey.getAlgorithm().regionMatches(true, 0, "XDH", 0, 3)) // Modern Ed25519 (1.3.6.1.4.1.11591.15.1 & 1.3.101.112) case PublicKeyAlgorithmTags.Ed25519: { - return getPublicBCPGKey(pubKey, Ed25519PublicBCPGKey.LENGTH, Ed25519PublicBCPGKey::new); + return getPublicBCPGKey(pubKey, Ed25519PublicBCPGKey.LENGTH, new BCPGKeyOperation() + { + @Override + public BCPGKey getBCPGKey(byte[] key) + { + return new Ed25519PublicBCPGKey(key); + } + }); } // Modern Ed448 (1.3.101.113) case PublicKeyAlgorithmTags.Ed448: { - return getPublicBCPGKey(pubKey, Ed448PublicBCPGKey.LENGTH, Ed448PublicBCPGKey::new); + return getPublicBCPGKey(pubKey, Ed448PublicBCPGKey.LENGTH, new BCPGKeyOperation() + { + @Override + public BCPGKey getBCPGKey(byte[] key) + { + return new Ed448PublicBCPGKey(key); + } + }); } // Modern X25519 (1.3.6.1.4.1.3029.1.5.1 & 1.3.101.110) case PublicKeyAlgorithmTags.X25519: { - return getPublicBCPGKey(pubKey, X25519PublicBCPGKey.LENGTH, X25519PublicBCPGKey::new); + return getPublicBCPGKey(pubKey, X25519PublicBCPGKey.LENGTH, new BCPGKeyOperation() + { + @Override + public BCPGKey getBCPGKey(byte[] key) + { + return new X25519PublicBCPGKey(key); + } + }); } // Modern X448 (1.3.101.111) case PublicKeyAlgorithmTags.X448: { - return getPublicBCPGKey(pubKey, X448PublicBCPGKey.LENGTH, X448PublicBCPGKey::new); + return getPublicBCPGKey(pubKey, X448PublicBCPGKey.LENGTH, new BCPGKeyOperation() + { + @Override + public BCPGKey getBCPGKey(byte[] key) + { + return new X448PublicBCPGKey(key); + } + }); } default: