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