/*
* 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.
*/
/*
* The kernel SSL module ioctls.
*/
#include <sys/sysmacros.h>
#include "ksslimpl.h"
#include "kssl.h"
#include "ksslproto.h"
int kssl_entry_tab_size;
static void
{
}
static void
{
int i;
}
}
static void
{
if (s->is_valid_handle) {
s->is_valid_handle = B_FALSE;
}
if (s->evnt_handle != NULL) {
s->evnt_handle = NULL;
}
}
/*
* Frees the space for the entry and the keys and certs
* it carries.
*/
void
{
int i;
if (kssl_entry->ke_no_freeall) {
return;
}
}
}
for (i = 0; i < kssl_entry->sid_cache_nentries; i++)
sess_free(s);
}
}
/*
* Returns the index of the entry in kssl_entry_tab[] that matches
* the address and port. Returns -1 if no match is found.
*/
static int
{
int i;
for (i = 0; i < kssl_entry_tab_size; i++) {
ep = kssl_entry_tab[i];
continue;
continue;
break;
}
if (i == kssl_entry_tab_size)
return (-1);
return (i);
}
static void
{
}
static int
{
int i, len;
int cert_buf_len;
/*
* Get the certs array. First the array of sizes, then the actual
* certs.
*/
if (ncert == 0) {
/* no certs in here! why did ya call? */
return (EINVAL);
}
return (EINVAL);
}
/* Trusting that the system call preserved the 4-byte alignment */
/* should this be an ASSERT()? */
return (EINVAL);
}
len = 0;
for (i = 0; i < ncert; i++) {
if (cert_sizes[i] < 1) {
return (EINVAL);
}
}
for (i = 0; i < ncert; i++) {
cert_to += 3;
return (EINVAL);
}
cert_from += cert_sizes[i];
cert_to += cert_sizes[i];
}
len += 4;
return (0);
}
static int
{
char *end_pos;
int i, j, rv;
char *mp_attrs;
char *attval;
switch (kssl_privkey->ck_format) {
case CRYPTO_KEY_ATTR_LIST:
break;
case CRYPTO_KEY_RAW:
case CRYPTO_KEY_REFERENCE:
default:
goto err1;
}
/* allocate the attributes */
sizeof (crypto_object_attribute_t);
goto err1;
}
/* Now the individual attributes */
for (i = 0; i < kssl_privkey->ck_count; i++) {
mp_attrs += sizeof (kssl_object_attribute_t);
goto err2;
}
}
*privkey = kssl_privkey;
return (0);
err2:
for (j = 0; j < i; j++) {
}
err1:
return (rv);
}
static int
{
int rv;
char *p;
kssl_tokinfo_t *t;
t = &kssl_params->kssl_token;
/* Do a sanity check */
if (t->pinlen > MAX_PIN_LENGTH) {
return (EINVAL);
}
p = (char *)kssl_params + t->tokpin_offset;
kssl_entry->ke_sessinfo = s;
/* Get the handle to the non extractable key */
if (rv != CRYPTO_SUCCESS) {
sess_free(s);
return (EINVAL);
}
return (0);
}
static kssl_entry_t *
{
int i;
uint16_t s;
if (kssl_params->kssl_session_cache_timeout == 0)
else
if (kssl_params->kssl_session_cache_size == 0)
else
if (kssl_entry->ke_is_nxkey) {
return (NULL);
}
}
for (i = 0; i < mech_count; i++) {
CRYPTO_MAX_MECH_NAME) == 0)
CRYPTO_MAX_MECH_NAME) == 0)
CRYPTO_MAX_MECH_NAME) == 0)
CRYPTO_MAX_MECH_NAME) == 0)
CRYPTO_MAX_MECH_NAME) == 0)
CRYPTO_MAX_MECH_NAME) == 0)
CRYPTO_MAX_MECH_NAME) == 0)
}
cnt = 0;
ep = kssl_entry;
for (i = 0; i < CIPHER_SUITE_COUNT - 1; i++) {
switch (s = kssl_params->kssl_suites[i]) {
case SSL_RSA_WITH_RC4_128_MD5:
break;
case SSL_RSA_WITH_RC4_128_SHA:
break;
case SSL_RSA_WITH_DES_CBC_SHA:
break;
break;
break;
break;
case CIPHER_NOTSET:
default:
break;
}
}
}
/*
* Add the no encryption suite to the end if requested by the
* to be running with it by default.
*/
for (i = 0; i < cnt; i++)
kssl_entry->kssl_saved_Suites[i] =
for (i = 0; i < kssl_entry->sid_cache_nentries; i++) {
}
return (kssl_entry);
}
int
{
return (rv);
}
return (rv);
}
if (kssl_entry == NULL) {
return (EINVAL);
}
/* Allocate the array first time here */
if (kssl_entry_tab == NULL) {
int tmp_size;
if (kssl_entry_tab != NULL) {
goto retry;
}
index = 0;
} else {
/* Check if a matching entry exists already */
if (index == -1) {
/* Check if an entry with the same proxy port exists */
return (EADDRINUSE);
}
/* No matching entry, find an empty spot */
for (i = 0; i < kssl_entry_tab_size; i++) {
if (kssl_entry_tab[i] == NULL)
break;
}
/* Table full. Gotta grow it */
if (i == kssl_entry_tab_size) {
sizeof (kssl_entry_t *);
if (kssl_entry_tab_size > old_size) {
goto retry;
}
}
index = i;
} else {
/*
* We do not want an entry with a specific address and
* an entry with IN_ADDR_ANY to coexist. We could
* replace the existing entry. But, most likely this
* is misconfiguration. Better bail out with an error.
*/
if ((IN6_IS_ADDR_UNSPECIFIED(&laddr) &&
(!IN6_IS_ADDR_UNSPECIFIED(&laddr) &&
return (EEXIST);
}
/* Replace the existing entry */
}
}
return (0);
}
int
{
int index;
if (index == -1) {
return (ENOENT);
}
return (0);
}
/*
* We care about only one private key object.
* So, set the max count to only 1.
*/
/*
* Open a session to the provider specified by the label and
* authenticate to it. Find the private key object with the
* specified attributes and save the handle. The userland component
* must set all the attributes in the template so as to uniquely
* identify the object.
*
* Note that the handle will be invalid if we logout or close
* the session to the provider.
*/
int
{
int rv;
unsigned int count;
s = kp->ke_sessinfo;
return (CRYPTO_UNKNOWN_PROVIDER);
if (rv != CRYPTO_SUCCESS) {
goto err1;
}
if (rv != CRYPTO_SUCCESS) {
goto err2;
}
if (rv != CRYPTO_SUCCESS) {
goto err3;
}
if (count == 0)
rv = CRYPTO_FAILED;
goto err3;
}
/* Keep the handle around for later use */
return (CRYPTO_SUCCESS);
err3:
err2:
err1:
return (rv);
}