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

implement Clone for LessSafeKey #1175

Merged
merged 1 commit into from
May 4, 2021

Conversation

oconnor663
Copy link
Contributor

OpeningKey and SealingKey intentionally avoid implementing Copy and
Clone, because they're attached to a fixed nonce sequence that should be
unique. LessSafeKey isn't attached to a nonce sequence, though, and
making it Clone lets callers avoid repeating key setup work.

Coming from #1158 (comment).

@codecov
Copy link

codecov bot commented Jan 22, 2021

Codecov Report

Merging #1175 (2f29364) into main (b94d61e) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1175      +/-   ##
==========================================
+ Coverage   93.13%   93.17%   +0.04%     
==========================================
  Files         116      116              
  Lines       18081    18127      +46     
  Branches      195      195              
==========================================
+ Hits        16839    16890      +51     
+ Misses       1208     1202       -6     
- Partials       34       35       +1     
Impacted Files Coverage Δ
src/aead.rs 65.90% <100.00%> (+14.74%) ⬆️
src/aead/aes.rs 82.96% <100.00%> (+0.15%) ⬆️
src/aead/aes_gcm.rs 98.99% <100.00%> (+<0.01%) ⬆️
src/aead/chacha.rs 100.00% <100.00%> (ø)
src/aead/gcm.rs 79.48% <100.00%> (+0.10%) ⬆️
src/aead/less_safe_key.rs 96.55% <100.00%> (+0.02%) ⬆️
tests/aead_tests.rs 99.53% <100.00%> (+0.04%) ⬆️
crypto/curve25519/curve25519.c 99.70% <0.00%> (-0.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b94d61e...2f29364. Read the comment docs.

@briansmith
Copy link
Owner

Please review PR #1185 and see if rebasing this on top of that PR will simplify this. AFAICT it will.

@oconnor663
Copy link
Contributor Author

Yes it looks like the manual impl isn't needed on that branch. Everything is just #[derive(Clone)]: oconnor663@3275a8d

@briansmith
Copy link
Owner

Yes it looks like the manual impl isn't needed on that branch. Everything is just #[derive(Clone)]: oconnor663@3275a8d

Thanks! I have now merged that refactoring. If you rebase this on top of main, and add a test that encrypting some arbitrary data with the original key results in the same output as encrypting the same arbitrary data with a clone of the key (with the same nonce), then I'll prioritize merging this and ensure it is included in the next release.

@briansmith
Copy link
Owner

@oconnor663 Are you still interested in this? I'm preparing a new release that could include this if you rebase it onto main.

@oconnor663
Copy link
Contributor Author

Done! Thanks for the reminder.

tests/aead_tests.rs Outdated Show resolved Hide resolved
tests/aead_tests.rs Outdated Show resolved Hide resolved
tests/aead_tests.rs Outdated Show resolved Hide resolved
@oconnor663
Copy link
Contributor Author

Addressed the comments above. Let me know what you think about the allow(unused_imports) workaround in particular. Also if you want me to combine the three separate tests into one test with a loop.

@briansmith
Copy link
Owner

@oconnor663 If you can rebase this and address the comment above, then I think we're good to go and I'll be able to include this in the next release.

OpeningKey and SealingKey intentionally avoid implementing Clone,
because they're attached to a fixed nonce sequence that should be
unique. LessSafeKey isn't attached to a nonce sequence, though, and
making it Clone lets callers avoid repeating key setup work.
@oconnor663
Copy link
Contributor Author

I've rebased the branch and removed the extra commit that was just fixing a warning. Not sure about the codecov message. If I put a panic!() at the end of that function, cargo test fails as expected, so those lines are certainly getting run. I haven't yet figured out how to run codecov locally, but if you think that's the best next step let me know.

It looks like some repo settings have changed, and the CI run for the rebased branch won't start until I get some new permissions. Let me know if you need anything from me for that.

@briansmith
Copy link
Owner

It looks like some repo settings have changed, and the CI run for the rebased branch won't start until I get some new permissions. Let me know if you need anything from me for that.

I started the CI run. Recently GitHub started requiring manual approval for the first PR from a new contributor to a repo, to prevent cryptocurrency mining and other abuse of GitHub Actions.

@oconnor663
Copy link
Contributor Author

Oof. As they say about nice things, and why we cannot have them...

@briansmith briansmith merged commit fcbeeab into briansmith:main May 4, 2021
@briansmith
Copy link
Owner

Thanks! Merged.

@oconnor663
Copy link
Contributor Author

Great! Thanks for all the feedback.

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.

2 participants