def test_getPrimes(self):
     """
     L{OpenSSHFactory.getPrimes} should return the available primes
     in the moduli directory.
     """
     primes = self.factory.getPrimes()
     self.assertEqual(primes, {
         1024: [getDHGeneratorAndPrime(b"diffie-hellman-group1-sha1")],
         2048: [getDHGeneratorAndPrime(b"diffie-hellman-group14-sha1")],
     })
Ejemplo n.º 2
0
 def test_getPrimes(self):
     """
     L{OpenSSHFactory.getPrimes} should return the available primes
     in the moduli directory.
     """
     primes = self.factory.getPrimes()
     self.assertEqual(
         primes, {
             1024: [getDHGeneratorAndPrime(b"diffie-hellman-group1-sha1")],
             2048: [getDHGeneratorAndPrime(b"diffie-hellman-group14-sha1")],
         })
Ejemplo n.º 3
0
        def getPrimes(self):
            """
            Diffie-Hellman primes that can be used for the
            diffie-hellman-group-exchange-sha1 key exchange.

            @return: The primes and generators.
            @rtype: L{dict} mapping the key size to a C{list} of
                C{(generator, prime)} tupple.
            """
            # In these tests, we hardwire the prime values to those defined by
            # the diffie-hellman-group14-sha1 key exchange algorithm, to avoid
            # requiring a moduli file when running tests.
            # See OpenSSHFactory.getPrimes.
            return {
                2048:
                [_kex.getDHGeneratorAndPrime(b"diffie-hellman-group14-sha1")]
            }
Ejemplo n.º 4
0
        def getPrimes(self):
            """
            Diffie-Hellman primes that can be used for the
            diffie-hellman-group-exchange-sha1 key exchange.

            @return: The primes and generators.
            @rtype: C{dict} mapping the key size to a C{list} of
                C{(generator, prime)} tupple.
            """
            # In these tests, we hardwire the prime values to those defined by
            # the diffie-hellman-group1-sha1 key exchange algorithm, to avoid
            # requiring a moduli file when running tests.
            # See OpenSSHFactory.getPrimes.
            return {
                2048: [
                    _kex.getDHGeneratorAndPrime('diffie-hellman-group1-sha1')]
            }
Ejemplo n.º 5
0
    def closed(self):
        pass


class MiladSSHRealm(object):
    implements(portal.IRealm)

    def requestMiladtar(self, MiladtarId, mind, *interfaces):
        if IConchUser in interfaces:
            return interfaces[0], MiladSSHMiladtar(MiladtarId), lambda: None
        else:
            raise NotImplementedError("No supported interfaces found.")


DH_GENERATOR, DH_PRIME = _kex.getDHGeneratorAndPrime(
    'diffie-hellman-group1-sha1')

MSG_DISCONNECT = 1
MSG_IGNORE = 2
MSG_UNIMPLEMENTED = 3
MSG_DEBUG = 4
MSG_SERVICE_REQUEST = 5
MSG_SERVICE_ACCEPT = 6
MSG_KEXINIT = 20
MSG_NEWKEYS = 21
MSG_KEXDH_INIT = 30
MSG_KEXDH_REPLY = 31
MSG_KEX_DH_GEX_REQUEST_OLD = 30
MSG_KEX_DH_GEX_REQUEST = 34
MSG_KEX_DH_GEX_GROUP = 31
MSG_KEX_DH_GEX_INIT = 32