xref: /netbsd-src/external/mpl/dhcp/bind/dist/lib/dns/pkcs11.c (revision 4afad4b7fa6d4a0d3dedf41d1587a7250710ae54)
1 /*	$NetBSD: pkcs11.c,v 1.1 2024/02/18 20:57:33 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 #if USE_PKCS11
17 
18 #include <isc/util.h>
19 
20 #include <pk11/internal.h>
21 #include <pk11/pk11.h>
22 
23 #include <dns/log.h>
24 #include <dns/result.h>
25 
26 #include "dst_internal.h"
27 #include "dst_pkcs11.h"
28 
29 isc_result_t
dst__pkcs11_toresult(const char * funcname,const char * file,int line,isc_result_t fallback,CK_RV rv)30 dst__pkcs11_toresult(const char *funcname, const char *file, int line,
31 		     isc_result_t fallback, CK_RV rv) {
32 	isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_CRYPTO,
33 		      ISC_LOG_WARNING, "%s:%d: %s: Error = 0x%.8lX\n", file,
34 		      line, funcname, rv);
35 	if (rv == CKR_HOST_MEMORY) {
36 		return (ISC_R_NOMEMORY);
37 	}
38 	return (fallback);
39 }
40 
41 #endif /* USE_PKCS11 */
42 /*! \file */
43