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)
This commit is contained in:
Christian Brabandt
2021-06-20 14:02:16 +02:00
committed by Bram Moolenaar
parent 208f0b48b2
commit f573c6e1ed
29 changed files with 820 additions and 64 deletions

View File

@ -963,7 +963,9 @@ undo_flush(bufinfo_T *bi)
{
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 @@ fwrite_crypt(bufinfo_T *bi, char_u *ptr, size_t len)
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 @@ undo_read(bufinfo_T *bi, char_u *buffer, size_t size)
}
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 @@ read_string_decrypt(bufinfo_T *bi, int len)
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;