/src/sudo/plugins/sudoers/digestname.c
Line | Count | Source |
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 | | #include <config.h> |
20 | | |
21 | | #include <sudo_compat.h> |
22 | | #include <sudo_digest.h> |
23 | | #include <sudoers_debug.h> |
24 | | #include <parse.h> |
25 | | |
26 | | const char * |
27 | | digest_type_to_name(unsigned int digest_type) |
28 | 1.94k | { |
29 | 1.94k | const char *digest_name; |
30 | 1.94k | debug_decl(digest_type_to_name, SUDOERS_DEBUG_UTIL); |
31 | | |
32 | 1.94k | switch (digest_type) { |
33 | 967 | case SUDO_DIGEST_SHA224: |
34 | 967 | digest_name = "sha224"; |
35 | 967 | break; |
36 | 475 | case SUDO_DIGEST_SHA256: |
37 | 475 | digest_name = "sha256"; |
38 | 475 | break; |
39 | 66 | case SUDO_DIGEST_SHA384: |
40 | 66 | digest_name = "sha384"; |
41 | 66 | break; |
42 | 437 | case SUDO_DIGEST_SHA512: |
43 | 437 | digest_name = "sha512"; |
44 | 437 | break; |
45 | 0 | default: |
46 | 0 | digest_name = "unknown digest"; |
47 | 0 | break; |
48 | 1.94k | } |
49 | 1.94k | debug_return_const_str(digest_name); |
50 | 1.94k | } |