Jump to content
Tuts 4 You

How to properly use Cryptohash lib


RETN

Recommended Posts

Posted

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 MARS

It'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 inbuff

For 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 you

RETN

New Folder.zip

Posted

1) MARS is a block cipher, and MARSEncrypt encrypts one block (128bits = 16bytes) at a time

2) 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 key
mov keysize,eax
invoke GetDlgItemText,hWin,EDIT_INPUT,addr inbuff,sizeof inbuffinvoke MARSSetKey,addr key,keysize
invoke MARSEncrypt,addr inbuff,addr hash ----> encrypted output goes to "hash".
invoke HexEncode,addr hash,16,addr outbuff ----> "outbuff" now contains string representation of encrypted data
invoke SetDlgItemText,hWin,EDIT_HASH,addr outbuffinvoke RtlZeroMemory,addr inbuff,sizeof inbuff
invoke MARSDecrypt,addr outbuff,addr inbuff ----> you should decrypt "hash", not outbuff.
invoke SetDlgItemText,hWin,EDIT_DECRYPTEDHASH,addr inbuff
  • Like 1
Posted

Nice question and Nice answer Kao, it will be useful.

Thanks

Posted

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
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
Posted

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. :confused:

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...