News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

File encryption

Started by donkey, April 10, 2006, 04:32:42 AM

Previous topic - Next topic

donkey

Recently I have been working on adding some functions to WinExplorer and one of them was the ability to encrypt and decrypt files. I decided on the RC6 algorithm and translated TOLA's implementation of it. In order to use it I required a 16 byte key, to accomplish this while still allowing keys of any length I generate a key from user input using SHA which outputs a hash of 16 bytes. This allows keys of from 1 to n characters. The limitation of RC6 is that it cannot encrypt anything larger than the key length so we must step through the file 16 bytes at a time, this is accomplished in a loop. Since there are likely to be multiple repeats in a file I use the 16 encrypted bytes as the key for the next 16 bytes etc..., this will foul up anybody looking for patterns as the primary key is used only once. For security purposes, the actual text key that is used for the primary key is zeroed out as soon as the hash is complete, this cannot stop memory walkers but it can make setting the breakpoints properly more critical. At any rate here is the assembly code, there is no working executable as of yet but it will appear in the next release of WinExplorer.

I would appreciate it if someone could test it for me and report any bugs or problems.

Edgar

[attachment deleted by admin]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

donkey

There is a major security issue with the encryption scheme, it should use the 16 unencrypted bytes for the next blocks keys, I have fixed it but not uploaded the new file yet. It requires just that you move the memcopy so I will wait till I release the next version of WinExplorer. Also it appears to have problems with the end of file, I will address that also.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable