-
Notifications
You must be signed in to change notification settings - Fork 131
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
Issues decrypting LCP resources (CBCDRMInputStream) #154
Comments
@mickael-menu can this issue be closed? can I assume it is fixed by this PR readium/r2-streamer-swift#140 |
@aferditamuriqi No I didn't do anything to fix this issue so far |
I will take a look at the padding rules.
…On Sat, 28 Dec 2019, 13:18 Mickaël Menu, ***@***.***> wrote:
@aferditamuriqi <https://github.com/aferditamuriqi> No I didn't do
anything to fix this issue so far
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/readium/r2-streamer-swift/issues/141?email_source=notifications&email_token=AAEYUMPSME3DBGIHSFOA2STQ25G4FA5CNFSM4JV2H4P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHYJXJI#issuecomment-569416613>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEYUMI3RC75C5T7F2UMQM3Q25G4FANCNFSM4JV2H4PQ>
.
|
@mickael-menu ok, great, just wanted to make sure, since it was connected to a PR |
See this recent bugfix: |
@danielweck Thanks, this looks promising! Do we need to provide the padding scheme as well? There's no way to do that with the R2 LCP lib. // Figure out what padding scheme to use
BlockPaddingSchemeDef::BlockPaddingScheme padding = BlockPaddingSchemeDef::NO_PADDING;
if (total > (ssize - CryptoPP::AES::BLOCKSIZE))
{
padding = BlockPaddingSchemeDef::W3C_PADDING; // Note that handling of W3C padding scheme during decryption also handles PKCS#7 (which is BlockPaddingSchemeDef::PKCS_PADDING in CryptoPP, with AES CBC Block Size > 8 (not PKCS#5))
} |
This is a CryptoPP implementation detail, strictly-speaking we do not need to ask the underlying crypto lib to automatically remove padding, instead we can just trim the padding suffix "manually". |
Equivalent issue on r2-lcp-kotlin: readium/kotlin-toolkit#207 And a Kotlin PR fixing it: readium/r2-lcp-kotlin#84 |
CBCDRMInputStream
needs to be reviewed because there are a number of issues:CBCDRMInputStream
).positionList
of a LCPDF, we have to read theCBCDRMInputStream
entirely into aData
buffer, otherwise random access doesn't work:https://github.com/readium/r2-streamer-swift/blob/1de6db2cf5c72e88384d238454a6fd8b9746022f/r2-streamer-swift/Parser/PDF/PDFParser.swift#L193-L197
A few clues:
plainTextSize
instead, but it's supposed to be done already.CBCDRMInputStream
was directly translated from this C++ implementation. The only difference I can see is that the C++ version provides the type of padding. The private LCP framework doesn't take any padding scheme as a parameter though, so I'm not sure we're getting the properoutSize
, which might explain why the padding could not be removed properly. Any thoughts on the padding scheme @danielweck?The text was updated successfully, but these errors were encountered: