corvias Posted May 5, 2010 Share Posted May 5, 2010 So, I'm not sure if this is a problem in Crypt.au3, a limitation of Windows' implementation of AES, or a lack of knowledge on my part, but is appears that either _Crypt_EncryptFile or _Crypt_DecryptFile mangles .zip files that are over ~1MB. In the script below, if test.zip is more than a few megabytes, the resulting dec_test.zip will be unreadable. Zip programs can see files in the .zip, but will not be able to extract the data due to corruption. This doesn't seem to happen to other large files, but I've managed to corrupt other archive types, like .7z as well as installer executables, and .msi files. This only seems to happen with the AES family of algorithms. RC4 works fine. I haven't tried others. Can anyone provide some insight as to what is happening? I'm using ver. 3.3.6.1 (NOTE: I tried to post this on the Bug Tracker, but it seems to be down) #Include <Crypt.au3> $file2encrypt="test.zip" $encryptedfile="test.zip.enc" $decryptedfile="dec_test.zip" $key="12345" _Crypt_EncryptFile($file2encrypt , $encryptedfile, $key, $CALG_AES_256) _Crypt_DecryptFile($encryptedfile , $decryptedfile, $key, $CALG_AES_256) Link to comment Share on other sites More sharing options...
monoceres Posted May 5, 2010 Share Posted May 5, 2010 Doesn't look good. Is the limit exactly at 1 MB (crypt.au3 reads in chunks of 1 MB)? Is the corrupted file of the right filesize? Does either _Crypt_EncryptFile or _Crypt_DecryptFile throw any error? Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
corvias Posted May 5, 2010 Author Share Posted May 5, 2010 Doesn't look good.Is the limit exactly at 1 MB (crypt.au3 reads in chunks of 1 MB)?Is the corrupted file of the right filesize?Does either _Crypt_EncryptFile or _Crypt_DecryptFile throw any error?The files come out to the same size. The limit is pretty close to ~1mb, though I didn't measure it. I'll add error msgs to the script and report back. brb Link to comment Share on other sites More sharing options...
corvias Posted May 5, 2010 Author Share Posted May 5, 2010 Added quick error output to my little test script. No errors on encryption or decryption. #Include <Crypt.au3> $file2encrypt="test.zip" $encryptedfile="test.zip.enc" $decryptedfile="dec_test.zip" $key="12345" _Crypt_EncryptFile($file2encrypt , $encryptedfile, $key, $CALG_AES_128) MsgBox(262208, "Done Encrypting", @error) _Crypt_DecryptFile($encryptedfile , $decryptedfile, $key, $CALG_AES_128) MsgBox(262208, "Done Decrypting", @error) Link to comment Share on other sites More sharing options...
V3000 Posted August 15, 2011 Share Posted August 15, 2011 (edited) From 5 May 2010 Until Now, Any iDea How To Fix iT Edited August 15, 2011 by V3000 Link to comment Share on other sites More sharing options...
V3000 Posted August 15, 2011 Share Posted August 15, 2011 This Issue Appears If We Use [AES 128 192 256] And [DES] And [RC2] ; But It Work Very Well With [RC4] Only, I Tested With More Than 80 MB <= Work Fine, (MD5) Hash Comparison Matched With The Decrypted . Link to comment Share on other sites More sharing options...
Sirilius Posted September 15, 2011 Share Posted September 15, 2011 I believe I found the fix for this problem and it's wonderfully simple. You have to make a very small change to the _Crypt_EncryptData function which is in the Crypt.au3 include file. If you look at that function you'll see the first DLLCall to CryptEncrypt is passing a "bool" of 1 where it should be passing the $fFinal parameter (like it does in the second DllCall). So change the line in the _Crypt_EncryptData function from this:$aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptEncrypt", "ptr", $vCryptKey, "ptr", 0, "bool", 1, "dword", 0, "ptr", 0, _ To this:$aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptEncrypt", "ptr", $vCryptKey, "ptr", 0, "bool", $fFinal, "dword", 0, "ptr", 0, _ After making that change AES encryption (et al) should work correctly on files over 1 MB. Link to comment Share on other sites More sharing options...
KaFu Posted September 15, 2011 Share Posted September 15, 2011 That's a good first post, would be great if you could submit it to the bug tracker ! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now