-
Notifications
You must be signed in to change notification settings - Fork 259
Rough key-verification implementation #787
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -472,6 +472,21 @@ def onConnected(interface): | |||||
waitForAckNak = True | ||||||
interface.getNode(args.dest, False, **getNode_kwargs).removeIgnored(args.remove_ignored_node) | ||||||
|
||||||
if args.key_verification: | ||||||
closeNow = True | ||||||
waitForAckNak = True | ||||||
interface.getNode(args.dest, False, **getNode_kwargs).keyVerification(args.key_verification) | ||||||
|
||||||
if args.key_verification_number: | ||||||
closeNow = True | ||||||
waitForAckNak = True | ||||||
interface.getNode(args.dest, False, **getNode_kwargs).keyVerificationNumber(args.key_verification_number, args.key_verification_nonce) | ||||||
|
||||||
if args.key_verification_confirm: | ||||||
closeNow = True | ||||||
waitForAckNak = True | ||||||
interface.getNode(args.dest, False, **getNode_kwargs).keyVerificationConfirm(args.key_verification_confirm) | ||||||
|
||||||
if args.reset_nodedb: | ||||||
closeNow = True | ||||||
waitForAckNak = True | ||||||
|
@@ -1832,6 +1847,22 @@ def addRemoteAdminArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPars | |||||
"Use the node ID with a '!' or '0x' prefix or the node number.", | ||||||
metavar="!xxxxxxxx" | ||||||
) | ||||||
group.add_argument( | ||||||
"--key-verification", | ||||||
help="start key verification. " | ||||||
"Use the node ID with a '!' or '0x' prefix or the node number.", | ||||||
metavar="!xxxxxxxx" | ||||||
) | ||||||
group.add_argument( | ||||||
"--key-verification-number", | ||||||
help="start key verification. " | ||||||
"Use the node ID with a '!' or '0x' prefix or the node number.", | ||||||
) | ||||||
group.add_argument( | ||||||
"--key-verification-confirm", | ||||||
help="start key verification. " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The help text is incorrect for this argument. It should describe confirming key verification, not starting it.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
"Use the node ID with a '!' or '0x' prefix or the node number.", | ||||||
) | ||||||
group.add_argument( | ||||||
"--reset-nodedb", | ||||||
help="Tell the destination node to clear its list of nodes", | ||||||
|
@@ -1961,6 +1992,12 @@ def initParser(): | |||||
action="store_true", | ||||||
) | ||||||
|
||||||
group.add_argument( | ||||||
"--key-verification-nonce", | ||||||
help="start key verification. " | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The help text is incorrect for this argument. It should describe providing a nonce value, not starting key verification.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
"Use the node ID with a '!' or '0x' prefix or the node number.", | ||||||
) | ||||||
|
||||||
power_group = parser.add_argument_group( | ||||||
"Power Testing", "Options for power testing/logging." | ||||||
) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -770,6 +770,49 @@ def removeIgnored(self, nodeId: Union[int, str]): | |||||||||||||||||
onResponse = self.onAckNak | ||||||||||||||||||
return self._sendAdmin(p, onResponse=onResponse) | ||||||||||||||||||
|
||||||||||||||||||
def keyVerification(self, nodeId: Union[int, str]): | ||||||||||||||||||
if isinstance(nodeId, str): | ||||||||||||||||||
if nodeId.startswith("!"): | ||||||||||||||||||
nodeId = int(nodeId[1:], 16) | ||||||||||||||||||
else: | ||||||||||||||||||
nodeId = int(nodeId) | ||||||||||||||||||
p = admin_pb2.KeyVerificationAdmin() | ||||||||||||||||||
p.message_type = p.MessageType.INITIATE_VERIFICATION | ||||||||||||||||||
p.remote_nodenum = nodeId | ||||||||||||||||||
p.nonce = 0 | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hardcoded nonce value of 0 appears to be a magic number. Consider using a named constant or adding a comment explaining why 0 is used for initiation.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
a = admin_pb2.AdminMessage() | ||||||||||||||||||
a.key_verification_admin.CopyFrom(p) | ||||||||||||||||||
if self == self.iface.localNode: | ||||||||||||||||||
onResponse = None | ||||||||||||||||||
else: | ||||||||||||||||||
onResponse = self.onAckNak | ||||||||||||||||||
return self._sendAdmin(a, onResponse=onResponse) | ||||||||||||||||||
def keyVerificationNumber(self, number: int, nonce: int,): | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the trailing comma after the last parameter in the function definition.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
print(int(number)) | ||||||||||||||||||
print(int(nonce)) | ||||||||||||||||||
Comment on lines
+791
to
+792
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug print statements should be removed from production code. Consider using proper logging instead.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback
Comment on lines
+791
to
+792
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug print statements should be removed from production code. Consider using proper logging instead.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
p = admin_pb2.KeyVerificationAdmin() | ||||||||||||||||||
p.message_type = p.MessageType.PROVIDE_SECURITY_NUMBER | ||||||||||||||||||
p.nonce = int(nonce) | ||||||||||||||||||
p.security_number = int(number) | ||||||||||||||||||
a = admin_pb2.AdminMessage() | ||||||||||||||||||
a.key_verification_admin.CopyFrom(p) | ||||||||||||||||||
if self == self.iface.localNode: | ||||||||||||||||||
onResponse = None | ||||||||||||||||||
else: | ||||||||||||||||||
onResponse = self.onAckNak | ||||||||||||||||||
return self._sendAdmin(a, onResponse=onResponse) | ||||||||||||||||||
def keyVerificationConfirm(self, nonce: int,): | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the trailing comma after the last parameter in the function definition.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
print(int(nonce)) | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug print statements should be removed from production code. Consider using proper logging instead.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||
p = admin_pb2.KeyVerificationAdmin() | ||||||||||||||||||
p.message_type = p.MessageType.DO_VERIFY | ||||||||||||||||||
p.nonce = int(nonce) | ||||||||||||||||||
a = admin_pb2.AdminMessage() | ||||||||||||||||||
a.key_verification_admin.CopyFrom(p) | ||||||||||||||||||
if self == self.iface.localNode: | ||||||||||||||||||
onResponse = None | ||||||||||||||||||
else: | ||||||||||||||||||
onResponse = self.onAckNak | ||||||||||||||||||
return self._sendAdmin(a, onResponse=onResponse) | ||||||||||||||||||
def resetNodeDb(self): | ||||||||||||||||||
"""Tell the node to reset its list of nodes.""" | ||||||||||||||||||
self.ensureSessionKey() | ||||||||||||||||||
|
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.
The help text is incorrect for this argument. It should describe providing a security number, not starting key verification.
Copilot uses AI. Check for mistakes.