forked from SteamWar/SteamWar
Fix concurrent cipher usage
This commit is contained in:
+7
-9
@@ -37,10 +37,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.*;
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
|
||||||
import javax.crypto.NoSuchPaddingException;
|
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -56,16 +53,15 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
|||||||
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
|
||||||
private final ConcurrentHashMap<Player, Long> patterns = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Player, Long> patterns = new ConcurrentHashMap<>();
|
||||||
private final TechHider techHider;
|
private final TechHider techHider;
|
||||||
private final Cipher cipher;
|
private final SecretKey key;
|
||||||
|
|
||||||
public TechHiderWrapper() {
|
public TechHiderWrapper() {
|
||||||
super(ENABLED, FightState.Schem);
|
super(ENABLED, FightState.Schem);
|
||||||
techHider = new TechHider(this, Config.ObfuscateWith, Config.HiddenBlocks, Config.HiddenBlockEntities);
|
techHider = new TechHider(this, Config.ObfuscateWith, Config.HiddenBlocks, Config.HiddenBlockEntities);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cipher = Cipher.getInstance("AES_256/CFB/NoPadding");
|
key = new SecretKeySpec(Files.readAllBytes(new File(System.getProperty("user.home"), "hullhider.key").toPath()), "AES");
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(Files.readAllBytes(new File(System.getProperty("user.home"), "hullhider.key").toPath()), "AES"));
|
} catch (IOException e) {
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IOException e) {
|
|
||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,8 +149,10 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Cipher cipher = Cipher.getInstance("AES_256/CFB/NoPadding");
|
||||||
|
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||||
bytes = cipher.doFinal(bytes);
|
bytes = cipher.doFinal(bytes);
|
||||||
} catch (IllegalBlockSizeException | BadPaddingException e) {
|
} catch (IllegalBlockSizeException | BadPaddingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
|
||||||
throw new SecurityException(e);
|
throw new SecurityException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user