/*
* 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
*/
/*
*/
#include <stdio.h>
#include <errno.h>
#include <strings.h>
#include <locale.h>
#include <stdlib.h>
#include "cryptoutil.h"
static int uef_interpret(char *, uentry_t **);
static int parse_policylist(char *, uentry_t *);
/*
* Retrieve the user-level provider info from the pkcs11.conf file.
* If successful, the result is returned from the ppliblist argument.
* This function returns SUCCESS if successfully done; otherwise it returns
* FAILURE.
*/
int
{
return (FAILURE);
}
continue; /* ignore comment lines */
}
len--;
}
break;
}
/* append pent into ppliblist */
break;
}
} else {
}
}
}
return (rc);
}
static int
{
char *value;
value++; /* get rid of = */
} else {
"Failed to parse pkcs11.conf file.\n"));
return (CKR_FUNCTION_FAILED);
}
return (CKR_OK);
} else {
return (CKR_FUNCTION_FAILED);
}
} else {
/* should not come here */
"Failed to parse pkcs11.conf file.\n"));
return (CKR_FUNCTION_FAILED);
}
}
/*
* This routine converts a char string into a uentry_t structure
* The input string "buf" should be one of the following:
* library_name
* library_name:NO_RANDOM
* library_name:disabledlist=m1,m2,...,mk
* library_name:disabledlist=m1,m2,...,mk;NO_RANDOM
* library_name:enabledlist=
* library_name:enabledlist=;NO_RANDOM
* library_name:enabledlist=m1,m2,...,mk
* library_name:enabledlist=m1,m2,...,mk;NO_RANDOM
* metaslot:status=enabled;enabledlist=m1,m2,....;slot=<slot-description>;\
* token=<token-label>
*
* Note:
* The mechanisms m1,..mk are in hex form. For example, "0x00000210"
* for CKM_MD5.
*
* For the metaslot entry, "enabledlist", "slot", "auto_key_migrate"
* or "token" is optional
*/
static int
{
char *token1;
char *token2;
char *lasts;
int rc;
/* buf is NULL */
return (FAILURE);
};
return (FAILURE);
}
return (rc);
}
return (SUCCESS);
}
/*
* in case metaslot_auto_key_migrate is not specified, it should
* be default to true
*/
return (rc);
}
}
return (SUCCESS);
}
/*
* This routine parses the policy list and stored the result in the argument
* pent.
*
* Arg buf: input only, its format should be one of the following:
* enabledlist=
* enabledlist=m1,m2,...,mk
* disabledlist=m1,m2,...,mk
* NO_RANDOM
* metaslot_status=enabled|disabled
* metaslot_token=<token-label>
* metaslot_slot=<slot-description.
*
*
* return: SUCCESS or FAILURE
*/
static int
{
char *next_token;
char *value;
char *lasts;
int count = 0;
return (FAILURE);
}
return (rc);
sizeof (METASLOT_TOKEN) - 1) == 0) {
value++; /* get rid of = */
sizeof (pent->metaslot_ks_token));
return (SUCCESS);
} else {
return (FAILURE);
}
sizeof (METASLOT_SLOT) - 1) == 0) {
value++; /* get rid of = */
sizeof (pent->metaslot_ks_slot));
return (SUCCESS);
} else {
return (FAILURE);
}
sizeof (METASLOT_STATUS) - 1) == 0) {
value++; /* get rid of = */
} else {
return (FAILURE);
}
return (SUCCESS);
} else {
return (FAILURE);
}
sizeof (METASLOT_AUTO_KEY_MIGRATE) - 1) == 0) {
value++; /* get rid of = */
} else {
return (FAILURE);
}
return (SUCCESS);
} else {
return (FAILURE);
}
} else {
return (FAILURE);
}
value++; /* get rid of = */
}
if (pent->flag_enabledlist) {
return (SUCCESS);
} else {
return (FAILURE);
}
}
while (next_token) {
break;
}
} else {
}
count++;
}
} else {
}
return (rc);
}
/*
* Create one item of type umechlist_t with the mechanism name. A NULL is
* returned when the input name is NULL or the heap memory is insufficient.
*/
{
return (NULL);
}
}
return (pmech);
}
void
{
}
}
void
{
return;
} else {
}
}
void
{
}
}
/*
* Duplicate an UEF mechanism list. A NULL pointer is returned if out of
* memory or the input argument is NULL.
*/
static umechlist_t *
{
break;
}
} else {
}
}
return (NULL);
}
return (pres);
}
/*
* Duplicate an uentry. A NULL pointer is returned if out of memory
* or the input argument is NULL.
*/
static uentry_t *
{
return (NULL);
}
return (NULL);
} else {
return (puent2);
}
}
/*
* Find the entry in the "pkcs11.conf" file with "libname" as the provider
* name. Return the entry if found, otherwise return NULL.
*/
uentry_t *
{
return (NULL);
}
return (NULL);
}
while (plib) {
break;
} else {
}
}
if (found) {
}
return (puent);
}
/*
* Retrieve the metaslot information from the pkcs11.conf file.
* This function returns SUCCESS if successfully done; otherwise it returns
* FAILURE. If successful, the caller is responsible to free the space
* allocated for objectstore_slot_info and objectstore_token_info.
*/
int
char **objectstore_slot_info, char **objectstore_token_info)
{
/* metaslot entry doesn't exist */
return (FAILURE);
}
goto out;
}
if (objectstore_slot_info == NULL) {
goto out;
}
out:
}
}
}
}
return (rc);
}
static boolean_t
{
return (B_TRUE);
} else {
return (B_FALSE);
}
}
{
int len;
int found = 0;
char *token1;
"failed to open the pkcs11.conf file for read only.");
return (CKR_OK);
}
continue; /* ignore comment lines */
}
len--;
}
/* Get provider name */
NULL) { /* buf is NULL */
return (CKR_FUNCTION_FAILED);
};
goto out;
} else {
found++;
else
break;
}
} else {
continue;
}
}
if (!found) {
}
out:
return (rc);
}