-
Notifications
You must be signed in to change notification settings - Fork 141
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
feat(cli): introduce planet key sign
command
#1920
Conversation
618ab92
to
5292ec6
Compare
key sign
commandplanet key sign
command
As a remind, could you review this pull request if you have a time please? |
) | ||
{ | ||
PrivateKey key = UnprotectKey(keyId, passphrase); | ||
Console.WriteLine(Convert.ToBase64String(key.Sign(Convert.FromBase64String(message)))); |
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.
It's trivial but could you break the line? It looks quite long.
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.
How about printing out the raw bytes instead of base64?
Or at least hexadecimals might be better than base64, because there are quite many variations of base64, which confuse those who need to decode them.
If such behavior causing average terminal emulators to go weird concerns you, we could provide an option like -o
/--binary-output=FILE
:
# The signature is printed out in hexadecimals:
planet key sign 00000000-0000-0000-0000-000000000000 msg.dat
# The signature is written in the "sig.dat" file (no hex, but raw binary):
planet key sign \
--binary-output sig.dat \
00000000-0000-0000-0000-000000000000 \
msg.dat
# The signature is printed out in raw bytes:
planet key sign \
--binary-output - \
00000000-0000-0000-0000-000000000000 \
msg.dat
# The signature is written in the "-" file:
planet key sign \
--binary-output ./- \
00000000-0000-0000-0000-000000000000 \
msg.dat
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.
I tried to implement the feature in 4487e53 commit. --binary-output
option is optional and it prints the signature as hexadecimal string in default behaviour.
[Argument( | ||
"MESSAGE", | ||
Description = "A message encoded by base64 encoding to sign." | ||
)] | ||
string message, |
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.
It'd better to take the message through a file as it can be long. (That's how gpg --sign
command works.) Of course, -
should mean the standard input here. E.g.:
# Sign the message that the "msg.dat" file contains:
planet key sign 00000000-0000-0000-0000-000000000000 msg.dat
# Sign the message provided from the stnadard input:
planet key sign 00000000-0000-0000-0000-000000000000 -
# Sign the message that the "-" file contains:
planet key sign 00000000-0000-0000-0000-000000000000 ./-
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.
I tried to implement the feature in 735756f commit.
) | ||
{ | ||
PrivateKey key = UnprotectKey(keyId, passphrase); | ||
Console.WriteLine(Convert.ToBase64String(key.Sign(Convert.FromBase64String(message)))); |
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.
How about printing out the raw bytes instead of base64?
Or at least hexadecimals might be better than base64, because there are quite many variations of base64, which confuse those who need to decode them.
If such behavior causing average terminal emulators to go weird concerns you, we could provide an option like -o
/--binary-output=FILE
:
# The signature is printed out in hexadecimals:
planet key sign 00000000-0000-0000-0000-000000000000 msg.dat
# The signature is written in the "sig.dat" file (no hex, but raw binary):
planet key sign \
--binary-output sig.dat \
00000000-0000-0000-0000-000000000000 \
msg.dat
# The signature is printed out in raw bytes:
planet key sign \
--binary-output - \
00000000-0000-0000-0000-000000000000 \
msg.dat
# The signature is written in the "-" file:
planet key sign \
--binary-output ./- \
00000000-0000-0000-0000-000000000000 \
msg.dat
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
This pull request's build seems failed because the |
Nevermind, I'm going to merge this right now. Thanks! |
This pull requests introduces
planet key sign
command throughKeyCommand
inLibplanet.Extensions.Cocona
.The command provides a feature to sign the given message encoded by base64 with the given private key, and prints the signature encoded by base64.