mirror of
https://github.com/romanz/amodem.git
synced 2026-04-21 05:36:42 +08:00
client: show current time instead of identity.path
This commit is contained in:
@@ -3,6 +3,7 @@ import functools
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
from . import client, formats, protocol, server
|
from . import client, formats, protocol, server
|
||||||
|
|
||||||
@@ -57,7 +58,8 @@ def setup_logging(verbosity):
|
|||||||
|
|
||||||
|
|
||||||
def ssh_sign(conn, label, blob):
|
def ssh_sign(conn, label, blob):
|
||||||
return conn.sign_ssh_challenge(label=label, blob=blob)
|
now = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
return conn.sign_ssh_challenge(label=label, blob=blob, visual=now)
|
||||||
|
|
||||||
|
|
||||||
def run_agent(client_factory):
|
def run_agent(client_factory):
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class Client(object):
|
|||||||
vk = formats.decompress_pubkey(pubkey=pubkey, curve_name=self.curve)
|
vk = formats.decompress_pubkey(pubkey=pubkey, curve_name=self.curve)
|
||||||
return formats.export_public_key(vk=vk, label=label)
|
return formats.export_public_key(vk=vk, label=label)
|
||||||
|
|
||||||
def sign_ssh_challenge(self, label, blob):
|
def sign_ssh_challenge(self, label, blob, visual=''):
|
||||||
identity = self.get_identity(label=label)
|
identity = self.get_identity(label=label)
|
||||||
msg = _parse_ssh_blob(blob)
|
msg = _parse_ssh_blob(blob)
|
||||||
log.debug('%s: user %r via %r (%r)',
|
log.debug('%s: user %r via %r (%r)',
|
||||||
@@ -58,7 +58,6 @@ class Client(object):
|
|||||||
log.info('please confirm user "%s" login to "%s" using %s...',
|
log.info('please confirm user "%s" login to "%s" using %s...',
|
||||||
msg['user'], label, self.device_name)
|
msg['user'], label, self.device_name)
|
||||||
|
|
||||||
visual = identity.path # not signed when proto='ssh'
|
|
||||||
result = self.client.sign_identity(identity=identity,
|
result = self.client.sign_identity(identity=identity,
|
||||||
challenge_hidden=blob,
|
challenge_hidden=blob,
|
||||||
challenge_visual=visual,
|
challenge_visual=visual,
|
||||||
|
|||||||
@@ -85,8 +85,10 @@ def test_ssh_agent():
|
|||||||
|
|
||||||
def ssh_sign_identity(identity, challenge_hidden,
|
def ssh_sign_identity(identity, challenge_hidden,
|
||||||
challenge_visual, ecdsa_curve_name):
|
challenge_visual, ecdsa_curve_name):
|
||||||
|
assert (client.identity_to_string(identity) ==
|
||||||
|
client.identity_to_string(ident))
|
||||||
assert challenge_hidden == BLOB
|
assert challenge_hidden == BLOB
|
||||||
assert challenge_visual == identity.path
|
assert challenge_visual == 'VISUAL'
|
||||||
assert ecdsa_curve_name == b'nist256p1'
|
assert ecdsa_curve_name == b'nist256p1'
|
||||||
|
|
||||||
result = mock.Mock(spec=[])
|
result = mock.Mock(spec=[])
|
||||||
@@ -95,7 +97,8 @@ def test_ssh_agent():
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
c.client.sign_identity = ssh_sign_identity
|
c.client.sign_identity = ssh_sign_identity
|
||||||
signature = c.sign_ssh_challenge(label=label, blob=BLOB)
|
signature = c.sign_ssh_challenge(label=label, blob=BLOB,
|
||||||
|
visual='VISUAL')
|
||||||
|
|
||||||
key = formats.import_public_key(PUBKEY_TEXT)
|
key = formats.import_public_key(PUBKEY_TEXT)
|
||||||
serialized_sig = key['verifier'](sig=signature, msg=BLOB)
|
serialized_sig = key['verifier'](sig=signature, msg=BLOB)
|
||||||
|
|||||||
Reference in New Issue
Block a user