View Issue Details

IDProjectCategoryView StatusLast Update
0000202fileGeneralpublic2020-10-11 20:28
Reporterosmans Assigned Tochristos  
PrioritynormalSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
Product Version5.37 
Fixed in Version5.40 
Summary0000202: Support Vim encryption modes
DescriptionThe Magic file for Vim encrypted files (i.e. /file/magic/Magdir/editors) currently only reads the first 9 bytes and not the full 12 bytes used by Vim to define its encrypted files magic numbers[1]. This issue is to request that file should read the full 12 bytes so as to identify which of the three currently supported encryption modes were used to encrypt the file. I know this doesn't meet the 16byte bar, but it's what is authoritative for Vim.

Possible modes of Vim's built-in encryption are the following with their corresponding magic numbers as of Vim 8.2[2]:
* zip: VimCrypt~01!
* blowfish: VimCrypt~02!
* blowfish2: VimCrypt~03!

[1] https://github.com/vim/vim/blob/c667da5185ce5dce914d2006d62da2be0cedb384/src/crypt.c#L133
[2] https://github.com/vim/vim/blob/c667da5185ce5dce914d2006d62da2be0cedb384/src/crypt.c#L78-L131
Steps To Reproduce1. Open up Vim with encryption enabled:
$ vim -x hello_world.encrypted

2. Specify which encryption method to use:
:set cryptmethod=blowfish2

3. Set password on the file:
:set key=hunter2

4. Save and exit:
:wq

5. Repeat for each supported cryptmethod and observe results of magic numbers used:
$ xxd -l 12 hello_world.encrypted
00000000: 5669 6d43 7279 7074 7e30 3121 VimCrypt~01!
$ xxd -l 12 hello_world2.encrypted
00000000: 5669 6d43 7279 7074 7e30 3221 VimCrypt~02!
$ xxd -l 12 hello_world3.encrypted
00000000: 5669 6d43 7279 7074 7e30 3321 VimCrypt~03!

I've done the reproduction in some dummy files which you can find attached to this report. All files are encrypted with the literal password "password"
Additional InformationHere is my proposed patch:

diff --git a/magic/Magdir/editors b/magic/Magdir/editors
index 78f3a840..93ad2955 100644
--- a/magic/Magdir/editors
+++ b/magic/Magdir/editors
@@ -11,7 +11,11 @@

 # Vi IMproved Encrypted file
 # by David Necas <yeti@physics.muni.cz>
+# updated by Osman Surkatty
 0 string VimCrypt~ Vim encrypted file data
+>9 string 01! with zip cryptmethod
+>9 string 02! with blowfish cryptmethod
+>9 string 03! with blowfish2 cryptmethod

 0 name vimnanoswap
 >67 byte 0
TagsNo tags attached.

Activities

osmans

2020-10-11 16:33

reporter  

osmans

2020-10-11 16:36

reporter   ~0003486

Attaching patch file.
vim_magic.patch (461 bytes)   
diff --git a/magic/Magdir/editors b/magic/Magdir/editors
index 78f3a840..93ad2955 100644
--- a/magic/Magdir/editors
+++ b/magic/Magdir/editors
@@ -11,7 +11,11 @@
 
 # Vi IMproved Encrypted file
 # by David Necas <yeti@physics.muni.cz>
+# updated by Osman Surkatty
 0	string	VimCrypt~	Vim encrypted file data
+>9	string	01!	with zip cryptmethod
+>9	string	02!	with blowfish cryptmethod
+>9	string	03!	with blowfish2 cryptmethod
 
 0	name	vimnanoswap
 >67	byte	0
vim_magic.patch (461 bytes)   

christos

2020-10-11 20:28

manager   ~0003492

Added, thanks!

Issue History

Date Modified Username Field Change
2020-10-11 16:33 osmans New Issue
2020-10-11 16:33 osmans File Added: hello_world3.encrypted
2020-10-11 16:33 osmans File Added: hello_world2.encrypted
2020-10-11 16:33 osmans File Added: hello_world.encrypted
2020-10-11 16:36 osmans File Added: vim_magic.patch
2020-10-11 16:36 osmans Note Added: 0003486
2020-10-11 20:28 christos Assigned To => christos
2020-10-11 20:28 christos Status new => assigned
2020-10-11 20:28 christos Status assigned => resolved
2020-10-11 20:28 christos Resolution open => fixed
2020-10-11 20:28 christos Fixed in Version => 5.40
2020-10-11 20:28 christos Note Added: 0003492