1"""
2Functions to view the minion's public key information
3"""
4
5import os
6
7import salt.utils.crypt
8
9
10def finger(hash_type=None):
11    """
12    Return the minion's public key fingerprint
13
14    hash_type
15        The hash algorithm used to calculate the fingerprint
16
17    CLI Example:
18
19    .. code-block:: bash
20
21        salt '*' key.finger
22    """
23    if hash_type is None:
24        hash_type = __opts__["hash_type"]
25
26    return salt.utils.crypt.pem_finger(
27        os.path.join(__opts__["pki_dir"], "minion.pub"), sum_type=hash_type
28    )
29
30
31def finger_master(hash_type=None):
32    """
33    Return the fingerprint of the master's public key on the minion.
34
35    hash_type
36        The hash algorithm used to calculate the fingerprint
37
38    CLI Example:
39
40    .. code-block:: bash
41
42        salt '*' key.finger_master
43    """
44    if hash_type is None:
45        hash_type = __opts__["hash_type"]
46
47    return salt.utils.crypt.pem_finger(
48        os.path.join(__opts__["pki_dir"], "minion_master.pub"), sum_type=hash_type
49    )
50