~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/conch/openssh_compat/primes.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

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
"""Parsing for the moduli file, which contains Diffie-Hellman prime groups.
 
7
 
 
8
This module is unstable.
 
9
 
 
10
Maintainer: U{Paul Swartz<mailto:z3p@twistedmatrix.com>}
 
11
"""
 
12
 
 
13
def parseModuliFile(filename):
 
14
    lines = open(filename).readlines()
 
15
    primes = {}
 
16
    for l in lines:
 
17
        l = l.strip()
 
18
        if  not l or l[0]=='#':
 
19
            continue
 
20
        tim, typ, tst, tri, size, gen, mod = l.split()
 
21
        size = int(size) + 1
 
22
        gen = long(gen)
 
23
        mod = long(mod, 16)
 
24
        if not primes.has_key(size):
 
25
            primes[size] = []
 
26
        primes[size].append((gen, mod))
 
27
    return primes