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.player.PlayerQuitEvent;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.*;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.File;
|
||||
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, Long> patterns = new ConcurrentHashMap<>();
|
||||
private final TechHider techHider;
|
||||
private final Cipher cipher;
|
||||
private final SecretKey key;
|
||||
|
||||
public TechHiderWrapper() {
|
||||
super(ENABLED, FightState.Schem);
|
||||
techHider = new TechHider(this, Config.ObfuscateWith, Config.HiddenBlocks, Config.HiddenBlockEntities);
|
||||
|
||||
try {
|
||||
cipher = Cipher.getInstance("AES_256/CFB/NoPadding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(Files.readAllBytes(new File(System.getProperty("user.home"), "hullhider.key").toPath()), "AES"));
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException | IOException e) {
|
||||
key = new SecretKeySpec(Files.readAllBytes(new File(System.getProperty("user.home"), "hullhider.key").toPath()), "AES");
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
@@ -153,8 +149,10 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
||||
};
|
||||
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES_256/CFB/NoPadding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
bytes = cipher.doFinal(bytes);
|
||||
} catch (IllegalBlockSizeException | BadPaddingException e) {
|
||||
} catch (IllegalBlockSizeException | BadPaddingException | NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
|
||||
throw new SecurityException(e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user