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

Use one set of encryption keys on all shards for match key encryption #1474

Merged
merged 3 commits into from
Dec 4, 2024

Conversation

akoshelev
Copy link
Collaborator

This builds on top #1473 and only adds this commit

This takes the simplest approach of overwriting the key files after
creating them. Unfortunately there is no easy way to test this without
writing a new protocol, so we'll wait until Hybrid comes into play.

In the meantime I tested it manually to make sure files get overwritten

running 1 test
generating configuration for 3 shards in /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb

...
❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard1/h1_mk.key

❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard1/h2_mk.key
/var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard1/h2_mk.key differ: char 1, line 1

❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard2/h1_mk.key

❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h2_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard2/h2_mk.key

cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h3_mk.pub /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard2/h3_mk.pub

This almost completes the setup for TLS/encryption infrastructure
with one major exception - match key encryption keys are not re-used
across shards. I have a PR almost ready, but decided to split that
functionality to make PR somewhat revieweable
This takes the simplest approach of overwriting the key files after
creating them. Unfortunately there is no easy way to test this without
writing a new protocol, so we'll wait until Hybrid comes into play.

In the meantime I tested it manually to make sure files get overwritten

```bash
running 1 test
generating configuration for 3 shards in /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb

...
❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard1/h1_mk.key

❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard1/h2_mk.key
/var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard1/h2_mk.key differ: char 1, line 1

❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h1_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard2/h1_mk.key

❯ cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h2_mk.key /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard2/h2_mk.key

cmp /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard0/h3_mk.pub /var/folders/n2/wgkrrbd57173j9dvy8bdjcvw0000gn/T/.tmpCMhgQb/shard2/h3_mk.pub
```
@akoshelev akoshelev changed the title One mk per helper Use one set of encryption keys on all shards for match key encryption Dec 4, 2024
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 98.91304% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.85%. Comparing base (cf7efd4) to head (d7bd606).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
ipa-core/src/cli/clientconf.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1474      +/-   ##
==========================================
- Coverage   93.86%   93.85%   -0.01%     
==========================================
  Files         235      235              
  Lines       42451    42453       +2     
==========================================
  Hits        39845    39845              
- Misses       2606     2608       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

for dest_shard in 1..args.shard_count() {
let dest_shard_dir = args.output_dir.join(shard_conf_folder(dest_shard));
for helper_id in 1..=3 {
fs::copy(
Copy link
Collaborator

Choose a reason for hiding this comment

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

the previous version of this code just referred to the leader shards conf. We need to have an actual copy of the files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the previous version didn't really work because it hasn't created the appropriate files for all shards to be initialized correctly. The structure was something like this

shard0/
        h1.pem
shard1/
        h2.pem
...

instead of

   shard0/
        h1.pem,
        h2.pem,
        h3.pem
        ...

as each shard needs its own configuration to be complete, they need to have access to encryption keys in their folder

@akoshelev akoshelev merged commit d8b73fb into private-attribution:main Dec 4, 2024
12 checks passed
@akoshelev akoshelev deleted the one-mk-per-helper branch December 4, 2024 18:48
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.

3 participants