File: test_dheater.py

package info (click to toggle)
ssh-audit 3.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,508 kB
  • sloc: python: 7,318; sh: 661; makefile: 12
file content (29 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pytest

from ssh_audit.ssh2_kexdb import SSH2_KexDB
from ssh_audit.dheat import DHEat


class TestDHEat:

    @pytest.fixture(autouse=True)
    def init(self):
        self.SSH2_KexDB = SSH2_KexDB
        self.DHEat = DHEat

    def test_kex_definition_completeness(self):
        alg_db = self.SSH2_KexDB.get_db()
        kex_db = alg_db['kex']

        # Get all Diffie-Hellman algorithms defined in our database.
        dh_algs = []
        for kex in kex_db:
            if kex.startswith('diffie-hellman-'):
                dh_algs.append(kex)

        # Ensure that each DH algorithm in our database is in either DHEat's alg_priority or gex_algs list.  Also ensure that all non-group exchange algorithms are accounted for in the alg_modulus_sizes dictionary.
        for dh_alg in dh_algs:
            assert (dh_alg in self.DHEat.alg_priority) or (dh_alg in self.DHEat.gex_algs)

            if dh_alg.find("group-exchange") == -1:
                assert dh_alg in self.DHEat.alg_modulus_sizes