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

Add SHA1 and SHA256 algorithms for EC2 fingerprint calculation #8235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nifadyev
Copy link

Resolves localstack issue

@viren-nadkarni is recommended to make changes in moto in this comment

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.55%. Comparing base (77fbf51) to head (b20489d).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8235   +/-   ##
=======================================
  Coverage   94.54%   94.55%           
=======================================
  Files        1158     1158           
  Lines      100124   100129    +5     
=======================================
+ Hits        94667    94672    +5     
  Misses       5457     5457           
Flag Coverage Δ
servertests 28.88% <100.00%> (+<0.01%) ⬆️
unittests 94.52% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Collaborator

@bblommers bblommers left a comment

Choose a reason for hiding this comment

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

Hi @nifadyev, thank you for the PR! I just have a nitpick on the naming.

@viren-nadkarni Do you want to review this as well?

# TODO: Use different fingerprint calculation methods based on key type and source
# see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/verify-keys.html#how-ec2-key-fingerprints-are-calculated
def public_key_fingerprint(
public_key: Union[RSAPublicKey, Ed25519PublicKey], is_created: bool = False
Copy link
Collaborator

Choose a reason for hiding this comment

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

The naming of is_created is a bit confusing for people without any context. Any objections to rename this to something like use_sha1: bool?

A comment in the caller function (random_rsa_key_pair) can then explain why we're using sha1:

# This fingerprint should use sha1 because it's created by EC2
# See https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/verify-keys.html#how-ec2-key-fingerprints-are-calculated

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.

bug: EC2 key pair fingerprint calculation
2 participants