diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-03-18 07:54:23 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-03-18 07:54:23 -0400 |
commit | ffcbc09d314d710f5db87573b398be1c8c5f177c (patch) | |
tree | a33105d9d10079b749d54dbab204baadcb0ae8d8 /paramiko/ecdsakey.py | |
parent | 6ed173a4606e404a3908926beabc02b50a5ad8a8 (diff) | |
download | paramiko-ffcbc09d314d710f5db87573b398be1c8c5f177c.tar.gz |
More progress towards cleanup
Diffstat (limited to 'paramiko/ecdsakey.py')
-rw-r--r-- | paramiko/ecdsakey.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/paramiko/ecdsakey.py b/paramiko/ecdsakey.py index af9200c0..16a2c3db 100644 --- a/paramiko/ecdsakey.py +++ b/paramiko/ecdsakey.py @@ -144,12 +144,20 @@ class ECDSAKey(PKey): return True def write_private_key_file(self, filename, password=None): - with open(filename, "w") as f: - self.write_private_key(f, password=password) + self._write_private_key_file( + filename, + self.signing_key, + serialization.Format.TraditionalOpenSSL, + password=password + ) def write_private_key(self, file_obj, password=None): - key = self.signing_key or self.verifying_key - file_obj.write(self._to_pem(key, password=password).decode()) + self._write_private_key( + file_obj, + self.signing_key, + serialization.Format.TraditionalOpenSSL, + password=password + ) @staticmethod def generate(curve=ec.SECP256R1(), progress_func=None): @@ -182,17 +190,6 @@ class ECDSAKey(PKey): self.verifying_key = key.public_key() self.size = key.curve.key_size - def _to_pem(self, key, password): - if password is None: - encryption = serialization.NoEncryption() - else: - encryption = serialization.BestEncryption(password) - return key.private_bytes( - serialization.Encoding.PEM, - serialization.PrivateFormat.TraditionalOpenSSL, - encryption - ) - def _sigencode(self, r, s): msg = Message() msg.add_mpint(r) |