jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.172

073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.172
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.172
073263
Problem:    The blowfish code mentions output feedback, but the code is
073263
	    actually doing cipher feedback.
073263
Solution:   Adjust names and comments.
073263
Files:	    src/blowfish.c, src/fileio.c, src/proto/blowfish.pro,
073263
	    src/memline.c
073263
073263
073263
*** ../vim-7.4.171/src/blowfish.c	2010-12-17 19:58:18.000000000 +0100
073263
--- src/blowfish.c	2014-02-11 15:18:12.882118804 +0100
073263
***************
073263
*** 6,12 ****
073263
   * Do ":help credits" in Vim to see a list of people who contributed.
073263
   * See README.txt for an overview of the Vim source code.
073263
   *
073263
!  * Blowfish encryption for Vim; in Blowfish output feedback mode.
073263
   * Contributed by Mohsin Ahmed, http://www.cs.albany.edu/~mosh
073263
   * Based on http://www.schneier.com/blowfish.html by Bruce Schneier.
073263
   */
073263
--- 6,12 ----
073263
   * Do ":help credits" in Vim to see a list of people who contributed.
073263
   * See README.txt for an overview of the Vim source code.
073263
   *
073263
!  * Blowfish encryption for Vim; in Blowfish cipher feedback mode.
073263
   * Contributed by Mohsin Ahmed, http://www.cs.albany.edu/~mosh
073263
   * Based on http://www.schneier.com/blowfish.html by Bruce Schneier.
073263
   */
073263
***************
073263
*** 19,25 ****
073263
  
073263
  #define BF_BLOCK    8
073263
  #define BF_BLOCK_MASK 7
073263
! #define BF_OFB_LEN  (8*(BF_BLOCK))
073263
  
073263
  typedef union {
073263
      UINT32_T ul[2];
073263
--- 19,25 ----
073263
  
073263
  #define BF_BLOCK    8
073263
  #define BF_BLOCK_MASK 7
073263
! #define BF_CFB_LEN  (8*(BF_BLOCK))
073263
  
073263
  typedef union {
073263
      UINT32_T ul[2];
073263
***************
073263
*** 554,595 ****
073263
      return err > 0 ? FAIL : OK;
073263
  }
073263
  
073263
! /* Output feedback mode. */
073263
  static int randbyte_offset = 0;
073263
  static int update_offset = 0;
073263
! static char_u ofb_buffer[BF_OFB_LEN]; /* 64 bytes */
073263
  
073263
  /*
073263
   * Initialize with seed "iv[iv_len]".
073263
   */
073263
      void
073263
! bf_ofb_init(iv, iv_len)
073263
      char_u *iv;
073263
      int    iv_len;
073263
  {
073263
      int i, mi;
073263
  
073263
      randbyte_offset = update_offset = 0;
073263
!     vim_memset(ofb_buffer, 0, BF_OFB_LEN);
073263
      if (iv_len > 0)
073263
      {
073263
! 	mi = iv_len > BF_OFB_LEN ? iv_len : BF_OFB_LEN;
073263
  	for (i = 0; i < mi; i++)
073263
! 	    ofb_buffer[i % BF_OFB_LEN] ^= iv[i % iv_len];
073263
      }
073263
  }
073263
  
073263
! #define BF_OFB_UPDATE(c) { \
073263
!     ofb_buffer[update_offset] ^= (char_u)c; \
073263
!     if (++update_offset == BF_OFB_LEN) \
073263
  	update_offset = 0; \
073263
  }
073263
  
073263
  #define BF_RANBYTE(t) { \
073263
      if ((randbyte_offset & BF_BLOCK_MASK) == 0) \
073263
! 	bf_e_cblock(&ofb_buffer[randbyte_offset]); \
073263
!     t = ofb_buffer[randbyte_offset]; \
073263
!     if (++randbyte_offset == BF_OFB_LEN) \
073263
  	randbyte_offset = 0; \
073263
  }
073263
  
073263
--- 554,595 ----
073263
      return err > 0 ? FAIL : OK;
073263
  }
073263
  
073263
! /* Cipher feedback mode. */
073263
  static int randbyte_offset = 0;
073263
  static int update_offset = 0;
073263
! static char_u cfb_buffer[BF_CFB_LEN]; /* 64 bytes */
073263
  
073263
  /*
073263
   * Initialize with seed "iv[iv_len]".
073263
   */
073263
      void
073263
! bf_cfb_init(iv, iv_len)
073263
      char_u *iv;
073263
      int    iv_len;
073263
  {
073263
      int i, mi;
073263
  
073263
      randbyte_offset = update_offset = 0;
073263
!     vim_memset(cfb_buffer, 0, BF_CFB_LEN);
073263
      if (iv_len > 0)
073263
      {
073263
! 	mi = iv_len > BF_CFB_LEN ? iv_len : BF_CFB_LEN;
073263
  	for (i = 0; i < mi; i++)
073263
! 	    cfb_buffer[i % BF_CFB_LEN] ^= iv[i % iv_len];
073263
      }
073263
  }
073263
  
073263
! #define BF_CFB_UPDATE(c) { \
073263
!     cfb_buffer[update_offset] ^= (char_u)c; \
073263
!     if (++update_offset == BF_CFB_LEN) \
073263
  	update_offset = 0; \
073263
  }
073263
  
073263
  #define BF_RANBYTE(t) { \
073263
      if ((randbyte_offset & BF_BLOCK_MASK) == 0) \
073263
! 	bf_e_cblock(&cfb_buffer[randbyte_offset]); \
073263
!     t = cfb_buffer[randbyte_offset]; \
073263
!     if (++randbyte_offset == BF_CFB_LEN) \
073263
  	randbyte_offset = 0; \
073263
  }
073263
  
073263
***************
073263
*** 610,616 ****
073263
      {
073263
  	ztemp = from[i];
073263
  	BF_RANBYTE(t);
073263
! 	BF_OFB_UPDATE(ztemp);
073263
  	to[i] = t ^ ztemp;
073263
      }
073263
  }
073263
--- 610,616 ----
073263
      {
073263
  	ztemp = from[i];
073263
  	BF_RANBYTE(t);
073263
! 	BF_CFB_UPDATE(ztemp);
073263
  	to[i] = t ^ ztemp;
073263
      }
073263
  }
073263
***************
073263
*** 630,636 ****
073263
      {
073263
  	BF_RANBYTE(t);
073263
  	*p ^= t;
073263
! 	BF_OFB_UPDATE(*p);
073263
      }
073263
  }
073263
  
073263
--- 630,636 ----
073263
      {
073263
  	BF_RANBYTE(t);
073263
  	*p ^= t;
073263
! 	BF_CFB_UPDATE(*p);
073263
      }
073263
  }
073263
  
073263
***************
073263
*** 646,658 ****
073263
  
073263
      for (p = passwd; *p != NUL; ++p)
073263
      {
073263
! 	BF_OFB_UPDATE(*p);
073263
      }
073263
  }
073263
  
073263
  static int save_randbyte_offset;
073263
  static int save_update_offset;
073263
! static char_u save_ofb_buffer[BF_OFB_LEN];
073263
  static UINT32_T save_pax[18];
073263
  static UINT32_T save_sbx[4][256];
073263
  
073263
--- 646,658 ----
073263
  
073263
      for (p = passwd; *p != NUL; ++p)
073263
      {
073263
! 	BF_CFB_UPDATE(*p);
073263
      }
073263
  }
073263
  
073263
  static int save_randbyte_offset;
073263
  static int save_update_offset;
073263
! static char_u save_cfb_buffer[BF_CFB_LEN];
073263
  static UINT32_T save_pax[18];
073263
  static UINT32_T save_sbx[4][256];
073263
  
073263
***************
073263
*** 665,671 ****
073263
  {
073263
      save_randbyte_offset = randbyte_offset;
073263
      save_update_offset = update_offset;
073263
!     mch_memmove(save_ofb_buffer, ofb_buffer, BF_OFB_LEN);
073263
      mch_memmove(save_pax, pax, 4 * 18);
073263
      mch_memmove(save_sbx, sbx, 4 * 4 * 256);
073263
  }
073263
--- 665,671 ----
073263
  {
073263
      save_randbyte_offset = randbyte_offset;
073263
      save_update_offset = update_offset;
073263
!     mch_memmove(save_cfb_buffer, cfb_buffer, BF_CFB_LEN);
073263
      mch_memmove(save_pax, pax, 4 * 18);
073263
      mch_memmove(save_sbx, sbx, 4 * 4 * 256);
073263
  }
073263
***************
073263
*** 679,685 ****
073263
  {
073263
      randbyte_offset = save_randbyte_offset;
073263
      update_offset = save_update_offset;
073263
!     mch_memmove(ofb_buffer, save_ofb_buffer, BF_OFB_LEN);
073263
      mch_memmove(pax, save_pax, 4 * 18);
073263
      mch_memmove(sbx, save_sbx, 4 * 4 * 256);
073263
  }
073263
--- 679,685 ----
073263
  {
073263
      randbyte_offset = save_randbyte_offset;
073263
      update_offset = save_update_offset;
073263
!     mch_memmove(cfb_buffer, save_cfb_buffer, BF_CFB_LEN);
073263
      mch_memmove(pax, save_pax, 4 * 18);
073263
      mch_memmove(sbx, save_sbx, 4 * 4 * 256);
073263
  }
073263
*** ../vim-7.4.171/src/fileio.c	2013-11-28 18:53:47.000000000 +0100
073263
--- src/fileio.c	2014-02-11 15:16:57.546117649 +0100
073263
***************
073263
*** 2973,2979 ****
073263
  	    else
073263
  	    {
073263
  		bf_key_init(cryptkey, ptr + CRYPT_MAGIC_LEN, salt_len);
073263
! 		bf_ofb_init(ptr + CRYPT_MAGIC_LEN + salt_len, seed_len);
073263
  	    }
073263
  
073263
  	    /* Remove magic number from the text */
073263
--- 2973,2979 ----
073263
  	    else
073263
  	    {
073263
  		bf_key_init(cryptkey, ptr + CRYPT_MAGIC_LEN, salt_len);
073263
! 		bf_cfb_init(ptr + CRYPT_MAGIC_LEN + salt_len, seed_len);
073263
  	    }
073263
  
073263
  	    /* Remove magic number from the text */
073263
***************
073263
*** 3025,3031 ****
073263
  	if (fread(buffer, salt_len + seed_len, 1, fp) != 1)
073263
  	    return FAIL;
073263
  	bf_key_init(curbuf->b_p_key, buffer, salt_len);
073263
! 	bf_ofb_init(buffer + salt_len, seed_len);
073263
      }
073263
      return OK;
073263
  }
073263
--- 3025,3031 ----
073263
  	if (fread(buffer, salt_len + seed_len, 1, fp) != 1)
073263
  	    return FAIL;
073263
  	bf_key_init(curbuf->b_p_key, buffer, salt_len);
073263
! 	bf_cfb_init(buffer + salt_len, seed_len);
073263
      }
073263
      return OK;
073263
  }
073263
***************
073263
*** 3064,3070 ****
073263
  	    seed = salt + salt_len;
073263
  	    sha2_seed(salt, salt_len, seed, seed_len);
073263
  	    bf_key_init(buf->b_p_key, salt, salt_len);
073263
! 	    bf_ofb_init(seed, seed_len);
073263
  	}
073263
      }
073263
      *lenp = CRYPT_MAGIC_LEN + salt_len + seed_len;
073263
--- 3064,3070 ----
073263
  	    seed = salt + salt_len;
073263
  	    sha2_seed(salt, salt_len, seed, seed_len);
073263
  	    bf_key_init(buf->b_p_key, salt, salt_len);
073263
! 	    bf_cfb_init(seed, seed_len);
073263
  	}
073263
      }
073263
      *lenp = CRYPT_MAGIC_LEN + salt_len + seed_len;
073263
*** ../vim-7.4.171/src/proto/blowfish.pro	2013-08-10 13:37:06.000000000 +0200
073263
--- src/proto/blowfish.pro	2014-02-11 15:18:20.382118919 +0100
073263
***************
073263
*** 1,6 ****
073263
  /* blowfish.c */
073263
  void bf_key_init __ARGS((char_u *password, char_u *salt, int salt_len));
073263
! void bf_ofb_init __ARGS((char_u *iv, int iv_len));
073263
  void bf_crypt_encode __ARGS((char_u *from, size_t len, char_u *to));
073263
  void bf_crypt_decode __ARGS((char_u *ptr, long len));
073263
  void bf_crypt_init_keys __ARGS((char_u *passwd));
073263
--- 1,6 ----
073263
  /* blowfish.c */
073263
  void bf_key_init __ARGS((char_u *password, char_u *salt, int salt_len));
073263
! void bf_cfb_init __ARGS((char_u *iv, int iv_len));
073263
  void bf_crypt_encode __ARGS((char_u *from, size_t len, char_u *to));
073263
  void bf_crypt_decode __ARGS((char_u *ptr, long len));
073263
  void bf_crypt_init_keys __ARGS((char_u *passwd));
073263
*** ../vim-7.4.171/src/memline.c	2013-11-28 17:41:41.000000000 +0100
073263
--- src/memline.c	2014-02-11 15:17:02.190117720 +0100
073263
***************
073263
*** 4914,4920 ****
073263
  	 * block for the salt. */
073263
  	vim_snprintf((char *)salt, sizeof(salt), "%ld", (long)offset);
073263
  	bf_key_init(key, salt, (int)STRLEN(salt));
073263
! 	bf_ofb_init(seed, MF_SEED_LEN);
073263
      }
073263
  }
073263
  
073263
--- 4914,4920 ----
073263
  	 * block for the salt. */
073263
  	vim_snprintf((char *)salt, sizeof(salt), "%ld", (long)offset);
073263
  	bf_key_init(key, salt, (int)STRLEN(salt));
073263
! 	bf_cfb_init(seed, MF_SEED_LEN);
073263
      }
073263
  }
073263
  
073263
*** ../vim-7.4.171/src/version.c	2014-02-11 15:10:38.138111836 +0100
073263
--- src/version.c	2014-02-11 15:16:01.206116786 +0100
073263
***************
073263
*** 740,741 ****
073263
--- 740,743 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     172,
073263
  /**/
073263
073263
-- 
073263
GALAHAD: No look, really, this isn't nescess ...
073263
PIGLET:  We must examine you.
073263
GALAHAD: There's nothing wrong with ... that.
073263
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///