-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add XAR header format #473
Conversation
checksum_algorithm field 3 created with the XAR archiver referenced in the doc-ref
The version from Apple (which is in current use) has the same version number in the header but supports additional checksum algorithms. I am not sure how to wiggle these into this particular specification. Basically, it should ignore one field, but only if that field is not a valid strz. Ideally I would use some sort of "lookahead" operation, or some other conditional. |
You can try to implement the approach I use in |
This is a very similar concept to the glTF binary format (#445), where one needs to parse JSON to be able to parse the binary structure. However, this does not mean it can't be described with the KS language - you can either outsource the XML parsing to opaque types (which I don't really recommend though, because you'll have lose any type checks / derivations that the compiler does and you'll have to resort to unsafe Which means that although the KSY won't read the whole file down to bottom (so it won't be so enjoyable to use in the Web IDE, for example), it's quite easy to use and you don't lose any type checks and you won't have to use type castings. For the glTF binary format, I have created a proof of concept for this approach, so you can see what I mean: #445 (comment) |
I fixed a few things. One thing I am not happy about is that currently the toc is defined as part of the header, but it shouldn't be. I tried this: seq:
- id: magic
contents: 'xar!'
- id: len_header
type: u2
- id: header
type:
switch-on: len_header
cases:
28: apple_header
_: regular_header
- id: toc
size: header.len_toc_compressed
process: zlib
doc: zlib compressed XML further describing the content of the archive
but that doesn't seem to work:
I don't know where I am going wrong there. |
It would require interfaces proposal to implement it the way you wanted. There may be another way to implement it though |
@armijnhemel Sample files, both with the Apple header and the regular one? |
Test files with gzip, bzip2 and no compression: https://github.com/armijnhemel/binaryanalysis-ng/blob/master/src/test/testdata/unpackers/xar/test-bzip2.xar I would need to search for test files for the Apple version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* add XAR format * xar: document variations, add support for versions with checksum_algorithm field 3 created with the XAR archiver referenced in the doc-ref * xar: differentiate between the regular header and the apple header (probably misnomers) * xar: use correct variable * xar: rename from `xar_header` * xar: add `/meta/xref/justsolve` * xar: restructure (`header` to substream), provide cksum alg name * xar: change `/meta/title` * xar: improve sentence in `/doc` * xar: update Apple Open Source GitHub mirror link * xar: remove sentence from `/doc`, add link to Wikipedia * xar: move "xar" file extension above "pkg" See kaitai-io#473 (comment) * xar: change "read" to "access" to avoid confusion Co-authored-by: Petr Pucil <[email protected]>
* add XAR format * xar: document variations, add support for versions with checksum_algorithm field 3 created with the XAR archiver referenced in the doc-ref * xar: differentiate between the regular header and the apple header (probably misnomers) * xar: use correct variable * xar: rename from `xar_header` * xar: add `/meta/xref/justsolve` * xar: restructure (`header` to substream), provide cksum alg name * xar: change `/meta/title` * xar: improve sentence in `/doc` * xar: update Apple Open Source GitHub mirror link * xar: remove sentence from `/doc`, add link to Wikipedia * xar: move "xar" file extension above "pkg" See kaitai-io#473 (comment) * xar: change "read" to "access" to avoid confusion Co-authored-by: Petr Pucil <[email protected]>
The XAR format is an archive that consists of a header, a zlib compressed XML document and then the payload. The structure of the payload (the files, etc.) is described in the XML file. Because Kaitai Struct does not have a built in XML parser this parser is limited to just the header.