4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
26 * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
30 * Core KCF (Kernel Cryptographic Framework). This file implements
31 * the loadable module entry points and module verification routines.
34 #include <sys/systm.h>
35 #include <sys/cmn_err.h>
37 #include <sys/sunddi.h>
38 #include <sys/modctl.h>
39 #include <sys/errno.h>
40 #include <sys/rwlock.h>
45 #include <sys/crypto/common.h>
46 #include <sys/crypto/api.h>
47 #include <sys/crypto/spi.h>
48 #include <sys/crypto/impl.h>
49 #include <sys/crypto/sched_impl.h>
50 #include <sys/crypto/elfsign.h>
51 #include <sys/crypto/ioctladmin.h>
54 int kcf_frmwrk_debug
= 0;
56 #define KCF_FRMWRK_DEBUG(l, x) if (kcf_frmwrk_debug >= l) printf x
58 #define KCF_FRMWRK_DEBUG(l, x)
61 static struct modlmisc modlmisc
= {
62 &mod_miscops
, "Kernel Crypto Framework"
65 static struct modlinkage modlinkage
= {
66 MODREV_1
, (void *)&modlmisc
, NULL
69 extern int sys_shutdown
;
74 /* initialize the mechanisms tables supported out-of-the-box */
77 /* initialize the providers tables */
80 /* initialize the policy table */
81 kcf_policy_tab_init();
83 /* initialize soft_config_list */
84 kcf_soft_config_init();
87 * Initialize scheduling structures. Note that this does NOT
88 * start any threads since it might not be safe to do so.
92 /* initialize the RNG support structures */
95 return (mod_install(&modlinkage
));
99 _info(struct modinfo
*modinfop
)
101 return (mod_info(&modlinkage
, modinfop
));
105 * We do not allow kcf to unload.
115 * Return a pointer to the modctl structure of the
119 kcf_get_modctl(crypto_provider_info_t
*pinfo
)
121 struct modctl
*mctlp
;
123 /* Get the modctl struct for this module */
124 if (pinfo
->pi_provider_type
== CRYPTO_SW_PROVIDER
)
125 mctlp
= mod_getctl(pinfo
->pi_provider_dev
.pd_sw
);
130 if ((major
= ddi_driver_major(pinfo
->pi_provider_dev
.pd_hw
))
131 != DDI_MAJOR_T_NONE
) {
132 drvmod
= ddi_major_to_name(major
);
133 mctlp
= mod_find_by_filename("drv", drvmod
);