-
Notifications
You must be signed in to change notification settings - Fork 69
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
IF: Update signature-provider parsing for base64 BLS public keys #2066
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.
Later tests can be added.
@@ -42,6 +42,9 @@ class signature_provider_plugin_impl { | |||
std::tuple<std::string, std::string, std::string> parse_spec(const std::string& spec) const { | |||
auto delim = spec.find("="); | |||
EOS_ASSERT(delim != std::string::npos, chain::plugin_config_exception, "Missing \"=\" in the key spec pair"); | |||
// public_key can be base64 encoded with trailing `=` | |||
while( spec.size() > delim+1 && spec[delim+1] == '=' ) | |||
++delim; | |||
auto pub_key_str = spec.substr(0, delim); | |||
auto spec_str = spec.substr(delim + 1); |
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.
Will this be out of range if =
is the last char in spec
and delim
points to =
?
@@ -42,6 +42,9 @@ class signature_provider_plugin_impl { | |||
std::tuple<std::string, std::string, std::string> parse_spec(const std::string& spec) const { | |||
auto delim = spec.find("="); | |||
EOS_ASSERT(delim != std::string::npos, chain::plugin_config_exception, "Missing \"=\" in the key spec pair"); | |||
// public_key can be base64 encoded with trailing `=` |
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.
Can you add in the comment what spec
looks like when the public_key has trailing =
?
// e.g. --signature-provider PUB_BLS_Fmgk<snip>iuA===KEY:PVT_BLS_NZhJ<snip>ZHFu | ||
while( spec.size() > delim+1 && spec[delim+1] == '=' ) | ||
++delim; | ||
EOS_ASSERT(delim < spec.size() + 1, chain::plugin_config_exception, "Missing spec data in the key spec pair"); | ||
auto pub_key_str = spec.substr(0, delim); |
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.
won't pub_key_str
potentially end with multiple =
characters? Maybe it is not an issue?
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.
Yes, which like the example comment shows is rather ugly. We will likely move to base64url in the future partly do to this.
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.
So should we do something like this:
auto delim_end = delim;
while( spec.size() > delim_end+1 && spec[delim_end+1] == '=' )
++delim_end;
EOS_ASSERT(delim_end < spec.size() + 1, chain::plugin_config_exception, "Missing spec data in the key spec pair");
auto pub_key_str = spec.substr(0, delim);
auto spec_str = spec.substr(delim_end + 1);
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.
No, The public key is PUB_BLS_Fmgk<snip>iuA==
the separator is =KEY:
. Also note the separator can also be =KEOSD:
and =SE:
.
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.
Oh, OK. No spaces possible, right?
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.
Correct, no spaces allowed.
Note:start |
BLS public keys are base64 encoded which include trailing
=
. Update thesignature-provider
parsing to expect these "extra"=
s.Shutdown on startup for malformed
signature-provider
arguments. Previously nodeos would log an error and continue.Resolves #2060