aboutsummaryrefslogtreecommitdiff
path: root/yt_dlp/aes.py
diff options
context:
space:
mode:
authorsepro <sepro@sepr0.com>2024-11-03 21:03:09 +0100
committerGitHub <noreply@github.com>2024-11-03 21:03:09 +0100
commitbeae2db127d3b5017cbcf685da9de7a9ef496541 (patch)
tree0add778bdf350c240dafb614901b223e75a58851 /yt_dlp/aes.py
parent3945677a75e94a1fecc085432d791e1c21220cd3 (diff)
[aes] Fix GCM pad length calculation (#11438)
Closes #10169 Authored by: seproDev
Diffstat (limited to 'yt_dlp/aes.py')
-rw-r--r--yt_dlp/aes.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/yt_dlp/aes.py b/yt_dlp/aes.py
index abf54a998..be67b40fe 100644
--- a/yt_dlp/aes.py
+++ b/yt_dlp/aes.py
@@ -230,11 +230,11 @@ def aes_gcm_decrypt_and_verify(data, key, tag, nonce):
iv_ctr = inc(j0)
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
)