xref: /netbsd-src/external/mpl/dhcp/bind/dist/lib/dns/dst_pkcs11.h (revision 4afad4b7fa6d4a0d3dedf41d1587a7250710ae54)
1 /*	$NetBSD: dst_pkcs11.h,v 1.1 2024/02/18 20:57:31 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 #ifndef DST_PKCS11_H
17 #define DST_PKCS11_H 1
18 
19 #include <isc/lang.h>
20 #include <isc/log.h>
21 #include <isc/result.h>
22 
23 ISC_LANG_BEGINDECLS
24 
25 isc_result_t
26 dst__pkcs11_toresult(const char *funcname, const char *file, int line,
27 		     isc_result_t fallback, CK_RV rv);
28 
29 #define PK11_CALL(func, args, fallback)                                 \
30 	((void)(((rv = (func)args) == CKR_OK) ||                        \
31 		((ret = dst__pkcs11_toresult(#func, __FILE__, __LINE__, \
32 					     fallback, rv)),            \
33 		 0)))
34 
35 #define PK11_RET(func, args, fallback)                                  \
36 	((void)(((rv = (func)args) == CKR_OK) ||                        \
37 		((ret = dst__pkcs11_toresult(#func, __FILE__, __LINE__, \
38 					     fallback, rv)),            \
39 		 0)));                                                  \
40 	if (rv != CKR_OK)                                               \
41 		goto err;
42 
43 ISC_LANG_ENDDECLS
44 
45 #endif /* DST_PKCS11_H */
46