On Wed, 21 Oct 2009, Mindaugas Kavaliauskas wrote: Hi,
> >Technically you can use any non empty string as cPass. Bytes from > >cPass are used cyclically to create 32bit values used to xor keys > >in p-array. The implementation I committed does not follow the original > >BlowFish description but rather reference implementations which instead > >of xoring keys from 1 to 14 xors all 18 keys. It means that insted of > >448 bits upto 576 bits from passsed cPass is used. > I guess 448bits is not a problem. Anyone can write LEFT(cPassword, > 56) if he wants a strict compatibility with another software. BTW, > sample implementation presented by the author at > http://www.schneier.com/code/bfsh-sch.zip does not contains limit on > password length also. Just like most of other implementations I've seen. They are limited only by number of subkeys in P array so for default 18 items in P array the maximum user key size is 18 * 4 * 8 == 576 bits. > I've looked to key length encoding in Harbour level functions. Is it > some standard way to encode length of 8byte unaligned data? I guess you are talking about .prg functions. No, it's not a standard. I implemented it only for these functions. > I find useful to add a function hb_blofish{En|De}cryptRaw() (or 3rd > optional lRaw=.F. parameter in current functions), for those who has > aligned data and are unable to store a longer encrypted data. > It will also allow to encrypt/decrypt large amount of data (eg. files) > in multiple function calls. The last call can be made without > lRaw=.T. parameter to force encoding of unaligned data length if > necessary. function hb_blowfishEncryptRaw( bfKey, cData ) return left( hb_blowfishEncrypt( bfKey, cData ), len( cData ) ) function hb_blowfishDecryptRaw( bfKey, cData ) return hb_blowfishDecrypt( bfKey, cData + ; hb_blowfishEncryptRaw( bfKey, repl( chr( 0 ), 7 ) + chr( 8 ) ) ) Anyhow for performance reasons I'll add support for <lRaw> parameter to hb_blofish{En|De}crypt() functions. There is only one question: what to do if passed string length is not multiple of 8. We have few choices: 1. generate RTE 2. return NIL or "" to indicate error 3. pad string with spaces or chr( 0 ) before encoding 4. pad only strings shorter then 8 bytes. For longer strings encode encode all full 64bit blocks then encode last 64bits (decode in reveresed order) The version 4 allow to encode any data longer then 7 bytes without any problems keeping original size. What do you prefer? best regards, Przemek _______________________________________________ Harbour mailing list [email protected] http://lists.harbour-project.org/mailman/listinfo/harbour
