Skip to content

Commit 31484a7

Browse files
committed
updated for version 7.4.509
Problem: Users are not aware their encryption is weak. Solution: Give a warning when prompting for the key.
1 parent 9f61322 commit 31484a7

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

src/crypt.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,26 @@ crypt_free_key(key)
503503
}
504504
}
505505

506+
/*
507+
* Check the crypt method and give a warning if it's outdated.
508+
*/
509+
void
510+
crypt_check_method(method)
511+
int method;
512+
{
513+
if (method < CRYPT_M_BF2)
514+
{
515+
msg_scroll = TRUE;
516+
MSG(_("Warning: Using a weak encryption method; see :help 'cm'"));
517+
}
518+
}
519+
520+
void
521+
crypt_check_current_method()
522+
{
523+
crypt_check_method(crypt_get_method_nr(curbuf));
524+
}
525+
506526
/*
507527
* Ask the user for a crypt key.
508528
* When "store" is TRUE, the new key is stored in the 'key' option, and the

src/ex_docmd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11524,6 +11524,7 @@ ex_match(eap)
1152411524
ex_X(eap)
1152511525
exarg_T *eap UNUSED;
1152611526
{
11527+
crypt_check_current_method();
1152711528
(void)crypt_get_key(TRUE, TRUE);
1152811529
}
1152911530
#endif

src/fileio.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,7 @@ check_for_cryptkey(cryptkey, ptr, sizep, filesizep, newfile, fname, did_ask)
29582958
* Happens when retrying to detect encoding. */
29592959
smsg((char_u *)_(need_key_msg), fname);
29602960
msg_scroll = TRUE;
2961+
crypt_check_method(method);
29612962
cryptkey = crypt_get_key(newfile, FALSE);
29622963
*did_ask = TRUE;
29632964

src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,7 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
854854
#ifdef FEAT_CRYPT
855855
if (params.ask_for_key)
856856
{
857+
crypt_check_current_method();
857858
(void)crypt_get_key(TRUE, TRUE);
858859
TIME_MSG("getting crypt key");
859860
}

src/proto/crypt.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void crypt_decode __ARGS((cryptstate_T *state, char_u *from, size_t len, char_u
1919
void crypt_encode_inplace __ARGS((cryptstate_T *state, char_u *buf, size_t len));
2020
void crypt_decode_inplace __ARGS((cryptstate_T *state, char_u *buf, size_t len));
2121
void crypt_free_key __ARGS((char_u *key));
22+
void crypt_check_method __ARGS((int method));
23+
void crypt_check_current_method __ARGS((void));
2224
char_u *crypt_get_key __ARGS((int store, int twice));
2325
void crypt_append_msg __ARGS((buf_T *buf));
2426
/* vim: set ft=c : */

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
509,
744746
/**/
745747
508,
746748
/**/

0 commit comments

Comments
 (0)