RETN Posted July 19, 2011 Posted July 19, 2011 Hi masters,I am new here on tuts4you.I need help of you guys.I am coding an personal hasher tool in ASM with the help of cryptohash lib.I am having problem with EnCrypters like MARSIt's not giving me proper hash and not decryting it too.Here is a piece of code, I have coded. invoke GetDlgItemText,hWin,EDIT_KEY,addr key,sizeof key mov keysize,eax invoke GetDlgItemText,hWin,EDIT_INPUT,addr inbuff,sizeof inbuff invoke MARSSetKey,addr key,keysize invoke MARSEncrypt,addr inbuff,addr hash invoke HexEncode,addr hash,16,addr outbuff invoke SetDlgItemText,hWin,EDIT_HASH,addr outbuff invoke RtlZeroMemory,addr inbuff,sizeof inbuff invoke MARSDecrypt,addr outbuff,addr inbuff invoke SetDlgItemText,hWin,EDIT_DECRYPTEDHASH,addr inbuffFor more, I have attached my project of winASM, kindly solve the issue.If possible please tell me how to use all Encrypters of cryptohash.Thanking youRETNNew Folder.zip
kao Posted July 19, 2011 Posted July 19, 2011 1) MARS is a block cipher, and MARSEncrypt encrypts one block (128bits = 16bytes) at a time2) If input was less than 16 bytes, your code will encrypt some garbage too.3) Before decrypting *perhaps* you should set the decryption key again.4) But the biggest problem is here:invoke GetDlgItemText,hWin,EDIT_KEY,addr key,sizeof keymov keysize,eaxinvoke GetDlgItemText,hWin,EDIT_INPUT,addr inbuff,sizeof inbuffinvoke MARSSetKey,addr key,keysizeinvoke MARSEncrypt,addr inbuff,addr hash ----> encrypted output goes to "hash". invoke HexEncode,addr hash,16,addr outbuff ----> "outbuff" now contains string representation of encrypted datainvoke SetDlgItemText,hWin,EDIT_HASH,addr outbuffinvoke RtlZeroMemory,addr inbuff,sizeof inbuffinvoke MARSDecrypt,addr outbuff,addr inbuff ----> you should decrypt "hash", not outbuff. invoke SetDlgItemText,hWin,EDIT_DECRYPTEDHASH,addr inbuff 1
Blue Posted July 19, 2011 Posted July 19, 2011 Nice question and Nice answer Kao, it will be useful.Thanks
RETN Posted July 21, 2011 Author Posted July 21, 2011 Thanks Kao,But help me on this.I am using Rijandael and XTEA from cryptolib and having two different problems.When Using Rijandael the program crashes when I click on Calculate and whenI am using XTEA the program hangs. Here are codes : XTEA :invoke XTEAInit,addr key,addr keysize invoke XTEAEncrypt,addr instring,addr tempbuff invoke HexEncode,addr tempbuff,bvalue,addr outstring invoke SetDlgItemInt,hWin,1038,bvalue,0 invoke SetDlgItemText,hWin,1024,addr outstring
RETN Posted July 21, 2011 Author Posted July 21, 2011 Thanks Kao, But help me on this. I am using Rijandael and XTEA from cryptolib and having two different problems. When Using Rijandael the program crashes when I click on Calculate and when I am using XTEA the program hangs. Here are codes : XTEA : invoke XTEAInit,addr key,addr keysize ; keysize is length of key invoke XTEAEncrypt,addr instring,addr tempbuff invoke HexEncode,addr tempbuff,16,addr outstring invoke SetDlgItemText,hWin,1024,addr outstring Rijandael : invoke RijndaelInit,addr key,keysize invoke RijndaelEncrypt,addr instring,addr tempbuff invoke HexEncode,addr tempbuff,bvalue,addr outstring invoke SetDlgItemInt,hWin,1038,bvalue,0 invoke SetDlgItemText,hWin,1024,addr outstring
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