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

Centralize key validations and check more invalid cases #156

Merged
merged 3 commits into from
Jul 10, 2023
Merged

Conversation

qmuntal
Copy link
Contributor

@qmuntal qmuntal commented Jul 5, 2023

This PR does the following:

  • Make Key.Validate private. The checks in that method are not exhaustive, e.g., we not validating that the key cryptographically ok. I would rather keep it private so we can evolve it without being tied to an specific behavior.
  • Validate that all required key parameters exists depending on the key type.
  • Key.PublicKey and Key.PrivateKey now call Key.validate so we don't return a malformed key.
  • NewSymmetricKey no longer returns an error, as this function can't fail.
  • Add more test cases

Signed-off-by: qmuntal <qmuntaldiaz@microsoft.com>
Signed-off-by: qmuntal <qmuntaldiaz@microsoft.com>
@codecov
Copy link

codecov bot commented Jul 5, 2023

Codecov Report

Merging #156 (c768d2b) into main (2f778da) will increase coverage by 0.47%.
The diff coverage is 84.61%.

@@            Coverage Diff             @@
##             main     #156      +/-   ##
==========================================
+ Coverage   91.05%   91.52%   +0.47%     
==========================================
  Files          12       12              
  Lines        1542     1545       +3     
==========================================
+ Hits         1404     1414      +10     
+ Misses        101       94       -7     
  Partials       37       37              
Impacted Files Coverage Δ
key.go 89.88% <84.61%> (+1.01%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Signed-off-by: qmuntal <qmuntaldiaz@microsoft.com>
@qmuntal
Copy link
Contributor Author

qmuntal commented Jul 10, 2023

@thomas-fossati @yogeshbdeshpande @shizhMSFT please take a look.

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@thomas-fossati thomas-fossati left a comment

Choose a reason for hiding this comment

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

awesome, thanks!

@qmuntal qmuntal merged commit d16fe13 into main Jul 10, 2023
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