Marco Ricci commited on 2024-06-30 16:37:52
Zeige 1 geänderte Dateien mit 9 Einfügungen und 8 Löschungen.
| ... | ... |
@@ -15,7 +15,7 @@ import socket |
| 15 | 15 |
|
| 16 | 16 |
from collections.abc import Sequence, MutableSequence |
| 17 | 17 |
from typing import Any, NamedTuple, Self, TypeAlias |
| 18 |
-from ssh_agent_client.types import KeyCommentPair, SSH_AGENT, SSH_AGENTC |
|
| 18 |
+from ssh_agent_client import types |
|
| 19 | 19 |
|
| 20 | 20 |
__all__ = ('SSHAgentClient',)
|
| 21 | 21 |
__author__ = 'Marco Ricci <m@the13thletter.info>' |
| ... | ... |
@@ -245,7 +245,7 @@ class SSHAgentClient: |
| 245 | 245 |
raise EOFError('truncated response from SSH agent')
|
| 246 | 246 |
return response[0], response[1:] |
| 247 | 247 |
|
| 248 |
- def list_keys(self) -> Sequence[KeyCommentPair]: |
|
| 248 |
+ def list_keys(self) -> Sequence[types.KeyCommentPair]: |
|
| 249 | 249 |
"""Request a list of keys known to the SSH agent. |
| 250 | 250 |
|
| 251 | 251 |
Returns: |
| ... | ... |
@@ -261,8 +261,8 @@ class SSHAgentClient: |
| 261 | 261 |
|
| 262 | 262 |
""" |
| 263 | 263 |
response_code, response = self.request( |
| 264 |
- SSH_AGENTC.REQUEST_IDENTITIES.value, b'') |
|
| 265 |
- if response_code != SSH_AGENT.IDENTITIES_ANSWER.value: |
|
| 264 |
+ types.SSH_AGENTC.REQUEST_IDENTITIES.value, b'') |
|
| 265 |
+ if response_code != types.SSH_AGENT.IDENTITIES_ANSWER.value: |
|
| 266 | 266 |
raise RuntimeError( |
| 267 | 267 |
f'error return from SSH agent: ' |
| 268 | 268 |
f'{response_code = }, {response = }'
|
| ... | ... |
@@ -281,14 +281,15 @@ class SSHAgentClient: |
| 281 | 281 |
buf.append(val) |
| 282 | 282 |
return bytes(buf) |
| 283 | 283 |
key_count = int.from_bytes(shift(4), 'big') |
| 284 |
- keys: collections.deque[KeyCommentPair] = collections.deque() |
|
| 284 |
+ keys: collections.deque[types.KeyCommentPair] |
|
| 285 |
+ keys = collections.deque() |
|
| 285 | 286 |
for i in range(key_count): |
| 286 | 287 |
key_size = int.from_bytes(shift(4), 'big') |
| 287 | 288 |
key = shift(key_size) |
| 288 | 289 |
comment_size = int.from_bytes(shift(4), 'big') |
| 289 | 290 |
comment = shift(comment_size) |
| 290 | 291 |
# Both `key` and `comment` are not wrapped as SSH strings. |
| 291 |
- keys.append(KeyCommentPair(key, comment)) |
|
| 292 |
+ keys.append(types.KeyCommentPair(key, comment)) |
|
| 292 | 293 |
if response_stream: |
| 293 | 294 |
raise TrailingDataError('overlong response from SSH agent')
|
| 294 | 295 |
return keys |
| ... | ... |
@@ -340,8 +341,8 @@ class SSHAgentClient: |
| 340 | 341 |
request_data.extend(self.string(payload)) |
| 341 | 342 |
request_data.extend(self.uint32(flags)) |
| 342 | 343 |
response_code, response = self.request( |
| 343 |
- SSH_AGENTC.SIGN_REQUEST.value, request_data) |
|
| 344 |
- if response_code != SSH_AGENT.SIGN_RESPONSE.value: |
|
| 344 |
+ types.SSH_AGENTC.SIGN_REQUEST.value, request_data) |
|
| 345 |
+ if response_code != types.SSH_AGENT.SIGN_RESPONSE.value: |
|
| 345 | 346 |
raise RuntimeError( |
| 346 | 347 |
f'signing data failed: {response_code = }, {response = }'
|
| 347 | 348 |
) |
| 348 | 349 |