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
This is an effort to document desired decryption process across platforms.
inputs:
KeyWithPassPhrase[] - a list of OpenPGP keys (SecretKeyRing) and their pass phrases (optional) to use for decryption
byte array of data
steps:
decide if the message is armored, if so, dearmor it
parse the message. If there is error parsing it, or not a valid message, return Err.FORMAT
if the message is cleartext signed, only verify signatures (not addressed here)
extract list of longids the message is encrypted for
find an intersection between these longids and supplied private keys. If no intersection found, throw Err.KEY_MISMATCH. If the message contains a wildcard 0000... longid, then use all keys.
within the matched subset, only decrypt the (sub)key packets that are actually going to be used for decryption (an array, typically single one). Throw if a packet cannot be decrypted Err.WRONG_PASS_PHRASE or if we don't have even a single such decrypted packet Err.MISSING_PASS_PHRASE (or have library throw errors and re-categorize them)
attempt decryption with these semi-decrypted keys. Observe returned errors and correctly categorize them as Err.NO_MDC, Err.BAD_MDC, Err.KEY_MISMATCH etc.
return result (streaming if possible)
Signature verification of plain or encrypted messages is ignored here.
In Kotlin, steps 4-7 would ideally be done by the encryption library.
We also have a caching mechanism on browser extension, where step 6 uses a cache of partially decrypted keys, so that we don't have to keep decrypting the same key as use opens several messages (or a conversation).
Activity
IvanPizhenko commentedon May 10, 2021
I think this is what I was missing all this time.
IvanPizhenko commentedon May 10, 2021
I believe in Kotlin we do not have decrypted key cache, unless PGPainless somehow maintains it, but to me that would be surprising.
DenBond7 commentedon May 10, 2021
Actually, we have a cache (cache in RAM). Due to a lot of reasons.(due to some logic, Node usage and other)
tomholub commentedon May 10, 2021
Not yet - that would be for the future
tomholub commentedon May 10, 2021
But not for this particular usecase? To be fair, the node code does cache this as described, but the new kotlin code won't (yet).
DenBond7 commentedon May 10, 2021
Sorry, I've missed 'decrypted' word. We just have a cache of encrypted keys and passphrases. So never mind my comment above.
DenBond7 commentedon May 13, 2021
@tomholub Please look at this one and correct me if needed. It relates to encrypted attachments.
edit: It relates to separate encrypted attachments
tomholub commentedon May 13, 2021
Looks good 👍
tomholub commentedon May 13, 2021
For each of the error scenarios, we will have specific error handling and UI options to guide user - but that's for later on.