summaryrefslogtreecommitdiff
path: root/paramiko/dsskey.py
diff options
context:
space:
mode:
authorJared Hobbs <jared@pyhacker.com>2018-11-27 17:22:59 -0700
committerJared Hobbs <jared@pyhacker.com>2018-11-27 17:22:59 -0700
commiteff204faf5624c51b7ac96b9b93e4ce9622f853a (patch)
tree8cfd853320df944d7fd9ca7b272c22079af277e7 /paramiko/dsskey.py
parent6656f5453cedf9d9e497a6f49a25f8fc683b8551 (diff)
downloadparamiko-eff204faf5624c51b7ac96b9b93e4ce9622f853a.tar.gz
add support for new OpenSSH private key format
This work is based off the work done in https://github.com/paramiko/paramiko/pull/618
Diffstat (limited to 'paramiko/dsskey.py')
-rw-r--r--paramiko/dsskey.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/paramiko/dsskey.py b/paramiko/dsskey.py
index ec358ee2..a1adf818 100644
--- a/paramiko/dsskey.py
+++ b/paramiko/dsskey.py
@@ -229,12 +229,19 @@ class DSSKey(PKey):
self._decode_key(data)
def _decode_key(self, data):
+ pkformat, data = data
# private key file contains:
# DSAPrivateKey = { version = 0, p, q, g, y, x }
- try:
- keylist = BER(data).decode()
- except BERException as e:
- raise SSHException("Unable to parse key file: " + str(e))
+ if pkformat == self.PRIVATE_KEY_FORMAT_ORIGINAL:
+ try:
+ keylist = BER(data).decode()
+ except BERException as e:
+ raise SSHException("Unable to parse key file: " + str(e))
+ elif pkformat == self.PRIVATE_KEY_FORMAT_OPENSSH:
+ keylist = self._uint32_cstruct_unpack(data, 'iiiii')
+ keylist = [0] + list(keylist)
+ else:
+ raise SSHException('private key format.')
if type(keylist) is not list or len(keylist) < 6 or keylist[0] != 0:
raise SSHException(
"not a valid DSA private key file (bad ber encoding)"