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_SECALG_H
15 #define DNS_SECALG_H 1
16 
17 /*! \file dns/secalg.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_secalg_fromtext(dns_secalg_t *secalgp, isc_textregion_t *source);
27 /*%<
28  * Convert the text 'source' refers to into a DNSSEC security algorithm value.
29  * The text may contain either a mnemonic algorithm name or a decimal algorithm
30  * number.
31  *
32  * Requires:
33  *\li	'secalgp' 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_secalg_totext(dns_secalg_t secalg, isc_buffer_t *target);
45 /*%<
46  * Put a textual representation of the DNSSEC security algorithm 'secalg'
47  * into 'target'.
48  *
49  * Requires:
50  *\li	'secalg' is a valid secalg.
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_SECALG_FORMATSIZE 20
64 void
65 dns_secalg_format(dns_secalg_t alg, char *cp, unsigned int size);
66 /*%<
67  * Wrapper for dns_secalg_totext(), writing text into 'cp'
68  */
69 
70 ISC_LANG_ENDDECLS
71 
72 #endif /* DNS_SECALG_H */
73