summaryrefslogtreecommitdiffstats
path: root/src/crypt.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-01-18 22:48:34 +0100
committerBram Moolenaar <Bram@vim.org>2019-01-18 22:48:34 +0100
commit987411db9e4b76b524d0579db21074be0bffd61b (patch)
tree215f2c2b7c988b5572e645cbb52c73d65b6bad2a /src/crypt.c
parent0314236aabcb2ca9d0b74074dadecf68d7c7ed5f (diff)
patch 8.1.0773: not all crypt code is testedv8.1.0773
Problem: Not all crypt code is tested. Solution: Disable unused crypt code. Add more test coverage.
Diffstat (limited to 'src/crypt.c')
-rw-r--r--src/crypt.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/crypt.c b/src/crypt.c
index 599607078a..f82ee7bdb7 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -34,7 +34,9 @@ typedef struct {
char *magic; /* magic bytes stored in file header */
int salt_len; /* length of salt, or 0 when not using salt */
int seed_len; /* length of seed, or 0 when not using salt */
+#ifdef CRYPT_NOT_INPLACE
int works_inplace; /* encryption/decryption can be done in-place */
+#endif
int whole_undofile; /* whole undo file is encrypted */
/* Optional function pointer for a self-test. */
@@ -80,7 +82,9 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
"VimCrypt~01!",
0,
0,
+#ifdef CRYPT_NOT_INPLACE
TRUE,
+#endif
FALSE,
NULL,
crypt_zip_init,
@@ -95,7 +99,9 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
"VimCrypt~02!",
8,
8,
+#ifdef CRYPT_NOT_INPLACE
TRUE,
+#endif
FALSE,
blowfish_self_test,
crypt_blowfish_init,
@@ -110,7 +116,9 @@ static cryptmethod_T cryptmethods[CRYPT_M_COUNT] = {
"VimCrypt~03!",
8,
8,
+#ifdef CRYPT_NOT_INPLACE
TRUE,
+#endif
TRUE,
blowfish_self_test,
crypt_blowfish_init,
@@ -167,6 +175,7 @@ crypt_method_nr_from_magic(char *ptr, int len)
return -1;
}
+#ifdef CRYPT_NOT_INPLACE
/*
* Return TRUE if the crypt method for "method_nr" can be done in-place.
*/
@@ -175,6 +184,7 @@ crypt_works_inplace(cryptstate_T *state)
{
return cryptmethods[state->method_nr].works_inplace;
}
+#endif
/*
* Get the crypt method for buffer "buf" as a number.
@@ -366,6 +376,7 @@ crypt_free_state(cryptstate_T *state)
vim_free(state);
}
+#ifdef CRYPT_NOT_INPLACE
/*
* Encode "from[len]" and store the result in a newly allocated buffer, which
* is stored in "newptr".
@@ -422,6 +433,7 @@ crypt_decode_alloc(
method->decode_fn(state, ptr, len, *newptr);
return len;
}
+#endif
/*
* Encrypting "from[len]" into "to[len]".
@@ -436,6 +448,7 @@ crypt_encode(
cryptmethods[state->method_nr].encode_fn(state, from, len, to);
}
+#if 0 // unused
/*
* decrypting "from[len]" into "to[len]".
*/
@@ -448,6 +461,7 @@ crypt_decode(
{
cryptmethods[state->method_nr].decode_fn(state, from, len, to);
}
+#endif
/*
* Simple inplace encryption, modifies "buf[len]" in place.