From 1d46640b42e2cc1e2328e034b3033ddf3cc1cfb0 Mon Sep 17 00:00:00 2001 From: games647 Date: Thu, 23 Jun 2022 19:28:37 +0200 Subject: [PATCH] Limit length of server keys --- .../bukkit/listener/protocollib/EncryptionUtilTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java index e50423a2..582496d3 100644 --- a/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java +++ b/bukkit/src/test/java/com/github/games647/fastlogin/bukkit/listener/protocollib/EncryptionUtilTest.java @@ -75,14 +75,15 @@ public class EncryptionUtilTest { public void testServerKey() { KeyPair keyPair = EncryptionUtil.generateKeyPair(); - PrivateKey privateKey = keyPair.getPrivate(); + Key privateKey = keyPair.getPrivate(); assertThat(privateKey.getAlgorithm(), is("RSA")); - PublicKey publicKey = keyPair.getPublic(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); assertThat(publicKey.getAlgorithm(), is("RSA")); - // clients accept larger values, but we shouldn't crash them - assertTrue(publicKey.getEncoded().length > (1024 / 8)); + // clients accept larger values than the standard vanilla server, but we shouldn't crash them + assertTrue(publicKey.getModulus().bitLength() >= 1024); + assertTrue(publicKey.getModulus().bitLength() < 8192); } @Test