Coverage Report

Created: 2025-07-11 06:57

/src/sudo/plugins/sudoers/digestname.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * SPDX-License-Identifier: ISC
3
 *
4
 * Copyright (c) 2017 Todd C. Miller <Todd.Miller@sudo.ws>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
/*
20
 * This is an open source non-commercial project. Dear PVS-Studio, please check it.
21
 * PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
22
 */
23
24
#include <config.h>
25
26
#include <sudo_compat.h>
27
#include <sudo_digest.h>
28
#include <sudoers_debug.h>
29
#include <parse.h>
30
31
const char *
32
digest_type_to_name(unsigned int digest_type)
33
2.34k
{
34
2.34k
    const char *digest_name;
35
2.34k
    debug_decl(digest_type_to_name, SUDOERS_DEBUG_UTIL);
36
37
2.34k
    switch (digest_type) {
38
651
    case SUDO_DIGEST_SHA224:
39
651
  digest_name = "sha224";
40
651
  break;
41
894
    case SUDO_DIGEST_SHA256:
42
894
  digest_name = "sha256";
43
894
  break;
44
332
    case SUDO_DIGEST_SHA384:
45
332
  digest_name = "sha384";
46
332
  break;
47
468
    case SUDO_DIGEST_SHA512:
48
468
  digest_name = "sha512";
49
468
  break;
50
0
    default:
51
0
  digest_name = "unknown digest";
52
0
  break;
53
2.34k
    }
54
2.34k
    debug_return_const_str(digest_name);
55
2.34k
}