/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This file is part of the core Kernel Cryptographic Framework.
* It implements the management of the policy table. Entries are
* added and removed by administrative ioctls.
*
* Each element of the policy table contains a pointer to a
* policy descriptor, or NULL if the entry is free.
*/
static int kcf_policy_add_entry(kcf_policy_desc_t *);
static kcf_policy_desc_t *kcf_policy_alloc_desc(int);
/*
* Initialize the policy table. The policy table is dynamically
* allocated with policy_tab_max entries.
*/
void
kcf_policy_tab_init(void)
{
KM_SLEEP);
}
/*
* Add entry to the policy table. If no free slot can be found
* return CRYPTO_HOST_MEMORY, otherwise CRYPTO_SUCCESS.
*
* policy_tab_mutex must already be held.
*/
static int
{
uint_t i = 0;
/* find free slot in policy table */
i++;
if (i == KCF_MAX_POLICY) {
/* ran out of policy entries */
return (CRYPTO_HOST_MEMORY);
}
/* initialize entry */
policy_tab[i] = policy_desc;
return (CRYPTO_SUCCESS);
}
/*
* Remove policy descriptor for the specified software module.
*/
void
{
int i;
for (i = 0; i < KCF_MAX_POLICY; i++) {
MAXNAMELEN) == 0) {
sizeof (kcf_policy_desc_t));
policy_tab[i] = NULL;
break;
}
}
}
if (i == KCF_MAX_POLICY) {
*count = 0;
}
}
/*
* Remove policy descriptor for the specified device.
*/
void
{
int i;
for (i = 0; i < KCF_MAX_POLICY; i++) {
policy_tab[i] = NULL;
break;
}
}
if (i == KCF_MAX_POLICY) {
*count = 0;
}
}
/*
* Returns policy descriptor for the specified software module.
*/
{
uint_t i;
for (i = 0; i < KCF_MAX_POLICY; i++) {
MAXNAMELEN) == 0) {
return (policy_desc);
}
}
}
return (NULL);
}
/*
* Returns policy descriptor for the specified device.
*/
{
uint_t i;
for (i = 0; i < KCF_MAX_POLICY; i++) {
return (policy_desc);
}
}
return (NULL);
}
/*
* Loads disabled mechanism array for specified software provider, and
* creates a policy descriptor if one does not already exist.
* Important note: new_array is consumed.
*/
int
{
uint_t i;
int rv;
/*
* Allocate storage for a new entry.
* Free new entry if a policy descriptor already exists.
*/
/*
* Search for an existing entry.
*/
for (i = 0; i < KCF_MAX_POLICY; i++) {
if (policy_tab[i] != NULL &&
MAXNAMELEN) == 0) {
policy_desc = policy_tab[i];
break;
}
}
}
if (policy_desc == NULL) {
if (rv != CRYPTO_SUCCESS) {
return (rv);
}
} else {
}
/* prev_array is freed by the caller */
return (CRYPTO_SUCCESS);
}
/*
* Loads disabled mechanism array for specified device, and
* creates a policy descriptor if one does not already exist.
* Important note: new_array is consumed.
*/
int
{
uint_t i;
int rv;
/*
* Allocate storage for a new entry.
* Free new entry if a policy descriptor already exists.
*/
/*
* Search for an existing entry.
*/
for (i = 0; i < KCF_MAX_POLICY; i++) {
if (policy_tab[i] != NULL &&
policy_desc = policy_tab[i];
break;
}
}
if (policy_desc == NULL) {
if (rv != CRYPTO_SUCCESS) {
return (rv);
}
} else {
}
/* prev_array is freed by the caller */
return (CRYPTO_SUCCESS);
}
/*
* Allocate a policy descriptor.
*/
static kcf_policy_desc_t *
{
return (NULL);
return (desc);
}
/*
* Free a policy descriptor.
*/
void
{
return;
}