You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsignedchar*out, int*outl,
37
+
const unsignedchar*in_, int inl) nogil
38
+
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsignedchar*out, int*outl,
39
+
const unsignedchar*in_, int inl) nogil
40
+
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX* ctx, unsignedchar* out, int* outl) nogil
41
+
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX* ctx, unsignedchar* out, int* outl) nogil
42
+
int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *ctx, int pad) nogil
43
+
18
44
# Cyclic polynomial / buzhash
19
45
#
20
46
# https://en.wikipedia.org/wiki/Rolling_hash
@@ -117,7 +143,11 @@ cdef class ChunkerBuzHash64:
117
143
cdef size_t reader_block_size
118
144
cdef bint sparse
119
145
120
-
def__cinit__(self, bytes key, int chunk_min_exp, int chunk_max_exp, int hash_mask_bits, int hash_window_size, bint sparse=False):
146
+
# optional AES encryption for rolling hash based chunking decision
147
+
cdef bint do_encrypt
148
+
cdef Crypter crypter
149
+
150
+
def__cinit__(self, bytes key, int chunk_min_exp, int chunk_max_exp, int hash_mask_bits, int hash_window_size, bint sparse=False, bint do_encrypt=False):
121
151
min_size =1<< chunk_min_exp
122
152
max_size =1<< chunk_max_exp
123
153
assert max_size <=len(zeros)
@@ -143,6 +173,10 @@ cdef class ChunkerBuzHash64:
143
173
self.reader_block_size =1024*1024
144
174
self.sparse = sparse
145
175
176
+
self.do_encrypt = do_encrypt
177
+
if do_encrypt:
178
+
self.crypter = Crypter(key[:16])
179
+
146
180
def__dealloc__(self):
147
181
"""Free the chunker's resources."""
148
182
ifself.table !=NULL:
@@ -188,11 +222,12 @@ cdef class ChunkerBuzHash64:
188
222
189
223
cdef object process(self) except*:
190
224
"""Process the chunker's buffer and return the next chunk."""
0 commit comments