Skip to content

Commit

Permalink
Fix more ssh tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
adiroiban committed Mar 12, 2024
1 parent d1c38ee commit f8df309
Show file tree
Hide file tree
Showing 7 changed files with 414 additions and 241 deletions.
15 changes: 11 additions & 4 deletions keycert-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def ssh_load_key(options, open_method=None):
path = options.file
output_format = options.type
password = options.password
key_password = options.key_password

if not path:
return print_error('No path specified')
Expand All @@ -72,14 +73,14 @@ def ssh_load_key(options, open_method=None):
key = Key.fromString(key_content, passphrase=password)

if key.isPublic():
to_string = key.toString(output_format)
to_string = key.toString(output_format, extra=key_password)
else:
to_string = key.toString(output_format)
to_string = key.toString(output_format, extra=key_password)

result = '%r\nKey type %s\n\n%s' % (
key,
Key.getKeyFormat(key_content),
to_string,
to_string.decode('utf-8'),
)
return result

Expand Down Expand Up @@ -164,7 +165,13 @@ def ssh_verify_data(options):
'--password',
metavar='PASSWORD',
default=None,
help='Option password or commented used when re-encoding the loaded key.'
help='Option password used when loading the key.'
)
sub.add_argument(
'--key-password',
metavar='PASSWORD',
default=None,
help='Option password used when writing key.'
)
sub.set_defaults(handler=ssh_load_key)

Expand Down
7 changes: 6 additions & 1 deletion pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ def lint():
except SystemExit as pyflakes_exit:
pass

sys.argv.extend(['--ignore=E741', '--hang-closing'])
sys.argv.extend([
'--ignore=E741',
'--ignore=E741',
'--hang-closing',
'--max-line-length=80',
])
pycodestyle_exit = pycodestyle_main()

sys.exit(pyflakes_exit.code or pycodestyle_exit)
4 changes: 3 additions & 1 deletion src/chevah_keycert/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import base64
import inspect

import cryptography.utils


def _path(path, encoding='utf-8'):
if sys.platform.startswith('win'):
Expand All @@ -32,7 +34,7 @@ def native_string(string):
for member in ['Callable', 'Iterable', 'Mapping', 'Sequence']:
if not hasattr(collections, member):
setattr(collections, member, getattr(collections.abc, member))
import cryptography.utils

if not hasattr(cryptography.utils, 'int_from_bytes'):
cryptography.utils.int_from_bytes = int.from_bytes

Expand Down
Loading

0 comments on commit f8df309

Please sign in to comment.