Merge lp:~cjwatson/lazr.sshserver/moduli into lp:lazr.sshserver

Proposed by Colin Watson on 2015-11-17
Status: Merged
Merged at revision: 58
Proposed branch: lp:~cjwatson/lazr.sshserver/moduli
Merge into: lp:lazr.sshserver
Diff against target: 98 lines (+22/-4)
3 files modified
src/lazr/sshserver/NEWS.txt (+6/-0)
src/lazr/sshserver/service.py (+15/-3)
src/lazr/sshserver/version.txt (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.sshserver/moduli
Reviewer Review Type Date Requested Status
William Grant code 2015-11-17 Approve on 2015-11-18
Review via email: mp+277641@code.launchpad.net

Commit Message

Add moduli file handling to lazr.sshserver.service, needed to support the diffie-hellman-group-exchange-* key exchange algorithms.

Description of the Change

Add moduli file handling to lazr.sshserver.service, needed to support the diffie-hellman-group-exchange-* key exchange algorithms. This is most useful with an upgrade to Twisted 15.5.0 (once released), but doesn't require it.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/lazr/sshserver/NEWS.txt'
2--- src/lazr/sshserver/NEWS.txt 2015-01-21 13:33:30 +0000
3+++ src/lazr/sshserver/NEWS.txt 2015-11-17 01:36:44 +0000
4@@ -2,6 +2,12 @@
5 NEWS for lazr.sshserver
6 =======================
7
8+0.1.2 (2015-XX-XX)
9+==================
10+
11+- Add moduli file handling to lazr.sshserver.service, needed to support the
12+ diffie-hellman-group-exchange-* key exchange algorithms.
13+
14 0.1.1 (2015-01-21)
15 ==================
16
17
18=== modified file 'src/lazr/sshserver/service.py'
19--- src/lazr/sshserver/service.py 2015-01-12 18:49:43 +0000
20+++ src/lazr/sshserver/service.py 2015-11-17 01:36:44 +0000
21@@ -19,6 +19,7 @@
22 service,
23 strports,
24 )
25+from twisted.conch.openssh_compat import primes
26 from twisted.conch.ssh.factory import SSHFactory
27 from twisted.conch.ssh.keys import Key
28 from twisted.conch.ssh.transport import SSHServerTransport
29@@ -72,7 +73,8 @@
30
31 protocol = KeepAliveSettingSSHServerTransport
32
33- def __init__(self, portal, private_key, public_key, banner=None):
34+ def __init__(self, portal, private_key, public_key, banner=None,
35+ moduli_path=None):
36 """Construct an SSH factory.
37
38 :param portal: The portal used to turn credentials into users.
39@@ -81,6 +83,7 @@
40 :param public_key: The public key of the server, must be an RSA
41 key, given as a `twisted.conch.ssh.keys.Key` object.
42 :param banner: The text to display when users successfully log in.
43+ :param moduli_path: The path to the OpenSSH moduli file to read.
44 """
45 # Although 'portal' isn't part of the defined interface for
46 # `SSHFactory`, defining it here is how the `SSHUserAuthServer` gets
47@@ -91,6 +94,7 @@
48 self._private_key = private_key
49 self._public_key = public_key
50 self._banner = banner
51+ self._moduli_path = moduli_path
52
53 def _makeAuthServer(self, *args, **kwargs):
54 kwargs['banner'] = self._banner
55@@ -142,13 +146,19 @@
56 """
57 return {'ssh-rsa': self._private_key}
58
59+ def getPrimes(self):
60+ try:
61+ return primes.parseModuliFile(self._moduli_path)
62+ except IOError:
63+ return None
64+
65
66 class SSHService(service.Service):
67 """A Twisted service for the SSH server."""
68
69 def __init__(self, portal, private_key_path, public_key_path,
70 main_log, access_log, access_log_path, strport='tcp:22',
71- factory_decorator=None, banner=None):
72+ factory_decorator=None, banner=None, moduli_path=None):
73 """Construct an SSH service.
74
75 :param portal: The `twisted.cred.portal.Portal` that turns
76@@ -168,12 +178,14 @@
77 argument, a factory, and must return a factory.
78 :param banner: An announcement printed to users when they connect.
79 By default, announce nothing.
80+ :param moduli_path: The path to the OpenSSH moduli file to read.
81 """
82 ssh_factory = Factory(
83 portal,
84 private_key=Key.fromFile(private_key_path),
85 public_key=Key.fromFile(public_key_path),
86- banner=banner)
87+ banner=banner,
88+ moduli_path=moduli_path)
89 if factory_decorator is not None:
90 ssh_factory = factory_decorator(ssh_factory)
91 self.service = strports.service(strport, ssh_factory)
92
93=== modified file 'src/lazr/sshserver/version.txt'
94--- src/lazr/sshserver/version.txt 2015-01-21 04:17:35 +0000
95+++ src/lazr/sshserver/version.txt 2015-11-17 01:36:44 +0000
96@@ -1,1 +1,1 @@
97-0.1.1
98+0.1.2

Subscribers

People subscribed via source and target branches

to all changes: