1 /* $NetBSD: dnssectool.h,v 1.9 2026/01/29 18:36:26 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 <inttypes.h> 19 #include <stdbool.h> 20 21 #include <isc/attributes.h> 22 #include <isc/log.h> 23 #include <isc/stdtime.h> 24 25 #include <dns/kasp.h> 26 #include <dns/rdatastruct.h> 27 28 #include <dst/dst.h> 29 30 #include <isccfg/cfg.h> 31 #include <isccfg/kaspconf.h> 32 #include <isccfg/namedconf.h> 33 34 #define MAX_RSA 4096 /* should be long enough... */ 35 #define MAX_DH 4096 /* should be long enough... */ 36 37 /*! verbosity: set by -v and -q option in each program, defined in dnssectool.c 38 */ 39 extern int verbose; 40 extern bool quiet; 41 42 /*! program name, statically initialized in each program */ 43 extern const char *program; 44 45 /*! journal file */ 46 extern const char *journal; 47 48 /*! 49 * List of DS digest types used by dnssec-cds and dnssec-dsfromkey, 50 * defined in dnssectool.c. Filled in by add_dtype() from -a 51 * arguments, sorted (so that DS records are in a canonical order) and 52 * terminated by a zero. The size of the array is an arbitrary limit 53 * which should be greater than the number of known digest types. 54 */ 55 extern uint8_t dtype[8]; 56 57 typedef void(fatalcallback_t)(void); 58 59 noreturn void 60 fatal(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); 61 62 void 63 setfatalcallback(fatalcallback_t *callback); 64 65 void 66 check_result(isc_result_t result, const char *message); 67 68 void 69 vbprintf(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3); 70 71 noreturn void 72 version(const char *program); 73 74 void 75 sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size); 76 #define SIG_FORMATSIZE \ 77 (DNS_NAME_FORMATSIZE + DNS_SECALG_FORMATSIZE + sizeof("65535")) 78 79 void 80 setup_logging(isc_mem_t *mctx, isc_log_t **logp); 81 82 void 83 cleanup_logging(isc_log_t **logp); 84 85 dns_ttl_t 86 strtottl(const char *str); 87 88 dst_key_state_t 89 strtokeystate(const char *str); 90 91 isc_stdtime_t 92 strtotime(const char *str, int64_t now, int64_t base, bool *setp); 93 94 dns_rdataclass_t 95 strtoclass(const char *str); 96 97 unsigned int 98 strtodsdigest(const char *str); 99 100 void 101 add_dtype(unsigned int dt); 102 103 isc_result_t 104 try_dir(const char *dirname); 105 106 void 107 check_keyversion(dst_key_t *key, char *keystr); 108 109 void 110 set_keyversion(dst_key_t *key); 111 112 bool 113 key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir, 114 isc_mem_t *mctx, uint16_t min, uint16_t max, bool *exact); 115 116 bool 117 isoptarg(const char *arg, char **argv, void (*usage)(int ret)); 118 119 void 120 loadjournal(isc_mem_t *mctx, dns_db_t *db, const char *journal); 121 122 void 123 kasp_from_conf(cfg_obj_t *config, isc_mem_t *mctx, isc_log_t *lctx, 124 const char *name, const char *keydir, const char *engine, 125 dns_kasp_t **kaspp); 126