Remove legacy fix in crypto.py that is no longer needed and was causing issues with encryption

This commit is contained in:
Campbell 2024-04-02 18:14:24 -04:00
parent 57fb0576e9
commit b9edeb160d
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344

View File

@ -62,9 +62,9 @@ def decrypt_content(content_enc, title_key, content_index, content_length) -> by
content_index_bin = struct.pack('>H', content_index) content_index_bin = struct.pack('>H', content_index)
while len(content_index_bin) < 16: while len(content_index_bin) < 16:
content_index_bin += b'\x00' content_index_bin += b'\x00'
# Align content to 64 bytes to ensure that all the data is being decrypted, and so it works with AES encryption. # Align content to 16 bytes to ensure that it works with AES encryption.
if (len(content_enc) % 64) != 0: if (len(content_enc) % 16) != 0:
content_enc = content_enc + (b'\x00' * (64 - (len(content_enc) % 64))) content_enc = content_enc + (b'\x00' * (16 - (len(content_enc) % 16)))
# Create a new AES object with the values provided, with the content's unique ID as the IV. # Create a new AES object with the values provided, with the content's unique ID as the IV.
aes = AES.new(title_key, AES.MODE_CBC, content_index_bin) aes = AES.new(title_key, AES.MODE_CBC, content_index_bin)
# Decrypt the content using the AES object. # Decrypt the content using the AES object.
@ -101,9 +101,9 @@ def encrypt_content(content_dec, title_key, content_index) -> bytes:
content_index_bin += b'\x00' content_index_bin += b'\x00'
# Calculate the intended size of the encrypted content. # Calculate the intended size of the encrypted content.
enc_size = len(content_dec) + (16 - (len(content_dec) % 16)) enc_size = len(content_dec) + (16 - (len(content_dec) % 16))
# Align content to 64 bytes to ensure that all the data is being encrypted, and so it works with AES encryption. # Align content to 16 bytes to ensure that it works with AES encryption.
if (len(content_dec) % 64) != 0: if (len(content_dec) % 16) != 0:
content_dec = content_dec + (b'\x00' * (64 - (len(content_dec) % 64))) content_dec = content_dec + (b'\x00' * (16 - (len(content_dec) % 16)))
# Create a new AES object with the values provided, with the content's unique ID as the IV. # Create a new AES object with the values provided, with the content's unique ID as the IV.
aes = AES.new(title_key, AES.MODE_CBC, content_index_bin) aes = AES.new(title_key, AES.MODE_CBC, content_index_bin)
# Encrypt the content using the AES object. # Encrypt the content using the AES object.