mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-25 07:23:28 +00:00
avoid losing the key
if we just have a pointer to a bytes object which might go out of scope, we can lose it. also: cython can directly assign a bytes object into a same-size char array.
This commit is contained in:
parent
41082f558f
commit
6d6d3caa24
1 changed files with 2 additions and 3 deletions
|
@ -428,7 +428,7 @@ cdef class _AEAD_BASE:
|
||||||
|
|
||||||
cdef CIPHER cipher
|
cdef CIPHER cipher
|
||||||
cdef EVP_CIPHER_CTX *ctx
|
cdef EVP_CIPHER_CTX *ctx
|
||||||
cdef unsigned char *key
|
cdef unsigned char key[32]
|
||||||
cdef int cipher_blk_len
|
cdef int cipher_blk_len
|
||||||
cdef int iv_len
|
cdef int iv_len
|
||||||
cdef int aad_offset
|
cdef int aad_offset
|
||||||
|
@ -587,8 +587,7 @@ cdef class _AEAD_BASE:
|
||||||
if isinstance(iv, int):
|
if isinstance(iv, int):
|
||||||
iv = iv.to_bytes(self.iv_len, byteorder='big')
|
iv = iv.to_bytes(self.iv_len, byteorder='big')
|
||||||
assert isinstance(iv, bytes) and len(iv) == self.iv_len
|
assert isinstance(iv, bytes) and len(iv) == self.iv_len
|
||||||
for i in range(self.iv_len):
|
self.iv = iv
|
||||||
self.iv[i] = iv[i]
|
|
||||||
self.blocks = 0 # number of cipher blocks encrypted with this IV
|
self.blocks = 0 # number of cipher blocks encrypted with this IV
|
||||||
|
|
||||||
def next_iv(self):
|
def next_iv(self):
|
||||||
|
|
Loading…
Reference in a new issue