Navigation Menu

Skip to content
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

10.2.2 library - whole library post-hdfm is encrypted #15

Open
josephw opened this issue Mar 13, 2015 · 2 comments
Open

10.2.2 library - whole library post-hdfm is encrypted #15

josephw opened this issue Mar 13, 2015 · 2 comments

Comments

@josephw
Copy link
Owner

josephw commented Mar 13, 2015

Original issue 15 created by josephw on 2011-05-19T05:03:15.000Z:

What steps will reproduce the problem?

  1. Run titl on a 905kb 10.2.2 library

What is the expected output? What do you see instead?
I get a zlib exception. Changing the parser to decrypt the whole file (after the header) works.

What version of the product are you using? On what operating system?
Checked out yesterday, OS X 10.6.7, iTunes 10.2.2

Please provide any additional information below.
Apple must have fixed the bug introduced in 10.0 (100k library encryption) in 10.1 or 10.2. I don't have a 10.1 library of sufficient size to test with.

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #1 originally posted by josephw on 2011-05-29T05:41:44.000Z:

Thanks for this. It looks like the behaviour is different between MacOS and Windows.

One option is to fall back if one technique fails, but there may be fields in the header to distinguish between the two types beforehand.

@josephw
Copy link
Owner Author

josephw commented Mar 13, 2015

Comment #2 originally posted by josephw on 2014-12-16T01:31:43.000Z:

// decrypt all full blocks in the body
Key key = new SecretKeySpec("BHUILuilfghuila3".getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, key);
int crypt_size = (data.length - header_size) & ~0xf;
int max_crypt_size = read32(data, 0x5C);
if (max_crypt_size != 0)
crypt_size = Math.min(crypt_size, max_crypt_size);
cipher.doFinal(data, header_size, crypt_size, data, header_size);

    // un-zip body
    Inflater inflater = new Inflater();
    inflater.setInput(data, header_size, data.length - header_size);
    byte[] clear_data = new byte[65536];
    while (!inflater.finished())
    {
        int n = inflater.inflate(clear_data);
        o.write(clear_data, 0, n);
    }

    library_data.header = new byte[header_size];
    System.arraycopy(data, 0, library_data.header, 0, header_size);
    library_data.body = o.toByteArray();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant