Hello,
I need to decrypt Data with Standard C# AesCryptoServiceProvider which was encrypted with Bouncy Castle AesFastEngine on the Java side. (To decrypt the Data using the c# implementation of Bounca Castle is no problem)
Is there a way to do this?
I don't find the IV used in the Bouncy Castle implementation... Is there any?
Any help would be really fine! Markus
EDIT:
The following code is used to initialize the AesFastEngine:
BlockCipher coder = new AESFastEngine();
CFBBlockCipher cfbCipher = new CFBBlockCipher(coder, 8);
StreamCipher streamCipher = new StreamBlockCipher(cfbCipher);
streamCipher.Init(true, keyParameter);
streamCipher.ProcessBytes(data, 0, data.Length, encodedMessageBytes, 0);
EDIT:
Hello Grec, thanks for your answer, but it is still not working... I have a sample solution to download here.
If you click the two Buttons you get already a different crypted array...??? Decrypting the Array produced with bouncy castle is leading to an exception saying that the crypted data has an invalid length...
Here is the Code I wrote for decryption:
AesManagedAlg = new AesManaged();
AesManagedAlg.Mode = CipherMode.CBC;
AesManagedAlg.FeedbackSize = 8;
AesManagedAlg.Key = key;
// Use Test
AesManagedAlg.IV = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Create a decrytor to perform the stream transform.
ICryptoTransform decryptor = AesManagedAlg.CreateDecryptor(AesManagedAlg.Key, AesManagedAlg.IV);
// Create the streams used for decryption.
msDecrypt = new MemoryStream(cipherText);
csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read);
// Read the decrypted bytes from the decrypting stream
var decryptedData = new List<byte>();
var buffer = new byte[1];
while (true) {
var readedBytes = csDecrypt.Read(buffer, 0, buffer.Length);
if(readedBytes == 0) break;
decryptedData.Add(buffer[0]);
}
ret = decryptedData.ToArray();
Edit:
Getting close! RijndaelManaged managed is working but it gives me one byte more of crypted data. All the other bytes are the same... I tryed a lot but I don't know how to get the last byte with bouncy castle... Without this last byte it is not possible to decrypte the data with RijndaelManaged...