diff --git a/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java b/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java index 900a767..6ce2f11 100644 --- a/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java +++ b/server/src/main/java/org/orinprojects/encryption/EncryptionUtil.java @@ -10,7 +10,7 @@ import java.util.Base64; public class EncryptionUtil { - public static final int RSA_KEY_SIZE = 4096; + public static final int RSA_KEY_SIZE = 2048; public static final int AES_KEY_SIZE = 256; @@ -51,7 +51,7 @@ public class EncryptionUtil { } public static String encryptWithRSA(String data, PublicKey publicKey) throws InvalidKeyException, NoSuchPaddingException, NoSuchAlgorithmException, IllegalBlockSizeException, BadPaddingException { - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); cipher.init(Cipher.ENCRYPT_MODE, publicKey); byte[] encryptedMessage = cipher.doFinal(data.getBytes()); @@ -59,7 +59,7 @@ public class EncryptionUtil { } public static String decryptWithRSA(String encryptedData, PrivateKey pk) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { - Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding"); + Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding"); cipher.init(Cipher.DECRYPT_MODE, pk); byte[] decryptedMessage = cipher.doFinal(Base64.getDecoder().decode(encryptedData));