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_DS_H
15 #define DNS_DS_H 1
16 
17 #include <isc/lang.h>
18 
19 #include <dns/rdatastruct.h>
20 #include <dns/types.h>
21 
22 #define DNS_DSDIGEST_SHA1   (1)
23 #define DNS_DSDIGEST_SHA256 (2)
24 #define DNS_DSDIGEST_GOST   (3)
25 #define DNS_DSDIGEST_SHA384 (4)
26 
27 /*
28  * Assuming SHA-384 digest type.
29  */
30 #define DNS_DS_BUFFERSIZE (52)
31 
32 ISC_LANG_BEGINDECLS
33 
34 isc_result_t
35 dns_ds_fromkeyrdata(const dns_name_t *owner, dns_rdata_t *key,
36 		    dns_dsdigest_t digest_type, unsigned char *digest,
37 		    dns_rdata_ds_t *dsrdata);
38 /*%<
39  * Build a DS rdata structure from a key.
40  *
41  * Requires:
42  *\li	key	Points to a valid DNSKEY or CDNSKEY record.
43  *\li	buffer	Points to a buffer of at least
44  * 		#ISC_MAX_MD_SIZE bytes.
45  */
46 
47 isc_result_t
48 dns_ds_buildrdata(dns_name_t *owner, dns_rdata_t *key,
49 		  dns_dsdigest_t digest_type, unsigned char *buffer,
50 		  dns_rdata_t *rdata);
51 /*%<
52  * Similar to dns_ds_fromkeyrdata(), but copies the DS into a
53  * dns_rdata object.
54  *
55  * Requires:
56  *\li	key	Points to a valid DNSKEY or CDNSKEY record.
57  *\li	buffer	Points to a buffer of at least
58  * 		#DNS_DS_BUFFERSIZE bytes.
59  *\li	rdata	Points to an initialized dns_rdata_t.
60  *
61  * Ensures:
62  *  \li    *rdata	Contains a valid DS rdata.  The 'data' member refers
63  *		to 'buffer'.
64  */
65 
66 ISC_LANG_ENDDECLS
67 
68 #endif /* DNS_DS_H */
69