/*
* 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 Nexenta Systems, Inc. All rights reserved.
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <locale.h>
#include <libgen.h>
#include <zone.h>
#include "cryptoadm.h"
static crypto_get_soft_info_t *setup_get_soft_info(char *, int);
/*
* Prepare the argument for the LOAD_SOFT_CONFIG ioctl call for the
* provider pointed by pent. Return NULL if out of memory.
*/
{
int i;
return (NULL);
}
if (sup_count > 1) {
extra_mech_size = sizeof (crypto_mech_name_t) *
(sup_count - 1);
}
if (pload_soft_conf == NULL) {
cryptodebug("out of memory.");
return (NULL);
}
i = 0;
while (i < sup_count) {
}
return (pload_soft_conf);
}
/*
* Prepare the argument for the LOAD_SOFT_DISABLED ioctl call for the
* provider pointed by pent. Return NULL if out of memory.
*/
{
int i;
return (NULL);
}
if (dis_count > 1) {
extra_mech_size = sizeof (crypto_mech_name_t) *
(dis_count - 1);
}
if (pload_soft_dis == NULL) {
cryptodebug("out of memory.");
return (NULL);
}
i = 0;
while (i < dis_count) {
}
return (pload_soft_dis);
}
/*
* Prepare the argument for the LOAD_DEV_DISABLED ioctl call for the
* provider pointed by pent. Return NULL if out of memory.
*/
{
int i;
int inst_num;
return (NULL);
}
/* get the device name and the instance number */
return (NULL);
}
/* allocate space for pload_dev_des */
if (dis_count > 1) {
extra_mech_size = sizeof (crypto_mech_name_t) *
(dis_count - 1);
}
if (pload_dev_dis == NULL) {
cryptodebug("out of memory.");
return (NULL);
}
/* set the values for pload_dev_dis */
i = 0;
while (i < dis_count) {
}
return (pload_dev_dis);
}
/*
* Prepare the calling argument of the UNLOAD_SOFT_MODULE ioctl call for the
* provider pointed by pent. Return NULL if out of memory.
*/
{
return (NULL);
}
if (punload_soft == NULL) {
cryptodebug("out of memory.");
return (NULL);
}
return (punload_soft);
}
/*
* Prepare the calling argument for the GET_SOFT_INFO call for the provider
* with the number of mechanisms specified in the second argument.
*
* Called by get_soft_info().
*/
static crypto_get_soft_info_t *
{
return (NULL);
}
if (count > 1) {
}
if (psoft_info == NULL) {
cryptodebug("out of memory.");
return (NULL);
}
return (psoft_info);
}
/*
* Get the device list from kernel.
*/
int
{
cryptodebug("out of memory.");
return (FAILURE);
}
return (FAILURE);
}
cryptodebug("CRYPTO_GET_DEV_LIST ioctl failed: %s",
return (FAILURE);
}
/* BUFFER is too small, get the number of devices and retry it. */
cryptodebug("out of memory.");
return (FAILURE);
}
cryptodebug("CRYPTO_GET_DEV_LIST ioctl failed: %s",
return (FAILURE);
}
}
cryptodebug("CRYPTO_GET_DEV_LIST ioctl failed, "
return (FAILURE);
}
return (SUCCESS);
}
/*
* Get all the mechanisms supported by the hardware provider.
* The result will be stored in the second argument.
*/
int
{
int i;
int rc;
cryptodebug("get_dev_info(): devname is NULL or bogus count");
return (FAILURE);
}
/* Set up the argument for the CRYPTO_GET_DEV_INFO ioctl call */
cryptodebug("out of memory.");
return (FAILURE);
}
/* Open the ioctl device */
return (FAILURE);
}
cryptodebug("CRYPTO_GET_DEV_INFO ioctl failed: %s",
return (FAILURE);
}
cryptodebug("CRYPTO_GET_DEV_INFO ioctl failed, "
return (FAILURE);
}
break;
} else {
} else {
}
}
}
*ppmechlist = phead;
} else {
}
return (rc);
}
/*
* Get the supported mechanism list of the software provider from kernel.
*
* Parameters phardlist and psoftlist are supplied by get_kcfconf_info().
* If NULL, this function calls get_kcfconf_info() internally.
*/
int
{
int count;
int rc;
int i;
return (FAILURE);
}
if (getzoneid() == GLOBAL_ZONEID) {
/* use kcf.conf for kernel software providers in global zone */
NULL) {
/* No kcf.conf entry for this provider */
== FAILURE) {
return (FAILURE);
return (FAILURE);
}
/*
* Set mech count to 1. It will be reset to the
* correct value later if the setup buffer is too small.
*/
count = 1;
} else {
}
} else {
/*
* kcf.conf not there in non-global zone: set mech count to 1.
* It will be reset to the correct value later if the setup
* buffer is too small.
*/
count = 1;
}
return (FAILURE);
}
return (FAILURE);
}
/* make GET_SOFT_INFO ioctl call */
cryptodebug("CRYPTO_GET_SOFT_INFO ioctl failed: %s",
return (FAILURE);
}
/* BUFFER is too small, get the number of mechanisms and retry it. */
== NULL) {
return (FAILURE);
} else {
if (rc == -1) {
cryptodebug("CRYPTO_GET_SOFT_INFO ioctl "
return (FAILURE);
}
}
}
cryptodebug("CRYPTO_GET_SOFT_INFO ioctl failed, "
return (FAILURE);
}
/* Build the mechanism linked list and return it */
for (i = 0; i < psoft_info->si_count; i++) {
break;
} else {
} else {
}
}
}
} else {
*ppmechlist = phead;
}
return (rc);
}
/*
* Get the kernel software provider list from kernel.
*/
int
{
int len;
return (FAILURE);
}
cryptodebug("out of memory.");
return (FAILURE);
}
cryptodebug("CRYPTO_GET_SOFT_LIST ioctl failed: %s",
return (FAILURE);
}
/*
* if BUFFER is too small, get the number of software providers and
* the minimum length needed for names and length and retry it.
*/
cryptodebug("out of memory.");
return (FAILURE);
}
cryptodebug("CRYPTO_GET_SOFT_LIST ioctl failed:"
return (FAILURE);
}
}
cryptodebug("CRYPTO_GET_SOFT_LIST ioctl failed, "
return (FAILURE);
}
*ppsoftlist = psoftlist;
return (SUCCESS);
}