This is rather specific so I don't think there is a ready made solution. With the right libraries it is however simple to create one.
package nl.owlstead.crypto;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.bouncycastle.crypto.engines.RijndaelEngine;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.crypto.paddings.ISO10126d2Padding;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;
import org.bouncycastle.util.encoders.Hex;
public class RijndaelStrangeCLI {
private static final int RIJNDAEL_256 = 256;
private static final boolean FOR_ENCRYPTION = true;
private static final boolean FOR_DECRYPTION = false;
private static final int BUFFER_SIZE = 1_024;
private static final int EOS = -1;
public static void main(String[] args) throws Exception {
int argOff = 0;
boolean encryptOrDecrypt;
String choice = args[argOff++];
if (choice.matches("(?i)-e")) {
encryptOrDecrypt = FOR_ENCRYPTION;
} else if (choice.matches("(?i)-d")) {
encryptOrDecrypt = FOR_DECRYPTION;
} else {
throw new IllegalArgumentException("Try either -e or -d");
}
byte[] keyData = Hex.decode(args[argOff++]);
byte[] ivData = Hex.decode(args[argOff++]);
KeyParameter key = new KeyParameter(keyData);
ParametersWithIV keyAndIV = new ParametersWithIV(key, ivData);
RijndaelEngine rijndael = new RijndaelEngine(RIJNDAEL_256);
ISO10126d2Padding almostPKCS7Padding = new ISO10126d2Padding();
CBCBlockCipher cbcMode = new CBCBlockCipher(rijndael);
PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(cbcMode,
almostPKCS7Padding);
cipher.init(encryptOrDecrypt, keyAndIV);
byte[] inBuf = new byte[BUFFER_SIZE];
byte[] outBuf = new byte[cipher.getOutputSize(BUFFER_SIZE)];
try (FileInputStream fis = new FileInputStream(args[argOff++]);
FileOutputStream fos = new FileOutputStream(args[argOff++])) {
while (true) {
int read = fis.read(inBuf);
if (read == EOS) {
break;
}
int outLen = cipher.processBytes(inBuf, 0, read, outBuf, 0);
fos.write(outBuf, 0, outLen);
}
int last = cipher.doFinal(outBuf, 0);
fos.write(outBuf, 0, last);
}
}
}
Usage:
Compilation: only requires Java, say Java 8 and the Bouncy Castle provider or lightweight API.
Running:
java nl.owlstead.crypto.RijndaelStrangeCLI <"-e" or "-d"> <key in hex> <IV in hex> <input filename> <output filename>