Data encryption using C # AesCryptoServiceProvider, encrypted using BouncyCastle AesFastEngine

I need to decrypt data with a standard C # AesCryptoServiceProvider, which was encrypted using Bouncy Castle AesFastEngine on the Java side. (To decrypt data using the C # implementation of the Bounca castle is not a problem)

Is there any way to do this?

I do not find the IV used in the implementation of Bouncy Castle ... Is there anything?

Any help would be really wonderful! Marcus

EDIT:

The following code is used to initialize 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:

Hi Greek, thanks for your reply, but it still does not work ... I have a sample download solution here .

, ...??? , , , , ...

, :

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:

! RijndaelManaged , . ... , , bouncy castle... RijndaelManaged...

+3
1

IV, , - IV, . .NET, AesManaged, CipherMode.CFB FeedbackSize 8. CreateEncryptor ICryptoTransform CryptoStream. .

EDIT:

, , . CFB, CBC.

AesManagedAlg.Mode = CipherMode.CFB;

, , readedBytes , buffer[0] .

2:

, AesManaged CFB, RijndaelManaged. , AES Rijndael, 128- 128, 192 256 . . .

+1

Source: https://habr.com/ru/post/1752300/


All Articles