Commit Graph
9 Commits
Author SHA1 Message Date
Justin Mitchell d6600ed0a8 Improve download resilience with smarter retry logic
Replace single retry counter with separate stalled-attempt and total-attempt limits. This allows downloads to recover from early truncations (common in first ~100KB during heap settling) while still protecting against dead servers. Also removes HAVE_MAX_FRAGMENT flag due to memory corruption issues with ADEPT servers and removes unused decrypt method from ContentProtection.
2026-07-27 23:19:26 -04:00
Justin Mitchell 31f2bb71ae Add memory safety checks to prevent OOM aborts
Implement safeguards against out-of-memory conditions in DRM decryption and HTTP relay. Cap rights document size at 64KB with heap check before allocation. Limit HTTP relay responses to 32KB with streaming validation to prevent unbounded memory growth. Use makeUniqueNoThrow for safer allocation. These changes prevent abort() calls from bad_alloc under -fno-exceptions.
2026-07-27 14:29:58 -04:00
Justin Mitchell c405c223c2 Pre-scan ZIP before initializing crypto for EPUBs
Perform ZIP scan upfront to check for encryption.xml before initializing crypto or loading credentials. This allows plain EPUBs to return immediately through the normal reader path, while protected EPUBs still only scan once by reusing the same ZIP index via openFromScan().
2026-07-27 00:38:48 -04:00
Justin Mitchell b95e0bcd48 Remove redundant ZIP scan in ContentProtection
Delegate encryption detection to ProtectedBook class instead of performing a separate preliminary ZIP scan. ProtectedBook now handles the authoritative scan and determines protection status, including distinguishing plain EPUBs from font-obfuscation-only cases.
2026-07-26 23:28:49 -04:00
Justin Mitchell 90581d1ba4 Stream decryption to avoid buffering in memory
Replace in-memory vector buffering with sink-based streaming for decryption. Adds decryptedSize() and decryptToSink() methods to allow writing decrypted content directly to output buffers or streams, reducing memory usage for large encrypted files.
2026-07-26 23:00:42 -04:00
Justin Mitchell 5987594b2d Remove plugin host allowlist security mechanism
Removes the allowedHosts manifest validation that restricted which external hosts plugins could access via the relay endpoint. Also updates comments throughout to use more generic 'encrypted-entry' terminology instead of 'protected content', and adds NO_WOLFSSL_ESP32_CRYPT_RSA_PRI flag to work around ESP32-C3 hardware RSA limitations with 4096-bit keys.
2026-07-26 22:49:33 -04:00
Justin Mitchell 41f17f1b5c Reformat code and reorganize include statements
Alphabetize include statements and apply consistent formatting to if-else blocks. No functional changes.
2026-07-26 18:56:11 -04:00
Justin Mitchell e017d099e2 Allow opening EPUBs with font obfuscation only
Previously, any EPUB with encryption.xml would fail to open without a credential, even if it only used font obfuscation (not DRM). Now credentials are optional until actual content protection is detected. Added user-facing error message for genuinely DRM-protected books and styling for SD-card plugin UI in File Manager.
2026-07-26 18:43:06 -04:00
Justin Mitchell c6a968d0e1 Add content protection SDK binding for SD storage
Implements HAL binding layer that connects the storage-agnostic ContentProtection SDK to the device's SD card storage. Provides SdByteSource for reading encrypted files, credential lookup from provisioned keys, and openProtectedBook() entry point for the reader. This glue code lives in firmware to keep the portable SDK library HAL-independent.
2026-07-26 17:29:02 -04:00