Hopefully it is better dealing with a lot of small-object allocations than malloc/free is.
Small allocs happen if the input file is small, so it results only in 1 small chunk.
This breaks it on OpenSSL 1.0.x as there is no HMAC_CTX_new/free() yet.
OTOH, this change is consistent with the previous change done for
EVP_CIPHER_CTX (which works on 1.0 and 1.1).
includes:
- aes256-ctr-hmac-sha256 (attic/borg legacy, optional aad support)
- aes256-gcm (new, optional aad support)
uses 96bits for iv, 128bit for auth tag.
- header support
the caller-provided header will be just copied in front of the rest -
this avoids expensive operations (memcpy, garbage collection) in Python.
the first bytes in the header may be non-authenticated data if aad_offset > 0.
this is to support legacy attic/borg envelope layout, where the type byte
is not authenticated.
- aad support
additional authenticated data - it just contributes to the computed mac,
but is not encrypted). the current api assumes that aad starts at some
aad_offset inside the given header and extends to the end of it.
- iv handling helpers, compute next iv based on amount of processed data
- unit tests
Note: the changes are intentionally kept isolated / not integrated into the
rest of the code, so this has to be done later.
chunk_incref was called when dealing with part files without giving the
known chunk size in the size_ parameter.
adjusted LocalCache.chunk_incref to have same signature.
lgtm:
Calling next() in a generator may cause unintended early termination of
an iteration.
It seems that lgtm did not detect the more loose wrapping that we used
before.
Coalesce together commits by the same person in git-shortlog(1).
For people with different aliases, prefer full names over abbreviations
or nick names. For people with different email addresses, use the most
recent email address.
lgtm:
Nested loops in which the target variable is the same for each loop make
the behavior of the loops difficult to understand.
(not really here, just wanted to get rid of lgtm warning)