~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/conch/openssh_compat/primes.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
2
# See LICENSE for details.
 
3
 
 
4
 
5
 
 
6
"""
 
7
Parsing for the moduli file, which contains Diffie-Hellman prime groups.
 
8
 
 
9
Maintainer: Paul Swartz
 
10
"""
 
11
 
 
12
def parseModuliFile(filename):
 
13
    lines = open(filename).readlines()
 
14
    primes = {}
 
15
    for l in lines:
 
16
        l = l.strip()
 
17
        if  not l or l[0]=='#':
 
18
            continue
 
19
        tim, typ, tst, tri, size, gen, mod = l.split()
 
20
        size = int(size) + 1
 
21
        gen = long(gen)
 
22
        mod = long(mod, 16)
 
23
        if not primes.has_key(size):
 
24
            primes[size] = []
 
25
        primes[size].append((gen, mod))
 
26
    return primes