summaryrefslogtreecommitdiffstats
path: root/include/sudo_digest.h
blob: 9fffa1b4d1b1621540184c840364186c092f63c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (c) 2018 Todd C. Miller <Todd.Miller@sudo.ws>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef SUDO_DIGEST_H
#define SUDO_DIGEST_H

/* Digest types. */
#define SUDO_DIGEST_SHA224	0
#define SUDO_DIGEST_SHA256	1
#define SUDO_DIGEST_SHA384	2
#define SUDO_DIGEST_SHA512	3
#define SUDO_DIGEST_INVALID	4

struct sudo_digest;

/* Public functions. */
__dso_public struct sudo_digest *sudo_digest_alloc_v1(int digest_type);
__dso_public void sudo_digest_free_v1(struct sudo_digest *dig);
__dso_public void sudo_digest_reset_v1(struct sudo_digest *dig);
__dso_public int sudo_digest_getlen_v1(int digest_type);
__dso_public void sudo_digest_update_v1(struct sudo_digest *dig, const void *data, size_t len);
__dso_public void sudo_digest_final_v1(struct sudo_digest *dig, unsigned char *md);

#define sudo_digest_alloc(_a) sudo_digest_alloc_v1((_a))
#define sudo_digest_free(_a) sudo_digest_free_v1((_a))
#define sudo_digest_reset(_a) sudo_digest_reset_v1((_a))
#define sudo_digest_getlen(_a) sudo_digest_getlen_v1((_a))
#define sudo_digest_update(_a, _b, _c) sudo_digest_update_v1((_a), (_b), (_c))
#define sudo_digest_final(_a, _b) sudo_digest_final_v1((_a), (_b))

#endif /* SUDO_DIGEST_H */