jakcron / nstool

General purpose read/extract tool for Nintendo Switch file formats.
MIT License
449 stars 43 forks source link

Data layer block(s) failed hash validation error when extracting NCA3 Meta files #85

Closed relm closed 1 year ago

relm commented 2 years ago

I'm getting an error that says [pie::hac::HierarchicalIntegrityStream ERROR] Data layer block(s) failed hash validation when extracting files of the following type:

[NCA Header]
  Format Type:     NCA3
  Dist. Type:      Download
  Content Type:    Meta
  Key Generation:  11
  Sig. Generation: 0
  Kaek Index:      Application (0)
  Size:            0xdfe00
  ProgID:          0x010096f00ff22000
  Content Index:   0
  SdkAddon Ver.:   9.6.0 (v151388160)

[ContentArchive/Tree]
 meta:/
  0/
   control.nacp
   icon_AmericanEnglish.dat
   icon_BritishEnglish.dat
   icon_CanadianFrench.dat
   icon_French.dat
   icon_German.dat
   icon_Italian.dat
   icon_Japanese.dat
   icon_LatinAmericanSpanish.dat
   icon_Spanish.dat

Inspecting the files, they all look correct aside from the last one - icon_Spanish.dat in this case. It's an icon of the game/Title ID but part of it is cut off. The other icons render fine when opened up in an image editor. So it looks like for whatever reason, the length of the last file is calculated wrong when extracted. I'm not sure if it's related to the error message I received above but my guess is that it is.

FYI - I tried extracting other files of this type and same thing - the last icon in the set is cut off.

Let me know if you need me to upload any files. This is the command I used to extract:

./nstool -k prod.keys -x ./nacp/ 010096f00ff22000.bin

jakcron commented 2 years ago

Interesting, it looks like NSTool isn't parsing the file system properly. Thank you for reporting this. If you're offering to upload sample data, that would help.

Heath123 commented 2 years ago

I am getting the same error on a different file (the content type is Control) but it happens after extracting a few files

martinlindhe commented 2 years ago

@jakcron here is 2 samples

NCA3-hash-failed.zip

jakcron commented 1 year ago

Thank you all, the issue was identified by @sagumamugas. There was an issue where reading a partial end block resulted in uninitialised data being included in hash generation.

This should be fixed in the next release.

jakcron commented 1 year ago

@relm @Heath123 @martinlindhe Thank you for your patience.

Please try NSTool v1.7.0 (https://github.com/jakcron/nstool/releases/tag/v1.7.0-r2)