blawar / nut

GNU General Public License v3.0
1.08k stars 189 forks source link

[Bug] titleKeks[i] and firmware 17.0.0 #485

Closed hhgosparrow closed 6 months ago

hhgosparrow commented 7 months ago

Describe the bug Recent games that use the keys from 17.0.0 are failing to read something or having problems with the array of kek keys (apparently). I double checked the keys.txt and are the same that I use to test on ryujinx and yuzu, dumped from my own console.

To Reproduce Example execution.

/Documents/Borderlands 3 [01009970122E4800][v196608].nsp -> /Documents/nut/titles/nsp/updates/Borderlands 3 Ultimate Edition [01009970122E4800][v196608].nsp
nut exception: list index out of range
Traceback (most recent call last):
  File "/Documents/nut/nut.py", line 975, in <module>
    nut.organize()
  File "/Documents/nut/nut/__init__.py", line 873, in organize
    latest.move()
  File "/Documents/nut/Fs/IndexedFile.py", line 165, in move
    self.open(self.path)
  File "/Documents/nut/Fs/Nsp.py", line 152, in open
    super(Nsp, self).open(path or self.path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "/Documents/nut/Fs/Pfs0.py", line 201, in open
    self.files[i].open(None, None)
  File "/Documents/nut/Fs/Nca.py", line 507, in open
    self.partition(0x0, 0xC00, self.header, Fs.Type.Crypto.XTS, uhx(Keys.get('header_key')))
  File "/Documents/nut/Fs/File.py", line 72, in partition
    n.open(None, None, cryptoType, cryptoKey, cryptoCounter)
  File "/Documents/nut/Fs/Nca.py", line 295, in open
    self.titleKeyDec = Keys.decryptTitleKey(uhx(Titles.get(titleRightsTitleId).key), self.masterKey)
  File "/Documents/nut/nut/Keys.py", line 49, in decryptTitleKey
    kek = getTitleKek(i)
  File "/Documents/nut/nut/Keys.py", line 46, in getTitleKek
    return titleKeks[i]
IndexError: list index out of range

Actual behaviour Failed to organize or compress files that request firmware 17.0.0.

Expected behaviour Scan, organize and be able to compress.

NUT version (or git hash):

Additional context

├ Title ID: 01009970122E4800
├ Base Title ID: 01009970122E4000
├ Title Name: Borderlands 3
├ Display Version: 1.0.3
├ Version: 196608
├ Latest Version: 
├ System Update: 17.0.0
├ System Version: 17.0.0

I'm using Python 3.10.12 that comes with Ubuntu 22.04 LTS, that is superior to Python 3.9, and are working for a year. I do not believe that the Python version is the problem. But I'm adding maximum context. :-)