Skip to content

API Reference: Cipher Algorithms

These helpers split cipher-suite names into readable components. Start with Retrieving Cipher Information to see them through the monitor API. TLS 1.3 cipher names do not encode the key-exchange group.

certmonitor.cipher_algorithms

ALL_ALGORITHMS module-attribute

ALL_ALGORITHMS: dict[str, AlgorithmDict] = {'encryption': {'AES': 'AES', 'CHACHA20': 'CHACHA20', '3DES': '3DES|DES-EDE3', 'CAMELLIA': 'CAMELLIA', 'ARIA': 'ARIA', 'SEED': 'SEED', 'SM4': 'SM4', 'IDEA': 'IDEA', 'RC4': 'RC4'}, 'key_exchange': {'ECDHE': 'ECDHE|EECDH', 'DHE': 'DHE|EDH', 'ECDH': 'ECDH', 'DH': 'DH', 'RSA': 'RSA', 'PSK': 'PSK', 'SRP': 'SRP', 'GOST': 'GOST', 'ECCPWD': 'ECCPWD', 'SM2': 'SM2'}, 'mac': {'SHA384': 'SHA384', 'SHA256': 'SHA256', 'SHA224': 'SHA224', 'SHA': 'SHA1?', 'MD5': 'MD5', 'POLY1305': 'POLY1305', 'AEAD': 'GCM|CCM|OCB', 'GOST': 'GOST28147|GOST34\\.11', 'SM3': 'SM3'}}

AlgorithmDict module-attribute

AlgorithmDict = dict[str, str | Pattern[str]]

list_algorithms

list_algorithms() -> dict[str, Any]

List all known algorithms by category.

Source code in certmonitor/cipher_algorithms.py
def list_algorithms() -> dict[str, Any]:
    """
    List all known algorithms by category.
    """
    alg_list = {}
    for category, alg_dict in ALL_ALGORITHMS.items():
        alg_list[category] = list(alg_dict.keys())
    return alg_list

parse_cipher_suite cached

parse_cipher_suite(cipher_suite: str) -> dict[str, str]

Parse a cipher suite string to identify encryption, key exchange, and MAC algorithms.

Source code in certmonitor/cipher_algorithms.py
@lru_cache(maxsize=128)
def parse_cipher_suite(cipher_suite: str) -> dict[str, str]:
    """
    Parse a cipher suite string to identify encryption, key exchange, and MAC algorithms.
    """
    result = {"encryption": "Unknown", "key_exchange": "Unknown", "mac": "Unknown"}

    for category, algorithms in ALL_ALGORITHMS.items():
        for alg, pattern in algorithms.items():
            # At runtime, patterns are compiled regex objects after initialization
            compiled_pattern = cast(Pattern[str], pattern)
            if compiled_pattern.search(cipher_suite):
                result[category] = alg
                break

    return result

update_algorithms

update_algorithms(custom_algorithms: dict[str, dict[str, str]]) -> None

Update the ALL_ALGORITHMS dictionary with user-provided custom algorithms.

Source code in certmonitor/cipher_algorithms.py
def update_algorithms(custom_algorithms: dict[str, dict[str, str]]) -> None:
    """
    Update the ALL_ALGORITHMS dictionary with user-provided custom algorithms.
    """
    global ALL_ALGORITHMS

    for category, algs in custom_algorithms.items():
        if category not in ALL_ALGORITHMS:
            ALL_ALGORITHMS[category] = {}
        for alg_name, pattern in algs.items():
            ALL_ALGORITHMS[category][alg_name] = re.compile(pattern)

    parse_cipher_suite.cache_clear()