Skip to content

Integrated WKD in the app#1399

Merged
tomholub merged 15 commits intomasterfrom
issue_1201_wkd_support
Aug 16, 2021
Merged

Integrated WKD in the app#1399
tomholub merged 15 commits intomasterfrom
issue_1201_wkd_support

Conversation

@DenBond7
Copy link
Collaborator

@DenBond7 DenBond7 commented Aug 11, 2021

This PR added support of WKD in the app

close #1201


Tests (delete all except exactly one):

  • Tests added or updated

To be filled by reviewers

I have reviewed that this PR... (tick whichever items you personally focused on during this review):

  • addresses the issue it closes (if any)
  • code is readable and understandable
  • is accompanied with tests, or tests are not needed
  • is free of vulnerabilities

@DenBond7 DenBond7 added this to the 1.2.0: Enterprise features milestone Aug 11, 2021
Comment on lines +35 to +49
val matchingKeys = keys.keyRings.asSequence().filter {
for (userId in it.publicKey.userIDs) {
try {
val parsed = BetterInternetAddress(userId)
if (parsed.emailAddress.toLowerCase(Locale.ROOT) == lowerCaseEmail) return@filter true
} catch (ex: Exception) {
// ignore
suspend fun lookupEmail(context: Context, email: String): Response<String> =
withContext(Dispatchers.IO) {
val pgpPublicKeyRingCollection = rawLookupEmail(context, email)
val lowerCaseEmail = email.toLowerCase(Locale.ROOT)
val firstMatchedKey = pgpPublicKeyRingCollection?.keyRings?.asSequence()?.filter {
for (userId in it.publicKey.userIDs) {
try {
val parsed = BetterInternetAddress(userId)
if (parsed.emailAddress.toLowerCase(Locale.ROOT) == lowerCaseEmail) return@filter true
} catch (ex: Exception) {
ex.printStackTrace()
}
}
}
false
}.toList()
return if (matchingKeys.isNotEmpty()) PGPPublicKeyRingCollection(matchingKeys) else null
}
false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please still return an array from WkdClient, and then pick the key in PubLookup. To pick the key, instead of blindly the first one, let's use the first one that is .usableForEncryption, and add a comment in the code pointing to the issues to fix it.

That way, after we refactor code to allow for more than one pubkey, we can leave WkdClient class and tests untouched.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.usableForEncryption - it seems that we don't have such code. How do we determine that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@tomholub tomholub Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Let's leave usableForEncryption for later. For now, have WkdClient return an array, and choose the first result that is not expired and not revoked. (with a comment linking to #480 )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DenBond7 you can use KeyRingInfo.getEncryptionSubkeys(purpose), where purpose is encryption. If it returns > 1 element, then the key is usable for encryption. Same for #480 later.

Copy link
Contributor

@IvanPizhenko IvanPizhenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions here

@DenBond7 DenBond7 marked this pull request as ready for review August 13, 2021 13:43
IvanPizhenko
IvanPizhenko previously approved these changes Aug 14, 2021
@DenBond7
Copy link
Collaborator Author

@tomholub That's an important issue. I will merge it after your approve.

@tomholub
Copy link
Collaborator

"after your approval" or "after you approve" :-) I'll take a look

Copy link
Collaborator

@tomholub tomholub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestions below to make distinction between public key sources clearer.

@tomholub
Copy link
Collaborator

class AccountKeysInfoViewModel(application: Application) : AccountViewModel(application) {

This should maybe be called AccountPublicKeyServersViewModel. I don't have a good name for it.

@tomholub
Copy link
Collaborator

I have a general question. This getPub method (which we should call pubLookup instead to mimic the browser) has three usages. But none of the three usages look like they are related to fetching public keys in the message compose view.

How does the compose view fetch messages? Does it use the ContactsViewModel?

image

@tomholub
Copy link
Collaborator

Ok I see it now, it's the ContactsViewModel. I'll add a comment for clarity.

Copy link
Collaborator

@tomholub tomholub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with some minor adjustments for increased clarity, as above.

@DenBond7
Copy link
Collaborator Author

@tomholub I've added the requested changes. Please look at them.

@DenBond7 DenBond7 requested a review from tomholub August 16, 2021 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

search pubic keys of recipients on WKD

3 participants