Skip to content

Added emails and fingerprints to PrvKeyInfo #1640 - #3213

Merged
tomholub merged 18 commits into
masterfrom
issue-1640-keyinfo-emails-fingerprints
Dec 7, 2020
Merged

Added emails and fingerprints to PrvKeyInfo #1640#3213
tomholub merged 18 commits into
masterfrom
issue-1640-keyinfo-emails-fingerprints

Conversation

@rrrooommmaaa

@rrrooommmaaarrrooommmaaa commented Dec 3, 2020

Copy link
Copy Markdown
Contributor

Closes#1640

// edit tom: closes#3220

@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

@tomholub Looks like I broke gmail test setup, probably with Config.secrets refactoring. There is no longer "Secure Compose" button during live tests. Can you point me where the test is wiring to the gmail account so I can debug it properly?

@tomholub

Copy link
Copy Markdown
Collaborator

Can you point me where the test is wiring to the gmail account so I can debug it properly?

If setup went fine but it doesn't work on https://mail.google.com then the content scripts are broken, or they fail during initialization.
You should build the extension and manually run it. Navigate to the gmail page and check error console. Check background page console, too. There will be an error somewhere.

The entrypoint for content scripts is extension/js/content_scripts/webmail/webmail.ts so if you want to use a debugger, you'd probably want to start there.

Also, this method is more or less at the core of content script setup:

constentrypoint=async()=>{try{constacctEmail=awaitwaitForAcctEmail();const{ tabId, notifications, factory, inject }=awaitinitInternalVars(acctEmail);awaitshowNotificationsAndWaitTilAcctSetUp(acctEmail,notifications);browserMsgListen(acctEmail,tabId,inject,factory,notifications);awaitwebmailSpecific.start(acctEmail,inject,notifications,factory,notifyMurdered);}catch(e){if(einstanceofTabIdRequiredError){console.error(`FlowCrypt cannot start: ${String(e)}`);}elseif(einstanceofError&&e.message==='Extension context invalidated.'){console.info(`FlowCrypt cannot start: extension context invalidated. Destroying.`);win.destroy();}elseif(!(einstanceofDestroyTrigger)){Catch.reportErr(e);}}};

@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

@tomholub The tests now went well.
I suggest to refactor decrypted field out of PrvKeyInfo.
Should we create a migration test?

@tomholub

tomholub commented Dec 5, 2020 via email

Copy link
Copy Markdown
Collaborator

@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

I'm looking at Chrome console, but the local storage seems empty....
@tomholub Can you please assist?
image

@tomholub

tomholub commented Dec 5, 2020 via email

Copy link
Copy Markdown
Collaborator

@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

No for migration test, but need to do thorough manual testing.

I have run background_page in the debugger, the migration passed.

@rrrooommmaaa
rrrooommmaaa marked this pull request as ready for review December 6, 2020 14:36
@rrrooommmaaa

Copy link
Copy Markdown
ContributorAuthor

We should probably have distinct types for storage and operation. I assume we never want to store passphrase in the storage?
So we should have a type without the passphrase to be stored

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code looks good with tome improvements to make. I will also do manual testing, once updated. Thanks!

Comment threadextension/chrome/elements/compose-modules/compose-my-pubkey-module.ts Outdated
Comment threadextension/js/common/core/crypto/key.ts Outdated
Comment threadextension/js/background_page/migrations.ts Outdated
}
}

public static keyInfoObj = async (prv: Key, passphrase?: string): Promise<KeyInfo> => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking at KeyInfo and PrvKeyInfo, I'm not sure if there is any use to having both anymore. I think nearly all usecases we have are for PrvKeyInfo. Wherever we need KeyInfo, we should use a Key instead (without storing it in storage).

I'm not 100% sure about this, but I think we could simplify this way.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

public property is read in many places, for example, in keyserver (replacePublicKeyHandler)
In other places, like composer module, do you suggest to replace parse(ki.public) with parse(ki.private).asPublicKey?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll have to have a look and maybe attempt refactoring that away. I suspect there are a bunch of usages that are no longer needed, but I'll have to see them one by one to confirm.

Comment threadextension/js/common/core/crypto/pgp/msg-util.ts Outdated
Comment threadtest/source/util/index.ts

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code looks good. Will test tomorrow. Thanks!

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Code looks ok so far (to my eyes) but need to fix tests again after my changes, and do manual testing.

// todo - the `ki.passphrase || ''` used to be `ki.passphrase!` which could have actually allowed an undefined to be passed
// as fixed currently it appears better, but it may be best to instead check `ki.passphrase && await MsgUtil.decryptKeyFor(...)`
// but that is a larger change that would require separate PR and testing
if (MsgUtil.isKeyDecryptedFor(parsed, matchingKeyids) || await MsgUtil.decryptKeyFor(parsed, ki.passphrase || '', matchingKeyids) === true) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have a concern about this particular original code, I'll have a second look later in a separate PR.

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tests seem to be passing, manual tests look good too.

@tomholub

Copy link
Copy Markdown
Collaborator

@rrrooommmaaa can you please also review my changes that I added? These were to join PrvKeyInfo and KeyInfo, and also fix #3220 so that the result are: KeyInfo and KeyInfoWithOptionalPassPhrase.

@tomholubtomholub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll go ahead and merge this, but please do have a look and let me know if I overlooked anything.

@tomholub
tomholub merged commit 83fb99f into masterDec 7, 2020
@tomholub
tomholub deleted the issue-1640-keyinfo-emails-fingerprints branch December 7, 2020 20:57

@rrrooommmaaarrrooommmaaa left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

LGTM!

@tomholub

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for freeto 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.

Use separate types for storage add all subkey fingerprints, and uid emails, into KeyInfo as optional arrays

2 participants

@rrrooommmaaa@tomholub