/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Deimos - cryptographic acceleration based upon Broadcom 582x.
*/
/*
* Random number implementation.
*/
static void dca_rngdone(dca_request_t *, int);
static void dca_random_done();
int dca_random_init();
void dca_random_fini();
int
{
int rv;
return (CRYPTO_HOST_MEMORY);
}
if (rv != CRYPTO_QUEUED) {
else
}
return (rv);
}
int
{
cmd = CMD_RNGSHA1;
} else {
cmd = CMD_RNGDIRECT;
}
if ((len < dca_mindma) ||
}
/* Try to do direct DMA. */
return (CRYPTO_DEVICE_ERROR);
}
}
reqp->dr_in_paddr = 0;
reqp->dr_in_next = 0;
/*
* Setup for scattering the result back out
* Using the pre-mapped buffers to store random numbers. Since the
* data buffer is a linked list, we need to transfer its head to MCR
*/
else
}
/* write out the context structure */
/* schedule the work by doing a submit */
}
void
{
if (errno == CRYPTO_SUCCESS) {
DDI_SUCCESS) {
goto errout;
}
if (errno != CRYPTO_SUCCESS) {
goto errout;
}
} else {
}
/*
* If there is more to do, then reschedule another
* pass.
*/
if (errno == CRYPTO_QUEUED) {
return;
}
}
}
if (reqp->dr_kcf_req) {
/* notify framework that request is completed */
} else {
/* For internal random number generation */
}
"dca_rngdone: returning %d to the kef via crypto_op_notification",
errno);
else
}
/*
* This gives a 32k random bytes per buffer. The two buffers will switch back
* and forth. When a buffer is used up, a request will be submitted to refill
* this buffer before switching to the other one
*/
int
{
/* Mutex for the local random number pool */
NULL) {
return (CRYPTO_FAILED);
}
NULL) {
return (CRYPTO_FAILED);
}
return (CRYPTO_SUCCESS);
}
void
{
}
int
{
int rv;
int i, j;
char *fill_buf;
return (CRYPTO_FAILED);
}
/* Very first time. Let us fill the first buffer */
NULL) != CRYPTO_QUEUED) {
return (CRYPTO_FAILED);
}
/* Pretend we are using buffer2 and it is empty */
}
i = 0;
while (i < len) {
j = 0;
while (dca->dca_random_filling) {
/* Only wait here at the first time */
if (j++ >= DCA_RANDOM_MAX_WAIT)
break;
}
if (j > DCA_RANDOM_MAX_WAIT) {
return (CRYPTO_FAILED);
}
/* switch to the other buffer */
} else {
}
return (rv);
}
}
}
return (CRYPTO_SUCCESS);
}
static void
{
}