Dominique, The bf_self_test is important - it checks the constants have not been modified. There is a similar self test in sha2.c.
I have some more ideas to enhance the feature: key strengthening, enhance the header to include filesize, salt for password. I would also like to run bf in cbc mode, encrypting blocks of 8 chars at a time, and padding the last block with NULLs, though this involves some changes to the fileio.c Another would be to redact visual-selection in a text file, Here is a javascript demo of it: http://hmi-tech.com/mosh/tea4.htm Thanks for testing it and the comments, m 2010/3/21 Dominique Pellé <[email protected]>: > Mosh wrote: > >> Dominique, >> Resending as a zip file. >> thanks, >> mohsin > > Hi Mosh, > > I tried your blowfish patch today. Here are some remarks. > > The patch is missing the changes to the Makefile (I needed > to add blowfish.c & sha2.c to the Makefile to be able to link > successfully). > > I compiled with -g -O0 -Wall -Wmissing-prototypes and I see compilation > warnings: > > blowfish.c:34: warning: missing braces around initializer > blowfish.c:34: warning: (near initialization for ‘sbi[0]’) > blowfish.c: In function ‘bf_key_init’: > blowfish.c:271: warning: pointer targets in passing argument 1 of > ‘strlen’ differ in signedness > /usr/include/string.h:397: note: expected ‘const char *’ but argument > is of type ‘const unsigned char *’ > blowfish.c: At top level: > blowfish.c:334: warning: missing braces around initializer > blowfish.c:334: warning: (near initialization for ‘bft[0]’) > blowfish.c: In function ‘bf_self_test’: > blowfish.c:347: warning: pointer targets in passing argument 1 of > ‘bf_key_init’ differ in signedness > blowfish.c:267: note: expected ‘const unsigned char *’ but argument is > of type ‘char *’ > blowfish.c: At top level: > blowfish.c:233: warning: ‘bf_d_block’ defined but not used > > > sha2.c:178:9: warning: multi-character character constant > sha2.c:180:9: warning: multi-character character constant > sha2.c:686: warning: no previous prototype for ‘int2chars’ > sha2.c: In function ‘sha2_key’: > sha2.c:732: warning: pointer targets in return differ in signedness > sha2.c:733: warning: pointer targets in passing argument 1 of ‘strcmp’ > differ in signedness > /usr/include/string.h:142: note: expected ‘const char *’ but argument > is of type ‘const unsigned char *’ > sha2.c:741: warning: pointer targets in passing argument 1 of ‘strlen’ > differ in signedness > /usr/include/string.h:397: note: expected ‘const char *’ but argument > is of type ‘const unsigned char *’ > sha2.c: At top level: > sha2.c:789: warning: missing braces around initializer > sha2.c:789: warning: (near initialization for ‘sht[0]’) > sha2.c: In function ‘sha2_self_test’: > sha2.c:803: warning: pointer targets in assignment differ in signedness > sha2.c:804: warning: pointer targets in passing argument 1 of ‘strlen’ > differ in signedness > /usr/include/string.h:397: note: expected ‘const char *’ but argument > is of type ‘unsigned char *’ > > > > > fileio.c: In function ‘check_for_cryptkey’: > fileio.c:2824: warning: pointer targets in passing argument 1 of > ‘is_crypt_sig’ differ in signedness > fileio.c:2801: note: expected ‘char *’ but argument is of type ‘char_u *’ > fileio.c: In function ‘buf_write’: > fileio.c:4264: warning: pointer targets in passing argument 1 of > ‘bf_ofb_init’ differ in signedness > blowfish.h:12: note: expected ‘const unsigned char *’ but argument is > of type ‘char *’ > fileio.c:4270: warning: pointer targets in assignment differ in signedness > > > When I run Ex command ":X" I get the error: > > E000: bf_self_test() failed<00> > > So something is broken for me (I'm using Vim-7.2.402 on Linux x86). > ":X" worked before the patch. > > I'm not sure why <00> appears at the end of the error message. > > Instead of using EMSG2(...) for E000, you can use EMSG(...) since > there is only 1 argument. > > Despite the E000 error, Vim still encrypts the file with VimCrypt~02 in > the header. When I open the encrypted file, Vim asks for the key and > it then decrypts the file correctly. So maybe only the self test is wrong. > > I see a typo in comment at blowfish.c:350 (resuse -> reuse) > > Global variable 'bft' at blowfish.c:333 could be local to function > bf_self_test() > > Global variables in fileio.c CRYPT_MAGIC, CRYPT_MAGIC_LEN (etc) > could be declared static. > > Following the Vim coding style (see ":help coding-style") would > help to accept the patch (placement of curly braces, etc.) > > It would be worth including a documentation patch as well. > > Open questions: > > Should code be in something like #ifdef FEAT_BLOWFISH. Right > now blowfish code is in #ifdef FEAT_CRYPT (which is enabled when > building vim with configure ---with-features=normal). > > Should ":X" command have an argument to chose the encryption > algorithm? (blowfish or the older algorithm). > > Cheers > -- Dominique > -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php To unsubscribe from this group, send email to vim_dev+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
