Karsten Hopp f7e344
To: vim_dev@googlegroups.com
Karsten Hopp f7e344
Subject: Patch 7.4.509
Karsten Hopp f7e344
Fcc: outbox
Karsten Hopp f7e344
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp f7e344
Mime-Version: 1.0
Karsten Hopp f7e344
Content-Type: text/plain; charset=UTF-8
Karsten Hopp f7e344
Content-Transfer-Encoding: 8bit
Karsten Hopp f7e344
------------
Karsten Hopp f7e344
Karsten Hopp f7e344
Patch 7.4.509
Karsten Hopp f7e344
Problem:    Users are not aware their encryption is weak.
Karsten Hopp f7e344
Solution:   Give a warning when prompting for the key.
Karsten Hopp f7e344
Files:	    src/crypt.c, src/ex_docmd.c, src/fileio.c, src/main.c,
Karsten Hopp f7e344
	    src/proto/crypt.pro
Karsten Hopp f7e344
Karsten Hopp f7e344
Karsten Hopp f7e344
*** ../vim-7.4.508/src/crypt.c	2014-08-13 22:05:49.032892299 +0200
Karsten Hopp f7e344
--- src/crypt.c	2014-11-12 15:10:22.359161977 +0100
Karsten Hopp f7e344
***************
Karsten Hopp f7e344
*** 504,509 ****
Karsten Hopp f7e344
--- 504,529 ----
Karsten Hopp f7e344
  }
Karsten Hopp f7e344
  
Karsten Hopp f7e344
  /*
Karsten Hopp f7e344
+  * Check the crypt method and give a warning if it's outdated.
Karsten Hopp f7e344
+  */
Karsten Hopp f7e344
+     void
Karsten Hopp f7e344
+ crypt_check_method(method)
Karsten Hopp f7e344
+     int method;
Karsten Hopp f7e344
+ {
Karsten Hopp f7e344
+     if (method < CRYPT_M_BF2)
Karsten Hopp f7e344
+     {
Karsten Hopp f7e344
+ 	msg_scroll = TRUE;
Karsten Hopp f7e344
+ 	MSG(_("Warning: Using a weak encryption method; see :help 'cm'"));
Karsten Hopp f7e344
+     }
Karsten Hopp f7e344
+ }
Karsten Hopp f7e344
+ 
Karsten Hopp f7e344
+     void
Karsten Hopp f7e344
+ crypt_check_current_method()
Karsten Hopp f7e344
+ {
Karsten Hopp f7e344
+     crypt_check_method(crypt_get_method_nr(curbuf));
Karsten Hopp f7e344
+ }
Karsten Hopp f7e344
+ 
Karsten Hopp f7e344
+ /*
Karsten Hopp f7e344
   * Ask the user for a crypt key.
Karsten Hopp f7e344
   * When "store" is TRUE, the new key is stored in the 'key' option, and the
Karsten Hopp f7e344
   * 'key' option value is returned: Don't free it.
Karsten Hopp f7e344
*** ../vim-7.4.508/src/ex_docmd.c	2014-11-05 09:53:19.989153321 +0100
Karsten Hopp f7e344
--- src/ex_docmd.c	2014-11-12 14:53:09.621921631 +0100
Karsten Hopp f7e344
***************
Karsten Hopp f7e344
*** 11524,11529 ****
Karsten Hopp f7e344
--- 11524,11530 ----
Karsten Hopp f7e344
  ex_X(eap)
Karsten Hopp f7e344
      exarg_T	*eap UNUSED;
Karsten Hopp f7e344
  {
Karsten Hopp f7e344
+     crypt_check_current_method();
Karsten Hopp f7e344
      (void)crypt_get_key(TRUE, TRUE);
Karsten Hopp f7e344
  }
Karsten Hopp f7e344
  #endif
Karsten Hopp f7e344
*** ../vim-7.4.508/src/fileio.c	2014-10-31 19:51:33.010698056 +0100
Karsten Hopp f7e344
--- src/fileio.c	2014-11-12 15:10:44.986925300 +0100
Karsten Hopp f7e344
***************
Karsten Hopp f7e344
*** 2958,2963 ****
Karsten Hopp f7e344
--- 2958,2964 ----
Karsten Hopp f7e344
  		 * Happens when retrying to detect encoding. */
Karsten Hopp f7e344
  		smsg((char_u *)_(need_key_msg), fname);
Karsten Hopp f7e344
  		msg_scroll = TRUE;
Karsten Hopp f7e344
+ 		crypt_check_method(method);
Karsten Hopp f7e344
  		cryptkey = crypt_get_key(newfile, FALSE);
Karsten Hopp f7e344
  		*did_ask = TRUE;
Karsten Hopp f7e344
  
Karsten Hopp f7e344
*** ../vim-7.4.508/src/main.c	2014-09-19 13:46:49.550399801 +0200
Karsten Hopp f7e344
--- src/main.c	2014-11-12 14:52:47.866169622 +0100
Karsten Hopp f7e344
***************
Karsten Hopp f7e344
*** 854,859 ****
Karsten Hopp f7e344
--- 854,860 ----
Karsten Hopp f7e344
  #ifdef FEAT_CRYPT
Karsten Hopp f7e344
      if (params.ask_for_key)
Karsten Hopp f7e344
      {
Karsten Hopp f7e344
+ 	crypt_check_current_method();
Karsten Hopp f7e344
  	(void)crypt_get_key(TRUE, TRUE);
Karsten Hopp f7e344
  	TIME_MSG("getting crypt key");
Karsten Hopp f7e344
      }
Karsten Hopp f7e344
*** ../vim-7.4.508/src/proto/crypt.pro	2014-08-10 13:34:59.060785459 +0200
Karsten Hopp f7e344
--- src/proto/crypt.pro	2014-11-12 15:06:51.349363319 +0100
Karsten Hopp f7e344
***************
Karsten Hopp f7e344
*** 19,24 ****
Karsten Hopp f7e344
--- 19,26 ----
Karsten Hopp f7e344
  void crypt_encode_inplace __ARGS((cryptstate_T *state, char_u *buf, size_t len));
Karsten Hopp f7e344
  void crypt_decode_inplace __ARGS((cryptstate_T *state, char_u *buf, size_t len));
Karsten Hopp f7e344
  void crypt_free_key __ARGS((char_u *key));
Karsten Hopp f7e344
+ void crypt_check_method __ARGS((int method));
Karsten Hopp f7e344
+ void crypt_check_current_method __ARGS((void));
Karsten Hopp f7e344
  char_u *crypt_get_key __ARGS((int store, int twice));
Karsten Hopp f7e344
  void crypt_append_msg __ARGS((buf_T *buf));
Karsten Hopp f7e344
  /* vim: set ft=c : */
Karsten Hopp f7e344
*** ../vim-7.4.508/src/version.c	2014-11-12 13:07:48.774069557 +0100
Karsten Hopp f7e344
--- src/version.c	2014-11-12 14:45:09.979391243 +0100
Karsten Hopp f7e344
***************
Karsten Hopp f7e344
*** 743,744 ****
Karsten Hopp f7e344
--- 743,746 ----
Karsten Hopp f7e344
  {   /* Add new patch number below this line */
Karsten Hopp f7e344
+ /**/
Karsten Hopp f7e344
+     509,
Karsten Hopp f7e344
  /**/
Karsten Hopp f7e344
Karsten Hopp f7e344
-- 
Karsten Hopp f7e344
Q: How do you tell the difference between a female cat and a male cat?
Karsten Hopp f7e344
A: You ask it a question and if HE answers, it's a male but, if SHE
Karsten Hopp f7e344
   answers, it's a female.
Karsten Hopp f7e344
Karsten Hopp f7e344
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp f7e344
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp f7e344
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp f7e344
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///