-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
KMS: add asymmetric keys samples #1638
KMS: add asymmetric keys samples #1638
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor point: hanging indents ending on lines 110 and 133 of asymmetric.py have closing paren on lines by themselves. Also, closing braces in lines 34 through 38 of asymmetric_test.py not completely consistent, though all are perfectly clear. Other hanging indents have them at the end of the last line.
LGTM
b8b14ce
to
9e29b65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
def signAsymmetric(message, client, key_path): | ||
"""Create a signature for a message using a private key stored on Cloud KMS | ||
""" | ||
digest_bytes = hashlib.sha256(message.encode('ascii')).digest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually varies based on the key algorithm. For EC P-384 keys, it needs to be SHA-384.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think leaving a comment explaining this above this line would be sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!-- or something similar to what you did in the Golang lib, where the sample method was obviously limited to a particular key+digest combo.
s2 = create_key_helper(t.rsaSignId, t.rsaSign, 'ASYMMETRIC_SIGN', | ||
'RSA_SIGN_PSS_2048_SHA256', t) | ||
s3 = create_key_helper(t.ecSignId, t.ecSign, 'ASYMMETRIC_SIGN', | ||
'EC_SIGN_P224_SHA256', t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P224 was dropped from the API
Added samples for the KMS Asymmetric Keys launch