/*
* 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
*
*/
/*
* KMF CN certificate-to-name mapper.
*/
#include <kmftypes.h>
#include <kmfapi.h>
#include <fcntl.h>
/*
* KMF uses long identifiers for RDN processing which makes it hard to keep
* cstyle cleanliness without using some auxiliary macros. Parameter 'x' is of
* the KMF_X509_NAME type.
*/
#define RDN_VALUE(x, i) \
#define RDN_OID(x, i) \
/* Error codes specific to this mapper. */
typedef struct cooked_opts {
int casesensitive;
} cooked_opts;
{
return (KMF_ERR_MEMORY);
/* This is the default. */
}
return (KMF_OK);
}
void
{
void *opts;
}
/*
* The CN string returned in name.Data will be NULL-terminated. The caller is
* expected to free name->Data after use.
*/
{
int i, j;
char *dn;
return (rv);
return (rv);
}
/* Go through the list of RDNs and look for the CN. */
for (i = 0; i < x509name.numberOfRDNs; ++i) {
for (j = 0; j < RDN_NPAIRS(x509name, i); ++j) {
continue;
/* Is this RDN a Common Name? */
return (KMF_ERR_MEMORY);
}
/* Terminate the string. */
goto finished;
}
}
}
return (KMF_OK);
else {
return (KMF_ERR_INTERNAL);
}
}
/*
* Note that name_to_match->Data might or might not be NULL terminated. If
* mapped_name->Length returned is greater than zero the caller is expected to
* free mapped_name->Data after use.
*/
{
int ret;
/* Initialize the output parameter. */
if (mapped_name != NULL) {
mapped_name->Length = 0;
}
return (rv);
if (mapped_name != NULL) {
}
/*
* If name_to_match->Data is not NULL terminated, check that we have the
* same number of characters.
*/
/* We know that get_name.Data is NULL terminated. */
return (KMF_ERR_NAME_NOT_MATCHED);
/*
* Compare the strings. We must use name_to_match->Length in case
* name_to_match->Data was not NULL terminated. If we used
* get_name.Length we could overrun name_to_match->Data by one byte.
*/
else
if (mapped_name == NULL)
if (ret == 0)
return (KMF_OK);
else
return (KMF_ERR_NAME_NOT_MATCHED);
}
/* The caller is responsible for freeing the error string when done with it. */
{
if (lasterr == 0)
return (KMF_ERR_MISSING_ERRCODE);
switch (lasterr) {
break;
default:
}
return (KMF_ERR_MEMORY);
return (KMF_OK);
}