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

cipher: clarify the EncryptingKey docs #488

Merged
merged 2 commits into from
Aug 7, 2024

Conversation

cpu
Copy link
Contributor

@cpu cpu commented Aug 5, 2024

Issues:

N/A

Description of changes:

While working with the aws_lc_rs::cipher module downstream in rustls/rustls#2066 we noticed the documentation here could use a small touch-up.

Previously the aws_lc_rs::cipher::EncryptingKey type's encrypt() and less_safe_encrypt() functions were documented as returning a reference to the encrypted data. However, the implementation uses an in_out: &mut [u8] argument for the encrypted data and returns a DecryptionContext, not a ref. to ciphertext.

Similarly, it feels important to call out that the DecryptionContext when using encrypt() contains a randomly generated IV. This makes usage clearer and also provides good counter-point to the disclaimer on less_safe_encrypt() about the provenance (and safety) of the IV being unknown.

Call-outs:

None that I can think of :-)

Testing:

N/A - docs only update.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

Previously the `aws_lc_rs::cipher::EncryptingKey` type's `encrypt()` and
`less_safe_encrypt()` functions were documented as returning a reference
to the encrypted data. However, the implementation uses an `in_out: &mut
[u8]` argument for the encrypted data and **returns**
a `DecryptionContext`, not a ref. to ciphertext.

Similarly, it feels important to call out that the `DecryptionContext`
when using `encrypt()` contains a randomly generated IV. This makes
usage clearer and also provides good counter-point to the disclaimer on
`less_safe_encrypt()` about the provenance (and safety) of the IV being
unknown.
Copy link
Contributor

@justsmth justsmth left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@skmcgrail skmcgrail left a comment

Choose a reason for hiding this comment

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

Thanks!

@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.69%. Comparing base (c358484) to head (fa3209b).
Report is 49 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #488      +/-   ##
==========================================
- Coverage   95.80%   92.69%   -3.11%     
==========================================
  Files          61       63       +2     
  Lines        8143     8456     +313     
  Branches        0     8456    +8456     
==========================================
+ Hits         7801     7838      +37     
- Misses        342      361      +19     
- Partials        0      257     +257     

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

@skmcgrail skmcgrail merged commit cb17eb3 into aws:main Aug 7, 2024
185 of 196 checks passed
@cpu cpu deleted the cpu-cipher-doc-tweaks branch August 7, 2024 21:58
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.

4 participants