Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move key loading from deprecated Key struct to DcKey trait #1365

Merged
merged 1 commit into from Apr 23, 2020

Conversation

flub
Copy link
Member

@flub flub commented Mar 29, 2020

tl;dr

  • Do not leave internal API in half-finished state, new API adopted in Refactor keypair handling and expose storing keypairs on ffi #1237
    • New API has stricter correctness guarantees
  • Avoid the need everywhere to explicitly check key was generated correctly
  • This isn't the last PR in this series, this API is still in transition but doing this in smaller chunks for reviewability.

This moves the loading of the keys from the database to the trait and
thus with types differing between public and secret keys. This
fetches the Config::ConfiguredAddr (configured_addr) directly from the
database in the SQL to simplify the API and consistency instead of
making this the responsiblity of all callers to get this right.

Since anyone invoking these methods also wants to be sure the keys
exist, move key generation here as well. This already simplifies some
code in contact.rs and will eventually replace all manual checks for
existing keys.

To make errors more manageable this gives EmailAddress it's own error
type and adds some conversions for it. Otherwise the general error
type leaks to far. The EmailAddress type also gets its ToSql trait impl
to be able to save it to the database directly.

@hpk42
Copy link
Contributor

hpk42 commented Apr 14, 2020

needs a rebase now -- and could you add a TLDR for the goal/aim of this PR?
I guess this is about making handling of loaded keys safer but not sure.

@flub
Copy link
Member Author

flub commented Apr 14, 2020 via email

@flub
Copy link
Member Author

flub commented Apr 14, 2020

@hpk42 rebased and added tl;dr

src/e2ee.rs Outdated Show resolved Hide resolved
src/key.rs Outdated Show resolved Hide resolved
@flub flub requested a review from link2xt April 23, 2020 20:44
This moves the loading of the keys from the database to the trait and
thus with types differing between public and secret keys.  This
fetches the Config::ConfiguredAddr (configured_addr) directly from the
database in the SQL to simplify the API and consistency instead of
making this the responsiblity of all callers to get this right.

Since anyone invoking these methods also wants to be sure the keys
exist, move key generation here as well.  This already simplifies some
code in contact.rs and will eventually replace all manual checks for
existing keys.

To make errors more manageable this gives EmailAddress it's own error
type and adds some conversions for it.  Otherwise the general error
type leaks to far.  The EmailAddress type also gets its ToSql trait impl
to be able to save it to the database directly.
@flub flub merged commit 220500e into master Apr 23, 2020
@flub flub deleted the flub-load-key branch April 23, 2020 23:11
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.

None yet

3 participants