Mercurial > vim
annotate src/testdir/test_crypt.vim @ 32489:d6055989fa27 v9.0.1576
patch 9.0.1576: users may not know what to do with an internal error
Commit: https://github.com/vim/vim/commit/097c5370ea8abab17ceb0f3bcd74f57b1655c7f7
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed May 24 21:02:24 2023 +0100
patch 9.0.1576: users may not know what to do with an internal error
Problem: Users may not know what to do with an internal error.
Solution: Add a translated message with instructions.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 May 2023 22:15:06 +0200 |
parents | 6761c71f4b25 |
children | 5d07e7e9580f |
rev | line source |
---|---|
10221
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for encryption. |
10231
cbee14cc4da6
commit https://github.com/vim/vim/commit/1eceadaf481e34ed8155011534159775697ce884
Christian Brabandt <cb@256bit.org>
parents:
10225
diff
changeset
|
2 |
17089
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
3 source check.vim |
8e9e9124c7a2
patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents:
17049
diff
changeset
|
4 CheckFeature cryptv |
10221
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
31035
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
6 " Use the xxd command from: |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
7 " 1: $XXDPROG if set and it is executable |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
8 " 2: the ../xxd directory if the executable is found there |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
9 if !empty($XXDPROG) && executable($XXDPROG) |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
10 let s:xxd_cmd = $XXDPROG |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
11 elseif executable('..\xxd\xxd.exe') |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
12 " we're on MS-Windows |
25925
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
13 let s:xxd_cmd = '..\xxd\xxd.exe' |
31035
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
14 elseif executable('../xxd/xxd') |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
15 " we're on something like Unix |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
16 let s:xxd_cmd = '../xxd/xxd' |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
17 else |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
18 " looks like xxd wasn't build (yet) |
10e6088a2a72
patch 9.0.0852: crypt test is skipped if xxd is not found
Bram Moolenaar <Bram@vim.org>
parents:
28171
diff
changeset
|
19 let s:xxd_cmd = '' |
25925
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
20 endif |
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
21 |
10221
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 func Common_head_only(text) |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " This was crashing Vim |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 split Xtest.txt |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 call setline(1, a:text) |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 wq |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 call feedkeys(":split Xtest.txt\<CR>foobar\<CR>", "tx") |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 call delete('Xtest.txt') |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call assert_match('VimCrypt', getline(1)) |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 bwipe! |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 endfunc |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 func Test_head_only_2() |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call Common_head_only('VimCrypt~02!abc') |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 endfunc |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 func Test_head_only_3() |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 call Common_head_only('VimCrypt~03!abc') |
fb1fde4fcff7
commit https://github.com/vim/vim/commit/680e015bfe19be6772d3bd754486fbd45c1a9d3b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 endfunc |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
40 |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
41 func Test_head_only_4() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
42 CheckFeature sodium |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
43 call Common_head_only('VimCrypt~04!abc') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
44 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
45 |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
46 func Crypt_uncrypt(method) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
47 exe "set cryptmethod=" . a:method |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
48 " If the blowfish test fails 'cryptmethod' will be 'zip' now. |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
49 call assert_equal(a:method, &cryptmethod) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
50 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
51 split Xtest.txt |
32313
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
52 let text =<< trim END |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
53 01234567890123456789012345678901234567, |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
54 line 2 foo bar blah, |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
55 line 3 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
56 END |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
57 call setline(1, text) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
58 call feedkeys(":X\<CR>foobar\<CR>foobar\<CR>", 'xt') |
15531
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
59 call assert_equal('*****', &key) |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
60 w! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
61 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
62 call feedkeys(":split Xtest.txt\<CR>foobar\<CR>", 'xt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
63 call assert_equal(text, getline(1, 3)) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
64 set key= cryptmethod& |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
65 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
66 call delete('Xtest.txt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
67 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
68 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
69 func Test_crypt_zip() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
70 call Crypt_uncrypt('zip') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
71 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
72 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
73 func Test_crypt_blowfish() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
74 call Crypt_uncrypt('blowfish') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
75 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
76 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
77 func Test_crypt_blowfish2() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
78 call Crypt_uncrypt('blowfish2') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
79 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
80 |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
81 func Test_crypt_sodium() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
82 CheckFeature sodium |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
83 call Crypt_uncrypt('xchacha20') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
84 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
85 |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
86 func Test_crypt_sodium_v2() |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
87 CheckFeature sodium |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
88 call Crypt_uncrypt('xchacha20v2') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
89 endfunc |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
90 |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
91 func Uncrypt_stable(method, crypted_text, key, uncrypted_text) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
92 split Xtest.txt |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
93 set bin noeol key= fenc=latin1 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
94 exe "set cryptmethod=" . a:method |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
95 call setline(1, a:crypted_text) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
96 w! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
97 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
98 set nobin |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
99 call feedkeys(":split Xtest.txt\<CR>" . a:key . "\<CR>", 'xt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
100 call assert_equal(a:uncrypted_text, getline(1, len(a:uncrypted_text))) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
101 bwipe! |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
102 call delete('Xtest.txt') |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
103 set key= |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
104 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
105 |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
106 func Uncrypt_stable_xxd(method, hex, key, uncrypted_text, verbose) |
25925
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
107 if empty(s:xxd_cmd) |
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
108 throw 'Skipped: xxd program missing' |
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
109 endif |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
110 " use xxd to write the binary content |
25925
8b34c216a523
patch 8.2.3496: crypt test fails if xxd was not installed yet
Bram Moolenaar <Bram@vim.org>
parents:
25362
diff
changeset
|
111 call system(s:xxd_cmd .. ' -r >Xtest.txt', a:hex) |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
112 let cmd = (a:verbose ? ':verbose' : '') .. |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
113 \ ":split Xtest.txt\<CR>" . a:key . "\<CR>" |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
114 call feedkeys(cmd, 'xt') |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
115 call assert_equal(a:uncrypted_text, getline(1, len(a:uncrypted_text))) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
116 bwipe! |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
117 call delete('Xtest.txt') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
118 set key= |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
119 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
120 |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
121 func Test_uncrypt_zip() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
122 call Uncrypt_stable('zip', "VimCrypt~01!\u0006\u001clV'\u00de}Mg\u00a0\u00ea\u00a3V\u00a9\u00e7\u0007E#3\u008e2U\u00e9\u0097", "foofoo", ["1234567890", "aábbccddeëff"]) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
123 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
124 |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
125 func Test_uncrypt_blowfish() |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
126 call Uncrypt_stable('blowfish', "VimCrypt~02!k)\u00be\u0017\u0097#\u0016\u00ddS\u009c\u00f5=\u00ba\u00e0\u00c8#\u00a5M\u00b4\u0086J\u00c3A\u00cd\u00a5M\u00b4\u0086!\u0080\u0015\u009b\u00f5\u000f\u00e1\u00d2\u0019\u0082\u0016\u0098\u00f7\u000d\u00da", "barbar", ["asdfasdfasdf", "0001112223333"]) |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
127 endfunc |
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
128 |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
129 func Test_uncrypt_blowfish2a() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
130 call Uncrypt_stable('blowfish', "VimCrypt~03!\u001e\u00d1N\u00e3;\u00d3\u00c0\u00a0^C)\u0004\u00f7\u007f.\u00b6\u00abF\u000eS\u0019\u00e0\u008b6\u00d2[T\u00cb\u00a7\u0085\u00d8\u00be9\u000b\u00812\u000bQ\u00b3\u00cc@\u0097\u000f\u00df\u009a\u00adIv\u00aa.\u00d8\u00c9\u00ee\u009e`\u00bd$\u00af%\u00d0", "barburp", ["abcdefghijklmnopqrstuvwxyz", "!@#$%^&*()_+=-`~"]) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
131 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
132 |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
133 func Test_uncrypt_blowfish2() |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
134 call Uncrypt_stable('blowfish2', "VimCrypt~03!\u001e\u00d1N\u00e3;\u00d3\u00c0\u00a0^C)\u0004\u00f7\u007f.\u00b6\u00abF\u000eS\u0019\u00e0\u008b6\u00d2[T\u00cb\u00a7\u0085\u00d8\u00be9\u000b\u00812\u000bQ\u00b3\u00cc@\u0097\u000f\u00df\u009a\u00adIv\u00aa.\u00d8\u00c9\u00ee\u009e`\u00bd$\u00af%\u00d0", "barburp", ["abcdefghijklmnopqrstuvwxyz", "!@#$%^&*()_+=-`~"]) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
135 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
136 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
137 func Test_uncrypt_xchacha20() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
138 CheckFeature sodium |
32313
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
139 let hex =<< trim END |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
140 00000000: 5669 6d43 7279 7074 7e30 3421 6b7d e607 vimCrypt~04!k}.. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
141 00000010: 4ea4 e99f 923e f67f 7b59 a80d 3bca 2f06 N....>..{Y..;./. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
142 00000020: fa11 b951 8d09 0dc9 470f e7cf 8b90 4310 ...Q....G.....C. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
143 00000030: 653b b83b e493 378b 0390 0e38 f912 626b e;.;..7....8..bk |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
144 00000040: a02e 4697 0254 2625 2d8e 3a0b 784b e89c ..F..T&%-.:.xK.. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
145 00000050: 0c67 a975 3c17 9319 8ffd 1463 7783 a1f3 .g.u<......cw... |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
146 00000060: d917 dcb3 8b3e ecd7 c7d4 086b 6059 7ead .....>.....k`Y~. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
147 00000070: 9b07 f96b 5c1b 4d08 cd91 f208 5221 7484 ...k\.M.....R!t. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
148 00000080: 72be 0136 84a1 d3 r..6... |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
149 END |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
150 " the file should be in latin1 encoding, this makes sure that readfile() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
151 " retries several times converting the multi-byte characters |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
152 call Uncrypt_stable_xxd('xchacha20', hex, "sodium_crypt", ["abcdefghijklmnopqrstuvwxyzäöü", "ZZZ_äüöÄÜÖ_!@#$%^&*()_+=-`~"], 0) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
153 endfunc |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
154 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
155 func Test_uncrypt_xchacha20v2_custom() |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
156 CheckFeature sodium |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
157 " Test, reading xchacha20v2 with custom encryption parameters |
32313
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
158 let hex =<< trim END |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
159 00000000: 5669 6d43 7279 7074 7e30 3521 934b f288 VimCrypt~05!.K.. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
160 00000010: 10ba 8bc9 25a0 8876 f85c f135 6fb8 518b ....%..v.\.5o.Q. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
161 00000020: b133 9af1 0300 0000 0000 0000 0000 0010 .3.............. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
162 00000030: 0000 0000 0200 0000 b973 5f33 80e9 54fc .........s_3..T. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
163 00000040: 138f ba3e 046b 3135 90b7 7783 5eac 7fe3 ...>.k15..w.^... |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
164 00000050: 0cd2 14df ed75 4b65 8763 8205 035c ec81 .....uKe.c...\.. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
165 00000060: a4cf 33d2 7507 ec38 ba62 a327 9068 d8ad ..3.u..8.b.'.h.. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
166 00000070: 2607 3fa6 f95d 7ea8 9799 f997 4820 0c &.?..]~.....H . |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
167 END |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
168 call Uncrypt_stable_xxd('xchacha20v2', hex, "foobar", ["", "foo", "bar", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"], 1) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
169 call assert_match('xchacha20v2: using custom \w\+ "\d\+" for Key derivation.', execute(':messages')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
170 endfunc |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
171 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
172 func Test_uncrypt_xchacha20v2() |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
173 CheckFeature sodium |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
174 " Test, reading xchacha20v2 |
32313
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
175 let hex =<< trim END |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
176 00000000: 5669 6d43 7279 7074 7e30 3521 9f20 4e14 VimCrypt~05!. N. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
177 00000010: c7da c1bd 7dea 8fbc db6c 38e6 7a77 6fef ....}....l8.zwo. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
178 00000020: 82dd 964b 0300 0000 0000 0000 0000 0010 ...K............ |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
179 00000030: 0000 0000 0200 0000 a97c 2f00 0b9d 19eb .........|/..... |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
180 00000040: 1d92 1ea5 3f22 c179 4b3e 870a eb19 6380 ....?".yK>....c. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
181 00000050: 63f8 222d b5d1 3c73 7be5 d580 47ea 44cc c."-..<s{...G.D. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
182 00000060: 6c25 8078 3fd5 d836 c700 0122 bb30 7a59 l%.x?..6...".0zY |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
183 00000070: b184 2ae8 e7db 113a f732 938f 7a34 1333 ..*....:.2..z4.3 |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
184 00000080: dc89 1491 51a0 67b9 0f3a b56c 1f9d 53b0 ....Q.g..:.l..S. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
185 00000090: 2416 205a 8c4c 5fde 4dac 2611 8a48 24f0 $. Z.L_.M.&..H$. |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
186 000000a0: ba00 92c1 60 ....` |
6761c71f4b25
patch 9.0.1488: xchacha20v2 crypt header is platform dependent
Bram Moolenaar <Bram@vim.org>
parents:
32299
diff
changeset
|
187 END |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
188 call Uncrypt_stable_xxd('xchacha20v2', hex, "foo1234", ["abcdefghijklmnopqrstuvwxyzäöü", 'ZZZ_äüöÄÜÖ_!@#$%^&*()_+=-`~"'], 0) |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
189 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
190 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
191 func Test_uncrypt_xchacha20_invalid() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
192 CheckFeature sodium |
25168
68f0093134b1
patch 8.2.3120: crypt with sodium test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
193 |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
194 " load an invalid encrypted file and verify it can be decrypted with an |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
195 " error message |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
196 try |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
197 call feedkeys(":split samples/crypt_sodium_invalid.txt\<CR>sodium\<CR>", 'xt') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
198 call assert_false(1, 'should not happen') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
199 catch |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
200 call assert_exception('pre-mature') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
201 endtry |
25362
68a7e6d70a5e
patch 8.2.3218: when using xchaha20 crypt undo file is not removed
Bram Moolenaar <Bram@vim.org>
parents:
25242
diff
changeset
|
202 call assert_match("Note: Encryption of swapfile not supported, disabling swap file", execute(':5messages')) |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
203 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
204 call assert_equal(0, &swapfile) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
205 call assert_equal("xchacha20", &cryptmethod) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
206 call assert_equal('311111111111111111111111', getline('$')) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
207 bw! |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
208 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
209 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
210 func Test_uncrypt_xchacha20_2() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
211 CheckFeature sodium |
25168
68f0093134b1
patch 8.2.3120: crypt with sodium test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
212 |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
213 sp Xcrypt_sodium.txt |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
214 " Create a larger file, so that Vim will write in several blocks |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
215 call setline(1, range(1, 4000)) |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
216 call assert_equal(1, &swapfile) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
217 set cryptmethod=xchacha20 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
218 call feedkeys(":X\<CR>sodium\<CR>sodium\<CR>", 'xt') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
219 " swapfile disabled |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
220 call assert_equal(0, &swapfile) |
25362
68a7e6d70a5e
patch 8.2.3218: when using xchaha20 crypt undo file is not removed
Bram Moolenaar <Bram@vim.org>
parents:
25242
diff
changeset
|
221 call assert_match("Note: Encryption of swapfile not supported, disabling swap file", execute(':messages')) |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
222 w! |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
223 " encrypted using xchacha20 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
224 call assert_match("\[xchacha20\]", execute(':messages')) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
225 bw! |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
226 call feedkeys(":sp Xcrypt_sodium.txt\<CR>sodium\<CR>", 'xt') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
227 " successfully decrypted |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
228 call assert_equal(range(1, 4000)->map( {_, v -> string(v)}), getline(1,'$')) |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
229 set key= |
25168
68f0093134b1
patch 8.2.3120: crypt with sodium test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
230 w! ++ff=unix |
28171
b4c111ea83b1
patch 8.2.4611: typos in tests; one lua line not covered by test
Bram Moolenaar <Bram@vim.org>
parents:
25925
diff
changeset
|
231 " encryption removed (on MS-Windows the .* matches [unix]) |
25242
1ef6880ba4a9
patch 8.2.3157: crypt test may fail on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
25168
diff
changeset
|
232 call assert_match('"Xcrypt_sodium.txt".*4000L, 18893B written', execute(':message')) |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
233 bw! |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
234 call delete('Xcrypt_sodium.txt') |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
235 set cryptmethod&vim |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
236 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
237 endfunc |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
238 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
239 func Test_uncrypt_xchacha20v2_2() |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
240 CheckFeature sodium |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
241 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
242 sp Xcrypt_sodium_v2.txt |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
243 " Create a larger file, so that Vim will write in several blocks |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
244 call setline(1, range(1, 4000)) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
245 call assert_equal(1, &swapfile) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
246 set cryptmethod=xchacha20v2 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
247 call feedkeys(":X\<CR>sodium\<CR>sodium\<CR>", 'xt') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
248 " swapfile disabled |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
249 call assert_equal(0, &swapfile) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
250 call assert_match("Note: Encryption of swapfile not supported, disabling swap file", execute(':messages')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
251 w! |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
252 " encrypted using xchacha20 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
253 call assert_match("\[xchachav2\]", execute(':messages')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
254 bw! |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
255 call feedkeys(":verbose :sp Xcrypt_sodium_v2.txt\<CR>sodium\<CR>", 'xt') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
256 " successfully decrypted |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
257 call assert_equal(range(1, 4000)->map( {_, v -> string(v)}), getline(1,'$')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
258 call assert_match('xchacha20v2: using default \w\+ "\d\+" for Key derivation.', execute(':messages')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
259 set key= |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
260 w! ++ff=unix |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
261 " encryption removed (on MS-Windows the .* matches [unix]) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
262 call assert_match('"Xcrypt_sodium_v2.txt".*4000L, 18893B written', execute(':message')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
263 bw! |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
264 call delete('Xcrypt_sodium_v2.txt') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
265 set cryptmethod&vim |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
266 |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
267 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
268 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
269 func Test_uncrypt_xchacha20_3_persistent_undo() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
270 CheckFeature sodium |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
271 CheckFeature persistent_undo |
25168
68f0093134b1
patch 8.2.3120: crypt with sodium test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
24970
diff
changeset
|
272 |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
273 for meth in ['xchacha20', 'xchacha20v2'] |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
274 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
275 sp Xcrypt_sodium_undo.txt |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
276 exe "set cryptmethod=" .. meth .. " undofile" |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
277 call feedkeys(":X\<CR>sodium\<CR>sodium\<CR>", 'xt') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
278 call assert_equal(1, &undofile) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
279 let ufile=undofile(@%) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
280 call append(0, ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
281 call cursor(1, 1) |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
282 |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
283 set undolevels=100 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
284 normal dd |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
285 set undolevels=100 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
286 normal dd |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
287 set undolevels=100 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
288 normal dd |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
289 set undolevels=100 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
290 w! |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
291 call assert_equal(0, &undofile) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
292 bw! |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
293 call feedkeys(":sp Xcrypt_sodium_undo.txt\<CR>sodium\<CR>", 'xt') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
294 " should fail |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
295 norm! u |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
296 call assert_match('Already at oldest change', execute(':1mess')) |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
297 call assert_fails('verbose rundo ' .. fnameescape(ufile), 'E822') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
298 bw! |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
299 set undolevels& cryptmethod& undofile& |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
300 call delete('Xcrypt_sodium_undo.txt') |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
301 |
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
302 endfor |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
303 endfunc |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
304 |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
305 func Test_encrypt_xchacha20_missing() |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
306 if has("sodium") |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
307 return |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
308 endif |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
309 sp Xcrypt_sodium_undo.txt |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
310 call assert_fails(':set cryptmethod=xchacha20', 'E474') |
32299
3d4e28569a6d
patch 9.0.1481: decrypting with libsodium may fail if the library changes
Bram Moolenaar <Bram@vim.org>
parents:
31035
diff
changeset
|
311 call assert_fails(':set cryptmethod=xchacha20v2', 'E474') |
24970
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
312 bw! |
7e9e53a0368f
patch 8.2.3022: available encryption methods are not strong enough
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
313 set cm& |
10239
ebbc8d21105b
commit https://github.com/vim/vim/commit/177778575148e265c0e32ec2abf2d2c615f5ead5
Christian Brabandt <cb@256bit.org>
parents:
10231
diff
changeset
|
314 endfunc |
15531
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
315 |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
316 func Test_uncrypt_unknown_method() |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
317 split Xuncrypt_unknown.txt |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
318 set bin noeol key= fenc=latin1 |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
319 call setline(1, "VimCrypt~93!\u001e\u00d1") |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
320 w! |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
321 bwipe! |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
322 set nobin |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
323 call assert_fails(":split Xuncrypt_unknown.txt", 'E821:') |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
324 |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
325 bwipe! |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
326 call delete('Xuncrypt_unknown.txt') |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
327 set key= |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
328 endfunc |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
329 |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
330 func Test_crypt_key_mismatch() |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
331 set cryptmethod=blowfish |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
332 |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
333 split Xtest.txt |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
334 call setline(1, 'nothing') |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
335 call feedkeys(":X\<CR>foobar\<CR>nothing\<CR>", 'xt') |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
336 call assert_match("Keys don't match!", execute(':2messages')) |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
337 call assert_equal('', &key) |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
338 call feedkeys("\<CR>\<CR>", 'xt') |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
339 |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
340 set cryptmethod& |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
341 bwipe! |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
342 endfunc |
959cf4c63b18
patch 8.1.0773: not all crypt code is tested
Bram Moolenaar <Bram@vim.org>
parents:
10239
diff
changeset
|
343 |
20415
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
344 func Test_crypt_set_key_changes_buffer() |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
345 |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
346 new Xtest1.txt |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
347 call setline(1, 'nothing') |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
348 set cryptmethod=blowfish2 |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
349 call feedkeys(":X\<CR>foobar\<CR>foobar\<CR>", 'xt') |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
350 call assert_fails(":q", "E37:") |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
351 w |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
352 set key=anotherkey |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
353 call assert_fails(":bw") |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
354 w |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
355 call feedkeys(":X\<CR>foobar\<CR>foobar\<CR>", 'xt') |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
356 call assert_fails(":bw") |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
357 w |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
358 let winnr = winnr() |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
359 wincmd p |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
360 call setwinvar(winnr, '&key', 'yetanotherkey') |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
361 wincmd p |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
362 call assert_fails(":bw") |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
363 w |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
364 |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
365 set cryptmethod& |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
366 set key= |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
367 bwipe! |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
368 call delete('Xtest1.txt') |
b582eb6ef192
patch 8.2.0762: buffer is not considered modified after setting crypt key
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
369 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20415
diff
changeset
|
370 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
20415
diff
changeset
|
371 " vim: shiftwidth=2 sts=2 expandtab |