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:
committed by
Bram Moolenaar
parent
208f0b48b2
commit
f573c6e1ed
12
src/undo.c
12
src/undo.c
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user