/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 | 0 | { |
34 | 0 | const char *digest_name; |
35 | 0 | debug_decl(digest_type_to_name, SUDOERS_DEBUG_UTIL); |
36 | |
|
37 | 0 | switch (digest_type) { |
38 | 0 | case SUDO_DIGEST_SHA224: |
39 | 0 | digest_name = "sha224"; |
40 | 0 | break; |
41 | 0 | case SUDO_DIGEST_SHA256: |
42 | 0 | digest_name = "sha256"; |
43 | 0 | break; |
44 | 0 | case SUDO_DIGEST_SHA384: |
45 | 0 | digest_name = "sha384"; |
46 | 0 | break; |
47 | 0 | case SUDO_DIGEST_SHA512: |
48 | 0 | digest_name = "sha512"; |
49 | 0 | break; |
50 | 0 | default: |
51 | 0 | digest_name = "unknown digest"; |
52 | 0 | break; |
53 | 0 | } |
54 | 0 | debug_return_const_str(digest_name); |
55 | 0 | } |