The goal
We’ve been using EasyByte’s Cryptocx library to encrypt documents using AES256. The library is 32-bit and is preventing us from building a 64-bit version of our application. EasyByte went out of business and there’s no 64-bit version, source code or support for the library.
We’d like to use Chilkat’s 64-bit ActiveX component to be able to decrypt the documents directly. Migrating all our customer’s documents by decrypting and re-encrypting them would be a huge cost.
I’m trying to infer the mode of operation (ECB, CBC…) so that I can send Chilkat the right parameters. The Cryptocx method we’re using only accepts the source and destination files and a string password:
http://www.easybyte.com/support/cryptocx/aesfileencrypt.html
What I tried
I don’t have a strong background in cryptography, but this is what I tried.
A 64-byte input file (4 blocks in AES) filled with As (hex 41). A 32-character string for the password, also filled with As. By calling the previous method to encrypt several times (same file, same password) and using a hex editor I can observe that files have five 16-byte blocks in the encrypted file.
The first four blocks are identical and the fifth differs. Is this the initialization vector being stored in the file? If it is and it’s different in all the files, shouldn’t the first four blocks also be different?
Assuming it was CBC (since the Wikipedia article claims it’s the most used) I tried removing the last 16 bytes from the file (using a hex editor) and using them as the IV to decrypt the file.
But I didn’t get the expected clear text.
Some code
This is the code I tried, in VB.net:
Dim chilkat As ChilkatCrypt2 = New ChilkatCrypt2
chilkat.UnlockComponent(licenseKey)
chilkat.CryptAlgorithm = "aes"
chilkat.KeyLength = 256
chilkat.CipherMode = "cbc"
chilkat.SetEncodedKey("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "ascii")
chilkat.SetEncodedIV("36cd36dae64316e80d50871e3b26b4bb", "hex")
Dim result = chilkat.CkDecryptFile(pathToEncryptedFile, pathToDecryptedFile)
If result = 0 Then
Console.WriteLine(chilkat.LastErrorText)
Console.ReadLine()
End If
I would appreciate some direction. Can the right parameters even be inferred from the output without knowing the implementation details?
Thanks a lot.