1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-24 19:52:32 +01:00

[aes] fix GCM pad length calculation

https://github.com/yt-dlp/yt-dlp/pull/11438
This commit is contained in:
Mike Fährmann 2024-11-03 21:25:45 +01:00
parent 390b8ddd3e
commit d77f5154a5
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -227,11 +227,12 @@ def aes_gcm_decrypt_and_verify(data, key, tag, nonce):
decrypted_data = aes_ctr_decrypt(
data, key, iv_ctr + [0] * (BLOCK_SIZE_BYTES - len(iv_ctr)))
pad_len = len(data) // 16 * 16
pad_len = (
(BLOCK_SIZE_BYTES - (len(data) % BLOCK_SIZE_BYTES)) % BLOCK_SIZE_BYTES)
s_tag = ghash(
hash_subkey,
data +
[0] * (BLOCK_SIZE_BYTES - len(data) + pad_len) + # pad
[0] * pad_len + # pad
bytes_to_intlist(
(0 * 8).to_bytes(8, "big") + # length of associated data
((len(data) * 8).to_bytes(8, "big")) # length of data