Archived Forum Post

Index of archived forum posts

Question:

Decrypt EBcrypt data using ChillKat tools?

Apr 08 '13 at 15:34

I have a large quantity of ebencrypted data and existing routines. I would like to convert the routines to CHILKAT CRYP. Do you have any sample code showing how to decrypt EBencrypted data?

Function EncryptStringEX(subText,subKey)
    on error resume next
    'Encryption engine for encrypting the actual URLs
    Dim cipherObject
    set cipherObject = CreateObject("EbCrypt.eb_c_Cipher")
    Dim libObject
    set libObject = CreateObject("EbCrypt.eb_c_Library")
    EncryptStringEX = _
        libObject.BLOBToHex(_
            cipherObject.EncryptString(19, _
                cstr(subKey), cstr(right("99009900" & cstr(subKey),8)), _
                subText))
end Function

How would I decrypt this using the ChillKat component?


Answer

I don't know anything about EbCrypt, and therefore I don't have a good answer.

All I can say is that Chilkat will produce results that are in agreement with the various published test vectors for various algorithms: AES, Blowfish, TwoFish. In other words, there is nothing proprietary about the Chilkat encryption -- as long as the inputs are the same, such as secret key, key length, cipher mode, padding scheme, etc., then Chilkat will interoperate with any other encryption software that produces correct results -- i.e. results where the encryption algorithm is implemented to published specifications.


Answer

I have tried to produce the same output using chilkat as I get from ebCrypt. Cipher algorithm 19 (above) is Blowfish CBC.

EncryptString(algorithm As EB_CRYPT_CIPHER_ALGORITHM, passPhrase As String, salt As String, plainText As String) As Byte()

Testing in VB6 IDE using "This is a test" as the input string, "MyPass" as the password. Using ebcrypt the output string is :"919606543DE09AACE379C2E13ABE511EF5D9DD30B716D2961DD1A3836EF1A3C9" Using chillkat the output string is :"A9502569CDA4393253740360B7B33B5E"

As you can see the output length is substantially different. For the Chillkat routines, I have altered the key length, padding and IV. Nothing I do remotely comes close to the output length of EbCrypt.

Crypt.CryptAlgorithm = "blowfish2"
Crypt.CipherMode = "cbc"
Crypt.KeyLength = 128
Crypt.PaddingScheme = 0
Crypt.EncodingMode = "hex"

Dim hexKey As String
hexKey = Crypt.GenEncodedSecretKey(Password & "4242", "hex")
Crypt.SetEncodedKey hexKey, "hex"

Text3.Text = Crypt.EncryptStringENC(TestText)

I am beginning to think its how EB returns the encrypted data compared to how yours does. The input string is 14 characters. Chilkat outputs 32 characters. EB outputs 64 characters. When I change the input to 7 characters, Chillkat outputs 15 characters, EB outputs 32. EB always outputs 2x the size Chillkat does.

Kinda thinking this isn't solvable.


Answer

You would NOT want to use GenEncodedSecretKey if you are trying to match the encryption of some other system. See the reference documentation here:
http://www.chilkatsoft.com/refdoc/xChilkatCrypt2Ref.html

Make sure to read about GenerateSecretKey also:

IMPORTANT: If you are trying to decrypt something encrypted by another party such that the other party provided you with the secret key, DO NOT use this method. This method is for transforming an arbitrary-length password into a binary secret key of the proper length. Please see this Chilkat blog post: Getting Started with AES Decryption