Skip to content

Commit bcc7dc3

Browse files
crypto: fix the stale API sketch in the low_level docstring
None of the ciphersuite classes in this module has next_iv(len(data)) - both the AEAD and the legacy AES-CTR classes compute the next iv without arguments. Also, header_len and aad_offset are constructor arguments, not encrypt/decrypt arguments, and encrypt takes iv and aad.
1 parent 57009fb commit bcc7dc3

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/borg/crypto/low_level.pyx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
33
API:
44
5-
encrypt(data, header=b'', aad_offset=0) -> envelope
6-
decrypt(envelope, header_len=0, aad_offset=0) -> data
5+
encrypt(data, header=b'', iv=None, aad=b'') -> envelope
6+
decrypt(envelope, aad=b'') -> data
7+
8+
header_len and aad_offset are given to the ciphersuite class when creating it, see below.
79
810
Envelope layout:
911
@@ -25,12 +27,13 @@ garbage.
2527
2628
Newly designed envelope layouts can just authenticate the whole header.
2729
28-
IV handling:
30+
IV handling (CS is one of the ciphersuite classes below - the AEAD ones take a single key,
31+
the legacy AES-CTR ones a mac_key and an enc_key):
2932
3033
iv = ... # just never repeat!
31-
cs = CS(hmac_key, enc_key, iv=iv)
32-
envelope = cs.encrypt(data, header, aad_offset)
33-
iv = cs.next_iv(len(data))
34+
cs = CS(..., iv=iv, header_len=header_len, aad_offset=aad_offset)
35+
envelope = cs.encrypt(data, header=header)
36+
iv = cs.next_iv()
3437
(repeat)
3538
"""
3639

0 commit comments

Comments
 (0)