swift-toolkit icon indicating copy to clipboard operation
swift-toolkit copied to clipboard

Decryption of license user data (email, name) with user key (not content key)

Open danielweck opened this issue 6 years ago • 5 comments

The current LCP lib API (findValidPassphrase(), createContext(), decrypt()) is very minimal, and as far as I know does not support decrypting buffers that are encrypted with the user key (only those encrypted with the content key). In this Swift implementation, is there support for encrypted user email / name license fields?

danielweck avatar Dec 01 '19 11:12 danielweck

Related issue: https://github.com/readium/kotlin-toolkit/issues/205

danielweck avatar Dec 01 '19 11:12 danielweck

It's not supported, the User object only mirrors the JSON schema with the list of encrypted fields: https://github.com/readium/r2-lcp-swift/blob/d69f7bd315d40ea29c5f75d80adbc6a0578d1c7e/readium-lcp-swift/License/Model/Components/LCP/User.swift#L24

mickael-menu-mantano avatar Dec 04 '19 14:12 mickael-menu-mantano

Good to know. This is not implemented in r2-lcp-js either, as it is currently technically impossible (this would require C++ code modifications / additions in the public API of the LCP native lib)

danielweck avatar Dec 04 '19 15:12 danielweck

This is now available in the C++ LCP lib and its accompanying platform-specific wrappers (iOS/Swift/ObjectiveC and Android/Kotlin/JNI and Electron/NodeJS) as a new API function aptly-named getSupportedLCPProfileURIs that returns a vector/array/list of strings (i.e. LCP profile URIs). The new LCP lib with its increase API surface area hasn't started shipping yet, but integrators will be in the loop. In fact there will also be a new decryptField function very similar to decrypt but for LCP license email/name/etc. fields which are encrypted with the user key, unlike resources (e.g. HTML/CSS/image files) which are encrypted with the content key.

danielweck avatar Mar 09 '24 11:03 danielweck

Thanks for the heads-up Daniel, I'm reopening to track the Integration in the toolkit.

mickael-menu avatar Mar 09 '24 16:03 mickael-menu