@@ -13,20 +13,21 @@ import java.security.PublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
public class Server {
|
||||
|
||||
public static List<ClientHandler> clients = new ArrayList<>();
|
||||
static List<ClientHandler> clients = new ArrayList<>();
|
||||
|
||||
public static HashMap<String, PublicKey> clientKeys = new HashMap<>();
|
||||
static Map<String, PublicKey> clientKeys = new HashMap<>();
|
||||
|
||||
public static ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(20);
|
||||
static ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(20);
|
||||
|
||||
public static KeyPair serverKeys;
|
||||
static KeyPair serverKeys;
|
||||
|
||||
public static SecretKey aesKey;
|
||||
static SecretKey aesKey;
|
||||
|
||||
public static void main(String[] args) throws IOException, ArgumentsException, NoSuchAlgorithmException {
|
||||
Server.serverKeys = EncryptionUtil.generateRSAKeys();
|
||||
|
||||
@@ -10,13 +10,17 @@ import java.util.Base64;
|
||||
|
||||
public class EncryptionUtil {
|
||||
|
||||
public static final int rsaKeySize = 4096;
|
||||
public static final int RSA_KEY_SIZE = 4096;
|
||||
|
||||
public static final int aesKeySize = 256;
|
||||
public static final int AES_KEY_SIZE = 256;
|
||||
|
||||
private EncryptionUtil() throws IllegalAccessException {
|
||||
throw new IllegalAccessException("Can't be instantiated");
|
||||
}
|
||||
|
||||
public static KeyPair generateRSAKeys() throws NoSuchAlgorithmException {
|
||||
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA");
|
||||
generator.initialize(rsaKeySize);
|
||||
generator.initialize(RSA_KEY_SIZE);
|
||||
|
||||
return generator.generateKeyPair();
|
||||
}
|
||||
@@ -64,7 +68,7 @@ public class EncryptionUtil {
|
||||
|
||||
public static SecretKey generateAESKey() throws NoSuchAlgorithmException {
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
|
||||
keyGenerator.init(aesKeySize);
|
||||
keyGenerator.init(AES_KEY_SIZE);
|
||||
|
||||
return keyGenerator.generateKey();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user