Fixed: Static initialization vectors for encryption (OFBIZ-12281)

(after discussing this on security@ofbiz.apache.org, it was decided to open a
Jira issue for that)

I've noticed that OFBiz Framework sometimes uses static initialization vectors
(IV) while creating a cipher:

https://s.apache.org/vhlbj
https://s.apache.org/nyndk

IVs should be unique and ideally unpredictable to avoid producing the same
ciphertexts for the same plaintexts.

The issues can be fixed with something like the following:

byte[] rawIV = new byte[8];
SecureRandom random = new SecureRandom();
random.nextBytes(rawIV).
IvParameterSpec iv = new IvParameterSpec(rawIV);

jleroux: this prepends the IV in order to decrypt the plaintexts. It's similar
to what has been done for the DesCrypt class. But contrary to the DesCrypt class
I did not test.

Thanks: Artem Smotrakov

Conflicts handled by hand (a lot)
ValueLinkApi.java
This commit is contained in:
Jacques Le Roux
2021-07-23 09:29:37 +02:00
parent 5a069a9991
commit d890ebaedc
2 changed files with 105 additions and 47 deletions
@@ -76,8 +76,6 @@ public class DesCrypt {
}
public static byte[] decrypt(Key key, byte[] bytes) throws GeneralException {
// create the Cipher - DESede/CBC/PKCS5Padding
// separate prefix with IV from the rest of encrypted data
byte[] encryptedPayload = Base64.decodeBase64(bytes);
byte[] iv = new byte[8];