Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/include/sudo_digest.h
1532 views
1
/*
2
* SPDX-License-Identifier: ISC
3
*
4
* Copyright (c) 2018 Todd C. Miller <[email protected]>
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
#ifndef SUDO_DIGEST_H
20
#define SUDO_DIGEST_H
21
22
/* Digest types. */
23
#define SUDO_DIGEST_SHA224 0
24
#define SUDO_DIGEST_SHA256 1
25
#define SUDO_DIGEST_SHA384 2
26
#define SUDO_DIGEST_SHA512 3
27
#define SUDO_DIGEST_INVALID 4
28
29
struct sudo_digest;
30
31
/* Public functions. */
32
sudo_dso_public struct sudo_digest *sudo_digest_alloc_v1(unsigned int digest_type);
33
sudo_dso_public void sudo_digest_free_v1(struct sudo_digest *dig);
34
sudo_dso_public void sudo_digest_reset_v1(struct sudo_digest *dig);
35
sudo_dso_public int sudo_digest_getlen_v1(unsigned int digest_type);
36
sudo_dso_public size_t sudo_digest_getlen_v2(unsigned int digest_type);
37
sudo_dso_public void sudo_digest_update_v1(struct sudo_digest *dig, const void *data, size_t len);
38
sudo_dso_public void sudo_digest_final_v1(struct sudo_digest *dig, unsigned char *md);
39
40
#define sudo_digest_alloc(_a) sudo_digest_alloc_v1((_a))
41
#define sudo_digest_free(_a) sudo_digest_free_v1((_a))
42
#define sudo_digest_reset(_a) sudo_digest_reset_v1((_a))
43
#define sudo_digest_getlen(_a) sudo_digest_getlen_v2((_a))
44
#define sudo_digest_update(_a, _b, _c) sudo_digest_update_v1((_a), (_b), (_c))
45
#define sudo_digest_final(_a, _b) sudo_digest_final_v1((_a), (_b))
46
47
#endif /* SUDO_DIGEST_H */
48
49