How to check if an ePub file is DRM-protected?
Asked Answered
L

1

7

Is there any programmatic way to safely check whether if an epub file is DRM-protected (encrypted)?

I have found that there might be a rights.xml and an encryption.xml in the META-INF directory. Does the existance of any or both of these files mean that the content is encrypted and if not, is there any other way to check?
(To be clear, I do not want to read ePubs with DRM at all, I just want to check whether they are encrypted or not.)

Laureen answered 21/1, 2013 at 16:26 Comment(0)
S
9

FWIW the Wikipedia epub article states

When present, DRMed EPUB files must contain a file called rights.xml within the META-INF directory at the root level of the ZIP container.

epubcheck as of v1.0 is reported to detect DRM-protection via the existence of encryption.xml and report an error. The epub3 spec says

An optional encryption.xml file within the META-INF directory at the root level of the container file system holds all encryption information on the contents of the container. This file is an XML document whose root element is encryption. The encryption element contains child elements of type EncryptedKey and EncryptedData as defined by [XML ENC Core]. Each EncryptedData element describes how one or more files within the container are encrypted. Consequently, if any resource within the container is encrypted, encryption.xml must be present to indicate that the resource is encrypted and provide information on how it is encrypted.

The EPUB3 is vague on rights.xml, its meaning and whether it is mandatory for DRM'd files, so it might be best not to depend on it.

Skate answered 22/1, 2013 at 3:21 Comment(2)
Thanks for the clarification. I have checked some DRMed ePubs, and the encryption.xml file lists all the files inside the ePub protected by encryption. So I might check whether the encryption.xml lists any of the files in the ePub (or any of the .html or .xhtml files?) and if it does, I consider that ePub as being encrypted.Laureen
EPUB3 has a file obfuscation feature that isn't DRM but is also listed in encryption.xml. It is therefore possible to find an encryption.xml in a DRM-free EPUB-file. This makes it necessary to parse the XML-file and check if any EncryptionMethod element has an Algorithm attribute that is not http://www.idpf.org/2008/embeddingEngud

© 2022 - 2024 — McMap. All rights reserved.