adm_kef_ioctl.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#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"
#define DEFAULT_DEV_NUM 5
#define DEFAULT_SOFT_NUM 10
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.
*/
{
size_t extra_mech_size = 0;
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.
*/
{
size_t extra_mech_size = 0;
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.
*/
{
size_t extra_mech_size = 0;
int i;
char pname[MAXNAMELEN];
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.
*/
static crypto_get_soft_info_t *
{
size_t extra_mech_size = 0;
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
{
int fd;
int count = DEFAULT_DEV_NUM;
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 fd;
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.
*/
int
{
int count;
int fd;
int rc;
int i;
return (FAILURE);
}
if (getzoneid() == GLOBAL_ZONEID) {
/* use kcf.conf for kernel software providers in global zone */
provname);
return (FAILURE);
}
} 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);
}
/* Get the mechanism 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 count = DEFAULT_SOFT_NUM;
int len;
int fd;
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);
}