xref: /netbsd-src/external/mpl/dhcp/bind/dist/lib/dns/include/dns/dsdigest.h (revision 4afad4b7fa6d4a0d3dedf41d1587a7250710ae54)
1 /*	$NetBSD: dsdigest.h,v 1.1 2024/02/18 20:57:36 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef DNS_DSDIGEST_H
17 #define DNS_DSDIGEST_H 1
18 
19 /*! \file dns/dsdigest.h */
20 
21 #include <isc/lang.h>
22 
23 #include <dns/types.h>
24 
25 ISC_LANG_BEGINDECLS
26 
27 isc_result_t
28 dns_dsdigest_fromtext(dns_dsdigest_t *dsdigestp, isc_textregion_t *source);
29 /*%<
30  * Convert the text 'source' refers to into a DS digest type value.
31  * The text may contain either a mnemonic digest name or a decimal
32  * digest number.
33  *
34  * Requires:
35  *\li	'dsdigestp' is a valid pointer.
36  *
37  *\li	'source' is a valid text region.
38  *
39  * Returns:
40  *\li	ISC_R_SUCCESS			on success
41  *\li	ISC_R_RANGE			numeric type is out of range
42  *\li	DNS_R_UNKNOWN			mnemonic type is unknown
43  */
44 
45 isc_result_t
46 dns_dsdigest_totext(dns_dsdigest_t dsdigest, isc_buffer_t *target);
47 /*%<
48  * Put a textual representation of the DS digest type 'dsdigest'
49  * into 'target'.
50  *
51  * Requires:
52  *\li	'dsdigest' is a valid dsdigest.
53  *
54  *\li	'target' is a valid text buffer.
55  *
56  * Ensures,
57  *	if the result is success:
58  *\li		The used space in 'target' is updated.
59  *
60  * Returns:
61  *\li	ISC_R_SUCCESS			on success
62  *\li	ISC_R_NOSPACE			target buffer is too small
63  */
64 
65 #define DNS_DSDIGEST_FORMATSIZE 20
66 void
67 dns_dsdigest_format(dns_dsdigest_t typ, char *cp, unsigned int size);
68 /*%<
69  * Wrapper for dns_dsdigest_totext(), writing text into 'cp'
70  */
71 
72 ISC_LANG_ENDDECLS
73 
74 #endif /* DNS_DSDIGEST_H */
75