|
|
|
|
|
|
|
|
cryptoAlg = algo; |
|
|
cryptoAlg = algo; |
|
|
|
|
|
|
|
|
// Verify if cipher is present. |
|
|
// Verify if cipher is present. |
|
|
Cipher cipher = Cipher.getInstance(cryptoAlg); |
|
|
|
|
|
|
|
|
Cipher cipher = InsecureCipherFactory.create(cryptoAlg); |
|
|
|
|
|
|
|
|
// Standard names are not case-sensitive. |
|
|
// Standard names are not case-sensitive. |
|
|
// http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html |
|
|
// http://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
OutputStream encrypt(final OutputStream os) throws IOException { |
|
|
OutputStream encrypt(final OutputStream os) throws IOException { |
|
|
try { |
|
|
try { |
|
|
final Cipher cipher = Cipher.getInstance(cryptoAlg); |
|
|
|
|
|
|
|
|
final Cipher cipher = InsecureCipherFactory.create(cryptoAlg); |
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec); |
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey, paramSpec); |
|
|
return new CipherOutputStream(os, cipher); |
|
|
return new CipherOutputStream(os, cipher); |
|
|
} catch (GeneralSecurityException e) { |
|
|
} catch (GeneralSecurityException e) { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
InputStream decrypt(final InputStream in) throws IOException { |
|
|
InputStream decrypt(final InputStream in) throws IOException { |
|
|
try { |
|
|
try { |
|
|
final Cipher cipher = Cipher.getInstance(cryptoAlg); |
|
|
|
|
|
|
|
|
final Cipher cipher = InsecureCipherFactory.create(cryptoAlg); |
|
|
cipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec); |
|
|
cipher.init(Cipher.DECRYPT_MODE, secretKey, paramSpec); |
|
|
return new CipherInputStream(in, cipher); |
|
|
return new CipherInputStream(in, cipher); |
|
|
} catch (GeneralSecurityException e) { |
|
|
} catch (GeneralSecurityException e) { |
|
|
|
|
|
|
|
|
String keySalt = props.getProperty(profile + X_KEY_SALT, DEFAULT_KEY_SALT); |
|
|
String keySalt = props.getProperty(profile + X_KEY_SALT, DEFAULT_KEY_SALT); |
|
|
|
|
|
|
|
|
// Verify if cipher is present. |
|
|
// Verify if cipher is present. |
|
|
Cipher cipher = Cipher.getInstance(cipherAlgo); |
|
|
|
|
|
|
|
|
Cipher cipher = InsecureCipherFactory.create(cipherAlgo); |
|
|
|
|
|
|
|
|
// Verify if key factory is present. |
|
|
// Verify if key factory is present. |
|
|
SecretKeyFactory factory = SecretKeyFactory.getInstance(keyAlgo); |
|
|
SecretKeyFactory factory = SecretKeyFactory.getInstance(keyAlgo); |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
OutputStream encrypt(OutputStream output) throws IOException { |
|
|
OutputStream encrypt(OutputStream output) throws IOException { |
|
|
try { |
|
|
try { |
|
|
Cipher cipher = Cipher.getInstance(cipherAlgo); |
|
|
|
|
|
|
|
|
Cipher cipher = InsecureCipherFactory.create(cipherAlgo); |
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey); |
|
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey); |
|
|
AlgorithmParameters params = cipher.getParameters(); |
|
|
AlgorithmParameters params = cipher.getParameters(); |
|
|
if (params == null) { |
|
|
if (params == null) { |
|
|
|
|
|
|
|
|
JGitText.get().unsupportedEncryptionVersion, vers)); |
|
|
JGitText.get().unsupportedEncryptionVersion, vers)); |
|
|
} |
|
|
} |
|
|
try { |
|
|
try { |
|
|
decryptCipher = Cipher.getInstance(cipherAlgo); |
|
|
|
|
|
|
|
|
decryptCipher = InsecureCipherFactory.create(cipherAlgo); |
|
|
if (cont.isEmpty()) { |
|
|
if (cont.isEmpty()) { |
|
|
decryptCipher.init(Cipher.DECRYPT_MODE, secretKey); |
|
|
decryptCipher.init(Cipher.DECRYPT_MODE, secretKey); |
|
|
} else { |
|
|
} else { |