You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The only reason why the current code "works" is because of a fortunate side effect from the CryptoPP lib, which emits an error when an attempt to decrypt a cypher using the wrong key is made, because of incorrect padding number parsing:
...more specifically m_storageProvider->EnumerateVault which will find the first existing user key that "works", without actually verifying the KeyCheck!
Then DecryptLicenseByUserKey() => DecryptContentKey() where the KeyCheck verification is missing. Thankfully, we have the CryptoPP "crash" to simulate the KeyCheck verification, but this is VERY hacky!
The KeyCheck is correctly verified in
DecryptUserKey()
:readium-lcp-client/src/lcp-client-lib/CryptoppCryptoProvider.cpp
Lines 232 to 276 in e4c02fd
However, it should also be verified in
DecryptContentKey()
:readium-lcp-client/src/lcp-client-lib/CryptoppCryptoProvider.cpp
Lines 278 to 310 in e4c02fd
The only reason why the current code "works" is because of a fortunate side effect from the CryptoPP lib, which emits an error when an attempt to decrypt a cypher using the wrong key is made, because of incorrect padding number parsing:
readium-lcp-client/src/third-parties/cryptopp/filters.cpp
Line 762 in e4c02fd
The source of the problem is
DecryptLicenseByStorage()
:readium-lcp-client/src/lcp-client-lib/LcpService.cpp
Lines 410 to 459 in e4c02fd
...more specifically
m_storageProvider->EnumerateVault
which will find the first existing user key that "works", without actually verifying the KeyCheck!This is the call chain:
OpenLicense()
=>CheckDecrypted()
=>DecryptLicenseOnOpening()
=>DecryptLicenseByStorage()
Then
DecryptLicenseByUserKey()
=>DecryptContentKey()
where the KeyCheck verification is missing. Thankfully, we have the CryptoPP "crash" to simulate the KeyCheck verification, but this is VERY hacky!The line that crashes:
readium-lcp-client/src/lcp-client-lib/CryptoppCryptoProvider.cpp
Line 301 in e4c02fd
...is caught here:
readium-lcp-client/src/lcp-client-lib/CryptoppCryptoProvider.cpp
Lines 306 to 309 in e4c02fd
...which allows graceful continuation of the
m_storageProvider->EnumerateVault
iteration, here:readium-lcp-client/src/lcp-client-lib/LcpService.cpp
Lines 454 to 456 in e4c02fd
The text was updated successfully, but these errors were encountered: