Skip to content

Commit

Permalink
Merge pull request #246 from Tim203/fix/remove-old-key
Browse files Browse the repository at this point in the history
Remove the old Mojang key
  • Loading branch information
SupremeMortal authored Aug 13, 2024
2 parents 02581c8 + 79bb30c commit 71c73b9
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@
@UtilityClass
public class EncryptionUtils {
private static final ECPublicKey MOJANG_PUBLIC_KEY;
private static final ECPublicKey OLD_MOJANG_PUBLIC_KEY;

private static final SecureRandom SECURE_RANDOM = new SecureRandom();
private static final String MOJANG_PUBLIC_KEY_BASE64 =
"MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAECRXueJeTDqNRRgJi/vlRufByu/2G0i2Ebt6YMar5QX/R0DIIyrJMcUpruK4QveTfJSTp3Shlq4Gk34cD/4GUWwkv0DVuzeuB+tXija7HBxii03NHDbPAD0AKnLr2wdAp";
private static final String OLD_MOJANG_PUBLIC_KEY_BASE64 =
"MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8ELkixyLcwlZryUQcu1TvPOmI2B7vX83ndnWRUaXm74wFfa5f/lwQNTfrLVHa2PmenpGI6JhIMUJaWZrjmMj90NoKNFSNBuKdm8rYiXsfaz3K36x/1U26HpG0ZxK/V1V";
private static final KeyPairGenerator KEY_PAIR_GEN;

public static final String ALGORITHM_TYPE = AlgorithmIdentifiers.ECDSA_USING_P384_CURVE_AND_SHA384;
Expand All @@ -52,7 +49,6 @@ public class EncryptionUtils {
KEY_PAIR_GEN = KeyPairGenerator.getInstance("EC");
KEY_PAIR_GEN.initialize(new ECGenParameterSpec("secp384r1"));
MOJANG_PUBLIC_KEY = parseKey(MOJANG_PUBLIC_KEY_BASE64);
OLD_MOJANG_PUBLIC_KEY = parseKey(OLD_MOJANG_PUBLIC_KEY_BASE64);
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException | InvalidKeySpecException e) {
throw new AssertionError("Unable to initialize required encryption", e);
}
Expand Down Expand Up @@ -124,7 +120,7 @@ public static ChainValidationResult validateChain(List<String> chain)
}

// the second chain entry has to be signed by Mojang
if (i == 1 && (!currentKey.equals(MOJANG_PUBLIC_KEY) && !currentKey.equals(OLD_MOJANG_PUBLIC_KEY))) {
if (i == 1 && !currentKey.equals(MOJANG_PUBLIC_KEY)) {
throw new IllegalStateException("The chain isn't signed by Mojang!");
}

Expand Down

0 comments on commit 71c73b9

Please sign in to comment.