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