masaccio / numbers-parser

Python module for parsing Apple Numbers .numbers files
MIT License
208 stars 15 forks source link

About password protected numbers files #93

Open Deng-yongbiao opened 2 weeks ago

Deng-yongbiao commented 2 weeks ago

According to some information on the Internet, encrypted documents are encrypted using ASE-128. So is there a simpler way to determine whether a numbers document is encrypted? I do not need to parse the content of the encrypted document.

masaccio commented 2 weeks ago

See also #88. The challenge will be that AES-encrypted data is indistinguishable from random noise. It's possible for numbers-parser to unpack the top-level document and spot that it has what looks like Numbers metadata, but no readable IWA files, and infer from this the document might be encrypted. But the only option would be to raise an exception on the Document() class.

Deng-yongbiao commented 2 weeks ago

I noticed that if a numbers file is encrypted, then almost all iwa files in it are unreadable, that is, the iwa binary stream does not start with 0x00

masaccio commented 1 week ago

The most recent commits on the GitHub main branch include a test for the existence of .iwph in the document, which is an indication it's encrypted. Opening such a document will raise a UnsupportedError.