mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Don't use dynamic quiried key size as it varies on different JVM implementation and security providers
This commit is contained in:
parent
316267f684
commit
102bc1f39f
@ -14,6 +14,7 @@ package com.cloud.consoleproxy;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
@ -54,7 +55,7 @@ public class ConsoleProxyPasswordBasedEncryptor {
|
||||
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("DES");
|
||||
int maxKeySize = Cipher.getMaxAllowedKeyLength("DES") / 8;
|
||||
int maxKeySize = 8;
|
||||
SecretKeySpec keySpec = new SecretKeySpec(normalizeKey(password.getBytes(), maxKeySize), "DES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
|
||||
byte[] encryptedBytes = cipher.doFinal(text.getBytes());
|
||||
@ -86,7 +87,7 @@ public class ConsoleProxyPasswordBasedEncryptor {
|
||||
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("DES");
|
||||
int maxKeySize = Cipher.getMaxAllowedKeyLength("DES") / 8;
|
||||
int maxKeySize = 8;
|
||||
SecretKeySpec keySpec = new SecretKeySpec(normalizeKey(password.getBytes(), maxKeySize), "DES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public class ConsoleProxyPasswordBasedEncryptor {
|
||||
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("DES");
|
||||
int maxKeySize = Cipher.getMaxAllowedKeyLength("DES") / 8;
|
||||
int maxKeySize = 8;
|
||||
SecretKeySpec keySpec = new SecretKeySpec(normalizeKey(password.getBytes(), maxKeySize), "DES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec);
|
||||
byte[] encryptedBytes = cipher.doFinal(text.getBytes());
|
||||
@ -68,7 +68,7 @@ public class ConsoleProxyPasswordBasedEncryptor {
|
||||
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("DES");
|
||||
int maxKeySize = Cipher.getMaxAllowedKeyLength("DES") / 8;
|
||||
int maxKeySize = 8;
|
||||
SecretKeySpec keySpec = new SecretKeySpec(normalizeKey(password.getBytes(), maxKeySize), "DES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, keySpec);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user