jchd Posted July 7, 2015 Share Posted July 7, 2015 This depends on the algorithm you use: switch to RC4 and see that the error doesn't occur.Here's why: depending on the encryption algorithm detail in implementation, the decryption with a wrong file or passphrase can be detected or not. Since the actual error is raised (at least with AES) only on the final block when it doesn't fit the structure expected by the implementation protocol, I think it's still the right way to handle the case. Look, if I receive a large encrypted file wich has suffered alteration, I'd rather decide by myself if the bulk of the file "decrypted" so far makes sense or not. It's pretty similar to an error occuring while copying a directory subtree: if an error occurs at some point, the files already copied are not deleted.In all cases, you can always do like J1 said.Nevertheless, the implementation of AES turns it into an oracle telling whether the supplied passphrase is correct or not, which is very, VERY bad. Imagine you're caught by political police in some country with an encrypted file, they can waterboard you until you give them the right passphrase, without any possibility to provide a wrong one. This isn't so with the one-time pad, which makes it ridiculously easy to provide a made up passphrase to masquerade the recovered plaintext into a completely innocuous one. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
legend Posted July 7, 2015 Author Share Posted July 7, 2015 JohnOne, Your solution perfectly solved my problem, Thank's a lot jchd, thanks for explaining it in details, it helped me understand how it works Link to comment Share on other sites More sharing options...
jchd Posted July 7, 2015 Share Posted July 7, 2015 (edited) Here's an illustration of plausible denial when applying to ciphertext content: suppose you sent a mail containing the ciphertext "R=.0tDG::HgN(]P6!7N!9gSLjS-,$(TJ3QIb+8;dQ8C$xhIYz4;1,LPhWQ0agOhq^ wuw;("I'm a suspecting secret service agent and I doubt you would send such a mail just for fun. So I suspect you're a alien opponent or terrorist or infiltrated agent trying to communicate stolen secrets or planning something bad for my country. I arrest you and urge you (threathen with hammering all of your fingers, or such) to decode this. Depending on the passphrase you give, you have a chance of escaping torture/prison/hanging if what gets decoded makes enough innocuous sense to me, as shown by the following script:Local $sCipher = "R=.0tDG::HgN(]P6!7N!9gSLjS-,$(TJ3QIb+8;dQ8C$xhIYz4;1,LPhWQ0agOhq^ wuw;(" Local $bPass1 = Binary("0x1A540E52152622161A3F0F2B467D1916425823441905322F01734543494D74031435690E444E5E4428573604081A2C291B465E115523251A77235112172D0D032C5957051E5E09") Local $bPass2 = Binary("0x0B525B1016212B535F3E026E617A3D1640596E604C133C051E734B4D4A4A3B3313333C160B5155443759205058216E345A474B4845223748313E424129201C197E6B1807125A09") Local $bPass3 = Binary("0x1C58564454372259482D136E453835424859291B195764635B6B0D151E1B641A7E7128160B7558203E5622481C1B690A0E146B505920700432221025063744511852161B145E06") Local $bPass4 = Binary("0x34525C10002C2E491A3B042F457D2545441718686A26732F0B21490C4A5D392856237342120F0F57690F761C495C7B694F0209000C2928183E234941032E1C1464004743580A1F") ConsoleWrite(BinaryToString(_XOR_Code($sCipher, $bPass1), 1) & @LF) ConsoleWrite(BinaryToString(_XOR_Code($sCipher, $bPass2), 1) & @LF) ConsoleWrite(BinaryToString(_XOR_Code($sCipher, $bPass3), 1) & @LF) ConsoleWrite(BinaryToString(_XOR_Code($sCipher, $bPass4), 1) & @LF) Func _XOR_Code($bIn, $bPass) If IsString($bIn) Then $bIn = Binary($bIn) If IsString($bPass) Then $bPass = Binary($bPass) Local $sOut For $i = 1 To BinaryLen($bIn) $sOut &= Chr(BitXOR(BinaryMid($bIn, $i, 1), BinaryMid($bPass, $i, 1))) Next Return Binary($sOut) EndFuncBut of course you'd have to hide the real passphrase well enough, while making the innocuous passphrase easy enough to find. Edited July 7, 2015 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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