patch 8.2.3022: available encryption methods are not strong enough
Problem: Available encryption methods are not strong enough.
Solution: Add initial support for xchaha20. (Christian Brabandt,
closes #8394)
diff --git a/src/undo.c b/src/undo.c
index 12f3e96..4b1158a 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -963,7 +963,9 @@
{
if (bi->bi_buffer != NULL && bi->bi_state != NULL && bi->bi_used > 0)
{
- crypt_encode_inplace(bi->bi_state, bi->bi_buffer, bi->bi_used);
+ // Last parameter is only used for sodium encryption and that
+ // explicitly disables encryption of undofiles.
+ crypt_encode_inplace(bi->bi_state, bi->bi_buffer, bi->bi_used, FALSE);
if (fwrite(bi->bi_buffer, bi->bi_used, (size_t)1, bi->bi_fp) != 1)
return FAIL;
bi->bi_used = 0;
@@ -995,7 +997,9 @@
if (copy == NULL)
return 0;
}
- crypt_encode(bi->bi_state, ptr, len, copy);
+ // Last parameter is only used for sodium encryption and that
+ // explicitly disables encryption of undofiles.
+ crypt_encode(bi->bi_state, ptr, len, copy, TRUE);
i = fwrite(copy, len, (size_t)1, bi->bi_fp);
if (copy != small_buf)
vim_free(copy);
@@ -1129,7 +1133,7 @@
}
bi->bi_avail = n;
bi->bi_used = 0;
- crypt_decode_inplace(bi->bi_state, bi->bi_buffer, bi->bi_avail);
+ crypt_decode_inplace(bi->bi_state, bi->bi_buffer, bi->bi_avail, FALSE);
}
n = size_todo;
if (n > bi->bi_avail - bi->bi_used)
@@ -1176,7 +1180,7 @@
ptr[len] = NUL;
#ifdef FEAT_CRYPT
if (bi->bi_state != NULL && bi->bi_buffer == NULL)
- crypt_decode_inplace(bi->bi_state, ptr, len);
+ crypt_decode_inplace(bi->bi_state, ptr, len, FALSE);
#endif
}
return ptr;