Repository navigation
Fixes #325 -- add support for Ed25519 keys - #972
Conversation
|
I haven't done any integration testing, besides the tests themselves. Can you suggest where and how to add more tests for this? |
|
looks like a unit test could go in |
| keyfiles.append((keytype, full_path)) | ||
|
|
||
| # look in ~/ssh/ for windows users: | ||
| full_path = os.path.expanduser("~/ssh/id_%s" % path) |
There was a problem hiding this comment.
you could parameterize a bit more e.g.
for ssh_dir in ["~/.ssh", "~/ssh"]:
full_path = os.path.expanduser("%s/id_%s" % (ssh_dir, path))
...
mithrandi
left a comment
There was a problem hiding this comment.
The file format stuff all looks correct to me.
| def unpad(data): | ||
| # At the moment, this is only used for unpadding private keys on disk, and | ||
| # only unencrypted ones at that. In the future, if either of those changes, | ||
| # this really ought to be made constant time. |
There was a problem hiding this comment.
I don't think this comment is accurate, unpad seems to be used for encrypted keys too. Although, I'm not sure how anyone able to observe the timing of this code would not have access to the ciphertext as well, which would appear to render a timing attack irrelevant.
| from paramiko.ssh_exception import SSHException, PasswordRequiredException | ||
|
|
||
|
|
||
| OPENSSH_AUTH_MAGIC = b"openssh-key-v1\x00" |
There was a problem hiding this comment.
Minor nitpick: You seem to flipflop between 'strings' and "strings" in this code, maybe stick to one? 😼
|
very nice 👍 |
|
OMG, I love you @alex! Will take a crack at testing & merging this early next week. |
| install_requires=[ | ||
| 'bcrypt>=3.0.0', | ||
| 'cryptography>=1.1', | ||
| 'pynacl', |
There was a problem hiding this comment.
Would love at least some pinning here; latest pynacl seems to be 1.1.2. What's good - pynacl>=1.0, >=1.1, other?
There was a problem hiding this comment.
@reaperhulk opinions on an appropriate minimum version?
There was a problem hiding this comment.
=1.0 (or 1.0.1) would be fine. That's the cffi 1.0 out-of-line version.
|
Testing this out...
Sanity check with ssh, Fabric 2 and Paramiko master (massaging my known_hosts in between, as necessary, to avoid complaints):
Unfortunately, when I switch from Paramiko master to an integration branch based on this PR (still with only the ED25519 key enabled on the target) Paramiko dies with When I dig, it's due to a I haven't looked any deeper yet; key exchange stuff isn't something I've had to muck with much before. Left to my own devices I'll dive in and educate myself and see if something obvious jumps out, otherwise, direction is welcome. |
|
Grumble, this is what I get for not doing the integration testing myself. Will try to debug this weekend. |
|
@bitprophet Ok, should be good now. |
Public point was accidentally encoded as 32 bytes, with no length prefix.
|
Nope, I was the one doing something silly. |
|
In version 2.2.1, I still have to manually The error: Openssl information: |
|
"pynacl" is an explicit requirement in setup.py - it is up to the method you used to install paramiko 2.2.1 to install pynacl at the same time. If you didn't use pip, you should probably use pip. |
|
Another day I was wondering if there's a way to reuse cryptography built-in support for this instead of introducing a train of libsodium dependencies, unless I'm missing something very obvious here. Can't paramiko (and thus, something else, like Ansible) rely on the one crypto library and/or its backend, or at least have another one as optional for specific key support? |
|
Ed25519 is different from X25519. Once OpenSSL has Ed25519, cryptography
will expose it and then we can drop the pynacl requirement here.
…On Sat, Oct 21, 2017 at 12:11 PM, Vlad Glagolev ***@***.***> wrote:
Another day I was wondering if there's a way to reuse cryptography built-in
support <pyca/cryptography#3686> for this instead
of introducing a train of libsodium dependencies, unless I'm missing
something very obvious here.
Can't paramiko (and thus, something else, like Ansible) rely on the *one*
crypto library and/or its backend, or at least have another one as
*optional*
<http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies>
for specific key support?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#972 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAADBAiOQfntu5br9Fu3LDpC2s130hkOks5suheggaJpZM4NoLd8>
.
--
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: D1B3 ADC0 E023 8CA6
|
|
Ah, I see, it's my misunderstanding then. So it's more like a temporary workaround than a solid permanent solution, waiting until the unified part "is ready". Looking forward to it! |
Ed25519 support arrived in 2.2 (paramiko#325 via paramiko#972) backed by PyNaCl, because Cryptography had no Ed25519 primitive at the time; it landed in Cryptography 2.6, roughly two years later. Our floor is already 3.3, so the primitive has been available across the entire supported range, and Ed25519Key was the last remaining user of PyNaCl. Beyond dropping a C-extension dependency, this puts Ed25519 under the same OpenSSL configuration that already governs every other key type, cipher and KEX we use -- including any algorithm policy the host OpenSSL enforces, which a separately bundled libsodium cannot participate in. Compare KexCurve25519.is_available(), which already defers to Cryptography for exactly that reason. Implementation notes: * Uses public_bytes(Encoding.Raw, PublicFormat.Raw) rather than the tidier public_bytes_raw(), which only exists as of Cryptography 40. The older spelling works across our whole supported range, including the 3.3.2 and 39.0.0 cells in CI. * Ed25519Key._fields now holds the key's raw bytes rather than the key object itself. Cryptography's key objects compare by identity on older versions (3.3.2, 39.0.0) and are unhashable on newer ones, so neither is safe for the equality and hashing contract PKey relies on here; raw bytes are exact on every version. test_ed25519_compare gains a hash() assertion so it covers both failure modes. * Cryptography's verify() takes (signature, data), the reverse of PyNaCl's verify(smessage, signature). Wire format is unchanged. Ed25519 is deterministic, so the new test_sign_and_verify_ed25519 pins the exact signature bytes the PyNaCl implementation produced for the existing test key. The one user-visible change is Ed25519Key.verifying_key, which now returns an Ed25519PublicKey rather than a nacl.signing.VerifyKey. Refs paramiko#1419, paramiko#2527. Builds on the earlier attempts by @adiroiban in paramiko#1806 and @boyxuper in paramiko#2103.
Ed25519 support arrived in 2.2 (paramiko#325 via paramiko#972) backed by PyNaCl, because Cryptography had no Ed25519 primitive at the time; it landed in Cryptography 2.6, roughly two years later. Our floor is already 3.3, so the primitive has been available across the entire supported range, and Ed25519Key was the last remaining user of PyNaCl. Beyond dropping a C-extension dependency, this puts Ed25519 under the same OpenSSL configuration that already governs every other key type, cipher and KEX we use -- including any algorithm policy the host OpenSSL enforces, which a separately bundled libsodium cannot participate in. Compare KexCurve25519.is_available(), which already defers to Cryptography for exactly that reason. Implementation notes: * Uses public_bytes(Encoding.Raw, PublicFormat.Raw) rather than the tidier public_bytes_raw(), which only exists as of Cryptography 40. The older spelling works across our whole supported range, including the 3.3.2 and 39.0.0 cells in CI. * Ed25519Key._fields now holds the key's raw bytes rather than the key object itself. Cryptography's key objects compare by identity on older versions (3.3.2, 39.0.0) and are unhashable on newer ones, so neither is safe for the equality and hashing contract PKey relies on here; raw bytes are exact on every version. test_ed25519_compare gains a hash() assertion so it covers both failure modes. * Cryptography's verify() takes (signature, data), the reverse of PyNaCl's verify(smessage, signature). Wire format is unchanged. Ed25519 is deterministic, so the new test_sign_and_verify_ed25519 pins the exact signature bytes the PyNaCl implementation produced for the existing test key. The one user-visible change is Ed25519Key.verifying_key, which now returns an Ed25519PublicKey rather than a nacl.signing.VerifyKey. Refs paramiko#1419, paramiko#2527. Builds on the earlier attempts by @adiroiban in paramiko#1806 and @boyxuper in paramiko#2103.
#325